管理系统增加扫码的时候如果码关联关系找不到那就调用外网的阿里接口进行插入关联关系
parent
ab3e5a7173
commit
e86612240b
@ -0,0 +1,17 @@
|
||||
package com.glxp.api.req.alihealth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlihealthRelCodeInsertReqeust {
|
||||
/**
|
||||
* 往来单位名称
|
||||
*/
|
||||
private String name;
|
||||
private String appKey;
|
||||
private String appSecret;
|
||||
|
||||
private String customerId;
|
||||
private String code;
|
||||
private String refEntId;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.glxp.api.res.alihealth;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlihealthKytCommonParametersResponse {
|
||||
|
||||
private String msg_code;
|
||||
private String msg_info;
|
||||
private String response_success;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
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.entity.collect.RelCodeDetail;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
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;
|
||||
|
||||
private String refEntId;
|
||||
public AlihealthKytSinglerelationResponse() {
|
||||
|
||||
}
|
||||
|
||||
public AlihealthKytSinglerelationResponse(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){
|
||||
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(0);
|
||||
relCodeBatch.setUploadFlagDown(0);
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue