//Controller
class Product_PutawayController extends Zend_Controller_Action {
public function putawaySendReportAction(){
if($this->_request->isPost()){
$page = $this->_request->getParam('page',1);
$pageSize = $this->_request->getParam('pageSize',20);
$customer_id = $this->_request->getParam('customer_id','');
$start_date = $this->_request->getParam('dateFrom','');
$end_date = $this->_request->getParam('dateTo','');
$warehouse = $this->_request->getParam('userWarehouse','1');
$rate = $this->_request->getParam('rate', '');
$rate_type = $this->_request->getParam('rate_type', '');
$data=array('result'=>0,'ask'=>0);
$rateType = array('<=', '=', '>=');
$condition = array(
'start_date' => $start_date,
'end_date' => $end_date,
'warehouse_id'=>$warehouse,
'rate' => $rate,
'rate_type' => $rateType[$rate_type],
);
$total = Product_Service_AsnSendReport::getByCondition($condition,'count(*)');
if ($total == 0)
die(Zend_Json::encode($data));
$asrRe = Product_Service_AsnSendReport::getByCondition($condition,'*','asr_date');
list($list, $total) = Product_Service_AsnSendReport::countData($asrRe);
$data=array(
'result'=>$list,
'total'=>$total,
'ask'=>1
);
die(json_encode($data));
}
echo Cff::renderTpl($this->tplDirectory.'send-report.tpl',"layout");
}
}
//Service
class Product_Service_AsnSendReport {
//统计数据
public static function countData($rows, $customers = array('STK01'), $divid_start_time='1150001', $divid_end_time='') {
$list = $total = array();
$weekName = array('1'=>'周一', '周二', '周三', '周四', '周五', '周六', '周日');
$stk_count = $other_count = 0;
$point = 2;
foreach ($rows as $key => $val){
$ym = date('Ym', strtotime($val['asr_date']));
if (!isset($list[$ym])) {
$list[$ym] = array();
$total[$ym]['asr_24h_sku_sum'] = $total[$ym]['asr_24h_item_sum'] = $total[$ym]['asr_all_sku_sum']
= $total[$ym]['asr_all_item_sum'] = $total[$ym]['asr_all_packaging_sum'] = $total[$ym]['asr_automaticity_item_sum'] = $total[$ym]['asr_csp_rate_sum'] = $total[$ym]['asr_automaticity_rate_sum'] = $total[$ym]['asr_asn_rate_sum'] = $total[$ym]['asr_qc_rate_sum']
= $total[$ym]['asr_priority_rate_sum'] = $total[$ym]['asr_all_rate_sum'] = $total[$ym]['asr_48h_rate_sum']
= $total[$ym]['asr_72h_rate_sum'] = 0;
$pcount[$ym] = 0;
}
if (isset($list[$ym][$val['asr_date']]))
continue;
$list[$ym][$val['asr_date']] = array(
'asr_24h_sku' => $val['asr_24h_sku'],
'asr_24h_item' => $val['asr_24h_item'],
'asr_all_sku' => $val['asr_all_sku'],
'asr_all_item' => $val['asr_all_item'],
"asr_all_packaging" => $val['asr_all_packaging'],
"asr_automaticity_item" => $val['asr_automaticity_item'],
"asr_csp_rate" => $val['asr_csp_rate'],
"asr_automaticity_rate" => $val['asr_automaticity_rate'],
'asr_asn_rate' => $val['asr_asn_rate'],
'asr_qc_rate' => $val['asr_qc_rate'],
'asr_priority_rate' => $val['asr_priority_rate'],
'asr_all_rate' => $val['asr_all_rate'],
'asr_48h_rate' => $val['asr_48h_rate'],
'asr_72h_rate' => $val['asr_72h_rate'],
'week_name'=>$weekName[date('N', strtotime($val['asr_date']))],
);
//总计
if ($val['asr_all_sku'] != 0) {
$total[$ym]['asr_24h_sku_sum'] += $val['asr_24h_sku'];
$total[$ym]['asr_24h_item_sum'] += $val['asr_24h_item'];
$total[$ym]['asr_all_sku_sum'] += $val['asr_all_sku'];
$total[$ym]['asr_all_item_sum'] += $val['asr_all_item'];
$total[$ym]['asr_all_packaging_sum'] += $val['asr_all_packaging'];
$total[$ym]['asr_automaticity_item_sum'] += $val['asr_automaticity_item'];
$total[$ym]['asr_csp_rate_sum'] += $val['asr_csp_rate'];
$total[$ym]['asr_automaticity_rate_sum'] += $val['asr_automaticity_rate'];
$total[$ym]['asr_asn_rate_sum'] += $val['asr_asn_rate'];
$total[$ym]['asr_qc_rate_sum'] += $val['asr_qc_rate'];
$total[$ym]['asr_priority_rate_sum'] += $val['asr_priority_rate'];
$total[$ym]['asr_all_rate_sum'] += $val['asr_all_rate'];
$total[$ym]['asr_48h_rate_sum'] += $val['asr_48h_rate'];
$total[$ym]['asr_72h_rate_sum'] += $val['asr_72h_rate'];
$pcount[$ym]++;
}
}
foreach ($total as $ym=>$value) {
//平均
$total[$ym]['asr_24h_sku_svg'] = round($pcount[$ym]?$value['asr_24h_sku_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_24h_item_svg'] = round($pcount[$ym]?$value['asr_24h_item_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_all_sku_svg'] = round($pcount[$ym]?$value['asr_all_sku_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_all_item_svg'] = round($pcount[$ym]?$value['asr_all_item_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_all_packaging_svg'] = round($pcount[$ym] ? $value['asr_all_packaging_sum'] / $pcount[$ym] : 0, $point);
$total[$ym]['asr_automaticity_item_svg'] = round($pcount[$ym] ? $value['asr_automaticity_item_sum'] / $pcount[$ym] : 0, $point);
$total[$ym]['asr_csp_rate_svg'] = round($pcount[$ym] ? $value['asr_csp_rate_sum'] / $pcount[$ym] : 0, $point);
$total[$ym]['asr_automaticity_rate_svg'] = round($pcount[$ym] ? $value['asr_automaticity_rate_sum'] / $pcount[$ym] : 0, $point);
$total[$ym]['asr_asn_rate_svg'] = round($pcount[$ym]?$value['asr_asn_rate_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_qc_rate_svg'] = round($pcount[$ym]?$value['asr_qc_rate_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_priority_rate_svg'] = round($pcount[$ym]?$value['asr_priority_rate_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_all_rate_svg'] = round($pcount[$ym]?$value['asr_all_rate_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_48h_rate_svg'] = round($pcount[$ym]?$value['asr_48h_rate_sum']/$pcount[$ym]:0, $point);
$total[$ym]['asr_72h_rate_svg'] = round($pcount[$ym]?$value['asr_72h_rate_sum']/$pcount[$ym]:0, $point);
}
return array($list, $total);
}
}
//Html
<!DOCTYPE html>
<html>
<head>
<title>入库时效列表</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
<script type="text/javascript">
//记录总数
var paginationTotal = 1;
$(function () {
var dayNamesMin = ['日', '一', '二', '三', '四', '五', '六'];
var monthNamesShort = ['01月', '02月', '03月', '04月', '05月', '06月', '07月', '08月', '09月', '10月', '11月', '12月'];
$('#dateFrom,#dateTo').datepicker({
dayNamesMin: dayNamesMin,
monthNamesShort: monthNamesShort,
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd'
});
$(".lists").live('click', function () {
$.each($(".list" + $(this).attr('ref')), function () {
$(this).toggle();
});
});
});
function search() {
if ($("#userWarehouse").val() == '') {
alert('请选择仓库');
return;
}
initData(0);
}
function loadData(page, pageSize) {
var wh_id = $("#userWarehouse").val();
loading();
$.ajax({
url: "/product/putaway/putaway-send-report/",
async: false,
dataType: "json",
type: "post",
data: $("#seach-form").serialize(),
success: function (json) {
var list = '';
if (json.ask) {
$.each(json.total, function (kk, vv) {
$.each(json.result, function (ks, vs) {
if (kk == ks) {
var i = 0;
$.each(vs, function (key, val) {
list += "<tr class='list" + kk + "' style='display:none'>";
list += "<td width='32'>" + key + "</td>";
list += "<td width='20'>" + val.week_name + "</td>";
list += "<td>" + val.asr_24h_sku + "</td>";
list += '<td>' + val.asr_24h_item + '</td>';
list += '<td>' + val.asr_all_sku + '</td>';
list += '<td>' + val.asr_all_item + '</td>';
list += "<td>" + val.asr_all_packaging + "</td>";
list += "<td>" + val.asr_automaticity_item + "</td>";
list += "<td>" + val.asr_csp_rate + "%</td>";
list += "<td>" + val.asr_automaticity_rate + "%</td>";
list += '<td>' + val.asr_asn_rate + '%</td>';
list += '<td>' + val.asr_qc_rate + '%</td>';
list += '<td>' + val.asr_priority_rate + '%</td>';
list += '<td>' + val.asr_all_rate + '%</td>';
list += '<td>' + val.asr_48h_rate + '%</td>';
list += '<td>' + val.asr_72h_rate + '%</td>';
list += "</tr>";
i++;
});
}
});
list += '<tr ref="' + kk + '" class="lists"><td rowspan="2" class=" even-tr"><b>' + kk.substring(0, 4) + '-' + kk.substring(4) + '</b></td><td>合计</td>';
list += '<td>' + vv.asr_24h_sku_sum + '</td>';
list += '<td>' + vv.asr_24h_item_sum + '</td>';
list += '<td>' + vv.asr_all_sku_sum + '</td>';
list += '<td>' + vv.asr_all_item_sum + '</td>';
list += "<td>" + vv.asr_all_packaging_sum + "</td>";
list += "<td>" + vv.asr_automaticity_item_sum + "</td>";
list += "<td>" + vv.asr_csp_rate_svg + "%</td>";
list += "<td>" + vv.asr_automaticity_rate_svg + "%</td>";
list += '<td>' + vv.asr_asn_rate_svg + '%</td>';
list += '<td>' + vv.asr_qc_rate_svg + '%</td>';
list += '<td>' + vv.asr_priority_rate_svg + '%</td>';
list += '<td>' + vv.asr_all_rate_svg + '%</td>';
list += '<td>' + vv.asr_48h_rate_svg + '%</td>';
list += '<td>' + vv.asr_72h_rate_svg + '%</td></tr>';
list += "<tr><td>平均</td>";
list += '<td>' + vv.asr_24h_sku_svg + '</td>';
list += '<td>' + vv.asr_24h_item_svg + '</td>';
list += '<td>' + vv.asr_all_sku_svg + '</td>';
list += '<td>' + vv.asr_all_item_svg + '</td>';
list += "<td>" + vv.asr_all_packaging_svg + "</td>";
list += "<td>" + vv.asr_automaticity_item_svg + "</td>";
list += "<td>" + vv.asr_csp_rate_svg + "%</td>";
list += "<td>" + vv.asr_automaticity_rate_svg + "%</td>";
list += '<td>' + vv.asr_asn_rate_svg + '%</td>';
list += '<td>' + vv.asr_qc_rate_svg + '%</td>';
list += '<td>' + vv.asr_priority_rate_svg + '%</td>';
list += '<td>' + vv.asr_all_rate_svg + '%</td>';
list += '<td>' + vv.asr_48h_rate_svg + '%</td>';
list += '<td>' + vv.asr_72h_rate_svg + '%</td></tr>';
});
$("#loadData").html(list);
} else {
$("#loadData").html("<tr><td colspan='16' align='center'>没有数据</td></tr>");
}
}
});
}
</script>
<style type="text/css">
table.myTab th{background:none; background-color:#2F82A0; color:#ffffff;}
.myTab table td{border-top:none; border-left:none;}
#iTitle div {
display: inline-block;
float: left;
padding: 0 0 0 10px;
margin-bottom: 12px;
}
.mySelect {
height: 22px;
border: 1px solid #CCCCCC;
}
#iTitle input {
height: 20px;
border: 1px solid #CCCCCC;
}
.sort{cursor:pointer;}
.button {
background: #f1f6f9 url("/images/left-menu-li.gif") repeat-x scroll left top;
border: 1px solid #318dac;
color: #318dac;
font-weight: lighter;
margin: auto 5px;
padding: 2px 5px;
vertical-align: middle;
width: 60px;
}
</style>
</head>
<body>
<div class="search_div">
<div id="iTitle">
<form id="seach-form" onsubmit="return false;" action="" method="post" name="seach-form">
<div>
<{include file=$userWarehouseTpl}>
</div>
<div>时间段:</div>
<div>
<input type="text" id="dateFrom" name="dateFrom" class="myInput" size='15'/> ~
<input type="text" id="dateTo" name="dateTo" class="myInput" size='15'/>
</div>
<div style="padding-left:10px">入库及时率:</div>
<div>
<select name="rate_type" id='rate_type' >
<option value="0">小于等于</option>
<option value="1">等于</option>
<option value="2">大于等于</option>
</select>
<input type="text" id="rate" name="rate" class="myInput" />
</div>
<div class="tDiv8">
<input id="searchSubmit" class="button" style="height:27px;border: 1px solid #318dac;" type="button" onclick="search();" value="搜索">
</div>
<div class="myClear"></div>
</form>
</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="myTab">
<tbody id="loadHeader">
<tr class="even-tr">
<th colspan="2" width="70">月份</th>
<th colspan="1">24小时内入库的SKU数</th>
<th colspan="1">24小时内入库的产品数</th>
<th colspan="1">当天入库的SKU总数</th>
<th width="108">当天入库的产品总数</th>
<th width="96">当天包装产品总数</th>
<th width="96">自动包装产品总数</th>
<th width="112">CSP 产品入库占比率</th>
<th width="112">自动包装产品占比率</th>
<th width="85">ASN单合格率</th>
<th width="85">QC单合格率</th>
<th width="85">优先入库及时率(8H)</th>
<th>入库及时率(24H)</th>
<th>入库及时率(48H)</th>
<th>入库及时率(72H)</th>
</tr>
</tbody>
<tbody id="loadData"></tbody>
</table>
</body>
</html>
入库时效列表
最新推荐文章于 2025-06-03 12:02:56 发布