wangliang 1 жил өмнө
parent
commit
ec93b76424

+ 2 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java

@@ -118,9 +118,10 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
      * 根据serviceId查询所有sop信息
      *
      * @param serviceId
+     * @param userId
      * @return
      */
-    List<SopInfoResult> findFlowByServiceId(@Param("serviceId") Long serviceId);
+    List<SopInfoResult> findFlowByServiceId(@Param("serviceId") Long serviceId, @Param("userId") Long userId);
 
     /**
      * 根据sopId查询用户

+ 2 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -1454,7 +1454,8 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
      */
     @Override
     public List<SopInfoResult> findFlowByServiceId(Long serviceId) {
-        return this.baseMapper.findFlowByServiceId(serviceId);
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        return this.baseMapper.findFlowByServiceId(serviceId, sysUser.getId());
     }
 
     /**

+ 85 - 21
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -212,34 +212,98 @@
         </where>) t
         join t_f_custom_flow_entity tfcfe on tfcfe.code = t.sop_no
         join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
-        where t.status = 'DRAFT' and (tffa.status in ('START', 'DRAFT', 'AUDITING', 'REJECT', 'CANCEL') or (tffa.status = 'FINISH' and (t.datediff <![CDATA[ >= ]]> -1 and t.datediff <![CDATA[ <= ]]> 0)))
+--         where t.status = 'DRAFT' and (tffa.status in ('START', 'DRAFT', 'AUDITING', 'REJECT', 'CANCEL') or (tffa.status = 'FINISH' and (t.datediff <![CDATA[ >= ]]> -1 and t.datediff <![CDATA[ <= ]]> 0)))
+        where (tffa.status in ('START', 'DRAFT', 'AUDITING', 'REJECT', 'CANCEL') or (tffa.status = 'FINISH' and (t.datediff <![CDATA[ >= ]]> -1 and t.datediff <![CDATA[ <= ]]> 0)))
     </select>
 
     <select id="findFlowByServiceId" resultType="com.qmth.sop.business.bean.result.SopInfoResult">
-        select
-            tbsi.id,
-            tbsi.sop_no as sopNo,
-            tbsi.crm_no as crmNo,
-            tbc.name as crmName,
-            sc.name as customName,
-            sc.type as customType,
-            sc.id as customId,
-            tbsi.service_id as serviceId,
-            tbs.name as serviceName
-        from
-            t_b_sop_info tbsi
-            left join t_b_crm tbc on tbc.crm_no = tbsi.crm_no
-            left join sys_custom sc on sc.id = tbsi.custom_id
-            left join t_b_service tbs on tbs.id = tbsi.service_id
-            left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbsi.sop_no
-            left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
+<!--        select-->
+<!--            tbsi.id,-->
+<!--            tbsi.sop_no as sopNo,-->
+<!--            tbsi.crm_no as crmNo,-->
+<!--            tbc.name as crmName,-->
+<!--            sc.name as customName,-->
+<!--            sc.type as customType,-->
+<!--            sc.id as customId,-->
+<!--            tbsi.service_id as serviceId,-->
+<!--            tbs.name as serviceName-->
+<!--        from-->
+<!--            t_b_sop_info tbsi-->
+<!--            left join t_b_crm tbc on tbc.crm_no = tbsi.crm_no-->
+<!--            left join sys_custom sc on sc.id = tbsi.custom_id-->
+<!--            left join t_b_service tbs on tbs.id = tbsi.service_id-->
+<!--            left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbsi.sop_no-->
+<!--            left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id-->
+<!--        <where>-->
+<!--            <if test="serviceId != null and serviceId != ''">-->
+<!--                and tbsi.service_id = #{serviceId}-->
+<!--            </if>-->
+<!--                and tbsi.status = 'DRAFT'-->
+<!--                and tffa.status not in('END')-->
+<!--        </where>-->
+        select t.* from(SELECT
+        tbsi.id,
+        tbsi.sop_no as sopNo,
+        tbsi.crm_no as crmNo,
+        tbc.name as crmName,
+        sc.name as customName,
+        sc.type as customType,
+        sc.id as customId,
+        tbsi.service_id as serviceId,
+        tbs.name as serviceName
+        FROM  t_b_sop_info tbsi
+        left join t_b_crm tbc on tbc.crm_no = tbsi.crm_no
+        left join sys_custom sc on sc.id = tbsi.custom_id
+        left join t_b_service tbs on tbs.id = tbsi.service_id
+        left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbsi.sop_no
+        left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
+        left join t_b_crm_detail tbcd on tbsi.sop_no = tbcd.sop_no
+        left join t_b_user_archives_allocation tbuaa on tbuaa.crm_detail_id = tbcd.id
         <where>
             <if test="serviceId != null and serviceId != ''">
-                and tbsi.service_id = #{serviceId}
+               and tbuaa.service_id = #{serviceId}
             </if>
-                and tbsi.status = 'DRAFT'
-                and tffa.status not in('END')
+            <if test="userId != null and userId != ''">
+                and tbuaa.user_id = #{serviceId}
+            </if>
+            and tbuaa.sop_role_type = 'ENGINEER'
+            and tffa.status not in('END')
+        </where>
+        union
+        SELECT  tbsi.id,
+        tbsi.sop_no as sopNo,
+        tbsi.crm_no as crmNo,
+        tbc.name as crmName,
+        sc.name as customName,
+        sc.type as customType,
+        sc.id as customId,
+        tbsi.service_id as serviceId,
+        tbs.name as serviceName
+        from t_b_sop_info tbsi
+        left join t_b_crm tbc on tbc.crm_no = tbsi.crm_no
+        left join sys_custom sc on sc.id = tbsi.custom_id
+        left join t_b_service tbs on tbs.id = tbsi.service_id
+        left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbsi.sop_no
+        left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
+        left join t_b_crm_detail tbcd on tbsi.sop_no = tbcd.sop_no
+        left join t_b_user_archives_allocation_log tbuaal on tbuaal.crm_detail_id = tbcd.id
+        WHERE exists (
+        SELECT tbuaa.crm_detail_id FROM t_b_user_archives_allocation tbuaa
+        left join t_b_crm_detail tbcd on tbcd.id = tbuaa.crm_detail_id
+        left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbcd.sop_no
+        left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
+        <where>
+            <if test="serviceId != null and serviceId != ''">
+                and tbuaa.service_id = #{serviceId}
+            </if>
+            <if test="userId != null and userId != ''">
+                and tbuaa.user_id = #{serviceId}
+            </if>
+            and tbuaa.sop_role_type = 'ENGINEER'
+            and tffa.status not in('END')
+            and tbuaal.crm_detail_id = tbuaa.crm_detail_id
         </where>
+        )) t order by t.sopNo
     </select>
 
     <select id="userList" resultType="com.qmth.sop.business.entity.SysUser">

+ 1 - 1
sop-business/src/main/resources/mapper/TBSopPlanDateLogMapper.xml

@@ -9,7 +9,7 @@
                left join t_b_service tbs on tbs.id = tbsi.service_id
                left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
         <where> 1 = 1
-                and tbsi.status = 'DRAFT'
+--                 and tbsi.status = 'DRAFT'
             <if test="serviceId != null and serviceId != ''">
                 and tbs.id = #{serviceId}
             </if>