|
@@ -0,0 +1,454 @@
|
|
|
+package com.platform.service.repair.strategy.impl;
|
|
|
+
|
|
|
+import com.platform.common.cache.ConfigCache;
|
|
|
+import com.platform.common.constant.CommonConstants;
|
|
|
+import com.platform.common.exception.DeniedException;
|
|
|
+import com.platform.common.util.*;
|
|
|
+import com.platform.dao.dto.repair.RepairApplicationFormDTO;
|
|
|
+import com.platform.dao.dto.repair.RepairRecordTemplateData;
|
|
|
+import com.platform.dao.dto.repair.RepairStatusTemplateData;
|
|
|
+import com.platform.dao.dto.upms.SysUserDTO;
|
|
|
+import com.platform.dao.entity.customize.CustomFieldTemplateData;
|
|
|
+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.RepairApplicationFormStatusEnum;
|
|
|
+import com.platform.dao.enums.SysConfigEnum;
|
|
|
+import com.platform.dao.enums.SysRoleCodeEnum;
|
|
|
+import com.platform.dao.enums.WorkplaceBacklogDetailTypeEnum;
|
|
|
+import com.platform.dao.mapper.customize.CustomFieldTemplateDataMapper;
|
|
|
+import com.platform.dao.mapper.upms.SysUserMapper;
|
|
|
+import com.platform.dao.util.MessageTemplateUtil;
|
|
|
+import com.platform.dao.vo.SysUserVO;
|
|
|
+import com.platform.service.repair.strategy.AbstractRepairBaseStrategy;
|
|
|
+import com.platform.service.util.SendMessageUtils;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import tk.mybatis.mapper.weekend.Weekend;
|
|
|
+import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 维修接单模式 -- 龙岩
|
|
|
+ * 报修指定
|
|
|
+ * 维修主管出方案
|
|
|
+ * 多个维修人执行
|
|
|
+ * 维修审核
|
|
|
+ * 生产审核
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class LongYanRepairStrategy extends AbstractRepairBaseStrategy {
|
|
|
+ @Resource
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
+ @Resource
|
|
|
+ private CustomFieldTemplateDataMapper customFieldTemplateDataMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 龙岩报修人报修
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public RepairApplicationForm callRepair(RepairApplicationFormDTO model) {
|
|
|
+ RepairApplicationForm form = super.callRepair(model);
|
|
|
+ // 设置报修推送地方
|
|
|
+ if(StringUtils.isBlank(model.getRepairDeptId())){
|
|
|
+ throw new DeniedException("报修必须选择维修部门");
|
|
|
+ }
|
|
|
+ SysUserDTO queryUserDTO = new SysUserDTO();
|
|
|
+ queryUserDTO.setDeptId(model.getRepairDeptId());
|
|
|
+ queryUserDTO.setRoleCode(SysRoleCodeEnum.REPAIR_MANAGE.name());
|
|
|
+ List<SysUserVO> sysUserVOList = sysUserMapper.selectDeptRoleUser(queryUserDTO);
|
|
|
+ if(sysUserVOList == null || sysUserVOList.size() ==0 || sysUserVOList.size() > 1){
|
|
|
+ throw new DeniedException("您选择的维修部门,无维修主管或存在多个维修主管");
|
|
|
+ }
|
|
|
+ form.setDispatchUserId(sysUserVOList.get(0).getUserId());
|
|
|
+ // 报修人
|
|
|
+ form.setActualUser(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ form.setUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ repairApplicationFormMapper.insert(form);
|
|
|
+ // 记录维修状态跟踪
|
|
|
+ addRepairStatusRecord(form,"报修");
|
|
|
+ // 给相关的维修主管推送信息
|
|
|
+ sendMessageToRepairManger(form,sysUserVOList.get(0),CommonConstants.CALL_REPAIR_NOTICE);
|
|
|
+ return form;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RepairApplicationForm callRepairAgain(RepairApplicationFormDTO model) {
|
|
|
+ RepairApplicationForm form = repairApplicationFormMapper.selectByPrimaryKey(model.getId());
|
|
|
+ SysUserDTO queryUserDTO = new SysUserDTO();
|
|
|
+ queryUserDTO.setDeptId(model.getRepairDeptId());
|
|
|
+ queryUserDTO.setRoleCode(SysRoleCodeEnum.REPAIR_MANAGE.name());
|
|
|
+ List<SysUserVO> sysUserVOList = sysUserMapper.selectDeptRoleUser(queryUserDTO);
|
|
|
+ if(sysUserVOList == null || sysUserVOList.size() ==0 || sysUserVOList.size() > 1){
|
|
|
+ throw new DeniedException("您选择的维修部门,无维修主管或存在多个维修主管");
|
|
|
+ }
|
|
|
+ form.setDispatchUserId(sysUserVOList.get(0).getUserId());
|
|
|
+ form.setStatus(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
|
|
|
+ repairApplicationFormMapper.updateByPrimaryKeySelective(form);
|
|
|
+ // 给相关的维修主管推送信息
|
|
|
+ sendMessageToRepairManger(form,sysUserVOList.get(0),CommonConstants.CALL_REPAIR_NOTICE);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 记录维修状态
|
|
|
+ * @param form
|
|
|
+ */
|
|
|
+ private void addRepairStatusRecord(RepairApplicationForm form,String remark){
|
|
|
+ CustomFieldTemplateData data = new CustomFieldTemplateData();
|
|
|
+ data.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ data.setObjId(form.getId());
|
|
|
+ data.setCreatedTime(LocalDateTime.now());
|
|
|
+ data.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ data.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ data.setRemark(CommonConstants.REPAIR_STATUS_RECORD);
|
|
|
+ RepairStatusTemplateData dataInfo = new RepairStatusTemplateData();
|
|
|
+ dataInfo.setRemark(remark);
|
|
|
+ dataInfo.setStatus(form.getStatus());
|
|
|
+ data.setData(JsonUtils.objectToJson(dataInfo));
|
|
|
+ customFieldTemplateDataMapper.insert(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修主管接收并指派报修人
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public RepairApplicationFormDTO sendRepair(RepairApplicationFormDTO model) {
|
|
|
+ RepairApplicationFormDTO superModel = super.sendRepair(model);
|
|
|
+ if(StringUtils.isBlank(superModel.getRepairUserId())){
|
|
|
+ throw new DeniedException("请指派维修人");
|
|
|
+ }
|
|
|
+ SysUser repairUser = sysUserMapper.selectByPrimaryKey(superModel.getRepairUserId());
|
|
|
+ superModel.setRepairUserName(repairUser.getUsername());
|
|
|
+ // 修改维修状态并记录
|
|
|
+ RepairApplicationForm applicationForm = new RepairApplicationForm();
|
|
|
+ applicationForm.setId(model.getId());
|
|
|
+ applicationForm.setRepairUserId(superModel.getRepairUserId()); // 当前维修人
|
|
|
+ applicationForm.setRepairUserName(repairUser.getUsername());
|
|
|
+ applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
|
|
|
+ superModel.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
|
|
|
+ superModel.setRepairUserName(repairUser.getUsername());
|
|
|
+ if (superModel.getRepairStartTime() == null) {
|
|
|
+ applicationForm.setRepairStartTime(LocalDateTime.now());
|
|
|
+ superModel.setRepairStartTime(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ applicationForm.setReceiveMinutes(DateUtils.getDurationHours(superModel.getApplyTime(), superModel.getRepairStartTime()));
|
|
|
+ // 判断接单是否超时
|
|
|
+ String minuteStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_WARN_MINUTE.name());
|
|
|
+ if (StringUtils.isBlank(minuteStr)) {
|
|
|
+ applicationForm.setReceiveOvertime(false);
|
|
|
+ } else if (applicationForm.getReceiveMinutes() > Double.valueOf(minuteStr)) {
|
|
|
+ applicationForm.setReceiveOvertime(true);
|
|
|
+ } else {
|
|
|
+ applicationForm.setReceiveOvertime(false);
|
|
|
+ }
|
|
|
+ applicationForm.setUpdateTime(LocalDateTime.now());
|
|
|
+ repairApplicationFormMapper.updateByPrimaryKeySelective(applicationForm);
|
|
|
+ // 添加状态跟踪
|
|
|
+ addRepairStatusRecord(BeanConverterUtil.copyObjectProperties(superModel,RepairApplicationForm.class),"维修中");
|
|
|
+ // 添加维修记录
|
|
|
+ addRepairRecord(superModel);
|
|
|
+ // 给报修人发送消息
|
|
|
+ sendMessageToRepairCaller(superModel,CommonConstants.CALL_REPAIR_PASS);
|
|
|
+ // 给维修人发送消息
|
|
|
+ sendMessageToRepairer(superModel);
|
|
|
+ // 启动超时监控
|
|
|
+ overTimeListen(model.getId());
|
|
|
+ return superModel;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报修驳回
|
|
|
+ * @param model
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void refusedRepair(RepairApplicationFormDTO model) {
|
|
|
+ RepairApplicationForm updRepair = new RepairApplicationForm();
|
|
|
+ updRepair.setId(model.getId());
|
|
|
+ updRepair.setRemark(model.getRemark());
|
|
|
+ updRepair.setStatus(RepairApplicationFormStatusEnum.REFUSED_REPAIR.getValue());
|
|
|
+ repairApplicationFormMapper.updateByPrimaryKeySelective(updRepair);
|
|
|
+ // 添加状态记录
|
|
|
+ addRepairStatusRecord(updRepair,"报修驳回");
|
|
|
+ // 通知报修人
|
|
|
+ sendMessageToRepairCaller(model,CommonConstants.CALL_REPAIR_REFUSED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人能力无法胜任本次维修,辜负了主管的信任
|
|
|
+ * @param model
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void stopRepairByPerson(RepairApplicationFormDTO model) {
|
|
|
+ // 1、完善终止人的维修记录
|
|
|
+ RepairApplicationForm form = repairApplicationFormMapper.selectById(model.getId());
|
|
|
+ double hours = editRepairRecord(model,CommonConstants.REPAIR_RECORD_EDIT_STOP);
|
|
|
+ // 2、回写并修改维修表
|
|
|
+ RepairApplicationForm updRepair = new RepairApplicationForm();
|
|
|
+ updRepair.setId(model.getId());
|
|
|
+ updRepair.setRemark(model.getRemark());
|
|
|
+ updRepair.setStatus(RepairApplicationFormStatusEnum.REPAIR_FAIL.getValue());
|
|
|
+ updRepair.setRepairMinutes(form.getRepairMinutes() + hours);
|
|
|
+ updRepair.setRepairUserName(null);
|
|
|
+ updRepair.setRepairUserId(null);
|
|
|
+ repairApplicationFormMapper.updateLongYan(updRepair);
|
|
|
+ // 3、状态记录表
|
|
|
+ addRepairStatusRecord(updRepair,"维修转派中");
|
|
|
+ // 4、通知维修主管
|
|
|
+ sendMessageToRepairManger(form,BeanConverterUtil.copyObjectProperties(sysUserMapper.selectByPrimaryKey(model.getDispatchUserId()),SysUserVO.class),CommonConstants.REPAIR_FAIL_NOTICE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修人提交维修完成
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public RepairApplicationFormDTO handleRepair(RepairApplicationFormDTO dto) {
|
|
|
+ super.handleRepair(dto);
|
|
|
+ RepairApplicationForm form = repairApplicationFormMapper.selectById(dto.getId());
|
|
|
+ // 计算维修时长
|
|
|
+ double hours = editRepairRecord(dto,CommonConstants.REPAIR_RECORD_EDIT_ADD);
|
|
|
+ form.setRepairMinutes(form.getRepairMinutes() + hours);
|
|
|
+ // 判断维修是否超时
|
|
|
+ String hourFirstStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_OVERTIME_MINUTE_FIRST.name());
|
|
|
+ int hourFirst = 180;// 默认3小时,180分钟
|
|
|
+ if (StringUtils.isNotBlank(hourFirstStr)) {
|
|
|
+ hourFirst = Integer.valueOf(hourFirstStr) * 60;
|
|
|
+ }
|
|
|
+ if (form.getRepairMinutes() > hourFirst) {
|
|
|
+ form.setRepairOvertime(true);
|
|
|
+ } else {
|
|
|
+ form.setRepairOvertime(false);
|
|
|
+ }
|
|
|
+ repairApplicationFormMapper.updateByPrimaryKeySelective(form);
|
|
|
+ // 添加状态记录
|
|
|
+ addRepairStatusRecord(form,"维修完成待审");
|
|
|
+ // 通知维修主管审核
|
|
|
+ SysUserVO vo = BeanConverterUtil.copyObjectProperties(sysUserMapper.selectByPrimaryKey(form.getDispatchUserId()),SysUserVO.class);
|
|
|
+ sendMessageToRepairManger(form,vo,CommonConstants.REPAIR_COMPLETE_NOTICE);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交生产审核
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public RepairApplicationForm submitRepair(RepairApplicationFormDTO model) {
|
|
|
+ RepairApplicationForm form = super.submitRepair(model);
|
|
|
+ // 添加状态跟踪
|
|
|
+ addRepairStatusRecord(form,"待生产确认");
|
|
|
+ // 通知报修人(生产审核)
|
|
|
+ sendMessageToRepairCaller(BeanConverterUtil.copyObjectProperties(form,RepairApplicationFormDTO.class),CommonConstants.CALL_REPAIR_SUCCESS);
|
|
|
+ return form;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生产审核通过
|
|
|
+ * @param model
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void verifyRepair(RepairApplicationFormDTO model) {
|
|
|
+ super.verifyRepair(model);
|
|
|
+ RepairApplicationForm form = repairApplicationFormMapper.selectById(model.getId());
|
|
|
+ // 添加跟踪状态
|
|
|
+ addRepairStatusRecord(form,"维修完成");
|
|
|
+ // 通知主管,是否通知维修人
|
|
|
+ SysUserVO vo = BeanConverterUtil.copyObjectProperties(sysUserMapper.selectByPrimaryKey(form.getDispatchUserId()),SysUserVO.class);
|
|
|
+ sendMessageToRepairManger(form,vo,CommonConstants.CALL_REPAIR_FINISH);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RepairApplicationFormDTO verifyRefused(RepairApplicationFormDTO model) {
|
|
|
+ super.verifyRefused(model);
|
|
|
+ RepairApplicationForm form = repairApplicationFormMapper.selectById(model.getId());
|
|
|
+ // 添加跟踪状态
|
|
|
+ addRepairStatusRecord(form,"生产驳回");
|
|
|
+ // 通知主管,再次派工维修
|
|
|
+ SysUserVO vo = BeanConverterUtil.copyObjectProperties(sysUserMapper.selectByPrimaryKey(form.getDispatchUserId()),SysUserVO.class);
|
|
|
+ sendMessageToRepairManger(form,vo,CommonConstants.CALL_REPAIR_FAIL);
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据情况修改数据
|
|
|
+ * @param form
|
|
|
+ * @param type 1 回写数据 2 终止
|
|
|
+ */
|
|
|
+ private double editRepairRecord(RepairApplicationFormDTO form,String type){
|
|
|
+ double hours = 0.0;
|
|
|
+ // 获取维修记录
|
|
|
+ Weekend<CustomFieldTemplateData> weekend = new Weekend<>(CustomFieldTemplateData.class);
|
|
|
+ WeekendCriteria<CustomFieldTemplateData, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(CustomFieldTemplateData::getRemark,CommonConstants.REPAIR_STATUS_RECORD)
|
|
|
+ .andEqualTo(CustomFieldTemplateData::getObjId,form.getId()).
|
|
|
+ andEqualTo(CustomFieldTemplateData::getCreatedUserId,form.getRepairUserId());
|
|
|
+ weekend.orderBy("createdTime").desc();
|
|
|
+ List<CustomFieldTemplateData> list = customFieldTemplateDataMapper.selectByExample(weekend);
|
|
|
+ if(list == null || list.size() == 0){
|
|
|
+ throw new DeniedException("维修记录异常,请联系技术处理");
|
|
|
+ }
|
|
|
+ CustomFieldTemplateData queryData = list.get(0);
|
|
|
+ CustomFieldTemplateData updData = new CustomFieldTemplateData();
|
|
|
+ updData.setId(queryData.getId());
|
|
|
+ updData.setUpdateTime(LocalDateTime.now());
|
|
|
+ RepairRecordTemplateData dataInfo = JsonUtils.jsonToModel(queryData.getData(),RepairRecordTemplateData.class);
|
|
|
+ switch (type){
|
|
|
+ case CommonConstants.REPAIR_RECORD_EDIT_STOP: // 终止维修,计算时长
|
|
|
+ updData.setUpdateTime(LocalDateTime.now());
|
|
|
+ hours = DateUtils.getDurationHours(queryData.getCreatedTime(), updData.getUpdateTime());
|
|
|
+ dataInfo.setRepairMinutes(hours);
|
|
|
+ dataInfo.setRemark(form.getRemark());
|
|
|
+ dataInfo.setImageList(form.getImageList());
|
|
|
+ dataInfo.setFile(form.getFile());
|
|
|
+ break;
|
|
|
+ case CommonConstants.REPAIR_RECORD_EDIT_ADD: // 完成维修
|
|
|
+ updData.setUpdateTime(LocalDateTime.now());
|
|
|
+ hours = DateUtils.getDurationHours(queryData.getCreatedTime(), updData.getUpdateTime());
|
|
|
+ dataInfo.setRepairMinutes(hours);
|
|
|
+ dataInfo.setImageList(form.getImageList());
|
|
|
+ dataInfo.setFile(form.getFile());
|
|
|
+ dataInfo.setRemark(form.getRemark());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ updData.setData(JsonUtils.objectToJson(dataInfo));
|
|
|
+ customFieldTemplateDataMapper.updateByPrimaryKeySelective(updData);
|
|
|
+ return hours;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加维修记录
|
|
|
+ * @param form
|
|
|
+ */
|
|
|
+ private void addRepairRecord(RepairApplicationFormDTO form){
|
|
|
+ CustomFieldTemplateData data = new CustomFieldTemplateData();
|
|
|
+ data.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ data.setObjId(form.getId());
|
|
|
+ data.setCreatedTime(LocalDateTime.now());
|
|
|
+ data.setCreatedUserId(form.getRepairUserId());
|
|
|
+ data.setCreatedUserName(form.getRepairUserName());
|
|
|
+ data.setRemark(CommonConstants.REPAIR_RECORD);
|
|
|
+ RepairRecordTemplateData dataInfo = new RepairRecordTemplateData();
|
|
|
+ dataInfo.setRemark("");
|
|
|
+ dataInfo.setRepairMinutes(0.0);
|
|
|
+ dataInfo.setFile("");
|
|
|
+ dataInfo.setImageList("");
|
|
|
+ data.setData(JsonUtils.objectToJson(dataInfo));
|
|
|
+ customFieldTemplateDataMapper.insert(data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给报修人发送消息
|
|
|
+ * @param model
|
|
|
+ * @param type 1 报修成功 2 报修驳回 3 维修成功
|
|
|
+ */
|
|
|
+ private void sendMessageToRepairCaller(RepairApplicationFormDTO model,String type){
|
|
|
+ SysUser user = sysUserMapper.selectByPrimaryKey(model.getUserId()); // 推送对象
|
|
|
+ String messageInfo = ""; // 通知内容
|
|
|
+ Integer detailType = WorkplaceBacklogDetailTypeEnum.REPAIR_RECEIVE.getValue();
|
|
|
+ String[] values = null; // 微信填充内容
|
|
|
+ String wechatTemplateId = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_RECEIVE_SUCCESS_WECHAT_TEMPLATE_ID.name()); // 微信模板ID
|
|
|
+ String detailUrl = "pages/repair-detail/repair-detail?detailId=" + model.getId(); // 微信跳转url
|
|
|
+ switch (type){
|
|
|
+ case CommonConstants.CALL_REPAIR_PASS:
|
|
|
+ messageInfo = MessageTemplateUtil.getReceive(model.getNo());
|
|
|
+ values = new String[]{"您提交的报修单已被接收并开始维修!",model.getNo(),"维修中",DateUtils.dateToString(model.getRepairStartTime()),"请知悉"};
|
|
|
+ break;
|
|
|
+ case CommonConstants.CALL_REPAIR_REFUSED:
|
|
|
+ messageInfo = MessageTemplateUtil.getRefusedReceive(model.getNo(),model.getRemark());
|
|
|
+ values = new String[]{"您提交的报修单已被驳回!",model.getNo(),"报修驳回","","请知悉"};
|
|
|
+ break;
|
|
|
+ case CommonConstants.CALL_REPAIR_SUCCESS:
|
|
|
+ messageInfo = MessageTemplateUtil.getRepairSuccess(model.getNo());
|
|
|
+ values = new String[]{"您提交的报修单已维修完成!",model.getNo(),"报修完成","","请知悉"};
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // 1、站内信和email
|
|
|
+ sendWorkplaceAndEmailNew(ListUtils.newArrayList(user.getEmail()),
|
|
|
+ ListUtils.newArrayList(user.getUserId()),model.getId(),messageInfo, detailType);
|
|
|
+ // 2、微信
|
|
|
+ SendMessageUtils.sendWechatNew(ListUtils.newArrayList(user.getWxOpenId()),detailUrl,values,wechatTemplateId);
|
|
|
+ // 3、短信
|
|
|
+ if(StringUtils.isNotBlank(user.getPhone()) && user.getPhone().trim().length() == 11){
|
|
|
+ SendMessageUtils.sendCommonSms(ListUtils.newArrayList(user.getPhone()),messageInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给维修人发送消息
|
|
|
+ * @param model
|
|
|
+ */
|
|
|
+ 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.getFreemarkerHtmlContent(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/repair-detail/repair-detail?detailId=" + model.getId();
|
|
|
+ SendMessageUtils.sendWechatNew(ListUtils.newArrayList(user.getWxOpenId()),detailUrl,values,wechatTemplateId);
|
|
|
+ // 3、短信
|
|
|
+ SendMessageUtils.sendCommonSms(ListUtils.newArrayList(user.getPhone()),info);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给维修主管推送消息
|
|
|
+ * @param form
|
|
|
+ * @param type 1 报修通知 2 维修终止通知 3 维修完成 4 生产驳回
|
|
|
+ */
|
|
|
+ private void sendMessageToRepairManger(RepairApplicationForm form,SysUserVO userVO,String type){
|
|
|
+ SbInfo sbInfo = sbInfoService.getModelById(form.getSbId());
|
|
|
+ String domain = getAndCheckPcDomain();
|
|
|
+ String repairUrl = domain + "repair/form?no=" + form.getNo();
|
|
|
+ String info = MessageTemplateUtil.getFreemarkerHtmlContent(repairUrl,
|
|
|
+ BeanConverterUtil.copyObjectProperties(form,RepairApplicationFormDTO.class), sbInfo);
|
|
|
+ Integer detailType = WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue();;
|
|
|
+ String[] values = null;
|
|
|
+ String wechatTemplateId = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_SEND_SUCCESS_WECHAT_TEMPLATE_ID.name());;
|
|
|
+ String detailUrl = "pages/repair-detail/repair-detail?detailId=" + form.getId();;
|
|
|
+ switch (type){
|
|
|
+ case CommonConstants.CALL_REPAIR_NOTICE:
|
|
|
+ values = new String[]{"贵部有一条新的报修消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请知悉"};
|
|
|
+ break;
|
|
|
+ case CommonConstants.REPAIR_FAIL_NOTICE:
|
|
|
+ values = new String[]{"维修单终止维修消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请再次派工"};
|
|
|
+ detailType = WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION_STOP.getValue();
|
|
|
+ break;
|
|
|
+ case CommonConstants.REPAIR_COMPLETE_NOTICE:
|
|
|
+ values = new String[]{"维修完成消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请确认后,提交生产审核"};
|
|
|
+ detailType = WorkplaceBacklogDetailTypeEnum.REPAIR_OK.getValue();
|
|
|
+ break;
|
|
|
+ case CommonConstants.CALL_REPAIR_FAIL:
|
|
|
+ values = new String[]{"维修审核驳回消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请知悉"};
|
|
|
+ detailType = WorkplaceBacklogDetailTypeEnum.REPAIR_BACK.getValue();
|
|
|
+ break;
|
|
|
+ case CommonConstants.CALL_REPAIR_FINISH:
|
|
|
+ values = new String[]{"维修生产通过消息!",form.getNo(),sbInfo.getName(),form.getContent(),form.getSbCph(),"请知悉"};
|
|
|
+ detailType = WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // 1、站内信
|
|
|
+ sendWorkplaceAndEmailNew(ListUtils.newArrayList(userVO.getEmail()),
|
|
|
+ ListUtils.newArrayList(userVO.getUserId()),form.getId(),info, detailType);
|
|
|
+ // 2、微信
|
|
|
+ SendMessageUtils.sendWechatNew(ListUtils.newArrayList(userVO.getWxOpenId()),detailUrl,values,wechatTemplateId);
|
|
|
+ // 3、短信
|
|
|
+ SendMessageUtils.sendCommonSms(ListUtils.newArrayList(userVO.getPhone()),info);
|
|
|
+ }
|
|
|
+}
|