diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java index c95f306..acbaf97 100644 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java +++ b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java @@ -1,5 +1,6 @@ package com.glxp.mipsdl.client.ptxhyy; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -9,6 +10,7 @@ import com.glxp.mipsdl.client.CommonHttpClient; import com.glxp.mipsdl.config.ThirdSysConfig; import com.glxp.mipsdl.constant.ConstantType; import com.glxp.mipsdl.constant.Constants; +import com.glxp.mipsdl.dao.auth.AuthUserDao; import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao; import com.glxp.mipsdl.dao.basic.BasicCorpDao; @@ -18,14 +20,16 @@ import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao; 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.AuthUserEntity; import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity; +import com.glxp.mipsdl.entity.auth.AuthWarehouseUser; +import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper; import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity; import com.glxp.mipsdl.entity.basic.BasicCorpEntity; 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.req.base.UdiwmsOrderDetailRequest; @@ -42,6 +46,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; @@ -98,19 +103,31 @@ public class PtxhyyClient extends CommonHttpClient { String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); udiwmsOrderRequest.setCorpName(corpName); } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { - //内部科室 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper().eq(AuthWarehouseEntity::getCode, udiwmsOrderRequest.getCorpId())); - try { - //根据第三方系统标识,获取对应字段的值 - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - udiwmsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); - udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - String msg = "查询单据对应往来单位的第三方仓库信息异常"; - log.error(msg, e); - return ResultVOUtils.error(500, msg); + if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { + BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); + if (null != basicCorpEntity) { + udiwmsOrderRequest.setCorpId(basicCorpEntity.getThirdId()); + udiwmsOrderRequest.setCorpName(basicCorpEntity.getName()); + } else { + String msg = "查询单据对应的第三方往来单位信息异常"; + log.error(msg); + return ResultVOUtils.error(500, msg); + } + } else { + //内部科室 + AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper().eq(AuthWarehouseEntity::getCode, udiwmsOrderRequest.getCorpId())); + try { + //根据第三方系统标识,获取对应字段的值 + ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() + .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) + .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); + udiwmsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); + udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); + } catch (Exception e) { + String msg = "查询单据对应往来单位的第三方仓库信息异常"; + log.error(msg, e); + return ResultVOUtils.error(500, msg); + } } } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) { //供应商 @@ -140,6 +157,7 @@ public class PtxhyyClient extends CommonHttpClient { // udiwmsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); } catch (Exception e) { log.info("查询第三方系统仓库信息异常", e); + return ResultVOUtils.error(500, "查询第三方系统仓库信息异常"); } // if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) { @@ -175,17 +193,22 @@ public class PtxhyyClient extends CommonHttpClient { //单据金额 BigDecimal djje = detailBizEntities.stream().map(IoOrderDetailBizEntity::getPrice).reduce(BigDecimal.ONE, BigDecimal::add); List ioOrderInvoiceEntities = IoOrderInvoiceEntity.builder().build().selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getId())); + + String userName = getUserName(orderEntity); + if (StrUtil.isEmpty(userName)) { + return ResultVOUtils.error(500, "该单据无创建人!"); + } PtxhyyOrderRequest ptxhyyOrderRequest = PtxhyyOrderRequest .builder() .kfxh(udiwmsOrderRequest.getLocInvCode()) .lzdh(udiwmsOrderRequest.getBillNo()) - .czgh("udi_" + orderEntity.getCreateUser()) + .czgh(userName) .lzfs(udiwmsOrderRequest.getBillType()) .dwxh(udiwmsOrderRequest.getCorpId()) .rkrq(LocalDate.from(cn.hutool.core.date.DateUtil.parseLocalDateTime(udiwmsOrderRequest.getBillDate()))) .djje(djje) .fpbz(CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) && ioOrderInvoiceEntities.size() > 0) - .zdrq(cn.hutool.core.date.DateUtil.parseLocalDateTime(udiwmsOrderRequest.getBillDate())) + .zdrq(udiwmsOrderRequest.getBillDate()) .lsje(djje) .fpzs(CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) ? ioOrderInvoiceEntities.size() : 0) .udixh(udiwmsOrderRequest.getBillNo()) @@ -213,16 +236,17 @@ public class PtxhyyClient extends CommonHttpClient { } PtxhyyOrderDetailRequest detailRequest = PtxhyyOrderDetailRequest.builder() .wzxh(i.getProductId()) - .cjxh(i.getSupCode()) + .cjxh(i.getManufactoryCode()) .bzdw(i.getMeasname()) .bzsl(i.getCount()) .wzjg(i.getPrice()) .lsje(i.getPrice()) .udim(udim) - .hsfl(i.getManufactoryCode()) + .hsfl(i.getCplb()) .wzph(i.getBatchNo()) .fphm(fphm) .fprq(fprq) + .djrq(DateUtil.formatDate(orderEntity.getCreateTime(),"yyyy-MM-dd")) .build(); ptxhyyOrderRequest.getDetailList().add(detailRequest); } @@ -246,4 +270,30 @@ public class PtxhyyClient extends CommonHttpClient { } } + @Resource + AuthUserDao authUserDao; + @Resource + AuthWarehouseUserMapper authWarehouseUserMapper; + + public String getUserName(IoOrderEntity orderEntity) { + + //创建人非供应商 + if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) { + AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser()); + return authUserEntity.getUserName(); + } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) { + AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser()); + return authUserEntity.getUserName(); + } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { + AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); + return authUserEntity.getUserName(); + } else { + List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); + if (CollUtil.isNotEmpty(authWarehouseUsers)) { + return authWarehouseUsers.get(0).getUserName(); + } + } + return null; + } + } diff --git a/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java b/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java index a276832..3a5128e 100644 --- a/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java +++ b/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java @@ -128,7 +128,6 @@ public class UdiwmsOrderDetailRequest { private String serialNo; - /** * 生产厂家编码 */ @@ -139,6 +138,8 @@ public class UdiwmsOrderDetailRequest { */ private String supCode; + private String cplb; + /** * 码明细 */ diff --git a/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderDetailRequest.java b/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderDetailRequest.java index 98c3806..1824e89 100644 --- a/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderDetailRequest.java +++ b/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderDetailRequest.java @@ -48,15 +48,18 @@ public class PtxhyyOrderDetailRequest { */ private BigDecimal wzjg; + private String wzje; + /** * 零售金额 */ private BigDecimal lsje; + private String lsjg; /** * 单据日期 */ - private LocalDate djrq; + private String djrq; /** * UDI追溯码 @@ -82,4 +85,6 @@ public class PtxhyyOrderDetailRequest { * 发票日期 */ private LocalDateTime fprq; + + private String mjph; } diff --git a/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderRequest.java b/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderRequest.java index 10a3314..b2c2ad3 100644 --- a/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderRequest.java +++ b/src/main/java/com/glxp/mipsdl/req/ptxhyy/PtxhyyOrderRequest.java @@ -68,7 +68,7 @@ public class PtxhyyOrderRequest { /** * 制单日期 */ - private LocalDateTime zdrq; + private String zdrq; /** * 零售金额 diff --git a/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java b/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java index c40b676..8d53512 100644 --- a/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java +++ b/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java @@ -129,6 +129,7 @@ public class SubmitOrderUtil { item.setAllowNoBatch(basicProducts.getAllowNoBatch()); //是否允许无批次号 item.setManufactoryCode(thrProductsEntity.getManufactoryCode()); item.setSupCode(thrProductsEntity.getSupCode()); + item.setCplb(thrProductsEntity.getFlbm()); return item; }