diff --git a/src/main/java/com/zcloud/controller/hiddenApi/HiddenApiController.java b/src/main/java/com/zcloud/controller/hiddenApi/HiddenApiController.java index eda8ac2e..a8b87855 100644 --- a/src/main/java/com/zcloud/controller/hiddenApi/HiddenApiController.java +++ b/src/main/java/com/zcloud/controller/hiddenApi/HiddenApiController.java @@ -1460,7 +1460,131 @@ public class HiddenApiController extends BaseController { return mv; } + /** + * 查询隐患统计表 + * @param response + * @return + * @throws Exception + */ + @RequestMapping(value = "/getCountSelect") + @ResponseBody + public Object getCountSelect(HttpServletResponse response) throws Exception { + PageData pd = new PageData(); + pd = this.getPageData(); + //这里进入开始获取数据阶段 首先拿到所有部门数据 + String url ="department_list.html?DEPARTMENT_ID="; + List departments = departmentService.listAllDepartment(Jurisdiction.getCORPINFO_ID(), url); + //装船部 zcb id集合 89f3d30c4031432da53b75bed442ced8 + List zcbdepartmentIds = new ArrayList<>(); + //保障部 bzb id集合 fcae9cc13a354be699d85d6aea3b3450 + List bzbdepartmentIds = new ArrayList<>(); + //卸车部 xcb id集合 aad337cf728b4cc2b63e210caf4e185f + List xcbdepartmentIds = new ArrayList<>(); + //安监部 ajb id集合 4c4b7bc93e3347978f5a3e1f0c4a0b56 + List ajbdepartmentIds = new ArrayList<>(); + //开始处理数据 扔进对应结合中 + for(Department department:departments){ + if(StringUtils.equals("89f3d30c4031432da53b75bed442ced8",department.getDEPARTMENT_ID())){ + zcbdepartmentIds = getIdsList(department,zcbdepartmentIds); + } + if(StringUtils.equals("fcae9cc13a354be699d85d6aea3b3450",department.getDEPARTMENT_ID())){ + bzbdepartmentIds = getIdsList(department,bzbdepartmentIds); + } + if(StringUtils.equals("aad337cf728b4cc2b63e210caf4e185f",department.getDEPARTMENT_ID())){ + xcbdepartmentIds = getIdsList(department,xcbdepartmentIds); + } + if(StringUtils.equals("4c4b7bc93e3347978f5a3e1f0c4a0b56",department.getDEPARTMENT_ID())){ + ajbdepartmentIds = getIdsList(department,ajbdepartmentIds); + } + } + //处理日期 类型 年 季度 月 + String type = pd.getString("type"); + String year = pd.getString("year"); + String num = pd.getString("num"); + String startTime = ""; + String endTime = ""; + //年 + if(StringUtils.equals("1",type)){ + startTime = year+"-01-01 00:00:00"; + endTime = year+"-12-31 23:59:59"; + } + //季度 + if(StringUtils.equals("2",type)){ + switch (num){ + case "1" : + startTime = year+"-01-01 00:00:00"; + endTime = year+"-03-31 23:59:59"; + break; + case "2" : + startTime = year+"-04-01 00:00:00"; + endTime = year+"-06-30 23:59:59"; + break; + case "3" : + startTime = year+"-07-01 00:00:00"; + endTime = year+"-09-30 23:59:59"; + break; + case "4" : + startTime = year+"-10-01 00:00:00"; + endTime = year+"-12-31 23:59:59"; + break; + } + } + //月 + if(StringUtils.equals("3",type)){ + startTime = year+"-01 00:00:00"; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + // 解析字符串为LocalDateTime + LocalDateTime dateTime = LocalDateTime.parse(startTime, formatter); + LocalDate localDate = dateTime.toLocalDate(); + LocalDate lastDayOfMonth = localDate.with(java.time.temporal.TemporalAdjusters.lastDayOfMonth()); + // 将LocalDateTime转换为ZonedDateTime(如果需要的话) + ZonedDateTime zonedDateTime = lastDayOfMonth.atStartOfDay(ZoneId.of("Asia/Shanghai")); + // 定义日期格式化器(仅日期部分) + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + // 格式化ZonedDateTime对象为仅包含日期的字符串 + String formattedDate = dateFormatter.format(zonedDateTime); + endTime = formattedDate+" 23:59:59"; + } + //前置搜索条件处理完毕 + pd.put("zcbdepartmentIds",zcbdepartmentIds); + pd.put("bzbdepartmentIds",bzbdepartmentIds); + pd.put("xcbdepartmentIds",xcbdepartmentIds); + pd.put("ajbdepartmentIds",ajbdepartmentIds); + pd.put("startTime",startTime); + pd.put("endTime",endTime); + //这里获取数据 获取指定日期范围内和指定部门集合创建的隐患总数 + Map map = hiddenService.getExcelMap(pd); + //年 + if(StringUtils.equals("1",type)){ + map.put("type","统计年度:"); + map.put("num",year+"年"); + } + //季度 + if(StringUtils.equals("2",type)){ + map.put("type","统计季度:"); + map.put("num",year+"年第"+num+"季度"); + } + //月 + if(StringUtils.equals("3",type)){ + String[] month = year.split("-"); + map.put("type","统计月度:"); + map.put("num",month[0]+"年第"+month[1]+"月"); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + String date =sdf.format(new Date()); + map.put("date","填表日期:"+date); + map.put("weidu",map.get("type").toString()+map.get("num").toString()); + Map Returnmap = new HashMap(); + Returnmap.put("result", "success"); + Returnmap.put("pd",map); + return Returnmap; + } + /** + * 导出隐患统计表 + * @param response + * @throws Exception + */ @RequestMapping(value = "/getCountExcel") public void exportExcels(HttpServletResponse response) throws Exception { PageData pd = new PageData(); diff --git a/src/main/java/com/zcloud/service/bus/impl/HiddenServiceImpl.java b/src/main/java/com/zcloud/service/bus/impl/HiddenServiceImpl.java index b653daba..2623644b 100644 --- a/src/main/java/com/zcloud/service/bus/impl/HiddenServiceImpl.java +++ b/src/main/java/com/zcloud/service/bus/impl/HiddenServiceImpl.java @@ -927,6 +927,13 @@ public class HiddenServiceImpl implements HiddenService{ //保障 map.put("ajbBzbGsc","保障部公司检查"+map.get("bzbGscZs").toString()+"项,已完成"+map.get("bzbGscZg").toString()+"项"); map.put("ajbBzbZc","自查"+map.get("bzbZcZs").toString()+"项,已完成"+map.get("bzbZcZg").toString()+"项"); + //各部门合计 + int allBuMenZs = Integer.parseInt(map.get("zcbZcZs").toString())+Integer.parseInt(map.get("xcbZcZs").toString())+Integer.parseInt(map.get("bzbZcZs").toString()); + int allBuMenHjZg = Integer.parseInt(map.get("zcbZcZg").toString())+Integer.parseInt(map.get("xcbZcZg").toString())+Integer.parseInt(map.get("bzbZcZg").toString()); + map.put("ajbHjZsTable",ajbHjZs); + map.put("ajbHjZgTable",ajbHjZg); + map.put("allBuMenZs",allBuMenZs); + map.put("allBuMenHjZg",allBuMenHjZg); return map; } }