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 | 233 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 191 insertions(+), 42 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 a441c4b..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,6 +1,7 @@
锘縰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;
@@ -21,6 +22,7 @@
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;
@@ -229,6 +231,11 @@
_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淇℃伅宸插瓨鍦�");
@@ -358,9 +365,14 @@
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;
- if (weight != bSTStockInfoDTO.Qty && weight < stockInfoOld.InitialWeight)
+ 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);
@@ -369,7 +381,7 @@
Paper_code = stockInfoOld.PalletCode,
Estimate_weight = bSTStockInfoDTO.Qty,
Actual_weight = weight,
- Error_weight = Math.Abs(weight - bSTStockInfoDTO.Qty),
+ Error_weight = errWeight,
Weigh_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
Operator = "LiKu",
Width = bSTStockInfoDTO.W,
@@ -390,6 +402,11 @@
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)
@@ -958,6 +975,10 @@
{
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 ?? "";
}
@@ -981,6 +1002,25 @@
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())
@@ -1033,7 +1073,7 @@
}
proInUpModel.PB_INV_PRODUCT_IN= pRODUCT_INItems;
string request = _invokeERPService.ERPProInUp(proInUpModel) ?? throw new Exception("鎴愬搧鍏ュ簱鎺ュ彛璇锋眰澶辫触");
- if (!request.Contains("Success"))
+ if (!request.Contains("success"))
{
throw new Exception($"鎴愬搧鍏ュ簱澶辫触");
}
@@ -1226,7 +1266,7 @@
/// <summary>
/// 鎴愬搧绌烘墭鍥炲簱
/// </summary>
- public WebResponseContent EmptyBackTask(string barCode, string startPoint)
+ public WebResponseContent EmptyBackTask(string barCode, string startPoint,int target)
{
WebResponseContent content = new WebResponseContent();
try
@@ -1253,41 +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_ProStockInfo proStockInfo = new Dt_ProStockInfo()
+ else //绔嬪簱绌烘墭浠诲姟
{
- PalletCode=barCode,
- ProStockAttribute=ProStockAttributeEnum.绌烘墭.ObjToInt(),
- PalletType=1,
- LocationCode="",
- WarehouseId= WarehouseEnum.LLDFL.ObjToInt(),
- 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 = WarehouseEnum.LLDFL.ObjToInt(),
- 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();
//鎺ㄩ�佷换鍔�
@@ -1897,13 +1960,13 @@
string request = _invokeERPService.ERPSemiProInUp(
new ERPProInUpModel()
{
- PB_INV_PRODUCT_IN= pRODUCT_INItems
+ PB_INV_PRODUCT_IN = pRODUCT_INItems
}) ?? throw new Exception("鍗婃垚鍝佸叆搴撴帴鍙h姹傚け璐�");
//鐢熸垚鍗婃垚鍝佸叆搴�
- List<Dt_MESProInOrderInfo> semiProInOrderInfos = mESProInOrderInfos.Where(x => x.MESProInStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt()).ToList();
+ List<Dt_MESProInOrderInfo> semiProInOrderInfos = mESProInOrderInfos.Where(x => x.MESProInStatus == InOrderStatusEnum.鏈紑濮�.ObjToInt() && x.WarehouseId==WarehouseEnum.LLDYL.ObjToInt()).ToList();
if (semiProInOrderInfos.Count>0)
{
- WebResponseContent webResponse = SemiProInbound(AddMESProInOrders.Where(x => x.MESProOrderType == MaterielTypeEnum.鍗婃垚鍝�.ObjToInt()).ToList());
+ WebResponseContent webResponse = SemiProInbound(semiProInOrderInfos);
if (!webResponse.Status)
{
throw new Exception(webResponse.Message);
@@ -1914,6 +1977,7 @@
{
throw new Exception(taskResponse.Message);
}
+ _inboundRepository.MESProInOrderInfoRepository.UpdateData(mESProInOrderInfos);
}
}
List<Dt_MESProInOrderInfo> proInOrderInfos = AddMESProInOrders.Where(x => x.MESProOrderType == MaterielTypeEnum.鎴愬搧.ObjToInt()).ToList();
@@ -1948,7 +2012,6 @@
{
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>();
@@ -2009,23 +2072,27 @@
NextAddress = "",
PalletCode = item.BarCode,
Roadway = "",
- SourceAddress = CheckPointCode.AGVStationCode,
+ 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
+ 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.WFBYLInbound,
+ nameof(StationAreaEnum.涓�妤兼棤绾烘穻鑶�) => TaskTypeEnum.WFBLMYLInbound,
_ => throw new Exception("鏈壘鍒板搴斾换鍔�")
};
- if (taskTypeEnum == TaskTypeEnum.WFBYLInbound)
+ if (taskTypeEnum == TaskTypeEnum.WFBYLInbound || taskTypeEnum == TaskTypeEnum.WFBLMYLInbound)
{
Dt_AGVStationInfo? stationInfo = AssignWFBStation(_AGVStationInfos?.Select(x => x.AGVStationCode).ToList()) ?? throw new Exception("鏈壘鍒板彲鐢ㄦ棤绾哄竷鏆傚瓨鏋�");
newTask.NextAddress = stationInfo.AGVStationCode;
@@ -2091,6 +2158,10 @@
throw new Exception(ex.Message);
}
}
+ /// <summary>
+ /// 鎴愬搧缁勭洏
+ /// </summary>
+ /// <returns></returns>
public WebResponseContent BoxingInBound(string stationCode,List<string> barCodes)
{
WebResponseContent content = new WebResponseContent();
@@ -2180,5 +2251,83 @@
}
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