From 95c92db3c831c73b05068b09221c13ad4a250322 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期一, 02 二月 2026 20:07:00 +0800
Subject: [PATCH] 条码扫描成功音频播放功能,代码优化
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs | 133 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 125 insertions(+), 8 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_InboundService/InboundService.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_InboundService/InboundService.cs"
index 700891d..ca8c34e 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_InboundService/InboundService.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_InboundService/InboundService.cs"
@@ -3,6 +3,7 @@
using MailKit.Search;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Org.BouncyCastle.Asn1.X509;
+using Org.BouncyCastle.Bcpg;
using SixLabors.ImageSharp;
using SqlSugar;
using System;
@@ -11,12 +12,14 @@
using System.Data;
using System.Linq;
using System.Net;
+using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.AllocateEnum;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.Helper;
@@ -54,7 +57,8 @@
private readonly IRepository<Dt_MesReturnRecord> _mesReturnRecord;
private readonly ILocationInfoService _locationInfoService;
private readonly IRepository<Dt_TakeStockOrder> _takeStockOrder;
- public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord,ILocationInfoService locationInfoService,IRepository<Dt_TakeStockOrder> takeStockOrder)
+ private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository;
+ public InboundService(IUnitOfWorkManage unitOfWorkManage, IInboundOrderDetailService inboundOrderDetailService, IInboundOrderService inbounOrderService, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IStockService stockService, IRepository<Dt_Task> taskRepository,IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfo, HttpClientHelper httpClientHelper, IRepository<Dt_MesReturnRecord> mesReturnRecord,ILocationInfoService locationInfoService,IRepository<Dt_TakeStockOrder> takeStockOrder,IRepository<Dt_StockInfoDetail> stockInfoDetailRepository)
{
_unitOfWorkManage = unitOfWorkManage;
InboundOrderDetailService = inboundOrderDetailService;
@@ -71,6 +75,7 @@
_mesReturnRecord = mesReturnRecord;
_locationInfoService = locationInfoService;
_takeStockOrder = takeStockOrder;
+ _stockInfoDetailRepository = stockInfoDetailRepository;
}
public async Task<WebResponseContent> GroupPallet(GroupPalletDto palletDto)
@@ -91,9 +96,41 @@
var details = _inboundOrderDetailRepository.QueryData(x => (x.OutBoxbarcodes == palletDto.Barcode|| x.Barcode == palletDto.Barcode) && x.OrderDetailStatus == (int)InOrderStatusEnum.鏈紑濮�);
+
if (details.Count() <= 0)
{
- return content.Error("璇风‘璁ゆ槸鍚﹀凡缁忕粍鐩�");
+
+ var inbounddetail = _inboundOrderDetailRepository.QueryFirst(x => x.Barcode == palletDto.Barcode || x.OutBoxbarcodes == palletDto.Barcode);
+ if (inbounddetail == null)
+ {
+ return content.Error($"鏉$爜{palletDto.Barcode}涓嶅瓨鍦�");
+ }
+ var inbound = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.Id == inbounddetail.OrderId).First();
+ if (inbound == null)
+ {
+ return content.Error("鍗曟嵁涓嶈兘涓虹┖");
+ }
+
+ var detail = _inboundOrderDetailRepository.Db.Queryable<Dt_InboundOrderDetail>().LeftJoin<Dt_InboundOrder>((d, o) => d.OrderId == o.Id).Where((d, o) => d.OrderId == inbound.Id
+ && d.ReceiptQuantity != 0
+ && d.OverInQuantity == 0).Select((d, o) => new
+ {
+ orderNo = o.InboundOrderNo,
+ d.Barcode,
+ d.MaterielCode,
+ d.BatchNo,
+ d.ReceiptQuantity,
+ d.Unit,
+ d.SupplyCode,
+ d.WarehouseCode
+ }).ToList();
+ var palletId = _stockInfoDetailRepository.QueryFirst(x => x.Barcode == palletDto.Barcode);
+ if (palletId == null)
+ {
+ return content.Error($"鏉$爜{palletDto.Barcode}宸茬粍鐩�");
+ }
+ var pallet = _stockInfoRepository.QueryFirst(x => x.Id == palletId.StockId);
+ return content.Error($"鏉$爜{palletDto.Barcode}宸茬粡缁勫埌{pallet.PalletCode}", detail);
}
inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Includes(x=>x.Details).Where(x => x.Id == details.First().OrderId).First();
@@ -134,10 +171,30 @@
{
return content.Error($"璇ユ墭鐩樼粍鐩樹粨搴撲负{stockInfo.Details.FirstOrDefault()?.WarehouseCode}涓庡綋鍓嶄粨搴搟palletDto.WarehouseType}涓嶄竴鑷达紝涓嶅厑璁哥粍鐩�");
}
+ var isWarehouse = _inboundOrderDetailRepository.QueryFirst(x => x.OrderId == inboundOrder.Id && !string.IsNullOrEmpty(x.WarehouseCode));
+ if (isWarehouse != null && inboundOrder.BusinessType == "11" && isWarehouse.WarehouseCode != palletDto.WarehouseType)
+ {
+ return content.Error($"涓�涓噰璐崟鎹噷闈笉鍏佽缁勭洏涓や釜浠撳簱锛岃閲嶆柊閫夋嫨浠撳簱锛屼笂涓�涓粍鐩樹粨搴撲负{isWarehouse.WarehouseCode}");
+ }
+ if (inboundOrder.BusinessType == "11" && inboundOrder.IsTestMaterials == 1 && (palletDto.WarehouseType != "1076" || palletDto.WarehouseType != "5057"))
+ {
+ return content.Error($"璇ュ崟鎹负璇曚骇鐗╂枡锛岄渶瑕佸叆搴撳埌璇曚骇浠擄紝璇烽噸鏂版牴鎹巶鍖洪�夋嫨璇曚骇浠撳簱杩涜缁勭洏鍏ュ簱");
+ }
if (!_locationInfoService.QueryLocationCount(Convert.ToInt32(palletDto.locationType)))
{
return content.Error($"璇ュ簱鍖簕palletDto.locationType}涓嶅瓨鍦ㄧ┖闂插簱浣�");
+ }
+
+ var nullpallet =_stockInfoRepository.QueryFirst(x => x.PalletType == -1 && x.PalletCode == palletDto.PalletCode);
+ if (nullpallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}宸茬粡杩涜绌烘墭缁勭洏,涓嶈兘鍦ㄨ繘琛岀粍鐩�");
+ }
+ var outbundPallet = _stockInfoRepository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.鍑哄簱瀹屾垚 && x.PalletCode == palletDto.PalletCode);
+ if (outbundPallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}鏈繘琛屽彇绌虹,涓嶈兘杩涜缁勭洏");
}
foreach (var item in details)
@@ -231,7 +288,16 @@
{
return content.Error("宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏");
}
-
+ var nullpallet = _stockInfoRepository.QueryFirst(x => x.PalletType == -1 && x.PalletCode == palletDto.PalletCode);
+ if (nullpallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}宸茬粡杩涜绌烘墭缁勭洏,涓嶈兘鍦ㄨ繘琛岀粍鐩�");
+ }
+ var outbundPallet = _stockInfoRepository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.鍑哄簱瀹屾垚 && x.PalletCode == palletDto.PalletCode);
+ if (outbundPallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}鏈繘琛屽彇绌虹,涓嶈兘杩涜缁勭洏");
+ }
if (_stockService.StockInfoDetailService.ExistBarcodes(palletDto.Barcode))
{
return content.Error($"{palletDto.Barcode} 鏉$爜鍦ㄥ簱瀛樹腑宸插瓨鍦�");
@@ -397,13 +463,24 @@
//}
}
_mesReturnRecord.UpdateData(returnRecords);
+ //閲嶆柊鍥炶皟瀹屾垚鐨勫崟鎹紝鏇存柊搴撳瓨鐘舵��
+ foreach (var returnRecord in returnRecords)
+ {
+ if (returnRecord.ReturnStatus == 1)
+ {
+ _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+ {
+ Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+ }).Where(it => it.OrderNo == returnRecord.OrderNo && returnRecord.RequestData.Contains(it.Barcode)).ExecuteCommand();
+ }
+ }
var inboundOrderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrderDetail>()
- .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus==(int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
+ .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus == (int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
.ToList();
var stocks = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == (int)StockStatusEmun.鍏ュ簱瀹屾垚)
- .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo).Any())
+ .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo && s.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt()).Any())
.ToList();
var stockIds = stocks.Select(s => s.Id).ToList();
@@ -424,6 +501,13 @@
inbound => inbound.Barcode,
stockdetail => stockdetail.Barcode,
(inbound, stockdetail) => inbound.Id)
+ .ToList();
+
+ var inbounddetailBarcode = inboundOrderDetail
+ .Join(allDetailsData,
+ inbound => inbound.Barcode,
+ stockdetail => stockdetail.Barcode,
+ (inbound, stockdetail) => stockdetail.Barcode)
.ToList();
var detail = allDetailsData.Where(x => matchedData.Contains(x.Barcode)).ToList();
@@ -469,6 +553,11 @@
{
_inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
.Where(it => it.OrderId == inboundOrder.Id && inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+ _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+ {
+ Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+ }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
}
else
{
@@ -492,7 +581,7 @@
details = FeedbackInboundDetailsModelDto(detail)
};
- if (feedmodel.details.Count<=0)
+ if (feedmodel.details.Count <= 0)
{
if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
{
@@ -515,6 +604,11 @@
{
_inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
.Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+ _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+ {
+ Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+ }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
}
else
{
@@ -531,6 +625,7 @@
return content.Error(ex.Message);
}
}
+
public List<AllocateDtoDetail> GetAllocateDtoDetails(List<Dt_StockInfoDetail> stockInfoDetails)
{
@@ -662,7 +757,16 @@
{
return content.Error("宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏");
}
-
+ var nullpallet = _stockInfoRepository.QueryFirst(x => x.PalletType == -1 && x.PalletCode == palletDto.PalletCode);
+ if (nullpallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}宸茬粡杩涜绌烘墭缁勭洏,涓嶈兘鍦ㄨ繘琛岀粍鐩�");
+ }
+ var outbundPallet = _stockInfoRepository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.鍑哄簱瀹屾垚 && x.PalletCode == palletDto.PalletCode);
+ if (outbundPallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}鏈繘琛屽彇绌虹,涓嶈兘杩涜缁勭洏");
+ }
Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
.Where(x => x.Barcode == palletDto.Barcode && x.StockId == 0)
.First();
@@ -782,6 +886,16 @@
{
return content.Error($"璇ユ墭鐩樼粍鐩樹粨搴撲负{stockInfo.Details.FirstOrDefault()?.WarehouseCode}涓庡綋鍓嶄粨搴搟palletDto.WarehouseType}涓嶄竴鑷达紝涓嶅厑璁哥粍鐩�");
}
+ var nullpallet = _stockInfoRepository.QueryFirst(x => x.PalletType == -1 && x.PalletCode == palletDto.PalletCode);
+ if (nullpallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}宸茬粡杩涜绌烘墭缁勭洏,涓嶈兘鍦ㄨ繘琛岀粍鐩�");
+ }
+ var outbundPallet = _stockInfoRepository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.鍑哄簱瀹屾垚 && x.PalletCode == palletDto.PalletCode);
+ if (outbundPallet != null)
+ {
+ return content.Error($"璇ユ墭鐩榹palletDto.PalletCode}鏈繘琛屽彇绌虹,涓嶈兘杩涜缁勭洏");
+ }
Dt_StockInfoDetail stockInfoDetail = _stockInfoRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.Barcode == palletDto.Barcode && x.Status == StockStatusEmun.閲嶆涓�.ObjToInt()).First();
if(stockInfoDetail == null)
{
@@ -790,7 +904,7 @@
Dt_ReCheckOrder reCheckOrder = _stockInfoRepository.Db.Queryable<Dt_ReCheckOrder>().Where(x => x.MaterielCode == stockInfoDetail.MaterielCode && x.BatchNo == stockInfoDetail.BatchNo && x.OrderNo == stockInfoDetail.OrderNo && (x.Result == 1 || x.Result == 2 )).First();
if(reCheckOrder == null)
{
- return content.Error($"璇ラ噸妫�鏉$爜鐨勬壒娆″湪閲嶆鍗曚腑鏈嬁鍒伴噸妫�缁撴灉锛岃妫�娴嬮噸妫�鍗晎reCheckOrder.OrderNo}鐘舵��");
+ return content.Error($"璇ラ噸妫�鏉$爜鐨勬壒娆″湪閲嶆鍗曚腑鏈嬁鍒伴噸妫�缁撴灉锛岃妫�鏌ラ噸妫�鍗曚腑鐗╂枡{stockInfoDetail.MaterielCode}鍜寋stockInfoDetail.BatchNo}鐗╂枡鎵规鐘舵��");
}
int newStatus = reCheckOrder.Result == 1 ? StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(): StockStatusEmun.鎵嬪姩鍐荤粨.ObjToInt();
@@ -844,5 +958,8 @@
return content.Error(ex.Message);
}
}
+
+
+
}
}
--
Gitblit v1.9.3