1.基础数据-医疗器械信息导入/导出修改为json格式

master
MrZhai 3 years ago
parent d3f12d66ee
commit fd0266f0c4

@ -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<BasicUnitMaintainEntity> basicUnitMaintainEntities = JSONUtil.toList(jsonData, BasicUnitMaintainEntity.class);

@ -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文件请稍后刷新查看!");
}

@ -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文件");
}
Sheet sheet = null;
Row row = null;
UdiInfoImportLogEntity udiInfoImportLogEntity = 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<UdiInfoImportDetailEntity> 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());
String fileType = fileName.substring(fileName.lastIndexOf("."));
if (!".json".equals(fileType.toLowerCase())) {
return ResultVOUtils.error(500, "请上传json文件");
}
Cell cell3 = row.getCell(2);
if (cell3 != null) {
cell3.setCellType(CellType.STRING);
udiInfoImportEntity.setSptm(cell3.getStringCellValue());
//导入数据
String jsonData = IoUtil.read(file.getInputStream()).toString();
UdiRelevanceExportJsonResponse importData = JSONUtil.toBean(jsonData, UdiRelevanceExportJsonResponse.class);
}
Cell cell4 = row.getCell(3);
if (cell4 != null) {
cell4.setCellType(CellType.STRING);
udiInfoImportEntity.setThirdId(cell4.getStringCellValue());
//导入日志
UdiInfoImportLogEntity importLog = new UdiInfoImportLogEntity();
String genKey = CustomUtil.getId();
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);
}
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();
}
}
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("后台已开始下载并更新,请稍后刷新查看!");
}

@ -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);

@ -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<UdiInfoEntity> batchSelectByUuid(@Param("uuids") List<String> uuids);
/**
*
*
* @param udiInfoEntities
*/
void importUdiInfo(@Param("udiInfoEntities") List<UdiInfoEntity> udiInfoEntities);
}

@ -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);
}

@ -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<UdiRelevanceEntity> filterEntity(FilterUdiInfoRequest filterUdiInfoRequest);
@ -34,4 +34,20 @@ public interface UdiRelevanceDao {
boolean deleteByIds(@Param("ids") List<String> id);
boolean deleteByUuid(@Param("uuid") String uuid);
/**
* UUID
*
* @param uuids
* @return
*/
List<UdiRelevanceEntity> batchSelectByUuid(@Param("uuids") List<String> uuids);
/**
*
*
* @param udiRelevanceEntities
*/
void importUdiRelevance(@Param("udiRelevanceEntities") List<UdiRelevanceEntity> udiRelevanceEntities);
}

@ -26,5 +26,7 @@ public class UdiRelevanceEntity {
private Boolean isDisable;
private String mainId;
private String mainName;
//阳光菜头平台编码
private String udplatCode;
}

@ -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<UdiInfoEntity> udiInfoEntities;
List<UdiRelevanceEntity> udiRelevanceEntities;
public UdiRelevanceExportJsonResponse() {
this.udiInfoEntities = new ArrayList<>();
this.udiRelevanceEntities = new ArrayList<>();
}
}

@ -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);
}

@ -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);
}
}

@ -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<UdiInfoImportDetailEntity> 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());
}
}
}

@ -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());

@ -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<String> uuids = udiInfoExportRequest.getUuids();
uuids.forEach(uuid -> {
FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest();
filterUdiInfoRequest.setUuid(uuid);
List<UdiRelevanceResponse> udiRelevanceResponses = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest);
if (CollUtil.isNotEmpty(udiRelevanceResponses)) {
parseUdiRelevanceResponses(exportData, udiRelevanceResponses);
}
});
} else {
//一键导出
FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest();
BeanUtil.copyProperties(udiInfoExportRequest, filterUdiInfoRequest);
filterUdiInfoRequest.setPage(null);
List<UdiRelevanceResponse> 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<UdiRelevanceResponse> udiRelevanceResponses) {
List<String> uuids = new ArrayList<>(udiRelevanceResponses.size());
udiRelevanceResponses.forEach(udi -> {
uuids.add(udi.getUuid());
});
List<UdiInfoEntity> udiInfoEntities = udiInfoDao.batchSelectByUuid(uuids);
List<UdiRelevanceEntity> udiRelevanceEntities = udiRelevanceDao.batchSelectByUuid(uuids);
List<UdiInfoEntity> udiInfo = exportData.getUdiInfoEntities();
List<UdiRelevanceEntity> udiRelevance = exportData.getUdiRelevanceEntities();
udiInfo.addAll(udiInfoEntities);
udiRelevance.addAll(udiRelevanceEntities);
exportData.setUdiInfoEntities(udiInfo);
exportData.setUdiRelevanceEntities(udiRelevance);
}
}

@ -164,4 +164,34 @@
FROM basic_corp
WHERE (name = #{name}) limit 1
</select>
<insert id="importBasicUnitMaintain" keyProperty="id">
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})
</insert>
</mapper>

@ -159,4 +159,52 @@
</trim>
WHERE nameCode = #{nameCode}
</update>
<select id="batchSelectByUuid" resultType="com.glxp.api.admin.entity.basic.UdiInfoEntity">
select *
from basic_products where uuid in
<foreach collection="uuids" item="item" separator="," index="index" open="(" close=")">
#{item}
</foreach>
</select>
<insert id="importUdiInfo" parameterType="java.util.List">
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
<foreach collection="udiInfoEntities" item="item" index="index" separator=",">
(#{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})
</foreach>
</insert>
</mapper>

@ -50,4 +50,7 @@
WHERE genKey = #{genKey}
</update>
<select id="selectFilePathById" resultType="java.lang.String">
select filePath from basic_products_export_log where id = #{id}
</select>
</mapper>

@ -298,4 +298,43 @@
</set>
WHERE id = #{id}
</update>
<select id="batchSelectByUuid" resultType="com.glxp.api.admin.entity.basic.UdiRelevanceEntity">
select *
from basic_udirel where uuid in
<foreach collection="uuids" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<insert id="importUdiRelevance" parameterType="java.util.List">
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
<foreach collection="udiRelevanceEntities" item="item" index="index" separator=",">
(#{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})
</foreach>
</insert>
</mapper>
Loading…
Cancel
Save