diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/client/BaseHttpClient.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/client/BaseHttpClient.java index a31a323..40919ff 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/client/BaseHttpClient.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/client/BaseHttpClient.java @@ -15,4 +15,5 @@ public interface BaseHttpClient { BaseResponse getOrders(UdiwmsOrderRequest udiwmsOrderRequest); BaseResponse getInvProducts(UdiwmsOnhandRequest udiwmsOnhandRequest); + } diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/UdPlatClient.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/UdPlatClient.java new file mode 100644 index 0000000..a968f7c --- /dev/null +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/client/http/UdPlatClient.java @@ -0,0 +1,207 @@ +package com.glxp.mipsdl.admin.client.http; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.glxp.mipsdl.admin.client.BaseHttpClient; +import com.glxp.mipsdl.admin.config.UdPlatConfig; +import com.glxp.mipsdl.admin.entity.ygudplat.UdplatGoodsEntity; +import com.glxp.mipsdl.admin.req.UdiwmsOnhandRequest; +import com.glxp.mipsdl.admin.req.UdiwmsOrderRequest; +import com.glxp.mipsdl.admin.req.UdiwmsProductRequest; +import com.glxp.mipsdl.admin.req.UdiwmsUnitRequest; +import com.glxp.mipsdl.admin.res.system.UdiwmsProductInfoResponse; +import com.glxp.mipsdl.admin.util.Md5Utils; +import com.glxp.mipsdl.common.res.BaseResponse; +import com.glxp.mipsdl.common.util.ResultVOUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +@Slf4j +@Service +public class UdPlatClient implements BaseHttpClient { + + @Autowired + private UdPlatConfig udPlatConfig; + + @Override + public BaseResponse getUnit(UdiwmsUnitRequest testUnitRequest) { + return null; + } + + @Override + public BaseResponse getPrdoucts(UdiwmsProductRequest udiwmsProductRequest) { + StringBuilder builder = new StringBuilder(); + Map params = new TreeMap<>(); + if (null != udiwmsProductRequest) { + Field[] fields = ReflectUtil.getFields(UdiwmsProductRequest.class); + for (Field field : fields) { + Object fieldValue = ReflectUtil.getFieldValue(udiwmsProductRequest, field); + if (null != fieldValue && "" != fieldValue) { + if ("limit".equals(field.getName())) { + params.put("pageSize", String.valueOf(fieldValue)); + } else if ("manufactory".equals(field.getName())) { + params.put("manufactureId", String.valueOf(fieldValue)); + } else if ("name".equals(field.getName())) { + params.put("brandName", String.valueOf(fieldValue)); + } else if ("model".equals(field.getName())) { + params.put("model", String.valueOf(fieldValue)); + } else if ("sepc".equals(field.getName())) { + params.put("spec", String.valueOf(fieldValue)); + } else if ("standard".equals(field.getName())) { + params.put("spec", String.valueOf(fieldValue)); + } else { + params.put(field.getName(), String.valueOf(fieldValue)); + } + } + } + + if (CollUtil.isNotEmpty(params)) { + for (String key : params.keySet()) { + if (StrUtil.isBlank(builder.toString())) { + builder.append("?").append(key).append("=").append(params.get(key)); + } else { + builder.append("&").append(key).append("=").append(params.get(key)); + } + } + } + } + + String url = udPlatConfig.getHost() + "/hsapi/purchase/hosp/goods/query"; + url += builder; + HttpResponse response = HttpRequest.get(url).headerMap(getHeader(params), true).execute(); + List result = new ArrayList<>(); + if (!response.body().contains("校验失败")) { + JSONObject jsonObject = JSON.parseObject(response.body()); + List udplatGoodsEntities = JSON.parseArray(jsonObject.getJSONObject("data").getString("data"), UdplatGoodsEntity.class); + udplatGoodsEntities = getSingleSpecProduct(udplatGoodsEntities); + result.addAll(convertProduct(udplatGoodsEntities)); + } + return ResultVOUtils.success(result); + } + + /** + * 查询对照层级为产品的所有规格数据 + * + * @param udplatGoodsEntities + */ + private List getSingleSpecProduct(List udplatGoodsEntities) { + List data = new ArrayList<>(); + for (UdplatGoodsEntity udplatGoodsEntity : udplatGoodsEntities) { + if (udplatGoodsEntity.getMatchLevel().equals(1)) { + //对照层级为产品,调用院内目录查询此产品关联的所有规格型号 + Map params = new TreeMap<>(); + params.put("hospGoodsId", String.valueOf(udplatGoodsEntity.getId())); + params.put("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(); + 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) { + Map map = JSON.parseObject(JSON.toJSONString(o), Map.class); + UdplatGoodsEntity entity = new UdplatGoodsEntity(); + BeanUtil.copyProperties(udplatGoodsEntity, entity); + entity.setSpec(String.valueOf(map.get("spec"))); + entity.setModel(String.valueOf(map.get("model"))); + data.add(entity); + } + } + } + } else { + //单一规格 + data.add(udplatGoodsEntity); + } + } + return data; + } + + @Override + public BaseResponse getOrders(UdiwmsOrderRequest udiwmsOrderRequest) { + return null; + } + + @Override + public BaseResponse getInvProducts(UdiwmsOnhandRequest udiwmsOnhandRequest) { + return null; + } + + /** + * 转换产品数据格式 + * + * @param udplatGoodsEntities + * @return + */ + private List convertProduct(List udplatGoodsEntities) { + List list = new ArrayList<>(udplatGoodsEntities.size()); + for (UdplatGoodsEntity udplatGoodsEntity : udplatGoodsEntities) { + UdiwmsProductInfoResponse productInfoResponse = new UdiwmsProductInfoResponse(); + BeanUtil.copyProperties(udplatGoodsEntity, productInfoResponse); + productInfoResponse.setRegisterNo(udplatGoodsEntity.getRegNum()); + productInfoResponse.setYlqxzcrbarmc(udplatGoodsEntity.getRegName()); + productInfoResponse.setSupName(udplatGoodsEntity.getDistributorName()); + productInfoResponse.setManufactory(udplatGoodsEntity.getManufactureName()); + productInfoResponse.setYbbm(udplatGoodsEntity.getMedicalCode()); + productInfoResponse.setZczyxqz(DateUtil.format(udplatGoodsEntity.getRegValidTo(), "YYYY-MM-dd HH:mm:ss")); + productInfoResponse.setStandard(udplatGoodsEntity.getSpec()); + productInfoResponse.setSpec(udplatGoodsEntity.getSpec() + udplatGoodsEntity.getModel()); + productInfoResponse.setName(udplatGoodsEntity.getProductName()); + list.add(productInfoResponse); + } + return list; + } + + private Map getHeader(Map mapParam) { + Map map = new TreeMap<>(); + String time = String.valueOf(System.currentTimeMillis()); + mapParam.put("time", time); + map.put("appId", udPlatConfig.getAppId()); + map.put("Content-Type", "application/json"); + map.put("userName", udPlatConfig.getUserName()); + map.put("time", time); + map.put("secretKey", udPlatConfig.getSecretKey()); + map.put("sign", getSign(mapParam)); + log.info(map.toString()); + return map; + } + + /** + * 获取签名 + * + * @param mapParam + * @return + */ + private String getSign(Map mapParam) { + TreeMap map = new TreeMap<>(); + map.put("appId", udPlatConfig.getAppId()); + map.put("userName", udPlatConfig.getUserName()); + map.put("secretKey", udPlatConfig.getUdPlatConfig().getSecretKey()); + map.put("time", mapParam.get("time")); + map.putAll(mapParam); + StringBuilder sb = new StringBuilder(); + for (Map.Entry entry : map.entrySet()) { + sb.append(entry.getKey()).append("=").append(entry.getValue()); + sb.append("&"); + } + String str = sb.toString(); + String str0 = str.substring(0, str.length() - 1); + return Md5Utils.stringToMD5(str0); + } + +} diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/config/UdPlatConfig.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/config/UdPlatConfig.java new file mode 100644 index 0000000..7f2a12f --- /dev/null +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/config/UdPlatConfig.java @@ -0,0 +1,60 @@ +package com.glxp.mipsdl.admin.config; + +import com.glxp.mipsdl.admin.dao.config.ThrConfigDao; +import com.glxp.mipsdl.admin.entity.config.ThrPartConfig; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; +import java.net.URLEncoder; + +@Slf4j +@Configuration +public class UdPlatConfig { + + @Autowired + private ThrConfigDao thrConfigDao; + + private ThrPartConfig udPlatConfig; + + @PostConstruct + public void initConfig() { + this.udPlatConfig = thrConfigDao.selectByPartName("udplat"); + } + + public ThrPartConfig getUdPlatConfig() { + return udPlatConfig; + } + + public String getHost() { + return udPlatConfig.getHost(); + } + + public String getAppId() { + return udPlatConfig.getAppId(); + } + + public String getSecretKey() { + return udPlatConfig.getSecretKey(); + } + + /** + * 返回经过编码的用户名 + * + * @return + */ + public String getUserName() { + try { + return URLEncoder.encode(udPlatConfig.getUserName(), "UTF-8"); + } catch (Exception e) { + log.error("用户名编码异常", e); + return ""; + } + } + + public String getPartName() { + return udPlatConfig.getPartName(); + } + +} diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java index d086652..0b12d09 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/controller/UdiWmsController.java @@ -1,5 +1,6 @@ package com.glxp.mipsdl.admin.controller; +import com.glxp.mipsdl.admin.client.http.UdPlatClient; import com.glxp.mipsdl.admin.client.http.YyUCloud31Client; import com.glxp.mipsdl.admin.http.request.USignRequest; import com.glxp.mipsdl.admin.req.*; @@ -23,6 +24,9 @@ public class UdiWmsController { @Resource YyUCloud31Client pzhzdClient; + @Resource + private UdPlatClient udPlatClient; + //获取erp往来单位信息接口 @PostMapping("/udiwms/erp/getUnits") public BaseResponse getUnits(@RequestBody UdiwmsUnitRequest testUnitRequest, @@ -41,7 +45,9 @@ public class UdiWmsController { public BaseResponse getProducts(@RequestBody UdiwmsProductRequest udiwmsProductRequest) { if (curFlag.equals("YONGYOU_U8_V3.1")) { return pzhzdClient.getPrdoucts(udiwmsProductRequest); - } else + } else if (curFlag.equals("YG_UDPLAT_V1.0")){ + return udPlatClient.getPrdoucts(udiwmsProductRequest); + } return ResultVOUtils.error(500, "未设置系统版本!"); } diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/dao/config/ThrConfigDao.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/dao/config/ThrConfigDao.java new file mode 100644 index 0000000..b385547 --- /dev/null +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/dao/config/ThrConfigDao.java @@ -0,0 +1,12 @@ +package com.glxp.mipsdl.admin.dao.config; + +import com.glxp.mipsdl.admin.entity.config.ThrPartConfig; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface ThrConfigDao { + + ThrPartConfig selectByPartName(@Param("partName") String partName); + +} diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/config/ThrPartConfig.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/config/ThrPartConfig.java new file mode 100644 index 0000000..916223e --- /dev/null +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/config/ThrPartConfig.java @@ -0,0 +1,40 @@ +package com.glxp.mipsdl.admin.entity.config; + +import lombok.Data; + +@Data +public class ThrPartConfig { + + private Integer id; + + /** + * 第三方平台标识 / 名称 + */ + private String partName; + + /** + * 服务地址 + */ + private String host; + + /** + * appId + */ + private String appId; + + /** + * 秘钥 + */ + private String secretKey; + + /** + * 用户名 + */ + private String userName; + + /** + * 备注 + */ + private String remark; + +} diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/ygudplat/UdplatGoodsEntity.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/ygudplat/UdplatGoodsEntity.java index a58b15b..6f83b8e 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/ygudplat/UdplatGoodsEntity.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/entity/ygudplat/UdplatGoodsEntity.java @@ -42,4 +42,6 @@ public class UdplatGoodsEntity { private Date createTime;//创建时间 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime;//最后更新时间 + + private Integer matchLevel; //对照层级 1.产品 2.单一规格 } diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsProductRequest.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsProductRequest.java index ba47bb2..57a94f7 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsProductRequest.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/req/UdiwmsProductRequest.java @@ -8,4 +8,71 @@ public class UdiwmsProductRequest extends ListPageRequest{ private String code; //产品编码 private String name; //产品名称 + + //计量单位 + private String measname; + + //规格型号 + private String spec; + + //注册/备案号 + private String registerNo; + + //生产厂家 + private String manufactory; + + //产品类别 + private String cplb; + + //分类编码 + private String flbm; + + //器械类别 + private String qxlb; + + //医保编码 + private String ybbm; + + //商品条码 + private String sptm; + + //注册人社会信用号 + private String tyshxydm; + + //注册证 备案证号 + private String zczbhhzbapzbh; + + //注册/备案人 + private String ylqxzcrbarmc; + + //注册/备案人英文 + private String ylqxzcrbarywmc; + + //产品描述 + private String cpms; + + //型号 + private String model; + + //型号 + private String standard; + + //商品名称 + private String spmc; + + //其他编码 + private String qtbm; + + //注册证有效期至 + private String zczyxqz; + + //备注 + private String remark; + //备注1 + private String remark1; + //备注2 + private String remark2; + //备注3 + private String remark3; + } diff --git a/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsProductInfoResponse.java b/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsProductInfoResponse.java index ec6c4c2..f99081c 100644 --- a/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsProductInfoResponse.java +++ b/api-sync/src/main/java/com/glxp/mipsdl/admin/res/system/UdiwmsProductInfoResponse.java @@ -2,14 +2,74 @@ package com.glxp.mipsdl.admin.res.system; import lombok.Data; +import java.util.Date; + @Data public class UdiwmsProductInfoResponse { private String code; //产品编码 - private String name; + private String name; //通用名称 private String measname; //计量单位 private String spec; //规格型号 private String registerNo; //注册证号 private String manufactory; //生产厂家 private String supName; //配送企业 + + private Date updateTime; + private boolean isChecked; + + //产品类别 + private String cplb; + + //分类编码 + private String flbm; + + //器械类别 + private String qxlb; + + //医保编码 + private String ybbm; + + //商品条码 + private String sptm; + + //注册人社会信用号 + private String tyshxydm; + + //注册证 备案证号 + private String zczbhhzbapzbh; + + //注册/备案人 + private String ylqxzcrbarmc; + + //注册/备案人英文 + private String ylqxzcrbarywmc; + + //产品描述 + private String cpms; + + //型号 + private String model; + + //型号 + private String standard; + + //商品名称 + private String spmc; + + //其他编码 + private String qtbm; + + //注册证有效期至 + private String zczyxqz; + + //备注 + private String remark; + //备注1 + private String remark1; + //备注2 + private String remark2; + //备注3 + private String remark3; + } diff --git a/api-sync/src/main/resources/mybatis/mapper/config/ThrPartConfigDao.xml b/api-sync/src/main/resources/mybatis/mapper/config/ThrPartConfigDao.xml new file mode 100644 index 0000000..d8a45f6 --- /dev/null +++ b/api-sync/src/main/resources/mybatis/mapper/config/ThrPartConfigDao.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file