package cn.stylefeng.guns.plcserver.init; 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.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.opc.GlobalVariable; import cn.stylefeng.guns.plcserver.opc.OPCElement; import cn.stylefeng.guns.plcserver.server.HEARTBEAT.HeartBeatServerInterface; import cn.stylefeng.guns.plcserver.server.HEARTBEAT.impl.HeartBeatServerInterfaceImpl; import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; 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.Calendar; 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"); SubscriptionManage InitCallback = new SubscriptionManage(miloService,productionOrdeInfoService, passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService, productionOrderBatchInfoService); Calendar calendar = Calendar.getInstance(); String Months = StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH) + 1),2, "0"); if(Months.equals("04") ||Months.equals("07") ||Months.equals("08") || Months.equals("09") || Months.equals("10") || Months.equals("11") || Months.equals("12") || Months.equals("01") || Months.equals("02") || Months.equals("03") ){ GlobalVariable.IS_CLOCK = false; } /* ExecutorService cachedThreadPool = Executors.newCachedThreadPool(); cachedThreadPool.execute(new HeartBeatTaskThreadPool());*/ System.out.println("start run^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); List lists = getList(); miloService.subscriptionFromOpcUa(lists,500,InitCallback); } public List getList(){ List lists = new ArrayList<>(); lists.add(OPCElement.COP010_F_HEART_BEAT); lists.add(OPCElement.COP010_PLC_REQUST); lists.add(OPCElement.COP020_F_HEART_BEAT); lists.add(OPCElement.COP020_PLC_REQUST); lists.add(OPCElement.COP030_PLC_REQUST); lists.add(OPCElement.BOP010_F_HEART_BEAT); lists.add(OPCElement.BOP010_PLC_REQUST); lists.add(OPCElement.BOP020_PLC_REQUST); lists.add(OPCElement.BOP030_F_HEART_BEAT); lists.add(OPCElement.BOP030_PLC_REQUST); lists.add(OPCElement.BOP030B_PLC_REQUST); lists.add(OPCElement.BOP040_PLC_REQUST); lists.add(OPCElement.BOP040B_PLC_REQUST); lists.add(OPCElement.DOP010_F_HEART_BEAT); lists.add(OPCElement.DOP010_PLC_REQUST); lists.add(OPCElement.EOP010_F_HEART_BEAT); lists.add(OPCElement.EOP010_PLC_REQUST); lists.add(OPCElement.EOP020_F_HEART_BEAT); lists.add(OPCElement.EOP020_PLC_REQUST); lists.add(OPCElement.EOP030_F_HEART_BEAT); lists.add(OPCElement.EOP030_PLC_REQUST); lists.add(OPCElement.EOP040_PLC_REQUST); lists.add(OPCElement.EOP050_F_HEART_BEAT); lists.add(OPCElement.EOP050_PLC_REQUST); lists.add(OPCElement.EOP060_F_HEART_BEAT); lists.add(OPCElement.EOP060_PLC_REQUST); lists.add(OPCElement.EOP070_F_HEART_BEAT); lists.add(OPCElement.EOP070_PLC_REQUST); lists.add(OPCElement.EOP080_F_HEART_BEAT); lists.add(OPCElement.EOP080_PLC_REQUST); 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_J_PLC_START); lists.add(OPCElement.EOP090B_J_PLC_FINISH); lists.add(OPCElement.OP010_F_HEART_BEAT); lists.add(OPCElement.OP010_PLC_REQUST); lists.add(OPCElement.OP020_F_HEART_BEAT); lists.add(OPCElement.OP020_PLC_REQUST); lists.add(OPCElement.OP030_F_HEART_BEAT); lists.add(OPCElement.OP030_PLC_REQUST); lists.add(OPCElement.OP040_F_HEART_BEAT); lists.add(OPCElement.OP040_PLC_REQUST); lists.add(OPCElement.OP050_F_HEART_BEAT); lists.add(OPCElement.OP050_PLC_REQUST); lists.add(OPCElement.OP070_F_HEART_BEAT); lists.add(OPCElement.OP070_PLC_REQUST); //lists.add(OPCElement.OP080_F_HEART_BEAT); lists.add(OPCElement.OP080_PLC_REQUST); lists.add(OPCElement.OP090_F_HEART_BEAT); lists.add(OPCElement.OP090_PLC_REQUST); lists.add(OPCElement.OP100_F_HEART_BEAT); lists.add(OPCElement.OP100_PLC_REQUST); lists.add(OPCElement.OP110_F_HEART_BEAT); lists.add(OPCElement.OP110_PLC_REQUST); lists.add(OPCElement.OP120_F_HEART_BEAT); lists.add(OPCElement.OP120_PLC_REQUST); //lists.add(OPCElement.OP120B_F_HEART_BEAT); lists.add(OPCElement.OP120B_PLC_REQUST); lists.add(OPCElement.OP130_F_HEART_BEAT); lists.add(OPCElement.OP130_PLC_REQUST); //lists.add(OPCElement.OP130B_F_HEART_BEAT); lists.add(OPCElement.OP130B_PLC_REQUST); lists.add(OPCElement.OP140_F_HEART_BEAT); lists.add(OPCElement.OP140_PLC_REQUST); lists.add(OPCElement.OP150_F_HEART_BEAT); lists.add(OPCElement.OP150_PLC_REQUST); lists.add(OPCElement.OP160_F_HEART_BEAT); // lists.add(OPCElement.OP160_PLC_REQUST); 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_PLC_REQUST); /*if(null == stateLists ){ EquipmentInfoParam equipmentInfoParam = new EquipmentInfoParam(); stateLists = equipmentInfoService.findListBySpec(equipmentInfoParam); } if(!stateLists.isEmpty()){ for(int i=0;i