cheng
2023-12-12 c64c9f6fb38f65be99b827c1af8d3c3852f68ba4
guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/DOP020/impl/DOP020ServerInterfaceImpl.java
@@ -8,6 +8,9 @@
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.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.plcserver.opc.GlobalVariable;
import cn.stylefeng.guns.plcserver.opc.OPCComm;
import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit;
@@ -19,6 +22,8 @@
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List;
@@ -68,7 +73,7 @@
                        handleFinsh();
                    }
                }
                handleOilState();
            }else{
                logger.info("DOP020工位与PLC断开,请检查PLC或网络是否异常!");
            }
@@ -82,6 +87,27 @@
        }
    }
    public void handleOilState(){
        GreaseManageParam param = new GreaseManageParam();
        GreaseManageService greaseManageService = opc.greaseManageService;
        param.setLocationCode(LOCATION_CODE);
        List<GreaseManageResult> list = greaseManageService.findListBySpec(param);
        if(list.size()>0) {
            String duaDate = list.get(0).getDuaDate();
            LocalDate date1 = LocalDate.parse(duaDate); // 第一个日期
            LocalDate date2 = LocalDate.now(); // 当前日期(或者指定其他日期)
            long daysBetween = ChronoUnit.DAYS.between(date1, date2);
            if(daysBetween>0){
                OPCUnit.write(opc.getOP050_OIL_STATE(), "false"); //写油脂状态
            }else{
                OPCUnit.write(opc.getOP050_OIL_STATE(), "true"); //写油脂状态
            }
            logger.info("到期日期:"+date1+"当前日期:"+date1+"剩余天数::"+daysBetween);
        }
    }
    //PC读工单
    public void handleOrder() {
        IN_TIME = DateTool.getLocalTimeForDate();