From edc7293bf81729ebaa2d7cdd9a1f3aeaf567f538 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 31 十二月 2025 17:32:08 +0800
Subject: [PATCH] 更新
---
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 510 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 374 insertions(+), 136 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
index 721cf23..0dd2c7b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs"
@@ -2,6 +2,7 @@
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+using OfficeOpenXml.FormulaParsing.Excel.Operators;
using SqlSugar;
using System;
using System.Collections;
@@ -51,12 +52,7 @@
return WebResponseContent.Instance.OK($"璇ユ墭鐩樺凡鐢熸垚浠诲姟", _mapper.Map<WMSTaskDTO>(task));
}
- if (Repository.QueryFirst(x => x.SourceAddress == stationCode && x.TaskStatus == TaskStatusEnum.New.ObjToInt()) != null)
- {
- return WebResponseContent.Instance.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�");
- }
-
- Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+ Dt_ProStockInfo stockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
if (stockInfo == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
@@ -98,7 +94,7 @@
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
- _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ _stockRepository.ProStockInfoRepository.UpdateData(stockInfo);
_unitOfWorkManage.CommitTran();
WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
@@ -216,8 +212,13 @@
else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfoOld.IsPick==WhetherEnum.False.ObjToInt() && stationCode.IsNotEmptyOrNull())
{
decimal oldQty = stockInfoOld.StockLength;
- //璋冪敤鏇存柊閫�鏂欏簱瀛�
- stockInfoOld = ReturnStockUp(stockInfoOld, thickness);
+ //璋冪敤鏇存柊閫�鏂欏簱瀛樺強涓婃姤閲嶉噺
+ WebResponseContent returnContent = ReturnStockUp(stockInfoOld, thickness, weight);
+ if (!returnContent.Status)
+ {
+ throw new Exception(returnContent.Message);
+ }
+ stockInfoOld = returnContent.Data as Dt_StockInfo;
//鏇存柊鏁版嵁
UpdateStock(stockInfoOld, weight, thickness, wide);
//璁板綍搴撳瓨鍙樺姩
@@ -227,8 +228,13 @@
else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�鏂欐殏瀛�.ObjToInt() && stationCode.IsNotEmptyOrNull())
{
decimal oldQty = stockInfoOld.StockLength;
- //璋冪敤鏇存柊閫�鏂欏簱瀛�
- stockInfoOld = ReturnStockUp(stockInfoOld, thickness);
+ //璋冪敤鏇存柊閫�鏂欏簱瀛樺強涓婃姤閲嶉噺
+ WebResponseContent returnContent = ReturnStockUp(stockInfoOld, thickness, weight);
+ if (!returnContent.Status)
+ {
+ throw new Exception(returnContent.Message);
+ }
+ stockInfoOld = returnContent.Data as Dt_StockInfo;
//鏇存柊鏁版嵁
UpdateStock(stockInfoOld, weight, thickness, wide);
//璁板綍搴撳瓨鍙樺姩
@@ -349,32 +355,64 @@
/// 鏇存柊閫�鏂欏簱瀛�
/// </summary>
/// <returns></returns>
- public Dt_StockInfo ReturnStockUp(Dt_StockInfo stockInfoOld,decimal thickness)
+ public WebResponseContent ReturnStockUp(Dt_StockInfo stockInfoOld,decimal thickness,decimal weight)
{
- BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(stockInfoOld.PalletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>();
- if (bSTResponse.Code == 500)
+ WebResponseContent content = new WebResponseContent();
+ try
{
- throw new Exception($"鏈壘鍒版潯鐮亄stockInfoOld.PalletCode}涓�鏈烢RP搴撳瓨涓嶅瓨鍦�");
- }
+ BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(stockInfoOld.PalletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>();
+ if (bSTResponse.Code == 500)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄stockInfoOld.PalletCode}涓�鏈烢RP搴撳瓨涓嶅瓨鍦�");
+ }
- BSTStockInfoDTO bSTStockInfoDTO = bSTResponse.Data ?? throw new Exception($"涓�鏈烢RP鏈繑鍥瀧stockInfoOld.PalletCode}鐨勫簱瀛樹俊鎭�");
- if (stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�鏂欐殏瀛�.ObjToInt())
- {
- stockInfoOld.IsPick = WhetherEnum.False.ObjToInt();
+ BSTStockInfoDTO bSTStockInfoDTO = bSTResponse.Data ?? throw new Exception($"涓�鏈烢RP鏈繑鍥瀧stockInfoOld.PalletCode}鐨勫簱瀛樹俊鎭�");
+ if (stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�鏂欐殏瀛�.ObjToInt())
+ {
+ stockInfoOld.IsPick = WhetherEnum.False.ObjToInt();
+ }
+ decimal stockLength = bSTStockInfoDTO.StockMeter;
+ if (weight != bSTStockInfoDTO.Qty)
+ {
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == stockInfoOld.MaterielId);
+ int gramWeight = (int)(materielInfo.MaterielWeight * 1000);
+ BSTWeightUpDTO bSTWeightUpDTO = new BSTWeightUpDTO()
+ {
+ Paper_code = stockInfoOld.PalletCode,
+ Estimate_weight = bSTStockInfoDTO.Qty,
+ Actual_weight = weight,
+ Error_weight = Math.Abs(weight - bSTStockInfoDTO.Qty),
+ Weigh_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ Operator = "LiKu",
+ Width = bSTStockInfoDTO.W,
+ Gram_weight = gramWeight
+ };
+ BSTResponse<object> Response = _invokeERPService.BSTWeightUp(bSTWeightUpDTO).DeserializeObject<BSTResponse<object>>();
+ if (Response.Code != 200)
+ {
+ throw new Exception($"涓婃姤绉伴噸澶辫触");
+ }
+ stockLength = weight / bSTStockInfoDTO.W / gramWeight * 1000000;
+ }
+ stockInfoOld.StockStatus = StockStatusEmun.鑰佸巶閫�搴�.ObjToInt();
+ stockInfoOld.MaterielThickness = bSTStockInfoDTO.Thick;
+ stockInfoOld.MaterielWeight = weight;
+ stockInfoOld.MaterielWide = bSTStockInfoDTO.W;
+ stockInfoOld.StockLength = stockLength;
+ stockInfoOld.IsFull = WhetherEnum.True.ObjToInt();
+ stockInfoOld.StockOutLength = 0;
+ stockInfoOld.WarehouseId = WarehouseEnum.LLDYL.ObjToInt();
+ if (thickness < 400)
+ {
+ throw new Exception($"RFID{stockInfoOld.RfidCode}鏉$爜{stockInfoOld.PalletCode}鐩村緞灏忎簬400mm");
+ }
+ content.OK("鎴愬姛",data:stockInfoOld);
}
- stockInfoOld.StockStatus = StockStatusEmun.鑰佸巶閫�搴�.ObjToInt();
- stockInfoOld.MaterielThickness = bSTStockInfoDTO.Thick;
- stockInfoOld.MaterielWeight = bSTStockInfoDTO.Qty;
- stockInfoOld.MaterielWide = bSTStockInfoDTO.W;
- stockInfoOld.StockLength = bSTStockInfoDTO.StockMeter;
- stockInfoOld.IsFull = WhetherEnum.True.ObjToInt();
- stockInfoOld.StockOutLength = 0;
- stockInfoOld.WarehouseId = WarehouseEnum.LLDYL.ObjToInt();
- if (thickness < 800)
+ catch (Exception ex)
{
- throw new Exception($"RFID{stockInfoOld.RfidCode}鏉$爜{stockInfoOld.PalletCode}鐩村緞灏忎簬800mm");
+ content.Error(ex.Message);
}
- return stockInfoOld;
+ return content;
}
public void UpdateStock(Dt_StockInfo stockInfo, decimal weight = 0, decimal thickness = 0, decimal wide = 0)
{
@@ -405,98 +443,200 @@
}
if (orderType>0) //鏂板巶绾稿嵎骞冲彴鍏ュ簱
{
- //鑾峰彇涓诲崟
- Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x=>x.OrderType==orderType).Includes(x=>x.Details).Where(x=>x.Details.Any(v=>v.BarCode==palletCode)).First();
- if (inboundOrder==null)
+ InOrderTypeEnum inOrderTypeEnum = (InOrderTypeEnum)orderType;
+ if (inOrderTypeEnum== InOrderTypeEnum.PurchaseIn)
{
- throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鍏ュ簱鍗曟嵁淇℃伅");
- }
- Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x=>x.BarCode == palletCode);
- if (inboundOrderDetail==null)
- {
- throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
- }
- if (inboundOrderDetail.MaterialWide < 700)
- {
- return content.Error("鏂板巶鐗╂枡骞呭闄愬埗涓�700-2700mm");
- }
- if (inboundOrderDetail.MaterialThick<=0)
- {
- return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
- }
- if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
- {
- throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
- }
- Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
- if (yLInboundCache == null)
- {
- throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
- }
- int Id = yLInboundCache.Id;
- if (yLInboundCache.BarCode == palletCode)
- {
- throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
- }
- else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
- {
- yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
- yLInboundCache.Id = Id;
+ //鑾峰彇涓诲崟
+ Dt_PurchaseOrder inboundOrder = BaseDal.Db.Queryable<Dt_PurchaseOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == palletCode)).First();
- //鑾峰彇鐗╂枡
- Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
- //鐢熸垚搴撳瓨缁勭洏淇℃伅
- Dt_StockInfo stockInfo = new Dt_StockInfo()
+ if (inboundOrder == null)
{
- MaterielInvOrgId = materielInfo.MaterielInvOrgId,
- PalletCode = inboundOrderDetail.BarCode,
- RfidCode = "",
- LocationCode = "",
- PalletType = 1,
- WarehouseId = materielInfo.WarehouseId,
- StockAttribute = materielInfo.MaterielSourceType,
- StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
- MaterielSpec = materielInfo.MaterielSpec,
- Unit = materielInfo.MaterielUnit,
- MaterielThickness = inboundOrderDetail.MaterialThick,
- MaterielWide = inboundOrderDetail.MaterialWide,
- MaterielWeight = inboundOrderDetail.MaterialWeight,
- MaterielCode = materielInfo.MaterielCode,
- MaterielName = materielInfo.MaterielName,
- BatchNo=inboundOrderDetail.MaterialLot,
- StockLength = inboundOrderDetail.OrderQuantity
- };
- if (inboundOrderDetail.MaterialWide > 1200)
- {
- stockInfo.PalletType = 2;
+ throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘鍏ュ簱鍗曟嵁淇℃伅");
}
- inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
- _unitOfWorkManage.BeginTran();
- _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
- //鏂板缁勭洏淇℃伅
- _stockRepository.StockInfoRepository.AddData(stockInfo);
- if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ Dt_PurchaseOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == palletCode);
+
+ if (inboundOrderDetail == null)
{
- inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
- _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.PurchaseOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
}
- _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
- //鍚姩绾夸綋
- WebResponseContent webResponse = YLPurchasePush();
- if (!webResponse.Status)
+ if (inboundOrderDetail.PurchaseDetailWide < 690 || inboundOrderDetail.PurchaseDetailWide > 2500)
{
- throw new Exception(webResponse.Message);
+ return content.Error($"鐗╂枡骞呭闄愬埗涓�690-2500mm,褰撳墠绾稿嵎骞呭{inboundOrderDetail.PurchaseDetailWide}");
}
- _unitOfWorkManage.CommitTran();
- Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
- //璁板綍搴撳瓨鍙樺姩
- _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
- return content.OK("鎴愬姛", yLInboundCache);
+ if (inboundOrderDetail.PurchaseDetailThickness <= 0)
+ {
+ return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
+ }
+ if (inboundOrderDetail.PurchaseDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+ }
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
+ if (yLInboundCache == null)
+ {
+ throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+ }
+ int Id = yLInboundCache.Id;
+ if (yLInboundCache.BarCode == palletCode)
+ {
+ throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
+ }
+ else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+ {
+ yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
+ yLInboundCache.Id = Id;
+
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
+ //鐢熸垚搴撳瓨缁勭洏淇℃伅
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = inboundOrderDetail.BarCode,
+ RfidCode = "",
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = inboundOrderDetail.PurchaseDetailThickness,
+ MaterielWide = inboundOrderDetail.PurchaseDetailWide,
+ MaterielWeight = inboundOrderDetail.PurchaseDetailWeight,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ BatchNo = inboundOrderDetail.MaterialLot,
+ StockLength = inboundOrderDetail.PurchaseDetailQuantity
+ };
+ if (inboundOrderDetail.PurchaseDetailWide >= 1160)
+ {
+ stockInfo.PalletType = 2;
+ }
+ inboundOrderDetail.PurchaseDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ //鏂板缁勭洏淇℃伅
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ if (inboundOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ inboundOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.PurchaseOrderRepository.UpdateData(inboundOrder);
+ }
+ _inboundRepository.PurchaseOrderDetailRepository.UpdateData(inboundOrderDetail);
+ //鍚姩绾夸綋
+ WebResponseContent webResponse = YLPurchasePush();
+ if (!webResponse.Status)
+ {
+ throw new Exception(webResponse.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+ //璁板綍搴撳瓨鍙樺姩
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
+ return content.OK("鎴愬姛", yLInboundCache);
+ }
+ else
+ {
+ throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+ }
}
else
{
- throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+ //鑾峰彇涓诲崟
+ Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderType == orderType).Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == palletCode)).First();
+ if (inboundOrder == null)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鍏ュ簱鍗曟嵁淇℃伅");
+ }
+ Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == palletCode);
+ if (inboundOrderDetail == null)
+ {
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
+ }
+ if (inboundOrderDetail.MaterialWide < 690 || inboundOrderDetail.MaterialWide > 2500)
+ {
+ return content.Error($"鐗╂枡骞呭闄愬埗涓�690-2500mm,褰撳墠绾稿嵎骞呭{inboundOrderDetail.MaterialWide}");
+ }
+ if (inboundOrderDetail.MaterialThick <= 0)
+ {
+ return content.Error("鐗╂枡鐩村緞闇�瑕佸ぇ浜�0");
+ }
+ if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ throw new Exception($"鏉$爜{palletCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+ }
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
+ if (yLInboundCache == null)
+ {
+ throw new Exception("鏈壘鍒板師鏂欐潯鐮佺紦瀛樹俊鎭�");
+ }
+ int Id = yLInboundCache.Id;
+ if (yLInboundCache.BarCode == palletCode)
+ {
+ throw new Exception($"鏉$爜{palletCode}宸叉壂鐮�");
+ }
+ else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+ {
+ yLInboundCache = _mapper.Map<Dt_YLInboundCache>(inboundOrderDetail);
+ yLInboundCache.Id = Id;
+
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == inboundOrderDetail.MaterialCode);
+ //鐢熸垚搴撳瓨缁勭洏淇℃伅
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = inboundOrderDetail.BarCode,
+ RfidCode = "",
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = inboundOrderDetail.MaterialThick,
+ MaterielWide = inboundOrderDetail.MaterialWide,
+ MaterielWeight = inboundOrderDetail.MaterialWeight,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ BatchNo = inboundOrderDetail.MaterialLot,
+ StockLength = inboundOrderDetail.OrderQuantity
+ };
+ if (inboundOrderDetail.MaterialWide >= 1160)
+ {
+ stockInfo.PalletType = 2;
+ }
+ inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ //鏂板缁勭洏淇℃伅
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ }
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
+ //鍚姩绾夸綋
+ WebResponseContent webResponse = YLPurchasePush();
+ if (!webResponse.Status)
+ {
+ throw new Exception(webResponse.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ Dt_StockInfo stockInfoAdd = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
+ //璁板綍搴撳瓨鍙樺姩
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoAdd, 0, stockInfoAdd.StockLength, StockChangeTypeEnum.MaterielGroup);
+ return content.OK("鎴愬姛", yLInboundCache);
+ }
+ else
+ {
+ throw new Exception($"涓婂嵎鏉$爜{yLInboundCache.BarCode}杩樻湭杩涜缁戝畾");
+ }
}
+
}
else //鑰佸巶绾稿嵎骞冲彴鍏ュ簱
{
@@ -511,9 +651,11 @@
}
BSTStockInfoDTO bSTStockInfoDTO = bSTResponse.Data ?? throw new Exception($"涓�鏈烢RP鏈繑鍥瀧palletCode}鐨勫簱瀛樹俊鎭�");
-
+ if (bSTStockInfoDTO.W < 690 || bSTStockInfoDTO.W > 2500)
+ {
+ return content.Error($"鐗╂枡骞呭闄愬埗涓�690-2500mm,褰撳墠绾稿嵎骞呭{bSTStockInfoDTO.W}");
+ }
Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == bSTStockInfoDTO.MaterialId) ?? throw new Exception($"鏈壘鍒版潯鐮亄palletCode}鐗╂枡淇℃伅{bSTStockInfoDTO.MaterialNo}");
-
//鐢熸垚搴撳瓨缁勭洏淇℃伅
Dt_StockInfo stockInfo = new Dt_StockInfo()
{
@@ -535,7 +677,7 @@
StockLength = bSTStockInfoDTO.StockMeter,
MaterielId = materielInfo.MaterialSourceId
};
- if (bSTStockInfoDTO.W > 1200)
+ if (bSTStockInfoDTO.W >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -589,6 +731,10 @@
}
else if (yLInboundCache.BarCode != palletCode && yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
{
+ if (purchaseBSTOrderDetail.MaterialWide < 690 || purchaseBSTOrderDetail.MaterialWide > 2500)
+ {
+ return content.Error($"鐗╂枡骞呭闄愬埗涓�690-2500mm,褰撳墠绾稿嵎骞呭{purchaseBSTOrderDetail.MaterialWide}");
+ }
yLInboundCache = _mapper.Map<Dt_YLInboundCache>(purchaseBSTOrderDetail);
yLInboundCache.Id = Id;
//鑾峰彇閲囪喘涓诲崟
@@ -616,7 +762,7 @@
StockLength = purchaseBSTOrderDetail.ProcurementLength,
MaterielId = purchaseBSTOrderDetail.MaterialId
};
- if (purchaseBSTOrderDetail.MaterialWide > 1200)
+ if (purchaseBSTOrderDetail.MaterialWide >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -686,7 +832,7 @@
/// <param name="palletCode">鏉$爜鍙�</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
- public string AssignYLRoadwayNo(string palletCode)
+ public string AssignYLRoadwayNo(string palletCode, int wide = 0, int thickness = 0, int weight = 0)
{
try
{
@@ -704,38 +850,80 @@
string roadwayNo = "";
+ bool isReturn=false;
+
if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.鏂板巶.ObjToInt())
{
- //闄愬埗鐩村緞
- if (stockInfo.MaterielThickness >= 300 && stockInfo.MaterielThickness <= 1300 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2700)
+ if (wide>0 && thickness>0 && weight>0)
{
+ stockInfo.CheckThickness = thickness;
+ stockInfo.CheckWeight = weight;
+ stockInfo.CheckWide = wide;
+ isReturn = true;
+ }
+ //闄愬埗鐩村緞
+ if (stockInfo.CheckThickness >= 300 && stockInfo.CheckThickness <= 1300 && stockInfo.MaterielWide >= 690 && stockInfo.MaterielWide <= 2500)
+ {
+ bool LayerLimit = stockInfo.CheckThickness >= 1200;
//鑾峰彇鍒嗛厤
List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("YLDual") && (stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt() ? x.LocationType == LocationTypeEnum.MediumPallet.ObjToInt(): x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt())).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
-
+ if (LayerLimit)
+ {
+ locationCounts = locationCounts.Where(x => x.RoadwayNo != "SC03_YLDual").ToList();
+ }
+
roadwayNo = HandleRoadway(locationCounts, warehouse);
}
}
else
{
//闄愬埗
- if ((stockInfo.MaterielThickness >= 800 || (stockInfo.CheckThickness >= 800 && stockInfo.StockStatus==StockStatusEmun.鑰佸巶閫�搴�.ObjToInt())) && stockInfo.MaterielThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
+ if (stockInfo.CheckThickness >= 800 && stockInfo.CheckThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
{
- bool LayerLimit = false;
- if (stockInfo.MaterielThickness>1300)
+ bool LayerLimit = stockInfo.CheckThickness > 1300;
+ bool RoadwayLimit = stockInfo.MaterielWide > 2200;
+ var query = Db.Queryable<Dt_LocationInfo>()
+ .Where(x => x.WarehouseId == warehouse.WarehouseId
+ && x.LocationStatus == (int)LocationStatusEnum.Free
+ && x.EnableStatus == (int)EnableStatusEnum.Normal
+ && x.RoadwayNo.Contains("YL"))
+ .Select(x => new { x.RoadwayNo, x.Columns });
+
+ // 鏍规嵁鏉′欢杩囨护
+ if (LayerLimit)
{
- LayerLimit = true;
+ query = query.Where(x => x.Columns >= 56 && !x.RoadwayNo.Contains("YLDual"));
}
+ if (RoadwayLimit)
+ {
+ query = query.Where(x => !x.RoadwayNo.Contains("SC01_YL"));
+ }
+ List<LocationCount> locationCounts = query
+ .GroupBy(x => x.RoadwayNo)
+ .Select(x => new LocationCount
+ {
+ RoadwayNo = x.RoadwayNo,
+ Count = SqlFunc.AggregateCount(x)
+ })
+ .OrderBy(x => x.RoadwayNo)
+ .ToList();
+
+ roadwayNo = HandleRoadway(locationCounts, warehouse);
+ }
+ else if (stockInfo.CheckThickness >= 400 && stockInfo.CheckThickness < 800 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
+ {
//鑾峰彇鍒嗛厤
- List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("YL") && !x.RoadwayNo.Contains("YLDual") && (LayerLimit ? x.Columns>=56 : x.Columns<=55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
- if (stockInfo.MaterielWide > 2200)
- {
- locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo == "SC02_YL" && (LayerLimit ? x.Columns >= 56 : x.Columns <= 55)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
- }
+ List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("YLDual") && (stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt() ? x.LocationType == LocationTypeEnum.MediumPallet.ObjToInt() : x.LocationType == LocationTypeEnum.SmallPallet.ObjToInt())).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).OrderBy(x => x.RoadwayNo).ToList();
roadwayNo = HandleRoadway(locationCounts, warehouse);
}
}
-
+
+ if (isReturn && !string.IsNullOrEmpty(roadwayNo))
+ {
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ }
+
return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("鏈壘鍒板彲鍒嗛厤宸烽亾");
}
catch (Exception ex)
@@ -777,7 +965,7 @@
{
return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
}
- Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == nameof(StationAreaEnum.涓�妤兼湀鍙扮爜澶�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾虹粐甯�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�)));
+ Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == nameof(StationAreaEnum.涓�妤兼湀鍙扮爜澶�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾虹粐甯�) || x.StationArea == nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�)));
if (agvstation != null)
{
agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
@@ -834,7 +1022,7 @@
}
//鑾峰彇璐т綅淇℃伅
Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
- if (locationInfoEnd == null)
+ if (locationInfoEnd == null && task.TaskType!=TaskTypeEnum.WFBLMYLBackInbound.ObjToInt() && task.TaskType != TaskTypeEnum.WFBYLInbound.ObjToInt())
{
return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
}
@@ -846,18 +1034,44 @@
Dt_LocationInfo locationInfoStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
_basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
}
- stockInfo.LocationCode = locationInfoEnd.LocationCode;
+ if (task.TaskType != TaskTypeEnum.WFBLMYLBackInbound.ObjToInt() && task.TaskType != TaskTypeEnum.WFBYLInbound.ObjToInt())
+ {
+ stockInfo.LocationCode = locationInfoEnd.LocationCode;
+ }
+ else
+ {
+ stockInfo.LocationCode = task.TargetAddress;
+ }
+
stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
if (task.TaskType!=TaskTypeEnum.Inbound.ObjToInt())
{
stockInfo.IsFull = WhetherEnum.True.ObjToInt();
}
_stockService.StockInfoService.Repository.UpdateData(stockInfo);
- _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
+ if (locationInfoEnd!=null)
+ {
+ _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
+ }
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
_unitOfWorkManage.CommitTran();
//璁板綍搴撳瓨鍙樺姩
_recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.StockLength, 0, StockChangeTypeEnum.Inbound,taskNum:task.TaskNum);
+ //涓婃姤鏂板巶ERP
+ if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.鏂板巶.ObjToInt() && task.TaskType == TaskTypeEnum.Inbound.ObjToInt())
+ {
+ string request = _invokeERPService.ERPPurchaseUp(new ERPPurchaseUpModel()
+ {
+ INV_BARCODE_RFID = new List<INV_BARCODE_RFIDItem>()
+ {
+ new INV_BARCODE_RFIDItem()
+ {
+ INV_BARCODE=stockInfo.PalletCode,
+ RFID_BARCODE=stockInfo.RfidCode
+ }
+ }
+ });
+ }
//涓婃姤鑰佸巶ERP
if (stockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && task.TaskType == TaskTypeEnum.Inbound.ObjToInt())
{
@@ -1257,6 +1471,10 @@
Quantity = inboundOrderDetail.OrderQuantity,
PalletType = 1
};
+ if (agvstation.StationArea==StationAreaEnum.浜屾ゼ鎴愬搧搴撶紦瀛樺尯.ToString())
+ {
+ newTask.TaskType = TaskTypeEnum.Inbound2ndFloor.ObjToInt();
+ }
inboundOrderDetail.OrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
_unitOfWorkManage.BeginTran();
if (inboundOrder.InboundOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
@@ -1434,7 +1652,7 @@
MaterielCode = materielInfo.MaterielCode,
MaterielName = materielInfo.MaterielName,
};
- if (wide > 1200)
+ if (wide >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -1520,7 +1738,7 @@
MaterielCode = materielInfo.MaterielCode,
MaterielName = materielInfo.MaterielName,
};
- if (wide > 1200)
+ if (wide >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -1604,6 +1822,10 @@
{
return content.Error($"鍛ㄨ浆浣峽nameof(MESReturnIssueDTO.PointCode)}{item?.PointCode}涓嶅瓨鍦�,浠呮垚鍝佺墿鏂欏彲涓嶄紶");
}
+ }
+ if (materielInfo.MaterielSourceType == MaterielTypeEnum.鎴愬搧.ObjToInt() && (item.Length <= 0 || item.Width <= 0 || item.Height<=0))
+ {
+ return content.Error($"绠辩爜{item.ProPackCode}锛岄暱搴�/瀹藉害/楂樺害涓嶈兘涓�0");
}
Dt_MESProInOrderInfo AddproInOrderInfo = _mapper.Map<Dt_MESProInOrderInfo>(item);
AddproInOrderInfo.WarehouseId = materielInfo.WarehouseId;
@@ -1694,7 +1916,7 @@
MaterielName = materielInfo.MaterielName,
StockLength=item.ProQuantity
};
- if (item.Wide > 1200)
+ if (item.Wide >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -1736,5 +1958,21 @@
}
return content;
}
+ public Dt_AGVStationInfo? AssignWFBStation(List<string> assignPoints)
+ {
+ try
+ {
+ Dictionary<string, OrderByType> orderBy = new Dictionary<string, OrderByType>()
+ {
+ { nameof(Dt_AGVStationInfo.Depth),OrderByType.Asc }
+ };
+ List<string> stockPoints = _stockRepository.StockInfoRepository.QueryData(x=>x.StockAttribute== MaterielTypeEnum.鍗婃垚鍝�.ObjToInt() && x.LocationCode.StartsWith("PNT")).Select(x=>x.LocationCode).ToList();
+ return _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.StationArea == StationAreaEnum.涓�妤兼殏瀛樻灦.ToString() && x.IsOccupied == WhetherEnum.False.ObjToInt() && !stockPoints.Contains(x.AGVStationCode) && !assignPoints.Contains(x.AGVStationCode), orderBy);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
}
}
--
Gitblit v1.9.3