| | |
| | | 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; |
| | | |
| | | /** |
| | | * 分页列表 |
| | |
| | | eamReportRepairService.updateById(eamReportRepair); |
| | | //更新设备维修状态 |
| | | eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name()); |
| | | //推送企业微信消息 |
| | | sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, null); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | TemplateCardEntity.HorizontalContent content5 = new TemplateCardEntity.HorizontalContent(); |
| | | TemplateCardEntity.HorizontalContent content6 = new TemplateCardEntity.HorizontalContent(); |
| | | |
| | | if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { |
| | | SysUser sysUser = sysUserService.getUserByName(eamRepairOrder.getRepairer()); |
| | | if (Objects.isNull(reportRepair) && Objects.isNull(request)) { |
| | | content5.setKeyname("指派人"); |
| | | SysUser assignUser = sysUserService.getUserByName(eamRepairOrder.getCreateBy()); |
| | | content5.setValue(assignUser.getRealname()); |
| | | horizontalContentList.add(content5); |
| | | } else if (Objects.isNull(request)) { |
| | | TemplateCardEntity.HorizontalContent content = new TemplateCardEntity.HorizontalContent(); |
| | | content.setKeyname("领取人"); |
| | | content.setValue(sysUser.getRealname()); |
| | | horizontalContentList.add(content); |
| | | } else { |
| | | content5.setKeyname("备件领取人"); |
| | | SysUser assignUser = sysUserService.getUserByName(request.getAssignee()); |
| | | content5.setValue(assignUser.getRealname()); |
| | | horizontalContentList.add(content5); |
| | | } |
| | | content6.setKeyname("维修人"); |
| | | content6.setValue(sysUser.getRealname()); |
| | | horizontalContentList.add(content6); |
| | | } |
| | | if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus) || ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { |
| | | content5.setKeyname("维修人"); |
| | | SysUser repairUser = sysUserService.getUserByName(eamRepairOrder.getRepairer()); |
| | | content5.setValue(repairUser.getRealname()); |
| | | horizontalContentList.add(content5); |
| | | } |
| | | if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { |
| | | content6.setKeyname("确认人"); |
| | | SysUser sysUser = sysUserService.getUserByName(reportRepair.getCreateBy()); |
| | | content6.setValue(sysUser.getRealname()); |
| | | horizontalContentList.add(content6); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |