|
@@ -1,9 +1,11 @@
|
|
|
package com.usky.fire.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.itextpdf.text.*;
|
|
|
import com.itextpdf.text.pdf.BaseFont;
|
|
|
import com.itextpdf.text.pdf.PdfPCell;
|
|
@@ -15,6 +17,7 @@ import com.usky.fire.mapper.ReportIndexResultMapper;
|
|
|
import com.usky.fire.service.*;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.fire.service.config.pdf.MyHeaderFooter;
|
|
|
+import com.usky.fire.service.util.OnlineMethod;
|
|
|
import com.usky.fire.service.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -24,6 +27,7 @@ import java.io.FileOutputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.List;
|
|
@@ -68,34 +72,33 @@ public class ReportIndexResultServiceImpl extends AbstractCrudService<ReportInde
|
|
|
private DemFireStatisticsService demFireStatisticsService;
|
|
|
@Autowired
|
|
|
private ReportResultService reportResultService;
|
|
|
+ @Autowired
|
|
|
+ private BaseCompanyAttach1Service baseCompanyAttach1Service;
|
|
|
|
|
|
@Override
|
|
|
public void reportIndexResult() {
|
|
|
try {
|
|
|
- List<BaseCompany> baseCompanies = baseCompanyService.companyIdByTypeList("4");
|
|
|
+ List<BaseCompany> baseCompanies = baseCompanyService.companyIdByTypeList("1");
|
|
|
if (CollectionUtils.isNotEmpty(baseCompanies)) {
|
|
|
Calendar now = Calendar.getInstance();
|
|
|
LocalDate date=LocalDate.now();
|
|
|
LocalDateTime dateTime=LocalDateTime.now();
|
|
|
for (int i = 0; i < baseCompanies.size(); i++) {
|
|
|
// 1.新建document对象
|
|
|
- Document document = new Document(PageSize.A4);// 建立一个Document对象
|
|
|
-
|
|
|
-// 2.建立一个书写器(Writer)与document对象关联
|
|
|
-// File file =
|
|
|
-// new File("/var/www/usky-file/"+now.get(Calendar.YEAR)+"0"+now.get(Calendar.MONTH+1)+"/"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+".pdf");
|
|
|
- File file = new File("D:\\"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+".pdf");
|
|
|
- file.createNewFile();
|
|
|
- PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
|
|
|
-// writer.setPageEvent(new Watermark("hello word"));// 水印
|
|
|
- writer.setPageEvent(new MyHeaderFooter());// 页眉/页脚
|
|
|
- // 3.打开文档
|
|
|
- document.open();
|
|
|
- document.addTitle("fire report");// 标题
|
|
|
- document.addAuthor("mhzd");// 作者
|
|
|
-// document.addSubject("Subject@iText pdf sample");// 主题
|
|
|
-// document.addKeywords("Keywords@iTextpdf");// 关键字
|
|
|
-// document.addCreator("Creator@umiz`s");// 创建者
|
|
|
+// Document document = new Document(PageSize.A4);// 建立一个Document对象
|
|
|
+//
|
|
|
+//// 2.建立一个书写器(Writer)与document对象关联
|
|
|
+//// File file =
|
|
|
+//// new File("/var/www/usky-file/"+now.get(Calendar.YEAR)+"0"+now.get(Calendar.MONTH+1)+"/"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+".pdf");
|
|
|
+// File file = new File("D:\\"+now.get(Calendar.YEAR)+now.get(Calendar.MONTH)+baseCompanies.get(i).getCompanyId()+".pdf");
|
|
|
+// file.createNewFile();
|
|
|
+// PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
|
|
|
+//// writer.setPageEvent(new Watermark("hello word"));// 水印
|
|
|
+// writer.setPageEvent(new MyHeaderFooter());// 页眉/页脚
|
|
|
+// // 3.打开文档
|
|
|
+// document.open();
|
|
|
+// document.addTitle("fire report");// 标题
|
|
|
+// document.addAuthor("mhzd");// 作者
|
|
|
DemReportDataVo demReportDataVo = new DemReportDataVo();
|
|
|
demReportDataVo.setCompanyName(baseCompanies.get(i).getCompanyName());
|
|
|
demReportDataVo.setLastMonthEndTime(date.toString());
|
|
@@ -1007,8 +1010,8 @@ public class ReportIndexResultServiceImpl extends AbstractCrudService<ReportInde
|
|
|
demReportDataVo.setOverallRating("高风险");
|
|
|
}
|
|
|
}
|
|
|
- this.generatePDF(document,demReportDataVo);
|
|
|
- document.close();
|
|
|
+// this.generatePDF(document,demReportDataVo);
|
|
|
+// document.close();
|
|
|
reportResultService.save(reportResult);
|
|
|
}
|
|
|
}
|
|
@@ -1703,4 +1706,157 @@ public class ReportIndexResultServiceImpl extends AbstractCrudService<ReportInde
|
|
|
list.add(map1);
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ResultStatisticsVO> resultStatistic(Integer id, String createDate) {
|
|
|
+ List<ResultStatisticsVO> list = new ArrayList<>();
|
|
|
+ ResultStatisticsVO resultStatisticsVO = new ResultStatisticsVO();
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
+ String formattedDate = currentDate.format(formatter);
|
|
|
+ resultStatisticsVO.setHighRisk(getReportCountByScoreRange(0, 60, formattedDate).size());
|
|
|
+ resultStatisticsVO.setMildHighRisk(getReportCountByScoreRange(60, 70, formattedDate).size());
|
|
|
+ resultStatisticsVO.setNormalRisk(getReportCountByScoreRange(70, 80, formattedDate).size());
|
|
|
+ resultStatisticsVO.setLowRisk(getReportCountByScoreRange(80, 100, formattedDate).size());
|
|
|
+ list.add(resultStatisticsVO);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ReportResult> getReportCountByScoreRange(int startScore, int endScore, String createDate) {
|
|
|
+ LambdaQueryWrapper<ReportResult> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.ge(ReportResult::getOverallScore, startScore).le(ReportResult::getOverallScore, endScore)
|
|
|
+ .like(ReportResult::getCreateDate, createDate);
|
|
|
+ return reportResultService.list(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Object> riskGradeScatter(Integer riskGrade) {
|
|
|
+ List<Object> list10 = new ArrayList<>();
|
|
|
+ String streetTown = "";
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
+ String formattedDate = currentDate.format(formatter);
|
|
|
+ List<ReportResult> highRiskList = new ArrayList<>();
|
|
|
+ if (riskGrade.equals(1)) {
|
|
|
+ highRiskList = getReportCountByScoreRange(0, 60, formattedDate);
|
|
|
+ }else if (riskGrade.equals(2)){
|
|
|
+ highRiskList = getReportCountByScoreRange(60, 70, formattedDate);
|
|
|
+ }else if (riskGrade.equals(3)){
|
|
|
+ highRiskList = getReportCountByScoreRange(70, 80, formattedDate);
|
|
|
+ }else if (riskGrade.equals(4)){
|
|
|
+ highRiskList = getReportCountByScoreRange(80, 100, formattedDate);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(highRiskList)) {
|
|
|
+ List<Integer> idList = new ArrayList<>();
|
|
|
+ for (int a = 0; a < highRiskList.size(); a++) {
|
|
|
+ idList.add(highRiskList.get(a).getObjectId());
|
|
|
+ }
|
|
|
+ List<String> streetTownList = new ArrayList<>();
|
|
|
+ streetTownList.add("华漕镇");
|
|
|
+ streetTownList.add("新虹街道");
|
|
|
+ streetTownList.add("七宝镇");
|
|
|
+ streetTownList.add("虹桥镇");
|
|
|
+ streetTownList.add("古美路街道");
|
|
|
+ streetTownList.add("莘庄镇");
|
|
|
+ streetTownList.add("梅陇镇");
|
|
|
+ streetTownList.add("颛桥镇");
|
|
|
+ streetTownList.add("马桥镇");
|
|
|
+ streetTownList.add("江川路街道");
|
|
|
+ streetTownList.add("吴泾镇");
|
|
|
+ streetTownList.add("浦锦街道");
|
|
|
+ streetTownList.add("浦江镇");
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ IPage<BaseCompany> page = new Page<>(1, 500);
|
|
|
+ LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BaseCompany::getId, BaseCompany::getCompanyId, BaseCompany::getCompanyName,
|
|
|
+ BaseCompany::getCompanyType, BaseCompany::getLinkPhone, BaseCompany::getAddress, BaseCompany::getStreetTown)
|
|
|
+ .eq(BaseCompany::getEnable, 0)
|
|
|
+ .in(BaseCompany::getId, idList);
|
|
|
+ page = baseCompanyService.page(page, queryWrapper);
|
|
|
+ List<BaseCompany> list1 = page.getRecords();
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
+ List<String> companyIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ companyIdList.add(list1.get(i).getCompanyId());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<BaseCompanyAttach1> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(BaseCompanyAttach1::getId, BaseCompanyAttach1::getCompanyId, BaseCompanyAttach1::getLongitude,
|
|
|
+ BaseCompanyAttach1::getLatitude)
|
|
|
+ .in(BaseCompanyAttach1::getCompanyId, companyIdList);
|
|
|
+ List<BaseCompanyAttach1> list2 = baseCompanyAttach1Service.list(queryWrapper1);
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", list1.get(i).getId());
|
|
|
+ map.put("companyName", list1.get(i).getCompanyName());
|
|
|
+ String companyTypeName = null;
|
|
|
+ if (StringUtils.isNotBlank(list1.get(i).getCompanyType())) {
|
|
|
+ if (list1.get(i).getCompanyType().equals("1")) {
|
|
|
+ companyTypeName = "重点单位";
|
|
|
+ } else if (list1.get(i).getCompanyType().equals("2")) {
|
|
|
+ companyTypeName = "一般单位";
|
|
|
+ } else if (list1.get(i).getCompanyType().equals("3")) {
|
|
|
+ companyTypeName = "九小场所";
|
|
|
+ } else if (list1.get(i).getCompanyType().equals("9")) {
|
|
|
+ companyTypeName = "其他单位";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("companyTypeName", companyTypeName);
|
|
|
+ map.put("companyId", list1.get(i).getCompanyId());
|
|
|
+ map.put("linkPhone", list1.get(i).getLinkPhone());
|
|
|
+ map.put("address", list1.get(i).getAddress());
|
|
|
+ map.put("longitude", null);
|
|
|
+ map.put("latitude", null);
|
|
|
+ map.put("streetTown", null);
|
|
|
+ for (int j = 0; j < list2.size(); j++) {
|
|
|
+ if (list1.get(i).getCompanyId().equals(list2.get(j).getCompanyId())) {
|
|
|
+ String longitude = null;
|
|
|
+ String latitude = null;
|
|
|
+ if ((StringUtils.isBlank(list2.get(j).getLongitude()) && StringUtils.isNotBlank(list1.get(i).getAddress()))) {
|
|
|
+ List<LocateInfo> lonLat = OnlineMethod.getLonLat(list1.get(i).getAddress());
|
|
|
+ if (CollectionUtils.isNotEmpty(lonLat)) {
|
|
|
+ if (StringUtils.isBlank(list2.get(j).getLongitude()) && StringUtils.isBlank(list2.get(j).getLatitude())) {
|
|
|
+ longitude = "" + lonLat.get(0).getLongitude();
|
|
|
+ latitude = "" + lonLat.get(0).getLatitude();
|
|
|
+ } else {
|
|
|
+ longitude = list2.get(j).getLongitude();
|
|
|
+ latitude = list2.get(j).getLatitude();
|
|
|
+ }
|
|
|
+ String location = longitude + "," + latitude;
|
|
|
+ String streetTown2 = OnlineMethod.getStreetTown(location);
|
|
|
+ if (StringUtils.isBlank(list1.get(i).getStreetTown())) {
|
|
|
+ streetTown = streetTown2;
|
|
|
+ } else {
|
|
|
+ streetTown = list1.get(i).getStreetTown();
|
|
|
+ }
|
|
|
+ baseCompanyService.updateCompany1(list1.get(i).getId(), list2.get(j).getId(), longitude, latitude, streetTown);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ longitude = list2.get(j).getLongitude();
|
|
|
+ latitude = list2.get(j).getLatitude();
|
|
|
+ streetTown = list1.get(i).getStreetTown();
|
|
|
+ }
|
|
|
+ map.put("streetTown", streetTown);
|
|
|
+ map.put("longitude", longitude);
|
|
|
+ map.put("latitude", latitude);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (map.get("longitude") != null && map.get("latitude") != null && map.get("streetTown") != null) {
|
|
|
+ String streetTown1 = map.get("streetTown").toString();
|
|
|
+ if (streetTownList.contains(streetTown1)) {
|
|
|
+ if (StringUtils.isNotBlank(streetTown)) {
|
|
|
+ if (streetTown.equals(map.get("streetTown").toString())) {
|
|
|
+ list10.add(map);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list10.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list10;
|
|
|
+ }
|
|
|
+
|
|
|
}
|