|
@@ -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.toolkit.CollectionUtils;
|
|
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
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.BscEnterpriseScreen;
|
|
|
import com.usky.fire.domain.DemBuildScore;
|
|
|
import com.usky.fire.domain.DemBuildScoreRecord;
|
|
@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -61,6 +64,9 @@ public class BscEnterpriseScreenServiceImpl extends AbstractCrudService<BscEnter
|
|
|
@Autowired
|
|
|
private PatrolInspectionPlanSiteSonMapper patrolInspectionPlanSiteSonMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BaseCompanyService baseCompanyService;
|
|
|
+
|
|
|
@Override
|
|
|
public Object screenDataStatistic(String dataType, String moduleType) {
|
|
|
String companyId = baseUserCompanyService.companyId();
|
|
@@ -120,11 +126,72 @@ public class BscEnterpriseScreenServiceImpl extends AbstractCrudService<BscEnter
|
|
|
return disparateData;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ @Override
|
|
|
public void dataSynchro() {
|
|
|
+ List<BaseCompany> baseCompanies = baseCompanyService.companyIdList();
|
|
|
+ if (CollectionUtils.isNotEmpty(baseCompanies)) {
|
|
|
+ for (int i = 0; i < baseCompanies.size(); i++) {
|
|
|
+ Object postInspectStatistics = this.postInspectStatistics(baseCompanies.get(i).getCompanyId());
|
|
|
+ Object fireAlarmStatistics = this.fireAlarmStatistics(baseCompanies.get(i).getCompanyId());
|
|
|
+ Object reservePlanStatistics = this.reservePlanStatistics(baseCompanies.get(i).getCompanyId());
|
|
|
+ Object hiddenDangerStatistics = this.hiddenDangerStatistics(baseCompanies.get(i).getCompanyId());
|
|
|
+ Object buildScoreStatistics = this.buildScoreStatistics(baseCompanies.get(i).getCompanyId());
|
|
|
+ Object patrolInspectionStatistics = this.patrolInspectionStatistics(baseCompanies.get(i).getCompanyId());
|
|
|
+ List<BscEnterpriseScreen> list = this.bscEnterpriseScreenCount(baseCompanies.get(i).getCompanyId());
|
|
|
+ BscEnterpriseScreen bscEnterpriseScreen = new BscEnterpriseScreen();
|
|
|
+ bscEnterpriseScreen.setCompanyId(baseCompanies.get(i).getCompanyId());
|
|
|
+ bscEnterpriseScreen.setCreateTime(LocalDateTime.now());
|
|
|
+ bscEnterpriseScreen.setPatrolInspection(JSON.toJSONString(postInspectStatistics));
|
|
|
+ bscEnterpriseScreen.setPostInspect(JSON.toJSONString(patrolInspectionStatistics));
|
|
|
+ bscEnterpriseScreen.setFireAlarm(JSON.toJSONString(fireAlarmStatistics));
|
|
|
+ bscEnterpriseScreen.setReservePlan(JSON.toJSONString(reservePlanStatistics));
|
|
|
+ bscEnterpriseScreen.setHiddenDanger(JSON.toJSONString(hiddenDangerStatistics));
|
|
|
+ bscEnterpriseScreen.setBuildScore(JSON.toJSONString(buildScoreStatistics));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ bscEnterpriseScreen.setId(list.get(0).getId());
|
|
|
+ this.updateById(bscEnterpriseScreen);
|
|
|
+ } else {
|
|
|
+ this.save(bscEnterpriseScreen);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
|
|
|
+ long timeStamp = OnlineMethod.getLastPeroid(2, new Date());
|
|
|
+ String scoreDate = format.format(timeStamp);
|
|
|
+ List<DemBuildScoreRecord> list1 = demBuildScoreRecordService.demBuildScoreRecordListOne(scoreDate, null);
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ int count = demBuildScoreRecordService.demBuildScoreRecordCount(scoreDate, null, null);
|
|
|
+ int overstepCount = demBuildScoreRecordService.demBuildScoreRecordCount(scoreDate, list1.get(i).getBuildScore(), null);
|
|
|
+ double faultRatio1 = Arith.div(overstepCount, count, 2) * 100;
|
|
|
+ int faultRatio = new Double(faultRatio1).intValue();
|
|
|
+ int rank = count - overstepCount;
|
|
|
+ List<BscEnterpriseScreen> enterpriseScreensList = this.bscEnterpriseScreenCount(list1.get(i).getCompanyId());
|
|
|
+ if (CollectionUtils.isNotEmpty(enterpriseScreensList)) {
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.put("value", rank);
|
|
|
+ Map<String, Object> map2 = new HashMap<>();
|
|
|
+ map2.put("value", faultRatio);
|
|
|
+ JSONObject buildScore = JSONObject.parseObject(enterpriseScreensList.get(0).getBuildScore());
|
|
|
+ buildScore.put("data3", map1);
|
|
|
+ buildScore.put("data4", map2);
|
|
|
+ BscEnterpriseScreen bscEnterpriseScreen = new BscEnterpriseScreen();
|
|
|
+ bscEnterpriseScreen.setId(enterpriseScreensList.get(0).getId());
|
|
|
+ bscEnterpriseScreen.setBuildScore(JSON.toJSONString(buildScore));
|
|
|
+ this.updateById(bscEnterpriseScreen);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<BscEnterpriseScreen> bscEnterpriseScreenCount(String companyId) {
|
|
|
+ LambdaQueryWrapper<BscEnterpriseScreen> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BscEnterpriseScreen::getId, BscEnterpriseScreen::getBuildScore)
|
|
|
+ .eq(BscEnterpriseScreen::getCompanyId, companyId);
|
|
|
+ List<BscEnterpriseScreen> list = this.list(queryWrapper);
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public Object postInspectStatistics(String companyId) {
|
|
|
int uncharCount = postInspectService.postInspectCount(companyId, 0);
|
|
@@ -502,6 +569,7 @@ public class BscEnterpriseScreenServiceImpl extends AbstractCrudService<BscEnter
|
|
|
return map2;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public Object patrolInspectionStatistics(String companyId) {
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String sameDay = format.format(new Date());
|
|
@@ -517,10 +585,12 @@ public class BscEnterpriseScreenServiceImpl extends AbstractCrudService<BscEnter
|
|
|
startTime = sameDay;
|
|
|
endTime = sameDay;
|
|
|
} else if (i == 1) {
|
|
|
- startTime = sameDay;
|
|
|
+ long timeStamp = OnlineMethod.getLastPeroid(1, new Date());
|
|
|
+ startTime = format.format(timeStamp);
|
|
|
endTime = sameDay;
|
|
|
} else if (i == 2) {
|
|
|
- startTime = sameDay;
|
|
|
+ long timeStamp = OnlineMethod.getLastPeroid(2, new Date());
|
|
|
+ startTime = format.format(timeStamp);
|
|
|
endTime = sameDay;
|
|
|
}
|
|
|
qualifiedCount = patrolInspectionPlanSiteSonMapper.planSonSiteCout(startTime, endTime, 2);
|
|
@@ -536,7 +606,48 @@ public class BscEnterpriseScreenServiceImpl extends AbstractCrudService<BscEnter
|
|
|
seriesDataList3.add(undetectedCount);
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
+ List<String> categories = new ArrayList<>();
|
|
|
+ categories.add("合格数");
|
|
|
+ categories.add("漏检数");
|
|
|
+
|
|
|
+ List<Object> series = new ArrayList<>();
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.put("name", "数据");
|
|
|
+ map1.put("data", seriesDataList1);
|
|
|
+ series.add(map1);
|
|
|
+ Map<String, Object> data1Data = new HashMap<>();
|
|
|
+ data1Data.put("categories", categories);
|
|
|
+ data1Data.put("series", series);
|
|
|
+ Map<String, Object> map4 = new HashMap<>();
|
|
|
+ map4.put("data", data1Data);
|
|
|
+
|
|
|
+ List<Object> series1 = new ArrayList<>();
|
|
|
+ Map<String, Object> map2 = new HashMap<>();
|
|
|
+ map2.put("name", "数据");
|
|
|
+ map2.put("data", seriesDataList2);
|
|
|
+ series1.add(map2);
|
|
|
+ Map<String, Object> data2Data = new HashMap<>();
|
|
|
+ data2Data.put("categories", categories);
|
|
|
+ data2Data.put("series", series1);
|
|
|
+ Map<String, Object> map5 = new HashMap<>();
|
|
|
+ map5.put("data", data2Data);
|
|
|
+
|
|
|
+ List<Object> series2 = new ArrayList<>();
|
|
|
+ Map<String, Object> map3 = new HashMap<>();
|
|
|
+ map3.put("name", "数据");
|
|
|
+ map3.put("data", seriesDataList3);
|
|
|
+ series2.add(map3);
|
|
|
+ Map<String, Object> data3Data = new HashMap<>();
|
|
|
+ data3Data.put("categories", categories);
|
|
|
+ data3Data.put("series", series2);
|
|
|
+ Map<String, Object> map6 = new HashMap<>();
|
|
|
+ map6.put("data", data3Data);
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("data1", map4);
|
|
|
+ map.put("data2", map5);
|
|
|
+ map.put("data3", map6);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
}
|