Commit 3e6c0fc541d50f78e46eb917c7d026ed21efd2aa

Authored by 游瑞烽
2 parents 8fd41b90 f7de1d19

Merge branch 'pudong' into pudong_jdk8

# Conflicts:
#	src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONArray;
5 5 import com.bsth.common.ResponseCode;
6 6 import com.bsth.data.BasicData;
  7 +import com.bsth.entity.Cars;
7 8 import com.bsth.entity.Line;
8 9 import com.bsth.entity.calc.CalcBusMileage;
9 10 import com.bsth.entity.calc.CalcInterval;
... ... @@ -16,6 +17,7 @@ import com.bsth.entity.oil.Ylb;
16 17 import com.bsth.entity.realcontrol.ChildTaskPlan;
17 18 import com.bsth.entity.realcontrol.ScheduleRealInfo;
18 19 import com.bsth.entity.sys.Interval;
  20 +import com.bsth.repository.CarsRepository;
19 21 import com.bsth.repository.LineRepository;
20 22 import com.bsth.repository.calc.CalcBusMileageRepository;
21 23 import com.bsth.repository.calc.CalcIntervalRepository;
... ... @@ -91,7 +93,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
91 93 private LineService lineService;
92 94 @Autowired
93 95 private ReportService reportService;
94   -
  96 + @Autowired
  97 + CarsRepository carsRepository;
  98 +
95 99 @Autowired
96 100 JdbcTemplate jdbcTemplate;
97 101  
... ... @@ -1348,7 +1352,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
1348 1352 } else {
1349 1353 calcLineMileageRepository.deleteByDate(date);
1350 1354 }
1351   - calcLineMileageRepository.saveAll(list);
  1355 + calcLineMileageRepository.save(list);
1352 1356  
1353 1357 resMap.put("status", ResponseCode.SUCCESS);
1354 1358 } catch (Exception e) {
... ... @@ -1474,7 +1478,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
1474 1478 } else {
1475 1479 calcBusMileageRepository.deleteByDate(date);
1476 1480 }
1477   - calcBusMileageRepository.saveAll(list);
  1481 + calcBusMileageRepository.save(list);
1478 1482  
1479 1483 resMap.put("status", ResponseCode.SUCCESS);
1480 1484 } catch (Exception e) {
... ... @@ -2207,6 +2211,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
2207 2211 } else if(flag==3){
2208 2212 list1.add("自编号");
2209 2213 list1.add("车牌号");
  2214 + list1.add("燃油类型");
2210 2215 }
2211 2216 list1.add("计划公里");
2212 2217 list1.add("总公里");
... ... @@ -2223,8 +2228,14 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer
2223 2228 list1.add("合计");
2224 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 2239 DecimalFormat df = new DecimalFormat("0.00");//格式化小数
2229 2240 double allNum = 0.0;
2230 2241 while (iter.hasNext()) {
... ...
src/main/java/com/bsth/util/ReportUtils.java
... ... @@ -726,20 +726,28 @@ public class ReportUtils {
726 726  
727 727 //设置wordsheet名
728 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 736 try{
731 737 for(int i=0; i<list.size(); i++){
732   - HSSFRow rowYSi = sheetYS.createRow(i);
  738 + HSSFRow rowYSi = sheetYS.createRow(i+1);
733 739 List<String> stringList = list.get(i);
734 740 int num = 4;
735 741 if("xl".equals(type))
736 742 num = 2;
  743 + else if("cl".equals(type))
  744 + num = 5;
737 745 for(int j=0; j<stringList.size(); j++){
738 746 String str = stringList.get(j);
739 747 if(i == list.size()-1){
740 748 if(j==0) {
741 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 751 sheetYS.addMergedRegion(callRangeAddressYSi);
744 752 // 样式
745 753 setMergeCellStyle (callRangeAddressYSi, sheetYS, workbook);
... ... @@ -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 764 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/";
757 765 String targetPath = path+name+".xls";
758 766 createFolder(targetPath);
... ... @@ -761,6 +769,7 @@ public class ReportUtils {
761 769 workbook.write(fout);
762 770 fout.close();
763 771 } catch (Exception e) {
  772 + e.printStackTrace();
764 773 }
765 774 }
766 775  
... ... @@ -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 841 * @param row
... ...
src/main/resources/static/pages/forms/calc/calcDetailMonthly.html
... ... @@ -29,7 +29,7 @@
29 29  
30 30 #analy_body{
31 31 margin-top: 20px;
32   - height: 650px;
  32 + height: 620px;
33 33 width: 100%
34 34 }
35 35  
... ... @@ -46,7 +46,7 @@
46 46  
47 47 .table_body{
48 48 width:101%;
49   - height:620px;
  49 + height:580px;
50 50 overflow: auto;
51 51 margin-top: -20px;
52 52 }
... ... @@ -218,8 +218,8 @@
218 218 } else if(item == "gl"){
219 219 options += '<option value="zgl">总公里</option>' +
220 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 223 } else if(item == "bc"){
224 224 options += '<option value="sjbc">实际班次</option>' +
225 225 '<option value="jhbc">计划班次</option>';
... ... @@ -255,6 +255,44 @@
255 255 datas.destroy = $("#destroy").val();
256 256 datas.statisticalObj = $("#statisticalObj").val();
257 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 296 if(startDate==null || startDate =="" ||endDate==null || endDate ==""){
259 297 layer.msg('请选择时间段!');
260 298 }else if(endTime<startTime){
... ... @@ -276,7 +314,7 @@
276 314 return;
277 315 }else
278 316 $("#export").removeAttr("disabled");
279   - var htmlHead = "", htmlBody = "";
  317 + var htmlHead = "<tr><td colspan='"+rs[0].length+"'>"+datas.name+"</td></tr>", htmlBody = "";
280 318 var rsLength = rs.length;
281 319 rs.forEach(function (o, i) {
282 320 var html = "<tr>"
... ... @@ -284,12 +322,14 @@
284 322 var colspan;
285 323 if (i == rsLength - 1 && j == 0) {
286 324 colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'");
  325 + if(statisticalObj == "cl")
  326 + colspan = "colspan='6'";
287 327 }
288 328 html += "<td " + colspan + ">" + td + "</td>"
289 329 });
290 330 html += "</tr>"
291 331 if (i == 0) {
292   - htmlHead = html;
  332 + htmlHead += html;
293 333 } else
294 334 htmlBody += html;
295 335 });
... ... @@ -302,44 +342,6 @@
302 342 });
303 343  
304 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 345 $post("/report/calcDetailMonthlyE",datas,function(result){
344 346 window.open("/downloadFile/download?fileName="+datas.name);
345 347 });
... ...
src/main/resources/static/pages/forms/calc/calcDetailYear.html
... ... @@ -29,7 +29,7 @@
29 29  
30 30 #analy_body{
31 31 margin-top: 20px;
32   - height: 650px;
  32 + height: 620px;
33 33 width: 100%
34 34 }
35 35  
... ... @@ -46,7 +46,7 @@
46 46  
47 47 .table_body{
48 48 width:101%;
49   - height:620px;
  49 + height:580px;
50 50 overflow: auto;
51 51 margin-top: -20px;
52 52 }
... ... @@ -263,6 +263,44 @@
263 263 datas.itemDetails = $("#itemDetails").val();
264 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 304 if(startDate==null || startDate =="" ||endDate==null || endDate ==""){
267 305 layer.msg('请选择时间段!');
268 306 }else if(endTime<startTime){
... ... @@ -284,7 +322,7 @@
284 322 return;
285 323 }else
286 324 $("#export").removeAttr("disabled");
287   - var htmlHead = "", htmlBody = "";
  325 + var htmlHead = "<tr><td colspan='"+rs[0].length+"'>"+datas.name+"</td></tr>", htmlBody = "";
288 326 var rsLength = rs.length;
289 327 rs.forEach(function (o, i) {
290 328 var html = "<tr>"
... ... @@ -292,12 +330,14 @@
292 330 var colspan;
293 331 if (i == rsLength - 1 && j == 0) {
294 332 colspan = (statisticalObj == "xl" ? "colspan='3'" : "colspan='5'");
  333 + if(statisticalObj == "cl")
  334 + colspan = "colspan='6'";
295 335 }
296 336 html += "<td " + colspan + ">" + td + "</td>"
297 337 });
298 338 html += "</tr>"
299 339 if (i == 0) {
300   - htmlHead = html;
  340 + htmlHead += html;
301 341 } else
302 342 htmlBody += html;
303 343 });
... ... @@ -310,44 +350,6 @@
310 350 });
311 351  
312 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 353 $post("/report/calcDetailMonthlyE",datas,function(result){
352 354 window.open("/downloadFile/download?fileName="+datas.name);
353 355 });
... ...