Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 10 months ago
parent
commit
debd08915f
  1. 5
      hzims-biz-common/src/main/java/com/hnac/hzims/common/support/constants/Order.java
  2. 49
      hzims-biz-common/src/main/java/com/hnac/hzims/common/support/utils/Condition.java
  3. 21
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/DictConstants.java
  4. 13
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DangerSourceEntity.java
  5. 5
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/vo/DangerSourceVO.java
  6. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java
  7. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java
  8. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java
  9. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/controller/DangerSourceController.java
  10. 19
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/IDangerSourceService.java
  11. 67
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java
  12. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/wrapper/DangerSourceWrapper.java
  13. 33
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  14. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java
  15. 62
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  16. 43
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/vo/DangerSourceExportVO.java
  17. BIN
      hzims-service/safeproduct/src/main/resources/template/卫生自查表.docx

5
hzims-biz-common/src/main/java/com/hnac/hzims/common/support/constants/Order.java

@ -0,0 +1,5 @@
package com.hnac.hzims.common.support.constants;
public enum Order {
ASC,DESC;
}

49
hzims-biz-common/src/main/java/com/hnac/hzims/common/support/utils/Condition.java

@ -0,0 +1,49 @@
package com.hnac.hzims.common.support.utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.hnac.hzims.common.support.constants.Order;
import org.springblade.core.tool.utils.BeanUtil;
import java.lang.reflect.Field;
import java.util.*;
import java.util.function.Function;
public class Condition extends org.springblade.core.mp.support.Condition {
public static List<Field> getFieldList(Object object) {
Class<?> clazz = object.getClass();
List<Field> fields = Lists.newArrayList();
while (null != clazz){
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
return fields;
}
public static <T> LambdaQueryWrapper<T> getQueryWrapper(Object query, Class<T> clazz, Map<String,? extends Enum<Order>> orderFields) {
QueryWrapper<T> queryWrapper = getQueryWrapper(BeanUtil.copy(query,clazz));
List<Field> fields = getFieldList(query);
// 填充排序字段
orderFields.forEach((fieldName,order) -> {
Optional<Field> existField = fields.stream().filter(field -> camel2under(fieldName).equals(camel2under(field.getName()))).findAny();
if(existField.isPresent()) {
if(Order.ASC.equals(order)) {
queryWrapper.orderByAsc(fieldName);
}
else if(Order.DESC.equals(order)) {
queryWrapper.orderByDesc(fieldName);
}
}
});
return queryWrapper.lambda();
}
private static String camel2under(String c) {
String separator = "_";
c = c.replaceAll("([a-z])([A-Z])", "$1" + separator + "$2").toUpperCase();
return c;
}
}

21
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/DictConstants.java

@ -1,5 +1,11 @@
package com.hnac.hzims.safeproduct.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Optional;
/**
* @author xiashandong
* @created 2021/5/27 10:09
@ -11,4 +17,19 @@ public interface DictConstants {
String DANGER_TYPE = "dangerType";
/**危险等级**/
String RISK_LEVEL = "riskLevel";
@AllArgsConstructor
enum DangerSourceTypeEnum {
OPERATION(1,"作业活动"),
EQUIPMENT(2,"设备"),
;
@Getter
private Integer type;
@Getter
private String typeName;
public static String getTypeNameByType(Integer type) {
Optional<DangerSourceTypeEnum> first = Arrays.stream(DangerSourceTypeEnum.class.getEnumConstants()).filter(e -> type.equals(e.getType())).findFirst();
return first.map(DangerSourceTypeEnum::getTypeName).orElse(null);
}
}
}

13
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/DangerSourceEntity.java

@ -1,5 +1,7 @@
package com.hnac.hzims.safeproduct.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
@ -7,6 +9,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
@ -23,12 +27,14 @@ public class DangerSourceEntity extends TenantEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("所属机构")
@QueryField(condition = SqlCondition.EQUAL)
private Long refDept;
@ApiModelProperty("所属机构名称")
private String refDeptName;
@ApiModelProperty(value = "危险源库ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long libraryId;
/**
@ -36,15 +42,18 @@ public class DangerSourceEntity extends TenantEntity {
*/
@ApiModelProperty(value = "危险源类型 1=作业活动 2=设备")
@JsonSerialize(nullsUsing = NullSerializer.class)
@QueryField(condition = SqlCondition.EQUAL)
private Integer type;
/**
* 设备ID
*/
@ApiModelProperty(value = "设备ID")
@JsonSerialize(nullsUsing = NullSerializer.class)
@QueryField(condition = SqlCondition.EQUAL)
private Long eqId;
@ApiModelProperty("设备编号")
@QueryField(condition = SqlCondition.LIKE)
private String emCode;
@ApiModelProperty("设备名称")
@ -53,17 +62,20 @@ public class DangerSourceEntity extends TenantEntity {
* 危险源名称
*/
@ApiModelProperty(value = "危险源名称")
@QueryField(condition = SqlCondition.LIKE)
private String name;
/**
* 危险因素
*/
@ApiModelProperty(value = "危险因素")
@QueryField(condition = SqlCondition.LIKE)
private String dangerEle;
/**
* 应用类型
*/
@ApiModelProperty(value = "应用类型")
@QueryField(condition = SqlCondition.EQUAL)
private String applyType;
/**
* 可能导致的事故
@ -80,6 +92,7 @@ public class DangerSourceEntity extends TenantEntity {
*/
@ApiModelProperty(value = "风险等级 10=稍有危险 20=一般危险 30=显著危险 40=高度危险")
@JsonSerialize(nullsUsing = NullSerializer.class)
@QueryField(condition = SqlCondition.EQUAL)
private Integer level;
}

5
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/vo/DangerSourceVO.java

@ -1,5 +1,7 @@
package com.hnac.hzims.safeproduct.hazard.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.hnac.hzims.safeproduct.entity.DangerSourceEntity;
import com.hnac.hzims.safeproduct.hazard.enums.DangerSourceLevelEnum;
import com.hnac.hzims.safeproduct.hazard.vo.DangerSourcePositionVO;
@ -23,6 +25,9 @@ public class DangerSourceVO extends DangerSourceEntity {
@ApiModelProperty(value = "危险等级Name")
private String applyTypeName;
@ApiModelProperty(value = "危险源类型名称")
private String typeName;
@ApiModelProperty("创建人名称")
private String createUserName;

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;

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/controller/DangerSourceController.java

@ -22,6 +22,7 @@ import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -119,4 +120,11 @@ public class DangerSourceController extends BladeController {
public R importDangerSource(@RequestBody HazardInstanceDTO req) {
return R.status(dangerSourceService.importDangerSource(req));
}
@GetMapping("/exportDangerSource")
@ApiOperation("导出危险源")
@ApiOperationSupport(order = 90)
public void exportDangerSource(DangerSourceEntity req, HttpServletResponse response) {
dangerSourceService.exportDangerSource(req,response);
}
}

19
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/IDangerSourceService.java

@ -1,6 +1,9 @@
package com.hnac.hzims.safeproduct.hazard.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.common.support.constants.Order;
import com.hnac.hzims.common.support.utils.Condition;
import com.hnac.hzims.safeproduct.hazard.dto.DangerSourceDTO;
import com.hnac.hzims.safeproduct.entity.DangerSourceEntity;
import com.hnac.hzims.safeproduct.hazard.dto.HazardInstanceDTO;
@ -13,7 +16,10 @@ import org.springblade.core.tool.api.R;
import org.springblade.system.vo.CreateTableVO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author xiashandong
@ -44,4 +50,17 @@ public interface IDangerSourceService extends BaseService<DangerSourceEntity> {
List<DangerSourceEntity> safes(String safeInfos);
Boolean importDangerSource(HazardInstanceDTO req);
/**
* 导出危险源
* @param req 筛选条件
* @param response 请求响应
*/
void exportDangerSource(DangerSourceEntity req, HttpServletResponse response);
default LambdaQueryWrapper<DangerSourceEntity> getQueryWrapper(Object req) {
Map<String, Order> param = new HashMap<>();
param.put("create_time",Order.DESC);
return Condition.getQueryWrapper(req,DangerSourceEntity.class,param);
}
}

67
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java

@ -1,5 +1,8 @@
package com.hnac.hzims.safeproduct.hazard.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -7,8 +10,10 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.common.support.constants.Order;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.operational.maintenance.vo.MaintenanceTaskQueryVO;
import com.hnac.hzims.safeproduct.constants.DictConstants;
import com.hnac.hzims.safeproduct.hazard.dto.DangerSourceDTO;
import com.hnac.hzims.safeproduct.hazard.dto.DangerSourcePositionDTO;
@ -25,6 +30,7 @@ import com.hnac.hzims.safeproduct.hazard.service.IDangerSourceService;
import com.hnac.hzims.safeproduct.utils.ExcelToolListener;
import com.hnac.hzims.safeproduct.utils.TableJsonUtils;
import com.hnac.hzims.safeproduct.hazard.vo.DangerSourcePositionVO;
import com.hnac.hzims.safeproduct.vo.DangerSourceExportVO;
import com.hnac.hzims.safeproduct.vo.DangerSourceReportVO;
import com.hnac.hzims.safeproduct.hazard.vo.DangerSourceVO;
import com.hnac.hzims.safeproduct.vo.SourceVO;
@ -33,6 +39,7 @@ import com.hnac.hzims.safeproduct.hazard.wrapper.DangerSourceWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.springblade.core.excel.support.ExcelException;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
@ -52,9 +59,12 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -174,28 +184,7 @@ public class DangerSourceServiceImpl extends BaseServiceImpl<DangerSourceMapper,
@Override
public R<IPage<DangerSourceVO>> pageCondition(DangerSourceEntity req, Query query) {
Wrapper<DangerSourceEntity> queryWrapper = new LambdaQueryWrapper<DangerSourceEntity>() {{
orderByDesc(DangerSourceEntity::getCreateTime);
if (req.getType() != null) {
eq(DangerSourceEntity::getType, req.getType());
}
if (null != req.getEqId()) {
eq(DangerSourceEntity::getEqId, req.getEqId());
}
if (null != req.getLevel()) {
eq(DangerSourceEntity::getLevel, req.getLevel());
}
if (StringUtil.isNotBlank(req.getName())) {
like(DangerSourceEntity::getName, req.getName());
}
if (StringUtil.isNotBlank(req.getDangerEle())) {
like(DangerSourceEntity::getDangerEle, req.getDangerEle());
}
if (StringUtil.isNotBlank(req.getApplyType())) {
eq(DangerSourceEntity::getApplyType, req.getApplyType());
}
}};
IPage page = super.page(Condition.getPage(query), queryWrapper);
IPage page = super.page(Condition.getPage(query), getQueryWrapper(req));
page.setRecords(DangerSourceWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
@ -327,6 +316,8 @@ public class DangerSourceServiceImpl extends BaseServiceImpl<DangerSourceMapper,
List<DangerSourceEntity> sourceList = req.getHazardList().stream().map(h -> {
DangerSourceEntity result = JSONObject.parseObject(JSON.toJSONString(h), DangerSourceEntity.class);
result.setId(null);
result.setEmCode(req.getEmCode());
result.setEmName(req.getEmName());
result.setLibraryId(h.getId());
result.setRefDept(req.getDeptId());
result.setRefDeptName(req.getDeptName());
@ -342,6 +333,38 @@ public class DangerSourceServiceImpl extends BaseServiceImpl<DangerSourceMapper,
}
@Override
public void exportDangerSource(DangerSourceEntity req, HttpServletResponse response) {
List<DangerSourceEntity> dangerSourceList = this.list(getQueryWrapper(req));
List<DangerSourceVO> voList = DangerSourceWrapper.build().listVO(dangerSourceList);
List<DangerSourceExportVO> exportVOList = BeanUtil.copy(voList, DangerSourceExportVO.class);
// 设置响应头
// URLEncoder.encode防止中文乱码
String fileName;
try {
fileName = URLEncoder.encode("危险点列表", "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
contentWriteCellStyle.setWrapped(true);
try {
EasyExcel.write(response.getOutputStream(), DangerSourceExportVO.class)
.registerWriteHandler(new HorizontalCellStyleStrategy(new WriteCellStyle(), contentWriteCellStyle))
.autoCloseStream(Boolean.FALSE).sheet("危险点列表")
.doWrite(exportVOList);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public List<SourceVO> listByTenantId(String tenantId) {
return this.baseMapper.listByTenantId(tenantId);
}

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/wrapper/DangerSourceWrapper.java

@ -29,6 +29,8 @@ public class DangerSourceWrapper extends BaseEntityWrapper<DangerSourceEntity, D
vo.setCreateUserName(Optional.ofNullable(createUser).map(User::getName).orElse(null));
vo.setUpdateUserName(Optional.ofNullable(updateUser).map(User::getName).orElse(null));
vo.setApplyTypeName(DictCache.getValue(DictConstants.SAFE_DANGER_SOURCE_APPLY_TYPE, entity.getApplyType()));
vo.setLevelName(DictCache.getValue(DictConstants.RISK_LEVEL, entity.getLevel()));
vo.setTypeName(DictConstants.DangerSourceTypeEnum.getTypeNameByType(entity.getType()));
return vo;
}

33
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,9 +138,9 @@ 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++) {
HygieneZoneDetailVO zoneDetailVO = new HygieneZoneDetailVO();
@ -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 文件路径

43
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/vo/DangerSourceExportVO.java

@ -0,0 +1,43 @@
package com.hnac.hzims.safeproduct.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@Data
@EqualsAndHashCode
public class DangerSourceExportVO implements Serializable {
@ExcelProperty(value = "所属站点",index = 0)
@ColumnWidth(value = 25)
private String refDeptName;
@ExcelProperty(value = "危险源类型",index = 1)
@ColumnWidth(value = 15)
private String typeName;
@ExcelProperty(value = "风险等级",index = 2)
@ColumnWidth(value = 20)
private String levelName;
@ExcelProperty(value = "设备",index = 3)
@ColumnWidth(value = 15)
private String emName;
@ExcelProperty(value = "危险源名称",index = 4)
@ColumnWidth(value = 30)
private String name;
@ExcelProperty(value = "危险因素",index = 5)
@ColumnWidth(value = 30)
private String dangerEle;
@ExcelProperty(value = "措施",index = 6)
@ColumnWidth(value = 40)
private String measures;
}

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

Binary file not shown.
Loading…
Cancel
Save