Parcourir la source

防伪码 3#刮登 3#施釉后

chenxy il y a 4 ans
Parent
commit
0a8c492558

+ 2 - 0
PCLCommunication/ConnSetting.cs

@@ -35,6 +35,7 @@ namespace PCLCommunication
         public static string INI_PATH_UserCode = null;
         public static string PLC_GlazingRoom = null;
         public static bool AutoPost = false;
+        public static bool SE_CODE_FLAG = false;
 
         public static string[] PLCServiceSettings = new string[2];
         public static MESInfo MESInfo = null;
@@ -58,6 +59,7 @@ namespace PCLCommunication
             }
 
             AutoPost = (ini.Read("iBOSS.MES", "AutoPost").ToLower() == "true");
+            SE_CODE_FLAG = (ini.Read("PLCService", "SE_CODE_FLAG").ToLower() == "true");
 
             if (!string.IsNullOrWhiteSpace(MESInfo.IP))
             {

+ 3 - 0
PCLCommunication/DBSetting.ini

@@ -8,8 +8,11 @@ Password=etLHPkLTOLw=
 [PLCService]
 AutoStart=true
 Port=5001
+;¶ÁÈ¡·ÀαÂë
+SE_CODE_FLAG=true
 
 [iBOSS.MES]
+;¼Æ¼þ
 AutoPost=false
 IP=127.0.0.1
 Port=1234

+ 62 - 0
PCLCommunication/FrmMelsecA1EAscii.cs

@@ -743,6 +743,68 @@ namespace PCLCommunication
                         LogNet_BeforeSaveToFile(roomcode);
                         lbl.AppendLine(roomcode);
 
+                        #region 防伪码
+                        if (ConnSetting.SE_CODE_FLAG)
+                        {
+                            // 读取防伪码
+                            int lianti = 222;
+                            string se_code1 = m.GetHexData("D", lianti, 6);
+                            if (!string.IsNullOrWhiteSpace(se_code1) &&
+                                se_code1.StartsWith("8100"))
+                            {
+                                se_code1 = se_code1.Substring(4);
+                                if (se_code1.StartsWith("0"))
+                                { se_code1 = null; }
+                            }
+                            else
+                            { se_code1 = null; }
+
+                            int zhineng = 222;
+                            string se_code2 = m.GetHexData("D", zhineng, 6);
+                            if (!string.IsNullOrWhiteSpace(se_code2) &&
+                                se_code2.StartsWith("8100"))
+                            {
+                                se_code2 = se_code2.Substring(4);
+                                if (se_code2.StartsWith("0"))
+                                { se_code2 = null; }
+                            }
+                            else
+                            { se_code2 = null; }
+
+                            string se_code = null;
+                            if (!string.IsNullOrWhiteSpace(se_code1))
+                            { se_code = se_code1; }
+                            else if (!string.IsNullOrWhiteSpace(se_code2))
+                            { se_code = se_code2; }
+                            
+                            if (string.IsNullOrWhiteSpace(se_code))
+                            {
+                                ConnSetting.SetPLCError2(m, lbl, "读取防伪码失败");
+                                return;
+                            }
+                            if (!string.IsNullOrWhiteSpace(ConnSetting.INI_PATH_UserCode))
+                            {
+                                this.lblUsercode.Text = INIUtil.Read("iBOSS.MES", "UserCode", ConnSetting.INI_PATH_UserCode);
+                                ConnSetting.MESInfo.UserCode = this.lblUsercode.Text;
+                            }
+                            string se_result = SmartDeviceProxy.Instance.Invoke<string>(
+                                p => p.CheckSecurityCodeByBarcode(
+                                    ConnSetting.MESInfo.AccountCode,
+                                    ConnSetting.MESInfo.UserCode,
+                                    barcode,
+                                    se_code
+                                    ));
+
+                            // 返回状态(成功、失败)
+                            if (se_result != "OK")
+                            {
+                                ConnSetting.SetPLCError2(m, lbl, "防伪码:" + this.lblUsercode.Text + " " + se_result);
+                                simplifyServer.SendMessage(arg1, "0000");
+                                return;
+                            }
+                        }
+                        #endregion
+
                         // 自动工序计件
                         string scode = "OK";
                         if (ConnSetting.AutoPost)

+ 21 - 0
PCLCommunication/Proxy/ISmartDevice.cs

@@ -22,5 +22,26 @@ namespace Dongke.IBOSS.PRD.WCF.Contracts
         [OperationContract]
         string AddWorkPieceByStatus(string accountCode, string userCode, string userPassword,
             int procedureID, string barcode, string remarks);
+
+        #region 防伪码
+        /// <summary>
+        /// 防伪码绑定和防伪码更改
+        /// </summary>
+        /// <param name="barCode">条码</param>
+        /// <param name="securityCode">防伪码</param>
+        /// <param name="procedureID">工序</param>
+        /// <returns></returns>
+        [OperationContract]
+        string UpdateSecurityCodeByBarcode(string accountCode, string userCode, string barCode, string securityCode, string procedureID);
+
+        /// <summary>
+        /// 防伪码校验
+        /// </summary>
+        /// <param name="barCode">条码</param>
+        /// <param name="securityCode">防伪码</param>
+        /// <returns></returns>
+        [OperationContract]
+        string CheckSecurityCodeByBarcode(string accountCode, string userCode, string barCode, string securityCode);
+        #endregion
     }
 }