| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamRepairOrder; |
| | | import org.jeecg.modules.eam.entity.EamReportRepair; |
| | | import org.jeecg.modules.eam.mapper.EamRepairOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamRepairOrderQuery; |
| | | import org.jeecg.modules.eam.request.EamRepairOrderRequest; |
| | | import org.jeecg.modules.eam.request.EamRepairOrderResponse; |
| | | import org.jeecg.modules.eam.request.EamReportRepairQuery; |
| | | import org.jeecg.modules.eam.request.*; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentExtendService; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamRepairOrderService; |
| | |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.domain.vo.WorkTaskDataVo; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.qywx.message.vo.TemplateCard; |
| | | import org.jeecg.modules.qywx.message.vo.TemplateCardEntity; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 维修工单 |
| | |
| | | @Resource |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | |
| | | @Resource |
| | | private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService; |
| | | |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | |
| | | /** |
| | | * 分页列表 |
| | | * |
| | | * @param page |
| | | * @param eamRepairOrderQuery |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<EamRepairOrder> pageList(Page<EamRepairOrder> page, EamRepairOrderQuery eamRepairOrderQuery) { |
| | | public IPage<EamRepairOrder> pageList(Page<EamRepairOrder> page, EamRepairOrderQuery query) { |
| | | // //用户数据权限 |
| | | // LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | // if (sysUser == null) { |
| | | // return page; |
| | | // } |
| | | // List<String> equipmentIds = new ArrayList<>(); |
| | | // if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | // //选择了设备,根据设备id过滤设备 |
| | | // equipmentIds = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | // } |
| | | // return this.baseMapper.pageList(page, eamRepairOrderQuery, sysUser.getId(), equipmentIds); |
| | | QueryWrapper<EamRepairOrder> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("wmo.del_flag", CommonConstant.DEL_FLAG_0); |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | equipmentIds = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | } |
| | | return this.baseMapper.pageList(page, eamRepairOrderQuery, sysUser.getId(), equipmentIds); |
| | | //查询条件过滤 |
| | | if (query != null) { |
| | | if (StringUtils.isNotBlank(query.getEquipmentId())) { |
| | | queryWrapper.eq("wmo.equipment_id", query.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getEquipmentCode())) { |
| | | queryWrapper.like("e.equipment_code", query.getEquipmentCode()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getEquipmentName())) { |
| | | queryWrapper.like("e.equipment_name", query.getEquipmentName()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getRepairStatus())) { |
| | | queryWrapper.eq("wmo.repair_status", query.getRepairStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getRepairer())) { |
| | | queryWrapper.like("wmo.repairer", query.getRepairer()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getRepairCode())) { |
| | | queryWrapper.like("wmo.repair_code", query.getRepairCode()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getSparePartDescription())) { |
| | | queryWrapper.like("wmo.spare_part_description", query.getSparePartDescription()); |
| | | } |
| | | // if(query.getStartTime() != null && query.getEndTime() != null) { |
| | | // queryWrapper.between("wmo.fault_start_time", query.getStartTime(), query.getEndTime()); |
| | | // } |
| | | //排序 |
| | | if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { |
| | | String column = query.getColumn(); |
| | | if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); |
| | | } |
| | | if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(query.getOrder())) { |
| | | queryWrapper.orderByAsc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | |
| | | return baseMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | super.save(eamRepairOrder); |
| | | EamEquipment eamEquipment = eamEquipmentService.getById(eamReportRepair.getEquipmentId()); |
| | | // 启动维修流程 |
| | | flowCommonService.initActBusiness("维修工单号:" + codeSeq + ", 设备编号:" + eamEquipment.getEquipmentCode() + "开始维修", |
| | | flowCommonService.initActBusiness("工单号:" + codeSeq + ", 设备编号:" + eamEquipment.getEquipmentCode() + ";安装位置: " + eamEquipment.getInstallationPosition(), |
| | | eamRepairOrder.getId(), |
| | | "IEamRepairOrderService", |
| | | "eam_repair", |
| | |
| | | eamReportRepairService.updateById(eamReportRepair); |
| | | //更新设备维修状态 |
| | | eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name()); |
| | | //推送企业微信消息 |
| | | sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, null); |
| | | } |
| | | } |
| | | |
| | |
| | | super.save(eamRepairOrder); |
| | | EamEquipment eamEquipment = eamEquipmentService.getById(eamReportRepair.getEquipmentId()); |
| | | // 启动维修流程 |
| | | flowCommonService.initActBusiness("维修工单号:" + codeSeq + ", 设备编号:" + eamEquipment.getEquipmentCode() + "开始维修", |
| | | flowCommonService.initActBusiness("工单号: " + codeSeq + ";设备编号: " + eamEquipment.getEquipmentCode() + ";安装位置: " + eamEquipment.getInstallationPosition(), |
| | | eamRepairOrder.getId(), |
| | | "IEamRepairOrderService", |
| | | "eam_repair", |
| | |
| | | eamReportRepairService.updateById(eamReportRepair); |
| | | //更新设备维修状态 |
| | | eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name()); |
| | | //推送企业微信消息 |
| | | sendQywxTemplateCardMessage(eamRepairOrder, null, null); |
| | | } |
| | | } |
| | | |
| | | private void sendQywxTemplateCardMessage(EamRepairOrder eamRepairOrder, EamReportRepair reportRepair, EamRepairOrderRequest request) { |
| | | TemplateCard templateCard = new TemplateCard(); |
| | | String repairStatus = eamRepairOrder.getRepairStatus(); |
| | | EamEquipment equipment = eamEquipmentService.getById(eamRepairOrder.getEquipmentId()); |
| | | eamRepairOrder.setEquipmentCode(equipment.getEquipmentCode()); |
| | | if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { |
| | | //工单已指派,推送消息给维修工 |
| | | String repairer = eamRepairOrder.getRepairer(); |
| | | String touser = wechatEnterpriseService.getTouser(repairer, false); |
| | | templateCard.setTouser(touser); |
| | | } |
| | | if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus)) { |
| | | //工单进入等待备件状态,推送消息给设备管理员 |
| | | List<String> nextAssignee = (List<String>) request.getValues().get("NextAssignee"); |
| | | String nextAssigneeStr = nextAssignee.stream() |
| | | .filter(Objects::nonNull) // 可选:过滤 null 值 |
| | | .collect(Collectors.joining(",")); |
| | | String touser = wechatEnterpriseService.getTouser(nextAssigneeStr, false); |
| | | templateCard.setTouser(touser); |
| | | } |
| | | if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { |
| | | //工单进入待确认状态,推送消息给报修员 |
| | | String touser = wechatEnterpriseService.getTouser(reportRepair.getCreateBy(), false); |
| | | templateCard.setTouser(touser); |
| | | } |
| | | |
| | | TemplateCardEntity templateCardEntity = new TemplateCardEntity(); |
| | | templateCard.setTemplate_card(templateCardEntity); |
| | | templateCardEntity.setTask_id(eamRepairOrder.getId()); |
| | | TemplateCardEntity.MainTitle mainTitle = new TemplateCardEntity.MainTitle(); |
| | | mainTitle.setTitle("设备维修"); |
| | | templateCardEntity.setMain_title(mainTitle); |
| | | |
| | | if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { |
| | | if (Objects.isNull(reportRepair) && Objects.isNull(request)) { |
| | | templateCardEntity.setSub_title_text("收到指派工单: " + eamRepairOrder.getRepairCode() + " 请开始进行维修"); |
| | | } else if (Objects.isNull(request)) { |
| | | templateCardEntity.setSub_title_text("已领取维修工单: " + eamRepairOrder.getRepairCode() + " 开始进行维修"); |
| | | } |
| | | else { |
| | | templateCardEntity.setSub_title_text("维修工单: " + eamRepairOrder.getRepairCode() + " 备件已到位,请继续进行维修"); |
| | | } |
| | | } |
| | | if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus)) { |
| | | templateCardEntity.setSub_title_text("维修工单: " + eamRepairOrder.getRepairCode() + " 需要领用备件"); |
| | | } |
| | | if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { |
| | | templateCardEntity.setSub_title_text("工单: " + eamRepairOrder.getRepairCode() + " 已完成设备维修,请进入系统确认"); |
| | | } |
| | | |
| | | List<TemplateCardEntity.HorizontalContent> horizontalContentList = CollectionUtil.newArrayList(); |
| | | TemplateCardEntity.HorizontalContent content1 = new TemplateCardEntity.HorizontalContent(); |
| | | content1.setKeyname("工单号"); |
| | | content1.setValue(eamRepairOrder.getRepairCode()); |
| | | horizontalContentList.add(content1); |
| | | TemplateCardEntity.HorizontalContent content2 = new TemplateCardEntity.HorizontalContent(); |
| | | content2.setKeyname("设备编号"); |
| | | content2.setValue(eamRepairOrder.getEquipmentCode()); |
| | | horizontalContentList.add(content2); |
| | | |
| | | //如果工单状态为待维修(没指派维修人),流程是没有启动的,无法获取节点信息 |
| | | if (!ReportRepairEnum.WAIT_REPAIR.name().equals(repairStatus)) { |
| | | WorkTaskDataVo previousFlowInfo = flowTaskService.getPreviousFlowInfo(eamRepairOrder.getId()); |
| | | TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent(); |
| | | content3.setKeyname("前驱节点"); |
| | | content3.setValue(previousFlowInfo.getPreNode()); |
| | | horizontalContentList.add(content3); |
| | | TemplateCardEntity.HorizontalContent content4 = new TemplateCardEntity.HorizontalContent(); |
| | | content4.setKeyname("当前节点"); |
| | | if (InspectionStatus.COMPLETE.name().equals(repairStatus)) { |
| | | content4.setValue("已完成"); |
| | | } else { |
| | | content4.setValue(previousFlowInfo.getName()); |
| | | } |
| | | horizontalContentList.add(content4); |
| | | } |
| | | |
| | | if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { |
| | | TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent(); |
| | | SysUser sysUser = sysUserService.getUserByName(eamRepairOrder.getRepairer()); |
| | | if (Objects.isNull(reportRepair) && Objects.isNull(request)) { |
| | | content3.setKeyname("指派人"); |
| | | SysUser assignUser = sysUserService.getUserByName(eamRepairOrder.getCreateBy()); |
| | | content3.setValue(assignUser.getRealname()); |
| | | horizontalContentList.add(content3); |
| | | } else if (Objects.isNull(request)) { |
| | | TemplateCardEntity.HorizontalContent content = new TemplateCardEntity.HorizontalContent(); |
| | | content.setKeyname("领取人"); |
| | | content.setValue(sysUser.getRealname()); |
| | | horizontalContentList.add(content); |
| | | } else { |
| | | content3.setKeyname("备件领取人"); |
| | | SysUser assignUser = sysUserService.getUserByName(request.getAssignee()); |
| | | content3.setValue(assignUser.getRealname()); |
| | | horizontalContentList.add(content3); |
| | | } |
| | | } |
| | | if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus) || ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { |
| | | TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent(); |
| | | content3.setKeyname("维修人"); |
| | | SysUser repairUser = sysUserService.getUserByName(eamRepairOrder.getRepairer()); |
| | | content3.setValue(repairUser.getRealname()); |
| | | horizontalContentList.add(content3); |
| | | } |
| | | |
| | | templateCardEntity.setHorizontal_content_list(horizontalContentList); |
| | | |
| | | TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction(); |
| | | cardAction.setType(1); |
| | | cardAction.setUrl("http://houjie.xalxzn.com:8866/h5"); |
| | | templateCardEntity.setCard_action(cardAction); |
| | | |
| | | wechatEnterpriseService.sendTemplateCardMsg(templateCard, true); |
| | | } |
| | | |
| | | @Override |
| | |
| | | this.baseMapper.updateById(eamRepairOrder); |
| | | // 同步更新报修表状态 |
| | | eamReportRepairService.updateById(eamReportRepair); |
| | | if (!ReportRepairEnum.COMPLETE.name().equals(eamRepairOrder.getRepairStatus())) { |
| | | //推送企业微信消息(流程完结不发送消息) |
| | | sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, request); |
| | | } |
| | | return eamRepairOrder; |
| | | } |
| | | |
| | |
| | | BeanUtils.copyProperties(eamReportRepair, eamRepairOrderResponse); |
| | | eamRepairOrderResponse.setReportImageFiles(eamReportRepair.getImageFiles()); |
| | | eamRepairOrderResponse.setImageFiles(eamRepairOrder.getImageFiles()); |
| | | eamRepairOrderResponse.setReporter(eamReportRepair.getCreateBy()); |
| | | return eamRepairOrderResponse; |
| | | } |
| | | |