| | |
| | | import com.mes.hollow.entity.HollowBigStorageCageDetails; |
| | | import com.mes.hollow.entity.HollowFormulaDetails; |
| | | import com.mes.hollow.entity.HollowGlassOutRelationInfo; |
| | | import com.mes.hollow.entity.dto.*; |
| | | import com.mes.hollow.entity.dto.LisecHollowDetails; |
| | | import com.mes.hollow.entity.dto.LisecHollowFrameDetails; |
| | | import com.mes.hollow.entity.dto.LisecHollowGlassAndFrameDetails; |
| | | import com.mes.hollow.entity.dto.LisecHollowGlassDetails; |
| | | import com.mes.hollow.entity.request.HollowHistoryTaskRequest; |
| | | import com.mes.hollow.entity.request.HollowTaskRequest; |
| | | import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper; |
| | |
| | | private static final int ID_RATIO = 10; |
| | | |
| | | @Override |
| | | @Transactional |
| | | // @Transactional |
| | | public HollowGlassOutRelationInfo receiveTask(HollowTaskRequest request) { |
| | | return childrenTask(request, 0); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | // @Transactional |
| | | public HollowGlassOutRelationInfo forceOutGlass(HollowTaskRequest request) { |
| | | return childrenTask(request, 1); |
| | | } |
| | |
| | | if (CollectionUtil.isEmpty(outRelationList) || outRelationList.size() != 1) { |
| | | return "本条线不存在该流程任务或者同流程卡任务数大于1"; |
| | | } |
| | | log.info("李赛克流程卡:{}", flowCardId); |
| | | HollowGlassOutRelationInfo relationInfo = outRelationList.get(0); |
| | | if (relationInfo.getTotalLayer() < 2) { |
| | | return "任务总层数小于2,不生成李赛克文件"; |
| | |
| | | if (null == order) { |
| | | return "生成失败,相关订单信息不存在"; |
| | | } |
| | | log.info("李赛克相关订单信息{}", order); |
| | | //获取配方相关信息 |
| | | HollowFormulaDetails formulaDetails = hollowFormulaDetailsService.getById(relationInfo.getFormulaId()); |
| | | if (null == formulaDetails) { |
| | |
| | | if (layerCount != relationInfo.getTotalLayer() && isForce == 0) { |
| | | return "生成失败,该流程卡内层数与进笼关系表内层数数量不相同"; |
| | | } |
| | | |
| | | log.info("李赛克总层数{}", layerCount); |
| | | //设置文件的主体内容 |
| | | LisecHollowDetails details = new LisecHollowDetails(); |
| | | String randomNumber = "" + (int) (Math.random() * 100000 + 100000); |
| | |
| | | // 创建Calculator实例 |
| | | Blank blank = new Blank(); |
| | | |
| | | log.info("李赛克基础数据已生成:{}", details); |
| | | // 创建数据模型 |
| | | Map<String, Object> root = new HashMap<>(); |
| | | root.put("blank", blank); |
| | |
| | | writer.write(out.toString()); |
| | | } catch (TemplateException | IOException e) { |
| | | e.printStackTrace(); |
| | | |
| | | log.info("李赛克生成异常:{}", e.getMessage()); |
| | | } |
| | | return "success"; |
| | | } |
| | |
| | | } |
| | | |
| | | private HollowGlassOutRelationInfo childrenTask(HollowTaskRequest request, int isForce) { |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1")); |
| | | HollowGlassOutRelationInfo info = new HollowGlassOutRelationInfo(); |
| | | if (null == glassInfo) { |
| | | log.info("该流程卡信息系统未找到"); |
| | | return info; |
| | | } |
| | | List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId()) |
| | | .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)); |
| | | if (CollectionUtil.isNotEmpty(outRelationInfos)) { |
| | | log.info("当前流程卡有未完成的任务"); |
| | | return null; |
| | | } |
| | | //保存任务关系主表 |
| | | info.setFlowCardId(request.getFlowCardId()); |
| | | info.setCell(request.getCell()); |
| | | info.setIsForce(isForce); |
| | | info.setTotalLayer(glassInfo.getTotalLayer()); |
| | | info.setState(Const.HOLLOW_FLOW_CARD_NEW); |
| | | info.setTotalPairQuantity(request.getTotalPairQuantity()); |
| | | info.setFormulaId(request.getFormulaId()); |
| | | this.save(info); |
| | | // 查询出需要出玻璃的队列 |
| | | List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService |
| | | .queryOutGlassList(request.getFlowCardId(), request.getCell()); |
| | | int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity(); |
| | | List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>(); |
| | | Integer carWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_CAR_WIDTH); |
| | | // Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_GLASS_GAP); |
| | | Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(hollowBigStorageCageDetailsList.get(0).getThickness()); |
| | | if (930 == request.getCell()) { |
| | | Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream() |
| | | .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence)); |
| | | Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>(); |
| | | sortListMap.putAll(listMap); |
| | | for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) { |
| | | //创建队列接收不满足成对情况下:一对玻璃分几次上车的次序问题 |
| | | List<HollowGlassQueueInfo> tempList = new ArrayList<>(); |
| | | //先将玻璃按照正常顺序排列,计算一车最多放几块,算好块数之后将一车的玻璃按照倒序存储 |
| | | List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue()); |
| | | int remainWidth = carWidth; |
| | | for (HollowBigStorageCageDetails item : reverse) { |
| | | remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | if (remainWidth < 0) { |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | tempList = new ArrayList<>(); |
| | | remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | } |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | tempList.add(queueInfo); |
| | | remainWidth = remainWidth - glassGap; |
| | | } |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | HollowBigStorageCageDetails cageDetails = entry.getValue().get(0); |
| | | if (cageDetails.getIsPair() == 1) { |
| | | isPairCount = isPairCount - cageDetails.getTotalLayer(); |
| | | if (isPairCount == 0) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | loop: |
| | | for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) { |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | hollowQueues.add(queueInfo); |
| | | if (item.getIsPair() == 1) { |
| | | isPairCount = isPairCount - 1; |
| | | if (isPairCount == 0) { |
| | | break loop; |
| | | try { |
| | | |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getFlowCardId, request.getFlowCardId()).last("limit 1")); |
| | | HollowGlassOutRelationInfo info = new HollowGlassOutRelationInfo(); |
| | | if (null == glassInfo) { |
| | | log.info("该流程卡信息系统未找到"); |
| | | return info; |
| | | } |
| | | log.error("创建任务时获取玻璃信息:{}", info); |
| | | List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, request.getFlowCardId()) |
| | | .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE)); |
| | | if (CollectionUtil.isNotEmpty(outRelationInfos)) { |
| | | log.info("当前流程卡有未完成的任务"); |
| | | return null; |
| | | } |
| | | //保存任务关系主表 |
| | | info.setFlowCardId(request.getFlowCardId()); |
| | | info.setCell(request.getCell()); |
| | | info.setIsForce(isForce); |
| | | info.setTotalLayer(glassInfo.getTotalLayer()); |
| | | info.setState(Const.HOLLOW_FLOW_CARD_NEW); |
| | | info.setTotalPairQuantity(request.getTotalPairQuantity()); |
| | | info.setFormulaId(request.getFormulaId()); |
| | | this.save(info); |
| | | // 查询出需要出玻璃的队列 |
| | | List<HollowBigStorageCageDetails> hollowBigStorageCageDetailsList = hollowBigStorageCageDetailsService |
| | | .queryOutGlassList(request.getFlowCardId(), request.getCell()); |
| | | int isPairCount = glassInfo.getTotalLayer() * request.getTotalPairQuantity(); |
| | | List<HollowGlassQueueInfo> hollowQueues = new ArrayList<>(); |
| | | Integer carWidth = sysConfigService.queryConfigValue(ConstSysConfig.HOLLOW_CAR_WIDTH); |
| | | Integer glassGap = hollowGlassRelationInfoService.getGlassGapByThickness(hollowBigStorageCageDetailsList.get(0).getThickness()); |
| | | if (930 == request.getCell()) { |
| | | Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowBigStorageCageDetailsList.stream() |
| | | .collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence)); |
| | | Map<Integer, List<HollowBigStorageCageDetails>> sortListMap = new TreeMap<>(); |
| | | sortListMap.putAll(listMap); |
| | | for (Map.Entry<Integer, List<HollowBigStorageCageDetails>> entry : sortListMap.entrySet()) { |
| | | //创建队列接收不满足成对情况下:一对玻璃分几次上车的次序问题 |
| | | List<HollowGlassQueueInfo> tempList = new ArrayList<>(); |
| | | //先将玻璃按照正常顺序排列,计算一车最多放几块,算好块数之后将一车的玻璃按照倒序存储 |
| | | List<HollowBigStorageCageDetails> reverse = CollectionUtil.reverse(entry.getValue()); |
| | | int remainWidth = carWidth; |
| | | for (HollowBigStorageCageDetails item : reverse) { |
| | | remainWidth = remainWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | if (remainWidth < 0) { |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | tempList = new ArrayList<>(); |
| | | remainWidth = carWidth - (int) Math.max(item.getWidth(), item.getHeight()); |
| | | } |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | tempList.add(queueInfo); |
| | | remainWidth = remainWidth - glassGap; |
| | | } |
| | | hollowQueues.addAll(CollectionUtil.reverse(tempList)); |
| | | HollowBigStorageCageDetails cageDetails = entry.getValue().get(0); |
| | | if (cageDetails.getIsPair() == 1) { |
| | | isPairCount = isPairCount - cageDetails.getTotalLayer(); |
| | | if (isPairCount == 0) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | loop: |
| | | for (HollowBigStorageCageDetails item : hollowBigStorageCageDetailsList) { |
| | | HollowGlassQueueInfo queueInfo = HollowBDetailToQueue(item, info.getId(), request.getCell()); |
| | | hollowQueues.add(queueInfo); |
| | | if (item.getIsPair() == 1) { |
| | | isPairCount = isPairCount - 1; |
| | | if (isPairCount == 0) { |
| | | break loop; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | hollowGlassQueueInfoService.saveBatch(hollowQueues); |
| | | try { |
| | | if (request.getCell() == 930) { |
| | | generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0); |
| | | hollowGlassQueueInfoService.saveBatch(hollowQueues); |
| | | try { |
| | | log.info("李赛克生成文件:{}", request); |
| | | if (request.getCell() == 930) { |
| | | generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("生成李赛克文件时发生异常,流程卡号为{}", request.getFlowCardId()); |
| | | } |
| | | return info; |
| | | |
| | | } catch (Exception e) { |
| | | log.info("生成李赛克文件时发生异常,流程卡号为{}", request.getFlowCardId()); |
| | | log.error("创建任务时发生异常:{}", e.getMessage()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | return info; |
| | | } |
| | | |
| | | private HollowGlassQueueInfo HollowBDetailToQueue(HollowBigStorageCageDetails details, Long taskId, int targetCell) { |