24282 2 vuotta sitten
vanhempi
commit
2ce946379d

+ 56 - 0
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/product/controller/ProductAssessmentControllerV2.java

@@ -0,0 +1,56 @@
+package com.fjhx.product.controller;
+
+import com.fjhx.activiti.SubmitFlowCondition;
+import com.fjhx.flow.params.FlowVo;
+import com.fjhx.product.entity.Product;
+import com.fjhx.product.service.IProductAssessmentService;
+import org.springblade.common.constant.ApiConstant;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 生产评估
+ */
+@RestController
+@RequestMapping(ApiConstant.Project.SAAS_BUSINESS_TRADEERP_REQUEST_PREFIX + "/product/assessmentV2")
+public class ProductAssessmentControllerV2 extends BladeController {
+
+    @Autowired
+    private IProductAssessmentService iProductAssessmentService;
+
+    /**
+     * 提交生效
+     *
+     * @param product
+     */
+    @PostMapping("/success")
+    public R success(@RequestBody Product product) {
+        iProductAssessmentService.success(product);
+        return R.success();
+    }
+
+    /**
+     * 开始流程
+     *
+     * @param product
+     */
+    @PostMapping("/start")
+    public R start(@RequestBody Product product) {
+        iProductAssessmentService.startV2(product);
+        return R.success();
+    }
+
+
+    @PostMapping("/jump")
+    public R jump(@RequestBody Product product) {
+        iProductAssessmentService.jumpV2(product);
+        return R.success();
+    }
+
+
+}

+ 5 - 0
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/product/service/IProductAssessmentService.java

@@ -1,6 +1,7 @@
 package com.fjhx.product.service;
 
 import com.fjhx.activiti.SubmitFlowCondition;
+import com.fjhx.flow.params.FlowVo;
 import com.fjhx.product.entity.Product;
 
 /**
@@ -43,4 +44,8 @@ public interface IProductAssessmentService {
      */
     void reject(SubmitFlowCondition condition);
 
+    void startV2(Product product);
+
+    void jumpV2( Product product);
+
 }

+ 75 - 1
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/product/service/impl/ProductAssessmentServiceImpl.java

@@ -1,16 +1,21 @@
 package com.fjhx.product.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.fjhx.activiti.ProcessTaskReferBuilder;
 import com.fjhx.activiti.ProcessTaskResult;
 import com.fjhx.activiti.SubmitFlowCondition;
 import com.fjhx.activiti.feign.IActivitiApi;
 import com.fjhx.common.attachment.IAttachmentApi;
+import com.fjhx.flow.params.FlowVo;
+import com.fjhx.message.enums.MessageNoticeEnum;
 import com.fjhx.product.constant.ProductConstant;
 import com.fjhx.product.entity.Product;
 import com.fjhx.product.enums.ProductAssessStatusEnum;
 import com.fjhx.product.service.IProductAssessmentService;
 import com.fjhx.product.service.IProductService;
+import com.fjhx.utils.ExampleAbstract;
+import com.fjhx.utils.FlowConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springblade.common.constant.ActivitiConstant;
@@ -259,6 +264,75 @@ public class ProductAssessmentServiceImpl implements IProductAssessmentService {
         iProductService.update(updateWrapper);
     }
 
+    private FlowConstructor flowConstructor() {
+        return FlowConstructor.init(
+                new ExampleAbstract() {
+                    @Override
+                    public String getCode() {
+                        return MessageNoticeEnum.MESSAGE_NOTICE_TYPE_32.getValue();
+                    }
+
+                    /**
+                     * 结束
+                     *  @param flowLinkNo    流程关联编码
+                     */
+                    @Transactional(rollbackFor = {Exception.class})
+                    @Override
+                    public void end(String flowLinkNo) {
+                        Long productId = getCacheData(Long.class);
+                        Product product = iProductService.getById(productId);
+                        // 流程状态,0:具备、1:不具备
+                        if (StringUtils.equals(product.getFlowStatus(), "0")) {
+                            product.setAssessStatus(ProductAssessStatusEnum.HAVE.getKey());
+                        } else {
+                            product.setAssessStatus(ProductAssessStatusEnum.UN_HAVE.getKey());
+                        }
+
+                        // 审核通过时间
+                        product.setApprovedDate(new Date());
+                        iProductService.updateById(product);
+                    }
+
+
+                }
+        );
+    }
+
+    @Override
+    public void startV2(Product product) {
+        // 租户id
+        product.setTenantId(AuthUtil.getTenantId());
+        // 来源=生产评估
+        product.setSource(ProductConstant.Source.PRODUCTION_ASSESS);
+        // 评估状态=待评估
+        product.setAssessStatus(ProductAssessStatusEnum.UN_ASSESS.getKey());
+
+        if (StringUtils.isBlank(product.getId())) {
+            // 保存产品
+            iProductService.save(product);
+            // 保存附件
+            if (CollectionUtils.isNotEmpty(product.getAttachments())) {
+                for (Attachment attachment : product.getAttachments()) {
+                    // 关联业务id=产品id
+                    attachment.setBusiId(product.getId());
+                }
+                attachmentApi.batchInsert(product.getAttachments());
+            }
+        } else {
+            // 修改产品
+            iProductService.updateProductById(product);
+        }
+        String title = AuthUtil.getUserName() + " 在" + LocalDate.now() + "日发起了 生产评估流程";
+        flowConstructor().create(product.getId(), title, null, product.getId());
+    }
+
+    @Override
+    public void jumpV2(Product product) {
+        iProductService.updateById(product);
+        FlowVo flowVo = BeanUtil.toBean(product, FlowVo.class);
+        flowConstructor().jump(flowVo);
+    }
+
     /**
      * 启动流程
      *
@@ -267,7 +341,7 @@ public class ProductAssessmentServiceImpl implements IProductAssessmentService {
      */
     private ProcessTaskResult startUpFlow(Product product) {
         if (StringUtils.isBlank(product.getId())) {
-            //如果是新增,清空流程字段,防止复制时有值
+            // 如果是新增,清空流程字段,防止复制时有值
             product.setProcessInstanceId(null);
             product.setProcessInstanceName(null);
             product.setProcessInstanceUserId(null);

+ 8 - 3
bladex-saas-project/saas-business-tradeerp/src/main/java/com/fjhx/purchase/service/impl/PurchaseContractPdfServiceImpl.java

@@ -172,11 +172,14 @@ public class PurchaseContractPdfServiceImpl implements IPurchaseContractPdfServi
             throw new ServiceException("生成采购合同PDF文件失败:采购合同不存在");
         }
         if (StringUtils.isNotBlank(purchaseContract.getRemark())) {
-            //内容特殊符号转义
+            // 内容特殊符号转义
             String remark = purchaseContract.getRemark();
-            remark = remark.replaceAll("<", "<").replaceAll(">", ">").replaceAll(" ", "");
+            remark = remark
+                    .replaceAll("<", "<")
+                    .replaceAll(">", ">")
+                    .replaceAll(" ", "");
             remark = remark.replaceAll(""", "'");
-            //富文本内容每隔n位追加符号
+            // 富文本内容每隔n位追加符号
             remark = CommonUtil.nodeTextAppendBR(remark, text_row_symbol, text_row_count);
             remark = remark.replaceAll("</", purchaseContract.getCode() + "</");
             // 标签过滤
@@ -247,6 +250,8 @@ public class PurchaseContractPdfServiceImpl implements IPurchaseContractPdfServi
                     Map<String, List<PurchaseContractProduct>> accessoriesMap = accessories.stream().collect(Collectors.groupingBy(PurchaseContractProduct::getParentId));
                     if (MapUtils.isNotEmpty(accessoriesMap) && CollectionUtils.isNotEmpty(accessoriesMap.get(tempProduct.getId()))) {
                         newProducts.addAll(accessoriesMap.get(tempProduct.getId()));
+                    } else if (MapUtils.isNotEmpty(accessoriesMap) && CollectionUtils.isNotEmpty(accessoriesMap.get(tempProduct.getContractProductId()))) {
+                        newProducts.addAll(accessoriesMap.get(tempProduct.getContractProductId()));
                     }
                 }
             }

+ 53 - 57
bladex-saas-project/saas-customer/src/main/java/com/fjhx/customer/service/impl/CustomerServiceImpl.java

@@ -13,13 +13,7 @@ import com.fjhx.customer.lable.entity.CustomerCompanyLabel;
 import com.fjhx.customer.lable.entity.CustomerLabel;
 import com.fjhx.customer.level.entity.CustomerLevel;
 import com.fjhx.customer.mapper.CustomerMapper;
-import com.fjhx.customer.service.ICustomerCompanyLabelService;
-import com.fjhx.customer.service.ICustomerContactsService;
-import com.fjhx.customer.service.ICustomerFollowLogService;
-import com.fjhx.customer.service.ICustomerGroupService;
-import com.fjhx.customer.service.ICustomerLabelService;
-import com.fjhx.customer.service.ICustomerLevelService;
-import com.fjhx.customer.service.ICustomerService;
+import com.fjhx.customer.service.*;
 import com.fjhx.customer.starmark.entity.CustomerStarMark;
 import com.fjhx.excel.CustomerDuplicateCheckExcel;
 import com.fjhx.excel.CustomerExcel;
@@ -52,12 +46,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -180,59 +169,66 @@ public class CustomerServiceImpl extends BasicsServiceImpl<CustomerMapper, Custo
     @Transactional(rollbackFor = {Exception.class})
     @Override
     public String insert(Customer customer) {
-        //如果是从邮箱页面新增客户
-        if (customer == null || (customer.getAddType() != null && customer.getAddType() == mail_list_add)
-                && customer.getIsCustomer() == null) {
-            throw new ServiceException("参数缺失");
-        }
-        //是否客户 0=非客户 1=客户
-        if (customer.getIsCustomer() != 0 && customer.getIsCustomer() != 1) {
-            throw new ServiceException("参数格式错误");
-        }
-
-        if (customer.getIsCustomer() == 1 && StringUtils.isBlank(customer.getUserMailbox())) {
-            customer.setUserMailbox("0");
-            customer.setUserId("0");
-        } else if (customer.getIsCustomer() == 1 && StringUtils.isNotBlank(customer.getUserMailbox())) {
-            //客户所述业务员ID=登录账号ID
-            customer.setUserId(AuthUtil.getUserIdStr());
-        } else if (customer.getIsCustomer() == 0) {
-            //非客户不设置客户所属业务员信息
-            customer.setUserId("0");
-            customer.setUserMailbox("0");
-        }
-
-        //如果是从客户管理页面新增客户
+        // 如果是从邮箱页面新增客户
+        // if (customer == null || (customer.getAddType() != null && customer.getAddType() == mail_list_add)
+        //         && customer.getIsCustomer() == null) {
+        //     throw new ServiceException("参数缺失");
+        // }
+        // 是否客户 0=非客户 1=客户
+        // if (customer.getIsCustomer() != 0 && customer.getIsCustomer() != 1) {
+        //     throw new ServiceException("参数格式错误");
+        // }
+
+        // if (customer.getIsCustomer() == 1 && StringUtils.isBlank(customer.getUserMailbox())) {
+        //     customer.setUserMailbox("0");
+        //     customer.setUserId("0");
+        // } else if (customer.getIsCustomer() == 1 && StringUtils.isNotBlank(customer.getUserMailbox())) {
+        //     //客户所述业务员ID=登录账号ID
+        //     customer.setUserId(AuthUtil.getUserIdStr());
+        // } else if (customer.getIsCustomer() == 0) {
+        //     //非客户不设置客户所属业务员信息
+        //     customer.setUserId("0");
+        //     customer.setUserMailbox("0");
+        // }
+
+        customer.setUserId(AuthUtil.getUserIdStr());
+        String userMailbox = customer.getUserMailbox();
+        if (StringUtils.isBlank(userMailbox)) {
+            throw new ServiceException("未绑定邮箱,请联系管理员");
+        }
+        customer.setUserMailbox(userMailbox);
+
+        // 如果是从客户管理页面新增客户
         if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
-            //判断公司名称是否重复(去除所有空格)
+            // 判断公司名称是否重复(去除所有空格)
             boolean exist = getCorporateNameIsExist(null, customer.getCorporateName());
             if (exist) {
                 throw new ServiceException("公司名称已存在");
             }
         }
-        //多个连续空格替换为一个空格,并去除前后空格
+        // 多个连续空格替换为一个空格,并去除前后空格
         customer.setCorporateName(customer.getCorporateName().trim().replaceAll(" +", " "));
         // 表名
         customer.setTableName(Customer.getTableName(AuthUtil.getTenantId()));
 
-        if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
-            //=================从客户管理列表新增客户=================
-            // 查询当前登入人的邮箱
-            List<Mailbox> mailboxes = iMailboxApi.getByUserId(AuthUtil.getUserIdStr());
-            if (CollectionUtils.isNotEmpty(mailboxes)) {
-                //获取出默认邮箱
-                List<Mailbox> defaults = mailboxes.stream().filter(obj -> obj.getIsDefault() == 1).collect(Collectors.toList());
-                if (CollectionUtils.isNotEmpty(defaults)) {
-                    //如果有存在默认邮箱
-                    Mailbox mailbox = defaults.get(0);
-                    customer.setUserMailbox(mailbox.getMailboxName());
-                } else {
-                    //如果不存在默认邮箱,随机取一条
-                    Mailbox mailbox = mailboxes.get(0);
-                    customer.setUserMailbox(mailbox.getMailboxName());
-                }
-            }
-        }
+        // if (customer.getAddType() != null && customer.getAddType() == customer_list_add) {
+        //     //=================从客户管理列表新增客户=================
+        //     // 查询当前登入人的邮箱
+        //     List<Mailbox> mailboxes = iMailboxApi.getByUserId(AuthUtil.getUserIdStr());
+        //     if (CollectionUtils.isNotEmpty(mailboxes)) {
+        //         //获取出默认邮箱
+        //         List<Mailbox> defaults = mailboxes.stream().filter(obj -> obj.getIsDefault() == 1).collect(Collectors.toList());
+        //         if (CollectionUtils.isNotEmpty(defaults)) {
+        //             //如果有存在默认邮箱
+        //             Mailbox mailbox = defaults.get(0);
+        //             customer.setUserMailbox(mailbox.getMailboxName());
+        //         } else {
+        //             //如果不存在默认邮箱,随机取一条
+        //             Mailbox mailbox = mailboxes.get(0);
+        //             customer.setUserMailbox(mailbox.getMailboxName());
+        //         }
+        //     }
+        // }
 
         // 分组如果为空默认为0
         if (StringUtils.isBlank(customer.getGroupId())) {
@@ -242,7 +238,7 @@ public class CustomerServiceImpl extends BasicsServiceImpl<CustomerMapper, Custo
 
         customer.setId(IdUtils.fastSimpleUUID());
 
-        //异常状态=正常
+        // 异常状态=正常
         customer.setAbnormalStatus(CustomerAbnormalStatusEnum.ABNORMAL_STATUS_NORMAL.getKey());
         //最后互动时间=当前时间
         customer.setLastInteractionTime(now);

+ 5 - 3
bladex-saas-project/saas-entity/src/main/java/com/fjhx/flow/params/FlowVo.java

@@ -8,16 +8,18 @@ public class FlowVo {
     /**
      * 流程关联编号
      */
-    String flowLinkNo;
+    private String flowLinkNo;
 
     /**
      * 按钮id
      */
-    Long buttonId;
+    private Long buttonId;
 
     /**
      * 审批意见
      */
-    String remarks;
+    private String remarks;
+
+    private Integer status;
 
 }

+ 2 - 0
bladex-saas-project/saas-entity/src/main/java/com/fjhx/message/enums/MessageNoticeEnum.java

@@ -44,6 +44,8 @@ public enum MessageNoticeEnum {
     MESSAGE_NOTICE_TYPE_30(30, "FUNDS_EHSD4"), // ERP 请款审批
 
     MESSAGE_NOTICE_TYPE_31(31, "ALTERATION_PURCHASE_CONTRACT"), // 采购合同变更
+
+    MESSAGE_NOTICE_TYPE_32(32, "PRODUCTION_EVALUATION"), // 生产评估
     ;
 
     private int key;

+ 18 - 0
bladex-saas-project/saas-entity/src/main/java/com/fjhx/product/entity/Product.java

@@ -356,4 +356,22 @@ public class Product extends BasicsEntity {
     @TableField(exist = false)
     private String flowRemark;
 
+    /**
+     * 流程关联编号
+     */
+    @TableField(exist = false)
+    private String flowLinkNo;
+
+    /**
+     * 按钮id
+     */
+    @TableField(exist = false)
+    private Long buttonId;
+
+    /**
+     * 审批意见
+     */
+    @TableField(exist = false)
+    private String remarks;
+
 }

+ 3 - 7
bladex-saas-project/saas-mail/src/main/java/com/fjhx/mail/box/service/impl/MailboxServiceImpl.java

@@ -25,12 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -440,7 +435,8 @@ public class MailboxServiceImpl extends BasicsServiceImpl<MailboxMapper, Mailbox
     @Override
     public List<Mailbox> getByUserIdATenantId(String userId) {
         QueryWrapper<Mailbox> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("user_id", userId).eq("tenant_id", AuthUtil.getTenantId()).eq("status", 0);
+        queryWrapper.eq("user_id", userId)
+                .eq("tenant_id", AuthUtil.getTenantId());
         return this.list(queryWrapper);
     }