| | |
| | | string HSupNumber = ""; // ä¾åºåç¼ç |
| | | string HPOInStockBillNo = ""; // æ¶æéç¥åå· |
| | | |
| | | string HPOOrderBillNo = ""; // éè´è®¢åå· |
| | | |
| | | DataSet Ds; |
| | | msg2 = msg2.Replace("\\", ""); |
| | | msg2 = msg2.Replace("\n", ""); //\n |
| | |
| | | |
| | | HPOInStockBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo); // æ¶æéç¥åå· å
´è¾¾æ¡ç |
| | | HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber);// ä¾åºåç¼å· å
´è¾¾æ¡ç |
| | | |
| | | HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo); // éè´è®¢åå· å°å«çµå¨ |
| | | // |
| | | sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2); |
| | | sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString(); |
| | |
| | | Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //è·åæå¤§æµæ°´å· |
| | | LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]); |
| | | LSHlen = 3; // ä¸ä½æµæ°´å· |
| | | } |
| | | else if (CampanyName.Contains("å°å«")) |
| | | { |
| | | // å°å«çµå¨ |
| | | // æ¡ç åç¼ = åæ®å· + ç©æç¼ç + æ¹æ¬¡å· |
| | | sTMNumber = HPOOrderBillNo + "@" + HMaterNumber + "@" + HBatchNo; |
| | | Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //è·åæå¤§æµæ°´å· |
| | | LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]); |
| | | } |
| | | else //éç¨æ¹æ³ |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region æ´æ°æ¡ç 对åºåæ® åå· æ¬¡æ° æ¶é´ |
| | | #region æ´æ°æ¡ç 对åºåºåºç³è¯·åå· å
´è¾¾ |
| | | public class BarCodeMeta |
| | | { |
| | | public string HBarCode { get; set; } |
| | |
| | | string msg2 = sArray[0].ToString(); |
| | | string HBillType = sArray[1].ToString(); |
| | | string HBillNo = sArray[2].ToString(); |
| | | string HOrgName = sArray[3].ToString(); |
| | | |
| | | List<BarCodeMeta> BarCodeMetaList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BarCodeMeta>>(msg2); |
| | | oCN.BeginTran(); |
| | | try |
| | | { |
| | | oCN.BeginTran(); |
| | | |
| | | for(int i = 0; i < BarCodeMetaList.Count; i++) |
| | | { |
| | | if (HBillType == "1205") // éå®åºåº |
| | | { |
| | | oCN.RunProcReturn("Update Gy_BarCodeBill set HOutStockDate = getdate(), HOutStockCounts=isnull(HOutStockCounts,0)+1," + |
| | | "HOutStockBillNo='" + HBillNo + " 'where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill"); |
| | | } |
| | | if (HBillType == "1201") // éè´å
¥åº |
| | | { |
| | | oCN.RunProcReturn("Update Gy_BarCodeBill set HInStockDate = getdate(), HInStockCounts=isnull(HOutStockCounts,0)+1," + |
| | | "HInStockBillNo='" + HBillNo + " 'where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill"); |
| | | |
| | | if (HOrgName.Contains("å
´è¾¾") && !string.IsNullOrEmpty(HBillNo)) |
| | | { |
| | | // å
´è¾¾ éå®åºåºæ´æ° åè´§éç¥å |
| | | oCN.RunProcReturn("Update Gy_BarCodeBill set " + |
| | | "HSeOutStockBillNo='" + HBillNo + "' where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿®æ¹å¤±è´¥!" + e.Message; |
| | |
| | | #region [è·åæ ç¾æå°æä»¤ CPCLæä»¤] |
| | | [Route("Sc_BarCode/Get_BarCodePrintCode_CPCL")] |
| | | [HttpGet] |
| | | public object Get_BarCodePrintCode_CPCL(string HOrginationName, string HViewName, string HBillSubType, int HInterID, int HItemID) |
| | | public object Get_BarCodePrintCode_CPCL(string HOrginationName, string HBillSubType, int HInterID, int HItemID) |
| | | { |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_getHBarCodePrintCode_CPCL N'" + HOrginationName + "'" + |
| | | ",N'" + HViewName + "',N'" + HBillSubType + "'," + HInterID + "," + HItemID, "h_p_getHBarCodePrintCode_CPCL"); |
| | | ",N'" + HBillSubType + "'," + HInterID + "," + HItemID, "h_p_getHBarCodePrintCode_CPCL"); |
| | | if((int)ds.Tables[0].Rows[0]["resultType"] == 1) |
| | | { |
| | | string resultMesg = ds.Tables[0].Rows[0]["payload"].ToString().Replace("\\r\\n", "\r\n"); |
| | |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | //æ¥è¯¢æ¡ç ä¿¡æ¯ |
| | | if (HBarCodeNo != null) |
| | | if (string.IsNullOrWhiteSpace(HBarCodeNo)) |
| | | { |
| | | string prefix = HBarCodeNo.Trim() + "-"; |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "请è¾å
¥æ¡ç ç¼å·"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCn.RunProcReturn("SELECT * FROM h_v_Gy_SplitBarCode WITH(NOLOCK) WHERE HBarCode LIKE '" + prefix + "' + '%' AND HBarCode NOT LIKE '" + prefix + "' + '%-%' AND ISNUMERIC(RIGHT(HBarCode, LEN(HBarCode) - LEN( '" + prefix + "' ))) = 1 AND TRY_CAST(RIGHT(HBarCode, LEN(HBarCode) - LEN( '" + prefix + "' )) AS INT) IS NOT NULL ", "Gy_BarCodeBill"); |
| | | if (ds != null || ds.Tables[0].Rows.Count >= 0) |
| | | // å»ç©ºæ ¼ |
| | | string cleanBarCode = HBarCodeNo.Trim(); |
| | | string prefix = cleanBarCode + "-"; // ç¨äºæ¥åç |
| | | |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | |
| | | // 1. å
æ¥ç´æ¥åç ï¼ä¸çº§åç ï¼xxx-1, xxx-2, ...ï¼ |
| | | string sqlSub = @"SELECT * FROM h_v_Gy_SplitBarCode WITH(NOLOCK) WHERE HBarCode LIKE '" + prefix + @"%' |
| | | AND HBarCode NOT LIKE '" + prefix + @"%-%' |
| | | AND ISNUMERIC(RIGHT(HBarCode, LEN(HBarCode) - LEN('" + prefix + @"'))) = 1 |
| | | AND TRY_CAST(RIGHT(HBarCode, LEN(HBarCode) - LEN('" + prefix + @"')) AS INT) IS NOT NULL"; |
| | | |
| | | DataSet ds = oCn.RunProcReturn(sqlSub, "Gy_BarCodeBill"); |
| | | |
| | | // 2. 妿æåç â è¿ååç + ä¸ä¸ä¸ªç¼å· |
| | | if (ds != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | int maxSuffix = 0; |
| | | foreach (DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | // æ¾åºæå¤§åç¼æ°åï¼ç¨äºçæä¸ä¸ä¸ªç¼å· |
| | | int maxSuffix = 0; |
| | | foreach (DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | string barCode = row["HBarCode"].ToString(); |
| | | string suffixPart = barCode.Substring(prefix.Length); // å - åçé¨å |
| | | if (int.TryParse(suffixPart, out int num)) |
| | | { |
| | | if (num > maxSuffix) maxSuffix = num; |
| | | } |
| | | } |
| | | string barCode = row["HBarCode"].ToString(); |
| | | string suffix = barCode.Substring(prefix.Length); |
| | | if (int.TryParse(suffix, out int num) && num > maxSuffix) |
| | | maxSuffix = num; |
| | | } |
| | | |
| | | // çæä¸ä¸ä¸ªåç ç¼å· |
| | | string nextBarCode = $"{HBarCodeNo}-{maxSuffix + 1}"; |
| | | string nextBarCode = $"{cleanBarCode}-{maxSuffix + 1}"; |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = ds.Tables[0].Rows.Count; |
| | | objJsonResult.Message = "æ¥è¯¢æåï¼è¿åç´æ¥åç "; |
| | | objJsonResult.data = new |
| | | { |
| | | SubBarCodes = ds.Tables[0], |
| | | NextBarCode = nextBarCode |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | // 3. 没æåç â æ¥èªå·± |
| | | string sqlSelf = @"SELECT * FROM h_v_Gy_SplitBarCode WITH(NOLOCK) WHERE HBarCode = '" + cleanBarCode.Replace("'", "''") + "'"; |
| | | |
| | | DataSet dsSelf = oCn.RunProcReturn(sqlSelf, "Gy_BarCodeBill"); |
| | | |
| | | if (dsSelf != null && dsSelf.Tables[0].Rows.Count > 0) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.Message = "该æ¡ç æ åç ï¼è¿åèªèº«"; |
| | | objJsonResult.data = new |
| | | { |
| | | SubBarCodes = ds.Tables[0], // æ¡ç åºç¡ä¿¡æ¯ |
| | | NextBarCode = nextBarCode // ä¸ä¸ä¸ªçæçæ¡ç |
| | | SubBarCodes = dsSelf.Tables[0], |
| | | NextBarCode = $"{cleanBarCode}-1" // å»ºè®®ä» -1 å¼å§ |
| | | }; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¡ç ç¼å·ä¸åå¨, æç¤º"; |
| | | objJsonResult.Message = "æ¡ç ä¸åå¨ï¼è¯·æ£æ¥"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "请è¾å
¥æ¡ç ç¼å·ææåæ¡ç æ°"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) //æåºå¼å¸¸ |
| | | catch (Exception ex) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.Message = "å¼å¸¸ï¼" + ex.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region [æ¡ç çææ¥å£_å°å«ééç ] |
| | | [Route("Sc_BarCode/GetSNByICMO_XW")] |
| | | [HttpGet] |
| | | public object GetSNByICMO(String HBillNo,int HSeq) |
| | | { |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_WMS_GetSNByICMO_XW '" + HBillNo + "', "+ HSeq, "h_p_WMS_GetSNByICMO_XW"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "[0000-1-037]æ¡ç çææåï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[0000-2-020]没æè¿åä»»ä½ç»æ,æ¡ç çæå¤±è´¥ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[3899-2-006]æ¡ç çæå¤±è´¥!" + e.Message; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | } |
| | | } |