Sfoglia il codice sorgente

1、7688-合同开始日期、结束日期校验

dongpo 6 mesi fa
parent
commit
655d8e5a9b

+ 2 - 0
yudao-module-finance/yudao-module-contract-api/src/main/java/cn/iocoder/yudao/module/contract/enums/ErrorCodeConstants.java

@@ -8,6 +8,7 @@ public interface ErrorCodeConstants {
     ErrorCode SUPPLIER_CONTRACT_NOT_CLOSED = new ErrorCode(1_052_000_002, "采购合同已经是开启状态");
     ErrorCode SUPPLIER_CONTRACT_CODE_EXISTS = new ErrorCode(1_052_000_003, "采购合同编号已存在");
     ErrorCode SUPPLIER_CONTRACT_NAME_EXISTS = new ErrorCode(1_052_000_004, "采购合同名称已存在");
+    ErrorCode SUPPLIER_CONTRACT_START_DATE_GREATER_THAN_END_DATE = new ErrorCode(1_052_000_005, "采购合同开始日期不能大于结束日期");
     // ========== 采购合同历史信息 1_052_001_001 ==========
     ErrorCode SUPPLIER_CONTRACT_HISTORY_NOT_EXISTS = new ErrorCode(1_052_001_001, "采购合同历史信息不存在");
 
@@ -16,6 +17,7 @@ public interface ErrorCodeConstants {
     ErrorCode CUSTOMER_CONTRACT_NOT_CLOSED = new ErrorCode(1_052_002_002, "销售合同已经是开启状态");
     ErrorCode CUSTOMER_CONTRACT_CODE_EXISTS = new ErrorCode(1_052_002_003, "销售合同编号已存在");
     ErrorCode CUSTOMER_CONTRACT_NAME_EXISTS = new ErrorCode(1_052_002_004, "销售合同名称已存在");
+    ErrorCode CUSTOMER_CONTRACT_START_DATE_GREATER_THAN_END_DATE = new ErrorCode(1_052_002_005, "销售合同开始日期不能大于结束日期");
     // ========== 销售合同历史信息 1_052_003_001 ==========
     ErrorCode CUSTOMER_CONTRACT_HISTORY_NOT_EXISTS = new ErrorCode(1_052_003_001, "销售合同历史信息不存在");
 

+ 14 - 0
yudao-module-finance/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/customercontract/CustomerContractServiceImpl.java

@@ -81,6 +81,13 @@ public class CustomerContractServiceImpl implements CustomerContractService {
         if (StrUtil.isNotBlank(customerContractName)) {
             validateCustomerContractName(customerContractName, createReqVO.getId());
         }
+        String startDate = createReqVO.getStartDate();
+        String endDate = createReqVO.getEndDate();
+        if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
+            if (startDate.compareTo(endDate) > 0) {
+                throw exception(CUSTOMER_CONTRACT_START_DATE_GREATER_THAN_END_DATE);
+            }
+        }
         // 插入
         CustomerContractDO customerContract = BeanUtils.toBean(createReqVO, CustomerContractDO.class);
         // uuid
@@ -144,6 +151,13 @@ public class CustomerContractServiceImpl implements CustomerContractService {
         if (StrUtil.isNotBlank(customerContractName)) {
             validateCustomerContractName(customerContractName, updateReqVO.getId());
         }
+        String startDate = updateReqVO.getStartDate();
+        String endDate = updateReqVO.getEndDate();
+        if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
+            if (startDate.compareTo(endDate) > 0) {
+                throw exception(CUSTOMER_CONTRACT_START_DATE_GREATER_THAN_END_DATE);
+            }
+        }
         // 更新
         CustomerContractDO updateObj = BeanUtils.toBean(updateReqVO, CustomerContractDO.class);
         // 负责人及部门

+ 14 - 0
yudao-module-finance/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/suppliercontract/SupplierContractServiceImpl.java

@@ -78,6 +78,13 @@ public class SupplierContractServiceImpl implements SupplierContractService {
         if (StrUtil.isNotBlank(supplierContractName)) {
             validateSupplierContractName(supplierContractName, createReqVO.getId());
         }
+        String startDate = createReqVO.getStartDate();
+        String endDate = createReqVO.getEndDate();
+        if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
+            if (startDate.compareTo(endDate) > 0) {
+                throw exception(SUPPLIER_CONTRACT_START_DATE_GREATER_THAN_END_DATE);
+            }
+        }
         // 插入
         SupplierContractDO supplierContract = BeanUtils.toBean(createReqVO, SupplierContractDO.class);
         // uuid
@@ -141,6 +148,13 @@ public class SupplierContractServiceImpl implements SupplierContractService {
         if (StrUtil.isNotBlank(supplierContractName)) {
             validateSupplierContractName(supplierContractName, updateReqVO.getId());
         }
+        String startDate = updateReqVO.getStartDate();
+        String endDate = updateReqVO.getEndDate();
+        if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
+            if (startDate.compareTo(endDate) > 0) {
+                throw exception(SUPPLIER_CONTRACT_START_DATE_GREATER_THAN_END_DATE);
+            }
+        }
         // 更新
         SupplierContractDO updateObj = BeanUtils.toBean(updateReqVO, SupplierContractDO.class);
         // 负责人及部门