//Controller
//导出报表
public function exportOrderDayWorkloadAction() {
$warehouseId = $this->_request->getParam("userWarehouse", "");
$owDate = $this->_request->getParam("dateFrom", "");
$post = $this->_request->getParam("post", "");
$combination = array(
"warehouse_id" => $warehouseId,
"ow_date" => $owDate,
"ow_post" => $post,
);
Order_Service_OrderWorkload::exportOrderDayWorkload($combination);
}
//Services
/*
* 导出报表
*
* $combination array() 条件
*/
public static function exportOrderDayWorkload($combination) {
$list = 2;
$row = "";
$owIdInfo = Order_Service_OrderWorkload::getCombination($combination, "*");
if (!empty($owIdInfo)) {
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->getActiveSheet();
$sheet->getColumnDimension("B")->setWidth(15);
$sheet->getColumnDimension("E")->setWidth(20);
$sheet->getColumnDimension("G")->setWidth(20);
$sheet->getColumnDimension("H")->setWidth(20);
$sheet->setCellValue("A1", "序号");
$sheet->setCellValue("B1", "时间");
$sheet->setCellValue("C1", "姓名");
$sheet->setCellValue("D1", "岗位");
$sheet->setCellValue("E1", "账号开通时间");
$sheet->setCellValue("F1", "完成总票数");
$sheet->setCellValue("G1", "仓库");
$sheet->setCellValue("H1", "订单类型");
$sheet->setCellValue("I1", "最快(分)");
$sheet->setCellValue("J1", "平均(分)");
$sheet->setCellValue("K1", "最慢(分)");
$sheet->setCellValue("L1", "订单票数");
$sheet->setCellValue("M1", "超时票数");
$sheet->setCellValue("N1", "多配");
$sheet->setCellValue("O1", "错配");
$sheet->setCellValue("P1", "漏配");
foreach ($owIdInfo as $value) {
//岗位
$name = User_Service_User::getByUserId($value['user_id']);
$upName = User_Service_Position::getByUpIdS(array("up_id" => $name['up_id']));
//仓库
$warehouseNameCn = Warehouse_Service_Warehouse::getById($value['warehouse_id']);
//订单类型
if ($value['ow_type'] == 0) {
$row = "一票一件(A)";
} else if ($value['ow_type'] == 1) {
$row = "一票多件单 SKU(B)";
} else {
$row = "一票多件多 SKU(C)";
}
//订单票数为一票的情况下显示规范
if ($value['ow_orders'] == 1 && ($value['ow_avg'] > $value['ow_slow'] || $value['ow_overtime_qty'] > 0)) {
$owFast = $value['ow_slow'];
$owAvg = $value['ow_slow'];
} else {
$owFast = $value['ow_fast'];
$owAvg = $value['ow_avg'];
}
$sheet->setCellValue("A" . $list, $list - 1);
$sheet->setCellValue("B" . $list, $value['ow_date']);
$sheet->setCellValue("C" . $list, $value['ow_user_name']);
$sheet->setCellValue("D" . $list, $upName[0]['up_name']);
$sheet->setCellValue("E" . $list, $name['create_date']);
$sheet->setCellValue("F" . $list, $value['ow_total_pickup']);
$sheet->setCellValue("G" . $list, $warehouseNameCn['warehouse_name_cn']);
$sheet->setCellValue("H" . $list, $row);
$sheet->setCellValue("I" . $list, $owFast);
$sheet->setCellValue("J" . $list, $owAvg);
$sheet->setCellValue("K" . $list, $value['ow_slow']);
$sheet->setCellValue("L" . $list, $value['ow_orders']);
$sheet->setCellValue("M" . $list, $value['ow_overtime_qty']);
if ($value['ow_post'] == 0) {
$sheet->setCellValue("N" . $list, $value['ow_more']);
$sheet->setCellValue("O" . $list, $value['ow_wrong']);
$sheet->setCellValue("P" . $list, $value['ow_leakage']);
}
$list++;
}
$objPHPExcel->createSheet();
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel5");
header("Content-Type: application/vnd.ms-excel;charset=utf8");
header('Content-Disposition: attachment;filename="' . date("Y-m-d") . ' 订单组日工作量报表.xls"');
$objWriter->save("php://output");
} else {
echo "没有数据";
}
}
//Js
//导出报表
$(".export").click(function () {
var userWarehouse = $("[name=userWarehouse]").val();
var data = "userWarehouse/" + userWarehouse +
"/dateFrom/" + $("[name=dateFrom]").val() +
"/post/" + $("[name=post]").attr("value");
window.open("/order/order/export-order-day-workload/" + data);
});
导出报表
最新推荐文章于 2024-04-22 17:26:06 发布