|
|
|
@ -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,6 +103,17 @@ public class PtxhyyClient extends CommonHttpClient {
|
|
|
|
|
String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp());
|
|
|
|
|
udiwmsOrderRequest.setCorpName(corpName);
|
|
|
|
|
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) {
|
|
|
|
|
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<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, udiwmsOrderRequest.getCorpId()));
|
|
|
|
|
try {
|
|
|
|
@ -112,6 +128,7 @@ public class PtxhyyClient extends CommonHttpClient {
|
|
|
|
|
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<IoOrderInvoiceEntity> 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<AuthWarehouseUser> authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper<AuthWarehouseUser>().eq("code", orderEntity.getInvCode()));
|
|
|
|
|
if (CollUtil.isNotEmpty(authWarehouseUsers)) {
|
|
|
|
|
return authWarehouseUsers.get(0).getUserName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|