From 011ca316e6ec2ed93e31c45a9ebd9d3c66664871 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 17 四月 2026 11:47:03 +0800
Subject: [PATCH] 代码更新

---
 项目代码/WCS/WCSServices/WIDESEAWCS_TaskInfoService/PackaxisTaskService.cs |   97 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 68 insertions(+), 29 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 a680a09..4a29805 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,6 +15,7 @@
 using WIDESEAWCS_Core.BaseServices;
 using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.TaskInfo;
 using WIDESEAWCS_IBasicInfoRepository;
 using WIDESEAWCS_IPackInfoRepository;
 using WIDESEAWCS_ITaskInfoRepository;
@@ -47,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;
@@ -86,20 +89,19 @@
                     //娣诲姞鐮佸灈浠诲姟
                     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("鏈壘鍒板彲鍒嗛厤鍨涗綅");
@@ -108,8 +110,8 @@
                     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 = packaxes.FirstOrDefault(x => x.StationCode == packInfoAssign.StationCode).PackNum;
+                    packaxisTask = new Dt_PackaxisTask()
                     {
                         DeviceCode = deviceCode,
                         SourceAddress = "2421",
@@ -135,8 +137,9 @@
                     //娣诲姞鐮佸灈浠诲姟
                     BaseDal.AddData(packaxisTask);
                     _unitOfWorkManage.CommitTran();
-                    return content.OK(barCode, packaxisTask);
                 }
+                
+                return content.OK(barCode, packaxisTask);
             }
             catch (Exception ex)
             {
@@ -207,7 +210,6 @@
         {
             try
             {
-                
                 Dt_PackaxisTask? packaxisTaskFinish = null;
                 if (packaxisTask!=null)
                 {
@@ -246,5 +248,42 @@
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }
+        /// <summary>
+        /// 鍒犻櫎鐮佸灈浠诲姟淇℃伅
+        /// </summary>
+        /// <param name="packTaskNum"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public WebResponseContent PickaixsTaskDele(int PackTaskNum)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                    Dt_PackaxisTask packaxisTask = BaseDal.QueryFirst(x => x.PackTaskNum == PackTaskNum);
+                    if(packaxisTask == null)
+                    {
+                        return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔�");
+                    }
+                    else 
+                    {
+                        Dt_Packinfo packinfo = _packinfoRepository.QueryFirst(x => x.BarCode == packaxisTask.BarCode);
+                        packinfo.PackStatus = 0;
+                        _packinfoRepository.UpdateData(packinfo);
+                        BaseDal.DeleteAndMoveIntoHty(packaxisTask, App.User?.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐鍒犻櫎);
+                      content.Status = true;
+                    }
+            }
+            catch (Exception e)
+            {
+                return WebResponseContent.Instance.Error(e.Message);
+            }
+            return content;
+        }
+    }
+    public class MDCount
+    {
+        public string MDNo { get; set; }
+
+        public int Count { get; set; }
     }
 }

--
Gitblit v1.9.3