|  |  |  | @ -1,5 +1,6 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.glxp.api.controller.alihealth; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.bean.BeanUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.core.collection.CollUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.http.HttpUtil; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.hutool.json.JSONUtil; | 
			
		
	
	
		
			
				
					|  |  |  | @ -11,23 +12,12 @@ 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.entity.alihealth.AliYljgBillDetail; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.alihealth.AliYljgSearchbill; | 
			
		
	
		
			
				
					|  |  |  |  | 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.req.alihealth.AliYljgSearchbillReqeust; | 
			
		
	
		
			
				
					|  |  |  |  | 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.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 com.glxp.api.dao.collect.IoCollectCodeBackMapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.entity.collect.IoCollectCodeBackup; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.http.sync.SpGetHttpClient; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.alihealth.local.AlihealthGetRelCodeReqeust; | 
			
		
	
		
			
				
					|  |  |  |  | import com.glxp.api.req.collect.IoCollectCodeRequest; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.factory.annotation.Value; | 
			
		
	
	
		
			
				
					|  |  |  | @ -37,7 +27,6 @@ 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; | 
			
		
	
	
		
			
				
					|  |  |  | @ -46,250 +35,30 @@ import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | @RestController | 
			
		
	
		
			
				
					|  |  |  |  | public class AlihealthBusController extends BaseController { | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     private AlihealthUtils alihealthUtils; | 
			
		
	
		
			
				
					|  |  |  |  |     @Value("${ALIHEALTH_URL:http://gw.api.taobao.com/router/rest}") | 
			
		
	
		
			
				
					|  |  |  |  |     private String alihealthUrl; | 
			
		
	
		
			
				
					|  |  |  |  |     @Value("${UDI_SERVER_URL}") | 
			
		
	
		
			
				
					|  |  |  |  |     private String udiUrl; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @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; | 
			
		
	
		
			
				
					|  |  |  |  |     private IoCollectCodeBackMapper ioCollectCodeBackMapper; | 
			
		
	
		
			
				
					|  |  |  |  |     @Resource | 
			
		
	
		
			
				
					|  |  |  |  |     IoOrderService orderService; | 
			
		
	
		
			
				
					|  |  |  |  |     private SpGetHttpClient spGetHttpClient; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 阿里的采购单查询接口 | 
			
		
	
		
			
				
					|  |  |  |  |      * 阿里手动拉取完成单大级码没有关联关系的接口 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @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<>(); | 
			
		
	
		
			
				
					|  |  |  |  |     @PostMapping("/spms/alihealth/getAliCode") | 
			
		
	
		
			
				
					|  |  |  |  |     @Log(title = "获取阿里药品的采购单码明细", businessType = BusinessType.OTHER) | 
			
		
	
		
			
				
					|  |  |  |  |     public BaseResponse getAliCode() { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollUtil.isEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |  |             PageInfo<AliYljgSearchbill> pageInfo = new PageInfo<>(listResp); | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.page(pageInfo); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         List<IoCollectCodeBackup>  list = ioCollectCodeBackMapper.filterNotRelCode(new IoCollectCodeRequest()); | 
			
		
	
		
			
				
					|  |  |  |  |         if(list!=null && list.size() >1){ | 
			
		
	
		
			
				
					|  |  |  |  |             AlihealthGetRelCodeReqeust alihealthGetRelCodeReqeust = new AlihealthGetRelCodeReqeust(); | 
			
		
	
		
			
				
					|  |  |  |  |             alihealthGetRelCodeReqeust.setIoCollectCodeBackupList(list); | 
			
		
	
		
			
				
					|  |  |  |  |             BaseResponse baseResponse = spGetHttpClient.getAliCode(alihealthGetRelCodeReqeust); | 
			
		
	
		
			
				
					|  |  |  |  |             return baseResponse; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 使用 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); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         }else { | 
			
		
	
		
			
				
					|  |  |  |  |             return ResultVOUtils.success("没有需要调用关联关系的码列表"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         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); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |