|
@@ -19,11 +19,13 @@ import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.iot.domain.*;
|
|
import com.usky.iot.domain.*;
|
|
import com.usky.iot.mapper.DmpProductInfoMapper;
|
|
import com.usky.iot.mapper.DmpProductInfoMapper;
|
|
import com.usky.iot.service.*;
|
|
import com.usky.iot.service.*;
|
|
|
|
+import com.usky.iot.service.config.IntegerUtils;
|
|
import com.usky.iot.service.vo.DmpProductInfoRequest;
|
|
import com.usky.iot.service.vo.DmpProductInfoRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -267,7 +269,7 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
if (CollectionUtil.isNotEmpty(productIds2)){
|
|
if (CollectionUtil.isNotEmpty(productIds2)){
|
|
QueryWrapper<DmpDeviceStatus> query1 = Wrappers.query();
|
|
QueryWrapper<DmpDeviceStatus> query1 = Wrappers.query();
|
|
- query1.select("product_id as productId","count(*) as count","count(device_status != 1) as " +
|
|
|
|
|
|
+ query1.select("product_id as productId","count(*) as count","count(device_status != 1 or null) as " +
|
|
"faultCount")
|
|
"faultCount")
|
|
.in("product_id",productIds2)
|
|
.in("product_id",productIds2)
|
|
.groupBy("product_id");
|
|
.groupBy("product_id");
|
|
@@ -282,4 +284,45 @@ public class DmpProductInfoServiceImpl extends AbstractCrudService<DmpProductInf
|
|
}
|
|
}
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @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)){
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ list2.add(map);
|
|
|
|
+ return list2;
|
|
|
|
+ }
|
|
}
|
|
}
|