关于车辆派遣系统的总结(0809完结)
关于车辆派遣系统的总结(0809完结)
燃尽图:

上次内容,因为没有完整做完派车单审核的功能,这里一并阐述。派车单审核,在做了一系列的费用数据输入后,把费用数据写入数据库的同时,需要修改驾驶员和车辆号码的状态,通俗的说就是让驾驶员和车辆号码的“被占用状态”改为“可以被(再次)派遣”。派车单审核,是在审核一系列已派单但是没有结束派车业务的过程,审核的目的是在结束派车业务时,录入派车单的各项费用。这里把需要审核的派车单列表作为登录后首页的展示内容,点击对应的审核单,跳转到对应的审核页面。


在派车单审核页面中,对欠款金额进行了计算,并写入数据库中。
controller层
// 获取所有要审核的派单
@RequestMapping("/getAllCheck.do")
@ResponseBody
public ResponseResult<List<Order>> getAllCheck() {
ResponseResult<List<Order>> rr = new ResponseResult<List<Order>>();
List<Order> orderList = orderService.getAllCheck();
rr.setState(1);
rr.setMessage("获取全部审核派遣单成功");
rr.setData(orderList);
return rr;
}
//依据t_order表中的是否审核派车单的状态oflag字段,查询数据库中所有//没有被什么的派车单,拿到数据,在页面渲染。
//在渲染列表时,超链接--审核指向审核页面和携带对应本行数据的唯一标识符oid,以便在审核后,写入到对应的数据库的行中。
写入各项费用数据之后,需要修改派车单的审核状态,从需要审核的列表中去除。
同时也要修改对应的车辆和驾驶员状态,让其可以被派遣,不再是被占用状态。
// 审核派遣单
@RequestMapping("/check.do")
@ResponseBody
public ResponseResult<Void> check(Integer oyf, Integer ogqf, Integer otcf, Integer oxlf, Integer oltf, Integer ocbt,
Integer oxsgls, Integer oqkje, Integer oid) {
System.out.println("-->/order/check.do");
System.out.println("oyf=" + oyf + ",ogqf=" + ogqf + ",otcf=" + otcf + ",oxlf=" + oxlf + ",oltf=" + oltf
+ ",ocbt=" + ocbt + ",oxsgls=" + oxsgls + ",oqkje=" + oqkje + ",oid=" + oid);
ResponseResult<Void> rr = new ResponseResult<Void>();
Integer count = orderService.change(oyf, ogqf, otcf, oxlf, oltf, ocbt, oxsgls, oqkje, oid);
// 需要修改车辆和驾驶员的状态
Order order = orderService.getOrderByOid(oid);
System.out.println(order);
// 修改其他表数据
String oclhm = order.getOclhm();
Integer count2 = carService.changeState(0, oclhm);
String ojsy = order.getOjsy();
Integer count3 = driverService.changeState(0, ojsy);
rr.setState(1);
rr.setMessage("审核完成");
System.out.println("<--/order/check.do");
return rr;
}
跳转刷新审核列表页面时,重新请求需要审核的列表,至此审核功能完结。
单车月结算:
这里是对派车单收支明细的统计和计算

//因为测试数据有限,年份固定了,月份只有部分。
controller层:
// 根据月份查询所有订单信息
@RequestMapping("/getOrderByMonth.do")
@ResponseBody
public ResponseResult<List<Order>> getOrderByMonth(Integer year, Integer month) {
System.out.println("-->/order/getOrderByMonth.do");
System.out.println("year=" + year + ",month=" + month);
ResponseResult<List<Order>> rr = new ResponseResult<List<Order>>();
List<Order> orderList = orderService.getOrderByMonth(year, month);
System.out.println("list.size()=" + orderList.size());
for (Order order : orderList) {
System.out.println(order);
}
rr.setData(orderList);
rr.setMessage("获取数据成功");
rr.setState(1);
System.out.println("<--/order/getOrderByMonth.do");
return rr;
}
结算明细:
页面:

其实也和上面的单车月结算差不多,只是显示内容有些许区别,同时对收支做计算。另外根据需要,实现excel表格的下载。
controller层:
// 根据月份查询所有订单信息
@RequestMapping("/getOrderByMonth.do")
@ResponseBody
public ResponseResult<List<Order>> getOrderByMonth(Integer year, Integer month) {
System.out.println("-->/order/getOrderByMonth.do");
System.out.println("year=" + year + ",month=" + month);
ResponseResult<List<Order>> rr = new ResponseResult<List<Order>>();
List<Order> orderList = orderService.getOrderByMonth(year, month);
System.out.println("list.size()=" + orderList.size());
for (Order order : orderList) {
System.out.println(order);
}
rr.setData(orderList);
rr.setMessage("获取数据成功");
rr.setState(1);
System.out.println("<--/order/getOrderByMonth.do");
return rr;
}
// excel下载
@RequestMapping("/download_excel.do")
@ResponseBody
// 获取url链接上的参数
public String dowm(HttpServletResponse response, @RequestParam("year") Integer year,
@RequestParam("month") Integer month) {
response.setContentType("application/binary;charset=UTF-8");
try {
ServletOutputStream out = response.getOutputStream();
try {
// 设置文件头:最后一个参数是设置下载文件名(这里我们叫:张三.pdf)
response.setHeader("Content-Disposition",
"attachment;fileName=" + URLEncoder.encode(year+"" + month + ".xls", "UTF-8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
String[] titles = { "编号", "派车单号", "用车单位", "联系人", "出车日期", "出车时间", "起始地点", "车辆号码", "驾驶员", "经办人", "租车费",
"支付方式", "所属类别", "是否结算(1是0否)", "油费", "过桥费", "停车费", "修理费", "轮胎费", "车补贴", "行驶公里数", "欠款金额" };
orderService.export(titles, out, year, month);
return "success";
} catch (Exception e) {
e.printStackTrace();
return "导出信息失败";
}
}
到处excel表格所需jar包坐标
<!-- EXCEL -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
//单车查询
这里要根据年份、月份、车牌号实现动态的查询,根据不同的查询条件,获取不同的查询信息。并实现excel表格下载
页面:

controller层:
//动态获取
@RequestMapping("/getOrderBySome.do")
@ResponseBody
public ResponseResult<List<Order>> getOrderBySome(String year,String month,String carNum){
System.out.println("year="+year+",month="+month+",carNum="+carNum);
ResponseResult<List<Order>> rr = new ResponseResult<List<Order>>();
List<Order> orderList = orderService.getOrderBySome(year,month,carNum);
rr.setData(orderList);
rr.setMessage("获取someorder成功");
rr.setState(1);
return rr;
}
//统计
@RequestMapping("/count.do")
@ResponseBody
public ResponseResult<HashMap<String, BigDecimal>> count(String year,String month,String carNum){
ResponseResult<HashMap<String, BigDecimal>> rr = new ResponseResult<HashMap<String,BigDecimal>>();
HashMap<String, BigDecimal> map = orderService.getSumBySome(year,month,carNum);
rr.setData(map);
rr.setMessage("success");
rr.setState(1);
return rr;
}
@RequestMapping("/download_excel2.do")
@ResponseBody
public String dowm2(HttpServletResponse response, @RequestParam("year") String year,
@RequestParam("month") String month,String carNum) {
response.setContentType("application/binary;charset=UTF-8");
try {
ServletOutputStream out = response.getOutputStream();
try {
// 设置文件头:最后一个参数是设置下载文件名(这里我们叫:张三.pdf)
response.setHeader("Content-Disposition",
"attachment;fileName=" + URLEncoder.encode(year+"" + month + carNum + ".xls", "UTF-8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
String[] titles = { "编号", "派车单号", "用车单位", "联系人", "出车日期", "出车时间", "起始地点", "车辆号码", "驾驶员", "经办人", "租车费",
"支付方式", "所属类别", "是否结算(1是0否)", "油费", "过桥费", "停车费", "修理费", "轮胎费", "车补贴", "行驶公里数", "欠款金额" };
orderService.export2(titles, out, year, month,carNum);
return "success";
} catch (Exception e) {
e.printStackTrace();
return "导出信息失败";
}
}
动态SQL语句:
<!--
//依据some获取order
List<Order> selectOrderBySome(@Param("oyear")String year, @Param("omonth")String month, @Param("oclhm")String carNum);
-->
<select id="selectOrderBySome" resultType="com.houpu.bean.Order" >
select * from t_order where oyear='2020'
<if test="omonth != null and omonth!= '' ">
and omonth=#{omonth}
</if>
<if test="oclhm != null and oclhm != '' ">
and oclhm=#{oclhm}
</if>
</select>
<!--
//聚合函数
HashMap<String, Integer> selectSumBySome(@Param("oyear")String year, @Param("omonth")String month, @Param("oclhm")String carNum);
-->
<select id="selectSumBySome" resultType="java.util.HashMap" >
select
sum(ozcf) as 'sum_ozcf',
sum(oyf) as 'sum_oyf',
sum(ogqf) as 'sum_ogqf',
sum(otcf) as 'sum_otcf',
sum(oxlf) as 'sum_oxlf',
sum(oltf) as 'sum_oltf',
sum(ocbt) as 'sum_ocbt',
sum(oxsgls) as 'sum_oxsgls',
sum(oqkje) as 'sum_oqkje'
from t_order where oyear='2020'
<if test="omonth != null and omonth!= '' ">
and omonth=#{omonth}
</if>
<if test="oclhm != null and oclhm != '' ">
and oclhm=#{oclhm}
</if>
</select>
至此,要求功能均实现。需要增强的是页面的布局和美观等,有些短板了。。。
百度云:
链接:https://pan.baidu.com/s/1uBe8-Yj2DyyAQXk87WDOTg
提取码:nagl
复制这段内容后打开百度网盘手机App,操作更方便哦
项目发布地址:140.143.12.161/SummerProject01
项目演示:
链接:https://pan.baidu.com/s/1ynCIl3QEIInnjPsb6sEC1A
提取码:la01

浙公网安备 33010602011771号