Browse Source

添加方法调整

章政 6 years ago
parent
commit
1761a9b1ee

+ 116 - 0
UAS-出货标签管理/PublicMethod/Analysis.cs

@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace UAS_LabelMachine.PublicMethod
+{
+    class Analysis
+    {
+        /// <summary>
+        /// Brand对应品牌,item对应DateCode,LotNo等,Data对应具体解析的数据
+        /// </summary>
+        /// <param name="Brand"></param>
+        /// <param name="item"></param>
+        /// <param name="Data"></param>
+        /// <returns></returns>
+        //Brand对应品牌,item对应DateCode,LotNo等,Data对应具体解析的数据
+        public static string AnalysisData(string Brand, string item, string Data)
+        {
+            string ReturnData = "";
+            switch (Brand)
+            {
+                //采集怡海能达村田的LotNo的解析规则
+                case "MURATA":
+                    if (item.ToUpper() == "LOTNO" || item.ToUpper() == "DATECODE")
+                    {
+                        string Year = Data.Substring(2, 1);
+                        string Month = Data.Substring(3, 1);
+                        string Day = Data.Substring(4, 2);
+                        //处理年份
+                        //当前年份的前三位
+                        string CurrentYear_3 = DateTime.Now.Year.ToString().Substring(0, 3);
+                        //采集到的年份
+                        int CollectYear = int.Parse(CurrentYear_3 + Year);
+                        //当前的年份 
+                        int CurrentYear = int.Parse(DateTime.Now.Year.ToString());
+                        //如果采集到的年份大于当前年份,将十年数-1
+                        if (CollectYear > CurrentYear)
+                        {
+                            Year = int.Parse(CurrentYear_3) - 1 + Year;
+                        }
+                        else
+                        {
+                            Year = CollectYear.ToString();
+                        }
+                        //处理月份
+                        switch (Month)
+                        {
+                            case "O":
+                                Month = "10";
+                                break;
+                            case "N":
+                                Month = "11";
+                                break;
+                            case "D":
+                                Month = "12";
+                                break;
+                            default:
+                                Month = "0" + Month;
+                                break;
+                        }
+                        ReturnData = Year + Month + Day;
+                    }
+                    break;
+                case "KEC":
+                    if (item.ToUpper() == "LOTNO" || item.ToUpper() == "DATECODE")
+                    {
+                        string Year = Data.Substring(0, 1);
+                        string Week = Data.Substring(1, 2);
+                        DateTime DateBegin = DateTime.Now;
+                        GetDaysOfWeeks(int.Parse("201" + Year), int.Parse(Week), out DateBegin);
+                        ReturnData = DateBegin.ToString("yyyyMMdd");
+                    }
+                    break;
+                default:
+                    break;
+            }
+            return ReturnData;
+        }
+
+        public static bool GetDaysOfWeeks(int year, int index, out DateTime first)
+        {
+            first = DateTime.MinValue;
+            if (year < 1700 || year > 9999)
+            {
+                //"年份超限"
+                return false;
+            }
+            if (index < 1 || index > 53)
+            {
+                //"周数错误"
+                return false;
+            }
+            DateTime startDay = new DateTime(year, 1, 1);  //该年第一天
+            DateTime endDay = new DateTime(year + 1, 1, 1).AddMilliseconds(-1);
+            int dayOfWeek = 0;
+            if (Convert.ToInt32(startDay.DayOfWeek.ToString("d")) > 0)
+                dayOfWeek = Convert.ToInt32(startDay.DayOfWeek.ToString("d"));  //该年第一天为星期几
+            if (dayOfWeek == 7) { dayOfWeek = 0; }
+            if (index == 1)
+            {
+                first = startDay;
+            }
+            else
+            {
+                first = startDay.AddDays((7 - dayOfWeek) + (index - 1) * 7); //index周的起始日期
+            }
+            if (first > endDay)  //startDayOfWeeks不在该年范围内
+            {
+                //"输入周数大于本年最大周数";
+                return false;
+            }
+            return true;
+        }
+    }
+}

+ 22 - 22
UAS-出货标签管理/PublicMethod/DataHelper.cs

@@ -11,17 +11,17 @@ namespace UAS_LabelMachine
     public class DataHelper
     {
 
-        //富为外网地址
-        private readonly string ConnectionStrings = "Data Source=richwellgroup.com.cn/orcl;User ID=DATACENTER;PassWord=select!#%*(";
-        private readonly string InnerConnectionStrings = "Data Source=richwellgroup.com.cn/orcl;User ID=DATACENTER;PassWord=select!#%*(";
-        //富为ERP地址
-        public static readonly string ERPAddesss = "http://richwellgroup.com.cn:8099/ERP/";
-        //富为FTP
-        public static readonly string FTPAdress = "ftp://richwellgroup.com.cn|printuser|printuser";
-        //Oracle端口
-        public static readonly string OraclePort = "1521";
-        //需要显示的账套
-        public static readonly string Masters = "JDTSY,FW_JDT,N_DATACENTER,FY_TEST,JD_TEST,XY_TEST,FW_TEST,DATACENTER,FW,XY,FY";
+        ////富为外网地址
+        //private readonly string ConnectionStrings = "Data Source=richwellgroup.com.cn/orcl;User ID=DATACENTER;PassWord=select!#%*(";
+        //private readonly string InnerConnectionStrings = "Data Source=richwellgroup.com.cn/orcl;User ID=DATACENTER;PassWord=select!#%*(";
+        ////富为ERP地址
+        //public static readonly string ERPAddesss = "http://richwellgroup.com.cn:8099/ERP/";
+        ////富为FTP
+        //public static readonly string FTPAdress = "ftp://richwellgroup.com.cn|printuser|printuser";
+        ////Oracle端口
+        //public static readonly string OraclePort = "1521";
+        ////需要显示的账套
+        //public static readonly string Masters = "JDTSY,FW_JDT,N_DATACENTER,FY_TEST,JD_TEST,XY_TEST,FW_TEST,DATACENTER,FW,XY,FY";
 
         ////高登地址
         //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=183.238.39.179)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
@@ -35,19 +35,19 @@ namespace UAS_LabelMachine
         ////需要显示的账套
         //public static readonly string Masters = "GOLDEN";
 
-        //////怡海能达外网地址
-        //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=sz.hi-mantech.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        ////怡海能达外网地址
+        private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=sz.hi-mantech.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
-        //private readonly string InnerConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.200)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        private readonly string InnerConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.200)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
-        ////怡海能达ERP地址
-        //public static readonly string ERPAddesss = "http://sz.hi-mantech.com:8099/ERP/";
-        ////怡海能达FTP
-        //public static readonly string FTPAdress = "ftp://sz.hi-mantech.com:46688|yhndftp|Stga28ytG8";
-        ////Oracle端口
-        //public static readonly string OraclePort = "1521";
-        ////需要显示的账套
-        //public static readonly string Masters = "YHND_SZ,YHND_HK,DATACENTER,YITOA_ZX,T_YHND_HK";
+        //怡海能达ERP地址
+        public static readonly string ERPAddesss = "http://sz.hi-mantech.com:8099/ERP/";
+        //怡海能达FTP
+        public static readonly string FTPAdress = "ftp://sz.hi-mantech.com:46688|yhndftp|Stga28ytG8";
+        //Oracle端口
+        public static readonly string OraclePort = "1521";
+        //需要显示的账套
+        public static readonly string Masters = "YHND_SZ,YHND_HK,DATACENTER,YITOA_ZX,T_YHND_HK";
 
         ////华商龙外网地址
         //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YITOA_DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=218.18.115.198)(PORT=1523)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";

+ 1 - 3
UAS-出货标签管理/UAS-出货标签管理.csproj

@@ -97,9 +97,6 @@
     <ApplicationIcon>Resources\print_128px_1082624_easyicon.net.ico</ApplicationIcon>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Analysis">
-      <HintPath>tool\Analysis.dll</HintPath>
-    </Reference>
     <Reference Include="Interop.LabelManager2">
       <HintPath>..\..\..\UAS_WinForm\UAS-出货标签管理\bin\Debug\Interop.LabelManager2.dll</HintPath>
       <EmbedInteropTypes>False</EmbedInteropTypes>
@@ -237,6 +234,7 @@
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
       <DependentUpon>Settings.settings</DependentUpon>
     </Compile>
+    <Compile Include="PublicMethod\Analysis.cs" />
     <Compile Include="PublicMethod\ArrayList.cs" />
     <Compile Include="PublicMethod\AutoSizeFormClass.cs" />
     <Compile Include="PublicMethod\BaseUtil.cs" />

+ 0 - 1
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -10,7 +10,6 @@ using System.Diagnostics;
 using LabelManager2;
 using UAS_LabelMachine.PublicMethod;
 using UAS_LabelMachine.Entity;
-using UAS_特殊解析规则;
 using UAS_LabelMachine.PublicForm;
 using System.Threading;
 using System.IO;