1、阿里获取单据

dev_unify
qiuyt 7 months ago
parent c95a5cf291
commit b0d5378f43

@ -2,19 +2,25 @@ package com.glxp.api.controller.test;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.auth.AuthCompanyMapper;
import com.glxp.api.entity.auth.AuthCompany;
import com.glxp.api.entity.collect.RelCodeBatch; import com.glxp.api.entity.collect.RelCodeBatch;
import com.glxp.api.entity.collect.RelCodeDetail; import com.glxp.api.entity.collect.RelCodeDetail;
import com.glxp.api.entity.thrsys.ThirdAliDrug; import com.glxp.api.entity.thrsys.ThirdAliDrug;
import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust;
import com.glxp.api.req.alihealth.AlihealthKytSearchbillReqeust; import com.glxp.api.req.alihealth.AlihealthKytSearchbillReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutDetailReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutReqeust;
import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust; import com.glxp.api.req.alihealth.local.AlihealthRelCodeInsertReqeust;
import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust; import com.glxp.api.req.alihealth.local.AlihealthThirdAliDrugInsertReqeust;
import com.glxp.api.req.alihealth.local.AlihealthKytThirdAliSearchbillInsertReqeust; import com.glxp.api.req.alihealth.local.AlihealthKytThirdAliSearchbillInsertReqeust;
import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse; import com.glxp.api.res.alihealth.AlihealthKytSinglerelationResponse;
import com.glxp.api.res.alihealth.AlihealthYljgListupoutDetailResponse;
import com.glxp.api.service.collect.RelCodeBatchService; import com.glxp.api.service.collect.RelCodeBatchService;
import com.glxp.api.service.collect.RelCodeDetailService; import com.glxp.api.service.collect.RelCodeDetailService;
import com.glxp.api.service.thrsys.ThirdAliDrugService; import com.glxp.api.service.thrsys.ThirdAliDrugService;
import com.glxp.api.util.alihealth.AlihealthUtils; import com.glxp.api.util.alihealth.AlihealthUtils;
import com.glxp.api.util.alihealth.AlihealthYljgUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -35,6 +41,10 @@ public class TestCodeController {
private RelCodeBatchService relCodeBatchService; private RelCodeBatchService relCodeBatchService;
@Resource @Resource
private RelCodeDetailService relCodeDetailService; private RelCodeDetailService relCodeDetailService;
@Resource
private AuthCompanyMapper authCompanyMapper;
@Resource
private AlihealthYljgUtils alihealthYljgUtils;
@PostMapping("/test") @PostMapping("/test")
public BaseResponse test() { public BaseResponse test() {
AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust = new AlihealthRelCodeInsertReqeust(); AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust = new AlihealthRelCodeInsertReqeust();
@ -154,4 +164,54 @@ public class TestCodeController {
return alihealthUtils.thirdAliSearchbillInsert(alihealthKytThirdAliSearchbillInsertReqeust); return alihealthUtils.thirdAliSearchbillInsert(alihealthKytThirdAliSearchbillInsertReqeust);
} }
@PostMapping("/test3")
public BaseResponse test3() {
AlihealthYljgListupoutReqeust alihealthYljgListupoutReqeust1 = new AlihealthYljgListupoutReqeust();
// alihealthYljgListupoutReqeust1.setRef_ent_id("ef99b78bd9c54c1284f813149c858fb0");
// alihealthYljgListupoutReqeust1.setAuth_ref_user_id("ef99b78bd9c54c1284f813149c858fb0");
alihealthYljgListupoutReqeust1.setBegin_date("2019-01-01");
alihealthYljgListupoutReqeust1.setEnd_date("2024-05-01");
// alihealthKytSearchbillReqeust.setBill_type("A");
alihealthYljgListupoutReqeust1.setPage(1);
alihealthYljgListupoutReqeust1.setPage_size(20);
;
// BaseResponse<List<ThirdAliDrug>> baseResponse = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust);
// if(baseResponse.getCode() == 20000){
// List<ThirdAliDrug> list = baseResponse.getData();
// if(list!=null && list.size() >0){
// for (ThirdAliDrug thirdAliDrug : list) {
// ThirdAliDrug thirdAliDrugNew = thirdAliDrugService.getOne(new QueryWrapper<ThirdAliDrug>().eq("nameCode", thirdAliDrug.getNameCode())
// .last("limit 1")
// );
// if (Objects.isNull(thirdAliDrugNew)) {
//
// thirdAliDrugService.save(thirdAliDrug);
//
// } else {
// thirdAliDrugService.update(thirdAliDrug, new QueryWrapper<ThirdAliDrug>().eq("nameCode", thirdAliDrug.getNameCode()));
// }
// }
// }
//
// }
return alihealthYljgUtils.listupout(alihealthYljgListupoutReqeust1,"厦门同春医药股份有限公司");
}
@PostMapping("/test4")
public BaseResponse test4() {
AlihealthYljgListupoutDetailReqeust alihealthYljgListupoutDetailReqeust = new AlihealthYljgListupoutDetailReqeust();
// alihealthYljgListupoutDetailReqeust.setRef_ent_id();
alihealthYljgListupoutDetailReqeust.setBill_code("19604910");
alihealthYljgListupoutDetailReqeust.setFrom_ref_user_id("a74061d26923498785ad8489962d9de2");
// alihealthYljgListupoutDetailReqeust.setTo_ref_user_id();
return alihealthYljgUtils.listupoutDetail(alihealthYljgListupoutDetailReqeust);
}
} }

@ -15,7 +15,7 @@ public class AliYljgSearchbill {
/** /**
* *
*/ */
private String codeCount; private Integer codeCount;
/** /**
* *
*/ */
@ -47,7 +47,7 @@ public class AliYljgSearchbill {
/** /**
* *
*/ */
private String prepnCount; private Integer prepnCount;
/** /**
* REFENTID * REFENTID
*/ */
@ -87,11 +87,11 @@ public class AliYljgSearchbill {
/** /**
* ID * ID
*/ */
private String billOutId; private Long billOutId;
/** /**
* *
*/ */
private String prepnUnit; private Integer prepnUnit;
/** /**
* *
*/ */

@ -46,7 +46,7 @@ public class AlihealthYljgListupoutReqeust extends AlihealthKytCommonParametersR
private String bill_code; private String bill_code;
private Integer cur_page; private Integer page;
private Integer page_size; private Integer page_size;

@ -0,0 +1,12 @@
package com.glxp.api.req.alihealth.local;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutDetailReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutReqeust;
import lombok.Data;
@Data
public class AlihealthYljgLocalListupoutDetailReqeust {
private String appSecret;
private AlihealthYljgListupoutDetailReqeust alihealthYljgListupoutDetailReqeust;
}

@ -0,0 +1,13 @@
package com.glxp.api.req.alihealth.local;
import com.glxp.api.req.alihealth.AlihealthYljgListupoutReqeust;
import com.glxp.api.req.alihealth.AlihealthYljgUploadinoutbillReqeust;
import lombok.Data;
@Data
public class AlihealthYljgLocalListupoutReqeust {
private String erpName;
private String appSecret;
private AlihealthYljgListupoutReqeust alihealthYljgListupoutReqeust;
}

@ -3,16 +3,26 @@ package com.glxp.api.res.alihealth;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.glxp.api.entity.alihealth.AliYljgBillDetail;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrug;
import com.glxp.api.entity.alihealth.AliYljgBillDetailDrugCode;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.util.alihealth.AlihealthUtils;
import com.glxp.api.util.alihealth.CopyUtils;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
@Data @Data
public class AlihealthYljgListupoutDetailResponse extends AlihealthKytCommonParametersResponse { public class AlihealthYljgListupoutDetailResponse extends AlihealthKytCommonParametersResponse {
private JSONArray bill_up_out_detail_do; private JSONObject model;
private Integer total_num; @Resource
private AlihealthUtils alihealthUtils;
public AlihealthYljgListupoutDetailResponse(String json) { public AlihealthYljgListupoutDetailResponse(String json) {
// 初始化请求的值 // 初始化请求的值
@ -36,15 +46,43 @@ public class AlihealthYljgListupoutDetailResponse extends AlihealthKytCommonPara
public void disposeResult(JSONObject jsonObjectResult) { public void disposeResult(JSONObject jsonObjectResult) {
JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model");
if (!Objects.isNull(jsonObjectModel)) { if (!Objects.isNull(jsonObjectModel)) {
this.setTotal_num(jsonObjectModel.getInt("total_num")); this.setModel(jsonObjectModel);
this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do"));
} }
} }
public void disposeAliKytBillDetail(JSONObject jsonObjectResult) {
JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); public AliYljgBillDetail disposeAliYljgBillDetail() {
if (!Objects.isNull(jsonObjectModel)) { JSONObject jsonObject = this.getModel();
this.setTotal_num(jsonObjectModel.getInt("total_num")); AliYljgBillDetail aliYljgBillDetail = new AliYljgBillDetail();
this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do")); if (!Objects.isNull(jsonObject)) {
CopyUtils.compatibleCopy(jsonObject, aliYljgBillDetail);
JSONObject infosDto = jsonObject.getJSONObject("drug_infos_dto_list");
if (infosDto != null) {
List<JSONObject> infoDtoArray = (List) infosDto.getJSONArray("drug_infos_dto");
List<AliYljgBillDetailDrug> aliYljgBillDetailDrugList = new ArrayList<>();
if (infoDtoArray != null && infoDtoArray.size() > 0) {
for (JSONObject infoDto : infoDtoArray) {
AliYljgBillDetailDrug aliYljgBillDetailDrug = new AliYljgBillDetailDrug();
CopyUtils.compatibleCopy(infoDto, aliYljgBillDetailDrug);
aliYljgBillDetailDrugList.add(aliYljgBillDetailDrug);
JSONObject codeInfoListDto = infoDto.getJSONObject("code_info_list_dto_list");
if (codeInfoListDto != null) {
List<JSONObject> codeInfoListDtoArray = (List) codeInfoListDto.getJSONArray("code_info_list_dto");
List<AliYljgBillDetailDrugCode> aliYljgBillDetailDrugCodeList = new ArrayList<>();
AliYljgBillDetailDrugCode aliYljgBillDetailDrugCode = new AliYljgBillDetailDrugCode();
if (codeInfoListDtoArray != null && codeInfoListDtoArray.size() > 0) {
for (JSONObject codeInfoObj : codeInfoListDtoArray) {
CopyUtils.compatibleCopy(codeInfoObj, aliYljgBillDetailDrugCode);
aliYljgBillDetailDrugCodeList.add(aliYljgBillDetailDrugCode);
}
aliYljgBillDetailDrug.setAliYljgBillDetailDrugCodeList(aliYljgBillDetailDrugCodeList);
}
aliYljgBillDetail.setAliYljgBillDetailDrugList(aliYljgBillDetailDrugList);
} }
} }
}
}
}
return aliYljgBillDetail;
}
} }

@ -1,49 +1,28 @@
package com.glxp.api.res.alihealth; package com.glxp.api.res.alihealth;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.glxp.api.entity.alihealth.AliYljgSearchbill;
import com.glxp.api.util.alihealth.AlihealthUtils;
import com.glxp.api.util.alihealth.CopyUtils;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
@Data @Data
public class AlihealthYljgListupoutResponse extends AlihealthKytCommonParametersResponse { public class AlihealthYljgListupoutResponse extends AlihealthKytCommonParametersResponse {
/**
* private JSONArray bill_up_out_detail_do;
*/ @Resource
private String bill_code; private AlihealthUtils alihealthUtils;
/**
*
*/
private String bill_type_name;
/**
*
*/
private String bill_type;
/**
*
*/
private String ent_send_name;
/**
*
*/
private String ent_recv_name;
/**
* ref_ent_id
*/
private String ent_recv_id;
/**
*
*/
private String store_out_date;
/**
*
*/
private String update_date;
private JSONArray drug_infos_dto_list;
public AlihealthYljgListupoutResponse(String json) { public AlihealthYljgListupoutResponse(String json) {
// 初始化请求的值 // 初始化请求的值
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(json); cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(json);
@ -66,14 +45,23 @@ public class AlihealthYljgListupoutResponse extends AlihealthKytCommonParameters
public void disposeResult(JSONObject jsonObjectResult) { public void disposeResult(JSONObject jsonObjectResult) {
JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model");
if (!Objects.isNull(jsonObjectModel)) { if (!Objects.isNull(jsonObjectModel)) {
JSONArray jsonArray = jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do");
this.setBill_up_out_detail_do(jsonArray);
BeanUtils.copyProperties(jsonObjectModel,this); BeanUtils.copyProperties(jsonObjectModel,this);
} }
} }
// public void disposeAliKytBillDetail() { public List<AliYljgSearchbill> disposeAliYljgSearchbill() {
// JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); List<JSONObject> list = (List)this.getBill_up_out_detail_do();
// if (!Objects.isNull(jsonObjectModel)) { List<AliYljgSearchbill> aliYljgSearchbillList = new ArrayList<>();
// this.setTotal_num(jsonObjectModel.getInt("total_num")); if (!Objects.isNull(list)) {
// this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do")); for (JSONObject jsonObject : list) {
// } AliYljgSearchbill aliYljgSearchbill = new AliYljgSearchbill();
// } CopyUtils.compatibleCopy(jsonObject,aliYljgSearchbill);
aliYljgSearchbillList.add(aliYljgSearchbill);
}
}
return aliYljgSearchbillList;
}
} }

@ -30,6 +30,7 @@ import javax.crypto.Mac;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.*; import java.util.*;
@ -273,4 +274,7 @@ public class AlihealthUtils {
} }
return bytes; return bytes;
} }
} }

@ -0,0 +1,63 @@
package com.glxp.api.util.alihealth;
import cn.hutool.core.bean.BeanUtil;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
public class CopyUtils {
public static void compatibleCopy(Map<String,Object> map, Object target) {
try {
Class targetClass = target.getClass();//得到对象的Class
Field[] targetFields = targetClass.getDeclaredFields();//得到Class对象的所有属性
Set keySet =map.keySet(); //获取到所有值
for(Object key : keySet ) {
Object value = map.get(key);
for (Field targetField : targetFields) {
targetField.setAccessible(true);
String targetName = targetField.getName();//目标对象的属性名
System.out.println("1 "+targetName.equals(snakeToCamel((String) key)) +"targetName "+ targetName +"targetName "+ snakeToCamel((String) key ));
System.out.println("2 "+key);
if (targetName.equals(snakeToCamel((String) key)) && !Objects.isNull(value)) {
targetField.set(target, value);
}
}
}
} catch (Exception e) {
System.out.println("错误==="+e);
e.printStackTrace();
// BeanUtil.copyProperties(source, target);
}
}
public static String snakeToCamel(String snakeCase) {
// 将字符串按下划线分割
String[] parts = snakeCase.split("_");
StringBuilder camelCase = new StringBuilder();
for (String part : parts) {
if (camelCase.length() == 0) {
// 第一个单词首字母小写
camelCase.append(part.toLowerCase());
} else {
// 其他单词首字母大写
camelCase.append(part.substring(0, 1).toUpperCase())
.append(part.substring(1).toLowerCase());
}
}
return camelCase.toString();
}
}
Loading…
Cancel
Save