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

添加统计日志

parent 24a45472
-- ----------------------------
2024-04-08
-- 2024-04-08
-- ----------------------------
-- ----------------------------
-- 排号汇总表
......@@ -121,9 +121,11 @@ CREATE TABLE mortals_xhx_access(
`tag` varchar(255) NOT NULL DEFAULT '' COMMENT '标签',
`latitude` varchar(64) NOT NULL DEFAULT '' COMMENT '维度',
`longitude` varchar(64) COMMENT '经度',
`access_time` datetime COMMENT '接入开通时间',
`type` varchar(16) NOT NULL DEFAULT '类型' COMMENT '接入类型 (area.区域,site.站点)',
`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_time` datetime COMMENT '创建时间',
`update_time` datetime COMMENT '更新时间',
......@@ -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, '系统管理员');
-- ----------------------------
-- 区域统计日志表
-- ----------------------------
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
if (!ObjectUtils.isEmpty(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();
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;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask;
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.keys.RedisCacheKeys;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu;
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.PhQueueStatQuery;
import com.mortals.xhx.module.ph.service.PhQueueStatService;
......@@ -24,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import java.util.Arrays;
import java.util.Date;
......@@ -51,15 +58,23 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
@Autowired
private ICacheService cacheService;
@Autowired
private AccessService accessService;
@Autowired
private AccessStatLogService accessStatLogService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("站点评价统计任务");
//统计最近一周
statByDate();
log.info("站点统计缓存任务");
//统计排号与评价 部门,等字典顺序记录次数
updateSiteCache();
}
private void updateSiteCache() {
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
......@@ -131,7 +146,6 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
}
private void updatePjSectionCache(SitePdu site) {
PjEvaluateStatQuery pjEvaluateStatQuery = new PjEvaluateStatQuery();
pjEvaluateStatQuery.setSiteId(site.getId());
......@@ -178,7 +192,41 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
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);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
......@@ -195,7 +243,21 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
sitestatEntity.setDay(day);
//设置年月日
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.initAttrValue();
......@@ -208,7 +270,17 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
phQueueStatEntity.setDay(day);
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.initAttrValue();
statEntity.setSiteId(site.getId());
......@@ -222,6 +294,11 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
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;
import java.util.List;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
......@@ -12,11 +13,11 @@ import com.mortals.xhx.module.access.model.vo.AccessVo;
import com.mortals.xhx.module.access.model.AccessSystemEntity;
import lombok.Data;
/**
* 区域接入实体对象
*
* @author zxfei
* @date 2024-07-02
*/
* 区域接入实体对象
*
* @author zxfei
* @date 2024-07-26
*/
@Data
public class AccessEntity extends AccessVo {
private static final long serialVersionUID = 1L;
......@@ -77,6 +78,14 @@ public class AccessEntity extends AccessVo {
* 接入类型 (area.区域,site.站点)
*/
private String type;
/**
* 接入开通时间
*/
private Date accessTime;
/**
* 描述内容
*/
private String content;
/**
* 区域接入系统信息
*/
......@@ -119,5 +128,7 @@ public class AccessEntity extends AccessVo {
this.latitude = "";
this.longitude = "";
this.type = "类型";
this.accessTime = null;
this.content = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.access.model;
import java.util.List;
import java.util.Date;
import java.util.List;
import com.mortals.xhx.module.access.model.AccessEntity;
/**
* 区域接入查询对象
*
* @author zxfei
* @date 2024-07-02
*/
* 区域接入查询对象
*
* @author zxfei
* @date 2024-07-26
*/
public class AccessQuery extends AccessEntity {
/** 开始 序号,主键,自增长 */
private Long idStart;
......@@ -142,6 +143,17 @@ public class AccessQuery extends AccessEntity {
/** 接入类型 (area.区域,site.站点)排除列表 */
private List <String> typeNotList;
/** 开始 接入开通时间 */
private String accessTimeStart;
/** 结束 接入开通时间 */
private String accessTimeEnd;
/** 描述内容 */
private List<String> contentList;
/** 描述内容排除列表 */
private List <String> contentNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<AccessQuery> orConditionList;
......@@ -922,6 +934,70 @@ public class AccessQuery extends AccessEntity {
this.typeNotList = typeNotList;
}
/**
* 获取 开始 接入开通时间
* @return accessTimeStart
*/
public String getAccessTimeStart(){
return this.accessTimeStart;
}
/**
* 设置 开始 接入开通时间
* @param accessTimeStart
*/
public void setAccessTimeStart(String accessTimeStart){
this.accessTimeStart = accessTimeStart;
}
/**
* 获取 结束 接入开通时间
* @return accessTimeEnd
*/
public String getAccessTimeEnd(){
return this.accessTimeEnd;
}
/**
* 设置 结束 接入开通时间
* @param accessTimeEnd
*/
public void setAccessTimeEnd(String accessTimeEnd){
this.accessTimeEnd = accessTimeEnd;
}
/**
* 获取 描述内容
* @return contentList
*/
public List<String> getContentList(){
return this.contentList;
}
/**
* 设置 描述内容
* @param contentList
*/
public void setContentList(List<String> contentList){
this.contentList = contentList;
}
/**
* 获取 描述内容
* @return contentNotList
*/
public List<String> getContentNotList(){
return this.contentNotList;
}
/**
* 设置 描述内容
* @param contentNotList
*/
public void setContentNotList(List<String> contentNotList){
this.contentNotList = contentNotList;
}
/**
* 设置 序号,主键,自增长
* @param id
......@@ -1368,6 +1444,26 @@ public class AccessQuery extends AccessEntity {
return this;
}
/**
* 设置 描述内容
* @param content
*/
public AccessQuery content(String content){
setContent(content);
return this;
}
/**
* 设置 描述内容
* @param contentList
*/
public AccessQuery contentList(List<String> contentList){
this.contentList = contentList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
......
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;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
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.PhQueueQuery;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
......@@ -40,6 +42,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
@Autowired
private PhQueueService phQueueService;
@Override
public Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context) {
......@@ -215,7 +218,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
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;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
......@@ -236,7 +239,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
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;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
......@@ -257,7 +260,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
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;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
......@@ -277,7 +280,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
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]))
return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
......@@ -351,19 +354,14 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
}
public static void main(String[] args) {
String str="adbc&&";
String str = "adbc&&";
List<String> split = StrUtil.split(str, "&");
String[] strings = StrUtil.splitToArray(str, "&");
System.out.println(split.get(0));
System.out.println(split.get(1));
System.out.println(strings[0]);
System.out.println(strings[1]);
System.out.println(strings[2]);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.access.dao.ibatis.AccessDaoImpl">
<!-- 字段和属性映射 -->
......@@ -23,23 +23,10 @@
<result property="latitude" column="latitude" />
<result property="longitude" column="longitude" />
<result property="type" column="type" />
<collection property="accessSystemList" column="id" ofType="AccessSystemEntity" javaType="ArrayList" select="getAccessSystemByAccessId"></collection>
</resultMap>
<resultMap type="AccessSystemEntity" id="AccessSystemEntity-Map">
<result property="id" column="id" />
<result property="accessId" column="accessId" />
<result property="systemName" column="system_name" />
<result property="systemCode" column="system_code" />
<result property="enabled" column="enabled" />
<result property="accessTime" column="access_time" />
<result property="sort" column="sort" />
<result property="remark" column="remark" />
<result property="createUserId" column="create_user_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="content" column="content" />
</resultMap>
<!-- 表所有列 -->
<sql id="_columns">
<trim suffixOverrides="," suffix="">
......@@ -97,6 +84,12 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('type') or colPickMode == 1 and data.containsKey('type')))">
a.type,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('accessTime') or colPickMode == 1 and data.containsKey('accessTime')))">
a.access_time,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('content') or colPickMode == 1 and data.containsKey('content')))">
a.content,
</if>
</trim>
</sql>
<!-- 子表所有列 -->
......@@ -108,18 +101,18 @@
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="AccessEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_access
(area_name,area_code,big_path,tag,sort,remark,create_user_id,create_time,update_time,area_id,site_id,site_code,site_name,icon,latitude,longitude,type)
(area_name,area_code,big_path,tag,sort,remark,create_user_id,create_time,update_time,area_id,site_id,site_code,site_name,icon,latitude,longitude,type,access_time,content)
VALUES
(#{areaName},#{areaCode},#{bigPath},#{tag},#{sort},#{remark},#{createUserId},#{createTime},#{updateTime},#{areaId},#{siteId},#{siteCode},#{siteName},#{icon},#{latitude},#{longitude},#{type})
(#{areaName},#{areaCode},#{bigPath},#{tag},#{sort},#{remark},#{createUserId},#{createTime},#{updateTime},#{areaId},#{siteId},#{siteCode},#{siteName},#{icon},#{latitude},#{longitude},#{type},#{accessTime},#{content})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_access
(area_name,area_code,big_path,tag,sort,remark,create_user_id,create_time,update_time,area_id,site_id,site_code,site_name,icon,latitude,longitude,type)
(area_name,area_code,big_path,tag,sort,remark,create_user_id,create_time,update_time,area_id,site_id,site_code,site_name,icon,latitude,longitude,type,access_time,content)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.areaName},#{item.areaCode},#{item.bigPath},#{item.tag},#{item.sort},#{item.remark},#{item.createUserId},#{item.createTime},#{item.updateTime},#{item.areaId},#{item.siteId},#{item.siteCode},#{item.siteName},#{item.icon},#{item.latitude},#{item.longitude},#{item.type})
(#{item.areaName},#{item.areaCode},#{item.bigPath},#{item.tag},#{item.sort},#{item.remark},#{item.createUserId},#{item.createTime},#{item.updateTime},#{item.areaId},#{item.siteId},#{item.siteCode},#{item.siteName},#{item.icon},#{item.latitude},#{item.longitude},#{item.type},#{item.accessTime},#{item.content})
</foreach>
</insert>
......@@ -189,6 +182,12 @@
<if test="(colPickMode==0 and data.containsKey('type')) or (colPickMode==1 and !data.containsKey('type'))">
a.type=#{data.type},
</if>
<if test="(colPickMode==0 and data.containsKey('accessTime')) or (colPickMode==1 and !data.containsKey('accessTime'))">
a.access_time=#{data.accessTime},
</if>
<if test="(colPickMode==0 and data.containsKey('content')) or (colPickMode==1 and !data.containsKey('content'))">
a.content=#{data.content},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -335,6 +334,20 @@
</if>
</foreach>
</trim>
<trim prefix="access_time=(case" suffix="ELSE access_time end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('accessTime')) or (colPickMode==1 and !item.containsKey('accessTime'))">
when a.id=#{item.id} then #{item.accessTime}
</if>
</foreach>
</trim>
<trim prefix="content=(case" suffix="ELSE content end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('content')) or (colPickMode==1 and !item.containsKey('content'))">
when a.id=#{item.id} then #{item.content}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -853,6 +866,42 @@
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('accessTime')">
<if test="conditionParamRef.accessTime != null ">
${_conditionType_} a.access_time = #{${_conditionParam_}.accessTime}
</if>
<if test="conditionParamRef.accessTime == null">
${_conditionType_} a.access_time is null
</if>
</if>
<if test="conditionParamRef.containsKey('accessTimeStart') and conditionParamRef.accessTimeStart != null and conditionParamRef.accessTimeStart!=''">
${_conditionType_} a.access_time <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.accessTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('accessTimeEnd') and conditionParamRef.accessTimeEnd != null and conditionParamRef.accessTimeEnd!=''">
${_conditionType_} a.access_time <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.accessTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('content')">
<if test="conditionParamRef.content != null and conditionParamRef.content != ''">
${_conditionType_} a.content like #{${_conditionParam_}.content}
</if>
<if test="conditionParamRef.content == null">
${_conditionType_} a.content is null
</if>
</if>
<if test="conditionParamRef.containsKey('contentList') and conditionParamRef.contentList.size() > 0">
${_conditionType_} a.content in
<foreach collection="conditionParamRef.contentList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('contentNotList') and conditionParamRef.contentNotList.size() > 0">
${_conditionType_} a.content not in
<foreach collection="conditionParamRef.contentNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
......@@ -1012,6 +1061,16 @@
<if test='orderCol.type != null and "DESC".equalsIgnoreCase(orderCol.type)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('accessTime')">
a.access_time
<if test='orderCol.accessTime != null and "DESC".equalsIgnoreCase(orderCol.accessTime)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('content')">
a.content
<if test='orderCol.content != null and "DESC".equalsIgnoreCase(orderCol.content)'>DESC</if>
,
</if>
</trim>
</if>
......
###登录
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