|
@@ -3,6 +3,7 @@ package org.springblade.business.controller;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@@ -16,18 +17,21 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddressBase;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.select.Elements;
|
|
import org.jsoup.select.Elements;
|
|
|
|
+import org.springblade.business.dto.TrialSeleInspectionRecordBaseInfoDTO;
|
|
import org.springblade.business.dto.TrialSummaryRecordDTO;
|
|
import org.springblade.business.dto.TrialSummaryRecordDTO;
|
|
import org.springblade.business.dto.TrialSummaryRecordPageDTO;
|
|
import org.springblade.business.dto.TrialSummaryRecordPageDTO;
|
|
-import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
|
-import org.springblade.business.entity.TrialSummaryRecord;
|
|
|
|
-import org.springblade.business.entity.TrialSummaryRecordDataJson;
|
|
|
|
|
|
+import org.springblade.business.entity.*;
|
|
import org.springblade.business.service.impl.TrialSelfInspectionRecordServiceImpl;
|
|
import org.springblade.business.service.impl.TrialSelfInspectionRecordServiceImpl;
|
|
import org.springblade.business.service.impl.TrialSummaryRecordServiceImpl;
|
|
import org.springblade.business.service.impl.TrialSummaryRecordServiceImpl;
|
|
|
|
+import org.springblade.business.vo.TrialRawMaterialSelfRecord;
|
|
|
|
+import org.springblade.business.vo.TrialSelfInspectionRecordVO;
|
|
|
|
+import org.springblade.business.vo.TrialSelfSample;
|
|
import org.springblade.business.vo.TrialSummaryRecordVO;
|
|
import org.springblade.business.vo.TrialSummaryRecordVO;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
import org.springblade.common.constant.CommonConstant;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
@@ -36,16 +40,16 @@ import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.utils.*;
|
|
import org.springblade.core.tool.utils.*;
|
|
-import org.springblade.manager.entity.ContractInfo;
|
|
|
|
-import org.springblade.manager.entity.ExcelTab;
|
|
|
|
-import org.springblade.manager.entity.TrialSummaryClassificationConfiguration;
|
|
|
|
-import org.springblade.manager.entity.TrialSummaryExcelTabReflection;
|
|
|
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
|
+import org.springblade.manager.vo.TrialTableDataInfo;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.resource.vo.NewBladeFile;
|
|
import org.springblade.resource.vo.NewBladeFile;
|
|
import org.springblade.system.cache.ParamCache;
|
|
import org.springblade.system.cache.ParamCache;
|
|
import org.springblade.system.entity.Dict;
|
|
import org.springblade.system.entity.Dict;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
+import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -156,7 +160,8 @@ public class TrialSummaryController {
|
|
vo.setClassIdName(classificationConfigurationMap.get(obj.getClassId()).getClassName());
|
|
vo.setClassIdName(classificationConfigurationMap.get(obj.getClassId()).getClassName());
|
|
vo.setDetectionTypeName(dictMap.get(obj.getDetectionType().toString()).getDictValue());
|
|
vo.setDetectionTypeName(dictMap.get(obj.getDetectionType().toString()).getDictValue());
|
|
vo.setSummaryDateName(obj.getStartDate() + "~" + obj.getEndDate());
|
|
vo.setSummaryDateName(obj.getStartDate() + "~" + obj.getEndDate());
|
|
- vo.setUnitTypeName(obj.getUnitType().equals(1) ? "施工" : "监理");
|
|
|
|
|
|
+ vo.setUnitTypeName(obj.getUnitType().equals(1) ? "施工" : obj.getUnitType().equals(2) ? "监理" : "业主");
|
|
|
|
+ vo.setClassIdName(vo.getClassIdName() + "(" + vo.getUnitTypeName() + ")");
|
|
return vo;
|
|
return vo;
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
page.setRecords(collect);
|
|
page.setRecords(collect);
|
|
@@ -191,12 +196,20 @@ public class TrialSummaryController {
|
|
.in(TrialSelfInspectionRecord::getNodeId, Func.toLongList(classC.getTrialTreeIds()))
|
|
.in(TrialSelfInspectionRecord::getNodeId, Func.toLongList(classC.getTrialTreeIds()))
|
|
.eq(TrialSelfInspectionRecord::getContractId, dto.getContractId())
|
|
.eq(TrialSelfInspectionRecord::getContractId, dto.getContractId())
|
|
.eq(TrialSelfInspectionRecord::getDetectionCategory, dto.getDetectionType())
|
|
.eq(TrialSelfInspectionRecord::getDetectionCategory, dto.getDetectionType())
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getType, dto.getUnitType())
|
|
|
|
+ .eq(TrialSelfInspectionRecord::getTaskStatus, "已审批")
|
|
.between(TrialSelfInspectionRecord::getReportDate, startDate, endDate)
|
|
.between(TrialSelfInspectionRecord::getReportDate, startDate, endDate)
|
|
|
|
+ .last(" order by report_date, report_no, record_no asc")
|
|
);
|
|
);
|
|
if (records.size() <= 0) {
|
|
if (records.size() <= 0) {
|
|
throw new ServiceException("未获取到该报告时间段范围内的试验自检记录信息,操作失败");
|
|
throw new ServiceException("未获取到该报告时间段范围内的试验自检记录信息,操作失败");
|
|
}
|
|
}
|
|
- List<Long> recordIds = records.stream().map(TrialSelfInspectionRecord::getId).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Long> recordIds = new ArrayList<>();
|
|
|
|
+ Map<Long, Integer> sortMap = new HashMap<>();
|
|
|
|
+ for (int i = 0; i < records.size(); i++) {
|
|
|
|
+ sortMap.put(records.get(i).getId(), i);
|
|
|
|
+ recordIds.add(records.get(i).getId());
|
|
|
|
+ }
|
|
|
|
|
|
String sql_2 = "SELECT * FROM m_trial_summary_excel_tab_reflection WHERE excel_id = ? AND class_id = ?";
|
|
String sql_2 = "SELECT * FROM m_trial_summary_excel_tab_reflection WHERE excel_id = ? AND class_id = ?";
|
|
List<TrialSummaryExcelTabReflection> excelTabReflections = jdbcTemplate.query(sql_2,
|
|
List<TrialSummaryExcelTabReflection> excelTabReflections = jdbcTemplate.query(sql_2,
|
|
@@ -208,6 +221,7 @@ public class TrialSummaryController {
|
|
|
|
|
|
/*构造实体数据map*/
|
|
/*构造实体数据map*/
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
|
|
+ List<Map<String, Object>> trialTableData = trialSelfInspectionRecordServiceImpl.getTrialTableData(recordIds);
|
|
for (Map.Entry<String, List<TrialSummaryExcelTabReflection>> entry : maps.entrySet()) {
|
|
for (Map.Entry<String, List<TrialSummaryExcelTabReflection>> entry : maps.entrySet()) {
|
|
String tabName = entry.getKey().split("###")[0];
|
|
String tabName = entry.getKey().split("###")[0];
|
|
String tabPkeyId = entry.getKey().split("###")[1];
|
|
String tabPkeyId = entry.getKey().split("###")[1];
|
|
@@ -215,96 +229,115 @@ public class TrialSummaryController {
|
|
List<TrialSummaryExcelTabReflection> value = entry.getValue();
|
|
List<TrialSummaryExcelTabReflection> value = entry.getValue();
|
|
Map<String, List<TrialSummaryExcelTabReflection>> elementKeyWithHtmlKeyNameMap = value.stream().collect(Collectors.groupingBy(TrialSummaryExcelTabReflection::getElementKey));
|
|
Map<String, List<TrialSummaryExcelTabReflection>> elementKeyWithHtmlKeyNameMap = value.stream().collect(Collectors.groupingBy(TrialSummaryExcelTabReflection::getElementKey));
|
|
Set<String> elementKeys = elementKeyWithHtmlKeyNameMap.keySet();
|
|
Set<String> elementKeys = elementKeyWithHtmlKeyNameMap.keySet();
|
|
-
|
|
|
|
- String sql_3 = "SELECT " + String.join(",", elementKeys) + " FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
|
- List<Map<String, Object>> tabDataList = jdbcTemplate.queryForList(sql_3);
|
|
|
|
|
|
+ List<Map<String, Object>> tabDataList;
|
|
|
|
+ if (TrialTableDataInfo.TBN.equals(tabName)) {
|
|
|
|
+ if (trialTableData != null && !trialTableData.isEmpty()) {
|
|
|
|
+ tabDataList = trialTableData;
|
|
|
|
+ } else {
|
|
|
|
+ tabDataList = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String sql_3 = "SELECT " + String.join(",", elementKeys) + " ,group_id FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
|
+ tabDataList = jdbcTemplate.queryForList(sql_3);
|
|
|
|
+ }
|
|
if (tabDataList.isEmpty()) {
|
|
if (tabDataList.isEmpty()) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ Map<String, List<Map<String, Object>>> dataGroupMap = tabDataList.stream().collect(Collectors.groupingBy(data -> data.get("group_id") + ""));
|
|
|
|
+ List<String> list = tabDataList.stream().map(data -> data.get("group_id") + "").sorted((o1, o2) -> {
|
|
|
|
+ int i = sortMap.get(Long.parseLong(o1));
|
|
|
|
+ int j = sortMap.get(Long.parseLong(o2));
|
|
|
|
+ return Integer.compare(i, j);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
for (String elementKey : elementKeys) {
|
|
for (String elementKey : elementKeys) {
|
|
- for (Map<String, Object> stringObjectMap : tabDataList) {
|
|
|
|
- stringObjectMap.entrySet().removeIf(obj -> obj.getValue() == null || obj.getValue().equals(""));
|
|
|
|
- Object tabData = stringObjectMap.getOrDefault(elementKey, null);
|
|
|
|
- if (ObjectUtil.isEmpty(tabData)) {
|
|
|
|
|
|
+ for (String key : list) {
|
|
|
|
+ List<Map<String, Object>> dataList = dataGroupMap.get(key);
|
|
|
|
+ if (dataList == null || dataList.isEmpty()) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
- String tabDataStr = (String) tabData;
|
|
|
|
- //跨行
|
|
|
|
- if (tabDataStr.contains("☆")) {
|
|
|
|
- String[] split = tabDataStr.split("☆");
|
|
|
|
- for (String valueRow : split) {
|
|
|
|
- String[] splitValues = valueRow.split(Pattern.quote("_^_"));
|
|
|
|
- String valueInput = splitValues[0];
|
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
|
- String keyName = elementKey + "__";
|
|
|
|
-
|
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
|
- map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
|
- } else {
|
|
|
|
- map.put(keyName, valueInput);
|
|
|
|
- }
|
|
|
|
|
|
+ for (Map<String, Object> stringObjectMap : dataList) {
|
|
|
|
+ stringObjectMap.entrySet().removeIf(obj -> obj.getValue() == null || obj.getValue().equals(""));
|
|
|
|
+ Object tabData = stringObjectMap.getOrDefault(elementKey, null);
|
|
|
|
+ if (ObjectUtil.isEmpty(tabData)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
|
- //非跨行
|
|
|
|
- if (tabDataStr.contains(".000Z]") && tabDataStr.contains("T")) {
|
|
|
|
- String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
|
- String valueInput = splitValues[0];
|
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
|
- String keyName = elementKey + "__";
|
|
|
|
-
|
|
|
|
- //范围日期
|
|
|
|
- String[] split = valueInput.split(",");
|
|
|
|
- String date_1 = split[0].trim();
|
|
|
|
- String date_2 = split[1].trim();
|
|
|
|
- LocalDateTime startTime = LocalDateTime.parse(date_1, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
- LocalDateTime endTime = LocalDateTime.parse(date_2, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
- ZonedDateTime startZonedTime = startTime.atZone(ZoneId.of("UTC"));
|
|
|
|
- ZonedDateTime endZonedTime = endTime.atZone(ZoneId.of("UTC"));
|
|
|
|
- String time_1 = startZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
- String time_2 = endZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
-
|
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
|
- map.put(keyName, existingValue + "@@@###" + time_1 + "~" + time_2);
|
|
|
|
- } else {
|
|
|
|
- map.put(keyName, time_1 + "~" + time_2);
|
|
|
|
|
|
+ String tabDataStr = (String) tabData;
|
|
|
|
+ //跨行
|
|
|
|
+ if (tabDataStr.contains("☆")) {
|
|
|
|
+ String[] split = tabDataStr.split("☆");
|
|
|
|
+ for (String valueRow : split) {
|
|
|
|
+ String[] splitValues = valueRow.split(Pattern.quote("_^_"));
|
|
|
|
+ String valueInput = splitValues[0];
|
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
|
+
|
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
|
+ map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
|
+ } else {
|
|
|
|
+ map.put(keyName, valueInput);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- } else if (tabDataStr.contains(".000Z") && tabDataStr.contains("T")) {
|
|
|
|
- String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
|
- String valueInput = splitValues[0];
|
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
|
- String keyName = elementKey + "__";
|
|
|
|
|
|
+ } else {
|
|
|
|
+ //非跨行
|
|
|
|
+ if (tabDataStr.contains(".000Z]") && tabDataStr.contains("T")) {
|
|
|
|
+ String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
|
+ String valueInput = splitValues[0];
|
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
|
+
|
|
|
|
+ //范围日期
|
|
|
|
+ String[] split = valueInput.split(",");
|
|
|
|
+ String date_1 = split[0].trim();
|
|
|
|
+ String date_2 = split[1].trim();
|
|
|
|
+ LocalDateTime startTime = LocalDateTime.parse(date_1, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
+ LocalDateTime endTime = LocalDateTime.parse(date_2, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
+ ZonedDateTime startZonedTime = startTime.atZone(ZoneId.of("UTC"));
|
|
|
|
+ ZonedDateTime endZonedTime = endTime.atZone(ZoneId.of("UTC"));
|
|
|
|
+ String time_1 = startZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
+ String time_2 = endZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
+
|
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
|
+ map.put(keyName, existingValue + "@@@###" + time_1 + "~" + time_2);
|
|
|
|
+ } else {
|
|
|
|
+ map.put(keyName, time_1 + "~" + time_2);
|
|
|
|
+ }
|
|
|
|
|
|
- //单日期
|
|
|
|
- LocalDateTime time = LocalDateTime.parse(valueInput, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
- ZonedDateTime zonedDateTime = time.atZone(ZoneId.of("UTC"));
|
|
|
|
- String timeStr = zonedDateTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
|
|
+ } else if (tabDataStr.contains(".000Z") && tabDataStr.contains("T")) {
|
|
|
|
+ String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
|
+ String valueInput = splitValues[0];
|
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
|
+
|
|
|
|
+ //单日期
|
|
|
|
+ LocalDateTime time = LocalDateTime.parse(valueInput, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
+ ZonedDateTime zonedDateTime = time.atZone(ZoneId.of("UTC"));
|
|
|
|
+ String timeStr = zonedDateTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
|
+
|
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
|
+ map.put(keyName, existingValue + "@@@###" + timeStr);
|
|
|
|
+ } else {
|
|
|
|
+ map.put(keyName, timeStr);
|
|
|
|
+ }
|
|
|
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
|
- map.put(keyName, existingValue + "@@@###" + timeStr);
|
|
|
|
} else {
|
|
} else {
|
|
- map.put(keyName, timeStr);
|
|
|
|
- }
|
|
|
|
|
|
+ String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
|
+ String valueInput = splitValues[0];
|
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
|
+
|
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
|
+ map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
|
+ } else {
|
|
|
|
+ map.put(keyName, valueInput);
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
- String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
|
- String valueInput = splitValues[0];
|
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
|
- String keyName = elementKey + "__";
|
|
|
|
-
|
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
|
- map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
|
- } else {
|
|
|
|
- map.put(keyName, valueInput);
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -315,7 +348,7 @@ public class TrialSummaryController {
|
|
Map<String, Object> map2 = new HashMap<>();
|
|
Map<String, Object> map2 = new HashMap<>();
|
|
for(String mapKey : map.keySet()){
|
|
for(String mapKey : map.keySet()){
|
|
for(TrialSummaryExcelTabReflection data: excelTabReflections){
|
|
for(TrialSummaryExcelTabReflection data: excelTabReflections){
|
|
- if(mapKey.equals((data.getElementKey()+"__"))){
|
|
|
|
|
|
+ if(mapKey.equals(data.getElementKey() + "__" + data.getTrialTabId())){
|
|
map2.put(data.getHtmlKeyName().split("__")[0]+"__",map.get(mapKey));
|
|
map2.put(data.getHtmlKeyName().split("__")[0]+"__",map.get(mapKey));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -327,7 +360,7 @@ public class TrialSummaryController {
|
|
if (indexMap.size() > 0) {
|
|
if (indexMap.size() > 0) {
|
|
ExcelTab excelTab = jdbcTemplate.query("SELECT file_url FROM m_excel_tab WHERE id = ?", new Object[]{classC.getExcelId()}, new BeanPropertyRowMapper<>(ExcelTab.class)).stream().findAny().orElse(null);
|
|
ExcelTab excelTab = jdbcTemplate.query("SELECT file_url FROM m_excel_tab WHERE id = ?", new Object[]{classC.getExcelId()}, new BeanPropertyRowMapper<>(ExcelTab.class)).stream().findAny().orElse(null);
|
|
if (excelTab != null) {
|
|
if (excelTab != null) {
|
|
- List<MultipartFile> files = this.writeDataToMultipartFile(excelTab.getFileUrl(), indexMap);
|
|
|
|
|
|
+ List<MultipartFile> files = this.writeDataToMultipartFile(excelTab.getFileUrl(), indexMap, dto.getContractId());
|
|
if (files.size() > 0) {
|
|
if (files.size() > 0) {
|
|
NewBladeFile newBladeFile = newIOSSClient.excelToPdfs(files);
|
|
NewBladeFile newBladeFile = newIOSSClient.excelToPdfs(files);
|
|
if (newBladeFile != null) {
|
|
if (newBladeFile != null) {
|
|
@@ -379,7 +412,7 @@ public class TrialSummaryController {
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- private List<MultipartFile> writeDataToMultipartFile(String fileUrl, Map<String, String> indexMap) throws Exception {
|
|
|
|
|
|
+ private List<MultipartFile> writeDataToMultipartFile(String fileUrl, Map<String, String> indexMap, Long contractId) throws Exception {
|
|
/*pageSize分页分组*/
|
|
/*pageSize分页分组*/
|
|
Map<String, List<Map.Entry<String, String>>> groupedByPageSize = indexMap.entrySet().stream()
|
|
Map<String, List<Map.Entry<String, String>>> groupedByPageSize = indexMap.entrySet().stream()
|
|
.collect(Collectors.groupingBy(entry -> {
|
|
.collect(Collectors.groupingBy(entry -> {
|
|
@@ -388,7 +421,9 @@ public class TrialSummaryController {
|
|
}));
|
|
}));
|
|
|
|
|
|
List<MultipartFile> files = new LinkedList<>();
|
|
List<MultipartFile> files = new LinkedList<>();
|
|
-
|
|
|
|
|
|
+ List<String> query = jdbcTemplate.query("select project_name from m_project_info a left join m_contract_info b on a.id = b.p_id where b.id =" + contractId, new SingleColumnRowMapper<>(String.class));
|
|
|
|
+ String projectName = query.isEmpty()? "" : query.get(0);
|
|
|
|
+ indexMap.put("projectName", projectName);
|
|
/*每一页视为一份新excel*/
|
|
/*每一页视为一份新excel*/
|
|
for (Map.Entry<String, List<Map.Entry<String, String>>> page : groupedByPageSize.entrySet()) {
|
|
for (Map.Entry<String, List<Map.Entry<String, String>>> page : groupedByPageSize.entrySet()) {
|
|
InputStream modInput = CommonUtil.getOSSInputStream(fileUrl);
|
|
InputStream modInput = CommonUtil.getOSSInputStream(fileUrl);
|
|
@@ -414,6 +449,48 @@ public class TrialSummaryController {
|
|
/*根据位置信息,将value写入excel*/
|
|
/*根据位置信息,将value写入excel*/
|
|
mergeAndCenterCells(sheet, x1, x2, y1, y2, value);
|
|
mergeAndCenterCells(sheet, x1, x2, y1, y2, value);
|
|
}
|
|
}
|
|
|
|
+ //标题添加
|
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
|
+ int all = 0;
|
|
|
|
+ List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();
|
|
|
|
+ mergedRegions.sort(Comparator.comparingInt(CellRangeAddressBase::getFirstRow));
|
|
|
|
+ int xle = Math.min(mergedRegions.size(), 10);
|
|
|
|
+ for (int i = 0; i < xle; i++) {
|
|
|
|
+ CellRangeAddress mergedCell = sheet.getMergedRegion(i);
|
|
|
|
+ int xx = mergedCell.getLastColumn();
|
|
|
|
+ if (xx >= all) {
|
|
|
|
+ all = xx;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < xle; i++) {
|
|
|
|
+ CellRangeAddress mergedCell = mergedRegions.get(i);
|
|
|
|
+ int xx = mergedCell.getLastColumn() + 2;
|
|
|
|
+ if (xx >= all) {
|
|
|
|
+ int fisRow = mergedCell.getFirstRow();
|
|
|
|
+ int firsrCol = mergedCell.getFirstColumn();
|
|
|
|
+ Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
|
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
+ Font oldfontAt = workbook.getFontAt(fontIndex);
|
|
|
|
+ Font redFont = workbook.createFont();
|
|
|
|
+ redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
|
|
|
|
+ redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
|
|
+ CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
|
+ newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
+ short fontHeightInPoints = redFont.getFontHeightInPoints();
|
|
|
|
+ if (fontHeightInPoints >= 10 && StringUtils.isBlank(cell.getStringCellValue()) && fisRow <= 8) {
|
|
|
|
+ String title = indexMap.get("projectName");
|
|
|
|
+ if (title.length() >= 30) {
|
|
|
|
+ sheet.getRow(fisRow).setHeight((short) 900);
|
|
|
|
+ newStyle.setWrapText(true);
|
|
|
|
+ }
|
|
|
|
+ redFont.setBold(true);
|
|
|
|
+ newStyle.setFont(redFont);
|
|
|
|
+ cell.setCellStyle(newStyle);
|
|
|
|
+ cell.setCellValue(title);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
|
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
|
workbook.write(byteArrayOutputStream);
|
|
workbook.write(byteArrayOutputStream);
|
|
@@ -567,10 +644,11 @@ public class TrialSummaryController {
|
|
|
|
|
|
if (sortedElements.size() < data.length) {
|
|
if (sortedElements.size() < data.length) {
|
|
/*html输入框数量 < 试验自检实体数据 ,存在多页,需翻页*/
|
|
/*html输入框数量 < 试验自检实体数据 ,存在多页,需翻页*/
|
|
- int countInputAdd = data.length - sortedElements.size();
|
|
|
|
- /*每页需要sortedElements.size()个输入框,共需要countPage页*/
|
|
|
|
- int countPage = (countInputAdd + sortedElements.size()) / sortedElements.size();
|
|
|
|
- countPage += (countInputAdd + sortedElements.size() - 1) % sortedElements.size() > 0 ? 1 : 0;
|
|
|
|
|
|
+// int countInputAdd = data.length - sortedElements.size();
|
|
|
|
+// /*每页需要sortedElements.size()个输入框,共需要countPage页*/
|
|
|
|
+// int countPage = (countInputAdd + sortedElements.size()) / sortedElements.size();
|
|
|
|
+// countPage += (countInputAdd + sortedElements.size() - 1) % sortedElements.size() > 0 ? 1 : 0;
|
|
|
|
+ int countPage = data.length % sortedElements.size() == 0 ? data.length / sortedElements.size() : data.length / sortedElements.size() + 1;
|
|
|
|
|
|
List<Element> sortedElementsAll = new LinkedList<>();
|
|
List<Element> sortedElementsAll = new LinkedList<>();
|
|
for (int i = 0; i < countPage; i++) {
|
|
for (int i = 0; i < countPage; i++) {
|