|
@@ -2,18 +2,26 @@ 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.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
-import com.usky.fire.domain.DemFireAccidentDesc;
|
|
|
+import com.usky.fire.domain.DemFileLabel;
|
|
|
import com.usky.fire.domain.DemFireStatistics;
|
|
|
+import com.usky.fire.domain.DemFireStatisticsAttach;
|
|
|
import com.usky.fire.mapper.DemFireStatisticsMapper;
|
|
|
+import com.usky.fire.service.DemFileLabelService;
|
|
|
+import com.usky.fire.service.DemFireStatisticsAttachService;
|
|
|
import com.usky.fire.service.DemFireStatisticsService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -26,19 +34,115 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class DemFireStatisticsServiceImpl extends AbstractCrudService<DemFireStatisticsMapper, DemFireStatistics> implements DemFireStatisticsService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DemFireStatisticsAttachService demFireStatisticsAttachService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DemFileLabelService demFileLabelService;
|
|
|
+
|
|
|
@Override
|
|
|
- public CommonPage<DemFireStatistics> fireAccidentStatistic(String companyCode, String startDate, String endDate, Integer pageNum, Integer pageSize) {
|
|
|
+ public CommonPage<Object> fireAccidentStatistic(String fireNumber, Integer labelId, Integer classifyId, Integer pageNum, Integer pageSize) {
|
|
|
IPage<DemFireStatistics> page = new Page<>(pageNum, pageSize);
|
|
|
LambdaQueryWrapper<DemFireStatistics> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.select(DemFireStatistics::getBurnedArea, DemFireStatistics::getDirectPropertyLoss, DemFireStatistics::getVictimNumber,
|
|
|
DemFireStatistics::getInjuredNumber, DemFireStatistics::getDeathToll, DemFireStatistics::getFileCase, DemFireStatistics::getFireGrade,
|
|
|
DemFireStatistics::getSubordinateDetachment, DemFireStatistics::getAdministrativeDivision, DemFireStatistics::getFireNumber,
|
|
|
- DemFireStatistics::getFireAddress, DemFireStatistics::getFireTime, DemFireStatistics::getId)
|
|
|
- .eq(StringUtils.isNotBlank(companyCode), DemFireStatistics::getCompanyCode, companyCode)
|
|
|
- .between(StringUtils.isNotBlank(startDate) & StringUtils.isNotBlank(endDate), DemFireStatistics::getFillTime, startDate, endDate)
|
|
|
+ DemFireStatistics::getFireAddress, DemFireStatistics::getFireTime, DemFireStatistics::getId, DemFireStatistics::getLabelId,
|
|
|
+ DemFireStatistics::getClassifyId)
|
|
|
+ .like(StringUtils.isNotBlank(fireNumber), DemFireStatistics::getFireNumber, fireNumber)
|
|
|
+ .eq(labelId != null && labelId != 0, DemFireStatistics::getLabelId, labelId)
|
|
|
+ .eq(classifyId != null & classifyId != 0, DemFireStatistics::getClassifyId, classifyId)
|
|
|
.orderByDesc(DemFireStatistics::getId);
|
|
|
page = this.page(page, queryWrapper);
|
|
|
- return new CommonPage<>(page.getRecords(), page.getTotal(), pageSize, pageNum);
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ if (page.getTotal() > 0) {
|
|
|
+ List<String> fireNumberList = new ArrayList<>();
|
|
|
+ List<Integer> labelIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < page.getTotal(); i++) {
|
|
|
+ fireNumberList.add(page.getRecords().get(i).getFireNumber());
|
|
|
+ labelIdList.add(page.getRecords().get(i).getLabelId());
|
|
|
+ }
|
|
|
+ List<DemFireStatisticsAttach> demFireStatisticsAttaches = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(fireNumberList)) {
|
|
|
+ demFireStatisticsAttaches = demFireStatisticsAttachService.fireAccidentStatistic(fireNumberList);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DemFileLabel> demFileLabels = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(labelIdList)) {
|
|
|
+ demFileLabels = demFileLabelService.demFileLabelList(null, null, labelIdList);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < page.getTotal(); i++) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", page.getRecords().get(i).getId());
|
|
|
+ map.put("burnedArea", page.getRecords().get(i).getBurnedArea());
|
|
|
+ map.put("directPropertyLoss", page.getRecords().get(i).getDirectPropertyLoss());
|
|
|
+ map.put("victimNumber", page.getRecords().get(i).getVictimNumber());
|
|
|
+ map.put("injuredNumber", page.getRecords().get(i).getInjuredNumber());
|
|
|
+ map.put("deathToll", page.getRecords().get(i).getDeathToll());
|
|
|
+ map.put("fileCase", page.getRecords().get(i).getFileCase());
|
|
|
+ map.put("fireGrade", page.getRecords().get(i).getFireGrade());
|
|
|
+ map.put("subordinateDetachment", page.getRecords().get(i).getSubordinateDetachment());
|
|
|
+ map.put("administrativeDivision", page.getRecords().get(i).getAdministrativeDivision());
|
|
|
+ map.put("fireNumber", page.getRecords().get(i).getFireNumber());
|
|
|
+ map.put("fireAddress", page.getRecords().get(i).getFireAddress());
|
|
|
+ map.put("fireTime", page.getRecords().get(i).getFireTime());
|
|
|
+ map.put("labelId", page.getRecords().get(i).getLabelId());
|
|
|
+ map.put("classifyId", page.getRecords().get(i).getClassifyId());
|
|
|
+ map.put("zid", null);
|
|
|
+ map.put("fireCauseType1", null);
|
|
|
+ map.put("fireSiteType1", null);
|
|
|
+ map.put("labelName", null);
|
|
|
+ for (int j = 0; j < demFireStatisticsAttaches.size(); j++) {
|
|
|
+ if (page.getRecords().get(i).getFireNumber().equals(demFireStatisticsAttaches.get(j).getFireNumber())) {
|
|
|
+ map.put("zid", demFireStatisticsAttaches.get(j).getId());
|
|
|
+ map.put("fireCauseType1", demFireStatisticsAttaches.get(j).getFireCauseType1());
|
|
|
+ map.put("fireSiteType1", demFireStatisticsAttaches.get(j).getFireSiteType1());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int j = 0; j < demFileLabels.size(); j++) {
|
|
|
+ if (page.getRecords().get(i).getLabelId() == demFileLabels.get(j).getId()) {
|
|
|
+ map.put("labelName", demFileLabels.get(j).getLabelName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new CommonPage<>(list, page.getTotal(), pageSize, pageNum);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void addLabel(DemFileLabel demFileLabel){
|
|
|
+ if (demFileLabel.getId()==0){
|
|
|
+ demFileLabelService.addDemFileLabel(demFileLabel);
|
|
|
+ }else {
|
|
|
+ demFileLabelService.updateDemFileLabel(demFileLabel);
|
|
|
+ }
|
|
|
+ int fid = demFileLabel.getId();
|
|
|
+ List<DemFileLabel> demFileLabel1 = demFileLabel.getSubset();
|
|
|
+ if (CollectionUtils.isNotEmpty(demFileLabel1)){
|
|
|
+ List<DemFileLabel> demFileLabel2 = new ArrayList<>();
|
|
|
+ List<DemFileLabel> demFileLabel3 = new ArrayList<>();
|
|
|
+ List<Integer> idList1 = new ArrayList<>();
|
|
|
+ List<Integer> idList2 = new ArrayList<>();
|
|
|
+ for (int i = 0; i < demFileLabel1.size(); i++) {
|
|
|
+ if (demFileLabel1.get(i).getId()==0){
|
|
|
+ demFileLabel2.add(demFileLabel1.get(i));
|
|
|
+ }else {
|
|
|
+ demFileLabel3.add(demFileLabel1.get(i));
|
|
|
+ idList1.add(demFileLabel1.get(i).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<DemFileLabel> demFileLabels = demFileLabelService.demFileLabelList(fid, null, null);
|
|
|
+ if (CollectionUtils.isNotEmpty(demFileLabels)){
|
|
|
+ for (int i = 0; i < demFileLabels.size(); i++) {
|
|
|
+ idList2.add(demFileLabels.get(i).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|