|
|
@ -18,6 +18,7 @@ import com.glxp.mipsdl.admin.req.UdiwmsOrderRequest;
|
|
|
|
import com.glxp.mipsdl.admin.req.UdiwmsProductRequest;
|
|
|
|
import com.glxp.mipsdl.admin.req.UdiwmsProductRequest;
|
|
|
|
import com.glxp.mipsdl.admin.req.UdiwmsUnitRequest;
|
|
|
|
import com.glxp.mipsdl.admin.req.UdiwmsUnitRequest;
|
|
|
|
import com.glxp.mipsdl.admin.res.system.UdiwmsProductInfoResponse;
|
|
|
|
import com.glxp.mipsdl.admin.res.system.UdiwmsProductInfoResponse;
|
|
|
|
|
|
|
|
import com.glxp.mipsdl.admin.util.CustomUtil;
|
|
|
|
import com.glxp.mipsdl.admin.util.Md5Utils;
|
|
|
|
import com.glxp.mipsdl.admin.util.Md5Utils;
|
|
|
|
import com.glxp.mipsdl.common.res.BaseResponse;
|
|
|
|
import com.glxp.mipsdl.common.res.BaseResponse;
|
|
|
|
import com.glxp.mipsdl.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.mipsdl.common.util.ResultVOUtils;
|
|
|
@ -26,10 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -46,7 +44,7 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BaseResponse getPrdoucts(UdiwmsProductRequest udiwmsProductRequest) {
|
|
|
|
public BaseResponse getPrdoucts(UdiwmsProductRequest udiwmsProductRequest) {
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
Map<String, String> params = new TreeMap<>();
|
|
|
|
Map<String, Object> params = new TreeMap<>();
|
|
|
|
if (null != udiwmsProductRequest) {
|
|
|
|
if (null != udiwmsProductRequest) {
|
|
|
|
Field[] fields = ReflectUtil.getFields(UdiwmsProductRequest.class);
|
|
|
|
Field[] fields = ReflectUtil.getFields(UdiwmsProductRequest.class);
|
|
|
|
for (Field field : fields) {
|
|
|
|
for (Field field : fields) {
|
|
|
@ -83,12 +81,12 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
|
|
|
|
|
|
|
|
String url = udPlatConfig.getHost() + "/hsapi/purchase/hosp/goods/query";
|
|
|
|
String url = udPlatConfig.getHost() + "/hsapi/purchase/hosp/goods/query";
|
|
|
|
url += builder;
|
|
|
|
url += builder;
|
|
|
|
HttpResponse response = HttpRequest.get(url).headerMap(getHeader(params), true).execute();
|
|
|
|
HttpResponse response = HttpRequest.get(url).headerMap(getHeader(params, "get"), true).execute();
|
|
|
|
List<UdiwmsProductInfoResponse> result = new ArrayList<>();
|
|
|
|
List<UdiwmsProductInfoResponse> result = new ArrayList<>();
|
|
|
|
if (!response.body().contains("校验失败")) {
|
|
|
|
if (!response.body().contains("校验失败")) {
|
|
|
|
JSONObject jsonObject = JSON.parseObject(response.body());
|
|
|
|
JSONObject jsonObject = JSON.parseObject(response.body());
|
|
|
|
List<UdplatGoodsEntity> udplatGoodsEntities = JSON.parseArray(jsonObject.getJSONObject("data").getString("data"), UdplatGoodsEntity.class);
|
|
|
|
List<UdplatGoodsEntity> udplatGoodsEntities = JSON.parseArray(jsonObject.getJSONObject("data").getString("data"), UdplatGoodsEntity.class);
|
|
|
|
udplatGoodsEntities = getSingleSpecProduct(udplatGoodsEntities);
|
|
|
|
//udplatGoodsEntities = getSingleSpecProduct(udplatGoodsEntities);
|
|
|
|
result.addAll(convertProduct(udplatGoodsEntities));
|
|
|
|
result.addAll(convertProduct(udplatGoodsEntities));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ResultVOUtils.success(result);
|
|
|
|
return ResultVOUtils.success(result);
|
|
|
@ -104,12 +102,12 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
for (UdplatGoodsEntity udplatGoodsEntity : udplatGoodsEntities) {
|
|
|
|
for (UdplatGoodsEntity udplatGoodsEntity : udplatGoodsEntities) {
|
|
|
|
if (udplatGoodsEntity.getMatchLevel().equals(1)) {
|
|
|
|
if (udplatGoodsEntity.getMatchLevel().equals(1)) {
|
|
|
|
//对照层级为产品,调用院内目录查询此产品关联的所有规格型号
|
|
|
|
//对照层级为产品,调用院内目录查询此产品关联的所有规格型号
|
|
|
|
Map<String, String> params = new TreeMap<>();
|
|
|
|
Map<String, Object> params = new TreeMap<>();
|
|
|
|
params.put("hospGoodsId", String.valueOf(udplatGoodsEntity.getId()));
|
|
|
|
params.put("hospGoodsId", String.valueOf(udplatGoodsEntity.getId()));
|
|
|
|
params.put("compId", udplatGoodsEntity.getCompId());
|
|
|
|
params.put("compId", udplatGoodsEntity.getCompId());
|
|
|
|
|
|
|
|
|
|
|
|
String paramUrl = "?hospGoodsId=" + udplatGoodsEntity.getId() + "&compId=" + udplatGoodsEntity.getCompId();
|
|
|
|
String paramUrl = "?hospGoodsId=" + udplatGoodsEntity.getId() + "&compId=" + udplatGoodsEntity.getCompId();
|
|
|
|
HttpResponse response = HttpRequest.get(udPlatConfig.getHost() + "/hsapi/purchase/hospGoods/spec/query" + paramUrl).headerMap(getHeader(params), true).execute();
|
|
|
|
HttpResponse response = HttpRequest.get(udPlatConfig.getHost() + "/hsapi/purchase/hospGoods/spec/query" + paramUrl).headerMap(getHeader(params, "get"), true).execute();
|
|
|
|
JSONObject resp = JSON.parseObject(response.body());
|
|
|
|
JSONObject resp = JSON.parseObject(response.body());
|
|
|
|
if (resp.getBoolean("success").equals(true)) {
|
|
|
|
if (resp.getBoolean("success").equals(true)) {
|
|
|
|
JSONArray jsonArray = resp.getJSONObject("data").getJSONArray("data");
|
|
|
|
JSONArray jsonArray = resp.getJSONObject("data").getJSONArray("data");
|
|
|
@ -153,6 +151,7 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
for (UdplatGoodsEntity udplatGoodsEntity : udplatGoodsEntities) {
|
|
|
|
for (UdplatGoodsEntity udplatGoodsEntity : udplatGoodsEntities) {
|
|
|
|
UdiwmsProductInfoResponse productInfoResponse = new UdiwmsProductInfoResponse();
|
|
|
|
UdiwmsProductInfoResponse productInfoResponse = new UdiwmsProductInfoResponse();
|
|
|
|
BeanUtil.copyProperties(udplatGoodsEntity, productInfoResponse);
|
|
|
|
BeanUtil.copyProperties(udplatGoodsEntity, productInfoResponse);
|
|
|
|
|
|
|
|
productInfoResponse.setCode(String.valueOf(udplatGoodsEntity.getId()));
|
|
|
|
productInfoResponse.setRegisterNo(udplatGoodsEntity.getRegNum());
|
|
|
|
productInfoResponse.setRegisterNo(udplatGoodsEntity.getRegNum());
|
|
|
|
productInfoResponse.setYlqxzcrbarmc(udplatGoodsEntity.getRegName());
|
|
|
|
productInfoResponse.setYlqxzcrbarmc(udplatGoodsEntity.getRegName());
|
|
|
|
productInfoResponse.setSupName(udplatGoodsEntity.getDistributorName());
|
|
|
|
productInfoResponse.setSupName(udplatGoodsEntity.getDistributorName());
|
|
|
@ -162,12 +161,14 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
productInfoResponse.setStandard(udplatGoodsEntity.getSpec());
|
|
|
|
productInfoResponse.setStandard(udplatGoodsEntity.getSpec());
|
|
|
|
productInfoResponse.setSpec(udplatGoodsEntity.getSpec() + udplatGoodsEntity.getModel());
|
|
|
|
productInfoResponse.setSpec(udplatGoodsEntity.getSpec() + udplatGoodsEntity.getModel());
|
|
|
|
productInfoResponse.setName(udplatGoodsEntity.getProductName());
|
|
|
|
productInfoResponse.setName(udplatGoodsEntity.getProductName());
|
|
|
|
|
|
|
|
productInfoResponse.setProductSpecId(udplatGoodsEntity.getCompId());
|
|
|
|
|
|
|
|
|
|
|
|
list.add(productInfoResponse);
|
|
|
|
list.add(productInfoResponse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, String> getHeader(Map<String, String> mapParam) {
|
|
|
|
private Map<String, String> getHeader(Map<String, Object> mapParam, String reqType) {
|
|
|
|
Map<String, String> map = new TreeMap<>();
|
|
|
|
Map<String, String> map = new TreeMap<>();
|
|
|
|
String time = String.valueOf(System.currentTimeMillis());
|
|
|
|
String time = String.valueOf(System.currentTimeMillis());
|
|
|
|
mapParam.put("time", time);
|
|
|
|
mapParam.put("time", time);
|
|
|
@ -176,7 +177,7 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
map.put("userName", udPlatConfig.getUserName());
|
|
|
|
map.put("userName", udPlatConfig.getUserName());
|
|
|
|
map.put("time", time);
|
|
|
|
map.put("time", time);
|
|
|
|
map.put("secretKey", udPlatConfig.getSecretKey());
|
|
|
|
map.put("secretKey", udPlatConfig.getSecretKey());
|
|
|
|
map.put("sign", getSign(mapParam));
|
|
|
|
map.put("sign", getSign(mapParam, reqType));
|
|
|
|
log.info(map.toString());
|
|
|
|
log.info(map.toString());
|
|
|
|
return map;
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -185,23 +186,114 @@ public class UdPlatClient implements BaseHttpClient {
|
|
|
|
* 获取签名
|
|
|
|
* 获取签名
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param mapParam
|
|
|
|
* @param mapParam
|
|
|
|
|
|
|
|
* @param reqType 请求类型
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private String getSign(Map<String, String> mapParam) {
|
|
|
|
private String getSign(Map<String, Object> mapParam, String reqType) {
|
|
|
|
TreeMap<String, String> map = new TreeMap<>();
|
|
|
|
TreeMap<String, Object> map = new TreeMap<>();
|
|
|
|
map.put("appId", udPlatConfig.getAppId());
|
|
|
|
map.put("appId", udPlatConfig.getAppId());
|
|
|
|
map.put("userName", udPlatConfig.getUserName());
|
|
|
|
map.put("userName", udPlatConfig.getUserName());
|
|
|
|
map.put("secretKey", udPlatConfig.getUdPlatConfig().getSecretKey());
|
|
|
|
map.put("secretKey", udPlatConfig.getUdPlatConfig().getSecretKey());
|
|
|
|
map.put("time", mapParam.get("time"));
|
|
|
|
map.put("time", String.valueOf(mapParam.get("time")));
|
|
|
|
map.putAll(mapParam);
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
|
if ("post".equals(reqType)) {
|
|
|
|
sb.append(entry.getKey()).append("=").append(entry.getValue());
|
|
|
|
mapParam.remove("time");
|
|
|
|
sb.append("&");
|
|
|
|
//拼接body参数
|
|
|
|
|
|
|
|
sb.append("appId=").append(udPlatConfig.getAppId()).append("&body=").append(JSON.toJSONString(mapParam)).append("&");
|
|
|
|
|
|
|
|
map.remove("appId");
|
|
|
|
|
|
|
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
|
|
|
|
|
|
sb.append(entry.getKey()).append("=").append(entry.getValue());
|
|
|
|
|
|
|
|
sb.append("&");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
map.putAll(mapParam);
|
|
|
|
|
|
|
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
|
|
|
|
|
|
sb.append(entry.getKey()).append("=").append(entry.getValue());
|
|
|
|
|
|
|
|
sb.append("&");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String str = sb.toString();
|
|
|
|
String str = sb.toString();
|
|
|
|
String str0 = str.substring(0, str.length() - 1);
|
|
|
|
String str0 = str.substring(0, str.length() - 1);
|
|
|
|
|
|
|
|
log.info("签名---------------");
|
|
|
|
|
|
|
|
log.info(str0);
|
|
|
|
return Md5Utils.stringToMD5(str0);
|
|
|
|
return Md5Utils.stringToMD5(str0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 提交采购计划
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param udiwmsOrderRequest
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public BaseResponse postOrder(UdiwmsOrderRequest udiwmsOrderRequest) {
|
|
|
|
|
|
|
|
Map<String, Object> orderParam = new TreeMap<>();
|
|
|
|
|
|
|
|
orderParam.put("hisOrderId", udiwmsOrderRequest.getBillNo()); //医院计划单或订单主键(医院系统存储主键)
|
|
|
|
|
|
|
|
orderParam.put("remark", udiwmsOrderRequest.getRemark()); //医院采购计划备注
|
|
|
|
|
|
|
|
orderParam.put("shippingAddress", udiwmsOrderRequest.getAddress()); //收货地址
|
|
|
|
|
|
|
|
orderParam.put("shippingLinkMan", udiwmsOrderRequest.getLinkMan()); //收货联系人
|
|
|
|
|
|
|
|
orderParam.put("shippingLinkTel", udiwmsOrderRequest.getLinkTel()); //收货联系电话
|
|
|
|
|
|
|
|
orderParam.put("shippingInvoice", udiwmsOrderRequest.getCorpName()); //开票抬头
|
|
|
|
|
|
|
|
//orderParam.put("planTime", null); //期望到货时间,参数中无此字段,暂时不传
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map> detailsMap = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String, String> orderDetailParamMap = new TreeMap<>();
|
|
|
|
|
|
|
|
orderDetailParamMap.put("hisOrderDetailId", CustomUtil.getId()); //医院订单明细主键
|
|
|
|
|
|
|
|
orderDetailParamMap.put("hospHisCode", udiwmsOrderRequest.getProductId()); //院内目录商品编码
|
|
|
|
|
|
|
|
orderDetailParamMap.put("planBuyNum", udiwmsOrderRequest.getCount()); //采购数量
|
|
|
|
|
|
|
|
//orderDetailParamMap.put("purchaseRemark", null); //自定义订单备注信息,参数中无此字段,暂时不传
|
|
|
|
|
|
|
|
orderDetailParamMap.put("productSpecId", udiwmsOrderRequest.getProductId());
|
|
|
|
|
|
|
|
//查询产品规格型号信息
|
|
|
|
|
|
|
|
UdplatGoodsEntity udplatGoods = getGoodsInfoByProductSpecId(udiwmsOrderRequest.getProductId(), udiwmsOrderRequest.getProductSpecId());
|
|
|
|
|
|
|
|
if (null != udplatGoods) {
|
|
|
|
|
|
|
|
orderDetailParamMap.put("spec", udplatGoods.getSpec());
|
|
|
|
|
|
|
|
orderDetailParamMap.put("model", udplatGoods.getModel());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
detailsMap.add(orderDetailParamMap);
|
|
|
|
|
|
|
|
orderParam.put("items", detailsMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("参数-----");
|
|
|
|
|
|
|
|
log.info(JSON.toJSONString(orderParam));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//向阳光采购平台提交采购计划
|
|
|
|
|
|
|
|
HttpResponse response = HttpRequest.post(udPlatConfig.getHost() + "/hsapi/purchase/planOrder/submit").headerMap(getHeader(orderParam, "post"), true)
|
|
|
|
|
|
|
|
.body(JSON.toJSONString(orderParam))
|
|
|
|
|
|
|
|
.execute();
|
|
|
|
|
|
|
|
JSONObject resp = JSON.parseObject(response.body());
|
|
|
|
|
|
|
|
if (resp.getBoolean("success").equals(false)) {
|
|
|
|
|
|
|
|
log.info("提交采购计划失败");
|
|
|
|
|
|
|
|
log.info(response.body());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultVOUtils.success(resp.get("data"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 阳光采购平台院内目录查询
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param hospGoodsId 院内目录ID
|
|
|
|
|
|
|
|
* @param productSpecId 组件ID
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public UdplatGoodsEntity getGoodsInfoByProductSpecId(String hospGoodsId, String productSpecId) {
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
|
|
params.put("hospGoodsId", hospGoodsId);
|
|
|
|
|
|
|
|
params.put("compId", productSpecId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//拼接参数
|
|
|
|
|
|
|
|
String paramsUrl = "?hospGoodsId=" + hospGoodsId + "&compId=" + productSpecId;
|
|
|
|
|
|
|
|
HttpResponse response = HttpRequest.get(udPlatConfig.getHost() + "/hsapi/purchase/hospGoods/spec/query" + paramsUrl).headerMap(getHeader(params, "get"), true).execute();
|
|
|
|
|
|
|
|
JSONObject resp = JSON.parseObject(response.body());
|
|
|
|
|
|
|
|
if (resp.getBoolean("success").equals(true)) {
|
|
|
|
|
|
|
|
JSONArray jsonArray = resp.getJSONObject("data").getJSONArray("data");
|
|
|
|
|
|
|
|
if (!jsonArray.isEmpty()) {
|
|
|
|
|
|
|
|
for (Object o : jsonArray) {
|
|
|
|
|
|
|
|
UdplatGoodsEntity entity = JSON.parseObject(JSON.toJSONString(o), UdplatGoodsEntity.class);
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|