Browse Source

Merge branch 'dev_1.1.1' into dev_1.1.2
merge

wangliang 9 months ago
parent
commit
2c1d6adc95

+ 2 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SysUserMapper.java

@@ -132,4 +132,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
      * @return
      * @return
      */
      */
     List<OrgUserNameDto> findOrgUserName(@Param("userIds") List<Long> userIds);
     List<OrgUserNameDto> findOrgUserName(@Param("userIds") List<Long> userIds);
+
+    List<String> findOnPassageSopNoByUserId(@Param("userId") Long userId);
 }
 }

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysUserService.java

@@ -215,4 +215,12 @@ public interface SysUserService extends IService<SysUser> {
      * @return 用户
      * @return 用户
      */
      */
     SysUser findByArchivesId(Long archivesId);
     SysUser findByArchivesId(Long archivesId);
+
+    /**
+     * 根据用户id查询在途的sopNo
+     *
+     * @param userId 用户id
+     * @return 在途的sopNo集合
+     */
+    List<String> findOnPassageSopNoByUserId(Long userId);
 }
 }

+ 23 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java

@@ -362,6 +362,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 sysUserService.update(userUpdateWrapper);
                 sysUserService.update(userUpdateWrapper);
                 //如果修改了角色,需要重新登录
                 //如果修改了角色,需要重新登录
                 if (count > 0 || dbUserRolesList.size() != userRolesList.size()) {
                 if (count > 0 || dbUserRolesList.size() != userRolesList.size()) {
+                    // 如果涉及到区协和工程师身份的互相转变,则需要判断该用户没有在途的sop
+                    Long sysCoordinatorRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.REGION_COORDINATOR).getRoleId();
+                    Long sysEffectRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.EFFECT_ENGINEER).getRoleId();
+                    Long sysAssistantRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.ASSISTANT_ENGINEER)
+                            .getRoleId();
+
+                    if (userRolesList.contains(sysCoordinatorRoleId) && (dbUserRolesList.contains(sysEffectRoleId) || dbUserRolesList.contains(sysAssistantRoleId))
+                            || ((userRolesList.contains(sysEffectRoleId) || userRolesList.contains(sysAssistantRoleId))
+                            && dbUserRolesList.contains(sysCoordinatorRoleId))) {
+                        // 判断是否有在途的sop
+                        List<String> onPassageSopNoList = this.findOnPassageSopNoByUserId(sysUser.getId());
+                        if (!CollectionUtils.isEmpty(onPassageSopNoList)) {
+                            throw ExceptionResultEnum.ERROR.exception(
+                                    String.format("用户[%s]有在途的SOP[%s],无法切换人员档案的角色", sysUser.getRealName(),
+                                            String.join(",", onPassageSopNoList)));
+                        }
+                    }
+
                     QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
                     QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
                     sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, sysUser.getId());
                     sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, sysUser.getId());
                     sysUserRoleService.remove(sysUserRoleQueryWrapper);
                     sysUserRoleService.remove(sysUserRoleQueryWrapper);
@@ -704,4 +722,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         }
         }
         return sysUser;
         return sysUser;
     }
     }
+
+    @Override
+    public List<String> findOnPassageSopNoByUserId(Long userId) {
+        return this.baseMapper.findOnPassageSopNoByUserId(userId);
+    }
 }
 }

+ 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 {
                 } else {
                     // 区协
                     // 区协
                     tbDing = new TBDing(null, null, tbDingApply.getServiceId(), userArchivesResult.getUserArchivesId(),
                     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(
                 tbDing.setSignDate(
                         DateFormatUtils.format(tbDingApply.getApplyTime(), SystemConstant.DEFAULT_DATE_DAY_PATTERN));
                         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);
         TBDingApply tbDingApply = this.getById(id);
         Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
         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());
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbDingApply.getDingExceptionNo());
         //获取当前流程节点
         //获取当前流程节点

+ 11 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingServiceImpl.java

@@ -151,6 +151,8 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
             dingQueryWrapper.lambda().eq(TBDing::getServiceId, serviceId).eq(TBDing::getUserId, userId).orderByAsc(TBDing::getId);
             dingQueryWrapper.lambda().eq(TBDing::getServiceId, serviceId).eq(TBDing::getUserId, userId).orderByAsc(TBDing::getId);
             if (SystemConstant.strNotNull(sopNo)) {
             if (SystemConstant.strNotNull(sopNo)) {
                 dingQueryWrapper.lambda().eq(TBDing::getSopNo, sopNo);
                 dingQueryWrapper.lambda().eq(TBDing::getSopNo, sopNo);
+            } else {
+                dingQueryWrapper.lambda().isNull(TBDing::getSopNo);
             }
             }
 
 
             List<TBDing> tbDingList = this.list(dingQueryWrapper);
             List<TBDing> tbDingList = this.list(dingQueryWrapper);
@@ -406,8 +408,15 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
             List<TBDing> unFinishDingList = otherSopDingList.stream()
             List<TBDing> unFinishDingList = otherSopDingList.stream()
                     .filter(e -> !SystemConstant.longNotNull(e.getSignInTime()) || !SystemConstant.longNotNull(e.getSignOutTime())).collect(Collectors.toList());
                     .filter(e -> !SystemConstant.longNotNull(e.getSignInTime()) || !SystemConstant.longNotNull(e.getSignOutTime())).collect(Collectors.toList());
             if (CollectionUtils.isNotEmpty(unFinishDingList)) {
             if (CollectionUtils.isNotEmpty(unFinishDingList)) {
-                String unFinishDingError = String.format("请先完成sopNo为[%s]的打卡",
-                        unFinishDingList.stream().map(TBDing::getSopNo).collect(Collectors.joining(",")));
+                String unFinishDingError = "";
+                if (isCoordinator) {
+                    unFinishDingError = String.format("请先完成服务单元为[%s]的打卡",
+                            tbServiceService.listByIds(unFinishDingList.stream().map(TBDing::getServiceId).distinct().collect(Collectors.toList()))
+                                    .stream().map(TBService::getName).collect(Collectors.joining(",")));
+                } else {
+                    unFinishDingError = String.format("请先完成sopNo为[%s]的打卡",
+                            unFinishDingList.stream().map(TBDing::getSopNo).collect(Collectors.joining(",")));
+                }
                 throw ExceptionResultEnum.ERROR.exception(unFinishDingError);
                 throw ExceptionResultEnum.ERROR.exception(unFinishDingError);
             }
             }
         }
         }

+ 18 - 0
sop-business/src/main/resources/mapper/SysUserMapper.xml

@@ -336,4 +336,22 @@
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>
+    <select id="findOnPassageSopNoByUserId" resultType="java.lang.String">
+        SELECT DISTINCT
+            (tbcd.sop_no)
+        FROM
+            t_b_user_archives_allocation tbuaa
+                LEFT JOIN
+            t_b_crm_detail tbcd ON tbcd.id = tbuaa.crm_detail_id
+                INNER 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>
+            AND tffa.status NOT IN ('END' , 'FINISH')
+            <if test="userId != null">
+                AND tbuaa.user_id = #{userId}
+            </if>
+        </where>
+    </select>
 </mapper>
 </mapper>

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

@@ -465,6 +465,7 @@
         LEFT JOIN
         LEFT JOIN
         t_b_crm tbc ON tbuaa.crm_no = tbc.crm_no
         t_b_crm tbc ON tbuaa.crm_no = tbc.crm_no
         <where>
         <where>
+            AND tbc.status != 'UN_PUBLISH'
             <if test="userId != null">
             <if test="userId != null">
                 AND tbuaa.user_id = #{userId}
                 AND tbuaa.user_id = #{userId}
             </if>
             </if>

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

@@ -16,13 +16,13 @@
                      tfcf.version,
                      tfcf.version,
                      tfcfe.obj_id as objId,
                      tfcfe.obj_id as objId,
                      tfcfe.crm_no as crmNo,
                      tfcfe.crm_no as crmNo,
-                     tbda.sop_no as sopNo,
+                     IFNULL(tbda.sop_no,'--') as sopNo,
                      tbs.id as serviceId,
                      tbs.id as serviceId,
                      tbs.name as serviceName,
                      tbs.name as serviceName,
                      tbs.type as serviceType,
                      tbs.type as serviceType,
                      sc.id as customId,
                      sc.id as customId,
                      sc.type as customType,
                      sc.type as customType,
-                     sc.name as customName,
+                     IFNULL(sc.name,'--') as customName,
                      tfcfe.create_id as createId,
                      tfcfe.create_id as createId,
                      su.real_name as createRealName,
                      su.real_name as createRealName,
                      tfcfe.flow_id as flowId,
                      tfcfe.flow_id as flowId,
@@ -52,9 +52,9 @@
                 left join t_f_custom_flow tfcf on
                 left join t_f_custom_flow tfcf on
                 tfcf.id = tfcfe.t_f_custom_flow_id
                 tfcf.id = tfcfe.t_f_custom_flow_id
                 left join t_b_crm tbc on
                 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
                 left join t_b_service tbs on
-                tbs.id = tbc.service_id
+                tbs.id = tbda.service_id
                 left join sys_custom sc on
                 left join sys_custom sc on
                 sc.id = tbc.custom_id
                 sc.id = tbc.custom_id
                 left join t_b_ding tbd on
                 left join t_b_ding tbd on
@@ -74,45 +74,45 @@
     <sql id="flowTaskUnDoneListFoot">
     <sql id="flowTaskUnDoneListFoot">
         <where>
         <where>
             and tfcf.type = 'DING_EXCEPTION_FLOW'
             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 tffa.status in ('START','DRAFT','AUDITING','REJECT','CANCEL')
             and tbs.status = 'PUBLISH'
             and tbs.status = 'PUBLISH'
         </where>
         </where>
@@ -120,76 +120,76 @@
 
 
     <select id="flowTaskDoneList" resultType="com.qmth.sop.business.bean.result.DingApplyDoneResult">
     <select id="flowTaskDoneList" resultType="com.qmth.sop.business.bean.result.DingApplyDoneResult">
         select
         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'
         <where> 1 = 1 and tfcf.type = 'DING_EXCEPTION_FLOW'
             and tffa.status in ('AUDITING','REJECT','FINISH')
             and tffa.status in ('AUDITING','REJECT','FINISH')
             and tbs.status = 'PUBLISH'
             and tbs.status = 'PUBLISH'
@@ -237,6 +237,6 @@
                 </choose>
                 </choose>
             </if>
             </if>
         </where>
         </where>
-            order by tfcfe.code desc,tbda.create_time desc
+        order by tfcfe.code desc,tbda.create_time desc
     </select>
     </select>
 </mapper>
 </mapper>