2/25 优化1.0

axxyy
wangwei 1 month ago
parent 688a814d5f
commit f45166c392

@ -294,4 +294,6 @@ public interface BaseHttpClient {
* @return
*/
BaseResponse getPrescribesQx(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest);
}

@ -1,8 +1,10 @@
package com.glxp.mipsdl.client;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.ConstantType;
import com.glxp.mipsdl.constant.Constants;
import com.glxp.mipsdl.dao.auth.AuthWarehouseDao;
import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao;
@ -15,6 +17,7 @@ import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
import com.glxp.mipsdl.entity.inout.IoCodeEntity;
import com.glxp.mipsdl.entity.inout.IoOrderDetailBizEntity;
import com.glxp.mipsdl.entity.njxyy.A005;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.base.forthird.ForBasicProductsSearchFilter;
@ -26,9 +29,12 @@ import com.glxp.mipsdl.req.ctqyy.GetSickPrescribeRequest;
import com.glxp.mipsdl.req.ctqyy.GetSickRequest;
import com.glxp.mipsdl.req.post.*;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.PageSimpleResponse;
import com.glxp.mipsdl.res.udiwms.ThrInvResultResponse;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.util.DateUtil;
import com.glxp.mipsdl.util.DictUtl;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.util.SubmitOrderUtil;
@ -41,6 +47,7 @@ import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@ -347,4 +354,6 @@ public abstract class CommonHttpClient implements BaseHttpClient {
return databaseProductName;
}
}

@ -28,6 +28,7 @@ import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
import com.glxp.mipsdl.dao.thrsys.*;
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
import com.glxp.mipsdl.entity.axxyy.PriceDict;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
import com.glxp.mipsdl.entity.basic.BasicCorpEntity;
import com.glxp.mipsdl.entity.basic.BasicUdirelEntity;
@ -40,6 +41,8 @@ import com.glxp.mipsdl.entity.thrsys.*;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.base.forthird.*;
import com.glxp.mipsdl.req.ctqyy.CtqyyRequest;
import com.glxp.mipsdl.req.ctqyy.DlThirdProjectRequest;
import com.glxp.mipsdl.req.ctqyy.GetSickRequest;
import com.glxp.mipsdl.req.njxyy.PostThrProductRequest;
import com.glxp.mipsdl.req.phxyy.PhBusTypeRequest;
@ -58,19 +61,20 @@ import com.glxp.mipsdl.thirddao.njxyy.ThrProductsMapper;
import com.glxp.mipsdl.thirddao.njxyy.ThrSickerMapper;
import com.glxp.mipsdl.util.*;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.xml.bind.JAXBException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* Client
* Client
*/
@Slf4j
@Service(value = "100017HttpClient") //bean注册名称使用编码 + HttpClient文件接口加 FileClient
@ -123,6 +127,35 @@ public class AxxyyClient extends CommonHttpClient {
ThrSickerMapper thrSickerMapper;
/**
* xml
*
* @param methodName
* @return
*/
public String getMsgHeader(String methodName) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<root>" +
"<serverName>" + methodName + "</serverName>" +
"<format>" + "xml" + "</format>" +
"<callOperator>" + "" + "</callOperator>" +
"<certificate>" + "ousrgPVbTpn7ckRUZWypfBR7tGWi2EINBp4vIHOS44V/jN3U5dD+5A==" + "</certificate>" +
"</root>";
}
public String setFilter() {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<root>" +
// "<code>" + "" + "</code>" +
"<name>" + "红细胞寿命测定-呼气法" + "</name>" +
// "<spell>" + "" + "</spell>" +
// "<invalid>" + "" + "</invalid>" +
// "<subject>" + "" + "</subject>" +
"</root>";
}
/**
* ---(A001)
*
@ -913,4 +946,42 @@ public class AxxyyClient extends CommonHttpClient {
}
@Override
public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) {
CtqyyRequest ctqyyRequest = new CtqyyRequest();
String getPriceDict = getMsgHeader("getPriceDict");
String s = setFilter();
log.error("DANGQIAN 请求头:::" + getPriceDict);
log.error("DANGQIAN 请求体:::" + s);
ctqyyRequest.setMsgHeader(getMsgHeader("getPriceDict"));
ctqyyRequest.setMsgBody(setFilter());
String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_PROJECT), ctqyyRequest);
try {
List<PriceDict> priceDicts = JAXBUtil.unmarshalAndGetList(ProductVo.class, PriceDict.class, response);
log.error("获取到 智业返回产品信息:::::::::::::::::::::" + priceDicts);
} catch (Exception e) {
log.error("解析安溪县医院智业返回项目信息数据异常,返回结果:{}", response);
log.error("异常信息:{}", e);
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")");
}
return null;
}
// public String parserResult(String response) {
// if (response.contains("<root")) {
// try {
// JAXBUtil.unmarshalAndGetResult()
// Document document = DocumentHelper.parseText(response);
// String message = document.getRootElement().element("message").getText();
// return message;
// } catch (DocumentException e) {
// log.info("解析安溪县医院智业接口返回结果异常, 返回结果:{}", response);
// log.error("异常信息:", e);
// }
// }
// return response;
// }
}

@ -0,0 +1,75 @@
package com.glxp.mipsdl.client.axxyy;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.util.List;
/**
* @author : zhuzhu
* @date : 2025/2/28 16:03
* @modyified By :
*/
public class JAXBUtil {
// /**
// * 将XML字符串反序列化为指定类型的Java对象并返回该对象的data字段值。
// *
// * @param clazz 目标Java类
// * @param xml XML字符串
// * @param <T> 泛型,表示目标类的类型
// * @return 目标对象的data字段值
// * @throws JAXBException 如果JAXB操作失败
// */
// public static <T> Object unmarshalAndGetResult(Class<T> clazz, String xml) throws JAXBException {
// // 创建JAXB上下文
// JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
// // 创建Unmarshaller
// Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
//
// // 反序列化XML为Java对象
// T object = (T) unmarshaller.unmarshal(new StringReader(xml));
//
// // 调用目标对象的getData()方法并返回结果
// return ((ProductVo) object).getData();
// }
/**
* XMLJavadata
*
* @param clazz JavaProductVo.class
* @param dataClass dataItem.class
* @param xml XML
* @param <T> data
* @return dataList<T>
* @throws JAXBException JAXB
*/
public static <T> List<T> unmarshalAndGetList(Class<?> clazz, Class<T> dataClass, String xml) throws JAXBException {
// 创建JAXB上下文
JAXBContext jaxbContext = JAXBContext.newInstance(clazz, dataClass);
// 创建Unmarshaller
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
// 反序列化XML为Java对象
Object object = unmarshaller.unmarshal(new StringReader(xml));
// 假设反序列化后的对象是ProductVo类型
ProductVo<T> productVo = (ProductVo<T>) object;
// 返回data字段的值
return productVo.getData();
}
// public static void main(String[] args) {
// try {
// // 示例用法
// String xml = "<ProductVo><data>Example Data</data></ProductVo>";
// Object result = unmarshalAndGetResult(ProductVo.class, xml);
// System.out.println("Result: " + result);
// } catch (JAXBException e) {
// e.printStackTrace();
// }
// }
}

@ -0,0 +1,49 @@
package com.glxp.mipsdl.client.axxyy;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* @author : zhuzhu
* @date : 2025/2/28 16:04
* @modyified By :
*/
@XmlRootElement(name = "root")
public class ProductVo<T> {
private String code;
private String error;
private List<T> data;
@XmlElement(name = "code")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@XmlElement(name = "error")
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
@XmlElementWrapper(name = "data")
@XmlElement(name = "item") // 假设List中的元素由<item>标签包裹
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}

@ -0,0 +1,46 @@
package com.glxp.mipsdl.entity.axxyy;
import lombok.Data;
import javax.xml.bind.annotation.XmlElement;
/**
* @author : zhuzhu
* @date : 2025/2/28 16:21
* @modyified By :
*/
@Data
public class PriceDict {
@XmlElement(name = "code")
private String code;
@XmlElement(name = "name")
private String name;
@XmlElement(name = "unit")
private String unit;
@XmlElement(name = "price")
private String price;
@XmlElement(name = "subject")
private String subject;
@XmlElement(name = "starttime")
private String startTime;
@XmlElement(name = "stoptime")
private String stopTime;
@XmlElement(name = "country_code")
private String countryCode;
}

@ -11,4 +11,7 @@ public class DlThirdProjectRequest extends ListPageRequest {
private String thirdSys;
private String fygb;
}

Loading…
Cancel
Save