Procházet zdrojové kódy

Merge branch 'dev_1.1.0' of http://git.qmth.com.cn/sop/server into dev_1.1.0

haogh před 1 rokem
rodič
revize
8e4f941f7e

+ 5 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBDingController.java

@@ -63,6 +63,9 @@ public class TBDingController {
     @Resource
     TBServiceService tbServiceService;
 
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
     @ApiOperation(value = "考勤明细")
     @RequestMapping(value = "/detail", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = TBDing.class) })
@@ -248,13 +251,14 @@ public class TBDingController {
                     }
                     List<SopInfoResult> sopInfo = new ArrayList<>();
                     for (String sopNo : sopNoList) {
+                        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
                         SopInfoResult result = new SopInfoResult();
                         result.setSopNo(sopNo);
                         result.setCrmNo(tbCrm.getCrmNo());
                         result.setCrmName(tbCrm.getName());
                         result.setCustomId(crmProjectResult.getCustomId());
                         result.setCustomName(crmProjectResult.getCustomName());
-                        result.setCourseName(crmProjectResult.getCourseName());
+                        result.setCourseName(tbCrmDetail.getCourseName());
                         ProductTypeEnum productTypeEnum = crmProjectResult.getCustomType();
                         if (Objects.nonNull(productTypeEnum)) {
                             result.setCustomType(productTypeEnum);

+ 19 - 3
sop-business/src/main/java/com/qmth/sop/business/activiti/service/ActivitiService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.result.FlowViewResult;
 import com.qmth.sop.business.bean.result.WorkTaskResult;
+import com.qmth.sop.business.entity.TFCustomFlowEntity;
 import com.qmth.sop.common.enums.FlowTaskTypeEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import org.activiti.engine.task.Task;
@@ -74,7 +75,8 @@ public interface ActivitiService {
      * @param crmNo
      * @return
      */
-    public Map<String, Object> formPropertiesGet(String flowDeploymentId, Long flowId, Long taskId, Boolean dynamicTable, String crmNo) throws Exception;
+    public Map<String, Object> formPropertiesGet(String flowDeploymentId, Long flowId, Long taskId,
+            Boolean dynamicTable, String crmNo) throws Exception;
 
     /**
      * 获取用户待办
@@ -88,7 +90,8 @@ public interface ActivitiService {
      * @param crmNo
      * @return
      */
-    public IPage<WorkTaskResult> getFlowTaskList(IPage<Map> iPage, Long userId, TFCustomTypeEnum type, Long serviceId, String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
+    public IPage<WorkTaskResult> getFlowTaskList(IPage<Map> iPage, Long userId, TFCustomTypeEnum type, Long serviceId,
+            String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
 
     /**
      * 获取用户待办计数
@@ -101,7 +104,8 @@ public interface ActivitiService {
      * @param crmNo
      * @return
      */
-    public int getFlowTaskListCount(Long userId, TFCustomTypeEnum type, Long serviceId, String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
+    public int getFlowTaskListCount(Long userId, TFCustomTypeEnum type, Long serviceId, String customName,
+            FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
 
     /**
      * 流程节点转他人审批
@@ -152,4 +156,16 @@ public interface ActivitiService {
      * @return
      */
     public List<String> getTaskApprove(Task task);
+
+    /**
+     * 发送待办短信
+     *
+     * @param type
+     * @param tfCustomFlowEntity
+     * @param taskName
+     * @param userId
+     * @param taskId
+     */
+    public void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName,
+            Long userId, Long taskId);
 }

+ 47 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -13,6 +13,7 @@ import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.exec.MySQLExec;
 import com.qmth.sop.business.mapper.SysUserMapper;
 import com.qmth.sop.business.service.*;
+import com.qmth.sop.business.util.SmsSendUtil;
 import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
@@ -126,6 +127,12 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     TBCrmDetailService tbCrmDetailService;
 
+    @Resource
+    SmsSendUtil smsSendUtil;
+
+    @Resource
+    ActivitiService activitiService;
+
     /**
      * 根据deploymentId查找processDefinitionId
      *
@@ -263,6 +270,13 @@ public class ActivitiServiceImpl implements ActivitiService {
                     Long.parseLong(approveUserIds.get(approveUserIds.size() - 1)),
                     FlowStatusEnum.valueOf(flowApproveParam.getApprove().name()), sysUser.getId());
             flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
+
+            Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId())
+                    .singleResult();
+            Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.TASK_NO_DATA.exception());
+
+            activitiService.sendSopFlowDoneSms(maxTfCustomFlow.getType(), tfCustomFlowEntity, task.getName(),
+                    Long.parseLong(approveUserIds.get(0)), Long.parseLong(task.getId()));
         } else if (Objects.nonNull(flowApproveParam.getTaskId())) {
             taskTemp = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId()))
                     .singleResult();
@@ -788,6 +802,8 @@ public class ActivitiServiceImpl implements ActivitiService {
                     sysUser.getRealName() + "(" + orgName + ")转" + exchangeUser.getRealName() + "(" + exchangeOrgName
                             + ")审批");
             tfFlowLogService.save(tfFlowLog);
+            activitiService.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), userId,
+                    Long.parseLong(task.getId()));
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
@@ -1262,4 +1278,35 @@ public class ActivitiServiceImpl implements ActivitiService {
             tfFlowLog.setApproveRemark(DingExceptionApproveEnum.NO_PASS.getTitle());
         }
     }
+
+    /**
+     * 发送待办短信
+     *
+     * @param type
+     * @param tfCustomFlowEntity
+     * @param taskName
+     * @param userId
+     * @param taskId
+     */
+    @Override
+    public void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName,
+            Long userId, Long taskId) {
+        FlowTaskSmsResult flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(
+                tfCustomFlowEntity.getId(), userId);
+        if (Objects.isNull(flowTaskSmsResult)) {
+            flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getCrmNo(),
+                    userId);
+        }
+        Optional.ofNullable(flowTaskSmsResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
+
+        Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
+        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.TASK_NO_DATA.exception());
+
+        Map<String, Object> templateParam = new HashMap<>();
+        templateParam.put("userName", flowTaskSmsResult.getRealName());
+        templateParam.put("serviceName", flowTaskSmsResult.getServiceName());
+        templateParam.put("customName", flowTaskSmsResult.getCustomName());
+        templateParam.put("flowName", type.getTitle() + "【" + task.getName() + "】");
+        smsSendUtil.sendSms(flowTaskSmsResult.getMobileNumber(), SystemConstant.SMS_SOP_DONE_CODE, templateParam);
+    }
 }

+ 22 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/UserArchivesDto.java

@@ -28,12 +28,18 @@ public class UserArchivesDto {
     @ApiModelProperty("城市")
     private String city;
 
+    @ApiModelProperty("电话号码")
+    private String mobileNumber;
+
     @ApiModelProperty("供应商")
     private String supplierName;
 
     @ApiModelProperty("创建时间")
     private Long createTime;
 
+    @ApiModelProperty("档案角色")
+    private String archivesRoleName;
+
     public Long getUserId() {
         return userId;
     }
@@ -74,6 +80,14 @@ public class UserArchivesDto {
         this.city = city;
     }
 
+    public String getMobileNumber() {
+        return mobileNumber;
+    }
+
+    public void setMobileNumber(String mobileNumber) {
+        this.mobileNumber = mobileNumber;
+    }
+
     public String getSupplierName() {
         return supplierName;
     }
@@ -89,4 +103,12 @@ public class UserArchivesDto {
     public void setCreateTime(Long createTime) {
         this.createTime = createTime;
     }
+
+    public String getArchivesRoleName() {
+        return archivesRoleName;
+    }
+
+    public void setArchivesRoleName(String archivesRoleName) {
+        this.archivesRoleName = archivesRoleName;
+    }
 }

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

@@ -604,6 +604,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 .eq(TBUserArchivesAllocation::getSopRoleType, SopRoleTypeEnum.PROJECT_MANAGER)
                 .eq(TBUserArchivesAllocation::getUserId, userId));
         dto.setHasProjectManager(count > 0 ? true : false);
+
+        if (!dto.getHasProjectManager() && !dto.getHasRegionManager() && !dto.getHasAssistantEngineer()
+                && !dto.getHasAssistantEngineer()) {
+            dto.setHasEffectEngineer(true);
+            dto.setHasAssistantEngineer(true);
+        }
         if (dto.getHasThirdPmo() || dto.getHasDeviceDelivery()) {
             Long supplierId = sysUser.getSupplierId();
             if (supplierId == null || supplierId == 0) {

+ 5 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -552,6 +552,11 @@ public class TBUserArchivesAllocationServiceImpl
                 cell.setProvince(tbUserArchivesResult.getProvince());
                 cell.setCity(tbUserArchivesResult.getCity());
                 cell.setSupplierName(tbUserArchivesResult.getSupplierName());
+                cell.setMobileNumber(tbUserArchivesResult.getMobileNumber());
+                List<RoleResult> roleInfoList = tbUserArchivesResult.getRoleInfoList();
+                if (CollectionUtils.isNotEmpty(roleInfoList)){
+                    cell.setArchivesRoleName(roleInfoList.stream().map(RoleResult::getRoleName).collect(Collectors.joining(",")));
+                }
                 result.add(cell);
             }
         }

+ 20 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java

@@ -482,6 +482,26 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
                 throw ExceptionResultEnum.ERROR.exception("档案数据异常");
             }
             result = userArchivesResultList.get(0);
+            List<RoleResult> roleResultList = new ArrayList<>();
+            userId = result.getUserId();
+
+            // 认证的角色枚举
+            List<RoleTypeEnum> authRole = new ArrayList<>();
+            authRole.add(RoleTypeEnum.EFFECT_ENGINEER);
+            authRole.add(RoleTypeEnum.REGION_COORDINATOR);
+            authRole.add(RoleTypeEnum.ASSISTANT_ENGINEER);
+            if (userId != null && userId > 0) {
+                for (RoleTypeEnum roleTypeEnum : authRole) {
+                    // TODO: 2023/8/14 可优化查询
+                    if (sysUserRoleService.userContainsRoles(userId, roleTypeEnum)) {
+                        RoleResult roleResult = sysRoleService.findRoleInfoByArchivesType(roleTypeEnum);
+                        if (Objects.nonNull(roleResult)) {
+                            roleResultList.add(roleResult);
+                        }
+                    }
+                }
+            }
+            result.setRoleInfoList(roleResultList);
         }
         return result;
     }