| | |
| | | import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
| | | import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
| | | import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation; |
| | | import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
| | | import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService; |
| | | import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection; |
| | | import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService; |
| | |
| | | private IDaTileMatchCollectionService daTileMatchCollectionService; |
| | | @Resource |
| | | private ProductNewPassStationService productNewPassStationService; |
| | | |
| | | @Resource |
| | | private IDaPassingStationCollectionService daPassingStationCollectionService; |
| | | |
| | | @Autowired |
| | | MiloService miloService; |
| | |
| | | public R engineNoIsInModel(String engineNo,String model,String orderNo) throws Exception { |
| | | |
| | | if (StringUtils.isEmpty(engineNo)){ |
| | | return R.ok(500,"箱体码为空或已存在,请重试"); |
| | | return R.fail(500,"箱体码为空或已存在,请重试"); |
| | | } |
| | | |
| | | ProductNewPassStation checkStation = new ProductNewPassStation(); |
| | | checkStation.setBoxCode(engineNo); |
| | | List<ProductNewPassStation> checkList = productNewPassStationService.getProductPassStationList(checkStation); |
| | | BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); |
| | | bsOrderScheduling.setOrderNo(orderNo); |
| | | List<BsOrderScheduling> allList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); |
| | | List<BsOrderScheduling> dlist = allList.stream().filter(x->x.getProductionStatus().equals(Constants.WAIT_PRODUCTION)).collect(Collectors.toList()); |
| | | List<BsOrderScheduling> collect = allList.stream().filter(x -> x.getProductionStatus().equals(Constants.ORDER_STATUS_ING) |
| | | ||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList()); |
| | | ||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList()); |
| | | |
| | | BsOrderScheduling OrderScheduling=dlist.get(0); |
| | | |
| | | // DaParamCollection daParamCollection = new DaParamCollection(); |
| | | // daParamCollection.setParamValue(engineNo); |
| | | // daParamCollection.setLocationCode("OP010"); |
| | | // List<DaParamCollection> list = daParamCollectionService.selectDaParamCollectionList(daParamCollection); |
| | | // if (CollUtil.isNotEmpty(list)){ |
| | | // return R.ok(500,"已存在此箱体码,请勿重复扫描"); |
| | | // } |
| | | |
| | | OmProductionOrdeInfo info = new OmProductionOrdeInfo(); |
| | | info.setWorkOrderNo(orderNo); |
| | | List<OmProductionOrdeInfo> omProductionOrdeInfos = productionOrdeInfoService.selectOmProductionOrdeInfoList(info); |
| | | if (CollUtil.isNotEmpty(omProductionOrdeInfos)){ |
| | | OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfos.get(0); |
| | | Long planQty = omProductionOrdeInfo.getPlanQty(); |
| | | if (planQty<collect.size()){ |
| | | return R.ok(500,"超出计划数量,请检查后重试"); |
| | | if (CollUtil.isNotEmpty(checkList)){ |
| | | //重复扫码 |
| | | ProductNewPassStation productNewPassStation = checkList.get(0); |
| | | String sfcCode = productNewPassStation.getSfcCode(); |
| | | DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
| | | passingStationCollection.setSfcCode(sfcCode); |
| | | List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionService.selectDaPassingStationCollectionList(passingStationCollection); |
| | | if (CollUtil.isNotEmpty(daPassingStationCollections)){ |
| | | //过站后重新上线 |
| | | //OPC操作 |
| | | logger.info("过站后重新上线,{}",sfcCode); |
| | | ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", sfcCode); |
| | | OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN |
| | | return R.ok(); |
| | | } else { |
| | | //OPC操作 |
| | | logger.info("当前站重新扫码,{}",sfcCode); |
| | | ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", sfcCode); |
| | | OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN |
| | | return R.ok(); |
| | | } |
| | | } |
| | | //插入数据 |
| | | DaParamCollection saveData = new DaParamCollection(); |
| | | saveData.setSfcCode(OrderScheduling.getEngineNo()); |
| | | saveData.setParamValue(engineNo); |
| | | saveData.setLocationCode("OP010"); |
| | | saveData.setParamCode("XTM"); |
| | | saveData.setParamName("箱体"); |
| | | daParamCollectionService.insertDaParamCollection(saveData); |
| | | }else { |
| | | |
| | | DaTileMatchCollection MatchCollection = new DaTileMatchCollection(); |
| | | MatchCollection.setSfcCode(OrderScheduling.getEngineNo()); |
| | | MatchCollection.setParamValue(engineNo); |
| | | MatchCollection.setLocationCode("OP010"); |
| | | MatchCollection.setParamCode("XTM"); |
| | | MatchCollection.setParamName("箱体"); |
| | | daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection); |
| | | if (CollUtil.isNotEmpty(dlist)){ |
| | | BsOrderScheduling OrderScheduling=dlist.get(0); |
| | | |
| | | if (StrUtil.isNotBlank(OrderScheduling.getEngineNo())){ |
| | | String snCode = OrderScheduling.getEngineNo(); |
| | | if (snCode.startsWith("280") || snCode.startsWith("380")){ |
| | | ProductNewPassStation productNewPassStation = new ProductNewPassStation(); |
| | | UUID uuid = UUID.randomUUID(); |
| | | productNewPassStation.setId(uuid.getMostSignificantBits()); |
| | | productNewPassStation.setFinishFlag("0"); |
| | | productNewPassStation.setSfcCode(OrderScheduling.getEngineNo()); |
| | | productNewPassStation.setCreateTime(new Date()); |
| | | productNewPassStation.setBoxCode(engineNo); |
| | | if (snCode.startsWith("280")){ |
| | | productNewPassStation.setProductType("280"); |
| | | } else { |
| | | productNewPassStation.setProductType("380"); |
| | | OmProductionOrdeInfo info = new OmProductionOrdeInfo(); |
| | | info.setWorkOrderNo(orderNo); |
| | | List<OmProductionOrdeInfo> omProductionOrdeInfos = productionOrdeInfoService.selectOmProductionOrdeInfoList(info); |
| | | if (CollUtil.isNotEmpty(omProductionOrdeInfos)){ |
| | | OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfos.get(0); |
| | | Long planQty = omProductionOrdeInfo.getPlanQty(); |
| | | if (planQty<collect.size()){ |
| | | return R.ok(500,"超出计划数量,请检查后重试"); |
| | | } |
| | | } |
| | | productNewPassStationService.insertPassStation(productNewPassStation); |
| | | //插入数据 |
| | | DaParamCollection saveData = new DaParamCollection(); |
| | | saveData.setSfcCode(OrderScheduling.getEngineNo()); |
| | | saveData.setParamValue(engineNo); |
| | | saveData.setLocationCode("OP010"); |
| | | saveData.setParamCode("XTM"); |
| | | saveData.setParamName("箱体"); |
| | | daParamCollectionService.insertDaParamCollection(saveData); |
| | | |
| | | DaTileMatchCollection MatchCollection = new DaTileMatchCollection(); |
| | | MatchCollection.setSfcCode(OrderScheduling.getEngineNo()); |
| | | MatchCollection.setParamValue(engineNo); |
| | | MatchCollection.setLocationCode("OP010"); |
| | | MatchCollection.setParamCode("XTM"); |
| | | MatchCollection.setParamName("箱体"); |
| | | daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection); |
| | | |
| | | if (StrUtil.isNotBlank(OrderScheduling.getEngineNo())){ |
| | | String snCode = OrderScheduling.getEngineNo(); |
| | | if (snCode.startsWith("280") || snCode.startsWith("380")){ |
| | | ProductNewPassStation productNewPassStation = new ProductNewPassStation(); |
| | | UUID uuid = UUID.randomUUID(); |
| | | productNewPassStation.setId(uuid.getMostSignificantBits()); |
| | | productNewPassStation.setFinishFlag("0"); |
| | | productNewPassStation.setSfcCode(OrderScheduling.getEngineNo()); |
| | | productNewPassStation.setCreateTime(new Date()); |
| | | productNewPassStation.setBoxCode(engineNo); |
| | | if (snCode.startsWith("280")){ |
| | | productNewPassStation.setProductType("280"); |
| | | } else { |
| | | productNewPassStation.setProductType("380"); |
| | | } |
| | | productNewPassStationService.insertPassStation(productNewPassStation); |
| | | } |
| | | } |
| | | |
| | | //更新上线数量 |
| | | int onlineNum = 0; |
| | | List<BsOrderScheduling> onlineNumList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling) |
| | | .stream().filter(x -> Constants.ORDER_STATUS_ING.equals(x.getProductionStatus())||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(onlineNumList)){ |
| | | onlineNum = onlineNumList.size(); |
| | | } |
| | | OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
| | | omProductionOrdeInfo.setWorkOrderNo(orderNo); |
| | | List<OmProductionOrdeInfo> omList = productionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
| | | if (CollUtil.isNotEmpty(omList)){ |
| | | OmProductionOrdeInfo omInfo = omList.get(0); |
| | | String s = String.valueOf(onlineNum); |
| | | long l = Long.parseLong(s); |
| | | omInfo.setActualOnlineQty(l); |
| | | productionOrdeInfoService.updateOmProductionOrdeInfo(omInfo); |
| | | } |
| | | |
| | | //OPC操作 |
| | | ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", OrderScheduling.getEngineNo()); |
| | | OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN |
| | | |
| | | |
| | | OrderScheduling.setProductionStatus("2"); |
| | | bsOrderSchedulingService.updateBsOrderScheduling(OrderScheduling); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |
| | | //更新上线数量 |
| | | int onlineNum = 0; |
| | | List<BsOrderScheduling> onlineNumList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling) |
| | | .stream().filter(x -> Constants.ORDER_STATUS_ING.equals(x.getProductionStatus())||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(onlineNumList)){ |
| | | onlineNum = onlineNumList.size(); |
| | | } |
| | | OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); |
| | | omProductionOrdeInfo.setWorkOrderNo(orderNo); |
| | | List<OmProductionOrdeInfo> omList = productionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo); |
| | | if (CollUtil.isNotEmpty(omList)){ |
| | | OmProductionOrdeInfo omInfo = omList.get(0); |
| | | String s = String.valueOf(onlineNum); |
| | | long l = Long.parseLong(s); |
| | | omInfo.setActualOnlineQty(l); |
| | | productionOrdeInfoService.updateOmProductionOrdeInfo(omInfo); |
| | | } |
| | | |
| | | //OPC操作 |
| | | ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", OrderScheduling.getEngineNo()); |
| | | OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN |
| | | |
| | | |
| | | OrderScheduling.setProductionStatus("2"); |
| | | bsOrderSchedulingService.updateBsOrderScheduling(OrderScheduling); |
| | | return R.ok(); |
| | | } |
| | | } |