Browse Source

前端大屏接口

oyq28 9 tháng trước cách đây
mục cha
commit
c367298b24

+ 4 - 2
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/collection/DeviceCollectionTaskJob.java

@@ -426,7 +426,7 @@ public class DeviceCollectionTaskJob {
 
     //成航发
     //机床报警信息数据采集
-    @Scheduled(cron = "*/10 * * * * ?")
+    @Scheduled(cron = "*/20 * * * * ?")
     public void toolWarinCJ()  {
         Set<Map.Entry<String, String>> entries = map.entrySet();
         entries.stream().parallel().forEach(vo->{
@@ -447,8 +447,10 @@ public class DeviceCollectionTaskJob {
                 //String resultData=vo.getValue();
                 //log.info(vo+"_"+resultData);
                 //long l1 = System.currentTimeMillis() - l;
+                JSONObject jsonObject=new JSONObject(resultData);
                 ToolCostomAddressHistory toolCostomAddressHistory=new ToolCostomAddressHistory();
                 toolCostomAddressHistory.setValue(resultData);
+                toolCostomAddressHistory.setResult(jsonObject.get("result").toString());
                 toolCostomAddressHistory.setCreateTime(new Date());
                 toolCostomAddressHistory.setIp(vo.getKey());
                 toolCostomAddressHistoryMapper.insert(toolCostomAddressHistory);
@@ -461,7 +463,7 @@ public class DeviceCollectionTaskJob {
 
     //成航发
     //PLC报警信息数据采集
-    @Scheduled(cron = "*/10 * * * * ?")
+    @Scheduled(cron = "*/20 * * * * ?")
     public void plcWarinCJ()  {
         try{
             Object map = msgUtil.redis_get(CacheKey.PLC_COSTOM_ADDRESS);

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.centralToolMagazine.dto.ChfTwoDatas;
+import com.github.zuihou.business.centralToolMagazine.entity.ToolCostomAddressHistory;
 import com.github.zuihou.business.operationManagementCenter.entity.Plan;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
@@ -75,4 +76,8 @@ public interface TTaskMapper extends SuperMapper<TTask> {
     String getNodeDataToRfidUse(Long nodeId);
 
     List<ChfTwoDatas> getProduct(@Param("planStatus") String planStatus);
+    List<ChfTwoDatas> getRepairProduct();
+    List<ChfTwoDatas> getOnlineStatus();
+    List<ToolCostomAddressHistory> getMin();
+    List<ToolCostomAddressHistory> getMax();
 }

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

@@ -1789,18 +1789,80 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
 
         //已排产 待生产
         List<ChfTwoDatas> pendProduct = baseMapper.getProduct("1");
+        // 维保
+        List<ChfTwoDatas> repairProduct = baseMapper.getRepairProduct();
+        // 机床状态
+        List<ChfTwoDatas> onlineProduct = baseMapper.getOnlineStatus();
+
+
+        List<ToolCostomAddressHistory> minProduct = baseMapper.getMin();
+
+        List<ToolCostomAddressHistory> maxProduct = baseMapper.getMax();
+
+        Map<String,Integer> useMap=new HashMap<>();
+
+        minProduct.forEach(vo->{
+            cn.hutool.json.JSONObject jsonObject=new cn.hutool.json.JSONObject(vo.getValue());
+            JSONArray minJsonArray = JSONArray.parseArray(jsonObject.get("values").toString());
+            String min = minJsonArray.get(101).toString();
+            Optional<ToolCostomAddressHistory> first = maxProduct.stream().filter(it -> it.getIp().equals(vo.getIp())).findFirst();
+            String value = first.get().getValue();
+            cn.hutool.json.JSONObject maxJsonObject=new cn.hutool.json.JSONObject(value);
+            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);
+
+            // 计算差值
+            double difference = value1 - value2;
+
+            // 计算结果
+            double result = (difference / (16 * 3600)) * 100;
+
+            // 转换为整数
+            int finalResult = (int) Math.round(result);
+
+            if("10.161.30.245".equals(vo.getIp())){
+                useMap.put("GMU800AVI-1",finalResult);
+            }else if("10.161.30.246".equals(vo.getIp())){
+                useMap.put("GMU800AVI-2",finalResult);
+            }else{
+                useMap.put("GMU800AVI-3",finalResult);
+            }
+
+        });
+
+
+
 
         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(collect.size() > 0){
-                chfProduct.setChfTwoDatas(collect.get(0));
-            }
+            chfProduct.setChfTwoDatas(collect);
+
             List<ChfTwoDatas> pendingCollect = pendProduct.stream().filter(it -> it.getName().equals(vo.getKey())).collect(Collectors.toList());
             chfProduct.setChfTwoDatasList(pendingCollect);
 
+            List<ChfTwoDatas> repairCollect = repairProduct.stream().filter(it -> it.getName().equals(vo.getKey())).collect(Collectors.toList());
+            chfProduct.setRepairList(repairCollect);
+
+
+            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){
+                chfProduct.setOnlineStatus("2");
+            }else{
+                chfProduct.setOnlineStatus("1");
+            }
+            chfProduct.setUseRadio(useMap.get(vo.getKey()));
+
             map.put(vo.getKey(),chfProduct);
+
+
         });
 
         return map;

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

@@ -472,7 +472,7 @@
                 END AS downTime,
                tp.name
         <if test="planStatus==null">
-        ,ROUND((TIMESTAMPDIFF(MINUTE, ttn.start_time, NOW()) / bbp.rated_workHours), 3) AS point
+        ,ROUND(ROUND((TIMESTAMPDIFF(MINUTE, ttn.start_time, NOW()) / bbp.rated_workHours), 3) * 100, 0) AS point
         </if>
         from imcs_o_order oo
                INNER JOIN imcs_p_plan pp on oo.id=pp.order_id
@@ -500,7 +500,57 @@
             EXISTS(
         select * from imcs_t_task_node where order_id=pp.order_id and node_name='启动程序' and exe_status='2'
         )
+        order by pp.prority desc,oo.create_time asc limit 1
 
     </select>
 
+    <select id="getRepairProduct" resultType="com.github.zuihou.business.centralToolMagazine.dto.ChfTwoDatas">
+        select
+            CASE
+                WHEN timestampdiff( MINUTE, now(), a.repair_end_time ) > 0 THEN
+                    CONCAT(
+                            TRUNCATE ( timestampdiff( MINUTE, now(), a.repair_end_time ) / 1440, 0 ),
+                            '天',
+                            TRUNCATE ( MOD ( timestampdiff( MINUTE, now(), a.repair_end_time ), 1440 ) / 60, 0 ),
+                            '小时',
+                            MOD ( MOD ( timestampdiff( MINUTE, now(), a.repair_end_time ), 1440 ), 60 ),
+                            '分钟'
+                        ) ELSE '已到维保时间'
+                END AS downTime,
+            tp.name from
+            imcs_tenant_productionresource tp
+                INNER join imcs_tenant_repair a on a.productionresource_id=tp.id
+        where
+            tp.mode_specification='GMU800AVI'
+
+
+    </select>
+    
+    <select id="getOnlineStatus" resultType="com.github.zuihou.business.centralToolMagazine.dto.ChfTwoDatas">
+        select name,online_status from imcs_tenant_productionresource
+    </select>
+
+    <select id="getMin" resultType="com.github.zuihou.business.centralToolMagazine.entity.ToolCostomAddressHistory">
+        SELECT t.*
+        FROM tool_costom_address_history t
+                 JOIN (
+            SELECT ip, MIN(create_time) AS earliest_time
+            FROM tool_costom_address_history
+            WHERE DATE(create_time) = CURDATE() and result='true'
+        GROUP BY ip
+            ) sub
+        ON t.ip = sub.ip AND t.create_time = sub.earliest_time;
+    </select>
+    <select id="getMax" resultType="com.github.zuihou.business.centralToolMagazine.entity.ToolCostomAddressHistory">
+        SELECT t.*
+        FROM tool_costom_address_history t
+                 JOIN (
+            SELECT ip, MAX(create_time) AS earliest_time
+            FROM tool_costom_address_history
+            WHERE DATE(create_time) = CURDATE() and result='true'
+        GROUP BY ip
+            ) sub
+        ON t.ip = sub.ip AND t.create_time = sub.earliest_time;
+    </select>
+
 </mapper>

+ 7 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/centralToolMagazine/dto/ChfProduct.java

@@ -2,10 +2,16 @@ package com.github.zuihou.business.centralToolMagazine.dto;
 
 import lombok.Data;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Data
 public class ChfProduct {
-    private ChfTwoDatas chfTwoDatas;
+    private List<ChfTwoDatas> chfTwoDatas;
     private List<ChfTwoDatas> chfTwoDatasList;
+    private List<ChfTwoDatas> repairList;
+    private String onlineStatus;
+    private Integer useRadio=0;
+
+
 }

+ 3 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/centralToolMagazine/dto/ChfTwoDatas.java

@@ -16,9 +16,11 @@ public class ChfTwoDatas {
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date deliveryTime;
 
-    private BigDecimal point;
+    private int point;
 
     private String onlineStatus;
 
     private String downTime;
+
+    private BigDecimal useRadio;
 }

+ 4 - 4
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/centralToolMagazine/entity/ToolCostomAddressHistory.java

@@ -26,10 +26,10 @@ public class ToolCostomAddressHistory  {
     @TableId(type = IdType.AUTO)
     private Long id;
 
-    @ApiModelProperty(value = "异常解释")
-    @NotNull(message = "异常解释")
-    @TableField("tool_costom_address_id")
-    private Long toolCostomAddressId;
+    @ApiModelProperty(value = "result")
+    @NotNull(message = "result")
+    @TableField("result")
+    private String result;
 
     @ApiModelProperty(value = "接口返回数据")
     @NotNull(message = "接口返回数据")