通宇保税仓出入口订单关务推送;
This commit is contained in:
+178
@@ -17,8 +17,10 @@ import com.mhd.common.core.utils.poi.ExcelUtil;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.BmsServiceFeign;
|
||||
import com.mhd.system.api.OmsServiceFeign;
|
||||
import com.mhd.system.api.SystemServiceFeign;
|
||||
import com.mhd.system.api.UserServiceFeign;
|
||||
import com.mhd.system.api.domain.GwLogDTO;
|
||||
import com.mhd.system.api.domain.GwLogW;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
import com.mhd.system.api.domain.WarehouseFeignPO;
|
||||
@@ -42,7 +44,10 @@ import com.mhd.wms.domain.stockInOrder.repository.facade.IStockInOrderService;
|
||||
import com.mhd.wms.domain.stockInOrder.entity.StockInOrder;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.po.StockInOrderPO;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.todo.StockInOrderDO;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.vo.GwInDetail;
|
||||
import com.mhd.wms.domain.stockInOrder.repository.vo.GwStockInOrder;
|
||||
import com.mhd.wms.domain.stockInOrder.service.StockInOrderDomainService;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper;
|
||||
import com.mhd.wms.interfaces.dto.stockInOrder.StockInOrderDTO;
|
||||
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
|
||||
@@ -90,6 +95,8 @@ public class StockInOrderApplicationService {
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Resource
|
||||
private BmsServiceFeign bmsServiceFeign;
|
||||
@Resource
|
||||
private OmsServiceFeign omsServiceFeign;
|
||||
@Autowired
|
||||
private IMaterialBaseInfoService materialBaseInfoService;
|
||||
@Resource
|
||||
@@ -104,6 +111,8 @@ public class StockInOrderApplicationService {
|
||||
private IHandoverTaskOrderService handoverTaskOrderService;
|
||||
@Autowired
|
||||
private IInMaterialDetailService inMaterialDetailService;
|
||||
@Autowired
|
||||
private StockOutOrderMapper stockOutOrderMapper;
|
||||
private static final String PUSH_API_URL = "http://10.33.0.100/nagu-erp-api/transfer/pushData";
|
||||
private static final String API_NAME = "save_order_i";
|
||||
private static final String VERIFY = "ESLuxAmB6VXCgbqP1eFzxTPVRagkQ62BUkfhElrgQ6XmE/g2reHVflY/SiCSU7JD";
|
||||
@@ -2269,4 +2278,173 @@ public class StockInOrderApplicationService {
|
||||
}
|
||||
return stockInOrderDomainService.queryNoticePrintDetail(stockInOrderDO);
|
||||
}
|
||||
|
||||
public AjaxResult batchPush(List<Long> idList) {
|
||||
if (idList == null || idList.isEmpty()) {
|
||||
return AjaxResult.error("没有数据需要推送");
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long pushBy = loginUser != null ? loginUser.getUserid() : null;
|
||||
String pushByName = loginUser != null ? loginUser.getUsername() : null;
|
||||
Long organizationId = loginUser != null ? loginUser.getUserPo().getOrganizationId() : null;
|
||||
Long topOrganizationId = loginUser != null ? loginUser.getUserPo().getTopOrganizationId() : null;
|
||||
String organizationName = loginUser != null ? loginUser.getUserPo().getOrganizationName() : null;
|
||||
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
StringBuilder failMsg = new StringBuilder();
|
||||
|
||||
for (Long id : idList) {
|
||||
GwStockInOrder gwStockInOrder = new GwStockInOrder();
|
||||
StockInOrder stockInOrder = stockInOrderService.getById(id);
|
||||
Long shipperId = stockInOrder.getShipperId();
|
||||
String userNcCode = stockOutOrderMapper.getUserNcCode(shipperId);
|
||||
gwStockInOrder.setBill_no(stockInOrder.getInOrderNumber());
|
||||
gwStockInOrder.setBill_date(stockInOrder.getDocumentDate());
|
||||
gwStockInOrder.setIe_flag("I");
|
||||
gwStockInOrder.setCorp_code(userNcCode);
|
||||
|
||||
|
||||
List<InMaterialDetail> reservationInMaterialDetails = inMaterialDetailService.list(new LambdaQueryWrapper<InMaterialDetail>().eq(InMaterialDetail::getInOrderNumber, stockInOrder.getInOrderNumber()));
|
||||
List<GwInDetail> orderList = new LinkedList<>();
|
||||
for (InMaterialDetail reservationInMaterialDetail : reservationInMaterialDetails) {
|
||||
GwInDetail gwInDetail = new GwInDetail();
|
||||
Long materialBaseInfoId = reservationInMaterialDetail.getMaterialBaseInfoId();
|
||||
gwInDetail.setBill_no(gwStockInOrder.getBill_no());
|
||||
String lotNo = reservationInMaterialDetail.getLotNo();
|
||||
if (lotNo != null) {
|
||||
String[] split = lotNo.split("-");
|
||||
if (split.length == 2) {
|
||||
gwInDetail.setLine_num(split[1]);
|
||||
}
|
||||
}
|
||||
gwInDetail.setItem_no(materialBaseInfoId.toString());
|
||||
gwInDetail.setItem_name(reservationInMaterialDetail.getMaterialName());
|
||||
MaterialBaseInfoPO materialBaseInfoPO = materialBaseInfoService.getInfo(materialBaseInfoId);
|
||||
gwInDetail.setSpec(materialBaseInfoPO.getSpecificationModel());
|
||||
gwInDetail.setUnit(materialBaseInfoPO.getDeclarationUnit());
|
||||
gwInDetail.setQty(reservationInMaterialDetail.getQuantity());
|
||||
gwInDetail.setErp_curr(materialBaseInfoPO.getCurrency());
|
||||
gwInDetail.setErp_price(materialBaseInfoPO.getUnitPrice());
|
||||
BigDecimal unitPrice = materialBaseInfoPO.getUnitPrice();
|
||||
BigDecimal quantity = reservationInMaterialDetail.getQuantity();
|
||||
if (unitPrice != null && quantity != null && unitPrice.compareTo(BigDecimal.ZERO) != 0&&quantity.compareTo(BigDecimal.ZERO) != 0) {
|
||||
BigDecimal Amount = unitPrice.multiply(quantity).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
gwInDetail.setAmount(Amount);
|
||||
}
|
||||
orderList.add(gwInDetail);
|
||||
}
|
||||
gwStockInOrder.setOrderList(orderList);
|
||||
|
||||
//构建推送数据
|
||||
GwLogDTO gwLogDTO = new GwLogDTO();
|
||||
gwLogDTO.setType("保税仓-进口订单");
|
||||
gwLogDTO.setBusinessId(id);
|
||||
gwLogDTO.setRequestBody(com.alibaba.fastjson.JSONObject.toJSONString(gwStockInOrder));
|
||||
gwLogDTO.setResponseBody("");
|
||||
gwLogDTO.setStatus(1);
|
||||
gwLogDTO.setSendTime(new Date());
|
||||
gwLogDTO.setOrganizationId(organizationId);
|
||||
gwLogDTO.setTopOrganizationId(topOrganizationId);
|
||||
gwLogDTO.setOrganizationName(organizationName);
|
||||
gwLogDTO.setCreateBy(pushBy);
|
||||
gwLogDTO.setCreateTime(new Date());
|
||||
//gwLogMapper.insert(gwLogDTO);
|
||||
Long gwLogId = null;
|
||||
try {
|
||||
AjaxResult insertResult = omsServiceFeign.insertGwLog(gwLogDTO);
|
||||
if(insertResult !=null && "200".equals(String.valueOf(insertResult.get("code")))){
|
||||
Map<?,?>data = (Map<?,?>)insertResult.get("data");
|
||||
gwLogId = ((Number)data.get("id")).longValue();
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
log.error("保存Gwlog失败:{}",e.getMessage());
|
||||
}
|
||||
|
||||
updatePushStatus(id, 2, new Date(), pushBy,pushByName);
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(PUSH_API_URL);
|
||||
StringEntity postingString = new StringEntity(com.alibaba.fastjson.JSONObject.toJSONString(gwStockInOrder), "UTF-8");
|
||||
httpPost.setEntity(postingString);
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
httpPost.setHeader("apiName", API_NAME);
|
||||
httpPost.setHeader("verify", VERIFY);
|
||||
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
gwLogDTO.setResponseBody(responseString);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
gwLogDTO.setStatus(2);
|
||||
updatePushStatus(id, 3, new Date(), pushBy,pushByName);
|
||||
successCount++;
|
||||
} else {
|
||||
gwLogDTO.setStatus(3);
|
||||
gwLogDTO.setErrorMsg(responseString);
|
||||
updatePushStatus(id, 4, new Date(), pushBy,pushByName);
|
||||
failCount++;
|
||||
failMsg.append("入库单id:").append(id).append("失败;");
|
||||
}
|
||||
// gwLogMapper.updateById(gwLog);
|
||||
if (gwLogId != null){
|
||||
gwLogDTO.setLogId(gwLogId);
|
||||
try{
|
||||
AjaxResult updateResult = omsServiceFeign.updateGwLog(gwLogDTO);
|
||||
}catch (Exception e){
|
||||
log.error("更新GwLog失败:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
gwLogDTO.setStatus(3);
|
||||
gwLogDTO.setErrorMsg(e.getMessage());
|
||||
gwLogDTO.setResponseBody("请求异常:" + e.getMessage());
|
||||
// gwLogMapper.updateById(gwLog);
|
||||
if (gwLogId != null){
|
||||
gwLogDTO.setLogId(gwLogId);
|
||||
try{
|
||||
AjaxResult updateResult = omsServiceFeign.updateGwLog(gwLogDTO);
|
||||
}catch (Exception ex){
|
||||
log.error("更新GwLog失败:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
updatePushStatus(id, 4, new Date(), pushBy,pushByName);
|
||||
failCount++;
|
||||
failMsg.append("id:").append(id).append("异常:").append(e.getMessage()).append(";");
|
||||
log.error("进口订单推送异常: id={}, error={}", id, e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (Exception e) {
|
||||
log.error("关闭httpClient异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String resultMsg = "推送完成: 成功" + successCount + "条, 失败" + failCount + "条";
|
||||
if (failCount > 0) {
|
||||
resultMsg += "[" + failMsg.toString() + "]";
|
||||
}
|
||||
return AjaxResult.success(resultMsg);
|
||||
}
|
||||
|
||||
private void updatePushStatus(Long id, Integer pushStatus, Date pushTime, Long pushBy,String pushByName) {
|
||||
StockInOrder entity = new StockInOrder();
|
||||
entity.setInOrderId(id);
|
||||
entity.setPushStatus(pushStatus);
|
||||
if (pushTime != null) {
|
||||
entity.setPushTime(pushTime);
|
||||
}
|
||||
if (pushBy != null) {
|
||||
entity.setPushBy(pushBy);
|
||||
}
|
||||
if (pushByName != null) {
|
||||
entity.setPushByName(pushByName);
|
||||
}
|
||||
stockInOrderService.updateById(entity);
|
||||
}
|
||||
}
|
||||
+283
-8
@@ -18,12 +18,10 @@ import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.core.utils.uuid.IdGenerator;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.OmsServiceFeign;
|
||||
import com.mhd.system.api.SystemServiceFeign;
|
||||
import com.mhd.system.api.UserServiceFeign;
|
||||
import com.mhd.system.api.domain.BatchDetailFeignPO;
|
||||
import com.mhd.system.api.domain.StorageLocationFeignPO;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
import com.mhd.system.api.domain.WarehouseFeignPO;
|
||||
import com.mhd.system.api.domain.*;
|
||||
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
|
||||
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
@@ -31,6 +29,8 @@ import com.mhd.wms.domain.copyCodeReference.repository.po.CopyCodeReferencePO;
|
||||
import com.mhd.wms.domain.deliveryDetailsLink.entity.DeliveryDetailsLink;
|
||||
import com.mhd.wms.domain.deliveryDetailsLink.repository.facade.IDeliveryDetailsLinkService;
|
||||
import com.mhd.wms.domain.inMaterialDetail.entity.InMaterialDetail;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoService;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.po.MaterialBaseInfoPO;
|
||||
import com.mhd.wms.domain.materialInventory.entity.MaterialInventory;
|
||||
import com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper;
|
||||
import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO;
|
||||
@@ -51,15 +51,24 @@ import com.mhd.wms.domain.receiptOrderAccount.entity.ReceiptOrderAccount;
|
||||
import com.mhd.wms.domain.receiptOrderAccount.repository.facade.IReceiptOrderAccountService;
|
||||
import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.po.StockOutOrderPO;
|
||||
import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO;
|
||||
import com.mhd.wms.domain.stockOutOrder.service.StockOutOrderDomainService;
|
||||
import com.mhd.wms.interfaces.dto.stockOutOrder.StockOutOrderDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -84,11 +93,13 @@ public class StockOutOrderApplicationService {
|
||||
private MaterialInventoryDomainService materialInventoryDomainService;
|
||||
@Autowired
|
||||
private MaterialInventoryMapper materialInventoryMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
private UserServiceFeign userServiceFeign;
|
||||
@Autowired
|
||||
@Resource
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Autowired
|
||||
@Resource
|
||||
private OmsServiceFeign omsServiceFeign;
|
||||
@Resource
|
||||
private IdGenerator idGenerator;
|
||||
@Autowired
|
||||
private IStockOutOrderService stockOutOrderService;
|
||||
@@ -100,7 +111,13 @@ public class StockOutOrderApplicationService {
|
||||
private IReceiptOrderAccountService receiptOrderAccountService;
|
||||
@Autowired
|
||||
private IDeliveryDetailsLinkService deliveryDetailsLinkService;
|
||||
|
||||
@Autowired
|
||||
private IMaterialBaseInfoService materialBaseInfoService;
|
||||
@Autowired
|
||||
private StockOutOrderMapper stockOutOrderMapper;
|
||||
private static final String PUSH_API_URL = "http://10.33.0.100/nagu-erp-api/transfer/pushData";
|
||||
private static final String API_NAME = "save_order_i";
|
||||
private static final String VERIFY = "ESLuxAmB6VXCgbqP1eFzxTPVRagkQ62BUkfhElrgQ6XmE/g2reHVflY/SiCSU7JD";
|
||||
|
||||
/**
|
||||
* 分页查询出库单列表
|
||||
@@ -1461,5 +1478,263 @@ public class StockOutOrderApplicationService {
|
||||
return stockOutOrderDomainService.queryCopyCodeWeightListByBatch(batchNumber,materialBaseInfoId,warehouseId,boxPalletNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 出口订单-通宇
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
//出口订单-tongyu
|
||||
public AjaxResult batchPush(List<Long> idList) {
|
||||
if (idList == null || idList.isEmpty()) {
|
||||
return AjaxResult.error("没有数据需要推送");
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long pushBy = loginUser != null ? loginUser.getUserid() : null;
|
||||
String pushByName = loginUser != null ? loginUser.getUsername() : null;
|
||||
Long organizationId = loginUser != null ? loginUser.getUserPo().getOrganizationId() : null;
|
||||
Long topOrganizationId = loginUser != null ? loginUser.getUserPo().getTopOrganizationId() : null;
|
||||
String organizationName = loginUser != null ? loginUser.getUserPo().getOrganizationName() : null;
|
||||
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
StringBuilder failMsg = new StringBuilder();
|
||||
|
||||
|
||||
for (Long id : idList) {
|
||||
|
||||
|
||||
// 查询出库单
|
||||
StockOutOrder stockOutOrder = stockOutOrderService.getById(id);
|
||||
if (stockOutOrder == null) {
|
||||
failCount++;
|
||||
failMsg.append("id:").append(id).append("不存在;");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取货主NC编码
|
||||
Long shipperId = stockOutOrder.getShipperId();
|
||||
String userNcCode = stockOutOrderMapper.getUserNcCode(shipperId);
|
||||
|
||||
// 构建主单Map
|
||||
Map<String, Object> order = new HashMap<>();
|
||||
order.put("billNo", stockOutOrder.getOutOrderNumber());
|
||||
order.put("ieFlag", "E");
|
||||
order.put("billDate", stockOutOrder.getDocumentDate());
|
||||
order.put("corpCode", userNcCode != null ? userNcCode : "");
|
||||
|
||||
// 查询出库物料明细
|
||||
List<OutMaterialDetail> outMaterialDetails =
|
||||
outMaterialDetailService.list(
|
||||
new LambdaQueryWrapper<OutMaterialDetail>()
|
||||
.eq(OutMaterialDetail::getOutOrderNumber, stockOutOrder.getOutOrderNumber())
|
||||
);
|
||||
|
||||
if (outMaterialDetails == null || outMaterialDetails.isEmpty()) {
|
||||
failCount++;
|
||||
failMsg.append("id:").append(id).append("无物料明细;");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 构建明细List<Map>
|
||||
List<Map<String, Object>> orderList = new ArrayList<>();
|
||||
for (OutMaterialDetail detail : outMaterialDetails) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("billNo", stockOutOrder.getOutOrderNumber());
|
||||
String lotNo = detail.getLotNo();
|
||||
if (lotNo != null) {
|
||||
String[] split = lotNo.split("-");
|
||||
if (split.length == 2) {
|
||||
item.put("lineNum", split[1]);
|
||||
}
|
||||
}
|
||||
item.put("itemNo", detail.getMaterialBaseInfoId() != null ? detail.getMaterialBaseInfoId().toString() : "");
|
||||
item.put("itemName", detail.getMaterialName() != null ? detail.getMaterialName() : "");
|
||||
item.put("spec", detail.getSpecificationModel() != null ? detail.getSpecificationModel() : "");
|
||||
item.put("unit", detail.getUnit() != null ? detail.getUnit() : "");
|
||||
item.put("qty", detail.getQuantity());
|
||||
|
||||
// 获取物料详情
|
||||
if (detail.getMaterialBaseInfoId() != null) {
|
||||
MaterialBaseInfoPO materialBaseInfoPO = materialBaseInfoService.getInfo(detail.getMaterialBaseInfoId());
|
||||
if (materialBaseInfoPO != null) {
|
||||
item.put("erpCurr", materialBaseInfoPO.getCurrency() != null ? materialBaseInfoPO.getCurrency() : "");
|
||||
item.put("erpPrice", materialBaseInfoPO.getUnitPrice());
|
||||
|
||||
// 计算金额
|
||||
BigDecimal unitPrice = materialBaseInfoPO.getUnitPrice();
|
||||
BigDecimal quantity = detail.getQuantity();
|
||||
if (unitPrice != null && quantity != null && unitPrice.compareTo(BigDecimal.ZERO) != 0 && quantity.compareTo(BigDecimal.ZERO) != 0) {
|
||||
BigDecimal amount = unitPrice.multiply(quantity).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
item.put("amount", amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 库存关联信息(实体默认值 + WMS覆盖)
|
||||
item.put("orderINo", detail.getInOrderNumber() != null ? detail.getInOrderNumber() : "");
|
||||
if (detail.getLotNo() != null && detail.getLotNo().contains("-")) {
|
||||
String lotNumStr = detail.getLotNo().substring(detail.getLotNo().lastIndexOf("-") + 1);
|
||||
try {
|
||||
Integer lotRowNum = Integer.valueOf(lotNumStr);
|
||||
item.put("orderIRow", lotRowNum);
|
||||
item.put("billIRow", lotRowNum);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
item.put("warehouse", detail.getWarehouseName() != null ? detail.getWarehouseName() : "");
|
||||
item.put("opWhLoc", detail.getStorageLocationName() != null ? detail.getStorageLocationName() : "");
|
||||
|
||||
// WMS仓储数据(如有则覆盖)
|
||||
if (detail.getLotNo() != null) {
|
||||
Long kcId = stockOutOrderMapper.getKcId(detail.getLotNo());
|
||||
if (kcId != null) {
|
||||
String inOrderNumber = stockOutOrderMapper.getInOrderNumber(kcId);
|
||||
String inLotNo = inOrderNumber != null ? stockOutOrderMapper.getInLotNo(inOrderNumber, detail.getMaterialBaseInfoId()) : null;
|
||||
String warehouse = stockOutOrderMapper.getWarehouse(kcId);
|
||||
String opWhLoc = stockOutOrderMapper.getOpWhLoc(kcId);
|
||||
|
||||
if (inOrderNumber != null) {
|
||||
item.put("orderINo", inOrderNumber);
|
||||
}
|
||||
if (warehouse != null) {
|
||||
item.put("warehouse", warehouse);
|
||||
}
|
||||
|
||||
item.put("opWhLoc", opWhLoc != null ? opWhLoc : "");
|
||||
|
||||
// billI = 入库单号
|
||||
if (inOrderNumber != null) {
|
||||
item.put("billI", inOrderNumber);
|
||||
}
|
||||
if (inLotNo != null) {
|
||||
if (inLotNo.contains("-")) {
|
||||
String numStr = inLotNo.substring(inLotNo.lastIndexOf("-") + 1);
|
||||
try {
|
||||
Integer result = Integer.valueOf(numStr);
|
||||
item.put("orderIRow", result);
|
||||
item.put("billIRow", result);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
orderList.add(item);
|
||||
}
|
||||
order.put("orderList", orderList);
|
||||
|
||||
// 构建推送body
|
||||
List<Map<String, Object>> bodyList = new ArrayList<>();
|
||||
bodyList.add(order);
|
||||
|
||||
GwLogDTO gwLogDTO = new GwLogDTO();
|
||||
gwLogDTO.setType("保税仓-出口订单");
|
||||
gwLogDTO.setBusinessId(id);
|
||||
gwLogDTO.setRequestBody(com.alibaba.fastjson.JSONObject.toJSONString(bodyList));
|
||||
gwLogDTO.setResponseBody("");
|
||||
gwLogDTO.setStatus(1);
|
||||
gwLogDTO.setSendTime(new Date());
|
||||
gwLogDTO.setOrganizationId(organizationId);
|
||||
gwLogDTO.setTopOrganizationId(topOrganizationId);
|
||||
gwLogDTO.setOrganizationName(organizationName);
|
||||
gwLogDTO.setCreateBy(pushBy);
|
||||
gwLogDTO.setCreateTime(new Date());
|
||||
//save
|
||||
Long gwLogId = null;
|
||||
try {
|
||||
AjaxResult insertResult = omsServiceFeign.insertGwLog(gwLogDTO);
|
||||
if(insertResult !=null && "200".equals(String.valueOf(insertResult.get("code")))){
|
||||
Map<?,?>data = (Map<?,?>)insertResult.get("data");
|
||||
gwLogId = ((Number)data.get("id")).longValue();
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
log.error("保存Gwlog失败:{}",e.getMessage());
|
||||
}
|
||||
updatePushStatus(id, 2, new Date(), pushBy,pushByName);
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(PUSH_API_URL);
|
||||
StringEntity postingString = new StringEntity(com.alibaba.fastjson.JSONObject.toJSONString(bodyList), "UTF-8");
|
||||
httpPost.setEntity(postingString);
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
httpPost.setHeader("apiName", API_NAME);
|
||||
httpPost.setHeader("verify", VERIFY);
|
||||
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
gwLogDTO.setResponseBody(responseString);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
gwLogDTO.setStatus(2);
|
||||
updatePushStatus(id, 3, new Date(), pushBy,pushByName);
|
||||
successCount++;
|
||||
} else {
|
||||
gwLogDTO.setStatus(3);
|
||||
gwLogDTO.setErrorMsg(responseString);
|
||||
updatePushStatus(id, 4, new Date(), pushBy,pushByName);
|
||||
failCount++;
|
||||
failMsg.append("id:").append(id).append("失败;");
|
||||
}
|
||||
if (gwLogId != null){
|
||||
gwLogDTO.setLogId(gwLogId);
|
||||
try{
|
||||
AjaxResult updateResult = omsServiceFeign.updateGwLog(gwLogDTO);
|
||||
}catch (Exception e){
|
||||
log.error("更新GwLog失败:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
// gwLogMapper.updateById(gwLog);
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
gwLogDTO.setStatus(3);
|
||||
gwLogDTO.setErrorMsg(e.getMessage());
|
||||
gwLogDTO.setResponseBody("请求异常:" + e.getMessage());
|
||||
// gwLogMapper.updateById(gwLog);
|
||||
if (gwLogId != null){
|
||||
gwLogDTO.setLogId(gwLogId);
|
||||
try{
|
||||
AjaxResult updateResult = omsServiceFeign.updateGwLog(gwLogDTO);
|
||||
}catch (Exception ex){
|
||||
log.error("更新GwLog失败:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
updatePushStatus(id, 4, new Date(), pushBy,pushByName);
|
||||
failCount++;
|
||||
failMsg.append("id:").append(id).append("异常:").append(e.getMessage()).append(";");
|
||||
log.error("保税仓推送异常: id={}, error={}", id, e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (Exception e) {
|
||||
log.error("关闭httpClient异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String resultMsg = "推送完成: 成功" + successCount + "条, 失败" + failCount + "条";
|
||||
if (failCount > 0) {
|
||||
resultMsg += "[" + failMsg.toString() + "]";
|
||||
}
|
||||
return AjaxResult.success(resultMsg);
|
||||
}
|
||||
|
||||
private void updatePushStatus(Long id, Integer pushStatus, Date pushTime, Long pushBy,String pushByName) {
|
||||
StockOutOrder entity = new StockOutOrder();
|
||||
entity.setOutOrderId(id);
|
||||
entity.setPushStatus(pushStatus);
|
||||
if (pushTime != null) {
|
||||
entity.setPushTime(pushTime);
|
||||
}
|
||||
if (pushBy != null) {
|
||||
entity.setPushBy(pushBy);
|
||||
}
|
||||
if (pushByName != null) {
|
||||
entity.setPushByName(pushByName);
|
||||
}
|
||||
stockOutOrderService.updateById(entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -368,4 +368,18 @@ public class StockInOrder extends BaseVOEntity {
|
||||
@ApiModelProperty("附件url")
|
||||
@Excel(name = "附件url")
|
||||
private String pictureUrl;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
+14
@@ -429,4 +429,18 @@ public class StockInOrderPO extends BaseVOEntity {
|
||||
@Excel(name = "附件url")
|
||||
private String pictureUrl;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
|
||||
}
|
||||
+13
@@ -397,4 +397,17 @@ public class StockInOrderDO extends BaseVOEntity {
|
||||
@ApiModelProperty("附件url")
|
||||
@Excel(name = "附件url")
|
||||
private String pictureUrl;
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mhd.wms.domain.stockInOrder.repository.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class GwInDetail {
|
||||
//订单号
|
||||
private String bill_no;
|
||||
//订单行号
|
||||
private String line_num;
|
||||
//物料号
|
||||
private String item_no;
|
||||
//物料名称
|
||||
private String item_name;
|
||||
//物料规格
|
||||
private String spec;
|
||||
//计量单位
|
||||
private String unit;
|
||||
//数量
|
||||
private BigDecimal qty;
|
||||
//企业币制
|
||||
private String erp_curr;
|
||||
//企业单价
|
||||
private BigDecimal erp_price;
|
||||
//申报总价
|
||||
private BigDecimal amount;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.mhd.wms.domain.stockInOrder.repository.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GwStockInOrder {
|
||||
//订单号
|
||||
private String bill_no;
|
||||
//进出标记
|
||||
private String ie_flag;
|
||||
//下单日期
|
||||
private Date bill_date;
|
||||
//客户代码
|
||||
private String corp_code;
|
||||
|
||||
private List<GwInDetail> orderList;
|
||||
|
||||
}
|
||||
@@ -410,4 +410,18 @@ public class StockOutOrder extends BaseVOEntity {
|
||||
@ApiModelProperty("车次")
|
||||
@Excel(name = "车次")
|
||||
private Integer trainNo;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
+11
-1
@@ -34,4 +34,14 @@ public interface StockOutOrderMapper extends BaseMapper<StockOutOrder> {
|
||||
@Param("boxPalletNo") String boxPalletNo);
|
||||
|
||||
List<OutMaterialDetailPO> queryOutStockNoticePrintDetailGF(StockOutOrderDTO stockOutOrderDTO);
|
||||
}
|
||||
|
||||
public String getUserNcCode(@Param("id") Long id);
|
||||
|
||||
public Long getKcId(@Param("lotNo") String lotNo);
|
||||
|
||||
public String getInOrderNumber(@Param("id") Long id);
|
||||
public String getWarehouse(@Param("id") Long id);
|
||||
public String getOpWhLoc(@Param("id") Long id);
|
||||
|
||||
public String getInLotNo(@Param("inOrderNumber") String inOrderNumber, @Param("baseId") Long baseId);
|
||||
}
|
||||
+13
@@ -437,4 +437,17 @@ public class StockOutOrderPO extends BaseVOEntity {
|
||||
@ApiModelProperty("车次")
|
||||
@Excel(name = "车次")
|
||||
private Integer trainNo;
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
+13
@@ -458,4 +458,17 @@ public class StockOutOrderDO extends BaseVOEntity {
|
||||
@ApiModelProperty("车次")
|
||||
@Excel(name = "车次")
|
||||
private Integer trainNo;
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
@@ -395,4 +395,17 @@ public class StockInOrderDTO extends StockInOrderBaseDTO {
|
||||
@ApiModelProperty("附件url")
|
||||
@Excel(name = "附件url")
|
||||
private String pictureUrl;
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
@@ -452,4 +452,17 @@ public class StockOutOrderDTO extends StockOutOrderBaseDTO {
|
||||
@ApiModelProperty("车次")
|
||||
@Excel(name = "车次")
|
||||
private Integer trainNo;
|
||||
@ApiModelProperty("推送状态:1-未推送,2-推送中,3-推送成功,4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
@@ -454,6 +454,23 @@
|
||||
(SELECT out_order_number FROM stock_out_order WHERE out_order_id = #{outOrderId} AND del_flag = 1)
|
||||
ORDER BY b.material_detail_id
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 获取用户NC码 -->
|
||||
<select id="getUserNcCode" parameterType="java.lang.Long" resultType="java.lang.String">
|
||||
select CUSTOMER_NC_CODE from "NGWL_TEST_USER".USER_SHIPPER where 1 = 1 and DEL_FLAG = 1 and USER_ID = #{id} limit 1
|
||||
</select>
|
||||
<select id="getKcId" parameterType="java.lang.String" resultType="java.lang.Long">
|
||||
select MATERIAL_INVENTORY_ID from "NGWL_TEST_WMS".OUT_MATERIAL_DETAIL where lot_no = #{lotNo}
|
||||
</select>
|
||||
<select id="getInOrderNumber" parameterType="java.lang.Long" resultType="java.lang.String">
|
||||
select IN_ORDER_NUMBER from "NGWL_TEST_WMS".MATERIAL_INVENTORY where MATERIAL_INVENTORY_ID = #{id}
|
||||
</select>
|
||||
<select id="getWarehouse" parameterType="java.lang.Long" resultType="java.lang.String">
|
||||
select WAREHOUSE_NAME from "NGWL_TEST_WMS".MATERIAL_INVENTORY where MATERIAL_INVENTORY_ID = #{id}
|
||||
</select>
|
||||
<select id="getOpWhLoc" parameterType="java.lang.Long" resultType="java.lang.String">
|
||||
select STORAGE_LOCATION_NAME from "NGWL_TEST_WMS".MATERIAL_INVENTORY where MATERIAL_INVENTORY_ID = #{id}
|
||||
</select>
|
||||
<select id="getInLotNo" resultType="java.lang.String">
|
||||
select LOT_NO from "NGWL_TEST_WMS".IN_MATERIAL_DETAIL where MATERIAL_BASE_INFO_ID = #{baseId} and IN_ORDER_NUMBER = #{inOrderNumber}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user