提交erp判断逻辑修改:请求参数和返回数据修改
This commit is contained in:
@@ -145,8 +145,8 @@ public class ContractController implements BusinessControllerMarker {
|
|||||||
@PostMapping("/submit/erp")
|
@PostMapping("/submit/erp")
|
||||||
@Operation(summary = "提交ERP")
|
@Operation(summary = "提交ERP")
|
||||||
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
|
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
|
||||||
public CommonResult<List<String>> submitErp(@RequestBody List<Long> ids) {
|
public CommonResult<JSONObject> submitErp(@RequestParam("id") Long id) {
|
||||||
return success(contractService.submitErp(ids));
|
return success(contractService.submitErp(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list/up-not-relation")
|
@GetMapping("/list/up-not-relation")
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ public interface ContractService {
|
|||||||
/**
|
/**
|
||||||
* 提交ERP
|
* 提交ERP
|
||||||
*
|
*
|
||||||
* @param ids 合同ID集合
|
* @param id 合同ID
|
||||||
* @return
|
* @return 提交结果
|
||||||
*/
|
*/
|
||||||
List<String> submitErp(List<Long> ids);
|
JSONObject submitErp(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除合同
|
* 删除合同
|
||||||
|
|||||||
@@ -1317,55 +1317,52 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> submitErp(List<Long> ids) {
|
public JSONObject submitErp(Long id) {
|
||||||
|
|
||||||
List<String> results = new ArrayList<>();
|
JSONObject result = new JSONObject();
|
||||||
|
|
||||||
// 遍历合同ID集合
|
// 查询合同信息
|
||||||
ids.forEach(id -> {
|
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||||
|
|
||||||
// 查询合同信息
|
// 合同数据不存在
|
||||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
if (contractMainDO == null) {
|
||||||
|
throw exception(CONTRACT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
if (contractMainDO != null) {
|
// 合同状态校验
|
||||||
|
if (!(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(contractMainDO.getStatus())
|
||||||
|
|| DictEnum.BSE_CTRT_STS_VOID.getCode().equals(contractMainDO.getStatus())
|
||||||
|
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) {
|
||||||
|
|
||||||
// 合同状态校验
|
throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP,
|
||||||
if (!(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(contractMainDO.getStatus())
|
DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||||
|| DictEnum.BSE_CTRT_STS_VOID.getCode().equals(contractMainDO.getStatus())
|
}
|
||||||
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) {
|
|
||||||
|
|
||||||
throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP,
|
// 生成ERP合同映射表
|
||||||
DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO);
|
||||||
}
|
|
||||||
|
|
||||||
// 生成ERP合同映射表
|
// 调用ERP模块
|
||||||
ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO);
|
JSONObject erpResult = sendToErp(erpContractVO);
|
||||||
|
log.info("合同提交ERP结果:{}", erpResult);
|
||||||
|
result.putOnce("success", erpResult.getBool("success"));
|
||||||
|
|
||||||
// 调用ERP模块
|
// 更新合同状态
|
||||||
JSONObject erpResult = sendToErp(erpContractVO);
|
if (erpResult.getBool("success")) {
|
||||||
log.info("合同提交ERP结果:{}", erpResult);
|
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode());
|
||||||
String result = id
|
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_FIND.getCode());
|
||||||
+"-"+erpResult.getBool("success")
|
contractMainMapper.updateById(contractMainDO);
|
||||||
+(erpResult.getBool("success") ? "" : "-" + erpResult.getStr("errMsg"));
|
|
||||||
results.add(result);
|
|
||||||
|
|
||||||
// 更新合同状态
|
result.putOnce("data", erpResult.getStr("data"));
|
||||||
if (erpResult.getBool("success")) {
|
} else {
|
||||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode());
|
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode());
|
||||||
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_FIND.getCode());
|
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_RLBK.getCode());
|
||||||
contractMainMapper.updateById(contractMainDO);
|
contractMainDO.setCause(erpResult.getStr("errMsg"));
|
||||||
} else {
|
contractMainMapper.updateById(contractMainDO);
|
||||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode());
|
|
||||||
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_RLBK.getCode());
|
|
||||||
contractMainDO.setCause(erpResult.getStr("errMsg"));
|
|
||||||
contractMainMapper.updateById(contractMainDO);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
results.add(id+"-"+"false"+"-"+CONTRACT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return results;
|
result.putOnce("data", erpResult.getStr("errMsg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject sendToErp(ErpContractSaveReqVO erpContractVO) {
|
private JSONObject sendToErp(ErpContractSaveReqVO erpContractVO) {
|
||||||
@@ -1554,10 +1551,10 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
|
|
||||||
// 更新合同
|
// 更新合同
|
||||||
contractMainMapper.updateById(contractMainDO);
|
contractMainMapper.updateById(contractMainDO);
|
||||||
});
|
|
||||||
|
|
||||||
// 重新提交erp
|
// 重新提交erp
|
||||||
submitErp(ids);
|
submitErp(id);
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1585,10 +1582,10 @@ public class ContractServiceImpl implements ContractService {
|
|||||||
|
|
||||||
// 更新合同
|
// 更新合同
|
||||||
contractMainMapper.updateById(contractMainDO);
|
contractMainMapper.updateById(contractMainDO);
|
||||||
});
|
|
||||||
|
|
||||||
// 重新提交erp
|
// 重新提交erp
|
||||||
submitErp(ids);
|
submitErp(id);
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user