|  |  | @ -1,14 +1,25 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | package com.glxp.api.service.basic; |  |  |  | package com.glxp.api.service.basic; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.http.HttpUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.json.JSONArray; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.json.JSONObject; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import cn.hutool.json.JSONUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.alibaba.fastjson.TypeReference; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.util.ResultVOUtils; |  |  |  | import com.glxp.api.common.util.ResultVOUtils; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.entity.thrsys.*; |  |  |  | import com.glxp.api.entity.thrsys.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.exception.JsonException; |  |  |  | import com.glxp.api.exception.JsonException; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.http.sync.SpGetHttpClient; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.basic.YbDrugDetailFilterRequest; |  |  |  | import com.glxp.api.req.basic.YbDrugDetailFilterRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest; |  |  |  | import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.thrsys.ThrInsMaterialFeeRequest; |  |  |  | import com.glxp.api.req.thrsys.ThrInsMaterialFeeRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.res.PageSimpleResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.service.thrsys.*; |  |  |  | import com.glxp.api.service.thrsys.*; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.DimaUtil; |  |  |  | import com.glxp.api.util.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.IntUtil; |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import org.apache.xmlbeans.impl.xb.xsdschema.Public; |  |  |  | import org.apache.xmlbeans.impl.xb.xsdschema.Public; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.aspectj.weaver.ast.Var; |  |  |  | import org.aspectj.weaver.ast.Var; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.jfree.util.Log; |  |  |  | import org.jfree.util.Log; | 
			
		
	
	
		
		
			
				
					|  |  | @ -26,23 +37,19 @@ import com.glxp.api.req.basic.UdiCombineRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; |  |  |  | import com.glxp.api.req.basic.FilterUdiRelRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.thrsys.FilterThrProductsRequest; |  |  |  | import com.glxp.api.req.thrsys.FilterThrProductsRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; |  |  |  | import com.glxp.api.res.basic.UdiRelevanceResponse; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.CustomUtil; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.GennerOrderUtils; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.util.udi.UdiInfoUtil; |  |  |  | import com.glxp.api.util.udi.UdiInfoUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Service; |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import javax.annotation.Resource; |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.ArrayList; |  |  |  | import java.util.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Collections; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.Date; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import java.util.List; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import java.util.stream.Collectors; |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /** |  |  |  | /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  * 耗材字典对照 |  |  |  |  * 耗材字典对照 | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | @Service |  |  |  | @Service | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | @Slf4j | 
			
		
	
		
		
			
				
					
					|  |  |  | public class UdiContrastService { |  |  |  | public class UdiContrastService { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Resource |  |  |  |     @Resource | 
			
		
	
	
		
		
			
				
					|  |  | @ -65,6 +72,8 @@ public class UdiContrastService { | 
			
		
	
		
		
			
				
					
					|  |  |  |     BasicInsMaterialService basicInsMaterialService; |  |  |  |     BasicInsMaterialService basicInsMaterialService; | 
			
		
	
		
		
			
				
					
					|  |  |  |     @Resource |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |     YbDrugService ybDrugService; |  |  |  |     YbDrugService ybDrugService; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     private SpGetHttpClient spGetHttpClient; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public boolean isExit(String originUuid, String mainId, String thirdSys) { |  |  |  |     public boolean isExit(String originUuid, String mainId, String thirdSys) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -275,15 +284,24 @@ public class UdiContrastService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (thrProductsEntity.getYbbm() != null) { |  |  |  |         if (thrProductsEntity.getYbbm() != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             //判断药品还是器械
 |  |  |  |             //判断药品还是器械
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (thrProductsEntity.getProductType() == 2) { |  |  |  |             if (thrProductsEntity.getProductType() == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 String error=null; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ThrInsDrugFeeRequest thrInsDrugFeeRequest = new ThrInsDrugFeeRequest(); |  |  |  |                 ThrInsDrugFeeRequest thrInsDrugFeeRequest = new ThrInsDrugFeeRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 thrInsDrugFeeRequest.setMedCatalogCode(thrProductsEntity.getYbbm()); |  |  |  |                 thrInsDrugFeeRequest.setMedCatalogCode(thrProductsEntity.getYbbm()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 YbDrugDetailFilterRequest ybHcflDetailFilterRequest = new YbDrugDetailFilterRequest(); |  |  |  |                 YbDrugDetailFilterRequest ybHcflDetailFilterRequest = new YbDrugDetailFilterRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ybHcflDetailFilterRequest.setLimit(1); |  |  |  |                 ybHcflDetailFilterRequest.setLimit(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ybHcflDetailFilterRequest.setPage(1); |  |  |  |                 ybHcflDetailFilterRequest.setPage(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ybHcflDetailFilterRequest.setGoodsCode(thrProductsEntity.getYbbm()); |  |  |  |                 ybHcflDetailFilterRequest.setGoodsCode(thrProductsEntity.getYbbm()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 List<YbDrug> list = ybDrugService.getList(ybHcflDetailFilterRequest); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 UdiProductEntity udiProductEntity = new UdiProductEntity(); |  |  |  |                 UdiProductEntity udiProductEntity = new UdiProductEntity(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); |  |  |  |                 BeanUtils.copyProperties(thrProductsEntity, udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 YbDrug ybDrug=new YbDrug(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 // 数据处理
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 udiProductEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    udiProductEntity.setNameCode(thrProductsEntity.getCode());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); |  |  |  |                 udiProductEntity.setUuid(udiRelevanceEntity.getUuid()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setDiType(1); |  |  |  |                 udiProductEntity.setDiType(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setScbssfbhph("是"); |  |  |  |                 udiProductEntity.setScbssfbhph("是"); | 
			
		
	
	
		
		
			
				
					|  |  | @ -294,21 +312,22 @@ public class UdiContrastService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setRequireScanCode(1); |  |  |  |                 udiProductEntity.setRequireScanCode(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setMajorStatus(1); |  |  |  |                 udiProductEntity.setMajorStatus(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setPhysicType(3); |  |  |  |                 udiProductEntity.setPhysicType(3); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setCpmctymc(thrProductsEntity.getName()); |  |  |  |                 //设置包装级别
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setBzgg(thrProductsEntity.getSpec() + "/" + thrProductsEntity.getMeasname()); |  |  |  |                 udiProductEntity.setPackLevel(1 + ""); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setMeasname(thrProductsEntity.getMeasname()); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setNameCode(thrProductsEntity.getCode()); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 if (StrUtil.isEmpty(udiProductEntity.getPrice())) { |  |  |  |                 if (StrUtil.isEmpty(udiProductEntity.getPrice())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setPrice("0.00"); |  |  |  |                     udiProductEntity.setPrice("0.00"); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity.setUpdateTime(new Date()); |  |  |  |                 udiProductEntity.setUpdateTime(new Date()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); |  |  |  |                 udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 List<YbDrug> list = ybDrugService.getList(ybHcflDetailFilterRequest); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (list != null && list.size() > 0) { |  |  |  |                 if (list != null && list.size() > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     YbDrug ybDrug = list.get(0); |  |  |  |                     ybDrug = list.get(0); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setId(IdUtil.getSnowflakeNextId()); |  |  |  |                     // 数据做处理好查询阿里接口
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if(ybDrug.getApprovalCode().contains("(")){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         String[] charArr  = ybDrug.getRegisteredProductName().split("\\("); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         ybDrug.setApprovalCode(charArr[0]); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //                    udiProductEntity.setNameCode(thrProductsEntity.getCode());
 |  |  |  | //                    udiProductEntity.setNameCode(thrProductsEntity.getCode());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setPrepnSpec(ybDrug.getRealityOutlook()); |  |  |  |                     udiProductEntity.setPrepnSpec(ybDrug.getRealityOutlook()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setZczbhhzbapzbh(ybDrug.getApprovalCode()); |  |  |  |                     udiProductEntity.setZczbhhzbapzbh(ybDrug.getApprovalCode()); | 
			
		
	
	
		
		
			
				
					|  |  | @ -323,54 +342,131 @@ public class UdiContrastService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setPackUnit(ybDrug.getUnit()); |  |  |  |                     udiProductEntity.setPackUnit(ybDrug.getUnit()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //设置最小产品数量
 |  |  |  |                     //设置最小产品数量
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setBhxjsl(ybDrug.getFactor()); |  |  |  |                     udiProductEntity.setBhxjsl(ybDrug.getFactor()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //设置包装级别
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setPackLevel(1 + ""); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                     //生产厂家
 |  |  |  |                     //生产厂家
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setManufactory(ybDrug.getCompanyNameSc()); |  |  |  |                     udiProductEntity.setManufactory(ybDrug.getCompanyNameSc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //商品条码 essentialDrugMarkName sptm
 |  |  |  |                     //商品条码 essentialDrugMarkName sptm
 | 
			
		
	
		
		
			
				
					
					|  |  |  | //                    udiProductEntity.setSptm(ybDrug.getBusinessLicense());
 |  |  |  | //                    udiProductEntity.setSptm(ybDrug.getBusinessLicense());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel()); |  |  |  |                     udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel()); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     List<ThirdAliDrug> thirdAliDrugList = thirdAliDrugService.findByByApproved(ybDrug.getApprovalCode()); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     if (CollUtil.isNotEmpty(thirdAliDrugList)) { |  |  |  |                 } else { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         for (int i = 0; i < thirdAliDrugList.size(); i++) { |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             List<Integer> integers = new ArrayList<>(); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if (StrUtil.isNotEmpty(thirdAliDrug.getPackRatio())) { |  |  |  |                 } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 integers = DimaUtil.calculateLevels(thirdAliDrug.getPackRatio()); |  |  |  |                 List<ThirdAliDrug> thirdAliDrugList = thirdAliDrugService.list( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  |                         new QueryWrapper<ThirdAliDrug>() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             udiProductEntity.setPackLevel(thirdAliDrug.getPackLevel()); |  |  |  |                                 .eq(StringUtils.isNotEmpty(udiProductEntity.getCpmctymc()), "cpmctymc", udiProductEntity.getCpmctymc()) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             try { |  |  |  |                                 .eq(StringUtils.isNotEmpty(udiProductEntity.getZczbhhzbapzbh()), "approvalNum", udiProductEntity.getZczbhhzbapzbh()) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 udiProductEntity.setBhxjsl(integers.get(IntUtil.value(thirdAliDrug.getPackLevel()) - 1)); |  |  |  |                 ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } catch (IndexOutOfBoundsException e) { |  |  |  |                 if (CollUtil.isNotEmpty(thirdAliDrugList)) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 e.printStackTrace(); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 Log.error("计算包装级别出错" + thirdAliDrug.getPackLevel() + "---" + integers + "-----" + thirdAliDrug.toString()); |  |  |  |                 } else { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  |                     AlihealthThirdAliDrugInsertReqeust alihealthThirdAliDrugInsertReqeust = new AlihealthThirdAliDrugInsertReqeust(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                     alihealthThirdAliDrugInsertReqeust.setErpId("73157692795424"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); |  |  |  |                     alihealthThirdAliDrugInsertReqeust.setAppSecret("5231c601505706a9d49823c3dfe2cb01"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if (IntUtil.value(thirdAliDrug.getPackLevel()) == 1) { |  |  |  |                     AlihealthKytDrugrescodeReqeust alihealthKytDrugrescodeReqeust = new AlihealthKytDrugrescodeReqeust(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 udiProductEntity.setXjdw(ybDrug.getMinUnit()); |  |  |  |                     alihealthKytDrugrescodeReqeust.setPhysic_name(udiProductEntity.getCpmctymc()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 if (DimaUtil.trMinCount(thirdAliDrug.getBzgg()) != null) { |  |  |  |                     alihealthKytDrugrescodeReqeust.setApproval_licence_no(udiProductEntity.getZczbhhzbapzbh()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     udiProductEntity.setBhxjsl(DimaUtil.trMinCount(thirdAliDrug.getBzgg())); |  |  |  |                     alihealthKytDrugrescodeReqeust.setPage_size(100); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } else |  |  |  |                     alihealthKytDrugrescodeReqeust.setPage(1); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     udiProductEntity.setBhxjsl(ybDrug.getFactor()); |  |  |  |                     alihealthKytDrugrescodeReqeust.setApp_key("31721223"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  |                     alihealthKytDrugrescodeReqeust.setRef_ent_id("ef99b78bd9c54c1284f813149c858fb0"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if (thirdAliDrug.getPackLevel() != null) { |  |  |  |                     alihealthThirdAliDrugInsertReqeust.setAlihealthKytDrugrescodeReqeust(alihealthKytDrugrescodeReqeust); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4); |  |  |  |                     BaseResponse baseResponse = spGetHttpClient.thirdAliDrugList(alihealthThirdAliDrugInsertReqeust); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  |                     if (baseResponse.getCode() == 20000) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             udiProductEntity.setId(IdUtil.getSnowflakeNextId()); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         try { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             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()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         }catch (Exception e){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             log.info("供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                            udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                            error = "供应商平台获取阿里和国家库码段信息出现错误===" + e.getMessage();
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                             udiProductService.insertUdiInfo(udiProductEntity); |  |  |  |                             udiProductService.insertUdiInfo(udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } else { |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         log.info("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                        udiProductEntity.setBasicPrductRemak8("供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                        error = "供应商平台获取阿里和国家库码段信息出现错误===" + baseResponse.getMessage();
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                         udiProductService.insertUdiInfo(udiProductEntity); |  |  |  |                         udiProductService.insertUdiInfo(udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } else { |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     udiProductService.insertUdiInfo(udiProductEntity); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 for (int i = 0; i < thirdAliDrugList.size(); i++) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         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); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setNameCode(thirdAliDrug.getNameCode()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         // 数据处理
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setPrepnSpec(thirdAliDrug.getFormSpec()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setZczbhhzbapzbh(thirdAliDrug.getApprovalNum()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setCpmctymc(thirdAliDrug.getCpmctymc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setSpmc(thirdAliDrug.getSpmc()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setBzgg(thirdAliDrug.getBzgg()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                        udiProductEntity.setMatrial(ybDrug.getMaterialName());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                        udiProductEntity.setPackMatrial(ybDrug.getMaterialName());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                        udiProductEntity.setMedicareType(setMedicareType(ybDrug.getProductInsuranceType()));
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //最小产品单位
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //设置最小产品数量
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                        udiProductEntity.setBhxjsl(ybDrug.getFactor());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //设置包装级别
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setPackLevel(1 + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //生产厂家
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setManufactory(thirdAliDrug.getManufacturer()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //商品条码 essentialDrugMarkName sptm
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                    udiProductEntity.setSptm(ybDrug.getBusinessLicense());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setPrepnUnit(thirdAliDrug.getPrepnUnitName()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         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()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (thirdAliDrug.getPackLevel() != null && !thirdAliDrug.getPackLevel().equals("0")) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             udiProductEntity.setDiType(1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setXjdw(thirdAliDrug.getPrepnUnitName()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setPackUnit(thirdAliDrug.getPackUnitName()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductEntity.setId(IdUtil.getSnowflakeNextId()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         udiProductService.insertUdiInfo(udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  | //                setLevel(udiRelevanceEntity.getUuid());
 |  |  |  | //                setLevel(udiRelevanceEntity.getUuid());
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid()); |  |  |  |                 UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid); |  |  |  |                 udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //                udiRelevanceEntity.setThirdId4(error);
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 udiRelevanceEntity.setProductsType(thrProductsEntity.getProductType()); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); |  |  |  |                 udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductService.updateLevelCount(udiRelevanceEntity); |  |  |  |                 udiProductService.updateLevelCount(udiRelevanceEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else { |  |  |  |             } else { | 
			
		
	
	
		
		
			
				
					|  |  | @ -410,6 +506,7 @@ public class UdiContrastService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); |  |  |  |                 udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiProductService.insertUdiInfo(udiProductEntity); |  |  |  |                 udiProductService.insertUdiInfo(udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); |  |  |  |                 udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, udiProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); |  |  |  |                 udiRelevanceService.insertUdiRelevance(udiRelevanceEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |         } else { | 
			
		
	
	
		
		
			
				
					|  |  | 
 |