|
@@ -2,14 +2,17 @@ package com.platform.service.repair.strategy.impl;
|
|
|
|
|
|
import com.platform.common.cache.ConfigCache;
|
|
|
import com.platform.common.constant.CommonConstants;
|
|
|
+import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.exception.DeniedException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.dto.repair.*;
|
|
|
+import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
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.sb.SbPosition;
|
|
|
import com.platform.dao.entity.upms.SysConfig;
|
|
|
import com.platform.dao.entity.upms.SysUser;
|
|
|
import com.platform.dao.enums.*;
|
|
@@ -208,6 +211,48 @@ public class LongYanRepairStrategy extends AbstractRepairBaseStrategy {
|
|
|
customFieldTemplateDataMapper.insert(info);
|
|
|
}
|
|
|
|
|
|
+ private void updateGenerateTicketData(RepairApplicationForm form){
|
|
|
+ // 没有记录,增加记录值
|
|
|
+ CustomFieldTemplateData info = new CustomFieldTemplateData();
|
|
|
+ info.setObjId(form.getId());
|
|
|
+ info = customFieldTemplateDataMapper.selectOne(info);
|
|
|
+ info.setUpdateTime(LocalDateTime.now());
|
|
|
+ SbInfo sbInfo = sbInfoService.getModelById(form.getSbId());
|
|
|
+ RepairTicketTemplateData data = new RepairTicketTemplateData();
|
|
|
+ data.setCaller(sysUserMapper.selectByPrimaryKey(form.getUserId()).getRealName());
|
|
|
+ data.setSbPositionName(form.getSbPosition());
|
|
|
+ data.setCallTime(DateUtils.dateToString(form.getApplyTime(),DateUtils.PATTERN_YMD_HMS));
|
|
|
+ data.setContent(form.getContent());
|
|
|
+ if(StringUtils.isNotBlank(form.getDispatchUserId())){
|
|
|
+ data.setDispatcher(sysUserMapper.selectByPrimaryKey(form.getDispatchUserId()).getRealName());
|
|
|
+ }
|
|
|
+ // 维修专业
|
|
|
+ String[] arr1 = form.getRepairProfessor().split(",");
|
|
|
+ List<Integer> arrays1 = ListUtils.newArrayList();
|
|
|
+ for(String s : arr1){
|
|
|
+ arrays1.add(Integer.parseInt(s));
|
|
|
+ }
|
|
|
+ data.setRepairProfessor(arrays1);
|
|
|
+ // 涉及特殊作业类型
|
|
|
+ String[] arr = form.getRepairType().split(",");
|
|
|
+ List<Integer> arrays = ListUtils.newArrayList();
|
|
|
+ for(String s : arr){
|
|
|
+ arrays.add(Integer.parseInt(s));
|
|
|
+ }
|
|
|
+ data.setRepairType(arrays);
|
|
|
+ data.setLevel(form.getLevel());
|
|
|
+ data.setRepairNo(form.getNo());
|
|
|
+ data.setSbLocation(form.getSbCph());
|
|
|
+ data.setSbName(sbInfo.getName());
|
|
|
+ data.setSbNo(sbInfo.getPositionNo());
|
|
|
+ data.setTrustDept(form.getTrustDept());
|
|
|
+ data.setPlanStartTime(DateUtils.dateToString(form.getPlanStartTime(),DateUtils.PATTERN_YMD_HMS));
|
|
|
+ data.setPlanEndTime(DateUtils.dateToString(form.getPlanEndTime(),DateUtils.PATTERN_YMD_HMS));
|
|
|
+ data.setRepairFormType(form.getRepairFormType());
|
|
|
+ info.setData(JsonUtils.objectToJson(data));
|
|
|
+ customFieldTemplateDataMapper.updateByPrimaryKey(info);
|
|
|
+ }
|
|
|
+
|
|
|
private List<SysUserVO> getUserVOs(String user){
|
|
|
String[] users = user.split(",");
|
|
|
List<SysUserVO> vos = ListUtils.newArrayList();
|
|
@@ -338,19 +383,124 @@ public class LongYanRepairStrategy extends AbstractRepairBaseStrategy {
|
|
|
@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("您选择的维修部门,无维修主管或存在多个维修主管");
|
|
|
+ if(form == null){
|
|
|
+ throw new DeniedException("撤回报修单不存在");
|
|
|
+ }
|
|
|
+ // 判断设备录入方式
|
|
|
+ if(model.getInputType() == null){
|
|
|
+ throw new DeniedException("设备录入方式不能为空");
|
|
|
+ }
|
|
|
+ SbInfo sb = null;
|
|
|
+ if(model.getInputType() == 1){
|
|
|
+ if(StringUtils.isBlank(model.getSbName()) && StringUtils.isBlank(model.getPositionNo())){
|
|
|
+ throw new DeniedException("请填写报修设备信息");
|
|
|
+ }
|
|
|
+ // 手动录入
|
|
|
+ sb = packageSb(model.getSbName(),model.getPositionNo(),model.getPositionId(),model.getSbCph());
|
|
|
+ }else{
|
|
|
+ if(StringUtils.isBlank(model.getSbId())){
|
|
|
+ throw new DeniedException("请填写报修设备");
|
|
|
+ }
|
|
|
+ String sbId = model.getSbId();
|
|
|
+ sb = sbInfoService.getModelById(sbId);
|
|
|
+ if (sb == null) {
|
|
|
+ throw new DeniedException("设备不存在,无法报修");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ form.setSbId(sb.getId());
|
|
|
+ form.setModelId(sb.getModelId());
|
|
|
+ form.setLevel(model.getLevel());
|
|
|
+ form.setSbCph(model.getSbCph());
|
|
|
+ form.setPlanStartTime(model.getPlanStartTime());
|
|
|
+ form.setPlanEndTime(model.getPlanEndTime());
|
|
|
+ form.setRepairFormType(model.getRepairFormType());
|
|
|
+ // 根据配置判断是否可以多个提交
|
|
|
+ String only = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_ONLY_ONE.name());
|
|
|
+ if (StringUtils.isNotBlank(only) && Integer.valueOf(only).equals(RepairOnlyOneEnum.ONLY_ONE.getValue())) {
|
|
|
+ if (sb.getStatus().intValue() == SbInfoStatusEnum.IN_MAINTAIN.getValue()) {
|
|
|
+ throw new BusinessException("设备已经在维修中,请等待维修完成, sbId" + model.getSbId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果保修的设备位置和设备本身不一样,则可以更新该设备
|
|
|
+ boolean updateSb = false;
|
|
|
+ SbInfoDTO info = BeanConverterUtil.copyObjectProperties(sb, SbInfoDTO.class);
|
|
|
+ if (StringUtils.isNotBlank(model.getSbCph()) && !model.getSbCph().equalsIgnoreCase((sb.getCph()))) {
|
|
|
+ info.setCph(model.getSbCph());
|
|
|
+ updateSb = true;
|
|
|
+ }
|
|
|
+ // 如果选择了设备停机,则要修改设备状态,记录设备状态变更变
|
|
|
+ if (model.getNeedStop() != null && model.getNeedStop().intValue() == RepairApplicationFormStopEnum.STOP.getValue()) {
|
|
|
+ info.setStatus(SbInfoStatusEnum.IN_STOP.getValue());
|
|
|
+ updateSb = true;
|
|
|
+ }
|
|
|
+ if (updateSb) {
|
|
|
+ info.setChangeReason("维修停机");
|
|
|
+ info.setActualUser(model.getActualUser());
|
|
|
+ sbInfoService.updateStatus(info);
|
|
|
}
|
|
|
- form.setDispatchUserId(sysUserVOList.get(0).getUserId());
|
|
|
form.setStatus(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
|
|
|
- repairApplicationFormMapper.updateByPrimaryKeySelective(form);
|
|
|
- // 给相关的维修主管推送信息
|
|
|
- sendMessageToRepairManger(form,sysUserVOList,CommonConstants.CALL_REPAIR_NOTICE);
|
|
|
- return null;
|
|
|
+ form.setApplyTime(LocalDateTime.now());
|
|
|
+ form.setCreatedTime(model.getApplyTime());
|
|
|
+ form.setUpdateTime(model.getApplyTime());
|
|
|
+ sysFileService.saveFile(model.getId(), SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue(), model.getApplicationFileList());
|
|
|
+ sysFileService.saveFile(model.getId(),SysFileTypeEnum.REPAIR_APPLICATION_FILES.getValue(),model.getReportFileList());
|
|
|
+ if(StringUtils.isNotBlank(sb.getPositionId())){
|
|
|
+ // 车间位置
|
|
|
+ SbPosition sbPosition = sbPositionMapper.selectByPrimaryKey(sb.getPositionId());
|
|
|
+ if(sbPosition != null){
|
|
|
+ String topName = sbPositionMapper.selectNameById(sbPosition.getParentId());
|
|
|
+ form.setSbPosition(topName + "->" + sbPosition.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 是否具有报修权限
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
+ if(userInfo.getSuperAdmin() == 0){
|
|
|
+ // 根据用户的角色来定
|
|
|
+ String role = getCurrentRoles();
|
|
|
+ if(!role.contains(SysRoleCodeEnum.REPAIR_EXAMINE.name())){
|
|
|
+ throw new DeniedException("您不具有报修报修权限,如需报修,请管理员配置权限!");
|
|
|
+ }
|
|
|
+ if(role.contains(SysRoleCodeEnum.REPAIR_EXAMINE.name())){
|
|
|
+ // 生产部
|
|
|
+ form.setTrustDept(TrustDeptEnum.PRODUCE.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String repairDeptId = model.getRepairDeptId();
|
|
|
+ if(StringUtils.isBlank(repairDeptId)){
|
|
|
+ throw new DeniedException("送修部门不能为空!");
|
|
|
+ }
|
|
|
+ form.setRepairDeptId(repairDeptId); // 存储维修部门ID
|
|
|
+ List<SysUserVO> sysUserVOList = getRepairMangers(repairDeptId,null,SysRoleCodeEnum.REPAIR_MANAGE.name());
|
|
|
+ if(sysUserVOList == null || sysUserVOList.size() ==0){
|
|
|
+ throw new DeniedException("该维修部门,没有工程师,请确认!");
|
|
|
+ }
|
|
|
+ // 区域负责人
|
|
|
+ form.setReportLeaderId(getReportLeaderId(form.getSbId()));
|
|
|
+ repairApplicationFormMapper.updateByPrimaryKey(form);
|
|
|
+ // 记录维修状态跟踪
|
|
|
+ addRepairStatusRecord(form,"二次报修");
|
|
|
+ // 给相关的工程师推送信息
|
|
|
+ // 给生产工程师和区域负责人发信息
|
|
|
+ List<SysUserVO> mmScb = ListUtils.newArrayList();
|
|
|
+ sysUserVOList.forEach(item->{
|
|
|
+ mmScb.add(item);
|
|
|
+ });
|
|
|
+ sysUserVOList = getRepairMangers(null,null,SysRoleCodeEnum.MM.name());
|
|
|
+ if(sysUserVOList != null && sysUserVOList.size() > 0){
|
|
|
+ sysUserVOList.forEach(item->{
|
|
|
+ mmScb.add(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ sysUserVOList = getRepairMangers(null,null,SysRoleCodeEnum.SCB.name());
|
|
|
+ if(sysUserVOList != null && sysUserVOList.size() > 0){
|
|
|
+ sysUserVOList.forEach(item->{
|
|
|
+ mmScb.add(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ sendMessageToRepairManger(form,mmScb,CommonConstants.CALL_REPAIR_NOTICE);
|
|
|
+ // 更新生产票证数据
|
|
|
+ updateGenerateTicketData(form);
|
|
|
+ return form;
|
|
|
}
|
|
|
|
|
|
/**
|