guarantee-lsq hai 1 ano
pai
achega
edb8294f3a

+ 1 - 1
platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml

@@ -125,7 +125,7 @@
             <if test="repairStartTimeEnd != null">
                 and application.repair_start_time <![CDATA[ < ]]> #{repairStartTimeEnd}
             </if>
-            <if test="dispatchUserId != null">
+            <if test="dispatchUserId != null and dispatchUserId != ''">
                 and application.dispatch_user_id = #{dispatchUserId}
             </if>
             <if test="checkAllFlag != null and checkAllFlag == 1">

+ 32 - 7
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -1359,20 +1359,34 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
 
     @Override
     public MyVOPage<RepairApplicationFormVO> selectPageInfoVODispatch(RepairApplicationFormDTO record, int pageNum, int pageSize) {
-        PageHelper.startPage(pageNum, pageSize);
         if(StringUtils.isBlank(record.getSbId())){ // 非获取设备的维修记录
             UserInfo userInfo = SecurityUtils.getUserInfo();
-            record.setTempUserId(userInfo.getUserId());
+            String roles = getRoleCodesByUserId();
+            // 根据角色判断
+            if(userInfo.getSuperAdmin() != 1){
+                if(roles.contains(SysRoleCodeEnum.MM.name())){
+                    // 维修主管
+                    record.setDispatchUserId(userInfo.getUserId());
+                }else if(roles.contains(SysRoleCodeEnum.Maintenance.name())
+                        || roles.contains(SysRoleCodeEnum.Maintenance_Leader.name())){
+                    // 维修人
+                    record.setRepairUserId(userInfo.getUserId());
+                }else if(roles.contains(SysRoleCodeEnum.REPAIR_EXAMINE.name())){
+                    record.setUserId(userInfo.getUserId());
+                }else{
+                    record.setUserId(userInfo.getUserId());
+                }
+            }
             if(record.getSearchType() != null){
                 List<Integer> statusList = new ArrayList<>();
                 if(record.getSearchType() == 1){ // 待派工单
-                    statusList.add(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
+                    statusList.add(RepairApplicationFormStatusEnum.RECEIVED.getValue());
                 }else if(record.getSearchType() == 2){ // 我的工单
-                    statusList.add(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
+                    /*statusList.add(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
                     statusList.add(RepairApplicationFormStatusEnum.PROCESSING.getValue());
                     statusList.add(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
                     statusList.add(RepairApplicationFormStatusEnum.FINISHED.getValue());
-                    statusList.add(RepairApplicationFormStatusEnum.MM_REPAIR_CLOSE.getValue());
+                    statusList.add(RepairApplicationFormStatusEnum.MM_REPAIR_CLOSE.getValue());*/
                 }else if(record.getSearchType() == 3){ // 待审核工单
                     statusList.add(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
                 }else if(record.getSearchType() == 4){
@@ -1382,7 +1396,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                 record.setStatusList(statusList);
             }
             // 排除超级用户
-            String userNames = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_SUPER_USERS.name()); // 超级用户
+            /*String userNames = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_SUPER_USERS.name()); // 超级用户
             if(StringUtils.isBlank(userNames)){
                 throw new DeniedException("请设置维修菜单的超级用户");
             }
@@ -1395,11 +1409,22 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                     record.setCheckUserId(null);
                     record.setCheckAllFlag(1);
                 }
-            }
+            }*/
         }
+        PageHelper.startPage(pageNum, pageSize);
         return new MyVOPage<>(mapper.selectPageList(record));
     }
 
+    public String getRoleCodesByUserId() {
+        // 根据用户的角色来定
+        StringBuilder roleCodes = new StringBuilder();
+        List<SysUserRoleVO> roles = sysUserRoleMapper.selectRoleListByUserId(SecurityUtils.getUserInfo().getUserId());
+        roles.forEach(item->{
+            roleCodes.append(item.getRoleCode()).append("&");
+        });
+        return roleCodes.toString();
+    }
+
     @Override
     public RepairApplicationFormVO getById(Object id) {
         RepairApplicationForm model = mapper.selectById(id);

+ 48 - 54
platform-service/src/main/java/com/platform/service/repair/strategy/impl/AllocateRepairBaseStrategy.java

@@ -13,19 +13,24 @@ import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.upms.SysUser;
 import com.platform.dao.enums.*;
+import com.platform.dao.mapper.upms.SysUserMapper;
 import com.platform.dao.util.MessageTemplateUtil;
 import com.platform.dao.vo.SysUserVO;
 import com.platform.dao.vo.sb.SbInfoVO;
 import com.platform.service.event.WorkplaceBacklogEvent;
 import com.platform.service.repair.strategy.AbstractRepairBaseStrategy;
+import com.platform.service.util.SendMessageUtils;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 
 @Component
 public class AllocateRepairBaseStrategy extends AbstractRepairBaseStrategy {
+    @Resource
+    private SysUserMapper sysUserMapper;
 
     @Override
     public RepairApplicationForm callRepair(RepairApplicationFormDTO model) {
@@ -140,67 +145,56 @@ public class AllocateRepairBaseStrategy extends AbstractRepairBaseStrategy {
 
     @Override
     public RepairApplicationFormDTO sendRepair(RepairApplicationFormDTO model) {
-        RepairApplicationFormDTO superModel = super.sendRepair(model);
-        RepairApplicationForm applicationForm = new RepairApplicationForm();
-        applicationForm.setId(model.getId());
-        applicationForm.setRepairUserId(superModel.getRepairUserId());
-        applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
-        if (superModel.getRepairStartTime() == null) {
-            applicationForm.setRepairStartTime(LocalDateTime.now());
-            superModel.setRepairStartTime(LocalDateTime.now());
+        RepairApplicationForm applicationForm = repairApplicationFormMapper.selectById(model.getId());
+        String userId = SecurityUtils.getUserInfo().getUserId();
+        if(!userId.equals(applicationForm.getDispatchUserId())){
+            throw new DeniedException("您非该维修单的主管,不可以进行派单");
         }
-        applicationForm.setReceiveMinutes(DateUtils.getDurationHours(superModel.getApplyTime(), superModel.getRepairStartTime()));
-        applicationForm.setUpdateTime(LocalDateTime.now());
-        repairApplicationFormMapper.updateByPrimaryKeySelective(applicationForm);
-        // 给报修人发送消息
-        sendMessageToRepairCaller(superModel.getId(),superModel.getNo(),superModel.getUserId());
-        /*// 自己派工
-        UserInfo userInfo = SecurityUtils.getUserInfo();
-        String userNames = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_SUPER_USERS.name()); // 超级用户
-        if(StringUtils.isNotBlank(userNames)){
-            String arr[]=getStringArarry(userNames);
-            for(int i=0;i<arr.length;i++){
-                if(arr[i].equals(userInfo.getUsername())){
-                    RepairApplicationForm applicationForm = new RepairApplicationForm();
-                    applicationForm.setId(model.getId());
-                    applicationForm.setRepairUserId(superModel.getRepairUserId());
-                    applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
-                    if (superModel.getRepairStartTime() == null) {
-                        applicationForm.setRepairStartTime(LocalDateTime.now());
-                        superModel.setRepairStartTime(LocalDateTime.now());
-                    }
-                    applicationForm.setReceiveMinutes(DateUtils.getDurationHours(superModel.getApplyTime(), superModel.getRepairStartTime()));
-                    applicationForm.setUpdateTime(LocalDateTime.now());
-                    repairApplicationFormMapper.updateByPrimaryKeySelective(applicationForm);
-                    // 给报修人发送消息
-                    sendMessageToRepairCaller(superModel.getId(),superModel.getNo(),superModel.getUserId());
-                    break;
-                }else if(i>=arr.length-1){
-                    // 非超级用户,判断是否具有审核派工权限
-                    if(!userInfo.getUserId().equals(model.getDispatchUserId())){
-                        throw new DeniedException("您不具有派工权限");
-                    }
-                }
-            }
-
-        }*/
+        if (!RepairApplicationFormStatusEnum.RECEIVED.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException("该维修状态");
+        }
+        model.setApplyTime(applicationForm.getApplyTime());
+        model.setNo(applicationForm.getNo());
+        model.setUserId(applicationForm.getUserId());
+        model.setDispatchUserId(applicationForm.getDispatchUserId());
+        model.setSbId(applicationForm.getSbId());
 
+        RepairApplicationForm updForm = new RepairApplicationForm();
+        updForm.setId(model.getId());
+        updForm.setRepairUserId(model.getRepairUserId());
+        updForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+        if (model.getRepairStartTime() == null) {
+            updForm.setRepairStartTime(LocalDateTime.now());
+            model.setRepairStartTime(LocalDateTime.now());
+        }
+        updForm.setReceiveMinutes(DateUtils.getDurationHours(model.getApplyTime(), model.getRepairStartTime()));
+        updForm.setUpdateTime(LocalDateTime.now());
+        repairApplicationFormMapper.updateByPrimaryKeySelective(updForm);
+        // 给维修人发送消息
+        sendMessageToRepairer(model);
         return model;
     }
 
-    public static String[] getStringArarry(String str){
-        String arr[]=str.split(",");
-        return arr;
+    private void sendMessageToRepairer(RepairApplicationFormDTO model){
+        SbInfo sbInfo = sbInfoService.getModelById(model.getSbId());
+        SysUser user = sysUserMapper.selectByPrimaryKey(model.getRepairUserId());
+        // 1、站内信
+        String domain = getAndCheckPcDomain();
+        String repairUrl = domain + "repair/form?no=" + model.getNo();
+        // 获取站内信内容
+        String info = MessageTemplateUtil.getVmHtmlContent(repairUrl,
+                model, sbInfo);
+        sendWorkplaceAndEmailNew(ListUtils.newArrayList(user.getEmail()),
+                ListUtils.newArrayList(user.getUserId()),model.getId(),info, WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue());
+        // 2、微信
+        String[] values = new String[]{"你有一条维修任务!",model.getActualUser(),sbInfo.getName(),DateUtils.dateToString(model.getApplyTime()),model.getSbCph(),model.getContent(),"请知悉"};
+        String wechatTemplateId = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_NOTICE_SUCCESS_WECHAT_TEMPLATE_ID.name());
+        String detailUrl = "pages/service-detail/service-detail?id=" + model.getId();
+        SendMessageUtils.sendWechatNew(ListUtils.newArrayList(user.getWxOpenId()),detailUrl,values,wechatTemplateId,1);
+        // 3、短信
+        SendMessageUtils.sendCommonSms(ListUtils.newArrayList(user.getPhone()),info);
     }
 
-//    public static void main(String[] args) {
-//        String str="asdf,afdasdg,lksd";
-//        String arr[]=getStringArarry(str);
-//        for(String s:arr){
-//            System.out.println(s);
-//        }
-//    }
-
     @Override
     public RepairApplicationForm submitRepair(RepairApplicationFormDTO model) {
         RepairApplicationForm applicationForm = super.submitRepair(model);