Browse Source

重要事件文档生成

develop
lau572 10 months ago
parent
commit
43cc5bd69d
  1. 98
      zc-business/src/main/java/com/zc/business/controller/DcEventImportantController.java
  2. 165
      zc-business/src/main/java/com/zc/business/controller/DcEventImportantFileController.java
  3. 183
      zc-business/src/main/java/com/zc/business/domain/DcEventImportant.java
  4. 173
      zc-business/src/main/java/com/zc/business/domain/DcEventImportantFile.java
  5. 3
      zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java
  6. 61
      zc-business/src/main/java/com/zc/business/mapper/DcEventImportantFileMapper.java
  7. 61
      zc-business/src/main/java/com/zc/business/mapper/DcEventImportantMapper.java
  8. 61
      zc-business/src/main/java/com/zc/business/service/IDcEventImportantFileService.java
  9. 61
      zc-business/src/main/java/com/zc/business/service/IDcEventImportantService.java
  10. 120
      zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantFileServiceImpl.java
  11. 93
      zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java
  12. 216
      zc-business/src/main/java/com/zc/business/utils/PoiUtil.java
  13. 101
      zc-business/src/main/resources/mapper/business/DcEventImportantFileMapper.xml
  14. 121
      zc-business/src/main/resources/mapper/business/DcEventImportantMapper.xml
  15. BIN
      zc-business/src/main/resources/wordTemplate/importantTemplate.docx

98
zc-business/src/main/java/com/zc/business/controller/DcEventImportantController.java

@ -0,0 +1,98 @@
package com.zc.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.domain.DcEventImportant;
import com.zc.business.service.IDcEventImportantService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 事件侧重要素Controller
*
* @author ruoyi
* @date 2024-04-11
*/
@RestController
@RequestMapping("/business/eventImportant")
public class DcEventImportantController extends BaseController
{
@Autowired
private IDcEventImportantService dcEventImportantService;
/**
* 查询事件侧重要素列表
*/
@GetMapping("/list")
public TableDataInfo list(DcEventImportant dcEventImportant)
{
startPage();
List<DcEventImportant> list = dcEventImportantService.selectDcEventImportantList(dcEventImportant);
return getDataTable(list);
}
/**
* 导出事件侧重要素列表
*/
@Log(title = "事件侧重要素", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcEventImportant dcEventImportant)
{
List<DcEventImportant> list = dcEventImportantService.selectDcEventImportantList(dcEventImportant);
ExcelUtil<DcEventImportant> util = new ExcelUtil<>(DcEventImportant.class);
util.exportExcel(response, list, "事件侧重要素数据");
}
/**
* 获取事件侧重要素详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(dcEventImportantService.selectDcEventImportantByEventId(id));
}
/**
* 新增事件侧重要素
*/
@Log(title = "事件侧重要素", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventImportant dcEventImportant)
{
return toAjax(dcEventImportantService.insertDcEventImportant(dcEventImportant));
}
/**
* 修改事件侧重要素
*/
@Log(title = "事件侧重要素", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcEventImportant dcEventImportant)
{
return toAjax(dcEventImportantService.updateDcEventImportant(dcEventImportant));
}
/**
* 删除事件侧重要素
*/
@Log(title = "事件侧重要素", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(dcEventImportantService.deleteDcEventImportantByEventIds(ids));
}
}

165
zc-business/src/main/java/com/zc/business/controller/DcEventImportantFileController.java

@ -0,0 +1,165 @@
package com.zc.business.controller;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.zc.business.utils.PoiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.domain.DcEventImportantFile;
import com.zc.business.service.IDcEventImportantFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 重要事件文件内容Controller
*
* @author ruoyi
* @date 2024-04-12
*/
@Api(tags = "重要事件文件内容")
@RestController
@RequestMapping("/business/eventImportantFile")
public class DcEventImportantFileController extends BaseController
{
@Autowired
private IDcEventImportantFileService dcEventImportantFileService;
/**
* 分页查询重要事件文件内容
*/
@ApiOperation("分页查询重要事件文件内容")
@GetMapping("/page")
public TableDataInfo page(DcEventImportantFile dcEventImportantFile)
{
startPage();
List<DcEventImportantFile> list = dcEventImportantFileService.selectDcEventImportantFileList(dcEventImportantFile);
return getDataTable(list);
}
/**
* 无分页查询重要事件文件内容列表
*/
@ApiOperation("无分页查询重要事件文件内容列表")
@GetMapping("/list")
public List<DcEventImportantFile> list(DcEventImportantFile dcEventImportantFile)
{
return dcEventImportantFileService.selectDcEventImportantFileList(dcEventImportantFile);
}
/**
* 导出重要事件文件内容列表
*/
@Log(title = "重要事件文件内容", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcEventImportantFile dcEventImportantFile)
{
List<DcEventImportantFile> list = dcEventImportantFileService.selectDcEventImportantFileList(dcEventImportantFile);
ExcelUtil<DcEventImportantFile> util = new ExcelUtil<>(DcEventImportantFile.class);
util.exportExcel(response, list, "重要事件文件内容数据");
}
/**
* 下载重要事件文件
*/
@ApiOperation("下载重要事件文件")
@Log(title = "下载重要事件文件", businessType = BusinessType.EXPORT)
@PostMapping("/download")
public void download(HttpServletResponse response, DcEventImportantFile dcEventImportantFile)
{
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/importantTemplate.docx");
XWPFDocument document = null;
try {
//获取docx解析对象
document = new XWPFDocument(inputStream);
Map<String,Object> textMap = new HashMap<>();
textMap.put("${fromDept}",dcEventImportantFile.getFromDept());
textMap.put("${createTime}",dcEventImportantFile.getCreateTime());
textMap.put("${title}",dcEventImportantFile.getTitle());
textMap.put("${toDept}",dcEventImportantFile.getToDept());
textMap.put("${content}",dcEventImportantFile.getContent());
textMap.put("${createName}",dcEventImportantFile.getCreateName());
textMap.put("${phoneNumber}",dcEventImportantFile.getPhoneNumber());
textMap.put("${issued}",dcEventImportantFile.getIssued());
//解析替换文本段落对象
PoiUtil.changeText(document, textMap);
document.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 获取重要事件文件内容详细信息
*/
@ApiOperation("获取重要事件文件内容详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return AjaxResult.success(dcEventImportantFileService.selectDcEventImportantFileByEventId(id));
}
/**
* 新增重要事件文件内容
*/
@ApiOperation("新增重要事件文件内容")
@Log(title = "重要事件文件内容", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventImportantFile dcEventImportantFile)
{
return toAjax(dcEventImportantFileService.insertDcEventImportantFile(dcEventImportantFile));
}
/**
* 修改重要事件文件内容
*/
@ApiOperation("修改重要事件文件内容")
@Log(title = "重要事件文件内容", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcEventImportantFile dcEventImportantFile)
{
return toAjax(dcEventImportantFileService.updateDcEventImportantFile(dcEventImportantFile));
}
/**
* 删除重要事件文件内容
*/
@ApiOperation("删除重要事件文件内容")
@Log(title = "重要事件文件内容", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(dcEventImportantFileService.deleteDcEventImportantFileByEventIds(ids));
}
}

183
zc-business/src/main/java/com/zc/business/domain/DcEventImportant.java

@ -0,0 +1,183 @@
package com.zc.business.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Map;
/**
* @Description 事件侧重要素
*
* @author liuwenge
* @date 2024/4/11 18:28
*/
@ApiModel("事件侧重要素")
public class DcEventImportant
{
@ApiModelProperty(value = "事件id")
private String id;
@ApiModelProperty(value = "事件id")
private String eventId;
@ApiModelProperty(value = "车型及车牌号")
private String plateNumber;
@ApiModelProperty(value = "分流点名称及桩号")
private String diversionPoint;
@ApiModelProperty(value = "目前进度")
private String currentProgress;
@ApiModelProperty(value = "已采取措施")
private String takeSteps;
@ApiModelProperty(value = "是否启动预案")
private Integer planStatus;
@ApiModelProperty(value = "交警是否到达")
private Integer trafficPoliceStatus;
@ApiModelProperty(value = "医疗是否到达")
private Integer medicalStatus;
@ApiModelProperty(value = "消防是否到达")
private Integer fireStatus;
@ApiModelProperty(value = "是否做好情报板提示工作")
private Integer boardStatus;
@ApiModelProperty(value = "是否有危化品泄漏")
private Integer chemicalsStatus;
@ApiModelProperty(value = "预案等级")
private String planLevel;
@ApiModelProperty(value = "危化品名称")
private String chemicalsName;
@ApiModelProperty(value = "危化品泄露程度")
private String leakageLevel;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
public String getPlateNumber() {
return plateNumber;
}
public void setPlateNumber(String plateNumber) {
this.plateNumber = plateNumber;
}
public String getDiversionPoint() {
return diversionPoint;
}
public void setDiversionPoint(String diversionPoint) {
this.diversionPoint = diversionPoint;
}
public String getCurrentProgress() {
return currentProgress;
}
public void setCurrentProgress(String currentProgress) {
this.currentProgress = currentProgress;
}
public String getTakeSteps() {
return takeSteps;
}
public void setTakeSteps(String takeSteps) {
this.takeSteps = takeSteps;
}
public Integer getPlanStatus() {
return planStatus;
}
public void setPlanStatus(Integer planStatus) {
this.planStatus = planStatus;
}
public Integer getTrafficPoliceStatus() {
return trafficPoliceStatus;
}
public void setTrafficPoliceStatus(Integer trafficPoliceStatus) {
this.trafficPoliceStatus = trafficPoliceStatus;
}
public Integer getMedicalStatus() {
return medicalStatus;
}
public void setMedicalStatus(Integer medicalStatus) {
this.medicalStatus = medicalStatus;
}
public Integer getFireStatus() {
return fireStatus;
}
public void setFireStatus(Integer fireStatus) {
this.fireStatus = fireStatus;
}
public Integer getBoardStatus() {
return boardStatus;
}
public void setBoardStatus(Integer boardStatus) {
this.boardStatus = boardStatus;
}
public Integer getChemicalsStatus() {
return chemicalsStatus;
}
public void setChemicalsStatus(Integer chemicalsStatus) {
this.chemicalsStatus = chemicalsStatus;
}
public String getPlanLevel() {
return planLevel;
}
public void setPlanLevel(String planLevel) {
this.planLevel = planLevel;
}
public String getChemicalsName() {
return chemicalsName;
}
public void setChemicalsName(String chemicalsName) {
this.chemicalsName = chemicalsName;
}
public String getLeakageLevel() {
return leakageLevel;
}
public void setLeakageLevel(String leakageLevel) {
this.leakageLevel = leakageLevel;
}
}

173
zc-business/src/main/java/com/zc/business/domain/DcEventImportantFile.java

@ -0,0 +1,173 @@
package com.zc.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 重要事件文件内容对象 dc_event_important_file
*
* @author ruoyi
* @date 2024-04-12
*/
public class DcEventImportantFile
{
private static final long serialVersionUID = 1L;
private Long id;
/** 事件id */
private String eventId;
/** 报送单位 */
@Excel(name = "报送单位")
private String fromDept;
/** 报送时间 */
@Excel(name = "报送时间")
private String createTime;
/** 标题 */
@Excel(name = "标题")
private String title;
/** 发至单位 */
@Excel(name = "发至单位")
private String toDept;
/** 内容 */
@Excel(name = "内容")
private String content;
/** 填报人 */
@Excel(name = "填报人")
private String createName;
/** 联系电话 */
@Excel(name = "联系电话")
private String phoneNumber;
/** 签发人 */
@Excel(name = "签发人")
private String issued;
/** 类型 1:初报,2续报,3终报 */
@Excel(name = "类型 1:初报,2续报,3终报")
private String type;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public void setEventId(String eventId)
{
this.eventId = eventId;
}
public String getEventId()
{
return eventId;
}
public void setFromDept(String fromDept)
{
this.fromDept = fromDept;
}
public String getFromDept()
{
return fromDept;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setToDept(String toDept)
{
this.toDept = toDept;
}
public String getToDept()
{
return toDept;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setCreateName(String createName)
{
this.createName = createName;
}
public String getCreateName()
{
return createName;
}
public void setPhoneNumber(String phoneNumber)
{
this.phoneNumber = phoneNumber;
}
public String getPhoneNumber()
{
return phoneNumber;
}
public void setIssued(String issued)
{
this.issued = issued;
}
public String getIssued()
{
return issued;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("eventId", getEventId())
.append("fromDept", getFromDept())
.append("createTime", getCreateTime())
.append("title", getTitle())
.append("toDept", getToDept())
.append("content", getContent())
.append("createName", getCreateName())
.append("phoneNumber", getPhoneNumber())
.append("issued", getIssued())
.append("type", getType())
.toString();
}
}

3
zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java

@ -49,8 +49,9 @@ public class DcEventProcess
/** 1-节点
2-信息发布
3-设备管控
4-文件生成
*/
@ApiModelProperty(value="流程类型 1-节点,2-信息发布,3-设备管控")
@ApiModelProperty(value="流程类型 1-节点,2-信息发布,3-设备管控,4-文件生成")
@Excel(name = "流程类型")
private Integer processType;

61
zc-business/src/main/java/com/zc/business/mapper/DcEventImportantFileMapper.java

@ -0,0 +1,61 @@
package com.zc.business.mapper;
import java.util.List;
import com.zc.business.domain.DcEventImportantFile;
/**
* 重要事件文件内容Mapper接口
*
* @author ruoyi
* @date 2024-04-12
*/
public interface DcEventImportantFileMapper
{
/**
* 查询重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 重要事件文件内容
*/
public DcEventImportantFile selectDcEventImportantFileByEventId(String id);
/**
* 查询重要事件文件内容列表
*
* @param dcEventImportantFile 重要事件文件内容
* @return 重要事件文件内容集合
*/
List<DcEventImportantFile> selectDcEventImportantFileList(DcEventImportantFile dcEventImportantFile);
/**
* 新增重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int insertDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 修改重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int updateDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 删除重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 结果
*/
int deleteDcEventImportantFileByEventId(String id);
/**
* 批量删除重要事件文件内容
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcEventImportantFileByEventIds(String[] ids);
}

61
zc-business/src/main/java/com/zc/business/mapper/DcEventImportantMapper.java

@ -0,0 +1,61 @@
package com.zc.business.mapper;
import java.util.List;
import com.zc.business.domain.DcEventImportant;
/**
* 事件侧重要素Mapper接口
*
* @author ruoyi
* @date 2024-04-11
*/
public interface DcEventImportantMapper
{
/**
* 查询事件侧重要素
*
* @param id 事件侧重要素主键
* @return 事件侧重要素
*/
public DcEventImportant selectDcEventImportantByEventId(String id);
/**
* 查询事件侧重要素列表
*
* @param dcEventImportant 事件侧重要素
* @return 事件侧重要素集合
*/
List<DcEventImportant> selectDcEventImportantList(DcEventImportant dcEventImportant);
/**
* 新增事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int insertDcEventImportant(DcEventImportant dcEventImportant);
/**
* 修改事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int updateDcEventImportant(DcEventImportant dcEventImportant);
/**
* 删除事件侧重要素
*
* @param id 事件侧重要素主键
* @return 结果
*/
int deleteDcEventImportantByEventId(String id);
/**
* 批量删除事件侧重要素
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcEventImportantByEventIds(String[] ids);
}

61
zc-business/src/main/java/com/zc/business/service/IDcEventImportantFileService.java

@ -0,0 +1,61 @@
package com.zc.business.service;
import java.util.List;
import com.zc.business.domain.DcEventImportantFile;
/**
* 重要事件文件内容Service接口
*
* @author ruoyi
* @date 2024-04-12
*/
public interface IDcEventImportantFileService
{
/**
* 查询重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 重要事件文件内容
*/
public DcEventImportantFile selectDcEventImportantFileByEventId(String id);
/**
* 查询重要事件文件内容列表
*
* @param dcEventImportantFile 重要事件文件内容
* @return 重要事件文件内容集合
*/
List<DcEventImportantFile> selectDcEventImportantFileList(DcEventImportantFile dcEventImportantFile);
/**
* 新增重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int insertDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 修改重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
int updateDcEventImportantFile(DcEventImportantFile dcEventImportantFile);
/**
* 批量删除重要事件文件内容
*
* @param ids 需要删除的重要事件文件内容主键集合
* @return 结果
*/
int deleteDcEventImportantFileByEventIds(String[] ids);
/**
* 删除重要事件文件内容信息
*
* @param id 重要事件文件内容主键
* @return 结果
*/
int deleteDcEventImportantFileByEventId(String id);
}

61
zc-business/src/main/java/com/zc/business/service/IDcEventImportantService.java

@ -0,0 +1,61 @@
package com.zc.business.service;
import java.util.List;
import com.zc.business.domain.DcEventImportant;
/**
* 事件侧重要素Service接口
*
* @author ruoyi
* @date 2024-04-11
*/
public interface IDcEventImportantService
{
/**
* 查询事件侧重要素
*
* @param id 事件侧重要素主键
* @return 事件侧重要素
*/
public DcEventImportant selectDcEventImportantByEventId(String id);
/**
* 查询事件侧重要素列表
*
* @param dcEventImportant 事件侧重要素
* @return 事件侧重要素集合
*/
List<DcEventImportant> selectDcEventImportantList(DcEventImportant dcEventImportant);
/**
* 新增事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int insertDcEventImportant(DcEventImportant dcEventImportant);
/**
* 修改事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
int updateDcEventImportant(DcEventImportant dcEventImportant);
/**
* 批量删除事件侧重要素
*
* @param ids 需要删除的事件侧重要素主键集合
* @return 结果
*/
int deleteDcEventImportantByEventIds(String[] ids);
/**
* 删除事件侧重要素信息
*
* @param id 事件侧重要素主键
* @return 结果
*/
int deleteDcEventImportantByEventId(String id);
}

120
zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantFileServiceImpl.java

@ -0,0 +1,120 @@
package com.zc.business.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.zc.business.domain.DcEventProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcEventImportantFileMapper;
import com.zc.business.domain.DcEventImportantFile;
import com.zc.business.service.IDcEventImportantFileService;
/**
* 重要事件文件内容Service业务层处理
*
* @author ruoyi
* @date 2024-04-12
*/
@Service
public class DcEventImportantFileServiceImpl implements IDcEventImportantFileService
{
@Autowired
private DcEventImportantFileMapper dcEventImportantFileMapper;
@Autowired
private DcEventProcessServiceImpl dcEventProcessService;
/**
* 查询重要事件文件内容
*
* @param id 重要事件文件内容主键
* @return 重要事件文件内容
*/
@Override
public DcEventImportantFile selectDcEventImportantFileByEventId(String id)
{
return dcEventImportantFileMapper.selectDcEventImportantFileByEventId(id);
}
/**
* 查询重要事件文件内容列表
*
* @param dcEventImportantFile 重要事件文件内容
* @return 重要事件文件内容
*/
@Override
public List<DcEventImportantFile> selectDcEventImportantFileList(DcEventImportantFile dcEventImportantFile)
{
return dcEventImportantFileMapper.selectDcEventImportantFileList(dcEventImportantFile);
}
/**
* 新增重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
@Override
public int insertDcEventImportantFile(DcEventImportantFile dcEventImportantFile)
{
int i = dcEventImportantFileMapper.insertDcEventImportantFile(dcEventImportantFile);
if (i > 0){
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(dcEventImportantFile.getEventId());
dcEventProcess.setOperationTime(new Date());
dcEventProcess.setOperator(SecurityUtils.getUserId().toString());
dcEventProcess.setSource(1);
dcEventProcess.setProcessType(4);
dcEventProcess.setProcessId(dcEventImportantFile.getId());
String context = "重要事件";
if ("1".equals(dcEventImportantFile.getType())){
context = "重要事件初报";
} else if ("2".equals(dcEventImportantFile.getType())){
context = "重要事件续报";
} else if ("3".equals(dcEventImportantFile.getType())){
context = "重要事件终报";
}
dcEventProcess.setContext(context);
dcEventProcessService.insertDcEventProcess(dcEventProcess);
}
return i;
}
/**
* 修改重要事件文件内容
*
* @param dcEventImportantFile 重要事件文件内容
* @return 结果
*/
@Override
public int updateDcEventImportantFile(DcEventImportantFile dcEventImportantFile)
{
return dcEventImportantFileMapper.updateDcEventImportantFile(dcEventImportantFile);
}
/**
* 批量删除重要事件文件内容
*
* @param ids 需要删除的重要事件文件内容主键
* @return 结果
*/
@Override
public int deleteDcEventImportantFileByEventIds(String[] ids)
{
return dcEventImportantFileMapper.deleteDcEventImportantFileByEventIds(ids);
}
/**
* 删除重要事件文件内容信息
*
* @param eventId 重要事件文件内容主键
* @return 结果
*/
@Override
public int deleteDcEventImportantFileByEventId(String id)
{
return dcEventImportantFileMapper.deleteDcEventImportantFileByEventId(id);
}
}

93
zc-business/src/main/java/com/zc/business/service/impl/DcEventImportantServiceImpl.java

@ -0,0 +1,93 @@
package com.zc.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcEventImportantMapper;
import com.zc.business.domain.DcEventImportant;
import com.zc.business.service.IDcEventImportantService;
/**
* 事件侧重要素Service业务层处理
*
* @author ruoyi
* @date 2024-04-11
*/
@Service
public class DcEventImportantServiceImpl implements IDcEventImportantService
{
@Autowired
private DcEventImportantMapper dcEventImportantMapper;
/**
* 查询事件侧重要素
*
* @param id 事件侧重要素主键
* @return 事件侧重要素
*/
@Override
public DcEventImportant selectDcEventImportantByEventId(String id)
{
return dcEventImportantMapper.selectDcEventImportantByEventId(id);
}
/**
* 查询事件侧重要素列表
*
* @param dcEventImportant 事件侧重要素
* @return 事件侧重要素
*/
@Override
public List<DcEventImportant> selectDcEventImportantList(DcEventImportant dcEventImportant)
{
return dcEventImportantMapper.selectDcEventImportantList(dcEventImportant);
}
/**
* 新增事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
@Override
public int insertDcEventImportant(DcEventImportant dcEventImportant)
{
return dcEventImportantMapper.insertDcEventImportant(dcEventImportant);
}
/**
* 修改事件侧重要素
*
* @param dcEventImportant 事件侧重要素
* @return 结果
*/
@Override
public int updateDcEventImportant(DcEventImportant dcEventImportant)
{
return dcEventImportantMapper.updateDcEventImportant(dcEventImportant);
}
/**
* 批量删除事件侧重要素
*
* @param ids 需要删除的事件侧重要素主键
* @return 结果
*/
@Override
public int deleteDcEventImportantByEventIds(String[] ids)
{
return dcEventImportantMapper.deleteDcEventImportantByEventIds(ids);
}
/**
* 删除事件侧重要素信息
*
* @param id 事件侧重要素主键
* @return 结果
*/
@Override
public int deleteDcEventImportantByEventId(String id)
{
return dcEventImportantMapper.deleteDcEventImportantByEventId(id);
}
}

216
zc-business/src/main/java/com/zc/business/utils/PoiUtil.java

@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Units;
import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
@ -18,10 +19,8 @@ import org.springframework.util.StringUtils;
import java.io.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
/**
* @author : LCheng
@ -30,8 +29,6 @@ import java.util.Map;
*/
public class PoiUtil {
public static int headingCount1 = 1;
public static int headingCount2 = 1;
/**
* 根据word模板导出 针对图表柱状图折线图饼图等的处理
@ -365,5 +362,212 @@ public class PoiUtil {
tocField.setInstr(tocFieldCode);
tocField.setDirty(STOnOff.TRUE);
}
/**
* 替换段落文本
* @param document docx解析对象
* @param textMap 需要替换的信息集合
*/
public static void changeText(XWPFDocument document, Map<String, Object> textMap){
//获取段落集合
// 获取段落集合
Iterator<XWPFParagraph> iterator = document.getParagraphsIterator();
XWPFParagraph paragraph = null;
while (iterator.hasNext()) {
paragraph = iterator.next();
// 判断此段落是否需要替换
if (checkText(paragraph.getText())) {
replaceValue(paragraph, textMap);
}
}
}
/***
* @Description :检查文本中是否包含指定的字符(此处为$)
* @param text
* @return boolean
* @Date 2022/11/17 17:22
*/
public static boolean checkText(String text) {
boolean check = false;
if (text.contains("$")) {
check = true;
}
return check;
}
/**
* 替换图片
*
* @param document
* @param picData
* @throws Exception
*/
public static void changePic(XWPFDocument document, Map<String, Object> picData) throws Exception {
// 获取段落集合
Iterator<XWPFParagraph> iterator = document.getParagraphsIterator();
XWPFParagraph paragraph;
while (iterator.hasNext()) {
paragraph = iterator.next();
// 判断此段落是否需要替换
String text = paragraph.getText();
if (checkText(text)) {
replacePicValue(paragraph, picData);
}
}
}
/***
* @Description :替换表格内的文字
* @param document
* @param data
* @return void
* @Date 2022/11/18 11:29
*/
public static void changeTableText(XWPFDocument document, Map<String, Object> data) {
// 获取文件的表格
Iterator<XWPFTable> tableList = document.getTablesIterator();
XWPFTable table;
List<XWPFTableRow> rows;
List<XWPFTableCell> cells;
// 循环所有需要进行替换的文本,进行替换
while (tableList.hasNext()) {
table = tableList.next();
if (checkText(table.getText())) {
rows = table.getRows();
// 遍历表格,并替换模板
for (XWPFTableRow row : rows) {
cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
// 判断单元格是否需要替换
if (checkText(cell.getText())) {
List<XWPFParagraph> paragraphs = cell.getParagraphs();
for (XWPFParagraph paragraph : paragraphs) {
replaceValue(paragraph, data);
}
}
}
}
}
}
}
/***
* @Description :替换表格内图片
* @param document
* @param picData
* @return void
* @Date 2022/11/18 11:29
*/
public static void changeTablePic(XWPFDocument document, Map<String, Object> picData) throws Exception {
// 获取文件的表格
Iterator<XWPFTable> tableList = document.getTablesIterator();
XWPFTable table;
List<XWPFTableRow> rows;
List<XWPFTableCell> cells;
// 循环所有需要进行替换的文本,进行替换
while (tableList.hasNext()) {
table = tableList.next();
if (checkText(table.getText())) {
rows = table.getRows();
// 遍历表格,并替换模板
for (XWPFTableRow row : rows) {
cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
// 判断单元格是否需要替换
if (checkText(cell.getText())) {
List<XWPFParagraph> paragraphs = cell.getParagraphs();
for (XWPFParagraph paragraph : paragraphs) {
replacePicValue(paragraph, picData);
}
}
}
}
}
}
}
/***
* @Description :替换内容
* @param paragraph
* @param textMap
* @return void
* @Date 2022/11/18 11:33
*/
public static void replaceValue(XWPFParagraph paragraph, Map<String, Object> textMap) {
XWPFRun run, nextRun;
String runsText;
List<XWPFRun> runs = paragraph.getRuns();
for (int i = 0; i < runs.size(); i++) {
run = runs.get(i);
runsText = run.getText(0);
if (runsText.contains("${") || (runsText.contains("$") && runs.get(i + 1).getText(0).substring(0, 1).equals("{"))) {
while (!runsText.contains("}")) {
nextRun = runs.get(i + 1);
runsText = runsText + nextRun.getText(0);
//删除该节点下的数据
paragraph.removeRun(i + 1);
}
Object value = changeValue(runsText, textMap);
//判断key在Map中是否存在
if (textMap.containsKey(runsText)) {
if (value != null) {
run.setText(value.toString(), 0);
} else {
run.setText("", 0);
}
} else {
//如果匹配不到,则不修改
run.setText(runsText, 0);
}
}
}
}
/***
* @Description :替换图片内容
* @param paragraph
* @param picData
* @return void
* @Date 2022/11/18 11:33
*/
public static void replacePicValue(XWPFParagraph paragraph, Map<String, Object> picData) throws Exception {
List<XWPFRun> runs = paragraph.getRuns();
for (XWPFRun run : runs) {
Object value = changeValue(run.toString(), picData);
if (picData.containsKey(run.toString())) {
//清空内容
run.setText("", 0);
FileInputStream is = new FileInputStream((String) value);
//图片宽度、高度
int width = Units.toEMU(100), height = Units.toEMU(100);
//添加图片信息,段落高度需要在模板中自行调整
run.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, (String) value, width, height);
}
}
}
/***
* @Description :匹配参数
* @param value
* @param textMap
* @return java.lang.Object
* @Date 2022/11/18 11:33
*/
public static Object changeValue(String value, Map<String, Object> textMap) {
Object valu = "";
for (Map.Entry<String, Object> textSet : textMap.entrySet()) {
// 匹配模板与替换值 格式${key}
String key = textSet.getKey();
if (value.contains(key)) {
valu = textSet.getValue();
}
}
return valu;
}
}

101
zc-business/src/main/resources/mapper/business/DcEventImportantFileMapper.xml

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcEventImportantFileMapper">
<resultMap type="DcEventImportantFile" id="DcEventImportantFileResult">
<result property="id" column="id" />
<result property="eventId" column="event_id" />
<result property="fromDept" column="from_dept" />
<result property="createTime" column="create_time" />
<result property="title" column="title" />
<result property="toDept" column="to_dept" />
<result property="content" column="content" />
<result property="createName" column="create_name" />
<result property="phoneNumber" column="phone_number" />
<result property="issued" column="issued" />
<result property="type" column="type" />
</resultMap>
<sql id="selectDcEventImportantFileVo">
select id,event_id, from_dept, create_time, title, to_dept, content, create_name, phone_number, issued, type from dc_event_important_file
</sql>
<select id="selectDcEventImportantFileList" parameterType="DcEventImportantFile" resultMap="DcEventImportantFileResult">
<include refid="selectDcEventImportantFileVo"/>
<where>
<if test="eventId != null and fromDept != ''"> and event_id = #{eventId}</if>
<if test="fromDept != null and fromDept != ''"> and from_dept = #{fromDept}</if>
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="toDept != null and toDept != ''"> and to_dept = #{toDept}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="createName != null and createName != ''"> and create_name like concat('%', #{createName}, '%')</if>
<if test="phoneNumber != null and phoneNumber != ''"> and phone_number = #{phoneNumber}</if>
<if test="issued != null and issued != ''"> and issued = #{issued}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
</where>
</select>
<select id="selectDcEventImportantFileByEventId" parameterType="String" resultMap="DcEventImportantFileResult">
<include refid="selectDcEventImportantFileVo"/>
where id = #{id}
</select>
<insert id="insertDcEventImportantFile" parameterType="DcEventImportantFile" useGeneratedKeys="true" keyProperty="id">
insert into dc_event_important_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventId != null">event_id,</if>
<if test="fromDept != null">from_dept,</if>
<if test="createTime != null">create_time,</if>
<if test="title != null">title,</if>
<if test="toDept != null">to_dept,</if>
<if test="content != null">content,</if>
<if test="createName != null">create_name,</if>
<if test="phoneNumber != null">phone_number,</if>
<if test="issued != null">issued,</if>
<if test="type != null">type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventId != null">#{eventId},</if>
<if test="fromDept != null">#{fromDept},</if>
<if test="createTime != null">#{createTime},</if>
<if test="title != null">#{title},</if>
<if test="toDept != null">#{toDept},</if>
<if test="content != null">#{content},</if>
<if test="createName != null">#{createName},</if>
<if test="phoneNumber != null">#{phoneNumber},</if>
<if test="issued != null">#{issued},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<update id="updateDcEventImportantFile" parameterType="DcEventImportantFile">
update dc_event_important_file
<trim prefix="SET" suffixOverrides=",">
<if test="eventId != null">event_id = #{eventId},</if>
<if test="fromDept != null">from_dept = #{fromDept},</if>
<if test="fromDept != null">from_dept = #{fromDept},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="title != null">title = #{title},</if>
<if test="toDept != null">to_dept = #{toDept},</if>
<if test="content != null">content = #{content},</if>
<if test="createName != null">create_name = #{createName},</if>
<if test="phoneNumber != null">phone_number = #{phoneNumber},</if>
<if test="issued != null">issued = #{issued},</if>
<if test="type != null">type = #{type},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcEventImportantFileByEventId" parameterType="String">
delete from dc_event_important_file where id = #{id}
</delete>
<delete id="deleteDcEventImportantFileByEventIds" parameterType="String">
delete from dc_event_important_file where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

121
zc-business/src/main/resources/mapper/business/DcEventImportantMapper.xml

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcEventImportantMapper">
<resultMap type="DcEventImportant" id="DcEventImportantResult">
<result property="id" column="id" />
<result property="eventId" column="event_id" />
<result property="plateNumber" column="plate_number" />
<result property="diversionPoint" column="diversion_point" />
<result property="currentProgress" column="current_progress" />
<result property="takeSteps" column="take_steps" />
<result property="planStatus" column="plan_status" />
<result property="trafficPoliceStatus" column="traffic_police_status" />
<result property="medicalStatus" column="medical_status" />
<result property="fireStatus" column="fire_status" />
<result property="boardStatus" column="board_status" />
<result property="chemicalsStatus" column="chemicals_status" />
<result property="planLevel" column="plan_level" />
<result property="chemicalsName" column="chemicals_name" />
<result property="leakageLevel" column="leakage_level" />
</resultMap>
<sql id="selectDcEventImportantVo">
select id, event_id, plate_number, diversion_point, current_progress, take_steps, plan_status, traffic_police_status, medical_status, fire_status, board_status, chemicals_status, plan_level, chemicals_name, leakage_level from dc_event_important
</sql>
<select id="selectDcEventImportantList" parameterType="DcEventImportant" resultMap="DcEventImportantResult">
<include refid="selectDcEventImportantVo"/>
<where>
<if test="eventId != null and eventId != ''"> and event_id = #{eventId}</if>
<if test="plateNumber != null and plateNumber != ''"> and plate_number = #{plateNumber}</if>
<if test="diversionPoint != null and diversionPoint != ''"> and diversion_point = #{diversionPoint}</if>
<if test="currentProgress != null and currentProgress != ''"> and current_progress = #{currentProgress}</if>
<if test="takeSteps != null and takeSteps != ''"> and take_steps = #{takeSteps}</if>
<if test="planStatus != null "> and plan_status = #{planStatus}</if>
<if test="trafficPoliceStatus != null "> and traffic_police_status = #{trafficPoliceStatus}</if>
<if test="medicalStatus != null "> and medical_status = #{medicalStatus}</if>
<if test="fireStatus != null "> and fire_status = #{fireStatus}</if>
<if test="boardStatus != null "> and board_status = #{boardStatus}</if>
<if test="chemicalsStatus != null "> and chemicals_status = #{chemicalsStatus}</if>
<if test="planLevel != null and planLevel != ''"> and plan_level = #{planLevel}</if>
<if test="chemicalsName != null and chemicalsName != ''"> and chemicals_name like concat('%', #{chemicalsName}, '%')</if>
<if test="leakageLevel != null and leakageLevel != ''"> and leakage_level = #{leakageLevel}</if>
</where>
</select>
<select id="selectDcEventImportantByEventId" parameterType="String" resultMap="DcEventImportantResult">
<include refid="selectDcEventImportantVo"/>
where event_id = #{eventId}
</select>
<insert id="insertDcEventImportant" parameterType="DcEventImportant">
insert into dc_event_important
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventId != null">event_id,</if>
<if test="plateNumber != null">plate_number,</if>
<if test="diversionPoint != null">diversion_point,</if>
<if test="currentProgress != null">current_progress,</if>
<if test="takeSteps != null">take_steps,</if>
<if test="planStatus != null">plan_status,</if>
<if test="trafficPoliceStatus != null">traffic_police_status,</if>
<if test="medicalStatus != null">medical_status,</if>
<if test="fireStatus != null">fire_status,</if>
<if test="boardStatus != null">board_status,</if>
<if test="chemicalsStatus != null">chemicals_status,</if>
<if test="planLevel != null">plan_level,</if>
<if test="chemicalsName != null">chemicals_name,</if>
<if test="leakageLevel != null">leakage_level,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventId != null">#{eventId},</if>
<if test="plateNumber != null">#{plateNumber},</if>
<if test="diversionPoint != null">#{diversionPoint},</if>
<if test="currentProgress != null">#{currentProgress},</if>
<if test="takeSteps != null">#{takeSteps},</if>
<if test="planStatus != null">#{planStatus},</if>
<if test="trafficPoliceStatus != null">#{trafficPoliceStatus},</if>
<if test="medicalStatus != null">#{medicalStatus},</if>
<if test="fireStatus != null">#{fireStatus},</if>
<if test="boardStatus != null">#{boardStatus},</if>
<if test="chemicalsStatus != null">#{chemicalsStatus},</if>
<if test="planLevel != null">#{planLevel},</if>
<if test="chemicalsName != null">#{chemicalsName},</if>
<if test="leakageLevel != null">#{leakageLevel},</if>
</trim>
</insert>
<update id="updateDcEventImportant" parameterType="DcEventImportant">
update dc_event_important
<trim prefix="SET" suffixOverrides=",">
<if test="eventId != null">event_id = #{eventId},</if>
<if test="plateNumber != null">plate_number = #{plateNumber},</if>
<if test="diversionPoint != null">diversion_point = #{diversionPoint},</if>
<if test="currentProgress != null">current_progress = #{currentProgress},</if>
<if test="takeSteps != null">take_steps = #{takeSteps},</if>
<if test="planStatus != null">plan_status = #{planStatus},</if>
<if test="trafficPoliceStatus != null">traffic_police_status = #{trafficPoliceStatus},</if>
<if test="medicalStatus != null">medical_status = #{medicalStatus},</if>
<if test="fireStatus != null">fire_status = #{fireStatus},</if>
<if test="boardStatus != null">board_status = #{boardStatus},</if>
<if test="chemicalsStatus != null">chemicals_status = #{chemicalsStatus},</if>
<if test="planLevel != null">plan_level = #{planLevel},</if>
<if test="chemicalsName != null">chemicals_name = #{chemicalsName},</if>
<if test="leakageLevel != null">leakage_level = #{leakageLevel},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcEventImportantByEventId" parameterType="String">
delete from dc_event_important where id = #{id}
</delete>
<delete id="deleteDcEventImportantByEventIds" parameterType="String">
delete from dc_event_important where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

BIN
zc-business/src/main/resources/wordTemplate/importantTemplate.docx

Binary file not shown.
Loading…
Cancel
Save