From e4a391c581aaca1fa7b0239bc96375d0c0cb8de6 Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期三, 04 二月 2026 08:55:49 +0800
Subject: [PATCH] 1
---
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 422 +++++++++++++++++++++++++++++++---------------------
1 files changed, 252 insertions(+), 170 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 35e8717..94ef2cb 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -20,20 +20,30 @@
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Org.BouncyCastle.Asn1.Tsp;
+using Spire.Pdf;
using SqlSugar;
+using System;
+using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
+using System.Drawing.Printing;
+using System.IO;
using System.Linq;
+using System.Net.Http;
using System.Reflection;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
+using System.Threading.Tasks;
using WIDESEA_BasicRepository;
using WIDESEA_Common;
+using WIDESEA_Common.Log;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
@@ -43,6 +53,7 @@
using WIDESEA_Core.Helper;
using WIDESEA_Core.TaskEnum;
using WIDESEA_DTO.Basic;
+using WIDESEA_DTO.ERP;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Stock;
using WIDESEA_DTO.Task;
@@ -50,6 +61,7 @@
using WIDESEA_IBasicService;
using WIDESEA_IInboundRepository;
using WIDESEA_IInboundService;
+using WIDESEA_InboundRepository;
using WIDESEA_IOutboundRepository;
using WIDESEA_IOutboundService;
using WIDESEA_IRecordService;
@@ -59,28 +71,19 @@
using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Inbound;
+using WIDESEA_OutboundRepository;
using WIDESEA_StockRepository;
using WIDESEA_TaskInfoRepository;
using static WIDESEA_Common.Authentication;
using static WIDESEA_Common.HouseBackboundPassBack;
using static WIDESEA_Common.HouseInboundPassBack;
+using static WIDESEA_Common.HouseInboundPassBack.data.data1;
using static WIDESEA_Common.HouseoutboundPassBack;
using static WIDESEA_Common.InventoryAllocate;
+using static WIDESEA_Common.NewHouseInboundPassBack;
+using static WIDESEA_Common.NewHouseInboundPassBack.Parame.Syncretism;
using static WIDESEA_ITaskInfoService.ITaskService;
using Parameter = WIDESEA_Common.Parameter;
-using WIDESEA_DTO.ERP;
-using WIDESEA_OutboundRepository;
-using System.ComponentModel.DataAnnotations;
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Spire.Pdf;
-using WIDESEA_InboundRepository;
-using System.Drawing.Printing;
-using System;
-using WIDESEA_Common.Log;
-using static WIDESEA_Common.HouseInboundPassBack.data.data1;
namespace WIDESEA_TaskInfoService
{
@@ -720,6 +723,7 @@
}
if (inboundOrder.OrderStatus == InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.OrderType == 0 && inboundOrder.System.Equals("SMOM"))
{
+
List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db
.Queryable<Dt_StockInfo>()
.Includes(x => x.Details, d => d.StockDetails)
@@ -872,7 +876,79 @@
}
}
}
+ else if (inboundOrder.OrderStatus == InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.OrderType == 5 && inboundOrder.System.Equals("SMOM"))
+ {
+ List<Dt_StockInfo> StockInfos = _stockRepository.StockInfoRepository.Db
+ .Queryable<Dt_StockInfo>()
+ .Includes(x => x.Details, d => d.StockDetails)
+ .Where(x => x.WarehouseId == task.WarehouseId &&
+ x.Details.Any(v => v.OrderNo == inboundOrder.OrderNo))
+ .ToList();
+
+ Dt_InboundOrder? dt_InboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == inboundOrder.OrderNo).Includes(x => x.Details).First();
+ if (StockInfos.Count == 0) throw new Exception("鏈壘鍒板簱瀛樹俊鎭�");
+
+ var houseSyncretism = new NewHouseInboundPassBack
+ {
+ ApiType = "InventoryMoveController",
+ Method = "AsrsUnPickingDatas",
+ Parameters = new List<NewHouseInboundPassBack.Parame>
+ {
+ new NewHouseInboundPassBack.Parame
+ {
+
+ Value = new Parame.Syncretism
+ {
+ OrderNo = inboundOrder.OrderNo,
+ Details = StockInfos.SelectMany(stockInfo =>
+
+ stockInfo.Details.Select(g =>
+ {
+ //var InboundOrderde1=dt_InboundOrder.Details.FirstOrDefault;
+
+ return new Parame.Syncretism.details
+ {
+ MoveType = 0,
+ WareHouseCode = warehouse.WarehouseCode,
+ ItemCode = g.MaterielCode,
+ MoveNumber = g.StockQuantity,
+ LotNo = g.BatchNo,
+ WipBatch = g.BatchNo,
+ Lpn = g.StockDetails.FirstOrDefault().LPNNO,
+ LocationName = g.StockDetails.FirstOrDefault().OrinalLocation,
+ TargetLocName = stockInfo.LocationCode, // 娣诲姞null妫�鏌�
+ TargetLpn = stockInfo.PalletCode, // 娣诲姞null妫�鏌�
+ };
+
+
+ })).ToList()
+
+ }
+
+ }
+ }
+ };
+
+ var authResult = AuthenticateWithWMS();
+ if (authResult.IsSuccess)
+ {
+ houseSyncretism.Context = new Dictionary<string, string>
+ {
+ { "Ticket", authResult.Ticket },
+ { "InvOrgId", authResult.InvOrgId }
+
+ };
+
+ var response = HttpHelper.Post<MomRequestContent>(ReceiveWMSTaskin, houseSyncretism, "绔嬪簱鍏ュ簱鏁伴噺鍥炰紶WMS");
+ if (!response.Success)
+ {
+ throw new Exception($"鎿嶄綔澶辫触: {response.Message ?? "鏈彁渚涢敊璇俊鎭�"}");
+ }
+
+ }
+
+ }
_unitOfWorkManage.CommitTran();
return WebResponseContent.Instance.OK();
}
@@ -1686,10 +1762,13 @@
x.LocationName == stockInfo.LocationCode &&
x.LPNNo == stockInfo.PalletCode)
.ToList();
-
- List<Dt_NewOutboundOrderDetail> outboundOrderDetails1 = _outboundService.NewOutboundOrderDetailService.Db.Queryable<Dt_NewOutboundOrderDetail>()
- .Where(x => x.OrderId == outboundOrder.Id)
- .ToList();
+ List<Dt_NewOutboundOrderDetail> outboundOrderDetails1 = new List<Dt_NewOutboundOrderDetail>();
+ if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
+ {
+ outboundOrderDetails1 = _outboundService.NewOutboundOrderDetailService.Db.Queryable<Dt_NewOutboundOrderDetail>()
+ .Where(x => x.OrderId == outboundOrder.Id)
+ .ToList();
+ }
if ((outboundOrderDetails == null && outboundOrderDetails1 == null) || (outboundOrderDetails.Count == 0 && outboundOrderDetails1.Count == 0))
{
throw new Exception($"鏈壘鍒版墭鐩� {stockInfo.PalletCode} 鍦ㄨ揣浣� {stockInfo.LocationCode} 涓婄殑鍑哄簱鍗曟槑缁�");
@@ -1698,6 +1777,7 @@
var stockInfoDetails = stockInfo.Details.ToList();
int overCount = outboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
+
if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
{
foreach (var stockDetail in stockInfoDetails)
@@ -1858,7 +1938,7 @@
}
// 璋冩嫧鍑哄簱
- if (outboundOrder.OrderType == 2)
+ if (outboundOrder.OrderType == 4)
{
var allocate = new InventoryAllocate
{
@@ -2090,7 +2170,7 @@
}
// 璋冩嫧鍑哄簱
- if (outboundOrder.OrderType == 2)
+ if (outboundOrder.OrderType == 4)
{
var allocate = new InventoryAllocate
{
@@ -2177,14 +2257,14 @@
if (inboundOrder == null) return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟淇℃伅");
List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
- foreach(var detail in stockInfo.Details)
+ foreach (var detail in stockInfo.Details)
{
Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
.Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo).First();
outboundOrderDetails.Add(outboundOrderDetail);
}
- for(var i = 0; i<outboundOrderDetails.Count; i++)
+ for (var i = 0; i<outboundOrderDetails.Count; i++)
{
if (outboundOrderDetails[i].LocationName != null && outboundOrderDetails[i].LocationName != "")
{
@@ -2297,9 +2377,9 @@
// 鏇存柊搴撳瓨鐘舵�� 鍥炲簱鍗�
- AddRetrueOrder(stockInfo, inboundOrder);
-
-
+ AddRetrueOrder(stockInfo, inboundOrder);
+
+
// 鍖哄垎鍗曟嵁鏁版嵁鏉ユ簮鏇存柊璐т綅鐘舵��
if (inboundOrder.System == null)
{
@@ -2394,7 +2474,7 @@
var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>()
.Where(x => x.OrderNo == inboundOrder.OrderNo).First();
- foreach(var outboundOrderDetail in outboundOrderDetails)
+ foreach (var outboundOrderDetail in outboundOrderDetails)
{
var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
.Where(x => x.OrderId == outboundOrder.Id && x.BatchNo == outboundOrderDetail.BatchNo).First();
@@ -2498,7 +2578,7 @@
inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
}
}
-
+
}
private void DeleteAndMoveIntoHtStockStatus(Dt_StockInfo stockInfo)
@@ -2954,9 +3034,9 @@
}
}
// 鍙噺鍘诲崟鎹槑缁嗕腑鐨勬暟閲�
- matchedStockDetail.OutboundQuantity = 0;
- matchedStockDetail.StockQuantity = outDetail.OrderQuantity;
- matchedStockDetail.OrderNo = returnOrder.OrderNo;
+ //matchedStockDetail.OutboundQuantity = 0;
+ //matchedStockDetail.StockQuantity = outDetail.OrderQuantity;
+ //matchedStockDetail.OrderNo = returnOrder.OrderNo;
// 鏇存柊鍖归厤鐨勬槑缁�
_stockService.StockInfoDetailService.Repository.UpdateData(matchedStockDetail);
}
@@ -2971,163 +3051,165 @@
else
{
var groupedDetails = outboundOrderDetails
- .GroupBy(d => new { d.MaterielCode, d.BatchNo })
- .ToList();
+ .GroupBy(d => new { d.MaterielCode, d.BatchNo })
+ .ToList();
List<Dt_StockInfoDetail> processedStockDetails = new List<Dt_StockInfoDetail>();
List<Dt_ReturnOrder> returnOrders = new List<Dt_ReturnOrder>();
decimal totalOutboundQuantity = outboundOrderDetails.Sum(x => x.OrderQuantity);
decimal totalStockQuantity = stockInfoDetails.Sum(x => x.StockQuantity);
- foreach (var groupeDetail in groupedDetails)
+ foreach (var detail in stockInfo.Details)
{
- var outboundDetail = groupeDetail.First();
- decimal totalOrderQuantity = groupeDetail.Sum(x => x.OrderQuantity);
- var matchedStockDetail = stockInfoDetails.FirstOrDefault(x => x.MaterielCode == outboundDetail.MaterielCode && x.BatchNo == outboundDetail.BatchNo);
- if (matchedStockDetail == null)
+ foreach (var groupeDetail in groupedDetails)
{
- matchedStockDetail = stockInfoDetails.FirstOrDefault(x => x.MaterielCode == outboundDetail.MaterielCode);
- if (matchedStockDetail == null)
+ var outboundDetail = groupeDetail.First();
+ if (outboundDetail.MaterielCode == detail.MaterielCode)
{
- throw new Exception($"鏈壘鍒板尮閰嶇殑搴撳瓨鏄庣粏淇℃伅锛岀墿鏂�:{outboundDetail.MaterielCode}, 鎵规:{outboundDetail.BatchNo}");
+ decimal totalOrderQuantity = groupeDetail.Sum(x => x.OrderQuantity);
+ var matchedStockDetail = stockInfoDetails.FirstOrDefault(x => x.MaterielCode == outboundDetail.MaterielCode && x.BatchNo == outboundDetail.BatchNo);
+ if (matchedStockDetail == null)
+ {
+ matchedStockDetail = stockInfoDetails.FirstOrDefault(x => x.MaterielCode == outboundDetail.MaterielCode);
+
+ if (matchedStockDetail == null)
+ {
+ throw new Exception($"鏈壘鍒板尮閰嶇殑搴撳瓨鏄庣粏淇℃伅锛岀墿鏂�:{outboundDetail.MaterielCode}, 鎵规:{outboundDetail.BatchNo}");
+ }
+ }
+ // 璁$畻褰撳墠鎵规鐨勫墿浣欐暟閲�
+ decimal remainingQuantity = matchedStockDetail.StockQuantity - totalOrderQuantity;
+
+ if (remainingQuantity > 0)
+ {
+ Dt_ReturnOrder returnOrder = new Dt_ReturnOrder
+ {
+ MaterielCode = matchedStockDetail.MaterielCode,
+ MaterielName = matchedStockDetail.MaterielName,
+ BatchNo = matchedStockDetail.BatchNo,
+ OrderQuantity = remainingQuantity,
+ ReceiptQuantity = remainingQuantity,
+ OrderStatus = InOrderStatusEnum.鏈紑濮�.ObjToInt(),
+ LinId = matchedStockDetail.LinId,
+ LPNNo = stockInfo.PalletCode,
+ Creater = "LK",
+ CreateDate = DateTime.Now,
+ OrderType = OrderTypeEnum.浣欐枡鍥炲簱鍗�.ObjToInt(),
+ System = "WMS",
+ Remark = "澶氭壒娆¤繑搴�" // 娣诲姞澶囨敞鏍囪瘑
+ };
+
+ if (outboundOrder.System == "SMOM" && stockInfo.LocationCode != null)
+ {
+ returnOrder.LocationCode = stockInfo.LocationCode;
+ }
+
+ // 娣诲姞杩斿簱鍗�
+ returnOrders.Add(returnOrder);
+
+ }
+ if (remainingQuantity < 0 && matchedStockDetail.StockQuantity < matchedStockDetail.OutboundQuantity)
+ {
+ throw new Exception($"鍑哄簱鏁伴噺 {outboundDetail.OrderQuantity} 澶т簬搴撳瓨鏁伴噺 {matchedStockDetail.StockQuantity}");
+ }
+ processedStockDetails.Add(matchedStockDetail);
+
+
+ // 澶勭悊鍏朵粬鎵规鐨勫簱瀛樻槑缁嗭紙鍏ㄩ儴杩斿簱锛�
+ var otherBatchDetails = stockInfoDetails
+ .Where(x => !processedStockDetails.Contains(x) && x.StockQuantity > 0 && x.OutboundQuantity == 0)
+ .ToList();
+
+ if (returnOrders == null || returnOrders.Count == 0)
+ {
+ if (otherBatchDetails.Count > 0)
+ {
+ decimal totalOtherQuantity = otherBatchDetails.Sum(x => x.StockQuantity);
+
+ // 涓哄叾浠栨壒娆″垱寤鸿繑搴撳崟锛堝彧鍒涘缓涓�涓紝鍖呭惈鎵�鏈夋壒娆★級
+ var firstOtherDetail = otherBatchDetails.First();
+ Dt_ReturnOrder otherReturnOrder = new Dt_ReturnOrder
+ {
+ MaterielCode = firstOtherDetail.MaterielCode,
+ MaterielName = firstOtherDetail.MaterielName,
+ BatchNo = firstOtherDetail.BatchNo,
+ OrderQuantity = totalOtherQuantity,
+ ReceiptQuantity = totalOtherQuantity,
+ OrderStatus = InOrderStatusEnum.鏈紑濮�.ObjToInt(),
+ LinId = firstOtherDetail.LinId,
+ LPNNo = stockInfo.PalletCode,
+ Creater = "LK",
+ CreateDate = DateTime.Now,
+ OrderType = OrderTypeEnum.浣欐枡鍥炲簱鍗�.ObjToInt(),
+ System = "WMS",
+ Remark = $"澶氭壒娆¤繑搴擄紝鍏眥otherBatchDetails.Count}涓壒娆�"
+ };
+
+ if (outboundOrder.System == "SMOM" && !string.IsNullOrEmpty(stockInfo.LocationCode))
+ {
+ otherReturnOrder.LocationCode = stockInfo.LocationCode;
+ }
+ returnOrders.Add(otherReturnOrder);
+ }
+
+ }
+ else
+ {
+ decimal totalOtherQuantity = otherBatchDetails.Sum(x => x.StockQuantity);
+ foreach (var item in returnOrders)
+ {
+ item.OrderQuantity = totalOrderQuantity;
+ item.ReceiptQuantity = totalOrderQuantity;
+ item.Remark = $"澶氭壒娆¤繑搴擄紝鍏眥otherBatchDetails.Count}涓壒娆�";
+ }
+ }
+
+ // 鎵归噺鏇存柊宸插鐞嗙殑搴撳瓨鏄庣粏
+ var updateDetails = processedStockDetails.Where(x => x.StockQuantity > 0).ToList();
+ if (updateDetails.Any())
+ {
+ _stockService.StockInfoDetailService.Repository.UpdateData(updateDetails);
+ }
+
+ // 娣诲姞杩斿簱鍗�
+ if (returnOrders.Any())
+ {
+ _returnOrderRepository.AddData(returnOrders);
+ }
+
+ // 鏇存柊搴撳瓨涓昏〃鐘舵��
+ decimal returnQuantity = totalStockQuantity - totalOutboundQuantity;
+ if (returnQuantity == 0 || stockInfo.Details.All(x => x.StockQuantity == x.OutboundQuantity))
+ {
+ if (outboundOrder.System == "SMOM" && stockInfo.LocationCode != null)
+ {
+ Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
+ dt_LocationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+ _basicRepository.LocationInfoRepository.UpdateData(dt_LocationInfo);
+ }
+ //鍏ㄩ儴鍑哄簱锛屽垹闄ゅ簱瀛�
+ //DeleteAndMoveIntoHtStockStatus(stockInfo);
+ //foreach (var item in stockInfo.Details)
+ //{
+ // BaseDal.Db.Deleteable(item.StockDetails).ExecuteCommand();
+ //}
+ }
+ else if (returnQuantity > 0)
+ {
+ // 鏈変綑鏂欒繑搴�
+ stockInfo.LocationCode = "";
+ stockInfo.StockStatus = StockStatusEmun.浣欐枡閫�搴�.ObjToInt();
+ stockInfo.Remark = $"浣欐枡閫�搴擄紝鍏眥returnOrders.Count}涓繑搴撳崟";
+ _stockService.StockInfoService.Repository.UpdateData(stockInfo);
+ }
}
}
- // 璁$畻褰撳墠鎵规鐨勫墿浣欐暟閲�
- decimal remainingQuantity = matchedStockDetail.StockQuantity - totalOrderQuantity;
- if (remainingQuantity > 0)
- {
- Dt_ReturnOrder returnOrder = new Dt_ReturnOrder
- {
- MaterielCode = matchedStockDetail.MaterielCode,
- MaterielName = matchedStockDetail.MaterielName,
- BatchNo = matchedStockDetail.BatchNo,
- OrderQuantity = remainingQuantity,
- ReceiptQuantity = remainingQuantity,
- OrderStatus = InOrderStatusEnum.鏈紑濮�.ObjToInt(),
- LinId = matchedStockDetail.LinId,
- LPNNo = stockInfo.PalletCode,
- Creater = "LK",
- CreateDate = DateTime.Now,
- OrderType = OrderTypeEnum.浣欐枡鍥炲簱鍗�.ObjToInt(),
- System = "WMS",
- Remark = "澶氭壒娆¤繑搴�" // 娣诲姞澶囨敞鏍囪瘑
- };
-
- if (outboundOrder.System == "SMOM" && stockInfo.LocationCode != null)
- {
- returnOrder.LocationCode = stockInfo.LocationCode;
- }
-
- // 娣诲姞杩斿簱鍗�
- returnOrders.Add(returnOrder);
-
- // 鏇存柊褰撳墠鎵规鏄庣粏锛氬彧淇濈暀鍑哄簱鏁伴噺锛屽叾浣欒繑搴�
- matchedStockDetail.StockQuantity = remainingQuantity;
- matchedStockDetail.OutboundQuantity = outboundDetail.OrderQuantity;
- //matchedStockDetail.OrderNo = returnOrder.OrderNo;
- }
- else if (remainingQuantity == 0)
- {
- // 褰撳墠鎵规姝eソ鍑哄畬
- matchedStockDetail.OutboundQuantity = matchedStockDetail.StockQuantity;
- if (matchedStockDetail.StockQuantity == totalOrderQuantity)
- {
- _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(
- matchedStockDetail, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚);
- }
- else
- {
- matchedStockDetail.StockQuantity = 0;
- _stockService.StockInfoDetailService.Repository.UpdateData(matchedStockDetail);
- }
- }
- else
- {
- throw new Exception($"鍑哄簱鏁伴噺 {outboundDetail.OrderQuantity} 澶т簬搴撳瓨鏁伴噺 {matchedStockDetail.StockQuantity}");
- }
- processedStockDetails.Add(matchedStockDetail);
}
- // 澶勭悊鍏朵粬鎵规鐨勫簱瀛樻槑缁嗭紙鍏ㄩ儴杩斿簱锛�
- var otherBatchDetails = stockInfoDetails
- .Where(x => !processedStockDetails.Contains(x) && x.StockQuantity > 0)
- .ToList();
-
- if (otherBatchDetails.Count > 0)
- {
- decimal totalOtherQuantity = otherBatchDetails.Sum(x => x.StockQuantity);
-
- // 涓哄叾浠栨壒娆″垱寤鸿繑搴撳崟锛堝彧鍒涘缓涓�涓紝鍖呭惈鎵�鏈夋壒娆★級
- var firstOtherDetail = otherBatchDetails.First();
- Dt_ReturnOrder otherReturnOrder = new Dt_ReturnOrder
- {
- MaterielCode = firstOtherDetail.MaterielCode,
- MaterielName = firstOtherDetail.MaterielName,
- BatchNo = firstOtherDetail.BatchNo,
- OrderQuantity = totalOtherQuantity,
- ReceiptQuantity = totalOtherQuantity,
- OrderStatus = InOrderStatusEnum.鏈紑濮�.ObjToInt(),
- LinId = firstOtherDetail.LinId,
- LPNNo = stockInfo.PalletCode,
- Creater = "LK",
- CreateDate = DateTime.Now,
- OrderType = OrderTypeEnum.浣欐枡鍥炲簱鍗�.ObjToInt(),
- System = "WMS",
- Remark = $"澶氭壒娆¤繑搴擄紝鍏眥otherBatchDetails.Count}涓壒娆�"
- };
-
- if (outboundOrder.System == "SMOM" && !string.IsNullOrEmpty(stockInfo.LocationCode))
- {
- otherReturnOrder.LocationCode = stockInfo.LocationCode;
- }
-
-
- returnOrders.Add(otherReturnOrder);
- }
-
- // 鎵归噺鏇存柊宸插鐞嗙殑搴撳瓨鏄庣粏
- var updateDetails = processedStockDetails.Where(x => x.StockQuantity > 0).ToList();
- if (updateDetails.Any())
- {
- _stockService.StockInfoDetailService.Repository.UpdateData(updateDetails);
- }
-
- // 娣诲姞杩斿簱鍗�
- if (returnOrders.Any())
- {
- _returnOrderRepository.AddData(returnOrders);
- }
-
- // 鏇存柊搴撳瓨涓昏〃鐘舵��
- decimal returnQuantity = totalStockQuantity - totalOutboundQuantity;
- if (returnQuantity == 0)
- {
- if (outboundOrder.System == "SMOM" && stockInfo.LocationCode != null)
- {
- Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
- dt_LocationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
- _basicRepository.LocationInfoRepository.UpdateData(dt_LocationInfo);
- }
- // 鍏ㄩ儴鍑哄簱锛屽垹闄ゅ簱瀛�
- DeleteAndMoveIntoHtStockStatus(stockInfo);
- foreach (var item in stockInfo.Details)
- {
- BaseDal.Db.Deleteable(item.StockDetails).ExecuteCommand();
- }
- }
- else if (returnQuantity > 0)
- {
- // 鏈変綑鏂欒繑搴�
- stockInfo.LocationCode = "";
- stockInfo.StockStatus = StockStatusEmun.浣欐枡閫�搴�.ObjToInt();
- stockInfo.Remark = $"浣欐枡閫�搴擄紝鍏眥returnOrders.Count}涓繑搴撳崟";
- _stockService.StockInfoService.Repository.UpdateData(stockInfo);
- }
-
+ _unitOfWorkManage.CommitTran();
}
- _unitOfWorkManage.CommitTran();
}
catch (Exception ex)
{
--
Gitblit v1.9.3