From b39f01141a3ec0dfff105647a485033f7cf27dc7 Mon Sep 17 00:00:00 2001
From: duyongjia <adu_555@163.com>
Date: 星期五, 28 二月 2025 09:02:26 +0800
Subject: [PATCH] 增加数据脚本
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 159 insertions(+), 4 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs"
index 3c140a4..67d309a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs"
@@ -1,6 +1,7 @@
-锘縰sing Org.BouncyCastle.Crypto;
+锘縰sing Newtonsoft.Json;
+using Org.BouncyCastle.Crypto;
using SqlSugar;
-using SqlSugar.Extensions;
+//using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,17 +9,24 @@
using System.Threading.Tasks;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicRepository;
using WIDESEA_IStockRepository;
+using WIDESEA_Model;
using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.System.Reponse;
+using WIDESEA_Model.Models.System.Request;
namespace WIDESEA_StockRepository
{
public class StockInfoRepository : RepositoryBase<Dt_StockInfo>, IStockInfoRepository
{
- public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
+ private readonly ILabelMasterRepository _labelMasterRepository;
+ public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage,ILabelMasterRepository labelMasterRepository) : base(unitOfWorkManage)
{
+ _labelMasterRepository = labelMasterRepository;
}
public List<StockViewDTO> GetAllStockViews()
@@ -65,9 +73,20 @@
//return sugarQueryable.InnerJoin(sugarQueryable1, (a, b) => a.LocationCode == b.LocationCode).Select((a, b) => b).Includes(x => x.Details).ToList();
}
+ /// <summary>
+ /// 鏍规嵁鎵规鍙峰拰鐗╂枡缂栫爜鑾峰彇搴撳瓨淇℃伅
+ /// </summary>
+ /// <param name="materielCode"></param>
+ /// <returns></returns>
+ public List<Dt_StockInfo> GetStockInfos(string materielCode,string batchNo)
+ {
+ return Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode&&v.BatchNo==batchNo)).ToList();
+ }
+
public List<Dt_StockInfo> GetStockInfos(string materielCode, List<string> locationCodes)
{
- return Db.Queryable<Dt_StockInfo>().Where(x => locationCodes.Contains(x.LocationCode)).Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList();
+ //淇敼鍙幏鍙栧凡涓婃灦鐘舵�佺殑搴撳瓨
+ return Db.Queryable<Dt_StockInfo>().Where(x => locationCodes.Contains(x.LocationCode)&&x.StockStatus== (int)StockStatusEmun.宸蹭笂鏋�).Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList();
//ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>().Where(x => locationCodes.Contains(x.LocationCode));
@@ -82,6 +101,7 @@
public List<Dt_StockInfo> GetStockInfosByPalletCodes(List<string> palletCodes)
{
+
return Db.Queryable<Dt_StockInfo>().Where(x => palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).ToList();
}
@@ -112,5 +132,140 @@
return Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt() && x.PalletCode.Substring(0, 1) == "B" && SqlFunc.Subqueryable<Dt_LocationInfo>().Where(v => v.LocationCode == x.LocationCode && v.RoadwayNo == roadwayNo && v.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (EnableStatusEnum.Normal.ObjToInt() == v.EnableStatus)).Any()).OrderBy(x => x.ModifyDate).First();
}
}
+
+
+ /// <summary>
+ /// 绔嬪簱WMS搴撳瓨淇℃伅鎺ュ彛锛屼緵涓婃父绯荤粺璋冪敤
+ /// </summary>
+ /// <param name="inventoryQueryRequest"></param>
+ /// <returns></returns>
+ public InventoryQueryResponse InventoryQuery(string inventoryQueryRequeststr)
+ {
+ InventoryQueryResponse inventoryQueryResponse = new InventoryQueryResponse();
+ try
+ {
+ InventoryQueryRequest inventoryQueryRequest = JsonConvert.DeserializeObject<InventoryQueryRequest>(inventoryQueryRequeststr);
+ if (inventoryQueryRequest != null)
+ {
+ List<StockItem> DATA = new List<StockItem>();
+ inventoryQueryResponse.DATA = DATA;
+ List<StockViewDTO> stockviews = GetAllStockViews();
+ foreach (var view in stockviews)
+ {
+ foreach (var detail in view.Details)
+ {
+ Dt_LabelMaster labelMaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == detail.SerialNumber);
+ StockItem stockItem = new StockItem();
+ stockItem.BATCH = detail.BatchNo;
+ stockItem.LABEL_NO = detail.SerialNumber;
+ stockItem.LGORT = "0030";//搴撲綅
+ if (labelMaster != null)
+ {
+ if (labelMaster.WH_NUMBER == inventoryQueryRequest.DATA[0].WH_NUMBER && labelMaster.WERKS == inventoryQueryRequest.DATA[0].WH_NUMBER)
+ {
+ stockItem.LIFNR = labelMaster.LIFNR;
+ stockItem.LIKTX = labelMaster.LIKTX;
+ stockItem.LK_BIN_CODE = view.LocationCode;
+ stockItem.MAKTX = labelMaster.MAKTX;
+ stockItem.MATNR = labelMaster.MATNR;
+ stockItem.MEINS = labelMaster.UNIT;
+ stockItem.QTY = labelMaster.BOX_QTY;
+ stockItem.SOBKZ = labelMaster.SOBKZ;
+ stockItem.TPNUM = view.PalletCode;
+ stockItem.WERKS = labelMaster.WERKS;//宸ュ巶
+ stockItem.WH_NUMBER = labelMaster.WH_NUMBER;//浠撳簱鍙�
+ DATA.Add(stockItem);
+ }
+ }
+ }
+ }
+ if (DATA.Count > 0)
+ {
+ inventoryQueryResponse.MSGTY = "S";
+ inventoryQueryResponse.MSGTX = "";
+ }
+ else
+ {
+ inventoryQueryResponse.MSGTY = "I";
+ inventoryQueryResponse.MSGTX = "";
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ inventoryQueryResponse.MSGTY = "E";
+ inventoryQueryResponse.MSGTX = ex.Message;
+
+ }
+ return inventoryQueryResponse;
+
+ }
+
+ /// <summary>
+ /// 绔嬪簱WMS鍐荤粨/瑙e喕淇℃伅鎺ュ彛锛屼緵涓婃父绯荤粺璋冪敤
+ /// </summary>
+ /// <param name="freezeByCustomerResponse"></param>
+ /// <returns></returns>
+ public freezeByCustomerResponse freezeByCustomer(string freezeRequeststr)
+ {
+
+ freezeByCustomerResponse freezeResponse = new freezeByCustomerResponse();
+ try
+ {
+ freezeByCustomerRequest freezeRequest = JsonConvert.DeserializeObject<freezeByCustomerRequest>(freezeRequeststr);
+ if (freezeRequest.WERKS == AppSettings.Configuration["WERKS"] && freezeRequest.WH_NUMBER == AppSettings.Configuration["SYSNO"])
+ {
+ //鏍规嵁鎵规鍜岀墿鏂欏彿鏌ユ壘瀵瑰簲鐨勬墭鐩樺彿锛屽喕缁撳簱瀛橈紝鍙湁鍏ュ簱鎴愬姛浜嗭紝鎵嶈兘琚喕缁�
+ List<Dt_StockInfo> stockInfos = GetStockInfos(freezeRequest.MATNR, freezeRequest.BATCH);
+ if (freezeRequest.FREEZE_TYPE == "00")//00鍐荤粨
+ {
+ foreach (var item in stockInfos)
+ {
+ if (item.StockStatus == (int)StockStatusEmun.宸插叆搴�)
+ {
+ item.StockStatus = (int)StockStatusEmun.鍑哄簱鍐荤粨;
+ UpdateData(item);
+ }
+ }
+ freezeResponse.MSGTY = "S";
+ freezeResponse.MSGTX = "";
+ }
+ else if (freezeRequest.FREEZE_TYPE == "01") //01瑙e喕
+ {
+ foreach (var item in stockInfos)
+ {
+ if (item.StockStatus == (int)StockStatusEmun.鍑哄簱鍐荤粨)
+ {
+ item.StockStatus = (int)StockStatusEmun.宸插叆搴�;
+ UpdateData(item);
+ }
+ }
+ freezeResponse.MSGTY = "S";
+ freezeResponse.MSGTX = "";
+
+ }
+ else
+ {
+ freezeResponse.MSGTY = "E";
+ freezeResponse.MSGTX = "涓嶆敮鎸佽涓氬姟绫诲瀷";
+ }
+ }
+ else
+ {
+ freezeResponse.MSGTY = "E";
+ freezeResponse.MSGTX = "璇蜂紶鍏ユ纭殑宸ュ巶鍙峰拰浠撳簱鍙�";
+
+ }
+
+ }
+ catch (Exception ex)
+ {
+ freezeResponse.MSGTY = "E";
+ freezeResponse.MSGTX = ex.Message;
+
+ }
+ return freezeResponse;
+
+ }
}
}
--
Gitblit v1.9.3