|
@@ -7,9 +7,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.lantone.common.api.CommonResult;
|
|
|
import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.BeanUtil;
|
|
|
+import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.util.StringUtil;
|
|
|
+import com.lantone.common.util.SysUserUtils;
|
|
|
import com.lantone.daqe.dto.ExportImportDrugErrDTO;
|
|
|
+import com.lantone.daqe.dto.GetDrugByIdDTO;
|
|
|
import com.lantone.daqe.dto.GetDrugPageDTO;
|
|
|
import com.lantone.daqe.dto.GetMatchingDrugPageDTO;
|
|
|
import com.lantone.daqe.entity.DrugInfo;
|
|
@@ -18,6 +21,7 @@ import com.lantone.daqe.service.impl.DrugInfoServiceImpl;
|
|
|
import com.lantone.daqe.util.ExcelUtils;
|
|
|
import com.lantone.daqe.vo.AddDrugVO;
|
|
|
import com.lantone.daqe.vo.DelDrugByIdVO;
|
|
|
+import com.lantone.daqe.vo.GetDrugByIdVO;
|
|
|
import com.lantone.daqe.vo.GetDrugPageVO;
|
|
|
import com.lantone.daqe.vo.GetMatchingDrugPageVO;
|
|
|
import com.lantone.daqe.vo.ImportDrugVO;
|
|
@@ -49,6 +53,10 @@ public class DrugManagementFacade {
|
|
|
|
|
|
@Autowired
|
|
|
private DrugInfoServiceImpl drugInfoServiceImpl;
|
|
|
+ //医院药品名称长度
|
|
|
+ private int drugNameLength = 30;
|
|
|
+ //国药准字长度
|
|
|
+ private int approvalNumLength = 30;
|
|
|
|
|
|
public IPage<GetDrugPageDTO> getDrugPage(GetDrugPageVO getDrugPageVO) {
|
|
|
Page<GetDrugPageDTO> getDrugPageDTOPage = new Page<>();
|
|
@@ -129,7 +137,7 @@ public class DrugManagementFacade {
|
|
|
|
|
|
DrugInfo drugInfo = new DrugInfo();
|
|
|
BeanUtils.copyProperties(matchingDrugVO, drugInfo);
|
|
|
- drugInfo.setStandard(matchingDrugVO.getStandard() + "_" + matchingDrugVO.getForm());
|
|
|
+ drugInfo.setStandard(matchingDrugVO.getStandard() + "_" + matchingDrugVO.getDosageForm());
|
|
|
return drugInfoFacade.updateById(drugInfo);
|
|
|
}
|
|
|
|
|
@@ -146,20 +154,27 @@ public class DrugManagementFacade {
|
|
|
if (ListUtil.isEmpty(operationExcelVOS)) {
|
|
|
Asserts.fail("Excel文件为空");
|
|
|
}
|
|
|
+ Long hospitalId = SysUserUtils.getCurrentHospitalId();
|
|
|
//数据规范校验
|
|
|
List<ExportImportDrugErrDTO> errExports = new ArrayList<>();
|
|
|
- if (checkData(operationExcelVOS, errExports)) {
|
|
|
+ if (checkData(operationExcelVOS, errExports, hospitalId)) {
|
|
|
String fileName = "药品匹配信息导入异常.xls";
|
|
|
ExcelUtils.exportExcelUser(errExports, null, "sheet1", ExportImportDrugErrDTO.class, fileName, response);
|
|
|
} else {
|
|
|
//去重
|
|
|
List<ImportDrugVO> temp = delRepeat(operationExcelVOS);
|
|
|
- List<DrugInfo> insert = new ArrayList<>();
|
|
|
//导入数据转换
|
|
|
temp.stream().forEach(importDrugVO -> {
|
|
|
DrugInfo drugInfo = new DrugInfo();
|
|
|
BeanUtils.copyProperties(importDrugVO, drugInfo);
|
|
|
- drugInfo.setStandard(importDrugVO.getStandard() + "_" + importDrugVO.getForm());
|
|
|
+ drugInfo.setStandard(importDrugVO.getStandard() + "_" + importDrugVO.getDosageForm());
|
|
|
+ });
|
|
|
+ List<DrugInfo> insert = BeanUtil.listCopyTo(temp, DrugInfo.class);
|
|
|
+ insert.stream().forEach(drugInfo -> {
|
|
|
+ drugInfo.setHospitalId(hospitalId != null ? hospitalId : 0);
|
|
|
+ drugInfo.setGmtCreate(DateUtil.now());
|
|
|
+ drugInfo.setCreator(SysUserUtils.getCurrentPrincipleId() != null ? SysUserUtils.getCurrentPrincipleId() + "" : "0");
|
|
|
+ drugInfo.setGmtModified(DateUtil.now());
|
|
|
});
|
|
|
boolean out = drugInfoServiceImpl.saveBatch(insert);
|
|
|
CommonResult<String> outMsg = null;
|
|
@@ -183,24 +198,39 @@ public class DrugManagementFacade {
|
|
|
* 数据校验
|
|
|
*
|
|
|
* @param importDrugVOS 导入数据
|
|
|
- * @param errExports 导出异常i
|
|
|
+ * @param errExports 导出异常
|
|
|
* @Return java.lang.Boolean
|
|
|
*/
|
|
|
- private Boolean checkData(List<ImportDrugVO> importDrugVOS, List<ExportImportDrugErrDTO> errExports) {
|
|
|
+ private Boolean checkData(List<ImportDrugVO> importDrugVOS, List<ExportImportDrugErrDTO> errExports, Long hospitalId) {
|
|
|
AtomicBoolean errorFlog = new AtomicBoolean(false);
|
|
|
+ //获取数据库数据 判断医院药品名称和医院药品代码用于重复校验
|
|
|
+// List<DrugInfo> drugInfos = drugInfoFacade.list(new QueryWrapper<DrugInfo>()
|
|
|
+// .eq("hospital_id", hospitalId)
|
|
|
+// .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+// List<String> names = drugInfos.stream().map(DrugInfo::getName).collect(Collectors.toList());
|
|
|
+// List<String> codes = drugInfos.stream().map(DrugInfo::getCode).collect(Collectors.toList());
|
|
|
+
|
|
|
importDrugVOS.stream().forEach(importDrugVO -> {
|
|
|
ExportImportDrugErrDTO exportImportDrugErrDTO = new ExportImportDrugErrDTO();
|
|
|
BeanUtil.copyProperties(importDrugVO, exportImportDrugErrDTO);
|
|
|
StringBuffer errMsg = new StringBuffer();
|
|
|
- //数据校验
|
|
|
+ //数据校验(非空和过长、库中已存在)
|
|
|
+ //name
|
|
|
if (StringUtil.isEmpty(importDrugVO.getName())) {
|
|
|
- errMsg.append("医院手术/操作名称为空").append(";");
|
|
|
+ errMsg.append("【医院药品名称】未填写").append(";");
|
|
|
errorFlog.set(true);
|
|
|
- }
|
|
|
- if (StringUtil.isEmpty(importDrugVO.getStandard())) {
|
|
|
- errMsg.append("标准手术/操作名称为空").append(";");
|
|
|
+ } else if (importDrugVO.getName().length() > drugNameLength) {
|
|
|
+ errMsg.append("【医院诊断名称】过长").append(";");
|
|
|
errorFlog.set(true);
|
|
|
}
|
|
|
+
|
|
|
+ //approvalNum
|
|
|
+ if (StringUtil.isNotEmpty(importDrugVO.getApprovalNum())) {
|
|
|
+ if (importDrugVO.getApprovalNum().length() > approvalNumLength) {
|
|
|
+ errMsg.append("【国药准字】过长").append(";");
|
|
|
+ errorFlog.set(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
exportImportDrugErrDTO.setErrMsg(errMsg.toString());
|
|
|
errExports.add(exportImportDrugErrDTO);
|
|
|
});
|
|
@@ -234,9 +264,24 @@ public class DrugManagementFacade {
|
|
|
IPage<GetMatchingDrugPageDTO> drugPages = drugInfoServiceImpl.getBaseMapper().getMatchingDrugPage(getMatchingDrugPageVO);
|
|
|
for (GetMatchingDrugPageDTO drug : drugPages.getRecords()) {
|
|
|
//目前先按照_切割
|
|
|
- drug.setForm(drug.getStandard().split("_")[1]);
|
|
|
+ drug.setDosageForm(drug.getStandard().split("_")[1]);
|
|
|
getMatchingDrugPageDTOList.add(drug);
|
|
|
}
|
|
|
return drugPages.setRecords(getMatchingDrugPageDTOList);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 已匹配药品信息查看
|
|
|
+ *
|
|
|
+ * @param getDrugByIdVO
|
|
|
+ * @Return com.lantone.daqe.dto.GetDrugByIdDTO
|
|
|
+ */
|
|
|
+ public GetDrugByIdDTO getDrugById(GetDrugByIdVO getDrugByIdVO) {
|
|
|
+ GetDrugByIdDTO out = new GetDrugByIdDTO();
|
|
|
+ BeanUtil.copyProperties(drugInfoFacade.getById(getDrugByIdVO.getId()), out);
|
|
|
+ //目前先按照_切割
|
|
|
+ out.setDosageForm(out.getStandard().split("_")[1]);
|
|
|
+ out.setIsMapping(StringUtil.isBlank(out.getStandard()) ? "未匹配" : "已匹配");
|
|
|
+ return out;
|
|
|
+ }
|
|
|
}
|