| | |
| | | if ("Add".Equals(eventType)) |
| | | { |
| | | //判断客户为海诚 同步金蝶工序汇报单 |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "海诚") |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "海诚"|| oSystemParameter.omodel.WMS_CampanyName == "天擎") |
| | | { |
| | | object objResult = set_SaveStationOutBill_CLD_Json(HInterID, HBillNo, user); |
| | | } |
| | |
| | | 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 barcodeCount = (int)HPieceQty; // HPieceQty 作为条码张数 |
| | | if (totalWeight <= 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!重量必须大于0"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 计算每张条码的平均数量 |
| | | decimal baseQty = Math.Floor(HQty / HPieceQty); |
| | | decimal remainder = HQty % HPieceQty; |
| | | // 固定生成指定件数的条码 |
| | | int barcodeCount = (int)HPieceQty; // HPieceQty 作为条码件数 |
| | | |
| | | // 计算每张条码的基础数量和基础重量 |
| | | decimal baseQtyPerPiece = Math.Floor(HQty / HPieceQty); |
| | | decimal remainderQty = HQty % HPieceQty; |
| | | |
| | | // 计算每张条码的基础重量(净重和毛重相同) |
| | | decimal baseWeightPerPiece = Math.Floor(totalWeight / HPieceQty * 10000) / 10000; // 保留4位小数 |
| | | decimal remainderWeight = totalWeight - (baseWeightPerPiece * HPieceQty); |
| | | |
| | | // 查询原始单据信息 |
| | | ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain"); |
| | |
| | | for (int i = 0; i < barcodeCount; i++) |
| | | { |
| | | // 计算当前条码的数量 |
| | | decimal currentQty = baseQty; |
| | | if (i < remainder) // 如果有余数,前N张条码各加1 |
| | | decimal currentQty = baseQtyPerPiece; |
| | | if (i < remainderQty) // 如果有余数,前N张条码各加1 |
| | | { |
| | | currentQty += 1; |
| | | } |
| | | |
| | | // 计算当前条码的重量(净重和毛重相同) |
| | | decimal currentWeight = baseWeightPerPiece; |
| | | if (i < Math.Ceiling(remainderWeight / baseWeightPerPiece) && remainderWeight > 0) |
| | | { |
| | | 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) |