24282 2 rokov pred
rodič
commit
c76320fcde

+ 2 - 10
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/reportPrice/service/impl/ReportPriceBillFlowServiceImpl.java

@@ -16,11 +16,7 @@ import com.fjhx.reportPrice.entity.ReportPriceBill;
 import com.fjhx.reportPrice.entity.ReportPriceBillProduct;
 import com.fjhx.reportPrice.entity.ReportPriceBillProject;
 import com.fjhx.reportPrice.enums.ReportPriceBillStatusEnum;
-import com.fjhx.reportPrice.service.IReportPriceBillFlowService;
-import com.fjhx.reportPrice.service.IReportPriceBillPdfService;
-import com.fjhx.reportPrice.service.IReportPriceBillProductService;
-import com.fjhx.reportPrice.service.IReportPriceBillProjectService;
-import com.fjhx.reportPrice.service.IReportPriceBillService;
+import com.fjhx.reportPrice.service.*;
 import com.fjhx.utils.CodeRuleUtil;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -40,11 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.text.MessageFormat;
 import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * 报价单流程

+ 5 - 0
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/service/entity/po/ServiceContract.java

@@ -140,4 +140,9 @@ public class ServiceContract extends BasicsEntity {
      */
     private BigDecimal accountReceived;
 
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
 }

+ 6 - 0
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/service/entity/po/ServiceContractProduct.java

@@ -49,4 +49,10 @@ public class ServiceContractProduct extends BasicsEntity {
      * 备注
      */
     private String remark;
+
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
 }

+ 5 - 0
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/service/entity/po/ServiceContractRecord.java

@@ -44,4 +44,9 @@ public class ServiceContractRecord extends BasicsEntity {
      */
     private String remark;
 
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
 }

+ 4 - 2
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/service/service/impl/ServiceContractRecordServiceImpl.java

@@ -61,7 +61,10 @@ public class ServiceContractRecordServiceImpl extends BasicsServiceImpl<ServiceC
             serviceContractRecordIdList.add(record.getId());
         }
 
+        // 附件map
         Map<String, List<Attachment>> attachmentMap = iAttachmentApi.getByBusiIdsToMap(new ArrayList<>(serviceContractRecordIdList));
+
+        // 用户map
         Map<String, User> userMap = iUserClient.userInfoByIdsToMap(new ArrayList<>(userIdSet));
 
         for (ServiceContractRecordVo record : records) {
@@ -71,8 +74,7 @@ public class ServiceContractRecordServiceImpl extends BasicsServiceImpl<ServiceC
             // 赋值服务人员
             StringJoiner userNameJoiner = new StringJoiner(",");
             String serviceUser = record.getServiceUser();
-            String[] split = serviceUser.split(",");
-            for (String userId : split) {
+            for (String userId : serviceUser.split(",")) {
                 User user = userMap.get(userId);
                 if (user == null) {
                     continue;

+ 27 - 8
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/service/service/impl/ServiceContractServiceImpl.java

@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -116,20 +117,21 @@ public class ServiceContractServiceImpl extends BasicsServiceImpl<ServiceContrac
         serviceContractVo.setAccountReceived(BigDecimal.ZERO);
         save(serviceContractVo);
 
-        List<? extends ServiceContractProduct> serviceContractProductList = serviceContractVo.getServiceContractProductList();
-        if (ObjectUtil.isNotEmpty(serviceContractProductList)) {
-            return;
-        }
-        for (ServiceContractProduct serviceContractProduct : serviceContractProductList) {
-            serviceContractProduct.setServiceContractId(serviceContractVo.getId());
-        }
-        serviceContractProductService.saveBatch(BeanUtil.copyToList(serviceContractProductList, ServiceContractProduct.class));
+        // 保存服务合同产品关联
+        saveServiceContractProduct(serviceContractVo);
     }
 
     @Override
     public void edit(ServiceContractVo serviceContractVo) {
         serviceContractVo.setUpdate();
         updateById(serviceContractVo);
+
+        // 删除原服务合同产品关联
+        serviceContractProductService.remove(Wrappers.<ServiceContractProduct>lambdaQuery()
+                .eq(ServiceContractProduct::getServiceContractId, serviceContractVo.getId()));
+
+        // 保存服务合同产品关联
+        saveServiceContractProduct(serviceContractVo);
     }
 
     @Override
@@ -164,10 +166,27 @@ public class ServiceContractServiceImpl extends BasicsServiceImpl<ServiceContrac
     }
 
     /**
+     * 保存服务合同产品关联
+     */
+    private void saveServiceContractProduct(ServiceContractVo serviceContractVo) {
+        List<? extends ServiceContractProduct> serviceContractProductList = serviceContractVo.getServiceContractProductList();
+        if (ObjectUtil.isEmpty(serviceContractProductList)) {
+            return;
+        }
+        for (ServiceContractProduct serviceContractProduct : serviceContractProductList) {
+            serviceContractProduct.setServiceContractId(serviceContractVo.getId());
+        }
+        serviceContractProductService.saveBatch(BeanUtil.copyToList(serviceContractProductList, ServiceContractProduct.class));
+    }
+
+    /**
      * 获取产品map
      */
     private Map<String, Product> getProductMapByProductId(List<ServiceContractProductVo> serviceContractVos) {
         List<String> productIdList = serviceContractVos.stream().map(ServiceContractProduct::getProductId).collect(Collectors.toList());
+        if (productIdList.size() == 0) {
+            return new HashMap<>();
+        }
         List<Product> productList = productService.listByIds(productIdList);
 
         // 获取主图

+ 24 - 30
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/utils/CodeRuleUtil.java

@@ -18,7 +18,6 @@ import com.fjhx.purchase.service.IPurchaseContractService;
 import com.fjhx.reportPrice.service.IReportPriceBillService;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springblade.core.redis.lock.RedisLockClient;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.SpringUtil;
@@ -74,7 +73,7 @@ public class CodeRuleUtil {
      * @return
      */
     public static String getCode(int codeRuleType, String customerId, String productId, String countryId) {
-        String code = "";
+        StringBuilder code = new StringBuilder();
 
         //获取编码配置规则信息
         CodeRule rule = iCodeRuleApi.getCodeRule(codeRuleType);
@@ -95,19 +94,19 @@ public class CodeRuleUtil {
             Integer key = cr.getInteger("key");
             //年份编号
             if (key == CodeRuleEnum.CODE_RULE_1.getKey()) {
-                code += new SimpleDateFormat("yy").format(new Date());
+                code.append(new SimpleDateFormat("yy").format(new Date()));
                 continue;
             }
             //业务代码
             if (key == CodeRuleEnum.CODE_RULE_2.getKey()) {
-                code += Optional.ofNullable(cr.getString("value")).orElse("");
+                code.append(Optional.ofNullable(cr.getString("value")).orElse(""));
                 continue;
             }
             //国家代码
             if (key == CodeRuleEnum.CODE_RULE_3.getKey()) {
                 City city = iCityApi.getOneById(countryId);
                 if (Func.isNotEmpty(city)) {
-                    code += Optional.ofNullable(city.getEnglishShort()).orElse("");
+                    code.append(Optional.ofNullable(city.getEnglishShort()).orElse(""));
                 }
                 continue;
             }
@@ -115,7 +114,7 @@ public class CodeRuleUtil {
             if (key == CodeRuleEnum.CODE_RULE_4.getKey()) {
                 User user = iUserClient.getDetails(AuthUtil.getUserId());
                 if (Func.isNotEmpty(user)) {
-                    code += Optional.ofNullable(user.getDmCode()).orElse("");
+                    code.append(Optional.ofNullable(user.getDmCode()).orElse(""));
                 }
                 continue;
             }
@@ -123,7 +122,7 @@ public class CodeRuleUtil {
             if (key == CodeRuleEnum.CODE_RULE_5.getKey()) {
                 Customer customer = iCustomerApi.getCustomerById(customerId);
                 if (Func.isNotEmpty(customer)) {
-                    code += Optional.ofNullable(customer.getDmCode()).orElse("");
+                    code.append(Optional.ofNullable(customer.getDmCode()).orElse(""));
                 }
                 continue;
             }
@@ -131,26 +130,24 @@ public class CodeRuleUtil {
             if (key == CodeRuleEnum.CODE_RULE_6.getKey()) {
                 Product product = iProductService.getById(productId);
                 if (Func.isNotEmpty(product)) {
-                    code += Optional.ofNullable(product.getDmCode()).orElse("");
+                    code.append(Optional.ofNullable(product.getDmCode()).orElse(""));
                 }
                 continue;
             }
             //自增总编号
             if (key == CodeRuleEnum.CODE_RULE_7.getKey()) {
-                //总编号当前值
-                String codeCurrentValue = Optional.ofNullable(String.valueOf(rule.getCodeCurrentValue())).orElse("1");
-                //总编号长度
+                // 总编号当前值
+                StringBuilder codeCurrentValue = new StringBuilder(Optional.ofNullable(String.valueOf(rule.getCodeCurrentValue())).orElse("1"));
+                // 总编号长度
                 int value = Optional.ofNullable(cr.getInteger("value")).orElse(0);
                 if (codeCurrentValue.length() < value) {
-                    //进行补位
+                    // 进行补位
                     int complementLength = value - codeCurrentValue.length();
-                    if (complementLength > 0) {
-                        for (int i = 0; i < complementLength; i++) {
-                            codeCurrentValue = "0" + codeCurrentValue;
-                        }
+                    for (int i = 0; i < complementLength; i++) {
+                        codeCurrentValue.insert(0, "0");
                     }
                 }
-                code += codeCurrentValue;
+                code.append(codeCurrentValue);
                 continue;
             }
             //自增自编号
@@ -174,36 +171,33 @@ public class CodeRuleUtil {
                 if (codeRuleType == CodeRuleTypeEnum.CODE_RULE_TYPE_4.getKey()) {
                     count = iPurchaseContractService.getCount(prefixCode, countryId, customerId, productId);
                 }
-                //步长1
+                // 步长1
                 count++;
-                String countStr = String.valueOf(count);
-                //子编号长度
+                StringBuilder countStr = new StringBuilder(String.valueOf(count));
+                // 子编号长度
                 int value = Optional.ofNullable(cr.getInteger("value")).orElse(0);
                 if (countStr.length() < value) {
-                    //进行补位
+                    // 进行补位
                     int complementLength = value - countStr.length();
-                    if (complementLength > 0) {
-                        for (int i = 0; i < complementLength; i++) {
-                            countStr = "0" + countStr;
-                        }
+                    for (int i = 0; i < complementLength; i++) {
+                        countStr.insert(0, "0");
                     }
                 }
-                code += countStr;
+                code.append(countStr);
                 continue;
             }
             //间隔符
             if (key == CodeRuleEnum.CODE_RULE_9.getKey()) {
-                code += Optional.ofNullable(cr.getString("value")).orElse("");
-                continue;
+                code.append(Optional.ofNullable(cr.getString("value")).orElse(""));
             }
         }
 
         //自增总编号+1
-        if (StringUtils.isNotBlank(code)) {
+        if (StringUtils.isNotBlank(code.toString())) {
             iCodeRuleApi.updateCodeCurrentValueById(rule.getId());
         }
 
-        return code;
+        return code.toString();
     }
     /**
      * 获取分布式锁key