瀏覽代碼

大中型优化5(报告取号,退回逻辑)

wucl 1 年之前
父節點
當前提交
70d1c0dd17

+ 14 - 0
biz-base/src/main/java/com/dayou/controller/WorkFlowNodeInstanceController.java

@@ -128,5 +128,19 @@ public class WorkFlowNodeInstanceController extends BaseController {
         Boolean ret = workFlowNodeInstanceService.activateInstanceNode(id);
         return RestResponse.data(ret);
     }
+
+    /**
+     * 检查当前是否可退回节点
+     * @param productionType
+     * @param productionNo
+     * @return
+     */
+    @GetMapping("/checkIfReverse/{productionType}/{productionNo}")
+    public RestResponse<Boolean> checkIfReverse(@PathVariable("productionType") String productionType, @PathVariable("productionNo") String productionNo){
+        Boolean ret = workFlowNodeInstanceService.checkIfReverse(productionType,productionNo);
+        return RestResponse.data(ret);
+    }
+
+
 }
 

+ 2 - 0
dao/src/main/java/com/dayou/mapper/MajorProductionMapper.java

@@ -7,6 +7,7 @@ import com.dayou.vo.*;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -43,4 +44,5 @@ public interface MajorProductionMapper extends CustomBaseMapper<MajorProduction>
     void cancelDelivery(@Param("businessId")Long businessId, @Param("businessSubId")String businessSubId, @Param("productionType")String productionType );
 
     MajorProductionVO getMajorProductionById(@Param("productionId") Long productionId);
+
 }

+ 5 - 4
dao/src/main/java/com/dayou/mapper/MajorTargetMapper.java

@@ -6,6 +6,7 @@ import com.dayou.vo.IdNameVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -29,11 +30,11 @@ public interface MajorTargetMapper extends CustomBaseMapper<MajorTarget> {
 
     void updateMainLetterNo(@Param("mainNumber") String mainNumber, @Param("businessId")Long businessId);
 
-    void cleanSubReportNo(@Param("businessId") Long businessId);
+    List<MajorTarget> getSubReportNo(@Param("businessId")Long businessId);
 
-    void xCleanSubReportNo(@Param("businessId") Long businessId,@Param("businessSubId") String businessSubId);
-
-    List<String> getSubReportNo(@Param("businessId")Long businessId);
+    void cleanSubStatementNo(@Param("set") Set<String> statementNos);
 
+    void cleanSubReportNo(@Param("set") Set<String> reportNos);
 
+    void cleanSubLetterNo(@Param("set") Set<String> letterNos);
 }

+ 2 - 0
dao/src/main/java/com/dayou/mapper/WorkFlowNodeInstanceMapper.java

@@ -29,4 +29,6 @@ public interface WorkFlowNodeInstanceMapper extends CustomBaseMapper<WorkFlowNod
     void batchCommitNode(@Param("currentNodeIds") List<Long> currentNodeIds);
 
     List<NightingaleEchartsVO> instanceNodeCountByCode(@Param("businessType") String businessType);
+
+    List<String> checkIfReverse(@Param("productionType")String productionType, @Param("productionNo")String productionNo);
 }

+ 27 - 3
dao/src/main/resources/mapper/MajorTargetMapper.xml

@@ -32,7 +32,7 @@
         update major_target set statement_no = #{mainNumber} where major_id = #{businessId} and deleted = 0;
     </update>
 
-    <update id="cleanSubReportNo">
+    <update id="cleanSubReportNoByBusinessId">
         update major_target set report_no = null where major_id = #{businessId} and deleted = 0;
     </update>
 
@@ -40,7 +40,31 @@
         update major_target set report_no = null where major_id = #{businessId} and report_no = #{businessSubId} and deleted = 0;
     </update>
 
-    <select id="getSubReportNo" parameterType="java.lang.Long" resultType="java.lang.String">
-        select distinct report_no from major_target where major_id = #{businessId} and deleted = 0 and report_no is not null
+    <select id="getSubReportNo" parameterType="java.lang.Long" resultType="com.dayou.entity.MajorTarget">
+        select statement_no,report_no , letter_no from major_target where major_id = #{businessId} and deleted = 0
     </select>
+
+    <update id="cleanSubStatementNo" parameterType="java.util.Set">
+        update  major_target set statement_no = null where statement_no in (
+            <foreach collection="set" item="item" index="index" separator=",">
+                #{item}
+            </foreach>
+            )
+    </update>
+
+    <update id="cleanSubReportNo" parameterType="java.util.Set">
+        update  major_target set report_no = null where report_no in (
+        <foreach collection="set" item="item" index="index" separator=",">
+            #{item}
+        </foreach>
+        )
+    </update>
+
+    <update id="cleanSubLetterNo" parameterType="java.util.Set">
+        update  major_target set letter_no = null where letter_no in (
+        <foreach collection="set" item="item" index="index" separator=",">
+            #{item}
+        </foreach>
+        )
+    </update>
 </mapper>

+ 17 - 0
dao/src/main/resources/mapper/WorkFlowNodeInstanceMapper.xml

@@ -188,4 +188,21 @@
         ORDER BY
             t.num ASC
     </select>
+
+    <select id="checkIfReverse" resultType="java.lang.String">
+        SELECT
+            distinct wn.CODE
+        FROM
+            work_flow_node_instance wfi
+                LEFT JOIN work_node wn ON wn.id = wfi.node_id
+        WHERE
+            wfi.deleted = 0
+          AND wn.deleted = 0
+        <if test="productionType!=null and productionType!='' and productionType=='STATEMENT'">
+            AND wfi.business_sub_id like concat ('%',#{productionNo},'%')
+        </if>
+        <if test="productionType!=null and productionType!='' and productionType!='STATEMENT'">
+            AND wfi.business_min_id like concat ('%',#{productionNo},'%')
+        </if>
+    </select>
 </mapper>

+ 4 - 1
domain/src/main/java/com/dayou/entity/MajorProduction.java

@@ -236,5 +236,8 @@ public class MajorProduction extends BaseEntity {
     private BigDecimal realAmount;
     @TableField(exist = false)
     private String afterProduction;
-
+    @TableField(exist = false)
+    private Boolean ifReverse;
+    @TableField(exist = false)
+    private String statementNo;
 }

+ 2 - 2
service/src/main/java/com/dayou/service/IBusinessNumberService.java

@@ -64,7 +64,7 @@ public interface IBusinessNumberService extends IService<BusinessNumber> {
     List<IdNameVO> takeStatementSubNumber(String orderId, TakeNumberEnum takeNumberEnum,String mainNumber,List<IdNameVO> targets );
 
     /**
-     * 取复评函主号(大中型)
+     * 取复评函主号(大中型)
      * @param orderId
      * @param takeNumberEnum
      * @return
@@ -72,7 +72,7 @@ public interface IBusinessNumberService extends IService<BusinessNumber> {
     String takeLetterMainNumber(String orderId, TakeNumberEnum takeNumberEnum);
 
     /**
-     * 取复评函子号(大中型)
+     * 取复评函子号(大中型)
      * @param orderId
      * @param takeNumberEnum
      * @param mainNumber

+ 32 - 38
service/src/main/java/com/dayou/service/impl/MajorProductionServiceImpl.java

@@ -2,6 +2,7 @@ package com.dayou.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,6 +18,7 @@ import com.dayou.mapper.*;
 import com.dayou.message.annotation.SendMessage;
 import com.dayou.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.service.workflow.IWorkFlowNodeInstanceService;
 import com.dayou.utils.LoginContext;
 import com.dayou.vo.*;
 import lombok.extern.slf4j.Slf4j;
@@ -97,15 +99,25 @@ public class MajorProductionServiceImpl extends ServiceImpl<MajorProductionMappe
     @Autowired
     private IOrderFundAllotService orderFundAllotService;
 
+    @Autowired
+    private IWorkFlowNodeInstanceService workFlowNodeInstanceService;
+
 
 
     @Override
     @SuppressWarnings("unchecked")
     public List<MajorProduction> selectPage(MajorProduction majorProduction){
         List<MajorProduction> list = majorProductionMapper.getList(majorProduction);
-        list.stream().forEach(x->{
-            x.setSignatoryId(JSON.parseArray(x.getSignatory(),Long.class));
-        });
+        if(CollectionUtils.isNotEmpty(list)){
+            MajorProduction production = list.get(0);
+            String reportNo = production.getReportNo();
+            String productionType = production.getProduction();
+            Boolean ifReverse = workFlowNodeInstanceService.checkIfReverse(productionType, reportNo);
+            list.stream().forEach(x->{
+                x.setSignatoryId(JSON.parseArray(x.getSignatory(),Long.class));
+                x.setIfReverse(ifReverse);
+            });
+        }
         return list;
     }
 
@@ -118,45 +130,27 @@ public class MajorProductionServiceImpl extends ServiceImpl<MajorProductionMappe
     @Override
     public Boolean add(MajorProduction taskData){
         String reportNo = taskData.getReportNo();
+        String statementNo = taskData.getStatementNo();
         Long majorId = taskData.getMajorId();
-        //查询生成过该报告的产品信息
-        List<MajorProduction> list = this.list(new LambdaQueryWrapper<MajorProduction>().eq(MajorProduction::getMajorId, majorId).eq(MajorProduction::getReportNo, reportNo).eq(BaseEntity::getDeleted, Boolean.FALSE));
-        if (CollectionUtil.isNotEmpty(list)){
-            List<MajorProduction> ifExist = list.stream().filter(x -> x.getProduction().equals(taskData.getProduction())).collect(Collectors.toList());
-            if (CollectionUtil.isNotEmpty(ifExist)){
-                ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,ProductionEnum.valueOf(taskData.getProduction()).getMsg() + "类型产品已存在,请完善产品信息。");
-            }
-            MajorProduction production = list.get(0);
-            if (production!=null){
-                taskData.setName(production.getName());
-                taskData.setClientName(production.getClientName());
-                taskData.setClientTel(production.getClientTel());
-                taskData.setClientAddress(production.getClientAddress());
-                taskData.setOwner(production.getOwner());
-                taskData.setValueTiming(production.getValueTiming());
-                taskData.setEvaluateAcreage(production.getEvaluateAcreage());
-                taskData.setEvaluatePrice(production.getEvaluatePrice());
-                taskData.setEvaluateAmount(production.getEvaluateAmount());
-                Major major = majorService.getOne(new LambdaQueryWrapper<Major>().eq(BaseEntity::getId, production.getMajorId())
-                        .select(BaseEntity::getId, Major::getEvaluateAim));
-                //抵押类是否需要复审和三审逻辑 ?
-                if (major.getEvaluateAim().equals(PLEDGE)){
-                    BigDecimal evaluateAmount = production.getEvaluateAmount();
-                    if (evaluateAmount.compareTo(EVALUATE_MIN)<=0){
-                        taskData.setSecondCheck(ReportStatus.不审.name());
-                        taskData.setThirdCheck(ReportStatus.不审.name());
-                    }
-                    if (evaluateAmount.compareTo(EVALUATE_MIN)>0 && evaluateAmount.compareTo(EVALUATE_MAX)<=0){
-                        taskData.setSecondCheck(ReportStatus.待审核.name());
-                        taskData.setThirdCheck(ReportStatus.不审.name());
-                    }
-                    if (evaluateAmount.compareTo(EVALUATE_MAX)>0){
-                        taskData.setSecondCheck(ReportStatus.待审核.name());
-                        taskData.setThirdCheck(ReportStatus.待审核.name());
-                    }
+        //查询是否生成过该报告的产品
+        MajorProduction prod = this.getOne(new LambdaQueryWrapper<MajorProduction>().eq(MajorProduction::getReportNo, reportNo)
+                .eq(MajorProduction::getMajorId, majorId).eq(BaseEntity::getDeleted, Boolean.FALSE));
+        if (prod!=null){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,ProductionEnum.valueOf(taskData.getProduction()).getMsg() + "类型产品已存在,请完善产品信息。");
+        }
+        //查询该流程生成过的价值意见书产品信息
+        if (StrUtil.isNotBlank(statementNo)){
+            MajorProduction statementProd = this.getOne(new LambdaQueryWrapper<MajorProduction>().eq(MajorProduction::getReportNo, statementNo)
+                    .eq(MajorProduction::getMajorId, majorId).eq(BaseEntity::getDeleted, Boolean.FALSE));
+            if (statementProd != null){
+                taskData.setValueTiming(statementProd.getValueTiming());
+                if (StrUtil.isBlank(taskData.getOwner())){
+                    taskData.setOwner(statementProd.getOwner());
                 }
             }
+
         }
+
         //创建普通二维码
         taskData.setQrCode(businessProductionService.doCreateNormalCode(taskData.getProduction(),reportNo));
         taskData.setStandardAmount(productionFundService.calculateStandardAmount(taskData.getEvaluateAmount()));

+ 22 - 3
service/src/main/java/com/dayou/service/impl/MajorTargetServiceImpl.java

@@ -9,6 +9,7 @@ import com.dayou.dto.TaskRecordDTO;
 import com.dayou.entity.MajorTarget;
 import com.dayou.enums.ProductionEnum;
 import com.dayou.enums.TakeNumberEnum;
+import com.dayou.exception.ErrorCode;
 import com.dayou.mapper.MajorTargetMapper;
 import com.dayou.service.IBusinessNumberService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -20,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -145,8 +147,16 @@ public class MajorTargetServiceImpl extends ServiceImpl<MajorTargetMapper, Major
     public String majorTakeReportNo(TakeNumberDTO takeNumberDTO){
         Long businessId = takeNumberDTO.getBusinessId();
         List<IdNameVO> takeNumberTargets = takeNumberDTO.getTargets();
+        //如果选择不同的价值意见书号,来取同一个报告号。则不允许,此处selectedTargetStatementNos的size只能是1
+        List<String> selectedTargetStatementNos = takeNumberTargets.stream().map(IdNameVO::getName).distinct().collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(selectedTargetStatementNos) && selectedTargetStatementNos.size()!=1){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"取号报告号异常,请联系管理员。");
+        }
         List<MajorTarget> targets = this.list(new LambdaQueryWrapper<MajorTarget>().select(BaseEntity::getId, MajorTarget::getReportNo)
-                .eq(MajorTarget::getMajorId, businessId).eq(BaseEntity::getDeleted, Boolean.FALSE));
+                .eq(MajorTarget::getMajorId, businessId)
+                .eq(CollectionUtils.isNotEmpty(selectedTargetStatementNos)
+                        ,MajorTarget::getStatementNo,selectedTargetStatementNos.get(0))
+                .eq(BaseEntity::getDeleted, Boolean.FALSE));
         List<MajorTarget> taken = targets.stream().filter(x -> StrUtil.isNotEmpty(x.getReportNo())).collect(Collectors.toList());
         List<Long> takenIds = taken.stream().map(BaseEntity::getId).collect(Collectors.toList());
         //从请求数据中过滤出已取过好的对象
@@ -184,8 +194,17 @@ public class MajorTargetServiceImpl extends ServiceImpl<MajorTargetMapper, Major
         List<IdNameVO> takeNumberTargets = takeNumberDTO.getTargets();
         String orderId = takeNumberDTO.getOrderId();
         TakeNumberEnum takeType = takeNumberDTO.getTakeType();
+        //如果选择不同的价值意见书号,来取同一个复评函号。则不允许,此处selectedTargetStatementNos的size只能是1
+        List<String> selectedTargetStatementNos = takeNumberTargets.stream().map(IdNameVO::getName).distinct().collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(selectedTargetStatementNos) && selectedTargetStatementNos.size()!=1){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"取号报告号异常,请联系管理员。");
+        }
         List<MajorTarget> targets = this.list(new LambdaQueryWrapper<MajorTarget>().select(BaseEntity::getId, MajorTarget::getLetterNo)
-                .eq(MajorTarget::getMajorId, businessId).eq(BaseEntity::getDeleted, Boolean.FALSE));
+                .eq(MajorTarget::getMajorId, businessId)
+                .eq(CollectionUtils.isNotEmpty(selectedTargetStatementNos)
+                        ,MajorTarget::getStatementNo,selectedTargetStatementNos.get(0))
+                .eq(BaseEntity::getDeleted, Boolean.FALSE));
+
         List<MajorTarget> taken = targets.stream().filter(x -> StrUtil.isNotEmpty(x.getLetterNo())).collect(Collectors.toList());
         List<Long> takenIds = taken.stream().map(BaseEntity::getId).collect(Collectors.toList());
         //从请求数据中过滤出已取过号的对象
@@ -202,7 +221,7 @@ public class MajorTargetServiceImpl extends ServiceImpl<MajorTargetMapper, Major
                     return subNumbers.get(0).getName();
                 }else {
                     //已取过主号,后续取子号主号都一致。
-                    List<IdNameVO> subNumbers = businessNumberService.takeLetterSubNumber(orderId,takeType,sorted.get(0).getStatementNo(),takeNumberDTO.getTargets());
+                    List<IdNameVO> subNumbers = businessNumberService.takeLetterSubNumber(orderId,takeType,sorted.get(0).getLetterNo(),takeNumberDTO.getTargets());
                     majorTargetMapper.updateSubLetterNo(subNumbers);
                     return subNumbers.get(0).getName();
                 }

+ 2 - 0
service/src/main/java/com/dayou/service/workflow/IWorkFlowNodeInstanceService.java

@@ -44,4 +44,6 @@ public interface IWorkFlowNodeInstanceService extends IService<WorkFlowNodeInsta
     Boolean activateInstanceNode(Long id);
 
     List<WorkNodeInstanceVO> instanceArray(InstanceNodeDTO instance);
+
+    Boolean checkIfReverse(String productionType, String productionNo);
 }

+ 10 - 0
service/src/main/java/com/dayou/service/workflow/WorkFlowNodeInstanceServiceImpl.java

@@ -138,6 +138,16 @@ public class WorkFlowNodeInstanceServiceImpl extends ServiceImpl<WorkFlowNodeIns
     }
 
     @Override
+    public Boolean checkIfReverse(String productionType, String productionNo) {
+        if (StrUtil.isNotBlank(productionType) && StrUtil.isNotBlank(productionNo) && productionNo.contains("-")){
+            productionNo = productionNo.split("-")[0];
+            List<String> nodeCodes = workFlowNodeInstanceMapper.checkIfReverse(productionType,productionNo);
+            return CollectionUtil.isEmpty(nodeCodes);
+        }
+        return Boolean.TRUE;
+    }
+
+    @Override
     public List<WorkNodeInstanceVO> instanceQueue(InstanceNodeDTO instance) {
         String businessMinId = instance.getBusinessMinId();
         String businessSubId = instance.getBusinessSubId();

+ 27 - 6
service/src/main/java/com/dayou/workflow/handler/MajorNodeHandler.java

@@ -26,6 +26,8 @@ import org.springframework.stereotype.Component;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import static com.dayou.enums.ProductionEnum.STATEMENT;
 import static com.dayou.enums.workflow.NodeStateEnum.SKIP;
@@ -142,13 +144,32 @@ public class MajorNodeHandler extends WorkNodeProcessable {
         List<String> writeNodes = Arrays.asList(new String[]{WRITE_STATEMENT.name(), WRITE_REPORT.name(), WRITE_LETTER.name()});
         if (writeNodes.contains(currentNode.getNodeCode()) && commit.getCleanReportNo()!=null && commit.getCleanReportNo()){
             //是否取号?
-            List<String> reportNos =  majorTargetMapper.getSubReportNo(currentNode.getBusinessId());
-            if (CollectionUtil.isNotEmpty(reportNos)){
-                //清除子号
-                majorTargetMapper.cleanSubReportNo(currentNode.getBusinessId());
-                //清除产品信息
-                majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>().eq(MajorProduction::getMajorId,currentNode.getBusinessId()));
+            List<MajorTarget> productionNos = majorTargetMapper.getSubReportNo(currentNode.getBusinessId());
+            if (currentNode.getNodeCode().equals(WRITE_STATEMENT.name())){
+                Set<String> statementNos = productionNos.stream().map(MajorTarget::getStatementNo).collect(Collectors.toSet());
+                if (CollectionUtil.isNotEmpty(statementNos)){
+                    majorTargetMapper.cleanSubStatementNo(statementNos);
+                    majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>()
+                            .in(MajorProduction::getReportNo,statementNos));
+                }
+            }
+            if (currentNode.getNodeCode().equals(WRITE_REPORT.name())){
+                Set<String> reportNos = productionNos.stream().map(MajorTarget::getReportNo).collect(Collectors.toSet());
+                if (CollectionUtil.isNotEmpty(reportNos)){
+                    majorTargetMapper.cleanSubReportNo(reportNos);
+                    majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>()
+                            .in(MajorProduction::getReportNo,reportNos));
+                }
             }
+            if (currentNode.getNodeCode().equals(WRITE_LETTER.name())){
+                Set<String> letterNos = productionNos.stream().map(MajorTarget::getLetterNo).collect(Collectors.toSet());
+                if (CollectionUtil.isNotEmpty(letterNos)){
+                    majorTargetMapper.cleanSubLetterNo(letterNos);
+                    majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>()
+                            .in(MajorProduction::getReportNo,letterNos));
+                }
+            }
+
         }
         if (currentNode.getNodeCode().equals(STATEMENT_FEEDBACK.name())){
             majorProductionMapper.cancelDelivery(currentNode.getBusinessId(),currentNode.getBusinessSubId(),STATEMENT.name());