diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java index 8c439aa218..9c461a1f18 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java @@ -19,6 +19,7 @@ public interface ImportTaskConstants { String BIZ_TYPE_ATTENTION_VACCINATION = "attention_vaccination"; String BIZ_TYPE_ATTENTION_TRIP_REPORT = "attention_vaccination"; String BIZ_TYPE_IC_PARTY_MEMBER = "ic_party_member"; + String IC_POINT_NUCLEIC_MONITORING = "ic_point_nucleic_monitoring"; /** * 核酸检测 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CommunityInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CommunityInfoResultDTO.java new file mode 100644 index 0000000000..46300096d5 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CommunityInfoResultDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 社区所属组织基本信息 + * @Author wgf + * @Date 2020/4/26 22:35 + */ +@Data +public class CommunityInfoResultDTO implements Serializable { + private static final long serialVersionUID = 4360690752084258055L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 社区组织ID + */ + private String deptId; + + /** + * 社区名称 + */ + private String deptName; + + /** + * 网格的上级组织 + */ + private String pid; + + /** + * 网格的所有上级组织 + */ + private String pids; +} + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 5325163074..24008e536e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -463,5 +463,17 @@ public class CustomerAgencyController { return new Result().ok(customerAgencyService.getDelAgencyGridIdList(agencyId)); } + /** + * @param orgName + * @return com.epmet.commons.tools.utils.Result + * @Author wgf + * @Description 根据社区名称查询所属组织信息 + * @Date 2022/6/21 22:41 + **/ + @GetMapping("getCommunityInfo/{orgName}") + public Result getCommunityInfo(@PathVariable("orgName") String orgName) { + return customerAgencyService.getCommunityInfo(orgName); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 02e483d9f2..17fb8356f3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -344,5 +344,7 @@ public interface CustomerAgencyDao extends BaseDao { @Param("customerId") String customerId); List getDelAgencyIdList(@Param("agencyId") String agencyId); + + CommunityInfoResultDTO getCommunityInfo(@Param("orgName") String orgName); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index dcdc1d44a8..d6651bc29b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -24,6 +24,7 @@ import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; +import org.springframework.web.bind.annotation.PathVariable; import java.util.List; import java.util.Map; @@ -317,4 +318,13 @@ public interface CustomerAgencyService extends BaseService * @Description 获取当前组织及下级无效组织、网格Id列表 **/ DelAgencyGridIdResultDTO getDelAgencyGridIdList(String agencyId); + + /** + * @param orgName + * @return com.epmet.commons.tools.utils.Result + * @Author wgf + * @Description 根据社区名称查询所属组织信息 + * @Date 2022/6/21 22:41 + **/ + Result getCommunityInfo(String orgName); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index adaf547abf..7c6cfa6d50 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -1566,4 +1566,11 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl getCommunityInfo(String orgName) { + CommunityInfoResultDTO communityInfoResultDTO = baseDao.getCommunityInfo(orgName); + + return new Result().ok(communityInfoResultDTO); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 2fd5aa5feb..e5d635d88f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -880,4 +880,17 @@ AND pids LIKE CONCAT('%', #{agencyId}, '%') + + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcPointNucleicMonitoringController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcPointNucleicMonitoringController.java index 4b97c98389..b1bc4385a3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcPointNucleicMonitoringController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcPointNucleicMonitoringController.java @@ -1,7 +1,13 @@ package com.epmet.controller; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +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.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.AssertUtils; @@ -9,13 +15,22 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcPointNucleicMonitoringDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.excel.IcPointNucleicMonitoringExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcPointNucleicMonitoringService; +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; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,11 +43,15 @@ import java.util.Map; */ @RestController @RequestMapping("icPointNucleicMonitoring") +@Slf4j public class IcPointNucleicMonitoringController { @Autowired private IcPointNucleicMonitoringService icPointNucleicMonitoringService; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @RequestMapping("page") public Result> page(@RequestParam Map params){ PageData page = icPointNucleicMonitoringService.page(params); @@ -78,5 +97,57 @@ public class IcPointNucleicMonitoringController { } + /** + * Desc: 【核酸检测点】导入 + * @param + * @author wgf + * @date 2022/6/21 13:40 + */ + @PostMapping("pointNucleicMonitoringImport") + public Result pointNucleicMonitoringImport(@LoginUser TokenDto tokenDto, @RequestParam("file") MultipartFile file){ + if (file.isEmpty()) { + throw new EpmetException("请上传文件"); + } + // 校验文件类型 + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (!"xls".equals(extension) && !"xlsx".equals(extension)) { + throw new EpmetException("文件类型不匹配"); + } + + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.IC_POINT_NUCLEIC_MONITORING); + Result 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("读取文件失败"); + } + icPointNucleicMonitoringService.importFile(tokenDto,inputStream,result.getData().getTaskId()); + return new Result(); + } + + /** + * 导出模板 + * @param response + * @throws Exception + */ + @PostMapping("exporttemplate") + public void exportTemplate( HttpServletResponse response) throws Exception { + TemplateExportParams templatePath = new TemplateExportParams("excel/ic_point_nucleic_monitoring.xlsx"); + ExcelPoiUtils.exportExcel(templatePath ,new HashMap<>(),"核酸检测点录入表",response); + } + + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcPointNucleicMonitoringDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcPointNucleicMonitoringDao.java index 5621b19449..563d33553d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcPointNucleicMonitoringDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcPointNucleicMonitoringDao.java @@ -4,6 +4,8 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.IcPointNucleicMonitoringEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 核酸监测点 * @@ -12,5 +14,11 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcPointNucleicMonitoringDao extends BaseDao { - -} \ No newline at end of file + + /** + * 获取所有地点名称 + * @return + */ + List getAllAddressName(); + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcPointNucleicMonitoringImportExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcPointNucleicMonitoringImportExcel.java new file mode 100644 index 0000000000..22c04a2b51 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcPointNucleicMonitoringImportExcel.java @@ -0,0 +1,58 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; +import lombok.Data; + +import java.util.Date; + +/** + * 核酸监测点 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-06-20 + */ +@Data +public class IcPointNucleicMonitoringImportExcel { + + @Excel(name = "所属组织名称") + private String orgName; + + @Excel(name = "核酸监测点名称") + private String name; + + @Excel(name = "服务时间") + private String serveTime; + + @Excel(name = "咨询电话") + private String mobile; + + @Excel(name = "监测点地址") + private String address; + + @ExcelIgnore + private Boolean addStatus = false; + + @ExcelIgnore + private Integer num; + + /** + * 所属组织ID + */ + @ExcelIgnore + private String orgId; + + /** + * 组织ID上级 + */ + @ExcelIgnore + private String pid; + + /** + * 组织ID所有上级 + */ + @ExcelIgnore + private String pids; + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/PointNucleicMonitoringErrorModel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/PointNucleicMonitoringErrorModel.java new file mode 100644 index 0000000000..722142e35b --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/error/PointNucleicMonitoringErrorModel.java @@ -0,0 +1,35 @@ +package com.epmet.excel.error; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * @Author wgf + * @DateTime 2022/6/21 16:57 + * @DESC + */ +@Data +public class PointNucleicMonitoringErrorModel { + + @Excel(name = "行号",width = 10) + private Integer num; + + @Excel(name = "所属组织名称",width = 30) + private String orgName; + + @Excel(name = "核酸监测点名称",width = 30) + private String name; + + @Excel(name = "服务时间",width = 20) + private String serveTime; + + @Excel(name = "电话",width = 30) + private String mobile; + + @Excel(name = "监测点地址",width = 40) + private String address; + + @Excel(name = "错误信息", width = 200) + private String errorMsg; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index e0f881766e..b364fa689d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.CommonGridIdFormDTO; import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.result.CommunityInfoResultDTO; import com.epmet.dto.result.GridInfoResultDTO; import com.epmet.feign.fallback.GovOrgFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; @@ -63,4 +64,14 @@ public interface GovOrgFeignClient { //@PostMapping("/gov/org/grid/getbaseinfo") //Result getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO); + /** + * @param orgName + * @return com.epmet.commons.tools.utils.Result + * @Author wgf + * @Description 根据社区名称查询所属组织信息 + * @Date 2020/4/26 23:16 + **/ + @GetMapping("/gov/org/customeragency/getCommunityInfo/{orgName}") + Result getCommunityInfo(@PathVariable("orgName") String orgName); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java index 047208bdc4..f01da41601 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.CommonGridIdFormDTO; import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.result.CommunityInfoResultDTO; import com.epmet.dto.result.GridInfoResultDTO; import com.epmet.feign.GovOrgFeignClient; import org.springframework.stereotype.Component; @@ -39,4 +40,9 @@ public class GovOrgFeignClientFallBack implements GovOrgFeignClient { //public Result getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO) { // return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridBaseInfoByGridId", customerGridFormDTO); //} + + @Override + public Result getCommunityInfo(String orgName) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCommunityInfo",orgName); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java index 5cde04efe2..d74f89f861 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcPointNucleicMonitoringService.java @@ -2,9 +2,11 @@ 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.IcPointNucleicMonitoringDTO; import com.epmet.entity.IcPointNucleicMonitoringEntity; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -75,4 +77,13 @@ public interface IcPointNucleicMonitoringService extends BaseService implements IcPointNucleicMonitoringService { @Autowired private IcPointNucleicMonitoringRedis icPointNucleicMonitoringRedis; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + + @Autowired + private OssFeignClient ossFeignClient; + + @Autowired + private GovOrgFeignClient govOrgFeignClient; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -84,4 +128,196 @@ public class IcPointNucleicMonitoringServiceImpl extends BaseServiceImpl errorInfo = new ArrayList<>(); + + try { + List list = ExcelPoiUtils.importExcel(inputStream, 0,1,IcPointNucleicMonitoringImportExcel.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()); + } + // 获取所有地点名称 + List addressList = baseDao.getAllAddressName(); + for (int i = 0; i < list.size(); i++) { + list.get(i).setNum(i+1); + if (StringUtils.isBlank(list.get(i).getOrgName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "所属组织名称不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + 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).getServeTime()) && !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; + } + if (StringUtils.isBlank(list.get(i).getAddress()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "监测点地址不能为空",i+1)); + list.get(i).setAddStatus(true); + continue; + } + // 校验数据库是否存在该地点名称 + if (addressList.contains(list.get(i).getName()) && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "核酸监测点名称已存在",i+1)); + list.get(i).setAddStatus(true); + continue; + } + + // 校验所属组织通过名称能否匹配到ID + Result resultDTOResult = govOrgFeignClient.getCommunityInfo(list.get(i).getOrgName()); + CommunityInfoResultDTO communityInfoResultDTO = resultDTOResult.getData(); + if(communityInfoResultDTO == null && !list.get(i).getAddStatus()){ + errorInfo.add(getErrorInfo(list.get(i), "所属组织匹配失败",i+1)); + list.get(i).setAddStatus(true); + continue; + }else{ + list.get(i).setOrgId(communityInfoResultDTO.getDeptId()); + list.get(i).setPid(communityInfoResultDTO.getPid()); + list.get(i).setPids(communityInfoResultDTO.getPids()); + } + + } + if (list.size() > errorInfo.size()){ + Map groupByName = list.stream().collect(Collectors.groupingBy(IcPointNucleicMonitoringImportExcel::getName, Collectors.counting())); + groupByName.forEach((name,count) -> { + if (Integer.valueOf(count.toString()).compareTo(1) != 0){ + for (IcPointNucleicMonitoringImportExcel i : list) { + if (name.equals(i.getName()) && !i.getAddStatus()){ + errorInfo.add(getErrorInfo(i,"数据重复",i.getNum())); + i.setAddStatus(true); + } + } + } + }); + } + Map> groupByStatus = list.stream().collect(Collectors.groupingBy(IcPointNucleicMonitoringImportExcel::getAddStatus)); + List needInsert = groupByStatus.get(false); + if (CollectionUtils.isNotEmpty(needInsert)){ + List entities = ConvertUtils.sourceToTarget(needInsert, IcPointNucleicMonitoringEntity.class); + entities.forEach(e -> { + // 设置客户ID + 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,""); + } + } + + /** + * Desc: 关闭任务 + * @param taskId + * @param userId + * @param status + * @param url + * @author wgf + * @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 wgf + * @date 2022/3/29 17:17 + */ + public PointNucleicMonitoringErrorModel getErrorInfo(IcPointNucleicMonitoringImportExcel dto, String info, Integer num){ + PointNucleicMonitoringErrorModel result = ConvertUtils.sourceToTarget(dto, PointNucleicMonitoringErrorModel.class); + result.setErrorMsg(info); + result.setNum(num); + return result; + } + + /** + * Desc: 文件上传并返回url + * @param errorRows + * @param tClass + * @author zxc + * @date 2022/3/30 09:16 + */ + public String importOssUpload(Collection errorRows, Class 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 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(); + } + + +} diff --git a/epmet-user/epmet-user-server/src/main/resources/excel/ic_point_nucleic_monitoring.xlsx b/epmet-user/epmet-user-server/src/main/resources/excel/ic_point_nucleic_monitoring.xlsx new file mode 100644 index 0000000000..5afef2dc0a Binary files /dev/null and b/epmet-user/epmet-user-server/src/main/resources/excel/ic_point_nucleic_monitoring.xlsx differ diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcPointNucleicMonitoringDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcPointNucleicMonitoringDao.xml index e3c97b3342..2cb4e10db6 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcPointNucleicMonitoringDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcPointNucleicMonitoringDao.xml @@ -24,5 +24,12 @@ + - \ No newline at end of file + +