首页统计

This commit is contained in:
Renpc-kilig 2021-11-29 18:35:17 +08:00
parent 6d80d55afa
commit eccbae8c65
9 changed files with 986 additions and 0 deletions

View File

@ -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<StatisticsDTO> taskSysInfo() {
Map<String, Object> params = requestParams();
return statisticsService.taskSysInfo(params);
}
@ApiOperation(value = "任务系统总体数据", notes = "任务系统总体数据接口")
@ApiImplicitParams({})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("task_report_info")
public List<StatisticsLineDTO> taskReportInfo() {
Map<String, Object> params = requestParams();
return statisticsService.taskReportInfo(params);
}
}

View File

@ -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<StatisticsDTO> taskSysInfo(@RequestHeader("token") String token) {
AppTokenUser appTokenUser = null;
try{
appTokenUser = securityComponent.getAppTokenUser(token);
}catch (Exception e) {
e.printStackTrace();
}
Map<String, Object> params = requestParams();
params.put("userId", appTokenUser.getId());
params.put("token", token);
List<AppTokenUserDepartment> 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<StatisticsDTO> taskSysInfoDept(@RequestHeader("token") String token, @PathVariable("deptIds") String deptIds) {
List<String> userIdList = departmentUserService.listUserId(Arrays.asList(deptIds.split(",")).get(0));
System.out.println(userIdList);
Map<String, Object> 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<StatisticsLineDTO> taskReportInfo() {
Map<String, Object> params = requestParams();
return statisticsService.taskReportInfo(params);
}
}

View File

@ -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<String, Object> params) throws SearchException;
/**
* 任务上报数量
* @param params
* @return
*/
Integer taskPatrolCount(Map<String, Object> params) throws SearchException;
/**
* 任务上报数量
* @param params
* @return
*/
Integer taskReportInfo(Map<String, Object> params) throws SearchException;
}

View File

@ -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;
}
}

View File

@ -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<StatisticsDTO> 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<StatisticsDTO> getStatisticsDTOList() {
return statisticsDTOList;
}
public void setStatisticsDTOList(List<StatisticsDTO> statisticsDTOList) {
this.statisticsDTOList = statisticsDTOList;
}
}

View File

@ -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<StatisticsDTO> taskSysInfo(Map<String, Object> params);
/**
* 预警任务数量
* @param params
* @return
*/
Integer warningCount(Map<String, Object> params);
/**
* 督办任务数量
* @param params
* @return
*/
Integer superviseCount(Map<String, Object> params);
/**
* 代办任务数量
* @param params
* @return
*/
Integer agencyCount(Map<String, Object> params);
/**
* 普通任务数量
* @param params
* @return
*/
Integer ordinaryCount(Map<String, Object> params);
/**
* 巡查任务数量
* @param params
* @return
*/
Integer patrolCount(Map<String, Object> params);
/**
* 任务上报数量
* @param params
* @return
*/
Integer taskPatrolCount(Map<String, Object> params);
/**
* 任务上报数量
* @param params
* @return
*/
List<StatisticsLineDTO> taskReportInfo(Map<String, Object> params);
}

View File

@ -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<StatisticsDTO> taskSysInfo(Map<String, Object> params) {
List<StatisticsDTO> 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<String, Object> params) {
return statisticsDao.taskCount(params);
}
@Override
public Integer superviseCount(Map<String, Object> params) {
return statisticsDao.taskCount(params);
}
@Override
public Integer agencyCount(Map<String, Object> params) {
return statisticsDao.taskCount(params);
}
@Override
public Integer ordinaryCount(Map<String, Object> params) {
return statisticsDao.taskCount(params);
}
@Override
public Integer patrolCount(Map<String, Object> params) {
return statisticsDao.taskCount(params);
}
@Override
public Integer taskPatrolCount(Map<String, Object> params) {
return statisticsDao.taskPatrolCount(params);
}
@Override
public List<StatisticsLineDTO> taskReportInfo(Map<String, Object> params) {
List<StatisticsLineDTO> 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<StatisticsDTO> 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;
}
}

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.tenlion.systemtask.dao.statistics.IStatisticsDao">
<resultMap id="statisticsDTO" type="cn.com.tenlion.systemtask.pojo.dtos.statistics.StatisticsDTO">
<result column="dataType" property="dataType"/>
<result column="count" property="count"/>
</resultMap>
<!-- 任务数量 -->
<select id="taskCount" parameterType="map" resultType="Integer">
SELECT
COUNT(t1.receiver_user_id)
FROM
task_receiver_user t1 LEFT JOIN task_distribute t2 ON t1.distribute_id = t2.distribute_id AND t2.is_delete = 0
WHERE
t1.is_delete = 0
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
<if test="userId != null and userId != ''">
AND
t1.user_id = #{userId}
</if>
<if test="isWarning != null and isWarning != ''">
AND
t1.is_warning = #{isWarning}
</if>
<if test="isSupervision != null and isSupervision != ''">
AND
t1.is_supervision = #{isSupervision}
</if>
<if test="executeStatus != null and executeStatus != ''">
AND
t1.execute_status = #{executeStatus}
</if>
<if test="wrongExecuteStatus != null and wrongExecuteStatus != ''">
AND
t1.execute_status &lt;&gt; #{wrongExecuteStatus}
</if>
<if test="taskType != null and taskType != ''">
AND
t1.task_type = #{taskType}
</if>
<if test="distributeTaskType != null and distributeTaskType != ''">
AND
t2.distribute_task_type = #{distributeTaskType}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t2.distribute_time, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t2.distribute_time, 10) <![CDATA[ <= ]]> #{endTime}
</if>
</select>
<!-- 任务上报数量 -->
<select id="taskPatrolCount" parameterType="map" resultType="Integer">
SELECT
COUNT(t1.receiver_user_patrol_id)
FROM
task_receiver_user_patrol t1
WHERE
t1.is_delete = 0
<if test="patrolTime != null and patrolTime != ''">
AND LEFT(t1.patrol_time, 10) = #{patrolTime}
</if>
</select>
</mapper>

View File

@ -0,0 +1,339 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
*{margin:0;padding:0;}
[v-cloak]{display: none}
ul{list-style: none}
.container{width: 97%;margin:0 auto;}
.tab{margin-bottom: 10px;float: right;width: 74%;height:140px;overflow-y: auto}
.top:after, .tab:after, .list:after{content: '';display: block;clear: both}
.logo-box{float: left;width:25%;}
.logo{max-width: 100%;height:183px;}
.box h3{white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 18px;font-weight: normal;color: #000;}
.list-box{float:left;width: 18%;padding: 5px;box-sizing: border-box;border-top: 1px solid #000;border-bottom: 1px solid #000;border-left: 1px solid #000;}
.list-box:last-child{margin-right: 0}
.list-box h4{font-size: 16px;font-weight: normal;color: #000;}
.list-box ul li{height: 35px;color: #000;border-bottom: 1px solid #DDD;font-size: 0}
.list-box ul li a{display:inline-block;margin-right:5px;color: #000;text-decoration: none;font-size: 14px;line-height: 35px;vertical-align: top;}
.list-box ul li span{float:right;font-size: 14px;line-height: 35px;display: inline-block;max-width: 70%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;vertical-align: top;}
.layui-card-body{padding: 0 15px;}
</style>
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card" style="height: 1000px;">
<div class="layui-card-body">
<div class="list" style="padding-left: 15px;padding-right: 15px;">
<div class="list-box" style="margin-top:61px;">
<ul>
<li>
<span id="YJDiv">预警任务</span>
</li>
<li>
<span id="YJCountDiv"></span>
</li>
</ul>
</div>
<div class="list-box" style="margin-top:61px;">
<ul>
<li>
<span id="DUBDiv">督办任务</span>
</li>
<li>
<span id="DUBCountDiv"></span>
</li>
</ul>
</ul>
</div>
<div class="list-box" style="margin-top:61px;">
<ul>
<li>
<span id="DBDiv">待办任务</span>
</li>
<li>
<span id="DBCountDiv"></span>
</li>
</ul>
</ul>
</div>
<div class="list-box" style="margin-top:61px;">
<ul>
<li>
<span id="PTDiv">普通任务</span>
</li>
<li>
<span id="PTCountDiv"></span>
</li>
</ul>
</ul>
</div>
<div class="list-box" style="margin-top:61px;border-right: 1px solid #000;">
<ul>
<li>
<span id="XCDiv">巡查任务</span>
</li>
<li>
<span id="XCCountDiv"></span>
</li>
</ul>
</ul>
</div>
</div>
<div class="list" style="padding-left: 15px;padding-right: 15px;">
<div>
<input type="text" name="lineDate" id="lineDate" placeholder="年-月">
</div>
<div id="lineDiv" style="width: 1000px;height:360px;margin: 40px auto 0 70px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="assets/js/vue.min.js"></script>
<script type="text/javascript" src="assets/js/vendor/echarts/echarts.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'form', 'table', 'laydate', 'common', 'laytpl'], function() {
var $ = layui.$;
var $win = $(window);
var laytpl = layui.laytpl;
var form = layui.form;
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/statistics/task_sys_info';
var lineUrl = 'api/statistics/task_report_info';
var selectedAreaArray = [];
var app = {};
laydate.render({
elem: '#lineDate',
type: 'month',
format: 'yyyy-MM',
done:function(value,data){
reloadLineData(value);
}
})
// 年度重大事件统计柱状图
function lineCharts(data) {
var chartDom = document.getElementById('lineDiv');
var myChart = echarts.init(chartDom);
var option;
var lengendData = [];
var xAxisData = [];
var yAxisSeriesData = [];
var title;
if(!$.isEmptyObject(data)) {
var lineDataArr = data;
var statisticsDTOList = lineDataArr[0].statisticsDTOList;
lengendData.push('任务上报量')
if(null != lineDataArr && lineDataArr.length > 0) {
var seriesData = [];
var yAxisSeriesDataObj = {};
for (let key in lineDataArr) {
yAxisSeriesDataObj.type = 'line';
yAxisSeriesDataObj.stack = 'Total';
yAxisSeriesDataObj.name = lengendData[0];
var subList = lineDataArr[key].statisticsDTOList;
seriesData.push(subList[0]['count']);
}
yAxisSeriesDataObj.data = seriesData;
yAxisSeriesData.push(yAxisSeriesDataObj);
for (let key in lineDataArr) {
xAxisData.push(lineDataArr[key].day);
title = lineDataArr[key].month + '月任务上报量';
}
}
}
console.log(lengendData)
console.log(xAxisData)
console.log(yAxisSeriesData)
option = {
title: {
text: title
},
tooltip: {
trigger: 'axis'
},
legend: {
data: lengendData
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: xAxisData
},
yAxis: {
type: 'value'
},
series: yAxisSeriesData
};
option && myChart.setOption(option);
}
function reloadLineData(dateTime) {
var layIndex;
top.restAjax.get(top.restAjax.path(lineUrl + '?dateTime={dateTime}', [dateTime]), {}, null, function (code, data) {
lineCharts(data);
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
function initLineData() {
var layIndex;
top.restAjax.get(top.restAjax.path(lineUrl, []), {}, null, function (code, data) {
lineCharts(data);
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
initLineData();
function initTaskSysInfoData() {
var layIndex;
top.restAjax.get(top.restAjax.path(tableUrl, []), {}, null, function (code, data) {
for(var i=0;i<data.length;i++) {
$("div.list div").each(function(){
if(data[i].dataType == $(this).find('ul li:first').find('span').text()) {
$(this).find('ul li:first').siblings().find('span').text(data[i].count);
}
})
}
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
initTaskSysInfoData();
// 选择区域
$(document).on('click', '#area', function() {
top.dialog.open({
title: '选择地区',
url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#area').val())]),
width: '800px',
height: '225px',
onClose: function () {
selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
console.log(selectedAreaArray)
var areaCode = '';
var areaName = '';
if (selectedAreaArray.length > 0) {
areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
for (var i = 0, item; item = selectedAreaArray[i++];) {
if (areaName) {
areaName += ',';
}
areaName += item.areaName;
$('#areaId_' + i).val(item.areaId);
}
}
$('#area').val(areaName);
}
})
});
// 重载表格
function reloadTable(currentPage) {
initTaskSysInfoData();
initLineData();
}
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#startTime',
format: 'yyyy-MM-dd HH:mm:ss'
});
laydate.render({
elem: '#endTime',
format: 'yyyy-MM-dd HH:mm:ss'
});
}
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 事件 - 清空搜索条件
$(document).on('click', '#reset', function() {
$('#keywords').val('');
$('#startTime').val('');
$('#endTime').val('');
$('#area').val('');
$('#areaId_1').val('');
$('#areaId_2').val('');
$('#areaId_3').val('');
$('#areaId_4').val('');
$('#areaId_5').val('');
$('#receiverUser').val('');
$('#userId').val('');
$('#urgentLevel').val('');
$('#reportCount').val('');
});
});
</script>
</body>
</html>