cl
2024-01-16 cf6bff3922bbd0624b98834f6ea85c8e619e564f
修改数据采集
已修改45个文件
3753 ■■■■■ 文件已修改
guns-vip-main/src/main/java/cn/stylefeng/guns/modular/om/productionOrderBatchInfo/mapper/mapping/ProductionOrderBatchInfoMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/OpcServiceMain.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/opc/GlobalVariable.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/opc/OPCComm.java 153 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP010/impl/BOP010ServerInterfaceImpl.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP020/impl/BOP020ServerInterfaceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030B/impl/BOP030BServerInterfaceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP040/impl/BOP040ServerInterfaceImpl.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP040B/impl/BOP040BServerInterfaceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/COP010/impl/COP010ServerInterfaceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/COP020/impl/COP020ServerInterfaceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/COP030/impl/COP030ServerInterfaceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/DOP010/impl/DOP010ServerInterfaceImpl.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/DOP020/impl/DOP020ServerInterfaceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP010/impl/EOP010ServerInterfaceImpl.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP020/impl/EOP020ServerInterfaceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP030/impl/EOP030ServerInterfaceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP040/impl/EOP040ServerInterfaceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP050/impl/EOP050ServerInterfaceImpl.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP060/impl/EOP060ServerInterfaceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP070/impl/EOP070ServerInterfaceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP070B/impl/EOP070BServerInterfaceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP080/impl/EOP080ServerInterfaceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP090/impl/EOP090ServerInterfaceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP090B/impl/EOP090BServerInterfaceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP010/impl/OP010ServerInterfaceImpl.java 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP020/impl/OP020ServerInterfaceImpl.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP030/impl/OP030ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP040/impl/OP040ServerInterfaceImpl.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP050/impl/OP050ServerInterfaceImpl.java 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP070/impl/OP070ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP080/impl/OP080ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP090/impl/OP090ServerInterfaceImpl.java 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP100/impl/OP100ServerInterfaceImpl.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP110/impl/OP110ServerInterfaceImpl.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP120/impl/OP120ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP120B/impl/OP120BServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP130/impl/OP130ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP130B/impl/OP130BServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP140/impl/OP140ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP150/impl/OP150ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP160/impl/OP160ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP170/impl/OP170ServerInterfaceImpl.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/resources/application-local.yml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-vip-main/src/main/java/cn/stylefeng/guns/modular/om/productionOrderBatchInfo/mapper/mapping/ProductionOrderBatchInfoMapper.xml
@@ -42,7 +42,7 @@
            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>
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/OpcServiceMain.java
@@ -13,6 +13,8 @@
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;
@@ -143,22 +145,28 @@
    @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());
@@ -171,8 +179,8 @@
            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());
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/opc/GlobalVariable.java
@@ -9,7 +9,7 @@
    public static boolean TERMINATED = true;
    public static int SLEEP_TIME = 2000;
    public static int SLEEP_TIME = 1000;
    public static int HEART_MAX_COUNT = 10;
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/opc/OPCComm.java
@@ -10,6 +10,8 @@
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.*;
@@ -106,6 +108,12 @@
    public LocationInfoService locationInfoService;
    @Autowired
    public GreaseManageService greaseManageService;
    @Autowired
    public ProductionOrderRecordsService productionOrderRecordsService;
    @Autowired
    public ProductionOrderBatchInfoService productionOrderBatchInfoService;
    //OP010
    private Item OP010_F_HEART_BEAT;//心跳
@@ -727,7 +735,9 @@
                     EquipmentInfoService equipmentInfoService,
                     RepairManageInfoService repairManageInfoService,
                     LocationInfoService locationInfoService,
                     GreaseManageService greaseManageService
                     GreaseManageService greaseManageService,
                     ProductionOrderRecordsService productionOrderRecordsService,
                     ProductionOrderBatchInfoService productionOrderBatchInfoService
                    ) throws Exception {
        this.productionOrdeInfoService = productionOrdeInfoService;
        this.passingStationCollectionService = passingStationCollectionService;
@@ -741,6 +751,8 @@
        this.repairManageInfoService = repairManageInfoService;
        this.locationInfoService = locationInfoService;
        this.greaseManageService = greaseManageService;
        this.productionOrderRecordsService = productionOrderRecordsService;
        this.productionOrderBatchInfoService = productionOrderBatchInfoService;
        // 加载配置文件
        final ConnectionInformation ci = getCLSIDConnectionInfomation();
@@ -753,140 +765,7 @@
            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");
@@ -1047,7 +926,7 @@
            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读数据完成
@@ -1072,7 +951,7 @@
            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");
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP010/impl/BOP010ServerInterfaceImpl.java
@@ -12,6 +12,9 @@
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;
@@ -56,13 +59,32 @@
    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) {
@@ -88,6 +110,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getBOP010_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleFinsh();
                    }
                }
@@ -191,6 +214,60 @@
        }
    }
    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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP020/impl/BOP020ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,34 @@
    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开始
@@ -64,6 +93,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getBOP020_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -145,6 +175,60 @@
        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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java
@@ -8,9 +8,14 @@
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;
@@ -51,10 +56,34 @@
    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开始
@@ -71,6 +100,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getBOP030_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -105,7 +135,7 @@
            }else{
                OPCUnit.write(opc.getBOP030_OIL_STATE(), "true"); //写油脂状态
            }
            logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween);
            //logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween);
        }
    }
@@ -180,6 +210,60 @@
        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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030B/impl/BOP030BServerInterfaceImpl.java
@@ -44,10 +44,35 @@
    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开始
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP040/impl/BOP040ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,35 @@
    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开始
@@ -64,6 +94,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getBOP040_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -145,6 +176,60 @@
        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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP040B/impl/BOP040BServerInterfaceImpl.java
@@ -44,10 +44,35 @@
    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开始
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/COP010/impl/COP010ServerInterfaceImpl.java
@@ -6,9 +6,14 @@
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;
@@ -53,13 +58,32 @@
    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) {
@@ -83,6 +107,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getCOP010_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleFinsh();
                    }
                }
@@ -187,6 +212,60 @@
        }
    }
    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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/COP020/impl/COP020ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getCOP020_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -145,6 +174,60 @@
        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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/COP030/impl/COP030ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getCOP030_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -145,6 +174,60 @@
        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() {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/DOP010/impl/DOP010ServerInterfaceImpl.java
@@ -12,6 +12,9 @@
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;
@@ -52,13 +55,31 @@
    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) {
@@ -83,6 +104,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getDOP010_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleFinsh();
                    }
                }
@@ -196,6 +218,60 @@
        }
    }
    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完成
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/DOP020/impl/DOP020ServerInterfaceImpl.java
@@ -8,9 +8,14 @@
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;
@@ -51,10 +56,33 @@
    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开始
@@ -71,6 +99,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getDOP020_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -104,7 +133,7 @@
            }else{
                OPCUnit.write(opc.getDOP020_OIL_STATE(), "true"); //写油脂状态
            }
            logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween);
            //logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween);
        }
    }
@@ -180,6 +209,61 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP010/impl/EOP010ServerInterfaceImpl.java
@@ -10,6 +10,9 @@
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;
@@ -46,10 +49,33 @@
    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开始
@@ -69,6 +95,7 @@
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
                }
@@ -97,18 +124,63 @@
    }
    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 {
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP020/impl/EOP020ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP020_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -146,6 +175,61 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP030/impl/EOP030ServerInterfaceImpl.java
@@ -8,9 +8,14 @@
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;
@@ -49,10 +54,33 @@
    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开始
@@ -69,6 +97,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP030_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -152,6 +181,61 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP040/impl/EOP040ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP040_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -146,6 +175,61 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP050/impl/EOP050ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP050_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -146,6 +175,62 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP060/impl/EOP060ServerInterfaceImpl.java
@@ -14,6 +14,9 @@
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;
@@ -53,10 +56,33 @@
    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开始
@@ -79,6 +105,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP060_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -218,6 +245,62 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP070/impl/EOP070ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP070_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -146,6 +175,61 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP070B/impl/EOP070BServerInterfaceImpl.java
@@ -44,10 +44,33 @@
    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开始
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP080/impl/EOP080ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP080_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -146,6 +175,60 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP090/impl/EOP090ServerInterfaceImpl.java
@@ -8,6 +8,11 @@
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;
@@ -44,10 +49,33 @@
    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开始
@@ -64,6 +92,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getEOP090_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -146,6 +175,60 @@
        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)){
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/EOP090B/impl/EOP090BServerInterfaceImpl.java
@@ -44,10 +44,33 @@
    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开始
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP010/impl/OP010ServerInterfaceImpl.java
@@ -7,10 +7,18 @@
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;
@@ -57,13 +65,32 @@
    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) {
@@ -89,6 +116,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP010_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleFinsh();
                    }
                }
@@ -156,6 +184,7 @@
    }
    //PC下发工单
    public void handleOrder() {
        logger.info("OP010工位,handleOrder PC处理开始!");
        IN_TIME = DateTool.getLocalTimeForDate();
        ProductionOrdeInfoParam param = new ProductionOrdeInfoParam();
@@ -216,6 +245,18 @@
            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); //总成编码
@@ -229,6 +270,61 @@
    }
    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处理开始!");
@@ -239,8 +335,26 @@
            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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP020/impl/OP020ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP020_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,62 @@
        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读参数信息
@@ -146,6 +235,7 @@
        logger.info("OP020工位,handleInfo END!");
    }
    //PC完成
    public void handleFinsh() {
        if("".equals(S_ORDER_CODE)){
@@ -155,8 +245,26 @@
            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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP030/impl/OP030ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP030_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP040/impl/OP040ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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读工单
@@ -65,6 +97,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP040_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -92,6 +125,61 @@
        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读参数信息
@@ -158,6 +246,23 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP050/impl/OP050ServerInterfaceImpl.java
@@ -7,10 +7,19 @@
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;
@@ -51,10 +60,34 @@
    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开始
@@ -71,6 +104,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP050_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -108,7 +142,7 @@
            }else{
                OPCUnit.write(opc.getOP050_OIL_STATE(), "true"); //写油脂状态
            }
            logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween);
            //logger.info("到期日期:"+duaDate+"当前日期:"+currentDate+"剩余天数::"+daysBetween);
        }
    }
@@ -128,6 +162,61 @@
        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读参数信息
@@ -196,6 +285,7 @@
        //处理过站信息
        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);
@@ -208,9 +298,17 @@
        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);
@@ -220,6 +318,40 @@
        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完成
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP070/impl/OP070ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP070_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP080/impl/OP080ServerInterfaceImpl.java
@@ -11,6 +11,14 @@
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;
@@ -50,10 +58,34 @@
    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开始
@@ -76,6 +108,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP080_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -151,6 +184,61 @@
        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!");
@@ -215,6 +303,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP090/impl/OP090ServerInterfaceImpl.java
@@ -7,8 +7,16 @@
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;
@@ -45,10 +53,34 @@
    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开始
@@ -65,6 +97,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP090_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -92,6 +125,61 @@
        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读参数信息
@@ -184,6 +272,39 @@
        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处理完成!");
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP100/impl/OP100ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,33 @@
    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开始
@@ -64,6 +95,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP100_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +123,61 @@
        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读参数信息
@@ -157,6 +244,23 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP110/impl/OP110ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP110_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,23 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP120/impl/OP120ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP120_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP120B/impl/OP120BServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP120B_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        //handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP130/impl/OP130ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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读工单
@@ -65,6 +97,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP130_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -92,6 +125,61 @@
        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读参数信息
@@ -161,6 +249,24 @@
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP130B/impl/OP130BServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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读工单
@@ -65,6 +97,7 @@
                    if(isPLCFinish.equals("true")){
                        String isFinish = OPCUnit.read(opc.getOP130B_J_PC_FINISH());//PC操作完成
                        if(isFinish.equals("false")){
                           // handleMaterial();
                            handleInfo();
                            handleFinsh();
                        }
@@ -92,6 +125,61 @@
        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读参数信息
@@ -159,6 +247,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP140/impl/OP140ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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读工单
@@ -65,6 +97,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP140_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -92,6 +125,61 @@
        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读参数信息
@@ -158,6 +246,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP150/impl/OP150ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -65,6 +97,7 @@
                    String isFinish = OPCUnit.read(opc.getOP150_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                       /* handleInfo();*/
                        handleMaterial();
                        handleFinsh();
                    }
                }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP160/impl/OP160ServerInterfaceImpl.java
@@ -8,6 +8,14 @@
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;
@@ -44,10 +52,34 @@
    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开始
@@ -64,6 +96,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP160_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -91,6 +124,61 @@
        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读参数信息
@@ -157,6 +245,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/OP170/impl/OP170ServerInterfaceImpl.java
@@ -8,9 +8,17 @@
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;
@@ -47,10 +55,34 @@
    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读工单
@@ -68,6 +100,7 @@
                if(isPLCFinish.equals("true")){
                    String isFinish = OPCUnit.read(opc.getOP170_J_PC_FINISH());//PC操作完成
                    if(isFinish.equals("false")){
                        handleMaterial();
                        handleInfo();
                        handleFinsh();
                    }
@@ -95,6 +128,61 @@
        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读参数信息
@@ -161,6 +249,24 @@
        }
        //处理过站信息
        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);
guns-vip-main/src/main/resources/application-local.yml
@@ -21,12 +21,12 @@
  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