|
|
@ -1062,15 +1062,15 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da |
|
|
|
QueryWrapper<DailyReport> qw = new QueryWrapper<>(); |
|
|
|
DailyReportAppVo dailyReportAppVo = new DailyReportAppVo(); |
|
|
|
dailyReportAppVo.setTitle("分公司" + date + "日报"); |
|
|
|
qw.like("ddr.createTime",date); |
|
|
|
qw.eq("ddr.useOrgSid",useOrgSid); |
|
|
|
qw.like("ddr.createTime", date); |
|
|
|
qw.eq("ddr.useOrgSid", useOrgSid); |
|
|
|
qw.groupBy("ddr.brandSid"); |
|
|
|
qw.groupBy("bm.fuelTypeValue"); |
|
|
|
qw.groupBy("bm.emissionStandardValue"); |
|
|
|
List<DailyParameterVo> parameterVoList = baseMapper.selectByParameters(useOrgSid); |
|
|
|
parameterVoList.removeAll(Collections.singleton(null)); |
|
|
|
qw = getCommon(parameterVoList,qw); |
|
|
|
List<BrandVo> rows1 = baseMapper.selectByBrand2(useOrgSid, date,qw); |
|
|
|
qw = getCommon(parameterVoList, qw); |
|
|
|
List<BrandVo> rows1 = baseMapper.selectByBrand2(useOrgSid, date, qw); |
|
|
|
rows1.removeAll(Collections.singleton(null)); |
|
|
|
dailyReportAppVo.setRow1(rows1); |
|
|
|
List<String> brandList = rows1.stream().map(v -> v.getLinkSid()).collect(Collectors.toList()); |
|
|
@ -1079,15 +1079,15 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
qw = new QueryWrapper<>(); |
|
|
|
qw.eq("dr.useOrgSid",useOrgSid); |
|
|
|
qw.like("dr.createTime",date); |
|
|
|
qw.in("dr.brandSid",brandList); |
|
|
|
qw.eq("dr.useOrgSid", useOrgSid); |
|
|
|
qw.like("dr.createTime", date); |
|
|
|
qw.in("dr.brandSid", brandList); |
|
|
|
qw.orderByDesc("dr.brandSid"); |
|
|
|
qw.groupBy("dr.brandSid"); |
|
|
|
qw.groupBy("bm.fuelTypeValue"); |
|
|
|
qw.groupBy("bm.emissionStandardValue"); |
|
|
|
qw = getCommon(parameterVoList,qw); |
|
|
|
List<DailyReportVo> dailyReportVoList = baseMapper.selectReport4(brandList, useOrgSid, date,qw); |
|
|
|
qw = getCommon(parameterVoList, qw); |
|
|
|
List<DailyReportVo> dailyReportVoList = baseMapper.selectReport4(brandList, useOrgSid, date, qw); |
|
|
|
//燃料
|
|
|
|
List<String> row2 = dailyReportVoList.stream().map(v -> v.getFuelTypeValue()).collect(Collectors.toList()); |
|
|
|
dailyReportAppVo.setRow2(row2); |
|
|
@ -1095,10 +1095,15 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da |
|
|
|
List<String> row3 = dailyReportVoList.stream().map(v -> v.getEmissionStandardValue()).collect(Collectors.toList()); |
|
|
|
dailyReportAppVo.setRow3(row3); |
|
|
|
//存销比
|
|
|
|
List<String> row4 = dailyReportVoList.stream().map(v -> v.getSaleOfStockRatio()).collect(Collectors.toList()); |
|
|
|
List<String> row4 = dailyReportVoList.stream().map(v -> |
|
|
|
v.getSaleOfStockRatio().contains(".") ?dicimalToFraction(Double.valueOf(v.getSaleOfStockRatio())):(v.getSaleOfStockRatio()+":1") |
|
|
|
).collect(Collectors.toList()); |
|
|
|
//合计
|
|
|
|
BigDecimal row4All = row4.stream().map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
row4.add(row4All.toString()); |
|
|
|
BigDecimal row4All = dailyReportVoList.stream().map(v -> |
|
|
|
v.getSaleOfStockRatio() |
|
|
|
).collect(Collectors.toList()).stream().map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
String row4alll = row4All.toString().contains(".")?dicimalToFraction(Double.valueOf(row4All.toString())):(row4All.toString()+":1"); |
|
|
|
row4.add(row4alll); |
|
|
|
dailyReportAppVo.setRow4(row4); |
|
|
|
//库存总计
|
|
|
|
List<String> row5 = dailyReportVoList.stream().map(v -> String.valueOf(v.getStock_total())).collect(Collectors.toList()); |
|
|
@ -1420,8 +1425,8 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public QueryWrapper<DailyReport> getCommon(List<DailyParameterVo> parameterVoList,QueryWrapper<DailyReport> qw){ |
|
|
|
if(!parameterVoList.isEmpty()){ |
|
|
|
public QueryWrapper<DailyReport> getCommon(List<DailyParameterVo> parameterVoList, QueryWrapper<DailyReport> qw) { |
|
|
|
if (!parameterVoList.isEmpty()) { |
|
|
|
for (int i = 0; i < parameterVoList.size(); i++) { |
|
|
|
DailyParameterVo dailyParameterVo = parameterVoList.get(i); |
|
|
|
String tableName = Arrays.asList(dailyParameterVo.getTableNameKey().split("\\.")).get(1); |
|
|
@ -1432,77 +1437,77 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da |
|
|
|
case 0: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
if ("base_model_config".equals(tableName)) { |
|
|
|
// qw.groupBy("bmc." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bmc."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bmc." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bmc." + dailyParameterVo.getColName()); |
|
|
|
} else if ("base_vehicle_model".equals(tableName)) { |
|
|
|
// qw.groupBy("bm." + dailyParameterVo.getColName());
|
|
|
|
qw.groupBy("IFNULL(bm."+dailyParameterVo.getColName()+",'')"); |
|
|
|
qw.groupBy("IFNULL(bm." + dailyParameterVo.getColName() + ",'')"); |
|
|
|
qw.orderByDesc("bm." + dailyParameterVo.getColName()); |
|
|
|
} |
|
|
|
break; |
|
|
@ -1515,4 +1520,29 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da |
|
|
|
|
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public String dicimalToFraction(double num) { |
|
|
|
int count = 0; |
|
|
|
int base = 10; |
|
|
|
while (num != Math.floor(num)) { |
|
|
|
num *= base; |
|
|
|
count++; |
|
|
|
} |
|
|
|
|
|
|
|
base = (int) Math.pow(base, count); |
|
|
|
int nor = (int) num; |
|
|
|
int gcd = findGCD(nor, base); |
|
|
|
|
|
|
|
|
|
|
|
return String.valueOf(nor / gcd) + "/" + String.valueOf(base / gcd); |
|
|
|
} |
|
|
|
|
|
|
|
//求最大公约数
|
|
|
|
private int findGCD(int a, int b) { |
|
|
|
if (a == 0) { |
|
|
|
return b; |
|
|
|
} |
|
|
|
return findGCD(b % a, a); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|