Browse Source

销售合同相关

wanglang 2 months ago
parent
commit
40ce6fb64d

+ 13 - 5
trade-client/src/main/java/com/trade/client/trade/sales/service/impl/SalesServiceImpl.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.trade.common.utils.ConstantUtil;
 import com.trade.common.utils.LoggerUtil;
 import com.trade.common.utils.StringUtils;
 import com.trade.common.utils.file.ExcelImportUtils;
@@ -20,6 +21,7 @@ import com.trade.common.utils.file.FileUtils;
 import com.trade.service.companyrelated.domain.VendorEntity;
 import com.trade.service.companyrelated.service.IVendorEntityService;
 import com.trade.service.sales.vo.ImportCommodityVo;
+import com.trade.service.serialNum.service.SerialNumberGenerator;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -93,6 +95,8 @@ public class SalesServiceImpl implements SalesService {
     private ContractTermsExtendService contractTermsExtendService;
     @Resource
     private IVendorEntityService iVendorEntityService;
+    @Resource
+    private SerialNumberGenerator serialNumberGenerator;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -156,14 +160,18 @@ public class SalesServiceImpl implements SalesService {
         if (SubmitStatus.FORMAL.getCode().equals(contractTermsDto.getSubmitStatus())) {
             ValidatorUtil.validator(ValidatorGroup.ValidatorType.SUBMIT, contractTermsDto);
         }
-        ContractTerms contractTermsExist = contractTermsService.lambdaQuery()
-                .eq(ContractTerms::getContractNo, contractTermsDto.getContractNo()).eq(ContractTerms::getDeleted, 0)
-                .one();
+        // ContractTerms contractTermsExist = contractTermsService.lambdaQuery()
+        // .eq(ContractTerms::getContractNo, contractTermsDto.getContractNo()).eq(ContractTerms::getDeleted, 0)
+        // .one();
+        ContractTerms contractTermsExist = contractTermsService.getByContractIdAndType(contractTermsDto.getContractId(),
+                ConstantUtil.SALES_CONTRACT_NO_PREFIX);
         ContractTerms contractTerms = salesDataConverter.convertContractTermsDo(contractTermsDto);
         if (contractTermsExist != null) {
             contractTerms.setId(contractTermsExist.getId());
             contractTermsService.updateById(contractTerms);
         } else {
+            contractTerms.setContractId(contractTermsDto.getContractId());
+            contractTerms.setContractType(ConstantUtil.SALES_CONTRACT_NO_PREFIX);
             contractTermsService.save(contractTerms);
         }
         List<ContractTermsExtend> contractTermsExtendsExist = contractTermsExtendService.lambdaQuery()
@@ -411,7 +419,7 @@ public class SalesServiceImpl implements SalesService {
             contractFile.setOperatorName(customerUser.getNickname());
             if (salesContractDto.getTemplateType() && isTemplate) {
                 // 生成合同文件
-                contractFile.setContractNo(BizNoUtil.generateSalesContractNo());
+                contractFile.setContractNo(serialNumberGenerator.nextValue(ConstantUtil.SALES_CONTRACT_NO_PREFIX));
                 // ContractGenInput input = new ContractGenInput();
                 // input.setBizNo(contractFile.getContractNo());
                 // input.setUserId(customerUser.getId());
@@ -453,7 +461,7 @@ public class SalesServiceImpl implements SalesService {
             contractFile.setSignFileType(FileTypeEnum.SALES_CONTRACT.getCode());
             contractFile.setGenerationTime(LocalDateTime.now());
             contractFile.setOperatorName(customerUser.getNickname());
-            contractFile.setContractNo(BizNoUtil.generateSalesContractNo());
+            contractFile.setContractNo(serialNumberGenerator.nextValue(ConstantUtil.SALES_CONTRACT_NO_PREFIX));
             // ContractGenInput input = new ContractGenInput();
             // input.setBizNo(contractFile.getContractNo());
             // input.setUserId(customerUser.getId());

+ 10 - 12
trade-common/src/main/java/com/trade/common/utils/ConstantUtil.java

@@ -1,6 +1,5 @@
 package com.trade.common.utils;
 
-
 /**
  * @Description:纯常量工具类
  * @Author:wanxiangZhou
@@ -8,6 +7,7 @@ package com.trade.common.utils;
  * @Date:2018年6月5日 下午3:49:30
  */
 public class ConstantUtil {
+
     /**
      * 上午
      **/
@@ -16,15 +16,12 @@ public class ConstantUtil {
      * 下午
      **/
     public static final String PM_CNAME = "下午";
-
-
-    /* 主业务类型常量*/
+    /* 主业务类型常量 */
     /**
      * 企业准入
      */
     public static final String ENTERPRISE_ACCESS = "enterprise";
     public static final String ENTERPRISE_PERSON = "enterprisePerson";
-
     public static final String TRADING_PLATFORM = "tradingPlatform";
     /**
      * 验收单
@@ -34,7 +31,6 @@ public class ConstantUtil {
      * 采购合同管理
      **/
     public static final String PURCHASE_CONTRACT = "PurchaseContract";
-
     /**
      * 底层
      */
@@ -43,31 +39,33 @@ public class ConstantUtil {
      * 结算单
      */
     public static final String BILL_BASIC_INFORMATION = "BillBasicInformation";
-
-
     /* 单据编号常量 */
     /**
      * 验收单编号
      */
     public static final String ACCEPTANCE_SHEET_CODE = "SH";
-
     /**
      * 结算单编号
      */
     public static final String BILL_CODE = "JS";
-
     /**
      * 底层编号
      */
     public static final String UNDERLYING_CODE = "ULD";
-
     /**
      * 贸易平台
      */
     public static final String TRADE_PLATFORM = "P";
-
     /**
      * 进口商编号
      */
     public static final String IMPORTER_CODE = "BuyerCN";
+    /**
+     * 销售合同编号
+     */
+    public static final String SALES_CONTRACT_NO_PREFIX = "SC";
+    /**
+     * 采购订单
+     */
+    public static final String PURCHASE_ORDER_NO_PREFIX = "PO";
 }

+ 2 - 2
trade-service/src/main/java/com/trade/service/sales/service/impl/SalesContractServiceImpl.java

@@ -80,7 +80,7 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
         contractFileDto.setPath(fileStorage.getPath());
         salesContractInfoVo.setContractFile(contractFileDto);
         ContractTerms contractTerms = contractTermsService.lambdaQuery()
-                .eq(ContractTerms::getContractNo, contractFile.getId()).one();
+                .eq(ContractTerms::getContractNo, contractFile.getContractNo()).one();
         ContractTermsDto contractTermsDto = salesDataConverter.convertContractTermsDto(contractTerms);
         List<ContractTermsExtend> contractTermsExtends = contractTermsExtendService.lambdaQuery()
                 .eq(ContractTermsExtend::getContractTermsId, contractTerms.getId()).list();
@@ -121,7 +121,7 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
                 .eq(ContractFile::getContractNo, salesContract.getContractNo()).eq(ContractFile::getDeleted, 0).one();
         contractFile.setDeleted(1);
         ContractTerms contractTerms = contractTermsService.lambdaQuery()
-                .eq(ContractTerms::getContractNo, contractFile.getId()).one();
+                .eq(ContractTerms::getContractNo, contractFile.getContractNo()).one();
         contractTerms.setDeleted(1);
         List<ContractTermsExtend> contractTermsExtends = contractTermsExtendService.lambdaQuery()
                 .eq(ContractTermsExtend::getContractTermsId, contractTerms.getId()).list();

+ 20 - 5
trade-service/src/main/java/com/trade/service/serialNum/service/impl/SerialNumberGeneratorImpl.java

@@ -19,9 +19,9 @@ public class SerialNumberGeneratorImpl implements SerialNumberGenerator {
     @Override
     @Transactional
     public String nextValue(String prefixType) {
-        //获取前置字符
+        // 获取前置字符
         String prefix = getCurrentPrefix(prefixType);
-        //获取当前数据库中对应SystemSerialNum
+        // 获取当前数据库中对应SystemSerialNum
         SystemSerialNum sysSerialNum = sysSerialNumService.getByName(prefix);
         if (null == sysSerialNum && StrUtil.isNotEmpty(prefixType)) {
             switch (prefixType) {
@@ -40,6 +40,12 @@ public class SerialNumberGeneratorImpl implements SerialNumberGenerator {
                 case ConstantUtil.IMPORTER_CODE:
                     sysSerialNum = sysSerialNumService.add(createInitialNo(prefix, "进口商编号"));
                     break;
+                case ConstantUtil.SALES_CONTRACT_NO_PREFIX:
+                    sysSerialNum = sysSerialNumService.add(createInitialNo(prefix, "销售合同编号"));
+                    break;
+                case ConstantUtil.PURCHASE_ORDER_NO_PREFIX:
+                    sysSerialNum = sysSerialNumService.add(createInitialNo(prefix, "采购订单编号"));
+                    break;
             }
         }
         if (null != sysSerialNum) {
@@ -58,6 +64,10 @@ public class SerialNumberGeneratorImpl implements SerialNumberGenerator {
                 case ConstantUtil.IMPORTER_CODE:
                     curNum = getCurNum(sysSerialNum, 3);
                     break;
+                case ConstantUtil.SALES_CONTRACT_NO_PREFIX:
+                case ConstantUtil.PURCHASE_ORDER_NO_PREFIX:
+                    curNum = getCurNum(sysSerialNum, 2);
+                    break;
             }
             if (StrUtil.isNotEmpty(curNum)) {
                 return prefix + curNum;
@@ -97,11 +107,16 @@ public class SerialNumberGeneratorImpl implements SerialNumberGenerator {
      */
     private String getCurrentPrefix(String prefixType) {
         if (StrUtil.isNotEmpty(prefixType)) {
-            if (prefixType.equals(ConstantUtil.ACCEPTANCE_SHEET_CODE) ||
-                    prefixType.equals(ConstantUtil.BILL_CODE) ||
-                    prefixType.equals(ConstantUtil.UNDERLYING_CODE)) {
+            if (prefixType.equals(ConstantUtil.ACCEPTANCE_SHEET_CODE) || prefixType.equals(ConstantUtil.BILL_CODE)
+                    || prefixType.equals(ConstantUtil.UNDERLYING_CODE)) {
                 return DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + prefixType;
             }
+            if (prefixType.equals(ConstantUtil.SALES_CONTRACT_NO_PREFIX)) {
+                return prefixType + DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMM);
+            }
+            if (prefixType.equals(ConstantUtil.PURCHASE_ORDER_NO_PREFIX)) {
+                return prefixType + DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS);
+            }
             return prefixType;
         }
         return "";