wangliang 9 hónapja
szülő
commit
47e2a15b93

+ 10 - 6
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -372,7 +372,8 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
                 } else {
                     // 区协
                     tbDing = new TBDing(null, null, tbDingApply.getServiceId(), userArchivesResult.getUserArchivesId(),
-                            JSON.toJSONString(Collections.singletonList(SopRoleTypeEnum.REGION_COORDINATOR)), sysUser.getId(), null);
+                            JSON.toJSONString(Collections.singletonList(SopRoleTypeEnum.REGION_COORDINATOR)),
+                            sysUser.getId(), null);
                 }
                 tbDing.setSignDate(
                         DateFormatUtils.format(tbDingApply.getApplyTime(), SystemConstant.DEFAULT_DATE_DAY_PATTERN));
@@ -486,11 +487,14 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         TBDingApply tbDingApply = this.getById(id);
         Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
 
-        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tbDingApply.getSopNo());
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
-                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, tbDingApply.getCrmNo());
-        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+        CrmProjectResult crmProjectResult = null;
+        if (Objects.nonNull(tbDingApply.getSopNo())) {
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tbDingApply.getSopNo());
+            crmProjectResult = tbCrmService.findCrmProjectInfo(
+                    Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
+                    Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, tbDingApply.getCrmNo());
+            Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+        }
 
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbDingApply.getDingExceptionNo());
         //获取当前流程节点

+ 114 - 114
sop-business/src/main/resources/mapper/TBDingApplyMapper.xml

@@ -16,13 +16,13 @@
                      tfcf.version,
                      tfcfe.obj_id as objId,
                      tfcfe.crm_no as crmNo,
-                     tbda.sop_no as sopNo,
+                     IFNULL(tbda.sop_no,'--') as sopNo,
                      tbs.id as serviceId,
                      tbs.name as serviceName,
                      tbs.type as serviceType,
                      sc.id as customId,
                      sc.type as customType,
-                     sc.name as customName,
+                     IFNULL(sc.name,'--') as customName,
                      tfcfe.create_id as createId,
                      su.real_name as createRealName,
                      tfcfe.flow_id as flowId,
@@ -52,9 +52,9 @@
                 left join t_f_custom_flow tfcf on
                 tfcf.id = tfcfe.t_f_custom_flow_id
                 left join t_b_crm tbc on
-                tbc.service_id = tbda.service_id
+                tbc.crm_no = tfcfe.crm_no
                 left join t_b_service tbs on
-                tbs.id = tbc.service_id
+                tbs.id = tbda.service_id
                 left join sys_custom sc on
                 sc.id = tbc.custom_id
                 left join t_b_ding tbd on
@@ -74,45 +74,45 @@
     <sql id="flowTaskUnDoneListFoot">
         <where>
             and tfcf.type = 'DING_EXCEPTION_FLOW'
-        <if test="serviceId != null and serviceId != ''">
-            and tbs.id = #{serviceId}
-        </if>
-        <if test="name != null and name != ''">
-            and su.real_name like concat('%', #{name}, '%')
-        </if>
-        <if test="supplierId != null and supplierId != ''">
-            and ss.id = #{supplierId}
-        </if>
-        <if test="customName != null and customName != ''">
-            and sc.name like concat('%', #{customName}, '%')
-        </if>
-        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
-            and (tbda.apply_time <![CDATA[ >= ]]> #{startTime} and tbda.apply_time <![CDATA[ <= ]]> #{endTime})
-        </if>
-        <if test="applyStartTime != null and applyStartTime != '' and applyEndTime != null and applyEndTime != ''">
-            and (tbda.create_time <![CDATA[ >= ]]> #{applyStartTime} and tbda.create_time <![CDATA[ <= ]]> #{applyEndTime})
-        </if>
-        <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-            <choose>
-                <when test="dpr.hasBusiness">
-                    AND tbs.service_lead_id = #{dpr.requestUserId}
-                </when>
-                <otherwise>
-                    <choose>
-                        <when test="dpr.hasRegionManager">
-                            AND tbc.lead_id = #{dpr.requestUserId}
-                        </when>
-                        <otherwise>
-                            <choose>
-                                <when test="dpr.hasRegionCoordinator">
-                                    AND tbc.region_coordinator_id = #{dpr.requestUserId}
-                                </when>
-                            </choose>
-                        </otherwise>
-                    </choose>
-                </otherwise>
-            </choose>
-        </if>
+            <if test="serviceId != null and serviceId != ''">
+                and tbs.id = #{serviceId}
+            </if>
+            <if test="name != null and name != ''">
+                and su.real_name like concat('%', #{name}, '%')
+            </if>
+            <if test="supplierId != null and supplierId != ''">
+                and ss.id = #{supplierId}
+            </if>
+            <if test="customName != null and customName != ''">
+                and sc.name like concat('%', #{customName}, '%')
+            </if>
+            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+                and (tbda.apply_time <![CDATA[ >= ]]> #{startTime} and tbda.apply_time <![CDATA[ <= ]]> #{endTime})
+            </if>
+            <if test="applyStartTime != null and applyStartTime != '' and applyEndTime != null and applyEndTime != ''">
+                and (tbda.create_time <![CDATA[ >= ]]> #{applyStartTime} and tbda.create_time <![CDATA[ <= ]]> #{applyEndTime})
+            </if>
+            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
+                <choose>
+                    <when test="dpr.hasBusiness">
+                        AND tbs.service_lead_id = #{dpr.requestUserId}
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="dpr.hasRegionManager">
+                                AND tbc.lead_id = #{dpr.requestUserId}
+                            </when>
+                            <otherwise>
+                                <choose>
+                                    <when test="dpr.hasRegionCoordinator">
+                                        AND tbc.region_coordinator_id = #{dpr.requestUserId}
+                                    </when>
+                                </choose>
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
             and tffa.status in ('START','DRAFT','AUDITING','REJECT','CANCEL')
             and tbs.status = 'PUBLISH'
         </where>
@@ -120,76 +120,76 @@
 
     <select id="flowTaskDoneList" resultType="com.qmth.sop.business.bean.result.DingApplyDoneResult">
         select
-            distinct tfcf.type,
-            tfcfe.code,
-            tffa.status,
-            tffa.setup,
-            tfcf.version,
-            tfcfe.obj_id as objId,
-            tfcfe.crm_no as crmNo,
-            tbda.sop_no as sopNo,
-            tfcfe.flow_id as flowId,
-            tbs.id as serviceId,
-            tbs.name as serviceName,
-            tbs.type as serviceType,
-            sc.id as customId,
-            sc.type as customType,
-            sc.name as customName,
-            tfcfe.create_id as createId,
-            su.real_name as createRealName,
-            tfcfe.flow_process_var as flowProcessVar,
-            tfcfe.t_f_custom_flow_id as customFlowId,
-            tfcf.flow_deployment_id as flowDeploymentId,
-            tfcfe.id as customFlowEntityid,
-            tbda.`type` as dingExceptionType,
-            tbd.sign_date as exceptionTime,
-            tbda.apply_time as applyTime,
-            tbda.create_time as createTime,
-            tffa.update_time as flowTime,
-            tbda.reason,
-            tbda.attachment_paths as attachmentPaths,
-            (
-            select
-            CONCAT(tffl.approve_remark, ';' , tffl.create_time)
-            from
-            t_f_flow_log tffl
-            where
-            tffl.flow_id = tfcfe.flow_id
-            order by
-            tffl.create_time desc
-            limit 1) as approveInfo,
-            ss.id as supplierId,
-            tbd.id as dingId,
-            ss.name as supplierName,
-            ss.code as supplierCode,
-            tbda.approve as dingExceptionApprove,
-            tbs.service_lead_id as serviceUnitLeaderId,
-            tbc.lead_id as regionManagerId,
-            tbc.region_coordinator_id as coordinatorId
-            from
-            t_b_ding_apply tbda
-            left join t_f_custom_flow_entity tfcfe on
-            tbda.ding_exception_no = tfcfe.code
-            left join t_f_flow_approve tffa on
-            tfcfe.flow_id = tffa.flow_id
-            left join t_f_custom_flow tfcf on
-            tfcf.id = tfcfe.t_f_custom_flow_id
-            left join t_b_crm tbc on
-            tbc.service_id = tbda.service_id
-            left join t_b_service tbs on
-            tbs.id = tbc.service_id
-            left join sys_custom sc on
-            sc.id = tbc.custom_id
-            left join t_b_ding tbd on
-            tbd.id = tbda.ding_id
-            left join sys_user su on
-            tbda.create_id = su.id
-            left join t_b_user_archives tbua on
-            tbua.mobile_number = su.mobile_number
-            left join t_b_user_archives_supplier tbuas on
-            tbuas.user_archives_id = tbua.id
-            left join sys_supplier ss on
-            ss.id = tbuas.supplier_id
+        distinct tfcf.type,
+        tfcfe.code,
+        tffa.status,
+        tffa.setup,
+        tfcf.version,
+        tfcfe.obj_id as objId,
+        tfcfe.crm_no as crmNo,
+        IFNULL(tbda.sop_no,'--') as sopNo,
+        tfcfe.flow_id as flowId,
+        tbs.id as serviceId,
+        tbs.name as serviceName,
+        tbs.type as serviceType,
+        sc.id as customId,
+        sc.type as customType,
+        IFNULL(sc.name,'--') as customName,
+        tfcfe.create_id as createId,
+        su.real_name as createRealName,
+        tfcfe.flow_process_var as flowProcessVar,
+        tfcfe.t_f_custom_flow_id as customFlowId,
+        tfcf.flow_deployment_id as flowDeploymentId,
+        tfcfe.id as customFlowEntityid,
+        tbda.`type` as dingExceptionType,
+        tbd.sign_date as exceptionTime,
+        tbda.apply_time as applyTime,
+        tbda.create_time as createTime,
+        tffa.update_time as flowTime,
+        tbda.reason,
+        tbda.attachment_paths as attachmentPaths,
+        (
+        select
+        CONCAT(tffl.approve_remark, ';' , tffl.create_time)
+        from
+        t_f_flow_log tffl
+        where
+        tffl.flow_id = tfcfe.flow_id
+        order by
+        tffl.create_time desc
+        limit 1) as approveInfo,
+        ss.id as supplierId,
+        tbd.id as dingId,
+        ss.name as supplierName,
+        ss.code as supplierCode,
+        tbda.approve as dingExceptionApprove,
+        tbs.service_lead_id as serviceUnitLeaderId,
+        tbc.lead_id as regionManagerId,
+        tbc.region_coordinator_id as coordinatorId
+        from
+        t_b_ding_apply tbda
+        left join t_f_custom_flow_entity tfcfe on
+        tbda.ding_exception_no = tfcfe.code
+        left join t_f_flow_approve tffa on
+        tfcfe.flow_id = tffa.flow_id
+        left join t_f_custom_flow tfcf on
+        tfcf.id = tfcfe.t_f_custom_flow_id
+        left join t_b_crm tbc on
+        tbc.crm_no = tfcfe.crm_no
+        left join t_b_service tbs on
+        tbs.id = tbda.service_id
+        left join sys_custom sc on
+        sc.id = tbc.custom_id
+        left join t_b_ding tbd on
+        tbd.id = tbda.ding_id
+        left join sys_user su on
+        tbda.create_id = su.id
+        left join t_b_user_archives tbua on
+        tbua.mobile_number = su.mobile_number
+        left join t_b_user_archives_supplier tbuas on
+        tbuas.user_archives_id = tbua.id
+        left join sys_supplier ss on
+        ss.id = tbuas.supplier_id
         <where> 1 = 1 and tfcf.type = 'DING_EXCEPTION_FLOW'
             and tffa.status in ('AUDITING','REJECT','FINISH')
             and tbs.status = 'PUBLISH'
@@ -237,6 +237,6 @@
                 </choose>
             </if>
         </where>
-            order by tfcfe.code desc,tbda.create_time desc
+        order by tfcfe.code desc,tbda.create_time desc
     </select>
 </mapper>