From 91ead18d0e92b6e1ed916c5159f3431bf2071a56 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期五, 12 十二月 2025 13:59:40 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_AllocateService/AllocateService.cs | 172 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 149 insertions(+), 23 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 005d6fc..89a2938 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,13 +1,5 @@
-锘縰sing Autofac.Core;
-using MailKit.Search;
-using Microsoft.Extensions.Logging;
+锘縰sing Microsoft.Extensions.Logging;
using SqlSugar;
-using SqlSugar.Extensions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using WIDESEA_Common.AllocateEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
@@ -15,9 +7,10 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.DB;
-using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
using WIDESEA_Core.Seed;
using WIDESEA_IAllocateService;
+using WIDESEA_IBasicService;
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_Model.Models;
@@ -33,6 +26,8 @@
public readonly IOutboundService _outboundService;
public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
public readonly IRepository<Dt_AllocateOrderDetail> _allocateOrderDetailRepository;
+ private readonly IMaterielInfoService _materielInfoService;
+ public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
private readonly ILogger<AllocateService> _logger;
public AllocateService(IRepository<Dt_AllocateOrder> BaseDal,
@@ -41,7 +36,9 @@
IOutboundService outboundService,
IRepository<Dt_AllocateOrder> allocateOrderRepository,
IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository,
- ILogger<AllocateService> logger) : base(BaseDal)
+ IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository,
+ ILogger<AllocateService> logger,
+ IMaterielInfoService materielInfoService) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_inboundService = inboundService;
@@ -49,6 +46,8 @@
_allocateOrderRepository = allocateOrderRepository;
_allocateOrderDetailRepository = allocateOrderDetailRepository;
_logger = logger;
+ _inboundOrderDetailRepository = inboundOrderDetailRepository;
+ _materielInfoService = materielInfoService;
}
public IRepository<Dt_AllocateOrder> Repository => BaseDal;
@@ -79,9 +78,18 @@
{
if (BaseDal.QueryFirst(x => x.UpperOrderNo == allocateOrder.UpperOrderNo) != null)
{
- return WebResponseContent.Instance.Error($"璋冩嫧鍗曞彿閲嶅");
+ return WebResponseContent.Instance.Error($"{allocateOrder.UpperOrderNo}璋冩嫧鍗曞彿閲嶅");
}
allocateOrder.OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.AllocateOrderCodeRule));
+ var materielCodes = allocateOrder.Details.Select(x => x.MaterielCode).Distinct().ToList();
+ var materielInfos = _materielInfoService.Db.Queryable<Dt_MaterielInfo>().Where(x => materielCodes.Contains(x.MaterielCode)).ToList();
+ foreach (var item in allocateOrder.Details)
+ {
+ if (materielInfos.Any())
+ {
+ item.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? "";
+ }
+ }
Db.InsertNav(allocateOrder).Include(x => x.Details).ExecuteCommand();
await AddInOutData(allocateOrder);
return WebResponseContent.Instance.OK();
@@ -99,7 +107,7 @@
{
if (businessType == BusinessTypeEnum.澶栭儴浠撳簱璋冩櫤浠�)
{
- allocateOrder.OrderType = InOrderTypeEnum.AllocatInbound.ObjToInt();
+ allocateOrder.OrderType = (int)InOrderTypeEnum.AllocatInbound;
var inboundOrders = ConvertToInboundOrders(allocateOrder);
await _inboundService.InbounOrderService.ReceiveInboundOrder(inboundOrders, 1);
}
@@ -107,11 +115,11 @@
{
if (businessType == BusinessTypeEnum.鏅轰粨璋冨閮ㄤ粨搴�)
{
- allocateOrder.OrderType = InOrderTypeEnum.AllocatOutbound.ObjToInt();
+ allocateOrder.OrderType = (int)InOrderTypeEnum.AllocatOutbound;
}
else if (businessType == BusinessTypeEnum.鏅轰粨璋冩櫤浠�)
{
- allocateOrder.OrderType = InOrderTypeEnum.InternalAllocat.ObjToInt();
+ allocateOrder.OrderType = (int)InOrderTypeEnum.InternalAllocat;
}
var outboundOrders = ConvertToOutboundOrders(allocateOrder);
@@ -141,13 +149,13 @@
List<Dt_AllocateOrderDetail> allocateOrderDetails = new List<Dt_AllocateOrderDetail>();
List<Dt_AllocateOrderDetail> updateAllocateOrderDetails = new List<Dt_AllocateOrderDetail>();
List<int> detailIds = new List<int>();
+
+ var materielCodes = allocateOrder.Details.Select(x => x.MaterielCode).Distinct().ToList();
+ var materielInfos = _materielInfoService.Db.Queryable<Dt_MaterielInfo>().Where(x => materielCodes.Contains(x.MaterielCode)).ToList();
+
foreach (var item in model.Details)
{
- if (string.IsNullOrEmpty(item.Barcode))
- {
-
- }
- else
+ if (!string.IsNullOrEmpty(item.Barcode))
{
Dt_AllocateOrderDetail? allocateOrderDetail = allocateOrder.Details.FirstOrDefault(x => x.Barcode == item.Barcode);
if (allocateOrderDetail == null)
@@ -165,6 +173,10 @@
BarcodeQty = (decimal)item.BarcodeQty,
OrderQuantity = item.OrderQuantity
};
+ if (materielInfos.Any())
+ {
+ allocateOrderDetail.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? "";
+ }
allocateOrderDetails.Add(allocateOrderDetail);
}
else
@@ -178,7 +190,10 @@
allocateOrderDetail.BarcodeUnit = item.BarcodeUnit;
allocateOrderDetail.BarcodeQty = item.BarcodeQty;
allocateOrderDetail.OrderQuantity = item.OrderQuantity;
-
+ if (materielInfos.Any())
+ {
+ allocateOrderDetail.MaterielName = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterielCode)?.MaterielName ?? "";
+ }
updateAllocateOrderDetails.Add(allocateOrderDetail);
detailIds.Add(allocateOrderDetail.Id);
@@ -357,8 +372,8 @@
MaterielName = "",
BatchNo = item.Detail.BatchNo,
OrderQuantity = item.Detail.OrderQuantity,
- BarcodeQty = (decimal)item.Detail.BarcodeQty,
- BarcodeUnit = item.Detail.BarcodeUnit,
+ BarcodeQty = item.Detail.BarcodeQty??0,
+ BarcodeUnit = item.Detail.BarcodeUnit??"",
LockQuantity = 0,
lineNo = item.Detail.LineNo,
OverOutQuantity = 0,
@@ -431,5 +446,116 @@
return code;
}
}
+
+ public override PageGridData<Dt_AllocateOrder> GetPageData(PageDataOptions options)
+ {
+ string wheres = ValidatePageOptions(options);
+ //鑾峰彇鎺掑簭瀛楁
+ Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+ List<OrderByModel> orderByModels = new List<OrderByModel>();
+ foreach (var item in orderbyDic)
+ {
+ OrderByModel orderByModel = new()
+ {
+ FieldName = item.Key,
+ OrderByType = item.Value
+ };
+ orderByModels.Add(orderByModel);
+ }
+
+
+ int totalCount = 0;
+ List<SearchParameters> searchParametersList = new List<SearchParameters>();
+ if (!string.IsNullOrEmpty(options.Wheres))
+ {
+ try
+ {
+ searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+ options.Filter = searchParametersList;
+ }
+ catch { }
+ }
+ var data = BaseDal.Db.Queryable<Dt_AllocateOrder>()
+ .WhereIF(!wheres.IsNullOrEmpty(), wheres)
+ .OrderBy(orderByModels)
+ .ToPageList(options.Page, options.Rows, ref totalCount);
+
+ foreach (var item in data)
+ {
+ Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == item.UpperOrderNo).First();
+ Dt_OutboundOrder OutboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == item.UpperOrderNo).First();
+ if (_InboundOrder != null)
+ {
+ item.OrderStatus = _InboundOrder.OrderStatus;
+ item.OrderType = _InboundOrder.OrderType;
+ }else if (OutboundOrder!=null)
+ {
+ item.OrderStatus = OutboundOrder.OrderStatus;
+ item.OrderType = OutboundOrder.OrderType;
+ }
+ }
+ return new PageGridData<Dt_AllocateOrder>(totalCount, data);
+ }
+
+ public override PageGridData<Dt_InboundOrderDetail> GetDetailPage(PageDataOptions options)
+ {
+ string wheres = ValidatePageOptions(options);
+ //鑾峰彇鎺掑簭瀛楁
+ Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+ List<OrderByModel> orderByModels = new List<OrderByModel>();
+ foreach (var item in orderbyDic)
+ {
+ OrderByModel orderByModel = new()
+ {
+ FieldName = item.Key,
+ OrderByType = item.Value
+ };
+ orderByModels.Add(orderByModel);
+ }
+
+
+ int totalCount = 0;
+ List<SearchParameters> searchParametersList = new List<SearchParameters>();
+ if (!string.IsNullOrEmpty(options.Wheres))
+ {
+ try
+ {
+ searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+ options.Filter = searchParametersList;
+ }
+ catch { }
+ }
+ //var data = BaseDal.Db.Queryable<Dt_AllocateOrderDetail>()
+ // .WhereIF(!wheres.IsNullOrEmpty(), wheres)
+ // .OrderBy(orderByModels)
+ // .ToPageList(options.Page, options.Rows, ref totalCount);
+ //Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == (int)options.Value);
+ //Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First();
+ //var details = _inboundOrderDetailRepository.QueryData(x => x.OrderId == _InboundOrder.Id );
+ //foreach (var item in data)
+ //{
+ // var detail = details.Where(x => x.MaterielCode == item.MaterielCode).FirstOrDefault();
+ // if (detail != null)
+ // {
+ // item.OrderQuantity = detail.OrderQuantity;
+ // item.ReceiptQuantity = detail.ReceiptQuantity;
+ // item.OverInQuantity = detail.OverInQuantity;
+ // item.OrderDetailStatus = detail.OrderDetailStatus;
+ // }
+ //}
+ //return new PageGridData<Dt_AllocateOrderDetail>(totalCount, data);
+
+ Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == (int)options.Value);
+ Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First();
+ var Id = _InboundOrder == null ? 0 : _InboundOrder.Id;
+ var data = BaseDal.Db.Queryable<Dt_InboundOrderDetail>()
+ .WhereIF(!wheres.IsNullOrEmpty(), wheres)
+ .Where( x => x.OrderId == Id)
+ .OrderBy(orderByModels)
+ .ToPageList(options.Page, options.Rows, ref totalCount);
+
+
+ return new PageGridData<Dt_InboundOrderDetail>(totalCount, data);
+ }
}
}
--
Gitblit v1.9.3