| | |
| | | <artifactId>spring-boot-starter-websocket</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.kangaroohy</groupId> |
| | | <artifactId>milo-spring-boot-starter</artifactId> |
| | | <version>3.0.5</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.commons</groupId> |
| | | <artifactId>commons-pool2</artifactId> |
| | | <version>2.12.0</version> |
| | | </dependency> |
| | | |
| | | <!-- https://mvnrepository.com/artifact/com.google.guava/guava --> |
| | | <dependency> |
| | | <groupId>com.google.guava</groupId> |
| | | <artifactId>guava</artifactId> |
| | | <version>33.0.0-jre</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | @Component |
| | | public class BOP010Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(BOP010Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public BOP010Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.COP010_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP010_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP010_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | String isRepair = miloService. |
| | | readFromOpcUa(OPCElement.BOP010_P_REPAIR) |
| | | .getValue().toString();//æ¯å¦è¿ä¿® |
| | | if(isRepair.equals("true")){ |
| | | handleRepair(); |
| | | }else{ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP010_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("BOP010å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void handleOrder() throws Exception{ |
| | | |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
| | | param.setProductionLine("");//产线 |
| | | param.setOrderStatus("3");//å·¥åç¶æ |
| | | List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(param); |
| | | |
| | | if(list.size()>0) { |
| | | ProductionOrdeInfoResult result = list.get(0); |
| | | |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getMaterialCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | |
| | | //èªå¨çæå¯ä¸ç |
| | | Random random = new Random(System.currentTimeMillis()); |
| | | S_SFC_CODE = "BOP"+random.nextLong(); |
| | | |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_NUMBER,result.getPlanQty().toString())); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | |
| | | logger.info("BOP010å·¥ä½,handleOrder PCå¤çå®æï¼2"); |
| | | }else{ |
| | | logger.info("BOP010å·¥ä½æ²¡æå¯æ§è¡çå·¥å,请è系工å管çåä¸å该产线çå·¥åï¼"); |
| | | } |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.BOP010_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP010_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | public void handleRepair() throws Exception{ |
| | | RepairManageInfoParam repairManageInfoParam = new RepairManageInfoParam(); |
| | | repairManageInfoParam.setLocationCode(LOCATION_CODE); |
| | | repairManageInfoParam.setManageType("2"); |
| | | repairManageInfoParam.setUpPlc("0"); |
| | | List<RepairManageInfoResult> list = repairManageInfoService.findListBySpec(repairManageInfoParam); |
| | | if(list.size()>0) { |
| | | RepairManageInfoResult result = list.get(0); |
| | | |
| | | //èªå¨çæå¯ä¸ç |
| | | Random random = new Random(System.currentTimeMillis()); |
| | | S_SFC_CODE = "BOP" + random.nextLong(); |
| | | |
| | | |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getProductCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | String repairLocation = result.getPoorLocationCode();// |
| | | |
| | | //æ ¹æ®å·¥ä½ç¼ç æ¥è¯¢å·¥ä½è¡¨ä¸é
ç½®çè¿ä¿®å·¥ä½å· |
| | | LocationInfoParam param = new LocationInfoParam(); |
| | | param.setLocationCode(repairLocation); |
| | | List<LocationInfoResult> results = locationInfoService.findListBySpec(param); |
| | | if(results.size()>0) { |
| | | LocationInfoResult r = results.get(0); |
| | | String repairLocationNo = r.getSpareField2(); |
| | | if(null != repairLocationNo && "" != repairLocationNo){ |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_P_REPAIR_LOCATION,repairLocationNo)); |
| | | lists.add(new ReadWriteEntity(OPCElement.BOP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | //æ´æ°ä¸ºå·²ç»è¿ä¿®ä¸çº¿ |
| | | Long id = result.getId(); |
| | | repairManageInfoParam.setId(id); |
| | | repairManageInfoParam.setUpPlc("1"); |
| | | repairManageInfoService.update(repairManageInfoParam); |
| | | |
| | | }else{ |
| | | logger.info("BOP010å·¥ä½,handleRepair 请æ¥è¯¢"+repairLocation+"å·¥ä½æ¯å¦é
ç½®è¿ä¿®å·¥ä½å·ï¼"); |
| | | } |
| | | }else{ |
| | | logger.info("BOP010å·¥ä½,handleRepair æ æ³æ¥è¯¢å°"+repairLocation+"å·¥ä½ï¼"); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class BOP020Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(BOP020Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP020";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public BOP020Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.BOP020_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP020_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP020_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP020_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("BOP020å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP020_S_ORDER_CODE); |
| | | lists.add(OPCElement.BOP020_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.BOP020_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.BOP020_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.BOP020_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.BOP020_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP020_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.BOP020_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP020_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class BOP030BCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(BOP030BCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP030B";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public BOP030BCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.BOP030B_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030B_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP030B_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP030B_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("BOP030Bå¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP030B_S_ORDER_CODE); |
| | | lists.add(OPCElement.BOP030B_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.BOP030B_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.BOP030B_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.BOP030B_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.BOP030B_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030B_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.BOP030B_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030B_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class BOP030Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(BOP030Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP030";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public BOP030Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.BOP030_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP030_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP030_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("BOP030å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP030_S_ORDER_CODE); |
| | | lists.add(OPCElement.BOP030_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.BOP030_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.BOP030_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.BOP030_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.BOP030_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.BOP030_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class BOP040BCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(BOP040BCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP040B";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public BOP040BCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.BOP040B_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040B_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP040B_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP040B_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("BOP040Bå¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP040B_S_ORDER_CODE); |
| | | lists.add(OPCElement.BOP040B_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.BOP040B_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.BOP040B_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.BOP040B_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.BOP040B_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040B_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.BOP040B_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040B_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class BOP040Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(BOP040Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP040";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public BOP040Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.BOP040_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP040_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.BOP040_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("BOP040å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP040_S_ORDER_CODE); |
| | | lists.add(OPCElement.BOP040_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.BOP040_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.BOP040_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.BOP040_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.BOP040_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.BOP040_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.params.SerialNumbersConfParam; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.result.SerialNumbersConfResult; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.SFCCodeTool; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | |
| | | @Component |
| | | public class COP010Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(COP010Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "COP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "COP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public COP010Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.COP010_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP010_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.COP010_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | String isRepair = miloService. |
| | | readFromOpcUa(OPCElement.COP010_P_REPAIR) |
| | | .getValue().toString();//æ¯å¦è¿ä¿® |
| | | if(isRepair.equals("true")){ |
| | | handleRepair(); |
| | | }else{ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.COP010_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("COP010å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | System.out.println("finally" +ecpStr); |
| | | } |
| | | } |
| | | |
| | | public void handleOrder() throws Exception{ |
| | | |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
| | | param.setProductionLine("");//产线 |
| | | param.setOrderStatus("3");//å·¥åç¶æ |
| | | List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(param); |
| | | |
| | | if(list.size()>0) { |
| | | ProductionOrdeInfoResult result = list.get(0); |
| | | |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getMaterialCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | |
| | | //èªå¨çæå¯ä¸ç |
| | | Random random = new Random(System.currentTimeMillis()); |
| | | S_SFC_CODE = "COP"+random.nextLong(); |
| | | |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_NUMBER,result.getPlanQty().toString())); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | |
| | | logger.info("COP010å·¥ä½,handleOrder PCå¤çå®æï¼2"); |
| | | }else{ |
| | | logger.info("COP010å·¥ä½æ²¡æå¯æ§è¡çå·¥å,请è系工å管çåä¸å该产线çå·¥åï¼"); |
| | | } |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.COP010_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP010_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | public void handleRepair() throws Exception{ |
| | | RepairManageInfoParam repairManageInfoParam = new RepairManageInfoParam(); |
| | | repairManageInfoParam.setLocationCode(LOCATION_CODE); |
| | | repairManageInfoParam.setManageType("2"); |
| | | repairManageInfoParam.setUpPlc("0"); |
| | | List<RepairManageInfoResult> list = repairManageInfoService.findListBySpec(repairManageInfoParam); |
| | | if(list.size()>0) { |
| | | RepairManageInfoResult result = list.get(0); |
| | | |
| | | //èªå¨çæå¯ä¸ç |
| | | Random random = new Random(System.currentTimeMillis()); |
| | | S_SFC_CODE = "COP" + random.nextLong(); |
| | | |
| | | |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getProductCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | String repairLocation = result.getPoorLocationCode();// |
| | | |
| | | //æ ¹æ®å·¥ä½ç¼ç æ¥è¯¢å·¥ä½è¡¨ä¸é
ç½®çè¿ä¿®å·¥ä½å· |
| | | LocationInfoParam param = new LocationInfoParam(); |
| | | param.setLocationCode(repairLocation); |
| | | List<LocationInfoResult> results = locationInfoService.findListBySpec(param); |
| | | if(results.size()>0) { |
| | | LocationInfoResult r = results.get(0); |
| | | String repairLocationNo = r.getSpareField2(); |
| | | if(null != repairLocationNo && "" != repairLocationNo){ |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_P_REPAIR_LOCATION,repairLocationNo)); |
| | | lists.add(new ReadWriteEntity(OPCElement.COP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | //æ´æ°ä¸ºå·²ç»è¿ä¿®ä¸çº¿ |
| | | Long id = result.getId(); |
| | | repairManageInfoParam.setId(id); |
| | | repairManageInfoParam.setUpPlc("1"); |
| | | repairManageInfoService.update(repairManageInfoParam); |
| | | |
| | | }else{ |
| | | logger.info("COP010å·¥ä½,handleRepair 请æ¥è¯¢"+repairLocation+"å·¥ä½æ¯å¦é
ç½®è¿ä¿®å·¥ä½å·ï¼"); |
| | | } |
| | | }else{ |
| | | logger.info("COP010å·¥ä½,handleRepair æ æ³æ¥è¯¢å°"+repairLocation+"å·¥ä½ï¼"); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class COP020Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(COP020Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "COP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "COP020";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public COP020Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.COP020_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP020_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.COP020_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.COP020_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.COP020_S_ORDER_CODE); |
| | | lists.add(OPCElement.COP020_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.COP020_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.COP020_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.COP020_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.COP020_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP020_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.COP020_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP020_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class COP030Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(COP020Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "COP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "COP030";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public COP030Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.COP030_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP030_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.COP030_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.COP030_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.COP030_S_ORDER_CODE); |
| | | lists.add(OPCElement.COP030_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.COP030_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.COP030_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.COP030_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.COP030_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP030_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.COP030_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP030_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | @Component |
| | | public class DOP010Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(DOP010Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "DOP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public DOP010Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.COP010_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP010_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.DOP010_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | String isRepair = miloService. |
| | | readFromOpcUa(OPCElement.DOP010_P_REPAIR) |
| | | .getValue().toString();//æ¯å¦è¿ä¿® |
| | | if(isRepair.equals("true")){ |
| | | handleRepair(); |
| | | }else{ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.DOP010_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | //handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void handleOrder() throws Exception{ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
| | | param.setProductionLine("");//产线 |
| | | param.setOrderStatus("3");//å·¥åç¶æ |
| | | List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(param); |
| | | if(list.size()>0) { |
| | | ProductionOrdeInfoResult result = list.get(0); |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getMaterialCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | |
| | | //èªå¨çæå¯ä¸ç |
| | | Random random = new Random(System.currentTimeMillis()); |
| | | S_SFC_CODE = "EOP"+ random.nextLong(); |
| | | |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_NUMBER,result.getPlanQty().toString())); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | logger.info("DOP010å·¥ä½,handleOrder PCå¤çå®æï¼"); |
| | | }else{ |
| | | logger.info("DOP010å·¥ä½æ²¡æå¯æ§è¡çå·¥å,请è系工å管çåä¸å该产线çå·¥åï¼"); |
| | | } |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.DOP010_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP010_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | public void handleRepair() throws Exception{ |
| | | RepairManageInfoParam repairManageInfoParam = new RepairManageInfoParam(); |
| | | repairManageInfoParam.setLocationCode(LOCATION_CODE); |
| | | repairManageInfoParam.setManageType("2"); |
| | | repairManageInfoParam.setUpPlc("0"); |
| | | List<RepairManageInfoResult> list = repairManageInfoService.findListBySpec(repairManageInfoParam); |
| | | if(list.size()>0) { |
| | | RepairManageInfoResult result = list.get(0); |
| | | |
| | | //èªå¨çæå¯ä¸ç |
| | | Random random = new Random(System.currentTimeMillis()); |
| | | S_SFC_CODE = "BOP" + random.nextLong(); |
| | | |
| | | |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getProductCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | String repairLocation = result.getPoorLocationCode();// |
| | | |
| | | //æ ¹æ®å·¥ä½ç¼ç æ¥è¯¢å·¥ä½è¡¨ä¸é
ç½®çè¿ä¿®å·¥ä½å· |
| | | LocationInfoParam param = new LocationInfoParam(); |
| | | param.setLocationCode(repairLocation); |
| | | List<LocationInfoResult> results = locationInfoService.findListBySpec(param); |
| | | if(results.size()>0) { |
| | | LocationInfoResult r = results.get(0); |
| | | String repairLocationNo = r.getSpareField2(); |
| | | if(null != repairLocationNo && "" != repairLocationNo){ |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_P_REPAIR_LOCATION,repairLocationNo)); |
| | | lists.add(new ReadWriteEntity(OPCElement.DOP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | //æ´æ°ä¸ºå·²ç»è¿ä¿®ä¸çº¿ |
| | | Long id = result.getId(); |
| | | repairManageInfoParam.setId(id); |
| | | repairManageInfoParam.setUpPlc("1"); |
| | | repairManageInfoService.update(repairManageInfoParam); |
| | | |
| | | }else{ |
| | | logger.info("DOP010å·¥ä½,handleRepair 请æ¥è¯¢"+repairLocation+"å·¥ä½æ¯å¦é
ç½®è¿ä¿®å·¥ä½å·ï¼"); |
| | | } |
| | | }else{ |
| | | logger.info("DOP010å·¥ä½,handleRepair æ æ³æ¥è¯¢å°"+repairLocation+"å·¥ä½ï¼"); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class DOP020Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(DOP020Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "DOP020";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public DOP020Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.DOP020_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP020_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.DOP020_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.DOP020_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.DOP020_S_ORDER_CODE); |
| | | lists.add(OPCElement.DOP020_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.DOP020_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.DOP020_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.DOP020_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.DOP020_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP020_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.DOP020_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP020_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP010Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP010Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP010Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP010_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP010_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP010_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP010_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP010_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP010_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP010_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP010_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP010_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP010_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP010_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP010_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP010_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | |
| | | public void handleMaterial() throws Exception{ |
| | | String materialCode = miloService. |
| | | readFromOpcUa(OPCElement.EOP010_S_MATERIAL_CODE) |
| | | .getValue().toString(); |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setMaterialCode(materialCode); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP020Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP020Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP020";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP020Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP020_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP020_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP020_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP020_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP020_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP020_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP020_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP020_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP020_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP020_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP020_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP020_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP020_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP030Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP030Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP030";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP030Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP030_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP030_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP030_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP030_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP030_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP030_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP030_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP030_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP030_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP030_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP030_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP030_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP030_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP040Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP040Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP040";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP040Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP040_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP040_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP040_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP040_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP040_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP040_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP040_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP040_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP040_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP040_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP040_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP040_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP040_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP050Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP050Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP050";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP050Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP050_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP050_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP050_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP050_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP050_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP050_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP050_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP050_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP050_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP050_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP050_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP050_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP050_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP060Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP060Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP060";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP060Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP060_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP060_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP060_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP060_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP060_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP060_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP060_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP060_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP060_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP060_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP060_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP060_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP060_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP070Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP070Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP070";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP070Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP070_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP070_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP070_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP070_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP070_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP070_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP070_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP070_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP070_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP070_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP070_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP070_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP070_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP080Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP080Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP080";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP080Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP080_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP080_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP080_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP080_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP080_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP080_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP080_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP080_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP080_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP080_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP080_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP080_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP080_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP090BCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP090BCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP090B";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP090BCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP090B_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090B_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP090B_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP090B_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP090B_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP090B_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP090B_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP090B_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP090B_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP090B_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090B_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP090B_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090B_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class EOP090Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(EOP090Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "EOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "EOP090";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public EOP090Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.EOP090_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP090_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.EOP090_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP090_S_ORDER_CODE); |
| | | lists.add(OPCElement.EOP090_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.EOP090_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.EOP090_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.EOP090_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.EOP090_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.EOP090_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.model.params.EquipmentInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.model.result.EquipmentInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.model.params.EquipmentAlarmParam; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.model.params.EquipmentStatusParam; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.model.result.EquipmentStatusResult; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.params.SerialNumbersConfParam; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.result.SerialNumbersConfResult; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.SFCCodeTool; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class InitCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(InitCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | private static Integer ACTUAL_ONLINE_QTY = 0 ;//ä¸çº¿æ°é |
| | | |
| | | OP010Callback OP010Callback; |
| | | OP020Callback OP020Callback; |
| | | OP030Callback OP030Callback; |
| | | OP040Callback OP040Callback; |
| | | OP050Callback OP050Callback; |
| | | OP070Callback OP070Callback; |
| | | OP080Callback OP080Callback; |
| | | OP090Callback OP090Callback; |
| | | OP100Callback OP100Callback; |
| | | OP110Callback OP110Callback; |
| | | OP120Callback OP120Callback; |
| | | OP120BCallback OP120BCallback; |
| | | OP130Callback OP130Callback; |
| | | OP130BCallback OP130BCallback; |
| | | OP140Callback OP140Callback; |
| | | OP150Callback OP150Callback; |
| | | OP160Callback OP160Callback; |
| | | OP170Callback OP170Callback; |
| | | BOP010Callback BOP010Callback; |
| | | BOP020Callback BOP020Callback; |
| | | BOP030Callback BOP030Callback; |
| | | BOP030BCallback BOP030BCallback; |
| | | BOP040Callback BOP040Callback; |
| | | BOP040BCallback BOP040BCallback; |
| | | COP010Callback COP010Callback; |
| | | COP020Callback COP020Callback; |
| | | COP030Callback COP030Callback; |
| | | DOP010Callback DOP010Callback; |
| | | DOP020Callback DOP020Callback; |
| | | EOP010Callback EOP010Callback; |
| | | EOP020Callback EOP020Callback; |
| | | EOP030Callback EOP030Callback; |
| | | EOP040Callback EOP040Callback; |
| | | EOP050Callback EOP050Callback; |
| | | EOP060Callback EOP060Callback; |
| | | EOP070Callback EOP070Callback; |
| | | EOP080Callback EOP080Callback; |
| | | EOP090Callback EOP090Callback; |
| | | EOP090BCallback EOP090BCallback; |
| | | |
| | | StateCallback StateCallback; |
| | | |
| | | |
| | | public InitCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | |
| | | OP010Callback = new OP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP020Callback = new OP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP030Callback = new OP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP040Callback = new OP040Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP050Callback = new OP050Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | /* OP060Callback = new OP060Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService);*/ |
| | | OP070Callback = new OP070Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP080Callback = new OP080Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP090Callback = new OP090Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP100Callback = new OP100Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP110Callback = new OP110Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP120Callback = new OP120Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP120BCallback = new OP120BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP130Callback = new OP130Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP130BCallback = new OP130BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP140Callback = new OP140Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP150Callback = new OP150Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP160Callback = new OP160Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | OP170Callback = new OP170Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | COP010Callback = new COP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | COP020Callback = new COP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | COP030Callback = new COP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | BOP010Callback = new BOP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | BOP020Callback = new BOP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | BOP030Callback = new BOP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | BOP030BCallback = new BOP030BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | BOP040Callback = new BOP040Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | BOP040BCallback = new BOP040BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | DOP010Callback = new DOP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | DOP020Callback = new DOP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP010Callback = new EOP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP020Callback = new EOP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP030Callback = new EOP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP040Callback = new EOP040Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP050Callback = new EOP050Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP060Callback = new EOP060Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP070Callback = new EOP070Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP080Callback = new EOP080Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP090Callback = new EOP090Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | EOP090BCallback = new EOP090BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | |
| | | StateCallback = new StateCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | |
| | | if(null != value) { |
| | | //OP010 |
| | | //å¿è·³ |
| | | if (identifier.equals(OPCElement.OP010_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP010_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP010_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | String isRepair = miloService.readFromOpcUa(OPCElement.OP010_P_REPAIR).getValue().toString();//æ¯å¦è¿ä¿® |
| | | if (isRepair.equals("true")) { |
| | | OP010Callback.handleRepair(); |
| | | } else { |
| | | OP010Callback.handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP010_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP010Callback.handleFinsh(); |
| | | OP010Callback.handleMaterial(); |
| | | } |
| | | |
| | | //OP020 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP020_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP020_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP020_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP020Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP020_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP020Callback.handleFinsh(); |
| | | OP020Callback.handleMaterial(); |
| | | OP020Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP030 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP030_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP030_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP030Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP030_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP030Callback.handleFinsh(); |
| | | OP030Callback.handleMaterial(); |
| | | OP030Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP040 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP040_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP040_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP040_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP040Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP040_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP040Callback.handleFinsh(); |
| | | OP040Callback.handleMaterial(); |
| | | OP040Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP050 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP050_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP050_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP050Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP050_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP050Callback.handleMaterial(); |
| | | OP050Callback.handleInfo(); |
| | | OP050Callback.handleFinsh(); |
| | | } |
| | | |
| | | //OP070 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP070_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP070_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP070_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP070Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP070_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP070Callback.handleFinsh(); |
| | | OP070Callback.handleMaterial(); |
| | | OP070Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP080 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP080_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP080_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP080_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | String isRepair = miloService.readFromOpcUa(OPCElement.OP080_P_REPAIR).getValue().toString();//æ¯å¦è¿ä¿® |
| | | if (isRepair.equals("true")) { |
| | | OP080Callback.handleRepair(); |
| | | } else { |
| | | OP080Callback.handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP080_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP080Callback.handleFinsh(); |
| | | OP080Callback.handleMaterial(); |
| | | OP080Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP090 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP090_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP090_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP090Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP100_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP100Callback.handleMaterial(); |
| | | OP100Callback.handleInfo(); |
| | | OP100Callback.handleFinsh(); |
| | | } |
| | | |
| | | //OP110 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP110_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP110_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP110_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP110Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP110_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP110Callback.handleFinsh(); |
| | | OP110Callback.handleMaterial(); |
| | | OP110Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP120 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP120_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP120_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP120Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP120_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP120Callback.handleFinsh(); |
| | | OP120Callback.handleMaterial(); |
| | | OP120Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP120B |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP120B_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120B_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP120B_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP120BCallback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP120B_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP120BCallback.handleFinsh(); |
| | | OP120BCallback.handleMaterial(); |
| | | OP120BCallback.handleInfo(); |
| | | } |
| | | |
| | | //OP130 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP130_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP130_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP130Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP130_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP130Callback.handleFinsh(); |
| | | OP130Callback.handleMaterial(); |
| | | OP130Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP130B |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP130B_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130B_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP130B_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP130BCallback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP130B_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP130BCallback.handleFinsh(); |
| | | OP130BCallback.handleMaterial(); |
| | | OP130BCallback.handleInfo(); |
| | | } |
| | | |
| | | //OP140 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP140_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP140_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP140_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP140Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP140_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP140Callback.handleFinsh(); |
| | | OP140Callback.handleMaterial(); |
| | | OP140Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP150 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP150_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP150_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP150_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP150Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP150_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP150Callback.handleFinsh(); |
| | | OP150Callback.handleMaterial(); |
| | | OP150Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP160 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP160_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP160_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP160_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP160Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP160_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP160Callback.handleFinsh(); |
| | | OP160Callback.handleMaterial(); |
| | | OP160Callback.handleInfo(); |
| | | } |
| | | |
| | | //OP170 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.OP170_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP170_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.OP170_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | OP170Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.OP170_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | OP170Callback.handleFinsh(); |
| | | OP170Callback.handleMaterial(); |
| | | //OP170Callback.handleInfo(); |
| | | } |
| | | |
| | | //BOP010 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.BOP010_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP010_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.BOP010_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | String isRepair = miloService.readFromOpcUa(OPCElement.BOP010_P_REPAIR).getValue().toString();//æ¯å¦è¿ä¿® |
| | | if (isRepair.equals("true")) { |
| | | BOP010Callback.handleRepair(); |
| | | } else { |
| | | BOP010Callback.handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.BOP010_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | BOP010Callback.handleFinsh(); |
| | | BOP010Callback.handleMaterial(); |
| | | //BOP010Callback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //BOP020 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.BOP020_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP020_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.BOP020_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | BOP020Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.BOP020_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | BOP020Callback.handleFinsh(); |
| | | BOP020Callback.handleMaterial(); |
| | | BOP020Callback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //BOP030 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.BOP030_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.BOP030_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | BOP030Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.BOP030_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | BOP030Callback.handleFinsh(); |
| | | BOP030Callback.handleMaterial(); |
| | | BOP030Callback.handleInfo(); |
| | | } |
| | | |
| | | //BOP030B |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.BOP030B_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030B_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.BOP030B_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | BOP030BCallback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.BOP030B_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | BOP030BCallback.handleFinsh(); |
| | | //BOP030BCallback.handleMaterial(); |
| | | //BOP030BCallback.handleInfo(); |
| | | } |
| | | |
| | | //BOP040 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.BOP040_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.BOP040_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | BOP040Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.BOP040_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | BOP040Callback.handleFinsh(); |
| | | BOP040Callback.handleMaterial(); |
| | | BOP040Callback.handleInfo(); |
| | | } |
| | | |
| | | //BOP040B |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.BOP040B_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP040B_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.BOP040B_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | BOP040BCallback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.BOP040B_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | BOP040BCallback.handleFinsh(); |
| | | // BOP040BCallback.handleMaterial(); |
| | | //BOP040BCallback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //COP010 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.COP010_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP010_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.COP010_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | String isRepair = miloService.readFromOpcUa(OPCElement.COP010_P_REPAIR).getValue().toString();//æ¯å¦è¿ä¿® |
| | | if (isRepair.equals("true")) { |
| | | COP010Callback.handleRepair(); |
| | | } else { |
| | | COP010Callback.handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.COP010_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | COP010Callback.handleFinsh(); |
| | | COP010Callback.handleMaterial(); |
| | | //COP010Callback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //COP020 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.COP020_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP020_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.COP020_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | COP020Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.COP020_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | COP020Callback.handleFinsh(); |
| | | COP020Callback.handleMaterial(); |
| | | COP020Callback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //COP030 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.COP030_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.COP030_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.COP030_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | COP030Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.COP030_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | COP030Callback.handleFinsh(); |
| | | COP030Callback.handleMaterial(); |
| | | COP030Callback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //DOP010 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.DOP010_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP010_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.DOP010_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | String isRepair = miloService.readFromOpcUa(OPCElement.DOP010_P_REPAIR).getValue().toString();//æ¯å¦è¿ä¿® |
| | | if (isRepair.equals("true")) { |
| | | DOP010Callback.handleRepair(); |
| | | } else { |
| | | DOP010Callback.handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.DOP010_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | DOP010Callback.handleFinsh(); |
| | | DOP010Callback.handleMaterial(); |
| | | //DOP010Callback.handleInfo(); |
| | | } |
| | | |
| | | |
| | | //DOP020 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.DOP020_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP020_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.DOP020_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | DOP020Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.DOP020_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | DOP020Callback.handleFinsh(); |
| | | DOP020Callback.handleMaterial(); |
| | | DOP020Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP010 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP010_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP010_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP010_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP010Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP010_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP010Callback.handleFinsh(); |
| | | EOP010Callback.handleMaterial(); |
| | | EOP010Callback.handleInfo(); |
| | | } |
| | | //EOP020 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP020_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP020_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP020_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP020Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP020_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP020Callback.handleFinsh(); |
| | | EOP020Callback.handleMaterial(); |
| | | EOP020Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP030 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP030_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP030_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP030_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP030Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP030_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP030Callback.handleFinsh(); |
| | | EOP030Callback.handleMaterial(); |
| | | EOP030Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP040 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP040_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP040_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP040_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP040Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP040_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP040Callback.handleFinsh(); |
| | | EOP040Callback.handleMaterial(); |
| | | EOP040Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP050 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP050_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP050_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP050_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP050Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP050_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP050Callback.handleFinsh(); |
| | | EOP050Callback.handleMaterial(); |
| | | EOP050Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP060 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP060_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP060_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP060_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP060Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP060_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP060Callback.handleFinsh(); |
| | | EOP060Callback.handleMaterial(); |
| | | EOP060Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP070 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP070_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP070_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP070_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP070Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP070_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP070Callback.handleFinsh(); |
| | | EOP070Callback.handleMaterial(); |
| | | EOP070Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP080 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP080_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP080_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP080_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP080Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP080_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP080Callback.handleFinsh(); |
| | | EOP080Callback.handleMaterial(); |
| | | EOP080Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP090 |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP090_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP090_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP090Callback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP090_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP090Callback.handleFinsh(); |
| | | EOP090Callback.handleMaterial(); |
| | | EOP090Callback.handleInfo(); |
| | | } |
| | | |
| | | //EOP090B |
| | | //å¿è·³ |
| | | else if (identifier.equals(OPCElement.EOP090B_F_HEART_BEAT) && null != value && "false".equals(value.toString())) { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.EOP090B_F_HEART_BEAT, true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | //PLCè¿ç« |
| | | else if (identifier.equals(OPCElement.EOP090B_J_PLC_START) && null != value && "true".equals(value.toString())) { |
| | | EOP090BCallback.handleOrder(); |
| | | } |
| | | //PLCåºç« |
| | | else if (identifier.equals(OPCElement.EOP090B_J_PLC_FINISH) && null != value && "true".equals(value.toString())) { |
| | | EOP090BCallback.handleFinsh(); |
| | | EOP090BCallback.handleMaterial(); |
| | | EOP090BCallback.handleInfo(); |
| | | } |
| | | |
| | | else if (identifier.contains("STATE") && null != value && "true".equals(value.toString())) { |
| | | EquipmentInfoParam equipmentInfoParam = new EquipmentInfoParam(); |
| | | equipmentInfoParam.setSpareField1(identifier); |
| | | List<EquipmentInfoResult> lists = equipmentInfoService.findListBySpec(equipmentInfoParam); |
| | | if(!lists.isEmpty()){ |
| | | EquipmentInfoResult result = (EquipmentInfoResult) list.get(0); |
| | | String equipmentNo = result.getEquipmentNo(); |
| | | EquipmentStatusParam equipmentStatusParam = new EquipmentStatusParam(); |
| | | equipmentStatusParam.setEquipmentNo(equipmentNo); |
| | | List statuslist = equipmentStatusService.findListBySpec(equipmentStatusParam); |
| | | if(statuslist.size()>0){ |
| | | EquipmentStatusResult equipmentStatusResult = (EquipmentStatusResult) statuslist.get(0); |
| | | if(!value.equals(equipmentStatusResult.getStatus())){ |
| | | equipmentStatusParam.setId(equipmentStatusResult.getId()); |
| | | equipmentStatusParam.setStatus(value.toString()); |
| | | equipmentStatusParam.setUpdateTime(DateTool.getLocalTimeForDate()); |
| | | equipmentStatusService.update(equipmentStatusParam);//æ´æ°è®¾å¤ç¶æ |
| | | |
| | | //æ·»å 设å¤æ¥è¦ |
| | | if("3".equals(value)){ |
| | | EquipmentAlarmParam equipmentAlarmParam = new EquipmentAlarmParam(); |
| | | equipmentAlarmParam.setEquipmentNo(equipmentNo); |
| | | equipmentAlarmParam.setEquipmentName(result.getEquipmentName()); |
| | | equipmentAlarmParam.setWorkshopCode(result.getWorkshopCode()); |
| | | equipmentAlarmParam.setProductionLineCode(result.getProductionLineCode()); |
| | | equipmentAlarmParam.setLocationCode(result.getLocationCode()); |
| | | equipmentAlarmParam.setErrorDesc(result.getEquipmentName()+"æ¥è¦ï¼"); |
| | | equipmentAlarmParam.setAlarmTime(DateTool.getLocalTimeForDate()); |
| | | equipmentAlarmService.add(equipmentAlarmParam); |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | equipmentStatusParam.setEquipmentName(result.getEquipmentName()); |
| | | equipmentStatusParam.setWorkshopCode(result.getWorkshopCode()); |
| | | equipmentStatusParam.setProductionLineCode(result.getProductionLineCode()); |
| | | equipmentStatusParam.setLocationCode(result.getLocationCode()); |
| | | equipmentStatusParam.setStatus(value.toString()); |
| | | equipmentStatusParam.setUpdateTime(DateTool.getLocalTimeForDate()); |
| | | equipmentStatusService.add(equipmentStatusParam); |
| | | |
| | | //æ·»å 设å¤æ¥è¦ |
| | | if("3".equals(value)){ |
| | | EquipmentAlarmParam equipmentAlarmParam = new EquipmentAlarmParam(); |
| | | equipmentAlarmParam.setEquipmentNo(equipmentNo); |
| | | equipmentAlarmParam.setEquipmentName(result.getEquipmentName()); |
| | | equipmentAlarmParam.setWorkshopCode(result.getWorkshopCode()); |
| | | equipmentAlarmParam.setProductionLineCode(result.getProductionLineCode()); |
| | | equipmentAlarmParam.setLocationCode(result.getLocationCode()); |
| | | equipmentAlarmParam.setErrorDesc(result.getEquipmentName()+"æ¥è¦ï¼"); |
| | | equipmentAlarmParam.setAlarmTime(DateTool.getLocalTimeForDate()); |
| | | equipmentAlarmService.add(equipmentAlarmParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // handleOilState("DOP020"); |
| | | StateCallback.handleOilStateOP050("OP050"); |
| | | StateCallback.handleOilStateBOP030("BOP030"); |
| | | } |
| | | |
| | | else { |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | |
| | | |
| | | }else { |
| | | System.out.println("å¼ä¸ºç©º"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | System.out.println(ecpStr+"\r\n"); |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.params.SerialNumbersConfParam; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.model.result.SerialNumbersConfResult; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.SFCCodeTool; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP010Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP010Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | private static Integer ACTUAL_ONLINE_QTY = 0 ;//ä¸çº¿æ°é |
| | | public OP010Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP010_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP010_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP010_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | |
| | | String isRepair = miloService. |
| | | readFromOpcUa(OPCElement.OP010_P_REPAIR) |
| | | .getValue().toString();//æ¯å¦è¿ä¿® |
| | | if(isRepair.equals("true")){ |
| | | handleRepair(); |
| | | }else{ |
| | | handleOrder(); |
| | | } |
| | | |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP010_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | System.out.println("finally" +ecpStr); |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception{ |
| | | |
| | | logger.info("OP010å·¥ä½,handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
| | | param.setProductionLine("");//产线 |
| | | param.setOrderStatus("3");//å·¥åç¶æ |
| | | List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(param); |
| | | |
| | | if(!list.isEmpty()) { |
| | | ProductionOrdeInfoResult result = list.get(0); |
| | | |
| | | String softwareVersionCode = result.getSoftwareVersionCode();//产ååå· |
| | | String productCompanyCode = result.getProductCompanyCode();//ç次 |
| | | |
| | | //åºåå· |
| | | String serialNumbers = "0000"; |
| | | SerialNumbersConfParam serialNumbersConfParam = new SerialNumbersConfParam(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | String Years = String.valueOf(calendar.get(Calendar.YEAR)); //年份 |
| | | String Months = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1),2, "0"); //æ份 |
| | | String Dates = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.DATE)),2, "0"); //æ¥æ |
| | | serialNumbersConfParam.setYears(Years+Months+Dates);//è·åå½åæ¯åªä¸å¤© |
| | | serialNumbersConfParam.setState("1"); |
| | | |
| | | List<SerialNumbersConfResult> serialNumberslist = serialNumbersConfService.findListBySpec(serialNumbersConfParam); |
| | | if(!serialNumberslist.isEmpty()){ |
| | | SerialNumbersConfResult serialNumbersConfResult = serialNumberslist.get(0); |
| | | serialNumbers = serialNumbersConfResult.getSerialNumber(); |
| | | serialNumbersConfParam.setId(serialNumbersConfResult.getId()); |
| | | }else{ |
| | | serialNumbersConfParam.setSerialNumber(serialNumbers); |
| | | serialNumbersConfParam.setLengths("4"); |
| | | serialNumbersConfService.add(serialNumbersConfParam); |
| | | List<SerialNumbersConfResult> serialNumberslist2 = serialNumbersConfService.findListBySpec(serialNumbersConfParam); |
| | | if(!serialNumberslist2.isEmpty()){ |
| | | SerialNumbersConfResult serialNumbersConfResult = serialNumberslist2.get(0); |
| | | //serialNumbers = serialNumbersConfResult.getSerialNumber(); |
| | | serialNumbersConfParam.setId(serialNumbersConfResult.getId()); |
| | | } |
| | | } |
| | | |
| | | //æ´æ°åºåå·+1 |
| | | int i = Integer.valueOf(serialNumbers)+1; |
| | | serialNumbers = StringUtils.leftPad(String.valueOf(i),4, "0"); |
| | | serialNumbersConfParam.setSerialNumber(serialNumbers); |
| | | serialNumbersConfService.update(serialNumbersConfParam); |
| | | |
| | | //çææ»æç¼ç |
| | | String sfcCode = SFCCodeTool.createCodingRulesSFC(softwareVersionCode,productCompanyCode,serialNumbers);//æ»æå· |
| | | S_SFC_CODE = sfcCode; |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getMaterialCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | ACTUAL_ONLINE_QTY = result.getActualOnlineQty(); |
| | | |
| | | |
| | | //æ°å¢æ¥å·¥è®°å½ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | productionOrderRecordsParam.setMaterialCode(S_PRODUCT_CODE); |
| | | productionOrderRecordsParam.setStartTime(DateTool.getLocalTimeForDate()); |
| | | productionOrderRecordsParam.setWhetherPass("true"); |
| | | productionOrderRecordsService.add(productionOrderRecordsParam); |
| | | |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_NUMBER,result.getPlanQty().toString())); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | logger.info("OP010å·¥ä½,handleOrder PCå¤çå®æï¼^--------------------------------------------"); |
| | | }else{ |
| | | logger.info("OP010å·¥ä½æ²¡æå¯æ§è¡çå·¥å,请è系工å管çåä¸å该产线çå·¥åï¼"); |
| | | } |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP010_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP010_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void handleRepair() throws Exception{ |
| | | RepairManageInfoParam repairManageInfoParam = new RepairManageInfoParam(); |
| | | repairManageInfoParam.setLocationCode(LOCATION_CODE); |
| | | repairManageInfoParam.setManageType("2"); |
| | | repairManageInfoParam.setUpPlc("0"); |
| | | |
| | | List<RepairManageInfoResult> list = repairManageInfoService.findListBySpec(repairManageInfoParam); |
| | | if(list.size()>0) { |
| | | RepairManageInfoResult result = list.get(0); |
| | | |
| | | S_SFC_CODE = result.getSfc(); |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getProductCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | String repairLocation = result.getPoorLocationCode();// |
| | | |
| | | //æ ¹æ®å·¥ä½ç¼ç æ¥è¯¢å·¥ä½è¡¨ä¸é
ç½®çè¿ä¿®å·¥ä½å· |
| | | LocationInfoParam param = new LocationInfoParam(); |
| | | param.setLocationCode(repairLocation); |
| | | |
| | | List<LocationInfoResult> results = locationInfoService.findListBySpec(param); |
| | | if(results.size()>0) { |
| | | LocationInfoResult r = results.get(0); |
| | | String repairLocationNo = r.getSpareField2(); |
| | | if(null != repairLocationNo && "" != repairLocationNo){ |
| | | |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_P_REPAIR_LOCATION,repairLocationNo)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP010_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | |
| | | //æ´æ°ä¸ºå·²ç»è¿ä¿®ä¸çº¿ |
| | | Long id = result.getId(); |
| | | repairManageInfoParam.setId(id); |
| | | repairManageInfoParam.setUpPlc("1"); |
| | | repairManageInfoService.update(repairManageInfoParam); |
| | | |
| | | }else{ |
| | | logger.info("OP010å·¥ä½,handleRepair 请æ¥è¯¢"+repairLocation+"å·¥ä½æ¯å¦é
ç½®è¿ä¿®å·¥ä½å·ï¼"); |
| | | } |
| | | }else{ |
| | | logger.info("OP010å·¥ä½,handleRepair æ æ³æ¥è¯¢å°"+repairLocation+"å·¥ä½ï¼"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP020Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP020Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP020";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP020Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP020_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP020_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP020_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP020_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP020_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP020_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP020_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP020_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP020_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP020_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP020_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP020_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP020_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP030Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP030Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP030";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP030Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP030_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP030_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP030_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP030_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP030_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP030_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP030_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP030_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP030_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP030_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP030_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP040Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP040Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP040";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP040Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP040_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP040_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP040_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP040_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP040_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP040_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP040_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP040_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP040_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP040_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP040_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP040_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP040_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP050Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP050Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP050";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP050Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP050_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP050_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP050_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP050_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP050_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP050_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP050_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP050_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP050_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception{ |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | |
| | | String copSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_SFC_CODE_COP) |
| | | .getValue().toString(); |
| | | String bopSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP050_S_SFC_CODE_BOP) |
| | | .getValue().toString(); |
| | | |
| | | //æ ¹æ®åæ»æç¼ç ï¼å°EOPç©ææ°æ®ç»å®å
³ç³»ä¿®æ¹ä¸ºæ»æç¼ç |
| | | materialTraceabilityService.updateSFC(S_SFC_CODE,copSfcCode); |
| | | materialTraceabilityService.updateSFC(S_SFC_CODE,bopSfcCode); |
| | | |
| | | //æ ¹æ®åæ»æç¼ç ï¼å°EOPè¿ç«æ°æ®ç»å®å
³ç³»ä¿®æ¹ä¸ºæ»æç¼ç |
| | | passingStationCollectionService.updateSFC(S_SFC_CODE,copSfcCode); |
| | | passingStationCollectionService.updateSFC(S_SFC_CODE,bopSfcCode); |
| | | |
| | | |
| | | //æ ¹æ®åæ»æç¼ç ï¼å°EOPééæ°æ®ç»å®å
³ç³»ä¿®æ¹ä¸ºæ»æç¼ç |
| | | paramCollectionService.updateSFC(S_SFC_CODE,copSfcCode); |
| | | paramCollectionService.updateSFC(S_SFC_CODE,bopSfcCode); |
| | | |
| | | logger.info("S_SFC_CODE:"+S_SFC_CODE); |
| | | logger.info("copSfcCode:"+copSfcCode); |
| | | logger.info("bopSfcCode:"+bopSfcCode); |
| | | |
| | | //æ¥è¯¢COPåBOPæ¯å¦åæ ¼ |
| | | PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam(); |
| | | passingStationCollectionParam.setSfcCode(S_SFC_CODE); |
| | | List<PassingStationCollectionResult> passingStationCollectionResultList = |
| | | passingStationCollectionService.findListBySpec(passingStationCollectionParam); |
| | | |
| | | String isProductState = "true"; |
| | | for(int i=0;i<passingStationCollectionResultList.size();i++){ |
| | | PassingStationCollectionResult passingStationCollectionResult = passingStationCollectionResultList.get(i); |
| | | if("false".equals(passingStationCollectionResult.getOutRsSign())){ |
| | | isProductState = "false"; |
| | | break; |
| | | } |
| | | } |
| | | //ä¿®æ¹æ¥å·¥è®°å½ |
| | | if("false".equals(S_PRODUCT_STATE_CODE) || "false".equals(isProductState)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass("false"); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP070Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP070Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP070";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP070Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP070_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP070_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP070_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP070_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP070_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP070_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP070_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP070_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP070_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP070_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP070_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP070_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP070_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP080Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP080Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP080";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP080Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP080_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP080_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP080_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP080_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void handleRepair() throws Exception{ |
| | | RepairManageInfoParam repairManageInfoParam = new RepairManageInfoParam(); |
| | | repairManageInfoParam.setLocationCode(LOCATION_CODE); |
| | | repairManageInfoParam.setManageType("2"); |
| | | repairManageInfoParam.setUpPlc("0"); |
| | | List<RepairManageInfoResult> list = repairManageInfoService.findListBySpec(repairManageInfoParam); |
| | | if(list.size()>0) { |
| | | RepairManageInfoResult result = list.get(0); |
| | | |
| | | S_SFC_CODE = result.getSfc(); |
| | | S_ORDER_CODE = result.getWorkOrderNo(); |
| | | S_PRODUCT_CODE = result.getProductCode(); |
| | | S_PRODUCT_TYPE = GlobalVariable.PRODUCT_TYPE_MAP.get(S_PRODUCT_CODE); |
| | | String repairLocation = result.getPoorLocationCode();// |
| | | |
| | | //æ ¹æ®å·¥ä½ç¼ç æ¥è¯¢å·¥ä½è¡¨ä¸é
ç½®çè¿ä¿®å·¥ä½å· |
| | | LocationInfoParam param = new LocationInfoParam(); |
| | | param.setLocationCode(repairLocation); |
| | | List<LocationInfoResult> results = locationInfoService.findListBySpec(param); |
| | | if(results.size()>0) { |
| | | LocationInfoResult r = results.get(0); |
| | | String repairLocationNo = r.getSpareField2(); |
| | | if(null != repairLocationNo && "" != repairLocationNo){ |
| | | List<ReadWriteEntity> lists = new ArrayList<>(); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP080_S_ORDER_CODE,S_ORDER_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP080_S_PRODUCT_CODE,S_PRODUCT_TYPE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP080_S_SFC_CODE,S_SFC_CODE)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP080_P_REPAIR_LOCATION,repairLocationNo)); |
| | | lists.add(new ReadWriteEntity(OPCElement.OP080_J_PC_WRITE_ORDER,true)); |
| | | miloService.writeToOpcUa(lists); |
| | | |
| | | //æ´æ°ä¸ºå·²ç»è¿ä¿®ä¸çº¿ |
| | | Long id = result.getId(); |
| | | repairManageInfoParam.setId(id); |
| | | repairManageInfoParam.setUpPlc("1"); |
| | | repairManageInfoService.update(repairManageInfoParam); |
| | | |
| | | }else{ |
| | | logger.info("OP080å·¥ä½,handleRepair 请æ¥è¯¢"+repairLocation+"å·¥ä½æ¯å¦é
ç½®è¿ä¿®å·¥ä½å·ï¼"); |
| | | } |
| | | }else{ |
| | | logger.info("OP080å·¥ä½,handleRepair æ æ³æ¥è¯¢å°"+repairLocation+"å·¥ä½ï¼"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP080_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP080_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP080_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP080_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP080_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP080_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP080_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP080_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP080_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.result.PassingStationCollectionResult; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP090Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP090Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP090";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP090Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP090_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP090_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP090_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP090_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP090_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP090_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP090_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP090_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP090_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP090_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | String eopSfcCode = miloService. |
| | | readFromOpcUa(OPCElement.OP090_S_SFC_CODE_EOP) |
| | | .getValue().toString(); |
| | | |
| | | //æ ¹æ®åæ»æç¼ç ï¼å°EOPç©ææ°æ®ç»å®å
³ç³»ä¿®æ¹ä¸ºæ»æç¼ç |
| | | materialTraceabilityService.updateSFC(S_SFC_CODE,eopSfcCode); |
| | | |
| | | //æ ¹æ®åæ»æç¼ç ï¼å°EOPè¿ç«æ°æ®ç»å®å
³ç³»ä¿®æ¹ä¸ºæ»æç¼ç |
| | | passingStationCollectionService.updateSFC(S_SFC_CODE,eopSfcCode); |
| | | |
| | | //æ ¹æ®åæ»æç¼ç ï¼å°EOPééæ°æ®ç»å®å
³ç³»ä¿®æ¹ä¸ºæ»æç¼ç |
| | | paramCollectionService.updateSFC(S_SFC_CODE,eopSfcCode); |
| | | |
| | | logger.info("S_SFC_CODE:"+S_SFC_CODE); |
| | | logger.info("eopSfcCode:"+eopSfcCode); |
| | | |
| | | //æ¥è¯¢COPåBOPæ¯å¦åæ ¼ |
| | | PassingStationCollectionParam passingStationCollectionParam = new PassingStationCollectionParam(); |
| | | passingStationCollectionParam.setSfcCode(S_SFC_CODE); |
| | | List<PassingStationCollectionResult> passingStationCollectionResultList = |
| | | passingStationCollectionService.findListBySpec(passingStationCollectionParam); |
| | | |
| | | String isProductState = "true"; |
| | | for(int i=0;i<passingStationCollectionResultList.size();i++){ |
| | | PassingStationCollectionResult passingStationCollectionResult = passingStationCollectionResultList.get(i); |
| | | if("false".equals(passingStationCollectionResult.getOutRsSign())){ |
| | | isProductState = "false"; |
| | | break; |
| | | } |
| | | } |
| | | //ä¿®æ¹æ¥å·¥è®°å½ |
| | | if("false".equals(S_PRODUCT_STATE_CODE) || "false".equals(isProductState)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass("false"); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP090_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP100Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP100Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP100";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP100Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP100_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP100_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP100_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP100_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP100_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP100_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP100_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP100_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP100_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP100_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP100_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP100_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP100_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP110Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP110Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP110";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP110Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP110_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP110_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP110_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP110_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP110_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP110_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP110_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP110_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP110_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP110_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP110_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP110_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP110_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP120BCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP120BCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP120B";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP120BCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP120B_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120B_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP120B_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP120B_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP120B_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP120B_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP120B_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP120B_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP120B_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP120B_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120B_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP120B_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120B_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP120Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP120Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP120";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP120Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP120_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP120_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP120_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP120_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP120_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP120_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP120_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP120_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP120_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP120_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP120_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP130BCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP130BCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP130B";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP130BCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP130B_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130B_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP130B_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP130B_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP130B_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP130B_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP130B_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP130B_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP130B_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP130B_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130B_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP130B_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130B_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP130Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP130Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP130";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP130Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP130_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP130_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP130_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP130_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP130_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP130_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP130_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP130_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP130_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP130_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP130_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP140Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP140Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP140";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP140Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP140_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP140_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP140_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP140_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP140_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP140_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP140_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP140_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP140_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP140_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP140_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP140_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP140_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP150Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP150Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP150";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP150Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP150_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP150_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP150_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP150_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP150_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP150_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP150_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP150_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP150_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP150_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP150_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP150_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP150_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP160Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP160Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP160";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP160Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP160_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP160_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP160_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP160_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP160_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP160_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP160_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP160_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP160_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP160_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP160_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP160_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | if("2".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | } |
| | | //å¤çè¿ç«ä¿¡æ¯ |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP160_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.params.ProductionOrderRecordsParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.model.result.ProductionOrderRecordsResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class OP170Callback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(OP170Callback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "OP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "OP170";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public OP170Callback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | //å¿è·³ |
| | | if(null != value && identifier.equals(OPCElement.OP170_F_HEART_BEAT)){ |
| | | if( "false".equals(value.toString())) |
| | | { |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP170_F_HEART_BEAT,true); |
| | | miloService.writeToOpcUa(entity); |
| | | } |
| | | } |
| | | //PLCè¿ç« |
| | | else if(null != value && identifier.equals(OPCElement.OP170_J_PLC_START)){ |
| | | if("true".equals(value.toString())){ |
| | | handleOrder(); |
| | | } |
| | | } |
| | | //PLCåºç« |
| | | else if(null != value && identifier.equals(OPCElement.OP170_J_PLC_FINISH)){ |
| | | if("true".equals(value.toString())){ |
| | | handleFinsh(); |
| | | handleInfo(); |
| | | handleMaterial(); |
| | | } |
| | | }else{ |
| | | System.out.println("å¼æ²¡æå"); |
| | | } |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读工å |
| | | public void handleOrder() throws Exception { |
| | | logger.info("handleOrder PCå¤çå¼å§ï¼"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP170_S_ORDER_CODE); |
| | | lists.add(OPCElement.OP170_S_PRODUCT_CODE); |
| | | lists.add(OPCElement.OP170_S_SFC_CODE); |
| | | List<ReadWriteEntity> returnLists= miloService.readFromOpcUa(lists); |
| | | returnLists.forEach(element->{ |
| | | switch(element.getIdentifier()){ |
| | | case OPCElement.OP170_S_ORDER_CODE: |
| | | S_ORDER_CODE = element.getValue().toString(); |
| | | break; |
| | | case OPCElement.OP170_S_PRODUCT_CODE: |
| | | S_PRODUCT_TYPE = element.getValue().toString(); |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | break; |
| | | case OPCElement.OP170_S_SFC_CODE: |
| | | S_SFC_CODE = element.getValue().toString(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP170_J_PC_WRITE_ORDER,true); |
| | | miloService.writeToOpcUa(entity); |
| | | logger.info("handleOrder PCå¤çå®æï¼"); |
| | | } |
| | | |
| | | public void handleFinsh() throws Exception { |
| | | logger.info("handleFinsh PCå¤çå¼å§ï¼"); |
| | | String S_PRODUCT_STATE_CODE = miloService. |
| | | readFromOpcUa(OPCElement.OP170_S_PRODUCT_STATE_CODE) |
| | | .getValue().toString(); |
| | | |
| | | //ä¿®æ¹æ¥å·¥è®°å½ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | List<ProductionOrderRecordsResult> list2 = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(!list2.isEmpty()){ |
| | | ProductionOrderRecordsResult productionOrderRecordsResult = list2.get(0); |
| | | productionOrderRecordsParam.setId(productionOrderRecordsResult.getId()); |
| | | productionOrderRecordsParam.setWhetherPass(S_PRODUCT_STATE_CODE); |
| | | productionOrderRecordsParam.setEndTime(DateTool.getLocalTimeForDate()); |
| | | productionOrderRecordsService.update(productionOrderRecordsParam); |
| | | } |
| | | |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | | param.setSfcCode(S_SFC_CODE); |
| | | param.setProductionLine(PRODUCTION_LINE); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | param.setInboundTime(IN_TIME); |
| | | param.setOutboundTime(DateTool.getLocalTimeForDate()); |
| | | param.setOutRsSign(S_PRODUCT_STATE_CODE);//åºç«æ¯å¦åæ ¼ |
| | | passingStationCollectionService.add(param); |
| | | |
| | | //æ´æ°å·¥åå®ææ°é |
| | | ProductionOrdeInfoParam orderParam = new ProductionOrdeInfoParam(); |
| | | orderParam.setWorkOrderNo(S_ORDER_CODE); |
| | | if(!"".equals(S_ORDER_CODE)&&null!=S_ORDER_CODE){ |
| | | List<ProductionOrdeInfoResult> list = productionOrdeInfoService.findListBySpec(orderParam); |
| | | if(list.size()>0) { |
| | | ProductionOrdeInfoResult result = list.get(0); |
| | | orderParam.setId(result.getId()); |
| | | if (null == result.getActualQty() || "".equals(result.getActualQty())){ |
| | | result.setActualQty(0); |
| | | } |
| | | orderParam.setActualQty(result.getActualQty()+1); |
| | | productionOrdeInfoService.update(orderParam); |
| | | } |
| | | } |
| | | |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP170_J_PC_FINISH,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | logger.info("OP170å·¥ä½,handleFinsh PCå¤çå®æï¼"); |
| | | } |
| | | public void handleMaterial() { |
| | | |
| | | //æ¥è¯¢æ¹æ¬¡ä¸æä¿¡æ¯ |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | List<ProductionOrderBatchInfoResult> list = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list.get(i); |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//å©ä½æ°é |
| | | if(remainingQuantity>0 ){ |
| | | //æ°å¢ç©æ追溯 |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | materialTraceabilityParam.setWorkOrderNo(S_ORDER_CODE); |
| | | materialTraceabilityParam.setProductCode(S_PRODUCT_CODE); |
| | | materialTraceabilityParam.setProductNo(S_SFC_CODE); |
| | | materialTraceabilityParam.setLineCode(PRODUCTION_LINE); |
| | | materialTraceabilityParam.setLocationCode(LOCATION_CODE); |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityParam.setMaterialCode(productionOrderBatchInfoResult.getMaterialCode());//ç©æç¼ç |
| | | materialTraceabilityParam.setMaterialBatchNo(productionOrderBatchInfoResult.getBatch());//ç©ææ¹æ¬¡ |
| | | |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //æ´æ°å©ä½æ°é |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//å©ä½æ°é |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读åæ°ä¿¡æ¯ |
| | | public void handleInfo() throws Exception { |
| | | logger.info("handleInfo STARTï¼"); |
| | | |
| | | if(null == list){ |
| | | CollectionParamConfParam collectionParamConfParam = new CollectionParamConfParam(); |
| | | collectionParamConfParam.setLocationCode(LOCATION_CODE); |
| | | list = collectionParamConfService.findListBySpec(collectionParamConfParam); |
| | | } |
| | | if(null != list && !list.isEmpty()) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CollectionParamConfResult result = (CollectionParamConfResult) list.get(i); |
| | | String value = miloService. |
| | | readFromOpcUa(result.getGatherAddress()) |
| | | .getValue().toString();//读åæ°å¼ |
| | | ParamCollectionParam paramCollectionParam = new ParamCollectionParam(); |
| | | paramCollectionParam.setParamCode(result.getParamCode()); |
| | | paramCollectionParam.setParamName(result.getParamName()); |
| | | paramCollectionParam.setWorkOrderNo(S_ORDER_CODE); |
| | | paramCollectionParam.setSfcCode(S_SFC_CODE); |
| | | paramCollectionParam.setProductCode(S_PRODUCT_CODE); |
| | | paramCollectionParam.setProductionLine(result.getProductionLine()); |
| | | paramCollectionParam.setLocationCode(result.getLocationCode()); |
| | | paramCollectionParam.setParamValue(value); |
| | | paramCollectionParam.setParamLower(result.getParamLower()); |
| | | paramCollectionParam.setParamUpper(result.getParamUpper()); |
| | | paramCollectionParam.setParamStandard(result.getParamCentral()); |
| | | paramCollectionParam.setCollectionTime(DateTool.getLocalTimeForDate()); |
| | | paramCollectionParam.setUnit(result.getUnit()); |
| | | paramCollectionService.add(paramCollectionParam); |
| | | } |
| | | } |
| | | |
| | | logger.info("handleInfo ENDï¼"); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.callback; |
| | | |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.params.CollectionParamConfParam; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.model.result.CollectionParamConfResult; |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.model.params.EquipmentInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.model.result.EquipmentInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.params.LocationInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.model.result.LocationInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.model.params.PassingStationCollectionParam; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.model.params.EquipmentAlarmParam; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.model.params.EquipmentStatusParam; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.model.result.EquipmentStatusResult; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.model.params.GreaseManageParam; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.model.result.GreaseManageResult; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | | import cn.stylefeng.guns.plcserver.tool.DateTool; |
| | | import cn.stylefeng.guns.plcserver.tool.LogUtil; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import org.apache.log4j.Logger; |
| | | import org.openscada.opc.lib.da.Item; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | @Component |
| | | public class StateCallback implements SubscriptionCallback { |
| | | |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private static Logger logger; |
| | | LogUtil logUtil = new LogUtil(); |
| | | static { |
| | | logger = Logger.getLogger(StateCallback.class); |
| | | } |
| | | private static Date IN_TIME = null; |
| | | private static String S_ORDER_CODE = "";//å·¥åç¼å· |
| | | private static String S_PRODUCT_CODE = "";//产åç¼å· |
| | | private static String S_PRODUCT_TYPE= "";//产åç±»å |
| | | private static String S_SFC_CODE = "";//æ»æç¼ç |
| | | private static String PRODUCTION_LINE = "BOP";//äº§çº¿å· |
| | | private static String LOCATION_CODE = "BOP010";//å·¥ä½å· |
| | | private static List list = null; |
| | | |
| | | public StateCallback(MiloService miloService, |
| | | ProductionOrdeInfoService productionOrdeInfoService, |
| | | PassingStationCollectionService passingStationCollectionService, |
| | | ParamCollectionService paramCollectionService, |
| | | CollectionParamConfService collectionParamConfService, |
| | | SerialNumbersConfService serialNumbersConfService, |
| | | EquipmentStatusService equipmentStatusService, |
| | | EquipmentAlarmService equipmentAlarmService, |
| | | MaterialTraceabilityService materialTraceabilityService, |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService) { |
| | | this.miloService = miloService; |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | | this.paramCollectionService = paramCollectionService; |
| | | this.collectionParamConfService = collectionParamConfService; |
| | | this.serialNumbersConfService = serialNumbersConfService; |
| | | this.equipmentStatusService = equipmentStatusService; |
| | | this.equipmentAlarmService = equipmentAlarmService; |
| | | this.materialTraceabilityService = materialTraceabilityService; |
| | | this.equipmentInfoService = equipmentInfoService; |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | } |
| | | @Override |
| | | public void onSubscribe(String identifier, Object value) { |
| | | String ecpStr = "";//å¼å¸¸è®°å½æ è®° |
| | | try { |
| | | handleInfo(); |
| | | } catch (Exception e) { |
| | | ecpStr ="åºç°å¼å¸¸ï¼" + logUtil.getTrace(e); |
| | | }finally { |
| | | if(!"".equals(ecpStr)){ |
| | | logger.info(ecpStr+"\r\n"); |
| | | } |
| | | } |
| | | } |
| | | public void handleInfo() throws Exception { |
| | | logger.info("OP100å·¥ä½,handleInfo STARTï¼"); |
| | | |
| | | if(null == list ){ |
| | | EquipmentInfoParam equipmentInfoParam = new EquipmentInfoParam(); |
| | | list = equipmentInfoService.findListBySpec(equipmentInfoParam); |
| | | } |
| | | if(null != list && list.size()>0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | EquipmentInfoResult result = (EquipmentInfoResult) list.get(i); |
| | | Item item = result.getItem(); |
| | | String value = OPCUnit.read(item);//读åæ°å¼ 设å¤ç¶æ |
| | | String equipmentNo = result.getEquipmentNo(); |
| | | |
| | | EquipmentStatusParam equipmentStatusParam = new EquipmentStatusParam(); |
| | | equipmentStatusParam.setEquipmentNo(equipmentNo); |
| | | List statuslist = equipmentStatusService.findListBySpec(equipmentStatusParam); |
| | | if(statuslist.size()>0){ |
| | | EquipmentStatusResult equipmentStatusResult = (EquipmentStatusResult) statuslist.get(0); |
| | | if(!value.equals(equipmentStatusResult.getStatus())){ |
| | | equipmentStatusParam.setId(equipmentStatusResult.getId()); |
| | | equipmentStatusParam.setStatus(value); |
| | | equipmentStatusParam.setUpdateTime(DateTool.getLocalTimeForDate()); |
| | | equipmentStatusService.update(equipmentStatusParam);//æ´æ°è®¾å¤ç¶æ |
| | | |
| | | //æ·»å 设å¤æ¥è¦ |
| | | if("3".equals(value)){ |
| | | EquipmentAlarmParam equipmentAlarmParam = new EquipmentAlarmParam(); |
| | | equipmentAlarmParam.setEquipmentNo(equipmentNo); |
| | | equipmentAlarmParam.setEquipmentName(result.getEquipmentName()); |
| | | equipmentAlarmParam.setWorkshopCode(result.getWorkshopCode()); |
| | | equipmentAlarmParam.setProductionLineCode(result.getProductionLineCode()); |
| | | equipmentAlarmParam.setLocationCode(result.getLocationCode()); |
| | | equipmentAlarmParam.setErrorDesc(result.getEquipmentName()+"æ¥è¦ï¼"); |
| | | equipmentAlarmParam.setAlarmTime(DateTool.getLocalTimeForDate()); |
| | | equipmentAlarmService.add(equipmentAlarmParam); |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | equipmentStatusParam.setEquipmentName(result.getEquipmentName()); |
| | | equipmentStatusParam.setWorkshopCode(result.getWorkshopCode()); |
| | | equipmentStatusParam.setProductionLineCode(result.getProductionLineCode()); |
| | | equipmentStatusParam.setLocationCode(result.getLocationCode()); |
| | | equipmentStatusParam.setStatus(value); |
| | | equipmentStatusParam.setUpdateTime(DateTool.getLocalTimeForDate()); |
| | | equipmentStatusService.add(equipmentStatusParam); |
| | | |
| | | //æ·»å 设å¤æ¥è¦ |
| | | if("3".equals(value)){ |
| | | EquipmentAlarmParam equipmentAlarmParam = new EquipmentAlarmParam(); |
| | | equipmentAlarmParam.setEquipmentNo(equipmentNo); |
| | | equipmentAlarmParam.setEquipmentName(result.getEquipmentName()); |
| | | equipmentAlarmParam.setWorkshopCode(result.getWorkshopCode()); |
| | | equipmentAlarmParam.setProductionLineCode(result.getProductionLineCode()); |
| | | equipmentAlarmParam.setLocationCode(result.getLocationCode()); |
| | | equipmentAlarmParam.setErrorDesc(result.getEquipmentName()+"æ¥è¦ï¼"); |
| | | equipmentAlarmParam.setAlarmTime(DateTool.getLocalTimeForDate()); |
| | | equipmentAlarmService.add(equipmentAlarmParam); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | Thread.sleep(60*1000); |
| | | } |
| | | |
| | | public void handleOilStateDOP020(String LOCATION_CODE) throws Exception { |
| | | GreaseManageParam param = new GreaseManageParam(); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | List<GreaseManageResult> list = greaseManageService.findListBySpec(param); |
| | | if(!list.isEmpty()) { |
| | | String duaDate = list.get(0).getDuaDate(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String currentDate = format.format(new Date()); |
| | | long daysBetween = getRemainder(currentDate,duaDate); |
| | | if(daysBetween>0){ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP020_OIL_STATE,false); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | }else{ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.DOP020_OIL_STATE,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void handleOilStateOP050(String LOCATION_CODE) throws Exception { |
| | | GreaseManageParam param = new GreaseManageParam(); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | List<GreaseManageResult> list = greaseManageService.findListBySpec(param); |
| | | if(!list.isEmpty()) { |
| | | String duaDate = list.get(0).getDuaDate(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String currentDate = format.format(new Date()); |
| | | long daysBetween = getRemainder(currentDate,duaDate); |
| | | if(daysBetween>0){ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_OIL_STATE,false); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | }else{ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.OP050_OIL_STATE,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void handleOilStateBOP030(String LOCATION_CODE) throws Exception { |
| | | GreaseManageParam param = new GreaseManageParam(); |
| | | param.setLocationCode(LOCATION_CODE); |
| | | List<GreaseManageResult> list = greaseManageService.findListBySpec(param); |
| | | if(!list.isEmpty()) { |
| | | String duaDate = list.get(0).getDuaDate(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String currentDate = format.format(new Date()); |
| | | long daysBetween = getRemainder(currentDate,duaDate); |
| | | if(daysBetween>0){ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030_OIL_STATE,false); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | }else{ |
| | | ReadWriteEntity entity = new ReadWriteEntity(OPCElement.BOP030_OIL_STATE,true); |
| | | miloService.writeToOpcUa(entity);//åPCå®æ |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static long getRemainder(String currentDate,String tableDate){ |
| | | DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | LocalDate localDate1 = LocalDate.parse(currentDate, dateFormatter); |
| | | LocalDate localDate2 = LocalDate.parse(tableDate, dateFormatter); |
| | | long days = ChronoUnit.DAYS.between(localDate1, localDate2); |
| | | return days; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.stylefeng.guns.plcserver.init; |
| | | |
| | | import cn.stylefeng.guns.modular.bs.collectionParamConf.service.CollectionParamConfService; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.model.params.EquipmentInfoParam; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.model.result.EquipmentInfoResult; |
| | | import cn.stylefeng.guns.modular.bs.equipmentInfo.service.EquipmentInfoService; |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService; |
| | | import cn.stylefeng.guns.modular.cm.passingStationCollection.service.PassingStationCollectionService; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | import cn.stylefeng.guns.modular.em.equipmentAlarm.service.EquipmentAlarmService; |
| | | import cn.stylefeng.guns.modular.em.equipmentStatus.service.EquipmentStatusService; |
| | | import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
| | | import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
| | | import cn.stylefeng.guns.modular.om.productionOrderRecords.service.ProductionOrderRecordsService; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | | import cn.stylefeng.guns.modular.sc.serialNumbersConf.service.SerialNumbersConfService; |
| | | import cn.stylefeng.guns.plcserver.callback.*; |
| | | import cn.stylefeng.guns.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCElement; |
| | | import cn.stylefeng.guns.plcserver.server.OP010.OP010ServerInterface; |
| | | import cn.stylefeng.guns.plcserver.server.OP010.impl.OP010ServerInterfaceImpl; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.openscada.opc.lib.da.Item; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class CustomRunner implements ApplicationRunner { |
| | | |
| | | @Autowired |
| | | public MiloService miloService; |
| | | |
| | | @Autowired |
| | | public ProductionOrdeInfoService productionOrdeInfoService; |
| | | @Autowired |
| | | public PassingStationCollectionService passingStationCollectionService; |
| | | @Autowired |
| | | public ParamCollectionService paramCollectionService; |
| | | @Autowired |
| | | public CollectionParamConfService collectionParamConfService; |
| | | @Autowired |
| | | public SerialNumbersConfService serialNumbersConfService; |
| | | @Autowired |
| | | private EquipmentStatusService equipmentStatusService; |
| | | |
| | | @Autowired |
| | | private EquipmentAlarmService equipmentAlarmService; |
| | | @Autowired |
| | | private MaterialTraceabilityService materialTraceabilityService; |
| | | @Autowired |
| | | private EquipmentInfoService equipmentInfoService; |
| | | @Autowired |
| | | private RepairManageInfoService repairManageInfoService; |
| | | |
| | | @Autowired |
| | | private LocationInfoService locationInfoService; |
| | | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | private List stateLists = null; |
| | | @Override |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000198","1");//C1 36V |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000174","2");//C1 48V |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000194","3");//T1 36V |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("12980500000201","4");//T1 48V |
| | | |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("1","12980500000198"); |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("2","12980500000174"); |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("3","12980500000194"); |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("4","12980500000201"); |
| | | |
| | | EquipmentInfoParam equipmentInfoParam = new EquipmentInfoParam(); |
| | | List list = equipmentInfoService.findListBySpec(equipmentInfoParam); |
| | | |
| | | /* state();*/ |
| | | init(); |
| | | /* COP010(); |
| | | COP020(); |
| | | COP030(); |
| | | |
| | | BOP010(); |
| | | BOP020(); |
| | | BOP030(); |
| | | BOP030B(); |
| | | BOP040(); |
| | | BOP040B(); |
| | | |
| | | DOP010(); |
| | | //DOP020(); |
| | | |
| | | EOP010(); |
| | | EOP020(); |
| | | EOP030(); |
| | | EOP040(); |
| | | EOP050(); |
| | | EOP060(); |
| | | EOP070(); |
| | | EOP080(); |
| | | EOP090(); |
| | | EOP090B(); |
| | | |
| | | OP010(); |
| | | OP020(); |
| | | OP030(); |
| | | OP040(); |
| | | OP050(); |
| | | |
| | | OP070(); |
| | | OP080(); |
| | | OP090(); |
| | | OP100(); |
| | | OP110(); |
| | | OP120(); |
| | | OP120B(); |
| | | OP130(); |
| | | OP130B(); |
| | | OP140(); |
| | | //OP150(); |
| | | OP160(); |
| | | OP170(); |
| | | |
| | | state();*/ |
| | | } |
| | | |
| | | |
| | | |
| | | private void init() throws Exception { |
| | | InitCallback InitCallback = new InitCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | |
| | | List<String> lists = getList(); |
| | | miloService.subscriptionFromOpcUa(lists,InitCallback); |
| | | } |
| | | |
| | | private void state() throws Exception { |
| | | StateCallback StateCallback = new StateCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | StateCallback.handleInfo(); |
| | | // handleOilState("DOP020"); |
| | | StateCallback.handleOilStateOP050("OP050"); |
| | | StateCallback.handleOilStateBOP030("BOP030"); |
| | | } |
| | | private void COP010() throws Exception { |
| | | COP010Callback COP010Callback = new COP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.COP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.COP010_J_PLC_START); |
| | | lists.add(OPCElement.COP010_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,COP010Callback); |
| | | System.out.println("1"); |
| | | } |
| | | private void COP020() throws Exception { |
| | | COP020Callback COP020Callback = new COP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.COP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.COP020_J_PLC_START); |
| | | lists.add(OPCElement.COP020_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,COP020Callback); |
| | | } |
| | | private void COP030() throws Exception { |
| | | COP030Callback COP030Callback = new COP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.COP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.COP030_J_PLC_START); |
| | | lists.add(OPCElement.COP030_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,COP030Callback); |
| | | } |
| | | private void BOP010() throws Exception { |
| | | BOP010Callback BOP010Callback = new BOP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP010_J_PLC_START); |
| | | lists.add(OPCElement.BOP010_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,BOP010Callback); |
| | | } |
| | | private void BOP020() throws Exception { |
| | | BOP020Callback BOP020Callback = new BOP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP020_J_PLC_START); |
| | | lists.add(OPCElement.BOP020_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,BOP020Callback); |
| | | } |
| | | private void BOP030() throws Exception { |
| | | BOP030Callback BOP030Callback = new BOP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP030_J_PLC_START); |
| | | lists.add(OPCElement.BOP030_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,BOP030Callback); |
| | | } |
| | | private void BOP030B() throws Exception { |
| | | BOP030BCallback BOP030BCallback = new BOP030BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP030B_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP030B_J_PLC_START); |
| | | lists.add(OPCElement.BOP030B_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,BOP030BCallback); |
| | | } |
| | | private void BOP040() throws Exception { |
| | | BOP040Callback BOP040Callback = new BOP040Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP040_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP040_J_PLC_START); |
| | | lists.add(OPCElement.BOP040_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,BOP040Callback); |
| | | } |
| | | private void BOP040B() throws Exception { |
| | | BOP040BCallback BOP040BCallback = new BOP040BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.BOP040B_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP040B_J_PLC_START); |
| | | lists.add(OPCElement.BOP040B_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,BOP040BCallback); |
| | | } |
| | | private void DOP010() throws Exception { |
| | | DOP010Callback DOP010Callback = new DOP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.DOP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.DOP010_J_PLC_START); |
| | | lists.add(OPCElement.DOP010_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,DOP010Callback); |
| | | } |
| | | private void DOP020() throws Exception { |
| | | DOP020Callback DOP020Callback = new DOP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.DOP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.DOP020_J_PLC_START); |
| | | lists.add(OPCElement.DOP020_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,DOP020Callback); |
| | | } |
| | | private void EOP010() throws Exception { |
| | | EOP010Callback EOP010Callback = new EOP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP010_J_PLC_START); |
| | | lists.add(OPCElement.EOP010_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP010Callback); |
| | | } |
| | | private void EOP020() throws Exception { |
| | | EOP020Callback EOP020Callback = new EOP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP020_J_PLC_START); |
| | | lists.add(OPCElement.EOP020_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP020Callback); |
| | | } |
| | | private void EOP030() throws Exception { |
| | | EOP030Callback EOP030Callback = new EOP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP030_J_PLC_START); |
| | | lists.add(OPCElement.EOP030_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP030Callback); |
| | | } |
| | | private void EOP040() throws Exception { |
| | | EOP040Callback EOP040Callback = new EOP040Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP040_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP040_J_PLC_START); |
| | | lists.add(OPCElement.EOP040_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP040Callback); |
| | | } |
| | | |
| | | private void EOP050() throws Exception { |
| | | EOP050Callback EOP050Callback = new EOP050Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP050_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP050_J_PLC_START); |
| | | lists.add(OPCElement.EOP050_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP050Callback); |
| | | } |
| | | private void EOP060() throws Exception { |
| | | EOP060Callback EOP060Callback = new EOP060Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP060_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP060_J_PLC_START); |
| | | lists.add(OPCElement.EOP060_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP060Callback); |
| | | } |
| | | private void EOP070() throws Exception { |
| | | EOP070Callback EOP070Callback = new EOP070Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP070_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP070_J_PLC_START); |
| | | lists.add(OPCElement.EOP070_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP070Callback); |
| | | } |
| | | private void EOP080() throws Exception { |
| | | EOP080Callback EOP080Callback = new EOP080Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP080_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP080_J_PLC_START); |
| | | lists.add(OPCElement.EOP080_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP080Callback); |
| | | } |
| | | private void EOP090() throws Exception { |
| | | EOP090Callback EOP090Callback = new EOP090Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP090_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP090_J_PLC_START); |
| | | lists.add(OPCElement.EOP090_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP090Callback); |
| | | } |
| | | private void EOP090B() throws Exception { |
| | | EOP090BCallback EOP090BCallback = new EOP090BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.EOP090B_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP090B_J_PLC_START); |
| | | lists.add(OPCElement.EOP090B_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,EOP090BCallback); |
| | | } |
| | | private void OP010() throws Exception { |
| | | OP010Callback OP010Callback = new OP010Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP010_J_PLC_START); |
| | | lists.add(OPCElement.OP010_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP010Callback); |
| | | } |
| | | private void OP020() throws Exception { |
| | | OP020Callback OP020Callback = new OP020Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP020_J_PLC_START); |
| | | lists.add(OPCElement.OP020_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP020Callback); |
| | | } |
| | | private void OP030() throws Exception { |
| | | OP030Callback OP030Callback = new OP030Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP030_J_PLC_START); |
| | | lists.add(OPCElement.OP030_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP030Callback); |
| | | } |
| | | private void OP040() throws Exception { |
| | | OP040Callback OP040Callback = new OP040Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP040_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP040_J_PLC_START); |
| | | lists.add(OPCElement.OP040_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP040Callback); |
| | | } |
| | | private void OP050() throws Exception { |
| | | OP050Callback OP050Callback = new OP050Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP050_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP050_J_PLC_START); |
| | | lists.add(OPCElement.OP050_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP050Callback); |
| | | } |
| | | private void OP070() throws Exception { |
| | | OP070Callback OP070Callback = new OP070Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP070_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP070_J_PLC_START); |
| | | lists.add(OPCElement.OP070_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP070Callback); |
| | | } |
| | | private void OP080() throws Exception { |
| | | OP080Callback OP080Callback = new OP080Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP080_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP080_J_PLC_START); |
| | | lists.add(OPCElement.OP080_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP080Callback); |
| | | } |
| | | private void OP090() throws Exception { |
| | | OP090Callback OP090Callback = new OP090Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP090_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP090_J_PLC_START); |
| | | lists.add(OPCElement.OP090_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP090Callback); |
| | | } |
| | | private void OP100() throws Exception { |
| | | OP100Callback OP100Callback = new OP100Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP100_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP100_J_PLC_START); |
| | | lists.add(OPCElement.OP100_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP100Callback); |
| | | } |
| | | private void OP110() throws Exception { |
| | | OP110Callback OP110Callback = new OP110Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP110_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP110_J_PLC_START); |
| | | lists.add(OPCElement.OP110_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP110Callback); |
| | | } |
| | | private void OP120() throws Exception { |
| | | OP120Callback OP120Callback = new OP120Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP120_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP120_J_PLC_START); |
| | | lists.add(OPCElement.OP120_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP120Callback); |
| | | } |
| | | private void OP120B() throws Exception { |
| | | OP120BCallback OP120BCallback = new OP120BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP120B_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP120B_J_PLC_START); |
| | | lists.add(OPCElement.OP120B_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP120BCallback); |
| | | } |
| | | private void OP130() throws Exception { |
| | | OP130Callback OP130Callback = new OP130Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP130_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP130_J_PLC_START); |
| | | lists.add(OPCElement.OP130_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP130Callback); |
| | | } |
| | | private void OP130B() throws Exception { |
| | | OP130BCallback OP130BCallback = new OP130BCallback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP130B_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP130B_J_PLC_START); |
| | | lists.add(OPCElement.OP130B_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP130BCallback); |
| | | } |
| | | private void OP140() throws Exception { |
| | | OP140Callback OP140Callback = new OP140Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP140_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP140_J_PLC_START); |
| | | lists.add(OPCElement.OP140_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP140Callback); |
| | | } |
| | | private void OP150() throws Exception { |
| | | OP150Callback OP150Callback = new OP150Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP150_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP150_J_PLC_START); |
| | | lists.add(OPCElement.OP150_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP150Callback); |
| | | } |
| | | private void OP160() throws Exception { |
| | | OP160Callback OP160Callback = new OP160Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP160_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP160_J_PLC_START); |
| | | lists.add(OPCElement.OP160_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP160Callback); |
| | | } |
| | | private void OP170() throws Exception { |
| | | OP170Callback OP170Callback = new OP170Callback(miloService,productionOrdeInfoService, |
| | | passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, |
| | | productionOrderBatchInfoService); |
| | | List<String> lists = new ArrayList<>(); |
| | | lists.add(OPCElement.OP170_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP170_J_PLC_START); |
| | | lists.add(OPCElement.OP170_J_PLC_FINISH); |
| | | miloService.subscriptionFromOpcUa(lists,OP170Callback); |
| | | } |
| | | |
| | | |
| | | public List<String> getList(){ |
| | | List<String> lists = new ArrayList<>(); |
| | | |
| | | lists.add(OPCElement.COP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.COP010_J_PLC_START); |
| | | lists.add(OPCElement.COP010_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.COP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.COP020_J_PLC_START); |
| | | lists.add(OPCElement.COP020_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.COP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.COP030_J_PLC_START); |
| | | lists.add(OPCElement.COP030_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.BOP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP010_J_PLC_START); |
| | | lists.add(OPCElement.BOP010_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.BOP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP020_J_PLC_START); |
| | | lists.add(OPCElement.BOP020_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.BOP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP030_J_PLC_START); |
| | | lists.add(OPCElement.BOP030_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.BOP030B_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP030B_J_PLC_START); |
| | | lists.add(OPCElement.BOP030B_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.BOP040_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP040_J_PLC_START); |
| | | lists.add(OPCElement.BOP040_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.BOP040B_F_HEART_BEAT); |
| | | lists.add(OPCElement.BOP040B_J_PLC_START); |
| | | lists.add(OPCElement.BOP040B_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.DOP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.DOP010_J_PLC_START); |
| | | lists.add(OPCElement.DOP010_J_PLC_FINISH); |
| | | |
| | | /* lists.add(OPCElement.DOP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.DOP020_J_PLC_START); |
| | | lists.add(OPCElement.DOP020_J_PLC_FINISH);*/ |
| | | |
| | | lists.add(OPCElement.EOP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP010_J_PLC_START); |
| | | lists.add(OPCElement.EOP010_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP020_J_PLC_START); |
| | | lists.add(OPCElement.EOP020_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP030_J_PLC_START); |
| | | lists.add(OPCElement.EOP030_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP040_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP040_J_PLC_START); |
| | | lists.add(OPCElement.EOP040_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP050_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP050_J_PLC_START); |
| | | lists.add(OPCElement.EOP050_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP060_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP060_J_PLC_START); |
| | | lists.add(OPCElement.EOP060_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP070_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP070_J_PLC_START); |
| | | lists.add(OPCElement.EOP070_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP070_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP070_J_PLC_START); |
| | | lists.add(OPCElement.EOP070_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP090_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP090_J_PLC_START); |
| | | lists.add(OPCElement.EOP090_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.EOP090B_F_HEART_BEAT); |
| | | lists.add(OPCElement.EOP090B_J_PLC_START); |
| | | lists.add(OPCElement.EOP090B_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP010_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP010_J_PLC_START); |
| | | lists.add(OPCElement.OP010_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP020_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP020_J_PLC_START); |
| | | lists.add(OPCElement.OP020_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP030_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP030_J_PLC_START); |
| | | lists.add(OPCElement.OP030_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP040_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP040_J_PLC_START); |
| | | lists.add(OPCElement.OP040_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP050_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP050_J_PLC_START); |
| | | lists.add(OPCElement.OP050_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP070_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP070_J_PLC_START); |
| | | lists.add(OPCElement.OP070_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP080_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP080_J_PLC_START); |
| | | lists.add(OPCElement.OP080_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP090_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP090_J_PLC_START); |
| | | lists.add(OPCElement.OP090_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP100_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP100_J_PLC_START); |
| | | lists.add(OPCElement.OP100_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP110_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP110_J_PLC_START); |
| | | lists.add(OPCElement.OP110_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP120_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP120_J_PLC_START); |
| | | lists.add(OPCElement.OP120_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP120B_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP120B_J_PLC_START); |
| | | lists.add(OPCElement.OP120B_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP130_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP130_J_PLC_START); |
| | | lists.add(OPCElement.OP130_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP130B_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP130B_J_PLC_START); |
| | | lists.add(OPCElement.OP130B_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP140_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP140_J_PLC_START); |
| | | lists.add(OPCElement.OP140_J_PLC_FINISH); |
| | | |
| | | /* lists.add(OPCElement.OP150_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP150_J_PLC_START); |
| | | lists.add(OPCElement.OP150_J_PLC_FINISH);*/ |
| | | |
| | | lists.add(OPCElement.OP160_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP160_J_PLC_START); |
| | | lists.add(OPCElement.OP160_J_PLC_FINISH); |
| | | |
| | | lists.add(OPCElement.OP170_F_HEART_BEAT); |
| | | lists.add(OPCElement.OP170_J_PLC_START); |
| | | lists.add(OPCElement.OP170_J_PLC_FINISH); |
| | | |
| | | if(null == stateLists ){ |
| | | EquipmentInfoParam equipmentInfoParam = new EquipmentInfoParam(); |
| | | stateLists = equipmentInfoService.findListBySpec(equipmentInfoParam); |
| | | } |
| | | |
| | | if(!stateLists.isEmpty()){ |
| | | for(int i=0;i<stateLists.size();i++) { |
| | | EquipmentInfoResult result = (EquipmentInfoResult) stateLists.get(i); |
| | | if(null != result.getSpareField1()){ |
| | | lists.add(result.getSpareField1()); |
| | | } |
| | | } |
| | | } |
| | | return lists; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public class GlobalVariable { |
| | | |
| | | // public static boolean TERMINATED = false; |
| | | public static boolean TERMINATED = false; |
| | | |
| | | public static boolean TERMINATED = true; |
| | | // public static boolean TERMINATED = true; |
| | | |
| | | public static int SLEEP_TIME = 1000; |
| | | |
| | |
| | | id-type: assign_id |
| | | table-underline: true |
| | | |
| | | kangaroohy: |
| | | milo: |
| | | enabled: true |
| | | primary: default |
| | | config: |
| | | default: |
| | | endpoint: opc.tcp://127.0.0.1:49320 |
| | | security-policy: none |
| | | |
| | | log: |
| | | path: _app_logs |
| | | path: _app_logs |
| | | |