关于货物物品横竖摆放的问题

货车内宽是2.4米。考虑到最多装载,长宽130×100的货品,应该横竖摆放。

横竖摆放的数量如何自动计算呢?

采用数学公式,计算如下:

横向摆放数=(int)(横长+竖高)*数量/4/横长

竖向摆放数=数量-横向摆放数

结果如下:

横长130160
竖宽10080
公式横向摆放数=(int)(横长+竖高)*数量/4/横长
数量横向摆放竖向摆放横向摆放竖向摆放
10.44230810.3751
20.88461520.752
31.32692321.1252
41.76923131.53
52.21153831.8754
62.65384642.254
73.09615442.6255
83.538462535
93.98076963.3756
104.42307763.757
114.86538574.1257
125.30769274.58
135.7584.8759
146.19230885.259
156.63461595.62510
167.0769239610
177.519231106.37511
187.961538116.7512
198.403846117.12512
208.846154127.513

非常不理想!!

困惑三天,想的解决方法如下(计算两行货物长度最小值):

    struct HangGeshu
    {
        public int hang1ge, hang2ge;
    }
       private HangGeshu getHengshuShuliang(int heng,int shu,int shuliang,Boolean youxianheng)
        {
            HangGeshu hangGeshu = new HangGeshu();
            if (shuliang > 1)
            {
                hangGeshu.hang1ge = shuliang / 2;
                if (youxianheng)
                {
                    hangGeshu.hang1ge++;
                }
                else
                {
                    hangGeshu.hang1ge--;
                }
                hangGeshu.hang2ge = shuliang - hangGeshu.hang1ge;
                //货物横竖摆放,目标长度差值最小 (1 横放 2 竖放)
                int cha0 = Math.Abs(hangGeshu.hang1ge * heng - hangGeshu.hang2ge * shu);
                int chaold = cha0;
                Boolean key = true;
                while (key)
                {
                    cha0 = Math.Abs((hangGeshu.hang1ge-1) * heng - (hangGeshu.hang2ge+1) * shu);
                    if (cha0 < chaold)
                    {
                        chaold = cha0;
                        hangGeshu.hang1ge--;
                        hangGeshu.hang2ge++;
                    }
                    else
                    {
                        key = false;
                    }
                }
                key = true;
                while (key)
                {
                    cha0 = Math.Abs((hangGeshu.hang1ge + 1) * heng - (hangGeshu.hang2ge - 1) * shu);
                    if (cha0 < chaold)
                    {
                        chaold = cha0;
                        hangGeshu.hang1ge++;
                        hangGeshu.hang2ge--;
                    }
                    else
                    {
                        key = false;
                    }
                }
            }
            else
            {
                if (youxianheng)
                {
                    hangGeshu.hang1ge = 1;
                    hangGeshu.hang2ge = 0;
                }
                else
                {
                    hangGeshu.hang1ge = 0;
                    hangGeshu.hang2ge = 1;
                }
            }
            return hangGeshu;
        }
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Vue 中进行表格横竖屏切换可以通过 CSS 来实现。可以定义两个不同的 CSS 类,一个用于横屏显示表格,一个用于竖屏显示表格,然后通过 JavaScript 在横竖屏切换时动态地添加或删除对应的 CSS 类。 下面是一个简单的示例代码: ```html <template> <div class="table-container" :class="{ 'table-horizontal': isHorizontal }"> <table> <!-- 表格内容 --> </table> </div> </template> <script> export default { data() { return { isHorizontal: false, // 是否横屏显示表格 }; }, mounted() { // 监听窗口大小改变事件 window.addEventListener('resize', this.handleResize); // 初始化时执行一次 this.handleResize(); }, methods: { // 处理窗口大小改变事件 handleResize() { this.isHorizontal = window.innerWidth > 768; // 设置阈值,大于 768px 为横屏显示 }, }, }; </script> <style> .table-container { overflow: auto; /* 添加滚动条 */ } .table-horizontal table { writing-mode: vertical-lr; /* 竖排文字 */ transform: rotate(-180deg); /* 翻转表格 */ } @media screen and (min-width: 768px) { .table-horizontal table { writing-mode: horizontal-tb; /* 横排文字 */ transform: none; /* 恢复表格 */ } } </style> ``` 在上面的代码中,我们通过 `isHorizontal` 变量来控制表格的横竖显示。在 `mounted` 钩子函数中,我们监听窗口大小改变事件,并在该事件处理函数中根据窗口大小来设置 `isHorizontal` 变量的值。在模板中,我们动态地绑定了 `table-container` 的 CSS 类,如果 `isHorizontal` 为 `true`,则添加 `table-horizontal` 类,否则不添加。在 CSS 中,我们使用了 `writing-mode` 和 `transform` 属性来实现表格的横竖显示。在视口宽度大于 768px 时,我们使用 `@media` 查询来恢复表格的横排文字和正常显示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值