|
@@ -5,7 +5,9 @@ import java.io.FileOutputStream;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
|
+import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -13,6 +15,8 @@ import java.util.List;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.ruoyi.common.constant.Constants;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
@@ -41,8 +45,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
* @date 2024-07-17
|
|
* @date 2024-07-17
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
-public class TSpecReportServiceImpl implements ITSpecReportService
|
|
|
|
-{
|
|
|
|
|
|
+public class TSpecReportServiceImpl implements ITSpecReportService {
|
|
@Resource
|
|
@Resource
|
|
private TSpecReportMapper tSpecReportMapper;
|
|
private TSpecReportMapper tSpecReportMapper;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -59,6 +62,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
private ITSpecdevCcService tSpecdevCcService;
|
|
private ITSpecdevCcService tSpecdevCcService;
|
|
|
|
|
|
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
|
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询特种设备报告
|
|
* 查询特种设备报告
|
|
*
|
|
*
|
|
@@ -66,8 +70,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
* @return 特种设备报告
|
|
* @return 特种设备报告
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public TSpecReport selectTSpecReportById(Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public TSpecReport selectTSpecReportById(Long id) {
|
|
return tSpecReportMapper.selectTSpecReportById(id);
|
|
return tSpecReportMapper.selectTSpecReportById(id);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -78,8 +81,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
* @return 特种设备报告
|
|
* @return 特种设备报告
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public List<TSpecReport> selectTSpecReportList(TSpecReport tSpecReport)
|
|
|
|
- {
|
|
|
|
|
|
+ public List<TSpecReport> selectTSpecReportList(TSpecReport tSpecReport) {
|
|
return tSpecReportMapper.selectTSpecReportList(tSpecReport);
|
|
return tSpecReportMapper.selectTSpecReportList(tSpecReport);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,20 +93,21 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public int insertTSpecReport(TSpecReport tSpecReport, HttpServletResponse response)
|
|
|
|
- {
|
|
|
|
|
|
+ public int insertTSpecReport(TSpecReport tSpecReport, HttpServletResponse response) {
|
|
tSpecReportMapper.insertTSpecReport(tSpecReport);
|
|
tSpecReportMapper.insertTSpecReport(tSpecReport);
|
|
try {
|
|
try {
|
|
String tempUrl = "static/word/sems/report/sems-report.xlsx"; // 模板文件
|
|
String tempUrl = "static/word/sems/report/sems-report.xlsx"; // 模板文件
|
|
// 生成的路径
|
|
// 生成的路径
|
|
- String fileDir = RuoYiConfig.getProfile() + "/" + "sems/spec-sems";
|
|
|
|
|
|
+ String fileDir = RuoYiConfig.getProfile() + "/" + "sems/spec-report";
|
|
InputStream is = null;
|
|
InputStream is = null;
|
|
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
XSSFWorkbook wb1 = new XSSFWorkbook(is);
|
|
XSSFWorkbook wb1 = new XSSFWorkbook(is);
|
|
-
|
|
|
|
SXSSFWorkbook wb = new SXSSFWorkbook(wb1, 1000);
|
|
SXSSFWorkbook wb = new SXSSFWorkbook(wb1, 1000);
|
|
// 替换excel模板数据
|
|
// 替换excel模板数据
|
|
replaceExcel(wb);
|
|
replaceExcel(wb);
|
|
|
|
+ //从下往上渲染
|
|
|
|
+ replaceExcelByHi(wb);
|
|
|
|
+ replaceExcelExpireByThreeMonth(wb);
|
|
replaceExcelExpire(wb);
|
|
replaceExcelExpire(wb);
|
|
// Save the generated file
|
|
// Save the generated file
|
|
File dir = new File(fileDir);
|
|
File dir = new File(fileDir);
|
|
@@ -113,16 +116,180 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
dir.mkdirs();
|
|
dir.mkdirs();
|
|
}
|
|
}
|
|
FileOutputStream fos = null;
|
|
FileOutputStream fos = null;
|
|
- String filePath = fileDir + "/" + tSpecReport.getId() + "semsReport.xlsx";
|
|
|
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
+ String dateStr = currentDate.format(formatter);
|
|
|
|
+ String filePath = fileDir + "/" + dateStr + "Report" + tSpecReport.getId() +".xlsx";
|
|
fos = new FileOutputStream(filePath);
|
|
fos = new FileOutputStream(filePath);
|
|
wb.write(fos);
|
|
wb.write(fos);
|
|
-
|
|
|
|
|
|
+ //
|
|
|
|
+ int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
|
|
|
+ String currentDir = StringUtils.substring(filePath, dirLastIndex);
|
|
|
|
+ String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir ;
|
|
|
|
+ tSpecReport.setReportUrl(pathFileName);
|
|
|
|
+ tSpecReport.setReportName(dateStr + "报告");
|
|
|
|
+ tSpecReportMapper.updateTSpecReport(tSpecReport);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //数量变更说明(基于与上一个月数据对比)渲染
|
|
|
|
+ private void replaceExcelByHi(SXSSFWorkbook wb) {
|
|
|
|
+ Sheet sheet;
|
|
|
|
+ if (wb instanceof SXSSFWorkbook) {
|
|
|
|
+ SXSSFWorkbook sxssfWorkbook = (SXSSFWorkbook) wb;
|
|
|
|
+ sheet = sxssfWorkbook.getXSSFWorkbook().getSheetAt(0);
|
|
|
|
+ } else {
|
|
|
|
+ sheet = wb.getSheetAt(0);
|
|
|
|
+ }
|
|
|
|
+ List<Integer> numArr = new ArrayList<>();
|
|
|
|
+ List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrqHi(new TSpecReport());
|
|
|
|
+ numArr.add(ylrqList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(ylrqList));
|
|
|
|
+ Row row = sheet.getRow(13);
|
|
|
|
+ Cell cell = row.getCell(1);
|
|
|
|
+ // 获取单元格样式
|
|
|
|
+ CellStyle originalStyle = cell.getCellStyle();
|
|
|
|
+ cell.setCellStyle(originalStyle);
|
|
|
|
+ cell.setCellValue(getDevTotal(ylrqList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgdHi(new TSpecReport());
|
|
|
|
+ numArr.add(ylgdList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(ylgdList));
|
|
|
|
+ Row row2 = sheet.getRow(13);
|
|
|
|
+ Cell cell2 = row2.getCell(4);
|
|
|
|
+ cell2.setCellValue(getDevTotal(ylgdList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> glList = tSpecReportMapper.selectExpriedGlHi(new TSpecReport());
|
|
|
|
+ numArr.add(glList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(glList));
|
|
|
|
+ Row row3 = sheet.getRow(13);
|
|
|
|
+ Cell cell3 = row3.getCell(7);
|
|
|
|
+ cell3.setCellValue(getDevTotal(glList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDtHi(new TSpecReport());
|
|
|
|
+ numArr.add(dtList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(dtList));
|
|
|
|
+ Row row4 = sheet.getRow(13);
|
|
|
|
+ Cell cell4 = row4.getCell(10);
|
|
|
|
+ cell4.setCellValue(getDevTotal(dtList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsbHi(new TSpecReport());
|
|
|
|
+ numArr.add(dzsbList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(dzsbList));
|
|
|
|
+ Row row5 = sheet.getRow(13);
|
|
|
|
+ Cell cell5 = row5.getCell(13);
|
|
|
|
+ cell5.setCellValue(getDevTotal(dzsbList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCcHi(new TSpecReport());
|
|
|
|
+ numArr.add(ccList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(ccList));
|
|
|
|
+ Row row6 = sheet.getRow(8);
|
|
|
|
+ Cell cell6 = row6.getCell(16);
|
|
|
|
+ cell6.setCellValue(getDevTotal(ccList));
|
|
|
|
+
|
|
|
|
+ int maxNum = findMaxValue(numArr);
|
|
|
|
+ int needNum = maxNum - 3 > 0 ? maxNum - 3 : 0;
|
|
|
|
+ for (int i = 0; i < needNum; i++) {
|
|
|
|
+ sheet.shiftRows(16, sheet.getLastRowNum(), 1);
|
|
|
|
+ cpoyRow(16, sheet);
|
|
|
|
+ }
|
|
|
|
+ // 合并区域从第0行第0列到第0行第3列
|
|
|
|
+ CellRangeAddress mergedRegion = new CellRangeAddress(
|
|
|
|
+ 13, // 起始行
|
|
|
|
+ needNum + 17, // 结束行
|
|
|
|
+ 0, // 起始列
|
|
|
|
+ 0 // 结束列
|
|
|
|
+ );
|
|
|
|
+ sheet.addMergedRegion(mergedRegion);
|
|
|
|
+
|
|
|
|
+ renderCell(wb,sheet,ylrqList,14,1 );
|
|
|
|
+ renderCell(wb,sheet,ylgdList,14,4);
|
|
|
|
+ renderCell(wb,sheet,glList,14,7);
|
|
|
|
+ renderCell(wb,sheet,dtList,14,10);
|
|
|
|
+ renderCell(wb,sheet,dzsbList,14,13);
|
|
|
|
+ renderCell(wb,sheet,ccList,14,16);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //三个月到期渲染
|
|
|
|
+ private void replaceExcelExpireByThreeMonth(SXSSFWorkbook wb) {
|
|
|
|
+ Sheet sheet;
|
|
|
|
+ if (wb instanceof SXSSFWorkbook) {
|
|
|
|
+ SXSSFWorkbook sxssfWorkbook = (SXSSFWorkbook) wb;
|
|
|
|
+ sheet = sxssfWorkbook.getXSSFWorkbook().getSheetAt(0);
|
|
|
|
+ } else {
|
|
|
|
+ sheet = wb.getSheetAt(0);
|
|
|
|
+ }
|
|
|
|
+ List<Integer> numArr = new ArrayList<>();
|
|
|
|
+ List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrq3(new TSpecReport());
|
|
|
|
+ numArr.add(ylrqList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(ylrqList));
|
|
|
|
+ Row row = sheet.getRow(8);
|
|
|
|
+ Cell cell = row.getCell(1);
|
|
|
|
+ // 获取单元格样式
|
|
|
|
+ CellStyle originalStyle = cell.getCellStyle();
|
|
|
|
+ cell.setCellStyle(originalStyle);
|
|
|
|
+ cell.setCellValue(getDevTotal(ylrqList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgd3(new TSpecReport());
|
|
|
|
+ numArr.add(ylgdList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(ylgdList));
|
|
|
|
+ Row row2 = sheet.getRow(8);
|
|
|
|
+ Cell cell2 = row2.getCell(4);
|
|
|
|
+ cell2.setCellValue(getDevTotal(ylgdList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> glList = tSpecReportMapper.selectExpriedGl3(new TSpecReport());
|
|
|
|
+ numArr.add(glList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(glList));
|
|
|
|
+ Row row3 = sheet.getRow(8);
|
|
|
|
+ Cell cell3 = row3.getCell(7);
|
|
|
|
+ cell3.setCellValue(getDevTotal(glList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDt3(new TSpecReport());
|
|
|
|
+ numArr.add(dtList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(dtList));
|
|
|
|
+ Row row4 = sheet.getRow(8);
|
|
|
|
+ Cell cell4 = row4.getCell(10);
|
|
|
|
+ cell4.setCellValue(getDevTotal(dtList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsb3(new TSpecReport());
|
|
|
|
+ numArr.add(dzsbList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(dzsbList));
|
|
|
|
+ Row row5 = sheet.getRow(8);
|
|
|
|
+ Cell cell5 = row5.getCell(13);
|
|
|
|
+ cell5.setCellValue(getDevTotal(dzsbList));
|
|
|
|
+
|
|
|
|
+ List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCc3(new TSpecReport());
|
|
|
|
+ numArr.add(ccList.size());
|
|
|
|
+ logger.info(JSON.toJSONString(ccList));
|
|
|
|
+ Row row6 = sheet.getRow(8);
|
|
|
|
+ Cell cell6 = row6.getCell(16);
|
|
|
|
+ cell6.setCellValue(getDevTotal(ccList));
|
|
|
|
+
|
|
|
|
+ int maxNum = findMaxValue(numArr);
|
|
|
|
+ int needNum = maxNum - 3 > 0 ? maxNum - 3 : 0;
|
|
|
|
+ for (int i = 0; i < needNum; i++) {
|
|
|
|
+ sheet.shiftRows(11, sheet.getLastRowNum(), 1);
|
|
|
|
+ cpoyRow(11, sheet);
|
|
|
|
+ }
|
|
|
|
+ // 合并区域从第0行第0列到第0行第3列
|
|
|
|
+ CellRangeAddress mergedRegion = new CellRangeAddress(
|
|
|
|
+ 8, // 起始行
|
|
|
|
+ needNum + 12, // 结束行
|
|
|
|
+ 0, // 起始列
|
|
|
|
+ 0 // 结束列
|
|
|
|
+ );
|
|
|
|
+ sheet.addMergedRegion(mergedRegion);
|
|
|
|
+
|
|
|
|
+ renderCell(wb,sheet,ylrqList,10,1 );
|
|
|
|
+ renderCell(wb,sheet,ylgdList,10,4);
|
|
|
|
+ renderCell(wb,sheet,glList,10,7);
|
|
|
|
+ renderCell(wb,sheet,dtList,10,10);
|
|
|
|
+ renderCell(wb,sheet,dzsbList,10,13);
|
|
|
|
+ renderCell(wb,sheet,ccList,10,16);
|
|
|
|
+ }
|
|
//过期渲染
|
|
//过期渲染
|
|
private void replaceExcelExpire(SXSSFWorkbook wb) {
|
|
private void replaceExcelExpire(SXSSFWorkbook wb) {
|
|
Sheet sheet;
|
|
Sheet sheet;
|
|
@@ -132,7 +299,9 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
} else {
|
|
} else {
|
|
sheet = wb.getSheetAt(0);
|
|
sheet = wb.getSheetAt(0);
|
|
}
|
|
}
|
|
- List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrq(new TSpecReport());
|
|
|
|
|
|
+ List<Integer> numArr = new ArrayList<>();
|
|
|
|
+ List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrq(new TSpecReport());
|
|
|
|
+ numArr.add(ylrqList.size());
|
|
logger.info(JSON.toJSONString(ylrqList));
|
|
logger.info(JSON.toJSONString(ylrqList));
|
|
Row row = sheet.getRow(3);
|
|
Row row = sheet.getRow(3);
|
|
Cell cell = row.getCell(1);
|
|
Cell cell = row.getCell(1);
|
|
@@ -141,55 +310,64 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
cell.setCellStyle(originalStyle);
|
|
cell.setCellStyle(originalStyle);
|
|
cell.setCellValue(getDevTotal(ylrqList));
|
|
cell.setCellValue(getDevTotal(ylrqList));
|
|
|
|
|
|
- List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgd(new TSpecReport());
|
|
|
|
|
|
+ List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgd(new TSpecReport());
|
|
|
|
+ numArr.add(ylgdList.size());
|
|
logger.info(JSON.toJSONString(ylgdList));
|
|
logger.info(JSON.toJSONString(ylgdList));
|
|
Row row2 = sheet.getRow(3);
|
|
Row row2 = sheet.getRow(3);
|
|
Cell cell2 = row2.getCell(4);
|
|
Cell cell2 = row2.getCell(4);
|
|
cell2.setCellValue(getDevTotal(ylgdList));
|
|
cell2.setCellValue(getDevTotal(ylgdList));
|
|
|
|
|
|
- List<TSpecReport> glList = tSpecReportMapper.selectExpriedGl(new TSpecReport());
|
|
|
|
|
|
+ List<TSpecReport> glList = tSpecReportMapper.selectExpriedGl(new TSpecReport());
|
|
|
|
+ numArr.add(glList.size());
|
|
logger.info(JSON.toJSONString(glList));
|
|
logger.info(JSON.toJSONString(glList));
|
|
Row row3 = sheet.getRow(3);
|
|
Row row3 = sheet.getRow(3);
|
|
Cell cell3 = row3.getCell(7);
|
|
Cell cell3 = row3.getCell(7);
|
|
cell3.setCellValue(getDevTotal(glList));
|
|
cell3.setCellValue(getDevTotal(glList));
|
|
|
|
|
|
- List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDt(new TSpecReport());
|
|
|
|
|
|
+ List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDt(new TSpecReport());
|
|
|
|
+ numArr.add(dtList.size());
|
|
logger.info(JSON.toJSONString(dtList));
|
|
logger.info(JSON.toJSONString(dtList));
|
|
Row row4 = sheet.getRow(3);
|
|
Row row4 = sheet.getRow(3);
|
|
Cell cell4 = row4.getCell(10);
|
|
Cell cell4 = row4.getCell(10);
|
|
cell4.setCellValue(getDevTotal(dtList));
|
|
cell4.setCellValue(getDevTotal(dtList));
|
|
|
|
|
|
- List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsb(new TSpecReport());
|
|
|
|
|
|
+ List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsb(new TSpecReport());
|
|
|
|
+ numArr.add(dzsbList.size());
|
|
logger.info(JSON.toJSONString(dzsbList));
|
|
logger.info(JSON.toJSONString(dzsbList));
|
|
Row row5 = sheet.getRow(3);
|
|
Row row5 = sheet.getRow(3);
|
|
Cell cell5 = row5.getCell(13);
|
|
Cell cell5 = row5.getCell(13);
|
|
cell5.setCellValue(getDevTotal(dzsbList));
|
|
cell5.setCellValue(getDevTotal(dzsbList));
|
|
|
|
|
|
- List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCc(new TSpecReport());
|
|
|
|
|
|
+ List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCc(new TSpecReport());
|
|
|
|
+ numArr.add(ccList.size());
|
|
logger.info(JSON.toJSONString(ccList));
|
|
logger.info(JSON.toJSONString(ccList));
|
|
Row row6 = sheet.getRow(3);
|
|
Row row6 = sheet.getRow(3);
|
|
Cell cell6 = row6.getCell(16);
|
|
Cell cell6 = row6.getCell(16);
|
|
cell6.setCellValue(getDevTotal(ccList));
|
|
cell6.setCellValue(getDevTotal(ccList));
|
|
|
|
|
|
- sheet.shiftRows(6, sheet.getLastRowNum(), 1);
|
|
|
|
- cpoyRow(6 ,sheet );
|
|
|
|
- sheet.shiftRows(6, sheet.getLastRowNum(), 1);
|
|
|
|
- cpoyRow(6 ,sheet );
|
|
|
|
- sheet.shiftRows(6, sheet.getLastRowNum(), 1);
|
|
|
|
- cpoyRow(6 ,sheet );
|
|
|
|
- sheet.shiftRows(6, sheet.getLastRowNum(), 1);
|
|
|
|
- cpoyRow(6 ,sheet );
|
|
|
|
- sheet.shiftRows(6, sheet.getLastRowNum(), 1);
|
|
|
|
- cpoyRow(6 ,sheet );
|
|
|
|
|
|
+ int maxNum = findMaxValue(numArr);
|
|
|
|
+ int needNum = maxNum - 3 > 0 ? maxNum - 3 : 0;
|
|
|
|
+ for (int i = 0; i < needNum; i++) {
|
|
|
|
+ sheet.shiftRows(6, sheet.getLastRowNum(), 1);
|
|
|
|
+ cpoyRow(6, sheet);
|
|
|
|
+ }
|
|
// 合并区域从第0行第0列到第0行第3列
|
|
// 合并区域从第0行第0列到第0行第3列
|
|
CellRangeAddress mergedRegion = new CellRangeAddress(
|
|
CellRangeAddress mergedRegion = new CellRangeAddress(
|
|
3, // 起始行
|
|
3, // 起始行
|
|
- 12, // 结束行
|
|
|
|
|
|
+ needNum + 7, // 结束行
|
|
0, // 起始列
|
|
0, // 起始列
|
|
0 // 结束列
|
|
0 // 结束列
|
|
);
|
|
);
|
|
sheet.addMergedRegion(mergedRegion);
|
|
sheet.addMergedRegion(mergedRegion);
|
|
|
|
+
|
|
|
|
+ renderCell(wb,sheet,ylrqList,5,1 );
|
|
|
|
+ renderCell(wb,sheet,ylgdList,5,4);
|
|
|
|
+ renderCell(wb,sheet,glList,5,7);
|
|
|
|
+ renderCell(wb,sheet,dtList,5,10);
|
|
|
|
+ renderCell(wb,sheet,dzsbList,5,13);
|
|
|
|
+ renderCell(wb,sheet,ccList,5,16);
|
|
}
|
|
}
|
|
|
|
+
|
|
// Excel 渲染
|
|
// Excel 渲染
|
|
private void replaceExcel(SXSSFWorkbook wb) {
|
|
private void replaceExcel(SXSSFWorkbook wb) {
|
|
Sheet sheet;
|
|
Sheet sheet;
|
|
@@ -201,8 +379,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
}
|
|
}
|
|
//压力容器
|
|
//压力容器
|
|
int ylrqAll = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
|
|
int ylrqAll = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
|
|
- .eq("STATUS" , 1)
|
|
|
|
- .eq("del_flag" , 0)
|
|
|
|
|
|
+ .eq("STATUS", 1)
|
|
|
|
+ .eq("del_flag", 0)
|
|
);
|
|
);
|
|
Row row = sheet.getRow(2);
|
|
Row row = sheet.getRow(2);
|
|
Cell cell = row.getCell(1);
|
|
Cell cell = row.getCell(1);
|
|
@@ -213,8 +391,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
|
|
|
|
//压力管道
|
|
//压力管道
|
|
int ylgdAll = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
|
|
int ylgdAll = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
|
|
- .eq("STATUS" , 1)
|
|
|
|
- .eq("del_flag" , 0)
|
|
|
|
|
|
+ .eq("STATUS", 1)
|
|
|
|
+ .eq("del_flag", 0)
|
|
);
|
|
);
|
|
Row row2 = sheet.getRow(2);
|
|
Row row2 = sheet.getRow(2);
|
|
Cell cell2 = row2.getCell(4);
|
|
Cell cell2 = row2.getCell(4);
|
|
@@ -222,8 +400,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
cell2.setCellValue(ylgdAll + "(条)");
|
|
cell2.setCellValue(ylgdAll + "(条)");
|
|
//锅炉
|
|
//锅炉
|
|
int glAll = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
|
|
int glAll = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
|
|
- .eq("STATUS" , 1)
|
|
|
|
- .eq("del_flag" , 0)
|
|
|
|
|
|
+ .eq("STATUS", 1)
|
|
|
|
+ .eq("del_flag", 0)
|
|
);
|
|
);
|
|
Row row3 = sheet.getRow(2);
|
|
Row row3 = sheet.getRow(2);
|
|
Cell cell3 = row3.getCell(7);
|
|
Cell cell3 = row3.getCell(7);
|
|
@@ -231,8 +409,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
cell3.setCellValue(glAll + "(套)");
|
|
cell3.setCellValue(glAll + "(套)");
|
|
//电梯
|
|
//电梯
|
|
int dtAll = tSpecdevDtService.count(new QueryWrapper<TSpecdevDt>()
|
|
int dtAll = tSpecdevDtService.count(new QueryWrapper<TSpecdevDt>()
|
|
- .eq("STATUS" , 1)
|
|
|
|
- .eq("del_flag" , 0)
|
|
|
|
|
|
+ .eq("STATUS", 1)
|
|
|
|
+ .eq("del_flag", 0)
|
|
);
|
|
);
|
|
Row row4 = sheet.getRow(2);
|
|
Row row4 = sheet.getRow(2);
|
|
Cell cell4 = row4.getCell(10);
|
|
Cell cell4 = row4.getCell(10);
|
|
@@ -240,8 +418,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
cell4.setCellValue(dtAll + "(台)");
|
|
cell4.setCellValue(dtAll + "(台)");
|
|
//吊装设备
|
|
//吊装设备
|
|
int dzsbAll = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
|
|
int dzsbAll = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
|
|
- .eq("STATUS" , 1)
|
|
|
|
- .eq("del_flag" , 0)
|
|
|
|
|
|
+ .eq("STATUS", 1)
|
|
|
|
+ .eq("del_flag", 0)
|
|
);
|
|
);
|
|
Row row5 = sheet.getRow(2);
|
|
Row row5 = sheet.getRow(2);
|
|
Cell cell5 = row5.getCell(13);
|
|
Cell cell5 = row5.getCell(13);
|
|
@@ -249,8 +427,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
cell5.setCellValue(dzsbAll + "(条)");
|
|
cell5.setCellValue(dzsbAll + "(条)");
|
|
//叉车
|
|
//叉车
|
|
int ccAll = tSpecdevCcService.count(new QueryWrapper<TSpecdevCc>()
|
|
int ccAll = tSpecdevCcService.count(new QueryWrapper<TSpecdevCc>()
|
|
- .eq("STATUS" , 1)
|
|
|
|
- .eq("del_flag" , 0)
|
|
|
|
|
|
+ .eq("STATUS", 1)
|
|
|
|
+ .eq("del_flag", 0)
|
|
);
|
|
);
|
|
Row row6 = sheet.getRow(2);
|
|
Row row6 = sheet.getRow(2);
|
|
Cell cell6 = row6.getCell(16);
|
|
Cell cell6 = row6.getCell(16);
|
|
@@ -259,17 +437,18 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private int getDevTotal (List<TSpecReport> list){
|
|
|
|
|
|
+ private int getDevTotal(List<TSpecReport> list) {
|
|
int num = 0;
|
|
int num = 0;
|
|
for (TSpecReport t : list
|
|
for (TSpecReport t : list
|
|
- ) {
|
|
|
|
|
|
+ ) {
|
|
num = num + t.getDevNum();
|
|
num = num + t.getDevNum();
|
|
}
|
|
}
|
|
return num;
|
|
return num;
|
|
}
|
|
}
|
|
- void cpoyRow (int rowNum ,Sheet sheet ){
|
|
|
|
|
|
+
|
|
|
|
+ void cpoyRow(int rowNum, Sheet sheet) {
|
|
Row newRow = sheet.createRow(rowNum);
|
|
Row newRow = sheet.createRow(rowNum);
|
|
- Row oldRow = sheet.getRow(rowNum+1);
|
|
|
|
|
|
+ Row oldRow = sheet.getRow(rowNum + 1);
|
|
for (int i = 0; i < 22; i++) {
|
|
for (int i = 0; i < 22; i++) {
|
|
Cell newCell = newRow.createCell(i);
|
|
Cell newCell = newRow.createCell(i);
|
|
Cell oldCell = oldRow.getCell(i);
|
|
Cell oldCell = oldRow.getCell(i);
|
|
@@ -277,6 +456,64 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
newCell.setCellStyle(originalStyle);
|
|
newCell.setCellStyle(originalStyle);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public int findMaxValue(List<Integer> list) {
|
|
|
|
+ // Assume the first element is the largest
|
|
|
|
+ int max = list.get(0);
|
|
|
|
+
|
|
|
|
+ // Loop through the list starting from the second element
|
|
|
|
+ for (int i = 1; i < list.size(); i++) {
|
|
|
|
+ if (list.get(i) > max) {
|
|
|
|
+ max = list.get(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return max;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void renderCell(SXSSFWorkbook wb ,Sheet sheet,List<TSpecReport> list ,int startRow, int startCol ) {
|
|
|
|
+ int num = 0;
|
|
|
|
+ Font font = wb.createFont();
|
|
|
|
+ font.setFontHeightInPoints((short) 9); // 设置字体大小为12
|
|
|
|
+ font.setBold(false);
|
|
|
|
+ for (TSpecReport t: list
|
|
|
|
+ ) {
|
|
|
|
+ //装置
|
|
|
|
+ logger.info("开始渲染行:" + startRow +"开始渲染列:" + (startCol + num));
|
|
|
|
+ Row row = sheet.getRow(startRow + num);
|
|
|
|
+ Cell cell = row.getCell(startCol);
|
|
|
|
+ // 获取单元格样式
|
|
|
|
+ CellStyle originalStyle = cell.getCellStyle();
|
|
|
|
+ originalStyle.setFont(font);
|
|
|
|
+ cell.setCellStyle(originalStyle);
|
|
|
|
+ cell.setCellValue(t.getPlantCode());
|
|
|
|
+
|
|
|
|
+ //数量
|
|
|
|
+ logger.info("开始渲染行:" + startRow + num +"开始渲染列:" + startCol + 1);
|
|
|
|
+ Row row2 = sheet.getRow(startRow + num);
|
|
|
|
+ Cell cell2 = row2.getCell(startCol + 1);
|
|
|
|
+ // 获取单元格样式
|
|
|
|
+ originalStyle = cell2.getCellStyle();
|
|
|
|
+ originalStyle.setFont(font);
|
|
|
|
+ cell2.setCellStyle(originalStyle);
|
|
|
|
+ cell2.setCellValue(t.getDevNum());
|
|
|
|
+
|
|
|
|
+ //备注
|
|
|
|
+ logger.info("开始渲染行:" + startRow + num +"开始渲染列:" + startCol + 2 );
|
|
|
|
+ Row row3 = sheet.getRow(startRow + num);
|
|
|
|
+ Cell cell3 = row3.getCell(startCol + 2);
|
|
|
|
+ // 获取单元格样式
|
|
|
|
+ originalStyle = cell3.getCellStyle();
|
|
|
|
+ originalStyle.setFont(font);
|
|
|
|
+ cell3.setCellStyle(originalStyle);
|
|
|
|
+ if (t.getRemarks() != null) {
|
|
|
|
+ cell3.setCellValue(t.getRemarks().replace("-通过","").replace("批准",""));
|
|
|
|
+ }
|
|
|
|
+ num++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 修改特种设备报告
|
|
* 修改特种设备报告
|
|
*
|
|
*
|
|
@@ -284,8 +521,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public int updateTSpecReport(TSpecReport tSpecReport)
|
|
|
|
- {
|
|
|
|
|
|
+ public int updateTSpecReport(TSpecReport tSpecReport) {
|
|
return tSpecReportMapper.updateTSpecReport(tSpecReport);
|
|
return tSpecReportMapper.updateTSpecReport(tSpecReport);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -296,8 +532,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public int deleteTSpecReportByIds(Long[] ids)
|
|
|
|
- {
|
|
|
|
|
|
+ public int deleteTSpecReportByIds(Long[] ids) {
|
|
return tSpecReportMapper.deleteTSpecReportByIds(ids);
|
|
return tSpecReportMapper.deleteTSpecReportByIds(ids);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -308,8 +543,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public int deleteTSpecReportById(Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public int deleteTSpecReportById(Long id) {
|
|
return tSpecReportMapper.deleteTSpecReportById(id);
|
|
return tSpecReportMapper.deleteTSpecReportById(id);
|
|
}
|
|
}
|
|
}
|
|
}
|