From 39d468b76e60c05ffcdf749f7ed1d3c443d542f8 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期四, 30 四月 2026 17:13:05 +0800
Subject: [PATCH] 一堆需要求新增及更改
---
项目代码/WCS/WCSServices/WIDESEAWCS_TaskInfoService/PackaxisTaskService.cs | 169 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 90 insertions(+), 79 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/PackaxisTaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/PackaxisTaskService.cs"
index 397d188..ec80750 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/PackaxisTaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/PackaxisTaskService.cs"
@@ -1,4 +1,5 @@
锘縰sing Newtonsoft.Json;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -14,10 +15,7 @@
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
-<<<<<<< HEAD
-=======
using WIDESEAWCS_DTO.TaskInfo;
->>>>>>> main
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_IPackInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
@@ -51,33 +49,34 @@
/// <returns></returns>
public WebResponseContent ReqPackTask(string barCode,string deviceCode)
{
- WebResponseContent content= new WebResponseContent();
+ WebResponseContent content = new WebResponseContent();
try
{
- Dt_Packinfo packinfo = _packinfoRepository.QueryFirst(x=>x.BarCode==barCode && x.PackStatus==StationOccupiedEnum.None.ObjToInt());
- if (packinfo==null)
+ Dt_Packinfo packinfo = _packinfoRepository.QueryFirst(x => x.BarCode == barCode && x.PackStatus == StationOccupiedEnum.None.ObjToInt());
+ if (packinfo == null)
{
return content.Error($"鏈壘鍒版潯鐮亄barCode}");
}
- List<Dt_StationPackInfo> stationPackInfos = _stationPackInfoRepository.QueryData();
- Dt_StationPackInfo? stationPackInfo=stationPackInfos.FirstOrDefault(x=>x.PackType==packinfo.PackType && x.OrderNo==packinfo.OrderNo && x.AssignNum<x.PackNum);
+ List<Dt_StationPackInfo> stationPackInfos = _stationPackInfoRepository.Db.Queryable<Dt_StationPackInfo>().ToList();
+ Dt_StationPackInfo? stationPackInfo = stationPackInfos.FirstOrDefault(x => x.PackType == packinfo.PackType && x.OrderNo == packinfo.OrderNo && x.AssignNum < x.PackNum);
+ Dt_PackaxisTask packaxisTask = new Dt_PackaxisTask();
//濡傛灉璁㈠崟鐩稿悓銆佸灈鍨嬩竴鑷村苟涓斿垎閰嶆暟閲忓皯浜庣爜鍨涚粨鎵樻暟閲忓垯鍒嗛厤鍒颁竴璧�
- if (stationPackInfo!=null)
+ if (stationPackInfo != null)
{
- Dt_PackaxisTask packaxisTask = new Dt_PackaxisTask()
+ packaxisTask = new Dt_PackaxisTask()
{
- DeviceCode=deviceCode,
- SourceAddress= "2421",
- BarCode=barCode,
- CurrentAddress= "2421",
- TargetAddress=stationPackInfo.StationCode,
- NextAddress=stationPackInfo.LineCode,
- TaskState =TaskStatusEnum.Line_Executing.ObjToInt(),
- PackLength=packinfo.Length,
- PackWidth=packinfo.Width,
- PackHeight=packinfo.Height,
- PackType=packinfo.PackType,
- Dispatchertime=DateTime.Now,
+ DeviceCode = deviceCode,
+ SourceAddress = "2421",
+ BarCode = barCode,
+ CurrentAddress = "2421",
+ TargetAddress = stationPackInfo.StationCode,
+ NextAddress = stationPackInfo.LineCode,
+ TaskState = TaskStatusEnum.Line_Executing.ObjToInt(),
+ PackLength = packinfo.Length,
+ PackWidth = packinfo.Width,
+ PackHeight = packinfo.Height,
+ PackType = packinfo.PackType,
+ Dispatchertime = DateTime.Now,
};
stationPackInfo.AssignNum += 1;
stationPackInfo.ExecutingNum += 1;
@@ -90,30 +89,32 @@
//娣诲姞鐮佸灈浠诲姟
BaseDal.AddData(packaxisTask);
_unitOfWorkManage.CommitTran();
- return content.OK(barCode, packaxisTask);
}
else//鍒嗛厤鏂板伐浣�
{
//鑾峰彇褰撳墠绌虹洏鍑嗗鐨勭爜鍨涘伐浣�
List<string> stations = _stationMangerRepository.QueryData(x => x.StationDeviceCode == "CLC_CP" && x.IsOccupied == StationOccupiedEnum.None.ObjToInt()).Select(x => x.StationCode).ToList();
- //鑾峰彇鐮佸灈閰嶇疆琛ㄦ煡璇㈡湁閰嶇疆鐨勭爜鍨涘伐浣�
- List<Dt_Packaxis> packaxes = _packaxisRepository.QueryData(x => x.PackType == packinfo.PackType);
- if (packaxes.Count==0)
+ //鑾峰彇鐮佸灈閰嶇疆琛ㄦ煡璇㈠彲鍒嗛厤骞跺凡閰嶇疆鐨勭爜鍨涘伐浣�
+ List<Dt_Packaxis> packaxes = _packaxisRepository.Db.Queryable<Dt_Packaxis>().Where(x => x.PackType == packinfo.PackType && stations.Contains(x.StationCode)).ToList();
+ if (packaxes.Count == 0)
{
- return content.Error("鏈壘鍒扮爜鍨涘潗鏍囬厤缃�");
+ return content.Error("鏈壘鍒板彲鍒嗛厤鐮佸灈閰嶇疆");
}
List<string> packStations = packaxes.Select(x => x.StationCode).ToList();
- Dt_StationPackInfo? packInfoAssign = stationPackInfos.Where(x => x.PackType == 0 && x.AssignNum == 0 && stations.Contains(x.StationCode) && packStations.Contains(x.StationCode)).OrderByDescending(x => x.StationCode).FirstOrDefault();
+ Dt_StationPackInfo? packInfoAssign = stationPackInfos.Where(x => x.PackType == 0 && x.AssignNum == 0 && packStations.Contains(x.StationCode)).OrderBy(x => x.OrderIndex).FirstOrDefault();
if (packInfoAssign == null)
{
return content.Error("鏈壘鍒板彲鍒嗛厤鍨涗綅");
}
+ Dt_Packaxis packaxis = packaxes.FirstOrDefault(x => x.StationCode == packInfoAssign.StationCode);
packInfoAssign.PackType = packinfo.PackType;
packInfoAssign.OrderNo = packinfo.OrderNo;
packInfoAssign.MakeCode = packinfo.MakeCode;
packInfoAssign.MaterielCode = packInfoAssign.MaterielCode;
- packInfoAssign.PackNum = packaxes.FirstOrDefault(x=>x.StationCode== packInfoAssign.StationCode).PackNum;
- Dt_PackaxisTask packaxisTask = new Dt_PackaxisTask()
+ packInfoAssign.PackNum = packaxis.PackNum;
+ //璁$畻鐮佸灈瀹岀殑楂樺害
+ packInfoAssign.HeightNum = packaxis.AxisZCount * packaxis.AxisZSpacing + 200;
+ packaxisTask = new Dt_PackaxisTask()
{
DeviceCode = deviceCode,
SourceAddress = "2421",
@@ -139,8 +140,9 @@
//娣诲姞鐮佸灈浠诲姟
BaseDal.AddData(packaxisTask);
_unitOfWorkManage.CommitTran();
- return content.OK(barCode, packaxisTask);
}
+
+ return content.OK(barCode, packaxisTask);
}
catch (Exception ex)
{
@@ -159,18 +161,23 @@
WebResponseContent content = new WebResponseContent();
try
{
- Dt_StationPackInfo stationPackInfo = _stationPackInfoRepository.QueryFirst(x => x.StationCode == stationCode);
+ Dt_StationPackInfo stationPackInfo = _stationPackInfoRepository.Db.Queryable<Dt_StationPackInfo>().Where(x => x.StationCode == stationCode).Includes(x=>x.stationPackDetails).First();
if (stationPackInfo.OverNum != stationPackInfo.AssignNum)
{
throw new Exception($"鍒嗛厤鏁伴噺{stationPackInfo.AssignNum}锛屽畬鎴愭暟閲弡stationPackInfo.OverNum}鏁伴噺涓嶇");
}
- List<Dt_StationPackDetail> stationPackDetails = _stationPackDetailRepository.QueryData(x => x.StationPackId == stationPackInfo.id);
+ List<Dt_StationPackDetail> stationPackDetails = stationPackInfo.stationPackDetails;
if (stationPackDetails.Count <= 0)
{
throw new Exception($"{stationCode}鏈壘鍒扮爜鍨涙槑缁�");
}
List<string> barCodes = stationPackDetails.Select(x => x.BoxCode).ToList();
- List<Dt_Packinfo> packinfos = _packinfoRepository.QueryData(x => barCodes.Contains(x.BarCode)).ToList();
+ List<Dt_Packinfo> packinfos = _packinfoRepository.QueryData(x => barCodes.Contains(x.BarCode) && x.PackStatus== StationOccupiedEnum.Sure.ObjToInt()).ToList();
+ if (packinfos.Count != barCodes.Count)
+ {
+ throw new Exception($"鐮佸灈淇℃伅涓庡疄闄呬笉绗︼紝鐮佸灈淇℃伅鏁伴噺{packinfos.Count},瀹為檯鏁伴噺{barCodes.Count}");
+ }
+ int heightNum = stationPackInfo.HeightNum;
stationPackInfo.PackType = 0;
stationPackInfo.OrderNo = "";
stationPackInfo.MakeCode = "";
@@ -179,18 +186,19 @@
stationPackInfo.OverNum = 0;
stationPackInfo.AssignNum = 0;
stationPackInfo.ExecutingNum = 0;
+ stationPackInfo.HeightNum = 0;
_unitOfWorkManage.BeginTran();
_stationPackInfoRepository.UpdateData(stationPackInfo);
_stationPackDetailRepository.DeleteData(stationPackDetails);
_packinfoRepository.DeleteAndMoveIntoHty(packinfos, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
//鍚屾鍒癢MS
- string address = AppSettings.Get("WMSApiAddress");
- string response = HttpHelper.Post($"{address}/api/Task/BoxingInBound?stationCode=" + stationCode, barCodes.Serialize());
- WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(response) ?? throw new Exception($"鏈敹鍒拌繑鍥炵粨鏋�");
- if (!responseContent.Status)
- {
- throw new Exception(responseContent.Message);
- }
+ //string address = AppSettings.Get("WMSApiAddress");
+ //string response = HttpHelper.Post($"{address}/api/Task/BoxingInBound?stationCode={stationCode}&heightNum={heightNum}", barCodes.Serialize());
+ //WebResponseContent? responseContent = JsonConvert.DeserializeObject<WebResponseContent>(response) ?? throw new Exception($"鏈敹鍒拌繑鍥炵粨鏋�");
+ //if (!responseContent.Status)
+ //{
+ // throw new Exception(responseContent.Message);
+ //}
_unitOfWorkManage.CommitTran();
content.OK();
}
@@ -201,6 +209,7 @@
}
return content;
}
+ private readonly static object lockerCompleted = new object();
/// <summary>
/// 鐮佸灈浠诲姟瀹屾垚
/// </summary>
@@ -209,49 +218,49 @@
/// <returns></returns>
public WebResponseContent TaskCompleted(int taskNum=0,Dt_PackaxisTask? packaxisTask=null)
{
- try
+ lock (lockerCompleted)
{
-
- Dt_PackaxisTask? packaxisTaskFinish = null;
- if (packaxisTask!=null)
+ try
{
- packaxisTaskFinish= packaxisTask;
- }
- else
- {
- packaxisTaskFinish = BaseDal.QueryFirst(x => x.PackTaskNum == taskNum);
- packaxisTaskFinish.TaskState = TaskStatusEnum.Finish.ObjToInt();
- }
- if (packaxisTaskFinish != null)
- {
- Dt_StationPackInfo stationPackInfo = _stationPackInfoRepository.QueryFirst(x => x.StationCode == packaxisTaskFinish.TargetAddress);
- stationPackInfo.ExecutingNum -= 1;
- stationPackInfo.OverNum += 1;
- Dt_StationPackDetail stationPackDetail = new Dt_StationPackDetail()
+ Dt_PackaxisTask? packaxisTaskFinish = null;
+ if (packaxisTask != null)
{
- StationPackId = stationPackInfo.id,
- BoxCode = packaxisTaskFinish.BarCode
- };
- _unitOfWorkManage.BeginTran();
- _stationPackInfoRepository.UpdateData(stationPackInfo);
- _stationPackDetailRepository.AddData(stationPackDetail);
- BaseDal.DeleteAndMoveIntoHty(packaxisTaskFinish, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
- _unitOfWorkManage.CommitTran();
+ packaxisTaskFinish = packaxisTask;
+ }
+ else
+ {
+ packaxisTaskFinish = BaseDal.QueryFirst(x => x.PackTaskNum == taskNum);
+ }
+ if (packaxisTaskFinish != null)
+ {
+ Dt_StationPackInfo stationPackInfo = _stationPackInfoRepository.QueryFirst(x => x.StationCode == packaxisTaskFinish.TargetAddress);
+ stationPackInfo.ExecutingNum -= 1;
+ stationPackInfo.OverNum += 1;
+ Dt_StationPackDetail stationPackDetail = new Dt_StationPackDetail()
+ {
+ StationPackId = stationPackInfo.Id,
+ BoxCode = packaxisTaskFinish.BarCode
+ };
+ packaxisTaskFinish.TaskState = TaskStatusEnum.Finish.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ _stationPackInfoRepository.UpdateData(stationPackInfo);
+ _stationPackDetailRepository.AddData(stationPackDetail);
+ BaseDal.DeleteAndMoveIntoHty(packaxisTaskFinish, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
+ _unitOfWorkManage.CommitTran();
+ }
+ else
+ {
+ return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔�");
+ }
+ return WebResponseContent.Instance.OK();
}
- else
+ catch (Exception ex)
{
- return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔�");
+ _unitOfWorkManage.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
}
- return WebResponseContent.Instance.OK();
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- return WebResponseContent.Instance.Error(ex.Message);
}
}
-<<<<<<< HEAD
-=======
/// <summary>
/// 鍒犻櫎鐮佸灈浠诲姟淇℃伅
/// </summary>
@@ -263,7 +272,6 @@
WebResponseContent content = new WebResponseContent();
try
{
-
Dt_PackaxisTask packaxisTask = BaseDal.QueryFirst(x => x.PackTaskNum == PackTaskNum);
if(packaxisTask == null)
{
@@ -284,8 +292,11 @@
}
return content;
}
+ }
+ public class MDCount
+ {
+ public string MDNo { get; set; }
-
->>>>>>> main
+ public int Count { get; set; }
}
}
--
Gitblit v1.9.3