diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/CorpImportLogController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/CorpImportLogController.java index d0737e93..62653f40 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/CorpImportLogController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/CorpImportLogController.java @@ -126,7 +126,6 @@ public class CorpImportLogController { try { String fileType = fileName.substring(fileName.lastIndexOf(".")); if (".json".equals(fileType.toLowerCase())) { - //FileUtil.readString(file.getInputStream(), Charset.forName("UTF-8")); String jsonData = IoUtil.read(file.getInputStream()).toString(); List basicUnitMaintainEntities = JSONUtil.toList(jsonData, BasicUnitMaintainEntity.class); diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoExportLogController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoExportLogController.java index 6ccab466..f9aa8b1c 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoExportLogController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoExportLogController.java @@ -10,10 +10,10 @@ import com.glxp.api.admin.req.inout.DeleteRequest; import com.glxp.api.admin.res.PageSimpleResponse; import com.glxp.api.admin.res.basic.UdiRelevanceResponse; import com.glxp.api.admin.res.basic.UdiRlDlResponse; -import com.glxp.api.admin.res.inout.WarehouseResponse; import com.glxp.api.admin.service.basic.UdiInfoExportLogService; import com.glxp.api.admin.service.basic.UdiRelevanceService; import com.glxp.api.admin.thread.BasicGenExcelService; +import com.glxp.api.admin.thread.BasicGenJsonService; import com.glxp.api.admin.util.CustomUtil; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; @@ -46,6 +46,8 @@ public class UdiInfoExportLogController { UdiRelevanceService udiRelevanceService; @Resource BasicGenExcelService basicGenExcelService; + @Resource + BasicGenJsonService basicGenJsonService; @GetMapping("/udiwms/products/exportLog/filter") @@ -115,19 +117,18 @@ public class UdiInfoExportLogController { //产品信息导出生成Excel,并创建生成记录 @PostMapping("/udiwms/products/importLog/export") public BaseResponse excelDownload(@RequestBody UdiInfoExportRequest udiInfoExportRequest) { - - UdiInfoExportLogEntity udiInfoExportLogEntity = new UdiInfoExportLogEntity(); udiInfoExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS); String genKey = CustomUtil.getId(); - String fileName = "D:\\udiwms\\exportFile\\" + "医疗器械信息导出" + genKey + ".xls"; + String fileName = "D:\\udiwms\\exportFile\\" + "医疗器械信息导出" + genKey + ".json"; udiInfoExportLogEntity.setGenKey(genKey); udiInfoExportLogEntity.setFilePath(fileName); udiInfoExportLogEntity.setUpdateTime(new Date()); udiInfoExportLogEntity.setDlCount(0); - udiInfoExportLogEntity.setType(BasicProcessStatus.EXPORT_EXCEL); + udiInfoExportLogEntity.setType(BasicProcessStatus.EXPORT_JSON); udiInfoExportLogService.insertUdiInfoExportLog(udiInfoExportLogEntity); - basicGenExcelService.exportUdiInfo(genKey, udiInfoExportRequest); + //basicGenExcelService.exportUdiInfo(genKey, udiInfoExportRequest); + basicGenJsonService.exportUdiInfoJson(genKey, udiInfoExportRequest); return ResultVOUtils.success("后台正在导出生成excel文件,请稍后刷新查看!"); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java index d1bcd185..7b643625 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java +++ b/api-admin/src/main/java/com/glxp/api/admin/controller/basic/UdiInfoImportLogController.java @@ -1,6 +1,7 @@ package com.glxp.api.admin.controller.basic; -import cn.hutool.extra.pinyin.PinyinUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.json.JSONUtil; import com.github.pagehelper.PageInfo; import com.glxp.api.admin.constant.BasicProcessStatus; import com.glxp.api.admin.entity.basic.UdiInfoImportDetailEntity; @@ -9,16 +10,16 @@ import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest; import com.glxp.api.admin.req.basic.PostUdiInfoRequest; import com.glxp.api.admin.req.inout.DeleteRequest; import com.glxp.api.admin.res.PageSimpleResponse; -import com.glxp.api.admin.service.basic.UdiInfoImportLogService; +import com.glxp.api.admin.res.basic.UdiRelevanceExportJsonResponse; import com.glxp.api.admin.service.basic.UdiInfoImportDetailService; +import com.glxp.api.admin.service.basic.UdiInfoImportLogService; import com.glxp.api.admin.thread.BasicUdiInfoImportService; import com.glxp.api.admin.util.CustomUtil; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.validation.BindingResult; @@ -27,10 +28,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.File; -import java.io.IOException; -import java.io.InputStream; import java.sql.Date; -import java.util.ArrayList; import java.util.List; /** @@ -48,6 +46,7 @@ public class UdiInfoImportLogController { BasicUdiInfoImportService basicUdiInfoImportService; private static final String TAG = "UdiInfoImportLogControl"; private static final Logger log = LoggerFactory.getLogger(UdiInfoImportLogController.class); + @GetMapping("/udiwms/products/importLog/filter") public BaseResponse filter(FilterUdiIpLogRequest filterUdiIpLogRequest, BindingResult bindingResult) { @@ -130,121 +129,33 @@ public class UdiInfoImportLogController { } String fileName = file.getOriginalFilename(); try { - InputStream inputStream = file.getInputStream(); - Workbook workbook = null; - String filetype = fileName.substring(fileName.lastIndexOf(".")); - - if (".xls".equals(filetype)) { - workbook = new HSSFWorkbook(inputStream); - } else if (".xlsx".equals(filetype)) { - workbook = new XSSFWorkbook(inputStream); - } else { - return ResultVOUtils.error(500, "请上传excel文件"); + String fileType = fileName.substring(fileName.lastIndexOf(".")); + if (!".json".equals(fileType.toLowerCase())) { + return ResultVOUtils.error(500, "请上传json文件"); } - Sheet sheet = null; - Row row = null; - UdiInfoImportLogEntity udiInfoImportLogEntity = new UdiInfoImportLogEntity(); + //导入数据 + String jsonData = IoUtil.read(file.getInputStream()).toString(); + UdiRelevanceExportJsonResponse importData = JSONUtil.toBean(jsonData, UdiRelevanceExportJsonResponse.class); + + //导入日志 + UdiInfoImportLogEntity importLog = new UdiInfoImportLogEntity(); String genKey = CustomUtil.getId(); - udiInfoImportLogEntity.setGenKey(genKey); - udiInfoImportLogEntity.setFromType("文件导入"); - udiInfoImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS); - udiInfoImportLogEntity.setUpdateTime(new Date(System.currentTimeMillis())); - udiInfoImportLogService.insertImportLog(udiInfoImportLogEntity); - List udiInfoImportEntities = new ArrayList<>(); - for (int j = 0; j < 1; j++) { - sheet = workbook.getSheetAt(j); - if (sheet == null) { - continue; - } - // 滤过第一行标题 - row = sheet.getRow(0); - if ((row.getCell(0) == null || row.getCell(1) == null || row.getCell(2) == null - || row.getCell(3) == null || row.getCell(4) == null || row.getCell(5) == null || row.getCell(6) == null) || - (!"udiCode".equals(row.getCell(0).getStringCellValue()) - || !"医保编码".equals(row.getCell(1).getStringCellValue()) - || !"商品条码".equals(row.getCell(2).getStringCellValue()) - || !"thirdId".equals(row.getCell(3).getStringCellValue()) - || !"thirdId1".equals(row.getCell(4).getStringCellValue()) - || !"thirdId2".equals(row.getCell(5).getStringCellValue()) - || !"thirdId3".equals(row.getCell(6).getStringCellValue()))) { - return ResultVOUtils.error(500, "文件格式错误!"); - } - for (int k = sheet.getFirstRowNum() + 1; k <= sheet.getLastRowNum(); k++) { - row = sheet.getRow(k); - if (row == null || row.getRowNum() <= 0) { - continue; - } - if (filterEmpty(row)) { - continue; - } - UdiInfoImportDetailEntity udiInfoImportEntity = new UdiInfoImportDetailEntity(); - Cell cell1 = row.getCell(0); - if (cell1 != null) { - cell1.setCellType(CellType.STRING); - udiInfoImportEntity.setUdiCode(cell1.getStringCellValue()); - } - - - Cell cell2 = row.getCell(1); - if (cell2 != null) { - cell2.setCellType(CellType.STRING); - udiInfoImportEntity.setYbbm(cell2.getStringCellValue()); - } - Cell cell3 = row.getCell(2); - if (cell3 != null) { - cell3.setCellType(CellType.STRING); - udiInfoImportEntity.setSptm(cell3.getStringCellValue()); - - } - Cell cell4 = row.getCell(3); - if (cell4 != null) { - cell4.setCellType(CellType.STRING); - udiInfoImportEntity.setThirdId(cell4.getStringCellValue()); - - } - Cell cell5 = row.getCell(4); - if (cell5 != null) { - cell5.setCellType(CellType.STRING); - udiInfoImportEntity.setThirdId1(cell5.getStringCellValue()); - - } - Cell cell6 = row.getCell(5); - if (cell6 != null) { - cell6.setCellType(CellType.STRING); - udiInfoImportEntity.setThirdId2(cell6.getStringCellValue()); - } - - Cell cell7 = row.getCell(6); - if (cell7 != null) { - cell7.setCellType(CellType.STRING); - udiInfoImportEntity.setThirdId3(cell7.getStringCellValue()); - } - Cell cell8 = row.getCell(7); - if (cell8 != null) { - cell8.setCellType(CellType.STRING); - udiInfoImportEntity.setThirdId4(cell8.getStringCellValue()); - } - Cell cell9 = row.getCell(8); - if (cell9 != null) { - cell9.setCellType(CellType.STRING); - udiInfoImportEntity.setIsUseDy(cell9.getStringCellValue()); - } - - udiInfoImportEntity.setGenKeyFk(genKey); - udiInfoImportEntity.setStatus(0); - udiInfoImportEntity.setUpdateTime(new Date(System.currentTimeMillis())); - udiInfoImportEntities.add(udiInfoImportEntity); - } - } - udiInfoImportService.insertUdiInfoImports(udiInfoImportEntities); - udiInfoImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS); - udiInfoImportLogService.updateImportLog(udiInfoImportLogEntity); - workbook.close(); - basicUdiInfoImportService.importUdiInfo(genKey); - } catch (IOException e) { - e.printStackTrace(); + importLog.setGenKey(genKey); + importLog.setFromType("文件导入"); + importLog.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS); + + importLog.setUpdateTime(new Date(System.currentTimeMillis())); + udiInfoImportLogService.insertImportLog(importLog); + udiInfoImportService.importJsonData(importData); + importLog.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); + udiInfoImportLogService.updateImportLog(importLog); + } catch (Exception e) { + log.error("产品信息导入失败", e); } + } + + return ResultVOUtils.success("上传成功"); } @@ -378,7 +289,7 @@ public class UdiInfoImportLogController { udiInfoImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_CODE_UNPROCESS); udiInfoImportLogEntity.setUpdateTime(new java.util.Date()); udiInfoImportLogService.insertImportLog(udiInfoImportLogEntity); - basicUdiInfoImportService.downloadSmpUdiInfo(genKey,filterUdiIpLogRequest.getLastUpdateTime()); + basicUdiInfoImportService.downloadSmpUdiInfo(genKey, filterUdiIpLogRequest.getLastUpdateTime()); return ResultVOUtils.success("后台已开始下载并更新,请稍后刷新查看!"); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/BasicUnitMaintainDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/BasicUnitMaintainDao.java index 40c954f0..42c6d3c6 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/BasicUnitMaintainDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/BasicUnitMaintainDao.java @@ -2,7 +2,6 @@ package com.glxp.api.admin.dao.basic; import com.glxp.api.admin.entity.basic.BasicUnitMaintainEntity; import com.glxp.api.admin.req.basic.BasicUnitMaintainFilterRequest; -import com.glxp.api.admin.req.basic.BasicUnitMaintainSaveRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -16,6 +15,14 @@ public interface BasicUnitMaintainDao { boolean insert(BasicUnitMaintainEntity basicUnitMaintainEntity); + /** + * 导入数据 + * + * @param basicUnitMaintainEntity + * @return + */ + boolean importBasicUnitMaintain(BasicUnitMaintainEntity basicUnitMaintainEntity); + boolean updateById(BasicUnitMaintainEntity basicUnitMaintainSaveRequest); BasicUnitMaintainEntity selectByThirdId(BasicUnitMaintainFilterRequest basicUnitMaintainFilterRequest); diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java index f7752bbb..d30ef312 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoDao.java @@ -1,7 +1,6 @@ package com.glxp.api.admin.dao.basic; import com.glxp.api.admin.entity.basic.UdiInfoEntity; -import com.glxp.api.admin.entity.inout.Unit; import com.glxp.api.admin.req.basic.FilterUdiInfoRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -29,4 +28,19 @@ public interface UdiInfoDao { boolean deleteByUuid(@Param("uuid") String uuid); + /** + * 根据UUID批量查询数据 + * + * @param uuids + * @return + */ + List batchSelectByUuid(@Param("uuids") List uuids); + + /** + * 导入医疗器械信息 + * + * @param udiInfoEntities + */ + void importUdiInfo(@Param("udiInfoEntities") List udiInfoEntities); + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoExportLogDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoExportLogDao.java index 20dc81f6..93abd8f7 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoExportLogDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiInfoExportLogDao.java @@ -2,7 +2,6 @@ package com.glxp.api.admin.dao.basic; import com.glxp.api.admin.entity.basic.UdiInfoExportLogEntity; import com.glxp.api.admin.req.basic.FilterUdiEpLogRequest; -import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -19,4 +18,11 @@ public interface UdiInfoExportLogDao { boolean deleteById(@Param("id") String id); + /** + * 根据ID查询文件位置 + * + * @param id + * @return + */ + String selectFilePathById(@Param("id") String id); } diff --git a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiRelevanceDao.java b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiRelevanceDao.java index f9abdbfa..72dc8d89 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiRelevanceDao.java +++ b/api-admin/src/main/java/com/glxp/api/admin/dao/basic/UdiRelevanceDao.java @@ -1,6 +1,5 @@ package com.glxp.api.admin.dao.basic; -import com.glxp.api.admin.entity.basic.UdiInfoEntity; import com.glxp.api.admin.entity.basic.UdiRelevanceEntity; import com.glxp.api.admin.req.basic.FilterUdiInfoRequest; import com.glxp.api.admin.res.basic.UdiRelevanceResponse; @@ -22,6 +21,7 @@ public interface UdiRelevanceDao { UdiRelevanceEntity selectById(@Param("id") String id); UdiRelevanceEntity selectByThirdId(FilterUdiInfoRequest filterUdiInfoRequest); + List filterEntity(FilterUdiInfoRequest filterUdiInfoRequest); @@ -34,4 +34,20 @@ public interface UdiRelevanceDao { boolean deleteByIds(@Param("ids") List id); boolean deleteByUuid(@Param("uuid") String uuid); + + /** + * 根据UUID批量查询信息 + * + * @param uuids + * @return + */ + List batchSelectByUuid(@Param("uuids") List uuids); + + /** + * 批量导入数据 + * + * @param udiRelevanceEntities + */ + void importUdiRelevance(@Param("udiRelevanceEntities") List udiRelevanceEntities); + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/entity/basic/UdiRelevanceEntity.java b/api-admin/src/main/java/com/glxp/api/admin/entity/basic/UdiRelevanceEntity.java index 24d8f2dd..ae793b36 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/entity/basic/UdiRelevanceEntity.java +++ b/api-admin/src/main/java/com/glxp/api/admin/entity/basic/UdiRelevanceEntity.java @@ -26,5 +26,7 @@ public class UdiRelevanceEntity { private Boolean isDisable; private String mainId; private String mainName; + //阳光菜头平台编码 + private String udplatCode; } diff --git a/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java b/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java new file mode 100644 index 00000000..b6063ef4 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/api/admin/res/basic/UdiRelevanceExportJsonResponse.java @@ -0,0 +1,24 @@ +package com.glxp.api.admin.res.basic; + +import com.glxp.api.admin.entity.basic.UdiInfoEntity; +import com.glxp.api.admin.entity.basic.UdiRelevanceEntity; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * 医疗器械信息导出实体类 + */ +@Data +public class UdiRelevanceExportJsonResponse { + + List udiInfoEntities; + + List udiRelevanceEntities; + + public UdiRelevanceExportJsonResponse() { + this.udiInfoEntities = new ArrayList<>(); + this.udiRelevanceEntities = new ArrayList<>(); + } +} diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/basic/UdiInfoImportDetailService.java b/api-admin/src/main/java/com/glxp/api/admin/service/basic/UdiInfoImportDetailService.java index 0510e7a0..7a281ebd 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/basic/UdiInfoImportDetailService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/basic/UdiInfoImportDetailService.java @@ -2,6 +2,7 @@ package com.glxp.api.admin.service.basic; import com.glxp.api.admin.entity.basic.UdiInfoImportDetailEntity; import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest; +import com.glxp.api.admin.res.basic.UdiRelevanceExportJsonResponse; import java.util.List; @@ -20,4 +21,12 @@ public interface UdiInfoImportDetailService { boolean deleteById(String id); boolean deleteByGenkey(String genKey); + + /** + * 导入医疗器械信息 + * + * @param udiRelevanceResponse + */ + void importJsonData(UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse); + } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoExportLogServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoExportLogServiceImpl.java index 3ba9c883..532dd557 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoExportLogServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoExportLogServiceImpl.java @@ -1,10 +1,11 @@ package com.glxp.api.admin.service.basic.impl; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageHelper; import com.glxp.api.admin.dao.basic.UdiInfoExportLogDao; import com.glxp.api.admin.entity.basic.UdiInfoExportLogEntity; import com.glxp.api.admin.req.basic.FilterUdiEpLogRequest; -import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest; import com.glxp.api.admin.service.basic.UdiInfoExportLogService; import org.springframework.stereotype.Service; @@ -54,6 +55,11 @@ public class UdiInfoExportLogServiceImpl implements UdiInfoExportLogService { @Override public boolean deleteById(String id) { + //删除日志同步删除磁盘文件 + String filePath = udiInfoExportLogDao.selectFilePathById(id); + if (StrUtil.isNotBlank(filePath)) { + FileUtil.del(filePath); + } return udiInfoExportLogDao.deleteById(id); } } diff --git a/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java b/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java index e338d996..bf54beda 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java +++ b/api-admin/src/main/java/com/glxp/api/admin/service/basic/impl/UdiInfoImportDetailServiceImpl.java @@ -1,9 +1,13 @@ package com.glxp.api.admin.service.basic.impl; +import cn.hutool.core.collection.CollUtil; import com.github.pagehelper.PageHelper; +import com.glxp.api.admin.dao.basic.UdiInfoDao; import com.glxp.api.admin.dao.basic.UdiInfoImportDetailDao; +import com.glxp.api.admin.dao.basic.UdiRelevanceDao; import com.glxp.api.admin.entity.basic.UdiInfoImportDetailEntity; import com.glxp.api.admin.req.basic.FilterUdiIpLogRequest; +import com.glxp.api.admin.res.basic.UdiRelevanceExportJsonResponse; import com.glxp.api.admin.service.basic.UdiInfoImportDetailService; import org.springframework.stereotype.Service; @@ -16,7 +20,10 @@ public class UdiInfoImportDetailServiceImpl implements UdiInfoImportDetailServic @Resource UdiInfoImportDetailDao udiInfoImportDao; - + @Resource + UdiInfoDao udiInfoDao; + @Resource + UdiRelevanceDao udiRelevanceDao; @Override public List filterUdiInfoImport(FilterUdiIpLogRequest filterInCodeLogRequest) { @@ -57,4 +64,15 @@ public class UdiInfoImportDetailServiceImpl implements UdiInfoImportDetailServic public boolean deleteByGenkey(String genKey) { return udiInfoImportDao.deleteByGenkey(genKey); } + + @Override + public void importJsonData(UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse) { + if (CollUtil.isNotEmpty(udiRelevanceExportJsonResponse.getUdiInfoEntities())) { + udiInfoDao.importUdiInfo(udiRelevanceExportJsonResponse.getUdiInfoEntities()); + } + + if (CollUtil.isNotEmpty(udiRelevanceExportJsonResponse.getUdiRelevanceEntities())) { + udiRelevanceDao.importUdiRelevance(udiRelevanceExportJsonResponse.getUdiRelevanceEntities()); + } + } } diff --git a/api-admin/src/main/java/com/glxp/api/admin/thread/BasicCorpImportService.java b/api-admin/src/main/java/com/glxp/api/admin/thread/BasicCorpImportService.java index 1a14c011..1bcbd768 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/thread/BasicCorpImportService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/thread/BasicCorpImportService.java @@ -81,7 +81,7 @@ public class BasicCorpImportService { SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED); BasicUnitMaintainDao mapper = batchSession.getMapper(BasicUnitMaintainDao.class); for (BasicUnitMaintainEntity basicUnitMaintainEntity : basicUnitMaintainEntities) { - mapper.updateById(basicUnitMaintainEntity); + mapper.importBasicUnitMaintain(basicUnitMaintainEntity); } batchSession.commit(); log.info("导入数据成功,导入数量为:{} 条", basicUnitMaintainEntities.size()); diff --git a/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java b/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java index fff163c0..85eb46bb 100644 --- a/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java +++ b/api-admin/src/main/java/com/glxp/api/admin/thread/BasicGenJsonService.java @@ -1,21 +1,34 @@ package com.glxp.api.admin.thread; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.file.FileWriter; import cn.hutool.json.JSONUtil; import com.glxp.api.admin.constant.BasicProcessStatus; -import com.glxp.api.admin.entity.basic.BasicUnitMaintainEntity; -import com.glxp.api.admin.entity.basic.CorpExportLogEntity; +import com.glxp.api.admin.dao.basic.UdiInfoDao; +import com.glxp.api.admin.dao.basic.UdiRelevanceDao; +import com.glxp.api.admin.entity.basic.*; import com.glxp.api.admin.req.basic.BasicUnitMaintainFilterRequest; import com.glxp.api.admin.req.basic.CorpsExportRequest; +import com.glxp.api.admin.req.basic.FilterUdiInfoRequest; +import com.glxp.api.admin.req.basic.UdiInfoExportRequest; +import com.glxp.api.admin.res.basic.UdiRelevanceExportJsonResponse; +import com.glxp.api.admin.res.basic.UdiRelevanceResponse; import com.glxp.api.admin.service.basic.BasicUnitMaintainService; import com.glxp.api.admin.service.basic.CorpExportLogService; +import com.glxp.api.admin.service.basic.UdiInfoExportLogService; +import com.glxp.api.admin.service.basic.UdiRelevanceService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.io.File; import java.util.ArrayList; import java.util.List; +@Slf4j @Service public class BasicGenJsonService { @@ -23,6 +36,15 @@ public class BasicGenJsonService { CorpExportLogService corpExportLogService; @Resource BasicUnitMaintainService basicUnitMaintainService; + @Resource + UdiInfoExportLogService udiInfoExportLogService; + @Resource + UdiRelevanceService udiRelevanceService; + @Resource + UdiRelevanceDao udiRelevanceDao; + @Resource + UdiInfoDao udiInfoDao; + public void exportCorp(String genKey, CorpsExportRequest corpsExportRequest) { CorpExportLogEntity corpExportLogEntity = corpExportLogService.selectByGenKey(genKey); @@ -48,4 +70,72 @@ public class BasicGenJsonService { corpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); corpExportLogService.updateCorpExportLog(corpExportLogEntity); } + + /** + * 导出json格式医疗器械信息 + * + * @param genKey + * @param udiInfoExportRequest + */ + @Async + public void exportUdiInfoJson(String genKey, UdiInfoExportRequest udiInfoExportRequest) { + UdiInfoExportLogEntity udiInfoExportLogEntity = udiInfoExportLogService.selectByGenKey(genKey); + UdiRelevanceExportJsonResponse exportData = new UdiRelevanceExportJsonResponse(); + //选中导出 + if (CollUtil.isNotEmpty(udiInfoExportRequest.getUuids())) { + List uuids = udiInfoExportRequest.getUuids(); + uuids.forEach(uuid -> { + FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest(); + filterUdiInfoRequest.setUuid(uuid); + List udiRelevanceResponses = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest); + if (CollUtil.isNotEmpty(udiRelevanceResponses)) { + parseUdiRelevanceResponses(exportData, udiRelevanceResponses); + } + }); + } else { + //一键导出 + FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest(); + BeanUtil.copyProperties(udiInfoExportRequest, filterUdiInfoRequest); + filterUdiInfoRequest.setPage(null); + List data = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest); + if (CollUtil.isNotEmpty(data)) { + parseUdiRelevanceResponses(exportData, data); + } + } + + File file = new File(udiInfoExportLogEntity.getFilePath()); + if (!file.exists()) { + try { + file.createNewFile(); + } catch (Exception e) { + log.error("导出医疗器械信息异常", e); + } + } + FileWriter writer = new FileWriter(file); + writer.write(JSONUtil.toJsonStr(exportData)); + udiInfoExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); + udiInfoExportLogService.updateUdiInfoExportLog(udiInfoExportLogEntity); + } + + + /** + * 解析医疗器械信息查询结果,封装完整数据 + * + * @param exportData + * @param udiRelevanceResponses + */ + private void parseUdiRelevanceResponses(UdiRelevanceExportJsonResponse exportData, List udiRelevanceResponses) { + List uuids = new ArrayList<>(udiRelevanceResponses.size()); + udiRelevanceResponses.forEach(udi -> { + uuids.add(udi.getUuid()); + }); + List udiInfoEntities = udiInfoDao.batchSelectByUuid(uuids); + List udiRelevanceEntities = udiRelevanceDao.batchSelectByUuid(uuids); + List udiInfo = exportData.getUdiInfoEntities(); + List udiRelevance = exportData.getUdiRelevanceEntities(); + udiInfo.addAll(udiInfoEntities); + udiRelevance.addAll(udiRelevanceEntities); + exportData.setUdiInfoEntities(udiInfo); + exportData.setUdiRelevanceEntities(udiRelevance); + } } diff --git a/api-admin/src/main/resources/mybatis/mapper/basic/BasicUnitMaintainDao.xml b/api-admin/src/main/resources/mybatis/mapper/basic/BasicUnitMaintainDao.xml index b2c37297..ae5bc508 100644 --- a/api-admin/src/main/resources/mybatis/mapper/basic/BasicUnitMaintainDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/basic/BasicUnitMaintainDao.xml @@ -164,4 +164,34 @@ FROM basic_corp WHERE (name = #{name}) limit 1 + + + REPLACE + INTO basic_corp + (id, thirdId, erpId, name, spell, + addr, status, type, creditNo, contact, mobile, thirdId1, thirdId2, thirdId3, thirdId4, + thirdName, thirdName1, thirdName2, thirdName3, thirdName4, updateTime, corpType) + values (#{id}, + #{thirdId}, + #{erpId}, + #{name}, + #{spell}, + #{addr}, + #{status}, + #{type}, + #{creditNo}, + #{contact}, + #{mobile}, + #{thirdId1}, + #{thirdId2}, + #{thirdId3}, + #{thirdId4}, + #{thirdName}, + #{thirdName1}, + #{thirdName2}, + #{thirdName3}, + #{thirdName4}, + #{updateTime}, + #{corpType}) + diff --git a/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml b/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml index 53042951..cb970474 100644 --- a/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoDao.xml @@ -159,4 +159,52 @@ WHERE nameCode = #{nameCode} + + + + + replace into basic_products + (id, nameCode, packRatio, packLevel, bhxjsl, bhzxxsbzsl, zxxsbzbhsydysl, bhxjcpbm, bzcj, addType, + deviceRecordKey, cpmctymc, cplb, flbm, ggxh, qxlb, tyshxydm, ylqxzcrbarmc, zczbhhzbapzbh, + ylqxzcrbarywmc, sydycpbs, uuid, sjcpbm, versionNumber, diType, ybbm, sptm, manufactory, measname, + productType) values + + (#{item.id}, + #{item.nameCode}, + #{item.packRatio}, + #{item.packLevel}, + #{item.bhxjsl}, + #{item.bhzxxsbzsl}, + #{item.zxxsbzbhsydysl}, + #{item.bhxjcpbm}, + #{item.bzcj}, + #{item.addType}, + #{item.deviceRecordKey}, + #{item.cpmctymc}, + #{item.cplb}, + #{item.flbm}, + #{item.ggxh}, + #{item.qxlb}, + #{item.tyshxydm}, + #{item.ylqxzcrbarmc}, + #{item.zczbhhzbapzbh}, + #{item.ylqxzcrbarywmc}, + #{item.sydycpbs}, + #{item.uuid}, + #{item.sjcpbm}, + #{item.versionNumber}, + #{item.diType}, + #{item.ybbm}, + #{item.sptm}, + #{item.manufactory}, + #{item.measname}, + #{item.productType}) + + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoExportLogDao.xml b/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoExportLogDao.xml index 05837caf..73cc8e6f 100644 --- a/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoExportLogDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/basic/UdiInfoExportLogDao.xml @@ -50,4 +50,7 @@ WHERE genKey = #{genKey} + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml b/api-admin/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml index e140763c..f151dd20 100644 --- a/api-admin/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/basic/UdiRelevanceDao.xml @@ -298,4 +298,43 @@ WHERE id = #{id} + + + + + replace into basic_udirel (id, thirdId, thirdName, uuid, isUseDy, updateTime, thirdId1, thirdId2, thirdId3, + thirdId4, thirdName1, thirdName2, thirdName3, thirdName4, ybbm, sptm, manufactory, + measname, isDisable, mainId, mainName, udplatCode) + values + + (#{item.id}, + #{item.thirdId}, + #{item.thirdName}, + #{item.uuid}, + #{item.isUseDy}, + #{item.updateTime}, + #{item.thirdId1}, + #{item.thirdId2}, + #{item.thirdId3}, + #{item.thirdId4}, + #{item.thirdName1}, + #{item.thirdName2}, + #{item.thirdName3}, + #{item.thirdName4}, + #{item.ybbm}, + #{item.sptm}, + #{item.manufactory}, + #{item.measname}, + #{item.isDisable}, + #{item.mainId}, + #{item.mainName}, + #{item.udplatCode}) + + \ No newline at end of file