From 128c67958807233322395716bbaddb3808e4bda9 Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期四, 21 八月 2025 13:31:06 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/仓存管理/条码生成/Sc_BarCodeController.cs | 198 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 198 insertions(+), 0 deletions(-) diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs" index bdfbee0..7a75ca8 100644 --- "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs" +++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs" @@ -2211,6 +2211,204 @@ } } #endregion + + #region [app 鏉$爜鎷嗙爜鑾峰彇瀛愭潯鐮乚 + [Route("Sc_BarCode/SplitBarCode_Sub")] + [HttpGet] + public object SplitBarCode_Sub(string HBarCodeNo) + { + try + { + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + //鏌ヨ鏉$爜淇℃伅 + if (HBarCodeNo != null) + { + string prefix = HBarCodeNo.Trim() + "-"; + + 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) + { + // 鎵惧嚭鏈�澶у悗缂�鏁板瓧锛岀敤浜庣敓鎴愪笅涓�涓紪鍙� + 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 nextBarCode = $"{HBarCodeNo}-{maxSuffix + 1}"; + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = new + { + SubBarCodes = ds.Tables[0], // 鏉$爜鍩虹淇℃伅 + NextBarCode = nextBarCode // 涓嬩竴涓敓鎴愮殑鏉$爜 + }; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏉$爜缂栧彿涓嶅瓨鍦�, 鎻愮ず"; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "璇疯緭鍏ユ潯鐮佺紪鍙锋垨鎷嗗垎鏉$爜鏁�"; + objJsonResult.data = null; + return objJsonResult; + } + + } + catch (Exception e) //鎶涘嚭寮傚父 + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region [app鏉$爜鎷嗙爜鐢熸垚] + [Route("Sc_BarCode/SplitBarCode_Save")] + [HttpPost] + public object SplitBarCode_Save([FromBody] JObject msg) + { + try + { + ListModels oListModels = new ListModels(); + DAL.ClsGy_BarCodeBill_ChaiMa BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa(); + var _value = msg["msg"].ToString(); + string msg1 = _value.ToString(); + + string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string barcode = sArray[0].ToString(); //鏉$爜缂栧彿 + Double splitnum = Convert.ToDouble(sArray[1]); //鎷嗙爜鏁伴噺 + string data = sArray[2].ToString(); //琛ㄤ綋鏁版嵁 + string user = sArray[3].ToString(); //鐢ㄦ埛鍚� + + data = data.Replace("\\", ""); + data = data.Replace("\n", ""); //\n + + List<Model.ClsGy_BarCodeEdit_Model> lsmain = new List<Model.ClsGy_BarCodeEdit_Model>(); + lsmain = oListModels.getObjectByJson_Gy_SplitBarCode(data); + + oCN.BeginTran(); + + ds = oCN.RunProcReturn("select top 1 * from Gy_BarCodeBill where HBarCode='" + barcode + "'", "Gy_BarCodeBill"); + + if (ds != null || ds.Tables[0].Rows.Count > 0) + { + + string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " + + "HPrintQty, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HinitQty, HEndQty, HBarcodeQtys, HBarcodeNo, HDeptID, HWhID, HSPID, HRemark, " + + "HCusID, HCusType, HEndDate, HWorkLineName, HBarCodeDate, HSTOCKORGID, HOWNERID, HSeOrderBillNo, HGiveAwayFlag, HMaterName, HMaterModel, " + + "HPinfan, HAuxPropID, HMTONo, HInnerBillNo, HCoilNO, HFurnaceNO, HFactory, HAuxQty, HheatNO, HProduceDate, HExpiryDate, HEmpID, HCusModel, HCusMaterName, HCheckEmpName, HZZRQ" + + ") values (" + + "'" + ds.Tables[0].Rows[0]["HInterID"].ToString() + "', " + + "'" + (int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1).ToString() + "', " + + "'" + lsmain[0].HBarCode.ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HBarCodeType"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HBarCodeSubType"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HMaterID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HUnitID"].ToString() + "', " + + "'" + splitnum + "', " + + "'" + ds.Tables[0].Rows[0]["HBatchNo"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSupID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HGroupID"].ToString() + "', " + + "'" + user + "', getdate(), " + + "'" + ds.Tables[0].Rows[0]["HPrintQty"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSourceInterID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSourceEntryID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSourceBillNo"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSourceBillType"].ToString() + "', " + + "'" + splitnum + "', " + + "'" + ds.Tables[0].Rows[0]["HEndQty"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HBarcodeQtys"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HBarcodeNo"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HDeptID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HWhID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSPID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HRemark"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HCusID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HCusType"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HEndDate"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HWorkLineName"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HBarCodeDate"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSTOCKORGID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HOWNERID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HSeOrderBillNo"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HGiveAwayFlag"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HMaterName"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HMaterModel"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HPinfan"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HAuxPropID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HMTONo"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HInnerBillNo"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HCoilNO"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HFurnaceNO"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HFactory"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HAuxQty"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HheatNO"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HProduceDate"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HExpiryDate"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HEmpID"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HCusModel"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HCusMaterName"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HCheckEmpName"].ToString() + "', " + + "'" + ds.Tables[0].Rows[0]["HZZRQ"].ToString() + "'" + + ")"; + //鎻掑叆鎷嗗垎鏉$爜 + oCN.RunProc(sql); + //鏇存柊鑰佹潯鐮佺殑HQty鏁伴噺 + oCN.RunProc("update Gy_BarCodeBill set HQty= HQty-'"+splitnum+"' where HItemID="+ ds.Tables[0].Rows[0]["HItemID"].ToString()); + + + + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + + } + else + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佹湭鏌ヨ鍒版潯鐮佷俊鎭�"; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #endregion } } \ No newline at end of file -- Gitblit v1.9.1