Commit ce3dbc1a authored by jiaorz's avatar jiaorz

车辆统计修改导出数据

parent fefa6908
...@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Service @Service
...@@ -120,4 +121,33 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo ...@@ -120,4 +121,33 @@ public class BranchCompanyVehicleCountBiz extends BaseBiz<BranchCompanyVehicleCo
return ObjectRestResponse.succ(new PageDataVO<>()); return ObjectRestResponse.succ(new PageDataVO<>());
} }
public List<BranchCompanyVehicleCountVo> exportAllDate(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) {
if (StringUtils.isBlank(branchCompanyVehicleCountDTO.getStartTime()) || StringUtils.isBlank(branchCompanyVehicleCountDTO.getEndTime())) {
branchCompanyVehicleCountDTO.setStartTime(DateTime.now().minusDays(1).toString(DATE_TIME_FORMATTER));
branchCompanyVehicleCountDTO.setEndTime(DateTime.now().minusDays(1).toString(DATE_TIME_FORMATTER));
}
Integer type = branchCompanyVehicleCountDTO.getType() == null ? 1 : branchCompanyVehicleCountDTO.getType();
Query query = new Query(branchCompanyVehicleCountDTO);
if (type == 1) {//按天
return mapper.getAllCountInfo(query.getSuper());
}
if (type == 2) {//按周
List<BranchCompanyVehicleCountVo> pageDataVO = mapper.countByWeek(query.getSuper());
if (pageDataVO != null && pageDataVO.size() > 0) {
pageDataVO.parallelStream().forEach(result -> {
String weekStartDate = OrderDateUtils.getStartDayOfWeekNo(result.getCountYear(), result.getCountWeek());
String weekEndDate = OrderDateUtils.getEndDayOfWeekNo(result.getCountYear(), result.getCountWeek());
result.setWeekStartDate(weekStartDate);
result.setWeekEndDate(weekEndDate);
});
}
return pageDataVO;
}
if (type == 3) {//按月
return mapper.countByMonth(query.getSuper());
}
return new ArrayList<>();
}
} }
...@@ -123,7 +123,8 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh ...@@ -123,7 +123,8 @@ public class VehicleCountRecordBiz extends BaseBiz<VehicleCountRecordMapper, Veh
DateTime startDay = DateTime.parse(startDate, DEFAULT_DATE_TIME_FORMATTER); DateTime startDay = DateTime.parse(startDate, DEFAULT_DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(endDate, DEFAULT_DATE_TIME_FORMATTER); DateTime endDay = DateTime.parse(endDate, DEFAULT_DATE_TIME_FORMATTER);
int i = 0; int i = 0;
for (DateTime curDate = startDay; i < 30; curDate = curDate.minusDays(1)) { int monthDay = endDay.getDayOfMonth() - startDay.getDayOfMonth() + 1;
for (DateTime curDate = startDay; i < monthDay; curDate = curDate.minusDays(1)) {
i++; i++;
nowTime = curDate.getMillis(); nowTime = curDate.getMillis();
lastTime = nowTime + 24 * 3600 * 1000 - 1; lastTime = nowTime + 24 * 3600 * 1000 - 1;
......
...@@ -4,7 +4,6 @@ import cn.hutool.core.io.IoUtil; ...@@ -4,7 +4,6 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter; import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz; import com.xxfc.platform.vehicle.biz.BranchCompanyVehicleCountBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo; import com.xxfc.platform.vehicle.pojo.BranchCompanyVehicleCountVo;
...@@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Controller @Controller
@RequestMapping(value = "/bg-vehicle/count") @RequestMapping(value = "/bg-vehicle/count")
...@@ -33,8 +33,8 @@ public class BranchCompanyVehicleCountController extends BaseController<BranchCo ...@@ -33,8 +33,8 @@ public class BranchCompanyVehicleCountController extends BaseController<BranchCo
} }
@GetMapping("/app/unauth/export") @GetMapping("/app/unauth/export")
public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception { public void exportVehicleInfo(BranchCompanyVehicleCountDTO branchCompanyVehicleCountDTO) throws Exception {
PageDataVO<BranchCompanyVehicleCountVo> pageDataVO = baseBiz.getAllCountInfo(branchCompanyVehicleCountDTO).getData(); List<BranchCompanyVehicleCountVo> pageDataVO = baseBiz.exportAllDate(branchCompanyVehicleCountDTO);
if (pageDataVO != null && pageDataVO.getData() != null) { if (pageDataVO != null && pageDataVO.size() > 0) {
ExcelWriter writer = ExcelUtil.getWriter(true); ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("companyId", "公司ID"); writer.addHeaderAlias("companyId", "公司ID");
writer.addHeaderAlias("companyName", "公司名"); writer.addHeaderAlias("companyName", "公司名");
...@@ -50,7 +50,7 @@ public class BranchCompanyVehicleCountController extends BaseController<BranchCo ...@@ -50,7 +50,7 @@ public class BranchCompanyVehicleCountController extends BaseController<BranchCo
writer.setColumnWidth(6, 17); writer.setColumnWidth(6, 17);
writer.setColumnWidth(1, 17); writer.setColumnWidth(1, 17);
// 一次性写出内容,使用默认样式,强制输出标题 // 一次性写出内容,使用默认样式,强制输出标题
writer.write(pageDataVO.getData(), true); writer.write(pageDataVO, true);
//response为HttpServletResponse对象 //response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8"); response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
......
...@@ -608,7 +608,7 @@ ...@@ -608,7 +608,7 @@
FROM FROM
vehicle v vehicle v
LEFT JOIN branch_company b ON b.id = v.park_branch_company_id LEFT JOIN branch_company b ON b.id = v.park_branch_company_id
where v.id_del = 0 where v.is_del = 0
GROUP BY GROUP BY
b.id b.id
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment