diff --git a/src/main/java/com/glxp/api/controller/test/TestCodeController.java b/src/main/java/com/glxp/api/controller/test/TestCodeController.java index 3912ffa7..5b85fa63 100644 --- a/src/main/java/com/glxp/api/controller/test/TestCodeController.java +++ b/src/main/java/com/glxp/api/controller/test/TestCodeController.java @@ -2,19 +2,25 @@ package com.glxp.api.controller.test; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.RelCodeDetail; import com.glxp.api.entity.thrsys.ThirdAliDrug; import com.glxp.api.req.alihealth.AlihealthKytDrugrescodeReqeust; 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.AlihealthThirdAliDrugInsertReqeust; import com.glxp.api.req.alihealth.local.AlihealthKytThirdAliSearchbillInsertReqeust; 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.RelCodeDetailService; import com.glxp.api.service.thrsys.ThirdAliDrugService; 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.RestController; @@ -35,6 +41,10 @@ public class TestCodeController { private RelCodeBatchService relCodeBatchService; @Resource private RelCodeDetailService relCodeDetailService; + @Resource + private AuthCompanyMapper authCompanyMapper; + @Resource + private AlihealthYljgUtils alihealthYljgUtils; @PostMapping("/test") public BaseResponse test() { AlihealthRelCodeInsertReqeust alihealthRelCodeInsertReqeust = new AlihealthRelCodeInsertReqeust(); @@ -154,4 +164,54 @@ public class TestCodeController { 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> baseResponse = alihealthUtils.thirdAliDrugInsert(alihealthThirdAliDrugInsertReqeust); +// if(baseResponse.getCode() == 20000){ +// List list = baseResponse.getData(); +// if(list!=null && list.size() >0){ +// for (ThirdAliDrug thirdAliDrug : list) { +// ThirdAliDrug thirdAliDrugNew = thirdAliDrugService.getOne(new QueryWrapper().eq("nameCode", thirdAliDrug.getNameCode()) +// .last("limit 1") +// ); +// if (Objects.isNull(thirdAliDrugNew)) { +// +// thirdAliDrugService.save(thirdAliDrug); +// +// } else { +// thirdAliDrugService.update(thirdAliDrug, new QueryWrapper().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); + } } diff --git a/src/main/java/com/glxp/api/entity/alihealth/AliYljgSearchbill.java b/src/main/java/com/glxp/api/entity/alihealth/AliYljgSearchbill.java index 44bcf7ce..82bb4485 100644 --- a/src/main/java/com/glxp/api/entity/alihealth/AliYljgSearchbill.java +++ b/src/main/java/com/glxp/api/entity/alihealth/AliYljgSearchbill.java @@ -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 */ @@ -87,11 +87,11 @@ public class AliYljgSearchbill { /** * 单据ID */ - private String billOutId; + private Long billOutId; /** * 制剂单位 */ - private String prepnUnit; + private Integer prepnUnit; /** * 制剂规格 */ diff --git a/src/main/java/com/glxp/api/req/alihealth/AlihealthYljgListupoutReqeust.java b/src/main/java/com/glxp/api/req/alihealth/AlihealthYljgListupoutReqeust.java index ad677ac5..fa905253 100644 --- a/src/main/java/com/glxp/api/req/alihealth/AlihealthYljgListupoutReqeust.java +++ b/src/main/java/com/glxp/api/req/alihealth/AlihealthYljgListupoutReqeust.java @@ -46,7 +46,7 @@ public class AlihealthYljgListupoutReqeust extends AlihealthKytCommonParametersR private String bill_code; - private Integer cur_page; + private Integer page; private Integer page_size; diff --git a/src/main/java/com/glxp/api/req/alihealth/local/AlihealthYljgLocalListupoutDetailReqeust.java b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthYljgLocalListupoutDetailReqeust.java new file mode 100644 index 00000000..0b1fe9df --- /dev/null +++ b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthYljgLocalListupoutDetailReqeust.java @@ -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; +} diff --git a/src/main/java/com/glxp/api/req/alihealth/local/AlihealthYljgLocalListupoutReqeust.java b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthYljgLocalListupoutReqeust.java new file mode 100644 index 00000000..0bc1f379 --- /dev/null +++ b/src/main/java/com/glxp/api/req/alihealth/local/AlihealthYljgLocalListupoutReqeust.java @@ -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; +} diff --git a/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutDetailResponse.java b/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutDetailResponse.java index 45746078..6681aad0 100644 --- a/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutDetailResponse.java +++ b/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutDetailResponse.java @@ -3,16 +3,26 @@ 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.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 org.apache.commons.lang3.StringUtils; 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; - @Data public class AlihealthYljgListupoutDetailResponse extends AlihealthKytCommonParametersResponse { - private JSONArray bill_up_out_detail_do; - private Integer total_num; + private JSONObject model; + @Resource + private AlihealthUtils alihealthUtils; public AlihealthYljgListupoutDetailResponse(String json) { // 初始化请求的值 @@ -36,15 +46,43 @@ public class AlihealthYljgListupoutDetailResponse extends AlihealthKytCommonPara public void disposeResult(JSONObject jsonObjectResult) { JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); if (!Objects.isNull(jsonObjectModel)) { - this.setTotal_num(jsonObjectModel.getInt("total_num")); - this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do")); + this.setModel(jsonObjectModel); } } - public void disposeAliKytBillDetail(JSONObject jsonObjectResult) { - JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); - if (!Objects.isNull(jsonObjectModel)) { - this.setTotal_num(jsonObjectModel.getInt("total_num")); - this.setBill_up_out_detail_do(jsonObjectModel.getJSONObject("result_list").getJSONArray("bill_up_out_detail_do")); + + public AliYljgBillDetail disposeAliYljgBillDetail() { + JSONObject jsonObject = this.getModel(); + AliYljgBillDetail aliYljgBillDetail = new AliYljgBillDetail(); + if (!Objects.isNull(jsonObject)) { + CopyUtils.compatibleCopy(jsonObject, aliYljgBillDetail); + JSONObject infosDto = jsonObject.getJSONObject("drug_infos_dto_list"); + if (infosDto != null) { + List infoDtoArray = (List) infosDto.getJSONArray("drug_infos_dto"); + List 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 codeInfoListDtoArray = (List) codeInfoListDto.getJSONArray("code_info_list_dto"); + List 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; + } } diff --git a/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutResponse.java b/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutResponse.java index be62bcea..ed59289f 100644 --- a/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutResponse.java +++ b/src/main/java/com/glxp/api/res/alihealth/AlihealthYljgListupoutResponse.java @@ -1,49 +1,28 @@ 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 com.glxp.api.entity.alihealth.AliYljgSearchbill; +import com.glxp.api.util.alihealth.AlihealthUtils; +import com.glxp.api.util.alihealth.CopyUtils; import lombok.Data; import org.apache.commons.lang3.StringUtils; 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; - @Data public class AlihealthYljgListupoutResponse extends AlihealthKytCommonParametersResponse { - /** - * 单据编码 - */ - private String bill_code; - /** - * 单据类型描述 - */ - 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; + + private JSONArray bill_up_out_detail_do; + @Resource + private AlihealthUtils alihealthUtils; public AlihealthYljgListupoutResponse(String json) { // 初始化请求的值 cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(json); @@ -66,14 +45,23 @@ public class AlihealthYljgListupoutResponse extends AlihealthKytCommonParameters public void disposeResult(JSONObject jsonObjectResult) { JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); 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); } } -// public void disposeAliKytBillDetail() { -// JSONObject jsonObjectModel = jsonObjectResult.getJSONObject("model"); -// if (!Objects.isNull(jsonObjectModel)) { -// 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 disposeAliYljgSearchbill() { + List list = (List)this.getBill_up_out_detail_do(); + List aliYljgSearchbillList = new ArrayList<>(); + if (!Objects.isNull(list)) { + for (JSONObject jsonObject : list) { + AliYljgSearchbill aliYljgSearchbill = new AliYljgSearchbill(); + CopyUtils.compatibleCopy(jsonObject,aliYljgSearchbill); + aliYljgSearchbillList.add(aliYljgSearchbill); + } + } + return aliYljgSearchbillList; + + } + } diff --git a/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java b/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java index 6e3ae1ab..26459547 100644 --- a/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java +++ b/src/main/java/com/glxp/api/util/alihealth/AlihealthUtils.java @@ -30,6 +30,7 @@ import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import java.io.IOException; +import java.lang.reflect.Field; import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.util.*; @@ -273,4 +274,7 @@ public class AlihealthUtils { } return bytes; } + + + } diff --git a/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java b/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java new file mode 100644 index 00000000..fe2b93b7 --- /dev/null +++ b/src/main/java/com/glxp/api/util/alihealth/CopyUtils.java @@ -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 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(); + } +}