东山接口修改

dev
anthonywj 1 year ago
parent 2cff973619
commit 5c78d40d19

@ -52,6 +52,7 @@ import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.res.ctqyy.CtBaseResponse;
import com.glxp.mipsdl.res.udiwms.*;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.order.OrderUploadLogService;
import com.glxp.mipsdl.service.system.SysParamConfigService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
@ -119,6 +120,8 @@ public class CtqyyClient extends CommonHttpClient {
BasicUdirelDao basicUdirelDao;
@Resource
BasicProductsDao basicProductsDao;
@Resource
private OrderUploadLogService orderUploadLogService;
/**
* xml
@ -491,7 +494,10 @@ public class CtqyyClient extends CommonHttpClient {
zaxzyyOrderRequest.setCorpId(thrInvWarehouseEntity.getCode());
zaxzyyOrderRequest.setCorpName(thrInvWarehouseEntity.getName());
} catch (Exception e) {
log.error("查询单据对应往来单位的第三方仓库信息异常", e);
String msg = "查询单据对应往来单位的第三方仓库信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
@ -505,7 +511,10 @@ public class CtqyyClient extends CommonHttpClient {
zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId());
zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
log.error("查询单据对应的第三方往来单位信息异常");
String msg = "查询单据对应的第三方往来单位信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}

@ -1,11 +1,13 @@
package com.glxp.mipsdl.client.dsxyy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.mipsdl.client.BaseHttpClient;
import com.glxp.mipsdl.client.CommonHttpClient;
import com.glxp.mipsdl.config.ThirdSysConfig;
@ -20,22 +22,18 @@ 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.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.dao.thrsys.*;
import com.glxp.mipsdl.entity.auth.AuthUserEntity;
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
import com.glxp.mipsdl.entity.basic.BasicCorpEntity;
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.ThrCorpEntity;
import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.mipsdl.entity.thrsys.ThrProductsEntity;
import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity;
import com.glxp.mipsdl.entity.inout.IoOrderInvoiceEntity;
import com.glxp.mipsdl.entity.thrsys.*;
import com.glxp.mipsdl.http.HttpClient;
import com.glxp.mipsdl.req.base.*;
import com.glxp.mipsdl.req.dsxyy.DsBusTypeRequest;
@ -48,6 +46,7 @@ import com.glxp.mipsdl.req.post.PostThrInvProductsRequest;
import com.glxp.mipsdl.req.post.PostThrProductsRequest;
import com.glxp.mipsdl.res.BaseResponse;
import com.glxp.mipsdl.service.auth.AuthWarehouseService;
import com.glxp.mipsdl.service.order.OrderUploadLogService;
import com.glxp.mipsdl.service.thrsys.ThrCorpService;
import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService;
import com.glxp.mipsdl.util.*;
@ -59,6 +58,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
*
@ -105,6 +105,10 @@ public class DsxyyClient extends CommonHttpClient {
private BasicProductsDao basicProductsDao;
@Resource
private ThrProductsDao thrProductsDao;
@Resource
private OrderUploadLogService orderUploadLogService;
@Resource
private ThrOrderUploadBustypesMapper thrOrderUploadBustypesMapper;
@Override
public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) {
@ -157,16 +161,20 @@ public class DsxyyClient extends CommonHttpClient {
//查询单据和详情信息,组装第三方系统接口参数
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()).last("limit 1"));
dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
if (orderEntity.getAuditTime() == null)
dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
else {
dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getAuditTime()));
}
//设置操作人
if (orderEntity.getReviewUser() != null) {
AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getReviewUser());
udiwmsOrderRequest.setOperUser(authAdmin.getUserName());
dsOrderRequest.setOperUser(authAdmin.getUserName());
} else if (orderEntity.getCreateUser() != null) {
AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getCreateUser());
udiwmsOrderRequest.setOperUser(authAdmin.getUserName());
dsOrderRequest.setOperUser(authAdmin.getUserName());
}
//查询对应的第三方单据类型
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper<ThrSystemBusApiEntity>().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType()));
@ -176,11 +184,11 @@ public class DsxyyClient extends CommonHttpClient {
dsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode());
if (orderEntity.getInvCode().equals("1000000")) {
udiwmsOrderRequest.setLocInvCode("1161");
udiwmsOrderRequest.setLocInvName("设备科");
dsOrderRequest.setLocInvCode("1161");
dsOrderRequest.setLocInvName("设备科");
} else {
udiwmsOrderRequest.setLocInvCode("4050");
udiwmsOrderRequest.setLocInvName("西药库");
dsOrderRequest.setLocInvCode("4050");
dsOrderRequest.setLocInvName("西药库");
}
@ -193,27 +201,44 @@ public class DsxyyClient extends CommonHttpClient {
String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp());
dsOrderRequest.setCorpName(corpName);
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) {
//内部科室
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, udiwmsOrderRequest.getCorpId()));
try {
//根据第三方系统标识,获取对应字段的值
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
dsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode());
dsOrderRequest.setCorpName(thrInvWarehouseEntity.getName());
} catch (Exception e) {
log.error("查询单据对应往来单位的第三方仓库信息异常", e);
BasicCorpEntity basicCorpEntity = null;
if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) {
basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
}
if (basicCorpEntity != null) {
dsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
dsOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper<AuthWarehouseEntity>().eq("code", udiwmsOrderRequest.getCorpId()));
try {
//根据第三方系统标识,获取对应字段的值
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
dsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode());
dsOrderRequest.setCorpName(thrInvWarehouseEntity.getName());
} catch (Exception e) {
String msg = "查询单据对应往来单位的第三方仓库信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
//供应商
ThrCorpEntity thrCorp = thrCorpService.getThrCorp(udiwmsOrderRequest.getCorpId());
if (null != thrCorp) {
dsOrderRequest.setCorpId(thrCorp.getUnitId());
dsOrderRequest.setCorpName(thrCorp.getName());
BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
if (null != basicCorpEntity) {
dsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
dsOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
log.error("查询单据对应的第三方往来单位信息异常");
String msg = "查询单据对应的第三方往来单位信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
}
@ -262,85 +287,86 @@ public class DsxyyClient extends CommonHttpClient {
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) {
setOrderDetailList(ioCodeEntities, items, detailBizEntities);
//查询产品信息
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(detailBizEntity.getBindRlFk());
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()).last("limit 1"));
Collections.reverse(items);
dsOrderRequest.setItem(items);
UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest();
BeanUtil.copyProperties(detailBizEntity, item);
return submitOrderUtil.submitOrder(orderEntity, dsOrderRequest);
}
item.setProductDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getProductDate()) ? "19990101" : "20" + detailBizEntity.getProductDate()));
item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? "20991231" : "20" + detailBizEntity.getExpireDate()));
/**
*
*
* @param ioCodeEntities
* @param orderDetailRequests
* @param detailBizEntities
*/
private void setOrderDetailList(List<IoCodeEntity> ioCodeEntities, List<UdiwmsOrderDetailRequest> orderDetailRequests, List<IoOrderDetailBizEntity> detailBizEntities) {
for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) {
UdiwmsOrderDetailRequest item = buildProductInfo(detailBizEntity);
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
item.setProductId(thirdProductId); //产品ID
if (StrUtil.isNotEmpty(item.getProductDate())) {
item.setProductDate("20" + item.getProductDate());
} else {
item.setProductDate("19990101");
//查询第三方产品名称
ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new LambdaQueryWrapper<ThrProductsEntity>()
.eq(ThrProductsEntity::getCode, thirdProductId).last("limit 1"));
if (thrProductsEntity == null) {
String errMsg = "提交失败,错误信息:" + detailBizEntity.getCoName() + "产品DI未关联第三方产品信息";
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
if (StrUtil.isNotEmpty(item.getExpireDate())) {
item.setExpireDate("20" + item.getExpireDate());
} else {
item.setExpireDate("20991231");
if (StrUtil.isEmpty(thrProductsEntity.getPrice())) {
item.setPrice(new BigDecimal(0));
} else
item.setPrice(new BigDecimal(thrProductsEntity.getPrice()));
String fphm = "";
String fprq = null;
List<IoOrderInvoiceEntity> invoiceList = IoOrderInvoiceEntity.builder().build()
.selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo())
.eq(IoOrderInvoiceEntity::getBindRlFk, detailBizEntity.getBindRlFk())
.eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, detailBizEntity.getBatchNo()).
groupBy(IoOrderInvoiceEntity::getInvoiceEncode));
if (CollectionUtil.isNotEmpty(invoiceList)) {
fphm = invoiceList.stream().map(IoOrderInvoiceEntity::getInvoiceEncode).collect(Collectors.joining(","));
if (invoiceList.get(0).getInvoiceDate() != null)
fprq = DateUtil.formatDateTime(invoiceList.get(0).getInvoiceDate());
}
item.setFirstSalesInvNo(fphm);
item.setSecSalesInvNo(fphm);
item.setInvoiceDate(fprq);
boolean isNeedFp = false;
ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesMapper.selectOne(new QueryWrapper<ThrOrderUploadBustypesEntity>().eq("action", basicBussinessTypeEntity.getAction()).last("limit 1"));
if (thrOrderUploadBustypesEntity != null && IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) {
isNeedFp = true;
}
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT) && StrUtil.isEmpty(fphm) && isNeedFp) {
String errMsg = "提交失败,错误信息:" + detailBizEntity.getCoName() + "发票缺失,请补齐后重新提交";
orderUploadLogService.updateLocalErr(orderEntity, errMsg);
return ResultVOUtils.error(500, errMsg);
}
item.setProductName(thrProductsEntity.getName()); //产品名称
item.setBindRlFk(detailBizEntity.getBindRlFk());
item.setStandard(detailBizEntity.getSpec()); //规格型号
item.setBillNo(detailBizEntity.getOrderIdFk()); //单据号
item.setRegisterNo(detailBizEntity.getCertCode()); //注册/备案证号
item.setManufactory(basicProducts.getManufactory()); //生产厂家
item.setMeasname(basicProducts.getMeasname()); //计量单位
item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号
item.setManufactoryCode(thrProductsEntity.getManufactoryCode());
item.setSupCode(thrProductsEntity.getSupCode());
item.setCplb(thrProductsEntity.getFlbm());
item.setCount(detailBizEntity.getCount());
//封装条码信息
submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item);
orderDetailRequests.add(item);
items.add(item);
}
}
public UdiwmsOrderDetailRequest buildProductInfo(IoOrderDetailBizEntity detailBizEntity) {
//查询产品信息
BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(detailBizEntity.getBindRlFk());
BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper<BasicProductsEntity>().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()).last("limit 1"));
UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest();
BeanUtil.copyProperties(detailBizEntity, item);
item.setProductDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getProductDate()) ? null : "20" + detailBizEntity.getProductDate()));
item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "20" + detailBizEntity.getExpireDate()));
Collections.reverse(items);
dsOrderRequest.setItem(items);
String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId());
item.setProductId(thirdProductId); //产品ID
//查询第三方产品名称
ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new LambdaQueryWrapper<ThrProductsEntity>()
.eq(ThrProductsEntity::getCode, thirdProductId).last("limit 1"));
if (thrProductsEntity == null) {
log.error("第三方产品编码未关联");
return null;
}
if (StrUtil.isEmpty(thrProductsEntity.getPrice())) {
item.setPrice(new BigDecimal(0));
} else
item.setPrice(new BigDecimal(thrProductsEntity.getPrice()));
item.setProductName(thrProductsEntity.getName()); //产品名称
item.setBindRlFk(detailBizEntity.getBindRlFk());
item.setStandard(detailBizEntity.getSpec()); //规格型号
item.setBillNo(detailBizEntity.getOrderIdFk()); //单据号
item.setRegisterNo(detailBizEntity.getCertCode()); //注册/备案证号
item.setManufactory(basicProducts.getManufactory()); //生产厂家
item.setMeasname(basicProducts.getMeasname()); //计量单位
item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号
item.setManufactoryCode(thrProductsEntity.getManufactoryCode());
item.setSupCode(thrProductsEntity.getSupCode());
item.setCplb(thrProductsEntity.getFlbm());
item.setCount(detailBizEntity.getCount());
return item;
return submitOrderUtil.submitOrder(orderEntity, dsOrderRequest);
}
@Override
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_INV_PI_URL), udiwmsInvProductsRequest);

Loading…
Cancel
Save