|
@@ -288,17 +288,51 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
@Override
|
|
|
public List<Object> deviceStatusStatistic(Integer deptId,String productCode) {
|
|
|
List<Object> list2 = new ArrayList<>();
|
|
|
- QueryWrapper<DmpDeviceStatus> query = Wrappers.query();
|
|
|
- query.select("count(*) as count","COUNT(device_status=1 or null) as " +
|
|
|
- "onCount","COUNT(device_status=2 or null) as offCount")
|
|
|
- .eq(StringUtils.isNotBlank(productCode),"product_code",productCode);
|
|
|
- List<Map<String, Object>> list = dmpDeviceStatusService.listMaps(query);
|
|
|
- QueryWrapper<DmpDeviceInfo> query1 = Wrappers.query();
|
|
|
- query1.select("count(*) as count","COUNT(service_status=1 or null) as notActiveCount")
|
|
|
- .eq(StringUtils.isNotBlank(productCode),"product_code",productCode);
|
|
|
- List<Map<String, Object>> list1 = dmpDeviceInfoService.listMaps(query1);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- if (Integer.valueOf(list.get(0).get("offCount").toString()).equals(0)){
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId());
|
|
|
+ List<DmpDeviceInfo> deviceList = dmpDeviceInfoService.list(queryWrapper);
|
|
|
+ List<String> deviceIds = new ArrayList<>();
|
|
|
+ if(CollectionUtils.isNotEmpty(deviceList)){
|
|
|
+ for(int i=0;i<deviceList.size();i++){
|
|
|
+ deviceIds.add(deviceList.get(i).getDeviceId());
|
|
|
+ }
|
|
|
+ QueryWrapper<DmpDeviceStatus> query = Wrappers.query();
|
|
|
+ query.select("count(*) as count","COUNT(device_status=1 or null) as " +
|
|
|
+ "onCount","COUNT(device_status=2 or null) as offCount")
|
|
|
+ .eq(StringUtils.isNotBlank(productCode),"product_code",productCode)
|
|
|
+ .in("device_id",deviceIds);
|
|
|
+ List<Map<String, Object>> list = dmpDeviceStatusService.listMaps(query);
|
|
|
+ QueryWrapper<DmpDeviceInfo> query1 = Wrappers.query();
|
|
|
+ query1.select("count(*) as count","COUNT(service_status=1 or null) as notActiveCount")
|
|
|
+ .eq(StringUtils.isNotBlank(productCode),"product_code",productCode)
|
|
|
+ .eq("tenant_id",SecurityUtils.getTenantId());
|
|
|
+ List<Map<String, Object>> list1 = dmpDeviceInfoService.listMaps(query1);
|
|
|
+ if (Integer.valueOf(list.get(0).get("offCount").toString()).equals(0)){
|
|
|
+ map.put("count", 0);
|
|
|
+ map.put("onCount", 0);
|
|
|
+ map.put("offCount", 0);
|
|
|
+ map.put("notActiveCount", 0);
|
|
|
+ map.put("onCountBig", 0);
|
|
|
+ map.put("offCountBig", 0);
|
|
|
+ map.put("notActiveCountBig", 0);
|
|
|
+ }else {
|
|
|
+ BigDecimal onCountBig = new BigDecimal(Integer.valueOf(list.get(0).get("onCount").toString()));
|
|
|
+ BigDecimal temp = new BigDecimal(Integer.valueOf(list.get(0).get("count").toString()));
|
|
|
+ onCountBig = onCountBig.divide(temp,2,RoundingMode.HALF_UP);
|
|
|
+ BigDecimal offCountBig = new BigDecimal(Integer.valueOf(list.get(0).get("offCount").toString()));
|
|
|
+ offCountBig = offCountBig.divide(temp,2,RoundingMode.HALF_UP);
|
|
|
+ BigDecimal notActiveCountBig = new BigDecimal(Integer.valueOf(list1.get(0).get("notActiveCount").toString()));
|
|
|
+ notActiveCountBig = notActiveCountBig.divide(temp,2,RoundingMode.HALF_UP);
|
|
|
+ map.put("count", Integer.valueOf(list.get(0).get("count").toString()));
|
|
|
+ map.put("onCount", Integer.valueOf(list.get(0).get("onCount").toString()));
|
|
|
+ map.put("offCount", Integer.valueOf(list.get(0).get("offCount").toString()));
|
|
|
+ map.put("notActiveCount", Integer.valueOf(list1.get(0).get("notActiveCount").toString()));
|
|
|
+ map.put("onCountBig", onCountBig);
|
|
|
+ map.put("offCountBig", offCountBig);
|
|
|
+ map.put("notActiveCountBig", notActiveCountBig);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
map.put("count", 0);
|
|
|
map.put("onCount", 0);
|
|
|
map.put("offCount", 0);
|
|
@@ -306,21 +340,6 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
|
map.put("onCountBig", 0);
|
|
|
map.put("offCountBig", 0);
|
|
|
map.put("notActiveCountBig", 0);
|
|
|
- }else {
|
|
|
- BigDecimal onCountBig = new BigDecimal(Integer.valueOf(list.get(0).get("onCount").toString()));
|
|
|
- BigDecimal temp = new BigDecimal(Integer.valueOf(list.get(0).get("count").toString()));
|
|
|
- onCountBig = onCountBig.divide(temp,2,RoundingMode.HALF_UP);
|
|
|
- BigDecimal offCountBig = new BigDecimal(Integer.valueOf(list.get(0).get("offCount").toString()));
|
|
|
- offCountBig = offCountBig.divide(temp,2,RoundingMode.HALF_UP);
|
|
|
- BigDecimal notActiveCountBig = new BigDecimal(Integer.valueOf(list1.get(0).get("notActiveCount").toString()));
|
|
|
- notActiveCountBig = notActiveCountBig.divide(temp,2,RoundingMode.HALF_UP);
|
|
|
- map.put("count", Integer.valueOf(list.get(0).get("count").toString()));
|
|
|
- map.put("onCount", Integer.valueOf(list.get(0).get("onCount").toString()));
|
|
|
- map.put("offCount", Integer.valueOf(list.get(0).get("offCount").toString()));
|
|
|
- map.put("notActiveCount", Integer.valueOf(list1.get(0).get("notActiveCount").toString()));
|
|
|
- map.put("onCountBig", onCountBig);
|
|
|
- map.put("offCountBig", offCountBig);
|
|
|
- map.put("notActiveCountBig", notActiveCountBig);
|
|
|
}
|
|
|
list2.add(map);
|
|
|
return list2;
|