非采供应商泛微同步

This commit is contained in:
sez 2025-11-14 14:33:29 +08:00
parent ad080d56f7
commit 6d225d9efb
1 changed files with 58 additions and 35 deletions

View File

@ -15,6 +15,7 @@ import kd.bos.openapi.common.custom.annotation.ApiResponseBody;
import kd.bos.openapi.common.result.CustomApiResult;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.AttachmentServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
@ -40,6 +41,7 @@ public class SupplierControl implements Serializable {
@ApiPostMapping(value = "/FWFCSupplierImport", desc = "泛微非采购供应商导入")
public CustomApiResult<@ApiResponseBody("返回参数") ApiResultExt> fWSupplierImport
(@NotNull @Valid @ApiRequestBody(value = "入参") SupplierModel supplier) {
String entityName = "bd_supplier";
ApiResultExt resultExt = new ApiResultExt();
List<ApiResultExt.ResultBean> results = new ArrayList<>();
ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean();
@ -183,7 +185,7 @@ public class SupplierControl implements Serializable {
//出现错误后返回
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey("bd_supplier");
error.setEntityKey(entityName);
resultBean.setId("");
resultBean.setBillStatus(billStatus);
resultBean.setErrors(error);
@ -191,7 +193,7 @@ public class SupplierControl implements Serializable {
resultExt.setFailCount(1);
resultExt.setSuccessCount(0);
} else {
DynamicObject bd_supplier = BusinessDataServiceHelper.newDynamicObject("bd_supplier");
DynamicObject bd_supplier = BusinessDataServiceHelper.newDynamicObject(entityName);
bd_supplier.set("number", number);
bd_supplier.set("name", name);
bd_supplier.set("simplename", simplename);
@ -272,7 +274,7 @@ public class SupplierControl implements Serializable {
SaveServiceHelper.save(new DynamicObject[]{bd_suppliergroupdetails});
OperationResult operationResult = OperationServiceHelper.executeOperate("save", "bd_supplier", new DynamicObject[]{bd_supplier}, OperateOption.create());
OperationResult operationResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
if (!operationResult.isSuccess()) {
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
@ -280,15 +282,18 @@ public class SupplierControl implements Serializable {
}
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey("bd_supplier");
resultBean.setId("");
error.setEntityKey(entityName);
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(false);
resultBean.setErrors(error);
results.add(resultBean);
resultExt.setFailCount(1);
resultExt.setSuccessCount(0);
}
else {
//保存失败删除暂存单据
OperationServiceHelper.executeOperate("delete", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
} else {
bd_supplier.set("masterid", bd_supplier.getPkValue());
SaveServiceHelper.save(new DynamicObject[]{bd_supplier});
@ -305,39 +310,27 @@ public class SupplierControl implements Serializable {
BigDecimal attachementsize = BigDecimal.ZERO;
String attachementurl = attachmentBean.getAttachmentUrl();
/*DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("tqq9_registration", new QFilter[]{new QFilter("number", QCP.equals, "1134256")});
List<Map<String, Object>> attachments = AttachmentServiceHelper.getAttachments("tqq9_registration", dynamicObject.getPkValue(), "tqq9_attachmentpanelsh");
Object url = attachments.get(0).get("url");
attachementurl= (String) url;*/
String uid1 = uid.toString() + index++;
Map<String, Object> uploadres = null;
try {
uploadres = AttachmentFileUtil.saveUrlFile2Attchment(uid1, "bd_supplier", bd_supplier.getPkValue(), attachementurl, attachementname, attachementsize.toString(), "tqq9_attachmentpanelap");
uploadres = AttachmentFileUtil.saveUrlFile2Attchment(uid1, entityName, bd_supplier.getPkValue(), attachementurl, attachementname, attachementsize.toString(), "tqq9_attachmentpanelap");
} catch (Exception ee1) {
rowMsg.add("" + (j + 1) + "条附件信息处理错误上传失败The No." + j + 1 + " attachment information processing error.");
rowMsg.add("" + (j + 1) + "条附件信息处理错误上传失败The No." + j + 1 + " attachment information processing error." + ee1);
break;
}
if (uploadres.get("isSuccess") != "true") {
rowMsg.add("" + (j + 1) + "条附件信息处理错误上传失败The No." + j + 1 + " attachment information processing error.");
rowMsg.add("" + (j + 1) + "条附件信息处理错误上传失败The No." + j + 1 + " attachment information processing error." + uploadres.get("msg"));
break;
}
}
}
operationResult = OperationServiceHelper.executeOperate("submit", "bd_supplier", new DynamicObject[]{bd_supplier}, OperateOption.create());
if (!operationResult.isSuccess()) {
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
rowMsg.add(iOperateInfo.getMessage());
}
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey("bd_supplier");
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(false);
resultBean.setErrors(error);
results.add(resultBean);
resultExt.setFailCount(1);
resultExt.setSuccessCount(0);
} else {
operationResult = OperationServiceHelper.executeOperate("audit", "bd_supplier", new DynamicObject[]{bd_supplier}, OperateOption.create());
if (rowMsg.size() == 0) {
operationResult = OperationServiceHelper.executeOperate("submit", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
if (!operationResult.isSuccess()) {
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
@ -345,7 +338,7 @@ public class SupplierControl implements Serializable {
}
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey("bd_supplier");
error.setEntityKey(entityName);
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(false);
resultBean.setErrors(error);
@ -353,13 +346,43 @@ public class SupplierControl implements Serializable {
resultExt.setFailCount(1);
resultExt.setSuccessCount(0);
} else {
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(true);
results.add(resultBean);
resultExt.setFailCount(0);
resultExt.setSuccessCount(1);
operationResult = OperationServiceHelper.executeOperate("audit", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
if (!operationResult.isSuccess()) {
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
rowMsg.add(iOperateInfo.getMessage());
}
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey(entityName);
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(false);
resultBean.setErrors(error);
results.add(resultBean);
resultExt.setFailCount(1);
resultExt.setSuccessCount(0);
} else {
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(true);
results.add(resultBean);
resultExt.setFailCount(0);
resultExt.setSuccessCount(1);
}
}
} else {
//附件上传失败删除暂存单据
OperationServiceHelper.executeOperate("delete", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey(entityName);
resultBean.setId(bd_supplier.getString("id"));
resultBean.setBillStatus(false);
resultBean.setErrors(error);
results.add(resultBean);
resultExt.setFailCount(1);
resultExt.setSuccessCount(0);
}
}
resultExt.setResult(results);
return CustomApiResult.success(resultExt);
@ -375,7 +398,7 @@ public class SupplierControl implements Serializable {
//出现错误后返回
error.setKeys(keys);
error.setRowMsg(rowMsg);
error.setEntityKey("bd_supplier");
error.setEntityKey(entityName);
resultBean.setId("");
resultBean.setBillStatus(billStatus);
resultBean.setErrors(error);