Commit 21b03159 by 杨林龙

新E盾 1.30 版本开发 修改日里程统计 小数点准确度问题

1 parent f56dfe16
...@@ -22,9 +22,9 @@ public class MileageReportExport { ...@@ -22,9 +22,9 @@ public class MileageReportExport {
private String vin; private String vin;
@ExcelProperty(value = "总行驶次数", index = 4) @ExcelProperty(value = "总行驶次数", index = 4)
private String totalTripsNum; private Integer totalTripsNum;
@ExcelProperty(value = "总里程(Km)", index = 5) @ExcelProperty(value = "总里程(Km)", index = 5)
private String totalMileage; private double totalMileage;
} }
...@@ -14,7 +14,7 @@ public class OilReportExport extends ReportOrgDto { ...@@ -14,7 +14,7 @@ public class OilReportExport extends ReportOrgDto {
* 每辆车每天的油耗总量 * 每辆车每天的油耗总量
*/ */
@ExcelIgnore @ExcelIgnore
private Integer oilCnt; private double oilCnt;
/** /**
* 获取当前天数 * 获取当前天数
...@@ -44,98 +44,98 @@ public class OilReportExport extends ReportOrgDto { ...@@ -44,98 +44,98 @@ public class OilReportExport extends ReportOrgDto {
private String statDate; private String statDate;
@ExcelProperty(value = "1日", index = 10) @ExcelProperty(value = "1日", index = 10)
private Integer dayNum1; private double dayNum1;
@ExcelProperty(value = "2日", index = 11) @ExcelProperty(value = "2日", index = 11)
private Integer dayNum2; private double dayNum2;
@ExcelProperty(value = "3日", index = 12) @ExcelProperty(value = "3日", index = 12)
private Integer dayNum3; private double dayNum3;
@ExcelProperty(value = "4日", index = 13) @ExcelProperty(value = "4日", index = 13)
private Integer dayNum4; private double dayNum4;
@ExcelProperty(value = "5日", index = 14) @ExcelProperty(value = "5日", index = 14)
private Integer dayNum5; private double dayNum5;
@ExcelProperty(value = "6日", index = 15) @ExcelProperty(value = "6日", index = 15)
private Integer dayNum6; private double dayNum6;
@ExcelProperty(value = "7日", index = 16) @ExcelProperty(value = "7日", index = 16)
private Integer dayNum7; private double dayNum7;
@ExcelProperty(value = "8日", index = 17) @ExcelProperty(value = "8日", index = 17)
private Integer dayNum8; private double dayNum8;
@ExcelProperty(value = "9日", index = 18) @ExcelProperty(value = "9日", index = 18)
private Integer dayNum9; private double dayNum9;
@ExcelProperty(value = "10日", index = 19) @ExcelProperty(value = "10日", index = 19)
private Integer dayNum10; private double dayNum10;
@ExcelProperty(value = "11日", index = 20) @ExcelProperty(value = "11日", index = 20)
private Integer dayNum11; private double dayNum11;
@ExcelProperty(value = "12日", index = 21) @ExcelProperty(value = "12日", index = 21)
private Integer dayNum12; private double dayNum12;
@ExcelProperty(value = "13日", index = 22) @ExcelProperty(value = "13日", index = 22)
private Integer dayNum13; private double dayNum13;
@ExcelProperty(value = "14日", index = 23) @ExcelProperty(value = "14日", index = 23)
private Integer dayNum14; private double dayNum14;
@ExcelProperty(value = "15日", index = 24) @ExcelProperty(value = "15日", index = 24)
private Integer dayNum15; private double dayNum15;
@ExcelProperty(value = "16日", index = 25) @ExcelProperty(value = "16日", index = 25)
private Integer dayNum16; private double dayNum16;
@ExcelProperty(value = "17日", index = 26) @ExcelProperty(value = "17日", index = 26)
private Integer dayNum17; private double dayNum17;
@ExcelProperty(value = "18日", index = 27) @ExcelProperty(value = "18日", index = 27)
private Integer dayNum18; private double dayNum18;
@ExcelProperty(value = "19日", index = 28) @ExcelProperty(value = "19日", index = 28)
private Integer dayNum19; private double dayNum19;
@ExcelProperty(value = "20日", index = 29) @ExcelProperty(value = "20日", index = 29)
private Integer dayNum20; private double dayNum20;
@ExcelProperty(value = "21日", index = 30) @ExcelProperty(value = "21日", index = 30)
private Integer dayNum21; private double dayNum21;
@ExcelProperty(value = "22日", index = 31) @ExcelProperty(value = "22日", index = 31)
private Integer dayNum22; private double dayNum22;
@ExcelProperty(value = "23日", index = 32) @ExcelProperty(value = "23日", index = 32)
private Integer dayNum23; private double dayNum23;
@ExcelProperty(value = "24日", index = 33) @ExcelProperty(value = "24日", index = 33)
private Integer dayNum24; private double dayNum24;
@ExcelProperty(value = "25日", index = 34) @ExcelProperty(value = "25日", index = 34)
private Integer dayNum25; private double dayNum25;
@ExcelProperty(value = "26日", index = 35) @ExcelProperty(value = "26日", index = 35)
private Integer dayNum26; private double dayNum26;
@ExcelProperty(value = "27日", index = 36) @ExcelProperty(value = "27日", index = 36)
private Integer dayNum27; private double dayNum27;
@ExcelProperty(value = "28日", index = 37) @ExcelProperty(value = "28日", index = 37)
private Integer dayNum28; private double dayNum28;
@ExcelProperty(value = "29日", index = 38) @ExcelProperty(value = "29日", index = 38)
private Integer dayNum29; private double dayNum29;
@ExcelProperty(value = "30日", index = 39) @ExcelProperty(value = "30日", index = 39)
private Integer dayNum30; private double dayNum30;
@ExcelProperty(value = "31日", index = 40) @ExcelProperty(value = "31日", index = 40)
private Integer dayNum31; private double dayNum31;
@ExcelProperty(value = "总计(升)", index = 41) @ExcelProperty(value = "总计(升)", index = 41)
private Integer summation; private double summation;
} }
...@@ -35,7 +35,7 @@ public class MileageService { ...@@ -35,7 +35,7 @@ public class MileageService {
search.setVin(mileageReportExport.getVin()); search.setVin(mileageReportExport.getVin());
MileageReportExport statisticalData = trialMileageMapper.getStatisticalData(search); MileageReportExport statisticalData = trialMileageMapper.getStatisticalData(search);
mileageReportExport.setTotalTripsNum(statisticalData.getTotalTripsNum()); mileageReportExport.setTotalTripsNum(statisticalData.getTotalTripsNum());
mileageReportExport.setTotalMileage(statisticalData.getTotalMileage()); mileageReportExport.setTotalMileage(Double.isNaN(statisticalData.getTotalMileage()) ? 0.0 : statisticalData.getTotalMileage());
} }
return mileageReportExportList; return mileageReportExportList;
} }
...@@ -63,7 +63,7 @@ public class MileageService { ...@@ -63,7 +63,7 @@ public class MileageService {
flag = false; flag = false;
} else { } else {
if (flag) { if (flag) {
oneData.add("0公里"); oneData.add("0.0公里");
flag = false; flag = false;
} }
} }
......
...@@ -47,7 +47,7 @@ public class OilService { ...@@ -47,7 +47,7 @@ public class OilService {
maxDayNum = DateUtil.getDaysByYearMonth(Integer.parseInt(DateUtil.getYearOfNow()), Integer.parseInt(search.getMonth())); maxDayNum = DateUtil.getDaysByYearMonth(Integer.parseInt(DateUtil.getYearOfNow()), Integer.parseInt(search.getMonth()));
} }
int summation = 0; double summation = 0;
for (OilReportExport statisticalData : statisticalDataList) { for (OilReportExport statisticalData : statisticalDataList) {
oilReportExport.setStatDate(statisticalData.getStatDate()); oilReportExport.setStatDate(statisticalData.getStatDate());
summation = summation + statisticalData.getOilCnt(); summation = summation + statisticalData.getOilCnt();
...@@ -197,8 +197,8 @@ public class OilService { ...@@ -197,8 +197,8 @@ public class OilService {
return oilReportExportList; return oilReportExportList;
} }
private Integer replaceDayCount(Integer dayCount) { private double replaceDayCount(double dayCount) {
return dayCount == null ? 0 : dayCount; return Double.isNaN(dayCount) ? 0.0 : dayCount;
} }
public List<String> getYearWithData() { public List<String> getYearWithData() {
......
...@@ -24,6 +24,7 @@ public class OilServiceTest { ...@@ -24,6 +24,7 @@ public class OilServiceTest {
@Test @Test
public void search() { public void search() {
OilSearch search = new OilSearch(); OilSearch search = new OilSearch();
search.setVin("5645313123153454L");
List<OilReportExport> oilReportExportList = oilService.search(search); List<OilReportExport> oilReportExportList = oilService.search(search);
System.out.println("oilReportExportList = " + JSON.toJSONString(oilReportExportList)); System.out.println("oilReportExportList = " + JSON.toJSONString(oilReportExportList));
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!