From 62b5e514154820ed41f0093c29e35b07224a2ba9 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期二, 02 十二月 2025 09:11:55 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/InvokeMESService.cs | 226 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 160 insertions(+), 66 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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
index 34e8220..a4a8d8d 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_BasicService/InvokeMESService.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_BasicService/InvokeMESService.cs"
@@ -1,4 +1,5 @@
-锘縰sing Microsoft.Extensions.Logging;
+锘縰sing Dm.filter;
+using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Org.BouncyCastle.Asn1.Ocsp;
using SqlSugar;
@@ -14,6 +15,7 @@
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
+using WIDESEA_Core.Helper;
using WIDESEA_DTO.Allocate;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Inbound;
@@ -35,11 +37,11 @@
private readonly IRepository<Dt_StockInfoDetail> _stockInfoDetailRepository;
private readonly IRepository<Dt_StockInfo> _stockInfoRepository;
private readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
-
+ private readonly IMaterialUnitService _materialUnitService;
private readonly IOutboundOrderService _outboundOrderService;
private readonly IOutboundOrderDetailService _outboundOrderDetailService;
private readonly IOutStockLockInfoService _outStockLockInfoService;
- public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService)
+ public InvokeMESService(IHttpClientFactory httpClientFactory, ILogger<InvokeMESService> logger, IRepository<Dt_FeedbackToMes> feedbacktomesRepository, IRepository<Dt_StockInfoDetail> stockInfoDetailRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IOutStockLockInfoService outStockLockInfoService, IMaterialUnitService materialUnitService)
{
_httpClientFactory = httpClientFactory;
_logger = logger;
@@ -50,6 +52,7 @@
_outboundOrderService = outboundOrderService;
_outboundOrderDetailService = outboundOrderDetailService;
_outStockLockInfoService = outStockLockInfoService;
+ _materialUnitService = materialUnitService;
}
/// <summary>
@@ -115,9 +118,11 @@
public async Task<ResponseModel> FeedbackAllocate(AllocateDto model)
{
+ _logger.LogInformation($"InvokeMESService FeedbackAllocate 搴忓垪鍖栧墠: {JsonConvert.SerializeObject(model)}");
string json = JsonConvert.SerializeObject(model, new JsonSerializerSettings
{
- ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
+ ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(),
+ NullValueHandling = NullValueHandling.Include
});
var content = new StringContent(json, Encoding.UTF8, "application/json");
var _client = _httpClientFactory.CreateClient("MESUrl");
@@ -246,42 +251,89 @@
var inboundOrder = _inboundOrderRepository.Db.Queryable<Dt_InboundOrder>().First(x => x.InboundOrderNo == lists.FirstOrDefault().OrderNo);
if (inboundOrder != null)
{
- var feedmodel = new FeedbackInboundRequestModel
+ if (inboundOrder.OrderType == (int)InOrderTypeEnum.AllocatInbound)//璋冩嫧鍏ュ簱
{
- reqCode = Guid.NewGuid().ToString(),
- reqTime = DateTime.Now.ToString(),
- business_type = inboundOrder.BusinessType,
- factoryArea = inboundOrder.FactoryArea,
- operationType = 1,
- Operator = inboundOrder.Operator,
- orderNo = inboundOrder.UpperOrderNo,
- status = inboundOrder.OrderStatus,
- details = new List<FeedbackInboundDetailsModel>()
+ var allocate = SqlSugarHelper.DbWMS.Queryable<Dt_AllocateOrder>().Where(x => x.OrderNo == inboundOrder.InboundOrderNo).First();
+ var allocatefeedmodel = new AllocateDto
+ {
+ ReqCode = Guid.NewGuid().ToString(),
+ ReqTime = DateTime.Now.ToString(),
+ BusinessType = "2",
+ FactoryArea = inboundOrder.FactoryArea,
+ OperationType = 1,
+ Operator = inboundOrder.Operator,
+ OrderNo = inboundOrder.UpperOrderNo,
+ fromWarehouse = allocate?.FromWarehouse ?? "",
+ toWarehouse = allocate?.ToWarehouse ?? "",
+ Details = new List<AllocateDtoDetail>()
- };
+ };
- var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
- .Select(group => new FeedbackInboundDetailsModel
- {
- materialCode = group.Key.MaterielCode,
- supplyCode = group.Key.SupplyCode,
- batchNo = group.Key.BatchNo,
- lineNo = group.Key.InboundOrderRowNo,
- qty = group.Sum(x => x.BarcodeQty),
- // warehouseCode = group.Key.WarehouseCode=="0"?"1072": group.Key.WarehouseCode,
- warehouseCode = group.Key.WarehouseCode,
- unit = group.Key.BarcodeUnit,
- barcodes = group.Select(row => new FeedbackBarcodesModel
+ var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new AllocateDtoDetail
{
- barcode = row.Barcode,
- qty = row.BarcodeQty
- }).ToList()
- }).ToList();
- feedmodel.details = groupedData;
- var result = await FeedbackInbound(feedmodel);
- if (result != null && result.code == 200)
+ MaterialCode = group.Key.MaterielCode,
+ LineNo = group.Key.InboundOrderRowNo,
+ WarehouseCode = group.Key.WarehouseCode,
+ Qty = group.Sum(x => x.BarcodeQty),
+ // warehouseCode= "1072",
+ Unit = group.Key.BarcodeUnit,
+ Barcodes = group.Select(row => new BarcodeInfo
+ {
+ Barcode = row.Barcode,
+ Qty = row.BarcodeQty,
+ BatchNo = row.BatchNo,
+ SupplyCode = row.SupplyCode,
+ Unit = row.Unit
+ }).ToList()
+ }).ToList();
+ allocatefeedmodel.Details = groupedData;
+
+ var result = await FeedbackAllocate(allocatefeedmodel);
+ if (result != null && result.code == 200)
+ {
+ _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
+ }
+ }
+ else
{
- _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
+ var feedmodel = new FeedbackInboundRequestModel
+ {
+ reqCode = Guid.NewGuid().ToString(),
+ reqTime = DateTime.Now.ToString(),
+ business_type = inboundOrder.BusinessType,
+ factoryArea = inboundOrder.FactoryArea,
+ operationType = 1,
+ Operator = inboundOrder.Operator,
+ orderNo = inboundOrder.UpperOrderNo,
+ status = inboundOrder.OrderStatus,
+ details = new List<FeedbackInboundDetailsModel>()
+
+ };
+
+ var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group => new FeedbackInboundDetailsModel
+ {
+ materialCode = group.Key.MaterielCode,
+ supplyCode = group.Key.SupplyCode,
+ batchNo = group.Key.BatchNo,
+ lineNo = group.Key.InboundOrderRowNo,
+ qty = group.Sum(x => x.BarcodeQty),
+ // warehouseCode = group.Key.WarehouseCode=="0"?"1072": group.Key.WarehouseCode,
+ warehouseCode = group.Key.WarehouseCode,
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(row => new FeedbackBarcodesModel
+ {
+ barcode = row.Barcode,
+ qty = row.BarcodeQty
+ }).ToList()
+ }).ToList();
+ feedmodel.details = groupedData;
+ var result = await FeedbackInbound(feedmodel);
+ if (result != null && result.code == 200)
+ {
+ _feedbacktomesRepository.Db.Insertable(new Dt_FeedbackToMes { OrderNo = orderNo, PalletCode = item.PalletCode, ReportStatus = 1 }).ExecuteCommand();
+ }
}
}
}
@@ -376,27 +428,40 @@
{
// 鑾峰彇璇ユ槑缁嗗搴旂殑鏉$爜淇℃伅锛堜粠閿佸畾璁板綍锛�
var detailLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.OrderNo == orderNo && detailids.Contains(x.OrderDetailId) &&
+ .Where(x => x.OrderNo == orderNo && detail.Id == x.OrderDetailId &&
x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
.ToListAsync();
-
var detailModel = new FeedbackOutboundDetailsModel
{
materialCode = detail.MaterielCode,
lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
warehouseCode = detail.WarehouseCode,
- qty = detail.OverOutQuantity, // 浣跨敤璁㈠崟鏄庣粏鐨勫凡鍑哄簱鏁伴噺
- currentDeliveryQty = detail.OverOutQuantity,
- unit = detail.Unit,
- barcodes = detailLocks.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
- {
- barcode = lockInfo.CurrentBarcode,
- supplyCode = lockInfo.SupplyCode,
- batchNo = lockInfo.BatchNo,
- unit = lockInfo.Unit,
- qty = lockInfo.PickedQty // 鏉$爜绾у埆鐨勬暟閲忎粛鐢ㄩ攣瀹氳褰�
- }).ToList()
+ qty = detail.BarcodeQty, // 浣跨敤璁㈠崟鏄庣粏鐨勫凡鍑哄簱鏁伴噺
+ currentDeliveryQty = detail.BarcodeQty,
+ unit = detail.BarcodeUnit,
+ barcodes = new List<WIDESEA_DTO.Outbound.BarcodesModel>()
};
+
+ foreach (var item in detailLocks)
+ {
+ var barmodel = new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = item.CurrentBarcode,
+ supplyCode = item.SupplyCode,
+ batchNo = item.BatchNo,
+ unit = item.BarcodeUnit,
+ qty = item.BarcodeQty // 鏉$爜绾у埆鐨勬暟閲忎粛鐢ㄩ攣瀹氳褰�
+ };
+ if (item.BarcodeUnit != item.Unit)
+ {
+ var issueoStockResult = await _materialUnitService.ConvertAsync(item.MaterielCode, item.BarcodeQty, item.Unit, item.BarcodeUnit);
+ barmodel.unit = issueoStockResult.Unit;
+ barmodel.qty = issueoStockResult.Quantity;
+ }
+ detailModel.qty += barmodel.qty;
+ detailModel.currentDeliveryQty += barmodel.qty;
+ detailModel.barcodes.Add(barmodel);
+ }
feedmodel.details.Add(detailModel);
}
@@ -420,6 +485,33 @@
.SetColumns(x => x.ReturnToMESStatus == 1)
.Where(x => x.OrderNo == orderNo)
.ExecuteCommandAsync();
+ }
+ else
+ {
+ var dborderDetails = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+ .LeftJoin<Dt_OutboundOrder>((o, item) => o.OrderId == item.Id)
+ .Where((o, item) => item.OrderNo == orderNo && item.ReturnToMESStatus != 1)
+ .Select((o, item) => o)
+ .ToListAsync();
+ var secallCompleted = true;
+ foreach (var detail in orderDetails.Where(x => x.ReturnToMESStatus == 0).ToList())
+ {
+ if (detail.OverOutQuantity < detail.NeedOutQuantity)
+ {
+ secallCompleted = false;
+ }
+ }
+ if (secallCompleted)
+ {
+ await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+ .SetColumns(it => new Dt_OutboundOrder
+ {
+ ReturnToMESStatus = 1,
+ OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt(),
+ })
+ .Where(x => x.OrderNo == orderNo)
+ .ExecuteCommandAsync();
+ }
}
}
else
@@ -504,25 +596,27 @@
x.Status == (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
.ToListAsync();
- var detailModel = new FeedbackOutboundDetailsModel
- {
- materialCode = detail.MaterielCode,
- lineNo = detail.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
- warehouseCode = detail.WarehouseCode,
- qty = detail.OverOutQuantity, // 浣跨敤璁㈠崟鏄庣粏鐨勫凡鍑哄簱鏁伴噺
- currentDeliveryQty = detail.OverOutQuantity,
- unit = detail.Unit,
- barcodes = detailLocks.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
- {
- barcode = lockInfo.CurrentBarcode,
- supplyCode = lockInfo.SupplyCode,
- batchNo = lockInfo.BatchNo,
- unit = lockInfo.Unit,
- qty = lockInfo.PickedQty // 鏉$爜绾у埆鐨勬暟閲忎粛鐢ㄩ攣瀹氳褰�
- }).ToList()
- };
- feedmodel.details.Add(detailModel);
+ var groupdata = detailLocks.GroupBy(item => new { item.MaterielCode,item.lineNo, item.BarcodeUnit, item.WarehouseCode })
+ .Select(group =>new FeedbackOutboundDetailsModel
+ {
+
+ materialCode = group.Key.MaterielCode,
+ lineNo = group.Key.lineNo, // 娉ㄦ剰锛氳繖閲屽彲鑳介渶瑕佽皟鏁村瓧娈靛悕
+ warehouseCode = group.Key.WarehouseCode,
+ qty = group.Sum(x => x.BarcodeQty),
+ currentDeliveryQty = group.Sum(x => x.BarcodeQty),
+ unit = group.Key.BarcodeUnit,
+ barcodes = group.Select(lockInfo => new WIDESEA_DTO.Outbound.BarcodesModel
+ {
+ barcode = lockInfo.CurrentBarcode,
+ supplyCode = lockInfo.SupplyCode,
+ batchNo = lockInfo.BatchNo,
+ unit = lockInfo.BarcodeUnit,
+ qty = lockInfo.BarcodeQty // 鏉$爜绾у埆鐨勬暟閲忎粛鐢ㄩ攣瀹氳褰�
+ }).ToList()
+ }).ToList();
+ feedmodel.details.AddRange(groupdata);
}
var result = await FeedbackOutbound(feedmodel);
--
Gitblit v1.9.3