Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 10 months ago
parent
commit
2a9b3381e5
  1. 2
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/Constants.java
  2. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java
  3. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java
  4. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java
  5. 35
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  6. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java
  7. 62
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  8. BIN
      hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx

2
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/Constants.java

@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
* @Author: py
*/
public class Constants {
public final static String APP_NAME = "hzims-safeproduct-hx";
public final static String APP_NAME = "hzims-safeproduct";
/**
* 安全生产标准化评审标准

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java

@ -47,4 +47,10 @@ public class HygieneRecordDetailVO {
@ApiModelProperty("检查信息列表")
private List<HygieneZoneDetailVO> checkList;
@ApiModelProperty("年份")
private String year;
@ApiModelProperty("月份")
private String month;
}

1
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java

@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.service.IRehearsalPlanService;

1
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java

@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.dto.TestDTO;
import com.hnac.hzims.safeproduct.dto.TestScoreDTO;
import com.hnac.hzims.safeproduct.dto.TrainRecordDTO;

35
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

@ -94,7 +94,7 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
hygieneRecordEntity.setWeekNum(weekNum);
// 综合评分判断
HygienePlanEntity hygienePlanEntity = hygienePlanMapper.selectById(hygieneRecordEntity.getHygienePlanId());
String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",|,");
String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",");
for (String score : scores) {
int sc = Integer.parseInt(score);
if (sc > hygienePlanEntity.getStandardScore()) {
@ -122,7 +122,7 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
hygieneRecordEntity.setWeekNum(weekNum);
// 综合评分判断
HygienePlanEntity hygienePlanEntity = hygienePlanMapper.selectById(hygieneRecordEntity.getHygienePlanId());
String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",|,");
String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",");
for (String score : scores) {
int sc = Integer.parseInt(score);
if (sc > hygienePlanEntity.getStandardScore()) {
@ -138,11 +138,11 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
@Override
public HygieneRecordDetailVO getRecordDetail(Long id) {
HygieneRecordDetailVO recordDetailVO = baseMapper.getRecordDetail(id);
String[] zoneIds = recordDetailVO.getHygieneZoneIds().split(",|,");
String[] results = recordDetailVO.getCheckResult().split(",|,");
String[] scores = recordDetailVO.getComprehensiveScore().split(",|,");
String[] zoneIds = recordDetailVO.getHygieneZoneIds().split(",");
String[] results = recordDetailVO.getCheckResult().split(",");
String[] scores = recordDetailVO.getComprehensiveScore().split(",");
List<HygieneZoneDetailVO> checkDetailVOList = new ArrayList<>();
for (int i = 0; i < zoneIds.length ; i++) {
for (int i = 0; i < zoneIds.length; i++) {
HygieneZoneDetailVO zoneDetailVO = new HygieneZoneDetailVO();
HygieneZoneEntity hygieneZoneEntity = hygieneZoneService.getById(zoneIds[i]);
BeanUtils.copyProperties(hygieneZoneEntity, zoneDetailVO);
@ -169,6 +169,29 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
@Override
public void exportHygieneRecordData(Long id, HttpServletResponse response) {
HygieneRecordDetailVO hygieneRecordDetailVO = this.getRecordDetail(id);
// 数据处理
// 检查项
List<HygieneZoneDetailVO> checkList = hygieneRecordDetailVO.getCheckList();
List<HygieneZoneDetailVO> res = new ArrayList<>();
checkList.forEach(item -> {
String[] checkItem = item.getCheckItem().split(",");
String[] checkItemScore = item.getCheckItemScore().split(",");
for (int i = 0; i < checkItem.length; i++) {
HygieneZoneDetailVO hygieneZoneDetailVO = new HygieneZoneDetailVO();
hygieneZoneDetailVO.setZone(item.getZone());
hygieneZoneDetailVO.setPrincipal(item.getPrincipal());
hygieneZoneDetailVO.setResult(item.getResult());
hygieneZoneDetailVO.setScore(item.getScore());
hygieneZoneDetailVO.setCheckItem(checkItem[i]);
hygieneZoneDetailVO.setCheckItemScore(checkItemScore[i]);
res.add(hygieneZoneDetailVO);
}
});
// 表头
String code = hygieneRecordDetailVO.getCode();
hygieneRecordDetailVO.setYear(code.substring(4, 8));
hygieneRecordDetailVO.setMonth(code.substring(8, 10));
hygieneRecordDetailVO.setCheckList(res);
Map<String, Object> params = BaseUtil.obj2Map(hygieneRecordDetailVO);
String templateFile = "template/卫生自查表" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/卫生自查表" + SafeProductConstant.DOCX_SUFFIX;

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java

@ -70,7 +70,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
TestEntity test = getTestByCode(testEntity.getCode());
// 获取姓名数组
String people = test.getPeopleName();
String[] person = people.split(",|,");
String[] person = people.split(",");
// 新增参考人员成绩数据
List<TestScoreEntity> scoreList = getReferenceTestScore(test, person);
return R.status(testScoreService.saveBatch(scoreList));
@ -169,7 +169,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
boolean removeByIds = testScoreService.removeByIds(scoreIds);
// 若删除成功,新增新的考试成绩数据
if (removeByIds) {
String[] person = testEntity.getPeopleName().split(",|,");
String[] person = testEntity.getPeopleName().split(",");
// 新增参考人员成绩数据
List<TestScoreEntity> scoreList = getReferenceTestScore(testEntity, person);
return testScoreService.saveBatch(scoreList);

62
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -6,6 +6,10 @@ import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
@ -106,11 +110,15 @@ public class BaseUtil {
* 数据写入
* @param templatePath 模板文件路径
* @param params 数据参数
* @return 文件
*/
public static XWPFDocument fillDocument(String templatePath, Map<String, Object> params) {
XWPFDocument xwpfDocument = null;
try {
xwpfDocument = WordExportUtil.exportWord07(templatePath, params);
if (templatePath.equals("template/卫生自查表.docx")) {
formatHygieneRecordTable(xwpfDocument);
}
} catch (Exception e) {
log.error("数据写入异常: {}", e.getMessage());
e.printStackTrace();
@ -119,6 +127,60 @@ public class BaseUtil {
}
/**
* 卫生自查表格式处理
* @param xwpfDocument word文件类
*/
private static void formatHygieneRecordTable(XWPFDocument xwpfDocument) {
// 获取文档中所有的表格
List<XWPFTable> tableList = xwpfDocument.getTables();
if (tableList.size() > 0) {
// 循环表格
for (XWPFTable table : tableList) {
// 获取表格所有行数
List<XWPFTableRow> rows = table.getRows();
// 第三行到倒数第二行为需合并区域
for (int row = 3; row < rows.size() - 1;) {
XWPFTableCell startCell = rows.get(row).getCell(0);
String startText = startCell.getText();
int index = row + 1;
for (; index < rows.size(); index++) {
XWPFTableCell endCell = rows.get(index).getCell(0);
String endText = endCell.getText();
if (!startText.equals(endText)) {
break;
}
}
mergeCellsVertically(table, 0, row, index - 1);
mergeCellsVertically(table, 1, row, index - 1);
mergeCellsVertically(table, 4, row, index - 1);
mergeCellsVertically(table, 5, row, index - 1);
row = index;
}
}
}
}
/**
* word单元格行合并
* @param table 表格
* @param col 合并行所在列
* @param startRow 开始行
* @param endRow 结束行
*/
public static void mergeCellsVertically(XWPFTable table, int col, int startRow, int endRow) {
for (int i = startRow; i <= endRow; i++) {
XWPFTableCell cell = table.getRow(i).getCell(col);
if (i == startRow) {
// The first merged cell is set with RESTART merge value
cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART);
} else {
// Cells which join (merge) the first one, are set with CONTINUE
cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
}
}
}
/**
* 读取本地pdf,这里设置的是预览
* @param response 响应类
* @param filePath 文件路径

BIN
hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx

Binary file not shown.
Loading…
Cancel
Save