From 011ca316e6ec2ed93e31c45a9ebd9d3c66664871 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 17 四月 2026 11:47:03 +0800
Subject: [PATCH] 代码更新
---
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 1892 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 1,715 insertions(+), 177 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 5692ab7..1913125 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"
@@ -1,8 +1,14 @@
-锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+锘縰sing Autofac.Core;
+using Microsoft.IdentityModel.Tokens;
+using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+using OfficeOpenXml.FormulaParsing.Excel.Operators;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
@@ -16,11 +22,16 @@
using WIDESEA_Common.TaskEnum;
using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
+using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.Basic;
+using WIDESEA_DTO.ERP;
+using WIDESEA_DTO.MES;
using WIDESEA_DTO.Task;
+using WIDESEA_External.Model;
using WIDESEA_Model.Models;
+using WIDESEA_TaskInfoRepository;
namespace WIDESEA_TaskInfoService
{
@@ -32,34 +43,24 @@
/// <param name="stationCode"></param>
/// <param name="palletCode"></param>
/// <returns></returns>
- public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode, string palletCode)
+ public WebResponseContent DeviceRequestInboundTaskSimple(string stationCode)
{
try
{
- Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
+ Dt_Task task = Repository.QueryFirst(x => x.PalletCode == stationCode);
if (task != null)
{
PushTasksToWCS(new List<Dt_Task> { task });
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 = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == stationCode).Includes(x => x.proStockInfoDetails).First(); ;
if (stockInfo == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
}
- if (stockInfo.StockStatus != StockStatusEmun.MES浣欐枡閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt())
+ if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
{
return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
- }
- if (!string.IsNullOrEmpty(stockInfo.LocationCode))
- {
- return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
}
Dt_Task newTask = new Dt_Task()
@@ -67,35 +68,28 @@
CurrentAddress = stationCode,
Grade = 0,
NextAddress = "",
- PalletCode = palletCode,
+ PalletCode = stationCode,
Roadway = "",
SourceAddress = stationCode,
TargetAddress = "",
- TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+ TaskType = TaskTypeEnum.InProduct.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
WarehouseId = stockInfo.WarehouseId,
PalletType = stockInfo.PalletType,
};
-
-
- if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ stockInfo.proStockInfoDetails.ForEach(x =>
{
- stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
- }
- else
- {
- stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
- }
-
+ x.ProStockDetailStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ });
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
- _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ _stockRepository.ProStockInfoRepository.UpdateData(stockInfo);
+ _stockRepository.ProStockInfoDetailRepository.UpdateData(stockInfo.proStockInfoDetails);
_unitOfWorkManage.CommitTran();
WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask);
- PushTasksToWCS(new List<Dt_Task> { newTask });
- if (newTask.WarehouseId == 5) PutFinish(stationCode, newTask.PalletCode, newTask.TaskNum.ToString());
return WebResponseContent.Instance.OK(data: wMSTaskDTO);
}
catch (Exception ex)
@@ -115,7 +109,12 @@
WebResponseContent content = new WebResponseContent();
try
{
- Dt_Task task = Repository.QueryFirst(x => x.PalletCode == palletCode);
+ Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.RfidCode == palletCode);
+ if (stockInfo == null)
+ {
+ return content.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
+ }
+ Dt_Task task = Repository.QueryFirst(x => x.PalletCode == stockInfo.PalletCode);
if (task != null)
{
PushTasksToWCS(new List<Dt_Task> { task });
@@ -126,39 +125,45 @@
{
return content.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�");
}
- Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
- if (stockInfo == null)
- {
- return content.Error($"鏈壘鍒扮粍鐩樹俊鎭�");
- }
- if (stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+ if (stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鑰佸巶閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt())
{
return content.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱");
}
+ //鍒嗛厤宸烽亾
string rowWay = AssignYLRoadwayNo(stockInfo.PalletCode);
if (string.IsNullOrEmpty(rowWay))
{
return content.Error($"鏈壘鍒板彲鍒嗛厤宸烽亾");
}
+ //鐢熸垚浠诲姟
Dt_Task newTask = new Dt_Task()
{
CurrentAddress = stationCode,
Grade = 0,
NextAddress = "",
- PalletCode = palletCode,
+ PalletCode = stockInfo.PalletCode,
+ RfidCode=stockInfo.RfidCode,
Roadway = rowWay,
SourceAddress = stationCode,
TargetAddress = "",
- TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+ TaskType = stationCode=="307" ? TaskTypeEnum.PaperOldYLBackInbound.ObjToInt() : TaskTypeEnum.Inbound.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
WarehouseId = stockInfo.WarehouseId,
PalletType = stockInfo.PalletType,
+ TaskLength = (int)stockInfo.MaterielWide,
+ MaterielCode=stockInfo.MaterielCode,
+ Quantity=stockInfo.StockLength
};
-
+ //鏇存柊鐘舵��
if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
{
stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt();
}
+ else
+ {
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ }
+ //鏁版嵁鏇存柊
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
newTask.TaskId = taskId;
@@ -175,10 +180,671 @@
}
return content;
}
- public string AssignYLRoadwayNo(string palletCode)
+ private readonly static object lockerYLBoxing = new object();
+ /// <summary>
+ /// 鍘熸枡璇锋眰
+ /// </summary>
+ /// <param name="palletCode">RFID淇℃伅</param>
+ /// <returns></returns>
+ public WebResponseContent YLPurchaseBoxing(string palletCode, decimal weight = 0, decimal thickness = 0, decimal wide = 0, string stationCode = "")
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ lock (lockerYLBoxing)
+ {
+ Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.RfidCode == palletCode);
+ if (stockInfoOld != null && stockInfoOld.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt())
+ {
+ UpdateStock(stockInfoOld, weight, thickness, wide);
+ return content.OK($"涓存椂鍏ュ簱{stockInfoOld.RfidCode}");
+ }
+ else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stationCode.IsNotEmptyOrNull())
+ {
+ decimal oldQty = stockInfoOld.StockLength;
+ //璋冪敤鏇存柊閫�鏂欏簱瀛樺強涓婃姤閲嶉噺
+ 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);
+ //璁板綍搴撳瓨鍙樺姩
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoOld, oldQty, oldQty < stockInfoOld.StockLength ? stockInfoOld.StockLength - oldQty : oldQty - stockInfoOld.StockLength, StockChangeTypeEnum.MaterielGroup);
+ return content.OK($"鑰佸巶鏈鏂欓��搴揜FID{stockInfoOld.RfidCode}鏉$爜{stockInfoOld.PalletCode}");
+ }
+ else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鑰佸巶閫�鏂欐殏瀛�.ObjToInt() && stationCode.IsNotEmptyOrNull())
+ {
+ decimal oldQty = stockInfoOld.StockLength;
+ //璋冪敤鏇存柊閫�鏂欏簱瀛樺強涓婃姤閲嶉噺
+ 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);
+ //璁板綍搴撳瓨鍙樺姩
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoOld, oldQty, oldQty < stockInfoOld.StockLength ? stockInfoOld.StockLength- oldQty: oldQty- stockInfoOld.StockLength, StockChangeTypeEnum.MaterielGroup);
+ return content.OK($"鑰佸巶棰嗘枡閫�搴揜FID{stockInfoOld.RfidCode}鏉$爜{stockInfoOld.PalletCode}");
+ }
+ else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfoOld.StockLength<=0 && stationCode.IsNullOrEmpty())
+ {
+ _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfoOld, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+ throw new Exception($"{palletCode}RFID淇℃伅鑰佸巶棰嗘枡鍚庢棤搴撳瓨閫�鏂�");
+ }
+ else if (stockInfoOld != null)
+ {
+ throw new Exception($"{palletCode}RFID淇℃伅宸插瓨鍦�");
+ }
+
+ if (stationCode.IsNullOrEmpty())
+ {
+ //鏂板巶RFID缁戝畾閫昏緫
+ if (palletCode.StartsWith("A"))
+ {
+ #region 澶勭悊閲囪喘缁戝畾RFID閫昏緫
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鏂板巶.ToString()).FirstOrDefault();
+ if (yLInboundCache == null)
+ {
+ return content.Error("鏈壘鍒板師鏂欑紦瀛樻潯鐮佷俊鎭�");
+ }
+ if (yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+ {
+ return content.Error($"鍘熸枡缂撳瓨鏉$爜{yLInboundCache.BarCode}宸茬粦瀹歊FID{yLInboundCache.RfidCode}");
+ }
+ else
+ {
+ Dt_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode);
+ if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+ {
+ //鑾峰彇閲囪喘淇℃伅
+ yLInboundCache.RfidCode = palletCode;
+ yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
+ ExistStockInfo.RfidCode = palletCode;
+ _unitOfWorkManage.BeginTran();
+ UpdateStock(ExistStockInfo, weight, thickness, wide);
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ _unitOfWorkManage.CommitTran();
+ return content.OK($"閲囪喘鍏ュ簱RFID{ExistStockInfo.RfidCode}缁戝畾{ExistStockInfo.PalletCode}");
+ }
+ else
+ {
+ throw new Exception("鏈煡閿欒");
+ }
+ }
+ #endregion
+ }
+ else //鑰佸巶RFID缁戝畾閫昏緫
+ {
+ #region 澶勭悊閲囪喘缁戝畾RFID閫昏緫
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault();
+ if (yLInboundCache == null)
+ {
+ return content.Error("鏈壘鍒板師鏂欑紦瀛樻潯鐮佷俊鎭�");
+ }
+ if (yLInboundCache.BindStatus == WhetherEnum.True.ObjToInt())
+ {
+ return content.Error($"鍘熸枡缂撳瓨鏉$爜{yLInboundCache.BarCode}宸茬粦瀹歊FID{yLInboundCache.RfidCode}");
+ }
+ else
+ {
+ Dt_StockInfo ExistStockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == yLInboundCache.BarCode);
+ if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt())
+ {
+ yLInboundCache.RfidCode = palletCode;
+ yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
+ ExistStockInfo.RfidCode = palletCode;
+ _unitOfWorkManage.BeginTran();
+ //鏇存柊缁勭洏淇℃伅
+ UpdateStock(ExistStockInfo, weight, thickness, wide);
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ _unitOfWorkManage.CommitTran();
+ return content.OK($"鍗氭�濋�氬簱瀛樿浆瀛榹ExistStockInfo.RfidCode}");
+ }
+ else if (ExistStockInfo != null && ExistStockInfo.MaterielInvOrgId == MaterielInvOrgEnum.鑰佸巶.ObjToInt() && ExistStockInfo.StockStatus == StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+ {
+ //鑾峰彇閲囪喘淇℃伅
+ Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _inboundRepository.PurchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == yLInboundCache.BarCode);
+ yLInboundCache.RfidCode = palletCode;
+ yLInboundCache.BindStatus = WhetherEnum.True.ObjToInt();
+ ExistStockInfo.RfidCode = palletCode;
+ purchaseBSTOrderDetail.RfidCode = palletCode;
+ _unitOfWorkManage.BeginTran();
+ UpdateStock(ExistStockInfo, weight, thickness, wide);
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ _inboundRepository.PurchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
+ _unitOfWorkManage.CommitTran();
+ return content.OK($"閲囪喘鍏ュ簱{ExistStockInfo.RfidCode}");
+ }
+ else
+ {
+ throw new Exception("鏈煡閿欒");
+ }
+ }
+ #endregion
+ }
+ }
+ else if (!stationCode.IsNullOrEmpty() && stockInfoOld == null)
+ {
+ throw new Exception($"{palletCode}RFID淇℃伅涓嶅瓨鍦�");
+ }
+ else
+ {
+ throw new Exception("鏈煡閿欒");
+ }
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// 鏇存柊閫�鏂欏簱瀛�
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent ReturnStockUp(Dt_StockInfo stockInfoOld,decimal thickness,decimal weight)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (thickness < 400)
+ {
+ throw new Exception($"RFID{stockInfoOld.RfidCode}鏉$爜{stockInfoOld.PalletCode}鐩村緞灏忎簬400mm");
+ }
+ 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.StockLength <= 0 || bSTStockInfoDTO.StockMeter<=0)
+ {
+ throw new Exception($"{stockInfoOld.RfidCode}缁戝畾鏉$爜{stockInfoOld.PalletCode}搴撳瓨涓�0");
+ }
+ stockInfoOld.IsPick = WhetherEnum.False.ObjToInt();
+ decimal stockLength = bSTStockInfoDTO.StockMeter;
+ decimal errWeight = Math.Abs(weight - bSTStockInfoDTO.Qty);
+ if (weight != bSTStockInfoDTO.Qty && weight < stockInfoOld.InitialWeight && errWeight <= AppSettings.Get("ErrWeight").ObjToInt())
+ {
+ 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 = errWeight,
+ 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.IsFull = WhetherEnum.True.ObjToInt();
+ stockInfoOld.MaterielWeight = weight;
+ }
+ stockInfoOld.StockStatus = StockStatusEmun.鑰佸巶閫�搴�.ObjToInt();
+ stockInfoOld.MaterielThickness = bSTStockInfoDTO.Thick;
+ stockInfoOld.MaterielWide = bSTStockInfoDTO.W;
+ stockInfoOld.StockLength = stockLength;
+ stockInfoOld.StockOutLength = 0;
+ stockInfoOld.WarehouseId = WarehouseEnum.LLDYL.ObjToInt();
+ List<Dt_OutLineView> outLineViewsDel = _outboundRepository.OutLineViewRepository.QueryData(x=>x.PalletCode==stockInfoOld.PalletCode);
+ if (outLineViewsDel.Count>0)
+ {
+ _outboundRepository.OutLineViewRepository.DeleteData(outLineViewsDel);
+ }
+ content.OK("鎴愬姛",data:stockInfoOld);
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ public void UpdateStock(Dt_StockInfo stockInfo, decimal weight = 0, decimal thickness = 0, decimal wide = 0)
+ {
+ stockInfo.CheckWeight = weight;
+ stockInfo.CheckThickness = thickness;
+ stockInfo.CheckWide = wide;
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ }
+ /// <summary>
+ /// 鍘熸枡閲囪喘缁戝畾RFID
+ /// </summary>
+ /// <param name="palletCode">绾稿嵎鏉$爜</param>
+ /// <param name="rfidCode">绾稿嵎RIFD</param>
+ /// <returns></returns>
+ public WebResponseContent PurchaseBoxing(string palletCode, int orderType = 0)
+ {
+ WebResponseContent content=new WebResponseContent();
+ try
+ {
+ if (string.IsNullOrEmpty(palletCode))
+ {
+ throw new Exception("鏉$爜涓嶈兘涓虹┖");
+ }
+ Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+ if (stockInfoOld != null)
+ {
+ throw new Exception($"鏉$爜淇℃伅{palletCode}搴撳瓨涓凡瀛樺湪");
+ }
+ if (orderType>0) //鏂板巶绾稿嵎骞冲彴鍏ュ簱
+ {
+ InOrderTypeEnum inOrderTypeEnum = (InOrderTypeEnum)orderType;
+ if (inOrderTypeEnum== InOrderTypeEnum.PurchaseIn)
+ {
+ //鑾峰彇涓诲崟
+ Dt_PurchaseOrder inboundOrder = BaseDal.Db.Queryable<Dt_PurchaseOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == palletCode)).First();
+
+ if (inboundOrder == null)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘鍏ュ簱鍗曟嵁淇℃伅");
+ }
+ Dt_PurchaseOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == palletCode);
+
+ if (inboundOrderDetail == null)
+ {
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.PurchaseOrderNo}鏉$爜{palletCode}鍗曟嵁淇℃伅");
+ }
+ if (inboundOrderDetail.PurchaseDetailWide < 690 || inboundOrderDetail.PurchaseDetailWide > 2500)
+ {
+ return content.Error($"鐗╂枡骞呭闄愬埗涓�690-2500mm,褰撳墠绾稿嵎骞呭{inboundOrderDetail.PurchaseDetailWide}");
+ }
+ 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
+ {
+ //鑾峰彇涓诲崟
+ 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 //鑰佸巶绾稿嵎骞冲彴鍏ュ簱
+ {
+ //鑾峰彇閲囪喘淇℃伅
+ Dt_PurchaseBSTOrderDetail purchaseBSTOrderDetail = _inboundRepository.PurchaseBSTOrderDetailRepository.QueryFirst(x => x.Barcode == palletCode);
+ if (purchaseBSTOrderDetail == null)
+ {
+ BSTResponse<BSTStockInfoDTO> bSTResponse = _invokeERPService.BSTStockAsync(palletCode).DeserializeObject<BSTResponse<BSTStockInfoDTO>>();
+ if (bSTResponse.Code == 500)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄palletCode}閲囪喘淇℃伅骞朵竴鏈烢RP搴撳瓨涔熶笉瀛樺湪");
+ }
+
+ 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()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = palletCode,
+ RfidCode = "",
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.鍗氭�濋�氱粍鐩樻殏瀛�.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = bSTStockInfoDTO.Thick,
+ MaterielWide = bSTStockInfoDTO.W,
+ MaterielWeight = bSTStockInfoDTO.Qty,
+ InitialWeight = bSTStockInfoDTO.Qty,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ StockLength = bSTStockInfoDTO.StockMeter,
+ MaterielId = materielInfo.MaterialSourceId
+ };
+ if (bSTStockInfoDTO.W >= 1160)
+ {
+ stockInfo.PalletType = 2;
+ }
+ Dt_YLInboundCache? yLInboundCache = _inboundRepository.YLInboundCacheRepository.QueryData(x => x.InvOrg == MaterielInvOrgEnum.鑰佸巶.ToString()).FirstOrDefault() ?? 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>(stockInfo);
+ yLInboundCache.Id = Id;
+ _unitOfWorkManage.BeginTran();
+ //鏂板缁勭洏淇℃伅
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ //鍚姩绾夸綋
+ 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
+ {
+ if (purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus != 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())
+ {
+ if (purchaseBSTOrderDetail.MaterialWide < 690 || purchaseBSTOrderDetail.MaterialWide > 2500)
+ {
+ return content.Error($"鐗╂枡骞呭闄愬埗涓�690-2500mm,褰撳墠绾稿嵎骞呭{purchaseBSTOrderDetail.MaterialWide}");
+ }
+ yLInboundCache = _mapper.Map<Dt_YLInboundCache>(purchaseBSTOrderDetail);
+ yLInboundCache.Id = Id;
+ //鑾峰彇閲囪喘涓诲崟
+ Dt_PurchaseBSTOrder purchaseBSTOrder = _inboundRepository.PurchaseBSTOrderRepository.QueryFirst(x => x.Id == purchaseBSTOrderDetail.PurchaseBSTOrderId);
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterialSourceId == purchaseBSTOrderDetail.MaterialId);
+ //鐢熸垚搴撳瓨缁勭洏淇℃伅
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = purchaseBSTOrderDetail.Barcode,
+ RfidCode = "",
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = purchaseBSTOrderDetail.MaterialThick,
+ MaterielWide = purchaseBSTOrderDetail.MaterialWide,
+ MaterielWeight = purchaseBSTOrderDetail.DeliveryQty,
+ InitialWeight=purchaseBSTOrderDetail.DeliveryQty,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ StockLength = purchaseBSTOrderDetail.ProcurementLength,
+ MaterielId = purchaseBSTOrderDetail.MaterialId
+ };
+ if (purchaseBSTOrderDetail.MaterialWide >= 1160)
+ {
+ stockInfo.PalletType = 2;
+ }
+ purchaseBSTOrderDetail.PurchaseBSTOrderDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _inboundRepository.YLInboundCacheRepository.UpdateData(yLInboundCache);
+ //鏂板缁勭洏淇℃伅
+ _stockRepository.StockInfoRepository.AddData(stockInfo);
+ if (purchaseBSTOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ purchaseBSTOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.PurchaseBSTOrderRepository.UpdateData(purchaseBSTOrder);
+ }
+ _inboundRepository.PurchaseBSTOrderDetailRepository.UpdateData(purchaseBSTOrderDetail);
+ //鍚姩绾夸綋
+ 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}杩樻湭杩涜缁戝畾");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+
+ }
+ /// <summary>
+ /// 鎺ㄩ�佽嚦WCS鍘熸枡绾夸綋鍚姩
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent YLPurchasePush()
{
try
{
+ string url = AppSettings.Get("WCS");
+ if (string.IsNullOrEmpty(url))
+ {
+ throw new Exception($"鏈壘鍒癢CSAApi鍦板潃,璇锋鏌ラ厤缃枃浠�");
+ }
+ string response = HttpHelper.Post($"{url}/api/Task/YLPurchasePush?code=406");
+
+ return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鍘熸枡鍒嗛厤宸烽亾
+ /// </summary>
+ /// <param name="palletCode">鏉$爜鍙�</param>
+ /// <returns></returns>
+ /// <exception cref="Exception"></exception>
+ public string AssignYLRoadwayNo(string palletCode, int wide = 0, int thickness = 0, int weight = 0)
+ {
+ try
+ {
+ List<string> roadways = ExistRoadwaysError();
+ bool ErrorRoadway = false;
+ if (roadways!=null && roadways.Count>0)
+ {
+ ErrorRoadway = true;
+ }
Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
if (stockInfo==null)
{
@@ -192,16 +858,96 @@
}
string roadwayNo = "";
- if (stockInfo.MaterielThickness > 800)
+
+ bool isReturn=false;
+
+ if (stockInfo.MaterielInvOrgId==MaterielInvOrgEnum.鏂板巶.ObjToInt())
{
- List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("YL")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
- roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
- if (stockInfo.MaterielWide > 2200)
+ if (wide>0 && thickness>0 && weight>0)
{
- locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo=="SC02_YL").GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
- roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
+ 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, ErrorRoadway ? roadways : null);
}
}
+ else
+ {
+ //闄愬埗
+ if (stockInfo.CheckThickness >= 800 && stockInfo.CheckThickness <= 1500 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
+ {
+ bool LayerLimit = stockInfo.CheckThickness > 1300;
+ bool RoadwayLimit = stockInfo.MaterielWide > 2200;
+ bool RoadwayType = stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt();
+ 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)
+ {
+ 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();
+ if (RoadwayType)
+ {
+ foreach (var item in locationCounts)
+ {
+ if (item.RoadwayNo.Contains("YLDual"))
+ {
+ int count = Db.Queryable<Dt_LocationInfo>()
+ .Where(x => x.WarehouseId == warehouse.WarehouseId
+ && x.LocationStatus == (int)LocationStatusEnum.Free
+ && x.EnableStatus == (int)EnableStatusEnum.Normal
+ && x.LocationType==LocationTypeEnum.MediumPallet.ObjToInt()
+ && x.RoadwayNo == item.RoadwayNo).Count();
+ item.Count = count;
+ }
+ }
+ }
+ roadwayNo = HandleRoadway(locationCounts, warehouse, ErrorRoadway ? roadways : null);
+ }
+ else if (stockInfo.CheckThickness >= 400 && stockInfo.CheckThickness < 800 && stockInfo.MaterielWide >= 700 && stockInfo.MaterielWide <= 2500)
+ {
+ bool RoadwayType = stockInfo.PalletType == LocationTypeEnum.MediumPallet.ObjToInt();
+ //鑾峰彇鍒嗛厤
+ 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, ErrorRoadway ? roadways : null);
+ }
+ }
+
+ if (isReturn && !string.IsNullOrEmpty(roadwayNo))
+ {
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ }
+
return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("鏈壘鍒板彲鍒嗛厤宸烽亾");
}
catch (Exception ex)
@@ -210,25 +956,71 @@
throw new Exception(ex.Message);
}
}
+ //澶勭悊鍒嗛厤宸烽亾 浠诲姟鏁伴噺
+ public string HandleRoadway(List<LocationCount> locationCounts, Dt_Warehouse warehouse,List<string> roadways=null)
+ {
+ if (roadways != null)
+ {
+ locationCounts = locationCounts.Where(x => !roadways.Contains(x.RoadwayNo)).ToList();
+ }
+ //宸烽亾浠诲姟鍒嗛厤鏁伴噺
+ List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId
+ && locationCounts.Select(j => j.RoadwayNo).Distinct().Contains(x.Roadway)
+ && TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList();
+
+ foreach (var item in locationCounts)
+ {
+ LocationCount? count = useLocationCounts.FirstOrDefault(x => x.RoadwayNo == item.RoadwayNo);
+ if (count != null)
+ {
+ item.Count -= count.Count;
+ }
+ if (item.Count >= 50 && count?.Count<=1)
+ {
+ return item.RoadwayNo;
+ }
+ }
+ return locationCounts.Where(x => x.Count > 0).OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
+ }
/// <summary>
/// 鍏ュ簱瀹屾垚
/// </summary>
public WebResponseContent InboundTaskCompleted(Dt_Task task)
{
+ WebResponseContent content = new WebResponseContent();
try
{
Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId);
- if (warehouse.WarehouseCode == WarehouseEnum.LLDCP.ToString()) //鎴愬搧瀹屾垚
+ if (warehouse.WarehouseCode == WarehouseEnum.LLDCP.ToString() || warehouse.WarehouseCode == WarehouseEnum.LLDFL.ToString()) //鎴愬搧/杈呮枡瀹屾垚
{
Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
if (locationInfoEnd == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+ return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
}
- Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.SourceAddress && ( x.StationArea == AGVStationAreaEnum.AreaA.ObjToInt() || x.StationArea == AGVStationAreaEnum.AreaC.ObjToInt()));
+ 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();
+ }
+ //鍙犵洏/鍐插垏鎼繍鑷抽浘鍖� 浠诲姟鍗曠嫭瀹屾垚
+ if (task.TaskType==TaskTypeEnum.EmptyStackPlate.ObjToInt() || task.TaskType == TaskTypeEnum.PunchingInbound.ObjToInt())
+ {
+ task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ if (agvstation != null)
+ {
+ _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
+ }
+ if (task.ProductNo.IsNotEmptyOrNull())
+ {
+ Dt_MESProInOrderInfo mESProInOrderInfo = _inboundRepository.MESProInOrderInfoRepository.QueryFirst(x=>x.BarCode== task.ProductNo);
+ mESProInOrderInfo.MESProInStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+ _inboundRepository.MESProInOrderInfoRepository.UpdateData(mESProInOrderInfo);
+ }
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+ _unitOfWorkManage.CommitTran();
+ return content.OK();
}
Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First();
if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt())
@@ -237,7 +1029,7 @@
_unitOfWorkManage.BeginTran();
if (agvstation != null)
{
- _agvStationInfoRepository.UpdateData(agvstation);
+ _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
}
proStockInfo.LocationCode = locationInfoEnd.LocationCode;
proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
@@ -246,7 +1038,7 @@
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
_unitOfWorkManage.CommitTran();
}
- else if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt())
+ else if (proStockInfo != null &&( proStockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt() || proStockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt()))
{
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
proStockInfo.proStockInfoDetails.ForEach(x =>
@@ -256,7 +1048,7 @@
_unitOfWorkManage.BeginTran();
if (agvstation != null)
{
- _agvStationInfoRepository.UpdateData(agvstation);
+ _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
}
proStockInfo.LocationCode = locationInfoEnd.LocationCode;
proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
@@ -264,26 +1056,51 @@
_stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails);
_basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId);
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+ if (task.TaskType==TaskTypeEnum.InProduct.ObjToInt())
+ {
+ ERPProInUpModel proInUpModel = new ERPProInUpModel();
+ List<PB_INV_PRODUCT_INItem> pRODUCT_INItems = new List<PB_INV_PRODUCT_INItem>();
+ foreach (var item in proStockInfo.proStockInfoDetails)
+ {
+ PB_INV_PRODUCT_INItem pB_INV_PRODUCT_INItem = new PB_INV_PRODUCT_INItem()
+ {
+ WP_ID=item.LotNumber.ObjToInt(),
+ INV_BARCODE=item.ProductNo,
+ QTY=(int)item.StockQty,
+ REMARK="鎴愬搧鍏ュ簱"
+ };
+ pRODUCT_INItems.Add(pB_INV_PRODUCT_INItem);
+ }
+ proInUpModel.PB_INV_PRODUCT_IN= pRODUCT_INItems;
+ string request = _invokeERPService.ERPProInUp(proInUpModel) ?? throw new Exception("鎴愬搧鍏ュ簱鎺ュ彛璇锋眰澶辫触");
+ if (!request.Contains("success"))
+ {
+ throw new Exception($"鎴愬搧鍏ュ簱澶辫触");
+ }
+ }
_unitOfWorkManage.CommitTran();
+ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(proStockInfo, 0, proStockInfo.proStockInfoDetails.Sum(x => x.StockQty), StockChangeTypeEnum.Inbound);
}
else
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴斿簱瀛樹俊鎭�");
+ return content.Error($"鏈壘鍒板搴斿簱瀛樹俊鎭�");
}
}
else//鍘熸枡搴撳畬鎴�
{
+ //鑾峰彇搴撳瓨
Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode);
if (stockInfo == null)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴斿簱瀛樹俊鎭�");
+ return content.Error($"鏈壘鍒板搴斿簱瀛樹俊鎭�");
}
+ //鑾峰彇璐т綅淇℃伅
Dt_LocationInfo locationInfoEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
- if (locationInfoEnd == null)
+ if (locationInfoEnd == null && task.TaskType!=TaskTypeEnum.WFBBackInbound.ObjToInt() && task.TaskType != TaskTypeEnum.WFBLMYLBackInbound.ObjToInt() && task.TaskType != TaskTypeEnum.WFBYLInbound.ObjToInt())
{
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+ return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
}
-
+ //鏇存柊鐘舵��
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
_unitOfWorkManage.BeginTran();
if (task.TaskType == TaskTypeEnum.InPick.ObjToInt())
@@ -291,20 +1108,67 @@
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.WFBBackInbound.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())
+ {
+ int Qty = Convert.ToInt32(stockInfo.MaterielWeight);
+ BSTPurchaseUpModel bSTPurchaseUpModel = new BSTPurchaseUpModel()
+ {
+ Barcode = stockInfo.PalletCode,
+ BarcodeQty = Qty,
+ Rfid = stockInfo.RfidCode,
+ RfidUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
+ };
+ BSTResponse<object> bSTResponse = _invokeERPService.BSTPurchaseUp(bSTPurchaseUpModel).DeserializeObject<BSTResponse<object>>();
+ content.Message = bSTResponse?.Msg;
+ }
}
- return WebResponseContent.Instance.OK();
+ content.OK();
}
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
- return WebResponseContent.Instance.Error(ex.Message);
+ content.Error(ex.Message);
}
+ return content;
}
/// <summary>
/// 鍒嗛厤鎴愬搧宸烽亾
@@ -314,17 +1178,12 @@
{
try
{
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == 2);
- if (warehouse == null)
- {
- throw new Exception($"鏈壘鍒板贩閬撳搴斾粨搴撲俊鎭�");
- }
-
string roadwayNo = "";
- List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
+ //鑾峰彇宸烽亾鍙垎閰嶇殑璐т綅鏁伴噺
+ List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.RoadwayNo.Contains("CP")).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList();
//绛涢�夊綋鍓嶅叆搴撲换鍔′腑宸插垎閰嶅贩閬撲换鍔℃暟閲�
- List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => x.WarehouseId == warehouse.WarehouseId
- && locationCounts.Select(j=>j.RoadwayNo).Contains(x.Roadway)
+ List<LocationCount> useLocationCounts = Db.Queryable<Dt_Task>().Where(x => (x.WarehouseId == WarehouseEnum.LLDCP.ObjToInt()|| x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt())
+ && locationCounts.Select(j=>j.RoadwayNo).Distinct().Contains(x.Roadway)
&& TaskInboundTypes.Contains(x.TaskType)).GroupBy(x => x.Roadway).Select(x => new LocationCount { RoadwayNo = x.Roadway, Count = SqlFunc.AggregateCount(x) }).ToList();
foreach (var item in locationCounts)
{
@@ -334,7 +1193,8 @@
item.Count -= count.Count;
}
}
- roadwayNo = locationCounts.OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
+ //閫氳繃鍙敤璐т綅鏁伴噺鎺掑簭锛屾渶澶氱殑浼樺厛鍒嗛厤
+ roadwayNo = locationCounts.Where(x=>x.Count>0).OrderByDescending(x => x.Count).FirstOrDefault()?.RoadwayNo ?? "";
return !string.IsNullOrEmpty(roadwayNo) ? (roadwayNo) : throw new Exception("鏈壘鍒板彲鍒嗛厤宸烽亾");
}
catch (Exception ex)
@@ -364,8 +1224,13 @@
{
return WebResponseContent.Instance.OK(data: task.TargetAddress);
}
+ Dt_StockInfo? stockInfo = null;
+ if (roadwayNo.Contains("YL"))
+ {
+ stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x=>x.PalletCode==task.PalletCode);
+ }
//鍒嗛厤璐т綅
- Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId);
+ Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, stockInfo);
if (locationInfo == null)
{
return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
@@ -382,11 +1247,10 @@
task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt();
}
-
LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
//鏇存柊閿佸畾璐т綅
_unitOfWorkManage.BeginTran();
- _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);
+ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation,taskNum: taskNum);
_basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId);
BaseDal.UpdateData(task);
_unitOfWorkManage.CommitTran();
@@ -400,56 +1264,9 @@
}
/// <summary>
- ///
+ /// 鎴愬搧绌烘墭鍥炲簱
/// </summary>
- /// <param name="taskNum"></param>
- /// <param name="roadwayNo"></param>
- /// <param name="heightType"></param>
- /// <returns></returns>
- public WebResponseContent AssignInboundTaskLocationByHeight(int taskNum, string roadwayNo, int heightType)
- {
- try
- {
- Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
- if (task == null)
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒拌鍏ュ簱浠诲姟");
- }
-
- if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null)
- {
- return WebResponseContent.Instance.OK(data: task.TargetAddress);
- }
-
- Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(roadwayNo, task.PalletType, task.WarehouseId, heightType: heightType);
- if (locationInfo == null)
- {
- return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅");
- }
-
- task.Roadway = roadwayNo;
- task.TargetAddress = locationInfo.LocationCode;
- task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt();
-
- LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
-
- _unitOfWorkManage.BeginTran();
- _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation);
- _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, task.PalletType, LocationStatusEnum.Lock, task.WarehouseId);
- BaseDal.UpdateData(task);
- _unitOfWorkManage.CommitTran();
- return WebResponseContent.Instance.OK(data: locationInfo.LocationCode);
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- return WebResponseContent.Instance.Error(ex.Message);
- }
- }
- /// <summary>
- /// 绌烘鍥炲簱
- /// </summary>
- public WebResponseContent EmptyBackTask(string barCode, string startPoint)
+ public WebResponseContent EmptyBackTask(string barCode, string startPoint,int target)
{
WebResponseContent content = new WebResponseContent();
try
@@ -460,7 +1277,7 @@
//{
// return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}");
//}
- Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x=>x.AGVStationCode==startPoint);
+ Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==startPoint);
if (agvstation==null)
{
return content.Error($"璧风偣閿欒{startPoint}");
@@ -476,43 +1293,64 @@
{
return content.Error($"鎵樼洏{barCode}浠诲姟宸插瓨鍦�");
}
- Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
- if (proStockInfoOld!=null)
+ Dt_Task newTask = null;
+ Dt_ProStockInfo proStockInfo = null;
+ if (target==WhetherEnum.False.ObjToInt())//鍙犵洏绌烘墭浠诲姟
{
- return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+ newTask = new Dt_Task()
+ {
+ CurrentAddress = startPoint,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = barCode,
+ Roadway = agvstation.AGVStationCode.StartsWith("PNT_1") ? "StackPlate1": "StackPlate2",
+ SourceAddress = startPoint,
+ TargetAddress = "",
+ TaskType = TaskTypeEnum.EmptyStackPlate.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
+ PalletType = 1
+ };
}
- //鍒嗛厤宸烽亾
- string roadWay=AssignCPRoadwayNo();
-
- //鑾峰彇鎴愬搧搴�
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.LLDCP.ToString());
- Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+ else //绔嬪簱绌烘墭浠诲姟
{
- PalletCode=barCode,
- ProStockAttribute=ProStockAttributeEnum.绌烘墭.ObjToInt(),
- PalletType=1,
- LocationCode="",
- WarehouseId=warehouse.WarehouseId,
- StockStatus=StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()
- };
-
- Dt_Task newTask = new Dt_Task()
- {
- CurrentAddress = startPoint,
- Grade = 0,
- NextAddress = "",
- PalletCode = barCode,
- Roadway = roadWay,
- SourceAddress = startPoint,
- TargetAddress = "",
- TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
- TaskStatus = TaskStatusEnum.New.ObjToInt(),
- WarehouseId = warehouse.WarehouseId,
- PalletType = 1
- };
+ Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
+ if (proStockInfoOld != null)
+ {
+ return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+ }
+ //鍒嗛厤宸烽亾
+ string roadWay = AssignCPRoadwayNo();
+ proStockInfo = new Dt_ProStockInfo()
+ {
+ PalletCode = barCode,
+ ProStockAttribute = ProStockAttributeEnum.绌烘墭.ObjToInt(),
+ PalletType = 1,
+ LocationCode = "",
+ WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
+ StockStatus = StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()
+ };
+ newTask = new Dt_Task()
+ {
+ CurrentAddress = startPoint,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = barCode,
+ Roadway = roadWay,
+ SourceAddress = startPoint,
+ TargetAddress = "",
+ TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
+ PalletType = 1
+ };
+ }
_unitOfWorkManage.BeginTran();
int taskId = BaseDal.AddData(newTask);
- _stockRepository.ProStockInfoRepository.AddData(proStockInfo);
+ if (proStockInfo!=null)
+ {
+ _stockRepository.ProStockInfoRepository.AddData(proStockInfo);
+ }
newTask.TaskId = taskId;
_unitOfWorkManage.CommitTran();
//鎺ㄩ�佷换鍔�
@@ -526,30 +1364,35 @@
}
return content;
}
- private readonly static object _lockerFL = new object();
+ private readonly static object _lockerFLorCP = new object();
/// <summary>
- /// 杈呮枡鍏ュ簱
+ /// 杈呮枡/鎴愬搧涓存椂鍏ュ簱
/// </summary>
/// <returns></returns>
- public WebResponseContent InboundFLTask(string barCode, string startPoint,string matCode,int matCount)
+ public WebResponseContent InboundFLOrCPTask(string barCode, string startPoint,string matCode,int matCount, int oneCount)
{
- lock (_lockerFL)
+ lock (_lockerFLorCP)
{
WebResponseContent content = new WebResponseContent();
try
{
+ if (matCount<1 || oneCount < 1)
+ {
+ return content.Error("鐗╂枡鎬绘暟鎴栧崟涓暟閲忎笉鑳藉皬浜�1");
+ }
//string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮�
//bool isValid = Regex.IsMatch(barCode, palletCode);
//if (!isValid)
//{
// return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}");
//}
- Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == matCode && x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt() && x.MaterielSourceType == MaterielTypeEnum.杈呮枡澶囦欢.ObjToInt());
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == matCode && x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt() && (x.WarehouseId==WarehouseEnum.LLDCP.ObjToInt() || x.WarehouseId == WarehouseEnum.LLDFL.ObjToInt()));
if (materielInfo == null)
{
return content.Error($"鏈壘鍒扮墿鏂欎俊鎭瘂matCode}");
}
- Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
+ Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
if (agvstation == null)
{
return content.Error($"璧风偣閿欒{startPoint}");
@@ -574,22 +1417,31 @@
string roadWay = AssignCPRoadwayNo();
//鑾峰彇鎴愬搧搴�
- Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.LLDCP.ToString());
- Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+ WarehouseEnum warehouseEnum = materielInfo.MaterielSourceType == MaterielTypeEnum.鎴愬搧.ObjToInt() ? WarehouseEnum.LLDCP : WarehouseEnum.LLDFL;
+ List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
+ for (int i = 0; i < matCount; i++)
{
- ProductCode = matCode,
- StockQty = matCount,
- ProStockDetailStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()
- };
+ Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+ {
+ ProductCode = materielInfo.MaterielCode,
+ ProductName = materielInfo.MaterielName,
+ ProductSpec = materielInfo.MaterielSpec,
+ ProductUnit = materielInfo.MaterielUnit,
+ StockQty = oneCount,
+ ProStockDetailStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()
+ };
+ proStockInfoDetails.Add(proStockInfoDetail);
+ }
+
Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
{
PalletCode = barCode,
- ProStockAttribute = ProStockAttributeEnum.杈呮枡澶囦欢.ObjToInt(),
+ ProStockAttribute = materielInfo.MaterielSourceType,
PalletType = 1,
LocationCode = "",
- WarehouseId = warehouse.WarehouseId,
+ WarehouseId = warehouseEnum.ObjToInt(),
StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(),
- proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail }
+ proStockInfoDetails = proStockInfoDetails
};
Dt_Task newTask = new Dt_Task()
@@ -603,7 +1455,7 @@
TargetAddress = "",
TaskType = TaskTypeEnum.Inbound.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
- WarehouseId = warehouse.WarehouseId,
+ WarehouseId = warehouseEnum.ObjToInt(),
PalletType = 1
};
_unitOfWorkManage.BeginTran();
@@ -622,6 +1474,231 @@
}
return content;
}
+ }
+ /// <summary>
+ /// 杈呮枡(鎴愬搧)閲囪喘/鏈熷垵鍏ュ簱
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent InboundOrderInTask(string bindCode,string barCode,string startPoint, int orderType = 0)
+ {
+ WebResponseContent content=new WebResponseContent();
+ try
+ {
+ InOrderTypeEnum inOrderTypeEnum = (InOrderTypeEnum)orderType;
+ if (inOrderTypeEnum == InOrderTypeEnum.InventoryIn)
+ {
+ //鑾峰彇涓诲崟
+ Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == bindCode)).First();
+
+ if (inboundOrder == null)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄bindCode}鍏ュ簱鍗曟嵁淇℃伅");
+ }
+ Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == bindCode);
+ if (inboundOrderDetail == null)
+ {
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.UpperOrderNo}鏉$爜{bindCode}鍗曟嵁淇℃伅");
+ }
+ if (inboundOrderDetail.OrderDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ throw new Exception($"鏉$爜{bindCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+ }
+ Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
+ if (agvstation == null)
+ {
+ return content.Error($"璧风偣閿欒{startPoint}");
+ }
+ //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅
+ Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt()));
+ if (taskOldPoint != null)
+ {
+ return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�");
+ }
+ Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
+ if (taskOld != null)
+ {
+ return content.Error($"鎵樼洏{barCode}浠诲姟宸插瓨鍦�");
+ }
+ Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
+ if (proStockInfoOld != null)
+ {
+ return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+ }
+ //鍒嗛厤宸烽亾
+ string roadWay = AssignCPRoadwayNo();
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.WarehouseId == inboundOrder.WarehouseId && x.MaterielCode == inboundOrderDetail.MaterialCode);
+ Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+ {
+ ProductCode = materielInfo.MaterielCode,
+ ProductNo = bindCode,
+ ProductName = materielInfo.MaterielName,
+ ProductSpec = materielInfo.MaterielSpec,
+ LotNumber = inboundOrderDetail.MaterialLot,
+ ProductUnit = materielInfo.MaterielUnit,
+ StockQty = inboundOrderDetail.OrderQuantity,
+ ProStockDetailStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt()
+ };
+ Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+ {
+ PalletCode = barCode,
+ ProInOrderNo = inboundOrder.UpperOrderNo,
+ ProStockAttribute = materielInfo.MaterielSourceType,
+ PalletType = 1,
+ LocationCode = "",
+ WarehouseId = materielInfo.WarehouseId,
+ StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail }
+ };
+ //鐢熸垚浠诲姟
+ Dt_Task newTask = new Dt_Task()
+ {
+ CurrentAddress = startPoint,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = barCode,
+ Roadway = roadWay,
+ SourceAddress = startPoint,
+ TargetAddress = "",
+ TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = inboundOrder.WarehouseId,
+ OrderNo = inboundOrder.UpperOrderNo,
+ MaterielCode = inboundOrderDetail.MaterialCode,
+ 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())
+ {
+ inboundOrder.InboundOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ }
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
+ int taskId = BaseDal.AddData(newTask);
+ BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
+ newTask.TaskId = taskId;
+ _unitOfWorkManage.CommitTran();
+ //鎺ㄩ�佷换鍔�
+ PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV");
+ }
+ else if (inOrderTypeEnum == InOrderTypeEnum.PurchaseIn)
+ {
+ //鑾峰彇涓诲崟
+ Dt_PurchaseOrder inboundOrder = BaseDal.Db.Queryable<Dt_PurchaseOrder>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.BarCode == bindCode)).First();
+
+ if (inboundOrder == null)
+ {
+ throw new Exception($"鏈壘鍒版潯鐮亄bindCode}閲囪喘鍏ュ簱鍗曟嵁淇℃伅");
+ }
+ Dt_PurchaseOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BarCode == bindCode);
+ if (inboundOrderDetail == null)
+ {
+ throw new Exception($"鏈壘鍒板叆搴撳崟鍙蜂负{inboundOrder.PurchaseOrderNo}鏉$爜{bindCode}鍗曟嵁淇℃伅");
+ }
+ if (inboundOrderDetail.PurchaseDetailStatus != InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ throw new Exception($"鏉$爜{bindCode}淇℃伅宸插叆搴撴垨鍏ュ簱涓�");
+ }
+ Dt_AGVStationInfo agvstation = _basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
+ if (agvstation == null)
+ {
+ return content.Error($"璧风偣閿欒{startPoint}");
+ }
+ //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅
+ Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt()));
+ if (taskOldPoint != null)
+ {
+ return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�");
+ }
+ Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
+ if (taskOld != null)
+ {
+ return content.Error($"鎵樼洏{barCode}浠诲姟宸插瓨鍦�");
+ }
+ Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
+ if (proStockInfoOld != null)
+ {
+ return content.Error($"鎵樼洏{barCode}宸插瓨鍦�");
+ }
+ //鍒嗛厤宸烽亾
+ string roadWay = AssignCPRoadwayNo();
+ //鑾峰彇鐗╂枡
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.WarehouseId == inboundOrder.WarehouseId && x.MaterielCode == inboundOrderDetail.MaterialCode);
+ Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+ {
+ ProductCode = materielInfo.MaterielCode,
+ ProductNo = bindCode,
+ ProductName = materielInfo.MaterielName,
+ ProductSpec = materielInfo.MaterielSpec,
+ LotNumber = inboundOrderDetail.MaterialLot,
+ ProductUnit = materielInfo.MaterielUnit,
+ StockQty = inboundOrderDetail.PurchaseDetailQuantity,
+ ProStockDetailStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt()
+ };
+ Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+ {
+ PalletCode = barCode,
+ ProInOrderNo = inboundOrder.PurchaseOrderNo,
+ ProStockAttribute = materielInfo.MaterielSourceType,
+ PalletType = 1,
+ LocationCode = "",
+ WarehouseId = materielInfo.WarehouseId,
+ StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail }
+ };
+ //鐢熸垚浠诲姟
+ Dt_Task newTask = new Dt_Task()
+ {
+ CurrentAddress = startPoint,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = barCode,
+ Roadway = roadWay,
+ SourceAddress = startPoint,
+ TargetAddress = "",
+ TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = inboundOrder.WarehouseId,
+ OrderNo = inboundOrder.PurchaseOrderNo,
+ MaterielCode=inboundOrderDetail.MaterialCode,
+ Quantity=inboundOrderDetail.PurchaseDetailQuantity,
+ PalletType = 1
+ };
+ inboundOrderDetail.PurchaseDetailStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ if (inboundOrder.PurchaseOrderStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ inboundOrder.PurchaseOrderStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ _inboundRepository.PurchaseOrderRepository.UpdateData(inboundOrder);
+ }
+ _inboundRepository.PurchaseOrderDetailRepository.UpdateData(inboundOrderDetail);
+ int taskId = BaseDal.AddData(newTask);
+ BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
+ newTask.TaskId = taskId;
+ _unitOfWorkManage.CommitTran();
+ //鎺ㄩ�佷换鍔�
+ PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV");
+ }
+ else
+ {
+ return content.Error($"鏈壘鍒板搴斿崟鎹被鍨�");
+ }
+
+ content.OK("鍙戦�佹垚鍔�");
+
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
}
/// <summary>
/// 鍗板埛浣欐枡閫�鏂欎换鍔�
@@ -644,6 +1721,10 @@
if (materielInfo == null)
{
return content.Error("鏈壘鍒扮墿鏂欎俊鎭�");
+ }
+ if (materielInfo.MaterielSourceType != MaterielTypeEnum.鍘熸潗鏂�.ObjToInt())
+ {
+ return content.Error($"鐗╂枡淇℃伅涓嶇鍚坽MaterielTypeEnum.鍘熸潗鏂檥");
}
Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode);
if (stockInfoOld != null)
@@ -668,7 +1749,7 @@
MaterielCode = materielInfo.MaterielCode,
MaterielName = materielInfo.MaterielName,
};
- if (wide > 1200)
+ if (wide >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -686,7 +1767,7 @@
TaskType = TaskTypeEnum.PrintYLBackInbound.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
WarehouseId = warehouseId,
- PalletType = 1,
+ PalletType = stockInfo.PalletType,
TaskLength= wide
};
_unitOfWorkManage.BeginTran();
@@ -754,7 +1835,7 @@
MaterielCode = materielInfo.MaterielCode,
MaterielName = materielInfo.MaterielName,
};
- if (wide > 1200)
+ if (wide >= 1160)
{
stockInfo.PalletType = 2;
}
@@ -772,7 +1853,7 @@
TaskType = TaskTypeEnum.PrintYLInbound.ObjToInt(),
TaskStatus = TaskStatusEnum.New.ObjToInt(),
WarehouseId = warehouseId,
- PalletType = 1,
+ PalletType = stockInfo.PalletType,
TaskLength = wide
};
_unitOfWorkManage.BeginTran();
@@ -791,5 +1872,462 @@
}
return content;
}
+ /// <summary>
+ /// 鎴愬搧/鍗婃垚鍝佷俊鎭悓姝ユ帴鍙�
+ /// </summary>
+ public WebResponseContent ReceiveProCodeInfo(List<MESProInDTO> proInDTOs)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (proInDTOs == null || proInDTOs.Count <= 0)
+ {
+ return content.Error("浼犲叆淇℃伅涓虹┖");
+ }
+ //鑾峰彇鎵�鏈夋垚鍝侊紝鍗婃垚鍝佷俊鎭�
+ List<Dt_MESProInOrderInfo> proInOrderInfosOld = _inboundRepository.MESProInOrderInfoRepository.QueryData();
+ //鑾峰彇鎵�鏈夌墿鏂欎俊鎭�
+ List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(x => x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt());
+
+ MESProInDTO? CheckMaterialCode = proInDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode));
+ if (CheckMaterialCode != null)
+ {
+ return content.Error($"鐗╂枡缂栫爜{nameof(MESProInDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}淇℃伅涓嶅瓨鍦�");
+ }
+ //鑾峰彇鎵�鏈堿GV鐐逛綅
+ List<Dt_AGVStationInfo> aGVStationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode));
+
+ //鍒ゆ柇鏄惁瀛樺湪閲嶅
+ MESProInDTO? proInDTO = proInDTOs.FirstOrDefault(x => x.IsMantissa == false && proInOrderInfosOld.Select(x => x.BarCode).Contains(x.BarCode));
+ if (proInDTO != null)
+ {
+ return content.Error($"{proInDTO.ProductOrderNo}鐢熶骇宸ュ崟{proInDTO.BarCode}鏉$爜宸插瓨鍦�");
+ }
+ Dt_MESProInOrderInfo? proInOrderInfo = proInOrderInfosOld.FirstOrDefault(x => x.MESProInStatus == InOrderStatusEnum.鍏抽棴.ObjToInt() && proInDTOs.Select(x => x.ProductOrderNo).Distinct().Contains(x.ProductOrderNo));
+ if (proInOrderInfo != null)
+ {
+ return content.Error($"{proInOrderInfo.ProductOrderNo}鐢熶骇宸ュ崟宸插叧闂�");
+ }
+ List<Dt_MESProInOrderInfo> AddMESProInOrders = new List<Dt_MESProInOrderInfo>();
+ foreach (var item in proInDTOs)
+ {
+ Dt_MaterielInfo materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode);
+ //鍒ゆ柇
+ if ((item.Thickness <= 0 || item.Wide <= 0) && materielInfo.WarehouseId == WarehouseEnum.LLDYL.ObjToInt())
+ {
+ return content.Error($"鐗╂枡{item.MaterialCode}鏉$爜{item.BarCode}鐩村緞鎴栧箙瀹戒笉鑳藉皬浜�0");
+ }
+ if (materielInfo.MaterielSourceType != MaterielTypeEnum.鎴愬搧.ObjToInt())
+ {
+ Dt_AGVStationInfo? CheckPointCode = aGVStationInfos.FirstOrDefault(x => x.MESPointCode == item?.PointCode);
+ if (CheckPointCode == null)
+ {
+ 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;
+ AddproInOrderInfo.MESProOrderType = materielInfo.MaterielSourceType;
+ //灏忎簬550骞呭鍒欎笉鑳芥惉杩�
+ if (item.Wide < 550 && materielInfo.WarehouseId == WarehouseEnum.LLDYL.ObjToInt())
+ {
+ AddproInOrderInfo.MESProInStatus=InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+ }
+ AddMESProInOrders.Add(AddproInOrderInfo);
+ }
+ List<Dt_Task> tasks = new List<Dt_Task>();
+ _unitOfWorkManage.BeginTran();
+ _inboundRepository.MESProInOrderInfoRepository.AddData(AddMESProInOrders);
+ List<Dt_MESProInOrderInfo> mESProInOrderInfos = AddMESProInOrders.Where(x => x.MESProOrderType == MaterielTypeEnum.鍗婃垚鍝�.ObjToInt()).ToList();
+ if (mESProInOrderInfos.Count > 0)
+ {
+ List<PB_INV_PRODUCT_INItem> pRODUCT_INItems = new List<PB_INV_PRODUCT_INItem>();
+ foreach (var item in mESProInOrderInfos)
+ {
+ PB_INV_PRODUCT_INItem pB_INV_PRODUCT_INItem = new PB_INV_PRODUCT_INItem()
+ {
+ WP_ID = item.ProcessNum,
+ INV_BARCODE=item.BarCode,
+ REMARK = "鍗婃垚鍝佸叆搴�",
+ QTY=(int)item.ProQuantity
+ };
+ pRODUCT_INItems.Add(pB_INV_PRODUCT_INItem);
+ }
+ string request = _invokeERPService.ERPSemiProInUp(
+ new ERPProInUpModel()
+ {
+ PB_INV_PRODUCT_IN = pRODUCT_INItems
+ }) ?? throw new Exception("鍗婃垚鍝佸叆搴撴帴鍙h姹傚け璐�");
+ //鐢熸垚鍗婃垚鍝佸叆搴�
+ List<Dt_MESProInOrderInfo> semiProInOrderInfos = mESProInOrderInfos.Where(x => x.MESProInStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt() && x.WarehouseId==WarehouseEnum.LLDYL.ObjToInt()).ToList();
+ if (semiProInOrderInfos.Count>0)
+ {
+ WebResponseContent webResponse = SemiProInbound(semiProInOrderInfos);
+ if (!webResponse.Status)
+ {
+ throw new Exception(webResponse.Message);
+ }
+ tasks = webResponse.Data as List<Dt_Task>;
+ WebResponseContent taskResponse = PushTasksToWCS(tasks);
+ if (!taskResponse.Status)
+ {
+ throw new Exception(taskResponse.Message);
+ }
+ _inboundRepository.MESProInOrderInfoRepository.UpdateData(mESProInOrderInfos);
+ }
+ }
+ List<Dt_MESProInOrderInfo> proInOrderInfos = AddMESProInOrders.Where(x => x.MESProOrderType == MaterielTypeEnum.鎴愬搧.ObjToInt()).ToList();
+ if (proInOrderInfos.Count > 0)
+ {
+ WebResponseContent webResponse = PushPackaxisTaskToWCS(proInOrderInfos);
+ if (!webResponse.Status)
+ {
+ throw new Exception(webResponse.Message);
+ }
+ }
+ _unitOfWorkManage.CommitTran();
+ content.OK("鎺ユ敹鎴愬姛");
+
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// 鍗婃垚鍝佷笅鏂橫ES浠诲姟
+ /// </summary>
+ public WebResponseContent SemiProInbound(List<Dt_MESProInOrderInfo> mESProInOrderInfos)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (mESProInOrderInfos.Count <= 0)
+ {
+ return content.Error("浼犲叆淇℃伅涓虹┖");
+ }
+ List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData();
+ List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
+ List<Dt_Task> tasks = new List<Dt_Task>();
+ //鑾峰彇鎵�鏈堿GV鐐逛綅
+ List<Dt_AGVStationInfo> aGVStationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x => !string.IsNullOrEmpty(x.MESPointCode));
+ List<Dt_AGVStationInfo> _AGVStationInfos = new List<Dt_AGVStationInfo>();
+ //鏍规嵁鍗婃垚鍝佷俊鎭懠鍙搴斾换鍔�
+ foreach (var item in mESProInOrderInfos)
+ {
+ Dt_AGVStationInfo? CheckPointCode = aGVStationInfos.FirstOrDefault(x => x.MESPointCode == item?.PointCode);
+ Dt_MaterielInfo? materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode);
+ if (CheckPointCode==null)
+ {
+ return content.Error($"鏈壘鍒皗item?.PointCode}鐐逛綅");
+ }
+ if (materielInfo == null)
+ {
+ return content.Error("鏈壘鍒扮墿鏂欎俊鎭�");
+ }
+ if (materielInfo.MaterielSourceType != MaterielTypeEnum.鍗婃垚鍝�.ObjToInt())
+ {
+ return content.Error($"鏈壘鍒扮墿鏂檣materielInfo.MaterielCode}鍗婃垚鍝佷俊鎭�");
+ }
+ Dt_StockInfo stockInfoOld = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == item.BarCode);
+ if (stockInfoOld != null)
+ {
+ return content.Error("鎵樼洏淇℃伅宸插瓨鍦�");
+ }
+ //鐢熸垚搴撳瓨缁勭洏淇℃伅
+ Dt_StockInfo stockInfo = new Dt_StockInfo()
+ {
+ MaterielInvOrgId = materielInfo.MaterielInvOrgId,
+ PalletCode = item.BarCode,
+ LocationCode = "",
+ PalletType = 1,
+ WarehouseId = materielInfo.WarehouseId,
+ StockAttribute = materielInfo.MaterielSourceType,
+ StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+ MaterielSpec = materielInfo.MaterielSpec,
+ Unit = materielInfo.MaterielUnit,
+ MaterielThickness = item.Thickness,
+ MaterielWide = item.Wide,
+ MaterielWeight = item.Weight,
+ MaterielCode = materielInfo.MaterielCode,
+ MaterielName = materielInfo.MaterielName,
+ StockLength=item.ProQuantity
+ };
+ if (item.Wide >= 1160)
+ {
+ stockInfo.PalletType = 2;
+ }
+
+ //鍗婃垚鍝佸叆搴撲换鍔�
+ Dt_Task newTask = new Dt_Task()
+ {
+ CurrentAddress = item.PointCode.StartsWith("YS") ? CheckPointCode.AGVStationCode : CheckPointCode.MESPointCode,
+ Grade = 0,
+ NextAddress = "",
+ PalletCode = item.BarCode,
+ Roadway = "",
+ SourceAddress = item.PointCode.StartsWith("YS") ? CheckPointCode.AGVStationCode : CheckPointCode.MESPointCode,
+ TargetAddress = "",
+ TaskType = 0,
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = materielInfo.WarehouseId,
+ PalletType = stockInfo.PalletType,
+ TaskLength = (int)item.Wide,
+ WorkCentreCode=item.MakeCode,
+ MaterielCode = item.MaterialCode,
+ Quantity =item.ProQuantity
+ };
+ TaskTypeEnum taskTypeEnum = CheckPointCode.StationArea switch
+ {
+ nameof(StationAreaEnum.涓�妤煎嵃鍒�) => TaskTypeEnum.PrintYLInbound,
+ nameof(StationAreaEnum.涓�妤煎垎鍒�) => TaskTypeEnum.PartOffInbound,
+ nameof(StationAreaEnum.涓�妤肩焊寮犳穻鑶�) => TaskTypeEnum.PaperFilmInbound,
+ nameof(StationAreaEnum.涓�妤兼棤绾虹粐甯�) => TaskTypeEnum.WFBYLInbound,
+ nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�) => TaskTypeEnum.WFBLMYLInbound,
+ _ => throw new Exception("鏈壘鍒板搴斾换鍔�")
+ };
+ if (taskTypeEnum == TaskTypeEnum.WFBYLInbound || taskTypeEnum == TaskTypeEnum.WFBLMYLInbound)
+ {
+ Dt_AGVStationInfo? stationInfo = AssignWFBStation(_AGVStationInfos?.Select(x => x.AGVStationCode).ToList()) ?? throw new Exception("鏈壘鍒板彲鐢ㄦ棤绾哄竷鏆傚瓨鏋�");
+ newTask.NextAddress = stationInfo.AGVStationCode;
+ newTask.TargetAddress = stationInfo.AGVStationCode;
+ newTask.Roadway = "AGV";
+ stationInfo.IsOccupied = 1;
+ _AGVStationInfos.Add(stationInfo);
+ }
+ newTask.TaskType = taskTypeEnum.ObjToInt();
+ stockInfos.Add(stockInfo);
+ tasks.Add(newTask);
+ }
+ //鎿嶄綔鍏ュ簱鏁版嵁
+ BaseDal.AddData(tasks);
+ _basicRepository.AGVStationInfoRepository.UpdateData(_AGVStationInfos);
+ _stockRepository.StockInfoRepository.AddData(stockInfos);
+ //鎺ㄩ�佷换鍔�
+ content.OK("鍙戦�佹垚鍔�",data:tasks);
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// 鎺ㄩ�佺爜鍨涙暟鎹嚦WCS
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent PushPackaxisTaskToWCS(List<Dt_MESProInOrderInfo> mESProInOrderInfos)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ string url = AppSettings.Get("WCS");
+ if (string.IsNullOrEmpty(url))
+ {
+ throw new Exception($"鏈壘鍒癢CSAApi鍦板潃,璇锋鏌ラ厤缃枃浠�");
+ }
+ string response = HttpHelper.Post($"{url}/api/Packinfo/ReceivePackaxisTask", mESProInOrderInfos.Serialize());
+
+ return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ 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);
+ }
+ }
+ /// <summary>
+ /// 鎴愬搧缁勭洏
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent BoxingInBound(string stationCode,List<string> barCodes)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ //鑾峰彇鎴愬搧搴撳瓨
+ Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == stationCode);
+ if (proStockInfoOld != null)
+ {
+ return content.Error($"鎵樼洏{stationCode}宸插瓨鍦�");
+ }
+ //鑾峰彇鏉$爜淇℃伅
+ List<Dt_MESProInOrderInfo> proInOrderInfos = _inboundRepository.MESProInOrderInfoRepository.QueryData(x=> barCodes.Contains(x.BarCode));
+ Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x=>x.MaterielCode== proInOrderInfos.FirstOrDefault().MaterialCode);
+ List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
+ foreach (var item in proInOrderInfos)
+ {
+ Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
+ {
+ ProductCode = materielInfo.MaterielCode,
+ ProductNo = item.BarCode,
+ ProductName = materielInfo.MaterielName,
+ ProductSpec = materielInfo.MaterielSpec,
+ LotNumber = item.ProcessNum.ToString(),
+ ProductUnit = materielInfo.MaterielUnit,
+ StockQty = item.ProQuantity,
+ ProStockDetailStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt()
+ };
+ proStockInfoDetails.Add(proStockInfoDetail);
+ }
+
+ Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+ {
+ PalletCode = stationCode,
+ ProInOrderNo = proInOrderInfos.FirstOrDefault().ProductOrderNo,
+ ProStockAttribute = materielInfo.MaterielSourceType,
+ PalletType = 1,
+ LocationCode = "",
+ WarehouseId = materielInfo.WarehouseId,
+ StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ proStockInfoDetails = proStockInfoDetails
+ };
+ BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// 鎴愬搧鍏ュ簱鎵爜璇锋眰鏇存柊鏉$爜
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent InBoundPalletCode(int taskNum, string barCode)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ //鑾峰彇褰撳墠浠诲姟
+ Dt_Task? taskExist = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+ if (taskExist==null)
+ {
+ return content.Error($"鏈壘鍒颁换鍔taskNum}");
+ }
+ //鍒ゆ柇搴撳瓨涓槸鍚﹀瓨鍦ㄩ噸澶嶆墭鐩樻潯鐮�
+ Dt_ProStockInfo? proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x=>x.PalletCode==barCode);
+ if (proStockInfo!=null)
+ {
+ return content.Error($"搴撳瓨鏉$爜{proStockInfo.PalletCode}宸插瓨鍦�");
+ }
+ Dt_ProStockInfo proStockInfoExist = _stockRepository.ProStockInfoRepository.QueryFirst(x=>x.PalletCode== taskExist.PalletCode);
+ //鏇存柊
+ proStockInfoExist.PalletCode = barCode;
+ taskExist.PalletCode = barCode;
+ _unitOfWorkManage.BeginTran();
+ _stockRepository.ProStockInfoRepository.UpdateData(proStockInfoExist);
+ BaseDal.UpdateData(taskExist);
+ _unitOfWorkManage.CommitTran();
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
+ /// 鍗婃垚鍝佹墭鐩樻惉杩愬叆搴�
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent SemiProIn(string barcode, string palletCode, string address)
+ {
+
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ //鑾峰彇褰撳墠鍗婃垚鍝佷俊鎭�
+ Dt_MESProInOrderInfo mESProInOrderInfo = _inboundRepository.MESProInOrderInfoRepository.QueryFirst(x=>x.BarCode==barcode) ?? throw new Exception($"鍗婃垚鍝佹潯鐮亄barcode}淇℃伅涓嶅瓨鍦紝璇锋牳瀵逛俊鎭�");
+ //鑾峰彇鍔犲伐涓績
+ Dt_MakeCenterInfo makeCenterInfo = _basicRepository.MakeCenterInfoRepository.QueryFirst(x=>x.MakeCode==mESProInOrderInfo.MakeCode);
+ if (makeCenterInfo.MakeArea!=StationAreaEnum.涓�妤煎垎鍒�.ObjToInt() && makeCenterInfo.MakeArea != StationAreaEnum.涓�妤煎啿鍒�.ObjToInt() && makeCenterInfo.MakeArea != StationAreaEnum.涓�妤兼ā鍒�.ObjToInt()) throw new Exception($"鍗婃垚鍝佹潯鐮亄barcode}涓嶅睘浜庡垎鍒�/鍐插垏/妯″垏鍔犲伐");
+
+ //鍒ゆ柇浠诲姟
+ Dt_Task? taskExist = BaseDal.QueryFirst(x=>x.PalletCode==palletCode) == null ? null: throw new Exception($"鎵樼洏{palletCode}浠诲姟宸插瓨鍦�");
+ //鍒ゆ柇搴撳瓨
+ Dt_ProStockInfo? proStockInfoExist = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode== palletCode).Includes(x => x.proStockInfoDetails).First() == null ? null : throw new Exception($"鎵樼洏{palletCode}搴撳瓨宸插瓨鍦�"); ;
+ //鍒ゆ柇鍦板潃
+ Dt_AGVStationInfo StationInfoStart = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.AGVStationCode==address) ?? throw new Exception($"鍦板潃鐮亄address}涓嶅瓨鍦�");
+
+ Dt_AGVStationInfo? StationInfoEnd = null;
+ Dt_Task? newTask = null;
+ #region 閫昏緫鍒ゆ柇锛氬垎鍒�&妯″垏鍏ユ垚鍝�(杈呮枡)搴擄紱鍐插垏鎼繍鑷充簩妤奸浘鍖栦腑杞尯锛�
+ if (makeCenterInfo.MakeArea == StationAreaEnum.涓�妤煎啿鍒�.ObjToInt())
+ {
+ //鑾峰彇闆惧寲涓浆鍖虹偣浣�
+ StationInfoEnd = _basicRepository.AGVStationInfoRepository.QueryFirst(x=>x.StationArea== StationAreaEnum.浜屾ゼ闆惧寲.ToString() && x.IsOccupied==WhetherEnum.False.ObjToInt()) ?? throw new Exception($"浜屾ゼ闆惧寲鍙敤鐐逛綅涓嶈冻");
+ //鐢熸垚浠诲姟
+ newTask = new Dt_Task()
+ {
+ CurrentAddress = StationInfoStart.AGVStationCode,
+ Grade = 0,
+ NextAddress = StationInfoEnd.AGVStationCode,
+ PalletCode = palletCode,
+ Roadway = "AGV",
+ SourceAddress = StationInfoStart.AGVStationCode,
+ TargetAddress = StationInfoEnd.AGVStationCode,
+ TaskType = TaskTypeEnum.PunchingInbound.ObjToInt(),
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ WarehouseId = mESProInOrderInfo.WarehouseId,
+ PalletType = PalletTypeEnum.SmallPallet.ObjToInt(),
+ TaskLength = (int)mESProInOrderInfo.Wide,
+ WorkCentreCode = mESProInOrderInfo.MakeCode,
+ MaterielCode=mESProInOrderInfo.MaterialCode,
+ Quantity=mESProInOrderInfo.ProQuantity,
+ ProductNo=mESProInOrderInfo.BarCode
+ };
+ StationInfoEnd.IsOccupied = 1;
+ }
+ else
+ {
+ return content.Error("鏆傛椂鏃犳硶婊¤冻");
+ }
+ mESProInOrderInfo.MESProInStatus = InOrderStatusEnum.鍏ュ簱涓�.ObjToInt();
+ //鏁版嵁搴撴搷浣滃苟鎺ㄩ�乄CS浠诲姟
+ _unitOfWorkManage.BeginTran();
+ _basicRepository.AGVStationInfoRepository.UpdateData(StationInfoEnd);
+ BaseDal.AddData(newTask);
+ _inboundRepository.MESProInOrderInfoRepository.UpdateData(mESProInOrderInfo);
+ WebResponseContent taskResponse = PushTasksToWCS(new List<Dt_Task>() { newTask });
+ if (!taskResponse.Status)
+ {
+ throw new Exception(taskResponse.Message);
+ }
+ _unitOfWorkManage.CommitTran();
+ #endregion
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
+ }
}
}
--
Gitblit v1.9.3