Parcourir la source

后台数据处理bug

oyq28 il y a 2 ans
Parent
commit
cff51a6465

+ 32 - 1
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

@@ -1,6 +1,7 @@
 package com.github.zuihou.api;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 运维小程序接口
@@ -70,7 +72,18 @@ public class OpsAppApi {
         LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
         ProductionResource productionResource = BeanUtil.toBean(params.getModel(), ProductionResource.class);
         queryWrap.eq(ProductionResource::getStatus, "1").orderByDesc(ProductionResource::getCreateTime);
+        if(StringUtils.isNotEmpty(productionResource.getOnlineStatus())){
+            List<String> ids = productionTenantResourceService.getEquStatusIds(productionResource.getOnlineStatus());
+            queryWrap.in(ProductionResource::getId, ids);
+        }
         IPage<ProductionResource> list = productionTenantResourceService.pageList(page, queryWrap);
+        if(null!=list.getRecords() && list.getRecords().size()>0) {
+            list.getRecords().stream().forEach(item -> {
+                Map map = productionTenantResourceService.getEquRunInfo(item.getId());
+                item.setOnlineStatus(map.containsKey("equStatus")?map.get("equStatus").toString():"0");
+                item.setErrMsg(map.containsKey("errMsg") && map.get("errMsg")!=null ?map.get("errMsg").toString():"");
+            });
+        }
         return R.success(list);
     }
 
@@ -108,7 +121,16 @@ public class OpsAppApi {
         queryWrap.eq(ProductionResource::getId, equId);
         Page<ProductionResource> page = new Page<>(1L, 1);
         IPage<ProductionResource> productionResourceList = productionTenantResourceService.pageList(page, queryWrap);
-        return R.success(productionResourceList.getRecords().size() > 0 ? productionResourceList.getRecords().get(0) : ProductionResource.builder().build());
+        ProductionResource productionResource = null;
+        if(productionResourceList.getRecords().size()>0){
+            productionResource = productionResourceList.getRecords().get(0);
+            Map map = productionTenantResourceService.getEquRunInfo(productionResource.getId());
+            productionResource.setOnlineStatus(map.containsKey("equStatus")?map.get("equStatus").toString():"0");
+            productionResource.setErrMsg(map.containsKey("errMsg") && map.get("errMsg")!=null ?map.get("errMsg").toString():"");
+        }else{
+            productionResource = ProductionResource.builder().build();
+        }
+        return R.success(productionResource);
     }
 
 
@@ -244,6 +266,15 @@ public class OpsAppApi {
             paramsMap.put("orgIds", orgIds);
         }
         Map map = orderService.getStatisticMap(paramsMap);
+        //补充异常设备数据
+        List<String> ids = productionTenantResourceService.getEquStatusIds("2");
+        List<Long> orgArr = CommonUtil.getOrgIdsArr();
+        if(ids.size()>0 && orgArr.size()>0) {
+            ids = productionTenantResourceService.listByIds(ids).stream().filter(item->CollectionUtil.contains(orgArr,(Long)item.getOrgId())
+            ).map(item->item.getId().toString()).collect(Collectors.toList());
+        }
+        map.put("exceptDevice", ids.size());
+        map.put("lackDevice", ids.size());
         return R.success(map);
     }
 

+ 2 - 2
imcs-bt-be/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionresource/ProductionResourceController.java

@@ -199,9 +199,9 @@ public class ProductionResourceController extends SuperController<ProductionTena
         list.stream().forEach(item->{
             Map<String, String> resultMap = baseService.getEquRunInfo(item.getId());
             String equStatus =  resultMap.get("equStatus");
-            if(equStatus=="0"){
+            if(equStatus.equals("0")){
                 map.put("offlineCount", map.get("offlineCount")+1);
-            }else if(equStatus=="1"){
+            }else if(equStatus.equals("1")){
                 map.put("onLineCount", map.get("onLineCount")+1);
             }else{
                 map.put("exceptCount", map.get("exceptCount")+1);

+ 3 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/productionresource/dto/ProductionResourcePageDTO.java

@@ -191,4 +191,7 @@ public class ProductionResourcePageDTO implements Serializable {
 
     @ApiModelProperty(value = "纬度")
     private String latitude;
+
+    @ApiModelProperty(value = "错误信息")
+    private String errMsg;
 }

+ 4 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/productionresource/entity/ProductionResource.java

@@ -326,6 +326,10 @@ public class ProductionResource extends Entity<Long> {
     @TableField(exist = false)
     private String latitude;
 
+    @ApiModelProperty(value = "错误信息")
+    @TableField(exist = false)
+    private String errMsg;
+
     @Builder
     public ProductionResource(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
                               Long compnayId, String moduleId, String areaId, String name, String resourcesCategory,