From eccbae8c653037f4c9e4a780ca0c746ffbfee7b5 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Mon, 29 Nov 2021 18:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/statistics/StatisticsController.java | 52 +++ .../statistics/StatisticsAppController.java | 89 +++++ .../dao/statistics/IStatisticsDao.java | 40 +++ .../pojo/dtos/statistics/StatisticsDTO.java | 37 ++ .../dtos/statistics/StatisticsLineDTO.java | 80 +++++ .../statistics/IStatisticsService.java | 74 ++++ .../impl/StatisticsServiceImpl.java | 198 ++++++++++ .../mapper/statistics/statistics-mapper.xml | 77 ++++ .../resources/templates/default-home.html | 339 ++++++++++++++++++ 9 files changed, 986 insertions(+) create mode 100644 src/main/java/cn/com/tenlion/systemtask/controller/api/statistics/StatisticsController.java create mode 100644 src/main/java/cn/com/tenlion/systemtask/controller/app/api/statistics/StatisticsAppController.java create mode 100644 src/main/java/cn/com/tenlion/systemtask/dao/statistics/IStatisticsDao.java create mode 100644 src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsDTO.java create mode 100644 src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsLineDTO.java create mode 100644 src/main/java/cn/com/tenlion/systemtask/service/statistics/IStatisticsService.java create mode 100644 src/main/java/cn/com/tenlion/systemtask/service/statistics/impl/StatisticsServiceImpl.java create mode 100644 src/main/resources/mybatis/mapper/statistics/statistics-mapper.xml create mode 100644 src/main/resources/templates/default-home.html diff --git a/src/main/java/cn/com/tenlion/systemtask/controller/api/statistics/StatisticsController.java b/src/main/java/cn/com/tenlion/systemtask/controller/api/statistics/StatisticsController.java new file mode 100644 index 0000000..971a133 --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/controller/api/statistics/StatisticsController.java @@ -0,0 +1,52 @@ +package cn.com.tenlion.systemtask.controller.api.statistics; + +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO; +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsLineDTO; +import cn.com.tenlion.systemtask.service.statistics.IStatisticsService; +import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.login.oauth2.client.service.department.IDepartmentUserService; +import ink.wgink.pojo.result.ErrorResult; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: StatisticsController + * @Description: 统计 + * @Author: CodeFactory + * @Date: 2021-09-24 17:03:54 + * @Version: 3.0 + **/ +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "统计接口") +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/statistics") +public class StatisticsController extends DefaultBaseController { + + @Autowired + private IStatisticsService statisticsService; + + @ApiOperation(value = "任务系统总体数据", notes = "任务系统总体数据接口") + @ApiImplicitParams({}) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("task_sys_info") + public List taskSysInfo() { + Map params = requestParams(); + return statisticsService.taskSysInfo(params); + } + + @ApiOperation(value = "任务系统总体数据", notes = "任务系统总体数据接口") + @ApiImplicitParams({}) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("task_report_info") + public List taskReportInfo() { + Map params = requestParams(); + return statisticsService.taskReportInfo(params); + } + +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemtask/controller/app/api/statistics/StatisticsAppController.java b/src/main/java/cn/com/tenlion/systemtask/controller/app/api/statistics/StatisticsAppController.java new file mode 100644 index 0000000..e634f90 --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/controller/app/api/statistics/StatisticsAppController.java @@ -0,0 +1,89 @@ +package cn.com.tenlion.systemtask.controller.app.api.statistics; + +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO; +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsLineDTO; +import cn.com.tenlion.systemtask.service.statistics.IStatisticsService; +import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.common.component.SecurityComponent; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.login.oauth2.client.service.department.IDepartmentUserService; +import ink.wgink.pojo.app.AppTokenUser; +import ink.wgink.pojo.app.AppTokenUserDepartment; +import ink.wgink.pojo.result.ErrorResult; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: StatisticsController + * @Description: 统计 + * @Author: CodeFactory + * @Date: 2021-09-24 17:03:54 + * @Version: 3.0 + **/ +@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "统计接口") +@RestController +@RequestMapping(ISystemConstant.APP_PREFIX + "/statistics") +public class StatisticsAppController extends DefaultBaseController { + + @Autowired + private IStatisticsService statisticsService; + @Autowired + protected SecurityComponent securityComponent; + @Autowired + private IDepartmentUserService departmentUserService; + + @ApiOperation(value = "任务系统总体数据", notes = "任务系统总体数据接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query"), + @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("task_sys_info") + public List taskSysInfo(@RequestHeader("token") String token) { + AppTokenUser appTokenUser = null; + try{ + appTokenUser = securityComponent.getAppTokenUser(token); + }catch (Exception e) { + e.printStackTrace(); + } + Map params = requestParams(); + params.put("userId", appTokenUser.getId()); + params.put("token", token); + List appTokenUserDepartments = appTokenUser.getDepartments(); + System.out.println(appTokenUserDepartments); + return statisticsService.taskSysInfo(params); + } + + @ApiOperation(value = "任务系统每月任务上报数据", notes = "任务系统每月任务上报数据接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query"), + @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("task_sys_info_dept/{deptIds}") + public List taskSysInfoDept(@RequestHeader("token") String token, @PathVariable("deptIds") String deptIds) { + List userIdList = departmentUserService.listUserId(Arrays.asList(deptIds.split(",")).get(0)); + System.out.println(userIdList); + Map params = requestParams(); + params.put("token", token); + params.put("userIds", userIdList); + return statisticsService.taskSysInfo(params); + } + + @ApiOperation(value = "任务系统总体数据", notes = "任务系统总体数据接口") + @ApiImplicitParams({}) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("task_report_info") + public List taskReportInfo() { + Map params = requestParams(); + return statisticsService.taskReportInfo(params); + } + +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemtask/dao/statistics/IStatisticsDao.java b/src/main/java/cn/com/tenlion/systemtask/dao/statistics/IStatisticsDao.java new file mode 100644 index 0000000..d632d1f --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/dao/statistics/IStatisticsDao.java @@ -0,0 +1,40 @@ +package cn.com.tenlion.systemtask.dao.statistics; + +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO; +import ink.wgink.exceptions.SearchException; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: IStatisticsDao + * @Description: 统计 + * @Author: CodeFactory + * @Date: 2021-11-22 15:31:23 + * @Version: 3.0 + **/ +@Repository +public interface IStatisticsDao { + + /** + * 任务数量 + * @param params + * @return + */ + Integer taskCount(Map params) throws SearchException; + + /** + * 任务上报数量 + * @param params + * @return + */ + Integer taskPatrolCount(Map params) throws SearchException; + + /** + * 任务上报数量 + * @param params + * @return + */ + Integer taskReportInfo(Map params) throws SearchException; +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsDTO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsDTO.java new file mode 100644 index 0000000..8d43ce6 --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsDTO.java @@ -0,0 +1,37 @@ +package cn.com.tenlion.systemtask.pojo.dtos.statistics; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * + * @ClassName: StatisticsDTO + * @Description: 统计专用 + * @Author: CodeFactory + * @Date: 2021-09-17 14:43:53 + * @Version: 3.0 + **/ +@ApiModel +public class StatisticsDTO { + + @ApiModelProperty(name = "dataType", value = "数据类型") + private String dataType; + @ApiModelProperty(name = "count", value = "数量") + private String count; + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public String getCount() { + return count; + } + + public void setCount(String count) { + this.count = count; + } +} diff --git a/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsLineDTO.java b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsLineDTO.java new file mode 100644 index 0000000..510935e --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/pojo/dtos/statistics/StatisticsLineDTO.java @@ -0,0 +1,80 @@ +package cn.com.tenlion.systemtask.pojo.dtos.statistics; + +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +/** + * + * @ClassName: StatisticsDTO + * @Description: 统计专用 + * @Author: CodeFactory + * @Date: 2021-09-17 14:43:53 + * @Version: 3.0 + **/ +@ApiModel +public class StatisticsLineDTO { + + @ApiModelProperty(name = "dataType", value = "数据类型") + private String dataType; + @ApiModelProperty(name = "count", value = "数量") + private String count; + @ApiModelProperty(name = "year", value = "年份") + private String year; + @ApiModelProperty(name = "month", value = "月份") + private String month; + @ApiModelProperty(name = "day", value = "月份") + private String day; + @ApiModelProperty(name = "statisticsDTOList", value = "月份") + private List statisticsDTOList; + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public String getCount() { + return count; + } + + public void setCount(String count) { + this.count = count; + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public String getDay() { + return day; + } + + public void setDay(String day) { + this.day = day; + } + + public List getStatisticsDTOList() { + return statisticsDTOList; + } + + public void setStatisticsDTOList(List statisticsDTOList) { + this.statisticsDTOList = statisticsDTOList; + } +} diff --git a/src/main/java/cn/com/tenlion/systemtask/service/statistics/IStatisticsService.java b/src/main/java/cn/com/tenlion/systemtask/service/statistics/IStatisticsService.java new file mode 100644 index 0000000..585c3bb --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/service/statistics/IStatisticsService.java @@ -0,0 +1,74 @@ +package cn.com.tenlion.systemtask.service.statistics; + + +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO; +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsLineDTO; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: IResidentialIntroductionService + * @Description: 小区简介 + * @Author: CodeFactory + * @Date: 2021-11-22 15:31:23 + * @Version: 3.0 + **/ +public interface IStatisticsService { + + /** + * 任务系统总体数据 + * @param params + * @return + */ + List taskSysInfo(Map params); + + /** + * 预警任务数量 + * @param params + * @return + */ + Integer warningCount(Map params); + + /** + * 督办任务数量 + * @param params + * @return + */ + Integer superviseCount(Map params); + + /** + * 代办任务数量 + * @param params + * @return + */ + Integer agencyCount(Map params); + + /** + * 普通任务数量 + * @param params + * @return + */ + Integer ordinaryCount(Map params); + + /** + * 巡查任务数量 + * @param params + * @return + */ + Integer patrolCount(Map params); + + /** + * 任务上报数量 + * @param params + * @return + */ + Integer taskPatrolCount(Map params); + + /** + * 任务上报数量 + * @param params + * @return + */ + List taskReportInfo(Map params); +} \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/systemtask/service/statistics/impl/StatisticsServiceImpl.java b/src/main/java/cn/com/tenlion/systemtask/service/statistics/impl/StatisticsServiceImpl.java new file mode 100644 index 0000000..f6276e7 --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemtask/service/statistics/impl/StatisticsServiceImpl.java @@ -0,0 +1,198 @@ +package cn.com.tenlion.systemtask.service.statistics.impl; + + +import cn.com.tenlion.systemtask.dao.statistics.IStatisticsDao; +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO; +import cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsLineDTO; +import cn.com.tenlion.systemtask.service.statistics.IStatisticsService; +import cn.com.tenlion.systemtask.utils.StringHandler; +import ink.wgink.common.base.DefaultBaseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @ClassName: ResidentialIntroductionServiceImpl + * @Description: 小区简介 + * @Author: CodeFactory + * @Date: 2021-11-22 15:31:23 + * @Version: 3.0 + **/ +@Service +public class StatisticsServiceImpl extends DefaultBaseService implements IStatisticsService { + + @Autowired + private IStatisticsDao statisticsDao; + Calendar cal = Calendar.getInstance(); + + @Override + public List taskSysInfo(Map params) { + List statisticsDTOList = new ArrayList<>(); + // 预警任务 + params.put("isWarning", "1"); + Integer warningCount = warningCount(params); + params.remove("isWarning"); + StatisticsDTO statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("预警任务"); + statisticsDTO.setCount(warningCount.toString()); + statisticsDTOList.add(statisticsDTO); + // 督办任务 + params.put("isSupervision", "1"); + Integer superviseCount = superviseCount(params); + params.remove("isSupervision"); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("督办任务"); + statisticsDTO.setCount(superviseCount.toString()); + statisticsDTOList.add(statisticsDTO); + // 代办任务 + params.put("taskType", "正常"); + params.put("executeStatus", "未完成"); + Integer agencyCount = agencyCount(params); + params.remove("taskType"); + params.remove("executeStatus"); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("待办任务"); + statisticsDTO.setCount(agencyCount.toString()); + statisticsDTOList.add(statisticsDTO); + // 普通任务 + params.put("distributeTaskType", "普通任务"); + Integer ordinaryCount = ordinaryCount(params); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("普通任务"); + statisticsDTO.setCount(ordinaryCount.toString()); + statisticsDTOList.add(statisticsDTO); + // 巡查任务 + params.put("distributeTaskType", "巡查任务"); + Integer patrolCount = patrolCount(params); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("巡查任务"); + statisticsDTO.setCount(patrolCount.toString()); + statisticsDTOList.add(statisticsDTO); + + if(!StringHandler.isNull(params.get("token"))) { + // 未完成任务 + params.put("taskType", "正常"); + params.put("wrongExecuteStatus", "完成"); + Integer noOver = statisticsDao.taskCount(params); + params.remove("taskType"); + params.remove("wrongExecuteStatus"); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("未完成任务"); + statisticsDTO.setCount(noOver.toString()); + statisticsDTOList.add(statisticsDTO); + + // 完成任务 + params.put("taskType", "正常"); + params.put("executeStatus", "完成"); + Integer over = statisticsDao.taskCount(params); + params.remove("taskType"); + params.remove("executeStatus"); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("完成任务"); + statisticsDTO.setCount(over.toString()); + statisticsDTOList.add(statisticsDTO); + + // 超时任务 + params.put("taskType", "已超期"); + Integer overdue = statisticsDao.taskCount(params); + params.remove("taskType"); + params.remove("executeStatus"); + statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("超期任务"); + statisticsDTO.setCount(overdue.toString()); + statisticsDTOList.add(statisticsDTO); + } + return statisticsDTOList; + } + + @Override + public Integer warningCount(Map params) { + return statisticsDao.taskCount(params); + } + + @Override + public Integer superviseCount(Map params) { + return statisticsDao.taskCount(params); + } + + @Override + public Integer agencyCount(Map params) { + return statisticsDao.taskCount(params); + } + + @Override + public Integer ordinaryCount(Map params) { + return statisticsDao.taskCount(params); + } + + @Override + public Integer patrolCount(Map params) { + return statisticsDao.taskCount(params); + } + + @Override + public Integer taskPatrolCount(Map params) { + return statisticsDao.taskPatrolCount(params); + } + + @Override + public List taskReportInfo(Map params) { + List statisticsLineDTOList = new ArrayList<>(); + int day = 0; + int month = 0; + int year = 0; + if(null == params.get("dateTime")) { + params.put("year", cal.get(Calendar.YEAR)); + month = cal.get(Calendar.MONTH) + 1; + year = cal.get(Calendar.YEAR); + day = cal.get(Calendar.DAY_OF_MONTH); + }else { + String[] dateTime = params.get("dateTime").toString().split("-"); + year = Integer.valueOf(dateTime[0]); + month = Integer.valueOf(dateTime[1]); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + Calendar calendar = null; + try { + Date date = sdf.parse(params.get("dateTime").toString()); + calendar = Calendar.getInstance(); + calendar.setTime(date); + day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); + } catch (ParseException e) { + e.printStackTrace(); + } + } + String monthStr = ""; + if(month < 10) { + monthStr = "0" + month; + }else { + monthStr = "" + month; + } + for(int i=1;i<=day;i++) { + if (i < 10) { + params.put("patrolTime", year + "-" + monthStr + "-0" + i); + } else { + params.put("patrolTime", year + "-" + monthStr + "-" + i); + } + + StatisticsLineDTO statisticsLineDTO = new StatisticsLineDTO(); + statisticsLineDTO.setYear(String.valueOf(year)); + statisticsLineDTO.setMonth(String.valueOf(month)); + statisticsLineDTO.setDay(String.valueOf(i)); + List statisticsDTOList = new ArrayList<>(); + + Integer taskPatrolCount = taskPatrolCount(params); + StatisticsDTO statisticsDTO = new StatisticsDTO(); + statisticsDTO.setDataType("任务上报量"); + statisticsDTO.setCount(taskPatrolCount.toString()); + statisticsDTOList.add(statisticsDTO); + + statisticsLineDTO.setStatisticsDTOList(statisticsDTOList); + + statisticsLineDTOList.add(statisticsLineDTO); + } + return statisticsLineDTOList; + } +} \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/statistics/statistics-mapper.xml b/src/main/resources/mybatis/mapper/statistics/statistics-mapper.xml new file mode 100644 index 0000000..706b450 --- /dev/null +++ b/src/main/resources/mybatis/mapper/statistics/statistics-mapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/default-home.html b/src/main/resources/templates/default-home.html new file mode 100644 index 0000000..34818ba --- /dev/null +++ b/src/main/resources/templates/default-home.html @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
    +
  • + 预警任务 +
  • +
  • + +
  • +
+
+
+
    +
  • + 督办任务 +
  • +
  • + +
  • +
+ +
+
+
    +
  • + 待办任务 +
  • +
  • + +
  • +
+ +
+
+
    +
  • + 普通任务 +
  • +
  • + +
  • +
+ +
+
+
    +
  • + 巡查任务 +
  • +
  • + +
  • +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ + + + + + \ No newline at end of file