服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-09-18 e4ccb1dbd2af10d3322cba90722baf059e5bc853
优化工步信息机制
已修改5个文件
已添加3个文件
165 ■■■■ 文件已修改
Tiger.Api.sln 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/CollectNode.cs 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/PackingNode.cs 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/Position.cs 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/TestNode.cs 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MESTests/MesTests.cs 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MESTests/Tiger.Business.MESTests.csproj 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MESTests/Transaction/PositionTests.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Api.sln
@@ -28,7 +28,9 @@
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tiger.Business.MengQi", "Tiger.Business.MengQi\Tiger.Business.MengQi.csproj", "{DD5B5282-B673-45CB-8608-3AAEB4A469B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.WMS", "Tiger.Business.WMS\Tiger.Business.WMS.csproj", "{83F123C4-3E7A-485E-A99C-3FE66CA5867E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tiger.Business.WMS", "Tiger.Business.WMS\Tiger.Business.WMS.csproj", "{83F123C4-3E7A-485E-A99C-3FE66CA5867E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.MESTests", "Tiger.Business.MESTests\Tiger.Business.MESTests.csproj", "{2E20369F-54FD-4197-B2F8-761F651143EC}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -94,6 +96,14 @@
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|Any CPU.Build.0 = Release|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|x86.ActiveCfg = Release|Any CPU
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E}.Release|x86.Build.0 = Release|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Debug|x86.ActiveCfg = Debug|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Debug|x86.Build.0 = Debug|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Release|Any CPU.Build.0 = Release|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Release|x86.ActiveCfg = Release|Any CPU
        {2E20369F-54FD-4197-B2F8-761F651143EC}.Release|x86.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
@@ -106,6 +116,7 @@
        {3848BCAB-4E77-4D5E-8BF0-2A747981C1B4} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
        {DD5B5282-B673-45CB-8608-3AAEB4A469B9} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
        {83F123C4-3E7A-485E-A99C-3FE66CA5867E} = {70881CAB-17ED-4C46-895A-62F2CE39A607}
        {2E20369F-54FD-4197-B2F8-761F651143EC} = {CF29B377-FE5A-488A-AF99-DF9D9C6FCA95}
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {797A1D83-9F3C-4AEC-8A83-E3468102DBD1}
Tiger.Business.MES/Transaction/CollectNode.cs
@@ -54,12 +54,12 @@
                        if (!action.IsSuccessed)
                        {
                            var info = WoContext.GetSnOperInfo(input.SN).Data;
                            info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                            info.InputQty = CurOperInfo(input.Locale).InputQty;
                            action.Data.OperInfo = info;
                        }
                        else if (!IsFinishAllSteps)
                        {
                            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                            action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                        }
                    }
                    //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单
@@ -101,12 +101,12 @@
                                if (!action.IsSuccessed && !CurWipSNs.Any())
                                {
                                    var info = WoContext.GetSnOperInfo(input.SN).Data;
                                    info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                                    info.InputQty = CurOperInfo(input.Locale).InputQty;
                                    action.Data.OperInfo = info;
                                }
                                else if (!IsFinishAllSteps)
                                {
                                    action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                    action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                                }
                            }
                        }
@@ -144,7 +144,7 @@
                    if (submitStep.IsNullOrEmpty())
                    {
                        action = BeginNextActionStep(input);
                        action.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                        action.Data.OperInfo = CurOperInfo(input.Locale);
                    }
                    else
                    {
@@ -174,7 +174,7 @@
                        }
                        else
                        {
                            result.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                            result.Data.OperInfo = CurOperInfo(input.Locale);
                        }
                        return result;
                    }
@@ -183,7 +183,7 @@
                else
                {
                    action.Data.ShortMsg = new("重置扫描", ShortMessage.Types.Error);
                    action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                    action.Data.OperInfo = CurOperInfo(input.Locale);
                    ResetNode();
                    action.IsSuccessed = false;
                    //action.LocaleMsg = new($"岗位[{CurPosition.POST_CODE}]工步执行异常,请重新扫描产品条码", CurPosition.POST_CODE);
@@ -193,7 +193,7 @@
            catch (Exception ex)
            {
                action.Data.ShortMsg = new("工序异常", ShortMessage.Types.Error);
                action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                action.Data.OperInfo = CurOperInfo(input.Locale);
                ResetNode();
                //action.CatchExceptionWithLog(ex, $"采集工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.CollectNode.SubmitException"));
@@ -532,8 +532,8 @@
            SaveStepsCommitActionToDB();
            //保存成功,返回过站消息
            OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], locale);
            CurOperInfo(locale).InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(locale));
            action.Data.ShortMsg = new("过站成功", ShortMessage.Types.Success);
            //action.LocaleMsg = new($"工单[{CurWipSN.WORK_ORDER}]的条码[{CurWipSN.SN}]在岗位[{CurWipSN.POST_CODE}]工序[{CurWipSN.NODE_NAME}]过站成功,状态[{CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]");
            action.LocaleMsg = new("MES.Transaction.CollectNode.ScanSn.PassSuccess", CurWipSNs.First().WORK_ORDER, CurSN, CurWipSNs.First().POST_CODE, CurWipSNs.First().NODE_NAME,CurWipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>());
Tiger.Business.MES/Transaction/PackingNode.cs
@@ -55,7 +55,7 @@
                    //如果行为被标记成已完成,则重置工序
                    if (TempPkgAction.IsFinished)
                    {
                        action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                        action.Data.OperInfo = CurOperInfo(input.Locale);
                        ResetNode();
                    }
                }
@@ -77,12 +77,12 @@
                            if (!action.IsSuccessed)
                            {
                                var info = WoContext.GetSnOperInfo(input.SN).Data;
                                info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                                info.InputQty = CurOperInfo(input.Locale).InputQty;
                                action.Data.OperInfo = info;
                            }
                            else if (!IsFinishAllSteps)
                            {
                                action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                            }
                        }
                        //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单
@@ -142,12 +142,12 @@
                                    if (!action.IsSuccessed && !CurWipSNs.Any())
                                    {
                                        var info = WoContext.GetSnOperInfo(input.SN).Data;
                                        info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                                        info.InputQty = CurOperInfo(input.Locale).InputQty;
                                        action.Data.OperInfo = info;
                                    }
                                    else if (!IsFinishAllSteps)
                                    {
                                        action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                        action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                                    }
                                }
                            }
@@ -185,7 +185,7 @@
                        if (submitStep.IsNullOrEmpty())
                        {
                            action = BeginNextActionStep(input);
                            action.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                            action.Data.OperInfo = CurOperInfo(input.Locale);
                        }
                        else
                        {
@@ -215,7 +215,7 @@
                            }
                            else
                            {
                                result.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                                result.Data.OperInfo = CurOperInfo(input.Locale);
                            }
                            return result;
                        }
@@ -224,7 +224,7 @@
                    else
                    {
                        action.Data.ShortMsg = new("重置扫描", ShortMessage.Types.Error);
                        action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                        action.Data.OperInfo = CurOperInfo(input.Locale);
                        ResetNode();
                        action.IsSuccessed = false;
                        //action.LocaleMsg = new($"岗位[{CurPosition.POST_CODE}]工步执行异常,请重新扫描产品条码", CurPosition.POST_CODE);
@@ -235,7 +235,7 @@
            catch (Exception ex)
            {
                action.Data.ShortMsg = new("工序异常", ShortMessage.Types.Error);
                action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                action.Data.OperInfo = CurOperInfo(input.Locale);
                //action.CatchExceptionWithLog(ex, $"包装工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException"));
            }
@@ -573,8 +573,8 @@
            SaveStepsCommitActionToDB();
            //保存成功,返回过站消息
            OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], locale);
            CurOperInfo(locale).InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(locale));
            action.Data.ShortMsg = new("过站成功", ShortMessage.Types.Success);
            //action.LocaleMsg = new($"工单[{CurWipSN.WORK_ORDER}]的条码[{CurWipSN.SN}]在岗位[{CurWipSN.POST_CODE}]工序[{CurWipSN.NODE_NAME}]过站成功,状态[{CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]");
            action.LocaleMsg = new("MES.Transaction.CollectNode.ScanSn.PassSuccess", CurWipSNs.First().WORK_ORDER, CurSN, CurWipSNs.First().POST_CODE, CurWipSNs.First().NODE_NAME,CurWipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>());
Tiger.Business.MES/Transaction/Position.cs
@@ -73,8 +73,8 @@
        public bool NeedTemporaryStoreDBCommitAction { get; set; } = false;
        protected Dictionary<string, List<Action>> DBCommitList { get; set; } = new();
        protected List<Position> NodeCommitList { get; set; } = new();
        protected Dictionary<string, OperInfo> OperInfoDic { get; set; } = new();
        //protected OperInfo CurOperInfo { get; set; }
        private Dictionary<string, OperInfo> OperInfoDic = new();
        #endregion Propertys & Variables
        #region Functions
@@ -196,22 +196,32 @@
            CurDefects.Clear();
        }
        //获取当前的工序信息
        protected OperInfo CurOperInfo(string locale)
        {
            OperInfo info = new();
            if (CurBatch?.Batch?.BATCH_NO != null)
            {
                info = OperInfoDic[CurBatch.Batch.BATCH_NO ];
                info.StepsInfo = Steps.Select(q => q.GetInfo(locale)).ToList();
            }
            return info;
        }
        /// <summary>
        /// è®¾ç½®å½“前条码的工序信息
        /// </summary>
        public OperInfo SetOperNodeInfo(OperInfo info, string locale)
        public OperInfo SetOperNodeInfo(OperInfo info)
        {
            if (CurWipSNs.Any())
            {
                info.CurNode = CurWipSNs.First().NODE_NAME;
                info.NextNode = string.Join(",", CurBatch.GetNextNodes(CurWipSNs.First()).Select(q => q.NODE_NAME));
                info.StepsInfo = Steps.Select(q => q.GetInfo(locale)).ToList();
            }
            else
            {
                info.CurNode = "   â€”   ";
                info.NextNode = "   â€”   ";
                info.StepsInfo = new();
            }
            return info;
        }
@@ -424,6 +434,7 @@
            }
        }
        #region æ‰“印专用方法
        /// <summary>
        /// èŽ·å–æ‰“å°æ ‡ç­¾æ¨¡æ¿è¿‡ç¨‹å˜é‡å€¼
        /// </summary>
@@ -549,6 +560,7 @@
            return result;
        }
        #endregion
        #endregion Functions
        public override bool Close(bool needSaveHistoryLog = false)
Tiger.Business.MES/Transaction/TestNode.cs
@@ -55,12 +55,12 @@
                        if (!action.IsSuccessed)
                        {
                            var info = WoContext.GetSnOperInfo(input.SN).Data;
                            info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                            info.InputQty = CurOperInfo(input.Locale).InputQty;
                            action.Data.OperInfo = info;
                        }
                        else if (!IsFinishAllSteps)
                        {
                            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                            action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                        }
                    }
                    //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单
@@ -102,12 +102,12 @@
                                if (!action.IsSuccessed && !CurWipSNs.Any())
                                {
                                    var info = WoContext.GetSnOperInfo(input.SN).Data;
                                    info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                                    info.InputQty = CurOperInfo(input.Locale).InputQty;
                                    action.Data.OperInfo = info;
                                }
                                else if (!IsFinishAllSteps)
                                {
                                    action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                    action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                                }
                            }
                        }
@@ -145,7 +145,7 @@
                    if (submitStep.IsNullOrEmpty())
                    {
                        action = BeginNextActionStep(input);
                        action.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                        action.Data.OperInfo = CurOperInfo(input.Locale);
                    }
                    else
                    {
@@ -175,7 +175,7 @@
                        }
                        else
                        {
                            result.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                            result.Data.OperInfo = CurOperInfo(input.Locale);
                        }
                        return result;
                    }
@@ -184,7 +184,7 @@
                else
                {
                    action.Data.ShortMsg = new("重置扫描", ShortMessage.Types.Error);
                    action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                    action.Data.OperInfo = CurOperInfo(input.Locale);
                    ResetNode();
                    action.IsSuccessed = false;
                    //action.LocaleMsg = new($"岗位[{CurPosition.POST_CODE}]工步执行异常,请重新扫描产品条码", CurPosition.POST_CODE);
@@ -194,7 +194,7 @@
            catch (Exception ex)
            {
                action.Data.ShortMsg = new("工序异常", ShortMessage.Types.Error);
                action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                action.Data.OperInfo = CurOperInfo(input.Locale);
                //action.CatchExceptionWithLog(ex, $"测试工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.TestNode.SubmitException"));
            }
@@ -532,8 +532,8 @@
            SaveStepsCommitActionToDB();
            //保存成功,返回过站消息
            OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], locale);
            CurOperInfo(locale).InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(locale));
            action.Data.ShortMsg = new("过站成功", ShortMessage.Types.Success);
            //action.LocaleMsg = new($"工单[{CurWipSN.WORK_ORDER}]的条码[{CurWipSN.SN}]在岗位[{CurWipSN.POST_CODE}]工序[{CurWipSN.NODE_NAME}]过站成功,状态[{CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]");
            action.LocaleMsg = new("MES.Transaction.CollectNode.ScanSn.PassSuccess", CurWipSNs.First().WORK_ORDER, CurSN, CurWipSNs.First().POST_CODE, CurWipSNs.First().NODE_NAME, CurWipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>());
Tiger.Business.MESTests/MesTests.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tiger.Business.MESTests
{
    [TestClass()]
    public class MesTests
    {
        [TestMethod()]
        public void CommonTest()
        {
            var date = new DateTime(2022,1,1);
            int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
            ;
        }
    }
}
Tiger.Business.MESTests/Tiger.Business.MESTests.csproj
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="coverlet.collector" Version="6.0.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
    <PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Tiger.Business.MES\Tiger.Business.MES.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
  </ItemGroup>
</Project>
Tiger.Business.MESTests/Transaction/PositionTests.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tiger.Business.MES.Transaction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tiger.Business.MES.Transaction.Tests
{
    [TestClass()]
    public class PositionTests
    {
        [TestMethod()]
        public void GetPrintProcessValueTest()
        {
            Assert.Fail();
        }
    }
}