|
@@ -7,16 +7,11 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
+import com.usky.common.core.util.Arith;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
-import com.usky.fire.domain.BaseCompany;
|
|
|
-import com.usky.fire.domain.BaseDevice;
|
|
|
-import com.usky.fire.domain.BaseDeviceStatus;
|
|
|
-import com.usky.fire.domain.DemCase;
|
|
|
+import com.usky.fire.domain.*;
|
|
|
import com.usky.fire.mapper.DemCaseMapper;
|
|
|
-import com.usky.fire.service.BaseCompanyService;
|
|
|
-import com.usky.fire.service.BaseDeviceService;
|
|
|
-import com.usky.fire.service.BaseDeviceStatusService;
|
|
|
-import com.usky.fire.service.DemCaseService;
|
|
|
+import com.usky.fire.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -45,8 +40,11 @@ public class DemCaseServiceImpl extends AbstractCrudService<DemCaseMapper, DemCa
|
|
|
@Autowired
|
|
|
private BaseDeviceStatusService baseDeviceStatusService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceAjService deviceAjService;
|
|
|
+
|
|
|
@Override
|
|
|
- public CommonPage<DemCase> caseList(String streetTown, String companyName, String deviceType,Integer id, Integer pageNum, Integer pageSize) {
|
|
|
+ public CommonPage<DemCase> caseList(String streetTown, String companyName, String deviceType, Integer id, Integer pageNum, Integer pageSize) {
|
|
|
IPage<DemCase> page = new Page<>(pageNum, pageSize);
|
|
|
LambdaQueryWrapper<DemCase> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(StringUtils.isNotBlank(deviceType), DemCase::getDeviceType, deviceType)
|
|
@@ -62,33 +60,34 @@ public class DemCaseServiceImpl extends AbstractCrudService<DemCaseMapper, DemCa
|
|
|
int deviceCount = 0;
|
|
|
int onLineDeviceCount = 0;
|
|
|
int caseCount = 0;
|
|
|
- int handleCaseCount = 0;
|
|
|
+// int handleCaseCount = 0;
|
|
|
int closureCaseCount = 0;
|
|
|
List<String> deviceCodeList = this.deviceList(streetTown, companyId, 2);
|
|
|
if (CollectionUtils.isNotEmpty(deviceCodeList)) {
|
|
|
- this.deviceStatusCount(deviceCodeList, 1);
|
|
|
+ onLineDeviceCount = this.deviceStatusCount(deviceCodeList, 1);
|
|
|
}
|
|
|
deviceCount = deviceCodeList.size();
|
|
|
- caseCount = caseCount(streetTown, companyId, null);
|
|
|
- handleCaseCount = caseCount(streetTown, companyId, 2);
|
|
|
- closureCaseCount = caseCount(streetTown, companyId, 3);
|
|
|
+ caseCount = this.caseCount1(streetTown, companyId, null);
|
|
|
+// handleCaseCount = caseCount(streetTown, companyId, 2);
|
|
|
+ closureCaseCount = this.caseCount1(streetTown, companyId, 3);
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("deviceCount", deviceCount);
|
|
|
if (onLineDeviceCount != 0 && deviceCount != 0) {
|
|
|
- map.put("onLineDeviceRatio", onLineDeviceCount / deviceCount);
|
|
|
+ map.put("onLineDeviceRatio", Arith.div(onLineDeviceCount, deviceCount,2)*100 + "%");
|
|
|
} else {
|
|
|
map.put("onLineDeviceRatio", "0%");
|
|
|
}
|
|
|
-
|
|
|
- if (handleCaseCount != 0 && caseCount != 0) {
|
|
|
- map.put("handleCaseRatio", handleCaseCount / caseCount + "%");
|
|
|
- } else {
|
|
|
- map.put("handleCaseRatio", "0%");
|
|
|
- }
|
|
|
+ map.put("handleCaseRatio", "100%");
|
|
|
+// if (handleCaseCount != 0 && caseCount != 0) {
|
|
|
+// map.put("handleCaseRatio", handleCaseCount / caseCount + "%");
|
|
|
+// } else {
|
|
|
+// map.put("handleCaseRatio", "0%");
|
|
|
+// }
|
|
|
|
|
|
if (closureCaseCount != 0 && caseCount != 0) {
|
|
|
- map.put("closureCaseRatio", closureCaseCount / caseCount + "%");
|
|
|
+ double Ratio = Arith.div(closureCaseCount, caseCount, 2) * 100;
|
|
|
+ map.put("closureCaseRatio", Ratio + "%");
|
|
|
} else {
|
|
|
map.put("closureCaseRatio", "0%");
|
|
|
}
|
|
@@ -98,7 +97,7 @@ public class DemCaseServiceImpl extends AbstractCrudService<DemCaseMapper, DemCa
|
|
|
@Override
|
|
|
public Integer caseCount(String streetTown, String companyId, Integer caseFlag) {
|
|
|
List<String> companyNameList = new ArrayList<>();
|
|
|
- if (StringUtils.isNotBlank(streetTown)||StringUtils.isNotBlank(companyId)){
|
|
|
+ if (StringUtils.isNotBlank(streetTown) || StringUtils.isNotBlank(companyId)) {
|
|
|
List<BaseCompany> companyList = this.companyList(streetTown, companyId);
|
|
|
if (CollectionUtils.isNotEmpty(companyList)) {
|
|
|
for (int i = 0; i < companyList.size(); i++) {
|
|
@@ -115,11 +114,20 @@ public class DemCaseServiceImpl extends AbstractCrudService<DemCaseMapper, DemCa
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Integer caseCount1(String streetTown, String companyId, Integer caseFlag) {
|
|
|
+ LambdaQueryWrapper<DeviceAj> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(streetTown), DeviceAj::getStreet, streetTown)
|
|
|
+ .eq(caseFlag != null, DeviceAj::getAjFlag, caseFlag);
|
|
|
+ int count = deviceAjService.count(queryWrapper);
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public int deviceStatusCount(List<String> deviceCodeList, Integer deviceStatus) {
|
|
|
LambdaQueryWrapper<BaseDeviceStatus> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(CollectionUtils.isNotEmpty(deviceCodeList), BaseDeviceStatus::getDeviceCode, deviceCodeList)
|
|
|
+ queryWrapper.in(CollectionUtils.isNotEmpty(deviceCodeList), BaseDeviceStatus::getDeviceCode, deviceCodeList)
|
|
|
.eq(deviceStatus != null, BaseDeviceStatus::getDeviceStatus, deviceStatus);
|
|
|
int count = baseDeviceStatusService.count(queryWrapper);
|
|
|
return count;
|