添加院内药品和选入药品层级等逻辑代码优化

dev_drug
qiuyt 2 months ago
parent e065192e16
commit 52787a7080

@ -1,23 +1,18 @@
package com.glxp.api.controller.alihealth;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
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.metadata.IPage;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.annotation.Log;
import com.glxp.api.annotation.RepeatSubmit;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.RedissonCacheKey;
import com.glxp.api.controller.BaseController;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrugCode;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.entity.thrsys.CodeRel;
import com.glxp.api.entity.thrsys.ThirdAliDrug;
@ -27,27 +22,19 @@ import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.alihealth.AlihealthKytGetentinfoReqeust;
import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust;
import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust;
import com.glxp.api.req.thrsys.CodeRelRequest;
import com.glxp.api.req.thrsys.ThirdAliDrugRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.alihealth.AlihealthKytGetentinfoResponse;
import com.glxp.api.service.alihealth.AlihealthBusService;
import com.glxp.api.service.basic.UdiContrastService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.util.DimaUtil;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.JsonUtils;
import com.glxp.api.util.alihealth.AlihealthUtils;
import com.glxp.api.util.alihealth.CopyUtils;
import com.glxp.api.util.alihealth.PaginationUtil;
import com.google.api.client.json.Json;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.*;
@ -103,10 +90,6 @@ public class AlihealthBusController extends BaseController {
}
}
@Resource
private UdiContrastService udiContrastService;
@PostMapping("/spms/alihealth/thirdAliDrugList")
@Log(title = "获取阿里药品码段信息列表包括查询国家库", businessType = BusinessType.OTHER)
public BaseResponse<PageSimpleResponse<ThirdAliDrug>> thirdAliDrugList(@RequestBody AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) {
@ -114,7 +97,7 @@ public class AlihealthBusController extends BaseController {
PageSimpleResponse<ThirdAliDrug> pageSimpleResponse =new PageSimpleResponse();
// 本地查询和新增都先注释了 到时候加到这边来
YbDrug ybDrug = alihealthThirdAliDrugInsertReqeust.getYbDrug();
if(ybDrug!= null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())){
if(alihealthThirdAliDrugInsertReqeust.isSelectCodeRelMark() && ybDrug!= null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())){
// 用医保编码查询国家库药品信息
try {
CodeRel codeReNew = new CodeRel();
@ -138,104 +121,44 @@ public class AlihealthBusController extends BaseController {
log.error("国家库===用医保编码查询国家库药品信息===出现错误===" + e.getMessage());
}
}
// 校验标识判断 为false不会后续增加多玛融合库的逻辑 直接返回
if(alihealthThirdAliDrugInsertReqeust.isDrugCheckMark() == false){
pageSimpleResponse.setList(thirdAliDrugsListGjk);
return ResultVOUtils.success(pageSimpleResponse);
}
// 查询国家库药品信息 并且要插入到多玛融合表
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust();
Map map = new HashMap();
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getPhysic_name())) {
map.put("cpmctymc", alihealthKytDrugrescodeReqeust.getPhysic_name());
}
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getApproval_licence_no())) {
map.put("approvalNum", alihealthKytDrugrescodeReqeust.getApproval_licence_no());
}
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthThirdAliDrugInsertReqeust.getManufactory())) {
map.put("manufacturer", alihealthThirdAliDrugInsertReqeust.getManufactory());
}
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthThirdAliDrugInsertReqeust.getFormSpec())) {
map.put("formSpec", alihealthThirdAliDrugInsertReqeust.getFormSpec());
}
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthThirdAliDrugInsertReqeust.getBzgg())) {
map.put("bzgg", alihealthThirdAliDrugInsertReqeust.getBzgg());
}
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthThirdAliDrugInsertReqeust.getNameCode())) {
map.put("nameCode", alihealthThirdAliDrugInsertReqeust.getNameCode());
}
map.put("page", alihealthThirdAliDrugInsertReqeust.getPage());
map.put("limit", alihealthThirdAliDrugInsertReqeust.getLimit());
map.put("nameCodeIn", alihealthThirdAliDrugInsertReqeust.getNameCodeIn());
}else {
// 查询国家库药品信息 并且要插入到多玛融合表
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = alihealthThirdAliDrugInsertReqeust.getAlihealthKytDrugrescodeReqeust();
if(alihealthThirdAliDrugInsertReqeust.getGjkSwitch()){
try {
String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", map);
BaseResponse<PageSimpleResponse<ThirdAliDrug>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThirdAliDrug>>>() {
});
if (udiDlDeviceResponse != null
) {
// 查询国家库是否有值 有值直接返回没值查询阿里接口
thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList();
if(thirdAliDrugsListGjk.size() == udiDlDeviceResponse.getData().getTotal()){
thirdAliDrugsListGjk = PaginationUtil.getPage(thirdAliDrugsListGjk, alihealthThirdAliDrugInsertReqeust.getPage()
, alihealthThirdAliDrugInsertReqeust.getLimit());
ThirdAliDrugRequest thirdAliDrugRequest = new ThirdAliDrugRequest();
BeanUtil.copyProperties(alihealthThirdAliDrugInsertReqeust,thirdAliDrugRequest);
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getPhysic_name())) {
thirdAliDrugRequest.setCpmctymc(alihealthKytDrugrescodeReqeust.getPhysic_name());
}
if (com.glxp.api.util.StringUtils.isNotEmpty(alihealthKytDrugrescodeReqeust.getApproval_licence_no())) {
thirdAliDrugRequest.setApprovalNum(alihealthKytDrugrescodeReqeust.getApproval_licence_no());
}
try {
String response = HttpUtil.get(udiUrl + "/udiwms/aliDrug/getDrugLevelList", BeanUtil.beanToMap(thirdAliDrugRequest));
BaseResponse<PageSimpleResponse<ThirdAliDrug>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThirdAliDrug>>>() {
});
if (udiDlDeviceResponse != null
) {
// 查询国家库是否有值 有值直接返回没值查询阿里接口
thirdAliDrugsListGjk = udiDlDeviceResponse.getData().getList();
if(thirdAliDrugsListGjk.size() == udiDlDeviceResponse.getData().getTotal()){
thirdAliDrugsListGjk = PaginationUtil.getPage(thirdAliDrugsListGjk, alihealthThirdAliDrugInsertReqeust.getPage()
, alihealthThirdAliDrugInsertReqeust.getLimit());
}
pageSimpleResponse.setList(thirdAliDrugsListGjk);
pageSimpleResponse.setTotal(Long.valueOf(udiDlDeviceResponse.getData().getTotal()));
}
pageSimpleResponse.setList(thirdAliDrugsListGjk);
pageSimpleResponse.setTotal(Long.valueOf(udiDlDeviceResponse.getData().getTotal()));
}
} catch (Exception e) {
log.error("国家库===查询药品信息===出现错误===" + e.getMessage());
} catch (Exception e) {
log.error("国家库===查询药品信息===出现错误===" + e.getMessage());
}
}
return ResultVOUtils.success(pageSimpleResponse);
}
// if (thirdAliDrugsListGjk != null && thirdAliDrugsListGjk.size() > 0) {
//
// } else {
//// BaseResponse<List<ThirdAliDrug>> baseResponse = alihealthUtils.thirdAliDrugInsertAll(alihealthThirdAliDrugInsertReqeust);
//// if (baseResponse.getCode() == 20000) {
//// thirdAliDrugsListGjk = baseResponse.getData();
//// } else {
//// log.error("阿里接口未查到产品信息===" + baseResponse.getMessage());
//// return ResultVOUtils.error("阿里接口未查到产品信息===" + baseResponse.getMessage());
////
//// }
//// // 上传到国家库
//// try {
//// Map mapNew = new HashMap();
//// mapNew.put("list", thirdAliDrugsListGjk);
//// 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());
//// }
//
// }
// // 上传多玛关系于处理规则在插入到融合表
// if(ybDrug!= null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())
// ){
// // 规则匹配
// thirdAliDrugsListGjk = udiContrastService.disposeYbDrugList(thirdAliDrugsListGjk,ybDrug,alihealthThirdAliDrugInsertReqeust.getNameCodeIn());
//
// }
pageSimpleResponse.setList(thirdAliDrugsListGjk);
return ResultVOUtils.success(pageSimpleResponse);
// udiProductService.insertUdiInfo(udiProductEntity);
}

@ -13,12 +13,10 @@ import com.glxp.api.constant.*;
import com.glxp.api.controller.BaseController;
import com.glxp.api.controller.sync.SpsSyncWebSocket;
import com.glxp.api.dto.BasicProductsCreateDto;
import com.glxp.api.entity.basic.CompanyProductRelevanceEntity;
import com.glxp.api.entity.basic.ProductInfoEntity;
import com.glxp.api.entity.basic.UdiProductEntity;
import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.sync.SocketMsgEntity;
import com.glxp.api.entity.system.CompanyEntity;
import com.glxp.api.entity.thrsys.CodeRel;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
@ -39,7 +37,6 @@ import com.glxp.api.service.thrsys.ThrSystemService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.udi.UdiInfoUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -128,7 +125,7 @@ public class UdiContrastController extends BaseController{
} else {
BasicProductsCreateDto basicProductsCreateDto =new BasicProductsCreateDto();
basicProductsCreateDto.setMainId(thirdId);
basicProductsCreateDto.setDrugCheckMark(false);
basicProductsCreateDto.setAddCodeRelMark(false);
return udiContrastService.createOnlyMainId(basicProductsCreateDto);
}

@ -1,9 +1,9 @@
package com.glxp.api.controller.thrsys;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.annotation.RepeatSubmit;
@ -19,11 +19,8 @@ import com.glxp.api.entity.thrsys.ThirdAliDrug;
import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust;
import com.glxp.api.req.basic.FilterUdiRelRequest;
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
import com.glxp.api.req.thrsys.ThirdAliDrugRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.collect.RelCodeDetailResponse;
import com.glxp.api.res.thrsys.ThrCorpsResponse;
import com.glxp.api.service.auth.AuthAliUserService;
import com.glxp.api.service.basic.UdiProductService;
import com.glxp.api.service.thrsys.ThirdAliDrugService;
@ -74,8 +71,6 @@ public class ThirdAliDrugController extends BaseController {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (StrUtil.isEmpty(thirdAliDrug.getApprovalNum()) && StrUtil.isEmpty(thirdAliDrug.getNameCode()) &&
StrUtil.isEmpty(thirdAliDrug.getCpmctymc()) && StrUtil.isEmpty(thirdAliDrug.getManufacturer())
) {
@ -95,32 +90,19 @@ public class ThirdAliDrugController extends BaseController {
}
thirdAliDrug.setNameCodeIn(nameCodeIn);
List<ThirdAliDrug> list = new ArrayList<>();
// 不查本地库全查阿里的库
// List<ThirdAliDrug> list = thirdAliDrugService.filterList(thirdAliDrug);
// if(list == null || list.size() == 0){
// 查询国家库的阿里数据信息
AuthAliUser authAliUser = authAliUserService.getOne();
AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust();
BeanUtil.copyProperties(thirdAliDrug,alihealthThirdAliDrugInsertReqeust);
alihealthThirdAliDrugInsertReqeust.setErpId(authAliUser.getErpid());
alihealthThirdAliDrugInsertReqeust.setAppSecret(authAliUser.getAppsecret());
alihealthThirdAliDrugInsertReqeust.setManufactory(thirdAliDrug.getManufacturer());
alihealthThirdAliDrugInsertReqeust.setBzgg(thirdAliDrug.getBzgg());
alihealthThirdAliDrugInsertReqeust.setFormSpec(thirdAliDrug.getFormSpec());
alihealthThirdAliDrugInsertReqeust.setNameCodeIn(nameCodeIn);
alihealthThirdAliDrugInsertReqeust.setGjkSwitch(true);
alihealthThirdAliDrugInsertReqeust.setPage(thirdAliDrug.getPage());
alihealthThirdAliDrugInsertReqeust.setLimit(thirdAliDrug.getLimit());
alihealthThirdAliDrugInsertReqeust.setDrugCheckMark(true);
alihealthThirdAliDrugInsertReqeust.setNameCode(thirdAliDrug.getNameCode());
alihealthThirdAliDrugInsertReqeust.setSelectCodeRelMark(false);
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust();
alihealthKytDrugrescodeReqeust.setPhysic_name(thirdAliDrug.getCpmctymc());
alihealthKytDrugrescodeReqeust.setApproval_licence_no(thirdAliDrug.getApprovalNum());
// alihealthKytDrugrescodeReqeust.setEnt_name(thirdAliDrug.getManufacturer());
// alihealthKytDrugrescodeReqeust.setPackage_spec(thirdAliDrug.getBzgg());
// alihealthKytDrugrescodeReqeust.setPrepn_spec(thirdAliDrug.getFormSpec());
alihealthKytDrugrescodeReqeust.setPage_size(200);
alihealthKytDrugrescodeReqeust.setPage(1);
alihealthKytDrugrescodeReqeust.setApp_key(authAliUser.getAppkey());
@ -134,21 +116,14 @@ public class ThirdAliDrugController extends BaseController {
list = baseResponse.getData().getList();
total = baseResponse.getData().getTotal();
}
} else {
log.error("获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
// udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
// error = "供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage();
}
} catch (Exception e) {
log.error("获取阿里和国家库码段信息出现错误===" + e.getMessage());
}
// }
PageInfo<ThirdAliDrug> pageInfo = new PageInfo<>(list);
PageSimpleResponse<ThirdAliDrug> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(Long.valueOf(total));

@ -5,6 +5,8 @@ import lombok.Data;
@Data
public class BasicProductsCreateDto {
private String mainId;
private boolean drugCheckMark;
/**
*
*/
private boolean addCodeRelMark;
}

@ -179,8 +179,7 @@ public class ThirdAliDrug implements Serializable {
*/
@TableField(exist = false)
public String ybBzgg;
@TableField(exist = false)
public boolean dmcx = false;
private static final long serialVersionUID = 1L;
public ThirdAliDrug(String type, String manufacturer, String cpmctymc, String form, String formSpec, String bzgg,String approvalNum, String spmc, String nameCode, String packRatio, String packLevel, Date createTime, Date updateTime) {

@ -2,7 +2,6 @@ package com.glxp.api.req.alihealth.local;
import com.glxp.api.entity.thrsys.YbDrug;
import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.thrsys.ThirdAliDrugRequest;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
@ -12,16 +11,15 @@ import java.util.List;
public class AlihealthThirdAliDrugInsertReqeust extends ListPageRequest {
private String erpId;
private String appSecret;
private String manufactory;
private Boolean gjkSwitch = true;
private String manufacturer;
private YbDrug ybDrug;
private String formSpec;
private String bzgg;
private List<String> nameCodeIn;
/**
*
*
*/
private boolean drugCheckMark;
private boolean selectCodeRelMark;
private String nameCode;
private AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust;

@ -8,7 +8,6 @@ import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.exception.JsonException;
import com.glxp.api.http.ErpBasicClient;
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
import com.glxp.api.res.PageSimpleResponse;
@ -17,7 +16,6 @@ import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.glxp.api.service.thrsys.ThrSystemService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.DateUtil;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.RedisUtil;
import org.springframework.beans.BeanUtils;
@ -201,62 +199,10 @@ public class BasicBackUpdateProductService {
for (ThrProductsEntity thrProductsEntity : thrProductsEntities) {
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(thrProductsEntity.getCode(), thirdSysId);
if (udiRelevanceEntity == null) {
// if (isUpdate.getParamValue().equals("1")) {
//
// UdiProductEntity udiProductEntity = new UdiProductEntity();
// udiProductEntity.setNameCode(thrProductsEntity.getCode());
// udiProductEntity.setCpmctymc(thrProductsEntity.getName());
// udiProductEntity.setGgxh(thrProductsEntity.getSpec());
// udiProductEntity.setUuid(CustomUtil.getUUId());
// udiProductEntity.setProductType(ConstantStatus.PRODUCT_TYPE_THIRD);
// udiProductEntity.setDiType(1);
// udiProductEntity.setManufactory(thrProductsEntity.getManufactory());
// udiProductEntity.setYlqxzcrbarmc(thrProductsEntity.getManufactory());
// udiProductEntity.setZczbhhzbapzbh(thrProductsEntity.getRegisterNo());
// udiProductEntity.setRequireScanCode(0);
// udiProductService.insertUdiInfo(udiProductEntity);
// UdiRelevanceEntity udiRelevanceEntity1 = new UdiRelevanceEntity();
// udiRelevanceEntity1.setUuid(udiProductEntity.getUuid());
// udiRelevanceEntity1.setIsDisable(false);
// udiRelevanceEntity1.setSupName(thrProductsEntity.getSupName());
//
// if ("thirdId".equals(thirdSysId)) {
// udiRelevanceEntity1.setThirdId(thrProductsEntity.getCode());
// } else if ("thirdId1".equals(thirdSysId)) {
// udiRelevanceEntity1.setThirdId1(thrProductsEntity.getCode());
// } else if ("thirdId2".equals(thirdSysId)) {
// udiRelevanceEntity1.setThirdId4(thrProductsEntity.getCode());
// } else if ("thirdId3".equals(thirdSysId)) {
// udiRelevanceEntity1.setThirdId3(thrProductsEntity.getCode());
// } else if ("thirdId4".equals(thirdSysId)) {
// udiRelevanceEntity1.setThirdId4(thrProductsEntity.getCode());
// }
//
//
// ThrSystemEntity thrSystemEntity = thrSystemService.selectMainThrSys();
// String mainSys = thrSystemEntity.getThirdId();
// if (mainSys.equals("thirdId")) {
// udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId());
// } else if (mainSys.equals("thirdId1")) {
// udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId1());
// } else if (mainSys.equals("thirdId2")) {
// udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId2());
// } else if (mainSys.equals("thirdId3")) {
// udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId3());
// } else if (mainSys.equals("thirdId4")) {
// udiRelevanceEntity1.setMainId(udiRelevanceEntity1.getThirdId4());
// }
//
// udiRelevanceEntity1.setThirdId(thrProductsEntity.getCode());
// udiRelevanceEntity1.setUpdateTime(new Date());
// udiRelevanceEntity1.setModifyTime(new Date());
// udiRelevanceEntity1.setId(gennerOrderUtils.getRelId());
// udiRelevanceService.insertUdiRelevanceignore(udiRelevanceEntity1);
// }
try {
BasicProductsCreateDto basicProductsCreateDto =new BasicProductsCreateDto();
basicProductsCreateDto.setMainId(thrProductsEntity.getCode());
basicProductsCreateDto.setDrugCheckMark(false);
basicProductsCreateDto.setAddCodeRelMark(false);
udiContrastService.createOnlyMainId(basicProductsCreateDto);
} catch (Exception e) {

@ -7,7 +7,6 @@ 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;
@ -50,8 +49,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
@ -269,246 +266,46 @@ public class UdiContrastService {
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);
YbDrug ybDrug;
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,"未能查询到此医保编码");
return ResultVOUtils.error(500, "未能查询到此医保编码");
// udiProductEntity.setCpmctymc(thrProductsEntity.getName());
}
if (StrUtil.isEmpty(udiProductEntity.getZczbhhzbapzbh()) || StrUtil.isEmpty(udiProductEntity.getCpmctymc())) {
if (StrUtil.isEmpty(ybDrug.getApprovalCode()) || StrUtil.isEmpty(ybDrug.getRegisteredProductName())) {
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.setSelectCodeRelMark(true);
// alihealthThirdAliDrugInsertReqeust.setManufactory(udiProductEntity.getManufactory());
alihealthThirdAliDrugInsertReqeust.setYbDrug(ybDrug);
AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust();
alihealthKytDrugrescodeReqeust.setPhysic_name(udiProductEntity.getCpmctymc());
alihealthKytDrugrescodeReqeust.setApproval_licence_no(udiProductEntity.getZczbhhzbapzbh());
alihealthKytDrugrescodeReqeust.setPhysic_name(ybDrug.getRegisteredProductName());
alihealthKytDrugrescodeReqeust.setApproval_licence_no(ybDrug.getApprovalCode());
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);
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);
thirdAliDrugList = baseResponse.getData().getList();
}
} 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);
}
// 处理药品数据
disposeDrugData(basicProductsCreateDto,thrProductsEntity,ybDrug,thirdAliDrugList,udiRelevanceEntity);
// setLevel(udiRelevanceEntity.getUuid());
UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid());
udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid);
@ -608,6 +405,154 @@ public class UdiContrastService {
}
/**
*
*
* @param thrProductsEntity
* @param ybDrug
* @param thirdAliDrugList
*/
public void disposeDrugData(BasicProductsCreateDto basicProductsCreateDto, ThrProductsEntity thrProductsEntity
, YbDrug ybDrug, List<ThirdAliDrug> thirdAliDrugList,UdiRelevanceEntity udiRelevanceEntity) {
UdiProductEntity udiProductEntity = new UdiProductEntity();
BeanUtils.copyProperties(thrProductsEntity, udiProductEntity);
// 数据处理
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 (ybDrug.getApprovalCode().contains("(")) {
// String[] charArr = ybDrug.getRegisteredProductName().split("\\(");
// ybDrug.setApprovalCode(charArr[0]);
// }
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());
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.setPackUnit(CopyUtils.copyNullStr(udiProductEntity.getPackUnit(), thirdAliDrug.getPackUnitName()));
//商品条码 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.isAddCodeRelMark()) {
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.isAddCodeRelMark()
&& CollUtil.isNotEmpty(codeRelArrayList)) {
this.codeRelUpdateBatch(codeRelArrayList);
}
} else {
udiProductService.insertUdiInfo(udiProductEntity);
}
}
/**
*
*
@ -639,6 +584,11 @@ public class UdiContrastService {
}
/**
*
*
* @param codeRel
*/
public void deleteRelCode(CodeRel codeRel) {
try {
@ -658,29 +608,30 @@ public class UdiContrastService {
}
}
public List<ThirdAliDrug> optThirdAliDrug(ThirdAliDrugRequest thirdAliDrugRequest) {
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>>>() {
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());
});
if (baseResponse.getCode() == 20000) {
thirdAliDrugList = baseResponse.getData();
} else {
log.error("国家库===查询选入数据失败===" + baseResponse.getMessage());
}
}
} catch (Exception e) {
log.error("国家库===查询选入数据失败===出现错误===" + e.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;

@ -3,8 +3,6 @@ package com.glxp.api.service.basic.impl;
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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.res.BaseResponse;
@ -12,6 +10,7 @@ import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.dao.basic.UdiProductDao;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.dto.BasicProductsCreateDto;
import com.glxp.api.entity.basic.UdiProductEntity;
import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.thrsys.CodeRel;
@ -21,7 +20,6 @@ import com.glxp.api.entity.thrsys.YbDrug;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.basic.*;
import com.glxp.api.req.thrsys.ThirdAliDrugRequest;
import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest;
import com.glxp.api.res.DiLevelResponse;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.service.auth.CustomerService;
@ -31,24 +29,18 @@ import com.glxp.api.service.basic.UdiRelevanceService;
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.CustomUtil;
import com.glxp.api.util.DimaUtil;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.PinyinUtils;
import com.glxp.api.util.alihealth.CopyUtils;
import com.glxp.api.util.udi.FilterUdiUtils;
import com.glxp.api.util.udi.UdiInfoUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jfree.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.*;
@ -680,172 +672,39 @@ public class UdiProductServiceImpl implements UdiProductService {
List<ThirdAliDrug> thirdAliDrugList = new ArrayList<>();
thirdAliDrugRequest.setNameCode(thirdAliDrugRequest.getNameCodeRow());
thirdAliDrugList = udiContrastService.optThirdAliDrug(thirdAliDrugRequest);
if (thirdAliDrugList != null && thirdAliDrugList.size() > 0) {
// 获取第三方数据
ThrProductsEntity thrProductsEntity = thrProductsService.selectByCode(thirdAliDrugRequest.getYbbm());
// 获取医保数据
YbDrugDetailFilterRequest ybHcflDetailFilterRequest = new YbDrugDetailFilterRequest();
ybHcflDetailFilterRequest.setLimit(1);
ybHcflDetailFilterRequest.setPage(1);
ybHcflDetailFilterRequest.setGoodsCode(thirdAliDrugRequest.getYbbm());
List<YbDrug> list = ybDrugService.getList(ybHcflDetailFilterRequest);
YbDrug ybDrug;
if (thrProductsEntity !=null && !CollUtil.isEmpty(list)
&& !CollUtil.isEmpty(thirdAliDrugList)) {
ybDrug = list.get(0);
// 多码融合表拼接参数
List<CodeRel> codeRelArrayList = new ArrayList<>();
// 选入就要把标识为空的数据先删除
udiProductDao.delete(new QueryWrapper<UdiProductEntity>()
.eq("uuid", thirdAliDrugRequest.getUuid())
.isNull("nameCode")
);
ThrProductsEntity thrProductsEntity = thrProductsService.selectByCode(thirdAliDrugRequest.getYbbm());
for (ThirdAliDrug thirdAliDrug : thirdAliDrugList) {
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(thirdAliDrugRequest.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(udiContrastService.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());
}
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());
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);
}
UdiRelevanceEntity udiRelevanceEntity = new UdiRelevanceEntity();
try {
udiRelevanceEntity.setDetailSort(Integer.valueOf(thirdAliDrugList.get(0).getPhysicDetailType()));
detailSort = udiRelevanceEntity.getDetailSort();
detailSort = Integer.valueOf(thirdAliDrugList.get(0).getPhysicDetailType());
} catch (Exception e) {
log.error("明细分类转换出现错误" + e.getMessage());
}
udiRelevanceService.update(udiRelevanceEntity, new QueryWrapper<UdiRelevanceEntity>()
.eq("uuid", thirdAliDrugRequest.getUuid())
);
udiContrastService.codeRelUpdateBatch(codeRelArrayList);
// 设置新增多玛融合库
BasicProductsCreateDto basicProductsCreateDto =new BasicProductsCreateDto();
basicProductsCreateDto.setAddCodeRelMark(true);
UdiRelevanceEntity udiRelevanceEntity = new UdiRelevanceEntity();
udiRelevanceEntity.setUuid(thirdAliDrugRequest.getUuid());
udiContrastService.disposeDrugData(basicProductsCreateDto,thrProductsEntity,ybDrug,thirdAliDrugList,udiRelevanceEntity);
return ResultVOUtils.success(detailSort);
}

@ -218,38 +218,13 @@ public class AlihealthUtils {
} else {
return ResultVOUtils.error("阿里健康接口调用失败===用户找不到或者key和秘钥为空");
}
String physicName = alihealthKytDrugrescodeReqeust.getPhysic_name();
if (alihealthKytDrugrescodeResponse.judgeCall()) {
List<ThirdAliDrug> listNew = alihealthKytDrugrescodeResponse.disposeThirdAliDrugList(alihealthThirdAliDrugInsertReqeust.getErpId());
return ResultVOUtils.success(listNew);
} else {
//
// // 重新上传标识为true就改变一下
// if ("未查询到相关信息".equals(alihealthKytDrugrescodeResponse.getMsg_info())
// && callBool && (physicName.contains("(") || physicName.contains(""))) {
// if (physicName.contains("(")) {
// physicName = physicName.replace("(", "").replace(")", "");
//
// } else if (physicName.contains("")) {
// physicName = physicName.replace("", "(").replace("", ")");
//
// }
// alihealthKytDrugrescodeReqeust.setPhysic_name(physicName);
// alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust);
// thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust, false);
// }
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthKytDrugrescodeResponse.getMsg_info());
}
// if(physicName.equals("(")){
// thirdAliDrugInsert();
// }
// if(physicName.equals("")){
// thirdAliDrugInsert();
// }
}
//TODO 调用阿里接口用码进行批量处理只测试了两个包装层级的 暂时没有三个包装层级的数据做测试 到时候有数据之后要好好测试一下

Loading…
Cancel
Save