【泛微-单据状态更新接口】
This commit is contained in:
		
							parent
							
								
									3fcbd6b93b
								
							
						
					
					
						commit
						aaf223e706
					
				|  | @ -1,10 +1,19 @@ | ||||||
| package tqq9.lc123.cloud.app.api.controller; | package tqq9.lc123.cloud.app.api.controller; | ||||||
| 
 | 
 | ||||||
|  | import com.alibaba.fastjson.JSONObject; | ||||||
| import com.drew.lang.annotations.NotNull; | import com.drew.lang.annotations.NotNull; | ||||||
|  | import kd.bos.dataentity.OperateOption; | ||||||
|  | import kd.bos.dataentity.entity.DynamicObject; | ||||||
|  | import kd.bos.entity.operate.result.IOperateInfo; | ||||||
|  | import kd.bos.entity.operate.result.OperationResult; | ||||||
| import kd.bos.openapi.common.custom.annotation.ApiController; | import kd.bos.openapi.common.custom.annotation.ApiController; | ||||||
| import kd.bos.openapi.common.custom.annotation.ApiParam; | import kd.bos.openapi.common.custom.annotation.ApiParam; | ||||||
| import kd.bos.openapi.common.custom.annotation.ApiPostMapping; | import kd.bos.openapi.common.custom.annotation.ApiPostMapping; | ||||||
| import kd.bos.openapi.common.result.CustomApiResult; | import kd.bos.openapi.common.result.CustomApiResult; | ||||||
|  | import kd.bos.orm.query.QFilter; | ||||||
|  | import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||||
|  | import kd.bos.servicehelper.operation.OperationServiceHelper; | ||||||
|  | import kd.bos.servicehelper.operation.SaveServiceHelper; | ||||||
| import tqq9.lc123.cloud.app.api.model.FWBillStateUpdModel; | import tqq9.lc123.cloud.app.api.model.FWBillStateUpdModel; | ||||||
| import tqq9.lc123.cloud.app.api.utils.ApiResultExt; | import tqq9.lc123.cloud.app.api.utils.ApiResultExt; | ||||||
| 
 | 
 | ||||||
|  | @ -17,11 +26,82 @@ public class FWBillStateUpdController { | ||||||
|     @ApiPostMapping(value = "/FWBillUpd", desc = "泛微-单据状态更新api接口") |     @ApiPostMapping(value = "/FWBillUpd", desc = "泛微-单据状态更新api接口") | ||||||
|     public CustomApiResult<ApiResultExt> billUpd |     public CustomApiResult<ApiResultExt> billUpd | ||||||
|             (@NotNull @ApiParam(value = "入参", example = "") FWBillStateUpdModel model) { |             (@NotNull @ApiParam(value = "入参", example = "") FWBillStateUpdModel model) { | ||||||
|  |         String KDBillNumber = model.getKDBillNumber(); | ||||||
|  |         String KDBillType = model.getKDBillType(); | ||||||
|  |         int state = model.getState(); | ||||||
|  |         String message = model.getMessage(); | ||||||
|  | 
 | ||||||
|         ApiResultExt resultExt = new ApiResultExt(); |         ApiResultExt resultExt = new ApiResultExt(); | ||||||
|  |         ApiResultExt.Error errors = new ApiResultExt.Error(); | ||||||
|  |         ArrayList<String> errorList = new ArrayList<>(); | ||||||
|         List<ApiResultExt.ResultBean> results = new ArrayList<>(); |         List<ApiResultExt.ResultBean> results = new ArrayList<>(); | ||||||
|  |         ApiResultExt.ResultBean resultBean = new ApiResultExt.ResultBean(); | ||||||
|  |         resultBean.setBillStatus(true); | ||||||
|  |         resultBean.setBillIndex(0); | ||||||
|  |         resultBean.setNumber(KDBillNumber); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |         DynamicObject approveLog = BusinessDataServiceHelper.newDynamicObject("tqq9_fwapprovelog"); | ||||||
|  |         approveLog.set("name", KDBillType); | ||||||
|  |         approveLog.set("tqq9_billno", KDBillNumber); | ||||||
|  |         approveLog.set("tqq9_returnstring_tag", JSONObject.toJSONString(model)); | ||||||
|  |         approveLog.set("tqq9_message", message); | ||||||
| 
 | 
 | ||||||
|  |         //校验单据标识是否正确 | ||||||
|  |         QFilter f1 = new QFilter("number", "=", KDBillType); | ||||||
|  |         DynamicObject[] bos_entityobjects = BusinessDataServiceHelper.load("bos_entityobject", "id,name,number,modeltype", new QFilter[]{f1}); | ||||||
|  |         if(bos_entityobjects == null && bos_entityobjects.length == 0){ | ||||||
|  |             errorList.add("参数KDBillType["+KDBillType+"]不是正确的标识"); | ||||||
|  |         }else{ | ||||||
|  |             DynamicObject bosEntity = bos_entityobjects[0]; | ||||||
|  |             String modeltype = bosEntity.getString("modeltype"); | ||||||
|  |             String enetityNumber = bosEntity.getString("number"); | ||||||
|  |             String enetityName = bosEntity.getString("name"); | ||||||
|  |             String billNoFieldName = "billno"; | ||||||
|  |             if("BaseFormModel".equals(modeltype) || "gl_voucher".equals(enetityNumber)){ | ||||||
|  |                 billNoFieldName = "number"; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             //查询对应的安居 | ||||||
|  |             QFilter qf1 = new QFilter(billNoFieldName, "=", KDBillNumber); | ||||||
|  |             DynamicObject[] billArr = BusinessDataServiceHelper.load(enetityNumber, "id,tqq9_issuccess", new QFilter[]{qf1}); | ||||||
|  |             if(billArr != null && billArr.length > 0){ | ||||||
|  |                 boolean isSuccess = false; | ||||||
|  |                 if(state == 0){ | ||||||
|  |                     isSuccess = true; | ||||||
|  |                 } | ||||||
|  |                 billArr[0].set("tqq9_issuccess", isSuccess); | ||||||
|  |                 SaveServiceHelper.save(new DynamicObject[]{billArr[0]}); | ||||||
|  | 
 | ||||||
|  |                 approveLog.set("tqq9_issuccess", isSuccess); | ||||||
|  |                 approveLog.set("tqq9_entityname", enetityName); | ||||||
|  |                 OperationResult operationResult = OperationServiceHelper.executeOperate("save", "tqq9_fwapprovelog", new DynamicObject[]{approveLog}, OperateOption.create()); | ||||||
|  | 
 | ||||||
|  |                 if(isSuccess){ | ||||||
|  |                     OperationResult submitResult = OperationServiceHelper.executeOperate("submit", enetityNumber, new DynamicObject[]{billArr[0]}, OperateOption.create()); | ||||||
|  |                     if(!submitResult.isSuccess()){ | ||||||
|  |                         List<IOperateInfo> allErrorOrValidateInfo = submitResult.getAllErrorOrValidateInfo(); | ||||||
|  |                         for (IOperateInfo iOperateInfo : allErrorOrValidateInfo) { | ||||||
|  |                             errorList.add(enetityName+"审核时否生错误:"+iOperateInfo.getMessage()); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             }else{ | ||||||
|  |                 errorList.add("根据参数KDBillType["+KDBillType+"]。KDBillNumber["+KDBillNumber+"]没有查询到对应的"+enetityName+"信息"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         if(errorList.size() > 0){ | ||||||
|  |             resultBean.setBillStatus(false); | ||||||
|  |             errors.setRowMsg(errorList); | ||||||
|  |             resultBean.setErrors(errors); | ||||||
|  | 
 | ||||||
|  |             resultExt.setFailCount(1); | ||||||
|  |             resultExt.setSuccessCount(0); | ||||||
|  |         }else{ | ||||||
|  |             resultExt.setFailCount(0); | ||||||
|  |             resultExt.setSuccessCount(1); | ||||||
|  |         } | ||||||
|  |         results.add(resultBean); | ||||||
|         resultExt.setResult(results); |         resultExt.setResult(results); | ||||||
|         return CustomApiResult.success(resultExt); |         return CustomApiResult.success(resultExt); | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue