Browse Source

订正:月报统计模板

zhongwei
ty 8 months ago
parent
commit
8a547eb58c
  1. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  2. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java
  3. BIN
      hzims-service/operational/src/main/resources/template/word/stationMonthReport.docx

32
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

@ -416,10 +416,10 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED); wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds); wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper); List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper);
monPhenomenonList = monPhenomenonList.stream().filter(s -> s.getDefectGrading() != null).collect(Collectors.toList()); monPhenomenonList = monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList());
List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList());
// 只填写二类及以上缺陷 // 只填写二类及以上缺陷
List<OperPhenomenonEntity> monConclusionListByDefectGrading = monConclusionList.stream().filter(s -> !"1".equals(s.getDefectGrading())).sorted(Comparator.comparing(OperPhenomenonEntity::getCreateDept).reversed().thenComparing(OperPhenomenonEntity::getDefectGrading)).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionListByDefectGrading = monConclusionList.stream().filter(s -> !"1".equals(s.getDefectLevel())).sorted(Comparator.comparing(OperPhenomenonEntity::getCreateDept).reversed().thenComparing(OperPhenomenonEntity::getDefectLevel)).collect(Collectors.toList());
// 各电站缺陷处理统计表 // 各电站缺陷处理统计表
ArrayList<HashMap<String, String>> checkList = new ArrayList<>(); ArrayList<HashMap<String, String>> checkList = new ArrayList<>();
for (OperPhenomenonEntity operPhenomenonEntity : monConclusionListByDefectGrading) { for (OperPhenomenonEntity operPhenomenonEntity : monConclusionListByDefectGrading) {
@ -432,13 +432,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("name", createDeptName.getData()); temp.put("name", createDeptName.getData());
String checkLevel=""; String checkLevel="";
if("1".equals(operPhenomenonEntity.getDefectGrading())) { if("1".equals(operPhenomenonEntity.getDefectLevel())) {
checkLevel="Ⅰ级缺陷"; checkLevel="Ⅰ级缺陷";
} }
if("2".equals(operPhenomenonEntity.getDefectGrading()) ){ if("2".equals(operPhenomenonEntity.getDefectLevel()) ){
checkLevel="Ⅱ级缺陷"; checkLevel="Ⅱ级缺陷";
} }
if("3".equals(operPhenomenonEntity.getDefectGrading()) ){ if("3".equals(operPhenomenonEntity.getDefectLevel()) ){
checkLevel="Ⅲ级缺陷"; checkLevel="Ⅲ级缺陷";
} }
temp.put("level", checkLevel); temp.put("level", checkLevel);
@ -460,7 +460,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
wrapperYear.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED); wrapperYear.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapperYear.in(OperPhenomenonEntity::getCreateDept, deptIds); wrapperYear.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> yearPhenomenonEntities = operPhenomenonService.list(wrapperYear); List<OperPhenomenonEntity> yearPhenomenonEntities = operPhenomenonService.list(wrapperYear);
yearPhenomenonEntities = yearPhenomenonEntities.stream().filter(s -> StringUtil.isNotBlank(s.getDefectGrading())).filter(s -> ObjectUtil.isNotEmpty(s.getCreateDept())).collect(Collectors.toList()); yearPhenomenonEntities = yearPhenomenonEntities.stream().filter(s -> StringUtil.isNotBlank(s.getDefectLevel())).filter(s -> ObjectUtil.isNotEmpty(s.getCreateDept())).collect(Collectors.toList());
List<OperPhenomenonEntity> yearConclusionList = yearPhenomenonEntities.stream().filter(s -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList()); List<OperPhenomenonEntity> yearConclusionList = yearPhenomenonEntities.stream().filter(s -> "1".equals(s.getConclusionStatus())).collect(Collectors.toList());
ArrayList<HashMap<String, String>> checkStatistics = new ArrayList<>(); ArrayList<HashMap<String, String>> checkStatistics = new ArrayList<>();
@ -480,7 +480,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
} else { } else {
Map<Long, Map<String, List<OperPhenomenonEntity>>> phenomenonMap = yearPhenomenonEntities.stream().collect( Map<Long, Map<String, List<OperPhenomenonEntity>>> phenomenonMap = yearPhenomenonEntities.stream().collect(
Collectors.groupingBy(OperPhenomenonEntity::getCreateDept, Collectors.groupingBy(OperPhenomenonEntity::getCreateDept,
Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading))); Collectors.groupingBy(OperPhenomenonEntity::getDefectLevel)));
for (Map.Entry<Long, Map<String, List<OperPhenomenonEntity>>> deptMapEntry : phenomenonMap.entrySet()) { for (Map.Entry<Long, Map<String, List<OperPhenomenonEntity>>> deptMapEntry : phenomenonMap.entrySet()) {
R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey()); R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey());
for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) { for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) {
@ -488,26 +488,26 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
int shortagesYear = (int) levelList.getValue().stream().filter(s -> "1".equals(s.getConclusionStatus())).count(); int shortagesYear = (int) levelList.getValue().stream().filter(s -> "1".equals(s.getConclusionStatus())).count();
double shortagesRate = 0d; double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) { if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, RoundingMode.UP).doubleValue(); shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, RoundingMode.UP).setScale(2).doubleValue();
} }
int findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); int findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelList.getKey())).count();
int shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).count(); int shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelList.getKey())).count();
CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo); checkChartRes.add(checkChartVo);
} }
} }
// 总计 // 总计
Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading)); Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectLevel));
for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) { for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) {
int findShortagesYear = levelPhenomenon.getValue().size(); int findShortagesYear = levelPhenomenon.getValue().size();
int shortagesYear = (int) Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream() int shortagesYear = (int) Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream()
.filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); .filter(s -> s.getDefectLevel().equals(levelPhenomenon.getKey())).count();
double shortagesRate = 0d; double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) { if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, RoundingMode.UP).doubleValue(); shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, RoundingMode.UP).doubleValue();
} }
int findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); int findShortagesMon = (int) Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon.getKey())).count();
int shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).count(); int shortagesMon = (int) Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon.getKey())).count();
CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo); checkChartRes.add(checkChartVo);
} }
@ -528,8 +528,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
temp.put("checkLevel", checkLevel); temp.put("checkLevel", checkLevel);
temp.put("findShortagesMon", checkChartRe.getFindShortagesMon().toString()); temp.put("findShortagesMon", checkChartRe.getFindShortagesMon().toString());
temp.put("shortagesMon", checkChartRe.getShortagesMon().toString()); temp.put("shortagesMon", checkChartRe.getShortagesMon().toString());
temp.put("findShortagesYear", checkChartRe.getShortagesYear().toString()); temp.put("findShortagesYear", checkChartRe.getFindShortagesYear().toString());
temp.put("shortagesYear", checkChartRe.getFindShortagesYear().toString()); temp.put("shortagesYear", checkChartRe.getShortagesYear().toString());
temp.put("shortagesRate", checkChartRe.getShortagesRate()* 100 + "%"); temp.put("shortagesRate", checkChartRe.getShortagesRate()* 100 + "%");
checkStatistics.add(temp); checkStatistics.add(temp);
map.put("checkStatistics", checkStatistics); map.put("checkStatistics", checkStatistics);

15
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java

@ -112,21 +112,28 @@ public abstract class WordUtils {
XWPFTable xwpfTable = tableList.get(tabIndex); XWPFTable xwpfTable = tableList.get(tabIndex);
//获取表格所有行数 //获取表格所有行数
List<XWPFTableRow> rows = xwpfTable.getRows(); List<XWPFTableRow> rows = xwpfTable.getRows();
for (int i = 0; i < rows.size(); i++) { for (int i = 0; i < rows.size()-2; i++) {
if (i==rows.size()-1){ // if (i==rows.size()-2){
continue; // continue;
} // }
XWPFTableCell cell = rows.get(i).getCell(0); XWPFTableCell cell = rows.get(i).getCell(0);
XWPFTableCell cell2 = rows.get(i+1).getCell(0); XWPFTableCell cell2 = rows.get(i+1).getCell(0);
XWPFTableCell cell3 = rows.get(i+2).getCell(0);
String text = cell.getText(); String text = cell.getText();
String text2 = cell2.getText(); String text2 = cell2.getText();
String text3 = cell3.getText();
if (text2.equals(text)){ if (text2.equals(text)){
if (text3.equals(text)){
mergeCellsVertically(xwpfTable,0,i,i+2);
i=i+1;
}else{
mergeCellsVertically(xwpfTable,0,i,i+1); mergeCellsVertically(xwpfTable,0,i,i+1);
} }
} }
} }
} }
} }
}
/** /**
* word单元格列合并 * word单元格列合并

BIN
hzims-service/operational/src/main/resources/template/word/stationMonthReport.docx

Binary file not shown.
Loading…
Cancel
Save