删除合同接口、提erp接口
This commit is contained in:
@@ -22,4 +22,5 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CONTRACT_STATUS_NOT_SUBMIT_APPROVAL = new ErrorCode(1_027_000_007, "{}状态合同不允许提交审核");
|
||||
ErrorCode CONTRACT_STATUS_NOT_APPROVAL = new ErrorCode(1_027_000_008, "{}状态合同不允许审核");
|
||||
ErrorCode CONTRACT_ERP_COMPANY_PLEASE_BIND = new ErrorCode(1_027_000_009, "请先绑定{}ERP公司信息");
|
||||
ErrorCode CONTRACT_STATUS_NOT_DELETE = new ErrorCode(1_027_000_010, "{}状态合同不允许删除");
|
||||
}
|
||||
|
||||
@@ -63,4 +63,8 @@ public enum DictEnum {
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public static DictEnum getByCode(String code, String dictType) {
|
||||
return DictEnum.valueOf(dictType + "_" +code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +85,11 @@ public class ContractController implements BusinessControllerMarker {
|
||||
return success(contractService.update(reqVO));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除合同")
|
||||
@Parameter(name = "ids", description = "合同ID集合", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:delete')")
|
||||
public CommonResult<Boolean> delete(@RequestParam("ids") Long[] ids) {
|
||||
return success(true);
|
||||
public CommonResult<List<JSONObject>> delete(@RequestBody List<Long> ids) {
|
||||
return success(contractService.delete(ids));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -144,11 +142,10 @@ public class ContractController implements BusinessControllerMarker {
|
||||
public void viewApproval() {
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/submit/erp")
|
||||
@Operation(summary = "提交ERP")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
|
||||
public void submitErp(@RequestBody List<Long> ids) {
|
||||
contractService.submitErp(ids);
|
||||
public CommonResult<List<String>> submitErp(@RequestBody List<Long> ids) {
|
||||
return success(contractService.submitErp(ids));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.contractorder.service.contract;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*;
|
||||
@@ -101,5 +102,13 @@ public interface ContractService {
|
||||
* @param ids 合同ID集合
|
||||
* @return
|
||||
*/
|
||||
void submitErp(List<Long> ids);
|
||||
List<String> submitErp(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 删除合同
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 删除结果
|
||||
*/
|
||||
List<JSONObject> delete(List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.contractorder.service.contract;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
@@ -21,10 +22,7 @@ import com.zt.plat.module.contractorder.api.dto.contract.*;
|
||||
import com.zt.plat.module.contractorder.controller.admin.contract.vo.contract.*;
|
||||
import com.zt.plat.module.contractorder.dal.dataobject.contract.*;
|
||||
import com.zt.plat.module.contractorder.dal.mysql.contract.*;
|
||||
import com.zt.plat.module.contractorder.enums.ApiConstants;
|
||||
import com.zt.plat.module.contractorder.enums.DateConstants;
|
||||
import com.zt.plat.module.contractorder.enums.ProcessConstants;
|
||||
import com.zt.plat.module.contractorder.enums.TableFieldConstants;
|
||||
import com.zt.plat.module.contractorder.enums.*;
|
||||
import com.zt.plat.module.contractorder.enums.contract.DictEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO;
|
||||
@@ -412,7 +410,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
|| DictEnum.BSE_CTRT_STS_UNDER_REVIEW.getCode().equals(oldContractMainDO.getStatus())) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_UPDATE,
|
||||
DictEnum.valueOf(oldContractMainDO.getStatus()).getLabel());
|
||||
DictEnum.getByCode(oldContractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 请求更新的合同信息
|
||||
@@ -596,6 +594,83 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> delete(List<Long> ids) {
|
||||
|
||||
// 执行结果
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
|
||||
ids.forEach(id -> {
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
result.add(new JSONObject().putOnce("deleted", false).putOnce("msg", id.toString() + ":" + CONTRACT_NOT_EXISTS));
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!DictEnum.BSE_CTRT_STS_DRAFT.getCode().equals(contractMainDO.getStatus())) {
|
||||
String msg = id.toString()
|
||||
+ ":"
|
||||
+ CONTRACT_STATUS_NOT_DELETE.getMsg()
|
||||
.replace("{}", DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
result.add(new JSONObject().putOnce("deleted", false).putOnce("msg", msg));
|
||||
}
|
||||
|
||||
// 删除关联信息
|
||||
// 查询合同明细
|
||||
List<ContractDetailDO> detailDOS = contractDetailMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_DTL_CTRT_MAIN_ID, id);
|
||||
if (detailDOS != null && !detailDOS.isEmpty()) {
|
||||
detailDOS.forEach(detailDO -> {
|
||||
Long detailDOId = detailDO.getId();
|
||||
|
||||
// 删除交货计划
|
||||
contractPlanMapper.delete(TableFieldConstants.BSE_CTRT_PLN_CTRT_DTL_ID, detailDOId.toString());
|
||||
});
|
||||
|
||||
// 删除合同明细
|
||||
contractDetailMapper.delete(TableFieldConstants.BSE_CTRT_DTL_CTRT_MAIN_ID, id.toString());
|
||||
}
|
||||
|
||||
// 查询价款结算条款
|
||||
List<ContractFormulaDO> formulaDOS = contractFormulaMapper
|
||||
.selectList(TableFieldConstants.BSE_CTRT_FMU_CTRT_ID, id);
|
||||
if (formulaDOS != null && !formulaDOS.isEmpty()) {
|
||||
formulaDOS.forEach(formulaDO -> {
|
||||
|
||||
// 价款结算条款ID
|
||||
Long formulaDOId = formulaDO.getId();
|
||||
|
||||
// 删除基础系数配置
|
||||
contractCoefficientMapper.delete(TableFieldConstants.BSE_CTRT_COEF_FMU_ID, formulaDOId.toString());
|
||||
// 删除品位等级价配置
|
||||
contractGradeMapper.delete(TableFieldConstants.BSE_CTRT_GRD_FMU_ID, formulaDOId.toString());
|
||||
// 删除调整价配置
|
||||
contractDeductMapper.delete(TableFieldConstants.BSE_CTRT_DDCT_FMU_ID, formulaDOId.toString());
|
||||
// 删除市场价配置
|
||||
contractPriceMapper.delete(TableFieldConstants.BSE_CTRT_PRC_FMU_ID, formulaDOId.toString());
|
||||
});
|
||||
|
||||
// 删除价款结算条款
|
||||
contractFormulaMapper.delete(TableFieldConstants.BSE_CTRT_FMU_CTRT_ID, id.toString());
|
||||
}
|
||||
|
||||
// 删除参数降级规则
|
||||
contractDemoteMapper.delete(TableFieldConstants.BSE_CTRT_DMOT_CTRT_ID, id.toString());
|
||||
|
||||
// 删除品位不计价规则
|
||||
contractNotMapper.delete(TableFieldConstants.BSE_CTRT_NT_CTRT_ID, id.toString());
|
||||
|
||||
// 删除合同数据
|
||||
contractMainMapper.deleteById(id);
|
||||
|
||||
result.add(new JSONObject().putOnce("deleted", true).putOnce("msg", id.toString()));
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String submitApproval(Long id) {
|
||||
|
||||
@@ -618,7 +693,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
|| DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(contractMainDO.getStatus())) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_SUBMIT_APPROVAL,
|
||||
DictEnum.valueOf(contractMainDO.getStatus()).getLabel());
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 合同内容校验
|
||||
@@ -684,7 +759,7 @@ public class ContractServiceImpl implements ContractService {
|
||||
|| DictEnum.BSE_CTRT_STS_DELETED.getCode().equals(contractMainDO.getStatus())) {
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_APPROVAL,
|
||||
DictEnum.valueOf(contractMainDO.getStatus()).getLabel());
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -828,7 +903,10 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitErp(List<Long> ids) {
|
||||
public List<String> submitErp(List<Long> ids) {
|
||||
|
||||
// 返回结果
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
// 遍历合同ID集合
|
||||
ids.forEach(id -> {
|
||||
@@ -983,9 +1061,20 @@ public class ContractServiceImpl implements ContractService {
|
||||
erpContractVO.setUpdaterName(contractMainDO.getUpdaterName());
|
||||
|
||||
// 调用ERP模块
|
||||
erpContractService.submitErp(erpContractVO);
|
||||
String erpResult = null;
|
||||
try {
|
||||
erpContractService.submitErp(erpContractVO);
|
||||
} catch (Exception e) {
|
||||
erpResult = e.getMessage();
|
||||
}
|
||||
log.info("合同提交ERP结果:{}", erpResult);
|
||||
result.add(id.toString() + ":" + erpResult);
|
||||
} else {
|
||||
result.add(id.toString() + ":" + CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user