Browse Source

update: 演练管理新增演练记录表导出

zhongwei
liwen 11 months ago
parent
commit
c803096783
  1. 55
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalDetailVO.java
  2. 9
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java
  3. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java
  4. 11
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml
  5. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java
  6. 34
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java
  7. BIN
      hzims-service/safeproduct/src/main/resources/template/演练记录表.docx

55
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalDetailVO.java

@ -0,0 +1,55 @@
package com.hnac.hzims.safeproduct.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author liwen
* @date 2024-01-15
*/
@Data
@ApiModel(value = "演练记录表VO类")
public class RehearsalDetailVO {
@ApiModelProperty("编码")
private String code;
@ApiModelProperty("参演人员")
private String peopleName;
@ApiModelProperty("演练实际开始时间")
private Date actualStartTime;
@ApiModelProperty("演练实际结束时间")
private Date actualEndTime;
@ApiModelProperty("演练记录")
private String record;
@ApiModelProperty("演练评价")
private String comment;
@ApiModelProperty("演练图片")
private String imgPath;
@ApiModelProperty("演练附件")
private String filePath;
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("演练地点")
private String location;
@ApiModelProperty("总指挥")
private String commander;
@ApiModelProperty("演练方式")
private String rehearsalMethod;
@ApiModelProperty("演练科目")
private String subject;
}

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

@ -7,6 +7,7 @@ import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.service.IRehearsalPlanService;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.hnac.hzims.safeproduct.vo.RehearsalDetailVO;
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO;
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO;
import io.swagger.annotations.Api;
@ -105,8 +106,8 @@ public class RehearsalController extends BladeController {
@GetMapping("/rehearsalRecordDetail")
@ApiOperation(value = "演练记录详情")
@ApiOperationSupport(order = 9)
public R<RehearsalRecordEntity> rehearsalRecordDetail(@RequestParam Long id) {
return R.data(rehearsalRecordService.getById(id));
public R<RehearsalDetailVO> rehearsalRecordDetail(@RequestParam Long id) {
return R.data(rehearsalRecordService.getRecordDetailVOById(id));
}
@GetMapping("/rehearsalRecordPage")
@ -152,7 +153,7 @@ public class RehearsalController extends BladeController {
@GetMapping("/exportRecordDetailData")
@ApiOperation(value = "演练记录表导出")
@ApiOperationSupport(order = 14)
public void exportRecordDetailData(@RequestParam Long id) {
rehearsalRecordService.exportRecordDetailData(id);
public void exportRecordDetailData(@RequestParam Long id, HttpServletResponse response) {
rehearsalRecordService.exportRecordDetailData(id, response);
}
}

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java

@ -2,6 +2,7 @@ package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.vo.RehearsalDetailVO;
import org.apache.ibatis.annotations.Mapper;
/**
@ -13,4 +14,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RehearsalRecordMapper extends BaseMapper<RehearsalRecordEntity> {
/**
* 查询演练记录表详情
* @param id 演练记录id
* @return 演练记录表VO类
*/
RehearsalDetailVO getRecordDetailVOById(Long id);
}

11
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml

@ -2,4 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper">
<select id="getRecordDetailVOById" resultType="com.hnac.hzims.safeproduct.vo.RehearsalDetailVO">
SELECT
t1.code, t1.actual_start_time, t1.actual_end_time, t2.unit, t2.location, t2.rehearsal_method, t2.commander,
t2.subject, t1.people_name, t1.record, t1.img_path, t1.command, t1.file_path
FROM
hzims_rehearsal_record t1
LEFT JOIN hzims_rehearsal_plan t2 ON t1.rehearsal_plan_id = t2.id
WHERE
t1.is_deleted = 0
AND t1.id = #{id}
</select>
</mapper>

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java

@ -2,6 +2,9 @@ package com.hnac.hzims.safeproduct.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.vo.RehearsalDetailVO;
import javax.servlet.http.HttpServletResponse;
/**
* 演练记录服务类
@ -35,6 +38,14 @@ public interface IRehearsalRecordService extends IService<RehearsalRecordEntity>
/**
* 演练记录表导出
* @param id 演练记录id
* @param response 响应类
*/
void exportRecordDetailData(Long id, HttpServletResponse response);
/**
* 查询演练记录表详情
* @param id 演练记录id
* @return 演练记录表VO类
*/
void exportRecordDetailData(Long id);
RehearsalDetailVO getRecordDetailVOById(Long id);
}

34
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java

@ -13,17 +13,13 @@ import com.hnac.hzims.safeproduct.mapper.RehearsalPlanMapper;
import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.ticket.constants.WorkTicketConstants;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import com.hnac.hzims.safeproduct.vo.RehearsalDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
@ -40,6 +36,9 @@ public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMappe
@Resource
RehearsalPlanMapper rehearsalPlanMapper;
@Value("${hzims.rehearsal.savePath}")
private String savePath;
/**
* 新增演练
*/
@ -130,11 +129,20 @@ public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMappe
* 演练记录表导出
*/
@Override
public void exportRecordDetailData(Long id) {
RehearsalRecordEntity rehearsalRecordEntity = this.getById(id);
String tempFileName = "演练记录表.xlsx";
Assert.isTrue(StringUtil.isNotBlank(tempFileName),() -> {
throw new ServiceException("未找到模板文件,预览失败!");
});
public void exportRecordDetailData(Long id, HttpServletResponse response) {
RehearsalDetailVO rehearsalDetailVO = this.getRecordDetailVOById(id);
Map<String, Object> params = BaseUtil.obj2Map(rehearsalDetailVO);
String templateFile = "template/演练记录表" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/演练记录表" + SafeProductConstant.DOCX_SUFFIX;
String pdfPath = savePath + "/演练记录表" + SafeProductConstant.PDF_SUFFIX;
BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath, response);
}
/**
* 查询演练记录表详情
*/
@Override
public RehearsalDetailVO getRecordDetailVOById(Long id) {
return baseMapper.getRecordDetailVOById(id);
}
}

BIN
hzims-service/safeproduct/src/main/resources/template/演练记录表.docx

Binary file not shown.
Loading…
Cancel
Save