Commit 2df18a06c296b85904d8c2a5c355284e626aef36
1 parent
c7a85169
充电量月报表
Showing
9 changed files
with
388 additions
and
17 deletions
pom.xml
| ... | ... | @@ -279,11 +279,11 @@ |
| 279 | 279 | </dependency> |
| 280 | 280 | |
| 281 | 281 | |
| 282 | - <dependency> | |
| 282 | + <!--<dependency> | |
| 283 | 283 | <groupId>ojdbc</groupId> |
| 284 | 284 | <artifactId>ojdbc</artifactId> |
| 285 | 285 | <version>14</version> |
| 286 | - </dependency> | |
| 286 | + </dependency>--> | |
| 287 | 287 | |
| 288 | 288 | <dependency> |
| 289 | 289 | <groupId>org.apache.mina</groupId> | ... | ... |
src/main/java/com/bsth/controller/RefuelController.java
| ... | ... | @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestParam; |
| 15 | 15 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 16 | import org.springframework.web.multipart.MultipartFile; |
| 17 | 17 | |
| 18 | +import javax.servlet.http.HttpServletResponse; | |
| 19 | + | |
| 18 | 20 | /** |
| 19 | 21 | * Created in 19/9/3. |
| 20 | 22 | */ |
| ... | ... | @@ -83,5 +85,14 @@ public class RefuelController extends BaseController<Refuel, Long> { |
| 83 | 85 | private String getDataImportClasspath(){ |
| 84 | 86 | return this.getClass().getResource("/").getPath() + "/static/pages/forms"; |
| 85 | 87 | } |
| 86 | - | |
| 88 | + | |
| 89 | + @RequestMapping(value = "/queryDcMouth", method = RequestMethod.GET) | |
| 90 | + public Map<String,Object> queryDcMouth(@RequestParam Map<String, String> map){ | |
| 91 | + return refuelService.queryDcMouth(map); | |
| 92 | + } | |
| 93 | + | |
| 94 | + @RequestMapping(value = "/queryDcMouthExport" , method = RequestMethod.GET) | |
| 95 | + public Map<String, Object> queryDcMouthExport(@RequestParam Map<String, String> map, HttpServletResponse resp) { | |
| 96 | + return refuelService.queryDcMouthExport(map, resp); | |
| 97 | + } | |
| 87 | 98 | } | ... | ... |
src/main/java/com/bsth/entity/oil/JdlReception.java
| ... | ... | @@ -68,7 +68,41 @@ public class JdlReception { |
| 68 | 68 | private String updateBy; |
| 69 | 69 | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| 70 | 70 | private Date updateDate; |
| 71 | - | |
| 71 | + public static String[] parks = {"一期","二三期","青浦新城","商榻","大盈浦路","P23","重固","东站","漕盈路","朱家角","练塘","G1503","华新"}; | |
| 72 | + | |
| 73 | + public static String getParkName(String str) { | |
| 74 | + if ("特来电上海青浦巴士公交充电站".equals(str)) { | |
| 75 | + return "一期"; | |
| 76 | + } else if ("上海青浦公交二期充电站".equals(str)) { | |
| 77 | + return "二三期"; | |
| 78 | + } else if ("特来电上海青浦盈港公交停保场三期充电项目".equals(str)) { | |
| 79 | + return "二三期"; | |
| 80 | + } else if ("特来电上海青浦新城一站公交停保场充电站".equals(str)) { | |
| 81 | + return "青浦新城"; | |
| 82 | + } else if ("特来电上海青浦商榻汽车站充电项目".equals(str)) { | |
| 83 | + return "商榻"; | |
| 84 | + } else if ("特来电上海青浦大盈浦路公交枢纽充电站".equals(str)) { | |
| 85 | + return "大盈浦路"; | |
| 86 | + } else if ("P23公交场站".equals(str)) { | |
| 87 | + return "P23"; | |
| 88 | + } else if ("重固公交站2期".equals(str)) { | |
| 89 | + return "重固"; | |
| 90 | + } else if ("青浦区长途客运充电站".equals(str)) { | |
| 91 | + return "东站"; | |
| 92 | + } else if ("青浦区漕盈路公交枢纽充电站".equals(str)) { | |
| 93 | + return "漕盈路"; | |
| 94 | + } else if ("特来电上海青浦朱家角公交枢纽充电站".equals(str)) { | |
| 95 | + return "朱家角"; | |
| 96 | + } else if ("特来电上海青浦练塘公交枢纽充电站".equals(str)) { | |
| 97 | + return "练塘"; | |
| 98 | + } else if ("明仕电站青浦中心站".equals(str)) { | |
| 99 | + return "G1503"; | |
| 100 | + } else if ("特来电上海青浦华新枢纽公交站".equals(str)) { | |
| 101 | + return "华新"; | |
| 102 | + } else { | |
| 103 | + return ""; | |
| 104 | + } | |
| 105 | + } | |
| 72 | 106 | |
| 73 | 107 | public Long getId() { |
| 74 | 108 | return id; |
| ... | ... | @@ -214,5 +248,9 @@ public class JdlReception { |
| 214 | 248 | public void setUpdateDate(Date updateDate) { |
| 215 | 249 | this.updateDate = updateDate; |
| 216 | 250 | } |
| 217 | - | |
| 251 | + | |
| 252 | + public String getParkName() { | |
| 253 | + return getParkName(this.stationName); | |
| 254 | + } | |
| 255 | + | |
| 218 | 256 | } |
| 219 | 257 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/repository/RefuelRepository.java
| ... | ... | @@ -66,5 +66,9 @@ public interface RefuelRepository extends BaseRepository<Refuel, Long> { |
| 66 | 66 | |
| 67 | 67 | @Query(value="select s from Cars s where s.hydrogen=?1") |
| 68 | 68 | List<Cars> findCarsByHydrogen(Boolean hydrogen); |
| 69 | + | |
| 70 | + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | |
| 71 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr >= ?1 and s.scheduleDateStr <= ?2") | |
| 72 | + List<ScheduleRealInfo> scheduleByDate(String dateS, String dateE); | |
| 69 | 73 | |
| 70 | 74 | } | ... | ... |
src/main/java/com/bsth/repository/oil/JdlReceptionRepository.java
| ... | ... | @@ -16,4 +16,8 @@ public interface JdlReceptionRepository extends PagingAndSortingRepository<JdlRe |
| 16 | 16 | |
| 17 | 17 | @Query(value="SELECT j FROM JdlReception j where j.dateStr = ?1 and j.carCode like ?2 order by j.createDate") |
| 18 | 18 | List<JdlReception> queryListByDateStrAndCar(String dateStr,String car); |
| 19 | + | |
| 20 | + @Query(value="SELECT j FROM JdlReception j where j.dateStr >=?1 and j.dateStr <=?2") | |
| 21 | + List<JdlReception> queryListByDateStr(String dateS,String dateE); | |
| 22 | + | |
| 19 | 23 | } |
| 20 | 24 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/RefuelService.java
| ... | ... | @@ -6,6 +6,8 @@ import java.util.Map; |
| 6 | 6 | |
| 7 | 7 | import com.bsth.entity.Refuel; |
| 8 | 8 | |
| 9 | +import javax.servlet.http.HttpServletResponse; | |
| 10 | + | |
| 9 | 11 | /** |
| 10 | 12 | * Created in 19/9/3. |
| 11 | 13 | */ |
| ... | ... | @@ -30,4 +32,8 @@ public interface RefuelService extends BaseService<Refuel, Long> { |
| 30 | 32 | List<Map<String, Object>> exportQueryQc(Map<String, Object> map); |
| 31 | 33 | |
| 32 | 34 | public String importExcel(File file); |
| 35 | + | |
| 36 | + Map<String,Object> queryDcMouth(Map<String, String> map); | |
| 37 | + | |
| 38 | + Map<String, Object> queryDcMouthExport(Map<String,String> map, HttpServletResponse response); | |
| 33 | 39 | } | ... | ... |
src/main/java/com/bsth/service/impl/RefuelServiceImpl.java
| 1 | 1 | package com.bsth.service.impl; |
| 2 | 2 | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 3 | 4 | import com.bsth.entity.Cars; |
| 4 | 5 | import com.bsth.entity.Refuel; |
| 5 | 6 | import com.bsth.entity.oil.JdlReception; |
| ... | ... | @@ -13,22 +14,18 @@ import com.bsth.security.util.SecurityUtils; |
| 13 | 14 | import com.bsth.service.RefuelService; |
| 14 | 15 | import com.bsth.service.report.CulateMileageService; |
| 15 | 16 | import com.bsth.util.Arith; |
| 17 | +import com.bsth.util.ExcelUtil; | |
| 16 | 18 | import com.bsth.util.ReportUtils; |
| 17 | 19 | |
| 18 | 20 | import java.io.File; |
| 19 | 21 | import java.io.FileInputStream; |
| 20 | 22 | import java.math.BigDecimal; |
| 23 | +import java.math.RoundingMode; | |
| 21 | 24 | import java.text.DecimalFormat; |
| 22 | 25 | import java.text.ParseException; |
| 23 | 26 | import java.text.SimpleDateFormat; |
| 24 | -import java.util.ArrayList; | |
| 25 | -import java.util.Date; | |
| 26 | -import java.util.HashMap; | |
| 27 | -import java.util.HashSet; | |
| 28 | -import java.util.Iterator; | |
| 29 | -import java.util.List; | |
| 30 | -import java.util.Map; | |
| 31 | -import java.util.Set; | |
| 27 | +import java.util.*; | |
| 28 | +import java.util.stream.Collectors; | |
| 32 | 29 | |
| 33 | 30 | import org.apache.poi.hssf.usermodel.HSSFCell; |
| 34 | 31 | import org.apache.poi.hssf.usermodel.HSSFRow; |
| ... | ... | @@ -38,6 +35,8 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; |
| 38 | 35 | import org.springframework.beans.factory.annotation.Autowired; |
| 39 | 36 | import org.springframework.stereotype.Service; |
| 40 | 37 | |
| 38 | +import javax.servlet.http.HttpServletResponse; | |
| 39 | + | |
| 41 | 40 | /** |
| 42 | 41 | * Created in 19/9/3. |
| 43 | 42 | */ |
| ... | ... | @@ -1473,5 +1472,160 @@ public class RefuelServiceImpl extends BaseServiceImpl<Refuel, Long> implements |
| 1473 | 1472 | BigDecimal b2 = new BigDecimal(v2.toString()); |
| 1474 | 1473 | return b1.add(b2).toString(); |
| 1475 | 1474 | } |
| 1476 | - | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + public Map<String,Object> queryDcMouth(Map<String,String> map){ | |
| 1478 | + Map<String,Object> resultMap=new HashMap<>(); | |
| 1479 | + if(map.get("dateS") == null || map.get("dateE") == null){ | |
| 1480 | + return resultMap; | |
| 1481 | + } | |
| 1482 | + List<Map<String, Object>> result = new ArrayList<>(); | |
| 1483 | + String dateS=map.get("dateS"); | |
| 1484 | + String dateE=map.get("dateE"); | |
| 1485 | + List<JdlReception> jdlReceptions=jdlReceptionRepository.queryListByDateStr(dateS,dateE); | |
| 1486 | + Set<String> carSet = new HashSet<>(); | |
| 1487 | + Set<String> stationSet = new HashSet<>(); | |
| 1488 | + Map<String,String> carPlate = new HashMap<>(); | |
| 1489 | + for (JdlReception jdlReception : jdlReceptions) { | |
| 1490 | + if(jdlReception.getCarCode()!=null && !"".equals(jdlReception.getCarCode())){ | |
| 1491 | + carSet.add(jdlReception.getCarCode()); | |
| 1492 | + carPlate.put(jdlReception.getCarCode(),jdlReception.getCarPlate()); | |
| 1493 | + } | |
| 1494 | + if(jdlReception.getStationName()!=null && !"".equals(jdlReception.getStationName())){ | |
| 1495 | + stationSet.add(jdlReception.getStationName()); | |
| 1496 | + } | |
| 1497 | + } | |
| 1498 | + | |
| 1499 | + List<String> cars = new ArrayList<>(carSet); | |
| 1500 | + List<String> stations = Arrays.asList(JdlReception.parks); | |
| 1501 | + //路单分组 | |
| 1502 | + List<ScheduleRealInfo> realInfos=repository.scheduleByDate(dateS,dateE); | |
| 1503 | + Map<String,List<ScheduleRealInfo>> sMap=realInfos.stream().collect(Collectors.groupingBy(ScheduleRealInfo::getClZbh)); | |
| 1504 | + | |
| 1505 | + //给每个站充电量赋默认值 | |
| 1506 | + Map<String, Map<String, Double>> matrix = new LinkedHashMap<>(); | |
| 1507 | + for (String car : cars) { | |
| 1508 | + Map<String, Double> stationMap = new HashMap<>(); | |
| 1509 | + for (String station : stations) { | |
| 1510 | + stationMap.put(station, 0.00); | |
| 1511 | + } | |
| 1512 | + matrix.put(car, stationMap); | |
| 1513 | + } | |
| 1514 | + | |
| 1515 | + //计算实际充电量 | |
| 1516 | + for (JdlReception data : jdlReceptions) { | |
| 1517 | + String car = data.getCarCode(); | |
| 1518 | + String station = data.getParkName(); | |
| 1519 | + Double capacity = data.getChargeCapacity(); | |
| 1520 | + | |
| 1521 | + if (car != null && station != null && capacity != null) { | |
| 1522 | + Map<String, Double> stationMap = matrix.get(car); | |
| 1523 | + if (stationMap != null && !station.equals("")) { | |
| 1524 | + Double current = stationMap.getOrDefault(station, 0.00); | |
| 1525 | + stationMap.put(station, Arith.add(current, capacity)); | |
| 1526 | + } | |
| 1527 | + } | |
| 1528 | + } | |
| 1529 | + | |
| 1530 | + //数据统计 | |
| 1531 | + for (String car : cars) { | |
| 1532 | + Map<String, Object> row = new LinkedHashMap<>(); | |
| 1533 | + row.put("plate", carPlate.get(car)); | |
| 1534 | + row.put("car", car); | |
| 1535 | + String realMileage ="0"; | |
| 1536 | + List<ScheduleRealInfo> list = sMap.get(car); | |
| 1537 | + if(list!=null){ | |
| 1538 | + List<ScheduleRealInfo> list_s = new ArrayList<>(); // 实际路单(已完成班次与烂班班次等) | |
| 1539 | + for(ScheduleRealInfo s : list){ | |
| 1540 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 1541 | + if(cts != null && cts.size() > 0){ | |
| 1542 | + list_s.add(s); | |
| 1543 | + }else{ | |
| 1544 | + if(s.getZdsjActual()!=null&& s.getFcsjActual()!=null){ | |
| 1545 | + list_s.add(s); | |
| 1546 | + } | |
| 1547 | + } | |
| 1548 | + } | |
| 1549 | + | |
| 1550 | + //计算总公里 | |
| 1551 | + Double sjgl = culateMileageService.culateSjgl(list_s);//实际 | |
| 1552 | + Double ksgl = culateMileageService.culateKsgl(list_s);//空驶 | |
| 1553 | + Double jccgl = culateMileageService.culateJccgl(list_s);//进出场 | |
| 1554 | + Double ljgl = culateMileageService.culateLjgl(list_s);//临加 | |
| 1555 | + realMileage = add(add(sjgl, ksgl), add(jccgl, ljgl)); | |
| 1556 | + } | |
| 1557 | + row.put("zgl", realMileage); | |
| 1558 | + | |
| 1559 | + //按序存入充电数据 方便动态列 | |
| 1560 | + List<Double> refuels=new ArrayList<>(Collections.nCopies(stations.size(), new Double(0))); | |
| 1561 | + Map<String, Double> stationMap = matrix.get(car); | |
| 1562 | + for (int i = 0; i < stations.size(); i++) { | |
| 1563 | + Double total = stationMap.get(stations.get(i)); | |
| 1564 | + refuels.set(i,total); | |
| 1565 | + row.put("refuels", refuels); | |
| 1566 | + } | |
| 1567 | + | |
| 1568 | + //计算充电合计 | |
| 1569 | + Double carTotal = stationMap.values().stream().reduce(0.00,Double::sum); | |
| 1570 | + BigDecimal total=new BigDecimal(carTotal).setScale(3, RoundingMode.HALF_UP); | |
| 1571 | + row.put("total", total.doubleValue()); | |
| 1572 | + | |
| 1573 | + //计算百公里电耗 | |
| 1574 | + BigDecimal bgl= new BigDecimal(0); | |
| 1575 | + if(Double.parseDouble(realMileage)!=0){ | |
| 1576 | + bgl=total.divide(new BigDecimal(realMileage), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); | |
| 1577 | + } | |
| 1578 | + row.put("bgl", bgl); | |
| 1579 | + result.add(row); | |
| 1580 | + } | |
| 1581 | + resultMap.put("data",result); | |
| 1582 | + resultMap.put("stations",stations); | |
| 1583 | + return resultMap; | |
| 1584 | + } | |
| 1585 | + | |
| 1586 | + public Map<String, Object> queryDcMouthExport(Map<String,String> map, HttpServletResponse response){ | |
| 1587 | + Map<String, Object> resultMap = new HashMap<>(); | |
| 1588 | + try { | |
| 1589 | + Map<String, Object> params=new HashMap<>(); | |
| 1590 | + Map<String,Object> result=queryDcMouth(map); | |
| 1591 | + List<String> titleList = new ArrayList<>(); | |
| 1592 | + titleList.add("序号"); | |
| 1593 | + titleList.add("车牌"); | |
| 1594 | + titleList.add("自编号"); | |
| 1595 | + titleList.add("充电合计"); | |
| 1596 | + titleList.add("公里"); | |
| 1597 | + titleList.add("度/百公里"); | |
| 1598 | + List<String> stations = (List<String>) result.get("stations"); | |
| 1599 | + for (String station : stations) { | |
| 1600 | + titleList.add(station); | |
| 1601 | + } | |
| 1602 | + params.put("title",titleList); | |
| 1603 | + | |
| 1604 | + Map<String,List<String>> content = new HashMap<>(); | |
| 1605 | + List<Map<String, Object>> datas = (List<Map<String, Object>>) result.get("data"); | |
| 1606 | + for (int i = 1; i <= datas.size(); i++) { | |
| 1607 | + Map<String, Object> d=datas.get(i-1); | |
| 1608 | + List<String> list=new ArrayList<>(); | |
| 1609 | + list.add(String.valueOf(i)); | |
| 1610 | + list.add(String.valueOf(d.get("plate"))); | |
| 1611 | + list.add(String.valueOf(d.get("car"))); | |
| 1612 | + list.add(String.valueOf(d.get("total"))); | |
| 1613 | + list.add(String.valueOf(d.get("zgl"))); | |
| 1614 | + list.add(String.valueOf(d.get("bgl"))); | |
| 1615 | + List<Double> refuels= (List<Double>) d.get("refuels"); | |
| 1616 | + for (Double refuel : refuels) { | |
| 1617 | + list.add(String.valueOf(refuel)); | |
| 1618 | + } | |
| 1619 | + content.put(String.valueOf(i),list); | |
| 1620 | + } | |
| 1621 | + params.put("content",content); | |
| 1622 | + ExcelUtil.buildExcelDocument(params,"充电量月报表",response); | |
| 1623 | + resultMap.put("status", ResponseCode.SUCCESS); | |
| 1624 | + } catch (Exception e) { | |
| 1625 | + resultMap.put("status", ResponseCode.ERROR); | |
| 1626 | + logger.error("save erro.", e); | |
| 1627 | + } | |
| 1628 | + return resultMap; | |
| 1629 | + } | |
| 1630 | + | |
| 1477 | 1631 | } | ... | ... |
src/main/java/com/bsth/util/ExcelUtil.java
| ... | ... | @@ -26,7 +26,7 @@ import org.apache.poi.hssf.util.HSSFColor; |
| 26 | 26 | public class ExcelUtil { |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - public void buildExcelDocument(Map<String, Object> map, String exportName, HttpServletResponse response) throws Exception { | |
| 29 | + public static void buildExcelDocument(Map<String, Object> map, String exportName, HttpServletResponse response) throws Exception { | |
| 30 | 30 | // 声明一个工作薄 |
| 31 | 31 | HSSFWorkbook workbook = new HSSFWorkbook(); |
| 32 | 32 | /* // 生成一个表格 |
| ... | ... | @@ -64,13 +64,13 @@ public class ExcelUtil { |
| 64 | 64 | //创建第一行 |
| 65 | 65 | HSSFRow row = sheet.createRow(0); |
| 66 | 66 | //设置 ABCD列名 |
| 67 | - sheet.autoSizeColumn((short)0); | |
| 67 | + | |
| 68 | 68 | for(int i=0;i<titleList.size();i++){ |
| 69 | 69 | row.createCell(i).setCellValue(titleList.get(i)); |
| 70 | 70 | row.setRowStyle(cellStyle); |
| 71 | 71 | } |
| 72 | + sheet.autoSizeColumn((short)0); | |
| 72 | 73 | for(int i=1;i<=content.size();i++){ |
| 73 | - sheet.autoSizeColumn((short)i); //调整第一列宽度 | |
| 74 | 74 | HSSFRow row_ = sheet.createRow(i); |
| 75 | 75 | List<String> temp = content.get(i+""); |
| 76 | 76 | for(int j=0;j<temp.size();j++){ | ... | ... |
src/main/resources/static/pages/forms/statement/refuelDcMouth.html
0 → 100644
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; } | |
| 11 | + .table-bordered > thead > tr > th, | |
| 12 | + .table-bordered > thead > tr > td { | |
| 13 | + border-bottom-width: 2px; } | |
| 14 | + | |
| 15 | + .table > tbody + tbody { | |
| 16 | + border-top: 1px solid; } | |
| 17 | + .btn-default{ | |
| 18 | + margin-left: 5px; | |
| 19 | + } | |
| 20 | +</style> | |
| 21 | + | |
| 22 | +<div class="page-head"> | |
| 23 | + <div class="page-title"> | |
| 24 | + <h1>充电量月报表</h1> | |
| 25 | + </div> | |
| 26 | +</div> | |
| 27 | + | |
| 28 | +<div class="row"> | |
| 29 | + <div class="col-md-12"> | |
| 30 | + <div class="portlet light porttlet-fit bordered"> | |
| 31 | + <div class="portlet-title"> | |
| 32 | + <form class="form-inline" action=""> | |
| 33 | + <div style="display: inline-block;margin-left: 15px;"> | |
| 34 | + <span class="item-label" style="width: 80px;">开始时间: </span> | |
| 35 | + <input class="form-control" type="text" id="dateS" style="width: 180px;"/> | |
| 36 | + <span class="item-label" style="width: 80px;">结束时间: </span> | |
| 37 | + <input class="form-control" type="text" id="dateE" style="width: 180px;"/> | |
| 38 | + </div> | |
| 39 | + <div class="form-group"> | |
| 40 | + <input class="btn btn-default" type="button" id="query" value="筛选"/> | |
| 41 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 42 | + </div> | |
| 43 | + </form> | |
| 44 | + </div> | |
| 45 | + <div class="portlet-body"> | |
| 46 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | |
| 47 | + <table class="table table-bordered table-hover table-checkable" id="forms"> | |
| 48 | + <thead> | |
| 49 | + <tr> | |
| 50 | + <td width="3%">序号</td> | |
| 51 | + <td width="7%">车牌</td> | |
| 52 | + <td width="7%">自编号</td> | |
| 53 | + <td>充电合计</td> | |
| 54 | + <td>公里</td> | |
| 55 | + <td id="bgl">度/百公里</td> | |
| 56 | + </tr> | |
| 57 | + </thead> | |
| 58 | + <tbody id="tbody"> | |
| 59 | + | |
| 60 | + </tbody> | |
| 61 | + </table> | |
| 62 | + </div> | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </div> | |
| 66 | +</div> | |
| 67 | + | |
| 68 | +<script> | |
| 69 | + $(function(){ | |
| 70 | + | |
| 71 | + // 关闭左侧栏 | |
| 72 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 73 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 74 | + | |
| 75 | + //日期插件 | |
| 76 | + $("#dateS").datetimepicker({ | |
| 77 | + format : 'YYYY-MM', | |
| 78 | + locale : 'zh-cn' | |
| 79 | + }); | |
| 80 | + $("#dateE").datetimepicker({ | |
| 81 | + format : 'YYYY-MM', | |
| 82 | + locale : 'zh-cn' | |
| 83 | + }); | |
| 84 | + | |
| 85 | + //重置 | |
| 86 | + $('#czcl').on('click', function () { | |
| 87 | + $('#code').val('').change(); | |
| 88 | + }); | |
| 89 | + | |
| 90 | + | |
| 91 | + $("#query").on("click",function(){ | |
| 92 | + var dateS = $("#dateS").val(); | |
| 93 | + var dateE = $("#dateE").val(); | |
| 94 | + if(dateS==""||dateS==null||dateE==""||dateE==null){ | |
| 95 | + layer.msg('请选择日期.'); | |
| 96 | + return; | |
| 97 | + } | |
| 98 | + dateS+="-01" | |
| 99 | + dateE+="-31" | |
| 100 | + var i = layer.load(2); | |
| 101 | + $get('/refuel/queryDcMouth',{dateS:dateS,dateE:dateE,type:'query'},function(result){ | |
| 102 | + const tr = document.querySelector('tr'); | |
| 103 | + const dynamicCols = tr.querySelectorAll('.dynamic-col'); | |
| 104 | + dynamicCols.forEach(col => col.remove()); | |
| 105 | + const totalTd = document.getElementById('bgl'); | |
| 106 | + // 生成所有新的td元素HTML | |
| 107 | + const newTdsHTML = result.stations.map(item => | |
| 108 | + `<td class="dynamic-col">${item}</td>` | |
| 109 | + ).join(''); | |
| 110 | + // 在总计td后插入 | |
| 111 | + totalTd.insertAdjacentHTML('afterend', newTdsHTML); | |
| 112 | + | |
| 113 | + // 把数据填充到模版中 | |
| 114 | + var tbodyHtml = template('refuel_dc',{list:result.data}); | |
| 115 | + // 把渲染好的模版html文本追加到表格中 | |
| 116 | + $('#tbody').html(tbodyHtml); | |
| 117 | + layer.close(i); | |
| 118 | + }); | |
| 119 | + }); | |
| 120 | + | |
| 121 | + $("#export").on("click",function(){ | |
| 122 | + var dateS = $("#dateS").val(); | |
| 123 | + var dateE = $("#dateE").val(); | |
| 124 | + if(dateS==""||dateS==null||dateE==""||dateE==null){ | |
| 125 | + layer.msg('请选择日期.'); | |
| 126 | + return; | |
| 127 | + } | |
| 128 | + dateS+="-01" | |
| 129 | + dateE+="-31" | |
| 130 | + window.open('/refuel/queryDcMouthExport?dateS='+dateS+'&dateE='+dateE); | |
| 131 | + }); | |
| 132 | + | |
| 133 | +}); | |
| 134 | +</script> | |
| 135 | +<script type="text/html" id="refuel_dc"> | |
| 136 | + {{each list as obj i}} | |
| 137 | + <tr> | |
| 138 | + <td>{{i + 1}}</td> | |
| 139 | + <td>{{obj.plate}}</td> | |
| 140 | + <td>{{obj.car}}</td> | |
| 141 | + <td>{{obj.total}}</td> | |
| 142 | + <td>{{obj.zgl}}</td> | |
| 143 | + <td>{{obj.bgl}}</td> | |
| 144 | + {{each obj.refuels as refuel j}} | |
| 145 | + <td>{{refuel}}</td> | |
| 146 | + {{/each}} | |
| 147 | + </tr> | |
| 148 | + {{/each}} | |
| 149 | + {{if list.length == 0}} | |
| 150 | + <tr>1 | |
| 151 | + <td colspan="17"><h6 class="muted">没有找到相关数据</h6></td> | |
| 152 | + </tr> | |
| 153 | + {{/if}} | |
| 154 | +</script> | |
| 0 | 155 | \ No newline at end of file | ... | ... |