新增作废接口
新增完结接口 修改合同新增逻辑:设置erp甲乙方公司编号、名称 保存erp合同映射表是设置删除状态
This commit is contained in:
@@ -107,18 +107,18 @@ public class ContractController implements BusinessControllerMarker {
|
||||
return contractService.download(ids);
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/cancel")
|
||||
@Operation(summary = "作废 TODO")
|
||||
@Operation(summary = "作废")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:cancel')")
|
||||
public void cancel() {
|
||||
public CommonResult<Boolean> cancel(@RequestBody List<Long> ids) {
|
||||
return success(contractService.cancel(ids));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@PostMapping("/complete")
|
||||
@Operation(summary = "完结 TODO")
|
||||
@Operation(summary = "完结")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:complete')")
|
||||
public void complete() {
|
||||
public CommonResult<Boolean> complete(@RequestBody List<Long> ids) {
|
||||
return success(contractService.complete(ids));
|
||||
}
|
||||
|
||||
@PostMapping("/archive")
|
||||
|
||||
@@ -177,4 +177,20 @@ public interface ContractService {
|
||||
* @return 归档结果
|
||||
*/
|
||||
Boolean archive(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 作废
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 作废结果
|
||||
*/
|
||||
Boolean cancel(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 完结
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return 完结结果
|
||||
*/
|
||||
Boolean complete(List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ 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;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpCompanyDO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpContractDO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpCompanyService;
|
||||
import com.zt.plat.module.erp.service.erp.ErpContractService;
|
||||
@@ -140,23 +141,33 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
}
|
||||
|
||||
// 合同主信息
|
||||
ContractMainDO contractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class);
|
||||
|
||||
// 校验ERP的公司
|
||||
if (StringUtils.isNotEmpty(reqVO.getPurchaseCompanyNumber())
|
||||
|| StringUtils.isNotEmpty(reqVO.getSalesCompanyNumber())) {
|
||||
if (StringUtils.isNotEmpty(reqVO.getPurchaseCompanyNumber())) {
|
||||
if (erpCompanyService.getErpCompanyByNumber(reqVO.getPurchaseCompanyNumber()) == null) {
|
||||
ErpCompanyDO erpCompany = erpCompanyService.getErpCompanyByNumber(reqVO.getPurchaseCompanyNumber());
|
||||
if (erpCompany == null) {
|
||||
throw exception(CONTRACT_ERP_COMPANY_PLEASE_BIND, ApiConstants.PURCHASE);
|
||||
} else {
|
||||
contractMainDO.setErpPurchaseCompanyNumber(erpCompany.getNumber());
|
||||
contractMainDO.setErpPurchaseCompanyName(erpCompany.getName());
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(reqVO.getSalesCompanyNumber())) {
|
||||
if (erpCompanyService.getErpCompanyByNumber(reqVO.getSalesCompanyNumber()) == null) {
|
||||
ErpCompanyDO erpCompany = erpCompanyService.getErpCompanyByNumber(reqVO.getSalesCompanyNumber());
|
||||
if (erpCompany == null) {
|
||||
throw exception(CONTRACT_ERP_COMPANY_PLEASE_BIND, ApiConstants.SALES);
|
||||
} else {
|
||||
contractMainDO.setErpSalesCompanyNumber(erpCompany.getNumber());
|
||||
contractMainDO.setErpSalesCompanyName(erpCompany.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 合同主信息
|
||||
ContractMainDO contractMainDO = BeanUtils.toBean(reqVO, ContractMainDO.class);
|
||||
|
||||
// 合同状态保存为草稿
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_DRAFT.getCode());
|
||||
// 生成系统合同编号
|
||||
@@ -1499,6 +1510,62 @@ public class ContractServiceImpl implements ContractService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean cancel(List<Long> ids) {
|
||||
|
||||
// 遍历合同ID
|
||||
ids.forEach(id -> {
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())) {
|
||||
throw exception(CONTRACT_STATUS_NOT_ARCHIVE,
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 设置作废状态
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_VOID.getCode());
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean complete(List<Long> ids) {
|
||||
|
||||
// 遍历合同ID
|
||||
ids.forEach(id -> {
|
||||
|
||||
// 查询合同是否存在
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 合同状态校验
|
||||
if (!DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode().equals(contractMainDO.getStatus())) {
|
||||
throw exception(CONTRACT_STATUS_NOT_ARCHIVE,
|
||||
DictEnum.getByCode(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
// 设置完结状态
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_TERMINATED.getCode());
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验合同内容
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user