调整+平潭协和B003对接

dev
wj 2 years ago
parent d7b1fd573c
commit 2baa1e5d1e

@ -1,7 +1,9 @@
package com.glxp.mipsdl.client.ptxhyy;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.ConstantType;
@ -12,34 +14,40 @@ import com.glxp.mipsdl.dao.basic.BasicCorpDao;
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.ThrBustypeOriginDao;
import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.mipsdl.dao.thrsys.ThrProductsDao;
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
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.inout.IoOrderInvoiceEntity;
import com.glxp.mipsdl.entity.thrsys.ThrCorpEntity;
import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.base.UdiwmsOrderDetailRequest;
import com.glxp.mipsdl.req.base.UdiwmsOrderRequest;
import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderDetailRequest;
import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderRequest;
import com.glxp.mipsdl.res.BaseResponse;
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.ResultVOUtils;
import com.glxp.mipsdl.util.SubmitOrderUtil;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -63,6 +71,7 @@ public class PtxhyyClient extends CommonHttpClient {
private final IoCodeDao codeDao;
private final IoOrderDetailBizDao orderDetailBizDao;
private final SubmitOrderUtil submitOrderUtil;
private final ThrProductsDao thrProductsDao;
@Override
public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) {
@ -160,15 +169,62 @@ public class PtxhyyClient extends CommonHttpClient {
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
//单据金额
BigDecimal djje = detailBizEntities.stream().map(IoOrderDetailBizEntity::getPrice).reduce(BigDecimal.ONE, BigDecimal::add);
List<IoOrderInvoiceEntity> ioOrderInvoiceEntities = IoOrderInvoiceEntity.builder().build().selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getId()));
PtxhyyOrderRequest ptxhyyOrderRequest = PtxhyyOrderRequest
.builder()
.kfxh(udiwmsOrderRequest.getLocInvCode())
.lzdh(udiwmsOrderRequest.getBillNo())
.czgh("udi_" + orderEntity.getCreateUser())
.lzfs(udiwmsOrderRequest.getBillType())
.dwxh(udiwmsOrderRequest.getCorpId())
.rkrq(LocalDate.parse(udiwmsOrderRequest.getBillDate()))
.djje(djje)
.fpbz(CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) && ioOrderInvoiceEntities.size() > 0)
.zdrq(LocalDateTime.parse(udiwmsOrderRequest.getBillDate()))
.lsje(djje)
.fpzs(CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) ? ioOrderInvoiceEntities.size() : 0)
.udixh(udiwmsOrderRequest.getBillNo())
.build();
setOrderDetailList(ioCodeEntities, items, detailBizEntities);
Collections.reverse(items);
//云霄使用items字段其他医院使用item字段
udiwmsOrderRequest.setItem(items);
for (UdiwmsOrderDetailRequest i : items) {
String udim = "";
if (CollectionUtil.isNotEmpty(i.getCodeList())) {
udim = i.getCodeList().stream().map(UdiwmsOrderDetailRequest.CodeDetailEntity::getCode).collect(Collectors.joining(","));
}
String fphm = "";
LocalDateTime fprq = null;
if (CollectionUtil.isNotEmpty(ioOrderInvoiceEntities)) {
List<IoOrderInvoiceEntity> invoiceList = ioOrderInvoiceEntities.stream().filter(s -> i.getBindRlFk().equals(s.getBindRlFk()) && i.getBatchNo().equals(s.getBatchNo()))
.sorted(Comparator.comparing(IoOrderInvoiceEntity::getInvoiceDate, Comparator.reverseOrder())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(invoiceList)) {
fphm = invoiceList.stream().map(IoOrderInvoiceEntity::getInvoiceCode).collect(Collectors.joining(","));
fprq = LocalDateTime.parse(DateUtil.formatDateTime(invoiceList.get(0).getInvoiceDate()));
ioOrderInvoiceEntities.removeAll(invoiceList);
}
}
PtxhyyOrderDetailRequest detailRequest = PtxhyyOrderDetailRequest.builder()
.wzxh(i.getProductId())
.cjxh(i.getSupCode())
.bzdw(i.getMeasname())
.bzsl(i.getCount())
.wzjg(i.getPrice())
.lsje(i.getPrice())
.udim(udim)
.hsfl(i.getManufactoryCode())
.wzph(i.getBatchNo())
.fphm(fphm)
.fprq(fprq)
.build();
ptxhyyOrderRequest.getDetailList().add(detailRequest);
}
return submitOrderUtil.submitOrder(orderEntity, udiwmsOrderRequest);
return submitOrderUtil.submitOrder(orderEntity, ptxhyyOrderRequest);
}
/**

@ -0,0 +1,9 @@
package com.glxp.mipsdl.dao.inout;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.mipsdl.entity.inout.IoOrderInvoiceEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface IoOrderInvoiceDao extends BaseMapper<IoOrderInvoiceEntity> {
}

@ -0,0 +1,123 @@
package com.glxp.mipsdl.entity.inout;
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 com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "io_order_invoice")
public class IoOrderInvoiceEntity extends Model<IoOrderInvoiceEntity> {
@TableId(value = "id", type = IdType.INPUT)
private Long id;
/**
*
*/
@TableField(value = "orderIdFk")
private String orderIdFk;
/**
*
*/
@TableField(value = "machineNo")
private String machineNo;
/**
*
*/
@TableField(value = "invoiceCode")
private String invoiceCode;
/**
*
*/
@TableField(value = "invoiceEncode")
private String invoiceEncode;
/**
*
*/
@TableField(value = "invoiceDate")
private Date invoiceDate;
/**
*
*/
@TableField(value = "price")
private String price;
/**
*
*/
@TableField(value = "updateTime")
private Date updateTime;
/**
*
*/
@TableField(value = "`createUser`")
private String createUser;
/**
*
*/
@TableField(value = "createTime")
private Date createTime;
/**
*
*/
@TableField(value = "updateUser")
private String updateUser;
@TableField(value = "bindRlFk")
private String bindRlFk;
/**
*
*/
@TableField(value = "batchNo")
private String batchNo;
/**
*
*/
@TableField(value = "productDate")
private String productDate;
/**
*
*/
@TableField(value = "expireDate")
private String expireDate;
@TableField(value = "licenseUrl")
private String licenseUrl;
@TableField(value = "remark")
private String remark;
@TableField(value = "bizIdFk")
private Long bizIdFk;
@TableField(exist = false)
private Integer regId;
@TableField(exist = false)
private List<IoOrderDetailBizEntity> list;
}

@ -4,13 +4,14 @@ 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 com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import java.util.Date;
@Data
@TableName(value = "thr_products")
public class ThrProductsEntity {
public class ThrProductsEntity extends Model<ThrProductsEntity> {
@TableId(value = "id", type = IdType.INPUT)
private Long id;
@ -195,4 +196,16 @@ public class ThrProductsEntity {
@TableField(value = "updateUser")
private String updateUser;
/**
*
*/
@TableField("manufactoryCode")
private String manufactoryCode;
/**
*
*/
@TableField("supCode")
private String supCode;
}

@ -1,5 +1,6 @@
package com.glxp.mipsdl.req.base;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.math.BigDecimal;
@ -21,6 +22,11 @@ public class UdiwmsOrderDetailRequest {
*/
private String productName;
/**
* ID
*/
private String bindRlFk;
/**
*
*/
@ -121,6 +127,18 @@ public class UdiwmsOrderDetailRequest {
*/
private String serialNo;
/**
*
*/
private String manufactoryCode;
/**
*
*/
private String supCode;
/**
*
*/

@ -0,0 +1,85 @@
package com.glxp.mipsdl.req.ptxhyy;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
*
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PtxhyyOrderDetailRequest {
/**
*
*/
// private String djxh;
/**
*
*/
private String wzxh;
/**
*
*/
private String cjxh;
/**
*
*/
private String bzdw;
/**
*
*/
private Integer bzsl;
/**
*
*/
private BigDecimal wzjg;
/**
*
*/
private BigDecimal lsje;
/**
*
*/
private LocalDate djrq;
/**
* UDI
*/
private String udim;
/**
*
*/
private String hsfl;
/**
*
*/
private String wzph;
/**
*
*/
private String fphm;
/**
*
*/
private LocalDateTime fprq;
}

@ -0,0 +1,89 @@
package com.glxp.mipsdl.req.ptxhyy;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PtxhyyOrderRequest {
/**
*
*/
private String kfxh;
/**
* 簿 default:1
*/
private final Integer zblb = 1;
/**
*
*/
private String lzdh;
/**
*
*/
private String czgh;
/**
*
*/
private String lzfs;
/**
*
*/
private String dwxh;
/**
*
*/
private LocalDate rkrq;
/**
*
*/
private BigDecimal djje;
/**
* 0 1
*/
private boolean fpbz;
/**
*
*/
private LocalDateTime zdrq;
/**
*
*/
private BigDecimal lsje;
/**
*
*/
private Integer fpzs;
/**
* UDI
*/
private String udixh;
private List<PtxhyyOrderDetailRequest> detailList = new ArrayList<>(100);
}

@ -5,7 +5,7 @@ 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.Constants;
import com.glxp.mipsdl.dao.basic.BasicProductsDao;
@ -22,7 +22,6 @@ import com.glxp.mipsdl.entity.inout.IoOrderUploadLogEntity;
import com.glxp.mipsdl.entity.thrsys.ThrProductsEntity;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.UdiwmsOrderDetailRequest;
import com.glxp.mipsdl.req.base.UdiwmsOrderRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import lombok.extern.slf4j.Slf4j;
@ -106,7 +105,7 @@ public class SubmitOrderUtil {
public UdiwmsOrderDetailRequest buildProductInfo(IoOrderDetailBizEntity detailBizEntity) {
//查询产品信息
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(detailBizEntity.getBindRlFk());
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new QueryWrapper<BasicProductsEntity>().eq("uuid", basicUdirel.getUuid()));
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()));
UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest();
BeanUtil.copyProperties(detailBizEntity, item);
@ -117,16 +116,19 @@ public class SubmitOrderUtil {
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
item.setProductId(thirdProductId); //产品ID
//查询第三方产品名称
ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new QueryWrapper<ThrProductsEntity>()
.eq("code", thirdProductId));
ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new LambdaQueryWrapper<ThrProductsEntity>()
.eq(ThrProductsEntity::getCode, thirdProductId));
item.setProductName(thrProductsEntity.getName()); //产品名称
item.setBindRlFk(detailBizEntity.getBindRlFk());
item.setStandard(detailBizEntity.getSpec()); //规格型号
item.setBillNo(detailBizEntity.getOrderIdFk()); //单据号
item.setRegisterNo(basicProducts.getZczbhhzbapzbh()); //注册/备案证号
item.setManufactory(basicProducts.getManufactory()); //生产厂家
item.setMeasname(basicProducts.getMeasname()); //计量单位
item.setAllowNoBatch(basicProducts.getAllowNoBatch()); //是否允许无批次号
item.setManufactoryCode(thrProductsEntity.getManufactoryCode());
item.setSupCode(thrProductsEntity.getSupCode());
return item;
}
@ -137,7 +139,7 @@ public class SubmitOrderUtil {
* @param udiwmsOrderRequest
* @return
*/
public BaseResponse submitOrder(IoOrderEntity orderEntity, UdiwmsOrderRequest udiwmsOrderRequest) {
public BaseResponse submitOrder(IoOrderEntity orderEntity, Object udiwmsOrderRequest) {
//记录日志
IoOrderUploadLogEntity uploadLog = new IoOrderUploadLogEntity();
uploadLog.setBillDate(orderEntity.getCreateTime());

Loading…
Cancel
Save