新增用户使用统计

This commit is contained in:
wanggeng 2021-09-28 11:46:52 +08:00
parent d78f88c04b
commit 12ae026811
17 changed files with 432 additions and 16 deletions

View File

@ -3,9 +3,12 @@ package com.cm.inspection.controller.apis.count;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.ParamsException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.RegexUtil;
import com.cm.inspection.pojo.dtos.count.UserUseInfoDTO;
import com.cm.inspection.reportform.CheckDetailTable;
import com.cm.inspection.service.check.ICheckService;
import com.cm.inspection.service.count.ICountService;
@ -155,7 +158,7 @@ public class CountController extends AbstractController {
@RequestParam(name = "areaId", required = false) String areaId,
@RequestParam(name = "areaLevel", required = false) Integer areaLevel) {
Map<String, Object> result = CheckDetailTable.getInstance().get(year, areaId);
if(result == null) {
if (result == null) {
return countService.countCheckDetailTable(areaId, areaLevel, year);
}
return new SuccessResultData<>(result);
@ -197,4 +200,12 @@ public class CountController extends AbstractController {
return countService.countEnterprisePlanRealCheckTable(areaId, areaLevel, year);
}
@ApiOperation(value = "用户使用情况分页列表", notes = "用户使用情况分页列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage-user-use")
public SuccessResultList<List<UserUseInfoDTO>> listPageUserUse(ListPage page) {
page.setParams(requestParams());
return countService.listPageUserUse(page);
}
}

View File

@ -4,9 +4,9 @@ import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.common.result.SuccessResultList;
import com.cm.inspection.pojo.dtos.check.CheckDTO;
import com.cm.inspection.pojo.dtos.check.CheckSimpleWithEnterpriseDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -99,4 +99,13 @@ public interface ICheckDao {
* @throws SearchException
*/
List<CheckSimpleWithEnterpriseDTO> listCheckSimpleWithEnterprise(Map<String, Object> params) throws SearchException;
/**
* 用户案件上报数量统计列表
*
* @param params
* @return
* @throws SearchException
*/
List<IdCountPO> listUserIdCountPO(Map<String, Object> params) throws SearchException;
}

View File

@ -4,9 +4,9 @@ import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.common.result.SuccessResultList;
import com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO;
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -166,9 +166,19 @@ public interface IEnterpriseOfGridOperatorDao {
/**
* 统计用户组认领企业数据
*
* @param params
* @return
* @throws SearchException
*/
Integer countGroupUser(Map<String, Object> params) throws SearchException;
/**
* 用户企业认领统计列表
*
* @param params
* @return
* @throws SearchException
*/
List<IdCountPO> listUserIdCountPO(Map<String, Object> params) throws SearchException;
}

View File

@ -0,0 +1,37 @@
package com.cm.inspection.pojo.dtos.count;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
/**
* @ClassName: UserUseInfoDTO
* @Description: 用户使用情况
* @Author: wanggeng
* @Date: 2021/9/26 10:56 上午
* @Version: 1.0
*/
@ApiModel
@Data
@ToString
public class UserUseInfoDTO {
@ApiModelProperty(name = "userId", value = "用户ID")
private String userId;
@ApiModelProperty(name = "userUsername", value = "用户名")
private String userUsername;
@ApiModelProperty(name = "userName", value = "昵称")
private String userName;
@ApiModelProperty(name = "departmentName", value = "组织机构")
private String departmentName;
@ApiModelProperty(name = "lastLoginTime", value = "最后登录时间")
private String lastLoginTime;
@ApiModelProperty(name = "loginCount", value = "登录次数")
private String loginCount;
@ApiModelProperty(name = "checkCount", value = "检查次数")
private Integer checkCount;
@ApiModelProperty(name = "enterpriseCount", value = "企业数量")
private Integer enterpriseCount;
}

View File

@ -0,0 +1,22 @@
package com.cm.inspection.pojo.pos.count;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @ClassName: IdCountPO
* @Description: id数量统计
* @Author: wanggeng
* @Date: 2021/9/27 11:29 上午
* @Version: 1.0
*/
@Data
@ToString
public class IdCountPO implements Serializable {
private String userId;
private Integer total;
}

View File

@ -11,6 +11,7 @@ import com.cm.inspection.pojo.dtos.check.CheckDTO;
import com.cm.inspection.pojo.dtos.check.CheckSimpleWithEnterpriseDTO;
import com.cm.inspection.pojo.dtos.checkitem.CheckItemDTO;
import com.cm.inspection.pojo.dtos.hiddendangerreport.HiddenDangerReportDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import com.cm.inspection.pojo.vos.check.CheckVO;
import com.cm.inspection.pojo.vos.check.InspectVO;
@ -307,4 +308,12 @@ public interface ICheckService {
* @throws SearchException
*/
List<CheckSimpleWithEnterpriseDTO> listCheckSimpleWithEnterprise(Map<String, Object> params) throws SearchException;
/**
* 用户案件上报数量统计列表
*
* @param userIds
* @return
*/
List<IdCountPO> listUserIdCountPO(List<String> userIds);
}

View File

@ -18,6 +18,7 @@ import com.cm.inspection.pojo.dtos.checkitemoption.CheckItemOptionDTO;
import com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO;
import com.cm.inspection.pojo.dtos.hiddendangerreport.HiddenDangerReportDTO;
import com.cm.inspection.pojo.dtos.industrycheckitem.IndustryCheckItemDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import com.cm.inspection.pojo.vos.check.CheckVO;
import com.cm.inspection.pojo.vos.check.InspectVO;
import com.cm.inspection.pojo.vos.hiddendangerreport.HiddenDangerReportVO;
@ -721,6 +722,13 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
return checkDao.listCheckSimpleWithEnterprise(params);
}
@Override
public List<IdCountPO> listUserIdCountPO(List<String> userIds) {
Map<String, Object> params = getHashMap(2);
params.put("userIds", userIds);
return checkDao.listUserIdCountPO(params);
}
/**
* 获取用户ID
*

View File

@ -1,7 +1,10 @@
package com.cm.inspection.service.count;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.inspection.pojo.dtos.count.UserUseInfoDTO;
import java.util.List;
import java.util.Map;
@ -115,4 +118,12 @@ public interface ICountService {
* @throws SearchException
*/
SuccessResultData<Map<String, Integer>> countCurrentMonthOfMine(String token) throws SearchException;
/**
* 用户使用情况分页列表
*
* @param page
* @return
*/
SuccessResultList<List<UserUseInfoDTO>> listPageUserUse(ListPage page);
}

View File

@ -1,16 +1,24 @@
package com.cm.inspection.service.count.impl;
import com.alibaba.fastjson.JSONObject;
import com.cm.common.config.properties.ApiPathProperties;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.oauth.token.ClientTokenManager;
import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO;
import com.cm.common.plugin.service.datadictionary.IDataDictionaryService;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.http.HttpClientUtil;
import com.cm.inspection.pojo.dtos.check.CheckDTO;
import com.cm.inspection.pojo.dtos.checkitem.CheckItemDTO;
import com.cm.inspection.pojo.dtos.checkitemoption.CheckItemOptionDTO;
import com.cm.inspection.pojo.dtos.count.UserUseInfoDTO;
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
import com.cm.inspection.pojo.dtos.hiddendangerreport.HiddenDangerReportDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import com.cm.inspection.service.BaseService;
import com.cm.inspection.service.check.ICheckService;
import com.cm.inspection.service.checkitem.ICheckItemService;
@ -65,6 +73,8 @@ public class CountServiceImpl extends BaseService implements ICountService {
@Autowired
private ICheckItemService checkItemService;
public static final String DEFAULT_AREA_ID = "3f62e230-47a5-4ad9-ab01-08fd2c5218d8";
@Autowired
private ApiPathProperties apiPathProperties;
@Override
public SuccessResultData<Map<String, Object>> countWorkTable(String areaId, Integer areaLevel, String startDate, String endDate) throws SearchException {
@ -456,6 +466,51 @@ public class CountServiceImpl extends BaseService implements ICountService {
return new SuccessResultData<>(result);
}
@Override
public SuccessResultList<List<UserUseInfoDTO>> listPageUserUse(ListPage page) {
Map<String, Object> params = page.getParams();
params.put("access_token", ClientTokenManager.getInstance().getClientToken().getAccessToken());
String result = HttpClientUtil.doGetForm(String.format("%s/resource/count/listpage-user-use", apiPathProperties.getUserCenter()), params);
if (StringUtils.isBlank(result)) {
throw new SearchException("查询失败");
}
SuccessResultList<List<JSONObject>> successResultList = JSONObject.parseObject(result, SuccessResultList.class);
if (successResultList.getRows().isEmpty()) {
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
}
List<JSONObject> userUseInfoJSONObjects = successResultList.getRows();
List<UserUseInfoDTO> userUseInfoDTOs = new ArrayList<>();
Set<String> userIdSet = new HashSet<>();
for (JSONObject userUseInfoJSONObject : userUseInfoJSONObjects) {
UserUseInfoDTO userUseInfoDTO = JSONObject.toJavaObject(userUseInfoJSONObject, UserUseInfoDTO.class);
userUseInfoDTOs.add(userUseInfoDTO);
userIdSet.add(userUseInfoDTO.getUserId());
}
// 上报案件数量
List<IdCountPO> checkUserIdCountPOs = checkService.listUserIdCountPO(new ArrayList<>(userIdSet));
// 认领企业数量
List<IdCountPO> enterpriseUserIdCountPOs = enterpriseOfGridOperatorService.listUserIdCountPO(new ArrayList<>(userIdSet));
for (UserUseInfoDTO userUseInfoDTO : userUseInfoDTOs) {
int checkCount = 0;
int enterpriseCount = 0;
for (IdCountPO checkUserIdCountPO : checkUserIdCountPOs) {
if (StringUtils.equals(userUseInfoDTO.getUserId(), checkUserIdCountPO.getUserId())) {
checkCount = checkUserIdCountPO.getTotal();
break;
}
}
for (IdCountPO enterpriseUserIdCountPO : enterpriseUserIdCountPOs) {
if (StringUtils.equals(userUseInfoDTO.getUserId(), enterpriseUserIdCountPO.getUserId())) {
enterpriseCount = enterpriseUserIdCountPO.getTotal();
break;
}
}
userUseInfoDTO.setCheckCount(checkCount);
userUseInfoDTO.setEnterpriseCount(enterpriseCount);
}
return new SuccessResultList<>(userUseInfoDTOs, successResultList.getPage(), successResultList.getTotal());
}
/**
* 构建检查结果到检查项中
*

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;
@ -9,6 +8,7 @@ import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO;
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import com.cm.inspection.pojo.vos.enterpriseofgridoperator.EnterpriseOfGridOperatorVO;
import java.util.List;
@ -23,7 +23,7 @@ import java.util.Map;
**/
public interface IEnterpriseOfGridOperatorService {
Integer countGroupUser(Map<String,Object> params);
Integer countGroupUser(Map<String, Object> params);
/**
* 新增网格员的企业
@ -261,4 +261,12 @@ public interface IEnterpriseOfGridOperatorService {
* @return
*/
List<String> listEnterpriseIdByUserId(String userId);
/**
* 用户企业认领统计列表
*
* @param strings
* @return
*/
List<IdCountPO> listUserIdCountPO(List<String> userIds);
}

View File

@ -16,6 +16,7 @@ import com.cm.common.utils.UUIDUtil;
import com.cm.inspection.dao.enterpriseofgridoperator.IEnterpriseOfGridOperatorDao;
import com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO;
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
import com.cm.inspection.pojo.pos.count.IdCountPO;
import com.cm.inspection.pojo.vos.enterpriseofgridoperator.EnterpriseOfGridOperatorVO;
import com.cm.inspection.service.BaseService;
import com.cm.inspection.service.enterpriseofgridoperator.IEnterpriseOfGridOperatorService;
@ -298,6 +299,13 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements
return listEnterpriseId(params);
}
@Override
public List<IdCountPO> listUserIdCountPO(List<String> userIds) {
Map<String, Object> params = getHashMap(2);
params.put("userIds", userIds);
return enterpriseOfGridOperatorDao.listUserIdCountPO(params);
}
/**
* 初始化未认领地区
*

View File

@ -142,5 +142,5 @@ logging:
#大数据统计参数
count-big-data:
jiniqu-dept-id: 0
shengtaiwei-dept-id: 0
jiniqu-dept-id: bffcf04f-aa9d-4436-947d-f2e672b790b5
shengtaiwei-dept-id: fb7a3190-70a5-496d-8ba1-59228cce0a44

View File

@ -21,11 +21,11 @@ spring:
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://106.12.218.237:8668/db_cloud_inspection?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
url: jdbc:mysql://192.168.0.151:3306/db_btyjj_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
password: TSkj@0471.123
username: root
password: root
initial-size: 2
min-idle: 2
max-active: 5
@ -83,11 +83,11 @@ file:
# 安全
security:
oauth2:
oauth-server: http://106.12.218.237:8001/usercenter
oauth-server: http://192.168.0.103:7001/usercenter
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
client:
client-id: 8d1a7e1da9884fbbaa6aadc285f79113
client-secret: dHVuaTEvbzY1S3hHbzAzMFRhcTNkK1FsZDFUYVU0MjdzdUg1ZW9JT1NNd21ac2wwZTJHWk5NbXh3L3h3U2c4Rg==
client-id: 32ec344a5fd04fd9911586df5d1dc36b
client-secret: a2NORTAyZmthdTNtVHNwLytGVVo0ckFhNktHQU9JWVFmUks0TGw5L2hQRW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg==
user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize
access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token
grant-type: authorization_code
@ -100,10 +100,13 @@ security:
check-token-access: ${security.oauth2.oauth-server}/oauth_client/token_key
api-path:
user-center: http://106.12.218.237:8001/usercenter
notice-url: http://106.12.218.237:8001/usercenter
version: 2
user-center: http://192.168.0.103:7001/usercenter
notice-url: http://192.168.0.103:7001/usercenter
# 系统版本1包头应急局2集宁环保局
version: 1
# 报表
report-form:
# 是否预加载
check-detail: false
# 访问控制

View File

@ -629,4 +629,28 @@
</if>
</select>
<!-- 用户案件上报数量统计列表 -->
<select id="listUserIdCountPO" parameterType="map" resultType="com.cm.inspection.pojo.pos.count.IdCountPO" useCache="false">
SELECT
creator userId,
COUNT(creator) total
FROM
gen_check
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
creator = #{userId}
</if>
<if test="userIds != null and userIds.size > 0">
AND
creator IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
GROUP BY
creator
</select>
</mapper>

View File

@ -640,4 +640,28 @@
</if>
</select>
<!-- 用户企业认领统计列表 -->
<select id="listUserIdCountPO" parameterType="map" resultType="com.cm.inspection.pojo.pos.count.IdCountPO" useCache="false">
SELECT
user_id userId,
COUNT(user_id) total
FROM
gen_enterprise_of_grid_operator
WHERE
is_delete = 0
<if test="userId != null and userId != ''">
AND
user_id = #{userId}
</if>
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
GROUP BY
user_id
</select>
</mapper>

View File

@ -0,0 +1,165 @@
<!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" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
</div>
<div class="layui-inline">
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
</div>
<div class="layui-inline">
<input type="text" id="endTime" 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>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
</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', 'upload'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var layer = layui.layer;
var laydate = layui.laydate;
var windowWidth = $(window).width();
var windowHeight = $(window).height();
var resizeTimeout = null;
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('api/count/listpage-user-use', []),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [[
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field:'userUsername', width:140, title: '用户名', sort: true, align:'center',
templet: function(rowData) {
return '<a href="javascript:void(0);" lay-event="userUsernameEvent">'+ rowData.userUsername +'</a>';
}
},
{field:'userName', width:140, title: '昵称', sort: true, align:'center'},
{field:'departmentName', width:200, title: '机构', align:'center',
templet: function(item) {
if(!item.departmentName) {
return '-';
}
return item.departmentName;
}
},
{field:'lastLoginTime', width:200, title: '最后登录系统时间', align:'center',
templet: function(item) {
if(!item.lastLoginTime) {
return '-';
}
return item.lastLoginTime;
}
},
{field:'loginCount', width:120, title: '登录次数', align:'center',
templet: function(item) {
return item.loginCount;
}
},
{field:'checkCount', width:120, title: '上报数量', align:'center',
templet: function(item) {
return item.checkCount;
}
},
{field:'enterpriseCount', width:120, title: '企业数量', align:'center',
templet: function(item) {
return item.enterpriseCount;
}
}
]],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path('api/count/listpage-user-use', []),
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
},
page: {
curr: currentPage
},
height: $win.height() - 90,
});
}
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#startTime',
format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#endTime',
format: 'yyyy-MM-dd'
});
}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,12 @@
/**
* @ClassName: DataRepair
* @Description: 数据修复
* @Author: wanggeng
* @Date: 2021/9/27 4:40 下午
* @Version: 1.0
*/
public class DataRepair {
}