| | |
| | | string HCusMaterName = ""; //客æ·ç©æåç§° |
| | | string HCheckEmpName = ""; //æ£éªååç§° |
| | | |
| | | string HSupNumber = ""; // ä¾åºåç¼ç |
| | | string HPOInStockBillNo = ""; // æ¶æéç¥åå· |
| | | |
| | | DataSet Ds; |
| | | msg2 = msg2.Replace("\\", ""); |
| | | msg2 = msg2.Replace("\n", ""); //\n |
| | |
| | | HICMOBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HSourceBillNo); //ç产订åå·ï¼å¤å®çµå¨ï¼ |
| | | HBarCodeBatchNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HPinfanBarCode); //æ¡ç æ¹æ¬¡å·ï¼å¤å®çµå¨ï¼ |
| | | HBarCodeDate = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber); //æ¡ç æ¥æï¼å¤å®çµå¨ï¼ |
| | | |
| | | HPOInStockBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo); // æ¶æéç¥åå· å
´è¾¾æ¡ç |
| | | HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber);// ä¾åºåç¼å· å
´è¾¾æ¡ç |
| | | // |
| | | 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]); |
| | | } |
| | | } |
| | | else if (CampanyName.Contains("å
´è¾¾")) |
| | | { |
| | | |
| | | // å
´è¾¾æ¡ç |
| | | //æ¡ç åç¼ = æ¶æéç¥åå· + ä¾åºåç¼ç + å¹´ + æ + æ¥ + 3使µæ°´å· |
| | | |
| | | sTMNumber = HPOInStockBillNo + "@" + HSupNumber + "@" + sYear + sPeriod + sDay; |
| | | 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 //éç¨æ¹æ³ |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region æ´æ°æ¡ç 对åºåºåºç³è¯·åå· å
´è¾¾ |
| | | public class BarCodeMeta |
| | | { |
| | | public string HBarCode { get; set; } |
| | | public string HBatchNo { get; set; } |
| | | public string HMaterModel { get; set; } |
| | | public string HMaterName { get; set; } |
| | | public float HQty { get; set; } |
| | | public string HSCSPName { get; set; } |
| | | public string HSCWHName { get; set; } |
| | | public string HSPName { get; set; } |
| | | public float HTMQty { get; set; } |
| | | public string HUnitName { get; set; } |
| | | public string HWHName { get; set; } |
| | | } |
| | | |
| | | [Route("Sc_BarCode/Set_BarCodeBill")] |
| | | [HttpPost] |
| | | public object Set_BarCodeBill([FromBody] JObject msg) |
| | | { |
| | | |
| | | var _value = msg["msg"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.None); |
| | | 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 |
| | | { |
| | | for(int i = 0; i < BarCodeMetaList.Count; i++) |
| | | { |
| | | if (HBillType == "1205") // éå®åºåº |
| | | { |
| | | |
| | | if (HOrgName.Contains("å
´è¾¾") && !string.IsNullOrEmpty(HBillNo)) |
| | | { |
| | | // å
´è¾¾ éå®åºåºæ´æ° åè´§éç¥å |
| | | oCN.RunProcReturn("Update Gy_BarCodeBill set " + |
| | | "HSeOutStockBillNo='" + HBillNo + "' where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = ""; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿®æ¹å¤±è´¥!" + e.Message; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region [è·åæ ç¾æå°æä»¤ CPCLæä»¤] |
| | | [Route("Sc_BarCode/Get_BarCodePrintCode_CPCL")] |
| | | [HttpGet] |
| | | public object Get_BarCodePrintCode_CPCL(string HOrginationName, int HBillInterID, int HBillEntryID, string HViewName, string HBillSubType, int HInterID) |
| | | public object Get_BarCodePrintCode_CPCL(string HOrginationName, string HViewName, string HBillSubType, int HInterID, int HItemID) |
| | | { |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_getHBarCodePrintCode_CPCL N'" + HOrginationName + "'" + |
| | | "," + HBillInterID + "," + HBillEntryID + ",N'" + HViewName + "',N'" + HBillSubType + "'," + HInterID, "h_p_getHBarCodePrintCode_CPCL"); |
| | | ",N'" + HViewName + "',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"); |
| | |
| | | #region [APP è·åæå°æ¨¡æ¿] |
| | | public class PrintTemplate |
| | | { |
| | | public int Id { get; } |
| | | public string OrgShort { get; } |
| | | public string HBillSubtype { get; } |
| | | public string Format { get; } |
| | | public string Description { get; } |
| | | public string[] Placeholder { get; } |
| | | public int Id { get; set; } |
| | | public string OrgShort { get; set; } |
| | | public string HBillSubtype { get; set; } |
| | | public string Format { get; set; } |
| | | public string Description { get; set; } |
| | | public string[] Placeholder { get; set; } |
| | | } |
| | | |
| | | [Route("Sc_BarCode/Get_BarCodeGenTemplate")] |
| | |
| | | } |
| | | |
| | | string jsonContent = File.ReadAllText(fileFullPath); |
| | | var templates = JsonConvert.DeserializeObject<PrintTemplate[]>(jsonContent); |
| | | |
| | | var targetTemplate = templates.FirstOrDefault<PrintTemplate>(t => HOrginationName.Contains(t.OrgShort) && string.Equals(t.HBillSubtype, HBillSubType)); |
| | | PrintTemplate[] templates = JsonConvert.DeserializeObject<PrintTemplate[]>(jsonContent); |
| | | PrintTemplate targetTemplate = templates.FirstOrDefault<PrintTemplate>(t => HOrginationName.Contains(t.OrgShort) && string.Equals(t.HBillSubtype, HBillSubType)); |
| | | if (targetTemplate != null) |
| | | { |
| | | objJsonResult.code = "1"; |
| | |
| | | { |
| | | 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) |
| | | { |
| | | string barCode = row["HBarCode"].ToString(); |
| | | string suffixPart = barCode.Substring(prefix.Length); // å - åçé¨å |
| | | if (int.TryParse(suffixPart, out int num)) |
| | | { |
| | | if (num > maxSuffix) maxSuffix = num; |
| | | } |
| | | 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 = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.count = ds.Tables[0].Rows.Count; |
| | | objJsonResult.Message = "æ¥è¯¢æåï¼è¿åç´æ¥åç "; |
| | | objJsonResult.data = new |
| | | { |
| | | SubBarCodes = ds.Tables[0], // æ¡ç åºç¡ä¿¡æ¯ |
| | | NextBarCode = nextBarCode // ä¸ä¸ä¸ªçæçæ¡ç |
| | | SubBarCodes = ds.Tables[0], |
| | | NextBarCode = nextBarCode |
| | | }; |
| | | return objJsonResult; |
| | | } |
| | | 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 = "该æ¡ç æ åç ï¼è¿åèªèº«"; |
| | | objJsonResult.data = new |
| | | { |
| | | SubBarCodes = dsSelf.Tables[0], |
| | | NextBarCode = $"{cleanBarCode}-1" // å»ºè®®ä» -1 å¼å§ |
| | | }; |
| | | } |
| | | 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; |
| | | } |