|
|
|
@ -2,20 +2,37 @@ package com.glxp.api.admin.service.business.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.admin.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.admin.dao.basic.BasicThirdSysBusApiDao;
|
|
|
|
|
import com.glxp.api.admin.dao.basic.BasicThirdSysDao;
|
|
|
|
|
import com.glxp.api.admin.dao.basic.BussinessTypeDao;
|
|
|
|
|
import com.glxp.api.admin.dao.basic.UnitMaintainDao;
|
|
|
|
|
import com.glxp.api.admin.dao.business.StockOrderDao;
|
|
|
|
|
import com.glxp.api.admin.dao.business.StockOrderDetailDao;
|
|
|
|
|
import com.glxp.api.admin.dao.inout.OrderDao;
|
|
|
|
|
import com.glxp.api.admin.entity.basic.BasicThirdSysBusApiEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.basic.BasicThirdSysEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.basic.UnitMaintainEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.business.StockOrderDetailEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.business.StockOrderEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.business.StockOrderPrintEntity;
|
|
|
|
|
import com.glxp.api.admin.httpclient.req.UdiwmsOrderDetail;
|
|
|
|
|
import com.glxp.api.admin.httpclient.req.UdiwmsOrderRequest;
|
|
|
|
|
import com.glxp.api.admin.req.business.StockOrderDetailFilterRequest;
|
|
|
|
|
import com.glxp.api.admin.req.business.StockOrderFilterRequest;
|
|
|
|
|
import com.glxp.api.admin.req.business.StockOrderQueryRequest;
|
|
|
|
|
import com.glxp.api.admin.res.business.StockOrderDetailEntityVo;
|
|
|
|
|
import com.glxp.api.admin.res.business.StockOrderExportResponse;
|
|
|
|
|
import com.glxp.api.admin.service.business.StockOrderService;
|
|
|
|
|
import com.glxp.api.admin.util.HttpClient;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -29,6 +46,16 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
StockOrderDao stockOrderDao;
|
|
|
|
|
@Resource
|
|
|
|
|
StockOrderDetailDao stockOrderDetailDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicThirdSysBusApiDao thirdSysBusApiDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private UnitMaintainDao unitMaintainDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BussinessTypeDao bussinessTypeDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicThirdSysDao basicThirdSysDao;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrderDao orderDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<StockOrderEntity> listStockOrders(StockOrderQueryRequest stockOrderQueryRequest) {
|
|
|
|
@ -144,4 +171,66 @@ public class StockOrderServiceImpl implements StockOrderService {
|
|
|
|
|
public List<StockOrderEntity> getSupplementOrderBillNoList() {
|
|
|
|
|
return stockOrderDao.selectSupplementOrderList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse submitOrderToThirdys(String id) {
|
|
|
|
|
//查询单据和详情信息,组装第三方系统接口参数所需数据
|
|
|
|
|
StockOrderEntity stockOrderEntity = stockOrderDao.findById(id);
|
|
|
|
|
StockOrderDetailFilterRequest orderDetailFilterRequest = new StockOrderDetailFilterRequest();
|
|
|
|
|
orderDetailFilterRequest.setOrderIdFk(id);
|
|
|
|
|
List<StockOrderDetailEntity> stockOrderDetailEntities = stockOrderDetailDao.filterStockOrderDetail(orderDetailFilterRequest);
|
|
|
|
|
|
|
|
|
|
UdiwmsOrderRequest udiwmsOrderRequest = new UdiwmsOrderRequest();
|
|
|
|
|
udiwmsOrderRequest.setBillDate(stockOrderEntity.getBilldate()); //单据日期
|
|
|
|
|
udiwmsOrderRequest.setBillNo(stockOrderEntity.getBillNo()); //单号
|
|
|
|
|
//查询往来单位第三方系统对照编码
|
|
|
|
|
UnitMaintainEntity unitMaintainEntity = unitMaintainDao.selectThirdInfoByErpId(stockOrderEntity.getCorpId());
|
|
|
|
|
udiwmsOrderRequest.setCorpId(unitMaintainEntity.getThirdId()); //往来单位编码,需转换为第三方系统的ID
|
|
|
|
|
udiwmsOrderRequest.setCorpName(unitMaintainEntity.getThirdName()); //往来单位名称,需转换为第三方系统的名称
|
|
|
|
|
udiwmsOrderRequest.setBillFlag(stockOrderEntity.getBillFlag());//单据状态
|
|
|
|
|
//查询第三方系统的单据ID,及第三方系统标识
|
|
|
|
|
BasicThirdSysBusApiEntity thirdSysBusApiEntity = thirdSysBusApiDao.selectByCode(stockOrderEntity.getBillType());
|
|
|
|
|
udiwmsOrderRequest.setThirdSys(thirdSysBusApiEntity.getThirdSys()); //第三方系统标识
|
|
|
|
|
udiwmsOrderRequest.setBillType(thirdSysBusApiEntity.getThirdBuyName());
|
|
|
|
|
//查询单据出入库类型
|
|
|
|
|
String mainAction = bussinessTypeDao.selectInoutTypebByLocalAction(stockOrderEntity.getBillType());
|
|
|
|
|
if (ConstantType.TYPE_PUT.equals(mainAction)) {
|
|
|
|
|
udiwmsOrderRequest.setInoutType(1); //出入库类型:入库
|
|
|
|
|
} else if (ConstantType.TYPE_OUT.equals(mainAction)) {
|
|
|
|
|
udiwmsOrderRequest.setInoutType(2); //出入库类型:出库
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
udiwmsOrderRequest.setRemark("udi管理系统提交单据"); //备注
|
|
|
|
|
|
|
|
|
|
//组装明细数据
|
|
|
|
|
List<UdiwmsOrderDetail> items = new ArrayList<>(stockOrderDetailEntities.size());
|
|
|
|
|
for (StockOrderDetailEntity stockOrderDetailEntity : stockOrderDetailEntities) {
|
|
|
|
|
UdiwmsOrderDetail item = new UdiwmsOrderDetail();
|
|
|
|
|
BeanUtil.copyProperties(stockOrderDetailEntity, item);
|
|
|
|
|
items.add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
udiwmsOrderRequest.setItems(items);
|
|
|
|
|
|
|
|
|
|
//提交单据到第三方服务
|
|
|
|
|
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysDao.selectByThirdId(thirdSysBusApiEntity.getThirdSys());
|
|
|
|
|
String response = HttpClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders", udiwmsOrderRequest);
|
|
|
|
|
if (StrUtil.isNotBlank(response)) {
|
|
|
|
|
try {
|
|
|
|
|
BaseResponse baseResponse = JSONUtil.toBean(response, BaseResponse.class);
|
|
|
|
|
if (baseResponse.getCode().equals(20000)) {
|
|
|
|
|
//提交成功,更新导出状态
|
|
|
|
|
orderDao.updateExportStatus(stockOrderEntity.getOrderIdFk(), 1);
|
|
|
|
|
return ResultVOUtils.success("提交成功");
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|