1、封装阿里健康入参和返回 设计成通用方式后面再加个新接口比较方便
2、供应商增加码上放心企业信息增加阿里健康需要的信息 3、提供一个方法新增这个供应商的code阿里健康关联的所有关联关系存储dev_unify
							parent
							
								
									6188451289
								
							
						
					
					
						commit
						634775a6c8
					
				| @ -0,0 +1,20 @@ | ||||
| package com.glxp.api.controller.test; | ||||
| 
 | ||||
| import com.glxp.api.common.res.BaseResponse; | ||||
| import com.glxp.api.util.alihealth.AlihealthUtils; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| 
 | ||||
| @RestController | ||||
| public class TestCodeController { | ||||
| 
 | ||||
|     @Resource | ||||
|     private AlihealthUtils alihealthUtils; | ||||
| 
 | ||||
|     @PostMapping("/test") | ||||
|     public BaseResponse test() { | ||||
|         return alihealthUtils.relCodeInsert("73157692795424", "88979920013901715365"); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,57 @@ | ||||
| package com.glxp.api.req.alihealth; | ||||
| 
 | ||||
| import lombok.Data; | ||||
| 
 | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * 基础参数 | ||||
|  */ | ||||
| @Data | ||||
| public class AlihealthKytCommonParametersReqeust { | ||||
|     /** | ||||
|      * API接口名称 | ||||
|      */ | ||||
|     private String method; | ||||
|     /** | ||||
|      * key | ||||
|      */ | ||||
|     private String app_key; | ||||
|     /** | ||||
|      * 授权 | ||||
|      */ | ||||
|     private String session; | ||||
|     /** | ||||
|      * 时间 | ||||
|      */ | ||||
|     private String timestamp; | ||||
|     /** | ||||
|      * 版本号 | ||||
|      */ | ||||
|     private String v; | ||||
|     /** | ||||
|      * 签名的摘要算法 | ||||
|      */ | ||||
|     private String sign_method; | ||||
|     /** | ||||
|      * 签名的摘要算法 | ||||
|      */ | ||||
|     private String sign; | ||||
|     /** | ||||
|      * 响应格式 | ||||
|      */ | ||||
|     private String format; | ||||
| //    /**
 | ||||
| //     * 精简开关
 | ||||
| //     */
 | ||||
| //    private boolean simplify;
 | ||||
|     public AlihealthKytCommonParametersReqeust(){ | ||||
|         this.timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||||
|         this.v = "2.0"; | ||||
|         this.sign_method = "md5"; | ||||
|         this.format = "json"; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,11 @@ | ||||
| package com.glxp.api.req.alihealth; | ||||
| 
 | ||||
| import lombok.Data; | ||||
| 
 | ||||
| @Data | ||||
| public class AlihealthKytGetentinfoReqeust extends AlihealthKytCommonParametersReqeust { | ||||
|     private String ent_name; | ||||
|     public AlihealthKytGetentinfoReqeust(){ | ||||
|         this.setMethod("alibaba.alihealth.drug.kyt.getentinfo"); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.glxp.api.req.alihealth; | ||||
| 
 | ||||
| import lombok.Data; | ||||
| 
 | ||||
| @Data | ||||
| public class AlihealthKytSinglerelationReqeust extends AlihealthKytCommonParametersReqeust { | ||||
|     private String ref_ent_id; | ||||
|     private String des_ref_ent_id; | ||||
|     private String code; | ||||
|     public AlihealthKytSinglerelationReqeust(){ | ||||
|         this.setMethod("alibaba.alihealth.drug.kyt.singlerelation"); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,19 @@ | ||||
| package com.glxp.api.res.alihealth; | ||||
| 
 | ||||
| import cn.hutool.json.JSONObject; | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import lombok.Data; | ||||
| import org.apache.poi.ss.formula.functions.T; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| @Data | ||||
| public class AlihealthKytCommonParametersResponse { | ||||
| 
 | ||||
|     private String msg_code; | ||||
|     private String msg_info; | ||||
|     private String response_success; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,47 @@ | ||||
| package com.glxp.api.res.alihealth; | ||||
| 
 | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.json.JSONArray; | ||||
| import cn.hutool.json.JSONObject; | ||||
| import cn.hutool.json.JSONUtil; | ||||
| import lombok.Data; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| 
 | ||||
| import java.util.Objects; | ||||
| @Data | ||||
| public class AlihealthKytGetentinfoResponse extends AlihealthKytCommonParametersResponse{ | ||||
|     private String ent_id; | ||||
|     private String network_type; | ||||
|     private String ref_ent_id; | ||||
| 
 | ||||
| 
 | ||||
|     public AlihealthKytGetentinfoResponse(String json) { | ||||
|         // 初始化请求的值
 | ||||
|         cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(json); | ||||
|         JSONObject jsonObjectResult = null; | ||||
|         for (String s : jsonObject.keySet()) { | ||||
|             jsonObjectResult = jsonObject.getJSONObject(s).getJSONObject("result"); | ||||
| 
 | ||||
|         } | ||||
|         AlihealthKytCommonParametersResponse alihealthKytCommonParametersResponse = JSONUtil.toBean(jsonObjectResult.toString(), | ||||
|                 AlihealthKytCommonParametersResponse.class); | ||||
|         BeanUtils.copyProperties(alihealthKytCommonParametersResponse,this); | ||||
|         if(StringUtils.isNotEmpty(this.getMsg_info()) | ||||
|             && this.getMsg_info().equals("调用成功") | ||||
|         ){ | ||||
|             this.disposeResult(jsonObjectResult); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public void disposeResult(JSONObject jsonObjectResult){ | ||||
|         JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); | ||||
|         if (!Objects.isNull(jsonObjectModel)) { | ||||
|             this.setEnt_id(jsonObjectModel.getStr("ent_id")); | ||||
|             this.setNetwork_type(jsonObjectModel.getStr("network_type")); | ||||
|             this.setRef_ent_id(jsonObjectModel.getStr("ref_ent_id")); | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,148 @@ | ||||
| package com.glxp.api.res.alihealth; | ||||
| 
 | ||||
| import cn.hutool.Hutool; | ||||
| import cn.hutool.http.HttpUtil; | ||||
| import cn.hutool.json.JSONArray; | ||||
| import cn.hutool.json.JSONObject; | ||||
| import cn.hutool.json.JSONUtil; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.glxp.api.entity.collect.RelCodeBatch; | ||||
| import com.glxp.api.entity.collect.RelCodeDetail; | ||||
| import com.taobao.api.TaobaoObject; | ||||
| import com.taobao.api.internal.mapping.ApiField; | ||||
| import com.taobao.api.internal.mapping.ApiListField; | ||||
| import com.taobao.api.response.AlibabaAlihealthDrugtraceTopLsydQueryRelationResponse; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.poi.ss.formula.functions.T; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| import java.util.*; | ||||
| 
 | ||||
| @Data | ||||
| public class AlihealthKytSinglerelationResponse extends AlihealthKytCommonParametersResponse{ | ||||
|     private JSONObject base_infos_d_t_o; | ||||
|     private String code; | ||||
|     private JSONObject code_active_info_d_t_o; | ||||
|     private JSONObject code_relation_list; | ||||
|     private String is_smallest; | ||||
|     private JSONObject pkg_info_d_t_o; | ||||
|     private JSONObject produce_info_list; | ||||
| 
 | ||||
|     public AlihealthKytSinglerelationResponse(String json) { | ||||
|         // 初始化请求的值
 | ||||
|         cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(json); | ||||
|         JSONObject jsonObjectResult = null; | ||||
|         for (String s : jsonObject.keySet()) { | ||||
|             jsonObjectResult = jsonObject.getJSONObject(s).getJSONObject("result"); | ||||
| 
 | ||||
|         } | ||||
|         AlihealthKytCommonParametersResponse alihealthKytCommonParametersResponse = JSONUtil.toBean(jsonObjectResult.toString(), | ||||
|                 AlihealthKytCommonParametersResponse.class); | ||||
|         BeanUtils.copyProperties(alihealthKytCommonParametersResponse,this); | ||||
|         if(StringUtils.isNotEmpty(this.getMsg_info()) | ||||
|                 && this.getMsg_info().equals("调用成功") | ||||
|         ){ | ||||
|             this.disposeResult(jsonObjectResult); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
|     public void disposeResult(JSONObject jsonObjectResult){ | ||||
|         JSONArray jsonArray = jsonObjectResult.getJSONObject("model_list").getJSONArray("code_relation_dto"); | ||||
|         JSONObject codeRelationDto = (JSONObject) jsonArray.get(0); | ||||
|         if (!Objects.isNull(codeRelationDto)) { | ||||
|             this.setBase_infos_d_t_o(codeRelationDto.getJSONObject("base_infos_d_t_o")); | ||||
|             this.setCode(codeRelationDto.getStr("code")); | ||||
|             this.setCode_active_info_d_t_o(codeRelationDto.getJSONObject("code_active_info_d_t_o")); | ||||
|             this.setCode_relation_list(codeRelationDto.getJSONObject("code_relation_list")); | ||||
|             this.setIs_smallest(codeRelationDto.getStr("is_smallest")); | ||||
|             this.setPkg_info_d_t_o(codeRelationDto.getJSONObject("pkg_info_d_t_o")); | ||||
|             this.setProduce_info_list(codeRelationDto.getJSONObject("produce_info_list")); | ||||
|         } | ||||
|     } | ||||
|     public RelCodeBatch disposeRelCodeBatch(String customerId){ | ||||
|         JSONArray jsonArrayBaseInfoDto  = this.getBase_infos_d_t_o().getJSONObject("base_info_list").getJSONArray("base_info_dto"); | ||||
|         JSONObject jsonObject = (JSONObject) jsonArrayBaseInfoDto.get(0); | ||||
|         RelCodeBatch relCodeBatch = new RelCodeBatch(); | ||||
|         List<Map<String, String>> jsonArray = (List) this.getCode_relation_list().get("code_info"); | ||||
|         Integer oneLevelCount = 0; | ||||
|         Integer twoLevelCount = 0; | ||||
|         Integer threeLevelCount = 0; | ||||
|         String parentCode  = null; | ||||
|         if (jsonArray != null && jsonArray.size() > 0) { | ||||
|             parentCode = jsonArray.get(0).get("parent_code"); | ||||
|             relCodeBatch.setCurCode(parentCode); | ||||
| 
 | ||||
|             for (Map<String, String> map : jsonArray) { | ||||
|                 switch (map.get("code_level")) { | ||||
|                     case "1": | ||||
|                         oneLevelCount++; | ||||
|                         break; | ||||
|                     case "2": | ||||
|                         twoLevelCount++; | ||||
|                         break; | ||||
|                     case "3": | ||||
|                         threeLevelCount++; | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| //        relCodeBatch.setId();
 | ||||
|         relCodeBatch.setProductCode(parentCode); | ||||
|         relCodeBatch.setSubTypeNo(jsonObject.getStr("relation_type")); | ||||
|         relCodeBatch.setCascadeRatio(jsonObject.getStr("pkg_ratio")); | ||||
|         relCodeBatch.setPackageSpec(jsonObject.getStr("pkg_spec")); | ||||
| //        relCodeBatch.setComment();
 | ||||
|         relCodeBatch.setBatchNo(jsonObject.getStr("produce_batch_no")); | ||||
|         relCodeBatch.setMadeDate(jsonObject.getStr("produce_date")); | ||||
|         relCodeBatch.setValidateDate(jsonObject.getStr("exprie_date")); | ||||
|         relCodeBatch.setWorkShop(jsonObject.getStr("exprie_date")); | ||||
| //        relCodeBatch.setLineName();
 | ||||
|         relCodeBatch.setLineManager(jsonObject.getStr("oper_ic_name")); | ||||
| //        relCodeBatch.setCreateTime();
 | ||||
| //        relCodeBatch.setCreateUser();
 | ||||
|         relCodeBatch.setUpdateTime(new Date()); | ||||
|         relCodeBatch.setUpdateUser(customerId); | ||||
|         relCodeBatch.setUploadFlagUp(1); | ||||
|         relCodeBatch.setUploadFlagDown(1); | ||||
|         relCodeBatch.setParentCode(null); | ||||
| //        relCodeBatch.setErpId();
 | ||||
| 
 | ||||
|         relCodeBatch.setOneLevelCount(oneLevelCount); | ||||
|         relCodeBatch.setTwoLevelCount(twoLevelCount); | ||||
|         relCodeBatch.setThreeLevelCount(threeLevelCount); | ||||
| 
 | ||||
|         return relCodeBatch; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public List<RelCodeDetail> disposeRelRodeDetailList(Integer batchIdFk) { | ||||
|         List<RelCodeDetail> list = new ArrayList<>(); | ||||
|         List<Map<String, String>> jsonArray = (List) this.getCode_relation_list().get("code_info"); | ||||
|         if (jsonArray != null && jsonArray.size() > 0) { | ||||
|             for (Map<String, String> map : jsonArray) { | ||||
|                 if (!Objects.isNull(map)) { | ||||
|                     RelCodeDetail relCodeDetail = new RelCodeDetail(); | ||||
|                     relCodeDetail.setCurCode(map.get("code")); | ||||
|                     relCodeDetail.setPackLayer(Integer.valueOf(map.get("code_level"))); | ||||
|                     relCodeDetail.setParentCode(map.get("parent_code")); | ||||
|                     Integer flag = null; | ||||
|                     switch (map.get("status")) { | ||||
|                         case "I": | ||||
|                             flag = 1; | ||||
|                             break; | ||||
|                         case "O": | ||||
|                             flag = 0; | ||||
|                             break; | ||||
|                     } | ||||
|                     relCodeDetail.setFlag(flag); | ||||
|                     relCodeDetail.setBatchIdFk(batchIdFk); | ||||
|                     list.add(relCodeDetail); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return list; | ||||
|     } | ||||
| } | ||||
											
												Binary file not shown.
											
										
									
								
					Loading…
					
					
				
		Reference in New Issue