|
@@ -13,19 +13,24 @@ import com.platform.dao.entity.repair.RepairApplicationForm;
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
import com.platform.dao.entity.upms.SysUser;
|
|
import com.platform.dao.entity.upms.SysUser;
|
|
import com.platform.dao.enums.*;
|
|
import com.platform.dao.enums.*;
|
|
|
|
+import com.platform.dao.mapper.upms.SysUserMapper;
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
import com.platform.dao.vo.SysUserVO;
|
|
import com.platform.dao.vo.SysUserVO;
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
import com.platform.service.repair.strategy.AbstractRepairBaseStrategy;
|
|
import com.platform.service.repair.strategy.AbstractRepairBaseStrategy;
|
|
|
|
+import com.platform.service.util.SendMessageUtils;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class AllocateRepairBaseStrategy extends AbstractRepairBaseStrategy {
|
|
public class AllocateRepairBaseStrategy extends AbstractRepairBaseStrategy {
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public RepairApplicationForm callRepair(RepairApplicationFormDTO model) {
|
|
public RepairApplicationForm callRepair(RepairApplicationFormDTO model) {
|
|
@@ -140,67 +145,56 @@ public class AllocateRepairBaseStrategy extends AbstractRepairBaseStrategy {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public RepairApplicationFormDTO sendRepair(RepairApplicationFormDTO model) {
|
|
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;
|
|
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
|
|
@Override
|
|
public RepairApplicationForm submitRepair(RepairApplicationFormDTO model) {
|
|
public RepairApplicationForm submitRepair(RepairApplicationFormDTO model) {
|
|
RepairApplicationForm applicationForm = super.submitRepair(model);
|
|
RepairApplicationForm applicationForm = super.submitRepair(model);
|