| | |
| | | import com.mes.hollow.entity.HollowBigStorageCageDetails; |
| | | import com.mes.hollow.entity.HollowFormulaDetails; |
| | | import com.mes.hollow.entity.HollowGlassOutRelationInfo; |
| | | import com.mes.hollow.entity.HollowGlassRelationInfo; |
| | | import com.mes.hollow.entity.dto.*; |
| | | import com.mes.hollow.entity.request.HollowTaskRequest; |
| | | import com.mes.hollow.mapper.HollowGlassOutRelationInfoMapper; |
| | |
| | | |
| | | @Override |
| | | public Boolean startTask(String flowCardId, int cell) { |
| | | log.info("查看该流程卡是否由正在执行的任务,流程卡:{}", flowCardId); |
| | | int taskCount = this.count(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE) |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId)); |
| | | if (taskCount == 0 || taskCount > 1) { |
| | | log.info("该流程卡不存在任务或者有正在执行中,无法再次执行"); |
| | | return Boolean.FALSE; |
| | | } |
| | | //更新任务状态为开始 |
| | | return this.update(new LambdaUpdateWrapper<HollowGlassOutRelationInfo>() |
| | | .set(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START) |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String generateHollowLisecFile(String flowCardId, int cell, int isForce) throws IOException { |
| | | public String generateHollowLisecFile(String flowCardId, int cell, int isForce, int isOut) throws IOException { |
| | | List<HollowGlassOutRelationInfo> outRelationList = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_NEW, Const.HOLLOW_FLOW_CARD_START, Const.HOLLOW_FLOW_CARD_PAUSE) |
| | | .eq(HollowGlassOutRelationInfo::getFlowCardId, flowCardId) |
| | |
| | | String randomNumber = "" + (int) (Math.random() * 100000 + 100000); |
| | | details.setBcdStart(randomNumber); |
| | | details.setBatchNo(randomNumber); |
| | | details.setOrd(relationInfo.getFlowCardId().substring(2, 9)); |
| | | details.setOrd(relationInfo.getFlowCardId().substring(2, 9) + (int) (Math.random() * 100 + 100)); |
| | | details.setCustNum(order.getCustomerId() + ""); |
| | | details.setCustNam(order.getCustomerName()); |
| | | details.setCustNam(""); |
| | | details.setProDate((new SimpleDateFormat("dd/MM/yyyy").format(new Date()))); |
| | | details.setDelDate(new SimpleDateFormat("dd/MM/yyyy").format(order.getDeliveryDate())); |
| | | |
| | | //设置文件第一层列表数据 |
| | | //暂时生成笼内所有的玻璃信息(已配对和未配对的) |
| | | List<HollowGlassRelationInfo> hollowGlassRelationInfos = hollowGlassRelationInfoService.list(new LambdaQueryWrapper<HollowGlassRelationInfo>() |
| | | .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId).orderByAsc(HollowGlassRelationInfo::getHollowSequence)); |
| | | Map<Integer, List<HollowGlassRelationInfo>> listMap = hollowGlassRelationInfos.stream().collect(Collectors.groupingBy(HollowGlassRelationInfo::getHollowSequence)); |
| | | // List<HollowGlassRelationInfo> hollowGlassRelationInfos = hollowGlassRelationInfoService.list(new LambdaQueryWrapper<HollowGlassRelationInfo>() |
| | | // .eq(HollowGlassRelationInfo::getFlowCardId, flowCardId).orderByAsc(HollowGlassRelationInfo::getHollowSequence)); |
| | | List<HollowBigStorageCageDetails> hollowGlassRelationInfos = hollowBigStorageCageDetailsService.queryPairGlassList(flowCardId, relationInfo.getTotalLayer(), relationInfo.getTotalPairQuantity(), isOut); |
| | | Map<Integer, List<HollowBigStorageCageDetails>> listMap = hollowGlassRelationInfos.stream().collect(Collectors.groupingBy(HollowBigStorageCageDetails::getHollowSequence)); |
| | | |
| | | //设置间隔板数据共所有配对玻璃使用 |
| | | |
| | | // for (int i = 1; i < relationInfo.getTotalLayer(); i++) { |
| | | // LisecHollowFrameDetails frameDetails = new LisecHollowFrameDetails(); |
| | | // frameDetails.setRecType("<FR" + i + ">"); |
| | | // frameDetails.setType(formulaDetails.getIntervalFrameType()); |
| | | // frameDetails.setWidth(formulaDetails.getIntervalFrameWidth()); |
| | | // frameDetails.setHeight(formulaDetails.getIntervalFrameHeight()); |
| | | // frameList.add(frameDetails); |
| | | // } |
| | | List<LisecHollowGlassAndFrameDetails> glassAndFrameList = new ArrayList<>(); |
| | | listMap.forEach((e, v) -> { |
| | | LisecHollowGlassAndFrameDetails glassAndFrame = new LisecHollowGlassAndFrameDetails(); |
| | |
| | | List<LisecHollowFrameDetails> frameList = new ArrayList<>(); |
| | | for (int i = 1; i <= v.size(); i++) { |
| | | LisecHollowGlassDetails hollowGlassDetails = new LisecHollowGlassDetails(); |
| | | HollowBigStorageCageDetails glassInfo = v.get(i - 1); |
| | | hollowGlassDetails.setRecType("<GL" + i + ">"); |
| | | hollowGlassDetails.setThickness((int) (v.get(i - 1).getThickness() * 10) + ""); |
| | | hollowGlassDetails.setThickness((int) (glassInfo.getThickness() * 10) + ""); |
| | | hollowGlassDetails.setDescript(formulaDetails.getIntervalFrameWidthOne() + "-" + (int) (glassInfo.getThickness() * 10)); |
| | | hollowGlassDetails.setPaneBcd(randomNumber + "" + (e * ID_RATIO + i)); |
| | | glassList.add(hollowGlassDetails); |
| | | } |
| | |
| | | glassAndFrame.setHeight((int) (v.get(0).getHeight() * 10) + ""); |
| | | glassAndFrame.setGlass1(e * ID_RATIO + 1 + ""); |
| | | glassAndFrame.setFrame1(formulaDetails.getFrameOne()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR1",formulaDetails.getIntervalFrameTypeOne(), formulaDetails.getIntervalFrameWidthOne(), formulaDetails.getIntervalFrameHeightOne())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR1>", formulaDetails.getIntervalFrameTypeOne(), formulaDetails.getIntervalFrameWidthOne(), formulaDetails.getIntervalFrameHeightOne())); |
| | | glassAndFrame.setGasCode1(formulaDetails.getCasOne()); |
| | | if (relationInfo.getTotalLayer() == 2) { |
| | | glassAndFrame.setGlass2(e * ID_RATIO + 2 + ""); |
| | | } else if (relationInfo.getTotalLayer() == 3) { |
| | | glassAndFrame.setGlass2(e * ID_RATIO + 2 + ""); |
| | | glassAndFrame.setFrame2(formulaDetails.getFrameTwo()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR2",formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR2>", formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo())); |
| | | glassAndFrame.setGasCode2(formulaDetails.getCasTwo()); |
| | | glassAndFrame.setGlass3(e * ID_RATIO + 3 + ""); |
| | | } else if (relationInfo.getTotalLayer() == 4) { |
| | | glassAndFrame.setGlass2(e * ID_RATIO + 2 + ""); |
| | | glassAndFrame.setFrame2(formulaDetails.getFrameTwo()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR2",formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR2>", formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo())); |
| | | glassAndFrame.setGasCode2(formulaDetails.getCasTwo()); |
| | | glassAndFrame.setGlass3(e * ID_RATIO + 3 + ""); |
| | | glassAndFrame.setFrame3(formulaDetails.getFrameThree()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR3",formulaDetails.getIntervalFrameTypeThree(), formulaDetails.getIntervalFrameWidthThree(), formulaDetails.getIntervalFrameHeightThree())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR3>", formulaDetails.getIntervalFrameTypeThree(), formulaDetails.getIntervalFrameWidthThree(), formulaDetails.getIntervalFrameHeightThree())); |
| | | glassAndFrame.setGasCode3(formulaDetails.getCasThree()); |
| | | glassAndFrame.setGlass4(e * ID_RATIO + 4 + ""); |
| | | } else { |
| | | glassAndFrame.setGlass2(e * ID_RATIO + 2 + ""); |
| | | glassAndFrame.setFrame2(formulaDetails.getFrameTwo()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR2",formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR2>", formulaDetails.getIntervalFrameTypeTwo(), formulaDetails.getIntervalFrameWidthTwo(), formulaDetails.getIntervalFrameHeightTwo())); |
| | | glassAndFrame.setGasCode2(formulaDetails.getCasTwo()); |
| | | glassAndFrame.setGlass3(e * ID_RATIO + 3 + ""); |
| | | glassAndFrame.setFrame3(formulaDetails.getFrameThree()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR3",formulaDetails.getIntervalFrameTypeThree(), formulaDetails.getIntervalFrameWidthThree(), formulaDetails.getIntervalFrameHeightThree())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR3>", formulaDetails.getIntervalFrameTypeThree(), formulaDetails.getIntervalFrameWidthThree(), formulaDetails.getIntervalFrameHeightThree())); |
| | | glassAndFrame.setGasCode3(formulaDetails.getCasThree()); |
| | | glassAndFrame.setGlass4(e * ID_RATIO + 4 + ""); |
| | | glassAndFrame.setFrame3(formulaDetails.getFrameFour()); |
| | | frameList.add(new LisecHollowFrameDetails("<FR4",formulaDetails.getIntervalFrameTypeFour(), formulaDetails.getIntervalFrameWidthFour(), formulaDetails.getIntervalFrameHeightFour())); |
| | | frameList.add(new LisecHollowFrameDetails("<FR4>", formulaDetails.getIntervalFrameTypeFour(), formulaDetails.getIntervalFrameWidthFour(), formulaDetails.getIntervalFrameHeightFour())); |
| | | glassAndFrame.setGasCode4(formulaDetails.getCasFour()); |
| | | glassAndFrame.setGlass4(e * ID_RATIO + 5 + ""); |
| | | } |
| | |
| | | // 将生成的文件存入指定路径 |
| | | //计算生成李赛克需要的数据给到每个属性 |
| | | StringWriter out = new StringWriter(); |
| | | File file = new File(System.getProperty("user.dir")+"/lisec", relationInfo.getFlowCardId() + randomNumber.substring(randomNumber.length() - 3) + ".trf"); |
| | | File file = new File(System.getProperty("user.dir") + "/lisec", relationInfo.getFlowCardId() + randomNumber.substring(randomNumber.length() - 3) + ".trf"); |
| | | try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { |
| | | temp.process(root, out); |
| | | writer.write(out.toString()); |
| | |
| | | return info; |
| | | } |
| | | List<HollowGlassOutRelationInfo> outRelationInfos = this.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | | .eq(HollowGlassOutRelationInfo::getCell, request.getCell()) |
| | | .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("当前流程卡在本条线有未完成的任务"); |
| | | log.info("当前流程卡有未完成的任务"); |
| | | return null; |
| | | } |
| | | //保存任务关系主表 |
| | |
| | | hollowGlassQueueInfoService.saveBatch(hollowQueues); |
| | | try { |
| | | if (request.getCell() == 930) { |
| | | generateHollowLisecFile(request.getFlowCardId(), 930, isForce); |
| | | generateHollowLisecFile(request.getFlowCardId(), 930, isForce, 0); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("生成李赛克文件时发生异常,流程卡号为{}", request.getFlowCardId()); |