Commit 5105d17b authored by 赵啸非's avatar 赵啸非

添加系统接入模块

parent b54b8c95
...@@ -162,14 +162,22 @@ DROP TABLE IF EXISTS `mortals_xhx_pj_evaluate_stat`; ...@@ -162,14 +162,22 @@ DROP TABLE IF EXISTS `mortals_xhx_pj_evaluate_stat`;
DROP TABLE IF EXISTS `mortals_xhx_access`; DROP TABLE IF EXISTS `mortals_xhx_access`;
CREATE TABLE mortals_xhx_access( CREATE TABLE mortals_xhx_access(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`area_name` varchar(64) NOT NULL COMMENT '区域名称', `area_id` varchar(64) NOT NULL DEFAULT '' COMMENT '区域Id',
`area_code` varchar(64) NOT NULL COMMENT '区域编码', `area_name` varchar(64) NOT NULL DEFAULT '' COMMENT '区域名称',
`big_path` varchar(128) NOT NULL COMMENT '背景图片地址', `area_code` varchar(64) NOT NULL DEFAULT '' COMMENT '区域编码',
`tag` varchar(255) NOT NULL COMMENT '标签', `site_id` bigint(20) COMMENT '站点Id',
`site_code` varchar(128) NOT NULL DEFAULT '' COMMENT '站点编码',
`site_name` varchar(128) NOT NULL DEFAULT '' COMMENT '站点名称',
`big_path` varchar(128) NOT NULL DEFAULT '' COMMENT '背景图片地址',
`icon` varchar(128) NOT NULL DEFAULT '' COMMENT '图标',
`tag` varchar(255) NOT NULL DEFAULT '' COMMENT '标签',
`latitude` varchar(64) NOT NULL DEFAULT '' COMMENT '维度',
`longitude` varchar(64) COMMENT '经度',
`type` varchar(16) NOT NULL DEFAULT '类型' COMMENT '接入类型 (area.区域,site.站点)',
`sort` int(4) DEFAULT '0' COMMENT '排序', `sort` int(4) DEFAULT '0' COMMENT '排序',
`remark` varchar(128) COMMENT '备注', `remark` varchar(128) NOT NULL DEFAULT '' COMMENT '备注',
`create_user_id` bigint(20) COMMENT '创建用户', `create_user_id` bigint(20) COMMENT '创建用户',
`create_time` datetime NOT NULL COMMENT '创建时间', `create_time` datetime COMMENT '创建时间',
`update_time` datetime COMMENT '更新时间', `update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域接入'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域接入';
...@@ -191,4 +199,28 @@ CREATE TABLE mortals_xhx_access_system( ...@@ -191,4 +199,28 @@ CREATE TABLE mortals_xhx_access_system(
`create_time` datetime NOT NULL COMMENT '创建时间', `create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime COMMENT '更新时间', `update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域接入系统'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='区域接入系统';
\ No newline at end of file
-- ----------------------------
-- 汇总统计表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_stat`;
CREATE TABLE `mortals_xhx_stat` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`site_id` bigint(20) COMMENT '站点Id',
`site_code` varchar(128) DEFAULT '' COMMENT '站点编码',
`site_name` varchar(128) DEFAULT '' COMMENT '站点名称',
`count` int(9) NOT NULL COMMENT '数量',
`year` int(9) NOT NULL COMMENT '年',
`month` int(9) NOT NULL COMMENT '月',
`day` int(9) NOT NULL COMMENT '日',
`create_user_id` bigint(20) COMMENT '创建用户',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
,KEY `year` (`year`) USING BTREE
,KEY `month` (`month`) USING BTREE
,KEY `day` (`day`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='汇总统计';
\ No newline at end of file
...@@ -391,4 +391,8 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -391,4 +391,8 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
Long[] userIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getId).toArray(Long[]::new); Long[] userIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getId).toArray(Long[]::new);
roleUserService.remove(userIds, context); roleUserService.remove(userIds, context);
} }
public static void main(String[] args) throws Exception {
System.out.println(SecurityUtil.md5DoubleEncoding("wangdongmei@123"));
}
} }
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 接入类型 (area.区域,site.站点)枚举类
*
* @author zxfei
*/
public enum TypeEnum {
区域("area", "区域"),
站点("site", "站点");
private String value;
private String desc;
TypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static TypeEnum getByValue(String value) {
for (TypeEnum typeEnum : TypeEnum.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 (TypeEnum item : TypeEnum.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
...@@ -8,7 +8,7 @@ import java.util.List; ...@@ -8,7 +8,7 @@ import java.util.List;
* 区域接入 DAO接口 * 区域接入 DAO接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
public interface AccessDao extends ICRUDDao<AccessEntity,Long>{ public interface AccessDao extends ICRUDDao<AccessEntity,Long>{
......
...@@ -8,7 +8,7 @@ import java.util.List; ...@@ -8,7 +8,7 @@ import java.util.List;
* 区域接入系统 DAO接口 * 区域接入系统 DAO接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
public interface AccessSystemDao extends ICRUDDao<AccessSystemEntity,Long>{ public interface AccessSystemDao extends ICRUDDao<AccessSystemEntity,Long>{
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
* 区域接入DaoImpl DAO接口 * 区域接入DaoImpl DAO接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Repository("accessDao") @Repository("accessDao")
public class AccessDaoImpl extends BaseCRUDDaoMybatis<AccessEntity,Long> implements AccessDao { public class AccessDaoImpl extends BaseCRUDDaoMybatis<AccessEntity,Long> implements AccessDao {
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
* 区域接入系统DaoImpl DAO接口 * 区域接入系统DaoImpl DAO接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Repository("accessSystemDao") @Repository("accessSystemDao")
public class AccessSystemDaoImpl extends BaseCRUDDaoMybatis<AccessSystemEntity,Long> implements AccessSystemDao { public class AccessSystemDaoImpl extends BaseCRUDDaoMybatis<AccessSystemEntity,Long> implements AccessSystemDao {
......
...@@ -15,7 +15,7 @@ import lombok.Data; ...@@ -15,7 +15,7 @@ import lombok.Data;
* 区域接入实体对象 * 区域接入实体对象
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Data @Data
public class AccessEntity extends AccessVo { public class AccessEntity extends AccessVo {
...@@ -46,6 +46,38 @@ public class AccessEntity extends AccessVo { ...@@ -46,6 +46,38 @@ public class AccessEntity extends AccessVo {
*/ */
private String remark; private String remark;
/** /**
* 区域Id
*/
private String areaId;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点编码
*/
private String siteCode;
/**
* 站点名称
*/
private String siteName;
/**
* 图标
*/
private String icon;
/**
* 维度
*/
private String latitude;
/**
* 经度
*/
private String longitude;
/**
* 接入类型 (area.区域,site.站点)
*/
private String type;
/**
* 区域接入系统信息 * 区域接入系统信息
*/ */
private List<AccessSystemEntity> accessSystemList=new ArrayList<>();; private List<AccessSystemEntity> accessSystemList=new ArrayList<>();;
...@@ -79,5 +111,13 @@ public class AccessEntity extends AccessVo { ...@@ -79,5 +111,13 @@ public class AccessEntity extends AccessVo {
this.tag = ""; this.tag = "";
this.sort = 0; this.sort = 0;
this.remark = ""; this.remark = "";
this.areaId = "";
this.siteId = null;
this.siteCode = "";
this.siteName = "";
this.icon = "";
this.latitude = "";
this.longitude = "";
this.type = "类型";
} }
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ import lombok.Data; ...@@ -14,7 +14,7 @@ import lombok.Data;
* 区域接入系统实体对象 * 区域接入系统实体对象
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Data @Data
public class AccessSystemEntity extends AccessSystemVo { public class AccessSystemEntity extends AccessSystemVo {
......
...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.access.model.AccessSystemEntity; ...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.access.model.AccessSystemEntity;
* 区域接入系统查询对象 * 区域接入系统查询对象
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
public class AccessSystemQuery extends AccessSystemEntity { public class AccessSystemQuery extends AccessSystemEntity {
/** 开始 序号,主键,自增长 */ /** 开始 序号,主键,自增长 */
......
...@@ -11,7 +11,7 @@ import java.util.Date; ...@@ -11,7 +11,7 @@ import java.util.Date;
* 区域接入系统视图对象 * 区域接入系统视图对象
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Data @Data
public class AccessSystemVo extends BaseEntityLong { public class AccessSystemVo extends BaseEntityLong {
......
...@@ -11,7 +11,7 @@ import java.util.Date; ...@@ -11,7 +11,7 @@ import java.util.Date;
* 区域接入视图对象 * 区域接入视图对象
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Data @Data
public class AccessVo extends BaseEntityLong { public class AccessVo extends BaseEntityLong {
......
...@@ -8,7 +8,7 @@ import com.mortals.xhx.module.access.dao.AccessDao; ...@@ -8,7 +8,7 @@ import com.mortals.xhx.module.access.dao.AccessDao;
* 区域接入 service接口 * 区域接入 service接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
public interface AccessService extends ICRUDService<AccessEntity,Long>{ public interface AccessService extends ICRUDService<AccessEntity,Long>{
......
...@@ -8,7 +8,7 @@ import com.mortals.xhx.module.access.dao.AccessSystemDao; ...@@ -8,7 +8,7 @@ import com.mortals.xhx.module.access.dao.AccessSystemDao;
* 区域接入系统 service接口 * 区域接入系统 service接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
public interface AccessSystemService extends ICRUDService<AccessSystemEntity,Long>{ public interface AccessSystemService extends ICRUDService<AccessSystemEntity,Long>{
......
...@@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
* 区域接入 service实现 * 区域接入 service实现
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Service("accessService") @Service("accessService")
@Slf4j @Slf4j
......
...@@ -12,7 +12,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -12,7 +12,7 @@ import lombok.extern.slf4j.Slf4j;
* 区域接入系统 service实现 * 区域接入系统 service实现
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@Service("accessSystemService") @Service("accessSystemService")
@Slf4j @Slf4j
......
...@@ -28,7 +28,7 @@ import com.mortals.xhx.common.code.*; ...@@ -28,7 +28,7 @@ import com.mortals.xhx.common.code.*;
* 区域接入 * 区域接入
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@RestController @RestController
@RequestMapping("access") @RequestMapping("access")
...@@ -43,6 +43,7 @@ public class AccessController extends BaseCRUDJsonBodyMappingController<AccessSe ...@@ -43,6 +43,7 @@ public class AccessController extends BaseCRUDJsonBodyMappingController<AccessSe
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "type", TypeEnum.getEnumMap());
super.init(model, context); super.init(model, context);
} }
......
...@@ -28,7 +28,7 @@ import com.mortals.xhx.common.code.*; ...@@ -28,7 +28,7 @@ import com.mortals.xhx.common.code.*;
* 区域接入系统 * 区域接入系统
* *
* @author zxfei * @author zxfei
* @date 2024-06-28 * @date 2024-07-02
*/ */
@RestController @RestController
@RequestMapping("access/system") @RequestMapping("access/system")
......
...@@ -28,4 +28,49 @@ public class PhQueueStatVo extends BaseEntityLong { ...@@ -28,4 +28,49 @@ public class PhQueueStatVo extends BaseEntityLong {
private List<String> hallNameList; private List<String> hallNameList;
/** 开始 年 */
private Integer yearStart;
/** 结束 年 */
private Integer yearEnd;
/** 增加 年 */
private Integer yearIncrement;
/** 年列表 */
private List <Integer> yearList;
/** 年排除列表 */
private List <Integer> yearNotList;
/** 开始 月 */
private Integer monthStart;
/** 结束 月 */
private Integer monthEnd;
/** 增加 月 */
private Integer monthIncrement;
/** 月列表 */
private List <Integer> monthList;
/** 月排除列表 */
private List <Integer> monthNotList;
/** 开始 日 */
private Integer dayStart;
/** 结束 日 */
private Integer dayEnd;
/** 增加 日 */
private Integer dayIncrement;
/** 日列表 */
private List <Integer> dayList;
/** 日排除列表 */
private List <Integer> dayNotList;
} }
\ No newline at end of file
...@@ -26,4 +26,57 @@ public class PjEvaluateStatVo extends BaseEntityLong { ...@@ -26,4 +26,57 @@ public class PjEvaluateStatVo extends BaseEntityLong {
private List<String> windowFromnumList; private List<String> windowFromnumList;
private List<String> hallNameList; private List<String> hallNameList;
/** 开始 评价时间 */
private String timeStart;
/** 结束 评价时间 */
private String timeEnd;
/** 开始 年 */
private Integer yearStart;
/** 结束 年 */
private Integer yearEnd;
/** 增加 年 */
private Integer yearIncrement;
/** 年列表 */
private List <Integer> yearList;
/** 年排除列表 */
private List <Integer> yearNotList;
/** 开始 月 */
private Integer monthStart;
/** 结束 月 */
private Integer monthEnd;
/** 增加 月 */
private Integer monthIncrement;
/** 月列表 */
private List <Integer> monthList;
/** 月排除列表 */
private List <Integer> monthNotList;
/** 开始 日 */
private Integer dayStart;
/** 结束 日 */
private Integer dayEnd;
/** 增加 日 */
private Integer dayIncrement;
/** 日列表 */
private List <Integer> dayList;
/** 日排除列表 */
private List <Integer> dayNotList;
} }
\ No newline at end of file
...@@ -81,6 +81,9 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -81,6 +81,9 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
if (ObjectUtils.isEmpty(query.getPjOption())) query.setPjOption(""); if (ObjectUtils.isEmpty(query.getPjOption())) query.setPjOption("");
if (ObjectUtils.isEmpty(query.getWindowFromnum())) query.setWindowFromnum(""); if (ObjectUtils.isEmpty(query.getWindowFromnum())) query.setWindowFromnum("");
//年月日
model.put("siteId",query.getSiteId()); model.put("siteId",query.getSiteId());
} }
......
package com.mortals.xhx.module.stat.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import com.mortals.xhx.module.stat.model.StatEntity;
import com.mortals.xhx.module.stat.model.StatQuery;
import java.util.List;
/**
* 汇总统计Dao
* 汇总统计 DAO接口
*
* @author zxfei
* @date 2024-07-02
*/
public interface StatDao extends ICRUDDao<StatEntity,Long>{
String SQLID_GET_STATLIST = "getAllStatList";
List<StatEntity> getStatList(StatQuery query, PageInfo pageInfo);
}
package com.mortals.xhx.module.stat.dao.ibatis;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import com.mortals.xhx.module.stat.model.StatQuery;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.stat.dao.StatDao;
import com.mortals.xhx.module.stat.model.StatEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 汇总统计DaoImpl DAO接口
*
* @author zxfei
* @date 2024-07-02
*/
@Repository("statDao")
public class StatDaoImpl extends BaseCRUDDaoMybatis<StatEntity,Long> implements StatDao {
@Override
public List<StatEntity> getStatList(StatQuery query, PageInfo pageInfo) {
ParamDto queryParam = super.getQueryParam(query);
if (pageInfo.getPrePageResult() == -1) {
return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam);
} else {
RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam, rowBounds);
}
}
}
package com.mortals.xhx.module.stat.model;
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.stat.model.vo.StatVo;
import lombok.Data;
/**
* 汇总统计实体对象
*
* @author zxfei
* @date 2024-07-02
*/
@Data
public class StatEntity extends StatVo {
private static final long serialVersionUID = 1L;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点编码
*/
private String siteCode;
/**
* 站点名称
*/
private String siteName;
/**
* 数量
*/
private Integer count;
/**
* 年
*/
private Integer year;
/**
* 月
*/
private Integer month;
/**
* 日
*/
private Integer day;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof StatEntity) {
StatEntity tmp = (StatEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.siteId = null;
this.siteCode = "";
this.siteName = "";
this.count = 0;
this.year = DateUtil.year(new Date());
this.month = DateUtil.month(new Date())+1;
this.day = DateUtil.dayOfMonth(new Date());
}
}
\ No newline at end of file
package com.mortals.xhx.module.stat.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.stat.model.StatEntity;
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-02
*/
@Data
public class StatVo extends BaseEntityLong {
/** ID列表 */
private List <Long> idList;
/** 开始 创建时间 */
private String createTimeStart;
/** 结束 创建时间 */
private String createTimeEnd;
/** 开始 年 */
private Integer yearStart;
/** 结束 年 */
private Integer yearEnd;
/** 增加 年 */
private Integer yearIncrement;
/** 年列表 */
private List <Integer> yearList;
/** 年排除列表 */
private List <Integer> yearNotList;
/** 开始 月 */
private Integer monthStart;
/** 结束 月 */
private Integer monthEnd;
/** 增加 月 */
private Integer monthIncrement;
/** 月列表 */
private List <Integer> monthList;
/** 月排除列表 */
private List <Integer> monthNotList;
/** 开始 日 */
private Integer dayStart;
/** 结束 日 */
private Integer dayEnd;
/** 日列表 */
private List <Integer> dayList;
/** 日排除列表 */
private List <Integer> dayNotList;
}
\ No newline at end of file
package com.mortals.xhx.module.stat.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.stat.model.StatEntity;
import com.mortals.xhx.module.stat.dao.StatDao;
/**
* StatService
*
* 汇总统计 service接口
*
* @author zxfei
* @date 2024-07-02
*/
public interface StatService extends ICRUDService<StatEntity,Long>{
StatDao getDao();
/**
* 更新站点统计
* @param entity
* @param context
* @return
*/
Rest<Void> updateSiteStat(StatEntity entity, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.stat.service.impl;
import com.mortals.framework.common.Rest;
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.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.ph.service.PhQueueStatService;
import com.mortals.xhx.module.pj.model.PjEvaluateEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import com.mortals.xhx.module.pj.service.PjEvaluateStatService;
import com.mortals.xhx.module.stat.model.StatQuery;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.stat.dao.StatDao;
import com.mortals.xhx.module.stat.model.StatEntity;
import com.mortals.xhx.module.stat.service.StatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* StatService
* 汇总统计 service实现
*
* @author zxfei
* @date 2024-07-02
*/
@Service("statService")
@Slf4j
public class StatServiceImpl extends AbstractCRUDServiceImpl<StatDao, StatEntity, Long> implements StatService {
@Autowired
private PjEvaluateStatService pjEvaluateStatService;
@Autowired
private PhQueueStatService phQueueStatService;
@Override
public Result<StatEntity> find(StatEntity entity, PageInfo pageInfo, Context context) throws AppException {
Result<StatEntity> result = new Result<>();
StatQuery query = new StatQuery();
BeanUtils.copyProperties(entity, query, BeanUtil.getNullPropertyNames(entity));
List<StatEntity> billInfos = this.getBillInfos(query, pageInfo, context);
result.setList(billInfos);
result.setPageInfo(pageInfo);
return result;
}
public List<StatEntity> getBillInfos(StatQuery query, PageInfo pageInfo, Context context) {
if (!ObjectUtils.isEmpty(query.getGroupList())) {
//针对groupList分组 进行排序
if (query.getGroupList().contains("year") && query.getGroupList().contains("month") && query.getGroupList().contains("day")) {
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("day", OrderCol.DESCENDING), new OrderCol("createTime")));
} else if (query.getGroupList().contains("year") && query.getGroupList().contains("month")) {
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("createTime")));
} else if (query.getGroupList().contains("year")) {
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("createTime")));
}
}
return this.getDao().getStatList(query, pageInfo);
}
@Override
public Rest<Void> updateSiteStat(StatEntity entity, Context context) {
//查询当前站点当日评价数量
PjEvaluateStatQuery pjEvaluateStatQuery = new PjEvaluateStatQuery();
pjEvaluateStatQuery.setSiteId(entity.getSiteId());
pjEvaluateStatQuery.setYear(entity.getYear());
pjEvaluateStatQuery.setMonth(entity.getMonth());
pjEvaluateStatQuery.setDay(entity.getDay());
PjEvaluateStatEntity pjEvaluateStatEntity = pjEvaluateStatService.selectOne(pjEvaluateStatQuery, context);
PhQueueStatQuery phQueueStatQuery = new PhQueueStatQuery();
phQueueStatQuery.setSiteId(entity.getSiteId());
phQueueStatQuery.setYear(entity.getYear());
phQueueStatQuery.setMonth(entity.getMonth());
phQueueStatQuery.setDay(entity.getDay());
PhQueueStatEntity phQueueStatEntity = phQueueStatService.selectOne(phQueueStatQuery, context);
int pjcount = pjEvaluateStatEntity == null ? 0 : pjEvaluateStatEntity.getPjCount();
int phcount = phQueueStatEntity == null ? 0 : phQueueStatEntity.getPhCount();
StatEntity StatEntity = this.selectOne(new StatQuery()
.siteId(entity.getSiteId())
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
if (ObjectUtils.isEmpty(StatEntity)) {
StatEntity = new StatEntity();
StatEntity.initAttrValue();
StatEntity.setSiteId(entity.getSiteId());
StatEntity.setSiteCode(entity.getSiteCode());
StatEntity.setSiteName(entity.getSiteName());
StatEntity.setCount(pjcount+phcount);
StatEntity.setYear(entity.getYear());
StatEntity.setMonth(entity.getMonth());
StatEntity.setDay(entity.getDay());
StatEntity.setCreateTime(new Date());
StatEntity.setCreateUserId(1L);
this.save(StatEntity);
} else {
StatEntity.setCount(pjcount+phcount);
StatEntity.setYear(entity.getYear());
StatEntity.setMonth(entity.getMonth());
StatEntity.setDay(entity.getDay());
StatEntity.setUpdateTime(new Date());
StatEntity.setUpdateUserId(1L);
this.update(StatEntity);
}
return Rest.ok();
}
}
\ No newline at end of file
package com.mortals.xhx.module.stat.web;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
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.pj.model.PjEvaluateQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.stat.model.StatQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
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.stat.model.StatEntity;
import com.mortals.xhx.module.stat.service.StatService;
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-02
*/
@RestController
@RequestMapping("stat")
@Slf4j
public class StatController extends BaseCRUDJsonBodyMappingController<StatService, StatEntity, Long> {
@Autowired
private ParamService paramService;
@Autowired
private ISiteFeign siteFeign;
@Autowired
private ICacheService cacheService;
public StatController() {
super.setModuleDesc("汇总统计");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
@PostMapping(value = "/stat")
@UnAuth
public Rest<String> stat(@RequestBody StatQuery query) {
Rest<String> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code = 1;
try {
//天数区间分段计算
DateTime attendStart = DateUtil.parseDate(query.getCreateTimeStart());
DateTime attendEnd = DateUtil.parseDate(query.getCreateTimeEnd());
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
StatEntity statEntity = new StatEntity();
statEntity.initAttrValue();
statEntity.setSiteId(site.getId());
statEntity.setSiteName(site.getSiteName());
statEntity.setSiteCode(site.getSiteCode());
statEntity.setYear(curDate.year());
statEntity.setMonth(curDate.month() + 1);
statEntity.setDay(curDate.dayOfMonth());
//设置年月日
this.service.updateSiteStat(statEntity, context);
});
}
stopWatch.stop();
log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
}
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
code = -1;
this.doException(this.request, busiDesc, model, e);
model.put("message_info", e.getMessage());
}
this.init(model, context);
ret.setCode(code);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
\ No newline at end of file
...@@ -27,6 +27,13 @@ ...@@ -27,6 +27,13 @@
where where
<trim prefixOverrides="and" prefix=""> <trim prefixOverrides="and" prefix="">
<include refid="_condition_"/> <include refid="_condition_"/>
<if test="conditionParamRef.containsKey('timeStart') and conditionParamRef.timeStart != null and conditionParamRef.timeStart!=''">
${_conditionType_} STR_TO_DATE(CONCAT(`year`,'-',`month`,'-',`day`),'%Y-%m-%d')<![CDATA[ >= ]]>STR_TO_DATE(${_conditionParam_}.timeStart},'%Y-%m-%d')
</if>
<if test="conditionParamRef.containsKey('timeEnd') and conditionParamRef.timeEnd != null and conditionParamRef.timeEnd!=''">
${_conditionType_} STR_TO_DATE(CONCAT(`year`,'-',`month`,'-',`day`),'%Y-%m-%d')<![CDATA[ <= ]]>STR_TO_DATE(${_conditionParam_}.createTimeEnd},'%Y-%m-%d')
</if>
</trim> </trim>
</trim> </trim>
<include refid="_group_by_"/> <include refid="_group_by_"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.ph.dao.ibatis.PhQueueStatDaoImpl">
<!-- 获取统计列表 -->
<select id="getAllStatList" parameterType="paramDto" resultMap="StatEntity-Map">
select
<!-- 获取分组字段 -->
<if test="groupList != null and !groupList.isEmpty()">
<foreach collection="groupList" open="" close="" index="index" item="item">
${item},
</foreach>
</if>
a.site_id,
a.site_code,
a.site_name,
<!-- 评价数量-->
sum(IFNULL(a.count,0)) count
from mortals_xhx_stat as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
<include refid="_group_by_"/>
<include refid="_orderCols_"/>
</select>
</mapper>
\ No newline at end of file
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