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 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"); InitCallback InitCallback = new InitCallback(miloService,productionOrdeInfoService, passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, productionOrderBatchInfoService); System.out.println("start run^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); List lists = getList(); miloService.subscriptionFromOpcUa(lists,InitCallback); System.out.println("end run^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } public List getList(){ List 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