From 8639f19c82f6e263654db44286256bb8d028d2c2 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期日, 30 十一月 2025 10:10:40 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs | 136 +++++++++++++++++++++++++++++++++-----------
1 files changed, 101 insertions(+), 35 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs"
index 7d707ca..1908f29 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs"
@@ -1,4 +1,6 @@
-锘縰sing Microsoft.Extensions.Logging;
+锘縰sing Autofac.Core;
+using MailKit.Search;
+using Microsoft.Extensions.Logging;
using SqlSugar;
using SqlSugar.Extensions;
using System;
@@ -60,7 +62,7 @@
{
1 => await AddAllocateOrder(allocateOrder),
2 => await UpdateAllocateOrder(allocateOrder),
- 3 => DeleteAllocateOrder(allocateOrder),
+ 3 => await DeleteAllocateOrder(allocateOrder),
_ => WebResponseContent.Instance.OK(),
};
@@ -81,24 +83,7 @@
}
allocateOrder.OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.AllocateOrderCodeRule));
Db.InsertNav(allocateOrder).Include(x => x.Details).ExecuteCommand();
- if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType))
- {
- if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴�)
- {
- var inboundOrders = ConvertToInboundOrders(allocateOrder);
- await _inboundService.InbounOrderService.ReceiveInboundOrder(inboundOrders, 1);
- }
- else if (businessType == BusinessTypeEnum.澶栭儴浠撳簱璋冩櫤浠�)
- {
- var outboundOrders = ConvertToOutboundOrders(allocateOrder);
- await _outboundService.OutboundOrderService.ReceiveOutboundOrder(outboundOrders, 1);
- }
- else
- {
- // 澶勭悊鏈畾涔夌殑鏋氫妇鍊硷紙濡傛湭鏉ユ柊澧炰絾鏈疄鐜扮殑绫诲瀷锛�
- throw new NotSupportedException($"涓嶆敮鎸佺殑涓氬姟绫诲瀷鏋氫妇鍊�: {businessType}");
- }
- }
+ await AddInOutData(allocateOrder);
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
@@ -107,6 +92,39 @@
return WebResponseContent.Instance.Error(ex.Message);
}
}
+
+ private async Task AddInOutData(Dt_AllocateOrder allocateOrder)
+ {
+ if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType))
+ {
+ if (businessType == BusinessTypeEnum.澶栭儴浠撳簱璋冩櫤浠�)
+ {
+ allocateOrder.OrderType = InOrderTypeEnum.AllocatInbound.ObjToInt();
+ var inboundOrders = ConvertToInboundOrders(allocateOrder);
+ await _inboundService.InbounOrderService.ReceiveInboundOrder(inboundOrders, 1);
+ }
+ else if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴� || businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
+ {
+ if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴�)
+ {
+ allocateOrder.OrderType = InOrderTypeEnum.AllocatOutbound.ObjToInt();
+ }
+ else if (businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
+ {
+ allocateOrder.OrderType = InOrderTypeEnum.InternalAllocat.ObjToInt();
+ }
+
+ var outboundOrders = ConvertToOutboundOrders(allocateOrder);
+ await _outboundService.OutboundOrderService.ReceiveOutboundOrder(outboundOrders, 1);
+ }
+ else
+ {
+ // 澶勭悊鏈畾涔夌殑鏋氫妇鍊硷紙濡傛湭鏉ユ柊澧炰絾鏈疄鐜扮殑绫诲瀷锛�
+ throw new NotSupportedException($"涓嶆敮鎸佺殑涓氬姟绫诲瀷鏋氫妇鍊�: {businessType}");
+ }
+ }
+ }
+
public async Task<WebResponseContent> UpdateAllocateOrder(Dt_AllocateOrder model)
{
try
@@ -178,7 +196,7 @@
_unitOfWorkManage.BeginTran();
foreach (var item in deletePurchaseOrderDetails)
{
- // _allocateOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
+ // _allocateOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.鑷姩鍒犻櫎);
_allocateOrderDetailRepository.DeleteData(item);
}
@@ -186,6 +204,10 @@
_allocateOrderDetailRepository.AddData(allocateOrderDetails);
BaseDal.UpdateData(allocateOrder);
+
+ DeleteInOutData(model.UpperOrderNo, allocateOrder);
+ await AddInOutData(allocateOrder);
+
_unitOfWorkManage.CommitTran();
@@ -199,7 +221,7 @@
}
}
- public WebResponseContent DeleteAllocateOrder(Dt_AllocateOrder model)
+ public async Task<WebResponseContent> DeleteAllocateOrder(Dt_AllocateOrder model)
{
try
{
@@ -221,6 +243,9 @@
_allocateOrderDetailRepository.DeleteData(item);
}
BaseDal.DeleteData(allocateOrder);
+
+ DeleteInOutData(model.UpperOrderNo, allocateOrder);
+
_unitOfWorkManage.CommitTran();
return WebResponseContent.Instance.OK();
}
@@ -232,8 +257,33 @@
}
}
+ private void DeleteInOutData(string upperOrderNo, Dt_AllocateOrder allocateOrder)
+ {
+ if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType))
+ {
+ if (businessType == BusinessTypeEnum.澶栭儴浠撳簱璋冩櫤浠�)
+ {
+ _inboundService.InbounOrderService.Db.Deleteable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == upperOrderNo).ExecuteCommand();
+
+ _inboundService.InboundOrderDetailService.Db.Deleteable<Dt_InboundOrderDetail>()
+ .Where(p => SqlFunc.Subqueryable<Dt_InboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == upperOrderNo).Any()).ExecuteCommand();
+ }
+ else if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴� || businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
+ {
+ _outboundService.OutboundOrderService.Db.Deleteable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == upperOrderNo).ExecuteCommand();
+ _outboundService.OutboundOrderDetailService.Db.Deleteable<Dt_OutboundOrderDetail>()
+ .Where(p => SqlFunc.Subqueryable<Dt_OutboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == upperOrderNo).Any()).ExecuteCommand();
+ }
+ }
+ }
+
public List<Dt_InboundOrder> ConvertToInboundOrders(Dt_AllocateOrder allocateOrder)
{
+ var distinctDetails = allocateOrder.Details
+ .GroupBy(d => d.Barcode)
+ .Select(g => g.First())
+ .ToList();
+
return new List<Dt_InboundOrder>()
{
new Dt_InboundOrder(){
@@ -241,16 +291,16 @@
InboundOrderNo=allocateOrder.OrderNo,
UpperOrderNo=allocateOrder.UpperOrderNo,
SupplierId=allocateOrder.SupplierId,
- OrderType=InOrderTypeEnum.Allocat.ObjToInt(),
+ OrderType= allocateOrder.OrderType ,
OrderStatus=allocateOrder.OrderStatus,
CreateType=allocateOrder.CreateType,
BusinessType=allocateOrder.BusinessType,
IsBatch=allocateOrder.IsBatch,
FactoryArea=allocateOrder.FactoryArea,
Remark=allocateOrder.Remark,
- Details=allocateOrder.Details.Select(detail=>new Dt_InboundOrderDetail
+ Details=distinctDetails.Select(detail=>new Dt_InboundOrderDetail
{
- OrderId= detail.OrderId,
+ OrderId= 0,
MaterielCode=detail.MaterielCode,
MaterielName="",
BatchNo=detail.BatchNo,
@@ -260,6 +310,7 @@
OrderDetailStatus=detail.OrderDetailStatus,
Unit=detail.Unit,
RowNo=0,
+ lineNo=detail.LineNo,
SupplyCode=detail.SupplyCode,
WarehouseCode=detail.WarehouseCode,
Barcode=detail.Barcode,
@@ -273,12 +324,24 @@
public Dt_OutboundOrder ConvertToOutboundOrders(Dt_AllocateOrder allocateOrder)
{
+
+ var distinctDetails = allocateOrder.Details
+ .GroupBy(d => string.IsNullOrEmpty(d.Barcode)
+ ? $"{d.MaterielCode}_{d.BatchNo}_{d.SupplyCode}_{d.WarehouseCode}"
+ : d.Barcode)
+ .Select(g => new
+ {
+ Detail = g.First(),
+ //姹囨�诲垎缁勫唴鐨勬暟閲�
+ Qty = g.Sum(x => x.BarcodeQty ?? x.OrderQuantity)
+ }).ToList();
+
return new Dt_OutboundOrder()
{
WarehouseId = allocateOrder.WarehouseId,
OrderNo = allocateOrder.OrderNo,
UpperOrderNo = allocateOrder.UpperOrderNo,
- OrderType = OutOrderTypeEnum.Allocate.ObjToInt(),
+ OrderType = allocateOrder.OrderType,
OrderStatus = allocateOrder.OrderStatus,
CreateType = allocateOrder.CreateType,
BusinessType = allocateOrder.BusinessType,
@@ -287,20 +350,23 @@
Remark = allocateOrder.Remark,
DepartmentCode = "",
DepartmentName = "",
- Details = allocateOrder.Details.Select(detail => new Dt_OutboundOrderDetail
+ Details = distinctDetails.Select(item => new Dt_OutboundOrderDetail
{
- OrderId = detail.OrderId,
- MaterielCode = detail.MaterielCode,
+ OrderId = 0,
+ MaterielCode = item.Detail.MaterielCode,
MaterielName = "",
- BatchNo = detail.BatchNo,
- OrderQuantity = detail.OrderQuantity,
+ BatchNo = item.Detail.BatchNo,
+ OrderQuantity = item.Detail.OrderQuantity,
+ BarcodeQty = (decimal)item.Detail.BarcodeQty,
+ BarcodeUnit = item.Detail.BarcodeUnit,
LockQuantity = 0,
+ lineNo = item.Detail.LineNo,
OverOutQuantity = 0,
- OrderDetailStatus = detail.OrderDetailStatus,
- Unit = detail.Unit,
+ OrderDetailStatus = item.Detail.OrderDetailStatus,
+ Unit = item.Detail.Unit,
RowNo = 0,
- SupplyCode = detail.SupplyCode,
- WarehouseCode = detail.WarehouseCode,
+ SupplyCode = item.Detail.SupplyCode,
+ WarehouseCode = item.Detail.WarehouseCode,
}).ToList()
};
--
Gitblit v1.9.3