Browse Source

fix: 解决会议管理文件导出图片显示异常的问题

zhongwei
liwen 1 year ago
parent
commit
a9b4b4a995
  1. 10
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java
  2. 11
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailVO.java
  3. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java
  4. 11
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferenceRecordService.java
  5. 6
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java
  6. 60
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java
  7. BIN
      hzims-service/safeproduct/src/main/resources/template/会议记录表.docx

10
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java

@ -22,11 +22,9 @@ public class ConferenceExportDTO {
private String unit; private String unit;
@ApiModelProperty("会议计划开始时间") @ApiModelProperty("会议计划开始时间")
@ExcelProperty(value = "会议计划开始时间", index = 1)
private Date scheduledStartTime; private Date scheduledStartTime;
@ApiModelProperty("会议计划结束时间") @ApiModelProperty("会议计划结束时间")
@ExcelProperty(value = "会议计划结束时间", index = 2)
private Date scheduledEndTime; private Date scheduledEndTime;
@ApiModelProperty("会议主题") @ApiModelProperty("会议主题")
@ -48,4 +46,12 @@ public class ConferenceExportDTO {
@ApiModelProperty("会议状态") @ApiModelProperty("会议状态")
@ExcelProperty(value = "会议状态", index = 7) @ExcelProperty(value = "会议状态", index = 7)
private String conferenceStatus; private String conferenceStatus;
@ApiModelProperty("计划开始时间")
@ExcelProperty(value = "计划开始时间", index = 1)
private String startTime;
@ApiModelProperty("计划结束时间")
@ExcelProperty(value = "计划结束时间", index = 2)
private String endTime;
} }

11
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailVO.java

@ -1,10 +1,12 @@
package com.hnac.hzims.safeproduct.vo; package com.hnac.hzims.safeproduct.vo;
import cn.afterturn.easypoi.entity.ImageEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author liwen * @author liwen
@ -52,4 +54,13 @@ public class ConferenceRecordDetailVO {
@ApiModelProperty("会议附件") @ApiModelProperty("会议附件")
private String filePath; private String filePath;
@ApiModelProperty("图片列表")
private List<ImageEntity> images;
@ApiModelProperty("年份")
private String year;
@ApiModelProperty("月份")
private String month;
} }

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

@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity;
import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity;
import com.hnac.hzims.safeproduct.service.IConferencePlanService; import com.hnac.hzims.safeproduct.service.IConferencePlanService;
@ -110,13 +109,14 @@ public class ConferenceController extends BladeController {
@GetMapping("/recordPage") @GetMapping("/recordPage")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "conferencePlanId", value = "会议计划id", dataType = "query", paramType = "string") @ApiImplicitParam(name = "conferencePlanId", value = "会议计划id", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "actualStartTime", value = "计划开始时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "actualEndTime", value = "计划结束时间", dataType = "query", paramType = "string")
}) })
@ApiOperation(value = "会议记录分页") @ApiOperation(value = "会议记录分页")
@ApiOperationSupport(order = 10) @ApiOperationSupport(order = 10)
public R<IPage<ConferenceRecordEntity>> recordPage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { public R<IPage<ConferenceRecordEntity>> recordPage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<ConferenceRecordEntity> page = conferenceRecordService.page(Condition.getPage(query), Condition.getQueryWrapper( IPage<ConferenceRecordEntity> page = conferenceRecordService.recordPage(param, query);
param, ConferenceRecordEntity.class).lambda().orderByDesc(ConferenceRecordEntity::getCreateTime));
return R.data(page); return R.data(page);
} }

11
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferenceRecordService.java

@ -1,10 +1,13 @@
package com.hnac.hzims.safeproduct.service; package com.hnac.hzims.safeproduct.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity;
import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailVO; import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailVO;
import org.springblade.core.mp.support.Query;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/** /**
* 会议记录服务类 * 会议记录服务类
@ -41,4 +44,12 @@ public interface IConferenceRecordService extends IService<ConferenceRecordEntit
* @return 会议记录表VO类 * @return 会议记录表VO类
*/ */
ConferenceRecordDetailVO getConferenceRecordDetailById(Long id); ConferenceRecordDetailVO getConferenceRecordDetailById(Long id);
/**
* 会议记录分页
* @param param 入参
* @param query 分页类
* @return 会议记录数据
*/
IPage<ConferenceRecordEntity> recordPage(Map<String, Object> param, Query query);
} }

6
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java

@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.service.IConferencePlanService;
import com.hnac.hzims.safeproduct.service.IConferenceRecordService; import com.hnac.hzims.safeproduct.service.IConferenceRecordService;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -89,7 +90,7 @@ public class ConferencePlanServiceImpl extends ServiceImpl<ConferencePlanMapper,
String startTime = String.valueOf(param.get("scheduledStartTime")); String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf(param.get("scheduledEndTime")); String endTime = String.valueOf(param.get("scheduledEndTime"));
List<ConferenceExportDTO> conferenceList = getConferenceByUnitAndDate(unit, startTime, endTime); List<ConferenceExportDTO> conferenceList = getConferenceByUnitAndDate(unit, startTime, endTime);
// 处理会议数据信息 // 数据处理
conferenceList.forEach(conference -> { conferenceList.forEach(conference -> {
// 会议方式 // 会议方式
String method; String method;
@ -111,6 +112,9 @@ public class ConferencePlanServiceImpl extends ServiceImpl<ConferencePlanMapper,
status = ConferenceStatusEnum.FINISHED.getDesc(); status = ConferenceStatusEnum.FINISHED.getDesc();
} }
conference.setConferenceStatus(status); conference.setConferenceStatus(status);
// 时间格式
conference.setStartTime(DateUtil.format(conference.getScheduledStartTime(), DateUtil.PATTERN_DATE));
conference.setEndTime(DateUtil.format(conference.getScheduledEndTime(), DateUtil.PATTERN_DATE));
}); });
// 设置响应头 // 设置响应头
// URLEncoder.encode防止中文乱码 // URLEncoder.encode防止中文乱码

60
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java

@ -1,9 +1,13 @@
package com.hnac.hzims.safeproduct.service.impl; package com.hnac.hzims.safeproduct.service.impl;
import cn.afterturn.easypoi.entity.ImageEntity;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import com.alibaba.excel.util.CollectionUtils; import com.alibaba.excel.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity;
import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity;
@ -14,11 +18,14 @@ import com.hnac.hzims.safeproduct.mapper.ConferenceRecordMapper;
import com.hnac.hzims.safeproduct.service.IConferenceRecordService; import com.hnac.hzims.safeproduct.service.IConferenceRecordService;
import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailVO; import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailVO;
import org.springblade.core.mp.support.Query;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -60,14 +67,16 @@ public class ConferenceRecordServiceImpl extends ServiceImpl<ConferenceRecordMap
/** /**
* 新增会议记录 * 新增会议记录
*/ */
@Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean saveRecord(ConferenceRecordEntity conferenceRecord) { public boolean saveRecord(ConferenceRecordEntity conferenceRecord) {
// 获取当月时间(yyyymm) // 获取当月时间
String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date());
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号 // 查询是否存在同月编号
String lastCode = getLastCode(currentMonth); String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号 // 若不存在,新增编号
String code = BaseUtil.getUniqueCode("HYJL", lastCode, currentMonth); String code = BaseUtil.getUniqueCode("HYJL", lastCode, currentSimpleMonth);
conferenceRecord.setCode(code); conferenceRecord.setCode(code);
boolean save = this.save(conferenceRecord); boolean save = this.save(conferenceRecord);
// 若会议记录新增成功,修改会议计划状态为已完成 // 若会议记录新增成功,修改会议计划状态为已完成
@ -85,7 +94,8 @@ public class ConferenceRecordServiceImpl extends ServiceImpl<ConferenceRecordMap
@Override @Override
public void exportConferenceRecordData(Long id, HttpServletResponse response) { public void exportConferenceRecordData(Long id, HttpServletResponse response) {
ConferenceRecordDetailVO conferenceRecordDetailVO = this.getConferenceRecordDetailById(id); ConferenceRecordDetailVO conferenceRecordDetailVO = this.getConferenceRecordDetailById(id);
// 会议方式字段 // 数据处理
// 会议方式
String conferenceMethod = conferenceRecordDetailVO.getConferenceMethod(); String conferenceMethod = conferenceRecordDetailVO.getConferenceMethod();
if (conferenceMethod.equals(ConferenceMethodEnum.MIXED.getValue())) { if (conferenceMethod.equals(ConferenceMethodEnum.MIXED.getValue())) {
conferenceRecordDetailVO.setConferenceMethod(ConferenceMethodEnum.MIXED.getDesc()); conferenceRecordDetailVO.setConferenceMethod(ConferenceMethodEnum.MIXED.getDesc());
@ -94,6 +104,21 @@ public class ConferenceRecordServiceImpl extends ServiceImpl<ConferenceRecordMap
} else { } else {
conferenceRecordDetailVO.setConferenceMethod(ConferenceMethodEnum.OFFLINE.getDesc()); conferenceRecordDetailVO.setConferenceMethod(ConferenceMethodEnum.OFFLINE.getDesc());
} }
// 表头年月
String code = conferenceRecordDetailVO.getCode();
conferenceRecordDetailVO.setYear(code.substring(4, 8));
conferenceRecordDetailVO.setMonth(code.substring(8, 10));
// 图片
if (StringUtils.isNotEmpty(conferenceRecordDetailVO.getImgPath())) {
String[] imgArr = conferenceRecordDetailVO.getImgPath().split(",");
List<ImageEntity> list = new ArrayList<>();
for (String img : imgArr) {
ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath +
BaseUtil.downloadFileByUrl(img, savePath)), 180, 150);
list.add(imageEntity);
}
conferenceRecordDetailVO.setImages(list);
}
Map<String, Object> params = BaseUtil.obj2Map(conferenceRecordDetailVO); Map<String, Object> params = BaseUtil.obj2Map(conferenceRecordDetailVO);
String templateFile = "template/会议记录表" + SafeProductConstant.DOCX_SUFFIX; String templateFile = "template/会议记录表" + SafeProductConstant.DOCX_SUFFIX;
String wordPath = savePath + "/会议记录表" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/会议记录表" + SafeProductConstant.DOCX_SUFFIX;
@ -110,13 +135,34 @@ public class ConferenceRecordServiceImpl extends ServiceImpl<ConferenceRecordMap
} }
/** /**
* 会议记录分页
*/
@Override
public IPage<ConferenceRecordEntity> recordPage(Map<String, Object> param, Query query) {
QueryWrapper<ConferenceRecordEntity> queryWrapper = new QueryWrapper<>();
String conferencePlanId = String.valueOf(param.get("conferencePlanId"));
String startTime = String.valueOf(param.get("actualStartTime"));
String endTime = String.valueOf((param.get("actualEndTime")));
if (!conferencePlanId.equals("null") && !conferencePlanId.equals("")) {
queryWrapper.lambda().eq(ConferenceRecordEntity::getConferencePlanId, conferencePlanId);
}
if (!startTime.equals("null") && !startTime.equals("")) {
queryWrapper.lambda().ge(ConferenceRecordEntity::getActualStartTime, startTime);
}
if (!endTime.equals("null") && !endTime.equals("")) {
queryWrapper.lambda().le(ConferenceRecordEntity::getActualEndTime, endTime);
}
queryWrapper.lambda().orderByDesc(ConferenceRecordEntity::getCreateTime);
return this.page(Condition.getPage(query), queryWrapper);
}
/**
* 查询是否存在同月编号 * 查询是否存在同月编号
* @param currentMonth 当月 * @param currentMonth 当月
* @return 存在则返回上一编号否则返回null * @return 存在则返回上一编号否则返回null
*/ */
private String getLastCode(String currentMonth) { private String getLastCode(String currentMonth) {
String month = currentMonth.substring(currentMonth.length() - 2); List<ConferenceRecordEntity> list = getConferenceByMonth(currentMonth);
List<ConferenceRecordEntity> list = getConferenceByMonth(month);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return null; return null;
} }

BIN
hzims-service/safeproduct/src/main/resources/template/会议记录表.docx

Binary file not shown.
Loading…
Cancel
Save