医疗器械信息,供应商信息导入导出

master
anthonyywj2 3 years ago
parent 0fd79fd599
commit 4182796740

@ -110,7 +110,7 @@ public class CorpExportLogController {
CorpExportLogEntity corpExportLogEntity = new CorpExportLogEntity();
corpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
String genKey = CustomUtil.getId();
String fileName = "D:\\udiwms\\exportFile\\" + "往来单位信息" + genKey + ".xls";
String fileName = "D:\\udiwms\\exportFile\\" + "往来单位信息" + genKey + ".json";
corpExportLogEntity.setGenKey(genKey);
corpExportLogEntity.setFilePath(fileName);
corpExportLogEntity.setUpdateTime(new Date());

@ -1,8 +1,11 @@
package com.glxp.sale.admin.controller.basic;
import cn.hutool.core.io.IoUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.entity.basic.BasicThirdSysEntity;
import com.glxp.sale.admin.entity.basic.BasicUnitMaintainEntity;
import com.glxp.sale.admin.entity.basic.CorpImportDetailEntity;
import com.glxp.sale.admin.entity.basic.CorpImportLogEntity;
import com.glxp.sale.admin.req.basic.FilterUdiIpLogRequest;
@ -17,6 +20,7 @@ import com.glxp.sale.admin.util.CustomUtil;
import com.glxp.sale.common.enums.ResultEnum;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -32,6 +36,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@RestController
public class CorpImportLogController {
@Resource
@ -114,7 +119,6 @@ public class CorpImportLogController {
@PostMapping("/udiwms/corps/importLog/upload")
public BaseResponse uploadProducts(@RequestParam("file") List<MultipartFile> files, @RequestParam("thirdSys") String thirdSys) {
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectMainThrSys();
String filePath = "D:\\udiwms\\filePath\\";
File createFile = new File(filePath);
if (!createFile.exists()) {
@ -126,20 +130,14 @@ public class CorpImportLogController {
return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败");
}
String fileName = file.getOriginalFilename();
//解析数据
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = null;
String filetype = fileName.substring(fileName.lastIndexOf("."));
String fileType = fileName.substring(fileName.lastIndexOf("."));
if (".json".equals(fileType.toLowerCase())) {
String jsonData = IoUtil.read(file.getInputStream()).toString();
List<BasicUnitMaintainEntity> basicUnitMaintainEntities = JSONUtil.toList(jsonData, BasicUnitMaintainEntity.class);
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;
//导入日志
CorpImportLogEntity corpImportLogEntity = new CorpImportLogEntity();
String genKey = CustomUtil.getId();
corpImportLogEntity.setGenKey(genKey);
@ -147,191 +145,14 @@ public class CorpImportLogController {
corpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
corpImportLogEntity.setUpdateTime(new Date(System.currentTimeMillis()));
corpImportLogService.insertImportLog(corpImportLogEntity);
List<CorpImportDetailEntity> corpImportDetailEntities = new ArrayList<>();
for (int j = 0; j < 1; j++) {//workbook.getNumberOfSheets();
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) ||
(!"往来单位ID".equals(row.getCell(0).getStringCellValue())
|| !"往来单位名称".equals(row.getCell(1).getStringCellValue())
|| !"往来单位拼音简写".equals(row.getCell(2).getStringCellValue())
|| !"地址".equals(row.getCell(3).getStringCellValue())
|| !"联系人".equals(row.getCell(4).getStringCellValue())
|| !"联系电话".equals(row.getCell(5).getStringCellValue())
|| !"社会信用号".equals(row.getCell(6).getStringCellValue())
|| !"往来单位状态".equals(row.getCell(7).getStringCellValue())
|| !"往来单位类型".equals(row.getCell(8).getStringCellValue())
|| !"thirdId".equals(row.getCell(9).getStringCellValue()))) {
corpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
corpImportLogEntity.setUpdateTime(new Date(System.currentTimeMillis()));
corpImportLogEntity.setRemark("文件格式错误!");
basicCorpImportService.importJsonData(basicUnitMaintainEntities);
corpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
corpImportLogService.updateImportLog(corpImportLogEntity);
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;
}
CorpImportDetailEntity corpImportDetailEntity = new CorpImportDetailEntity();
Cell cell1 = row.getCell(0);
if (cell1 != null) {
cell1.setCellType(CellType.STRING);
corpImportDetailEntity.setErpId(cell1.getStringCellValue());
}
Cell cell2 = row.getCell(1);
if (cell2 != null) {
cell2.setCellType(CellType.STRING);
corpImportDetailEntity.setName(cell2.getStringCellValue());
}
Cell cell3 = row.getCell(2);
if (cell3 != null) {
cell3.setCellType(CellType.STRING);
corpImportDetailEntity.setSpell(cell3.getStringCellValue());
}
Cell cell4 = row.getCell(3);
if (cell4 != null) {
cell4.setCellType(CellType.STRING);
corpImportDetailEntity.setAddr(cell4.getStringCellValue());
}
Cell cell5 = row.getCell(4);
if (cell5 != null) {
cell5.setCellType(CellType.STRING);
corpImportDetailEntity.setContact(cell5.getStringCellValue());
}
Cell cell6 = row.getCell(5);
if (cell6 != null) {
cell6.setCellType(CellType.STRING);
corpImportDetailEntity.setMobile(cell6.getStringCellValue());
}
Cell cell7 = row.getCell(6);
if (cell7 != null) {
cell7.setCellType(CellType.STRING);
corpImportDetailEntity.setCreditNo(cell7.getStringCellValue());
}
Cell cell8 = row.getCell(7);
if (cell8 != null) {
cell8.setCellType(CellType.STRING);
corpImportDetailEntity.setStatus(cell8.getStringCellValue());
}
Cell cell9 = row.getCell(8);
if (cell9 != null) {
cell9.setCellType(CellType.STRING);
corpImportDetailEntity.setType(cell9.getStringCellValue());
}
Cell cell10 = row.getCell(9);
if (cell10 != null) {
cell10.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdId(cell10.getStringCellValue());
}
Cell cell11 = row.getCell(10);
if (cell11 != null) {
cell11.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdName(cell11.getStringCellValue());
}
Cell cell12 = row.getCell(11);
if (cell12 != null) {
cell12.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdId1(cell12.getStringCellValue());
}
Cell cell13 = row.getCell(12);
if (cell13 != null) {
cell13.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdName1(cell13.getStringCellValue());
}
Cell cell14 = row.getCell(13);
if (cell14 != null) {
cell14.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdId2(cell14.getStringCellValue());
}
Cell cell15 = row.getCell(14);
if (cell15 != null) {
cell15.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdName2(cell15.getStringCellValue());
}
Cell cell16 = row.getCell(15);
if (cell16 != null) {
cell16.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdId3(cell16.getStringCellValue());
}
Cell cell17 = row.getCell(16);
if (cell17 != null) {
cell17.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdName3(cell17.getStringCellValue());
}
Cell cell18 = row.getCell(17);
if (cell18 != null) {
cell18.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdId4(cell18.getStringCellValue());
}
Cell cell19 = row.getCell(18);
if (cell19 != null) {
cell19.setCellType(CellType.STRING);
corpImportDetailEntity.setThirdName4(cell19.getStringCellValue());
}
if (basicThirdSysEntity != null) {
if ("thirdId".equals(basicThirdSysEntity.getThirdId())) {
corpImportDetailEntity.setThirdId(corpImportDetailEntity.getThirdId());
corpImportDetailEntity.setThirdName(corpImportDetailEntity.getThirdName());
} else if ("thirdId1".equals(basicThirdSysEntity.getThirdId())) {
corpImportDetailEntity.setThirdId1(corpImportDetailEntity.getThirdId1());
corpImportDetailEntity.setThirdName1(corpImportDetailEntity.getThirdName1());
} else if ("thirdId2".equals(basicThirdSysEntity.getThirdId())) {
corpImportDetailEntity.setThirdId2(corpImportDetailEntity.getThirdId2());
corpImportDetailEntity.setThirdName2(corpImportDetailEntity.getThirdName2());
} else if ("thirdId3".equals(basicThirdSysEntity.getThirdId())) {
corpImportDetailEntity.setThirdId3(corpImportDetailEntity.getThirdId3());
corpImportDetailEntity.setThirdName3(corpImportDetailEntity.getThirdName3());
} else if ("thirdId4".equals(basicThirdSysEntity.getThirdId())) {
corpImportDetailEntity.setThirdId4(corpImportDetailEntity.getThirdId4());
corpImportDetailEntity.setThirdName4(corpImportDetailEntity.getThirdName4());
}
} else {
corpImportDetailEntity.setThirdId(corpImportDetailEntity.getErpId());
corpImportDetailEntity.setThirdName(corpImportDetailEntity.getName());
}
corpImportDetailEntity.setGenKeyFk(genKey);
corpImportDetailEntity.setImportStatus(BasicProcessStatus.UDIINFO_IMPORT_CODE_UNPROCESS);
corpImportDetailEntity.setUpdateTime(new Date(System.currentTimeMillis()));
corpImportDetailEntities.add(corpImportDetailEntity);
return ResultVOUtils.error(500, "请上传json文件");
}
}
corpImportDetailService.insertCorpImports(corpImportDetailEntities);
corpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
corpImportLogService.updateImportLog(corpImportLogEntity);
workbook.close();
basicCorpImportService.importCorps(genKey);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
log.error("导入往来单位信息错误,文件名为:{}", fileName);
}
}
return ResultVOUtils.success("上传成功");
@ -374,6 +195,7 @@ public class CorpImportLogController {
basicCorpImportService.importCorps(genKey);
return ResultVOUtils.success("上传成功");
}
public boolean filterEmpty(Row row) {
if (row.getCell(0) != null) {

@ -116,14 +116,14 @@ public class UdiInfoExportLogController {
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);
udiInfoExportLogService.insertUdiInfoExportLog(udiInfoExportLogEntity);
basicGenExcelService.exportUdiInfo(genKey, udiInfoExportRequest);
basicGenExcelService.exportJsonUdiInfo(genKey, udiInfoExportRequest);
return ResultVOUtils.success("后台正在导出生成excel文件请稍后刷新查看!");
}

@ -1,5 +1,7 @@
package com.glxp.sale.admin.controller.basic;
import cn.hutool.core.io.IoUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.entity.basic.UdiInfoImportDetailEntity;
@ -8,6 +10,7 @@ import com.glxp.sale.admin.req.basic.FilterUdiIpLogRequest;
import com.glxp.sale.admin.req.basic.PostUdiInfoRequest;
import com.glxp.sale.admin.req.info.DeleteRequest;
import com.glxp.sale.admin.res.PageSimpleResponse;
import com.glxp.sale.admin.res.basic.UdiRelevanceExportJsonResponse;
import com.glxp.sale.admin.service.basic.UdiInfoImportDetailService;
import com.glxp.sale.admin.service.basic.UdiInfoImportLogService;
import com.glxp.sale.admin.thread.BasicUdiInfoImportService;
@ -18,6 +21,8 @@ import com.glxp.sale.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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -43,6 +48,7 @@ public class UdiInfoImportLogController {
UdiInfoImportDetailService udiInfoImportService;
@Resource
BasicUdiInfoImportService basicUdiInfoImportService;
private static final Logger log = LoggerFactory.getLogger(UdiInfoImportLogController.class);
@GetMapping("/udiwms/products/importLog/filter")
public BaseResponse filter(FilterUdiIpLogRequest filterUdiIpLogRequest,
@ -126,122 +132,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());
}
Cell cell5 = row.getCell(4);
if (cell5 != null) {
cell5.setCellType(CellType.STRING);
udiInfoImportEntity.setThirdId1(cell5.getStringCellValue());
//导入日志
UdiInfoImportLogEntity importLog = new UdiInfoImportLogEntity();
String genKey = CustomUtil.getId();
importLog.setGenKey(genKey);
importLog.setFromType("文件导入");
importLog.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
}
Cell cell6 = row.getCell(5);
if (cell6 != null) {
cell6.setCellType(CellType.STRING);
udiInfoImportEntity.setThirdId2(cell6.getStringCellValue());
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 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("上传成功");
}

@ -24,4 +24,7 @@ public interface BasicUnitMaintainDao {
BasicUnitMaintainEntity selectById(@Param("id") String id);
BasicUnitMaintainEntity selectByName(@Param("name") String name);
boolean importBasicUnitMaintain(BasicUnitMaintainEntity basicUnitMaintainEntity);
}

@ -33,4 +33,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);
}

@ -33,4 +33,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);
}

@ -0,0 +1,24 @@
package com.glxp.sale.admin.res.basic;
import com.glxp.sale.admin.entity.basic.UdiInfoEntity;
import com.glxp.sale.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<>();
}
}

@ -3,6 +3,7 @@ package com.glxp.sale.admin.service.basic;
import com.glxp.sale.admin.entity.basic.UdiInfoImportDetailEntity;
import com.glxp.sale.admin.req.basic.FilterUdiIpLogRequest;
import com.glxp.sale.admin.res.basic.UdiRelevanceExportJsonResponse;
import java.util.List;
@ -21,4 +22,11 @@ public interface UdiInfoImportDetailService {
boolean deleteById(String id);
boolean deleteByGenkey(String genKey);
/**
*
*
* @param udiRelevanceResponse
*/
void importJsonData(UdiRelevanceExportJsonResponse udiRelevanceExportJsonResponse);
}

@ -1,9 +1,13 @@
package com.glxp.sale.admin.service.basic.impl;
import cn.hutool.core.collection.CollUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.sale.admin.dao.basic.UdiInfoDao;
import com.glxp.sale.admin.dao.basic.UdiInfoImportDetailDao;
import com.glxp.sale.admin.dao.basic.UdiRelevanceDao;
import com.glxp.sale.admin.entity.basic.UdiInfoImportDetailEntity;
import com.glxp.sale.admin.req.basic.FilterUdiIpLogRequest;
import com.glxp.sale.admin.res.basic.UdiRelevanceExportJsonResponse;
import com.glxp.sale.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());
}
}
}

@ -1,7 +1,9 @@
package com.glxp.sale.admin.thread;
import cn.hutool.core.collection.CollUtil;
import com.glxp.sale.admin.constant.ConstantStatus;
import com.glxp.sale.admin.constant.UdiInfoImportStatus;
import com.glxp.sale.admin.dao.basic.BasicUnitMaintainDao;
import com.glxp.sale.admin.entity.basic.BasicUnitMaintainEntity;
import com.glxp.sale.admin.entity.basic.CorpImportDetailEntity;
import com.glxp.sale.admin.entity.basic.CorpImportLogEntity;
@ -9,6 +11,11 @@ import com.glxp.sale.admin.req.basic.FilterUdiIpLogRequest;
import com.glxp.sale.admin.service.basic.BasicUnitMaintainService;
import com.glxp.sale.admin.service.basic.CorpImportDetailService;
import com.glxp.sale.admin.service.basic.CorpImportLogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -16,6 +23,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@Service
public class BasicCorpImportService {
@ -25,12 +33,14 @@ public class BasicCorpImportService {
CorpImportDetailService corpImportDetailService;
@Resource
BasicUnitMaintainService basicUnitMaintainService;
@Resource
SqlSessionFactory sqlSessionFactory;
@Async
public void importCorps(String genKey) {
CorpImportLogEntity corpImportLogEntity = corpImportLogService.selectByGenKey(genKey);
if(corpImportLogEntity!=null && corpImportLogEntity.getStatus() == UdiInfoImportStatus.UDIINFO_IMPORT_UNPROCESS){
if (corpImportLogEntity != null && corpImportLogEntity.getStatus() == UdiInfoImportStatus.UDIINFO_IMPORT_UNPROCESS) {
FilterUdiIpLogRequest filterUdiIpLogRequest = new FilterUdiIpLogRequest();
filterUdiIpLogRequest.setGenKey(genKey);
List<CorpImportDetailEntity> corpImportDetailEntities
@ -48,10 +58,28 @@ public class BasicCorpImportService {
corpImportLogEntity.setStatus(UdiInfoImportStatus.UDIINFO_IMPORT_SUCCESS);
corpImportLogService.updateImportLog(corpImportLogEntity);
}
}
/**
*
*
* @param basicUnitMaintainEntities
*/
public void importJsonData(List<BasicUnitMaintainEntity> basicUnitMaintainEntities) {
if (CollUtil.isNotEmpty(basicUnitMaintainEntities)) {
try {
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
BasicUnitMaintainDao mapper = batchSession.getMapper(BasicUnitMaintainDao.class);
for (BasicUnitMaintainEntity basicUnitMaintainEntity : basicUnitMaintainEntities) {
mapper.importBasicUnitMaintain(basicUnitMaintainEntity);
}
batchSession.commit();
log.info("导入数据成功,导入数量为:{} 条", basicUnitMaintainEntities.size());
} catch (Exception e) {
log.error("导入往来单位信息异常", e);
}
}
}
}

@ -1,14 +1,22 @@
package com.glxp.sale.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.sale.admin.constant.BasicProcessStatus;
import com.glxp.sale.admin.constant.ConstantStatus;
import com.glxp.sale.admin.constant.UdiInfoImportStatus;
import com.glxp.sale.admin.dao.basic.UdiInfoDao;
import com.glxp.sale.admin.dao.basic.UdiRelevanceDao;
import com.glxp.sale.admin.entity.basic.*;
import com.glxp.sale.admin.req.basic.*;
import com.glxp.sale.admin.res.basic.UdiExportJsonResponse;
import com.glxp.sale.admin.res.basic.UdiRelevanceExportJsonResponse;
import com.glxp.sale.admin.res.basic.UdiRelevanceResponse;
import com.glxp.sale.admin.service.basic.*;
import com.glxp.sale.admin.util.ExcelUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Async;
@ -22,6 +30,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class BasicGenExcelService {
@Resource
@ -34,66 +43,35 @@ public class BasicGenExcelService {
UdiRelevanceService udiRelevanceService;
@Resource
UdiInfoService udiInfoService;
@Resource
UdiRelevanceDao udiRelevanceDao;
@Resource
UdiInfoDao udiInfoDao;
//往来单位
@Async
public void exportCorp(String genKey, CorpsExportRequest corpsExportRequest) {
CorpExportLogEntity corpExportLogEntity = corpExportLogService.selectByGenKey(genKey);
List<List<String>> excelData = new ArrayList<>();
List<String> head = new ArrayList<>();
head.add("往来单位ID");
head.add("往来单位名称");
head.add("往来单位拼音简写");
head.add("地址");
head.add("联系人");
head.add("联系电话");
head.add("社会信用号");
head.add("往来单位状态");
head.add("往来单位类型");
head.add("thirdId");
head.add("thirdName");
head.add("thirdI1d");
head.add("thirdName1");
head.add("thirdId2");
head.add("thirdName2");
head.add("thirdId3");
head.add("thirdName3");
head.add("thirdId4");
head.add("thirdName4");
excelData.add(head);
//选中导出
List<BasicUnitMaintainEntity> exportData = new ArrayList<>();
if (corpsExportRequest.getIds() != null && corpsExportRequest.getIds().size() > 0) {
List<Integer> ids = corpsExportRequest.getIds();
for (Integer id : ids) {
BasicUnitMaintainFilterRequest filterRequest = new BasicUnitMaintainFilterRequest();
filterRequest.setId(id);
List<List<String>> genDatas = genExcelData(filterRequest);
if (genDatas != null && genDatas.size() > 0) {
excelData.addAll(genDatas);
}
}
} else {//一键导出
ids.forEach(id -> {
BasicUnitMaintainFilterRequest request = new BasicUnitMaintainFilterRequest();
request.setId(id);
List<BasicUnitMaintainEntity> basicUnitMaintainEntities = basicUnitMaintainService.filterList(request);
exportData.addAll(basicUnitMaintainEntities);
});
} else { //一键导出
BasicUnitMaintainFilterRequest filterRequest = new BasicUnitMaintainFilterRequest();
BeanUtils.copyProperties(corpsExportRequest, filterRequest);
filterRequest.setPage(null);
List<List<String>> genDatas = genExcelData(filterRequest);
if (genDatas != null && genDatas.size() > 0) {
excelData.addAll(genDatas);
}
List<BasicUnitMaintainEntity> basicUnitMaintainEntities = basicUnitMaintainService.filterList(filterRequest);
exportData.addAll(basicUnitMaintainEntities);
}
String sheetName = "往来单位信息";
File file = new File(corpExportLogEntity.getFilePath());
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
new ExcelUtil().exportExcel(excelData, sheetName, corpExportLogEntity.getFilePath(), 20);
FileWriter writer = new FileWriter(corpExportLogEntity.getFilePath());
writer.write(JSONUtil.toJsonStr(exportData));
corpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
corpExportLogService.updateCorpExportLog(corpExportLogEntity);
}
@ -225,9 +203,45 @@ public class BasicGenExcelService {
udiInfoExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
udiInfoExportLogService.updateUdiInfoExportLog(udiInfoExportLogEntity);
}
@Async
public void exportJsonUdiInfo(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);
}
@ -327,4 +341,26 @@ public class BasicGenExcelService {
}
return udiInfoImportDetailEntities;
}
/**
*
*
* @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);
}
}

@ -92,7 +92,8 @@
#{thirdName2},
#{thirdName3},
#{thirdName4},
#{updateTime},#{corpType}
#{updateTime},
#{corpType}
)
</insert>
@ -100,7 +101,7 @@
<insert id="insert" parameterType="com.glxp.sale.admin.entity.basic.BasicUnitMaintainEntity">
insert INTO basic_corp(thirdId, erpId, name, spell, addr,
status, type, creditNo, contact, mobile, thirdId1, thirdId2, thirdId3, thirdId4,
thirdName, thirdName1, thirdName2, thirdName3, thirdName4, updateTime,corpType)
thirdName, thirdName1, thirdName2, thirdName3, thirdName4, updateTime, corpType)
values (#{thirdId},
#{erpId},
#{name},
@ -112,7 +113,7 @@
#{contact},
#{mobile},
#{thirdId1}, #{thirdId2}, #{thirdId3}, #{thirdId4},
#{thirdName}, #{thirdName1}, #{thirdName2}, #{thirdName3}, #{thirdName4}, #{updateTime},#{corpType})
#{thirdName}, #{thirdName1}, #{thirdName2}, #{thirdName3}, #{thirdName4}, #{updateTime}, #{corpType})
</insert>
@ -163,4 +164,37 @@
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>

@ -226,4 +226,52 @@
</trim>
WHERE nameCode = #{nameCode}
</update>
<select id="batchSelectByUuid" resultType="com.glxp.sale.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>

@ -330,4 +330,43 @@
</trim>
WHERE id = #{id}
</update>
<select id="batchSelectByUuid" resultType="com.glxp.sale.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