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.
udi-spms-java/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgCodedetailResp...

93 lines
4.0 KiB
Java

package com.glxp.api.res.alihealth;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.util.udi.FilterUdiUtils;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import java.util.*;
@Data
public class AlihealthYljgCodedetailResponse extends AlihealthKytCommonParametersResponse{
private JSONArray code_full_info_dto;
public AlihealthYljgCodedetailResponse(String 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("models");
if (!Objects.isNull(jsonObjectModel)) {
this.code_full_info_dto = jsonObjectResult.getJSONArray("code_full_info_dto");
// this.setTotal_num(jsonObjectModel.getInt("total_num"));
// this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do"));
}
}
public List<RelCodeBatch> disposeRelCodeBatch(String customerId){
List<RelCodeBatch> relCodeBatchList =new ArrayList<>();
List<JSONObject> list = (List)this.getCode_full_info_dto();
if(list != null & list.size() >0){
for (JSONObject jsonObject : list) {
RelCodeBatch relCodeBatch = new RelCodeBatch();
relCodeBatch.setProductCode(FilterUdiUtils.getUdi(jsonObject.getStr("code")).getUdi());
// relCodeBatch.setSubTypeNo();
// relCodeBatch.setCascadeRatio();
relCodeBatch.setPackageSpec(jsonObject.getStr("pkg_spec_crit"));
// relCodeBatch.setComment();
List<JSONObject> jsonArray = (List) jsonObject.getJSONObject("code_produce_info_d_t_o").getJSONArray("produce_info_list");
JSONObject produceInfo =jsonArray.get(0);
relCodeBatch.setBatchNo(produceInfo.getStr("batch_no"));
relCodeBatch.setMadeDate(produceInfo.getStr("produce_date_str"));
relCodeBatch.setValidateDate(produceInfo.getStr("expire_date"));
relCodeBatch.setWorkShop(jsonObject.getJSONObject("p_user_ent_d_t_o").getStr("ent_name"));
// relCodeBatch.setLineName();
// relCodeBatch.setLineManager();
// relCodeBatch.setCreateTime();
// relCodeBatch.setCreateUser();
relCodeBatch.setUpdateTime(new Date());
relCodeBatch.setUpdateUser(customerId);
relCodeBatch.setUploadFlagUp(0);
relCodeBatch.setUploadFlagDown(0);
relCodeBatch.setParentCode(null);
relCodeBatch.setErpId(customerId);
relCodeBatch.setCurCode(jsonObject.getStr("code"));
// if(jsonObject.getJSONObject("p_user_ent_d_t_o").equals("1")){
//
// }else if(jsonObject.getJSONObject("p_user_ent_d_t_o").equals("2")){
//
// }
relCodeBatch.setOneLevelCount(0);
relCodeBatch.setTwoLevelCount(0);
relCodeBatch.setThreeLevelCount(0);
relCodeBatchList.add(relCodeBatch);
}
}
return relCodeBatchList;
}
}