|  | @@ -1,5 +1,6 @@
 | 
	
		
			
				|  |  |  package com.usky.fire.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
	
		
			
				|  | @@ -15,6 +16,7 @@ import com.usky.fire.service.*;
 | 
	
		
			
				|  |  |  import com.usky.fire.service.util.OnlineMethod;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.text.DecimalFormat;
 | 
	
		
			
				|  |  |  import java.text.SimpleDateFormat;
 | 
	
	
		
			
				|  | @@ -51,6 +53,12 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private PatrolInspectionPlanSiteSonService patrolInspectionPlanSiteSonService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private BaseDeviceService baseDeviceService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private BaseDeviceStatusService baseDeviceStatusService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Object enterpriseAutonomy(String moduleType, String dataType) {
 | 
	
		
			
				|  |  |          LambdaQueryWrapper<BscEnterpriseAutonomy> queryWrapper = Wrappers.lambdaQuery();
 | 
	
	
		
			
				|  | @@ -95,8 +103,26 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |          return disparateData;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void enterpriseAutonomyTask() {
 | 
	
		
			
				|  |  | +        Map<String, Object>  enterpriseAutonomy = this.enterpriseAutonomyData();
 | 
	
		
			
				|  |  | +        Object iotDevice = this.iotDevice();
 | 
	
		
			
				|  |  | +        Object patrolInspection = this.patrolInspection();
 | 
	
		
			
				|  |  | +        Object streetCompany = this.streetCompany();
 | 
	
		
			
				|  |  | +        BscEnterpriseAutonomy bscEnterpriseAutonomy = new BscEnterpriseAutonomy();
 | 
	
		
			
				|  |  | +        bscEnterpriseAutonomy.setEnterpriseAutonomy(JSON.toJSONString(enterpriseAutonomy));
 | 
	
		
			
				|  |  | +        bscEnterpriseAutonomy.setIotDevice(JSON.toJSONString(iotDevice));
 | 
	
		
			
				|  |  | +        bscEnterpriseAutonomy.setPatrolInspection(JSON.toJSONString(patrolInspection));
 | 
	
		
			
				|  |  | +        bscEnterpriseAutonomy.setStreetCompany(JSON.toJSONString(streetCompany));
 | 
	
		
			
				|  |  | +        bscEnterpriseAutonomy.setRpn(enterpriseAutonomy.get("data4").toString());
 | 
	
		
			
				|  |  | +        bscEnterpriseAutonomy.setCreateTime(LocalDateTime.now());
 | 
	
		
			
				|  |  | +        this.save(bscEnterpriseAutonomy);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public Object enterpriseAutonomyData() {
 | 
	
		
			
				|  |  | +    public Map<String, Object> enterpriseAutonomyData() {
 | 
	
		
			
				|  |  |          String LastMonthDate = OnlineMethod.getLastMonth(new Date());
 | 
	
		
			
				|  |  |          DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  |          int deviceDamageCount = 20;
 | 
	
	
		
			
				|  | @@ -119,12 +145,12 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |          Double highRiskRieo = 0.00;
 | 
	
		
			
				|  |  |          Double hiddenDangerRieo = 0.00;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Double deviceDamageScore = 0.00;
 | 
	
		
			
				|  |  | -        Double fireScore = 0.00;
 | 
	
		
			
				|  |  | -        Double rectificationScore = 0.00;
 | 
	
		
			
				|  |  | -        Double buildTypeScore = 0.00;
 | 
	
		
			
				|  |  | -        Double highRiskScore = 0.00;
 | 
	
		
			
				|  |  | -        Double hiddenDangerScore = 0.00;
 | 
	
		
			
				|  |  | +//        Double deviceDamageScore = 0.00;
 | 
	
		
			
				|  |  | +//        Double fireScore = 0.00;
 | 
	
		
			
				|  |  | +//        Double rectificationScore = 0.00;
 | 
	
		
			
				|  |  | +//        Double buildTypeScore = 0.00;
 | 
	
		
			
				|  |  | +//        Double highRiskScore = 0.00;
 | 
	
		
			
				|  |  | +//        Double hiddenDangerScore = 0.00;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Double deviceDamageScore1 = 0.00;
 | 
	
		
			
				|  |  |          Double fireScore1 = 0.00;
 | 
	
	
		
			
				|  | @@ -136,62 +162,62 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |          List<Object> data1 = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (int i = 0; i < list1.size(); i++) {
 | 
	
		
			
				|  |  |              Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  | -            double sub = 0.0;
 | 
	
		
			
				|  |  | -            double div = 0.0;
 | 
	
		
			
				|  |  | +//            double sub = 0.0;
 | 
	
		
			
				|  |  | +//            double div = 0.0;
 | 
	
		
			
				|  |  |              int riskMax = Integer.parseInt(list1.get(i).getRiskMax());
 | 
	
		
			
				|  |  | -            int weightProportion = Integer.parseInt(list1.get(i).getWeightProportion());
 | 
	
		
			
				|  |  | +//            int weightProportion = Integer.parseInt(list1.get(i).getWeightProportion());
 | 
	
		
			
				|  |  |              switch (list1.get(i).getRiskId()) {
 | 
	
		
			
				|  |  |                  case 1:
 | 
	
		
			
				|  |  |                      deviceDamageRieo = Double.valueOf(df.format((float) deviceDamageCount / riskMax * 100));
 | 
	
		
			
				|  |  | -                    sub = Arith.sub(100, deviceDamageRieo);
 | 
	
		
			
				|  |  | -                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | -                    deviceDamageScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | -                    deviceDamageScore1 = Arith.div(deviceDamageScore, companyCount1);
 | 
	
		
			
				|  |  | +//                    sub = Arith.sub(100, deviceDamageRieo);
 | 
	
		
			
				|  |  | +//                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | +//                    deviceDamageScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | +                    deviceDamageScore1 = Arith.div(deviceDamageRieo, companyCount1,2);
 | 
	
		
			
				|  |  |                      map1.put("name", "设备状况指数");
 | 
	
		
			
				|  |  | -                    map1.put("value", deviceDamageScore1);
 | 
	
		
			
				|  |  | +                    map1.put("value", deviceDamageRieo);
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 2:
 | 
	
		
			
				|  |  |                      fireRieo = Double.valueOf(df.format((float) fireCount / riskMax * 100));
 | 
	
		
			
				|  |  | -                    sub = Arith.sub(100, fireRieo);
 | 
	
		
			
				|  |  | -                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | -                    fireScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | -                    fireScore1 = Arith.div(fireScore, companyCount1);
 | 
	
		
			
				|  |  | +//                    sub = Arith.sub(100, fireRieo);
 | 
	
		
			
				|  |  | +//                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | +//                    fireScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | +                    fireScore1 = Arith.div(fireRieo, companyCount1,2);
 | 
	
		
			
				|  |  |                      map1.put("name", "历史火灾指数");
 | 
	
		
			
				|  |  |                      map1.put("value", fireScore1);
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 3:
 | 
	
		
			
				|  |  |                      rectificationRieo = Double.valueOf(df.format((float) rectificationCount / riskMax * 100));
 | 
	
		
			
				|  |  | -                    sub = Arith.sub(100, rectificationRieo);
 | 
	
		
			
				|  |  | -                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | -                    rectificationScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | -                    rectificationScore1 = Arith.div(rectificationScore, companyCount1);
 | 
	
		
			
				|  |  | +//                    sub = Arith.sub(100, rectificationRieo);
 | 
	
		
			
				|  |  | +//                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | +//                    rectificationScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | +                    rectificationScore1 = Arith.div(rectificationRieo, companyCount1,2);
 | 
	
		
			
				|  |  |                      map1.put("name", "执法监管安全指数");
 | 
	
		
			
				|  |  |                      map1.put("value", rectificationScore1);
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 4:
 | 
	
		
			
				|  |  |                      buildTypeRieo = Double.valueOf(df.format((float) buildTypeCount / riskMax * 100));
 | 
	
		
			
				|  |  | -                    sub = Arith.sub(100, buildTypeRieo);
 | 
	
		
			
				|  |  | -                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | -                    buildTypeScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | -                    buildTypeScore1 = Arith.div(buildTypeScore, companyCount1);
 | 
	
		
			
				|  |  | +//                    sub = Arith.sub(100, buildTypeRieo);
 | 
	
		
			
				|  |  | +//                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | +//                    buildTypeScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | +                    buildTypeScore1 = Arith.div(buildTypeRieo, companyCount1,2);
 | 
	
		
			
				|  |  |                      map1.put("name", "建筑整体风险指");
 | 
	
		
			
				|  |  |                      map1.put("value", buildTypeScore1);
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 5:
 | 
	
		
			
				|  |  |                      highRiskRieo = Double.valueOf(df.format((float) highRiskCount / riskMax * 100));
 | 
	
		
			
				|  |  | -                    sub = Arith.sub(100, highRiskRieo);
 | 
	
		
			
				|  |  | -                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | -                    highRiskScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | -                    highRiskScore1 = Arith.div(highRiskScore, companyCount1);
 | 
	
		
			
				|  |  | +//                    sub = Arith.sub(100, highRiskRieo);
 | 
	
		
			
				|  |  | +//                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | +//                    highRiskScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | +                    highRiskScore1 = Arith.div(highRiskRieo, companyCount1,2);
 | 
	
		
			
				|  |  |                      map1.put("name", "场所行业风险指数");
 | 
	
		
			
				|  |  |                      map1.put("value", highRiskScore1);
 | 
	
		
			
				|  |  |                      break;
 | 
	
		
			
				|  |  |                  case 6:
 | 
	
		
			
				|  |  |                      hiddenDangerRieo = Double.valueOf(df.format((float) hiddenDangerCount / riskMax * 100));
 | 
	
		
			
				|  |  | -                    sub = Arith.sub(100, hiddenDangerRieo);
 | 
	
		
			
				|  |  | -                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | -                    hiddenDangerScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | -                    hiddenDangerScore1 = Arith.div(hiddenDangerScore, companyCount1);
 | 
	
		
			
				|  |  | +//                    sub = Arith.sub(100, hiddenDangerRieo);
 | 
	
		
			
				|  |  | +//                    div = Arith.div(weightProportion, 100);
 | 
	
		
			
				|  |  | +//                    hiddenDangerScore = Arith.mul(sub, div);
 | 
	
		
			
				|  |  | +                    hiddenDangerScore1 = Arith.div(hiddenDangerRieo, companyCount1,2);
 | 
	
		
			
				|  |  |                      map1.put("name", "隐患状况指数");
 | 
	
		
			
				|  |  |                      map1.put("value", hiddenDangerScore1);
 | 
	
		
			
				|  |  |                      break;
 | 
	
	
		
			
				|  | @@ -231,9 +257,9 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |          List<Object> data3 = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (int i = 0; i < list.size(); i++) {
 | 
	
		
			
				|  |  |              Map<String, Object> map3 = new HashMap<>();
 | 
	
		
			
				|  |  | -            if (!formatter.format(LocalDateTime.now()).equals(formatter.format(list.get(i + list.size() - 1).getCreateTime()))) {
 | 
	
		
			
				|  |  | -                map3.put("time", formatter.format(list.get(i + list.size() - 1).getCreateTime()));
 | 
	
		
			
				|  |  | -                map3.put("value", list.get(i + list.size() - 1).getRpn());
 | 
	
		
			
				|  |  | +            if (!formatter.format(LocalDateTime.now()).equals(formatter.format(list.get(list.size() - 1-i).getCreateTime()))) {
 | 
	
		
			
				|  |  | +                map3.put("time", formatter.format(list.get(list.size() - 1-i).getCreateTime()));
 | 
	
		
			
				|  |  | +                map3.put("value", list.get(list.size() - 1-i).getRpn());
 | 
	
		
			
				|  |  |                  data3.add(map3);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -261,10 +287,134 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  |      public Object iotDevice() {
 | 
	
		
			
				|  |  | -        return null;
 | 
	
		
			
				|  |  | +        Integer typeCount1 = 0;
 | 
	
		
			
				|  |  | +        Integer typeCount2 = 0;
 | 
	
		
			
				|  |  | +        Integer typeCount6 = 0;
 | 
	
		
			
				|  |  | +        Integer typeCount7 = 0;
 | 
	
		
			
				|  |  | +        Integer typeCount9 = 0;
 | 
	
		
			
				|  |  | +        Integer typeOffCount1 = 0;
 | 
	
		
			
				|  |  | +        Integer typeOffCount2 = 0;
 | 
	
		
			
				|  |  | +        Integer typeOffCount6 = 0;
 | 
	
		
			
				|  |  | +        Integer typeOffCount7 = 0;
 | 
	
		
			
				|  |  | +        Integer typeOffCount9 = 0;
 | 
	
		
			
				|  |  | +        LambdaQueryWrapper<BaseDevice> queryWrapper = Wrappers.lambdaQuery();
 | 
	
		
			
				|  |  | +        queryWrapper.select(BaseDevice::getDeviceCode, BaseDevice::getDeviceType)
 | 
	
		
			
				|  |  | +                .eq(BaseDevice::getEnable, 1)
 | 
	
		
			
				|  |  | +                .ne(BaseDevice::getDeviceType, 16);
 | 
	
		
			
				|  |  | +        List<BaseDevice> list1 = baseDeviceService.list(queryWrapper);
 | 
	
		
			
				|  |  | +        Integer deviceCount = list1.size();
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(list1)) {
 | 
	
		
			
				|  |  | +            List<String> deviceCode1 = new ArrayList<>();
 | 
	
		
			
				|  |  | +            List<String> deviceCode2 = new ArrayList<>();
 | 
	
		
			
				|  |  | +            List<String> deviceCode6 = new ArrayList<>();
 | 
	
		
			
				|  |  | +            List<String> deviceCode7 = new ArrayList<>();
 | 
	
		
			
				|  |  | +            List<String> deviceCode9 = new ArrayList<>();
 | 
	
		
			
				|  |  | +            for (int i = 0; i < list1.size(); i++) {
 | 
	
		
			
				|  |  | +                switch (list1.get(i).getDeviceType()) {
 | 
	
		
			
				|  |  | +                    case 1:
 | 
	
		
			
				|  |  | +                    case 3:
 | 
	
		
			
				|  |  | +                        deviceCode1.add(list1.get(i).getDeviceCode());
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case 2:
 | 
	
		
			
				|  |  | +                    case 5:
 | 
	
		
			
				|  |  | +                        deviceCode2.add(list1.get(i).getDeviceCode());
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case 6:
 | 
	
		
			
				|  |  | +                        deviceCode6.add(list1.get(i).getDeviceCode());
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case 7:
 | 
	
		
			
				|  |  | +                        deviceCode7.add(list1.get(i).getDeviceCode());
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    default:
 | 
	
		
			
				|  |  | +                        deviceCode9.add(list1.get(i).getDeviceCode());
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(deviceCode1)) {
 | 
	
		
			
				|  |  | +                typeCount1 = deviceCode1.size();
 | 
	
		
			
				|  |  | +                typeOffCount1 = this.deviceStateCount(deviceCode1, 0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(deviceCode2)) {
 | 
	
		
			
				|  |  | +                typeCount2 = deviceCode2.size();
 | 
	
		
			
				|  |  | +                typeOffCount2 = this.deviceStateCount(deviceCode2, 0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(deviceCode6)) {
 | 
	
		
			
				|  |  | +                typeCount6 = deviceCode6.size();
 | 
	
		
			
				|  |  | +                typeOffCount6 = this.deviceStateCount(deviceCode6, 0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(deviceCode7)) {
 | 
	
		
			
				|  |  | +                typeCount7 = deviceCode7.size();
 | 
	
		
			
				|  |  | +                typeOffCount7 = this.deviceStateCount(deviceCode7, 0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(deviceCode9)) {
 | 
	
		
			
				|  |  | +                typeCount9 = deviceCode9.size();
 | 
	
		
			
				|  |  | +                typeOffCount9 = this.deviceStateCount(deviceCode9, 0);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Object> data2 = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (int i = 0; i < 5; i++) {
 | 
	
		
			
				|  |  | +            Map<String, Object> map2 = new HashMap<>();
 | 
	
		
			
				|  |  | +            switch (i) {
 | 
	
		
			
				|  |  | +                case 0:
 | 
	
		
			
				|  |  | +                    map2.put("name", "火系统");
 | 
	
		
			
				|  |  | +                    map2.put("on_line", typeCount1 - typeOffCount1);
 | 
	
		
			
				|  |  | +                    map2.put("off_line", typeOffCount1);
 | 
	
		
			
				|  |  | +                    map2.put("ratio", (typeCount1 - typeOffCount1) / typeCount1 * 100 + "%");
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                case 1:
 | 
	
		
			
				|  |  | +                    map2.put("name", "水系统");
 | 
	
		
			
				|  |  | +                    map2.put("on_line", typeCount2 - typeOffCount2);
 | 
	
		
			
				|  |  | +                    map2.put("off_line", typeOffCount2);
 | 
	
		
			
				|  |  | +                    map2.put("ratio", (typeCount2 - typeOffCount2) / typeCount2 * 100 + "%");
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                case 2:
 | 
	
		
			
				|  |  | +                    map2.put("name", "RTU");
 | 
	
		
			
				|  |  | +                    map2.put("on_line", typeCount6 - typeOffCount6);
 | 
	
		
			
				|  |  | +                    map2.put("off_line", typeOffCount6);
 | 
	
		
			
				|  |  | +                    map2.put("ratio", (typeCount6 - typeOffCount6) / typeCount6 * 100 + "%");
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                case 3:
 | 
	
		
			
				|  |  | +                    map2.put("name", "电气火灾");
 | 
	
		
			
				|  |  | +                    map2.put("on_line", typeCount7 - typeOffCount7);
 | 
	
		
			
				|  |  | +                    map2.put("off_line", typeOffCount7);
 | 
	
		
			
				|  |  | +                    map2.put("ratio", (typeCount7 - typeOffCount7) / typeCount7 * 100 + "%");
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                case 4:
 | 
	
		
			
				|  |  | +                    map2.put("name", "其他");
 | 
	
		
			
				|  |  | +                    map2.put("on_line", typeCount9 - typeOffCount9);
 | 
	
		
			
				|  |  | +                    map2.put("off_line", typeOffCount9);
 | 
	
		
			
				|  |  | +                    map2.put("ratio", (typeCount9 - typeOffCount9) / typeCount9 * 100 + "%");
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            data2.add(map2);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Object> data1 = new ArrayList<>();
 | 
	
		
			
				|  |  | +        Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  | +        map1.put("name", "累计接入设备");
 | 
	
		
			
				|  |  | +        map1.put("value", deviceCount);
 | 
	
		
			
				|  |  | +        data1.add(map1);
 | 
	
		
			
				|  |  | +        Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  | +        map.put("data1", data1);
 | 
	
		
			
				|  |  | +        map.put("data2", data2);
 | 
	
		
			
				|  |  | +        return map;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public Integer deviceStateCount(List<String> deviceCodeList, Integer state) {
 | 
	
		
			
				|  |  | +        LambdaQueryWrapper<BaseDeviceStatus> queryWrapper = Wrappers.lambdaQuery();
 | 
	
		
			
				|  |  | +        queryWrapper.in(BaseDeviceStatus::getDeviceCode, deviceCodeList)
 | 
	
		
			
				|  |  | +                .eq(BaseDeviceStatus::getDeviceStatus, state);
 | 
	
		
			
				|  |  | +        int count = baseDeviceStatusService.count(queryWrapper);
 | 
	
		
			
				|  |  | +        return count;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Object patrolInspection() {
 | 
	
		
			
				|  |  |          SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
	
		
			
				|  | @@ -289,7 +439,7 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |                  startTime = format.format(timeStamp);
 | 
	
		
			
				|  |  |                  endTime = sameDay;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            List<Integer> planSonIdList1 = this.planSonIdList(startTime,endTime);
 | 
	
		
			
				|  |  | +            List<Integer> planSonIdList1 = this.planSonIdList(startTime, endTime);
 | 
	
		
			
				|  |  |              if (CollectionUtils.isNotEmpty(planSonIdList1)) {
 | 
	
		
			
				|  |  |                  undoneCount = patrolInspectionPlanSiteSonService.siteCount(planSonIdList1, 1);
 | 
	
		
			
				|  |  |                  completedCount = patrolInspectionPlanSiteSonService.siteCount(planSonIdList1, 2);
 | 
	
	
		
			
				|  | @@ -297,7 +447,7 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              for (int j = 0; j < 4; j++) {
 | 
	
		
			
				|  |  |                  Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  | -                switch (i) {
 | 
	
		
			
				|  |  | +                switch (j) {
 | 
	
		
			
				|  |  |                      case 0:
 | 
	
		
			
				|  |  |                          map1.put("name", "今日巡检次数");
 | 
	
		
			
				|  |  |                          map1.put("value", undoneCount + completedCount);
 | 
	
	
		
			
				|  | @@ -305,7 +455,12 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |                          break;
 | 
	
		
			
				|  |  |                      case 1:
 | 
	
		
			
				|  |  |                          map1.put("name", "巡检率");
 | 
	
		
			
				|  |  | -                        map1.put("value", completedCount / (undoneCount + completedCount) * 100);
 | 
	
		
			
				|  |  | +                        if (undoneCount == 0 && completedCount == 0) {
 | 
	
		
			
				|  |  | +                            map1.put("value", 0);
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            map1.put("value", completedCount / (undoneCount + completedCount) * 100);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                          map1.put("mark", "%");
 | 
	
		
			
				|  |  |                          break;
 | 
	
		
			
				|  |  |                      case 2:
 | 
	
	
		
			
				|  | @@ -329,15 +484,15 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  | -        map.put("data1",data1);
 | 
	
		
			
				|  |  | -        map.put("data2",data2);
 | 
	
		
			
				|  |  | -        map.put("data3",data3);
 | 
	
		
			
				|  |  | +        map.put("data1", data1);
 | 
	
		
			
				|  |  | +        map.put("data2", data2);
 | 
	
		
			
				|  |  | +        map.put("data3", data3);
 | 
	
		
			
				|  |  |          return map;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<Integer> planSonIdList(String startDate,String endDate) {
 | 
	
		
			
				|  |  | +    public List<Integer> planSonIdList(String startDate, String endDate) {
 | 
	
		
			
				|  |  |          List<Integer> planSonIdList = new ArrayList<>();
 | 
	
		
			
				|  |  |          LambdaQueryWrapper<PatrolInspectionPlan> queryWrapper = Wrappers.lambdaQuery();
 | 
	
		
			
				|  |  |          queryWrapper.select(PatrolInspectionPlan::getId)
 | 
	
	
		
			
				|  | @@ -367,13 +522,67 @@ public class BscEnterpriseAutonomyServiceImpl extends AbstractCrudService<BscEnt
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<Map<String, Object>> streetCompany(){
 | 
	
		
			
				|  |  | +    public Object streetCompany() {
 | 
	
		
			
				|  |  |          QueryWrapper<BaseCompany> query = Wrappers.query();
 | 
	
		
			
				|  |  | -        query.select("street_town as streetTown","count(id) as count" )
 | 
	
		
			
				|  |  | -                .eq("enable",0)
 | 
	
		
			
				|  |  | -                .ne("street_town","")
 | 
	
		
			
				|  |  | +        query.select("street_town as streetTown", "company_type as companyType", "count(id) as count")
 | 
	
		
			
				|  |  | +                .eq("enable", 0)
 | 
	
		
			
				|  |  | +                .ne("street_town", "")
 | 
	
		
			
				|  |  | +                .groupBy("street_town,company_type");
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> list1 = baseCompanyService.listMaps(query);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        QueryWrapper<BaseCompany> query1 = Wrappers.query();
 | 
	
		
			
				|  |  | +        query1.select("street_town as streetTown")
 | 
	
		
			
				|  |  | +                .eq("enable", 0)
 | 
	
		
			
				|  |  | +                .ne("street_town", "")
 | 
	
		
			
				|  |  |                  .groupBy("street_town");
 | 
	
		
			
				|  |  | -        List<Map<String, Object>> list = baseCompanyService.listMaps(query);
 | 
	
		
			
				|  |  | -        return list;
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> list2 = baseCompanyService.listMaps(query1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> stressList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> generalList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> otherList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(list1)) {
 | 
	
		
			
				|  |  | +            for (int i = 0; i < list1.size(); i++) {
 | 
	
		
			
				|  |  | +                switch (list1.get(i).get("companyType").toString()) {
 | 
	
		
			
				|  |  | +                    case "1":
 | 
	
		
			
				|  |  | +                        stressList.add(list1.get(i));
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case "2":
 | 
	
		
			
				|  |  | +                        generalList.add(list1.get(i));
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    default:
 | 
	
		
			
				|  |  | +                        otherList.add(list1.get(i));
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Object> data = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (int i = 0; i < list2.size(); i++) {
 | 
	
		
			
				|  |  | +            Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  | +            map1.put("name", list2.get(i).get("streetTown"));
 | 
	
		
			
				|  |  | +            map1.put("stress", 0);
 | 
	
		
			
				|  |  | +            map1.put("general", 0);
 | 
	
		
			
				|  |  | +            map1.put("other", 0);
 | 
	
		
			
				|  |  | +            for (int j = 0; j < stressList.size(); j++) {
 | 
	
		
			
				|  |  | +                if (list2.get(i).get("streetTown").equals(stressList.get(j).get("streetTown"))) {
 | 
	
		
			
				|  |  | +                    map1.put("stress", stressList.get(j).get("count"));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (int j = 0; j < generalList.size(); j++) {
 | 
	
		
			
				|  |  | +                if (list2.get(i).get("streetTown").equals(generalList.get(j).get("streetTown"))) {
 | 
	
		
			
				|  |  | +                    map1.put("general", generalList.get(j).get("count"));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for (int j = 0; j < otherList.size(); j++) {
 | 
	
		
			
				|  |  | +                if (list2.get(i).get("streetTown").equals(otherList.get(j).get("streetTown"))) {
 | 
	
		
			
				|  |  | +                    map1.put("other", otherList.get(j).get("count"));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            data.add(map1);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  | +        map.put("data", data);
 | 
	
		
			
				|  |  | +        return map;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |