You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
5.6 KiB
Java
112 lines
5.6 KiB
Java
4 months ago
|
package com.glxp.api.res.alihealth;
|
||
|
|
||
|
import java.util.Date;
|
||
|
|
||
|
import cn.hutool.json.JSONArray;
|
||
|
import cn.hutool.json.JSONObject;
|
||
|
import cn.hutool.json.JSONUtil;
|
||
|
import com.glxp.api.entity.collect.RelCodeDetail;
|
||
|
import com.glxp.api.entity.thrsys.ThirdAliDrug;
|
||
|
import lombok.Data;
|
||
|
import org.apache.commons.lang3.StringUtils;
|
||
|
import org.springframework.beans.BeanUtils;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.Objects;
|
||
|
|
||
|
@Data
|
||
|
public class AlihealthKytDrugrescodeResponse extends AlihealthKytCommonParametersResponse {
|
||
|
private Integer total_num;
|
||
|
private JSONArray drug_table_dto;
|
||
|
private Integer page;
|
||
|
private Integer page_size;
|
||
|
|
||
|
public AlihealthKytDrugrescodeResponse(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.setTotal_num(jsonObjectModel.getInt("total_num"));
|
||
|
this.setDrug_table_dto(jsonObjectModel.getJSONObject("result_list").getJSONArray("drug_table_dto"));
|
||
|
this.setPage(jsonObjectModel.getInt("page"));
|
||
|
this.setPage_size(jsonObjectModel.getInt("page_size"));
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public List<ThirdAliDrug> disposeThirdAliDrugList(String erpId) {
|
||
|
List<ThirdAliDrug> list = new ArrayList<>();
|
||
|
List<JSONObject> jsonArray = (List) this.getDrug_table_dto();
|
||
|
if (jsonArray != null && jsonArray.size() > 0) {
|
||
|
for (JSONObject jsonObject : jsonArray) {
|
||
|
if (!Objects.isNull(jsonObject)) {
|
||
|
ThirdAliDrug thirdAliDrugShare = new ThirdAliDrug();
|
||
|
// thirdAliDrug.setId();
|
||
|
thirdAliDrugShare.setType(jsonObject.getStr("physic_type"));
|
||
|
thirdAliDrugShare.setManufacturer(jsonObject.getStr("ent_name"));
|
||
|
thirdAliDrugShare.setCpmctymc(jsonObject.getStr("physic_name"));
|
||
|
thirdAliDrugShare.setForm(jsonObject.getStr("prepn_type_desc"));
|
||
|
thirdAliDrugShare.setSpmc(jsonObject.getStr("prod_name"));
|
||
|
thirdAliDrugShare.setErpId(erpId);
|
||
|
thirdAliDrugShare.setCreateTime(new Date());
|
||
|
thirdAliDrugShare.setUpdateTime(new Date());
|
||
|
|
||
|
thirdAliDrugShare.setPhysicDetailType(jsonObject.getStr("physic_detail_type"));
|
||
|
thirdAliDrugShare.setPhysicDetailTypeDesc(jsonObject.getStr("physic_detail_type_desc"));
|
||
|
thirdAliDrugShare.setPhysicTypeDesc(jsonObject.getStr("physic_type_desc"));
|
||
|
// 阿里额外的字段 prepn_unit prepn_unit_name physic_detail_type physic_detail_type_desc physic_type_desc
|
||
|
;
|
||
|
List<JSONObject> jsonArraySubType = (List) jsonObject.getJSONObject("sub_type_list").getJSONArray("sub_type_list");
|
||
|
if (jsonArraySubType != null && jsonArraySubType.size() > 0) {
|
||
|
for (JSONObject oubType : jsonArraySubType) {
|
||
|
ThirdAliDrug thirdAliDrugShareTwo = new ThirdAliDrug();
|
||
|
BeanUtils.copyProperties(thirdAliDrugShare,thirdAliDrugShareTwo);
|
||
|
thirdAliDrugShareTwo.setFormSpec(oubType.getStr("prepn_spec"));
|
||
|
thirdAliDrugShareTwo.setBzgg(oubType.getStr("package_spec"));
|
||
|
thirdAliDrugShareTwo.setApprovalNum(oubType.getStr("approve_no"));
|
||
|
|
||
|
thirdAliDrugShareTwo.setPrepnUnit(oubType.getStr("prepn_unit"));
|
||
|
thirdAliDrugShareTwo.setPrepnUnitName(oubType.getStr("prepn_unit_name"));
|
||
|
thirdAliDrugShareTwo.setPackUnitName(oubType.getStr("pack_unit_name"));
|
||
|
|
||
|
|
||
|
if (oubType.containsKey("code_res_list")) {
|
||
|
List<JSONObject> codeReslist = (List) oubType.getJSONObject("code_res_list").getJSONArray("code_res_list");
|
||
|
for (JSONObject codeRes : codeReslist) {
|
||
|
ThirdAliDrug thirdAliDrug = new ThirdAliDrug();
|
||
|
BeanUtils.copyProperties(thirdAliDrugShareTwo,thirdAliDrug);
|
||
|
// 码有值才加入
|
||
|
thirdAliDrug.setNameCode(codeRes.getStr("res_code"));
|
||
|
thirdAliDrug.setPackRatio(codeRes.getStr("pkg_ratio"));
|
||
|
thirdAliDrug.setPackLevel(StringUtils.isEmpty(codeRes.getStr("code_level")) ? "0" : codeRes.getStr("code_level"));
|
||
|
list.add(thirdAliDrug);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return list;
|
||
|
}
|
||
|
}
|