1、今日完成任务:
(1)完成查询统计-出车率分析模块的代码书写及测试工作
(2)完成查询统计-已收款明细模块的代码书写及测试工作
(3)完成查询统计-未收款明细模块的代码书写及测试工作
2、核心源码:
@RequestMapping("/queryAllDispatchCount")
@ResponseBody
public List<Map<String,Object>> queryAllDispatchCount(String startdate,String enddate){
return ds.queryDispatchCount(startdate,enddate);
}
@RequestMapping("/exportChuchelv")
@ResponseBody
public void exportChuchelv(String startdate,String enddate,HttpServletResponse resp){
try {
List<Map<String, Object>> list = ds.queryDispatchCount(startdate,enddate);
// 创建新的Excel 工作簿
HSSFWorkbook workbook = new HSSFWorkbook();
// 在Excel工作簿中建一工作表
HSSFSheet sheet = workbook.createSheet("出车率分析");
// 在索引0的位置创建行(最顶端的行)
HSSFRow row = sheet.createRow(0);
//表头 创建单元格并输入内容
row.createCell(0).setCellValue("车牌号");
row.createCell(1).setCellValue("开始日期");
row.createCell(2).setCellValue("截止日期");
row.createCell(3).setCellValue("出车次数");
row.createCell(4).setCellValue("租车费用");
//表格内容
for (Map<String, Object> map : list) {
HSSFRow row1 = sheet.createRow(sheet.getLastRowNum()+1);
row1.createCell(0).setCellValue((String)map.get("carnumber"));
row1.createCell(1).setCellValue(startdate);
row1.createCell(2).setCellValue(enddate);
row1.createCell(3).setCellValue((Long)map.get("dispatchcounts"));
row1.createCell(4).setCellValue((Double)map.get("rentmoneys"));
}
//设置响应类型及头信息
resp.setContentType("application/vnd.ms-excel");
String filename = URLEncoder.encode("出车率分析.xls", "UTF-8");
if(!StringUtils.isEmpty(startdate)&&!StringUtils.isEmpty(enddate)){
filename = URLEncoder.encode(startdate+"到"+enddate+URLDecoder.decode(filename, "UTF-8"), "UTF-8");
}
resp.setHeader("Content-Disposition", "attachment;filename="+filename);
//导出
workbook.write(resp.getOutputStream());
//关闭
workbook.close();
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("/exportReceived")
@ResponseBody
public void exportReceived(Integer status,Integer companyid,HttpServletResponse resp){
try {
List<Dispatch> list = ds.queryAll(status,null,null,null,companyid,null,null,null,null);
String name = "";
if(status==0){
name = "未";
}
if(status==1){
name = "已";
}
HSSFWorkbook workbook = createDispatchExcel(list,name+"收款派车单明细");
//设置响应类型及头信息
resp.setContentType("application/vnd.ms-excel");
String filename = URLEncoder.encode(name+"收款派车单明细.xls", "UTF-8");
if(!StringUtils.isEmpty(companyid)){
filename = URLEncoder.encode(list.get(0).getCustomer().getCompany()+URLDecoder.decode(filename, "UTF-8"), "UTF-8");
}
resp.setHeader("Content-Disposition", "attachment;filename="+filename);
//导出
workbook.write(resp.getOutputStream());
//关闭
workbook.close();
} catch (Exception e) {
e.printStackTrace();
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,innitial-scale=1">
<title>出车率分析</title>
<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css"/>
<link rel="stylesheet" type="text/css" href="../../css/default.css"/>
<script src="../../js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/easyui/ext/jquery.portal.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#dg').datagrid({
toolbar: [{
text:'出车日期自:<input id="startdate" />'
},'-',{
text:'出车日期至:<input id="enddate" />'
},'-',{
text:'查询',
iconCls: 'icon-search',
handler:function(){
var startdate = $('#startdate').datebox('getValue');
var enddate = $('#enddate').datebox('getValue');
$('#dg').datagrid('load',{
startdate: startdate,
enddate: enddate
});
}
},'-',{
id: 'export',
text:'导出',
iconCls: 'icon-print',
handler:function(){
$("#startdate1").val($('#startdate').datebox('getValue'));
$("#enddate1").val($('#enddate').datebox('getValue'));
$("#ff").attr('action','../../exportChuchelv');
$("#ff").submit();
}
}]
});
$('#startdate').datebox();
$('#enddate').datebox();
});
</script>
</head>
<body>
<form action="" id="ff" method="post">
<input type="hidden" id="startdate1" name="startdate"/>
<input type="hidden" id="enddate1" name="enddate"/>
</form>
<table id="dg" class="easyui-datagrid"
data-options="url:'../../queryAllDispatchCount',fitColumns:true,rownumbers:true">
<thead>
<tr>
<th data-options="field:'carnumber',width:70,align:'center'">车牌号</th>
<th data-options="field:'dispatchcounts',width:70,align:'center'">出车次数</th>
<th data-options="field:'rentmoneys',width:70,align:'center'">租车费用</th>
</tr>
</thead>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,innitial-scale=1">
<title>已收款明细</title>
<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css"/>
<link rel="stylesheet" type="text/css" href="../../css/default.css"/>
<script src="../../js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/easyui/ext/jquery.portal.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$('#dg').datagrid({
toolbar: [{
text:'用车单位:<input id="companySelect"/>'
},'-',{
text:'查询',
iconCls: 'icon-search',
handler:function(){
var companyid = $("#companySelect").combobox('getValue');
$('#dg').datagrid('load',{
companyid: companyid,
status: 1
});
}
},'-',{
id: 'export',
text:'导出',
iconCls: 'icon-print',
handler:function(){
$("#companyid").val($("#companySelect").combobox('getValue'));
$("#ff").attr('action','../../exportReceived');
$("#ff").submit();
}
}]
});
$("#companySelect").combobox({
url:'../../queryAllCustomer',
valueField:'id',
textField:'company',
});
});
</script>
</head>
<body>
<form action="" id="ff" method="post">
<input type="hidden" id="companyid" name="companyid"/>
<input type="hidden" name="status" value="1"/>
</form>
<table id="dg" class="easyui-datagrid"
data-options="url:'../../queryAllDispatch',fitColumns:true,rownumbers:true,queryParams:{status:'1'}">
<thead>
<tr>
<th data-options="field:'id',width:70,align:'center'">派车单号</th>
<th data-options="field:'registdate',width:100,align:'center'">登记日期</th>
<th data-options="field:'car.carnumber',width:80,align:'center',formatter: function(value,row,index){return row.car.carnumber;}">车牌号码</th>
<th data-options="field:'senddate',width:100,align:'center'">出车日期</th>
<th data-options="field:'sendtime',width:70,align:'center'">出车时间</th>
<th data-options="field:'category',width:70,align:'center'">所属类别</th>
<th data-options="field:'start',width:120,align:'center'">起始地点</th>
<th data-options="field:'customer.company',width:100,align:'center',formatter: function(value,row,index){return row.customer.company;}">用车单位</th>
<th data-options="field:'customer.name',width:70,align:'center',formatter: function(value,row,index){return row.customer.name;}">联系人</th>
<th data-options="field:'customer.phone',width:100,align:'center',formatter: function(value,row,index){return row.customer.phone;}">联系电话</th>
<th data-options="field:'clerk.name',width:70,align:'center',formatter: function(value,row,index){return row.clerk.name;}">业务员</th>
<th data-options="field:'driver.name',width:70,align:'center',formatter: function(value,row,index){return row.driver.name;}">驾驶员</th>
<th data-options="field:'rentmoney',width:70,align:'center'">租车费</th>
<th data-options="field:'discount',width:70,align:'center'">折扣金额</th>
<th data-options="field:'realmoney',width:70,align:'center'">实际金额</th>
<th data-options="field:'paytype',width:70,align:'center'">支付方式</th>
<th data-options="field:'remark',width:70,align:'center'">备注</th>
<th data-options="field:'status',width:90,align:'center',formatter: function(value,row,index){if(value==-1){return '未审核未收款';}else if(value==0){return '已审核未收款';}else{return '已审核已收款';}}">状态</th>
</tr>
</thead>
</table>
</body>
</html>
3、遇到的问题:
无
4、解决的方法:
无
5、项目燃尽图更新: