|
@@ -3,6 +3,7 @@ package org.springblade.business.controller;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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.extension.plugins.pagination.Page;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@@ -21,13 +22,15 @@ import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
+import org.springblade.business.dto.TrialSeleInspectionRecordBaseInfoDTO;
|
|
|
import org.springblade.business.dto.TrialSummaryRecordDTO;
|
|
|
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.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.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
@@ -36,16 +39,16 @@ import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
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.vo.NewBladeFile;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springblade.system.entity.Dict;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -156,7 +159,8 @@ public class TrialSummaryController {
|
|
|
vo.setClassIdName(classificationConfigurationMap.get(obj.getClassId()).getClassName());
|
|
|
vo.setDetectionTypeName(dictMap.get(obj.getDetectionType().toString()).getDictValue());
|
|
|
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;
|
|
|
}).collect(Collectors.toList());
|
|
|
page.setRecords(collect);
|
|
@@ -191,6 +195,7 @@ public class TrialSummaryController {
|
|
|
.in(TrialSelfInspectionRecord::getNodeId, Func.toLongList(classC.getTrialTreeIds()))
|
|
|
.eq(TrialSelfInspectionRecord::getContractId, dto.getContractId())
|
|
|
.eq(TrialSelfInspectionRecord::getDetectionCategory, dto.getDetectionType())
|
|
|
+ .eq(TrialSelfInspectionRecord::getType, dto.getUnitType())
|
|
|
.between(TrialSelfInspectionRecord::getReportDate, startDate, endDate)
|
|
|
);
|
|
|
if (records.size() <= 0) {
|
|
@@ -208,6 +213,7 @@ public class TrialSummaryController {
|
|
|
|
|
|
/*构造实体数据map*/
|
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
|
+ List<Map<String, Object>> trialTableData = trialSelfInspectionRecordServiceImpl.getTrialTableData(recordIds);
|
|
|
for (Map.Entry<String, List<TrialSummaryExcelTabReflection>> entry : maps.entrySet()) {
|
|
|
String tabName = entry.getKey().split("###")[0];
|
|
|
String tabPkeyId = entry.getKey().split("###")[1];
|
|
@@ -215,9 +221,17 @@ public class TrialSummaryController {
|
|
|
List<TrialSummaryExcelTabReflection> value = entry.getValue();
|
|
|
Map<String, List<TrialSummaryExcelTabReflection>> elementKeyWithHtmlKeyNameMap = value.stream().collect(Collectors.groupingBy(TrialSummaryExcelTabReflection::getElementKey));
|
|
|
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) + " FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
+ tabDataList = jdbcTemplate.queryForList(sql_3);
|
|
|
+ }
|
|
|
if (tabDataList.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
@@ -329,7 +343,7 @@ public class TrialSummaryController {
|
|
|
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);
|
|
|
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) {
|
|
|
NewBladeFile newBladeFile = newIOSSClient.excelToPdfs(files);
|
|
|
if (newBladeFile != null) {
|
|
@@ -381,7 +395,7 @@ public class TrialSummaryController {
|
|
|
* @return
|
|
|
* @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分页分组*/
|
|
|
Map<String, List<Map.Entry<String, String>>> groupedByPageSize = indexMap.entrySet().stream()
|
|
|
.collect(Collectors.groupingBy(entry -> {
|
|
@@ -390,7 +404,9 @@ public class TrialSummaryController {
|
|
|
}));
|
|
|
|
|
|
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*/
|
|
|
for (Map.Entry<String, List<Map.Entry<String, String>>> page : groupedByPageSize.entrySet()) {
|
|
|
InputStream modInput = CommonUtil.getOSSInputStream(fileUrl);
|
|
@@ -416,6 +432,47 @@ public class TrialSummaryController {
|
|
|
/*根据位置信息,将value写入excel*/
|
|
|
mergeAndCenterCells(sheet, x1, x2, y1, y2, value);
|
|
|
}
|
|
|
+ //标题添加
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+ int all = 0;
|
|
|
+ List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();
|
|
|
+ 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 = sheet.getMergedRegion(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()) {
|
|
|
workbook.write(byteArrayOutputStream);
|