From 21fde820e495c08cfa0ba277685468baa5bf9118 Mon Sep 17 00:00:00 2001
From: 懒羊羊 <15939171744@163.com>
Date: 星期三, 13 十二月 2023 10:27:42 +0800
Subject: [PATCH] OPC

---
 guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java
index d40971c..aa9edbc 100644
--- a/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.java
+++ b/guns-vip-main/src/main/java/cn/stylefeng/guns/plcserver/server/BOP030/impl/BOP030ServerInterfaceImpl.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,10 @@
 import org.openscada.opc.lib.da.Group;
 import org.openscada.opc.lib.da.Item;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
 import java.util.Date;
 import java.util.List;
 
@@ -68,7 +75,7 @@
                         handleFinsh();
                     }
                 }
-
+                handleOilState();
             }else{
                 logger.info("BOP030宸ヤ綅涓嶱LC鏂紑,璇锋鏌LC鎴栫綉缁滄槸鍚﹀紓甯革紒");
             }
@@ -82,6 +89,34 @@
         }
     }
 
+    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();
+
+            SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+            String currentDate = format.format(new Date());
+            long  daysBetween = getRemainder(currentDate,duaDate);
+            if(daysBetween>0){
+                OPCUnit.write(opc.getBOP030_OIL_STATE(), "false"); //鍐欐补鑴傜姸鎬�
+            }else{
+                OPCUnit.write(opc.getBOP030_OIL_STATE(), "true"); //鍐欐补鑴傜姸鎬�
+            }
+            logger.info("鍒版湡鏃ユ湡锛�"+duaDate+"褰撳墠鏃ユ湡锛�"+currentDate+"鍓╀綑澶╂暟锛氾細"+daysBetween);
+        }
+    }
+
+    public static long getRemainder(String currentDate,String tableDate){
+        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        LocalDate localDate1 = LocalDate.parse(currentDate, dateFormatter);
+        LocalDate localDate2 = LocalDate.parse(tableDate, dateFormatter);
+        long days = ChronoUnit.DAYS.between(localDate1, localDate2);
+        return days;
+    }
+
     //PC璇诲伐鍗�
     public void handleOrder() {
         IN_TIME = DateTool.getLocalTimeForDate();

--
Gitblit v1.9.3