1
wtt
2 天以前 807bb9a2b4d6db408ebdded1cff41f3094eac11e
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -1425,9 +1425,9 @@
                decimal baseQtyPerPiece = Math.Floor(HQty / HPieceQty);
                decimal remainderQty = HQty % HPieceQty;
                // 计算每张条码的基础重量(净重和毛重相同)
                decimal baseWeightPerPiece = Math.Floor(totalWeight / HPieceQty * 10000) / 10000; // 保留4位小数
                decimal remainderWeight = totalWeight - (baseWeightPerPiece * HPieceQty);
                /// 重量均分基础值与余数
                decimal baseWeightPerPiece = totalWeight / HPieceQty;
                decimal remainderWeight = totalWeight % HPieceQty;
                // 查询原始单据信息
                ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
@@ -1439,18 +1439,36 @@
                    // 循环生成条码
                    for (int i = 0; i < barcodeCount; i++)
                    {
                        // 计算当前条码的数量
                        decimal currentQty = baseQtyPerPiece;
                        if (i < remainderQty)  // 如果有余数,前N张条码各加1
                        // ====================== 修复数量计算 ======================
                        decimal currentQty;
                        if (barcodeCount == 1)
                        {
                            currentQty += 1;
                            // 只有1件时,直接使用总数量,不做取整拆分
                            currentQty = HQty;
                        }
                        else
                        {
                            currentQty = baseQtyPerPiece;
                            // 有余数则前N条各加1(只针对整数余数场景)
                            if (i < remainderQty)
                            {
                                currentQty += 1;
                            }
                        }
                        // 计算当前条码的重量(净重和毛重相同)
                        decimal currentWeight = baseWeightPerPiece;
                        if (i < Math.Ceiling(remainderWeight / baseWeightPerPiece) && remainderWeight > 0)
                        // ====================== 修复重量计算 ======================
                        decimal currentWeight;
                        if (barcodeCount == 1)
                        {
                            currentWeight += baseWeightPerPiece; // 重量余数也分摊到前几张条码
                            currentWeight = totalWeight;
                        }
                        else
                        {
                            currentWeight = baseWeightPerPiece;
                            if (i < remainderWeight)
                            {
                                currentWeight += baseWeightPerPiece;
                            }
                        }
                        // 生成条码号