Commit 461ec576c8b2131220aaece3a1ba11b88665eeb6

Authored by yiming
1 parent 4be34257

bf

bsthLineProfiles/pom.xml
@@ -305,6 +305,16 @@ @@ -305,6 +305,16 @@
305 <artifactId>junit</artifactId> 305 <artifactId>junit</artifactId>
306 <version>4.12</version> 306 <version>4.12</version>
307 </dependency> 307 </dependency>
  308 + <dependency>
  309 + <groupId>cn.hutool</groupId>
  310 + <artifactId>hutool-all</artifactId>
  311 + <version>5.7.12</version>
  312 + </dependency>
  313 + <dependency>
  314 + <groupId>org.apache.poi</groupId>
  315 + <artifactId>poi-ooxml</artifactId>
  316 + <version>4.1.2</version>
  317 + </dependency>
308 </dependencies> 318 </dependencies>
309 319
310 <build> 320 <build>
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/controller/BsthTLineHistoryReportController.java
1 package com.ruoyi.project.system.line.controller; 1 package com.ruoyi.project.system.line.controller;
2 2
  3 +import java.io.IOException;
  4 +import java.io.OutputStream;
3 import java.lang.reflect.Constructor; 5 import java.lang.reflect.Constructor;
4 import java.lang.reflect.Field; 6 import java.lang.reflect.Field;
5 import java.lang.reflect.Method; 7 import java.lang.reflect.Method;
  8 +import java.net.URLEncoder;
  9 +import java.nio.charset.StandardCharsets;
6 import java.text.SimpleDateFormat; 10 import java.text.SimpleDateFormat;
  11 +import java.time.LocalDateTime;
7 import java.util.ArrayList; 12 import java.util.ArrayList;
8 import java.util.Date; 13 import java.util.Date;
9 import java.util.HashMap; 14 import java.util.HashMap;
10 import java.util.List; 15 import java.util.List;
11 import java.util.Map; 16 import java.util.Map;
  17 +import java.util.stream.Collectors;
12 18
  19 +import cn.hutool.core.collection.CollUtil;
  20 +import cn.hutool.core.io.IoUtil;
  21 +import cn.hutool.poi.excel.ExcelWriter;
  22 +import cn.hutool.poi.excel.StyleSet;
  23 +import com.ruoyi.project.system.line.domain.Export;
  24 +import org.apache.poi.*;
13 import com.ruoyi.common.utils.poi.ExcelUtil; 25 import com.ruoyi.common.utils.poi.ExcelUtil;
14 import com.ruoyi.project.system.line.domain.LineHistoryReport; 26 import com.ruoyi.project.system.line.domain.LineHistoryReport;
  27 +import org.apache.poi.ss.usermodel.*;
15 import org.apache.shiro.authz.annotation.RequiresPermissions; 28 import org.apache.shiro.authz.annotation.RequiresPermissions;
16 import org.springframework.beans.factory.annotation.Autowired; 29 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.stereotype.Controller; 30 import org.springframework.stereotype.Controller;
@@ -38,6 +51,9 @@ import com.ruoyi.project.system.user.domain.User; @@ -38,6 +51,9 @@ import com.ruoyi.project.system.user.domain.User;
38 import com.ruoyi.project.system.user.service.IUserService; 51 import com.ruoyi.project.system.user.service.IUserService;
39 import com.ruoyi.project.utils.ExcelUtils; 52 import com.ruoyi.project.utils.ExcelUtils;
40 53
  54 +import javax.servlet.ServletOutputStream;
  55 +import javax.servlet.http.HttpServletResponse;
  56 +
41 @Controller 57 @Controller
42 @RequestMapping("/system/historyReport") 58 @RequestMapping("/system/historyReport")
43 public class BsthTLineHistoryReportController extends BaseController 59 public class BsthTLineHistoryReportController extends BaseController
@@ -70,11 +86,9 @@ public class BsthTLineHistoryReportController extends BaseController @@ -70,11 +86,9 @@ public class BsthTLineHistoryReportController extends BaseController
70 public TableDataInfo list(BsthTLine bsthTLine) 86 public TableDataInfo list(BsthTLine bsthTLine)
71 { 87 {
72 startPage(); 88 startPage();
73 - bsthTLine.setHistoryId(1L);  
74 List<BsthTLine> list = bsthTLineService.selectBsthTLineHistoryList(bsthTLine); 89 List<BsthTLine> list = bsthTLineService.selectBsthTLineHistoryList(bsthTLine);
75 return getDataTable(list); 90 return getDataTable(list);
76 } 91 }
77 -  
78 92
79 @RequiresPermissions("system:HistoryReport:export") 93 @RequiresPermissions("system:HistoryReport:export")
80 @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) 94 @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@@ -180,6 +194,256 @@ public class BsthTLineHistoryReportController extends BaseController @@ -180,6 +194,256 @@ public class BsthTLineHistoryReportController extends BaseController
180 return util.exportExcel(list, "line"); 194 return util.exportExcel(list, "line");
181 } 195 }
182 196
  197 +
  198 +
  199 + @RequiresPermissions("system:HistoryReport:export2")
  200 + @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
  201 + @RequestMapping("/export2")
  202 + @ResponseBody
  203 + public void export(HttpServletResponse response,BsthTLine bsthTLine) throws NoSuchFieldException {
  204 +
  205 + //查询变更记录
  206 + List<LineHistoryReport> list =bsthTLineService.getLineHistoryReport(bsthTLine);
  207 +
  208 + List<DictData> dicts = dictDataService.selectDictDataList(null);
  209 + Map<String,List<DictData>> dictMap = new HashMap();
  210 + List<String> titles=new ArrayList<>();
  211 + for(DictData d : dicts) {
  212 + if(dictMap.get(d.getDictType()) == null) {
  213 + dictMap.put(d.getDictType(), new ArrayList<DictData>());
  214 + }
  215 + dictMap.get(d.getDictType()).add(d);
  216 + }
  217 +
  218 + try {
  219 + for(LineHistoryReport line:list) {
  220 + Field[] field = line.getClass().getDeclaredFields();
  221 + for(int j=0 ; j<field.length ; j++){ //遍历所有属性
  222 + String name = field[j].getName(); //获取属性的名字
  223 + if(name.length()>3&&!"Old".equals(name.substring(name.length()-3))&&!"lineName".equals(name)){
  224 + //获取变更前后的值
  225 + Field f = line.getClass().getDeclaredField(name);
  226 + Field f2 = line.getClass().getDeclaredField(name+"Old");
  227 + f.setAccessible(true);
  228 + f2.setAccessible(true);
  229 + f.get(line);
  230 + String v =f.get(line)==null?"":f.get(line).toString();
  231 + String vo=f2.get(line)==null?"":f2.get(line).toString();
  232 + //如果没变置空
  233 +// if(v.equals(vo)){
  234 +// f.set(line, null);
  235 +// f2.set(line, null);
  236 +// }
  237 + //编码转换
  238 + if(dictMap.get(name) != null) {
  239 + if(v != null && v.split(",").length > 0) {
  240 + String result = "";
  241 + for(String str:v.split(",")) {
  242 + for(DictData d:dictMap.get(name)) {
  243 + if(d.getDictValue().equals(str)) {
  244 + result += d.getDictLabel() + ",";
  245 + }
  246 + }
  247 + }
  248 + if(!result.isEmpty()) {
  249 + f.set(line, result.substring(0,result.length()-1));
  250 + }else {
  251 + f.set(line, v);
  252 + }
  253 + }
  254 + if(vo != null && vo.split(",").length > 0) {
  255 + String result = "";
  256 + for(String str:vo.split(",")) {
  257 + for(DictData d:dictMap.get(name)) {
  258 + if(d.getDictValue().equals(str)) {
  259 + result += d.getDictLabel() + ",";
  260 + }
  261 + }
  262 + }
  263 + if(!result.isEmpty()) {
  264 + f2.set(line, result.substring(0,result.length()-1));
  265 + }else {
  266 + f2.set(line, vo);
  267 + }
  268 + }
  269 + }
  270 + if("inoutDistrict".equals(name)||"isWarrant".equals(name)||"isMetro".equals(name)||"hasTimelists".equals(name)){
  271 + if(!"".equals(v)){
  272 + for(DictData d:dictMap.get("trueFalse")) {
  273 + if(d.getDictValue().equals(v)) {
  274 + f.set(line, d.getDictLabel());
  275 + }
  276 + }
  277 + }
  278 + if(!"".equals(vo)){
  279 + for(DictData d:dictMap.get("trueFalse")) {
  280 + if(d.getDictValue().equals(vo)) {
  281 + f2.set(line, d.getDictLabel());
  282 + }
  283 + }
  284 + }
  285 + }
  286 + }
  287 + }
  288 + }
  289 + } catch (Exception e) {
  290 + // TODO Auto-generated catch block
  291 + e.printStackTrace();
  292 + }
  293 + //设置列名
  294 + ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriterWithSheet("统计");
  295 + Sheet sheet = writer.getSheet();
  296 + //设置默认样式
  297 + Font font=ExcelUtils.setBaseFont(writer.getWorkbook(),false,false,"宋体",10);
  298 + ExcelUtils.GlobalStyleSet(writer,font);
  299 + //跳过3行做列名
  300 + writer.passCurrentRow();
  301 + writer.passCurrentRow();
  302 + writer.passCurrentRow();
  303 + //设置列名
  304 + writer.merge(0,0,0,13, "2021年1月1日起至今延辟调线路情况",true);
  305 + writer.setRowHeight(0,30);
  306 + writer.merge(1,2,0,0,"单位",false);
  307 + writer.merge(1,2,1,1,"序号",false);
  308 + writer.merge(1,2,2,2,"类别",false);
  309 + writer.merge(1,2,3,3,"线路",false);
  310 + writer.merge(1,2,4,4,"实施日期",false);
  311 + writer.merge(1,1,5,7,"调整类别",false);
  312 + writer.writeCellValue(5,2,"新辟");
  313 + writer.writeCellValue(6,2,"调整(分为:缩线、延伸、调整、增能、减能、调整首末班、增加班次、减少班次)");
  314 + writer.setRowHeight(2,60);
  315 + writer.writeCellValue(7,2,"撤销");
  316 + writer.merge(1,2,8,8,"合计",false);
  317 + writer.merge(1,2,9,9,"理由(备注)",false);
  318 + writer.merge(1,1,10,11,"调整前",false);
  319 + writer.writeCellValue(10,2,"配车");
  320 + writer.writeCellValue(11,2,"劳动力");
  321 + writer.merge(1,1,12,13,"调整后",false);
  322 + writer.writeCellValue(12,2,"配车");
  323 + writer.writeCellValue(13,2,"劳动力");
  324 +
  325 + //数据处理
  326 + Map<String,List<LineHistoryReport>>map= list.stream().collect(Collectors.groupingBy(LineHistoryReport::getCompany));
  327 +
  328 + int rowIndex=3;
  329 + //合计计数
  330 + long xpAll=0;
  331 + long tzAll=0;
  332 + long cxAll=0;
  333 + long xtcAll=0;
  334 + long pcAll=0;
  335 + long ldlAll=0;
  336 + long pcoAll=0;
  337 + long ldloAll=0;
  338 +
  339 + for(String k : map.keySet()){
  340 + List<LineHistoryReport> ll=map.get(k);
  341 + List<Export> list1=new ArrayList();
  342 + //小计计数
  343 + long xp=0;
  344 + long tz=0;
  345 + long cx=0;
  346 + long xtc=0;
  347 + long pc=0;
  348 + long ldl=0;
  349 + long pco=0;
  350 + long ldlo=0;
  351 + int i=1;
  352 + for (LineHistoryReport lineHistoryReport : ll) {
  353 + Export export=new Export();
  354 + export.setLine1(lineHistoryReport.getCompany());//单位
  355 + writer.setColumnWidth(0,25);
  356 + export.setLine2(String.valueOf(i));//序号
  357 + writer.setColumnWidth(1,10);
  358 + i++;
  359 + export.setLine3(lineHistoryReport.getLineLevel());//类别
  360 + writer.setColumnWidth(2,20);
  361 + export.setLine4(lineHistoryReport.getLineName());//线路
  362 + writer.setColumnWidth(3,20);
  363 + Date date=lineHistoryReport.getStartDate();
  364 + SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
  365 + export.setLine5( simpleDateFormat.format(date));//实施日期
  366 + writer.setColumnWidth(4,20);
  367 + if("新辟".equals(lineHistoryReport.getLineUpdateType())){
  368 + export.setLine6(lineHistoryReport.getLineUpdateType());//新辟
  369 + writer.setColumnWidth(5,20);
  370 + xp++;
  371 + }else if("撤销".equals(lineHistoryReport.getLineUpdateType())){
  372 + export.setLine8(lineHistoryReport.getLineUpdateType());//撤销
  373 + writer.setColumnWidth(7,20);
  374 + cx++;
  375 + }else {
  376 + export.setLine7(lineHistoryReport.getLineUpdateType());//调整
  377 + writer.setColumnWidth(6,20);
  378 + tz++;
  379 + }
  380 + writer.setColumnWidth(8,20);
  381 + export.setLine10(lineHistoryReport.getRemark());
  382 + writer.setColumnWidth(9,20);
  383 + long count=lineHistoryReport.getWarrantVehiclesLarge()+lineHistoryReport.getWarrantVehiclesMiddle()+lineHistoryReport.getVehiclesNumber()+
  384 + lineHistoryReport.getNumberVehiclesLarge()+lineHistoryReport.getNumberVehiclesMiddle();
  385 + pc+=count;
  386 + long countOld=lineHistoryReport.getWarrantVehiclesLargeOld()+lineHistoryReport.getWarrantVehiclesMiddleOld()+lineHistoryReport.getVehiclesNumberOld()+
  387 + lineHistoryReport.getNumberVehiclesLargeOld()+lineHistoryReport.getNumberVehiclesMiddleOld();
  388 + pco+=countOld;
  389 + export.setLine11(String.valueOf(count));
  390 + writer.setColumnWidth(10,10);
  391 + export.setLine12(String.valueOf(lineHistoryReport.getNumberPersonDriver()));
  392 + writer.setColumnWidth(11,10);
  393 + ldl+=lineHistoryReport.getNumberPersonDriver();
  394 + export.setLine13(String.valueOf(countOld));
  395 + writer.setColumnWidth(12,10);
  396 + export.setLine14(String.valueOf(lineHistoryReport.getNumberPersonDriverOld()));
  397 + writer.setColumnWidth(13,10);
  398 + ldlo+=lineHistoryReport.getNumberPersonDriverOld();
  399 + list1.add(export);
  400 + rowIndex++;
  401 + }
  402 +
  403 + Export export=new Export();
  404 + export.setLine2("小计");
  405 + export.setLine6(String.valueOf(xp));
  406 + xpAll+=xp;
  407 + export.setLine7(String.valueOf(tz));
  408 + tzAll+=tz;
  409 + export.setLine8(String.valueOf(cx));
  410 + cxAll+=cx;
  411 + xtc=xp+tz+cx;
  412 + xtcAll+=xtc;
  413 + export.setLine9(String.valueOf(xtc));
  414 + export.setLine11(String.valueOf(pc));
  415 + pcAll+=pc;
  416 + export.setLine12(String.valueOf(ldl));
  417 + ldlAll+=ldl;
  418 + export.setLine13(String.valueOf(pco));
  419 + pcoAll+=pco;
  420 + export.setLine14(String.valueOf(ldlo));
  421 + ldloAll+=ldlo;
  422 + list1.add(export);
  423 + //写入sheet
  424 + writer.write(list1, false);
  425 + //加背景色
  426 + ExcelUtils.setBackground(writer,IndexedColors.SEA_GREEN.getIndex(),rowIndex,writer.getColumnCount());
  427 + rowIndex++;
  428 + }
  429 + Export export=new Export();
  430 + export.setLine1("合计");
  431 + export.setLine6(String.valueOf(xpAll));
  432 + export.setLine7(String.valueOf(tzAll));
  433 + export.setLine8(String.valueOf(cxAll));
  434 + export.setLine9(String.valueOf(xtcAll));
  435 + export.setLine11(String.valueOf(pcAll));
  436 + export.setLine12(String.valueOf(ldlAll));
  437 + export.setLine13(String.valueOf(pcoAll));
  438 + export.setLine14(String.valueOf(ldloAll));
  439 + List<Export> result=new ArrayList();
  440 + result.add(export);
  441 + writer.write(result, false);
  442 + //设置行高
  443 + ExcelUtils.setHeight(writer, (short) 2);
  444 + ExcelUtils.downloadExcel(response,"变更报表",writer);
  445 + }
  446 +
183 public static Object getObjectField(Field field,String valueStr) throws Exception{ 447 public static Object getObjectField(Field field,String valueStr) throws Exception{
184 Class typeClass = field.getType(); 448 Class typeClass = field.getType();
185 Constructor con = typeClass.getConstructor(valueStr.getClass()); 449 Constructor con = typeClass.getConstructor(valueStr.getClass());
@@ -187,7 +451,4 @@ public class BsthTLineHistoryReportController extends BaseController @@ -187,7 +451,4 @@ public class BsthTLineHistoryReportController extends BaseController
187 return obj; 451 return obj;
188 } 452 }
189 453
190 - public static void main(String[] args) {  
191 -  
192 - }  
193 } 454 }
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/domain/Export.java 0 → 100644
  1 +package com.ruoyi.project.system.line.domain;
  2 +
  3 +public class Export {
  4 + private String line1;
  5 + private String line2;
  6 + private String line3;
  7 + private String line4;
  8 + private String line5;
  9 + private String line6;
  10 + private String line7;
  11 + private String line8;
  12 + private String line9;
  13 + private String line10;
  14 + private String line11;
  15 + private String line12;
  16 + private String line13;
  17 + private String line14;
  18 +
  19 + public String getLine1() {
  20 + return line1;
  21 + }
  22 +
  23 + public void setLine1(String line1) {
  24 + this.line1 = line1;
  25 + }
  26 +
  27 + public String getLine2() {
  28 + return line2;
  29 + }
  30 +
  31 + public void setLine2(String line2) {
  32 + this.line2 = line2;
  33 + }
  34 +
  35 + public String getLine3() {
  36 + return line3;
  37 + }
  38 +
  39 + public void setLine3(String line3) {
  40 + this.line3 = line3;
  41 + }
  42 +
  43 + public String getLine4() {
  44 + return line4;
  45 + }
  46 +
  47 + public void setLine4(String line4) {
  48 + this.line4 = line4;
  49 + }
  50 +
  51 + public String getLine5() {
  52 + return line5;
  53 + }
  54 +
  55 + public void setLine5(String line5) {
  56 + this.line5 = line5;
  57 + }
  58 +
  59 + public String getLine6() {
  60 + return line6;
  61 + }
  62 +
  63 + public void setLine6(String line6) {
  64 + this.line6 = line6;
  65 + }
  66 +
  67 + public String getLine7() {
  68 + return line7;
  69 + }
  70 +
  71 + public void setLine7(String line7) {
  72 + this.line7 = line7;
  73 + }
  74 +
  75 + public String getLine8() {
  76 + return line8;
  77 + }
  78 +
  79 + public void setLine8(String line8) {
  80 + this.line8 = line8;
  81 + }
  82 +
  83 + public String getLine9() {
  84 + return line9;
  85 + }
  86 +
  87 + public void setLine9(String line9) {
  88 + this.line9 = line9;
  89 + }
  90 +
  91 + public String getLine10() {
  92 + return line10;
  93 + }
  94 +
  95 + public void setLine10(String line10) {
  96 + this.line10 = line10;
  97 + }
  98 +
  99 + public String getLine11() {
  100 + return line11;
  101 + }
  102 +
  103 + public void setLine11(String line11) {
  104 + this.line11 = line11;
  105 + }
  106 +
  107 + public String getLine12() {
  108 + return line12;
  109 + }
  110 +
  111 + public void setLine12(String line12) {
  112 + this.line12 = line12;
  113 + }
  114 +
  115 + public String getLine13() {
  116 + return line13;
  117 + }
  118 +
  119 + public void setLine13(String line13) {
  120 + this.line13 = line13;
  121 + }
  122 +
  123 + public String getLine14() {
  124 + return line14;
  125 + }
  126 +
  127 + public void setLine14(String line14) {
  128 + this.line14 = line14;
  129 + }
  130 +}
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/domain/LineHistoryReport.java
@@ -1098,7 +1098,7 @@ public class LineHistoryReport extends BaseEntity @@ -1098,7 +1098,7 @@ public class LineHistoryReport extends BaseEntity
1098 } 1098 }
1099 1099
1100 public Long getWarrantVehiclesLarge() { 1100 public Long getWarrantVehiclesLarge() {
1101 - return warrantVehiclesLarge; 1101 + return warrantVehiclesLarge==null?0:warrantVehiclesLarge;
1102 } 1102 }
1103 1103
1104 public void setWarrantVehiclesLarge(Long warrantVehiclesLarge) { 1104 public void setWarrantVehiclesLarge(Long warrantVehiclesLarge) {
@@ -1106,7 +1106,7 @@ public class LineHistoryReport extends BaseEntity @@ -1106,7 +1106,7 @@ public class LineHistoryReport extends BaseEntity
1106 } 1106 }
1107 1107
1108 public Long getWarrantVehiclesLargeOld() { 1108 public Long getWarrantVehiclesLargeOld() {
1109 - return warrantVehiclesLargeOld; 1109 + return warrantVehiclesLargeOld==null?0:warrantVehiclesLargeOld;
1110 } 1110 }
1111 1111
1112 public void setWarrantVehiclesLargeOld(Long warrantVehiclesLargeOld) { 1112 public void setWarrantVehiclesLargeOld(Long warrantVehiclesLargeOld) {
@@ -1114,7 +1114,7 @@ public class LineHistoryReport extends BaseEntity @@ -1114,7 +1114,7 @@ public class LineHistoryReport extends BaseEntity
1114 } 1114 }
1115 1115
1116 public Long getWarrantVehiclesMiddle() { 1116 public Long getWarrantVehiclesMiddle() {
1117 - return warrantVehiclesMiddle; 1117 + return warrantVehiclesMiddle==null?0:warrantVehiclesMiddle;
1118 } 1118 }
1119 1119
1120 public void setWarrantVehiclesMiddle(Long warrantVehiclesMiddle) { 1120 public void setWarrantVehiclesMiddle(Long warrantVehiclesMiddle) {
@@ -1122,7 +1122,7 @@ public class LineHistoryReport extends BaseEntity @@ -1122,7 +1122,7 @@ public class LineHistoryReport extends BaseEntity
1122 } 1122 }
1123 1123
1124 public Long getWarrantVehiclesMiddleOld() { 1124 public Long getWarrantVehiclesMiddleOld() {
1125 - return warrantVehiclesMiddleOld; 1125 + return warrantVehiclesMiddleOld==null?0:warrantVehiclesMiddleOld;
1126 } 1126 }
1127 1127
1128 public void setWarrantVehiclesMiddleOld(Long warrantVehiclesMiddleOld) { 1128 public void setWarrantVehiclesMiddleOld(Long warrantVehiclesMiddleOld) {
@@ -1130,7 +1130,7 @@ public class LineHistoryReport extends BaseEntity @@ -1130,7 +1130,7 @@ public class LineHistoryReport extends BaseEntity
1130 } 1130 }
1131 1131
1132 public Long getVehiclesNumber() { 1132 public Long getVehiclesNumber() {
1133 - return vehiclesNumber; 1133 + return vehiclesNumber==null?0:vehiclesNumber;
1134 } 1134 }
1135 1135
1136 public void setVehiclesNumber(Long vehiclesNumber) { 1136 public void setVehiclesNumber(Long vehiclesNumber) {
@@ -1138,7 +1138,7 @@ public class LineHistoryReport extends BaseEntity @@ -1138,7 +1138,7 @@ public class LineHistoryReport extends BaseEntity
1138 } 1138 }
1139 1139
1140 public Long getVehiclesNumberOld() { 1140 public Long getVehiclesNumberOld() {
1141 - return vehiclesNumberOld; 1141 + return vehiclesNumberOld==null?0:vehiclesNumberOld;
1142 } 1142 }
1143 1143
1144 public void setVehiclesNumberOld(Long vehiclesNumberOld) { 1144 public void setVehiclesNumberOld(Long vehiclesNumberOld) {
@@ -1146,7 +1146,7 @@ public class LineHistoryReport extends BaseEntity @@ -1146,7 +1146,7 @@ public class LineHistoryReport extends BaseEntity
1146 } 1146 }
1147 1147
1148 public Long getNumberVehiclesLarge() { 1148 public Long getNumberVehiclesLarge() {
1149 - return numberVehiclesLarge; 1149 + return numberVehiclesLarge==null?0:numberVehiclesLarge;
1150 } 1150 }
1151 1151
1152 public void setNumberVehiclesLarge(Long numberVehiclesLarge) { 1152 public void setNumberVehiclesLarge(Long numberVehiclesLarge) {
@@ -1154,7 +1154,7 @@ public class LineHistoryReport extends BaseEntity @@ -1154,7 +1154,7 @@ public class LineHistoryReport extends BaseEntity
1154 } 1154 }
1155 1155
1156 public Long getNumberVehiclesLargeOld() { 1156 public Long getNumberVehiclesLargeOld() {
1157 - return numberVehiclesLargeOld; 1157 + return numberVehiclesLargeOld==null?0:numberVehiclesLargeOld;
1158 } 1158 }
1159 1159
1160 public void setNumberVehiclesLargeOld(Long numberVehiclesLargeOld) { 1160 public void setNumberVehiclesLargeOld(Long numberVehiclesLargeOld) {
@@ -1162,7 +1162,7 @@ public class LineHistoryReport extends BaseEntity @@ -1162,7 +1162,7 @@ public class LineHistoryReport extends BaseEntity
1162 } 1162 }
1163 1163
1164 public Long getNumberVehiclesMiddle() { 1164 public Long getNumberVehiclesMiddle() {
1165 - return numberVehiclesMiddle; 1165 + return numberVehiclesMiddle==null?0:numberVehiclesMiddle;
1166 } 1166 }
1167 1167
1168 public void setNumberVehiclesMiddle(Long numberVehiclesMiddle) { 1168 public void setNumberVehiclesMiddle(Long numberVehiclesMiddle) {
@@ -1170,7 +1170,7 @@ public class LineHistoryReport extends BaseEntity @@ -1170,7 +1170,7 @@ public class LineHistoryReport extends BaseEntity
1170 } 1170 }
1171 1171
1172 public Long getNumberVehiclesMiddleOld() { 1172 public Long getNumberVehiclesMiddleOld() {
1173 - return numberVehiclesMiddleOld; 1173 + return numberVehiclesMiddleOld==null?0:numberVehiclesMiddleOld;
1174 } 1174 }
1175 1175
1176 public void setNumberVehiclesMiddleOld(Long numberVehiclesMiddleOld) { 1176 public void setNumberVehiclesMiddleOld(Long numberVehiclesMiddleOld) {
@@ -1194,7 +1194,7 @@ public class LineHistoryReport extends BaseEntity @@ -1194,7 +1194,7 @@ public class LineHistoryReport extends BaseEntity
1194 } 1194 }
1195 1195
1196 public Long getNumberPerson() { 1196 public Long getNumberPerson() {
1197 - return numberPerson; 1197 + return numberPerson==null?0:numberPerson;
1198 } 1198 }
1199 1199
1200 public void setNumberPerson(Long numberPerson) { 1200 public void setNumberPerson(Long numberPerson) {
@@ -1202,7 +1202,7 @@ public class LineHistoryReport extends BaseEntity @@ -1202,7 +1202,7 @@ public class LineHistoryReport extends BaseEntity
1202 } 1202 }
1203 1203
1204 public Long getNumberPersonOld() { 1204 public Long getNumberPersonOld() {
1205 - return numberPersonOld; 1205 + return numberPersonOld==null?0:numberPersonOld;
1206 } 1206 }
1207 1207
1208 public void setNumberPersonOld(Long numberPersonOld) { 1208 public void setNumberPersonOld(Long numberPersonOld) {
@@ -1210,7 +1210,7 @@ public class LineHistoryReport extends BaseEntity @@ -1210,7 +1210,7 @@ public class LineHistoryReport extends BaseEntity
1210 } 1210 }
1211 1211
1212 public Long getNumberPersonDriver() { 1212 public Long getNumberPersonDriver() {
1213 - return numberPersonDriver; 1213 + return numberPersonDriver==null?0:numberPersonDriver;
1214 } 1214 }
1215 1215
1216 public void setNumberPersonDriver(Long numberPersonDriver) { 1216 public void setNumberPersonDriver(Long numberPersonDriver) {
@@ -1218,7 +1218,7 @@ public class LineHistoryReport extends BaseEntity @@ -1218,7 +1218,7 @@ public class LineHistoryReport extends BaseEntity
1218 } 1218 }
1219 1219
1220 public Long getNumberPersonDriverOld() { 1220 public Long getNumberPersonDriverOld() {
1221 - return numberPersonDriverOld; 1221 + return numberPersonDriverOld==null?0:numberPersonDriverOld;
1222 } 1222 }
1223 1223
1224 public void setNumberPersonDriverOld(Long numberPersonDriverOld) { 1224 public void setNumberPersonDriverOld(Long numberPersonDriverOld) {
@@ -1226,7 +1226,7 @@ public class LineHistoryReport extends BaseEntity @@ -1226,7 +1226,7 @@ public class LineHistoryReport extends BaseEntity
1226 } 1226 }
1227 1227
1228 public Long getNumberPersonSales() { 1228 public Long getNumberPersonSales() {
1229 - return numberPersonSales; 1229 + return numberPersonSales==null?0:numberPersonSales;
1230 } 1230 }
1231 1231
1232 public void setNumberPersonSales(Long numberPersonSales) { 1232 public void setNumberPersonSales(Long numberPersonSales) {
@@ -1234,7 +1234,7 @@ public class LineHistoryReport extends BaseEntity @@ -1234,7 +1234,7 @@ public class LineHistoryReport extends BaseEntity
1234 } 1234 }
1235 1235
1236 public Long getNumberPersonSalesOld() { 1236 public Long getNumberPersonSalesOld() {
1237 - return numberPersonSalesOld; 1237 + return numberPersonSalesOld==null?0:numberPersonSalesOld;
1238 } 1238 }
1239 1239
1240 public void setNumberPersonSalesOld(Long numberPersonSalesOld) { 1240 public void setNumberPersonSalesOld(Long numberPersonSalesOld) {
bsthLineProfiles/src/main/java/com/ruoyi/project/utils/ExcelUtils.java
@@ -3,11 +3,16 @@ package com.ruoyi.project.utils; @@ -3,11 +3,16 @@ package com.ruoyi.project.utils;
3 import java.io.File; 3 import java.io.File;
4 import java.io.FileInputStream; 4 import java.io.FileInputStream;
5 import java.io.FileOutputStream; 5 import java.io.FileOutputStream;
  6 +import java.io.IOException;
6 import java.lang.reflect.Method; 7 import java.lang.reflect.Method;
  8 +import java.nio.charset.StandardCharsets;
7 import java.text.SimpleDateFormat; 9 import java.text.SimpleDateFormat;
8 import java.util.Date; 10 import java.util.Date;
9 import java.util.List; 11 import java.util.List;
10 12
  13 +import cn.hutool.core.io.IoUtil;
  14 +import cn.hutool.poi.excel.ExcelWriter;
  15 +import cn.hutool.poi.excel.StyleSet;
11 import org.apache.poi.hssf.usermodel.HSSFCell; 16 import org.apache.poi.hssf.usermodel.HSSFCell;
12 import org.apache.poi.hssf.usermodel.HSSFRow; 17 import org.apache.poi.hssf.usermodel.HSSFRow;
13 import org.apache.poi.hssf.usermodel.HSSFSheet; 18 import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -16,7 +21,10 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -16,7 +21,10 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
16 21
17 import com.ruoyi.project.system.line.domain.BsthTLine; 22 import com.ruoyi.project.system.line.domain.BsthTLine;
18 import com.ruoyi.project.system.line.domain.LineEditReport; 23 import com.ruoyi.project.system.line.domain.LineEditReport;
  24 +import org.apache.poi.ss.usermodel.*;
19 25
  26 +import javax.servlet.ServletOutputStream;
  27 +import javax.servlet.http.HttpServletResponse;
20 28
21 public class ExcelUtils { 29 public class ExcelUtils {
22 30
@@ -178,4 +186,97 @@ public class ExcelUtils { @@ -178,4 +186,97 @@ public class ExcelUtils {
178 } 186 }
179 } 187 }
180 188
  189 + public static Font setBaseFont(Workbook workbook, boolean bold, boolean italic, String fontName, int fontSize) {
  190 + Font font = workbook.createFont();
  191 + //设置字体名称 宋体 / 微软雅黑 /等
  192 + font.setFontName(fontName);
  193 + //设置是否斜体
  194 + font.setItalic(italic);
  195 + //设置字体高度
  196 + //font.setFontHeight((short) fontHeight);
  197 + //设置字体大小 以磅为单位
  198 + font.setFontHeightInPoints((short) fontSize);
  199 + //设置是否加粗
  200 + font.setBold(bold);
  201 + //默认字体颜色
  202 + // font.setColor(Font.COLOR_NORMAL);
  203 + //红色
  204 + //font.setColor(Font.COLOR_RED);
  205 + //设置下划线样式
  206 + //font.setUnderline(Font.ANSI_CHARSET);
  207 + //设定文字删除线
  208 + //font.setStrikeout(true);
  209 + return font;
  210 + }
  211 +
  212 + //全局样式
  213 + public static StyleSet GlobalStyleSet(ExcelWriter writer, Font font) {
  214 + Workbook workbook=writer.getWorkbook();
  215 + //全局样式设置
  216 + StyleSet styleSet = writer.getStyleSet();
  217 + //设置全局文本居中
  218 + styleSet.setAlign(HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
  219 + //设置全局字体样式
  220 + styleSet.setFont(font,true);
  221 + //设置背景颜色 第二个参数表示是否将样式应用到头部
  222 + styleSet.setBackgroundColor(IndexedColors.WHITE, false);
  223 + //设置自动换行 当文本长于单元格宽度是否换行
  224 + styleSet.setWrapText();
  225 + // 设置全局边框样式
  226 + styleSet.setBorder(BorderStyle.THIN, IndexedColors.BLACK);
  227 + CellStyle cellStyle=styleSet.getCellStyle();
  228 + //设置头部标题样式
  229 + CellStyle headCellStyle = styleSet.getHeadCellStyle();
  230 + //水平居中
  231 + headCellStyle.setAlignment(HorizontalAlignment.CENTER);
  232 + //垂直居中
  233 + headCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  234 + //设置字体样式
  235 + Font f=setBaseFont(workbook,true,false,"宋体",15);
  236 + headCellStyle.setFont(f);
  237 + return styleSet;
  238 + }
  239 +
  240 + public static void setBackground(ExcelWriter writer,short color,int rowIndex,int columnCount){
  241 + CellStyle style = writer.getWorkbook().createCellStyle();
  242 + Sheet sheet=writer.getSheet();
  243 + style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  244 + style.setFillForegroundColor(color);
  245 + style.setAlignment(HorizontalAlignment.CENTER);
  246 + style.setVerticalAlignment(VerticalAlignment.CENTER);
  247 + Row row = sheet.getRow(rowIndex);
  248 + for (int i=0;i<columnCount;i++){
  249 + Cell cell = row.getCell(i);
  250 + cell.setCellStyle(style);
  251 + }
  252 + }
  253 +
  254 + public static void setHeight(ExcelWriter writer,short high){
  255 + Sheet sheet=writer.getSheet();
  256 + for (int i=3;i<writer.getCurrentRow();i++){
  257 + Row row = sheet.getRow(i);
  258 + short s= (short) (256*high);
  259 + row.setHeight(s);
  260 + }
  261 + }
  262 +
  263 + public static void downloadExcel(HttpServletResponse response, String fileName, ExcelWriter writer) {
  264 + response.setContentType("application/vnd.ms-excel;charset=utf-8");
  265 + // test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
  266 + ServletOutputStream out = null;
  267 + try {
  268 + // 设置请求头属性
  269 + response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xlsx").getBytes(), StandardCharsets.ISO_8859_1));
  270 + out = response.getOutputStream();
  271 + // 写出到文件
  272 + writer.flush(out, true);
  273 + // 关闭writer,释放内存
  274 + writer.close();
  275 + // 此处记得关闭输出Servlet流
  276 + IoUtil.close(out);
  277 + } catch (IOException e) {
  278 + e.printStackTrace();
  279 + }
  280 + }
  281 +
181 } 282 }
bsthLineProfiles/src/main/resources/application-druid.yml
@@ -5,15 +5,15 @@ spring: @@ -5,15 +5,15 @@ spring:
5 driverClassName: com.mysql.cj.jdbc.Driver 5 driverClassName: com.mysql.cj.jdbc.Driver
6 druid: 6 druid:
7 # 主库数据源 7 # 主库数据源
8 - master:  
9 - url: jdbc:mysql://localhost:3306/linedata?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8  
10 - username: root  
11 - password: Aa123456  
12 - # 主库数据源  
13 # master: 8 # master:
14 -# url: jdbc:mysql://localhost:3306/bsth_line_profiles?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 9 +# url: jdbc:mysql://localhost:3306/linedata?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
15 # username: root 10 # username: root
16 -# password: 1995627a 11 +# password: Aa123456
  12 + # 主库数据源
  13 + master:
  14 + url: jdbc:mysql://localhost:3306/bsth_line_profiles?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
  15 + username: root
  16 + password: 1995627a
17 # 从库数据源 17 # 从库数据源
18 slave: 18 slave:
19 # 从数据源开关/默认关闭 19 # 从数据源开关/默认关闭
bsthLineProfiles/src/main/resources/application.yml
@@ -80,7 +80,7 @@ spring: @@ -80,7 +80,7 @@ spring:
80 # 数据库索引 80 # 数据库索引
81 database: 0 81 database: 0
82 # 密码 82 # 密码
83 - password: test123 83 + #password: test123
84 # 连接超时时间 84 # 连接超时时间
85 timeout: 10s 85 timeout: 10s
86 lettuce: 86 lettuce:
bsthLineProfiles/src/main/resources/mybatis/mybatis/system/BsthTLineMapper.xml
@@ -1776,7 +1776,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -1776,7 +1776,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
1776 h2.full_customer_percent fullCustomerPercentOld,h2.low_customer_percent lowCustomerPercentOld,h2.divide_level divideLevelOld, 1776 h2.full_customer_percent fullCustomerPercentOld,h2.low_customer_percent lowCustomerPercentOld,h2.divide_level divideLevelOld,
1777 h2.has_timelists hasTimelistsOld,h2.is_metro isMetroOld,h2.metro_time metroTimeOld,h2.cold_bonus_type coldBonusTypeOld,h2.night_parking nightParkingOld,h2.start_date startDateOld, 1777 h2.has_timelists hasTimelistsOld,h2.is_metro isMetroOld,h2.metro_time metroTimeOld,h2.cold_bonus_type coldBonusTypeOld,h2.night_parking nightParkingOld,h2.start_date startDateOld,
1778 h2.line_update_type lineUpdateTypeOld,h2.revenue_type revenueTypeOld 1778 h2.line_update_type lineUpdateTypeOld,h2.revenue_type revenueTypeOld
1779 - FROM bsth_t_line_history h1 LEFT JOIN bsth_t_line_history h2 on h1.history_id=h2.id where h1.history_id is not null 1779 + FROM bsth_t_line_history h1 LEFT JOIN bsth_t_line_history h2 on h1.history_id=h2.id
1780 </select> 1780 </select>
1781 1781
1782 </mapper> 1782 </mapper>
1783 \ No newline at end of file 1783 \ No newline at end of file
bsthLineProfiles/src/main/resources/templates/index.html
@@ -100,7 +100,7 @@ @@ -100,7 +100,7 @@
100 <ul class="nav navbar-top-links navbar-right welcome-message" style="height:50px;"> 100 <ul class="nav navbar-top-links navbar-right welcome-message" style="height:50px;">
101 <li class="dropdown user-menu"> 101 <li class="dropdown user-menu">
102 <a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown"> 102 <a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
103 - <img th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/profile.jpg} : @{${user.avatar}}" th:onerror="this.src='img/profile.jpg'" class="user-image"> 103 + <img src="img/profile.jpg" class="user-image">
104 <i class="el-icon-caret-bottom"></i> 104 <i class="el-icon-caret-bottom"></i>
105 </a> 105 </a>
106 <ul class="dropdown-menu"> 106 <ul class="dropdown-menu">
bsthLineProfiles/src/main/resources/templates/system/historyReport/historyReport.html
@@ -42,7 +42,8 @@ @@ -42,7 +42,8 @@
42 </div> 42 </div>
43 43
44 <div class="btn-group-sm" id="toolbar" role="group"> 44 <div class="btn-group-sm" id="toolbar" role="group">
45 - <el-button plain size="mini" type="warning" icon="el-icon-download" onClick="$.table.exportExcel();" shiro:hasPermission="system:line:export"> 导出</el-button> 45 + <el-button plain size="mini" type="warning" icon="el-icon-download" onClick="$.table.exportExcel();" shiro:hasPermission="system:line:export"> 明细</el-button>
  46 + <el-button plain size="mini" type="warning" icon="el-icon-download" onClick="report();" shiro:hasPermission="system:line:export"> 统计</el-button>
46 </div> 47 </div>
47 <div class="col-sm-12 select-table table-striped"> 48 <div class="col-sm-12 select-table table-striped">
48 <table id="bootstrap-table"></table> 49 <table id="bootstrap-table"></table>
@@ -53,7 +54,6 @@ @@ -53,7 +54,6 @@
53 54
54 <th:block th:include="include :: datetimepicker-js" /> 55 <th:block th:include="include :: datetimepicker-js" />
55 <script th:inline="javascript"> 56 <script th:inline="javascript">
56 -  
57 new Vue({ 57 new Vue({
58 el: '#context', 58 el: '#context',
59 data: function() { 59 data: function() {
@@ -158,6 +158,11 @@ @@ -158,6 +158,11 @@
158 maxView : 3, 158 maxView : 3,
159 autoclose : true 159 autoclose : true
160 }); 160 });
  161 + function report(){
  162 + $.modal.confirm("确定导出统计报表吗?", function() {
  163 + location.href ="/system/historyReport/export2";
  164 + });
  165 + }
161 </script> 166 </script>
162 </body> 167 </body>
163 </html> 168 </html>
164 \ No newline at end of file 169 \ No newline at end of file
bsthLineProfiles/src/main/resources/templates/system/lineAdd/add.html
@@ -456,7 +456,7 @@ @@ -456,7 +456,7 @@
456 <label class="col-sm-1 control-label">性质:</label> 456 <label class="col-sm-1 control-label">性质:</label>
457 <div class="col-sm-2"> 457 <div class="col-sm-2">
458 <select name="lineUpdateType" th:with="type=${@dict.getType('lineUpdateType')}" class="form-control m-b" readonly> 458 <select name="lineUpdateType" th:with="type=${@dict.getType('lineUpdateType')}" class="form-control m-b" readonly>
459 - <option value="3" selected="selected">新辟</option> 459 + <option value="0" selected="selected">新辟</option>
460 </select> 460 </select>
461 </div> 461 </div>
462 <!----------------------------------> 462 <!---------------------------------->
bsthLineProfiles/src/main/resources/templates/system/lineAdd/edit.html
@@ -475,7 +475,7 @@ @@ -475,7 +475,7 @@
475 <label class="col-sm-1 control-label">性质:</label> 475 <label class="col-sm-1 control-label">性质:</label>
476 <div class="col-sm-2"> 476 <div class="col-sm-2">
477 <select name="lineUpdateType" th:with="type=${@dict.getType('lineUpdateType')}" class="form-control m-b" readonly> 477 <select name="lineUpdateType" th:with="type=${@dict.getType('lineUpdateType')}" class="form-control m-b" readonly>
478 - <option value="3" selected="selected">新辟</option> 478 + <option value="0" selected="selected">新辟</option>
479 </select> 479 </select>
480 </div> 480 </div>
481 <!----------------------------------> 481 <!---------------------------------->