Browse Source

实现缺料状态数据统计功能

oyq28 2 years ago
parent
commit
f49b530e7c

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

@@ -90,8 +90,10 @@ public class OpsAppApi {
         if (null != list.getRecords() && list.getRecords().size() > 0) {
         if (null != list.getRecords() && list.getRecords().size() > 0) {
             list.getRecords().stream().forEach(item -> {
             list.getRecords().stream().forEach(item -> {
                 Map map = productionTenantResourceService.getEquRunInfo(item.getId());
                 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() : "");
+                item.setOnlineStatus(map.containsKey("equStatus")?map.get("equStatus").toString():"0");
+                item.setErrMsg(map.containsKey("errMsg") && map.get("errMsg")!=null ?map.get("errMsg").toString():"");
+                Integer lackCount = productionTenantResourceService.getEquLockCount(item.getId());
+                item.setLackCount(lackCount);
             });
             });
         }
         }
         return R.success(list);
         return R.success(list);
@@ -135,9 +137,11 @@ public class OpsAppApi {
         if (productionResourceList.getRecords().size() > 0) {
         if (productionResourceList.getRecords().size() > 0) {
             productionResource = productionResourceList.getRecords().get(0);
             productionResource = productionResourceList.getRecords().get(0);
             Map map = productionTenantResourceService.getEquRunInfo(productionResource.getId());
             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.setOnlineStatus(map.containsKey("equStatus")?map.get("equStatus").toString():"0");
+            productionResource.setErrMsg(map.containsKey("errMsg") && map.get("errMsg")!=null ?map.get("errMsg").toString():"");
+            Integer lackCount = productionTenantResourceService.getEquLockCount(productionResource.getId());
+            productionResource.setLackCount(lackCount);
+        }else{
             productionResource = ProductionResource.builder().build();
             productionResource = ProductionResource.builder().build();
         }
         }
         return R.success(productionResource);
         return R.success(productionResource);
@@ -284,7 +288,6 @@ public class OpsAppApi {
             ).map(item -> item.getId().toString()).collect(Collectors.toList());
             ).map(item -> item.getId().toString()).collect(Collectors.toList());
         }
         }
         map.put("exceptDevice", ids.size());
         map.put("exceptDevice", ids.size());
-        map.put("lackDevice", ids.size());
         return R.success(map);
         return R.success(map);
     }
     }
 
 

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

@@ -28,4 +28,6 @@ public interface ProductionTenantResourceMapper extends SuperMapper<ProductionRe
     IPage<ProductionResource> pageList(IPage page, @Param(Constants.WRAPPER) LbqWrapper<ProductionResource> wrapper, DataScope dataScope);
     IPage<ProductionResource> pageList(IPage page, @Param(Constants.WRAPPER) LbqWrapper<ProductionResource> wrapper, DataScope dataScope);
 
 
     List<EquGoodsDto> getEquGoods(@Param("equId") Long equId);
     List<EquGoodsDto> getEquGoods(@Param("equId") Long equId);
+
+    Integer getEquLockCount(Long equId);
 }
 }

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

@@ -27,4 +27,6 @@ public interface ProductionTenantResourceService extends SuperService<Production
     HashMap<String, String> getEquRunInfo(Long equId);
     HashMap<String, String> getEquRunInfo(Long equId);
 
 
     List<String> getEquStatusIds(String onlineStatus);
     List<String> getEquStatusIds(String onlineStatus);
+
+    Integer getEquLockCount(Long equId);
 }
 }

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

@@ -72,4 +72,9 @@ public class ProductionTenantResourceServiceImpl extends SuperServiceImpl<Produc
         }).map(item->item.replace("equStatus","")).collect(Collectors.toList());
         }).map(item->item.replace("equStatus","")).collect(Collectors.toList());
         return list;
         return list;
     }
     }
+
+    @Override
+    public Integer getEquLockCount(Long equId) {
+        return baseMapper.getEquLockCount(equId);
+    }
 }
 }

+ 19 - 10
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/order/OrderMapper.xml

@@ -125,9 +125,10 @@
         sum(num5) as sevenNum,
         sum(num5) as sevenNum,
         sum(num6) as sevenAmount,
         sum(num6) as sevenAmount,
         sum(num7) as deviceNum,
         sum(num7) as deviceNum,
-        sum(num8) as yesterdayAmount
+        sum(num8) as yesterdayAmount,
+        sum(num9) as lackDevice
         from (
         from (
-        select count(1) as num1 ,0 as num2,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8 from bt_order o
+        select count(1) as num1 ,0 as num2,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from bt_order o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             where p.org_id in (${orgIds})
             where p.org_id in (${orgIds})
@@ -145,7 +146,7 @@
             and o.id = #{id}
             and o.id = #{id}
         </if>
         </if>
         union
         union
-        select 0 as num1, count(1) as num2 ,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8 from bt_order
+        select 0 as num1, count(1) as num2 ,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from bt_order
         o
         o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
@@ -159,7 +160,7 @@
         </if>
         </if>
         and o.order_status='4'
         and o.order_status='4'
         union
         union
-        select 0 as num1,0 as num2,count(1) as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8 from bt_order o
+        select 0 as num1,0 as num2,count(1) as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from bt_order o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             where p.org_id in (${orgIds})
             where p.org_id in (${orgIds})
@@ -172,7 +173,7 @@
         </if>
         </if>
         and o.order_status='4'
         and o.order_status='4'
         union
         union
-        select 0 as num1,0 as num2,0 as num3,sum(o.order_amount) as num4,0 as num5,0 as num6, 0 as num7, 0 as num8 from
+        select 0 as num1,0 as num2,0 as num3,sum(o.order_amount) as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from
         bt_order o
         bt_order o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
@@ -191,7 +192,7 @@
             and o.id = #{id}
             and o.id = #{id}
         </if>
         </if>
         union
         union
-        select 0,0,0,0,count(1) as num5,0, 0, 0 from bt_order o
+        select 0,0,0,0,count(1) as num5,0, 0, 0, 0 from bt_order o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             where p.org_id in (${orgIds})
             where p.org_id in (${orgIds})
@@ -209,7 +210,7 @@
             and o.id = #{id}
             and o.id = #{id}
         </if>
         </if>
         union
         union
-        select 0,0,0,0,0,sum(o.order_amount) as num6, 0, 0 from bt_order o
+        select 0,0,0,0,0,sum(o.order_amount) as num6, 0, 0, 0 from bt_order o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             where p.org_id in (${orgIds})
             where p.org_id in (${orgIds})
@@ -228,7 +229,7 @@
         </if>
         </if>
         and o.order_status = '1'
         and o.order_status = '1'
         union
         union
-        select 0,0,0,0,0,0, count(p.id) as num7, 0 from imcs_tenant_productionresource p where p.status = '1'
+        select 0,0,0,0,0,0, count(p.id) as num7, 0, 0 from imcs_tenant_productionresource p where p.status = '1'
         <if test="id != null">
         <if test="id != null">
             and p.id = #{id}
             and p.id = #{id}
         </if>
         </if>
@@ -236,7 +237,7 @@
             and p.org_id in (${orgIds})
             and p.org_id in (${orgIds})
         </if>
         </if>
         union
         union
-        select 0,0,0,0,0,0, 0, sum(o.order_amount) as num8 from bt_order o
+        select 0,0,0,0,0,0, 0, sum(o.order_amount) as num8 , 0 from bt_order o
         <if test="orgIds != null and orgIds != ''">
         <if test="orgIds != null and orgIds != ''">
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             left join imcs_tenant_productionresource p on o.order_equ_id = p.id
             where p.org_id in (${orgIds})
             where p.org_id in (${orgIds})
@@ -254,7 +255,15 @@
             and o.id = #{id}
             and o.id = #{id}
         </if>
         </if>
         and o.order_status = '1'
         and o.order_status = '1'
+        union
+        select 0,0,0,0,0,0, 0, 0, count(distinct p.id) 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
+        <if test="id != null">
+            and p.id = #{id}
+        </if>
+        <if test="orgIds != null and orgIds != ''">
+            and p.org_id in (${orgIds})
+        </if>
         ) f
         ) f
     </select>
     </select>
-
 </mapper>
 </mapper>

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

@@ -110,4 +110,12 @@
         Group by g.id
         Group by g.id
     </select>
     </select>
 
 
+    <select id="getEquLockCount" resultType="Integer">
+        select count(distinct p.id) 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
+        <if test="id != null">
+            and p.id = #{id}
+        </if>
+    </select>
+
 </mapper>
 </mapper>

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

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

+ 2 - 2
imcs-bt-fe/imcs-bt-fe/uni-mall/pages/device/device.vue

@@ -14,8 +14,8 @@
 					</view>					 
 					</view>					 
 				</view>
 				</view>
 				<view class="status">
 				<view class="status">
-					<text :class="item.onlineStatus==='1'? 'normal': item.onlineStatus==='2'? 'exception' : 'lack'">
-					 {{item.onlineStatus==='1'? '正常': (item.onlineStatus==='2'? '异常' : '缺料')}}
+					<text :class="item.lackCount>0? 'lack': item.onlineStatus==='1'? 'normal' : 'exception'">
+					  {{item.lackCount>0? '缺料': (item.onlineStatus==='1'? '正常': (item.onlineStatus==='2'? '异常' : '离线')) }}
 					</text>
 					</text>
 				</view>	 
 				</view>	 
 				<view class="desc">
 				<view class="desc">

+ 2 - 2
imcs-bt-fe/imcs-bt-fe/uni-mall/pages/device/deviceDetail.vue

@@ -8,8 +8,8 @@
 						<text class="name">{{device.name}}</text>
 						<text class="name">{{device.name}}</text>
 						<text class="desc">{{device.address}}</text>
 						<text class="desc">{{device.address}}</text>
 						<text class="status"
 						<text class="status"
-							:class="device.onlineStatus==='1'? 'normal': device.onlineStatus==='2'? 'exception' : 'lack'">
-							{{device.onlineStatus==='1'? '正常': (device.onlineStatus==='2'? '异常' : '缺料')}}
+							:class="device.lackCount>0? 'lack': device.onlineStatus==='1'? 'normal' : 'exception'">
+							 {{device.lackCount>0? '缺料': (device.onlineStatus==='1'? '正常': (device.onlineStatus==='2'? '异常' : '离线')) }}
 						</text>
 						</text>
 					</view>
 					</view>
 				</view>
 				</view>

+ 2 - 2
imcs-bt-fe/imcs-bt-fe/uni-mall/pages/index/index.vue

@@ -137,8 +137,8 @@
 								<text class="name">{{item.name}}</text>
 								<text class="name">{{item.name}}</text>
 								<text class="desc">{{item.address}}</text>
 								<text class="desc">{{item.address}}</text>
 								<text class="status"
 								<text class="status"
-									:class="item.onlineStatus==='1'? 'normal': item.onlineStatus==='2'? 'exception' : 'lack'">
-								 {{item.onlineStatus==='1'? '正常': (item.onlineStatus==='2'? '异常' : '缺料')}}
+									:class="item.lackCount>0? 'lack': item.onlineStatus==='1'? 'normal' : 'exception'">
+								     {{item.lackCount>0? '缺料': (item.onlineStatus==='1'? '正常': (item.onlineStatus==='2'? '异常' : '离线')) }}
 								</text>
 								</text>
 							</view>
 							</view>
 						</view>
 						</view>