Commit 99d1c9b8 authored by 赵啸非's avatar 赵啸非

添加统计日志

parent 24a45472
-- ---------------------------- -- ----------------------------
2024-04-08 -- 2024-04-08
-- ---------------------------- -- ----------------------------
-- ---------------------------- -- ----------------------------
-- 排号汇总表 -- 排号汇总表
...@@ -121,9 +121,11 @@ CREATE TABLE mortals_xhx_access( ...@@ -121,9 +121,11 @@ CREATE TABLE mortals_xhx_access(
`tag` varchar(255) NOT NULL DEFAULT '' COMMENT '标签', `tag` varchar(255) NOT NULL DEFAULT '' COMMENT '标签',
`latitude` varchar(64) NOT NULL DEFAULT '' COMMENT '维度', `latitude` varchar(64) NOT NULL DEFAULT '' COMMENT '维度',
`longitude` varchar(64) COMMENT '经度', `longitude` varchar(64) COMMENT '经度',
`access_time` datetime COMMENT '接入开通时间',
`type` varchar(16) NOT NULL DEFAULT '类型' COMMENT '接入类型 (area.区域,site.站点)', `type` varchar(16) NOT NULL DEFAULT '类型' COMMENT '接入类型 (area.区域,site.站点)',
`sort` int(4) DEFAULT '0' COMMENT '排序', `sort` int(4) DEFAULT '0' COMMENT '排序',
`remark` varchar(128) NOT NULL DEFAULT '' COMMENT '备注', `content` varchar(1024) NOT NULL DEFAULT '' COMMENT '描述内容',
`remark` varchar(256) NOT NULL DEFAULT '' COMMENT '备注',
`create_user_id` bigint(20) COMMENT '创建用户', `create_user_id` bigint(20) COMMENT '创建用户',
`create_time` datetime COMMENT '创建时间', `create_time` datetime COMMENT '创建时间',
`update_time` datetime COMMENT '更新时间', `update_time` datetime COMMENT '更新时间',
...@@ -231,3 +233,25 @@ CREATE TABLE `mortals_xhx_stat` ( ...@@ -231,3 +233,25 @@ CREATE TABLE `mortals_xhx_stat` (
INSERT INTO mortals_xhx_task VALUES (null, '报表统计', 'SiteStatTask', 0, 'SiteStatTask', '', '', 1, 3600, '21:00', '', '192.168.1.107', '2024-05-18 16:05:00', 0, '2024-03-01 10:59:53', 1, '系统管理员'); INSERT INTO mortals_xhx_task VALUES (null, '报表统计', 'SiteStatTask', 0, 'SiteStatTask', '', '', 1, 3600, '21:00', '', '192.168.1.107', '2024-05-18 16:05:00', 0, '2024-03-01 10:59:53', 1, '系统管理员');
-- ----------------------------
-- 区域统计日志表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_access_stat_log`;
CREATE TABLE mortals_xhx_access_stat_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`access_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '接入Id',
`site_id` bigint(20) COMMENT '站点Id',
`site_code` varchar(128) NOT NULL DEFAULT '' COMMENT '站点编码',
`site_name` varchar(128) NOT NULL DEFAULT '' COMMENT '站点名称',
`stat_start_time` datetime COMMENT '统计开始时间',
`stat_end_time` datetime COMMENT '统计结束时间',
`duration` bigint(20) DEFAULT '0' COMMENT '站点Id',
`type` varchar(16) NOT NULL DEFAULT '全部' COMMENT '类型 (ALL.全部,PJQ.评价器,PDJ.排队机)',
`remark` varchar(256) NOT NULL DEFAULT '' COMMENT '备注',
`create_user_id` bigint(20) COMMENT '创建用户',
`create_time` datetime COMMENT '创建时间',
`update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='统计日志表';
...@@ -138,7 +138,9 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -138,7 +138,9 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
if (!ObjectUtils.isEmpty(siteTreeStr)) { if (!ObjectUtils.isEmpty(siteTreeStr)) {
log.info("siteTreeStr:{}", siteTreeStr); log.info("siteTreeStr:{}", siteTreeStr);
//获取当前用户所拥有的站点列表 //获取当前用户所拥有的站点列表
accessEntities = accessService.find(new AccessQuery()); AccessQuery accessQuery = new AccessQuery();
accessQuery.setTagNotList(Arrays.asList(""));
accessEntities = accessService.find(accessQuery);
totalAccessSite = accessEntities.size(); totalAccessSite = accessEntities.size();
if (!ObjectUtils.isEmpty(accessEntities)) { if (!ObjectUtils.isEmpty(accessEntities)) {
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 接入类型 (area.区域,site.站点)枚举类
*
* @author zxfei
*/
public enum AccessTypeEnum {
全部("ALL", "全部"),
评价器("PJQ", "评价器"),
排队机("PDJ", "排队机");
private String value;
private String desc;
AccessTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static AccessTypeEnum getByValue(String value) {
for (AccessTypeEnum typeEnum : AccessTypeEnum.values()) {
if (typeEnum.getValue() == value) {
return typeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (AccessTypeEnum item : AccessTypeEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
...@@ -7,11 +7,17 @@ import com.mortals.framework.exception.AppException; ...@@ -7,11 +7,17 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.AccessTypeEnum;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.keys.RedisCacheKeys; import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu; import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.access.model.AccessEntity;
import com.mortals.xhx.module.access.model.AccessQuery;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import com.mortals.xhx.module.access.service.AccessService;
import com.mortals.xhx.module.access.service.AccessStatLogService;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity; import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery; import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.ph.service.PhQueueStatService; import com.mortals.xhx.module.ph.service.PhQueueStatService;
...@@ -24,6 +30,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -24,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
...@@ -51,15 +58,23 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -51,15 +58,23 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Autowired
private AccessService accessService;
@Autowired
private AccessStatLogService accessStatLogService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("站点评价统计任务"); log.info("站点评价统计任务");
//统计最近一周 //统计最近一周
statByDate(); statByDate();
log.info("站点统计缓存任务"); log.info("站点统计缓存任务");
//统计排号与评价 部门,等字典顺序记录次数 //统计排号与评价 部门,等字典顺序记录次数
updateSiteCache();
}
private void updateSiteCache() {
SitePdu sitePdu = new SitePdu(); SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1); sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
...@@ -131,7 +146,6 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -131,7 +146,6 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
} }
private void updatePjSectionCache(SitePdu site) { private void updatePjSectionCache(SitePdu site) {
PjEvaluateStatQuery pjEvaluateStatQuery = new PjEvaluateStatQuery(); PjEvaluateStatQuery pjEvaluateStatQuery = new PjEvaluateStatQuery();
pjEvaluateStatQuery.setSiteId(site.getId()); pjEvaluateStatQuery.setSiteId(site.getId());
...@@ -178,7 +192,41 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -178,7 +192,41 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData().getData();
for (SitePdu site : sitePduList) { for (SitePdu site : sitePduList) {
for (int i = 0; i < 4; i++) {
StopWatch allStopWatch = new StopWatch("allStopWatch");
StopWatch pjqStopWatch = new StopWatch("pjqStopWatch");
StopWatch pdjStopWatch = new StopWatch("pdjStopWatch");
allStopWatch.start();
AccessStatLogEntity statLogAllEntity = new AccessStatLogEntity();
statLogAllEntity.setCreateUserId(1L);
statLogAllEntity.setCreateTime(new Date());
statLogAllEntity.setSiteId(site.getId());
statLogAllEntity.setSiteCode(site.getSiteCode());
statLogAllEntity.setSiteName(site.getSiteName());
statLogAllEntity.setStatStartTime(new Date());
statLogAllEntity.setType(AccessTypeEnum.全部.getValue());
pjqStopWatch.start();
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.setCreateUserId(1L);
statLogEntity.setCreateTime(new Date());
statLogEntity.setSiteId(site.getId());
statLogEntity.setSiteCode(site.getSiteCode());
statLogEntity.setSiteName(site.getSiteName());
AccessQuery accessQuery = new AccessQuery();
accessQuery.setSiteId(site.getId());
AccessEntity accessEntity = accessService.selectOne(accessQuery);
statLogEntity.setAccessId(accessEntity.getId());
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.评价器.getValue());
int range = 4;
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i); DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year(); int year = beforeDate.year();
int month = beforeDate.month() + 1; int month = beforeDate.month() + 1;
...@@ -195,7 +243,21 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -195,7 +243,21 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
sitestatEntity.setDay(day); sitestatEntity.setDay(day);
//设置年月日 //设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, null); pjEvaluateStatService.updateSitePjStat(sitestatEntity, null);
}
pjqStopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, null);
pdjStopWatch.start();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
//设置排号 //设置排号
PhQueueStatEntity phQueueStatEntity = new PhQueueStatEntity(); PhQueueStatEntity phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue(); phQueueStatEntity.initAttrValue();
...@@ -208,7 +270,17 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -208,7 +270,17 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
phQueueStatEntity.setDay(day); phQueueStatEntity.setDay(day);
phQueueStatService.updateSitePhStat(phQueueStatEntity, null); phQueueStatService.updateSitePhStat(phQueueStatEntity, null);
}
pdjStopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, null);
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
StatEntity statEntity = new StatEntity(); StatEntity statEntity = new StatEntity();
statEntity.initAttrValue(); statEntity.initAttrValue();
statEntity.setSiteId(site.getId()); statEntity.setSiteId(site.getId());
...@@ -222,6 +294,11 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -222,6 +294,11 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
statService.updateSiteStat(statEntity, null); statService.updateSiteStat(statEntity, null);
} }
allStopWatch.stop();
statLogAllEntity.setStatEndTime(new Date());
statLogAllEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogAllEntity, null);
} }
} }
} }
......
package com.mortals.xhx.module.access.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import java.util.List;
/**
* 统计日志Dao
* 统计日志 DAO接口
*
* @author zxfei
* @date 2024-07-26
*/
public interface AccessStatLogDao extends ICRUDDao<AccessStatLogEntity,Long>{
}
package com.mortals.xhx.module.access.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.access.dao.AccessStatLogDao;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 统计日志DaoImpl DAO接口
*
* @author zxfei
* @date 2024-07-26
*/
@Repository("accessStatLogDao")
public class AccessStatLogDaoImpl extends BaseCRUDDaoMybatis<AccessStatLogEntity,Long> implements AccessStatLogDao {
}
package com.mortals.xhx.module.access.model; package com.mortals.xhx.module.access.model;
import java.util.List; import java.util.List;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -12,77 +13,85 @@ import com.mortals.xhx.module.access.model.vo.AccessVo; ...@@ -12,77 +13,85 @@ import com.mortals.xhx.module.access.model.vo.AccessVo;
import com.mortals.xhx.module.access.model.AccessSystemEntity; import com.mortals.xhx.module.access.model.AccessSystemEntity;
import lombok.Data; import lombok.Data;
/** /**
* 区域接入实体对象 * 区域接入实体对象
* *
* @author zxfei * @author zxfei
* @date 2024-07-02 * @date 2024-07-26
*/ */
@Data @Data
public class AccessEntity extends AccessVo { public class AccessEntity extends AccessVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 区域名称 * 区域名称
*/ */
private String areaName; private String areaName;
/** /**
* 区域编码 * 区域编码
*/ */
private String areaCode; private String areaCode;
/** /**
* 背景图片地址 * 背景图片地址
*/ */
private String bigPath; private String bigPath;
/** /**
* 标签 * 标签
*/ */
private String tag; private String tag;
/** /**
* 排序 * 排序
*/ */
private Integer sort; private Integer sort;
/** /**
* 备注 * 备注
*/ */
private String remark; private String remark;
/** /**
* 区域Id * 区域Id
*/ */
private String areaId; private String areaId;
/** /**
* 站点Id * 站点Id
*/ */
private Long siteId; private Long siteId;
/** /**
* 站点编码 * 站点编码
*/ */
private String siteCode; private String siteCode;
/** /**
* 站点名称 * 站点名称
*/ */
private String siteName; private String siteName;
/** /**
* 图标 * 图标
*/ */
private String icon; private String icon;
/** /**
* 维度 * 维度
*/ */
private String latitude; private String latitude;
/** /**
* 经度 * 经度
*/ */
private String longitude; private String longitude;
/** /**
* 接入类型 (area.区域,site.站点) * 接入类型 (area.区域,site.站点)
*/ */
private String type; private String type;
/** /**
* 区域接入系统信息 * 接入开通时间
*/ */
private Date accessTime;
/**
* 描述内容
*/
private String content;
/**
* 区域接入系统信息
*/
private List<AccessSystemEntity> accessSystemList=new ArrayList<>();; private List<AccessSystemEntity> accessSystemList=new ArrayList<>();;
public List<AccessSystemEntity> getAccessSystemList(){ public List<AccessSystemEntity> getAccessSystemList(){
return accessSystemList; return accessSystemList;
} }
public void setAccessSystemList(List<AccessSystemEntity> accessSystemList){ public void setAccessSystemList(List<AccessSystemEntity> accessSystemList){
...@@ -90,7 +99,7 @@ public class AccessEntity extends AccessVo { ...@@ -90,7 +99,7 @@ public class AccessEntity extends AccessVo {
} }
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -98,26 +107,28 @@ public class AccessEntity extends AccessVo { ...@@ -98,26 +107,28 @@ public class AccessEntity extends AccessVo {
if (obj instanceof AccessEntity) { if (obj instanceof AccessEntity) {
AccessEntity tmp = (AccessEntity) obj; AccessEntity tmp = (AccessEntity) obj;
if (this.getId() == tmp.getId()) { if (this.getId() == tmp.getId()) {
return true; return true;
} }
} }
return false; return false;
} }
public void initAttrValue(){ public void initAttrValue(){
this.areaName = ""; this.areaName = "";
this.areaCode = ""; this.areaCode = "";
this.bigPath = ""; this.bigPath = "";
this.tag = ""; this.tag = "";
this.sort = 0; this.sort = 0;
this.remark = ""; this.remark = "";
this.areaId = ""; this.areaId = "";
this.siteId = null; this.siteId = null;
this.siteCode = ""; this.siteCode = "";
this.siteName = ""; this.siteName = "";
this.icon = ""; this.icon = "";
this.latitude = ""; this.latitude = "";
this.longitude = ""; this.longitude = "";
this.type = "类型"; this.type = "类型";
this.accessTime = null;
this.content = "";
} }
} }
\ No newline at end of file
package com.mortals.xhx.module.access.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.access.model.vo.AccessStatLogVo;
import lombok.Data;
/**
* 统计日志实体对象
*
* @author zxfei
* @date 2024-07-26
*/
@Data
public class AccessStatLogEntity extends AccessStatLogVo {
private static final long serialVersionUID = 1L;
/**
* 接入Id
*/
private Long accessId;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点编码
*/
private String siteCode;
/**
* 站点名称
*/
private String siteName;
/**
* 统计开始时间
*/
private Date statStartTime;
/**
* 统计结束时间
*/
private Date statEndTime;
/**
* 站点Id
*/
private Long duration;
/**
* 类型 (ALL.全部,PJQ.评价器,PDJ.排队机)
*/
private String type;
/**
* 备注
*/
private String remark;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof AccessStatLogEntity) {
AccessStatLogEntity tmp = (AccessStatLogEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.accessId = 0L;
this.siteId = null;
this.siteCode = "";
this.siteName = "";
this.statStartTime = null;
this.statEndTime = null;
this.duration = 0L;
this.type = "全部";
this.remark = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.access.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.mortals.framework.annotation.Excel;
import java.math.BigDecimal;
import java.util.Date;
/**
* 统计日志视图对象
*
* @author zxfei
* @date 2024-07-26
*/
@Data
public class AccessStatLogVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private List <Long> idList;
}
\ No newline at end of file
package com.mortals.xhx.module.access.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import com.mortals.xhx.module.access.dao.AccessStatLogDao;
/**
* AccessStatLogService
*
* 统计日志 service接口
*
* @author zxfei
* @date 2024-07-26
*/
public interface AccessStatLogService extends ICRUDService<AccessStatLogEntity,Long>{
AccessStatLogDao getDao();
}
\ No newline at end of file
package com.mortals.xhx.module.access.service.impl;
import org.springframework.beans.BeanUtils;
import java.util.function.Function;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.access.dao.AccessStatLogDao;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import com.mortals.xhx.module.access.service.AccessStatLogService;
import lombok.extern.slf4j.Slf4j;
/**
* AccessStatLogService
* 统计日志 service实现
*
* @author zxfei
* @date 2024-07-26
*/
@Service("accessStatLogService")
@Slf4j
public class AccessStatLogServiceImpl extends AbstractCRUDServiceImpl<AccessStatLogDao, AccessStatLogEntity, Long> implements AccessStatLogService {
}
\ No newline at end of file
package com.mortals.xhx.module.access.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.access.model.AccessStatLogEntity;
import com.mortals.xhx.module.access.service.AccessStatLogService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
/**
*
* 统计日志
*
* @author zxfei
* @date 2024-07-26
*/
@RestController
@RequestMapping("access/stat/log")
public class AccessStatLogController extends BaseCRUDJsonBodyMappingController<AccessStatLogService,AccessStatLogEntity,Long> {
@Autowired
private ParamService paramService;
public AccessStatLogController(){
super.setModuleDesc( "统计日志");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "type", TypeEnum.getEnumMap());
super.init(model, context);
}
}
\ No newline at end of file
...@@ -7,6 +7,8 @@ import com.mortals.framework.model.OrderCol; ...@@ -7,6 +7,8 @@ import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.access.service.AccessService;
import com.mortals.xhx.module.access.service.AccessStatLogService;
import com.mortals.xhx.module.ph.model.PhQueueEntity; import com.mortals.xhx.module.ph.model.PhQueueEntity;
import com.mortals.xhx.module.ph.model.PhQueueQuery; import com.mortals.xhx.module.ph.model.PhQueueQuery;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery; import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
...@@ -40,6 +42,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -40,6 +42,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
@Autowired @Autowired
private PhQueueService phQueueService; private PhQueueService phQueueService;
@Override @Override
public Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context) { public Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context) {
...@@ -59,7 +62,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -59,7 +62,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
List<PhQueueEntity> phQueueEntities = phQueueService.find(phQueueQuery); List<PhQueueEntity> phQueueEntities = phQueueService.find(phQueueQuery);
// log.info("更新站点排队统计数据,站点ID:{},站点名称:{},日期:{},排队数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点ID:{},站点名称:{},日期:{},排队数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size());
updateSitePhCount(entity, phQueueEntities); updateSitePhCount(entity, phQueueEntities);
//部门 //部门
updateSiteSectionNamePhCount(currentDate, entity, phQueueEntities); updateSiteSectionNamePhCount(currentDate, entity, phQueueEntities);
...@@ -215,8 +218,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -215,8 +218,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&"); String[] split = StrUtil.splitToArray(vals, "&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
...@@ -236,7 +239,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -236,7 +239,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getWindowFromnum())); .collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&"); String[] split = StrUtil.splitToArray(vals, "&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
...@@ -257,7 +260,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -257,7 +260,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum())); .collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&"); String[] split = StrUtil.splitToArray(vals, "&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
...@@ -277,7 +280,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -277,7 +280,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName() + "&" + x.getWindowFromnum())); .collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&"); String[] split = StrUtil.splitToArray(vals, "&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1]) || ObjectUtils.isEmpty(split[2])) if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1]) || ObjectUtils.isEmpty(split[2]))
return null; return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
...@@ -295,7 +298,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -295,7 +298,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
saveUpdatePjStatList(saveAndUpdatelist); saveUpdatePjStatList(saveAndUpdatelist);
} }
private PhQueueStatQuery getPhQueueStatQuery(PhQueueStatEntity entity) { private PhQueueStatQuery getPhQueueStatQuery(PhQueueStatEntity entity) {
PhQueueStatQuery phQueueStatQuery = new PhQueueStatQuery().siteId(entity.getSiteId()) PhQueueStatQuery phQueueStatQuery = new PhQueueStatQuery().siteId(entity.getSiteId())
.year(entity.getYear()) .year(entity.getYear())
.month(entity.getMonth()) .month(entity.getMonth())
...@@ -333,37 +336,32 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -333,37 +336,32 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void saveUpdatePjStatList(List<PhQueueStatEntity> saveAndUpdatelist) { private void saveUpdatePjStatList(List<PhQueueStatEntity> saveAndUpdatelist) {
if (!ObjectUtils.isEmpty(saveAndUpdatelist)) { if (!ObjectUtils.isEmpty(saveAndUpdatelist)) {
Map<Boolean, List<PhQueueStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity())); Map<Boolean, List<PhQueueStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity()));
log.info("新增站点评价统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) {
//新增列表
this.save(saveUpdateCollect.get(true));
}
log.info("更新站点评价统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表
this.update(saveUpdateCollect.get(true));
}
log.info("新增站点评价统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) {
//新增列表
this.save(saveUpdateCollect.get(true));
}
log.info("更新站点评价统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表
this.update(saveUpdateCollect.get(true));
} }
}
} }
public static void main(String[] args) { public static void main(String[] args) {
String str="adbc&&"; String str = "adbc&&";
List<String> split = StrUtil.split(str, "&"); List<String> split = StrUtil.split(str, "&");
String[] strings = StrUtil.splitToArray(str, "&"); String[] strings = StrUtil.splitToArray(str, "&");
System.out.println(split.get(0)); System.out.println(split.get(0));
System.out.println(split.get(1)); System.out.println(split.get(1));
System.out.println(strings[0]); System.out.println(strings[0]);
System.out.println(strings[1]); System.out.println(strings[1]);
System.out.println(strings[2]); System.out.println(strings[2]);
} }
} }
\ No newline at end of file
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
{
"loginName":"admin",
"password":"admin",
"securityCode":"8888"
}
> {%
client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###统计日志列表
POST {{baseUrl}}/access/stat/log/list
Content-Type: application/json
{
"page":1,
"size":10
}
###统计日志更新与保存
POST {{baseUrl}}/access/stat/log/save
Authorization: {{authToken}}
Content-Type: application/json
{
"accessId":"6QOXxd",
"siteId":589,
"siteCode":"hnPF0D",
"siteName":"USMODh",
"statStartTime":"1721923200000",
"statEndTime":"1721923200000",
"duration":0,
"type":"全部",
"remark":"qYJVAJ",
}
> {%
client.global.set("AccessStatLog_id", JSON.parse(response.body).data.id);
%}
###统计日志查看
GET {{baseUrl}}/access/stat/log/info?id=1
###统计日志编辑
GET {{baseUrl}}/access/stat/log/edit?id=1
Accept: application/json
###统计日志删除
GET {{baseUrl}}/access/stat/log/delete?id=1
Authorization: {{authToken}}
Accept: application/json
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment