浏览代码

大屏及 报警bug修复

oyq28 9 月之前
父节点
当前提交
ba320dbb19

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

@@ -428,6 +428,7 @@ public class DeviceCollectionTaskJob {
     //机床报警信息数据采集
     @Scheduled(cron = "*/20 * * * * ?")
     public void toolWarinCJ()  {
+        BaseContextHandler.setTenant("0000");
         Set<Map.Entry<String, String>> entries = map.entrySet();
         entries.stream().parallel().forEach(vo->{
             try{
@@ -466,22 +467,24 @@ public class DeviceCollectionTaskJob {
     @Scheduled(cron = "*/20 * * * * ?")
     public void plcWarinCJ()  {
         try{
+            BaseContextHandler.setTenant("0000");
             Object map = msgUtil.redis_get(CacheKey.PLC_COSTOM_ADDRESS);
             List<PlcCostomAddress> list=null;
             if(map == null) {
                 list = plcCostomAddressMapper.getAddressList();
                 List<String> addressList=list.stream().map(PlcCostomAddress::getAddress).collect(Collectors.toList());
-                ObjectMapper objectMapper = new ObjectMapper();
-                String addressListJson = objectMapper.writeValueAsString(addressList);
-                msgUtil.redis_set(CacheKey.PLC_COSTOM_ADDRESS , addressListJson);
+                String str=String.join(",",addressList);
+                msgUtil.redis_set(CacheKey.PLC_COSTOM_ADDRESS , str);
             }
 
             long l = System.currentTimeMillis();
             //log.info("成航发PLC报警信息数据采集——开始:"+l);
-            BaseContextHandler.setTenant("0000");
             String httpserverUrl="http://localhost:8089/api/JobTasks/DataCollectS7JobWarn";
             //log.info("成航PLC报警信息数据采集,已请求");
             String resultData = msgUtil.httpForPost(httpserverUrl, null);
+            if(resultData==null){
+                return;
+            }
             //log.info("成航发PLC报警信息数据采集——返回:"+resultData);
             //long l1 = System.currentTimeMillis() - l;
             PlcCostomAddressHistory plcCostomAddressHistory=new PlcCostomAddressHistory();

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

@@ -80,4 +80,8 @@ public interface TTaskMapper extends SuperMapper<TTask> {
     List<ChfTwoDatas> getOnlineStatus();
     List<ToolCostomAddressHistory> getMin();
     List<ToolCostomAddressHistory> getMax();
+
+    Integer getYearProductCount();
+
+    Integer getMonthProductCount();
 }

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

@@ -126,4 +126,5 @@ public interface TaskService extends SuperService<TTask> {
     List<PlcCostomAddress> chfPlcWarning();
 
     Map<String,ChfProduct> chfTwoDatas();
+    Map<String,Integer> chfTwoDatasProductAndMes();
 }

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

@@ -1794,11 +1794,13 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
         // 机床状态
         List<ChfTwoDatas> onlineProduct = baseMapper.getOnlineStatus();
 
-
+        //获取机床当天最早采集数据
         List<ToolCostomAddressHistory> minProduct = baseMapper.getMin();
-
+        //获取机床当天最晚采集数据
         List<ToolCostomAddressHistory> maxProduct = baseMapper.getMax();
 
+
+
         Map<String,Integer> useMap=new HashMap<>();
 
         minProduct.forEach(vo->{
@@ -1843,9 +1845,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
             chfProduct.setChfTwoDatas(collect);
 
             List<ChfTwoDatas> pendingCollect = pendProduct.stream().filter(it -> it.getName().equals(vo.getKey())).collect(Collectors.toList());
-            chfProduct.setChfTwoDatasList(pendingCollect);
+            List list=new ArrayList<>();
+            if(CollectionUtil.isNotEmpty(pendingCollect)){
+                list.add(pendingCollect.get(0));
+            }
+            chfProduct.setChfTwoDatasList(list);
 
             List<ChfTwoDatas> repairCollect = repairProduct.stream().filter(it -> it.getName().equals(vo.getKey())).collect(Collectors.toList());
+
             chfProduct.setRepairList(repairCollect);
 
 
@@ -1868,6 +1875,19 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
         return map;
     }
 
+    @Override
+    public Map<String, Integer> chfTwoDatasProductAndMes() {
+        Map<String,Integer> map=new HashMap<>();
+        Integer yearCount=baseMapper.getYearProductCount();
+
+        Integer monthCount=baseMapper.getMonthProductCount();
+
+        map.put("yearCount",yearCount);
+        map.put("monthCount",monthCount);
+
+        return map;
+    }
+
     @Override
     public TTask getNNextTask(TTask task, int n) {
         TTask nTask = baseMapper.selectOne(new LbqWrapper<TTask>().eq(TTask::getCompleteBatchNo, task.getCompleteBatchNo()).eq(TTask::getProcedureSort, task.getProcedureSort() + n ));

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

@@ -500,7 +500,7 @@
             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
+        order by pp.prority desc,oo.create_time asc
 
     </select>
 
@@ -553,4 +553,26 @@
         ON t.ip = sub.ip AND t.create_time = sub.earliest_time;
     </select>
 
+    <select id="getYearProductCount" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*),0)
+        FROM (
+                 SELECT MAX(end_time) AS endTime, complete_batch_no
+                 FROM imcs_t_task
+                 GROUP BY complete_batch_no
+             ) a
+        WHERE a.endTime IS NOT NULL
+                  AND YEAR(a.endTime) = YEAR(CURDATE());
+    </select>
+
+    <select id="getMonthProductCount" resultType="java.lang.Integer">
+        SELECT IFNULL(COUNT(*),0)
+        FROM (
+                 SELECT MAX(end_time) AS endTime, complete_batch_no
+                 FROM imcs_t_task
+                 GROUP BY complete_batch_no
+             ) a
+        WHERE a.endTime IS NOT NULL
+                  AND MONTH(a.endTime) = MONTH(CURDATE());
+    </select>
+
 </mapper>

+ 6 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/TaskController.java

@@ -294,6 +294,12 @@ public class TaskController extends SuperController<TaskService, Long, TTask, TT
         return R.success(baseService.chfTwoDatas());
     }
 
+    @PostMapping("/chfTwoDatasProductAndMes")
+    public R chfTwoDatasProductAndMes() {
+
+        return R.success(baseService.chfTwoDatasProductAndMes());
+    }
+
 
 
 }