From 0e5c33e776e68700dbe443cd453dd844b125a2fc Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周三, 14 5月 2025 16:19:09 +0800
Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo

---
 PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs |  163 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 147 insertions(+), 16 deletions(-)

diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs
index e8fe2be..c3dc2d5 100644
--- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs
+++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.Application/Implements/SharedService.cs
@@ -15,6 +15,16 @@
 using System.Text;
 using CMS.Plugin.PipeLineLems.Domain.WorkPlan;
 using CMS.Plugin.PipeLineLems.Domain.CallMaterialOrderRecord;
+using Volo.Abp.Users;
+using CmsQueryExtensions.Entitys;
+using CMS.Unit.RuntimeValue.Abstractions;
+using CMS.Extensions.Variable;
+using CMS.Plugin.TraceManagement.Abstractions.Models.Traces;
+using CMS.Plugin.ProcessManagement.Abstractions;
+using KissUtil.Extensions;
+using CMS.Plugin.TraceManagement.Abstractions;
+using CMS.Plugin.ProductManagement.Abstractions.Models;
+using CMS.Plugin.MaterialManagement.Abstractions;
 
 namespace CMS.Plugin.PipeLineLems.Application.Implements;
 
@@ -23,6 +33,124 @@
 /// </summary> 
 public class SharedService : CMSPluginAppService
 {
+
+
+    public async Task<MesOrderResponse> CommonPick(IServiceProvider _serviceProvider, PickInput input, MyCurrentUser myCurrentUser)
+    {
+        //1銆佽褰曞垎鎷h褰曡〃
+        //2銆佹洿鏂颁綔涓氳鍒掕〃鐨勭姸鎬� =宸插垎鎷�
+        //3銆佸啓鍏� 鍒嗘嫞鍙橀噺
+
+        VariableService _variableService = _serviceProvider.GetRequiredService<VariableService>();
+        var _workSectionManager = _serviceProvider.GetRequiredService<IWorkSectionManager>();
+        var _workStationManager = _serviceProvider.GetRequiredService<IWorkStationManager>();
+        var traceProvider = _serviceProvider.GetRequiredService<ITraceProvider>();
+        var materialProvider = _serviceProvider.GetRequiredService<IMaterialProvider>();
+        var workPlanAppService = _serviceProvider.GetRequiredService<IWorkPlanAppService>();
+
+        Dictionary<string, object?> keyValuePairs = new Dictionary<string, object?>
+                    {
+                        { "鍒嗘嫞鎵樼洏鍙�","鎵樼洏1"},
+                        { "鍒嗘嫞鏂瑰悜", "鐭瑁呴厤"},
+                        { "鍒嗘嫞浜�", myCurrentUser.UserAccount }
+                    };
+        _variableService.WriteValueAsync(keyValuePairs);
+
+        //鏍规嵁宸ュ簭鍚嶈幏鍙栧伐搴忓璞�
+        var workSection = await _workSectionManager.GetByNameAsync("鍒嗘嫞宸ュ簭");
+        var workStation = await _workStationManager.GetByNameAsync("鍒嗘嫞宸ヤ綅");
+        //鍐欏叆杩芥函鎶ヨ〃
+        var finishTime = DateTime.Now;
+        TraceModel traceModel = new TraceModel()
+        {
+            SerialNumber = input.PipeSpecCode,
+            WorkSectionId = workSection.Id,
+            WorkSectionName = workSection.Name,
+            WorkStationName = workStation.Name,
+
+            FinishTime = finishTime,
+            IsQualified = true,
+            UnqualifiedReason = "",
+            ProductModel = "",
+            ProductName = "",
+
+        };
+        traceModel.Params = new List<TraceParamModel>();
+        foreach (var item in workSection.ProcessParameters)
+        {
+            var value = "ssss";
+            traceModel.Params.Add(new TraceParamModel()
+            {
+                Key = item.Key,
+                Value = value.SafeString()
+            });
+        }
+        //鐗╂枡鍙傛暟鍒楄〃
+        var firstWorkPlans = await workPlanAppService.GetListByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode);
+
+        var firstWorkPlan = await workPlanAppService.GetSingleByFilterAsync(x => x.PipeSpecCode == input.PipeSpecCode);
+        var rawPipe_DataIdentifier = await materialProvider.FindByNameAsync("鍒嗘嫞鍘熸枡绠℃爣璇�");
+        var rawPipe_MaterialMode = await materialProvider.FindByNameAsync("鍒嗘嫞鍘熸枡绠″瀷鍙�");
+        List<TraceMaterialModel> _MaterialParams = new List<TraceMaterialModel>();
+        foreach (var item in workSection.MaterialParameters)
+        {
+            if (item.Name == "鍒嗘嫞鍘熸枡绠″瀷鍙�")
+            {
+                _MaterialParams.Add(new TraceMaterialModel()
+                {
+                    Key = item.Key,
+                    Quantity = 1,
+                    MaterialId = rawPipe_MaterialMode.MaterialId,
+                    MaterialDetailId = rawPipe_MaterialMode.MaterialDetails.First().Id,
+                    Value = firstWorkPlan.MaterialMode
+
+                });
+            }
+            if (item.Name == "鍒嗘嫞鍘熸枡绠℃爣璇�")
+            {
+                _MaterialParams.Add(new TraceMaterialModel()
+                {
+                    Key = item.Key,
+                    Quantity = 1,
+                    MaterialId = rawPipe_DataIdentifier.MaterialId,
+                    MaterialDetailId = rawPipe_DataIdentifier.MaterialDetails.First().Id,
+                    Value = firstWorkPlan.DataIdentifier,
+
+                });
+            }
+        };
+
+        //閰嶇疆杩囩▼鍙傛暟(閲囬泦鍙傛暟銆侀厤鏂瑰弬鏁�)
+        traceModel.Params = new List<TraceParamModel>();
+        foreach (var item in workSection.ProcessParameters)
+        {
+            string _value = "";
+            if (item.Name == "鍒嗘嫞鏂瑰悜")
+            {
+                _value = "鐭瑁呴厤";
+            }
+            //item.Key
+            TraceParamModel traceParamModel = new TraceParamModel()
+            {
+                Key = item.Key,
+                Value = _value
+            };
+            traceModel.Params.Add(traceParamModel);
+        };
+
+        traceModel.MaterialParams = _MaterialParams;
+
+        await traceProvider.CreateTraceAsync(traceModel);
+
+        var response = new MesOrderResponse
+        {
+            Code = "200",
+            Data = "",
+            Message = "澶勭悊鎴愬姛",
+            Time = DateTime.UtcNow
+        };
+        return response;
+    }
     /// <summary>
     /// 鍒涘缓浣滀笟璁″垝
     /// </summary>
@@ -33,9 +161,11 @@
     /// <exception cref="UserFriendlyException"></exception>
 
     public async Task<MesOrderResponse> CommonCreatebyApsAsync(List<WorkPlanInput> input, IServiceProvider _serviceProvider,
-        WorkPlanAppService workPlanAppService
-        )
+    WorkPlanAppService workPlanAppService,
+    string userId, string userAccount
+    )
     {
+
         if (input == null)
         {
             throw new UserFriendlyException("杈撳叆鍙傛暟涓嶈兘涓虹┖");
@@ -62,6 +192,7 @@
         var orderManager = _serviceProvider.GetRequiredService<IOrderManager>();
         var productProvider = _serviceProvider.GetRequiredService<IProductProvider>();
         var formulaProvider = _serviceProvider.GetRequiredService<IFormulaProvider>();
+
         List<OrderModel> orderModels = new List<OrderModel>();
 
         #region 浜嬪姟
@@ -111,7 +242,8 @@
                     var order = await orderManager.GetByCodeAsync(prodOrderNo);
                     if (order != null)
                     {
-                        throw new UserFriendlyException($"鐢熶骇宸ュ崟[{prodOrderNo}]宸插瓨鍦�");
+                        //throw new UserFriendlyException($"鐢熶骇宸ュ崟[{prodOrderNo}]宸插瓨鍦�");
+                        continue;
                     }
 
                     OrderModel orderModelForCut = new OrderModel()
@@ -176,6 +308,7 @@
                     CallMaterialStatus = Domain.Shared.Enums.CallMaterialStatusEnum.鏈墽琛�,
                     DataIdentifier = gTask.Key,
                     MaterialMode = gTask.ToList().First().MaterialMode,
+                    CreatorName = userAccount,
                     Quantity = 1
                 };
 
@@ -184,15 +317,17 @@
 
 
 
-
+            //throw new UserFriendlyException($"涓诲姩瑙﹀彂澶辫触");
             //淇濆瓨鍒�  scms_workplans 琛ㄤ腑
             foreach (var item in input)
             {
                 var insertObj = ObjectMapper.Map<WorkPlanInput, WorkPlanCreateDto>(item);
                 //insertObj.OrgMaterialCode = "1111";
                 insertObj.CallMaterialStatus = Domain.Shared.Enums.CallMaterialStatusEnum.鏈墽琛�;
-                insertObj.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.鏈墽琛�;
+                insertObj.WorkPlanStatus = Domain.Shared.Enums.WorkPlanStatusEnum.鏈敓浜�;
                 insertObj.Sort = 1;
+                insertObj.CreatorName = userAccount;
+                insertObj.Remark = "绯荤粺瀵煎叆";
                 await workPlanAppService.CreateAsync(insertObj);
             }
 
@@ -223,9 +358,7 @@
         {
             Code = "000000",
             Data = orderModels,
-            Fail = false,
-            Mesg = "澶勭悊鎴愬姛",
-            Success = true,
+            Message = "澶勭悊鎴愬姛",
             Time = DateTime.UtcNow
         };
         return response;
@@ -296,10 +429,10 @@
         }
 
         // 楠岃瘉鐘舵��
-        //if (callMaterialOrder.CallMaterialStatus != Domain.Shared.Enums.CallMaterialStatusEnum.鏈墽琛�)
-        //{
-        //    throw new UserFriendlyException($"鍘熸枡鏍囪瘑涓� '{callMaterialOrder.DataIdentifier}' 鐨勫彨鏂欒褰曠姸鎬佷负 '{callMaterialOrder.CallMaterialStatus}'锛屼笉鍏佽鍙枡");
-        //}
+        if (callMaterialOrder.CallMaterialStatus != Domain.Shared.Enums.CallMaterialStatusEnum.鏈墽琛�)
+        {
+            throw new UserFriendlyException($"鍘熸枡鏍囪瘑涓� '{callMaterialOrder.DataIdentifier}' 鐨勫彨鏂欒褰曠姸鎬佷负 '{callMaterialOrder.CallMaterialStatus}'锛屼笉鍏佽鍙枡");
+        }
 
         // 鏇存柊鏁版嵁
         callMaterialOrder.WmsRetResult = "鎴愬姛";
@@ -348,10 +481,8 @@
         // 杩斿洖缁撴灉
         var response = new MesOrderResponse
         {
-            Code = "000000",
-            Fail = false,
-            Mesg = "鍙枡鎴愬姛",
-            Success = true,
+            Code = "200",
+            Message = "鍙枡鎴愬姛",
             Time = DateTime.UtcNow
         };
         return response;

--
Gitblit v1.9.3