diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/CustomerControler.java b/main/java/shjh/jhzj7/fi/fi/webapi/CustomerControler.java index 74d0092..54f536c 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/CustomerControler.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/CustomerControler.java @@ -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.CustomerModel; import javax.validation.Valid; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; @ApiController(value = "CustomerControler",desc = "客户接口,自定义插件") @@ -176,6 +180,7 @@ public class CustomerControler { itemsJson.add(itemInfo); } }else{ + currentCus.set("idno",cusnumber);//个人时必输身份证号 //修改客户 名称 税务登记号 联系人 联系电话 银行信息 客户组5 currentCustId = currentCus.getLong("id"); currentCus.set("name",cusname);//客户名称 @@ -191,10 +196,11 @@ public class CustomerControler { } 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", json_body.toJSONString()+errorMsg)); itemInfo = new JSONObject(); itemInfo.put("code",cusnumber); - itemInfo.put("error","客户保存失败"+operResult.getMessage()); + itemInfo.put("error","客户保存失败"+operResult.getMessage()+errorMsg); itemsJson.add(itemInfo); } } @@ -214,6 +220,26 @@ public class CustomerControler { } } + private StringBuilder getErrorMsg(OperationResult operResult){ +// return operResult.getValidateResult().getValidateErrors().get(0).getAllErrorInfo().get(0).getMessage(); + StringBuilder errorMsg = new StringBuilder(); + ValidateResultCollection validateResult = operResult.getValidateResult(); + if (null != validateResult) { + List validateErrors = validateResult.getValidateErrors(); + if (!validateErrors.isEmpty()) { + for (ValidateResult validateError : validateErrors) { + List allErrorInfo = validateError.getAllErrorInfo(); + if (!allErrorInfo.isEmpty()) { + for (OperateErrorInfo operateErrorInfo : allErrorInfo) { + errorMsg.append(operateErrorInfo.getMessage()).append(" "); + } + } + } + } + } + return errorMsg; + } + private void handleFive(JSONArray customerfivesJson,DynamicObjectCollection doc_five,String cusnumber){ if(customerfivesJson == null){ return;