Commit 514e44d543d09c3cbe970672e2c777c79f2033ac

Authored by 游瑞烽
1 parent 6e47d285

路单详情报表修改格式

src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.bsth.common.ResponseCode; 5 import com.bsth.common.ResponseCode;
6 import com.bsth.data.BasicData; 6 import com.bsth.data.BasicData;
  7 +import com.bsth.entity.Cars;
7 import com.bsth.entity.Line; 8 import com.bsth.entity.Line;
8 import com.bsth.entity.calc.CalcBusMileage; 9 import com.bsth.entity.calc.CalcBusMileage;
9 import com.bsth.entity.calc.CalcInterval; 10 import com.bsth.entity.calc.CalcInterval;
@@ -16,6 +17,7 @@ import com.bsth.entity.oil.Ylb; @@ -16,6 +17,7 @@ import com.bsth.entity.oil.Ylb;
16 import com.bsth.entity.realcontrol.ChildTaskPlan; 17 import com.bsth.entity.realcontrol.ChildTaskPlan;
17 import com.bsth.entity.realcontrol.ScheduleRealInfo; 18 import com.bsth.entity.realcontrol.ScheduleRealInfo;
18 import com.bsth.entity.sys.Interval; 19 import com.bsth.entity.sys.Interval;
  20 +import com.bsth.repository.CarsRepository;
19 import com.bsth.repository.LineRepository; 21 import com.bsth.repository.LineRepository;
20 import com.bsth.repository.calc.CalcBusMileageRepository; 22 import com.bsth.repository.calc.CalcBusMileageRepository;
21 import com.bsth.repository.calc.CalcIntervalRepository; 23 import com.bsth.repository.calc.CalcIntervalRepository;
@@ -91,6 +93,8 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer @@ -91,6 +93,8 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
91 private LineService lineService; 93 private LineService lineService;
92 @Autowired 94 @Autowired
93 private ReportService reportService; 95 private ReportService reportService;
  96 + @Autowired
  97 + CarsRepository carsRepository;
94 98
95 @Autowired 99 @Autowired
96 JdbcTemplate jdbcTemplate; 100 JdbcTemplate jdbcTemplate;
@@ -2207,6 +2211,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer @@ -2207,6 +2211,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
2207 } else if(flag==3){ 2211 } else if(flag==3){
2208 list1.add("自编号"); 2212 list1.add("自编号");
2209 list1.add("车牌号"); 2213 list1.add("车牌号");
  2214 + list1.add("燃油类型");
2210 } 2215 }
2211 list1.add("计划公里"); 2216 list1.add("计划公里");
2212 list1.add("总公里"); 2217 list1.add("总公里");
@@ -2223,8 +2228,14 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer @@ -2223,8 +2228,14 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
2223 list1.add("合计"); 2228 list1.add("合计");
2224 resList.add(list1); 2229 resList.add(list1);
2225 2230
2226 - int i=1; 2231 + Map<String, String> carsMap = new HashMap<>();
  2232 + List<Cars> carsList = carsRepository.findCars();
  2233 + for (Cars c:carsList) {
  2234 + String sfdc = c.getSfdc()+"";
  2235 + carsMap.put(c.getInsideCode(), sfdc.equals("true")?"纯电动":"柴油");
  2236 + }
2227 2237
  2238 + int i=1;
2228 DecimalFormat df = new DecimalFormat("0.00");//格式化小数 2239 DecimalFormat df = new DecimalFormat("0.00");//格式化小数
2229 double allNum = 0.0; 2240 double allNum = 0.0;
2230 while (iter.hasNext()) { 2241 while (iter.hasNext()) {
@@ -2250,6 +2261,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -2250,6 +2261,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
2250 } else if("cl".equals(statisticalObj)){ 2261 } else if("cl".equals(statisticalObj)){
2251 listStr.add(c.getCl()); 2262 listStr.add(c.getCl());
2252 listStr.add(BasicData.nbbmCompanyPlateMap.get(c.getCl())+""); 2263 listStr.add(BasicData.nbbmCompanyPlateMap.get(c.getCl())+"");
  2264 + listStr.add(carsMap.get(c.getCl()));
2253 } else if("xl".equals(statisticalObj)){ 2265 } else if("xl".equals(statisticalObj)){
2254 2266
2255 } 2267 }
src/main/java/com/bsth/util/ReportUtils.java
@@ -726,20 +726,28 @@ public class ReportUtils { @@ -726,20 +726,28 @@ public class ReportUtils {
726 726
727 //设置wordsheet名 727 //设置wordsheet名
728 HSSFSheet sheetYS = workbook.createSheet();//设置wordsheet名 728 HSSFSheet sheetYS = workbook.createSheet();//设置wordsheet名
  729 + HSSFRow row = sheetYS.createRow(0);
  730 + setCellStyleAndValue(row, style, 0, name);
  731 + CellRangeAddress callRangeAddress = new CellRangeAddress(0,0,0,list.get(0).size()-1);
  732 + sheetYS.addMergedRegion(callRangeAddress);
  733 + // 样式
  734 + setMergeCellStyle (callRangeAddress, sheetYS, workbook);
729 735
730 try{ 736 try{
731 for(int i=0; i<list.size(); i++){ 737 for(int i=0; i<list.size(); i++){
732 - HSSFRow rowYSi = sheetYS.createRow(i); 738 + HSSFRow rowYSi = sheetYS.createRow(i+1);
733 List<String> stringList = list.get(i); 739 List<String> stringList = list.get(i);
734 int num = 4; 740 int num = 4;
735 if("xl".equals(type)) 741 if("xl".equals(type))
736 num = 2; 742 num = 2;
  743 + else if("cl".equals(type))
  744 + num = 5;
737 for(int j=0; j<stringList.size(); j++){ 745 for(int j=0; j<stringList.size(); j++){
738 String str = stringList.get(j); 746 String str = stringList.get(j);
739 if(i == list.size()-1){ 747 if(i == list.size()-1){
740 if(j==0) { 748 if(j==0) {
741 setCellStyleAndValue(rowYSi, style, j, str); 749 setCellStyleAndValue(rowYSi, style, j, str);
742 - CellRangeAddress callRangeAddressYSi = new CellRangeAddress(i,i,0,num); 750 + CellRangeAddress callRangeAddressYSi = new CellRangeAddress(i+1,i+1,0,num);
743 sheetYS.addMergedRegion(callRangeAddressYSi); 751 sheetYS.addMergedRegion(callRangeAddressYSi);
744 // 样式 752 // 样式
745 setMergeCellStyle (callRangeAddressYSi, sheetYS, workbook); 753 setMergeCellStyle (callRangeAddressYSi, sheetYS, workbook);
@@ -752,7 +760,7 @@ public class ReportUtils { @@ -752,7 +760,7 @@ public class ReportUtils {
752 } 760 }
753 761
754 // 给列设置宽度自适应 762 // 给列设置宽度自适应
755 - setSizeColumn(sheetYS,list.get(0).size()); 763 + setSizeColumn1(sheetYS,1,list.get(0).size());
756 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; 764 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/";
757 String targetPath = path+name+".xls"; 765 String targetPath = path+name+".xls";
758 createFolder(targetPath); 766 createFolder(targetPath);
@@ -761,6 +769,7 @@ public class ReportUtils { @@ -761,6 +769,7 @@ public class ReportUtils {
761 workbook.write(fout); 769 workbook.write(fout);
762 fout.close(); 770 fout.close();
763 } catch (Exception e) { 771 } catch (Exception e) {
  772 + e.printStackTrace();
764 } 773 }
765 } 774 }
766 775
@@ -795,6 +804,38 @@ public class ReportUtils { @@ -795,6 +804,38 @@ public class ReportUtils {
795 } 804 }
796 } 805 }
797 806
  807 + /**
  808 + * 自适应宽度(中文支持)
  809 + * @param sheet
  810 + * @param index 从那一行开始自适应
  811 + * @param size
  812 + */
  813 + private static void setSizeColumn1(HSSFSheet sheet,int index, int size) {
  814 + for (int columnNum = index; columnNum < size; columnNum++) {
  815 + int columnWidth = sheet.getColumnWidth(columnNum) / 256;
  816 + for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
  817 + HSSFRow currentRow;
  818 + //当前行未被使用过
  819 + if (sheet.getRow(rowNum) == null) {
  820 + currentRow = sheet.createRow(rowNum);
  821 + } else {
  822 + currentRow = sheet.getRow(rowNum);
  823 + }
  824 + if (currentRow.getCell(columnNum) != null) {
  825 + HSSFCell currentCell = currentRow.getCell(columnNum);
  826 + if (currentCell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
  827 + int length = currentCell.getStringCellValue().getBytes().length;
  828 + if (columnWidth < length) {
  829 + columnWidth = length;
  830 + }
  831 + }
  832 + }
  833 + }
  834 + sheet.setColumnWidth(columnNum, columnWidth * 300);
  835 +// sheet.setColumnWidth(columnNum, columnWidth * 256);
  836 + }
  837 + }
  838 +
798 /** 839 /**
799 * 设置单元格值和样式 840 * 设置单元格值和样式
800 * @param row 841 * @param row
src/main/resources/static/pages/forms/calc/calcDetailMonthly.html
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 29
30 #analy_body{ 30 #analy_body{
31 margin-top: 20px; 31 margin-top: 20px;
32 - height: 650px; 32 + height: 620px;
33 width: 100% 33 width: 100%
34 } 34 }
35 35
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 46
47 .table_body{ 47 .table_body{
48 width:101%; 48 width:101%;
49 - height:620px; 49 + height:580px;
50 overflow: auto; 50 overflow: auto;
51 margin-top: -20px; 51 margin-top: -20px;
52 } 52 }
@@ -218,8 +218,8 @@ @@ -218,8 +218,8 @@
218 } else if(item == "gl"){ 218 } else if(item == "gl"){
219 options += '<option value="zgl">总公里</option>' + 219 options += '<option value="zgl">总公里</option>' +
220 '<option value="jhgl">计划公里</option>'; 220 '<option value="jhgl">计划公里</option>';
221 - /*'<option value="jclm">进场路码</option>'+  
222 - '<option value="cclm">出场路码</option>'*/ 221 + /*'<option value="jclm">进场路码</option>'+
  222 + '<option value="cclm">出场路码</option>'*/
223 } else if(item == "bc"){ 223 } else if(item == "bc"){
224 options += '<option value="sjbc">实际班次</option>' + 224 options += '<option value="sjbc">实际班次</option>' +
225 '<option value="jhbc">计划班次</option>'; 225 '<option value="jhbc">计划班次</option>';
@@ -255,6 +255,44 @@ @@ -255,6 +255,44 @@
255 datas.destroy = $("#destroy").val(); 255 datas.destroy = $("#destroy").val();
256 datas.statisticalObj = $("#statisticalObj").val(); 256 datas.statisticalObj = $("#statisticalObj").val();
257 datas.itemDetails = $("#itemDetails").val(); 257 datas.itemDetails = $("#itemDetails").val();
  258 + var itemDetails = datas.itemDetails,
  259 + type = "加注量[全部]";
  260 + if(itemDetails=="jzl0"){
  261 + type = "加注量[0#]"
  262 + } else if(itemDetails=="jzl-10"){
  263 + type = "加注量[-10#]"
  264 + } else if(itemDetails=="yhl"){
  265 + type = "油耗量"
  266 + } else if(itemDetails=="cccy"){
  267 + type = "出场存油"
  268 + } else if(itemDetails=="jccy"){
  269 + type = "进场存油"
  270 + } else if(itemDetails=="bglyh"){
  271 + type = "百公里油耗"
  272 + } else if(itemDetails=="zgl"){
  273 + type = "总公里"
  274 + } else if(itemDetails=="jhgl"){
  275 + type = "计划公里"
  276 + } else if(itemDetails=="jclm"){
  277 + type = "进场路码"
  278 + } else if(itemDetails=="cclm"){
  279 + type = "出场路码"
  280 + } else if(itemDetails=="sjbc"){
  281 + type = "实际班次"
  282 + } else if(itemDetails=="jhbc"){
  283 + type = "计划班次"
  284 + } else if(itemDetails=="dh"){
  285 + type = "耗电量"
  286 + } else if(itemDetails=="cdl"){
  287 + type = "充电量"
  288 + } else if(itemDetails=="cccd"){
  289 + type = "出场存电"
  290 + } else if(itemDetails=="jccd"){
  291 + type = "进场存电"
  292 + } else if(itemDetails=="bgldh"){
  293 + type = "百公里电耗"
  294 + }
  295 + datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细月报表("+type+")";
258 if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ 296 if(startDate==null || startDate =="" ||endDate==null || endDate ==""){
259 layer.msg('请选择时间段!'); 297 layer.msg('请选择时间段!');
260 }else if(endTime<startTime){ 298 }else if(endTime<startTime){
@@ -276,7 +314,7 @@ @@ -276,7 +314,7 @@
276 return; 314 return;
277 }else 315 }else
278 $("#export").removeAttr("disabled"); 316 $("#export").removeAttr("disabled");
279 - var htmlHead = "", htmlBody = ""; 317 + var htmlHead = "<tr><td colspan='"+rs[0].length+"'>"+datas.name+"</td></tr>", htmlBody = "";
280 var rsLength = rs.length; 318 var rsLength = rs.length;
281 rs.forEach(function (o, i) { 319 rs.forEach(function (o, i) {
282 var html = "<tr>" 320 var html = "<tr>"
@@ -284,12 +322,14 @@ @@ -284,12 +322,14 @@
284 var colspan; 322 var colspan;
285 if (i == rsLength - 1 && j == 0) { 323 if (i == rsLength - 1 && j == 0) {
286 colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); 324 colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'");
  325 + if(statisticalObj == "cl")
  326 + colspan = "colspan='6'";
287 } 327 }
288 html += "<td " + colspan + ">" + td + "</td>" 328 html += "<td " + colspan + ">" + td + "</td>"
289 }); 329 });
290 html += "</tr>" 330 html += "</tr>"
291 if (i == 0) { 331 if (i == 0) {
292 - htmlHead = html; 332 + htmlHead += html;
293 } else 333 } else
294 htmlBody += html; 334 htmlBody += html;
295 }); 335 });
@@ -302,44 +342,6 @@ @@ -302,44 +342,6 @@
302 }); 342 });
303 343
304 $("#export").on("click",function(){ 344 $("#export").on("click",function(){
305 - var itemDetails = datas.itemDetails,  
306 - type = "加注量[全部]";  
307 - if(itemDetails=="jzl0"){  
308 - type = "加注量[0#]"  
309 - } else if(itemDetails=="jzl-10"){  
310 - type = "加注量[-10#]"  
311 - } else if(itemDetails=="yhl"){  
312 - type = "油耗量"  
313 - } else if(itemDetails=="cccy"){  
314 - type = "出场存油"  
315 - } else if(itemDetails=="jccy"){  
316 - type = "进场存油"  
317 - } else if(itemDetails=="bglyh"){  
318 - type = "百公里油耗"  
319 - } else if(itemDetails=="zgl"){  
320 - type = "总公里"  
321 - } else if(itemDetails=="jhgl"){  
322 - type = "计划公里"  
323 - } else if(itemDetails=="jclm"){  
324 - type = "进场路码"  
325 - } else if(itemDetails=="cclm"){  
326 - type = "出场路码"  
327 - } else if(itemDetails=="sjbc"){  
328 - type = "实际班次"  
329 - } else if(itemDetails=="jhbc"){  
330 - type = "计划班次"  
331 - } else if(itemDetails=="dh"){  
332 - type = "耗电量"  
333 - } else if(itemDetails=="cdl"){  
334 - type = "充电量"  
335 - } else if(itemDetails=="cccd"){  
336 - type = "出场存电"  
337 - } else if(itemDetails=="jccd"){  
338 - type = "进场存电"  
339 - } else if(itemDetails=="bgldh"){  
340 - type = "百公里电耗"  
341 - }  
342 - datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细月报表("+type+")";  
343 $post("/report/calcDetailMonthlyE",datas,function(result){ 345 $post("/report/calcDetailMonthlyE",datas,function(result){
344 window.open("/downloadFile/download?fileName="+datas.name); 346 window.open("/downloadFile/download?fileName="+datas.name);
345 }); 347 });
src/main/resources/static/pages/forms/calc/calcDetailYear.html
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 29
30 #analy_body{ 30 #analy_body{
31 margin-top: 20px; 31 margin-top: 20px;
32 - height: 650px; 32 + height: 620px;
33 width: 100% 33 width: 100%
34 } 34 }
35 35
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 46
47 .table_body{ 47 .table_body{
48 width:101%; 48 width:101%;
49 - height:620px; 49 + height:580px;
50 overflow: auto; 50 overflow: auto;
51 margin-top: -20px; 51 margin-top: -20px;
52 } 52 }
@@ -263,6 +263,44 @@ @@ -263,6 +263,44 @@
263 datas.itemDetails = $("#itemDetails").val(); 263 datas.itemDetails = $("#itemDetails").val();
264 datas.item = item; 264 datas.item = item;
265 265
  266 + var itemDetails = datas.itemDetails,
  267 + type = "加注量[全部]";
  268 + if(itemDetails=="jzl0"){
  269 + type = "加注量[0#]"
  270 + } else if(itemDetails=="jzl-10"){
  271 + type = "加注量[-10#]"
  272 + } else if(itemDetails=="yhl"){
  273 + type = "油耗量"
  274 + } else if(itemDetails=="cccy"){
  275 + type = "出场存油"
  276 + } else if(itemDetails=="jccy"){
  277 + type = "进场存油"
  278 + } else if(itemDetails=="bglyh"){
  279 + type = "百公里油耗"
  280 + } else if(itemDetails=="zgl"){
  281 + type = "总公里"
  282 + } else if(itemDetails=="jhgl"){
  283 + type = "计划公里"
  284 + } else if(itemDetails=="jclm"){
  285 + type = "进场路码"
  286 + } else if(itemDetails=="cclm"){
  287 + type = "出场路码"
  288 + } else if(itemDetails=="sjbc"){
  289 + type = "实际班次"
  290 + } else if(itemDetails=="jhbc"){
  291 + type = "计划班次"
  292 + } else if(itemDetails=="dh"){
  293 + type = "耗电量"
  294 + } else if(itemDetails=="cdl"){
  295 + type = "充电量"
  296 + } else if(itemDetails=="cccd"){
  297 + type = "出场存电"
  298 + } else if(itemDetails=="jccd"){
  299 + type = "进场存电"
  300 + } else if(itemDetails=="bgldh"){
  301 + type = "百公里电耗"
  302 + }
  303 + datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细年报表("+type+")";
266 if(startDate==null || startDate =="" ||endDate==null || endDate ==""){ 304 if(startDate==null || startDate =="" ||endDate==null || endDate ==""){
267 layer.msg('请选择时间段!'); 305 layer.msg('请选择时间段!');
268 }else if(endTime<startTime){ 306 }else if(endTime<startTime){
@@ -284,7 +322,7 @@ @@ -284,7 +322,7 @@
284 return; 322 return;
285 }else 323 }else
286 $("#export").removeAttr("disabled"); 324 $("#export").removeAttr("disabled");
287 - var htmlHead = "", htmlBody = ""; 325 + var htmlHead = "<tr><td colspan='"+rs[0].length+"'>"+datas.name+"</td></tr>", htmlBody = "";
288 var rsLength = rs.length; 326 var rsLength = rs.length;
289 rs.forEach(function (o, i) { 327 rs.forEach(function (o, i) {
290 var html = "<tr>" 328 var html = "<tr>"
@@ -292,12 +330,14 @@ @@ -292,12 +330,14 @@
292 var colspan; 330 var colspan;
293 if (i == rsLength - 1 && j == 0) { 331 if (i == rsLength - 1 && j == 0) {
294 colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'"); 332 colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'");
  333 + if(statisticalObj == "cl")
  334 + colspan = "colspan='6'";
295 } 335 }
296 html += "<td " + colspan + ">" + td + "</td>" 336 html += "<td " + colspan + ">" + td + "</td>"
297 }); 337 });
298 html += "</tr>" 338 html += "</tr>"
299 if (i == 0) { 339 if (i == 0) {
300 - htmlHead = html; 340 + htmlHead += html;
301 } else 341 } else
302 htmlBody += html; 342 htmlBody += html;
303 }); 343 });
@@ -310,44 +350,6 @@ @@ -310,44 +350,6 @@
310 }); 350 });
311 351
312 $("#export").on("click",function(){ 352 $("#export").on("click",function(){
313 - var itemDetails = datas.itemDetails,  
314 - type = "加注量[全部]";  
315 - if(itemDetails=="jzl0"){  
316 - type = "加注量[0#]"  
317 - } else if(itemDetails=="jzl-10"){  
318 - type = "加注量[-10#]"  
319 - } else if(itemDetails=="yhl"){  
320 - type = "油耗量"  
321 - } else if(itemDetails=="cccy"){  
322 - type = "出场存油"  
323 - } else if(itemDetails=="jccy"){  
324 - type = "进场存油"  
325 - } else if(itemDetails=="bglyh"){  
326 - type = "百公里油耗"  
327 - } else if(itemDetails=="zgl"){  
328 - type = "总公里"  
329 - } else if(itemDetails=="jhgl"){  
330 - type = "计划公里"  
331 - } else if(itemDetails=="jclm"){  
332 - type = "进场路码"  
333 - } else if(itemDetails=="cclm"){  
334 - type = "出场路码"  
335 - } else if(itemDetails=="sjbc"){  
336 - type = "实际班次"  
337 - } else if(itemDetails=="jhbc"){  
338 - type = "计划班次"  
339 - } else if(itemDetails=="dh"){  
340 - type = "耗电量"  
341 - } else if(itemDetails=="cdl"){  
342 - type = "充电量"  
343 - } else if(itemDetails=="cccd"){  
344 - type = "出场存电"  
345 - } else if(itemDetails=="jccd"){  
346 - type = "进场存电"  
347 - } else if(itemDetails=="bgldh"){  
348 - type = "百公里电耗"  
349 - }  
350 - datas.name = datas.startDate+"-"+datas.endDate+"-路单线路明细年报表("+type+")";  
351 $post("/report/calcDetailMonthlyE",datas,function(result){ 353 $post("/report/calcDetailMonthlyE",datas,function(result){
352 window.open("/downloadFile/download?fileName="+datas.name); 354 window.open("/downloadFile/download?fileName="+datas.name);
353 }); 355 });