| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | 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.*; |
| | |
| | | import org.jeecg.modules.eam.request.EamReportRepairQuery; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentExtendService; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentFaultReasonService; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.eam.vo.EquipmentRepairListVO; |
| | | import org.jeecg.modules.eam.vo.EquipmentRepairStatistics; |
| | | import org.jeecg.modules.eam.vo.EquipmentRepairStatusStatistics; |
| | | import org.jeecg.modules.eam.vo.FaultTypeStatisticsVO; |
| | | import org.jeecg.modules.qywx.message.vo.TemplateCard; |
| | | import org.jeecg.modules.qywx.message.vo.TemplateCardEntity; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 故障报修 |
| | |
| | | private IMdcProductionService mdcProductionService; |
| | | @Autowired |
| | | private IEamEquipmentFaultReasonService eamEquipmentFaultReasonService; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService; |
| | | |
| | | @Value("${wechatEnterprise.cardActionUrl}") |
| | | private String cardActionUrl; |
| | | |
| | | /** |
| | | * 分页列表 |
| | | * |
| | | * @param page |
| | | * @param eamReportRepairQuery |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<EamReportRepair> pageList(Page<EamReportRepair> page, EamReportRepairQuery eamReportRepairQuery) { |
| | | public IPage<EamReportRepair> pageList(Page<EamReportRepair> page, EamReportRepairQuery query) { |
| | | QueryWrapper<EamReportRepair> 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, eamReportRepairQuery, 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.getBreakdownFlag())) { |
| | | queryWrapper.eq("wmo.breakdown_flag", query.getBreakdownFlag()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getReportStatus())) { |
| | | queryWrapper.eq("wmo.report_status", query.getReportStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getFaultDescription())) { |
| | | queryWrapper.like("wmo.fault_description", query.getFaultDescription()); |
| | | } |
| | | 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 |
| | |
| | | sb.append(detail.getItemCode()).append("、"); |
| | | sb.append(detail.getExceptionDescription()).append(";"); |
| | | }); |
| | | EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250009); |
| | | EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250010); |
| | | EamReportRepair entity = new EamReportRepair(); |
| | | entity.setEquipmentId(equipmentId); |
| | | entity.setCreateBy(reportUser); |
| | |
| | | this.baseMapper.insert(entity); |
| | | //更新设备维修状态 |
| | | eamEquipmentExtendService.updateEquipmentRepairStatus(entity.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name()); |
| | | //推送企业微信消息 |
| | | sendQywxTemplateCardMessage(entity); |
| | | return entity; |
| | | } |
| | | |
| | |
| | | sb.append(detail.getItemCode()).append("、"); |
| | | sb.append(detail.getExceptionDescription()).append(";"); |
| | | }); |
| | | EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250010); |
| | | EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250009); |
| | | EamReportRepair entity = new EamReportRepair(); |
| | | entity.setEquipmentId(equipmentId); |
| | | entity.setCreateBy(reportUser); |
| | |
| | | this.baseMapper.insert(entity); |
| | | //更新设备维修状态 |
| | | eamEquipmentExtendService.updateEquipmentRepairStatus(entity.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name()); |
| | | //推送企业微信消息 |
| | | sendQywxTemplateCardMessage(entity); |
| | | return entity; |
| | | } |
| | | |
| | |
| | | this.baseMapper.insert(eamReportRepair); |
| | | //更新设备维修状态 |
| | | eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name()); |
| | | //推送企业微信消息 |
| | | sendQywxTemplateCardMessage(eamReportRepair); |
| | | return eamReportRepair; |
| | | } |
| | | |
| | | private void sendQywxTemplateCardMessage(EamReportRepair eamReportRepair) { |
| | | TemplateCard templateCard = new TemplateCard(); |
| | | String equipmentId = eamReportRepair.getEquipmentId(); |
| | | EamEquipment equipment = eamEquipmentService.getById(equipmentId); |
| | | if (equipment != null) { |
| | | //查询有该设备权限的所有维修工 |
| | | String productionId = equipment.getOrgId(); |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), productionId, BusinessCodeConst.PCR0002); |
| | | String toUsers = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.joining(",")); |
| | | String touser = wechatEnterpriseService.getTouser(toUsers, false); |
| | | templateCard.setTouser(touser); |
| | | |
| | | TemplateCardEntity templateCardEntity = new TemplateCardEntity(); |
| | | templateCard.setTemplate_card(templateCardEntity); |
| | | templateCardEntity.setTask_id(eamReportRepair.getId()); |
| | | TemplateCardEntity.MainTitle mainTitle = new TemplateCardEntity.MainTitle(); |
| | | mainTitle.setTitle("设备维修"); |
| | | templateCardEntity.setMain_title(mainTitle); |
| | | templateCardEntity.setSub_title_text("您有待领取维修工单,请进入系统领取"); |
| | | TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction(); |
| | | cardAction.setType(1); |
| | | cardAction.setUrl(cardActionUrl); |
| | | templateCardEntity.setCard_action(cardAction); |
| | | wechatEnterpriseService.sendTemplateCardMsg(templateCard, true); |
| | | } else { |
| | | log.error("报修工单: " + eamReportRepair.getId() + " 设备不存在,无法推送工单待领取提醒消息!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | public List<EquipmentRepairListVO> repairList() { |
| | | return this.baseMapper.repairList(); |
| | | } |
| | | |
| | | @Override |
| | | public List<FaultTypeStatisticsVO> faultTypeStatistics(String start, String end) { |
| | | return this.baseMapper.faultTypeStatistics(start, end); |
| | | } |
| | | } |