feat: 选入阿里单据功能代码找回

dev_2.5_ocean
chenhc 4 months ago
parent 7ebb8bf5e0
commit e0491afe8f

@ -1,30 +1,66 @@
package com.glxp.api.controller.alihealth;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.Log;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.dao.collect.IoCollectCodeBackMapper;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.entity.collect.IoCollectCodeBackup;
import com.glxp.api.entity.thrsys.CodeRel;
import com.glxp.api.entity.thrsys.ThirdAliDrug;
import com.glxp.api.entity.thrsys.YbDrug;
import com.glxp.api.http.sync.SpGetHttpClient;
import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust;
import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.alihealth.AlihealthKytGetentinfoReqeust;
import com.glxp.api.req.alihealth.local.AlihealthGetRelCodeReqeust;
import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust;
import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust;
import com.glxp.api.req.collect.IoCollectCodeRequest;
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.alihealth.AlihealthUtils;
import com.glxp.api.util.alihealth.PaginationUtil;
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.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@RestController
public class AlihealthBusController extends BaseController {
@Resource
private IoCollectCodeBackMapper ioCollectCodeBackMapper;
@Resource
private SpGetHttpClient spGetHttpClient;
@Resource
private AlihealthUtils alihealthUtils;
@Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}")
private String alihealthUrl;
@Value("${UDI_SERVER_URL}")
private String udiUrl;
/**
*
@ -48,4 +84,243 @@ public class AlihealthBusController extends BaseController {
}
}
@PostMapping("/spms/alihealth/relCodeInsert")
@Log(title = "阿里健康自动赋码关联关系", businessType = BusinessType.OTHER)
public BaseResponse relCodeInsert(@RequestBody AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust) {
if (StringUtils.isEmpty(alihealthRelCodeInsertReqeust.getRefEntId())) {
AlihealthKytGetentinfoResponse alihealthKytGetentinfoResponse = null;
try {
AlihealthKytGetentinfoReqeust alihealthKytGetentinfoReqeust = new AlihealthKytGetentinfoReqeust();
alihealthKytGetentinfoReqeust.setApp_key(alihealthRelCodeInsertReqeust.getAppKey());
alihealthKytGetentinfoReqeust.setEnt_name(alihealthRelCodeInsertReqeust.getName());
alihealthRelCodeInsertReqeust.getAppSecret();
Map map = alihealthUtils.disposeSign(alihealthKytGetentinfoReqeust, alihealthRelCodeInsertReqeust.getAppSecret());
String json = HttpUtil.get(alihealthUrl, map);
alihealthKytGetentinfoResponse = new AlihealthKytGetentinfoResponse(json);
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error("阿里健康接口调用失败===请检查key和密文");
}
if (StringUtils.isNotEmpty(alihealthKytGetentinfoResponse.getMsg_info())
&& alihealthKytGetentinfoResponse.getMsg_info().equals("调用成功")
) {
alihealthRelCodeInsertReqeust.setRefEntId(alihealthKytGetentinfoResponse.getRef_ent_id());
} else {
return ResultVOUtils.error("阿里健康接口调用失败===" + alihealthKytGetentinfoResponse.getMsg_info());
}
}
BaseResponse baseResponse = alihealthUtils.relCodeInsert(alihealthRelCodeInsertReqeust);
if (baseResponse.getCode() == 20000) {
// 插入成功返回
return baseResponse;
} else {
log.error("调用阿里码获取关联关系接口===" + baseResponse.getMessage());
return ResultVOUtils.error("调用阿里码获取关联关系接口===" + baseResponse.getMessage());
}
}
@Resource
private UdiContrastService udiContrastService;
@PostMapping("/spms/alihealth/thirdAliDrugList")
@Log(title = "获取阿里药品码段信息列表包括查询国家库", businessType = BusinessType.OTHER)
public BaseResponse<PageSimpleResponse<ThirdAliDrug>> thirdAliDrugList(@RequestBody AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust) {
List<ThirdAliDrug> thirdAliDrugsListGjk = null;
PageSimpleResponse<ThirdAliDrug> pageSimpleResponse =new PageSimpleResponse();
// 本地查询和新增都先注释了 到时候加到这边来
YbDrug ybDrug = alihealthThirdAliDrugInsertReqeust.getYbDrug();
if(ybDrug!= null && StringUtils.isNotEmpty(ybDrug.getGoodsCode())){
// 用医保编码查询国家库药品信息
try {
CodeRel codeReNew = new CodeRel();
codeReNew.setYbbm(ybDrug.getGoodsCode());
String response = HttpUtil.post(udiUrl + "/udchs/codeRel/listAndAliDrug", JSONUtil.toJsonStr(codeReNew));
BaseResponse<List<ThirdAliDrug>> responseListAndAliDrug =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ThirdAliDrug>>>() {
});
if(responseListAndAliDrug.getCode() == 20000){
thirdAliDrugsListGjk = responseListAndAliDrug.getData();
if(thirdAliDrugsListGjk != null && thirdAliDrugsListGjk.size() >0){
pageSimpleResponse.setList(thirdAliDrugsListGjk);
return ResultVOUtils.success(pageSimpleResponse);
}
}else {
pageSimpleResponse.setList(thirdAliDrugsListGjk);
return ResultVOUtils.success(pageSimpleResponse);
}
} catch (Exception e) {
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());
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());
}
pageSimpleResponse.setList(thirdAliDrugsListGjk);
pageSimpleResponse.setTotal(Long.valueOf(udiDlDeviceResponse.getData().getTotal()));
}
} catch (Exception e) {
log.error("国家库===查询药品信息===出现错误===" + e.getMessage());
}
}
// 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());
//
// }
return ResultVOUtils.success(pageSimpleResponse);
// udiProductService.insertUdiInfo(udiProductEntity);
}
@Resource
AlihealthBusService alihealthBusService;
@Resource
IoOrderService orderService;
/**
*
*
* @param aliYljgSearchbillReqeust
* @return
*/
@PostMapping("/spms/alihealth/aliYljgSearchbillPage")
@Log(title = "获取阿里药品的采购单", businessType = BusinessType.OTHER)
public BaseResponse aliYljgSearchbillPage(@RequestBody AliYljgSearchbillReqeust aliYljgSearchbillReqeust) {
String customerId = getCustomerId();
aliYljgSearchbillReqeust.setErpId(customerId);
List<AliYljgSearchbill> list = alihealthBusService.aliYljgSearchbillPage(aliYljgSearchbillReqeust);
List<AliYljgSearchbill> listResp = new ArrayList<>();
if (CollUtil.isEmpty(list)) {
PageInfo<AliYljgSearchbill> pageInfo = new PageInfo<>(listResp);
return ResultVOUtils.page(pageInfo);
}
// 使用 groupingBy 进行分组
Map<String, List<AliYljgSearchbill>> groupedByMultipleFields = list.stream()
.collect(Collectors.groupingBy(
bill -> bill.getBillCode()
));
// 遍历分组结果
for (Map.Entry<String, List<AliYljgSearchbill>> entry : groupedByMultipleFields.entrySet()) {
List<AliYljgSearchbill> group = entry.getValue();
if (!group.isEmpty()) {
// 添加每个分组中的第一个对象到新列表
String key = entry.getKey();
//如果查得到就不可以再次选入
String billNo = orderService.selectAliYljgSearchbillByAliBillNo(key);
AliYljgSearchbill aliYljgSearchbill = group.get(0);
if (StringUtils.isNotEmpty(billNo)) {
aliYljgSearchbill.setCheckBillNO(true);
}
listResp.add(aliYljgSearchbill);
}
}
PageInfo<AliYljgSearchbill> pageInfo = new PageInfo<>(listResp);
return ResultVOUtils.page(pageInfo);
}
/**
*
*
* @param aliYljgSearchbillReqeust
* @return
*/
@PostMapping("/spms/alihealth/aliYljgBillDetail")
@Log(title = "获取阿里药品的采购单码明细", businessType = BusinessType.OTHER)
public BaseResponse aliYljgBillDetail(@RequestBody AliYljgSearchbillReqeust aliYljgSearchbillReqeust) {
AliYljgBillDetail aliYljgBillDetail = alihealthBusService.aliYljgBillDetail(aliYljgSearchbillReqeust);
return ResultVOUtils.success(aliYljgBillDetail);
}
}

@ -77,4 +77,5 @@ public interface IoOrderDao extends BaseMapperPlus<IoOrderDao, IoOrderEntity, Io
List<String> selectOrderfirstAndLastIdList(@Param("firstData") String firstData, @Param("lastData") String lastData, @Param("invCode") String invCode);
String selectAliYljgSearchbillByAliBillNo(@Param("aliOrderBillNo") String aliOrderBillNo);
}

@ -20,7 +20,15 @@ public class AlihealthThirdAliDrugInsertReqeust extends ListPageRequest {
*
*/
private boolean selectCodeRelMark;
private Boolean gjkSwitch;
private String manufactory;
private String nameCode;
/**
*
*/
private boolean drugCheckMark;
private AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust;
}

@ -2,11 +2,16 @@ package com.glxp.api.service.alihealth;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface AlihealthBusService {
List<AliYljgSearchbill> aliYljgSearchbillPage(AliYljgSearchbillReqeust aliYljgSearchbillReqeust);
AliYljgBillDetail aliYljgBillDetail(AliYljgSearchbillReqeust aliYljgSearchbillReqeust);
void ycFileUpload(String billNo, MultipartFile file);

@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.basic.CompanyProductRelevanceDao;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.entity.alihealth.YcFileCodeUploadVo;
import com.glxp.api.entity.alihealth.YcFileOrderUploadVo;
import com.glxp.api.entity.basic.CompanyProductRelevanceEntity;
@ -21,6 +22,7 @@ import com.glxp.api.entity.inout.IoOrderEntity;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.alihealth.AliYljgSearchbillReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutDetailReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutReqeust;
import com.glxp.api.req.inout.AddBizProductReqeust;
import com.glxp.api.req.inout.AddOrderRequest;
import com.glxp.api.req.inout.FilterOrderRequest;
@ -32,6 +34,7 @@ import com.glxp.api.service.inout.IoCodeLostService;
import com.glxp.api.service.inout.IoOrderDetailBizService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.StringUtils;
import com.glxp.api.util.alihealth.AlihealthYljgUtils;
import com.glxp.api.util.udi.FilterUdiUtils;
import org.springframework.beans.BeanUtils;
@ -43,6 +46,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Service
@ -55,6 +59,38 @@ public class AlihealthBusServiceImpl implements AlihealthBusService {
@Resource
CompanyProductRelevanceDao companyProductRelevanceDao;
@Override
public List<AliYljgSearchbill> aliYljgSearchbillPage(AliYljgSearchbillReqeust aliYljgSearchbillReqeust) {
if (aliYljgSearchbillReqeust == null) {
return Collections.emptyList();
}
AlihealthYljgListupoutReqeust alihealthYljgListupoutReqeust1 = new AlihealthYljgListupoutReqeust();
alihealthYljgListupoutReqeust1.setBegin_date(aliYljgSearchbillReqeust.getBeginDate());
alihealthYljgListupoutReqeust1.setEnd_date(aliYljgSearchbillReqeust.getEnsDate());
if (StringUtils.isNotEmpty(aliYljgSearchbillReqeust.getBillCode())) {
alihealthYljgListupoutReqeust1.setBill_code(aliYljgSearchbillReqeust.getBillCode());
}
if (aliYljgSearchbillReqeust.getPage() != null) {
alihealthYljgListupoutReqeust1.setPage(aliYljgSearchbillReqeust.getPage());
alihealthYljgListupoutReqeust1.setPage_size(aliYljgSearchbillReqeust.getLimit());
} else {
alihealthYljgListupoutReqeust1.setPage(1);
alihealthYljgListupoutReqeust1.setPage_size(20);
}
BaseResponse<List<AliYljgSearchbill>> listBaseResponse = alihealthYljgUtils.listupout(alihealthYljgListupoutReqeust1, aliYljgSearchbillReqeust.getErpId());
if (listBaseResponse.getCode() == 20000) {
List<AliYljgSearchbill> data = listBaseResponse.getData();
return data;
} else {
throw new JsonException(listBaseResponse.getMessage());
}
}
@Override
public AliYljgBillDetail aliYljgBillDetail(AliYljgSearchbillReqeust aliYljgSearchbillReqeust) {
AlihealthYljgListupoutDetailReqeust alihealthYljgListupoutDetailReqeust = new AlihealthYljgListupoutDetailReqeust();

@ -154,4 +154,6 @@ public interface IoOrderService {
IoOrderResponse findByWorkPlaceCode(String workPlaceCode,String getWorkPlaceQueueCode,Long UserId);
String selectAliYljgSearchbillByAliBillNo(String key);
}

@ -1173,4 +1173,10 @@ public class IoOrderServiceImpl implements IoOrderService {
return true;
}
@Override
public String selectAliYljgSearchbillByAliBillNo(String key) {
return orderDao.selectAliYljgSearchbillByAliBillNo(key);
}
}

@ -631,4 +631,13 @@
</otherwise>
</choose>
</select>
<select id="selectAliYljgSearchbillByAliBillNo" resultType="java.lang.String">
select aliOrderBillNo
from io_order
where aliOrderBillNo = #{aliOrderBillNo}
limit 1
</select>
</mapper>

Loading…
Cancel
Save