|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.glxp.mipsdl.client.dsxyy;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
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;
|
|
|
|
@ -9,22 +10,30 @@ import com.glxp.mipsdl.client.BaseHttpClient;
|
|
|
|
|
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;
|
|
|
|
|
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.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.AuthUserEntity;
|
|
|
|
|
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
|
|
|
|
|
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.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.http.HttpClient;
|
|
|
|
|
import com.glxp.mipsdl.req.base.*;
|
|
|
|
@ -40,14 +49,12 @@ 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.DictUtl;
|
|
|
|
|
import com.glxp.mipsdl.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.mipsdl.util.SubmitOrderUtil;
|
|
|
|
|
import com.glxp.mipsdl.util.*;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -89,6 +96,14 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
private IoOrderDetailBizDao orderDetailBizDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private SubmitOrderUtil submitOrderUtil;
|
|
|
|
|
@Resource
|
|
|
|
|
AuthUserDao authUserDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicUdirelDao basicUdirelDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicProductsDao basicProductsDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrProductsDao thrProductsDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) {
|
|
|
|
@ -140,9 +155,18 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
BeanUtil.copyProperties(udiwmsOrderRequest, dsOrderRequest);
|
|
|
|
|
|
|
|
|
|
//查询单据和详情信息,组装第三方系统接口参数
|
|
|
|
|
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()));
|
|
|
|
|
|
|
|
|
|
IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper<IoOrderEntity>().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()).last("limit 1"));
|
|
|
|
|
dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置操作人
|
|
|
|
|
if (orderEntity.getReviewUser() != null) {
|
|
|
|
|
AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getReviewUser());
|
|
|
|
|
udiwmsOrderRequest.setOperUser(authAdmin.getUserName());
|
|
|
|
|
} else if (orderEntity.getCreateUser() != null) {
|
|
|
|
|
AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getCreateUser());
|
|
|
|
|
udiwmsOrderRequest.setOperUser(authAdmin.getUserName());
|
|
|
|
|
}
|
|
|
|
|
//查询对应的第三方单据类型
|
|
|
|
|
ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper<ThrSystemBusApiEntity>().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType()));
|
|
|
|
|
if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) {
|
|
|
|
@ -150,6 +174,14 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode());
|
|
|
|
|
if (orderEntity.getInvCode().equals("1000000")) {
|
|
|
|
|
udiwmsOrderRequest.setLocInvCode("1161");
|
|
|
|
|
udiwmsOrderRequest.setLocInvName("设备科");
|
|
|
|
|
} else {
|
|
|
|
|
udiwmsOrderRequest.setLocInvCode("4050");
|
|
|
|
|
udiwmsOrderRequest.setLocInvName("西药库");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询单据类型,设置往来单位信息
|
|
|
|
|
BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType());
|
|
|
|
@ -184,31 +216,31 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询仓库信息
|
|
|
|
|
AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode()));
|
|
|
|
|
try {
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
|
|
|
|
|
|
|
|
|
|
dsOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
|
|
|
|
|
dsOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
|
|
|
|
|
|
|
|
|
|
dsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
|
|
|
|
|
dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.info("查询第三方系统仓库信息异常", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) {
|
|
|
|
|
dsOrderRequest.setCorpId(dsOrderRequest.getLocStorageCode());
|
|
|
|
|
dsOrderRequest.setCorpName(dsOrderRequest.getLocStorageName());
|
|
|
|
|
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, "29")
|
|
|
|
|
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
|
|
|
|
|
dsOrderRequest.setLocStorageCode("29");
|
|
|
|
|
dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
|
|
|
|
|
}
|
|
|
|
|
// //查询仓库信息
|
|
|
|
|
// AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper<AuthWarehouseEntity>().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode()));
|
|
|
|
|
// try {
|
|
|
|
|
// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
|
|
|
|
|
// .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
|
|
|
|
|
// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
|
|
|
|
|
//
|
|
|
|
|
// dsOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
|
|
|
|
|
// dsOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
|
|
|
|
|
//
|
|
|
|
|
// dsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
|
|
|
|
|
// dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// log.info("查询第三方系统仓库信息异常", e);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) {
|
|
|
|
|
// dsOrderRequest.setCorpId(dsOrderRequest.getLocStorageCode());
|
|
|
|
|
// dsOrderRequest.setCorpName(dsOrderRequest.getLocStorageName());
|
|
|
|
|
//
|
|
|
|
|
// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, "29")
|
|
|
|
|
// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
|
|
|
|
|
// dsOrderRequest.setLocStorageCode("29");
|
|
|
|
|
// dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
dsOrderRequest.setBillFlag("1");
|
|
|
|
|
//设置单据出入库类型
|
|
|
|
@ -223,7 +255,6 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
//组装单据明细数据
|
|
|
|
|
List<IoCodeEntity> ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper<IoCodeEntity>()
|
|
|
|
|
.eq(IoCodeEntity::getOrderId, orderEntity.getBillNo())
|
|
|
|
|
.ne(IoCodeEntity::getAction, "StockCheck")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<UdiwmsOrderDetailRequest> items = new ArrayList<>();
|
|
|
|
@ -248,7 +279,19 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
*/
|
|
|
|
|
private void setOrderDetailList(List<IoCodeEntity> ioCodeEntities, List<UdiwmsOrderDetailRequest> orderDetailRequests, List<IoOrderDetailBizEntity> detailBizEntities) {
|
|
|
|
|
for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) {
|
|
|
|
|
UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity);
|
|
|
|
|
UdiwmsOrderDetailRequest item = buildProductInfo(detailBizEntity);
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(item.getProductDate())) {
|
|
|
|
|
item.setProductDate("20" + item.getProductDate());
|
|
|
|
|
} else {
|
|
|
|
|
item.setProductDate("19990101");
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotEmpty(item.getExpireDate())) {
|
|
|
|
|
item.setExpireDate("20" + item.getExpireDate());
|
|
|
|
|
} else {
|
|
|
|
|
item.setExpireDate("20991231");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//封装条码信息
|
|
|
|
|
submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item);
|
|
|
|
@ -256,6 +299,47 @@ public class DsxyyClient implements BaseHttpClient {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) {
|
|
|
|
|
String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_INV_PI_URL), udiwmsInvProductsRequest);
|
|
|
|
|