Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

caosy 6 years ago
parent
commit
53c9b9e6de

+ 3 - 0
UAS-出货标签管理/App.config

@@ -59,6 +59,9 @@
       <setting name="OutboxCapacity" serializeAs="String">
         <value>0</value>
       </setting>
+      <setting name="FTPModel" serializeAs="String">
+        <value>True</value>
+      </setting>
     </UAS_LabelMachine.Properties.Settings>
   </userSettings>
 </configuration>

+ 3 - 0
UAS-出货标签管理/Properties/Settings.settings

@@ -23,5 +23,8 @@
     <Setting Name="OutboxCapacity" Type="System.Decimal" Scope="User">
       <Value Profile="(Default)">0</Value>
     </Setting>
+    <Setting Name="FTPModel" Type="System.Boolean" Scope="User">
+      <Value Profile="(Default)">True</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

+ 12 - 0
UAS-出货标签管理/Properties/Settings1.Designer.cs

@@ -106,5 +106,17 @@ namespace UAS_LabelMachine.Properties {
                 this["OutboxCapacity"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]
+        public bool FTPModel {
+            get {
+                return ((bool)(this["FTPModel"]));
+            }
+            set {
+                this["FTPModel"] = value;
+            }
+        }
     }
 }

+ 11 - 1
UAS-出货标签管理/PublicMethod/BaseUtil.cs

@@ -16,6 +16,16 @@ namespace UAS_LabelMachine
 
         static string SysDisc;
 
+        public static string lpad(int length, string number)
+        {
+            while (number.Length < length)
+            {
+                number = "0" + number;
+            }
+            number = number.Substring(number.Length - length, length);
+            return number;
+        }
+
         public static string SysDisc1
         {
             get
@@ -238,7 +248,7 @@ namespace UAS_LabelMachine
             //如果是传入的数据是从FTP取的文件
             if (URL.Contains("ftp:"))
             {
-                ftpOperater ftp = new ftpOperater();
+                ftpOperater ftp = new ftpOperater(Properties.Settings.Default.FTPModel);
                 return ftp.Download(LabelName, time);
             }
             else

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

@@ -22,27 +22,39 @@ namespace UAS_LabelMachine
         ////需要显示的账套
         //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=sz.hi-mantech.com)(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";
+        ////高登地址
+        //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)));";
+        ////高登ERP地址
+        //public static readonly string ERPAddesss = "http://183.238.39.179:8099/ERP/";
+        ////高登TP
+        //public static readonly string FTPAdress = "ftp://183.238.39.179|GOLDENFTP|Admin1@#";
         ////Oracle端口
         //public static readonly string OraclePort = "1521";
         ////需要显示的账套
-        //public static readonly string Masters = "YHND_SZ,YHND_HK,DATACENTER";
+        //public static readonly string Masters = "GOLDEN";
 
-        //华商龙外网地址
-        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)));";
-        //华商龙ERP地址
-        public static readonly string ERPAddesss = "http://218.18.115.198:8888/ERP/";
-        //华商龙FTP
-        public static readonly string FTPAdress = "ftp://218.18.115.198:21|Print|Administrator1@#";
+
+        //怡海能达外网地址
+        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)));";
+        //怡海能达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 = "1523";
+        public static readonly string OraclePort = "1521";
         //需要显示的账套
-        public static readonly string Masters = "XSQ,N_YITOA_YWC,ZXN,N_YITOA_LHCT,N_YITOA_CT,N_CHL,N_YITOA_HK,N_HUASL_SHTL,N_WILICHK,N_WILIC,N_E_SHINE_SH,N_SHBJ,N_BJKG,N_HUASL,N_HUASL_QD,N_HUASL_XM,N_HUASL_SZ";
+        public static readonly string Masters = "YHND_SZ,YHND_HK,DATACENTER";
+
+        ////华商龙外网地址
+        //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)));";
+        ////华商龙ERP地址
+        //public static readonly string ERPAddesss = "http://218.18.115.198:8888/ERP/";
+        ////华商龙FTP
+        //public static readonly string FTPAdress = "ftp://218.18.115.198:21|Print|Administrator1@#";
+        ////Oracle端口
+        //public static readonly string OraclePort = "1523";
+        ////需要显示的账套
+        //public static readonly string Masters = "XSQ,N_YITOA_YWC,ZXN,N_YITOA_LHCT,N_YITOA_CT,N_CHL,N_YITOA_HK,N_HUASL_SHTL,N_WILICHK,N_WILIC,N_E_SHINE_SH,N_SHBJ,N_BJKG,N_HUASL,N_HUASL_QD,N_HUASL_XM,N_HUASL_SZ";
 
         ////UAS测试地址
         //private readonly string ConnectionStrings = "Data Source=192.168.253.6/orcl;User ID=UAS_TEST;PassWord=select!#%*(";

+ 591 - 0
UAS-出货标签管理/PublicMethod/HttpCommand.cs

@@ -0,0 +1,591 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Net;
+using System.IO;
+//using System.Web.Script.Serialization;
+using System.Web.Script.Serialization;
+using System.Web;
+
+namespace UAS_LabelMachine.PublicMethod
+{
+    public class HttpCommand
+    {
+        /// <summary>
+        /// 获取签名值
+        /// </summary>
+        /// <param name="parameters"></param>
+        /// <param name="url"></param>
+        /// <param name="secret"></param>
+        /// <returns></returns>
+        public static string Sign(IDictionary<string, string> parameters, string url, string secret)
+        {
+            var builder = new StringBuilder();
+            builder.Append(url);
+            builder.Append("\n");
+
+            foreach (var param in parameters.OrderBy(t => t.Key))
+            {
+                builder.Append(string.Format("{0}={1}\n", param.Key, param.Value));
+            }
+
+            builder.Append(secret);
+            return GetMd5(builder.ToString());
+        }
+
+        //获取MD5值
+        public static string GetMd5(string src)
+        {
+            var buffer = new StringBuilder();
+            using (var md5 = MD5.Create())
+            {
+                var md5Bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(src));
+                for (var i = 0; i < md5Bytes.Length; i++)
+                {
+                    var val = Convert.ToInt32(md5Bytes[i] & 0xff);
+                    if (val < 16)
+                    {
+                        buffer.Append("0");
+                    }
+                    buffer.Append(string.Format("{0:X}", val));
+                }
+            }
+
+            return buffer.ToString();
+        }
+
+
+        /// <summary>
+        /// 获取ESB的时间戳,即C#实现java这个方法System.currentTimeMillis(),产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数
+        /// </summary>
+        /// <param name="time"></param>
+        /// <returns></returns>
+        public static string ConvertTimeStamp(string time)
+        {
+            DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
+            DateTime dtNow = DateTime.Parse(time);
+            TimeSpan toNow = dtNow.Subtract(dtStart);
+            string timeStamp = toNow.Ticks.ToString();
+            timeStamp = timeStamp.Substring(0, timeStamp.Length - 7);
+            return timeStamp;
+        }
+
+        /// <summary>
+        /// 对 URL 字符串进行编码。
+        /// </summary>
+        /// <param name="dict"></param>
+        /// <returns></returns>
+        public static string buildEncodeUrl(IDictionary<string, string> dict)
+        {
+            StringBuilder sb = new StringBuilder();
+            foreach (var param in dict.OrderBy(t => t.Key))
+            {
+                string encode = HttpUtility.UrlEncode(param.Value, Encoding.UTF8);
+                sb.Append(param.Key).Append("=").Append(encode).Append("&");
+            }
+
+            return sb.ToString().Substring(0, sb.ToString().LastIndexOf("&"));
+        }
+
+        /// <summary>
+        /// http方式获取数据
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="requestString"></param>
+        /// <param name="method"></param>
+        /// <param name="encoding"></param>
+        /// <param name="times">请求超时时间(默认60秒)</param>
+        /// <returns></returns>
+        public static String GetResponseHTML(string url, string requestString, string method, Encoding encoding, int times = 60)
+        {
+            try
+            {
+                if (encoding == null)
+                {
+                    encoding = Encoding.UTF8;
+                }
+                if (method == "POST")
+                {
+                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
+                    req.Method = method;
+                    req.ContentType = "application/x-www-form-urlencoded";
+
+                    req.KeepAlive = false;
+                    req.Timeout = times * 1000;
+                    req.ReadWriteTimeout = times * 1000;
+                    //req.UserAgent = new HttpConfig().RMSUserAgent;
+                    //不需要根据http协议版本匹配,不需要进行协议握手就是说
+                    //Expect:100-Continue的作用是,设定Client 和 Server在Post数据前需要进行“请求头域”的数据匹配,相当于是握手。如果匹配则开始进行body 的内容,Post数据。否则,报错(417) Unkown
+                    req.ServicePoint.Expect100Continue = false;
+
+
+                    //传输请求的数据
+                    if (!string.IsNullOrEmpty(requestString))
+                    {
+                        byte[] data = encoding.GetBytes(requestString);
+
+                        req.ContentLength = data.Length;
+                        using (Stream stream = req.GetRequestStream())
+                        {
+                            stream.Write(data, 0, data.Length);
+                            //stream.Flush();
+                            stream.Close();
+                        }
+                    }
+
+
+                    //获取回传数据
+                    using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
+                    {
+                        StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);
+                        string content = reader.ReadToEnd();
+                        reader.Close();
+
+                        return content;
+                    }
+                }
+                else
+                {
+                    HttpWebRequest req = null;
+
+                    if (string.IsNullOrEmpty(requestString))
+                    {
+                        req = (HttpWebRequest)WebRequest.Create(url);
+                    }
+                    else if (url.IndexOf("?") > 0)
+                    {
+                        req = (HttpWebRequest)WebRequest.Create(url + "&" + requestString);
+                    }
+                    else
+                    {
+                        req = (HttpWebRequest)WebRequest.Create(url + "?" + requestString);
+                    }
+
+                    // req.Method = method;
+                    req.Timeout = times * 1000;
+                    req.ReadWriteTimeout = times * 1000;
+                    req.ServicePoint.Expect100Continue = false;
+                    req.ContentType = "application/x-www-form-urlencoded";
+
+                    //获取回传数据
+                    using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
+                    {
+                        StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);
+                        string content = reader.ReadToEnd();
+                        reader.Close();
+
+                        return content;
+                    }
+                }
+            }
+            catch (System.Net.WebException ex)
+            {
+                HttpWebResponse res = (HttpWebResponse)ex.Response;
+                StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("UTF-8"));
+                string errorMessage = sr.ReadToEnd();
+                return errorMessage;
+            }
+            catch (Exception e)
+            {
+                //Logger log = new Logger();
+                //log.LogException(e);
+                return e.ToString();
+            }
+        }
+
+        /// <summary>
+        /// 检查UPN是否上传到OPPO成功
+        /// </summary>
+        /// <param name="esbUrl">OPPO的API URL</param>
+        /// <param name="appId"></param>
+        /// <param name="esbSecret"></param>
+        /// <param name="upn">UPN条码</param>
+        /// <returns>返回UPN的SN清单</returns>
+
+        public String checkWmsBatteryInfo(string esbUrl, string appId, string esbSecret, string upn)
+        {
+            string uri = "/mes/extranet/check_wms_battery_info";
+            Encoding encoding = Encoding.GetEncoding("utf-8");
+            //Map<String, Object> sendData = new LinkedHashMap<String, Object>();
+            IDictionary<string, Object> sendData = new Dictionary<string, Object>();
+
+
+            StringBuilder builder = new StringBuilder();
+            JavaScriptSerializer json = new JavaScriptSerializer();
+            json.Serialize(sendData, builder);
+
+            IDictionary<string, string> parameters = new Dictionary<string, string>();
+            //parameters.Add("app_id", "SUP-FMT");
+            parameters.Add("app_id", appId);
+            parameters.Add("bat_upn", upn);
+            parameters.Add("procstep", "1");
+            parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+            parameters.Add("sign", Sign(parameters, uri, esbSecret));
+
+            string result = GetResponseHTML(esbUrl + uri, buildEncodeUrl(parameters), null, null);
+            if ("{\"data\":\"\",\"error_code\":0,\"error_msg\":\"\"}".Equals(result))
+            {
+                return "Success";
+            }
+            else
+            {
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// 插入电池信息到OPPO
+        /// </summary>
+        /// <param name="esbUrl"></param>
+        /// <param name="appId"></param>
+        /// <param name="esbSecret"></param>
+        /// <param name="strBatteryList"></param>
+        /// <returns>返回oppo插入的电池个数</returns>
+        public String insertBatteryInfo(string esbUrl, string appId, string esbSecret, string strBatteryList)
+        {
+            //string uri = "/mes/basics/wms_battery_info_insert";
+            string uri = "/mes/extranet/mes_test_result_info_insert";
+            Encoding encoding = Encoding.GetEncoding("utf-8");
+            //Map<String, Object> sendData = new LinkedHashMap<String, Object>();
+
+            //IDictionary<string, Object> sendData = new Dictionary<string, Object>();
+            //StringBuilder builder = new StringBuilder();
+            //JavaScriptSerializer json = new JavaScriptSerializer();
+            //json.Serialize(sendData, builder);
+
+            IDictionary<string, string> parameters = new Dictionary<string, string>();
+            //parameters.Add("app_id", "SUP-FMT");
+            /*注意:参数添加到parameters,必须按参数字母顺序添加*/
+            parameters.Add("app_id", appId);
+
+            parameters.Add("test_info", strBatteryList);
+            parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+
+            parameters.Add("test_amount", "4");
+
+            parameters.Add("sign", Sign(parameters, uri, esbSecret));
+
+            string result = GetResponseHTML(esbUrl + uri, buildEncodeUrl(parameters), "POST", null);
+            if ("{\"data\":\"\",\"error_code\":0,\"error_msg\":\"\"}".Equals(result))
+            {
+                return "Success";
+            }
+            else
+            {
+                return result;
+            }
+        }
+
+        public String insertUpnInfo(string esbUrl, string appId, string esbSecret, string strUpnlist, int count)
+        {
+            //string uri = "/mes/basics/wms_battery_info_insert";
+            string uri = "/mes/extranet/mes_vendor_upn_inspection_result_insert";
+            Encoding encoding = Encoding.GetEncoding("utf-8");
+            //Map<String, Object> sendData = new LinkedHashMap<String, Object>();
+            IDictionary<string, Object> sendData = new Dictionary<string, Object>();
+
+
+            StringBuilder builder = new StringBuilder();
+            JavaScriptSerializer json = new JavaScriptSerializer();
+            json.Serialize(sendData, builder);
+
+            IDictionary<string, string> parameters = new Dictionary<string, string>();
+            //parameters.Add("app_id", "SUP-FMT");
+            /*注意:参数添加到parameters,必须按参数字母顺序添加*/
+            parameters.Add("app_id", appId);
+            parameters.Add("inspection_amount", count.ToString());
+            parameters.Add("inspection_info", strUpnlist);
+            parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+            parameters.Add("sign", Sign(parameters, uri, esbSecret));
+            string result = GetResponseHTML(esbUrl + uri, buildEncodeUrl(parameters), "POST", null);
+            Console.WriteLine(result);
+            //{"response":{"code":"200","success_count":2}}
+            if ("{\"data\":\"\",\"error_code\":0,\"error_msg\":\"\"}".Equals(result))
+            {
+                return "Success";
+            }
+            else
+            {
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// 删除UPN接口调用
+        /// mes_vendor_upn_inspection_to_del_insert
+        /// </summary>
+        /// <param name="esbUrl"></param>
+        /// <param name="appId"></param>
+        /// <param name="esbSecret"></param>
+        /// <param name="strUpnlist"></param>
+        /// <returns></returns>
+        public String deleteUpnInfo(string esbUrl, string appId, string esbSecret, string strUpnlist)
+        {
+            //string uri = "/mes/basics/wms_battery_info_insert";
+            string uri = "/mes/extranet/mes_vendor_upn_inspection_to_del_insert";
+            Encoding encoding = Encoding.GetEncoding("utf-8");
+            //Map<String, Object> sendData = new LinkedHashMap<String, Object>();
+            IDictionary<string, Object> sendData = new Dictionary<string, Object>();
+
+
+            StringBuilder builder = new StringBuilder();
+            JavaScriptSerializer json = new JavaScriptSerializer();
+            json.Serialize(sendData, builder);
+
+            IDictionary<string, string> parameters = new Dictionary<string, string>();
+            //parameters.Add("app_id", "SUP-FMT");
+            /*注意:参数添加到parameters,必须按参数字母顺序添加*/
+            //parameters.Add("app_id", appId);
+            //parameters.Add("inspection_amount", "1");
+            //parameters.Add("inspection_info", strUpnlist);
+            //parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+
+
+            parameters.Add("app_id", appId);
+            //parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));         
+            parameters.Add("upn_amount", "2");
+            parameters.Add("upn_info", strUpnlist);    //inspection_info     test_info
+            parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+
+            parameters.Add("sign", Sign(parameters, uri, esbSecret));
+            string result = GetResponseHTML(esbUrl + uri, buildEncodeUrl(parameters), "POST", null);
+            Console.Write(result);
+            if ("{\"data\":\"\",\"error_code\":0,\"error_msg\":\"\"}".Equals(result))
+            {
+                return "Success";
+            }
+            else
+            {
+                return result;
+            }
+        }
+
+
+
+        /// <summary>
+        /// 获取UPN信息
+        /// mes_vendor_upn_inspection_to_del_insert
+        /// </summary>
+        /// <param name="esbUrl"></param>
+        /// <param name="appId"></param>
+        /// <param name="esbSecret"></param>
+        /// <param name="strUpnlist"></param>
+        /// <returns></returns>
+        public String getUpnInfo(string esbUrl, string appId, string esbSecret, string strUpn)
+        {
+            //string uri = "/mes/basics/wms_battery_info_insert";
+            string uri = "/mes/extranet/mes_vendor_upn_process_result_list";
+            Encoding encoding = Encoding.GetEncoding("utf-8");
+            //Map<String, Object> sendData = new LinkedHashMap<String, Object>();
+            IDictionary<string, Object> sendData = new Dictionary<string, Object>();
+
+
+            StringBuilder builder = new StringBuilder();
+            JavaScriptSerializer json = new JavaScriptSerializer();
+            json.Serialize(sendData, builder);
+
+            IDictionary<string, string> parameters = new Dictionary<string, string>();
+            //parameters.Add("app_id", "SUP-FMT");
+            /*注意:参数添加到parameters,必须按参数字母顺序添加*/
+            //parameters.Add("app_id", appId);
+            //parameters.Add("inspection_amount", "1");
+            //parameters.Add("inspection_info", strUpnlist);
+            //parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+
+
+            parameters.Add("app_id", appId);
+            //parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));         
+            // parameters.Add("upn_amount", "2");
+            parameters.Add("upn_info", strUpn);    //inspection_info     test_info
+            parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+
+            parameters.Add("sign", Sign(parameters, uri, esbSecret));
+            string result = GetResponseHTML(esbUrl + uri, buildEncodeUrl(parameters), "POST", null);
+            if ("{\"data\":\"\",\"error_code\":0,\"error_msg\":\"\"}".Equals(result))
+            {
+                return "Success";
+            }
+            else
+            {
+                return result;
+            }
+        }
+
+
+        /// <summary>
+        /// 获取锁卡信息接口调用
+        /// mes_lock_card_info_list
+        /// </summary>
+        /// <param name="esbUrl"></param>
+        /// <param name="appId"></param>
+        /// <param name="esbSecret"></param>
+        /// <returns></returns>
+        public String Getinfo(string esbUrl, string appId, string esbSecret)
+        {
+            //string uri = "/mes/basics/wms_battery_info_insert";
+            string uri = "/mes/extranet/mes_lock_card_info_list";
+            Encoding encoding = Encoding.GetEncoding("utf-8");
+            //Map<String, Object> sendData = new LinkedHashMap<String, Object>();
+            IDictionary<string, Object> sendData = new Dictionary<string, Object>();
+
+            StringBuilder builder = new StringBuilder();
+            JavaScriptSerializer json = new JavaScriptSerializer();
+            json.Serialize(sendData, builder);
+
+            IDictionary<string, string> parameters = new Dictionary<string, string>();
+            //parameters.Add("app_id", "SUP-FMT");
+            /*注意:参数添加到parameters,必须按参数字母顺序添加*/
+            //parameters.Add("app_id", appId);
+            //parameters.Add("inspection_amount", "1");
+            //parameters.Add("inspection_info", strUpnlist);
+            //parameters.Add("timestamp", ConvertTimeStamp(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
+
+
+
+            parameters.Add("date_from", "20190227001000");
+            parameters.Add("date_to", "20190228002000");
+            parameters.Add("page_index", "1");
+            parameters.Add("page_size", "10");
+            parameters.Add("app_id", appId);
+            // parameters.Add("upn_info", strUpnlist);    //inspection_info     test_info
+            parameters.Add("timestamp", ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString());
+
+            parameters.Add("sign", GetSign(parameters, uri.Trim(), esbSecret));
+
+            string result = HttpGet(parameters, esbUrl + ":80" + uri, "GET");
+            //  string result = GetResponseHTML(esbUrl + uri, buildEncodeUrl(parameters), "GET", null);
+            if ("{\"data\":\"\",\"error_code\":0,\"error_msg\":\"\"}".Equals(result))
+            {
+                return "Success";
+            }
+            else
+            {
+                return result;
+            }
+        }
+
+
+        public static string GetPostDataStr(IDictionary<string, string> dict)
+        {
+            string postDataStr = "";
+            StringBuilder myStringBuilder = new StringBuilder();
+            foreach (var item in dict)
+            {
+                myStringBuilder.Append(HttpUtility.UrlEncode(item.Key));
+                myStringBuilder.Append("=");
+                myStringBuilder.Append(HttpUtility.UrlEncode(item.Value));
+                myStringBuilder.Append("&");
+            }
+            int lenght = myStringBuilder.ToString().Length;
+            postDataStr = lenght > 1 ? myStringBuilder.ToString().Remove(lenght - 1) : "";
+            return postDataStr;
+        }
+
+        public static string HttpGet(IDictionary<string, string> dict, string apiUrl, string strMethod, string ContentType = "text/html;charset=UTF-8")
+        {
+            string retString = "";
+            HttpWebRequest request = null;
+            HttpWebResponse response = null;
+            #region 记录接口日志相关
+            //   InterfaceInvokeLogEntity logInfo = new InterfaceInvokeLogEntity();
+            string postDataStr = string.Empty;
+            #endregion
+            try
+            {
+                #region 记录接口日志相关
+                //用于记录日志 MZ 2017-08-01
+                postDataStr = GetPostDataStr(dict);
+
+                #endregion
+                string url = apiUrl;
+                //请求参数
+                //请求路径
+                var requestPath = url + (postDataStr == "" ? "" : "?") + postDataStr;
+                request = (HttpWebRequest)WebRequest.Create(requestPath);
+                request.Method = strMethod;
+                if (!string.IsNullOrEmpty(ContentType))
+                    request.ContentType = ContentType;
+                else
+                    request.ContentType = "text/html;charset=UTF-8";
+                request.Timeout = 120000;
+                //获取响应,取出其中的json数据
+                response = (HttpWebResponse)request.GetResponse();
+                if (response.StatusCode == HttpStatusCode.OK)
+                {
+                    Stream myResponseStream = response.GetResponseStream();
+                    StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
+                    retString = myStreamReader.ReadToEnd();
+                    myStreamReader.Close();
+                    myResponseStream.Close();
+
+                    #region 记录接口日志相关
+                    //记录调用日志 MZ
+
+                    #endregion
+                }
+
+            }
+            catch (WebException ex)
+            {
+                try
+                {
+                    HttpWebResponse res = (HttpWebResponse)ex.Response;
+                    StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("UTF-8"));
+                    //真正的原因
+                    string errorMessage = sr.ReadToEnd();
+                    //todo:发超时邮件
+
+                    return null;
+                }
+                catch (Exception)
+                {
+                }
+            }
+            finally
+            {
+
+            }
+
+            return retString;
+        }
+
+
+        public static string GetSign(IDictionary<string, string> parameters, string url, string secret)
+        {
+            var builder = new StringBuilder();
+            builder.Append(url);
+            builder.Append("\n");
+
+            foreach (var param in parameters.OrderBy(t => t.Key))
+            {
+                builder.Append(string.Format("{0}={1}\n", param.Key, param.Value));
+            }
+
+            builder.Append(secret);
+            return GetMd5_2(builder.ToString());
+        }
+
+        public static string GetMd5_2(string src)
+        {
+            var buffer = new StringBuilder();
+            using (var md5 = MD5.Create())
+            {
+                var md5Bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(src));
+                for (var i = 0; i < md5Bytes.Length; i++)
+                {
+                    var val = Convert.ToInt32(md5Bytes[i] & 0xff);
+                    if (val < 16)
+                    {
+                        buffer.Append("0");
+                    }
+                    buffer.Append(string.Format("{0:X}", val));
+                }
+            }
+
+            return buffer.ToString();
+        }
+
+    }
+}

+ 5 - 2
UAS-出货标签管理/PublicMethod/ftpOperater.cs

@@ -16,7 +16,7 @@ namespace UAS_LabelMachine
         private string ftpUser;
         private string ftpPwd;
 
-        public ftpOperater()
+        public ftpOperater(bool PortModel)
         {
             string[] FTPInf = DataHelper.FTPAdress.Split('|');
             this.ftpServerIP = FTPInf[0];
@@ -43,6 +43,7 @@ namespace UAS_LabelMachine
             FtpWebRequest reqFTP;
             reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
             reqFTP.UseBinary = true;
+            reqFTP.UsePassive = Properties.Settings.Default.FTPModel;
             reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
             reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
             FileInfo file = new FileInfo(filepath + "/" + filename);
@@ -81,6 +82,7 @@ namespace UAS_LabelMachine
                 reqFTP.UseBinary = true;
                 reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
                 reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
+                reqFTP.UsePassive = Properties.Settings.Default.FTPModel;
                 WebResponse response = reqFTP.GetResponse();
                 StreamReader reader = new StreamReader(response.GetResponseStream());
 
@@ -119,6 +121,7 @@ namespace UAS_LabelMachine
                 reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP + "/" + filename));
                 reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;
                 reqFTP.UseBinary = true;
+                reqFTP.UsePassive = Properties.Settings.Default.FTPModel;
                 reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
                 FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                 Stream ftpStream = response.GetResponseStream();
@@ -147,7 +150,7 @@ namespace UAS_LabelMachine
                 reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
                 reqFTP.UseBinary = true;
                 reqFTP.Credentials = new NetworkCredential(ftpUser, ftpPwd);
-                reqFTP.UsePassive = true;
+                reqFTP.UsePassive = Properties.Settings.Default.FTPModel;
                 FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                 Stream ftpStream = response.GetResponseStream();
                 long cl = response.ContentLength;

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

@@ -237,6 +237,7 @@
     <Compile Include="PublicMethod\ExcelHandler.cs" />
     <Compile Include="PublicMethod\ftpOperater.cs" />
     <Compile Include="PublicMethod\GlobalEventsHandler.cs" />
+    <Compile Include="PublicMethod\HttpCommand.cs" />
     <Compile Include="PublicMethod\HttpHandler.cs" />
     <Compile Include="PublicMethod\LogManager.cs" />
     <Compile Include="Service References\Vivo_BoxReelRelation\Reference.cs">

+ 266 - 250
UAS-出货标签管理/UAS_出货标签管理.Designer.cs

@@ -61,7 +61,6 @@
             this.label3 = new System.Windows.Forms.Label();
             this.CleanInputAfterCollect = new System.Windows.Forms.CheckBox();
             this.AllCollected = new System.Windows.Forms.Button();
-            this.PowerSetting = new System.Windows.Forms.Button();
             this.RefreshDBConnect = new System.Windows.Forms.Timer(this.components);
             this.GetGridOnly = new System.Windows.Forms.CheckBox();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
@@ -95,12 +94,14 @@
             this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
             this.AttachInfo = new System.Windows.Forms.Button();
             this.pi_date = new System.Windows.Forms.Label();
+            this.CleanBarCode = new System.Windows.Forms.Button();
             this.groupBoxWithBorder1 = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.ExportData = new System.Windows.Forms.Button();
             this.label18 = new System.Windows.Forms.Label();
             this.MidBoxEnd = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.MidBoxBegin = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.label16 = new System.Windows.Forms.Label();
+            this.PowerSetting = new System.Windows.Forms.Button();
             this.SingleBoxEnd = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.SingleBoxBegin = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.label12 = new System.Windows.Forms.Label();
@@ -124,33 +125,9 @@
             this.sg_code = new UAS_LabelMachine.CustomControl.SearchTextBox();
             this.MessageLog = new UAS_LabelMachine.CustomControl.RichText.RichTextAutoBottom();
             this.LabelInf = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
-            this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifpick = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_cusbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_cusoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_outboxcode2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.SingleLabel = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.OPPOPlate = new System.Windows.Forms.Button();
             this.ViVoPlate = new System.Windows.Forms.Button();
             this.SingleLabelPrinter = new UAS_LabelMachine.CustomControl.PrinterCombox();
             this.SingleLabelPrint = new System.Windows.Forms.Button();
@@ -178,7 +155,31 @@
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
-            this.CleanBarCode = new System.Windows.Forms.Button();
+            this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifpick = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_cusbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_cusoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_outboxcode2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.Si_ItemDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             this.groupBoxWithBorder1.SuspendLayout();
@@ -515,19 +516,6 @@
             this.AllCollected.UseVisualStyleBackColor = true;
             this.AllCollected.Click += new System.EventHandler(this.AllCollected_Click);
             // 
-            // PowerSetting
-            // 
-            this.PowerSetting.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.PowerSetting.Location = new System.Drawing.Point(69, 202);
-            this.PowerSetting.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.PowerSetting.Name = "PowerSetting";
-            this.PowerSetting.Size = new System.Drawing.Size(68, 26);
-            this.PowerSetting.TabIndex = 76;
-            this.PowerSetting.Text = "权限设置";
-            this.PowerSetting.UseVisualStyleBackColor = true;
-            this.PowerSetting.Visible = false;
-            this.PowerSetting.Click += new System.EventHandler(this.PowerSetting_Click);
-            // 
             // RefreshDBConnect
             // 
             this.RefreshDBConnect.Tick += new System.EventHandler(this.RefreshDBConnect_Tick);
@@ -783,6 +771,18 @@
             this.pi_date.TabIndex = 86;
             this.pi_date.Visible = false;
             // 
+            // CleanBarCode
+            // 
+            this.CleanBarCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.CleanBarCode.Location = new System.Drawing.Point(522, 178);
+            this.CleanBarCode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.CleanBarCode.Name = "CleanBarCode";
+            this.CleanBarCode.Size = new System.Drawing.Size(68, 26);
+            this.CleanBarCode.TabIndex = 87;
+            this.CleanBarCode.Text = "清空条码";
+            this.CleanBarCode.UseVisualStyleBackColor = true;
+            this.CleanBarCode.Click += new System.EventHandler(this.CleanBarCode_Click);
+            // 
             // groupBoxWithBorder1
             // 
             this.groupBoxWithBorder1.Controls.Add(this.ExportData);
@@ -861,6 +861,19 @@
             this.label16.TabIndex = 87;
             this.label16.Text = "-";
             // 
+            // PowerSetting
+            // 
+            this.PowerSetting.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.PowerSetting.Location = new System.Drawing.Point(69, 202);
+            this.PowerSetting.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.PowerSetting.Name = "PowerSetting";
+            this.PowerSetting.Size = new System.Drawing.Size(68, 26);
+            this.PowerSetting.TabIndex = 76;
+            this.PowerSetting.Text = "权限设置";
+            this.PowerSetting.UseVisualStyleBackColor = true;
+            this.PowerSetting.Visible = false;
+            this.PowerSetting.Click += new System.EventHandler(this.PowerSetting_Click);
+            // 
             // SingleBoxEnd
             // 
             this.SingleBoxEnd.ID = null;
@@ -1170,203 +1183,6 @@
             this.LabelInf.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelInf_CellValueChanged);
             this.LabelInf.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.LabelInf_DataError);
             // 
-            // Choose
-            // 
-            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.Choose.HeaderText = "勾选";
-            this.Choose.Name = "Choose";
-            this.Choose.Resizable = System.Windows.Forms.DataGridViewTriState.True;
-            this.Choose.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
-            this.Choose.Width = 55;
-            // 
-            // pib_ifpick
-            // 
-            this.pib_ifpick.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_ifpick.DataPropertyName = "pib_ifpick";
-            this.pib_ifpick.HeaderText = "已采集";
-            this.pib_ifpick.Name = "pib_ifpick";
-            this.pib_ifpick.Width = 60;
-            // 
-            // pib_ifprint
-            // 
-            this.pib_ifprint.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_ifprint.DataPropertyName = "pib_ifprint";
-            this.pib_ifprint.HeaderText = "已打印";
-            this.pib_ifprint.Name = "pib_ifprint";
-            this.pib_ifprint.Width = 60;
-            // 
-            // pib_id1
-            // 
-            this.pib_id1.DataPropertyName = "pib_id";
-            this.pib_id1.HeaderText = "pib_id";
-            this.pib_id1.Name = "pib_id1";
-            this.pib_id1.Visible = false;
-            this.pib_id1.Width = 66;
-            // 
-            // pib_pdno
-            // 
-            this.pib_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_pdno.DataPropertyName = "pib_pdno";
-            this.pib_pdno.HeaderText = "明细序号";
-            this.pib_pdno.Name = "pib_pdno";
-            this.pib_pdno.ReadOnly = true;
-            this.pib_pdno.Width = 96;
-            // 
-            // pib_prodcode
-            // 
-            this.pib_prodcode.DataPropertyName = "pib_prodcode";
-            this.pib_prodcode.HeaderText = "物料编号";
-            this.pib_prodcode.Name = "pib_prodcode";
-            this.pib_prodcode.ReadOnly = true;
-            this.pib_prodcode.Width = 78;
-            // 
-            // pr_vendprodcode
-            // 
-            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
-            this.pr_vendprodcode.HeaderText = "MPN";
-            this.pr_vendprodcode.Name = "pr_vendprodcode";
-            this.pr_vendprodcode.ReadOnly = true;
-            this.pr_vendprodcode.Width = 48;
-            // 
-            // pib_brand
-            // 
-            this.pib_brand.DataPropertyName = "pib_brand";
-            this.pib_brand.HeaderText = "品牌";
-            this.pib_brand.Name = "pib_brand";
-            this.pib_brand.ReadOnly = true;
-            this.pib_brand.Width = 54;
-            // 
-            // pib_madein
-            // 
-            this.pib_madein.DataPropertyName = "pib_madein";
-            this.pib_madein.HeaderText = "产地";
-            this.pib_madein.Name = "pib_madein";
-            this.pib_madein.Width = 54;
-            // 
-            // pr_zxbzs
-            // 
-            this.pr_zxbzs.DataPropertyName = "pr_zxbzs";
-            this.pr_zxbzs.HeaderText = "最小包装数";
-            this.pr_zxbzs.Name = "pr_zxbzs";
-            this.pr_zxbzs.Visible = false;
-            this.pr_zxbzs.Width = 90;
-            // 
-            // pr_unit
-            // 
-            this.pr_unit.DataPropertyName = "pr_unit";
-            this.pr_unit.HeaderText = "单位";
-            this.pr_unit.Name = "pr_unit";
-            this.pr_unit.Visible = false;
-            this.pr_unit.Width = 54;
-            // 
-            // pib_lotno
-            // 
-            this.pib_lotno.DataPropertyName = "pib_lotno";
-            this.pib_lotno.HeaderText = "LotNo";
-            this.pib_lotno.Name = "pib_lotno";
-            this.pib_lotno.Width = 60;
-            // 
-            // pib_datecode
-            // 
-            this.pib_datecode.DataPropertyName = "pib_datecode";
-            this.pib_datecode.HeaderText = "DateCode";
-            this.pib_datecode.Name = "pib_datecode";
-            this.pib_datecode.Width = 78;
-            // 
-            // pib_cusbarcode
-            // 
-            this.pib_cusbarcode.DataPropertyName = "pib_cusbarcode";
-            this.pib_cusbarcode.HeaderText = "ViVo条码号";
-            this.pib_cusbarcode.Name = "pib_cusbarcode";
-            this.pib_cusbarcode.Width = 90;
-            // 
-            // pib_cusoutboxcode
-            // 
-            this.pib_cusoutboxcode.DataPropertyName = "pib_cusoutboxcode";
-            this.pib_cusoutboxcode.HeaderText = "ViVo外箱";
-            this.pib_cusoutboxcode.Name = "pib_cusoutboxcode";
-            this.pib_cusoutboxcode.Width = 78;
-            // 
-            // pib_datecode1
-            // 
-            this.pib_datecode1.DataPropertyName = "pib_datecode1";
-            this.pib_datecode1.HeaderText = "DateCode1";
-            this.pib_datecode1.Name = "pib_datecode1";
-            this.pib_datecode1.Visible = false;
-            this.pib_datecode1.Width = 84;
-            // 
-            // pib_qty
-            // 
-            this.pib_qty.DataPropertyName = "pib_qty";
-            this.pib_qty.HeaderText = "数量";
-            this.pib_qty.Name = "pib_qty";
-            this.pib_qty.ReadOnly = true;
-            this.pib_qty.Width = 54;
-            // 
-            // pib_barcode
-            // 
-            this.pib_barcode.DataPropertyName = "pib_barcode";
-            this.pib_barcode.HeaderText = "唯一条码";
-            this.pib_barcode.Name = "pib_barcode";
-            this.pib_barcode.ReadOnly = true;
-            this.pib_barcode.Width = 78;
-            // 
-            // pib_custbarcode
-            // 
-            this.pib_custbarcode.DataPropertyName = "pib_custbarcode";
-            this.pib_custbarcode.HeaderText = "客户条码";
-            this.pib_custbarcode.Name = "pib_custbarcode";
-            this.pib_custbarcode.ReadOnly = true;
-            this.pib_custbarcode.Width = 78;
-            // 
-            // pd_pocode
-            // 
-            this.pd_pocode.DataPropertyName = "pd_pocode";
-            this.pd_pocode.HeaderText = "客户PO";
-            this.pd_pocode.Name = "pd_pocode";
-            this.pd_pocode.ReadOnly = true;
-            this.pd_pocode.Width = 66;
-            // 
-            // pd_custprodcode
-            // 
-            this.pd_custprodcode.DataPropertyName = "pd_custprodcode";
-            this.pd_custprodcode.HeaderText = "客户料号";
-            this.pd_custprodcode.Name = "pd_custprodcode";
-            this.pd_custprodcode.ReadOnly = true;
-            this.pd_custprodcode.Width = 78;
-            // 
-            // pd_custprodspec
-            // 
-            this.pd_custprodspec.DataPropertyName = "pd_custprodspec";
-            this.pd_custprodspec.HeaderText = "客户型号";
-            this.pd_custprodspec.Name = "pd_custprodspec";
-            this.pd_custprodspec.ReadOnly = true;
-            this.pd_custprodspec.Width = 78;
-            // 
-            // pr_spec
-            // 
-            this.pr_spec.DataPropertyName = "pr_spec";
-            this.pr_spec.HeaderText = "规格";
-            this.pr_spec.Name = "pr_spec";
-            this.pr_spec.Visible = false;
-            this.pr_spec.Width = 54;
-            // 
-            // pib_outboxcode1
-            // 
-            this.pib_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_outboxcode1.DataPropertyName = "pib_outboxcode1";
-            this.pib_outboxcode1.HeaderText = "中盒号";
-            this.pib_outboxcode1.Name = "pib_outboxcode1";
-            this.pib_outboxcode1.Width = 90;
-            // 
-            // pib_outboxcode2
-            // 
-            this.pib_outboxcode2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_outboxcode2.DataPropertyName = "pib_outboxcode2";
-            this.pib_outboxcode2.HeaderText = "外箱号";
-            this.pib_outboxcode2.Name = "pib_outboxcode2";
-            this.pib_outboxcode2.Width = 90;
-            // 
             // pi_inoutno
             // 
             this.pi_inoutno.ID = null;
@@ -1382,6 +1198,7 @@
             // 
             // SingleLabel
             // 
+            this.SingleLabel.Controls.Add(this.OPPOPlate);
             this.SingleLabel.Controls.Add(this.ViVoPlate);
             this.SingleLabel.Controls.Add(this.SingleLabelPrinter);
             this.SingleLabel.Controls.Add(this.SingleLabelPrint);
@@ -1397,11 +1214,24 @@
             this.SingleLabel.TabStop = false;
             this.SingleLabel.Text = "单盘标签";
             // 
+            // OPPOPlate
+            // 
+            this.OPPOPlate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.OPPOPlate.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.OPPOPlate.Location = new System.Drawing.Point(68, 132);
+            this.OPPOPlate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.OPPOPlate.Name = "OPPOPlate";
+            this.OPPOPlate.Size = new System.Drawing.Size(80, 26);
+            this.OPPOPlate.TabIndex = 42;
+            this.OPPOPlate.Text = "Oppo料盘";
+            this.OPPOPlate.UseVisualStyleBackColor = true;
+            this.OPPOPlate.Click += new System.EventHandler(this.OPPOPlate_Click);
+            // 
             // ViVoPlate
             // 
             this.ViVoPlate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ViVoPlate.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ViVoPlate.Location = new System.Drawing.Point(34, 164);
+            this.ViVoPlate.Location = new System.Drawing.Point(68, 164);
             this.ViVoPlate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.ViVoPlate.Name = "ViVoPlate";
             this.ViVoPlate.Size = new System.Drawing.Size(68, 26);
@@ -1423,7 +1253,7 @@
             // 
             this.SingleLabelPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.SingleLabelPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelPrint.Location = new System.Drawing.Point(34, 199);
+            this.SingleLabelPrint.Location = new System.Drawing.Point(68, 199);
             this.SingleLabelPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelPrint.Name = "SingleLabelPrint";
             this.SingleLabelPrint.Size = new System.Drawing.Size(68, 26);
@@ -1726,17 +1556,202 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
-            // CleanBarCode
+            // Choose
             // 
-            this.CleanBarCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.CleanBarCode.Location = new System.Drawing.Point(522, 178);
-            this.CleanBarCode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.CleanBarCode.Name = "CleanBarCode";
-            this.CleanBarCode.Size = new System.Drawing.Size(68, 26);
-            this.CleanBarCode.TabIndex = 87;
-            this.CleanBarCode.Text = "清空条码";
-            this.CleanBarCode.UseVisualStyleBackColor = true;
-            this.CleanBarCode.Click += new System.EventHandler(this.CleanBarCode_Click);
+            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.Choose.HeaderText = "勾选";
+            this.Choose.Name = "Choose";
+            this.Choose.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.Choose.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.Choose.Width = 55;
+            // 
+            // pib_ifpick
+            // 
+            this.pib_ifpick.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_ifpick.DataPropertyName = "pib_ifpick";
+            this.pib_ifpick.HeaderText = "已采集";
+            this.pib_ifpick.Name = "pib_ifpick";
+            this.pib_ifpick.Width = 60;
+            // 
+            // pib_ifprint
+            // 
+            this.pib_ifprint.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_ifprint.DataPropertyName = "pib_ifprint";
+            this.pib_ifprint.HeaderText = "已打印";
+            this.pib_ifprint.Name = "pib_ifprint";
+            this.pib_ifprint.Width = 60;
+            // 
+            // pib_id1
+            // 
+            this.pib_id1.DataPropertyName = "pib_id";
+            this.pib_id1.HeaderText = "pib_id";
+            this.pib_id1.Name = "pib_id1";
+            this.pib_id1.Width = 66;
+            // 
+            // pib_pdno
+            // 
+            this.pib_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_pdno.DataPropertyName = "pib_pdno";
+            this.pib_pdno.HeaderText = "明细序号";
+            this.pib_pdno.Name = "pib_pdno";
+            this.pib_pdno.ReadOnly = true;
+            this.pib_pdno.Width = 96;
+            // 
+            // pib_prodcode
+            // 
+            this.pib_prodcode.DataPropertyName = "pib_prodcode";
+            this.pib_prodcode.HeaderText = "物料编号";
+            this.pib_prodcode.Name = "pib_prodcode";
+            this.pib_prodcode.ReadOnly = true;
+            this.pib_prodcode.Width = 78;
+            // 
+            // pr_vendprodcode
+            // 
+            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
+            this.pr_vendprodcode.HeaderText = "MPN";
+            this.pr_vendprodcode.Name = "pr_vendprodcode";
+            this.pr_vendprodcode.ReadOnly = true;
+            this.pr_vendprodcode.Width = 48;
+            // 
+            // pib_brand
+            // 
+            this.pib_brand.DataPropertyName = "pib_brand";
+            this.pib_brand.HeaderText = "品牌";
+            this.pib_brand.Name = "pib_brand";
+            this.pib_brand.ReadOnly = true;
+            this.pib_brand.Width = 54;
+            // 
+            // pib_madein
+            // 
+            this.pib_madein.DataPropertyName = "pib_madein";
+            this.pib_madein.HeaderText = "产地";
+            this.pib_madein.Name = "pib_madein";
+            this.pib_madein.Width = 54;
+            // 
+            // pr_zxbzs
+            // 
+            this.pr_zxbzs.DataPropertyName = "pr_zxbzs";
+            this.pr_zxbzs.HeaderText = "最小包装数";
+            this.pr_zxbzs.Name = "pr_zxbzs";
+            this.pr_zxbzs.Visible = false;
+            this.pr_zxbzs.Width = 90;
+            // 
+            // pr_unit
+            // 
+            this.pr_unit.DataPropertyName = "pr_unit";
+            this.pr_unit.HeaderText = "单位";
+            this.pr_unit.Name = "pr_unit";
+            this.pr_unit.Visible = false;
+            this.pr_unit.Width = 54;
+            // 
+            // pib_lotno
+            // 
+            this.pib_lotno.DataPropertyName = "pib_lotno";
+            this.pib_lotno.HeaderText = "LotNo";
+            this.pib_lotno.Name = "pib_lotno";
+            this.pib_lotno.Width = 60;
+            // 
+            // pib_datecode
+            // 
+            this.pib_datecode.DataPropertyName = "pib_datecode";
+            this.pib_datecode.HeaderText = "DateCode";
+            this.pib_datecode.Name = "pib_datecode";
+            this.pib_datecode.Width = 78;
+            // 
+            // pib_cusbarcode
+            // 
+            this.pib_cusbarcode.DataPropertyName = "pib_cusbarcode";
+            this.pib_cusbarcode.HeaderText = "ViVo条码号";
+            this.pib_cusbarcode.Name = "pib_cusbarcode";
+            this.pib_cusbarcode.Width = 90;
+            // 
+            // pib_cusoutboxcode
+            // 
+            this.pib_cusoutboxcode.DataPropertyName = "pib_cusoutboxcode";
+            this.pib_cusoutboxcode.HeaderText = "ViVo外箱";
+            this.pib_cusoutboxcode.Name = "pib_cusoutboxcode";
+            this.pib_cusoutboxcode.Width = 78;
+            // 
+            // pib_datecode1
+            // 
+            this.pib_datecode1.DataPropertyName = "pib_datecode1";
+            this.pib_datecode1.HeaderText = "DateCode1";
+            this.pib_datecode1.Name = "pib_datecode1";
+            this.pib_datecode1.Visible = false;
+            this.pib_datecode1.Width = 84;
+            // 
+            // pib_qty
+            // 
+            this.pib_qty.DataPropertyName = "pib_qty";
+            this.pib_qty.HeaderText = "数量";
+            this.pib_qty.Name = "pib_qty";
+            this.pib_qty.ReadOnly = true;
+            this.pib_qty.Width = 54;
+            // 
+            // pib_barcode
+            // 
+            this.pib_barcode.DataPropertyName = "pib_barcode";
+            this.pib_barcode.HeaderText = "唯一条码";
+            this.pib_barcode.Name = "pib_barcode";
+            this.pib_barcode.ReadOnly = true;
+            this.pib_barcode.Width = 78;
+            // 
+            // pib_custbarcode
+            // 
+            this.pib_custbarcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
+            this.pib_custbarcode.DataPropertyName = "pib_custbarcode";
+            this.pib_custbarcode.HeaderText = "客户条码";
+            this.pib_custbarcode.Name = "pib_custbarcode";
+            this.pib_custbarcode.ReadOnly = true;
+            this.pib_custbarcode.Width = 78;
+            // 
+            // pd_pocode
+            // 
+            this.pd_pocode.DataPropertyName = "pd_pocode";
+            this.pd_pocode.HeaderText = "客户PO";
+            this.pd_pocode.Name = "pd_pocode";
+            this.pd_pocode.ReadOnly = true;
+            this.pd_pocode.Width = 66;
+            // 
+            // pd_custprodcode
+            // 
+            this.pd_custprodcode.DataPropertyName = "pd_custprodcode";
+            this.pd_custprodcode.HeaderText = "客户料号";
+            this.pd_custprodcode.Name = "pd_custprodcode";
+            this.pd_custprodcode.ReadOnly = true;
+            this.pd_custprodcode.Width = 78;
+            // 
+            // pd_custprodspec
+            // 
+            this.pd_custprodspec.DataPropertyName = "pd_custprodspec";
+            this.pd_custprodspec.HeaderText = "客户型号";
+            this.pd_custprodspec.Name = "pd_custprodspec";
+            this.pd_custprodspec.ReadOnly = true;
+            this.pd_custprodspec.Width = 78;
+            // 
+            // pr_spec
+            // 
+            this.pr_spec.DataPropertyName = "pr_spec";
+            this.pr_spec.HeaderText = "规格";
+            this.pr_spec.Name = "pr_spec";
+            this.pr_spec.Visible = false;
+            this.pr_spec.Width = 54;
+            // 
+            // pib_outboxcode1
+            // 
+            this.pib_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_outboxcode1.DataPropertyName = "pib_outboxcode1";
+            this.pib_outboxcode1.HeaderText = "中盒号";
+            this.pib_outboxcode1.Name = "pib_outboxcode1";
+            this.pib_outboxcode1.Width = 90;
+            // 
+            // pib_outboxcode2
+            // 
+            this.pib_outboxcode2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_outboxcode2.DataPropertyName = "pib_outboxcode2";
+            this.pib_outboxcode2.HeaderText = "外箱号";
+            this.pib_outboxcode2.Name = "pib_outboxcode2";
+            this.pib_outboxcode2.Width = 90;
             // 
             // UAS_出货标签打印
             // 
@@ -1938,6 +1953,8 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn si_expressionitem;
         private System.Windows.Forms.Button AttachInfo;
         private System.Windows.Forms.Label pi_date;
+        private System.Windows.Forms.Button CleanBarCode;
+        private System.Windows.Forms.Button OPPOPlate;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifpick;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
@@ -1963,6 +1980,5 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
-        private System.Windows.Forms.Button CleanBarCode;
     }
 }

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

@@ -16,6 +16,7 @@ using System.Threading;
 using System.IO;
 using System.Globalization;
 using System.Threading.Tasks;
+using System.Reflection;
 
 namespace UAS_LabelMachine
 {
@@ -147,7 +148,12 @@ namespace UAS_LabelMachine
 
         public UAS_出货标签打印(string Master)
         {
+            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
+            this.UpdateStyles();
             InitializeComponent();
+            Type dgvType = this.LabelInf.GetType();
+            PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
+            pi.SetValue(this.LabelInf, true, null);
             Text = Text + "-" + Master;
         }
 
@@ -1947,7 +1953,7 @@ namespace UAS_LabelMachine
             if (DataHelper.DBConnectionString.Contains("richwell") || DataHelper.DBConnectionString.Contains("192.168.0.88"))
             {
                 sql.Clear();
-                sql.Append("select pd_custprodcode,pd_pocode,pd_inoutno,pib_custbarcode,pib_brand,pib_cusbarcode,pib_cusoutboxcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,");
+                sql.Append("select pd_custprodcode,pd_pocode,pd_inoutno,pib_madein,pib_custbarcode,pib_brand,pib_cusbarcode,pib_cusoutboxcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,");
                 sql.Append("pr_brand,pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint,");
                 sql.Append("pr_spec,pd_prodcode,pd_pocode,pr_code from prodiobarcode  left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno ");
                 sql.Append("and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join (select pd_prodcode ");
@@ -2533,5 +2539,52 @@ namespace UAS_LabelMachine
                 LoadGridData(sender, e);
             }
         }
+        HttpCommand hc = new HttpCommand();
+        const string AppId = "OPPO_UPN";
+        const string Secret = "c9f2e3237b66415ead1df77e97abd72d";
+        int PageCount = 100;
+        private void OPPOPlate_Click(object sender, EventArgs e)
+        {
+            StringBuilder strUpnList = new StringBuilder();
+            string date = System.DateTime.Now.ToString("yyMdd");
+            for (int i = 0; i < LabelInf.Rows.Count; i++)
+            {
+                if (i % PageCount == 0)
+                {
+                    strUpnList.Append("[");
+                }
+                string cuprodcode = LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString();
+                string vendprodcode = LabelInf.Rows[i].Cells["pr_vendprodcode"].Value.ToString();
+                string madein = LabelInf.Rows[i].Cells["pib_madein"].Value.ToString();
+                string dc = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
+                string ln = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
+                string qty = LabelInf.Rows[i].Cells["pib_qty"].Value.ToString();
+                string serial = BaseUtil.lpad(5, (i + 1).ToString());
+                string barcode = cuprodcode + "-" + "JW9591" + "-" + date + "-" + serial;
+                strUpnList.Append(@"{""upn_qr"":""@upn*@time*@MSD*@DC*@LN*@QC*@qty*@hd*@sw*@madein"",").Replace("@upn", cuprodcode + "-" + "JW9591" + "-" + date + "-" + serial)
+                    .Replace("@time", System.DateTime.Now.ToString("yyyyMMddhhmmssff")).Replace("@MSD", "").Replace("@DC", dc).Replace("@LN", ln)
+                    .Replace("@QC", "").Replace("@qty", qty).Replace("@hd", "").Replace("@sw", "").Replace("@madein", madein);
+                strUpnList.Append(@"""upn"":""@upn"",").Replace("@upn", barcode);
+                strUpnList.Append(@"""vendor_code"":""JW9591"",");
+                strUpnList.Append(@"""mat_id"":""@mat_id"",").Replace("@mat_id", cuprodcode);
+                strUpnList.Append(@"""vendor_spec"":""@vendor_spec"",").Replace("@vendor_spec", vendprodcode);
+                strUpnList.Append(@"""wafer_factory"":""@wafer_factory"",").Replace("@wafer_factory", madein);
+                strUpnList.Append(@"""pack_factory"":""@pack_factory"",").Replace("@pack_factory", madein);
+                strUpnList.Append(@"""dc"":""@dc"",").Replace("@dc", dc);
+                strUpnList.Append(@"""ln"":""@ln"",").Replace("@ln", ln);
+                strUpnList.Append(@"""qty"":@qty}").Replace("@qty", qty);
+                LabelInf.Rows[i].Cells["pib_custbarcode"].Value = barcode;
+                if (!((i != 0 && (i + 1) % PageCount == 0) || i == LabelInf.Rows.Count - 1))
+                {
+                    strUpnList.Append(",");
+                }
+                if ((i != 0 && (i + 1) % PageCount == 0) || i == LabelInf.Rows.Count - 1)
+                {
+                    strUpnList.Append("]");
+                    string strmsginsert = hc.insertUpnInfo("https://apitest.myoas.com", AppId, Secret, strUpnList.ToString(), (i + 1) % PageCount == 0 ? PageCount : (i + 1) % PageCount);
+                    strUpnList.Clear();
+                }
+            }
+        }
     }
 }

+ 41 - 12
UAS-出货标签管理/客户标签维护.Designer.cs

@@ -33,8 +33,8 @@ namespace UAS_LabelMachine
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(客户标签维护));
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
             this.cl_code_label = new System.Windows.Forms.Label();
             this.cu_name_label = new System.Windows.Forms.Label();
             this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
@@ -85,6 +85,7 @@ namespace UAS_LabelMachine
             this.UpdateGrid = new UAS_LabelMachine.CustomControl.NormalButton();
             this.Screen = new UAS_LabelMachine.CustomControl.NormalButton();
             this.cu_name = new UAS_LabelMachine.CustomControl.EnterTextBox();
+            this.PortModel = new System.Windows.Forms.CheckBox();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
             this.SuspendLayout();
@@ -332,17 +333,22 @@ namespace UAS_LabelMachine
             // 
             // la_code
             // 
+            this.la_code.AllPower = null;
             this.la_code.Caller = null;
             this.la_code.Condition = null;
+            this.la_code.DBTitle = null;
             this.la_code.FormName = null;
             this.la_code.Location = new System.Drawing.Point(659, 455);
             this.la_code.Name = "la_code";
+            this.la_code.Power = null;
+            this.la_code.ReturnData = null;
             this.la_code.SelectField = null;
             this.la_code.SetValueField = null;
             this.la_code.Size = new System.Drawing.Size(161, 21);
             this.la_code.TabIndex = 179;
             this.la_code.TableName = null;
             this.la_code.Tag = "la_code";
+            this.la_code.TextBoxEnable = false;
             // 
             // Save
             // 
@@ -395,16 +401,16 @@ namespace UAS_LabelMachine
             this.cl_status});
             this.LabelDataGridView.Location = new System.Drawing.Point(17, 90);
             this.LabelDataGridView.Name = "LabelDataGridView";
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle1.BackColor = System.Drawing.Color.Blue;
-            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
-            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.LabelDataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle1;
-            dataGridViewCellStyle2.BackColor = System.Drawing.Color.White;
-            this.LabelDataGridView.RowsDefaultCellStyle = dataGridViewCellStyle2;
+            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle3.BackColor = System.Drawing.Color.Blue;
+            dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
+            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.LabelDataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+            dataGridViewCellStyle4.BackColor = System.Drawing.Color.White;
+            this.LabelDataGridView.RowsDefaultCellStyle = dataGridViewCellStyle4;
             this.LabelDataGridView.RowTemplate.Height = 23;
             this.LabelDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.LabelDataGridView.Size = new System.Drawing.Size(890, 348);
@@ -519,31 +525,41 @@ namespace UAS_LabelMachine
             // 
             // 客户编号
             // 
+            this.客户编号.AllPower = null;
             this.客户编号.Caller = null;
             this.客户编号.Condition = null;
+            this.客户编号.DBTitle = null;
             this.客户编号.FormName = null;
             this.客户编号.Location = new System.Drawing.Point(116, 453);
             this.客户编号.Name = "客户编号";
+            this.客户编号.Power = null;
+            this.客户编号.ReturnData = null;
             this.客户编号.SelectField = null;
             this.客户编号.SetValueField = null;
             this.客户编号.Size = new System.Drawing.Size(136, 21);
             this.客户编号.TabIndex = 168;
             this.客户编号.TableName = null;
             this.客户编号.Tag = "cu_code";
+            this.客户编号.TextBoxEnable = false;
             // 
             // cu_code
             // 
+            this.cu_code.AllPower = null;
             this.cu_code.Caller = null;
             this.cu_code.Condition = null;
+            this.cu_code.DBTitle = null;
             this.cu_code.FormName = null;
             this.cu_code.Location = new System.Drawing.Point(127, 16);
             this.cu_code.Name = "cu_code";
+            this.cu_code.Power = null;
+            this.cu_code.ReturnData = null;
             this.cu_code.SelectField = null;
             this.cu_code.SetValueField = null;
             this.cu_code.Size = new System.Drawing.Size(150, 21);
             this.cu_code.TabIndex = 159;
             this.cu_code.TableName = null;
             this.cu_code.Tag = "cl_custcode";
+            this.cu_code.TextBoxEnable = false;
             // 
             // UpdateGrid
             // 
@@ -581,11 +597,23 @@ namespace UAS_LabelMachine
             this.cu_name.TabIndex = 147;
             this.cu_name.Tag = "cu_name";
             // 
+            // PortModel
+            // 
+            this.PortModel.AutoSize = true;
+            this.PortModel.Location = new System.Drawing.Point(924, 116);
+            this.PortModel.Name = "PortModel";
+            this.PortModel.Size = new System.Drawing.Size(96, 16);
+            this.PortModel.TabIndex = 192;
+            this.PortModel.Text = "启用被动模式";
+            this.PortModel.UseVisualStyleBackColor = true;
+            this.PortModel.CheckedChanged += new System.EventHandler(this.PortModel_CheckedChanged);
+            // 
             // 客户标签维护
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1179, 581);
+            this.Controls.Add(this.PortModel);
             this.Controls.Add(this.pictureBox1);
             this.Controls.Add(this.pagination1);
             this.Controls.Add(this.NewLabel);
@@ -687,5 +715,6 @@ namespace UAS_LabelMachine
         private DataGridViewTextBoxColumn cl_labelsoft;
         private DataGridViewTextBoxColumn cl_status;
         private PictureBox pictureBox1;
+        private CheckBox PortModel;
     }
 }

+ 11 - 4
UAS-出货标签管理/客户标签维护.cs

@@ -82,13 +82,14 @@ namespace UAS_LabelMachine
             la_code.SelectField = "la_code # 模板编号,la_name # 模板名称";
             NetURL.Text = Settings.Default.ShareUrl;
         }
-        
+
         private void 条码维护_Load(object sender, EventArgs e)
         {
             if (Settings.Default.FTPAddress == "")
             {
                 FTPShare.Visible = false;
             }
+            PortModel.Checked = Settings.Default.FTPModel;
             dh = SystemInf.dh;
             condition.Append("");
             ChooseAll.ChooseAll(LabelDataGridView);
@@ -126,7 +127,7 @@ namespace UAS_LabelMachine
                 if (CodeSoft.Checked)
                 {
                     string LabelName = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelname"].Value.ToString();
-                    doc = lbl.Documents.Open(BaseUtil.GetLabelUrl(LabelPath, LabelName,time));
+                    doc = lbl.Documents.Open(BaseUtil.GetLabelUrl(LabelPath, LabelName, time));
                     Bitmap bit = new Bitmap(doc.CopyImageToFile());
                     pictureBox1.Image = bit;
                     //如果文件已不存在则进行提示
@@ -146,7 +147,7 @@ namespace UAS_LabelMachine
                     System.DateTime time;
                     try
                     {
-                       time = Convert.ToDateTime(LabelDataGridView.Rows[e.RowIndex].Cells["cl_date"].Value.ToString());
+                        time = Convert.ToDateTime(LabelDataGridView.Rows[e.RowIndex].Cells["cl_date"].Value.ToString());
                     }
                     catch (Exception)
                     {
@@ -335,7 +336,7 @@ namespace UAS_LabelMachine
                 }
                 if (FTPShare.Checked)
                 {
-                    ftpOperater ftp = new ftpOperater();
+                    ftpOperater ftp = new ftpOperater(PortModel.Checked);
                     ftp.UpLoadFile(sourcePath, fileName);
                     string SoftWare = "CodeSoft";
                     if (CL_ID2 != null)
@@ -415,5 +416,11 @@ namespace UAS_LabelMachine
             FolderPath.Text = "";
             CL_ID2 = null;
         }
+
+        private void PortModel_CheckedChanged(object sender, EventArgs e)
+        {
+            Settings.Default.FTPModel = PortModel.Checked;
+            Settings.Default.Save();
+        }
     }
 }

+ 6 - 7
UAS-出货标签管理/生成条码.cs

@@ -449,13 +449,12 @@ namespace UAS_LabelMachine
                 //查询出入库的类型
                 dt = (DataTable)dh.ExecuteSql("select ds_inorout from documentsetup where ds_name='" + pi_class.Text + "'", "select");
                 sql.Clear();
-                sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,pd_piclass,pd_qty from (select ");
-                sql.Append("pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,pd_piclass,");
-                sql.Append("outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_ordercode=pd_ordercode ");
-                sql.Append("and pib_orderdetno=pd_orderdetno),0)pd_qty from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty,");
-                sql.Append("pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
-                sql.Append("from prodiodetail where pd_piclass='出货单' group by pd_piid,pd_ordercode,pd_orderdetno,pd_pdno)T left join product on pr_code=pd_prodcode ");
-                sql.Append("where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,");
+                sql.Append("pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_pdno,");
+                sql.Append("pd_prodcode,pd_piclass,outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno ),0)pd_qty ");
+                sql.Append("from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty,pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
+                sql.Append("from prodiodetail where pd_piclass='出货单' group by pd_piid,pd_ordercode, pd_orderdetno,pd_pdno)T left join product ");
+                sql.Append("on pr_code=pd_prodcode where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
             }