客商接口增加具体错误信息

This commit is contained in:
yuxueliang0813 2025-06-13 15:32:48 +08:00
parent cb00d6147d
commit 580b6a17c9
2 changed files with 31 additions and 7 deletions

View File

@ -152,10 +152,11 @@ public class CustomerControler {
// SaveServiceHelper.save(new DynamicObject[]{currentCus});
operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
if(!operResult.isSuccess()){
log.error(String.format("客户保存失败:%s", json_body.toJSONString()));
StringBuilder errorMsg = getErrorMsg(operResult);
log.error(String.format("客户保存失败:%s", cusname+errorMsg));
itemInfo = new JSONObject();
itemInfo.put("code",cusnumber);
itemInfo.put("error","客户保存失败"+operResult.getMessage());
itemInfo.put("error",operResult.getMessage()+errorMsg);
itemsJson.add(itemInfo);
continue;
}
@ -180,7 +181,6 @@ public class CustomerControler {
itemsJson.add(itemInfo);
}
}else{
currentCus.set("idno",cusnumber);//个人时必输身份证号
//修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5
currentCustId = currentCus.getLong("id");
currentCus.set("name",cusname);//客户名称
@ -197,10 +197,10 @@ public class CustomerControler {
operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentCus}, oop);
if(!operResult.isSuccess()){
StringBuilder errorMsg = getErrorMsg(operResult);
log.error(String.format("客户保存失败:%s", json_body.toJSONString()+errorMsg));
log.error(String.format("客户保存失败:%s", cusname+errorMsg));
itemInfo = new JSONObject();
itemInfo.put("code",cusnumber);
itemInfo.put("error","客户保存失败"+operResult.getMessage()+errorMsg);
itemInfo.put("error",operResult.getMessage()+errorMsg);
itemsJson.add(itemInfo);
}
}

View File

@ -10,7 +10,10 @@ import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.OperateErrorInfo;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.validate.ValidateResult;
import kd.bos.entity.validate.ValidateResultCollection;
import kd.bos.id.ID;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
@ -27,6 +30,7 @@ import shjh.jhzj7.fi.fi.webapi.model.SupplierModel;
import javax.validation.Valid;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ApiController(value = "SupplierControler",desc = "供应商接口,自定义插件")
@ -198,10 +202,11 @@ public class SupplierControler {
// SaveServiceHelper.save(new DynamicObject[]{currentSup});
operResult = OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{currentSup}, oop);
if(!operResult.isSuccess()){
log.error(String.format("供应商保存失败:%s", json_body.toJSONString()));
StringBuilder errorMsg = getErrorMsg(operResult);
log.error(String.format("供应商保存失败:%s", supname+errorMsg));
itemInfo = new JSONObject();
itemInfo.put("code",supnumber);
itemInfo.put("error","供应商保存失败"+operResult.getMessage());
itemInfo.put("error",operResult.getMessage()+errorMsg);
itemsJson.add(itemInfo);
continue;
}
@ -253,6 +258,25 @@ public class SupplierControler {
return null;
}
private StringBuilder getErrorMsg(OperationResult operResult){
StringBuilder errorMsg = new StringBuilder();
ValidateResultCollection validateResult = operResult.getValidateResult();
if (null != validateResult) {
List<ValidateResult> validateErrors = validateResult.getValidateErrors();
if (!validateErrors.isEmpty()) {
for (ValidateResult validateError : validateErrors) {
List<OperateErrorInfo> allErrorInfo = validateError.getAllErrorInfo();
if (!allErrorInfo.isEmpty()) {
for (OperateErrorInfo operateErrorInfo : allErrorInfo) {
errorMsg.append(operateErrorInfo.getMessage()).append(" ");
}
}
}
}
}
return errorMsg;
}
private DynamicObject getSAPInfo(DynamicObjectCollection doc_sap, String companynum){
//从当前供应商的sap公司集合中获取对应的对象
for (DynamicObject bankinfo : doc_sap) {