| | |
| | | oCN.RunProc(deleteSql); |
| | | } |
| | | |
| | | // 首先查询 HQty 和 HPieceQty |
| | | DataSet dsPiece = oCN.RunProcReturn("select HPieceQty, HQty from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain"); |
| | | // 查询 HQty、HPieceQty 和 重量字段 |
| | | DataSet dsPiece = oCN.RunProcReturn("select HPieceQty, HQty, HWeight from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain"); |
| | | |
| | | if (dsPiece == null || dsPiece.Tables[0].Rows.Count == 0) |
| | | { |
| | |
| | | |
| | | decimal HPieceQty = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HPieceQty"]); |
| | | decimal HQty = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HQty"]); |
| | | decimal totalWeight = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HWeight"]); |
| | | |
| | | if (HPieceQty <= 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!单张条码数量必须大于0"; |
| | | objJsonResult.Message = "保存失败!件数必须大于0"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 计算需要生成的条码数量 |
| | | int fullBarcodeCount = (int)(HQty / HPieceQty); // 完整箱数 |
| | | decimal remainder = HQty % HPieceQty; // 余数 |
| | | |
| | | int barcodeCount = fullBarcodeCount; |
| | | if (remainder > 0) |
| | | if (totalWeight <= 0) |
| | | { |
| | | barcodeCount += 1; // 有余数时增加一张条码 |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!重量必须大于0"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 固定生成指定件数的条码 |
| | | int barcodeCount = (int)HPieceQty; // HPieceQty 作为条码件数 |
| | | |
| | | // 计算每张条码的基础数量和基础重量 |
| | | decimal baseQtyPerPiece = Math.Floor(HQty / HPieceQty); |
| | | decimal remainderQty = HQty % HPieceQty; |
| | | |
| | | /// 重量均分基础值与余数 |
| | | decimal baseWeightPerPiece = totalWeight / HPieceQty; |
| | | decimal remainderWeight = totalWeight % HPieceQty; |
| | | |
| | | // 查询原始单据信息 |
| | | ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain"); |
| | |
| | | // 循环生成条码 |
| | | for (int i = 0; i < barcodeCount; i++) |
| | | { |
| | | // 计算当前条码的数量 |
| | | // ====================== 修复数量计算 ====================== |
| | | decimal currentQty; |
| | | if (i < fullBarcodeCount) |
| | | if (barcodeCount == 1) |
| | | { |
| | | // 前 fullBarcodeCount 张条码,每张数量为 HPieceQty |
| | | currentQty = HPieceQty; |
| | | // 只有1件时,直接使用总数量,不做取整拆分 |
| | | currentQty = HQty; |
| | | } |
| | | else |
| | | { |
| | | // 最后一张条码,数量为余数 |
| | | currentQty = remainder; |
| | | currentQty = baseQtyPerPiece; |
| | | // 有余数则前N条各加1(只针对整数余数场景) |
| | | if (i < remainderQty) |
| | | { |
| | | currentQty += 1; |
| | | } |
| | | } |
| | | |
| | | // 生成条码号(可以在原始条码号后面加序号) |
| | | // ====================== 修复重量计算 ====================== |
| | | decimal currentWeight; |
| | | if (barcodeCount == 1) |
| | | { |
| | | currentWeight = totalWeight; |
| | | } |
| | | else |
| | | { |
| | | currentWeight = baseWeightPerPiece; |
| | | if (i < remainderWeight) |
| | | { |
| | | currentWeight += baseWeightPerPiece; |
| | | } |
| | | } |
| | | |
| | | // 生成条码号 |
| | | string barcodeNumber = row["HBillNO"].ToString() + (barcodeCount > 1 ? "-" + (i + 1).ToString() : ""); |
| | | |
| | | string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " + |
| | | // 修改插入语句,添加HMaterialJQty和HMaterialMQty字段 |
| | | string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HMaterialJQty, HMaterialMQty, 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, HEmpID, HCusModel, HCusMaterName, HCheckEmpName, HZZRQ, HSupMaterNumber, HSupBatchNo" + |
| | |
| | | "'" + row["HMaterID"].ToString() + "', " + |
| | | "'0', " + |
| | | "'" + currentQty.ToString() + "', " + // 使用当前条码的数量 |
| | | "'" + currentWeight.ToString() + "', " + // 净重 |
| | | "'" + currentWeight.ToString() + "', " + // 毛重(与净重相同) |
| | | "'', " + |
| | | "'', " + |
| | | "'" + row["HGroupID"].ToString() + "', " + |
| | |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = ""; |
| | |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | string sql1 = "select * from h_v_MES_StationOutBillList_SN where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by 制单日期 desc"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList_SN"); |
| | | |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | LogService.Write(21231321); |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | |
| | | |
| | | #endregion |
| | | |
| | | //审核,带编辑功能 |
| | | [Route("Cj_StationOutBill/setOtherProperty")] |
| | | [HttpPost] |
| | | public object setOtherProperty([FromBody] JObject oMain) |
| | | { |
| | | try |
| | | { |
| | | var _value = oMain["oMain"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = "[" + sArray[0].ToString() + "]"; |
| | | string user = sArray[1].ToString(); |
| | | ////判断是否有编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无编辑权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Check", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | List<StationBill> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2); |
| | | long HInterID = list1[0].HInterID; |
| | | double HQty = list1[0].HQty; |
| | | double HBadCount = list1[0].HBadCount; |
| | | double HWasterQty = list1[0].HWasterQty; |
| | | long HSourceID = list1[0].HSourceID; |
| | | string HSourceName = list1[0].HSourceName; |
| | | long HCenterID = list1[0].HCenterID; |
| | | long HGroupID = list1[0].HGroupID; |
| | | long HEmpID = list1[0].HEmpID; |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | DataSet ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID=" + HInterID, "Sc_StationOutBillMain"); |
| | | |
| | | if (ds.Tables.Count > 0 && ds.Tables[0].Rows[0]["HChecker"].ToString() == "") |
| | | { |
| | | string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); |
| | | //审核前控制================================================================================ |
| | | string sql = "exec h_p_Sc_StationOutBill_BeforeCheckCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'"; |
| | | ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_BeforeCheckCtrl"); |
| | | if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //================================================================================ |
| | | |
| | | if (HQty > 0) |
| | | { |
| | | |
| | | oCN.RunProc($"update Sc_StationOutBillMain set HBillStatus = 2, HQty={HQty},HBadCount='{HBadCount}',HWasterQty='{HWasterQty}',HSourceID='{HSourceID}',HCenterID='{HCenterID}',HGroupID={HGroupID},HEmpID={HEmpID},HChecker='{user}',HCheckDate=getdate() where HInterID={HInterID} "); |
| | | |
| | | } |
| | | string sReturn = ""; |
| | | //获取系统参数 |
| | | oSystemParameter.ShowBill(ref sReturn); |
| | | //判断客户为天擎 同步金蝶工序汇报单 |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "天擎") |
| | | { |
| | | //同步前控制========================================= |
| | | ds = oCN.RunProcReturn("Exec h_p_Sc_StationOutBill_BeforeSyncCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + user + "'", " h_p_Sc_StationOutBill_BeforeSyncCtrl "); |
| | | if (ds == null) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[0000-2-012]保存前判断失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[0000-1-051]同步失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //========================================================= |
| | | if (oWebs.set_SaveStationOutBill_CLD(HInterID, HBillNo, user, ref DBUtility.ClsPub.sErrInfo)) |
| | | { |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = DBUtility.ClsPub.sErrInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核修改成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.Commit(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据不存在或已审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | } |