瀏覽代碼

大中型流程优化0704

wucl 1 年之前
父節點
當前提交
7192b261b1

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

@@ -24,11 +24,11 @@ public interface MajorTargetMapper extends CustomBaseMapper<MajorTarget> {
 
     void updateSubLetterNo(@Param("list") List<IdNameVO> list);
 
-    void updateMainReportNo(@Param("mainNumber") String mainNumber, @Param("businessId")Long businessId);
+    void updateMainReportNo(@Param("mainNumber") String mainNumber, @Param("businessId")Long businessId,@Param("statementNo")String statementNo);
 
     void updateMainStatementNo(@Param("mainNumber") String mainNumber, @Param("businessId")Long businessId);
 
-    void updateMainLetterNo(@Param("mainNumber") String mainNumber, @Param("businessId")Long businessId);
+    void updateMainLetterNo(@Param("mainNumber") String mainNumber, @Param("businessId")Long businessId, @Param("statementNo")String statementNo);
 
     List<MajorTarget> getSubReportNo(@Param("businessId")Long businessId);
 

+ 2 - 0
dao/src/main/resources/mapper/CommissionDeclareMapper.xml

@@ -336,6 +336,7 @@
 
     <select id="todoCheckList" resultMap="majorDeclareTodoCheckMap">
         <include refid="majorDeclareTodoCheck"/>
+        order by t.created DESC
         limit 8
     </select>
 
@@ -648,6 +649,7 @@
     <!--资产待办绩效申报集合-->
     <select id="assetsTodoCheckList" resultType="com.dayou.vo.CommissionDeclareTodoCheckVO" resultMap="assetsDeclareTodoCheckMap">
         <include refid="getAssetsTodoCheck" />
+        order by t.created DESC
         LIMIT 8
     </select>
 

+ 8 - 8
dao/src/main/resources/mapper/FinanceClaimMapper.xml

@@ -97,18 +97,18 @@
         FROM
         (
         SELECT
-        of.id AS oId,
+        orderFund.id AS oId,
         pf.id AS pId,
-        of.business_id,
-        of.order_id,
+        orderFund.business_id,
+        orderFund.order_id,
         pf.production_no,
-        of.should_amount
+        orderFund.should_amount
         FROM
-        order_fund of
-        LEFT JOIN ( SELECT id, real_amount, production_no, production_type, order_fund_id, created FROM production_fund WHERE business_type = "MAJOR_BUSINESS" AND deleted = 0 AND real_amount != 0 ) pf ON pf.order_fund_id = of.id
+        order_fund orderFund
+        LEFT JOIN ( SELECT id, real_amount, production_no, production_type, order_fund_id, created FROM production_fund WHERE business_type = "MAJOR_BUSINESS" AND deleted = 0 AND real_amount != 0 ) pf ON pf.order_fund_id = orderFund.id
         WHERE
-        of.business_type = 'MAJOR_BUSINESS'
-        AND of.deleted = 0
+        orderFund.business_type = 'MAJOR_BUSINESS'
+        AND orderFund.deleted = 0
         ) f
         INNER JOIN finance_claim fc ON
         IF

+ 2 - 1
dao/src/main/resources/mapper/MajorProductionMapper.xml

@@ -367,12 +367,13 @@
         LEFT JOIN department d ON d.id = m.department_id
         LEFT JOIN ( SELECT id, major_id, report_no, NAME, repertory_state, production FROM major_production WHERE deleted = 0 ) mp
         ON ( mp.major_id = m.id AND (mp.report_no =  wfni.business_sub_id or mp.report_no = wfni.business_min_id))
-        LEFT JOIN ( SELECT business_id, production_no, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 and real_amount is not null) pf
+        LEFT JOIN ( SELECT business_id, production_no, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS' AND deleted = 0 ) pf
         ON ( pf.business_id = m.id AND pf.production_no = mp.report_no  )
         WHERE u.deleted = 0
           and  wtr.handler_id =#{todoVO.handlerId}
           AND wnt.deleted = 0
           AND wtr.deleted = 0
+          and pf.real_amount is not null
         <if test="keyword!=null and keyword!='' ">
             and (
             mp.name like concat('%',#{keyword},'%')

+ 10 - 2
dao/src/main/resources/mapper/MajorTargetMapper.xml

@@ -21,11 +21,19 @@
     </update>
 
     <update id="updateMainLetterNo">
-        update major_target set letter_no = #{mainNumber} where major_id = #{businessId} and deleted = 0;
+        update major_target set letter_no = #{mainNumber} where major_id = #{businessId}
+        <if test="statementNo!=null and statementNo!=''">
+            and statement_no = #{statementNo}
+        </if>
+        and deleted = 0;
     </update>
 
     <update id="updateMainReportNo">
-        update major_target set report_no = #{mainNumber} where major_id = #{businessId} and deleted = 0;
+        update major_target set report_no = #{mainNumber} where major_id = #{businessId}
+        <if test="statementNo!=null and statementNo!=''">
+            and statement_no = #{statementNo}
+        </if>
+        and deleted = 0;
     </update>
 
     <update id="updateMainStatementNo">

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

@@ -34,4 +34,6 @@ public interface IProductionFundService extends IService<ProductionFund> {
         ProductionFundVO checkFund(ProductionFundVO productionFundVO);
 
         BigDecimal calculateStandardAmount(BigDecimal evaluateAmount);
+
+        BigDecimal getProductionRealAmountByProductionNo(String productionNo);
 }

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

@@ -185,7 +185,7 @@ public class MajorTargetServiceImpl extends ServiceImpl<MajorTargetMapper, Major
             }else {
                 //取主号
                 String mainNumber = businessNumberService.takeMainNumber(takeNumberDTO);
-                majorTargetMapper.updateMainReportNo(mainNumber,businessId);
+                majorTargetMapper.updateMainReportNo(mainNumber,businessId,statementNo);
                 return mainNumber;
             }
         }
@@ -236,7 +236,7 @@ public class MajorTargetServiceImpl extends ServiceImpl<MajorTargetMapper, Major
             }else {
                 //取主号
                 String mainNumber = businessNumberService.takeLetterMainNumber(orderId,takeType);
-                majorTargetMapper.updateMainLetterNo(mainNumber,businessId);
+                majorTargetMapper.updateMainLetterNo(mainNumber,businessId,statementNo);
                 return mainNumber;
             }
         }

+ 20 - 11
service/src/main/java/com/dayou/service/impl/MessageServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSON;
 import com.dayou.common.BaseEntity;
 import com.dayou.dto.OrderReportDTO;
+import com.dayou.dto.ReportDTO;
 import com.dayou.dto.WareHouseDTO;
 import com.dayou.entity.*;
 import com.dayou.enums.MainBusinessEnum;
@@ -249,18 +250,26 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
 
     @Override
     public void packagingMajorAllotCommissionRemind1(OrderReportDTO orderReportDTO) {
-        List<MajorProductionAllot> allots = majorProductionAllotService.list(new LambdaQueryWrapper<MajorProductionAllot>().eq(MajorProductionAllot::getMajorProductionId, orderReportDTO.getId())
-                .eq(MajorProductionAllot::getUserType, UserTypeEnum.EVALUATE.name()).eq(BaseEntity::getDeleted, Boolean.FALSE));
-        if (CollectionUtil.isEmpty(allots)){
-            MajorProductionVO majorProductionVO = majorProductionMapper.getMajorProductionById(orderReportDTO.getId());
-            SystemMessageBO systemMessageBO = new SystemMessageBO();
-            systemMessageBO.setReceiver(majorProductionVO.getDepartmentLeaderId());
-            systemMessageBO.setMessage(MAJOR_ALLOT_COMMISSION_CONTENT.replace("reportNo",majorProductionVO.getReportNo()));
-            systemMessageBO.setTitle(MAJOR_ALLOT_COMMISSION_REMIND1.getName());
-            systemMessageBO.setType(MAJOR_ALLOT_COMMISSION_REMIND1.name());
-            systemMessageBO.setParams(JSON.toJSONString(majorProductionVO));
-            systemMessageHandler.sendMessage(systemMessageBO);
+        List<ReportDTO> reports = orderReportDTO.getReports();
+        if (CollectionUtil.isNotEmpty(reports)){
+            List<Long> productionIds = reports.stream().map(ReportDTO::getId).collect(Collectors.toList());
+            List<MajorProductionAllot> allots = majorProductionAllotService.list(new LambdaQueryWrapper<MajorProductionAllot>().in(MajorProductionAllot::getMajorProductionId, productionIds)
+                    .eq(MajorProductionAllot::getUserType, UserTypeEnum.EVALUATE.name()).eq(BaseEntity::getDeleted, Boolean.FALSE));
+            if (CollectionUtil.isEmpty(allots)){
+                productionIds.stream().forEach(x->{
+                    MajorProductionVO majorProductionVO = majorProductionMapper.getMajorProductionById(x);
+                    SystemMessageBO systemMessageBO = new SystemMessageBO();
+                    systemMessageBO.setReceiver(majorProductionVO.getDepartmentLeaderId());
+                    systemMessageBO.setMessage(MAJOR_ALLOT_COMMISSION_CONTENT.replace("reportNo",majorProductionVO.getReportNo()));
+                    systemMessageBO.setTitle(MAJOR_ALLOT_COMMISSION_REMIND1.getName());
+                    systemMessageBO.setType(MAJOR_ALLOT_COMMISSION_REMIND1.name());
+                    systemMessageBO.setParams(JSON.toJSONString(majorProductionVO));
+                    systemMessageHandler.sendMessage(systemMessageBO);
+                });
+
+            }
         }
 
+
     }
 }

+ 20 - 0
service/src/main/java/com/dayou/service/impl/ProductionFundServiceImpl.java

@@ -1,5 +1,6 @@
 package com.dayou.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.dayou.common.BaseEntity;
 import com.dayou.entity.OrderFund;
 import com.dayou.entity.ProductionFund;
@@ -147,4 +148,23 @@ public class ProductionFundServiceImpl extends ServiceImpl<ProductionFundMapper,
         }
         return standardAmount;
     }
+
+    @Override
+    public BigDecimal getProductionRealAmountByProductionNo(String productionNo) {
+        try {
+            if (StrUtil.isNotEmpty(productionNo)){
+                ProductionFund one = this.getOne(new LambdaQueryWrapper<ProductionFund>().eq(ProductionFund::getProductionNo, productionNo).eq(BaseEntity::getDeleted, Boolean.FALSE));
+                if (one==null){
+                    return BigDecimal.ZERO;
+                }
+                if (one.getRealAmount()==null){
+                    return BigDecimal.ZERO;
+                }
+                return one.getRealAmount();
+            }
+            return BigDecimal.ZERO;
+        }catch (Exception e){
+            return BigDecimal.ZERO;
+        }
+    }
 }

+ 19 - 0
service/src/main/java/com/dayou/workflow/handler/MajorNodeHandler.java

@@ -14,7 +14,9 @@ import com.dayou.enums.ProductionEnum;
 import com.dayou.enums.workflow.CallbackEnum;
 import com.dayou.enums.workflow.HandlerPermissionEnum;
 import com.dayou.enums.workflow.WorkflowNodeEnum;
+import com.dayou.exception.ErrorCode;
 import com.dayou.mapper.*;
+import com.dayou.service.IProductionFundService;
 import com.dayou.service.IUserPostService;
 import com.dayou.service.IUserService;
 import com.dayou.service.workflow.IWorkFlowNodeInstanceService;
@@ -24,6 +26,7 @@ import com.dayou.workflow.config.WorkNodeProcessable;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -65,6 +68,9 @@ public class MajorNodeHandler extends WorkNodeProcessable {
     private IWorkTaskRecordService workTaskRecordService;
 
     @Autowired
+    private IProductionFundService productionFundService;
+
+    @Autowired
     private IUserService userService;
 
 
@@ -152,10 +158,12 @@ public class MajorNodeHandler extends WorkNodeProcessable {
             //是否取号?
             List<MajorTarget> productionNos = majorTargetMapper.getSubReportNo(currentNode.getBusinessId()).stream()
                     .filter(x->x!=null).collect(Collectors.toList());
+
             if (currentNode.getNodeCode().equals(WRITE_STATEMENT.name())){
                 Set<String> statementNos = productionNos.stream().filter(x->StrUtil.isNotBlank(x.getStatementNo()))
                         .map(MajorTarget::getStatementNo).collect(Collectors.toSet());
                 if (CollectionUtil.isNotEmpty(statementNos)){
+                    checkRealAmount(statementNos);
                     majorTargetMapper.cleanSubStatementNo(statementNos);
                     majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>()
                             .in(MajorProduction::getReportNo,statementNos));
@@ -165,6 +173,7 @@ public class MajorNodeHandler extends WorkNodeProcessable {
                 Set<String> reportNos = productionNos.stream().filter(x->StrUtil.isNotBlank(x.getReportNo()))
                         .map(MajorTarget::getReportNo).collect(Collectors.toSet());
                 if (CollectionUtil.isNotEmpty(reportNos)){
+                    checkRealAmount(reportNos);
                     majorTargetMapper.cleanSubReportNo(reportNos);
                     majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>()
                             .in(MajorProduction::getReportNo,reportNos));
@@ -174,6 +183,7 @@ public class MajorNodeHandler extends WorkNodeProcessable {
                 Set<String> letterNos = productionNos.stream().filter(x->StrUtil.isNotBlank(x.getLetterNo()))
                         .map(MajorTarget::getLetterNo).collect(Collectors.toSet());
                 if (CollectionUtil.isNotEmpty(letterNos)){
+                    checkRealAmount(letterNos);
                     majorTargetMapper.cleanSubLetterNo(letterNos);
                     majorProductionMapper.delete(new LambdaQueryWrapper<MajorProduction>()
                             .in(MajorProduction::getReportNo,letterNos));
@@ -252,4 +262,13 @@ public class MajorNodeHandler extends WorkNodeProcessable {
                 return departmentMapper.selectOne(new LambdaQueryWrapper<Department>().select(Department::getLeaderId).eq(BaseEntity::getId, major.getDepartmentId())).getLeaderId();
         }
     }
+
+    private void checkRealAmount(Set<String> productionNos){
+        productionNos.stream().forEach(x->{
+            BigDecimal realAmount = productionFundService.getProductionRealAmountByProductionNo(x);
+            if (BigDecimal.ZERO.compareTo(realAmount)!=0){
+                ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"产品已认领实收款,无法退回流程。");
+            }
+        });
+    }
 }