实时数据优化

//Controller
class Product_ReceivingController extends Zend_Controller_Action {
    //质检组收货及积压预警列表
    public function qcGroupReceivingAndBacklogReportAction() {
        set_time_limit(0);
        $catearray = Product_Service_Receiving::$productCategory;
        if ($this->_request->isPost()) {
            $warehouseId = $this->_request->getParam("userWarehouse", "");
            $startTime = $this->_request->getParam("start_time", "");
            $endTime = $this->_request->getParam("end_time", "");
            $return = array(
                "ask" => 0,
                "msg" => "",
                "data" => "",
                "count" => "",
            );
            if (!$warehouseId) {
                $return['msg'] = "请选择仓库";
                die(Zend_Json::encode($return));
            }
            if (!$startTime || !$endTime) {
                $return['msg'] = "请选择时间";
                die(Zend_Json::encode($return));
            }
            $data = array();
            $week = array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
            $date = date("Y-m-d");

            if (strtotime($endTime) >= strtotime($date)) {
                $data[] = Product_Service_QualityReceivingBacklog::generateQualityReceivingBacklog($date, $warehouseId);

                $combination = array(
                    "warehouse_id" => $warehouseId,
                    "start_date" => $startTime,
                    "end_date" => $endTime,
                );
                $qrbIds = Product_Service_QualityReceivingBacklog::getCombination($combination, "*", "qrb_date desc");
                if ($qrbIds) {
                    foreach ($qrbIds as $value) {
                        $data[] = $value;
                    }
                }
            } else {
                $combination = array(
                    "warehouse_id" => $warehouseId,
                    "start_date" => $startTime,
                    "end_date" => $endTime,
                );
                $qrbIds = Product_Service_QualityReceivingBacklog::getCombination($combination, "*", "qrb_date desc");
                if ($qrbIds) {
                    foreach ($qrbIds as $value) {
                        $data[] = $value;
                    }
                }
            }
            if (!$data) {
                $return['msg'] = "未获取到对应数据";
                die(json_encode($return));
            }
            $list = array();
            foreach ($data as $key => $valu) {
                $list[$key]['qrb_date'] = $valu['qrb_date'];
                $list[$key]['week'] = $week[date("w", strtotime($valu['qrb_date']))];
                $list[$key]['qrb_peceiving_votes'] = !isset($valu['qrb_peceiving_votes']) ? "" : $valu['qrb_peceiving_votes'];
                $list[$key]['qrb_po'] = !isset($valu['qrb_po']) ? "" : $valu['qrb_po'];
                $list[$key]['qrb_csp'] = !isset($valu['qrb_csp']) ? "" : $valu['qrb_csp'];
                $list[$key]['qrb_csp_proportion'] = !isset($valu['qrb_csp_proportion']) ? "" : $valu['qrb_csp_proportion'];
                $list[$key]['qrb_manual_asn'] = !isset($valu['qrb_manual_asn']) ? "" : $valu['qrb_manual_asn'];
                $list[$key]['qrb_manual_asn_proportion'] = !isset($valu['qrb_manual_asn_proportion']) ? "" : $valu['qrb_manual_asn_proportion'];
                $list[$key]['qrb_procurement_asn'] = !isset($valu['qrb_procurement_asn']) ? "" : $valu['qrb_procurement_asn'];
                $list[$key]['qrb_procurement_asn_proportion'] = !isset($valu['qrb_procurement_asn_proportion']) ? "" : $valu['qrb_procurement_asn_proportion'];
                $list[$key]['qrb_processing'] = !isset($valu['qrb_processing']) ? "" : $valu['qrb_processing'];
                $list[$key]['qrb_week_processing'] = !isset($valu['qrb_week_processing']) ? "" : $valu['qrb_week_processing'];
                $list[$key]['qrb_backlog'] = !isset($valu['qrb_backlog']) ? "" : $valu['qrb_backlog'];
                $list[$key]['qrb_backlog_proportion'] = !isset($valu['qrb_backlog_proportion']) ? "" : $valu['qrb_backlog_proportion'];
                $list[$key]['qrb_warning_level'] = !isset($valu['qrb_warning_level']) ? "" : $valu['qrb_warning_level'];
                $list[$key]['qrb_no_po'] = !isset($valu['qrb_no_po']) ? "" : $valu['qrb_no_po'];
                $list[$key]['qrb_no_csp'] = !isset($valu['qrb_no_csp']) ? "" : $valu['qrb_no_csp'];
                $list[$key]['qrb_is_csp'] = !isset($valu['qrb_is_csp']) ? "" : $valu['qrb_is_csp'];
                $list[$key]['qrb_category'] = !isset($valu['qrb_category']) ? "" : unserialize($valu['qrb_category']);
            }
            $return['ask'] = 1;
            $return['data'] = $list;
            $return['count'] = count($list);
            $return['count_category'] = count($catearray);
            die(Zend_Json::encode($return));
        }
        $this->view->category = $catearray;
        echo Cff::renderTpl($this->tplDirectory . "receiving-and-backlog-reports.tpl", "layout");
    }
}


Html
<!DOCTYPE html>
<html>
    <head>
        <title>质检组收货及积压预警列表</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="/css/order/transport.css" rel="stylesheet" type="text/css"/>
        <script src="/js/product/receiving/receiving-and-backlog-reports.js"></script>
    </head>
    <body>
        <div class="search_div">
            <form id="sForm" name="sForm" onsubmit='return false;'>
                <div>
                    <label>
                        <{include file=$userWarehouseTpl}>
                    </label>
                    &nbsp;&nbsp;
                    <input type="text"  name="start_time" id="start_time" style="text-align: center">
                    &nbsp;&nbsp;- -&nbsp;&nbsp;
                    <input type="text"  name="end_time" id="end_time" style="text-align: center">
                    &nbsp;&nbsp;
                    <input class="button search" type="button" value="搜索">
                    &nbsp;&nbsp;
                    <input class="button" type="button" value="收件人" onclick="addressee()">
                    &nbsp;&nbsp;
                    <input class="button" type="button" value="预警指标设置" onclick="warningIndicatorSetting()" style="color: red; width: 90px">
                </div>
            </form>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="myTab">
            <tbody>
                <tr class="even-tr">
                    <th colspan="2">时间</th>
                    <th colspan="4">收货数据</th>
                    <th colspan="4">PO 单绑定数据</th>
                    <th colspan="5">积压预警</th>
                    <th colspan="100%">积压数据</th>
                </tr>
                <tr class="even-tr">
                    <th>日期</th>
                    <th>星期</th>
                    <th>收货票数</th>
                    <th>PO 收货量</th>
                    <th>CSP 收货量</th>
                    <th>CSP 占比</th>
                    <th>有 ASN 单的票数</th>
                    <th>占比</th>
                    <th>无 ASN 单的票数</th>
                    <th>占比</th>
                    <th>当天处理票数</th>
                    <th>上周日均处理票数</th>
                    <th>积压票数</th>
                    <th>积压 / 日均处理票数 %</th>
                    <th>预警等级</th>
                    <th>未绑定 PO 票数</th>
                    <th>非 CSP</th>
                    <th>CSP</th>
                    <{foreach from=$category key="key" item="value"}>
                    <th value="<{$key}>"><{$value}></th>
                    <{/foreach}>
                </tr>
            </tbody>
            <tbody id="loadData" style="text-align: center"></tbody>
        </table>
        <div id="addresseeDialog" title="收件人"  style="display: none; text-align: center"></div>
        <div id="warningIndicatorSettingDialog" title="预警指标设置"  style="display: none"></div>
    </body>
</html>


js
//列表
function loadData() {
    loading();
    $.ajax({
        url: "/product/receiving/qc-group-receiving-and-backlog-report",
        async: false,
        dataType: "json",
        type: "post",
        data: $("#sForm").serializeArray(),
        success: function (json) {
            var Html = "";
            if (!json.ask) {
                alertTip(json.msg);
                Html += "<tr><td colspan='100%'>" + json.msg + "</td></tr>";
            } else {
                $.each(json.data, function (key, value) {
                    if (key % 2 == 0) {
                        Html += "<tr>";
                    } else {
                        Html += "<tr class='even-tr'>";
                    }
                    Html += "<td>" + value.qrb_date + "</td>";
                    Html += "<td>" + value.week + "</td>";
                    Html += "<td>" + value.qrb_peceiving_votes + "</td>";
                    Html += "<td>" + value.qrb_po + "</td>";
                    Html += "<td>" + value.qrb_csp + "</td>";
                    if (value.qrb_csp_proportion) {
                        Html += "<td>" + value.qrb_csp_proportion + "%</td>";
                    } else {
                        Html += "<td></td>";
                    }
                    Html += "<td>" + value.qrb_manual_asn + "</td>";
                    if (value.qrb_manual_asn_proportion) {
                        Html += "<td>" + value.qrb_manual_asn_proportion + "%</td>";
                    } else {
                        Html += "<td></td>";
                    }
                    Html += "<td>" + value.qrb_procurement_asn + "</td>";
                    if (value.qrb_procurement_asn_proportion) {
                        Html += "<td>" + value.qrb_procurement_asn_proportion + "%</td>";
                    } else {
                        Html += "<td></td>";
                    }
                    Html += "<td>" + value.qrb_processing + "</td>";
                    Html += "<td>" + value.qrb_week_processing + "</td>";
                    Html += "<td>" + value.qrb_backlog + "</td>";
                    if (value.qrb_backlog_proportion) {
                        Html += "<td>" + value.qrb_backlog_proportion + "%</td>";
                    } else {
                        Html += "<td></td>";
                    }
                    Html += "<td style='background-color: " + value.qrb_warning_level + "' ></td>";
                    Html += "<td>" + value.qrb_no_po + "</td>";
                    Html += "<td>" + value.qrb_no_csp + "</td>";
                    Html += "<td>" + value.qrb_is_csp + "</td>";
                    if (value.qrb_category) {
                        $.each(value.qrb_category, function (k, val) {
                            if (val != 0) {
                                Html += "<td value=" + k + ">" + val + "</td>";
                            } else {
                                Html += "<td value=" + k + "></td>";
                            }
                        })
                    } else {
                        for (var i = 0; i < json.count_category; i++) {
                            Html += "<td></td>";
                        }
                    }

                    Html += "</tr>";
                });
            }
            $("#loadData").html(Html);
        }
    });
    closeLoading();
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值