|
|
|
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 com.glxp.api.constant.ConstantStatus;
|
|
|
|
import com.glxp.api.dao.basic.UdiRelevanceDao;
|
|
|
|
import com.glxp.api.entity.basic.UdiProductEntity;
|
|
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.BasicInsMaterialEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrProductsAddDiEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.ThrProductsEntity;
|
|
|
|
import com.glxp.api.entity.thrsys.YbDrug;
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
import com.glxp.api.http.NmpaUdiClient;
|
|
|
|
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.basic.UdiRelevanceResponse;
|
|
|
|
import com.glxp.api.service.thrsys.BasicInsMaterialService;
|
|
|
|
import com.glxp.api.service.thrsys.ThrProductsService;
|
|
|
|
import com.glxp.api.service.thrsys.YbDrugService;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
|
|
import com.glxp.api.util.IntUtil;
|
|
|
|
import com.glxp.api.util.udi.UdiInfoUtil;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 耗材字典对照
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public UdiProductEntity getDiProduct(List<UdiProductEntity> udiInfoEntities) {
|
|
|
|
return udiInfoEntities.stream()
|
|
|
|
.filter(udiProductEntity -> IntUtil.value(udiProductEntity.getDiType()) == 1)
|
|
|
|
.findFirst()
|
|
|
|
.orElse(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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<YbDrug> list = ybDrugService.getList(ybHcflDetailFilterRequest);
|
|
|
|
UdiProductEntity udiProductEntity = new UdiProductEntity();
|
|
|
|
BeanUtils.copyProperties(thrProductsEntity, udiProductEntity);
|
|
|
|
udiProductEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
if (list != null && list.size() > 0){
|
|
|
|
YbDrug ybDrug = list.get(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.setPackLevel(1 + "");
|
|
|
|
//生产厂家
|
|
|
|
udiProductEntity.setManufactory(ybDrug.getCompanyNameSc());
|
|
|
|
//商品条码 essentialDrugMarkName sptm
|
|
|
|
// udiProductEntity.setSptm(ybDrug.getBusinessLicense());
|
|
|
|
udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel());
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
if (StrUtil.isEmpty(udiProductEntity.getPrice())) {
|
|
|
|
udiProductEntity.setPrice("0.00");
|
|
|
|
}
|
|
|
|
udiProductEntity.setUpdateTime(new Date());
|
|
|
|
udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity);
|
|
|
|
udiProductService.insertUdiInfo(udiProductEntity);
|
|
|
|
// setLevel(udiRelevanceEntity.getUuid());
|
|
|
|
UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid());
|
|
|
|
udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid);
|
|
|
|
udiRelevanceService.insertUdiRelevance(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());
|
|
|
|
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.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);
|
|
|
|
}
|
|
|
|
} 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<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);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|