You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
870 lines
45 KiB
Java
870 lines
45 KiB
Java
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.common.util.ResultVOUtils;
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
import com.glxp.api.controller.alihealth.AlihealthBusController;
|
|
import com.glxp.api.dao.basic.UdiRelevanceDao;
|
|
import com.glxp.api.dto.BasicProductsCreateDto;
|
|
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.ThirdAliDrugRequest;
|
|
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.alihealth.CopyUtils;
|
|
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.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
/**
|
|
* 耗材字典对照
|
|
*/
|
|
@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<UdiRelevanceResponse> udiRelevanceEntities = findDrkByUnion(deviceRecordKey, mainId);
|
|
if (CollUtil.isNotEmpty(udiRelevanceEntities)) {
|
|
return true;
|
|
} else
|
|
return false;
|
|
} else if (StrUtil.isNotEmpty(deviceRecordKey) && StrUtil.isEmpty(mainId)) {
|
|
List<UdiRelevanceResponse> 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<UdiRelevanceResponse> 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<UdiRelevanceResponse> udiRelevanceEntities = findByUnion2(deviceRecordKey, mainId, thirdSys);
|
|
if (CollUtil.isNotEmpty(udiRelevanceEntities)) {
|
|
return true;
|
|
} else
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private List<UdiRelevanceResponse> findByUnion2(String deviceRecordKey, String mainId, String thirdSys) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setMainId(mainId);
|
|
filterUdiRelRequest.setDeviceRecordKey(deviceRecordKey);
|
|
filterUdiRelRequest.setThirdSys(thirdSys);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
public List<UdiRelevanceResponse> 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<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
public List<UdiRelevanceResponse> findDrkByUnion(String deviceRecordKey, String mainId) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setMainId(mainId);
|
|
filterUdiRelRequest.setDeviceRecordKey(deviceRecordKey);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
|
|
public List<UdiRelevanceResponse> findByUuid(String uuid) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setUuid(uuid);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
public UdiRelevanceResponse findById(Long id) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setId(id);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
if (CollUtil.isNotEmpty(udiRelevanceEntities))
|
|
return udiRelevanceEntities.get(0);
|
|
return null;
|
|
}
|
|
|
|
public List<UdiRelevanceResponse> findByOriginUuid(String originUuid) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setOriginUuid(originUuid);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
public List<UdiRelevanceResponse> findByDeviceRecordKey(String deviceRecordKey) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setDeviceRecordKey(deviceRecordKey);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
|
|
public List<UdiRelevanceResponse> findByMainId(String mainId) {
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
filterUdiRelRequest.setMainId(mainId);
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
|
|
public List<UdiRelevanceResponse> filterAll(FilterUdiRelRequest filterUdiRelRequest) {
|
|
List<UdiRelevanceResponse> udiRelevanceEntities = udiRelevanceDao.contrastJoinSelect(filterUdiRelRequest);
|
|
return udiRelevanceEntities;
|
|
}
|
|
|
|
|
|
public void createUnionContrast(UdiCombineRequest udiCombineRequest, String key) {
|
|
List<UdiProductEntity> 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<UdiProductEntity> udiInfoEntities) {
|
|
return udiInfoEntities.stream()
|
|
.filter(udiProductEntity -> IntUtil.value(udiProductEntity.getDiType()) == 1)
|
|
.findFirst()
|
|
.orElse(null);
|
|
}
|
|
|
|
@Resource
|
|
ThirdAliDrugService thirdAliDrugService;
|
|
@Resource
|
|
private AlihealthBusController alihealthBusController;
|
|
|
|
// @Transactional
|
|
public BaseResponse createOnlyMainId(BasicProductsCreateDto basicProductsCreateDto) {
|
|
String mainId = basicProductsCreateDto.getMainId();
|
|
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<YbDrug> 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 {
|
|
return ResultVOUtils.error(500,"未能查询到此医保编码");
|
|
// udiProductEntity.setCpmctymc(thrProductsEntity.getName());
|
|
}
|
|
if (StrUtil.isEmpty(udiProductEntity.getZczbhhzbapzbh()) || StrUtil.isEmpty(udiProductEntity.getCpmctymc())) {
|
|
return ResultVOUtils.success();
|
|
}
|
|
// 本地查询先注释了
|
|
List<ThirdAliDrug> thirdAliDrugList = new ArrayList<>();
|
|
|
|
// List<ThirdAliDrug> thirdAliDrugList = thirdAliDrugService.list(
|
|
// new QueryWrapper<ThirdAliDrug>()
|
|
// .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 {
|
|
|
|
AuthAliUser authAliUser = authAliUserService.getOne();
|
|
AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust();
|
|
basicProductsCreateDto.setDrugCheckMark(basicProductsCreateDto.isDrugCheckMark());
|
|
alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid());
|
|
alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret());
|
|
alihealthThirdAliDrugInsertReqeust.setDrugCheckMark(basicProductsCreateDto.isDrugCheckMark());
|
|
// alihealthThirdAliDrugInsertReqeust.setManufactory(udiProductEntity.getManufactory());
|
|
alihealthThirdAliDrugInsertReqeust.setYbDrug(ybDrug);
|
|
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust();
|
|
alihealthKytDrugrescodeReqeust.setPhysic_name(udiProductEntity.getCpmctymc());
|
|
alihealthKytDrugrescodeReqeust.setApproval_licence_no(udiProductEntity.getZczbhhzbapzbh());
|
|
alihealthKytDrugrescodeReqeust.setPage_size(200);
|
|
alihealthKytDrugrescodeReqeust.setPage(1);
|
|
alihealthKytDrugrescodeReqeust.setApp_key(authAliUser.getAppkey());
|
|
alihealthKytDrugrescodeReqeust.setRef_ent_id(authAliUser.getRefentid());
|
|
alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust);
|
|
try {
|
|
BaseResponse<PageSimpleResponse<ThirdAliDrug>> baseResponse = alihealthBusController.thirdAliDrugList(alihealthThirdAliDrugInsertReqeust);
|
|
if (baseResponse.getCode() == 20000) {
|
|
thirdAliDrugList = baseResponse.getData().getList();
|
|
|
|
// if (thirdAliDrugService.addOrUpdate((List) baseResponse.getData())) {
|
|
// thirdAliDrugList = thirdAliDrugService.list(
|
|
// new QueryWrapper<ThirdAliDrug>()
|
|
// .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc())
|
|
// .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh())
|
|
// .eq(StringUtils.isNotEmpty(udiProductEntity.getManufactory()), "manufacturer", udiProductEntity.getManufactory())
|
|
//
|
|
// );
|
|
// } else {
|
|
// log.info("供应商平台获取阿里和国家库码段信息===未查到产品信息");
|
|
// udiProductService.insertUdiInfo(udiProductEntity);
|
|
//
|
|
// }
|
|
|
|
|
|
} else {
|
|
log.error("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
|
|
// udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
|
|
// error = "供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage();
|
|
|
|
udiProductService.insertUdiInfo(udiProductEntity);
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
log.error("供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage());
|
|
// udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage());
|
|
// error = "供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage();
|
|
udiProductService.insertUdiInfo(udiProductEntity);
|
|
|
|
}
|
|
|
|
// thirdAliDrugList = thirdAliDrugService.list(
|
|
// new QueryWrapper<ThirdAliDrug>()
|
|
// .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) {
|
|
List<CodeRel> codeRelArrayList = new ArrayList<>();
|
|
|
|
for (int i = 0; i < thirdAliDrugList.size(); i++) {
|
|
ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i);
|
|
|
|
udiProductEntity.setNameCode(thirdAliDrug.getNameCode());
|
|
|
|
// 数据处理
|
|
udiProductEntity.setPrepnSpec(CopyUtils.copyNullStr(udiProductEntity.getPrepnSpec(), thirdAliDrug.getFormSpec()));
|
|
udiProductEntity.setZczbhhzbapzbh(CopyUtils.copyNullStr(udiProductEntity.getZczbhhzbapzbh(), thirdAliDrug.getApprovalNum()));
|
|
udiProductEntity.setCpmctymc(CopyUtils.copyNullStr(udiProductEntity.getCpmctymc(), thirdAliDrug.getCpmctymc()));
|
|
udiProductEntity.setSpmc(CopyUtils.copyNullStr(udiProductEntity.getSpmc(), thirdAliDrug.getSpmc()));
|
|
|
|
udiProductEntity.setBzgg(CopyUtils.copyNullStr(udiProductEntity.getBzgg(), thirdAliDrug.getBzgg()));
|
|
udiProductEntity.setPackRatio(CopyUtils.copyNullStr(udiProductEntity.getPackRatio(), thirdAliDrug.getPackRatio()));
|
|
// udiProductEntity.setMatrial(ybDrug.getMaterialName());
|
|
// udiProductEntity.setPackMatrial(ybDrug.getMaterialName());
|
|
// udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType()));
|
|
//最小产品单位
|
|
udiProductEntity.setPackUnit(CopyUtils.copyNullStr(udiProductEntity.getPackUnit(), thirdAliDrug.getPackUnitName()));
|
|
//设置最小产品数量
|
|
// udiProductEntity.setBhxjsl(ybDrug.getFactor());
|
|
//生产厂家
|
|
// udiProductEntity.setManufactory(thirdAliDrug.getManufacturer());
|
|
//商品条码 essentialDrugMarkName sptm
|
|
// udiProductEntity.setSptm(ybDrug.getBusinessLicense());
|
|
udiProductEntity.setPrepnUnit(CopyUtils.copyNullStr(udiProductEntity.getPrepnUnit(), thirdAliDrug.getPrepnUnitName()));
|
|
|
|
List<Integer> 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(udiProductEntity.getBhxjsl()) == 0) {
|
|
udiProductEntity.setBhxjsl(IntUtil.value(ybDrug.getFactor()));
|
|
}
|
|
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());
|
|
} else {
|
|
udiProductEntity.setXjdw(thirdAliDrug.getPrepnUnitName());
|
|
|
|
}
|
|
if (thirdAliDrug.getPackLevel() != null && !thirdAliDrug.getPackLevel().equals("0")) {
|
|
udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4);
|
|
} else {
|
|
udiProductEntity.setDiType(1);
|
|
}
|
|
// udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName());
|
|
|
|
udiProductEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
// 多码融合表拼接参数
|
|
if (basicProductsCreateDto.isDrugCheckMark() && !thirdAliDrug.isDmcx()) {
|
|
CodeRel codeRel = new CodeRel();
|
|
codeRel.setDrugCode(thirdAliDrug.getNameCode());
|
|
codeRel.setUpdateTime(new Date());
|
|
codeRel.setYbbm(ybDrug.getGoodsCode());
|
|
codeRel.setPackUnit(udiProductEntity.getPackUnit());
|
|
codeRel.setBhxjsl(udiProductEntity.getBhxjsl());
|
|
codeRel.setXjdw(udiProductEntity.getXjdw());
|
|
codeRel.setYbBzgg(udiProductEntity.getBzgg());
|
|
codeRelArrayList.add(codeRel);
|
|
}
|
|
// 多码融合存在就以多码融合为准
|
|
udiProductEntity.setPackUnit(CopyUtils.copyNullStr(thirdAliDrug.getPackUnit(), udiProductEntity.getPackUnit()));
|
|
udiProductEntity.setBhxjsl(CopyUtils.copyNullNum(thirdAliDrug.getBhxjsl(), udiProductEntity.getBhxjsl()));
|
|
udiProductEntity.setXjdw(CopyUtils.copyNullStr(thirdAliDrug.getXjdw(), udiProductEntity.getXjdw()));
|
|
udiProductEntity.setBzgg(CopyUtils.copyNullStr(thirdAliDrug.getBzgg(), udiProductEntity.getBzgg()));
|
|
|
|
udiProductService.insertUdiInfo(udiProductEntity);
|
|
}
|
|
|
|
try {
|
|
udiRelevanceEntity.setDetailSort(Integer.valueOf(thirdAliDrugList.get(0).getPhysicDetailType()));
|
|
|
|
} catch (Exception e) {
|
|
log.error("明细分类转换出现错误" + e.getMessage());
|
|
}
|
|
// 上传到多码融合表
|
|
if (basicProductsCreateDto.isDrugCheckMark()
|
|
&& CollUtil.isNotEmpty(codeRelArrayList)) {
|
|
this.codeRelUpdateBatch(codeRelArrayList);
|
|
}
|
|
|
|
} 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<BasicInsMaterialEntity> 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 ResultVOUtils.success();
|
|
// 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);
|
|
}
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
/**
|
|
* 上传国家库多码融合库
|
|
*
|
|
* @param list
|
|
*/
|
|
public void codeRelUpdateBatch(List<CodeRel> list) {
|
|
if (list != null && list.size() > 0) {
|
|
|
|
try {
|
|
String response = HttpUtil.post(udiUrl + "/udchs/codeRel/updateBatch", JSONUtil.toJsonStr(list));
|
|
BaseResponse<String> baseResponse = JSONUtil.toBean(response, BaseResponse.class);
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
log.error("国家库===上传多码关系===" + list.get(0).getYbbm() + "成功===");
|
|
|
|
} else {
|
|
log.error("国家库===上传多码关系===出现错误===" + baseResponse.getMessage());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
log.error("国家库===上传多码关系===出现错误===" + e.getMessage());
|
|
|
|
}
|
|
} else {
|
|
log.error("国家库===上传多码关系===出现错误===数据为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void deleteRelCode(CodeRel codeRel) {
|
|
|
|
try {
|
|
String response = HttpUtil.post(udiUrl + "/udchs/codeRel/delete", JSONUtil.toJsonStr(codeRel));
|
|
BaseResponse<String> baseResponse = JSONUtil.toBean(response, BaseResponse.class);
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
} else {
|
|
log.error("国家库===删除多玛关系===出现错误===" + baseResponse.getMessage());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
log.error("国家库===删除多玛关系===出现错误===" + e.getMessage());
|
|
|
|
}
|
|
}
|
|
|
|
public List<ThirdAliDrug> optThirdAliDrug(ThirdAliDrugRequest thirdAliDrugRequest) {
|
|
List<ThirdAliDrug> thirdAliDrugList = new ArrayList<>();
|
|
try {
|
|
String response = HttpUtil.post(udiUrl + "/udiwms/aliDrug/optThirdAliDrug", JSONUtil.toJsonStr(thirdAliDrugRequest));
|
|
BaseResponse<List<ThirdAliDrug>> baseResponse =
|
|
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ThirdAliDrug>>>() {
|
|
|
|
});
|
|
if (baseResponse.getCode() == 20000) {
|
|
thirdAliDrugList =baseResponse.getData();
|
|
} else {
|
|
log.error("国家库===查询选入数据失败===" + baseResponse.getMessage());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
log.error("国家库===查询选入数据失败===出现错误===" + e.getMessage());
|
|
|
|
}
|
|
return thirdAliDrugList;
|
|
|
|
|
|
}
|
|
public List<ThirdAliDrug> disposeYbDrugList(List<ThirdAliDrug> thirdAliDrugList, YbDrug ybDrug, List<String> codeIn) {
|
|
List<ThirdAliDrug> list1 = new ArrayList<>();
|
|
String result = null;
|
|
if (codeIn != null && codeIn.size() > 0) {
|
|
result = String.join(", ", codeIn);
|
|
|
|
}
|
|
if (thirdAliDrugList != null && thirdAliDrugList.size() > 0) {
|
|
// List<ThirdAliDrug> list2 = new ArrayList<>();
|
|
for (ThirdAliDrug thirdAliDrug : thirdAliDrugList) {
|
|
String str = drugRulesVerify(ybDrug, thirdAliDrug);
|
|
if (StringUtils.isNotEmpty(str)) {
|
|
if (str.equals("1")) {
|
|
if (StringUtils.isNotEmpty(result)) {
|
|
if (!result.contains(thirdAliDrug.getNameCode())) {
|
|
list1.add(thirdAliDrug);
|
|
}
|
|
} else {
|
|
list1.add(thirdAliDrug);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// if(list1 !=null && list1.size() >0){
|
|
// return list1;
|
|
// }else if(list2 !=null && list2.size() >0){
|
|
// return list2;
|
|
// }
|
|
}
|
|
|
|
return list1;
|
|
}
|
|
|
|
public String drugRulesVerify(YbDrug ybDrug, ThirdAliDrug thirdAliDrug) {
|
|
try {
|
|
Integer bzggInt = DimaUtil.trMinCount(thirdAliDrug.getBzgg());
|
|
|
|
// 医保规格和阿里制剂规格双方都去除特殊符号和空格之后进行精准匹配
|
|
String realityOutlook = DimaUtil.specialCharactersRemover(ybDrug.getRealityOutlook());
|
|
String formSpec = DimaUtil.specialCharactersRemover(thirdAliDrug.getFormSpec());
|
|
|
|
|
|
// 按照医保数量与阿里包装规格对比
|
|
if ((bzggInt == ybDrug.getFactor()) && realityOutlook.equals(formSpec)) {
|
|
return "1";
|
|
}
|
|
|
|
// // 医保的规格与阿里制剂规格完全匹配
|
|
// if(thirdAliDrug.getFormSpec().equals(ybDrug.getRealityOutlook())){
|
|
// return "3";
|
|
// }
|
|
} catch (Exception e) {
|
|
log.error("药品校验出现错误===" + e.getMessage());
|
|
return null;
|
|
}
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
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<UdiProductEntity> 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<UdiProductEntity> 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;
|
|
}
|
|
|
|
|
|
}
|