package com.sercurityControl.proteam.controller; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.collect.Maps; import com.securityControl.common.core.utils.StringUtils; import com.securityControl.common.core.utils.aes.DateTimeHelper; import com.securityControl.common.core.utils.aes.ListHelper; import com.securityControl.common.core.utils.aes.StringHelper; import com.securityControl.common.core.utils.poi.ExcelUtil; import com.securityControl.common.core.web.controller.BaseController; import com.securityControl.common.core.web.domain.AjaxResult; import com.securityControl.common.core.web.page.TableDataInfo; import com.securityControl.common.log.annotation.Log; import com.securityControl.common.log.enums.BusinessType; import com.securityControl.common.log.enums.OperationType; import com.sercurityControl.proteam.domain.*; import com.sercurityControl.proteam.domain.dto.WeathQo; import com.sercurityControl.proteam.domain.vo.DeviceVo; import com.sercurityControl.proteam.domain.vo.WeekPlanVo; import com.sercurityControl.proteam.dutyTask.domain.TowerVo; import com.sercurityControl.proteam.mapper.HomeDataMapper; import com.sercurityControl.proteam.service.HomeDataService; import com.sercurityControl.proteam.util.WordUtils; import com.sun.jna.platform.win32.WinDef; import io.swagger.models.auth.In; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.crypto.Data; import java.util.*; /** * 综合首页接口 * * @author ljl */ @RestController @RequestMapping("/pot/home") public class HomeController extends BaseController { private static final Logger log = LoggerFactory.getLogger(HomeController.class); @Autowired private HomeDataService homeDataService; /** * 日计划-根据用户权限、日期获取工程类型为:全部、变电、线路的日计划总数、已执行总数和各个地市的计划总数和已执行数量 * * @return */ @PostMapping(value = "getDayPlan") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "日计划") public AjaxResult getDayPlan(DayPlanNum dayPlanNum) { DayPlanNum res = homeDataService.getDayPlan(dayPlanNum); if (res != null) { return success(res); } else { return success(null); } } /** * 周风险-根据用户信息和时间获取本周和下周的二级、三级风险数量 * * @return */ @PostMapping(value = "getWeekRiskNum") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "周风险") public AjaxResult getWeekRiskNum(WeekRiskData weekRiskData) { Map map = homeDataService.getWeekRiskNum(weekRiskData); if (map != null) { return success(map); } else { return success(null); } } /** * 周风险-周计划列表-根据用户信息和筛选条件获取周计划列表 * * @return */ @PostMapping(value = "getWeekPlanList") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "周计划列表") public Map getWeekPlanList(WeekRiskData weekRiskData) { PageHelper.startPage(Integer.parseInt(weekRiskData.getPage()), Integer.parseInt(weekRiskData.getLimit())); Map map = new HashMap(16); try { PageInfo pageInfo = homeDataService.getWeekPlanList(weekRiskData); map.put("code", 200); map.put("msg", "获取数据成功"); map.put("count", pageInfo.getTotal()); map.put("curr", Integer.parseInt(weekRiskData.getPage())); map.put("limit", Integer.parseInt(weekRiskData.getLimit())); map.put("data", pageInfo.getList()); } catch (Exception e) { log.error(e.toString(),e); map.put("code", 500); map.put("msg", "获取数据失败"); map.put("count", 0); map.put("curr", Integer.parseInt(weekRiskData.getPage())); map.put("limit", Integer.parseInt(weekRiskData.getLimit())); map.put("data", null); } return map; } /** * 电子地图-风险分布图-根据用户信息获取当天的风险分布情况 * * @return */ @PostMapping(value = "getRiskMap") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "电子地图-风险分布图") public AjaxResult getRiskMap(RiskMapData riskMapData) { List res = homeDataService.getRiskMap(riskMapData); if (res != null && res.size() > 0) { return success(res); } else { return success(null); } } /** * 电子地图-天气分布情况-根据用户信息获取当前的天气分布情况 * * @return */ @PostMapping(value = "getWeatherMap") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "电子地图-天气分布情况") public AjaxResult getWeatherMap() { List res = homeDataService.getWeatherMap(); if (res != null && res.size() > 0) { return success(res); } else { return success(null); } } /** * 电子地图-天气预警-根据用户信息获取当天的天气预警情况(恶劣天气) * * @return */ @PostMapping(value = "getWeatherAlert") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "电子地图-天气预警") public AjaxResult getWeatherAlert(String orgId, String currentDay) { List res = homeDataService.getWeatherAlert(currentDay, orgId); if (res != null && res.size() > 0) { return success(res); } else { return success(null); } } /** * 电子地图-天气预警-根据用户信息获取当天的天气预警情况(恶劣天气)列表 * * @return */ @PostMapping(value = "getWeatherAlertPlus") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "电子地图-根据用户信息获取当天的天气预警情况") public TableDataInfo getWeatherAlertPlus(@RequestBody WeathQo weathQo) { startPage(); List> res = homeDataService.getWeatherAlertPlus(weathQo); return getDataTable(res); } /** * - * * * @return */ @PostMapping(value = "getTicketNumByType") public AjaxResult getTicketNumByType(TicketTypeNum ticketTypeNum) { Map res = homeDataService.getTicketNumByType(ticketTypeNum); if (res != null) { return success(res); } else { return success(null); } } /** * 作业票-作业票地市对比图-根据用户信息和日期获取各个地市的A票、B票的作业票数量 * * @return */ @PostMapping(value = "getTicketNumByCicty") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "作业票-作业票地市对比图") public AjaxResult getTicketNumByCicty(TicketCityNum ticketTypeNum) { List> listMap = new ArrayList<>(); Map res = Maps.newHashMap(); Map res2 = Maps.newHashMap(); try { ticketTypeNum.setTicketType("B"); res = homeDataService.getTicketNumByCicty(ticketTypeNum); ticketTypeNum.setTicketType("A"); res2 = homeDataService.getTicketNumByCicty(ticketTypeNum); listMap.add(res); listMap.add(res2); return AjaxResult.success("获取成功", listMap); } catch (Exception e) { log.error(e.toString(), e); return AjaxResult.error("服务异常请稍后重试"); } } /** * 作业票-作业票信息列表-根据用户信息和筛选条件查询作业票列表 * * @return */ @PostMapping(value = "getTicketList") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "作业票-作业票信息列表") public Map getTicketList(TicketData ticketData) { PageHelper.startPage(Integer.parseInt(ticketData.getPage()), Integer.parseInt(ticketData.getLimit())); Map map = new HashMap(16); try { PageInfo pageInfo = homeDataService.getTicketList(ticketData); map.put("code", 200); map.put("msg", "获取数据成功"); map.put("count", pageInfo.getTotal()); map.put("curr", Integer.parseInt(ticketData.getPage())); map.put("limit", Integer.parseInt(ticketData.getLimit())); map.put("data", pageInfo.getList()); } catch (Exception e) { log.error(e.toString(), e); map.put("code", 200); map.put("msg", "获取数据失败"); map.put("count", 0); map.put("curr", Integer.parseInt(ticketData.getPage())); map.put("limit", Integer.parseInt(ticketData.getLimit())); map.put("data", null); } return map; } @Autowired private HomeDataMapper mapper; @GetMapping("exportTicket") public void exportTicket(HttpServletResponse response, TicketData ticketData) { // 地市多选切割 if (StringUtils.isNotBlank(ticketData.getBuildCode())) { String[] buildCodeArr = ticketData.getBuildCode().split(","); List buildCodeArrList = Arrays.asList(buildCodeArr); ticketData.setBuildCodeList(buildCodeArrList); } // 风险等级多选切割 if (StringUtils.isNotBlank(ticketData.getRiskType())) { String[] riskTypeArr = ticketData.getRiskType().split(","); List riskTypeList = Arrays.asList(riskTypeArr); ticketData.setRiskTypeList(riskTypeList); } List list = mapper.getTicketList(ticketData); ExcelUtil util = new ExcelUtil(TicketData.class); util.exportExcel(response, list, "作业票"); } /** * 人员统计-今日考勤统计-根据用户信息获取班组骨干、特种作业、普通施工人员类型的今日考勤数量 * * @return */ @PostMapping(value = "getDayAttendanceNum") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "人员统计-今日考勤统计") public AjaxResult getDayAttendanceNum() { String currentDay = DateTimeHelper.getNowDate(); List> list = new ArrayList<>(); try { Map res = homeDataService.getDayAttendanceNum(currentDay); Map res2 = homeDataService.getRealTimeNum(currentDay); list.add(res); list.add(res2); } catch (Exception e) { log.error(e.toString(), e); } if (ListHelper.isNotEmpty(list)) { return success(list); } return success(null); } /** * 人员统计-实时在场人员统计-根据用户信息获取今日实时在场的人员统计数量 * * @return */ @PostMapping(value = "getRealTimeNum") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "人员统计-实时在场人员统计") public AjaxResult getRealTimeNum() { String currentDay = DateTimeHelper.getNowDate(); Map res = homeDataService.getRealTimeNum(currentDay); if (res != null) { return success(res); } else { return success(null); } } /** * 人员统计-站班会人员统计 * * @return */ @PostMapping(value = "getClassPeopleNum") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "人员统计-站班会人员统计") public AjaxResult getClassPeopleNum(PersonNum personNum) { if(StringHelper.isEmpty(personNum.getCurrentDay())){ personNum.setCurrentDay(DateTimeHelper.getNowDate()); } Map res = homeDataService.getClassPeopleNum(personNum); if (res != null) { return success(res); } else { return success(null); } } /** * 人员统计-人员列表-根据用户信息获取人员列表信息 * * @return */ @PostMapping(value = "getPersonList") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "人员统计-人员列表") public Map getPersonList(PersonData personData) { PageHelper.startPage(Integer.parseInt(personData.getPage()), Integer.parseInt(personData.getLimit())); Map map = new HashMap(16); try { PageInfo pageInfo = homeDataService.getPersonList(personData); map.put("code", 200); map.put("msg", "获取数据成功"); map.put("count", pageInfo.getTotal()); map.put("curr", Integer.parseInt(personData.getPage())); map.put("limit", Integer.parseInt(personData.getLimit())); map.put("data", pageInfo.getList()); } catch (Exception e) { log.error(e.toString(), e); map.put("code", 200); map.put("msg", "获取数据失败"); map.put("count", 0); map.put("curr", Integer.parseInt(personData.getPage())); map.put("limit", Integer.parseInt(personData.getLimit())); map.put("data", null); } return map; } /** * 根据日期获取各地市风险等级数量 * * @param orgId * @param dateType * @return */ @PostMapping(value = "getRiskByDate") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "根据日期获取各地市风险等级数量") public AjaxResult getRiskByDate(String orgId, String dateType) { Map list = homeDataService.getRiskByDate(orgId, dateType); if (list != null && list.size() > 0) { return success(list); } else { return success(null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 日计划 * @Param proType * @Param dayType * @date 2023-01-10 14:06 */ @PostMapping(value = "getDayPlanNum") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "获取日计划数量") public AjaxResult getDayPlanNum(String proType, String dayType) { try { // Map map = homeDataService.getDayPlanNum(proType, dayType); Map map = homeDataService.getNewDayPlanNum(proType, dayType); return AjaxResult.success("success", map); } catch (Exception e) { log.error("日计划", e); return AjaxResult.success("error", null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 地市-人员统计 * @Param orgId * @date 2023-01-10 14:06 */ @PostMapping(value = "getAttendanceNum") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "人员统计") public AjaxResult getAttendanceNum(String orgId) { try { Map map = homeDataService.getAttendanceNum(orgId); return AjaxResult.success("success", map); } catch (Exception e) { log.error("地市-人员统计", e); return AjaxResult.success("error", null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 地市工程数量和占比 * @Param proData * @date 2023-01-30 11:26 */ @PostMapping(value = "getOrgNumAndRateByPro") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "地市工程数量和占比") public AjaxResult getOrgNumAndRateByPro(ProData proData) { try { List> list = homeDataService.getOrgNumAndRateByPro(proData); return AjaxResult.success(list); } catch (Exception e) { e.printStackTrace(); logger.error("地市工程数量和占比", e); return AjaxResult.success(null); } } @PostMapping(value = "getOrgNumAndRateByProNew") // @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "地市工程数量和占比") public AjaxResult getOrgNumAndRateByProNew(ProData proData) { try { List> list = homeDataService.getOrgNumAndRateByProNew(proData); return AjaxResult.success(list); } catch (Exception e) { e.printStackTrace(); logger.error("地市工程数量和占比", e); return AjaxResult.success(null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 地市周风险数量和占比 * @Param weekRiskData * @date 2023-01-31 9:24 */ @PostMapping(value = "getOrgNumAndRateByWeek") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "地市周风险数量和占比") public AjaxResult getOrgNumAndRateByWeek(WeekRiskData weekRiskData) { try { Map map = homeDataService.getOrgNumAndRateByWeek(weekRiskData); return AjaxResult.success(map); } catch (Exception e) { e.printStackTrace(); logger.error("地市周风险数量和占比", e); return AjaxResult.success(null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 地市周风险数量和占比-二级页面 * @Param weekRiskData * @date 2023-01-31 15:11 */ @PostMapping(value = "getOrgNumAndRateByWeekChild") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "地市周风险数量和占比二级页面") public AjaxResult getOrgNumAndRateByWeekChild(WeekRiskData weekRiskData) { try { List> list = homeDataService.getOrgNumAndRateByWeekChild(weekRiskData); return AjaxResult.success(list); } catch (Exception e) { e.printStackTrace(); logger.error("地市周风险数量和占比-二级页面", e); return AjaxResult.success(null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 地市作业票数量和占比-二级页面 * @Param ticketData * @date 2023-02-01 9:21 */ @PostMapping(value = "getOrgNumAndRateByTicket") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "地市作业票数量和占比二级页面") public AjaxResult getOrgNumAndRateByTicket(TicketData ticketData) { try { List> list = homeDataService.getOrgNumAndRateByTicket(ticketData); return AjaxResult.success(list); } catch (Exception e) { e.printStackTrace(); logger.error("地市作业票数量和占比-二级页面", e); return AjaxResult.success(null); } } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 根据工程类型和地市编码获取在建工程、在施工程、停工工程数量 * @Param proType * @Param orgId * @date 2023-03-02 15:54 */ @PostMapping(value = "getProNumByType") public AjaxResult getProNumByType(String proType, String orgId) { try { Map map = homeDataService.getProNumByType(proType, orgId); return AjaxResult.success("获取成功", map); } catch (Exception e) { e.printStackTrace(); logger.error("根据工程类型获取在建工程、在施工程、停工工程error", e); return AjaxResult.error("服务异常,请稍后重试"); } } /** * @return java.util.Map * @author cw chen * @description 获取在建、在施、停工数据列表 * @Param proData * @date 2023-03-02 16:58 */ @PostMapping(value = "getProListByType") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "工程列表") public Map getProListByType(ProData proData) { Map map = new HashMap(16); try { PageHelper.startPage(Integer.parseInt(proData.getPage()), Integer.parseInt(proData.getLimit())); PageInfo pageInfo = homeDataService.getProListByType(proData); map.put("code", 200); map.put("msg", "获取数据成功"); map.put("count", pageInfo.getTotal()); map.put("curr", Integer.parseInt(proData.getPage())); map.put("limit", Integer.parseInt(proData.getLimit())); map.put("data", pageInfo.getList()); } catch (Exception e) { map.put("code", 500); map.put("msg", "服务异常请稍后重试"); map.put("count", 0); map.put("curr", Integer.parseInt(proData.getPage())); map.put("limit", Integer.parseInt(proData.getLimit())); map.put("data", null); } return map; } /** * 站班会数据统计 * * @return */ @PostMapping(value = "getClassMettingData") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "站班会统计") public AjaxResult getClassMettingData(ClassMettingStaVo vo) { return success(homeDataService.getClassMettingData(vo)); } /** * 站班会数据统计 * * @return */ @PostMapping(value = "getClassMettingList") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "站班会详情") public Map getClassMettingList(ClassMettingStaVo vo) { Map map = new HashMap(16); try { PageHelper.startPage(Integer.parseInt(vo.getPage()), Integer.parseInt(vo.getLimit())); PageInfo pageInfo = homeDataService.getClassMettingList(vo); map.put("code", 200); map.put("msg", "获取数据成功"); map.put("count", pageInfo.getTotal()); map.put("curr", Integer.parseInt(vo.getPage())); map.put("limit", Integer.parseInt(vo.getLimit())); map.put("data", pageInfo.getList()); } catch (Exception e) { map.put("code", 500); map.put("msg", "服务异常请稍后重试"); map.put("count", 0); map.put("curr", Integer.parseInt(vo.getPage())); map.put("limit", Integer.parseInt(vo.getLimit())); map.put("data", null); } return map; } /** * @return com.securityControl.common.core.web.domain.AjaxResult * @author cw chen * @description 地市站班会数量和占比-二级页面 * @Param vo * @date 2023-03-07 10:58 */ @PostMapping(value = "getOrgNumAndRateByClass") public AjaxResult getOrgNumAndRateByClass(ClassMettingStaVo vo) { try { List> list = homeDataService.getOrgNumAndRateByClass(vo); return AjaxResult.success(list); } catch (Exception e) { e.printStackTrace(); logger.error("地市站班会数量和占比-二级页面", e); return AjaxResult.success(null); } } @PostMapping(value = "getOrgNumAndRateByDailPlan") @Log(title = "综合展示", menu = "日计划详情", businessType = BusinessType.QUERY, details = "日计划组织机构占比-二级页面") public AjaxResult getOrgNumAndRateByDailPlan(DailyPlanVo dailyPlanVo) { try { List> list = homeDataService.getOrgNumAndRateByDailPlan(dailyPlanVo); return AjaxResult.success(list); } catch (Exception e) { e.printStackTrace(); logger.error("日计划组织机构占比-二级页面", e); return AjaxResult.success(null); } } @PostMapping(value = "getDailPlanList") @Log(title = "综合展示", menu = "综合展示", businessType = BusinessType.QUERY, details = "日计划-日计划详情") public Map getDailPlanList(DailyPlanHome dailyPlanVo) { PageHelper.startPage(dailyPlanVo.getPage(), dailyPlanVo.getLimit()); Map map = new HashMap(16); try { PageInfo pageInfo = homeDataService.getNewDailPlanList(dailyPlanVo); // PageInfo pageInfo = homeDataService.getDailPlanList(dailyPlanVo); map.put("code", 200); map.put("msg", "获取数据成功"); map.put("count", pageInfo.getTotal()); map.put("curr",dailyPlanVo.getPage()); map.put("limit", dailyPlanVo.getLimit()); map.put("data", pageInfo.getList()); } catch (Exception e) { log.error(e.toString(), e); map.put("code", 200); map.put("msg", "获取数据失败"); map.put("count", 0); map.put("curr", dailyPlanVo.getPage()); map.put("limit", dailyPlanVo.getLimit()); map.put("data", null); } return map; } @PostMapping("getWeekTime") public AjaxResult getWeekTime(String time){ Map map = new HashMap(16); try{ if(StringHelper.isEmpty(time)){ time=DateTimeHelper.getNowDay(); } int nowWeek= DateTimeHelper.getNowWeeks(time);//周开始 String startWeek=DateTimeHelper.getWeekStartOrEndTime(time,true);//本周开始时间 String endWeek= DateTimeHelper.getWeekStartOrEndTime(time,false);//本周结束时间 map.put("year",time.split("-")[0]); map.put("week",nowWeek); map.put("startWeek",Integer.parseInt(startWeek.split("-")[1])+"月"+Integer.parseInt(startWeek.split("-")[2])+"日"); map.put("endWeek",Integer.parseInt(endWeek.split("-")[1])+"月"+Integer.parseInt(endWeek.split("-")[2])+"日"); return AjaxResult.success(map); }catch (Exception e){ log.error(e.toString(), e); } return AjaxResult.error("错误"); } /** * 获取地市违章信息 * @param orgId * @return */ @PostMapping("getWzXx") public AjaxResult getWzXx(String orgId){ try{ Integer num= homeDataService.getWzXx(orgId); return AjaxResult.success(num); }catch (Exception e){ log.error(e.toString(), e); } return AjaxResult.success(0); } /** * 查询杆塔集合 * @param * @return */ @PostMapping("getGtList") public AjaxResult getGtList(TowerVo params ){ try{ List list= homeDataService.getGtList(params); return AjaxResult.success(list); }catch (Exception e){ log.error(e.toString(), e); } return AjaxResult.success(0); } /** * 获取地市违章信息 * @param orgId * @return */ @PostMapping("getIsBg") public AjaxResult getIsBg(String orgId){ try{ Integer num= homeDataService.getIsBg(orgId); return AjaxResult.success(num); }catch (Exception e){ log.error(e.toString(), e); } return AjaxResult.success(0); } /** * 导出周风险 */ @GetMapping("downWeekPlan") public void downWeekPlan(HttpServletRequest request, HttpServletResponse response, String time) { try{ if(StringHelper.isEmpty(time)){ time=DateTimeHelper.getNowDay(); } Map maps = new HashMap<>(16); int nowWeek= DateTimeHelper.getNowWeeks(time);//周开始 int lastWeek=nowWeek-1;//上周 maps.put("nowWeek",nowWeek); maps.put("lastWeek",lastWeek); String startWeek=DateTimeHelper.getWeekStartOrEndTime(time,true);//本周开始时间 String endWeek= DateTimeHelper.getWeekStartOrEndTime(time,false);//本周结束时间 maps.put("startWeek",startWeek); maps.put("endWeek",endWeek); String lastTime=DateTimeHelper.getDayADDorReduce(time,-7);//获取上周时间 String lastStartWeek=DateTimeHelper.getWeekStartOrEndTime(lastTime,true);//上周开始时间 String lastEndWeek=DateTimeHelper.getWeekStartOrEndTime(lastTime,false);//上周结束时间 Map map=homeDataService.getWeekRiskNumByWeekTime(startWeek,endWeek);// Map map2=homeDataService.getWeekRiskNumByWeekTime(lastStartWeek,lastEndWeek);// map.replaceAll((k, v) -> String.valueOf(v)); //本周 maps.put("plan",map.get("planNum")); maps.put("twoPlan",map.get("twoRisk")); maps.put("threePlan",map.get("threeRisk")); maps.put("forePlan",map.get("foureRisk")); //上周 maps.put("lPlan",map2.get("planNum")); maps.put("ltwoPlan",map2.get("twoRisk")); maps.put("lthreePlan",map2.get("threeRisk")); maps.put("lforePlan",map2.get("foureRisk")); //环比 map.get("planNum").toString(); maps.put("palnhb",getHBValue(map2.get("planNum").toString(),map.get("planNum").toString())); maps.put("twoPlanhb",getHBValue(map2.get("twoRisk").toString(),map.get("twoRisk").toString())); maps.put("threePlanhb",getHBValue(map2.get("threeRisk").toString(),map.get("threeRisk").toString())); maps.put("forePlanhb",getHBValue(map2.get("foureRisk").toString(),map.get("foureRisk").toString())); List> list5=getRiskTableData(startWeek,endWeek,lastStartWeek,lastEndWeek,"三级"); maps.put("table1",list5); List> list6=getRiskTableData(startWeek,endWeek,lastStartWeek,lastEndWeek,"二级"); maps.put("table2",list6); List> list7=getNexWeekPro(startWeek,endWeek,"二级");//风险等级 maps.put("list1",list7); WordUtils.exportMillCertificateWord(request, response, maps, "周计划", "weekWord.ftl"); }catch (Exception e){ log.error(e.toString(),e); } } /** * 日计划导出功能 * @param request * @param response * @param time */ @GetMapping("downDayPlan") public void exportDayPlan(HttpServletRequest request, HttpServletResponse response, String time){ try{ Map maps = new HashMap<>(16); List> list=new ArrayList<>(); if(StringHelper.isEmpty(time)){ time=DateTimeHelper.getNowDay(); } //本周开始时间 String startWeek=DateTimeHelper.getWeekStartOrEndTime(time,true); for (int i = 0; i < 7; i++) { //时间叠加 String lastTime=DateTimeHelper.getDayADDorReduce(startWeek,i); //获取到户数 Map map=homeDataService.getAllRiskLevelNum(lastTime); map.replaceAll((k, v) -> String.valueOf(v)); String[] times=lastTime.split("-"); String date=Integer.parseInt(times[1])+"."+Integer.parseInt(times[2])+"("+getWeekDate(i)+")"; Map riskMap=Maps.newHashMap(); riskMap.put("date",date); riskMap.put("twoRisk",map.get("twoRisk").toString()); riskMap.put("threeRisk",map.get("threeRisk").toString()); riskMap.put("fourRisk",map.get("foureRisk").toString()); riskMap.put("allNum",map.get("planNum").toString()); list.add(riskMap); } maps.put("list",list); WordUtils.exportMillCertificateWord(request, response, maps, "日计划", "dayPlan.ftl"); }catch (Exception e){ log.error(e.toString(),e); } } public String getWeekDate(int i){ switch (i) { case 0: return "周一"; case 1: return "周二"; case 2: return "周三"; case 3: return "周四"; case 4: return "周五"; case 5: return "周六"; case 6: return "周日"; } return i+1+""; } /** * 依据风险和 日期获取下周风险工程 * @return */ public List> getNexWeekPro(String startWeek,String endWeek,String riskLevel){ List> list5 =new ArrayList<>(); try{ List list=homeDataService.getNexWeekPro(startWeek,endWeek,riskLevel); if(ListHelper.isEmpty(list)){ WeekPlanVo vo=new WeekPlanVo(); vo.setCityName("下周暂无二级风险施工"); vo.setProName("下周暂无二级风险施工"); vo.setWorkContent("下周暂无二级风险施工"); vo.setWorkType("无"); } int i=1; for (WeekPlanVo weekPlanVo:list) { Map twoRiskMap=Maps.newHashMap(); twoRiskMap.put("index",i); twoRiskMap.put("cityName",weekPlanVo.getCityName()); twoRiskMap.put("proName",weekPlanVo.getProName()); twoRiskMap.put("workType",weekPlanVo.getWorkType()); twoRiskMap.put("workContent",weekPlanVo.getWorkContent());//环比 i++; list5.add(twoRiskMap); } }catch (Exception e){ log.error(e.toString(),e); } return list5; } public List> getRiskTableData(String startWeek, String endWeek,String lastStartWeek,String lastEndWeek, String riskLevel){ List> list5 =new ArrayList<>(); try{ List riskList=homeDataService.getWeekRiskByRiskLevel(startWeek,endWeek,riskLevel);// //上周的二级统计 List riskList2=homeDataService.getWeekRiskByRiskLevel(lastStartWeek,lastEndWeek,riskLevel); if(ListHelper.isEmpty(riskList)){ MapsValueVo mapsValueVo=new MapsValueVo(); mapsValueVo.setName("合计"); mapsValueVo.setNum("0"); riskList.add(mapsValueVo); } int i=1; for (MapsValueVo mapsValueVo: riskList) { MapsValueVo vo=getLastMapValue(riskList2,mapsValueVo.getName());//获取上周数量 Map twoRiskMap=Maps.newHashMap(); twoRiskMap.put("index",i); twoRiskMap.put("name",mapsValueVo.getName()); twoRiskMap.put("lastNum",vo.getNum()); twoRiskMap.put("num",mapsValueVo.getNum()); twoRiskMap.put("hb",getHBValue(vo.getNum(),mapsValueVo.getNum()));//环比 i++; list5.add(twoRiskMap); } }catch (Exception e){ log.error(e.toString(),e); } return list5; } /** * 获取上周数据 * @return */ public MapsValueVo getLastMapValue(List list,String key){ MapsValueVo mapsValueVo=new MapsValueVo(); try{ for (MapsValueVo maps:list) { if(key.equals(maps.getName())){ return maps; } } mapsValueVo.setName(key); mapsValueVo.setNum("0"); }catch (Exception e){ mapsValueVo.setName(key); mapsValueVo.setNum("0"); log.error(e.toString(),e); } return mapsValueVo; } /** * 导出日计划 */ public String getHBValue(String value,String value1){ try{ Double num=Double.parseDouble(value); Double num1=Double.parseDouble(value1); if(num==0.0 && num1!=0.0){ return "100%"; } Double values=(num1-num)*100/num; Double result = Math.round (values * 10) / 10.0; if(result==0.0){ return "0"; } return result.toString()+"%"; }catch (Exception e){ log.error(e.toString(),e); } return "0"; } }