Browse Source

Merge remote-tracking branch 'origin/dev_epidemic_situation' into dev_epidemic_situation

master
yinzuomei 3 years ago
parent
commit
1b76381fc7
  1. 3
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  2. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java
  3. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionPackageFormDTO.java
  4. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinationListFormDTO.java
  5. 46
      epmet-user/epmet-user-client/src/main/java/com/epmet/enums/AttentionTypeEnum.java
  6. 44
      epmet-user/epmet-user-client/src/main/java/com/epmet/enums/ChannelEnum.java
  7. 52
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java
  8. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcEpidemicSpecialAttentionEntity.java
  9. 66
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ImportEpidemicSpecialAttention.java
  10. 29
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/EpidemicSpecialAttentionErrorModel.java
  11. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java
  12. 228
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java

3
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java

@ -15,6 +15,9 @@ public interface ImportTaskConstants {
String BIZ_TYPE_COMMUNITY_SELF_ORG = "community_self_org";
String BIZ_TYPE_PARTY_UNIT = "party_unit";
String BIZ_TYPE_PARTY_ACTIVITY = "party_activity";
String BIZ_TYPE_ATTENTION_NAT = "attention_nat";
String BIZ_TYPE_ATTENTION_VACCINATION = "attention_vaccination";
String BIZ_TYPE_ATTENTION_TRIP_REPORT = "attention_vaccination";
/**
* 核酸检测
*/

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcEpidemicSpecialAttentionDTO.java

@ -55,7 +55,7 @@ public class IcEpidemicSpecialAttentionDTO implements Serializable {
private Integer isAttention;
/**
* 关注类型核酸检测2疫苗接种1
* 关注类型核酸检测2疫苗接种1行程上报0
*/
@NotNull(message = "attentionType不能为空",groups = {IcEpidemicSpecialAttentionAdd.class,IcEpidemicSpecialAttentionUpdate.class})
private Integer attentionType;

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CancelAttentionPackageFormDTO.java

@ -28,7 +28,7 @@ public class CancelAttentionPackageFormDTO implements Serializable {
private List<String> idCards;
/**
* 关注类型核酸检测2疫苗接种1
* 关注类型核酸检测2疫苗接种1行程上报0
*/
@NotNull(message = "attentionType不能为空",groups = CancelAttentionPackageForm.class)
private Integer attentionType ;

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/VaccinationListFormDTO.java

@ -20,7 +20,7 @@ public class VaccinationListFormDTO extends PageFormDTO implements Serializable
public interface VaccinationListForm{}
/**
* 关注类型核酸检测2疫苗接种1
* 关注类型核酸检测2疫苗接种1行程上报0
*/
@NotNull(message = "attentionType不能为空",groups = VaccinationListForm.class)
private Integer attentionType;

46
epmet-user/epmet-user-client/src/main/java/com/epmet/enums/AttentionTypeEnum.java

@ -0,0 +1,46 @@
package com.epmet.enums;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
/**
* @Author zxc
* @DateTime 2022/3/29 16:17
* @DESC
*/
public enum AttentionTypeEnum {
XCSB(0,"行程上报"),
YMJZ(1,"疫苗接种"),
NAT(2,"核酸检测")
;
private Integer key;
private String value;
AttentionTypeEnum(Integer key, String value) {
this.key = key;
this.value = value;
}
public static Integer getKeyByValue(String value){
if (StringUtils.isBlank(value)){
return NumConstant.ZERO;
}
for (AttentionTypeEnum a : AttentionTypeEnum.values()) {
if (a.getValue().equals(value)){
return a.getKey();
}
}
return NumConstant.ZERO;
}
public Integer getKey() {
return key;
}
public String getValue() {
return value;
}
}

44
epmet-user/epmet-user-client/src/main/java/com/epmet/enums/ChannelEnum.java

@ -0,0 +1,44 @@
package com.epmet.enums;
import com.epmet.commons.tools.constant.NumConstant;
import org.apache.commons.lang3.StringUtils;
/**
* @Author zxc
* @DateTime 2022/3/29 16:35
* @DESC
*/
public enum ChannelEnum {
MINI("0","小程序"),
MSG("1","短信")
;
private String key;
private String value;
ChannelEnum(String key, String value) {
this.key = key;
this.value = value;
}
public static String getKeyByValue(String value){
if (StringUtils.isBlank(value)){
return NumConstant.ONE_STR;
}
for (ChannelEnum a : ChannelEnum.values()) {
if (a.getValue().equals(value)){
return a.getKey();
}
}
return NumConstant.ONE_STR;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
}

52
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcEpidemicSpecialAttentionController.java

@ -4,23 +4,28 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.IcEpidemicSpecialAttentionDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.excel.NatExportExcel;
import com.epmet.excel.UserResiRegisterVisitExcel;
import com.epmet.excel.VaccinationExportExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.IcEpidemicSpecialAttentionService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
/**
@ -31,10 +36,13 @@ import javax.servlet.http.HttpServletResponse;
*/
@RestController
@RequestMapping("icEpidemicSpecialAttention")
@Slf4j
public class IcEpidemicSpecialAttentionController {
@Autowired
private IcEpidemicSpecialAttentionService icEpidemicSpecialAttentionService;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
/**
* Desc: 疫苗接种关注名单疫苗接种关注名单列表
@ -102,8 +110,42 @@ public class IcEpidemicSpecialAttentionController {
* @date 2022/3/28 13:40
*/
@PostMapping("vaccination-import")
public Result vaccinationImport(@LoginUser TokenDto tokenDTO, @RequestParam("file") MultipartFile file,@RequestParam("attentionType")Integer attentionType){
public Result vaccinationImport(@LoginUser TokenDto tokenDto, @RequestParam("file") MultipartFile file,@RequestParam("attentionType")Integer attentionType){
if (file.isEmpty()) {
throw new EpmetException("请上传文件");
}
// 校验文件类型
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
throw new EpmetException("文件类型不匹配");
}
// 关注类型,核酸检测:2,疫苗接种:1,行程上报:0
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOriginFileName(file.getOriginalFilename());
importTaskForm.setOperatorId(tokenDto.getUserId());
if (attentionType.equals(NumConstant.ONE)){
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_ATTENTION_VACCINATION);
}else if (attentionType.equals(NumConstant.TWO)){
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_ATTENTION_NAT);
}else if (attentionType.equals(NumConstant.ZERO)){
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_ATTENTION_TRIP_REPORT);
}
Result<ImportTaskCommonResultDTO> result = commonServiceOpenFeignClient.createImportTask(importTaskForm);
if (!result.success()) {
throw new EpmetException(9999,"存在进行中的导入");
}
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
}catch (Exception e){
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(tokenDto.getUserId());
input.setTaskId(result.getData().getTaskId());
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
commonServiceOpenFeignClient.finishImportTask(input);
log.error("读取文件失败");
}
icEpidemicSpecialAttentionService.importFile(tokenDto,inputStream,attentionType,result.getData().getTaskId());
return new Result();
}
@ -122,7 +164,7 @@ public class IcEpidemicSpecialAttentionController {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setPage(false);
PageData pageData = icEpidemicSpecialAttentionService.vaccinationList(formDTO);
// 关注类型,核酸检测:2,疫苗接种:1
// 关注类型,核酸检测:2,疫苗接种:1,行程上报:0
if (formDTO.getAttentionType().equals(NumConstant.ONE)){
ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), VaccinationExportExcel.class);
}else {

2
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcEpidemicSpecialAttentionEntity.java

@ -47,7 +47,7 @@ public class IcEpidemicSpecialAttentionEntity extends BaseEpmetEntity {
private Integer isAttention;
/**
* 关注类型核酸检测2疫苗接种1
* 关注类型核酸检测2疫苗接种1行程上报0
*/
private Integer attentionType;

66
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ImportEpidemicSpecialAttention.java

@ -0,0 +1,66 @@
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.epmet.commons.tools.utils.ExcelVerifyInfo;
import lombok.Data;
import java.util.List;
/**
* @Author zxc
* @DateTime 2022/3/29 15:47
* @DESC
*/
@Data
public class ImportEpidemicSpecialAttention extends ExcelVerifyInfo {
/**
* 姓名
*/
@Excel(name = "姓名")
private String name;
/**
* 手机号
*/
@Excel(name = "手机号")
private String mobile;
/**
* 身份证号
*/
@Excel(name = "身份证号")
private String idCard;
/**
* 原因
*/
@Excel(name = "关注原因")
private String reason;
/**
* 备注
*/
@Excel(name = "备注")
private String remark;
@ExcelIgnore
private Integer attentionType;
@Excel(name = "通知内容")
private String content;
@Excel(name = "通知渠道")
private String channelString;
@ExcelIgnore
private List<String> channel;
@ExcelIgnore
private Boolean addStatus = false;
@ExcelIgnore
private Integer num;
}

29
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/EpidemicSpecialAttentionErrorModel.java

@ -0,0 +1,29 @@
package com.epmet.excel.error;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @Author zxc
* @DateTime 2022/3/29 16:57
* @DESC
*/
@Data
public class EpidemicSpecialAttentionErrorModel {
@Excel(name = "行号",width = 10)
private Integer num;
@Excel(name = "姓名",width = 20)
private String name;
@Excel(name = "电话",width = 20)
private String mobile;
@Excel(name = "身份证",width = 30)
private String idCard;
@Excel(name = "错误信息", width = 200)
private String errorMsg;
}

12
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcEpidemicSpecialAttentionService.java

@ -2,12 +2,14 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.IcEpidemicSpecialAttentionDTO;
import com.epmet.dto.form.CancelAttentionPackageFormDTO;
import com.epmet.dto.form.VaccinationAddFormDTO;
import com.epmet.dto.form.VaccinationListFormDTO;
import com.epmet.entity.IcEpidemicSpecialAttentionEntity;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -113,6 +115,16 @@ public interface IcEpidemicSpecialAttentionService extends BaseService<IcEpidemi
*/
void cancelAttention(CancelAttentionPackageFormDTO formDTO);
/**
* Desc: 疫苗接种关注名单核酸检测关注名单导入
* @param tokenDto
* @param inputStream
* @param attentionType
* @author zxc
* @date 2022/3/29 15:35
*/
void importFile(TokenDto tokenDto, InputStream inputStream, Integer attentionType, String taskId);
/**
* 传入身份证集合返回已经关注的身份证号列表
* @param idCardSet

228
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcEpidemicSpecialAttentionServiceImpl.java

@ -1,5 +1,7 @@
package com.epmet.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -8,27 +10,57 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcEpidemicSpecialAttentionDao;
import com.epmet.dto.IcEpidemicSpecialAttentionDTO;
import com.epmet.dto.form.CancelAttentionPackageFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.VaccinationAddFormDTO;
import com.epmet.dto.form.VaccinationListFormDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.VaccinationListResultDTO;
import com.epmet.entity.IcEpidemicSpecialAttentionEntity;
import com.epmet.enums.AttentionTypeEnum;
import com.epmet.enums.ChannelEnum;
import com.epmet.excel.ImportEpidemicSpecialAttention;
import com.epmet.excel.error.EpidemicSpecialAttentionErrorModel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.IcEpidemicSpecialAttentionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -38,8 +70,14 @@ import java.util.stream.Collectors;
* @since v1.0.0 2022-03-28
*/
@Service
@Slf4j
public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpidemicSpecialAttentionDao, IcEpidemicSpecialAttentionEntity> implements IcEpidemicSpecialAttentionService {
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
@Override
public PageData<IcEpidemicSpecialAttentionDTO> page(Map<String, Object> params) {
IPage<IcEpidemicSpecialAttentionEntity> page = baseDao.selectPage(
@ -106,7 +144,7 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
throw new EpmetException("未查询到工作人员信息"+formDTO.getUserId());
}
formDTO.setOrgId(staffInfo.getAgencyId());
// 关注类型,核酸检测:2,疫苗接种:1
// 关注类型,核酸检测:2,疫苗接种:1,行程上报:0
if (formDTO.getAttentionType().equals(NumConstant.ONE)){
if (formDTO.isPage()){
PageInfo<VaccinationListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.vaccinationList(formDTO));
@ -214,6 +252,148 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
}
}
/**
* Desc: 疫苗接种关注名单核酸检测关注名单导入
* @param tokenDto
* @param inputStream
* @param attentionType
* @param taskId
* @author zxc
* @date 2022/3/29 15:35
*/
@Override
@Async
public void importFile(TokenDto tokenDto, InputStream inputStream, Integer attentionType, String taskId) {
List<EpidemicSpecialAttentionErrorModel> errorInfo = new ArrayList<>();
try {
List<ImportEpidemicSpecialAttention> list = ExcelPoiUtils.importExcel(inputStream, 0,1,ImportEpidemicSpecialAttention.class);
if (CollectionUtils.isEmpty(list)){
closeTask(taskId,tokenDto.getUserId(), ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,"");
return;
}
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
if (null == staffInfo){
throw new EpmetException("未查询到工作人员信息"+tokenDto.getUserId());
}
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId());
if (null == agencyInfo){
throw new EpmetException("未查询到组织信息"+staffInfo.getAgencyId());
}
for (int i = 0; i < list.size(); i++) {
list.get(i).setNum(i+1);
list.get(i).setAttentionType(attentionType);
list.get(i).setChannel(getChannel(list.get(i).getChannelString()));
if (StringUtils.isBlank(list.get(i).getName()) && !list.get(i).getAddStatus()){
errorInfo.add(getErrorInfo(list.get(i), "姓名不能为空",i+1));
list.get(i).setAddStatus(true);
continue;
}
if (StringUtils.isBlank(list.get(i).getIdCard()) && !list.get(i).getAddStatus()){
errorInfo.add(getErrorInfo(list.get(i), "身份证号不能为空",i+1));
list.get(i).setAddStatus(true);
continue;
}
if (StringUtils.isBlank(list.get(i).getMobile()) && !list.get(i).getAddStatus()){
errorInfo.add(getErrorInfo(list.get(i), "电话不能为空",i+1));
list.get(i).setAddStatus(true);
continue;
}
}
Map<String, Long> groupByIdCard = list.stream().collect(Collectors.groupingBy(ImportEpidemicSpecialAttention::getIdCard, Collectors.counting()));
groupByIdCard.forEach((idCard,count) -> {
if (Integer.valueOf(count.toString()).compareTo(1) != 0){
for (ImportEpidemicSpecialAttention i : list) {
if (idCard.equals(i.getIdCard()) && !i.getAddStatus()){
errorInfo.add(getErrorInfo(i,"数据重复",i.getNum()));
i.setAddStatus(true);
}
}
}
});
List<String> idCards = list.stream().map(m -> m.getIdCard()).collect(Collectors.toList());
List<String> existList = baseDao.getExistList(attentionType, idCards);
if (CollectionUtils.isNotEmpty(existList)){
for (String s : existList) {
for (int i = NumConstant.ZERO; i < list.size(); i++) {
if (s.equals(list.get(i).getIdCard()) && !list.get(i).getAddStatus()){
errorInfo.add(getErrorInfo(list.get(i),"数据已存在",list.get(i).getNum()));
list.get(i).setAddStatus(true);
continue;
}
}
}
}
Map<Boolean, List<ImportEpidemicSpecialAttention>> groupByStatus = list.stream().collect(Collectors.groupingBy(ImportEpidemicSpecialAttention::getAddStatus));
List<ImportEpidemicSpecialAttention> needInsert = groupByStatus.get(false);
if (CollectionUtils.isNotEmpty(needInsert)){
List<IcEpidemicSpecialAttentionEntity> entities = ConvertUtils.sourceToTarget(needInsert, IcEpidemicSpecialAttentionEntity.class);
entities.forEach(e -> {
e.setIsAttention(NumConstant.ONE);
e.setOrgId(agencyInfo.getId());
e.setPid(agencyInfo.getPid());
e.setPids(agencyInfo.getPids());
e.setCustomerId(tokenDto.getCustomerId());
});
insertBatch(entities);
}
if (CollectionUtils.isNotEmpty(errorInfo)){
String url = importOssUpload(errorInfo, EpidemicSpecialAttentionErrorModel.class);
closeTask(taskId,tokenDto.getUserId(),ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,url);
}else {
closeTask(taskId,tokenDto.getUserId(),ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS,"");
}
}catch (Exception e){
log.error(e.getMessage());
closeTask(taskId,tokenDto.getUserId(),ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,"");
}
}
public List<String> getChannel(String channelString){
List<String> result = new ArrayList<>();
if (StringUtils.isBlank(channelString)){
return result;
}
String[] split = channelString.split(",");
for (String s : split) {
result.add(ChannelEnum.getKeyByValue(s));
}
return result;
}
/**
* Desc: 关闭任务
* @param taskId
* @param userId
* @param status
* @param url
* @author zxc
* @date 2022/3/30 09:05
*/
public void closeTask(String taskId,String userId,String status,String url){
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(userId);
input.setTaskId(taskId);
input.setProcessStatus(status);
input.setResultDescFilePath(url);
commonServiceOpenFeignClient.finishImportTask(input);
}
/**
* Desc: 构造错误信息
* @param dto
* @param info
* @param num
* @author zxc
* @date 2022/3/29 17:17
*/
public EpidemicSpecialAttentionErrorModel getErrorInfo(ImportEpidemicSpecialAttention dto,String info,Integer num){
EpidemicSpecialAttentionErrorModel result = ConvertUtils.sourceToTarget(dto, EpidemicSpecialAttentionErrorModel.class);
result.setErrorMsg(info);
result.setNum(num);
return result;
}
/**
* 传入身份证集合返回已经关注的身份证号列表
*
@ -229,4 +409,50 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
return baseDao.getIdCardList(customerId,idCardSet,NumConstant.TWO);
}
/**
* Desc: 文件上传并返回url
* @param errorRows
* @param tClass
* @author zxc
* @date 2022/3/30 09:16
*/
public <T> String importOssUpload(Collection<?> errorRows, Class<T> tClass) throws IOException {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"),
tClass, errorRows);
// 文件名
String resultDescFileName = UUID.randomUUID().toString().concat(".xls");
FileItemFactory factory = new DiskFileItemFactory(16, null);
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
OutputStream os = fileItem.getOutputStream();
Result<UploadImgResultDTO> uploadResult = null;
try {
workbook.write(os);
uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem));
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("上传错误描述文件:{}", errormsg);
} finally {
try {
os.close();
} catch (IOException e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("上传错误描述文件关闭输出流:{}", errormsg);
}
try {
fileItem.delete();
} catch (Exception e) {
String errormsg = ExceptionUtils.getErrorStackTrace(e);
log.error("上传错误描述文件删除临时文件:{}", errormsg);
}
}
if (uploadResult == null || !uploadResult.success()) {
log.error("调用OSS上传结果描述文件失败");
return null;
}
return uploadResult.getData().getUrl();
}
}
Loading…
Cancel
Save