|
|
@ -1,9 +1,11 @@ |
|
|
|
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.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
import com.hnac.hzims.safeproduct.constants.SafeProductConstant; |
|
|
|
import com.hnac.hzims.safeproduct.constants.SafeProductConstant; |
|
|
|
import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; |
|
|
|
import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; |
|
|
|
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; |
|
|
|
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; |
|
|
@ -23,6 +25,7 @@ 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; |
|
|
@ -136,7 +139,8 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void exportTrainRecordData(Long id, HttpServletResponse response) { |
|
|
|
public void exportTrainRecordData(Long id, HttpServletResponse response) { |
|
|
|
TrainRecordDetailVO trainRecordDetailVO = this.getTrainRecordDetailById(id); |
|
|
|
TrainRecordDetailVO trainRecordDetailVO = this.getTrainRecordDetailById(id); |
|
|
|
// 培训方式字段
|
|
|
|
// 数据处理
|
|
|
|
|
|
|
|
// 培训方式
|
|
|
|
String trainMethod = trainRecordDetailVO.getTrainMethod(); |
|
|
|
String trainMethod = trainRecordDetailVO.getTrainMethod(); |
|
|
|
if (trainMethod.equals(TrainMethodEnum.MIXED.getValue())) { |
|
|
|
if (trainMethod.equals(TrainMethodEnum.MIXED.getValue())) { |
|
|
|
trainRecordDetailVO.setTrainMethod(TrainMethodEnum.MIXED.getDesc()); |
|
|
|
trainRecordDetailVO.setTrainMethod(TrainMethodEnum.MIXED.getDesc()); |
|
|
@ -145,6 +149,21 @@ public class TrainRecordServiceImpl extends ServiceImpl<TrainRecordMapper, Train |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
trainRecordDetailVO.setTrainMethod(TrainMethodEnum.OFFLINE.getDesc()); |
|
|
|
trainRecordDetailVO.setTrainMethod(TrainMethodEnum.OFFLINE.getDesc()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 图片
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) { |
|
|
|
|
|
|
|
String[] imgArr = trainRecordDetailVO.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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
trainRecordDetailVO.setImages(list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 表头年月
|
|
|
|
|
|
|
|
String code = trainRecordDetailVO.getCode(); |
|
|
|
|
|
|
|
trainRecordDetailVO.setYear(code.substring(4, 8)); |
|
|
|
|
|
|
|
trainRecordDetailVO.setMonth(code.substring(8, 10)); |
|
|
|
Map<String, Object> params = BaseUtil.obj2Map(trainRecordDetailVO); |
|
|
|
Map<String, Object> params = BaseUtil.obj2Map(trainRecordDetailVO); |
|
|
|
String templateFile = "template/培训记录表" + SafeProductConstant.DOCX_SUFFIX; |
|
|
|
String templateFile = "template/培训记录表" + SafeProductConstant.DOCX_SUFFIX; |
|
|
|
String wordPath = savePath + "/培训记录表" + SafeProductConstant.DOCX_SUFFIX; |
|
|
|
String wordPath = savePath + "/培训记录表" + SafeProductConstant.DOCX_SUFFIX; |
|
|
|