Browse Source

优化

zhanglei
dimengzhe 1 year ago
parent
commit
cbaa7b4360
  1. 4
      anrui-reportcenter/anrui-reportcenter-biz/src/main/java/com/yxt/anrui/reportcenter/biz/dailyreport/DailyReportMapper.java
  2. 26
      anrui-reportcenter/anrui-reportcenter-biz/src/main/java/com/yxt/anrui/reportcenter/biz/dailyreport/DailyReportMapper.xml
  3. 205
      anrui-reportcenter/anrui-reportcenter-biz/src/main/java/com/yxt/anrui/reportcenter/biz/dailyreport/DailyReportService.java

4
anrui-reportcenter/anrui-reportcenter-biz/src/main/java/com/yxt/anrui/reportcenter/biz/dailyreport/DailyReportMapper.java

@ -56,7 +56,7 @@ public interface DailyReportMapper extends BaseMapper<DailyReport> {
List<DailyReportVo> selectReport3(@Param("date") String date, @Param("busOrgSid") String busOrgSid);
List<BrandVo> selectByBrand2(@Param("useOrgSid") String useOrgSid, @Param("date") String date);
List<BrandVo> selectByBrand2(@Param("useOrgSid") String useOrgSid, @Param("date") String date,@Param(Constants.WRAPPER) QueryWrapper<DailyReport> qw);
List<DailyReportVo> selectReport4(@Param("join") List<String> brandList, @Param("useOrgSid") String useOrgSid, @Param("date") String date);
List<DailyReportVo> selectReport4(@Param("join") List<String> brandList, @Param("useOrgSid") String useOrgSid, @Param("date") String date,@Param(Constants.WRAPPER) QueryWrapper<DailyReport> qw);
}

26
anrui-reportcenter/anrui-reportcenter-biz/src/main/java/com/yxt/anrui/reportcenter/biz/dailyreport/DailyReportMapper.xml

@ -403,13 +403,6 @@
SELECT dr.brandSid linkSid,
dr.brandName NAME,
b.colspan
<!--(
SELECT count(ddr.vehModelSid)
FROM daily_report ddr
WHERE ddr.brandSid = dr.brandSid
AND DATE_FORMAT(ddr.createTime, '%Y-%m-%d') = #{date}
and ddr.useOrgSid = #{useOrgSid}
) as colspan-->
FROM daily_report dr
left join
(
@ -418,16 +411,14 @@
from (SELECT ddr.brandSid
FROM daily_report ddr
left join
anrui_base.base_model_config bmv
on ddr.vehMConfigSid = bmv.sid
anrui_base.base_model_config bmc
on ddr.vehMConfigSid = bmc.sid
left join
anrui_base.base_vehicle_model bm
on bm.sid = ddr.vehModelSid
WHERE DATE_FORMAT(ddr.createTime, '%Y-%m-%d') = #{date}
and ddr.useOrgSid = #{useOrgSid}
group by ddr.brandSid,
bm.fuelTypeValue,
bm.emissionStandardValue) a
<where>
${ew.sqlSegment}
</where>) a
group by a.brandSid) b
on b.brandSid = dr.brandSid
WHERE dr.useOrgSid = #{useOrgSid}
@ -582,13 +573,16 @@
from daily_report dr
left join anrui_base.base_vehicle_model bm on bm.sid = dr.vehModelSid
left join anrui_base.base_model_config bmc on bmc.sid = dr.vehMConfigSid
where dr.useOrgSid = #{useOrgSid}
<!-- where dr.useOrgSid = #{useOrgSid}
AND DATE_FORMAT(dr.createTime, '%Y-%m-%d') = #{date}
and dr.brandSid in
<foreach collection="join" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
group by dr.brandSid, bm.fuelTypeValue, bm.emissionStandardValue
order by dr.brandSid desc
order by dr.brandSid desc-->
<where>
${ew.sqlSegment}
</where>
</select>
</mapper>

205
anrui-reportcenter/anrui-reportcenter-biz/src/main/java/com/yxt/anrui/reportcenter/biz/dailyreport/DailyReportService.java

@ -1059,9 +1059,18 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da
public ResultBean<DailyReportAppVo> list4(String date, String useOrgSid) {
ResultBean<DailyReportAppVo> rb = ResultBean.fireFail();
QueryWrapper<DailyReport> qw = new QueryWrapper<>();
DailyReportAppVo dailyReportAppVo = new DailyReportAppVo();
dailyReportAppVo.setTitle("分公司" + date + "日报");
List<BrandVo> rows1 = baseMapper.selectByBrand2(useOrgSid, date);
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);
rows1.removeAll(Collections.singleton(null));
dailyReportAppVo.setRow1(rows1);
List<String> brandList = rows1.stream().map(v -> v.getLinkSid()).collect(Collectors.toList());
@ -1069,7 +1078,16 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da
if (brandList.isEmpty()) {
return rb.success();
}
List<DailyReportVo> dailyReportVoList = baseMapper.selectReport4(brandList, useOrgSid, date);
qw = new QueryWrapper<>();
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);
//燃料
List<String> row2 = dailyReportVoList.stream().map(v -> v.getFuelTypeValue()).collect(Collectors.toList());
dailyReportAppVo.setRow2(row2);
@ -1310,82 +1328,161 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da
List<ParameterVo> dynamicRows = new ArrayList<>();
List<DailyParameterVo> parameterVoList = baseMapper.selectByParameters(useOrgSid);
parameterVoList.removeAll(Collections.singleton(null));
for (int i = 0; i < parameterVoList.size(); i++) {
DailyParameterVo dailyParameterVo = parameterVoList.get(i);
String tableName = Arrays.asList(dailyParameterVo.getTableNameKey().split("\\.")).get(1);
ParameterVo parameterVo = new ParameterVo();
parameterVo.setName(dailyParameterVo.getColText());
/*List<DailyParameterVo> parameterVoList = baseMapper.selectByParameters(useOrgSid);
parameterVoList.removeAll(Collections.singleton(null));*/
int totalRowspan = 3;
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);
ParameterVo parameterVo = new ParameterVo();
parameterVo.setName(dailyParameterVo.getColText());
List<String> columnNames = dailyReportVoList.stream().map(v -> {
String columnName = "";
try {
Field field = v.getClass().getDeclaredField(dailyParameterVo.getColName());
field.setAccessible(true);
columnName = (String) field.get(v);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
if (StringUtils.isBlank(columnName)) {
return "-";
} else {
return columnName;
}
}).collect(Collectors.toList());
List<String> columnNames = dailyReportVoList.stream().map(v -> {
String columnName = "";
try {
Field field = v.getClass().getDeclaredField(dailyParameterVo.getColName());
field.setAccessible(true);
columnName = (String) field.get(v);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
if (StringUtils.isBlank(columnName)) {
return "-";
} else {
return columnName;
}
}).collect(Collectors.toList());
// columnNames.add("");
parameterVo.setRow(columnNames);
dynamicRows.add(parameterVo);
parameterVo.setRow(columnNames);
dynamicRows.add(parameterVo);
}
dailyReportAppVo.setDynamicRows(dynamicRows);
if (!dynamicRows.isEmpty()) {
for (int i = 0; i < dynamicRows.size(); i++) {
if (i > 6) {
break;
} else {
ParameterVo parameterVo = dynamicRows.get(i);
switch (i) {
case 0:
if (parameterVo != null) {
dailyReportAppVo.setRow101(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
case 1:
if (parameterVo != null) {
dailyReportAppVo.setRow102(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
case 2:
if (parameterVo != null) {
dailyReportAppVo.setRow103(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
case 3:
if (parameterVo != null) {
dailyReportAppVo.setRow104(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
case 4:
if (parameterVo != null) {
dailyReportAppVo.setRow105(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
case 5:
if (parameterVo != null) {
dailyReportAppVo.setRow106(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
case 6:
if (parameterVo != null) {
dailyReportAppVo.setRow107(parameterVo);
totalRowspan = totalRowspan + 1;
}
break;
default:
break;
}
}
}
}
}
dailyReportAppVo.setDynamicRows(dynamicRows);
int totalRowspan = 3;
if (!dynamicRows.isEmpty()) {
for (int i = 0; i < dynamicRows.size(); i++) {
dailyReportAppVo.setTotalRowspan(totalRowspan);
return rb.success().setData(dailyReportAppVo);
}
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);
if (i > 6) {
break;
} else {
ParameterVo parameterVo = dynamicRows.get(i);
switch (i) {
case 0:
if (parameterVo != null) {
dailyReportAppVo.setRow101(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
case 1:
if (parameterVo != null) {
dailyReportAppVo.setRow102(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
case 2:
if (parameterVo != null) {
dailyReportAppVo.setRow103(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
case 3:
if (parameterVo != null) {
dailyReportAppVo.setRow104(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
case 4:
if (parameterVo != null) {
dailyReportAppVo.setRow105(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
case 5:
if (parameterVo != null) {
dailyReportAppVo.setRow106(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
case 6:
if (parameterVo != null) {
dailyReportAppVo.setRow107(parameterVo);
totalRowspan = totalRowspan+1;
if ("base_model_config".equals(tableName)) {
qw.groupBy("bmc." + dailyParameterVo.getColName());
qw.orderByDesc("bmc." + dailyParameterVo.getColName());
} else if ("base_vehicle_model".equals(tableName)) {
qw.groupBy("bm." + dailyParameterVo.getColName());
}
break;
default:
@ -1394,7 +1491,7 @@ public class DailyReportService extends MybatisBaseService<DailyReportMapper, Da
}
}
}
dailyReportAppVo.setTotalRowspan(totalRowspan);
return rb.success().setData(dailyReportAppVo);
return qw;
}
}

Loading…
Cancel
Save