| | |
| | | and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%') |
| | | </if> |
| | | <if test="paramCondition.locationCode != null and paramCondition.locationCode != ''"> |
| | | and location_code = #{paramCondition.locationCode} |
| | | and location_code like CONCAT('%',#{paramCondition.locationCode},'%') |
| | | </if> |
| | | </select> |
| | | |
| | |
| | | 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.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; |
| | |
| | | @Autowired |
| | | private GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | private ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | @Override |
| | | public void run(String... args) throws Exception { |
| | | if(GlobalVariable.TERMINATED) { |
| | | opc.init(productionOrdeInfoService,passingStationCollectionService,paramCollectionService,collectionParamConfService,serialNumbersConfService, |
| | | equipmentStatusService,equipmentAlarmService,materialTraceabilityService,equipmentInfoService, |
| | | repairManageInfoService,locationInfoService,greaseManageService); |
| | | repairManageInfoService,locationInfoService,greaseManageService,productionOrderRecordsService,productionOrderBatchInfoService); |
| | | |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("191.220001-01","1"); |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("191.220003-01","2"); |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("191.220002-01","3"); |
| | | GlobalVariable.PRODUCT_TYPE_MAP.put("191.220004-01","4"); |
| | | 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","191.220001-01"); |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("2","191.220003-01"); |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("3","191.220002-01"); |
| | | GlobalVariable.PRODUCT_CODE_MAP.put("4","191.220004-01"); |
| | | 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"); |
| | | |
| | | ExecutorService cachedThreadPool = Executors.newCachedThreadPool(); |
| | | cachedThreadPool.execute(new OP010TaskThreadPool()); |
| | |
| | | cachedThreadPool.execute(new OP090TaskThreadPool()); |
| | | cachedThreadPool.execute(new OP100TaskThreadPool()); |
| | | cachedThreadPool.execute(new OP110TaskThreadPool()); |
| | | /* cachedThreadPool.execute(new OP120TaskThreadPool()); |
| | | cachedThreadPool.execute(new OP120BTaskThreadPool());*/ |
| | | cachedThreadPool.execute(new OP120TaskThreadPool()); |
| | | cachedThreadPool.execute(new OP120BTaskThreadPool()); |
| | | cachedThreadPool.execute(new OP130TaskThreadPool()); |
| | | cachedThreadPool.execute(new OP130BTaskThreadPool()); |
| | | cachedThreadPool.execute(new OP140TaskThreadPool()); |
| | |
| | | |
| | | public static boolean TERMINATED = true; |
| | | |
| | | public static int SLEEP_TIME = 2000; |
| | | public static int SLEEP_TIME = 1000; |
| | | |
| | | public static int HEART_MAX_COUNT = 10; |
| | | |
| | |
| | | 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.server.BOP010.callback.*; |
| | |
| | | public LocationInfoService locationInfoService; |
| | | @Autowired |
| | | public GreaseManageService greaseManageService; |
| | | |
| | | @Autowired |
| | | public ProductionOrderRecordsService productionOrderRecordsService; |
| | | |
| | | @Autowired |
| | | public ProductionOrderBatchInfoService productionOrderBatchInfoService; |
| | | |
| | | //OP010 |
| | | private Item OP010_F_HEART_BEAT;//心跳 |
| | |
| | | EquipmentInfoService equipmentInfoService, |
| | | RepairManageInfoService repairManageInfoService, |
| | | LocationInfoService locationInfoService, |
| | | GreaseManageService greaseManageService |
| | | GreaseManageService greaseManageService, |
| | | ProductionOrderRecordsService productionOrderRecordsService, |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService |
| | | ) throws Exception { |
| | | this.productionOrdeInfoService = productionOrdeInfoService; |
| | | this.passingStationCollectionService = passingStationCollectionService; |
| | |
| | | this.repairManageInfoService = repairManageInfoService; |
| | | this.locationInfoService = locationInfoService; |
| | | this.greaseManageService = greaseManageService; |
| | | this.productionOrderRecordsService = productionOrderRecordsService; |
| | | this.productionOrderBatchInfoService = productionOrderBatchInfoService; |
| | | |
| | | // 加载配置文件 |
| | | final ConnectionInformation ci = getCLSIDConnectionInfomation(); |
| | |
| | | logger.info("This is {} message.", "OPCserver connect success"); |
| | | this.server = server; |
| | | // 同步读取,500ms一次 |
| | | final AccessBase access = new SyncAccess(server, 1000); |
| | | |
| | | //final AccessBase access = new Async20Access(server, 1000,false); |
| | | |
| | | //OP010回调 |
| | | access.addItem(OPCElement.OP010_F_HEART_BEAT, new DataCallBack_OP010_F_HEART_BEAT());//心跳 |
| | | /* access.addItem(OPCElement.OP010_E_STATE, new DataCallBack_OP010_E_STATE());//设备状态*/ |
| | | |
| | | //OP020回调 |
| | | access.addItem(OPCElement.OP020_F_HEART_BEAT, new DataCallBack_OP020_F_HEART_BEAT());//心跳 |
| | | |
| | | |
| | | //OP030回调 |
| | | access.addItem(OPCElement.OP030_F_HEART_BEAT, new DataCallBack_OP030_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP040回调 |
| | | access.addItem(OPCElement.OP040_F_HEART_BEAT, new DataCallBack_OP040_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP050回调 |
| | | access.addItem(OPCElement.OP050_F_HEART_BEAT, new DataCallBack_OP050_F_HEART_BEAT());//心跳 |
| | | |
| | | |
| | | //OP070回调 |
| | | access.addItem(OPCElement.OP070_F_HEART_BEAT, new DataCallBack_OP070_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP080回调 |
| | | access.addItem(OPCElement.OP080_F_HEART_BEAT, new DataCallBack_OP080_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP090回调 |
| | | access.addItem(OPCElement.OP090_F_HEART_BEAT, new DataCallBack_OP090_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP100回调 |
| | | access.addItem(OPCElement.OP100_F_HEART_BEAT, new DataCallBack_OP100_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP110回调 |
| | | access.addItem(OPCElement.OP110_F_HEART_BEAT, new DataCallBack_OP110_F_HEART_BEAT());//心跳 |
| | | |
| | | |
| | | /* |
| | | //OP120回调 |
| | | access.addItem(OPCElement.OP120_F_HEART_BEAT, new DataCallBack_OP120_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP120B回调 |
| | | access.addItem(OPCElement.OP120B_F_HEART_BEAT, new DataCallBack_OP120B_F_HEART_BEAT());//心跳 |
| | | */ |
| | | |
| | | |
| | | //OP130回调 |
| | | access.addItem(OPCElement.OP130_F_HEART_BEAT, new DataCallBack_OP130_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP130B回调 |
| | | access.addItem(OPCElement.OP130B_F_HEART_BEAT, new DataCallBack_OP130B_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP140回调 |
| | | access.addItem(OPCElement.OP140_F_HEART_BEAT, new DataCallBack_OP140_F_HEART_BEAT());//心跳 |
| | | |
| | | //OP150回调 |
| | | /* |
| | | access.addItem(OPCElement.OP150_F_HEART_BEAT, new DataCallBack_OP150_F_HEART_BEAT());//心跳 |
| | | */ |
| | | |
| | | //OP160回调 |
| | | access.addItem(OPCElement.OP160_F_HEART_BEAT, new DataCallBack_OP160_F_HEART_BEAT());//心跳 |
| | | |
| | | |
| | | //OP170回调 |
| | | access.addItem(OPCElement.OP170_F_HEART_BEAT, new DataCallBack_OP170_F_HEART_BEAT());//心跳 |
| | | |
| | | //COP010回调 |
| | | access.addItem(OPCElement.COP010_F_HEART_BEAT, new DataCallBack_COP010_F_HEART_BEAT());//心跳 |
| | | |
| | | //COP020回调 |
| | | access.addItem(OPCElement.COP020_F_HEART_BEAT, new DataCallBack_COP020_F_HEART_BEAT());//心跳 |
| | | |
| | | //COP030回调 |
| | | access.addItem(OPCElement.COP030_F_HEART_BEAT, new DataCallBack_COP030_F_HEART_BEAT());//心跳 |
| | | |
| | | //BOP010回调 |
| | | access.addItem(OPCElement.BOP010_F_HEART_BEAT, new DataCallBack_BOP010_F_HEART_BEAT());//心跳 |
| | | |
| | | //BOP020回调 |
| | | access.addItem(OPCElement.BOP020_F_HEART_BEAT, new DataCallBack_BOP020_F_HEART_BEAT());//心跳 |
| | | |
| | | //BOP030回调 |
| | | access.addItem(OPCElement.BOP030_F_HEART_BEAT, new DataCallBack_BOP030_F_HEART_BEAT());//心跳 |
| | | |
| | | //BOP030B回调 |
| | | access.addItem(OPCElement.BOP030B_F_HEART_BEAT, new DataCallBack_BOP030B_F_HEART_BEAT());//心跳 |
| | | |
| | | //BOP040回调 |
| | | access.addItem(OPCElement.BOP040_F_HEART_BEAT, new DataCallBack_BOP040_F_HEART_BEAT());//心跳 |
| | | |
| | | //BOP040B回调 |
| | | access.addItem(OPCElement.BOP040B_F_HEART_BEAT, new DataCallBack_BOP040B_F_HEART_BEAT());//心跳 |
| | | |
| | | //DOP010回调 |
| | | access.addItem(OPCElement.DOP010_F_HEART_BEAT, new DataCallBack_DOP010_F_HEART_BEAT());//心跳 |
| | | |
| | | //DOP020回调 |
| | | /* access.addItem(OPCElement.DOP020_F_HEART_BEAT, new DataCallBack_DOP020_F_HEART_BEAT());//心跳*/ |
| | | |
| | | //EOP010回调 |
| | | access.addItem(OPCElement.EOP010_F_HEART_BEAT, new DataCallBack_EOP010_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP020回调 |
| | | access.addItem(OPCElement.EOP020_F_HEART_BEAT, new DataCallBack_EOP020_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP030回调 |
| | | access.addItem(OPCElement.EOP030_F_HEART_BEAT, new DataCallBack_EOP030_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP040回调 |
| | | access.addItem(OPCElement.EOP040_F_HEART_BEAT, new DataCallBack_EOP040_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP050回调 |
| | | access.addItem(OPCElement.EOP050_F_HEART_BEAT, new DataCallBack_EOP050_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP060回调 |
| | | access.addItem(OPCElement.EOP060_F_HEART_BEAT, new DataCallBack_EOP060_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP070回调 |
| | | access.addItem(OPCElement.EOP070_F_HEART_BEAT, new DataCallBack_EOP070_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP070B回调 |
| | | /*access.addItem(OPCElement.EOP070B_F_HEART_BEAT, new DataCallBack_EOP070B_F_HEART_BEAT());//心跳*/ |
| | | |
| | | //EOP080回调 |
| | | access.addItem(OPCElement.EOP080_F_HEART_BEAT, new DataCallBack_EOP080_F_HEART_BEAT());//心跳 |
| | | |
| | | //EOP090回调 |
| | | access.addItem(OPCElement.EOP090_F_HEART_BEAT, new DataCallBack_EOP090_F_HEART_BEAT());//心跳 |
| | | |
| | | |
| | | //EOP090B回调 |
| | | access.addItem(OPCElement.EOP090B_F_HEART_BEAT, new DataCallBack_EOP090B_F_HEART_BEAT());//心跳 |
| | | final AccessBase access = new SyncAccess(server, 500); |
| | | |
| | | //OP010组 |
| | | final Group OP010_GROUP = server.addGroup("OP010"); |
| | |
| | | OP110_S_PRODUCT_STATE_CODE = OP110_GROUP.addItem((OPCElement.OP110_S_PRODUCT_STATE_CODE));//产品状态编码 |
| | | |
| | | //OP120组 |
| | | /* final Group OP120_GROUP = server.addGroup("OP120"); |
| | | final Group OP120_GROUP = server.addGroup("OP120"); |
| | | OP120_F_HEART_BEAT = OP120_GROUP.addItem((OPCElement.OP120_F_HEART_BEAT));//心跳 |
| | | OP120_J_PLC_START = OP120_GROUP.addItem((OPCElement.OP120_J_PLC_START));//PLC开始 |
| | | OP120_J_PC_WRITE_ORDER = OP120_GROUP.addItem((OPCElement.OP120_J_PC_WRITE_ORDER));//PC读数据完成 |
| | |
| | | OP120B_S_PRODUCT_CODE = OP120B_GROUP.addItem((OPCElement.OP120B_S_PRODUCT_CODE));//产品编号 |
| | | OP120B_S_SFC_CODE = OP120B_GROUP.addItem((OPCElement.OP120B_S_SFC_CODE));//总成编码 |
| | | |
| | | OP120B_S_PRODUCT_STATE_CODE = OP120B_GROUP.addItem((OPCElement.OP120B_S_PRODUCT_STATE_CODE));//产品状态编码*/ |
| | | OP120B_S_PRODUCT_STATE_CODE = OP120B_GROUP.addItem((OPCElement.OP120B_S_PRODUCT_STATE_CODE));//产品状态编码 |
| | | |
| | | //OP130组 |
| | | final Group OP130_GROUP = server.addGroup("OP130"); |
| | |
| | | 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.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if (value.equals("false")) { |
| | | OPCUnit.write(opc.getBOP010_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.BOP010_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.BOP010_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void monitor() { |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getBOP010_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.BOP010_F_HEART_BEAT) { |
| | | |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getBOP010_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getBOP010_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getBOP010_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getBOP010_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "BOP020_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if (value.equals("false")) { |
| | | OPCUnit.write(opc.getBOP020_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.BOP020_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.BOP020_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getBOP020_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.BOP020_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getBOP020_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getBOP020_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | |
| | | logger.info("BOP020工位,handleInfo END!"); |
| | | } |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getBOP020_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getBOP020_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getBOP020_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | 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.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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "BOP030_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if (value.equals("false")) { |
| | | OPCUnit.write(opc.getBOP030_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.BOP030_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.BOP030_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getBOP030_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.BOP030_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getBOP030_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getBOP030_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | }else{ |
| | | OPCUnit.write(opc.getBOP030_OIL_STATE(), "true"); //写油脂状态 |
| | | } |
| | | logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | //logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | logger.info("BOP030工位,handleInfo END!"); |
| | | } |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getBOP030_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getBOP030_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getBOP030_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | private static String GROUP_NAME = "BOP030B_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if (value.equals("false")) { |
| | | OPCUnit.write(opc.getBOP030B_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.BOP030B_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.BOP030B_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getBOP030B_F_HEART_BEAT()); |
| | | assert isHeartBeat != null; |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.BOP030B_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getBOP030B_J_PLC_START());//PLC开始 |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "BOP040_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if (value.equals("false")) { |
| | | OPCUnit.write(opc.getBOP040_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.BOP040_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.BOP040_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getBOP040_F_HEART_BEAT()); |
| | | assert isHeartBeat != null; |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.BOP040_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getBOP040_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getBOP040_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | |
| | | logger.info("BOP040工位,handleInfo END!"); |
| | | } |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getBOP040_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getBOP040_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getBOP040_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | private static String GROUP_NAME = "BOP040B_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if (value.equals("false")) { |
| | | OPCUnit.write(opc.getBOP040B_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.BOP040B_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.BOP040B_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getBOP040B_F_HEART_BEAT()); |
| | | assert isHeartBeat != null; |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.BOP040B_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getBOP040B_J_PLC_START());//PLC开始 |
| | |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | 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.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.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getCOP010_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.COP010_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.COP010_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void monitor() { |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getCOP010_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | |
| | | if(GlobalVariable.COP010_F_HEART_BEAT) { |
| | | |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getCOP010_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getCOP010_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getCOP010_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getCOP010_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "COP020_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getCOP020_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.COP020_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.COP020_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getCOP020_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.COP020_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getCOP020_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getCOP020_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | |
| | | logger.info("COP020工位,handleInfo END!"); |
| | | } |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getCOP020_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getCOP020_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getCOP020_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "COP030_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getCOP030_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.COP030_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.COP030_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getCOP030_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.COP030_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getCOP030_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getCOP030_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | |
| | | logger.info("COP030工位,handleInfo END!"); |
| | | } |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getCOP030_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getCOP030_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getCOP030_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | |
| | | 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.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getDOP010_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.DOP010_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.DOP010_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void monitor() { |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getDOP010_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.DOP010_F_HEART_BEAT) { |
| | | |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getDOP010_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getDOP010_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getDOP010_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getDOP010_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //PC完成 |
| | |
| | | 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.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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "DOP020_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getDOP020_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.DOP020_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.DOP020_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getDOP020_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.DOP020_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getDOP020_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getDOP020_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | }else{ |
| | | OPCUnit.write(opc.getDOP020_OIL_STATE(), "true"); //写油脂状态 |
| | | } |
| | | logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | //logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | } |
| | | } |
| | | |
| | |
| | | logger.info("DOP020工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getDOP020_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getDOP020_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getDOP020_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP010_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP010_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP010_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP010_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP010_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP010_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP010_J_PLC_START());//PLC开始 |
| | |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP010_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP010_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP010_S_SFC_CODE());//总成编码 |
| | | } |
| | | String materialCode = OPCUnit.read(opc.getEOP010_S_MATERIAL_CODE()); |
| | | MaterialTraceabilityParam materialTraceabilityParam = new MaterialTraceabilityParam(); |
| | | MaterialTraceabilityService materialTraceabilityService = opc.materialTraceabilityService; |
| | | 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); |
| | | MaterialTraceabilityService materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityParam.setAssemblyQty(1); |
| | | materialTraceabilityParam.setAssemblyTime(DateTool.getLocalTimeForDate()); |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 { |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP020_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP020_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP020_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP020_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP020_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP020_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP020_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP020_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP020工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP020_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP020_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP020_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | 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.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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP030_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP030_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP030_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP030_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP030_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP030_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP030_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP030_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP030工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP030_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP030_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP030_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP040_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP040_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP040_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP040_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP040_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP040_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP040_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP040_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP040工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP040_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP040_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP040_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP050_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP050_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP050_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP050_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP050_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP050_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP050_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP050_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP050工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP050_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP050_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP050_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.params.MaterialTraceabilityParam; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.model.result.MaterialTraceabilityResult; |
| | | import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService; |
| | | 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.sc.repairManageInfo.model.params.RepairManageInfoParam; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.model.result.RepairManageInfoResult; |
| | | import cn.stylefeng.guns.modular.sc.repairManageInfo.service.RepairManageInfoService; |
| | |
| | | private static String GROUP_NAME = "EOP060_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP060_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP060_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP060_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP060_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP060_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP060_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP060_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP060工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP060_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP060_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP060_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP070_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP070_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP070_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP070_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP070_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP070_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP070_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP070_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP070工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP070_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP070_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP070_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | private static String GROUP_NAME = "EOP070B_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP070B_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP070B_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP070B_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP070B_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP070B_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP070B_J_PLC_START());//PLC开始 |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP080_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP080_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP080_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP080_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP080_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP080_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP080_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP080_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP080工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP080_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP080_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP080_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "EOP090_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP090_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP090_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP090_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP090_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP090_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP090_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getEOP090_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("EOP090工位,handleInfo END!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getEOP090_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getEOP090_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getEOP090_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | private static String GROUP_NAME = "EOP090B_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getEOP090B_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.EOP090B_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.EOP090B_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | String isHeartBeat = OPCUnit.read(opc.getEOP090B_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.EOP090B_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getEOP090B_J_PLC_START());//PLC开始 |
| | |
| | | import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService; |
| | | 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.om.productionOrdeInfo.entity.ProductionOrdeInfo; |
| | | 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; |
| | |
| | | |
| | | private static Integer ACTUAL_ONLINE_QTY = 0 ;//上线数量 |
| | | |
| | | private int count = 0; |
| | | |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP010_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP010_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP010_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP010_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP010_F_HEART_BEAT) { |
| | | |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP010_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | } |
| | | } |
| | |
| | | } |
| | | //PC下发工单 |
| | | public void handleOrder() { |
| | | |
| | | logger.info("OP010工位,handleOrder PC处理开始!"); |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | ProductionOrdeInfoParam param = new ProductionOrdeInfoParam(); |
| | |
| | | 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 productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | productionOrderRecordsService.add(productionOrderRecordsParam); |
| | | |
| | | |
| | | OPCUnit.write(opc.getOP010_S_ORDER_CODE(),S_ORDER_CODE); //工单编号 |
| | | OPCUnit.write(opc.getOP010_S_PRODUCT_CODE(), S_PRODUCT_TYPE); //产品编号 |
| | | OPCUnit.write(opc.getOP010_S_SFC_CODE(), S_SFC_CODE); //总成编码 |
| | |
| | | } |
| | | |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP010_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP010_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP010_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | logger.info("OP010工位,handleFinsh PC处理开始!"); |
| | |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP010_S_SFC_CODE());//总成编码 |
| | | } |
| | | //处理过站信息 |
| | | |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP010_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP020_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP020_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP020_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP020_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP020_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP020_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP020_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP020_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP020_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP020_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP020工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP020_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP020_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP020_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | //productionOrderBatchInfoParam.setProductionLine((remainingQuantity-1)+""); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | logger.info("OP020工位,handleInfo END!"); |
| | | } |
| | | |
| | | |
| | | //PC完成 |
| | | public void handleFinsh() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP020_S_SFC_CODE());//总成编码 |
| | | } |
| | | //处理过站信息 |
| | | |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP020_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP030_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP030_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP030_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP030_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP030_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP030_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP030_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP030_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP030_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP030_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP030工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP030_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP030_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP030_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP030_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP040_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP040_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP040_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP040_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP040_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP040_F_HEART_BEAT) { |
| | | |
| | | //PC读工单 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP040_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP040_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP040_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP040工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP040_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP040_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP040_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP040_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP050_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP050_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP050_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP050_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP050_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP050_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP050_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP050_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | }else{ |
| | | OPCUnit.write(opc.getOP050_OIL_STATE(), "true"); //写油脂状态 |
| | | } |
| | | logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | //logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween); |
| | | } |
| | | } |
| | | |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP050_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP050_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP050工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP050_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP050_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP050_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP050_S_PRODUCT_STATE_CODE()); |
| | | |
| | | PassingStationCollectionParam param = new PassingStationCollectionParam(); |
| | | param.setWorkOrderNo(S_ORDER_CODE); |
| | | param.setProductCode(S_PRODUCT_CODE); |
| | |
| | | PassingStationCollectionService passingStationCollectionService = opc.passingStationCollectionService; |
| | | passingStationCollectionService.add(param); |
| | | |
| | | //根据分总成编码,将EOP过站数据绑定关系修改为总成编码 |
| | | |
| | | |
| | | String copSfcCode = OPCUnit.read(opc.getOP050_S_SFC_CODE_COP());//COP分总成 |
| | | String bopSfcCode = OPCUnit.read(opc.getOP050_S_SFC_CODE_BOP());//BOP分总成 |
| | | |
| | | //根据分总成编码,将EOP物料数据绑定关系修改为总成编码 |
| | | MaterialTraceabilityService materialTraceabilityService = opc.materialTraceabilityService; |
| | | 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); |
| | | |
| | |
| | | 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 = |
| | | opc.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); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |
| | | OPCUnit.write(opc.getOP050_J_PC_FINISH(), "true"); //PC完成 |
| | | |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP070_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP070_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP070_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP070_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP070_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP070_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP070_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP070_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP070_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP070_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP070工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP070_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP070_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP070_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP070_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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; |
| | |
| | | private static String GROUP_NAME = "OP080_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP080_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP080_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP080_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP080_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP080_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP080_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP080_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | logger.info("OP080工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP080_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP080_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP080_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | | public void handleInfo() throws Exception { |
| | | logger.info("OP080工位,handleInfo START!"); |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP080_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP090_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP090_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP090_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP090_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP090_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP090_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP090_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP090_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP090_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP090_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP090工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP090_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP090_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP090_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | ParamCollectionService paramCollectionService = opc.paramCollectionService; |
| | | 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 = |
| | | opc.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); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | OPCUnit.write(opc.getOP090_J_PC_FINISH(), "true"); //PC完成 |
| | | |
| | | logger.info("OP090工位,handleFinsh PC处理完成!"); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP100_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP100_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP100_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP100_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP100_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP100_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP100_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP100_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP100_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP100_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP100工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP100_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP100_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP100_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP100_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP110_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP110_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP110_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP110_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP110_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP110_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP110_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP110_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP110_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP110_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP110工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP110_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP110_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP110_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP110_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP120_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP120_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP120_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP120_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP120_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP120_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP120_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP120_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP120_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP120_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP120工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP120_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP120_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP120_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP120_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP120B_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP120B_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP120B_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP120B_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP120B_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP120B_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP120B_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP120B_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | //handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP120B_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP120B_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP120B工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP120B_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP120B_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP120B_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP120B_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP130_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP130_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP130_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP130_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP130_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP130_F_HEART_BEAT) { |
| | | |
| | | //PC读工单 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP130_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP130_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP130_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP130工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP130_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP130_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP130_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP130_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP130B_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP130B_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP130B_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP130B_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP130B_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP130B_F_HEART_BEAT) { |
| | | |
| | | //PC读工单 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP130B_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | // handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP130B_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP130B_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP130B工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP130B_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP130B_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP130B_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setProductionLine((remainingQuantity-1)+""); |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP130B_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP140_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP140_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP140_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP140_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP140_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP140_F_HEART_BEAT) { |
| | | |
| | | //PC读工单 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP140_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP140_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP140_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP140工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP140_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP140_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP140_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP140_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP150_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP150_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP150_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP150_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP150_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP150_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP150_J_PLC_START());//PLC开始 |
| | |
| | | String isFinish = OPCUnit.read(opc.getOP150_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | /* handleInfo();*/ |
| | | handleMaterial(); |
| | | handleFinsh(); |
| | | } |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP150_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP150_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP150工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP150_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP150_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP150_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP150_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP160_P";//组名 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP160_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP160_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP160_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP160_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP160_F_HEART_BEAT) { |
| | | //PC读工单 |
| | | String isPLCStart = OPCUnit.read(opc.getOP160_J_PLC_START());//PLC开始 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP160_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP160_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP160_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP160工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP160_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP160_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP160_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP160_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | if("false".equals(S_PRODUCT_STATE_CODE)){ |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list.size()>0){ |
| | | 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); |
| | |
| | | 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.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.plcserver.opc.GlobalVariable; |
| | | import cn.stylefeng.guns.plcserver.opc.OPCComm; |
| | | import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
| | |
| | | private static String GROUP_NAME = "OP170_P";//工位号 |
| | | private static List list = null; |
| | | private static Group group = null; |
| | | |
| | | private int count = 0; |
| | | |
| | | /** |
| | | * 设置心跳标志位,保存到全局变量 |
| | | */ |
| | | public void setHeartbeat(String value) { |
| | | if ("false".equals(value)) { |
| | | OPCUnit.write(opc.getOP170_F_HEART_BEAT(), "true"); |
| | | GlobalVariable.OP170_F_HEART_BEAT = true; |
| | | count = 0; |
| | | } else { |
| | | count++; |
| | | } |
| | | // 循环读取频率是:500ms一次,如果超过6次,也就是3s认定超时 |
| | | if (count > GlobalVariable.HEART_MAX_COUNT) { |
| | | GlobalVariable.OP170_F_HEART_BEAT = false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized void monitor() { |
| | | String ecpStr = "";//异常记录标记 |
| | | try{ |
| | | |
| | | String isHeartBeat = OPCUnit.read(opc.getOP170_F_HEART_BEAT()); |
| | | setHeartbeat(isHeartBeat); |
| | | |
| | | if(GlobalVariable.OP170_F_HEART_BEAT) { |
| | | |
| | | //PC读工单 |
| | |
| | | if(isPLCFinish.equals("true")){ |
| | | String isFinish = OPCUnit.read(opc.getOP170_J_PC_FINISH());//PC操作完成 |
| | | if(isFinish.equals("false")){ |
| | | handleMaterial(); |
| | | handleInfo(); |
| | | handleFinsh(); |
| | | } |
| | |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP170_S_SFC_CODE());//总成编码 |
| | | OPCUnit.write(opc.getOP170_J_PC_WRITE_ORDER(), "true"); //PC读工单完成 |
| | | logger.info("OP170工位,handleOrder PC处理完成!"); |
| | | } |
| | | |
| | | public void handleMaterial() { |
| | | if("".equals(S_ORDER_CODE)){ |
| | | IN_TIME = DateTool.getLocalTimeForDate(); |
| | | S_ORDER_CODE = OPCUnit.read(opc.getOP170_S_ORDER_CODE());//工单编号 |
| | | S_PRODUCT_TYPE = OPCUnit.read(opc.getOP170_S_PRODUCT_CODE());//产品编号 |
| | | S_PRODUCT_CODE = GlobalVariable.PRODUCT_CODE_MAP.get(S_PRODUCT_TYPE); |
| | | S_SFC_CODE = OPCUnit.read(opc.getOP170_S_SFC_CODE());//总成编码 |
| | | } |
| | | //查询批次上料信息 |
| | | ProductionOrderBatchInfoParam productionOrderBatchInfoParam = new ProductionOrderBatchInfoParam(); |
| | | productionOrderBatchInfoParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderBatchInfoParam.setLocationCode(LOCATION_CODE); |
| | | ProductionOrderBatchInfoService productionOrderBatchInfoService = opc.productionOrderBatchInfoService; |
| | | List<ProductionOrderBatchInfoResult> list1 = productionOrderBatchInfoService.findListBySpec(productionOrderBatchInfoParam); |
| | | for(int i=0;i<list1.size();i++){ |
| | | ProductionOrderBatchInfoResult productionOrderBatchInfoResult = list1.get(i); |
| | | |
| | | //判断是否有该工位 |
| | | String[] locationCodes = productionOrderBatchInfoResult.getLocationCode().split("/"); |
| | | logger.info("当前工位:"+locationCodes.toString()); |
| | | boolean isLocationCode = false; |
| | | if(locationCodes.length>0) |
| | | { |
| | | for (int j=0;j<locationCodes.length;j++){ |
| | | String location = locationCodes[j]; |
| | | if(location.equals(LOCATION_CODE)){ |
| | | isLocationCode = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int remainingQuantity = productionOrderBatchInfoResult.getResidueQuantity();//剩余数量 |
| | | if(remainingQuantity>0 && isLocationCode){ |
| | | //新增物料追溯 |
| | | 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 materialTraceabilityService = opc.materialTraceabilityService; |
| | | materialTraceabilityService.add(materialTraceabilityParam); |
| | | //更新剩余数量 |
| | | productionOrderBatchInfoParam.setId(productionOrderBatchInfoResult.getId()); |
| | | productionOrderBatchInfoParam.setResidueQuantity(remainingQuantity-1);//剩余数量 |
| | | productionOrderBatchInfoService.update(productionOrderBatchInfoParam); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //PC读参数信息 |
| | |
| | | } |
| | | //处理过站信息 |
| | | String S_PRODUCT_STATE_CODE = OPCUnit.read(opc.getOP170_S_PRODUCT_STATE_CODE()); |
| | | |
| | | //修改报工记录 |
| | | ProductionOrderRecordsParam productionOrderRecordsParam = new ProductionOrderRecordsParam(); |
| | | productionOrderRecordsParam.setWorkOrderNo(S_ORDER_CODE); |
| | | productionOrderRecordsParam.setProductNo(S_SFC_CODE); |
| | | ProductionOrderRecordsService productionOrderRecordsService = opc.productionOrderRecordsService; |
| | | |
| | | List<ProductionOrderRecordsResult> list2 = productionOrderRecordsService.findListBySpec(productionOrderRecordsParam); |
| | | if(list2.size()>0){ |
| | | 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); |
| | |
| | | datasource: |
| | | driverClassName: net.sourceforge.jtds.jdbc.Driver |
| | | # url: jdbc:jtds:sqlserver://120.48.135.247:1433;DatabaseName=festo_guns |
| | | # url: jdbc:jtds:sqlserver://172.20.1.10:1433;DatabaseName=MideaMes |
| | | url: jdbc:jtds:sqlserver://172.20.1.10:1433;DatabaseName=Jcdm019-Mes |
| | | # url: jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=MideaMesT1 |
| | | url: jdbc:jtds:sqlserver://192.168.0.189:1433;DatabaseName=Jcdm019-Mes |
| | | # url: jdbc:jtds:sqlserver://192.168.10.196:1433;DatabaseName=Jcdm019-Mes |
| | | username: sa |
| | | # password: admin@123 |
| | | password: JCDM@2023 |
| | | password: admin@123 |
| | | # password: JCDM@2023 |
| | | # 连接池大小根据实际情况调整 |
| | | max-active: 100 |
| | | max-pool-prepared-statement-per-connection-size: 100 |