| | |
| | | import org.jeecg.modules.quartz.service.ISysQuartzLogService; |
| | | import org.jeecg.modules.qywx.message.vo.TemplateCard; |
| | | import org.jeecg.modules.qywx.message.vo.TemplateCardEntity; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | 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.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private ISysQuartzLogService sysQuartzLogService; |
| | | @Autowired |
| | | private IQuartzJobService quartzJobService; |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | @Value("${wechatEnterprise.cardActionUrl}") |
| | | private String cardActionUrl; |
| | |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | //查询所有待保养的周保工单 |
| | | List<EamWeekMaintenanceOrder> waitOrderList = eamWeekMaintenanceOrderService.list(new LambdaQueryWrapper<EamWeekMaintenanceOrder>() |
| | | .eq(EamWeekMaintenanceOrder::getMaintenanceStatus, WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name()) |
| | | .eq(EamWeekMaintenanceOrder::getDelFlag, CommonConstant.DEL_FLAG_0)); |
| | | List<EamWeekMaintenanceOrder> unReceivedOrderList = eamWeekMaintenanceOrderService.selectUnReceivedMaintenanceOrder(); |
| | | if (!unReceivedOrderList.isEmpty()) { |
| | | //有待保养的工单,推送企业微信消息 |
| | | Map<String, List<EamWeekMaintenanceOrder>> unReceivedOrderMap = unReceivedOrderList.stream() |
| | | .collect(Collectors.groupingBy(EamWeekMaintenanceOrder::getOrgId)); |
| | | Set<String> productionIds = selectTwoLevelProductionIds(unReceivedOrderMap.keySet()); |
| | | StringBuilder message = new StringBuilder(); |
| | | for (String orgId : unReceivedOrderMap.keySet()) { |
| | | for (String orgId : productionIds) { |
| | | //查询该产线下的所有操作工 |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(null, orgId, BusinessCodeConst.PCR0001); |
| | | if (userSelectorList.isEmpty()) { |
| | | log.error("系统未设置操作工用户,无法推送工单领取提醒消息"); |
| | | message.append("系统未设置操作工用户,无法推送工单领取提醒消息").append("\n"); |
| | | log.error("id为:{},的产线未配置操作工用户,无法推送周保工单领取提醒消息", orgId); |
| | | message.append("id为: ").append(orgId).append(" 的产线未配置操作工用户,无法推送周保工单领取提醒消息").append("\n"); |
| | | } else { |
| | | String toUsers = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.joining(",")); |
| | | String touser = wechatEnterpriseService.getTouser(toUsers, false); |
| | |
| | | quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); |
| | | sysQuartzLogService.save(quartzLog); |
| | | } |
| | | |
| | | //如果当前产线是三级,查询对应二级产线,如果不是不做处理 |
| | | private Set<String> selectTwoLevelProductionIds(Set<String> productionIds) { |
| | | Set<String> result = new HashSet<>(); |
| | | List<MdcProduction> mdcProductionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().in(MdcProduction::getId, productionIds)); |
| | | for (MdcProduction production : mdcProductionList) { |
| | | //如果是三级产线,查找对应的二级产线,添加进结果集 |
| | | if ("3".equals(production.getOrgType())) { |
| | | mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>() |
| | | .eq(MdcProduction::getId, production.getParentId()) |
| | | .eq(MdcProduction::getOrgType, "2")) |
| | | .stream().findFirst().ifPresent(mdcProduction -> result.add(mdcProduction.getId())); |
| | | } |
| | | //如果是二级产线,添加进结果集 |
| | | if ("2".equals(production.getOrgType())) { |
| | | result.add(production.getId()); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |