package com.glxp.api.service.basic; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.constant.ConstantStatus; import com.glxp.api.dao.basic.UdiRelevanceDao; import com.glxp.api.entity.auth.AuthAliUser; import com.glxp.api.entity.basic.UdiProductEntity; import com.glxp.api.entity.basic.UdiRelevanceEntity; import com.glxp.api.entity.thrsys.*; import com.glxp.api.exception.JsonException; import com.glxp.api.http.NmpaUdiClient; import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; import com.glxp.api.req.basic.UdiCombineRequest; import com.glxp.api.req.basic.FilterUdiRelRequest; import com.glxp.api.req.basic.YbDrugDetailFilterRequest; import com.glxp.api.req.thrsys.FilterThrProductsRequest; import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest; import com.glxp.api.req.thrsys.ThrInsMaterialFeeRequest; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.basic.UdiRelevanceResponse; import com.glxp.api.service.auth.AuthAliUserService; import com.glxp.api.service.auth.CustomerInfoService; import com.glxp.api.service.auth.CustomerService; import com.glxp.api.service.thrsys.BasicInsMaterialService; import com.glxp.api.service.thrsys.ThirdAliDrugService; import com.glxp.api.service.thrsys.ThrProductsService; import com.glxp.api.service.thrsys.YbDrugService; import com.glxp.api.util.*; import com.glxp.api.util.alihealth.AlihealthUtils; import com.glxp.api.util.udi.UdiInfoUtil; import lombok.extern.slf4j.Slf4j; import org.jfree.util.Log; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; /** * 耗材字典对照 */ @Service @Slf4j public class UdiContrastService { @Resource UdiRelevanceDao udiRelevanceDao; @Resource GennerOrderUtils gennerOrderUtils; @Resource ThrProductsService thrProductsService; @Resource UdiRelevanceService udiRelevanceService; @Resource UdiProductService udiProductService; @Resource NmpaUdiClient udiDlHttpClient; @Resource BasicInsMaterialService basicInsMaterialService; @Resource YbDrugService ybDrugService; @Resource private CustomerService customerService; @Resource private CustomerInfoService customerInfoService; @Resource private AlihealthUtils alihealthUtils; @Value("${UDI_SERVER_URL}") private String udiUrl; @Resource private AuthAliUserService authAliUserService; public boolean isExit(String originUuid, String mainId, String thirdSys) { String deviceRecordKey = null; if (StrUtil.isNotEmpty(originUuid)) { UdiProductEntity udiProductEntity = udiProductService.findOneByOriginUuid(originUuid); if (udiProductEntity != null) deviceRecordKey = udiProductEntity.getDeviceRecordKey(); } if (StrUtil.isNotEmpty(deviceRecordKey) && StrUtil.isNotEmpty(mainId) && StrUtil.isBlank(thirdSys)) { List udiRelevanceEntities = findDrkByUnion(deviceRecordKey, mainId); if (CollUtil.isNotEmpty(udiRelevanceEntities)) { return true; } else return false; } else if (StrUtil.isNotEmpty(deviceRecordKey) && StrUtil.isEmpty(mainId)) { List udiRelevanceEntities = findByDeviceRecordKey(deviceRecordKey); if (CollUtil.isNotEmpty(udiRelevanceEntities)) { for (UdiRelevanceResponse udiRelevanceEntity : udiRelevanceEntities) { if (StrUtil.isEmpty(udiRelevanceEntity.getMainId()) && StrUtil.isNotEmpty(udiRelevanceEntity.getOriginUuid())) { return true; } } } return false; } else if (StrUtil.isEmpty(originUuid) && StrUtil.isNotEmpty(mainId)) { List udiRelevanceEntities = findByMainId(mainId); if (CollUtil.isNotEmpty(udiRelevanceEntities)) { for (UdiRelevanceResponse udiRelevanceEntity : udiRelevanceEntities) { if (StrUtil.isEmpty(udiRelevanceEntity.getOriginUuid()) && StrUtil.isNotEmpty(udiRelevanceEntity.getMainId())) { return true; } } } return false; } else if (StrUtil.isNotBlank(deviceRecordKey) && StrUtil.isNotBlank(mainId) && StrUtil.isNotBlank(thirdSys)) { List udiRelevanceEntities = findByUnion2(deviceRecordKey, mainId, thirdSys); if (CollUtil.isNotEmpty(udiRelevanceEntities)) { return true; } else return false; } return false; } private List findByUnion2(String deviceRecordKey, String mainId, String thirdSys) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setMainId(mainId); filterUdiRelRequest.setDeviceRecordKey(deviceRecordKey); filterUdiRelRequest.setThirdSys(thirdSys); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public List findByUnion(String originUuid, String mainId) { UdiProductEntity udiProductEntity = udiProductService.findOneByOriginUuid(originUuid); if (udiProductEntity == null) { return null; } FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setMainId(mainId); filterUdiRelRequest.setDeviceRecordKey(udiProductEntity.getDeviceRecordKey()); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public List findDrkByUnion(String deviceRecordKey, String mainId) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setMainId(mainId); filterUdiRelRequest.setDeviceRecordKey(deviceRecordKey); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public List findByUuid(String uuid) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setUuid(uuid); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public UdiRelevanceResponse findById(Long id) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setId(id); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); if (CollUtil.isNotEmpty(udiRelevanceEntities)) return udiRelevanceEntities.get(0); return null; } public List findByOriginUuid(String originUuid) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setOriginUuid(originUuid); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public List findByDeviceRecordKey(String deviceRecordKey) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setDeviceRecordKey(deviceRecordKey); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public List findByMainId(String mainId) { FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setMainId(mainId); List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public List filterAll(FilterUdiRelRequest filterUdiRelRequest) { List udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest); return udiRelevanceEntities; } public void createUnionContrast(UdiCombineRequest udiCombineRequest, String key) { List udiInfoEntities = udiDlHttpClient.getOrUpdateByUuid(key); UdiRelevanceEntity udiRelevanceEntity = new UdiRelevanceEntity(); udiRelevanceEntity.setThirdId(udiCombineRequest.getThirdId()); udiRelevanceEntity.setMainId(udiCombineRequest.getThirdId()); udiRelevanceEntity.setUpdateTime(new Date()); udiRelevanceEntity.setModifyTime(new Date()); udiRelevanceEntity.setUuid(udiInfoEntities.get(0).getUuid()); udiRelevanceEntity.setSupName(udiCombineRequest.getSupName()); udiRelevanceEntity.setId(gennerOrderUtils.getRelId()); udiRelevanceEntity.setIsDisable(false); UdiProductEntity udiProductEntity = getDiProduct(udiInfoEntities); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); insertUdiInfos(udiInfoEntities); udiProductService.updateLevelCount(udiRelevanceEntity); } public UdiProductEntity getDiProduct(List udiInfoEntities) { return udiInfoEntities.stream() .filter(udiProductEntity -> IntUtil.value(udiProductEntity.getDiType()) == 1) .findFirst() .orElse(null); } @Resource ThirdAliDrugService thirdAliDrugService; // @Transactional public void createOnlyMainId(String mainId) { FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest(); filterThrProductsRequest.setCode(mainId); ThrProductsEntity thrProductsEntity = thrProductsService.selectByCode(mainId); UdiRelevanceEntity udiRelevanceEntity = new UdiRelevanceEntity(); udiRelevanceEntity.setThirdId(thrProductsEntity.getCode()); udiRelevanceEntity.setMainId(thrProductsEntity.getCode()); udiRelevanceEntity.setUpdateTime(new Date()); udiRelevanceEntity.setModifyTime(new Date()); udiRelevanceEntity.setUuid(CustomUtil.getUUId()); udiRelevanceEntity.setSupName(thrProductsEntity.getSupName()); udiRelevanceEntity.setId(gennerOrderUtils.getRelId()); udiRelevanceEntity.setSplitEnable(true); udiRelevanceEntity.setAutoCode(true); udiRelevanceEntity.setIsDisable(false); BasicInsMaterialEntity basicInsMaterialEntity = null; if (thrProductsEntity.getYbbm() != null) { //判断药品还是器械 if (thrProductsEntity.getProductType() == 2) { ThrInsDrugFeeRequest thrInsDrugFeeRequest = new ThrInsDrugFeeRequest(); thrInsDrugFeeRequest.setMedCatalogCode(thrProductsEntity.getYbbm()); YbDrugDetailFilterRequest ybHcflDetailFilterRequest = new YbDrugDetailFilterRequest(); ybHcflDetailFilterRequest.setLimit(1); ybHcflDetailFilterRequest.setPage(1); ybHcflDetailFilterRequest.setGoodsCode(thrProductsEntity.getYbbm()); List list = ybDrugService.getList(ybHcflDetailFilterRequest); UdiProductEntity udiProductEntity = new UdiProductEntity(); BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); YbDrug ybDrug = new YbDrug(); // 数据处理 udiProductEntity.setId(IdUtil.getSnowflakeNextId()); // udiProductEntity.setNameCode(thrProductsEntity.getCode()); udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); udiProductEntity.setDiType(1); udiProductEntity.setScbssfbhph("是"); udiProductEntity.setScbssfbhscrq("是"); udiProductEntity.setScbssfbhsxrq("是"); udiProductEntity.setScbssfbhxlh("否"); udiProductEntity.setProductsType(thrProductsEntity.getProductType()); udiProductEntity.setRequireScanCode(1); udiProductEntity.setMajorStatus(1); udiProductEntity.setPhysicType(3); //设置包装级别 udiProductEntity.setPackLevel(1 + ""); if (StrUtil.isEmpty(udiProductEntity.getPrice())) { udiProductEntity.setPrice("0.00"); } udiProductEntity.setUpdateTime(new Date()); udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); if (list != null && list.size() > 0) { ybDrug = list.get(0); // 数据做处理好查询阿里接口 if (ybDrug.getApprovalCode().contains("(")) { String[] charArr = ybDrug.getRegisteredProductName().split("\\("); ybDrug.setApprovalCode(charArr[0]); } // udiProductEntity.setNameCode(thrProductsEntity.getCode()); udiProductEntity.setPrepnSpec(ybDrug.getRealityOutlook()); udiProductEntity.setZczbhhzbapzbh(ybDrug.getApprovalCode()); udiProductEntity.setCpmctymc(ybDrug.getRegisteredProductName()); udiProductEntity.setSpmc(ybDrug.getGoodsName()); udiProductEntity.setBzgg(String.valueOf(ybDrug.getFactor()) + ybDrug.getMinUnit() + "/" + ybDrug.getUnit()); udiProductEntity.setMatrial(ybDrug.getMaterialName()); udiProductEntity.setPackMatrial(ybDrug.getMaterialName()); udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType())); //最小产品单位 udiProductEntity.setPackUnit(ybDrug.getUnit()); //设置最小产品数量 udiProductEntity.setBhxjsl(ybDrug.getFactor()); //生产厂家 udiProductEntity.setManufactory(ybDrug.getCompanyNameSc()); //商品条码 essentialDrugMarkName sptm // udiProductEntity.setSptm(ybDrug.getBusinessLicense()); udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel()); }else { udiProductEntity.setCpmctymc(thrProductsEntity.getName()); } if (StrUtil.isEmpty(udiProductEntity.getZczbhhzbapzbh()) || StrUtil.isEmpty(udiProductEntity.getCpmctymc())) { return; } List thirdAliDrugList = thirdAliDrugService.list( new QueryWrapper() .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) .eq(StringUtils.isNotEmpty(udiProductEntity.getManufactory()), "manufacturer", udiProductEntity.getManufactory()) ); if (CollUtil.isNotEmpty(thirdAliDrugList)) { } else { Map map = new HashMap(); if (StringUtils.isNotEmpty(udiProductEntity.getCpmctymc())) { map.put("cpmctymc", udiProductEntity.getCpmctymc()); } if (StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh())) { map.put("approvalNum", udiProductEntity.getZczbhhzbapzbh()); } if (StringUtils.isNotEmpty(udiProductEntity.getManufactory())) { map.put("manufacturer", udiProductEntity.getManufactory()); } List thirdAliDrugsListGjk = null; try { String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", map); BaseResponse> udiDlDeviceResponse = JSONObject.parseObject(response, new TypeReference>>() { }); if (udiDlDeviceResponse != null) { // 查询国家库是否有值 有值直接返回没值查询阿里接口 thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList(); } } catch (Exception e) { log.error("国家库查询阿里产品访问出现错误===" + e.getMessage()); } if (thirdAliDrugService.addOrUpdate(thirdAliDrugsListGjk)) { } else { List thirdAliDrugListNew = null; AuthAliUser authAliUser = authAliUserService.getOne(); AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust(); alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid()); alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret()); alihealthThirdAliDrugInsertReqeust.setManufactory(udiProductEntity.getManufactory()); AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust(); alihealthKytDrugrescodeReqeust.setPhysic_name(udiProductEntity.getCpmctymc()); alihealthKytDrugrescodeReqeust.setApproval_licence_no(udiProductEntity.getZczbhhzbapzbh()); alihealthKytDrugrescodeReqeust.setPage_size(100); alihealthKytDrugrescodeReqeust.setPage(1); alihealthKytDrugrescodeReqeust.setApp_key(authAliUser.getAppkey()); alihealthKytDrugrescodeReqeust.setRef_ent_id(authAliUser.getRefentid()); alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust); try { BaseResponse> baseResponse = alihealthUtils.thirdAliDrugInsertAll(alihealthThirdAliDrugInsertReqeust); if (baseResponse.getCode() == 20000) { thirdAliDrugListNew = baseResponse.getData(); if (thirdAliDrugService.addOrUpdate(thirdAliDrugListNew)) { } else { log.error("阿里接口未查到产品信息==="); udiProductService.insertUdiInfo(udiProductEntity); } } else { log.error("阿里接口未查到产品信息===" + baseResponse.getMessage()); udiProductService.insertUdiInfo(udiProductEntity); // throw new JsonException(500, "阿里接口未查到产品信息"); } } catch (Exception e) { log.error("阿里接口查询产品信息出现错误===" + e.getMessage()); udiProductService.insertUdiInfo(udiProductEntity); } if (thirdAliDrugListNew != null && thirdAliDrugListNew.size() > 0) { try { // 上传到国家库 Map mapNew = new HashMap(); mapNew.put("list", thirdAliDrugListNew); String response = HttpUtil.post(udiUrl + "/udiwms/aliDrug/addThirdAliDrug", JSONUtil.toJsonStr(mapNew)); BaseResponse baseResponseAdd = JSONUtil.toBean(response, BaseResponse.class); log.info("成功上传国家库阿里产品数据"); } catch (Exception e) { log.error("国家库上传阿里产品访问出现错误===" + e.getMessage()); } } } thirdAliDrugList = thirdAliDrugService.list( new QueryWrapper() .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) .eq(StringUtils.isNotEmpty(udiProductEntity.getManufactory()), "manufacturer", udiProductEntity.getManufactory()) ); // udiProductService.insertUdiInfo(udiProductEntity); } if(thirdAliDrugList!= null && thirdAliDrugList.size() >0){ for (int i = 0; i < thirdAliDrugList.size(); i++) { ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i); udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); // 数据处理 udiProductEntity.setPrepnSpec(thirdAliDrug.getFormSpec()); udiProductEntity.setZczbhhzbapzbh(thirdAliDrug.getApprovalNum()); udiProductEntity.setCpmctymc(thirdAliDrug.getCpmctymc()); udiProductEntity.setSpmc(thirdAliDrug.getSpmc()); udiProductEntity.setBzgg(thirdAliDrug.getBzgg()); udiProductEntity.setPackRatio(thirdAliDrug.getPackRatio()); // udiProductEntity.setMatrial(ybDrug.getMaterialName()); // udiProductEntity.setPackMatrial(ybDrug.getMaterialName()); // udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType())); //最小产品单位 udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); //设置最小产品数量 // udiProductEntity.setBhxjsl(ybDrug.getFactor()); //生产厂家 // udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); //商品条码 essentialDrugMarkName sptm // udiProductEntity.setSptm(ybDrug.getBusinessLicense()); udiProductEntity.setPrepnUnit(thirdAliDrug.getPrepnUnitName()); List integers = new ArrayList<>(); if (StrUtil.isNotEmpty(thirdAliDrug.getPackRatio())) { integers = DimaUtil.calculateLevels(thirdAliDrug.getPackRatio()); } udiProductEntity.setPackLevel(thirdAliDrug.getPackLevel()); try { udiProductEntity.setBhxjsl(integers.get(IntUtil.value(thirdAliDrug.getPackLevel()) - 1)); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); Log.error("计算包装级别出错" + thirdAliDrug.getPackLevel() + "---" + integers + "-----" + thirdAliDrug.toString()); udiProductEntity.setBhxjsl(0); } if (IntUtil.value(thirdAliDrug.getPackLevel()) == 1) { udiProductEntity.setXjdw(ybDrug.getMinUnit()); if (DimaUtil.trMinCount(thirdAliDrug.getBzgg()) != null) { udiProductEntity.setBhxjsl(DimaUtil.trMinCount(thirdAliDrug.getBzgg())); } else udiProductEntity.setBhxjsl(ybDrug.getFactor()); } if (thirdAliDrug.getPackLevel() != null && !thirdAliDrug.getPackLevel().equals("0")) { udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4); } else { udiProductEntity.setDiType(1); } udiProductEntity.setXjdw(thirdAliDrug.getPrepnUnitName()); udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); udiProductEntity.setId(IdUtil.getSnowflakeNextId()); udiProductService.insertUdiInfo(udiProductEntity); } }else { udiProductService.insertUdiInfo(udiProductEntity); } // setLevel(udiRelevanceEntity.getUuid()); UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid()); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); udiProductService.updateLevelCount(udiRelevanceEntity); } else { //器械 ThrInsMaterialFeeRequest request = new ThrInsMaterialFeeRequest(); request.setMedCatalogCode(thrProductsEntity.getYbbm()); List basicInsMaterialEntities = basicInsMaterialService.filterList(request); if (basicInsMaterialEntities.size() > 0) { basicInsMaterialEntity = basicInsMaterialEntities.get(0); } UdiProductEntity udiProductEntity = new UdiProductEntity(); BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); udiProductEntity.setNameCode(thrProductsEntity.getCode()); udiProductEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo()); udiProductEntity.setPackUnit(thrProductsEntity.getMeasname()); if (basicInsMaterialEntity != null){ udiProductEntity.setGgxh(basicInsMaterialEntity.getSpecification() != null ? basicInsMaterialEntity.getSpecification() : thrProductsEntity.getSpec()); udiProductEntity.setManufactory(basicInsMaterialEntity.getManufacturerName() != null ? basicInsMaterialEntity.getManufacturerName() : thrProductsEntity.getManufactory()); } // udiProductEntity.setBzgg(thrProductsEntity.getSpec()); udiProductEntity.setGgxh(thrProductsEntity.getSpec()); udiProductEntity.setCpmctymc(thrProductsEntity.getName()); udiProductEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory()); //包装单位 udiProductEntity.setPrepnUnit(thrProductsEntity.getPrepnUnit() == null ? null : thrProductsEntity.getPrepnUnit()); udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); udiProductEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD); udiProductEntity.setDiType(1); udiProductEntity.setScbssfbhph("是"); udiProductEntity.setScbssfbhscrq("是"); udiProductEntity.setScbssfbhsxrq("是"); udiProductEntity.setScbssfbhxlh("否"); udiProductEntity.setPackLevel(1 + ""); udiProductEntity.setProductsType(thrProductsEntity.getProductType()); udiProductEntity.setRequireScanCode(0); udiProductEntity.setUpdateTime(new Date()); if (StrUtil.isEmpty(udiProductEntity.getPrice())) { udiProductEntity.setPrice(null); } udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); udiProductService.insertUdiInfo(udiProductEntity); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); udiProductService.updateLevelCount(udiRelevanceEntity); } } else { //没有医保编码 Boolean aBoolean = insertProduct(thrProductsEntity, basicInsMaterialEntity, udiRelevanceEntity); if (!aBoolean) { throw new JsonException(500, "系统繁忙,"); } return; // UdiProductEntity udiProductEntity = new UdiProductEntity(); // BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); // if (thrProductsEntity.getProductType() != 2){ // //不是药品就设置namecode // udiProductEntity.setNameCode(thrProductsEntity.getCode()); // udiProductEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo()); // udiProductEntity.setPackUnit(thrProductsEntity.getMeasname()); // udiProductEntity.setGgxh(basicInsMaterialEntity != null ? basicInsMaterialEntity.getSpecification() : thrProductsEntity.getSpec()); // udiProductEntity.setManufactory(basicInsMaterialEntity != null ? basicInsMaterialEntity.getManufacturerName() : thrProductsEntity.getManufactory()); // } // udiProductEntity.setBzgg(thrProductsEntity.getSpec()); // udiProductEntity.setCpmctymc(thrProductsEntity.getName()); // udiProductEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory()); // // //包装单位 // udiProductEntity.setPrepnUnit(thrProductsEntity.getMeasname()); // udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); // udiProductEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD); // udiProductEntity.setDiType(1); // udiProductEntity.setScbssfbhph("是"); // udiProductEntity.setScbssfbhscrq("是"); // udiProductEntity.setScbssfbhsxrq("是"); // udiProductEntity.setScbssfbhxlh("否"); // // udiProductEntity.setProductsType(thrProductsEntity.getProductType()); // if (thrProductsEntity.getProductType() == 2){ // udiProductEntity.setRequireScanCode(1); // udiProductEntity.setMajorStatus(1); // }else { // udiProductEntity.setRequireScanCode(0); // } // if (StrUtil.isEmpty(udiProductEntity.getPrice())) { // udiProductEntity.setPrice(null); // } // udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); // udiProductService.insertUdiInfo(udiProductEntity); // udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); // udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); } } public void createOnlyApply(ThrProductsAddDiEntity thrProductsAddDiEntity) { UdiRelevanceEntity udiRelevanceEntity = new UdiRelevanceEntity(); udiRelevanceEntity.setThirdId(thrProductsAddDiEntity.getCode()); udiRelevanceEntity.setMainId(thrProductsAddDiEntity.getCode()); udiRelevanceEntity.setUpdateTime(new Date()); udiRelevanceEntity.setModifyTime(new Date()); udiRelevanceEntity.setUuid(CustomUtil.getUUId()); udiRelevanceEntity.setSupName(thrProductsAddDiEntity.getSupName()); udiRelevanceEntity.setId(gennerOrderUtils.getRelId()); udiRelevanceEntity.setIsDisable(false); udiRelevanceEntity.setNewNeedUpload(true); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); UdiProductEntity udiProductEntity = new UdiProductEntity(); BeanUtils.copyProperties(thrProductsAddDiEntity, udiProductEntity); udiProductEntity.setNameCode(thrProductsAddDiEntity.getCode()); udiProductEntity.setCpmctymc(thrProductsAddDiEntity.getName()); udiProductEntity.setManufactory(thrProductsAddDiEntity.getManufactory()); udiProductEntity.setYlqxzcrbarmc(thrProductsAddDiEntity.getManufactory()); udiProductEntity.setGgxh(thrProductsAddDiEntity.getSpec()); udiProductEntity.setZczbhhzbapzbh(thrProductsAddDiEntity.getRegisterNo()); udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); udiProductEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD); udiProductEntity.setDiType(1); udiProductEntity.setScbssfbhph("否"); udiProductEntity.setScbssfbhscrq("否"); udiProductEntity.setScbssfbhsxrq("否"); udiProductEntity.setScbssfbhxlh("否"); udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); udiProductService.insertUdiInfo(udiProductEntity); } public Long createOnlyUuid(UdiCombineRequest udiCombineRequest, String key) { List udiInfoEntities = udiDlHttpClient.getOrUpdateByUuid(key); UdiRelevanceEntity udiRelevanceEntity = new UdiRelevanceEntity(); udiRelevanceEntity.setUpdateTime(new Date()); udiRelevanceEntity.setModifyTime(new Date()); udiRelevanceEntity.setUuid(udiInfoEntities.get(0).getUuid()); if (StrUtil.isNotBlank(udiCombineRequest.getSupName())) { udiRelevanceEntity.setSupName(udiCombineRequest.getSupName()); } Long relId = gennerOrderUtils.getRelId(); udiRelevanceEntity.setId(relId); udiRelevanceEntity.setIsDisable(false); UdiProductEntity udiProductEntity = udiRelevanceService.getDiProduct(udiInfoEntities); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); insertUdiInfos(udiInfoEntities); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); udiProductService.updateLevelCount(udiRelevanceEntity); return relId; } public Integer setMedicareType(String insuranceDrugClass) { if ("甲".equals(insuranceDrugClass)) { return 1; } else if ("乙".equals(insuranceDrugClass)) { return 2; } else if ("丙".equals(insuranceDrugClass)) { return 3; } else { return null; // 或者 throw new IllegalArgumentException("未知的医保类别"); } } public void insertUdiInfos(List udiInfoEntities) { if (CollUtil.isNotEmpty(udiInfoEntities)) { UdiProductEntity udiProductEntity = udiProductService.findByUuid(udiInfoEntities.get(0).getUuid()); if (udiProductEntity == null) { for (UdiProductEntity udiInfoEntity : udiInfoEntities) { udiInfoEntity.setId(IdUtil.getSnowflakeNextId()); } udiProductService.insertUdiInfos(UdiInfoUtil.initUdiInfoEntitys(udiInfoEntities)); } } } public Boolean insertProduct(ThrProductsEntity thrProductsEntity, BasicInsMaterialEntity basicInsMaterialEntity, UdiRelevanceEntity udiRelevanceEntity) { //没有医保编码 UdiProductEntity udiProductEntity = new UdiProductEntity(); BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); if (thrProductsEntity.getProductType() != 2) { //不是药品就设置namecode udiProductEntity.setNameCode(thrProductsEntity.getCode()); udiProductEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo()); udiProductEntity.setPackUnit(thrProductsEntity.getMeasname()); udiProductEntity.setGgxh(basicInsMaterialEntity != null ? basicInsMaterialEntity.getSpecification() : thrProductsEntity.getSpec()); udiProductEntity.setManufactory(basicInsMaterialEntity != null ? basicInsMaterialEntity.getManufacturerName() : thrProductsEntity.getManufactory()); } udiProductEntity.setBzgg(thrProductsEntity.getSpec()); udiProductEntity.setCpmctymc(thrProductsEntity.getName()); udiProductEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory()); //包装单位 udiProductEntity.setPackUnit(thrProductsEntity.getMeasname()); udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); udiProductEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD); udiProductEntity.setDiType(1); udiProductEntity.setScbssfbhph("是"); udiProductEntity.setScbssfbhscrq("是"); udiProductEntity.setScbssfbhsxrq("是"); udiProductEntity.setScbssfbhxlh("否"); udiProductEntity.setProductsType(thrProductsEntity.getProductType()); if (thrProductsEntity.getProductType() == 2) { udiProductEntity.setRequireScanCode(1); udiProductEntity.setMajorStatus(1); udiProductEntity.setPhysicType(3); } else { udiProductEntity.setPackLevel(1 + ""); udiProductEntity.setRequireScanCode(0); } if (StrUtil.isEmpty(udiProductEntity.getPrice())) { udiProductEntity.setPrice(null); } udiProductEntity.setUpdateTime(new Date()); udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); udiProductService.insertUdiInfo(udiProductEntity); udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); return true; } }