diff --git a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/controller/ErpContractInfoController.java b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/controller/ErpContractInfoController.java index e14b98fc..31886166 100644 --- a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/controller/ErpContractInfoController.java +++ b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/controller/ErpContractInfoController.java @@ -122,6 +122,17 @@ public class ErpContractInfoController extends BaseController { return R.ok(erpContractInfoService.contractSubmitAndFlowStart(bo)); } + /** + * 复制合同信息 + */ + @SaCheckPermission("oa/erp:contractInfo:update") + @Log(title = "合同信息", businessType = BusinessType.INSERT) + @RepeatSubmit() + @PostMapping("/copy") + public R copy(@RequestBody ErpContractInfoBo bo) { + return R.ok(erpContractInfoService.copyContract(bo)); + } + /** * 修改合同信息 */ diff --git a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/IErpContractInfoService.java b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/IErpContractInfoService.java index 4c6d7008..402dcd4c 100644 --- a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/IErpContractInfoService.java +++ b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/IErpContractInfoService.java @@ -80,4 +80,12 @@ public interface IErpContractInfoService { * @return Word模板数据Map */ java.util.Map buildApprovalWordExportData(Long contractId); + + /** + * 复制合同信息(新合同为暂存状态) + * + * @param bo + * @return 新合同信息 + */ + ErpContractInfoVo copyContract(ErpContractInfoBo bo); } diff --git a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java index ea2b7565..7fc10c4a 100644 --- a/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java +++ b/ruoyi-modules/ruoyi-oa/src/main/java/org/dromara/oa/erp/service/impl/ErpContractInfoServiceImpl.java @@ -187,7 +187,6 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService { } private MPJLambdaWrapper buildQueryWrapper(ErpContractInfoBo bo) { - Map params = bo.getParams(); MPJLambdaWrapper lqw = JoinWrappers.lambda(ErpContractInfo.class) .selectAll(ErpContractInfo.class) .eq(StringUtils.isNotBlank(bo.getContractFlag()), ErpContractInfo::getContractFlag, @@ -206,6 +205,8 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService { bo.getBusinessDirection()) .eq(bo.getContractDeptId() != null, ErpContractInfo::getContractDeptId, bo.getContractDeptId()) .eq(bo.getContractDate() != null, ErpContractInfo::getContractDate, bo.getContractDate()) + .apply(StringUtils.isNotBlank(bo.getOneCustomerName()), + "c1.customer_name LIKE CONCAT('%', {0}, '%')", bo.getOneCustomerName()) .eq(bo.getTotalPrice() != null, ErpContractInfo::getTotalPrice, bo.getTotalPrice()) .eq(StringUtils.isNotBlank(bo.getContractStatus()), ErpContractInfo::getContractStatus, bo.getContractStatus()) @@ -223,8 +224,8 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService { .eq(StringUtils.isNotBlank(bo.getContractTemplateFlag()), ErpContractInfo::getContractTemplateFlag, bo.getContractTemplateFlag()) .eq("t.del_flag", "0") - .eq("t.active_flag", "1") - .orderByDesc(ErpContractInfo::getCreateTime); + .eq("t.active_flag", "1"); + lqw.orderByDesc(ErpContractInfo::getCreateTime); return lqw; } @@ -263,6 +264,58 @@ public class ErpContractInfoServiceImpl implements IErpContractInfoService { return MapstructUtils.convert(add, ErpContractInfoVo.class); } + /** + * 复制合同信息(新合同为暂存状态) + * + * @param copyBo + * @return 新合同信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public ErpContractInfoVo copyContract(ErpContractInfoBo copyBo) { + Long sourceContractId = copyBo.getContractId(); + String contractCode = copyBo.getContractCode().trim(); + String contractName = copyBo.getContractName().trim(); + ErpContractInfoVo src = queryById(sourceContractId); + if (src == null) { + throw new ServiceException("被复制合同不存在"); + } + ErpContractInfoBo newBo = BeanUtil.copyProperties(src, ErpContractInfoBo.class, + "contractId", "contractMaterialList", "contractPaymentMethodList"); + newBo.setContractCode(contractCode); + newBo.setContractName(contractName); + newBo.setContractStatus(OAStatusEnum.DRAFT.getStatus()); + newBo.setFlowStatus(BusinessStatusEnum.DRAFT.getStatus()); + newBo.setCustomerContractCode(null); + newBo.setSignatureAppendix(null); + newBo.setInternalContractCode(null); + newBo.setExternalContractCode(null); + newBo.setOrderContractCode(null); + newBo.setProjectContractCode(null); + newBo.setOriginalContractId(null); + List materials = new ArrayList<>(); + if (src.getContractMaterialList() != null) { + for (ErpContractMaterialVo mvo : src.getContractMaterialList()) { + ErpContractMaterial m = BeanUtil.copyProperties(mvo, ErpContractMaterial.class); + m.setContractMaterialId(null); + m.setContractId(null); + materials.add(m); + } + } + newBo.setContractMaterialList(materials); + List payments = new ArrayList<>(); + if (src.getContractPaymentMethodList() != null) { + for (ErpContractPaymentMethodVo pvo : src.getContractPaymentMethodList()) { + ErpContractPaymentMethod p = BeanUtil.copyProperties(pvo, ErpContractPaymentMethod.class); + p.setPaymentMethodId(null); + p.setContractId(null); + payments.add(p); + } + } + newBo.setContractPaymentMethodList(payments); + return insertByBo(newBo); + } + /** * 修改合同信息 *