新增综合统计网格员统计

This commit is contained in:
wanggeng888 2021-06-08 18:22:52 +08:00
parent 2d1470f505
commit 05dd5b0fbb
9 changed files with 346 additions and 11 deletions

View File

@ -161,6 +161,21 @@ public class CountController extends AbstractController {
return new SuccessResultData<>(result);
}
@ApiOperation(value = "网格员检查统计详情表", notes = "网格员检查统计详情表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "year", value = "年份", paramType = "path"),
@ApiImplicitParam(name = "areaId", value = "地区ID", paramType = "path"),
@ApiImplicitParam(name = "areaLevel", value = "地区等级", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-grid-check-detail-table/{year}/{areaId}/{areaLevel}")
public SuccessResultData<Map<String, Object>> countGridCheckDetailTable(@PathVariable("year") String year,
@PathVariable("areaId") String areaId,
@PathVariable("areaLevel") Integer areaLevel) {
Map<String, Object> result = countService.countGridCheckDetailTable(areaId, areaLevel, year);
return new SuccessResultData<>(result);
}
@ApiOperation(value = "隐患上报详情表", notes = "隐患上报详情表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "year", value = "年份", paramType = "path"),

View File

@ -74,6 +74,16 @@ public interface ICountService {
*/
SuccessResultData<Map<String, Object>> countCheckDetailTable(String areaId, Integer areaLevel, String year) throws SearchException;
/**
* 检查网格统计详情表
*
* @param areaId
* @param areaLevel
* @param year
* @return
*/
Map<String, Object> countGridCheckDetailTable(String areaId, Integer areaLevel, String year);
/**
* 隐患上报详情表
*
@ -115,4 +125,5 @@ public interface ICountService {
* @throws SearchException
*/
SuccessResultData<Map<String, Integer>> countCurrentMonthOfMine(String token) throws SearchException;
}

View File

@ -258,6 +258,76 @@ public class CountServiceImpl extends BaseService implements ICountService {
return new SuccessResultData<>(result);
}
@Override
public Map<String, Object> countGridCheckDetailTable(String areaId, Integer areaLevel, String year) {
Map<String, Object> params = getHashMap(5);
if (areaLevel == 2) {
params.put("area2", areaId);
} else if (areaLevel == 3) {
params.put("area3", areaId);
} else if (areaLevel == 4) {
params.put("area4", areaId);
} else if (areaLevel == 5) {
params.put("area5", areaId);
} else {
params.put("area1", areaId);
}
params.put("level", areaLevel);
List<Map<String, Object>> resultList = new ArrayList<>();
List<GridPersonnelDTO> gridPersonnelDTOs = gridPersonnelService.listGridPersonnel(params);
for (GridPersonnelDTO gridPersonnelDTO : gridPersonnelDTOs) {
List<String> userIdList = new ArrayList<>();
String[] userIdArray = gridPersonnelDTO.getUserId().split("\\|");
String userId = userIdArray[0];
String userName = userIdArray[2];
userIdList.add(userId);
Map<String, Object> resultListMap = getHashMap(16);
resultListMap.put("areaId", userId);
resultListMap.put("areaName", userName);
// 地区认领企业总数
Integer enterpriseReceiveCount = countEnterpriseOfGridAndArea(userId, areaId, areaLevel, year); // enterpriseOfGridOperatorService.countClaimedEnterprise(userId);
resultListMap.put("enterpriseReceiveCount", enterpriseReceiveCount);
// 年度计划数量
Integer checkPlanCount = checkPlanService.countCheckPlanByUserIdsAndYear(userIdList, year);
resultListMap.put("checkPlanCount", checkPlanCount);
// 实际检查企业统计
Integer checkCount = getCheckCountByYear(userIdList, year);
resultListMap.put("checkCount", checkCount);
resultListMap.put("completeRatio", checkPlanCount == null || checkPlanCount == 0 ? 0 : String.format("%.2f", (double) checkCount / checkPlanCount * 100));
// 待复查企业
List<String> listNeedReCheck = listNeedReCheckIds(userIdList);
List<CheckDTO> checkDTOs = listNeedReCheck(listNeedReCheck, year);
resultListMap.put("needReCheck", checkDTOs.size());
// 超期企业
resultListMap.put("countTimeoutCheck", countTimeoutCheck(checkDTOs));
// 获取隐患列表
List<CheckItemOptionDTO> checkItemOptionDTOs = listCheckItemOptionDTO();
// 企业检查隐患总数
Integer countCheckHiddenDanger = countCheckHiddenDanger(checkItemOptionDTOs, userIdList, year);
resultListMap.put("countCheckHiddenDanger", countCheckHiddenDanger);
// 企业复查隐患总数
Integer countReCheckHiddenDanger = countReCheckHiddenDanger(checkItemOptionDTOs, userIdList, year);
// 需复查隐患数
resultListMap.put("countReCheckHiddenDanger", countReCheckHiddenDanger);
// 复查整改总数
Integer countRectification = countCheckHiddenDanger - countReCheckHiddenDanger;
resultListMap.put("countRectification", countRectification);
// 立即整改现场整改数量
Integer countImmediatelyRectification = countImmediatelyRectification(checkItemOptionDTOs, userIdList, year);
resultListMap.put("countImmediatelyRectification", countImmediatelyRectification);
// 整改率
resultListMap.put("rectificationRate", countCheckHiddenDanger == null || countCheckHiddenDanger == 0 ? 0 : String.format("%.2f", (double) countRectification / countCheckHiddenDanger * 100));
// 不配合次数上报条数
Integer countUnCoordination = countUnCoordination(userIdList, year);
resultListMap.put("countUnCoordination", countUnCoordination);
resultList.add(resultListMap);
}
Map<String, Object> result = getHashMap(5);
result.put("year", year);
result.put("resultList", resultList);
return result;
}
/**
* 立即整改数量
*
@ -797,6 +867,25 @@ public class CountServiceImpl extends BaseService implements ICountService {
return enterpriseOfGridOperatorService.countEnterpriseOfArea(params);
}
/**
* 统计网格员认领企业
*
* @param userId
* @param areaId
* @param areaLevel
* @param year
* @return
*/
private Integer countEnterpriseOfGridAndArea(String userId, String areaId, Integer areaLevel, String year) {
Map<String, Object> params = getHashMap(6);
params.put("isLogOff", 0);
setParentArea(areaId, areaLevel, params);
params.put("year", year);
params.put("userId", userId);
return enterpriseOfGridOperatorService.countEnterpriseOfArea(params);
}
/**
* 设置统计返回结果
*

View File

@ -1,7 +1,6 @@
package com.cm.inspection.service.enterpriseofgridoperator;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
@ -200,6 +199,14 @@ public interface IEnterpriseOfGridOperatorService {
*/
SuccessResultList<List<EnterpriseOfGridOperatorDTO>> listPageUnclaimedEnterpriseOfMine(String token, ListPage page) throws SearchException;
/**
* 认领企业总数
*
* @param userId
* @return
*/
Integer countClaimedEnterprise(String userId);
/**
* 统计我的未认领企业
*
@ -227,6 +234,14 @@ public interface IEnterpriseOfGridOperatorService {
*/
Integer countEnterpriseOfGridOperator(Map<String, Object> params) throws SearchException;
/**
* 统计网格员企业
*
* @param userId
* @return
*/
Integer countEnterpriseOfGridOperator(String userId);
/**
* 企业网格员列表简单格式
*
@ -259,4 +274,6 @@ public interface IEnterpriseOfGridOperatorService {
* @return
*/
List<String> listEnterpriseIdByUserId(String userId);
}

View File

@ -3,15 +3,12 @@ package com.cm.inspection.service.enterpriseofgridoperator.impl;
import com.cm.common.component.SecurityComponent;
import com.cm.common.exception.ParamsException;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.token.app.entity.AppToken;
import com.cm.common.token.app.entity.AppTokenUser;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.inspection.dao.enterpriseofgridoperator.IEnterpriseOfGridOperatorDao;
@ -27,7 +24,10 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @ClassName: EnterpriseOfGridOperatorServiceImpl
@ -247,6 +247,14 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements
return new SuccessResultList<>(enterpriseOfGridOperatorDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public Integer countClaimedEnterprise(String userId) {
Map<String, Object> params = getHashMap(2);
params.put("userId", userId);
Integer countResult = enterpriseOfGridOperatorDao.countClaimedEnterprise(params);
return countResult == null ? 0 : countResult;
}
@Override
public SuccessResultData<Integer> countUnclaimedEnterpriseOfMine(String token) throws SearchException {
String userId = AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId();
@ -271,6 +279,13 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements
return count == null ? 0 : count;
}
@Override
public Integer countEnterpriseOfGridOperator(String userId) {
Map<String, Object> params = getHashMap(2);
params.put("userId", userId);
return countEnterpriseOfGridOperator(params);
}
@Override
public List<EnterpriseOfGridOperatorDTO> listSimple(Map<String, Object> params) throws SearchException {
return enterpriseOfGridOperatorDao.listSimple(params);

View File

@ -20,14 +20,14 @@ spring:
max-request-size: 1GB
datasource:
druid:
url: jdbc:mysql://49.233.36.36:6688/db_cloud_inspection?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
# url: jdbc:mysql://127.0.0.1:3306/db_cloud_inspection?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
# url: jdbc:mysql://49.233.36.36:6688/db_cloud_inspection?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/db_cloud_inspection?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
db-type: mysql
driver-class-name: com.mysql.jdbc.Driver
username: wanggeng
# username: root
password: WenG>2132997
# password: root
# username: wanggeng
username: root
# password: WenG>2132997
password: root
initial-size: 2
min-idle: 2
max-active: 5

View File

@ -620,6 +620,12 @@
wt1.enterprise_id
FROM
gen_enterprise_of_grid_operator wt1
WHERE
wt1.is_delete = 0
<if test="userId != null and userId != ''">
AND
wt1.user_id = #{userId}
</if>
GROUP BY
wt1.enterprise_id
)

View File

@ -0,0 +1,169 @@
<!doctype html>
<html lang="en">
<head>
<base href="/inspection/">
<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>
table th, td {text-align: center !important;}
#title {text-align: center;}
</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">
<div class="layui-card-body">
<div class="layui-row">
<div class="layui-col-md12 button-group-box" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="year" class="layui-input search-item" placeholder="年份" readonly>
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
<button type="button" id="print" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-print"></i> 打印
</button>
</div>
<div class="layui-col-md12" id="tableBox"></div>
<script id="tableBoxTemplate" type="text/html">
<h2 id="title" style="line-height: 32px; text-align: center;">{{d.data.year}}综合统计情况</h2>
<table class="layui-table" id="table">
<thead>
<tr>
<th rowspan="2">地区</th>
<th rowspan="2">认领企业数(家)</th>
<th colspan="3">检(协)查情况</th>
<th colspan="2">待复查(家)</th>
<th colspan="5">隐患情况</th>
<th rowspan="2">上报(家次)</th>
</tr>
<tr>
<th>计划(家)</th>
<th>实际(家)</th>
<th>完成率</th>
<th>总数</th>
<th>超期</th>
<th>发现(条)</th>
<th>需复查(条)</th>
<th>整改(条)</th>
<th>现场整改(条)</th>
<th>整改率</th>
</tr>
</thead>
<tbody>
{{# for(var i = 0, item; item = d.data.resultList[i++];) { }}
<tr>
<td>{{item.areaName}}</td>
<td>{{item.enterpriseReceiveCount ? item.enterpriseReceiveCount : 0}}</td>
<td>{{item.checkPlanCount ? item.checkPlanCount : 0}}</td>
<td>{{item.checkCount ? item.checkCount : 0}}</td>
<td>{{item.completeRatio ? item.completeRatio : 0}}%</td>
<td>{{item.needReCheck ? item.needReCheck : 0}}</td>
<td>{{item.countTimeoutCheck ? item.countTimeoutCheck : 0}}</td>
<td>{{item.countCheckHiddenDanger ? item.countCheckHiddenDanger : 0}}</td>
<td>{{item.countReCheckHiddenDanger ? item.countReCheckHiddenDanger : 0}}</td>
<td>{{item.countRectification ? item.countRectification : 0}}</td>
<td>{{item.countImmediatelyRectification ? item.countImmediatelyRectification : 0}}</td>
<td>{{item.rectificationRate ? item.rectificationRate : 0}}%</td>
<td>{{item.countUnCoordination ? item.countUnCoordination : 0}}</td>
</tr>
{{# } }}
</tbody>
</table>
</script>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var laydate = layui.laydate;
var laytpl = layui.laytpl;
var common = layui.common;
var areaId = top.restAjax.params(window.location.href).areaId;
var areaLevel = top.restAjax.params(window.location.href).areaLevel;
areaLevel = areaLevel ? (areaLevel < 3 ? 3 : areaLevel) : 3;
var today = common.formatDate('yyyy', new Date())
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#year',
type: 'year',
format: 'yyyy',
trigger: 'click',
value: today
});
}
initDate();
function initTable() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/count/count-grid-check-detail-table/{year}/{areaId}/{areaLevel}', [$('#year').val() ? $('#year').val() : today, areaId, areaLevel]), {}, null, function(code, data) {
laytpl(document.getElementById('tableBoxTemplate').innerHTML).render(data, function(html) {
document.getElementById('tableBox').innerHTML = html;
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg('正在加载...', {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initTable();
// 事件 - 搜索
$(document).on('click', '#search', function() {
initTable();
});
$(document).on('click', '.area-name', function() {
var areaId = this.dataset.areaId;
var areaName = this.dataset.areaName;
top.dialog.open({
url: top.restAjax.path('route/count/list-countcheckdetailtable.html?areaId={areaId}&areaLevel={areaLevel}', [areaId, parseInt(areaLevel) + 1]),
title: areaName +'下级情况',
width: '99%',
height: '99%'
});
});
$(document).on('click', '#print', function() {
var bodyHtml = $('html');
var html = bodyHtml.clone();
html.find('.button-group-box').remove();
html.find('.layui-anim').css({'padding': '0px'});
var win = window.open("打印窗口", "_blank");
win.document.write(html.html());
$(win.document).ready(function() {
setTimeout(function() {
win.print();
win.close();
}, 100);
});
});
});
</script>
</body>
</html>

View File

@ -44,6 +44,7 @@
<th colspan="2">待复查(家)</th>
<th colspan="5">隐患情况</th>
<th rowspan="2">上报(家次)</th>
<th rowspan="2">人员统计</th>
</tr>
<tr>
<th>计划(家)</th>
@ -76,6 +77,7 @@
<td>{{item.countImmediatelyRectification ? item.countImmediatelyRectification : 0}}</td>
<td>{{item.rectificationRate ? item.rectificationRate : 0}}%</td>
<td>{{item.countUnCoordination ? item.countUnCoordination : 0}}</td>
<td><button type="button" class="layui-btn layui-btn-xs area-grid" data-area-id="{{item.areaId}}" data-area-name="{{item.areaName}}">点击查看</button></td>
</tr>
{{# } }}
</tbody>
@ -154,6 +156,17 @@
});
});
$(document).on('click', '.area-grid', function() {
var areaId = this.dataset.areaId;
var areaName = this.dataset.areaName;
top.dialog.open({
url: top.restAjax.path('route/count/list-countcheckdetailtable-grid.html?areaId={areaId}&areaLevel={areaLevel}', [areaId, parseInt(areaLevel)]),
title: areaName +'本级网格员综合统计',
width: '99%',
height: '99%'
});
});
$(document).on('click', '#print', function() {
var bodyHtml = $('html');
var html = bodyHtml.clone();