bug修改,新增HIS系统接口对接

dev
anthonywj 2 years ago
parent 930732061e
commit 3137bb980b

@ -146,30 +146,17 @@ public class PtxhyyClient extends CommonHttpClient {
//查询仓库信息
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode()));
try {
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
List<ThrInvWarehouseEntity> thrInvWarehouseEntitys = thrInvWarehouseDao.selectList(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
udiwmsOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
udiwmsOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
// udiwmsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
// udiwmsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
if (CollUtil.isNotEmpty(thrInvWarehouseEntitys)) {
udiwmsOrderRequest.setLocInvCode(thrInvWarehouseEntitys.get(0).getCode());
udiwmsOrderRequest.setLocInvName(thrInvWarehouseEntitys.get(0).getName());
}
} catch (Exception e) {
log.info("查询第三方系统仓库信息异常", e);
return ResultVOUtils.error(500, "查询第三方系统仓库信息异常");
}
// if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) {
// udiwmsOrderRequest.setCorpId(udiwmsOrderRequest.getLocStorageCode());
// udiwmsOrderRequest.setCorpName(udiwmsOrderRequest.getLocStorageName());
//
// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, "29")
// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
// udiwmsOrderRequest.setLocStorageCode("29");
// udiwmsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
// }
udiwmsOrderRequest.setBillFlag("1");
//设置单据出入库类型
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
@ -246,7 +233,7 @@ public class PtxhyyClient extends CommonHttpClient {
.wzph(i.getBatchNo())
.fphm(fphm)
.fprq(fprq)
.djrq(DateUtil.formatDate(orderEntity.getCreateTime(),"yyyy-MM-dd"))
.djrq(DateUtil.formatDate(orderEntity.getCreateTime(), "yyyy-MM-dd"))
.build();
ptxhyyOrderRequest.getDetailList().add(detailRequest);
}

@ -1,21 +1,50 @@
package com.glxp.mipsdl.client.ptxhyy;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.glxp.mipsdl.client.BaseHttpClient;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.client.ptxhyy.entity.HisFyRequest;
import com.glxp.mipsdl.client.ptxhyy.entity.HisProductEntity;
import com.glxp.mipsdl.client.ptxhyy.entity.PostHisDetailRequest;
import com.glxp.mipsdl.client.ptxhyy.entity.PostHisRequest;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.Constants;
import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao;
import com.glxp.mipsdl.dao.basic.BasicProductsDao;
import com.glxp.mipsdl.dao.basic.BasicUdirelDao;
import com.glxp.mipsdl.dao.inout.IoCodeDao;
import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao;
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
import com.glxp.mipsdl.entity.basic.BasicProductsEntity;
import com.glxp.mipsdl.entity.basic.BasicUdirelEntity;
import com.glxp.mipsdl.entity.inout.IoCodeEntity;
import com.glxp.mipsdl.entity.inout.IoOrderDetailBizEntity;
import com.glxp.mipsdl.entity.inout.IoOrderEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.post.PostFileThrOrderRequest;
import com.glxp.mipsdl.req.post.PostThrCorpRequest;
import com.glxp.mipsdl.req.post.PostThrInvProductsRequest;
import com.glxp.mipsdl.req.post.PostThrProductsRequest;
import com.glxp.mipsdl.req.base.UdiwmsOrderRequest;
import com.glxp.mipsdl.req.base.UdiwmsProductRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.PageSimpleResponse;
import com.glxp.mipsdl.res.udiwms.ThrProductsResponse;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.util.DateUtil;
import com.glxp.mipsdl.util.ResultVOUtils;
import com.glxp.mipsdl.util.SubmitOrderUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -29,10 +58,116 @@ public class PtxhyyHisClient extends CommonHttpClient {
private HttpClient httpClient;
@Resource
private ThirdSysConfig thirdSysConfig;
@Autowired
private ThrSystemDetailService thrSystemDetailService;
@Override
public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) {
HisFyRequest hisFyRequest = new HisFyRequest();
hisFyRequest.setFyxh(udiwmsProductRequest.getCode());
hisFyRequest.setFymc(udiwmsProductRequest.getName());
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), hisFyRequest);
BaseResponse<PageSimpleResponse<HisProductEntity>> baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<HisProductEntity>>>() {
});
List<ThrProductsResponse> thrProductsResponses = new ArrayList<>();
List<HisProductEntity> hisProductEntities = baseResponse.getData().getList();
if (CollUtil.isNotEmpty(hisProductEntities)) {
for (HisProductEntity hisProductEntity : hisProductEntities) {
ThrProductsResponse thrProductsResponse = new ThrProductsResponse();
thrProductsResponse.setCode(hisProductEntity.getFyxh());
thrProductsResponse.setName(hisProductEntity.getFymc());
thrProductsResponse.setFlbm(hisProductEntity.getFygb());
thrProductsResponse.setPrice(hisProductEntity.getFydj());
thrProductsResponse.setQtbm(hisProductEntity.getSm());
thrProductsResponse.setCpms(hisProductEntity.getSfmc());
thrProductsResponse.setMeasname(hisProductEntity.getFydw());
thrProductsResponses.add(thrProductsResponse);
}
}
PageSimpleResponse<ThrProductsResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setList(thrProductsResponses);
pageSimpleResponse.setTotal(-666l); //表示全量下载
return ResultVOUtils.success(pageSimpleResponse);
}
@Resource
private IoOrderDao orderDao;
@Resource
private ThrSystemBusApiDao thrSystemBusApiDao;
@Resource
private BasicBussinessTypeDao basicBussinessTypeDao;
@Resource
private IoCodeDao codeDao;
@Resource
private IoOrderDetailBizDao orderDetailBizDao;
@Resource
private BasicUdirelDao basicUdirelDao;
@Resource
private BasicProductsDao basicProductsDao;
@Resource
private SubmitOrderUtil submitOrderUtil;
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
return null;
if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) {
return ResultVOUtils.error(500, "单据号不能为空");
}
//查询单据和详情信息,组装第三方系统接口参数
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()));
udiwmsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
//查询对应的第三方单据类型
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper<ThrSystemBusApiEntity>().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType()));
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
return ResultVOUtils.error(500, "接口未配置,无法提交!");
}
PostHisRequest postHisRequest = new PostHisRequest();
//查询单据类型,设置往来单位信息
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction());
if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) {
//医院客户
postHisRequest.setZyh(orderEntity.getFromCorp());
} else {
return ResultVOUtils.error(500, "非使用出库单据");
}
//组装单据明细数据
List<IoCodeEntity> ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper<IoCodeEntity>()
.eq(IoCodeEntity::getOrderId, orderEntity.getBillNo())
);
List<PostHisDetailRequest> items = new ArrayList<>();
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
for (IoOrderDetailBizEntity orderDetailBizEntity : detailBizEntities) {
List<IoCodeEntity> codeEntities = filterCodes(orderDetailBizEntity, ioCodeEntities);
String udibm = codeEntities.stream().map(IoCodeEntity::getCode).collect(Collectors.joining(","));
PostHisDetailRequest postHisDetailRequest = new PostHisDetailRequest();
postHisDetailRequest.setUdibm(udibm);
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(orderDetailBizEntity.getBindRlFk());
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()));
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
postHisDetailRequest.setYldj(basicProducts.getPrice() + "");
postHisDetailRequest.setYlsl(orderDetailBizEntity.getReCount() + "");
postHisDetailRequest.setYlxh(thirdProductId);
items.add(postHisDetailRequest);
}
postHisRequest.setDetailList(items);
return submitOrderUtil.submitOrder(orderEntity, postHisRequest);
}
public List<IoCodeEntity> filterCodes(IoOrderDetailBizEntity orderDetailBizEntity, List<IoCodeEntity> codeEntities) {
List<IoCodeEntity> result = new ArrayList<>();
if (CollUtil.isNotEmpty(codeEntities)) {
for (IoCodeEntity codeEntity : codeEntities) {
if ((codeEntity.getRelId() + "").equals(orderDetailBizEntity.getBindRlFk())
&& StrUtil.trimToEmpty(codeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(orderDetailBizEntity.getBatchNo()))) {
result.add(codeEntity);
}
}
}
return result;
}
}

@ -0,0 +1,13 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class HisFyRequest {
private String fyxh;
private String fymc;
private String fygb;
private String sm;
}

@ -0,0 +1,19 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class HisProductEntity {
//费用序号
private String fyxh;
//费用单位
private String fydw;
//费用名称
private String fymc;
//费用单价
private String fydj;
private String sm;
private String sfmc;
private String fygb;
}

@ -0,0 +1,16 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
@Data
public class PostHisDetailRequest {
// 费用序号
private String ylxh;
// 单价
private String yldj;
// 数量
private String ylsl;
// UDI编码
private String udibm;
}

@ -0,0 +1,12 @@
package com.glxp.mipsdl.client.ptxhyy.entity;
import lombok.Data;
import java.util.List;
@Data
public class PostHisRequest {
private String zyh;
private List<PostHisDetailRequest> detailList;
}

@ -0,0 +1,7 @@
package com.glxp.mipsdl.dao.auth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.mipsdl.entity.auth.AuthWarehouseUser;
public interface AuthWarehouseUserMapper extends BaseMapper<AuthWarehouseUser> {
}

@ -0,0 +1,42 @@
package com.glxp.mipsdl.entity.auth;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Data;
/**
* -
*/
@Data
@TableName(value = "auth_warehouse_user")
public class AuthWarehouseUser {
@TableId(value = "id", type = IdType.INPUT)
private Long id;
/**
*
*/
@TableField(value = "code")
private String code;
/**
* id
*/
@TableField(value = "userId")
private Long userId;
/**
* /
*/
@TableField(value = "userName")
private String userName;
@TableField(value = "isDirector")
private Byte isDirector;
@TableField(value = "updateTime")
private Date updateTime;
}

@ -0,0 +1,53 @@
package com.glxp.mipsdl.res.udiwms;
import lombok.Data;
import java.util.Date;
@Data
public class ThrProductsResponse {
private Long id;
private String code; //产品编码
private String name;
private String measname; //计量单位
private String spec; //规格型号
private String registerNo; //注册证号
private String thirdSysFk;
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 supName; //配送企业
private String thirdSysName;
//辅助字段
private boolean isChecked;
private String thirdSys;
//添加字段
private String model; //型号
private String standard; //规格型号,二合一字段
private String qtbm; //其他编码
private String zczyxqz; //注册有效期截止时间
private String price;
private String remark1; //备注1
private String remark2; //备注2
private String remark3; //备注3
private String createUser;
private Date createTime;
private String updateUser;
private Date updateTime;
private String remark;
private String manufactoryCode;
private String supCode;
}

@ -67,7 +67,7 @@ public class SubmitOrderUtil {
List<IoCodeEntity> result = new ArrayList<>();
if (CollUtil.isNotEmpty(codeEntities)) {
for (IoCodeEntity codeEntity : codeEntities) {
if (codeEntity.getRelId().equals(orderDetailBizEntity.getBindRlFk())
if ((codeEntity.getRelId() + "").equals(orderDetailBizEntity.getBindRlFk())
&& StrUtil.trimToEmpty(codeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(orderDetailBizEntity.getBatchNo()))) {
result.add(codeEntity);
}

@ -1,9 +1,9 @@
spring:
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://192.168.0.66:3364/udi_wms_wmd?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: Glxp@6066
password: 123456
hikari:
connection-timeout: 60000
maximum-pool-size: 60

@ -16,8 +16,8 @@ server:
# min-spare: 10
#第三方系统标识
THIRD_ID: thirdId2
THIRD_NAME: thirdName2
THIRD_ID: thirdId
THIRD_NAME: thirdName
#UDI管理系统地址
UDIWMS_IP: http://127.0.0.1:9991

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper">
<resultMap id="BaseResultMap" type="com.glxp.mipsdl.entity.auth.AuthWarehouseUser">
<!--@mbg.generated-->
<!--@Table auth_warehouse_user-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="userId" jdbcType="BIGINT" property="userId" />
<result column="userName" jdbcType="VARCHAR" property="userName" />
<result column="isDirector" jdbcType="TINYINT" property="isDirector" />
<result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, code, userId, userName, isDirector, updateTime
</sql>
</mapper>
Loading…
Cancel
Save