wudingsheng 9 bulan lalu
induk
melakukan
b99528c994

+ 1 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/dao/TTaskMapper.java

@@ -89,4 +89,5 @@ public interface TTaskMapper extends SuperMapper<TTask> {
 
     ToolCostomAddressHistory getMinToolDay(@Param("startTime") String startTime, @Param("ip") String ip);
     ToolCostomAddressHistory getMaxToolDay(@Param("startTime") String startTime, @Param("ip") String ip);
+    ToolCostomAddressHistory getMaxByIp(@Param("ip") String ip);
 }

+ 43 - 23
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskServiceImpl.java

@@ -1822,16 +1822,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
             // 计算相差的天数
             long daysBetween = ChronoUnit.DAYS.between(startDate, today);
 
-            String ip;
-            if(StringUtils.equals("GMU800AVI-1",vo.getName())){
-                ip="10.161.30.245";
-            }else if(StringUtils.equals("GMU800AVI-2",vo.getName())){
-                ip="10.161.30.246";
-            }else if(StringUtils.equals("GMU800AVI-3",vo.getName())){
-                ip="10.161.30.247";
-            } else {
-                ip = null;
-            }
+            String ip=getIp(vo.getName());
             double difference = 0;
             if(daysBetween==1){
                 //获取机床启动程序时间的数据采集
@@ -1930,21 +1921,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
 
         Set<Map.Entry<String, ChfProduct>> entries = map.entrySet();
         entries.stream().forEach(vo->{
+
             ChfProduct chfProduct=new ChfProduct();
             List<ChfTwoDatas> collect = product.stream().filter(it -> it.getName().equals(vo.getKey())).collect(Collectors.toList());
             //获取机床当天最早采集数据
             if(CollectionUtil.isNotEmpty(collect)){
                 collect.stream().forEach(item->{
-                    String ip;
-                    if(StringUtils.equals("GMU800AVI-1",vo.getKey())){
-                        ip="10.161.30.245";
-                    }else if(StringUtils.equals("GMU800AVI-2",vo.getKey())){
-                        ip="10.161.30.246";
-                    }else if(StringUtils.equals("GMU800AVI-3",vo.getKey())){
-                        ip="10.161.30.247";
-                    } else {
-                        ip = null;
-                    }
+                    String ip=getIp(vo.getKey());
+
                     double beforeUseTime = 0;
                     if(useTimeMap.containsKey(ip)){
                         beforeUseTime=useTimeMap.get(ip);
@@ -1955,6 +1939,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
 
                     Optional<ToolCostomAddressHistory> first = maxProduct.stream().filter(it -> it.getIp().equals(ip)).findFirst();
 
+
+
                     if(minTool!=null && first.isPresent()){
                         cn.hutool.json.JSONObject jsonObject=new cn.hutool.json.JSONObject(minTool.getValue());
                         JSONArray minJsonArray = JSONArray.parseArray(jsonObject.get("values").toString());
@@ -1966,6 +1952,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
                         JSONArray maxJsonArray = JSONArray.parseArray(maxJsonObject.get("values").toString());
                         String max = maxJsonArray.get(101).toString();
 
+
                         // 转换为 double
                         double value1 = Double.parseDouble(max);
                         double value2 = Double.parseDouble(min);
@@ -2013,9 +2000,28 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
 
             List<ChfTwoDatas> onlineCollect = onlineProduct.stream().filter(it -> it.getName().equals(vo.getKey())).collect(Collectors.toList());
             ChfTwoDatas chfTwoDatas = onlineCollect.get(0);
-            if("0".equals(chfTwoDatas.getOnlineStatus())){
-                chfProduct.setOnlineStatus(chfTwoDatas.getOnlineStatus());
-            }else if(collect.size()>0){
+
+
+            Boolean deviceProductFlag=false;
+            String deviceIp=getIp(vo.getKey());
+            ToolCostomAddressHistory maxByIp = baseMapper.getMaxByIp(deviceIp);
+            if(maxByIp!=null && StringUtils.equals("true",maxByIp.getResult())){
+                String value = maxByIp.getValue();
+                cn.hutool.json.JSONObject maxJsonObject=new cn.hutool.json.JSONObject(value);
+                JSONArray maxJsonArray = JSONArray.parseArray(maxJsonObject.get("values").toString());
+
+                double feedRateOvr = Double.parseDouble(maxJsonArray.get(96).toString());
+                double speedOvr = Double.parseDouble(maxJsonArray.get(97).toString());
+                double actSpeed = Double.parseDouble(maxJsonArray.get(98).toString());
+                double vaLoad = Double.parseDouble(maxJsonArray.get(99).toString());
+                if(feedRateOvr > 0 && speedOvr > 0 && actSpeed > 0 && vaLoad > 0){
+                    deviceProductFlag=true;
+                }
+            }
+
+            if("0".equals(chfTwoDatas.getOnlineStatus()) || (maxByIp!=null && StringUtils.equals("false",maxByIp.getResult()))){
+                chfProduct.setOnlineStatus("0");
+            }else if(collect.size()>0 && deviceProductFlag){
                 chfProduct.setOnlineStatus("2");
             }else{
                 chfProduct.setOnlineStatus("1");
@@ -2088,4 +2094,18 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
         List<Tray> trayList = trayService.list(new LbqWrapper<Tray>().eq(Tray::getCategoryType, tray.getCategoryType()).eq(Tray::getProductionType, tray.getProductionType()).eq(Tray::getFiveAxis, tray.getFiveAxis()).in(Tray::getId, stockIds));
         return trayList;
     }
+
+    public String getIp(String deviceName){
+        String ip;
+        if(StringUtils.equals("GMU800AVI-1",deviceName)){
+            ip="10.161.30.245";
+        }else if(StringUtils.equals("GMU800AVI-2",deviceName)){
+            ip="10.161.30.246";
+        }else if(StringUtils.equals("GMU800AVI-3",deviceName)){
+            ip="10.161.30.247";
+        } else {
+            ip = null;
+        }
+        return ip;
+    }
 }

+ 4 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TTaskMapper.xml

@@ -614,5 +614,9 @@
             ) sub
         ON t.ip = sub.ip AND t.create_time = sub.earliest_time;
     </select>
+    
+    <select id="getMaxByIp" resultType="com.github.zuihou.business.centralToolMagazine.entity.ToolCostomAddressHistory">
+        select * from tool_costom_address_history where ip=#{ip} order by id desc limit 1
+    </select>
 
 </mapper>