非采供应商泛微同步
This commit is contained in:
parent
ad080d56f7
commit
6d225d9efb
|
|
@ -15,6 +15,7 @@ import kd.bos.openapi.common.custom.annotation.ApiResponseBody;
|
||||||
import kd.bos.openapi.common.result.CustomApiResult;
|
import kd.bos.openapi.common.result.CustomApiResult;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.AttachmentServiceHelper;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
|
@ -40,6 +41,7 @@ public class SupplierControl implements Serializable {
|
||||||
@ApiPostMapping(value = "/FWFCSupplierImport", desc = "泛微非采购供应商导入")
|
@ApiPostMapping(value = "/FWFCSupplierImport", desc = "泛微非采购供应商导入")
|
||||||
public CustomApiResult<@ApiResponseBody("返回参数") ApiResultExt> fWSupplierImport
|
public CustomApiResult<@ApiResponseBody("返回参数") ApiResultExt> fWSupplierImport
|
||||||
(@NotNull @Valid @ApiRequestBody(value = "入参") SupplierModel supplier) {
|
(@NotNull @Valid @ApiRequestBody(value = "入参") SupplierModel supplier) {
|
||||||
|
String entityName = "bd_supplier";
|
||||||
ApiResultExt resultExt = new ApiResultExt();
|
ApiResultExt resultExt = new ApiResultExt();
|
||||||
List<ApiResultExt.ResultBean> results = new ArrayList<>();
|
List<ApiResultExt.ResultBean> results = new ArrayList<>();
|
||||||
ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean();
|
ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean();
|
||||||
|
|
@ -183,7 +185,7 @@ public class SupplierControl implements Serializable {
|
||||||
//出现错误后返回
|
//出现错误后返回
|
||||||
error.setKeys(keys);
|
error.setKeys(keys);
|
||||||
error.setRowMsg(rowMsg);
|
error.setRowMsg(rowMsg);
|
||||||
error.setEntityKey("bd_supplier");
|
error.setEntityKey(entityName);
|
||||||
resultBean.setId("");
|
resultBean.setId("");
|
||||||
resultBean.setBillStatus(billStatus);
|
resultBean.setBillStatus(billStatus);
|
||||||
resultBean.setErrors(error);
|
resultBean.setErrors(error);
|
||||||
|
|
@ -191,7 +193,7 @@ public class SupplierControl implements Serializable {
|
||||||
resultExt.setFailCount(1);
|
resultExt.setFailCount(1);
|
||||||
resultExt.setSuccessCount(0);
|
resultExt.setSuccessCount(0);
|
||||||
} else {
|
} else {
|
||||||
DynamicObject bd_supplier = BusinessDataServiceHelper.newDynamicObject("bd_supplier");
|
DynamicObject bd_supplier = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||||
bd_supplier.set("number", number);
|
bd_supplier.set("number", number);
|
||||||
bd_supplier.set("name", name);
|
bd_supplier.set("name", name);
|
||||||
bd_supplier.set("simplename", simplename);
|
bd_supplier.set("simplename", simplename);
|
||||||
|
|
@ -272,7 +274,7 @@ public class SupplierControl implements Serializable {
|
||||||
|
|
||||||
SaveServiceHelper.save(new DynamicObject[]{bd_suppliergroupdetails});
|
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()) {
|
if (!operationResult.isSuccess()) {
|
||||||
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
|
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
|
||||||
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
|
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
|
||||||
|
|
@ -280,15 +282,18 @@ public class SupplierControl implements Serializable {
|
||||||
}
|
}
|
||||||
error.setKeys(keys);
|
error.setKeys(keys);
|
||||||
error.setRowMsg(rowMsg);
|
error.setRowMsg(rowMsg);
|
||||||
error.setEntityKey("bd_supplier");
|
error.setEntityKey(entityName);
|
||||||
resultBean.setId("");
|
resultBean.setId(bd_supplier.getString("id"));
|
||||||
resultBean.setBillStatus(false);
|
resultBean.setBillStatus(false);
|
||||||
resultBean.setErrors(error);
|
resultBean.setErrors(error);
|
||||||
results.add(resultBean);
|
results.add(resultBean);
|
||||||
resultExt.setFailCount(1);
|
resultExt.setFailCount(1);
|
||||||
resultExt.setSuccessCount(0);
|
resultExt.setSuccessCount(0);
|
||||||
}
|
|
||||||
else {
|
//保存失败——删除暂存单据
|
||||||
|
OperationServiceHelper.executeOperate("delete", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
|
||||||
|
|
||||||
|
} else {
|
||||||
bd_supplier.set("masterid", bd_supplier.getPkValue());
|
bd_supplier.set("masterid", bd_supplier.getPkValue());
|
||||||
SaveServiceHelper.save(new DynamicObject[]{bd_supplier});
|
SaveServiceHelper.save(new DynamicObject[]{bd_supplier});
|
||||||
|
|
||||||
|
|
@ -305,39 +310,27 @@ public class SupplierControl implements Serializable {
|
||||||
BigDecimal attachementsize = BigDecimal.ZERO;
|
BigDecimal attachementsize = BigDecimal.ZERO;
|
||||||
String attachementurl = attachmentBean.getAttachmentUrl();
|
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++;
|
String uid1 = uid.toString() + index++;
|
||||||
Map<String, Object> uploadres = null;
|
Map<String, Object> uploadres = null;
|
||||||
try {
|
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) {
|
} 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;
|
break;
|
||||||
}
|
}
|
||||||
if (uploadres.get("isSuccess") != "true") {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rowMsg.size() == 0) {
|
||||||
operationResult = OperationServiceHelper.executeOperate("submit", "bd_supplier", new DynamicObject[]{bd_supplier}, OperateOption.create());
|
operationResult = OperationServiceHelper.executeOperate("submit", 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("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 (!operationResult.isSuccess()) {
|
if (!operationResult.isSuccess()) {
|
||||||
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
|
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
|
||||||
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
|
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
|
||||||
|
|
@ -345,7 +338,7 @@ public class SupplierControl implements Serializable {
|
||||||
}
|
}
|
||||||
error.setKeys(keys);
|
error.setKeys(keys);
|
||||||
error.setRowMsg(rowMsg);
|
error.setRowMsg(rowMsg);
|
||||||
error.setEntityKey("bd_supplier");
|
error.setEntityKey(entityName);
|
||||||
resultBean.setId(bd_supplier.getString("id"));
|
resultBean.setId(bd_supplier.getString("id"));
|
||||||
resultBean.setBillStatus(false);
|
resultBean.setBillStatus(false);
|
||||||
resultBean.setErrors(error);
|
resultBean.setErrors(error);
|
||||||
|
|
@ -353,13 +346,43 @@ public class SupplierControl implements Serializable {
|
||||||
resultExt.setFailCount(1);
|
resultExt.setFailCount(1);
|
||||||
resultExt.setSuccessCount(0);
|
resultExt.setSuccessCount(0);
|
||||||
} else {
|
} else {
|
||||||
resultBean.setId(bd_supplier.getString("id"));
|
operationResult = OperationServiceHelper.executeOperate("audit", entityName, new DynamicObject[]{bd_supplier}, OperateOption.create());
|
||||||
resultBean.setBillStatus(true);
|
if (!operationResult.isSuccess()) {
|
||||||
results.add(resultBean);
|
List<IOperateInfo> allErrorOrValidateInfo = operationResult.getAllErrorOrValidateInfo();
|
||||||
resultExt.setFailCount(0);
|
for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) {
|
||||||
resultExt.setSuccessCount(1);
|
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);
|
resultExt.setResult(results);
|
||||||
return CustomApiResult.success(resultExt);
|
return CustomApiResult.success(resultExt);
|
||||||
|
|
@ -375,7 +398,7 @@ public class SupplierControl implements Serializable {
|
||||||
//出现错误后返回
|
//出现错误后返回
|
||||||
error.setKeys(keys);
|
error.setKeys(keys);
|
||||||
error.setRowMsg(rowMsg);
|
error.setRowMsg(rowMsg);
|
||||||
error.setEntityKey("bd_supplier");
|
error.setEntityKey(entityName);
|
||||||
resultBean.setId("");
|
resultBean.setId("");
|
||||||
resultBean.setBillStatus(billStatus);
|
resultBean.setBillStatus(billStatus);
|
||||||
resultBean.setErrors(error);
|
resultBean.setErrors(error);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue