Browse Source

后台新增设备状态方法

oyq28 2 years ago
parent
commit
0774c762db

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

@@ -412,5 +412,10 @@ public class OpsAppApi {
         return R.success(resultMap);
     }
 
-
+    @GetMapping("/getDevStatusMap")
+    public R<Map<String, String>> getDevStatusMap(@RequestParam(name = "equId", required = true) Long equId) {
+        BaseContextHandler.setTenant("0000");
+        Map<String, String> resultMap = productionTenantResourceService.getDevStatusMap(equId);
+        return R.success(resultMap);
+    }
 }

+ 3 - 0
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/productionresource/dao/ProductionTenantResourceMapper.java

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Repository;
 import com.github.zuihou.business.productionresource.entity.ProductionResource;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -30,4 +31,6 @@ public interface ProductionTenantResourceMapper extends SuperMapper<ProductionRe
     List<EquGoodsDto> getEquGoods(@Param("equId") Long equId);
 
     Integer getEquLockCount(Long equId);
+
+    Map getDevStatusMap(@Param("id")Long equId);
 }

+ 3 - 0
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/productionresource/service/ProductionTenantResourceService.java

@@ -8,6 +8,7 @@ import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -29,4 +30,6 @@ public interface ProductionTenantResourceService extends SuperService<Production
     List<String> getEquStatusIds(String onlineStatus);
 
     Integer getEquLockCount(Long equId);
+
+    Map getDevStatusMap(Long equId);
 }

+ 6 - 0
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/productionresource/service/impl/ProductionTenantResourceServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -77,4 +78,9 @@ public class ProductionTenantResourceServiceImpl extends SuperServiceImpl<Produc
     public Integer getEquLockCount(Long equId) {
         return baseMapper.getEquLockCount(equId);
     }
+
+    @Override
+    public Map getDevStatusMap(Long equId) {
+        return baseMapper.getDevStatusMap(equId);
+    }
 }

+ 32 - 0
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/productionresource/ProductionresourceMapper.xml

@@ -118,4 +118,36 @@
         </if>
     </select>
 
+    <select id="getDevStatusMap" parameterType="hashMap" resultType="java.util.Map">
+        select sum(num1) as barrelLackNum,
+               sum(num2) as barrelExprNum,
+               sum(num3) as cupLackNum,
+               sum(num4) as cupExprNum
+        from (
+                select count(distinct p.id) as num1 ,0 as num2,0 as num3,0 as num4 from imcs_tenant_productionresource p left join bt_equ_barrel b on b.equ_id = p.id
+                where p.status = '1' and b.residue_warn>=b.mtr_residue and b.barrel_type <![CDATA[ <= ]]> '3'
+                <if test="id != null">
+                    and p.id = #{id}
+                </if>
+                union
+                select 0 as num1 , count(distinct p.id) as num2,0 as num3,0 as num4 from imcs_tenant_productionresource p left join bt_equ_barrel b on b.equ_id = p.id
+                where p.status = '1' and  b.barrel_type <![CDATA[ <= ]]> '3' and  TIMESTAMPDIFF(DAY, now(), b.expr_time) <![CDATA[ < ]]> 0
+                <if test="id != null">
+                    and p.id = #{id}
+                </if>
+                union
+                select 0 as num1 ,0 as num2, count(distinct p.id) as num3,0 as num4 from imcs_tenant_productionresource p left join bt_equ_barrel b on b.equ_id = p.id
+                where p.status = '1' and b.residue_warn>=b.mtr_residue and b.barrel_type>'3'
+                <if test="id != null">
+                    and p.id = #{id}
+                </if>
+                union
+                select 0 as num1 ,0 as num2,  0 as num3, count(distinct p.id) as num4 from imcs_tenant_productionresource p left join bt_equ_barrel b on b.equ_id = p.id
+                where p.status = '1' and TIMESTAMPDIFF(DAY, now(), b.expr_time) <![CDATA[ < ]]> 0  and b.barrel_type>'3'
+                <if test="id != null">
+                    and p.id = #{id}
+                </if>
+             )s
+    </select>
+
 </mapper>