Commit 7422e1ac authored by 赵啸非's avatar 赵啸非

添加排号与评价统计报表

parent a98846b0
...@@ -28,7 +28,7 @@ CREATE TABLE mortals_xhx_ph_queue( ...@@ -28,7 +28,7 @@ CREATE TABLE mortals_xhx_ph_queue(
`device_name` varchar(128) NOT NULL COMMENT '取号设备名', `device_name` varchar(128) NOT NULL COMMENT '取号设备名',
`call_name` varchar(128) NOT NULL COMMENT '呼叫设备', `call_name` varchar(128) NOT NULL COMMENT '呼叫设备',
`matter_name` varchar(256) NOT NULL COMMENT '事项名', `matter_name` varchar(256) NOT NULL COMMENT '事项名',
`queueid` varchar(128) NOT NULL COMMENT '排号队列ID,唯一', `queueid` varchar(128) NOT NULL COMMENT '排号队列ID',
`wy_signin` varchar(16) NOT NULL DEFAULT '现场取号' COMMENT '取号方式 (现场取号,微信取号)', `wy_signin` varchar(16) NOT NULL DEFAULT '现场取号' COMMENT '取号方式 (现场取号,微信取号)',
`section_name` varchar(128) NOT NULL COMMENT '部门名称', `section_name` varchar(128) NOT NULL COMMENT '部门名称',
`hall_name` varchar(128) NOT NULL COMMENT '大厅名称', `hall_name` varchar(128) NOT NULL COMMENT '大厅名称',
...@@ -49,10 +49,65 @@ PRIMARY KEY (`id`) ...@@ -49,10 +49,65 @@ PRIMARY KEY (`id`)
,KEY `workman_number` (`workman_number`) USING BTREE ,KEY `workman_number` (`workman_number`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='排号汇总'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='排号汇总';
-- ----------------------------
-- 排号汇总统计表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_ph_queue_stat`;
CREATE TABLE `mortals_xhx_ph_queue_stat` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`site_id` bigint(20) DEFAULT '0' COMMENT '站点Id',
`site_code` varchar(128) COMMENT '站点编码',
`site_name` varchar(128) COMMENT '站点名称',
`business` varchar(128) NOT NULL COMMENT '业务名',
`section_name` varchar(128) NOT NULL COMMENT '部门',
`hall_name` varchar(128) DEFAULT NULL COMMENT '大厅名称',
`wait_time` int(9) DEFAULT '0' COMMENT '平均等待时间,单位s',
`window_fromnum` varchar(128) NOT NULL COMMENT '窗口编号',
`ph_count` int(9) NOT NULL COMMENT '取号数量',
`year` int(9) NOT NULL COMMENT '年',
`month` int(9) NOT NULL COMMENT '月',
`day` int(9) NOT NULL COMMENT '日',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) DEFAULT NULL COMMENT '更新用户',
`updateTime` datetime DEFAULT NULL 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='排队叫号汇总统计';
-- ---------------------------- -- ----------------------------
-- 评价汇总表 -- 评价汇总表
-- ---------------------------- -- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_pj_evaluate`; DROP TABLE IF EXISTS `mortals_xhx_pj_evaluate_stat`;
CREATE TABLE `mortals_xhx_pj_evaluate_stat` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`site_id` bigint(20) DEFAULT '0' COMMENT '站点Id',
`site_code` varchar(128) COMMENT '站点编码',
`site_name` varchar(128) COMMENT '站点名称',
`section_name` varchar(128) NOT NULL COMMENT '部门',
`pj_option` varchar(32) NOT NULL COMMENT '评价选项(非常满意,满意,基本满意,不满意,非常不满意)',
`window_fromnum` varchar(128) NOT NULL COMMENT '窗口编号',
`hall_name` varchar(128) DEFAULT NULL COMMENT '大厅名称',
`pj_count` int(9) NOT NULL COMMENT '评价数量',
`year` int(9) NOT NULL COMMENT '年',
`month` int(9) NOT NULL COMMENT '月',
`day` int(9) NOT NULL COMMENT '日',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) DEFAULT NULL COMMENT '更新用户',
`updateTime` datetime DEFAULT NULL 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='评价汇总统计';
-- ----------------------------
-- 评价汇总统计表
-- ----------------------------
CREATE TABLE mortals_xhx_pj_evaluate( CREATE TABLE mortals_xhx_pj_evaluate(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`people_idcard` varchar(64) NOT NULL COMMENT '评价人身份证号', `people_idcard` varchar(64) NOT NULL COMMENT '评价人身份证号',
...@@ -97,3 +152,5 @@ PRIMARY KEY (`id`) ...@@ -97,3 +152,5 @@ PRIMARY KEY (`id`)
,KEY `site_id` (`site_id`) USING BTREE ,KEY `site_id` (`site_id`) USING BTREE
,KEY `site_code` (`site_code`) USING BTREE ,KEY `site_code` (`site_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评价汇总'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评价汇总';
DROP TABLE IF EXISTS `mortals_xhx_pj_evaluate_stat`;
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.PlatformTypeEnum;
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.ph.service.PhQueueService;
import com.mortals.xhx.module.ph.service.PhQueueStatService;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.service.PjEvaluateService;
import com.mortals.xhx.module.pj.service.PjEvaluateStatService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 站点评价统计任务
*
* @author: zxfei
* @date: 2022/3/9 15:19
*/
@Slf4j
@Service("SiteStatTask")
public class SitePjStatTaskImpl implements ITaskExcuteService {
@Autowired
private ISiteFeign siteFeign;
@Autowired
private PjEvaluateStatService pjEvaluateStatService;
@Autowired
private PhQueueStatService phQueueStatService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("站点评价统计任务");
int year = DateUtil.date().year();
int month = DateUtil.date().month()+1;
int day = DateUtil.date().dayOfMonth();
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 -> {
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(year);
sitestatEntity.setMonth(month);
sitestatEntity.setDay(day);
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, null);
});
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
public static void main(String[] args) {
int year = DateUtil.date().year();
int month = DateUtil.date().month()+1;
int day = DateUtil.date().dayOfMonth();
System.out.println(year + "年" + month + "月" + day + "日");
}
}
package com.mortals.xhx.module.ph.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import java.util.List;
/**
* 排队叫号汇总统计Dao
* 排队叫号汇总统计 DAO接口
*
* @author zxfei
* @date 2024-06-24
*/
public interface PhQueueStatDao extends ICRUDDao<PhQueueStatEntity,Long>{
}
package com.mortals.xhx.module.ph.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.ph.dao.PhQueueStatDao;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 排队叫号汇总统计DaoImpl DAO接口
*
* @author zxfei
* @date 2024-06-24
*/
@Repository("phQueueStatDao")
public class PhQueueStatDaoImpl extends BaseCRUDDaoMybatis<PhQueueStatEntity,Long> implements PhQueueStatDao {
}
package com.mortals.xhx.module.ph.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.ph.model.vo.PhQueueStatVo;
import lombok.Data;
/**
* 排队叫号汇总统计实体对象
*
* @author zxfei
* @date 2024-06-24
*/
@Data
public class PhQueueStatEntity extends PhQueueStatVo {
private static final long serialVersionUID = 1L;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点编码
*/
private String siteCode;
/**
* 站点名称
*/
private String siteName;
/**
* 业务名
*/
private String business;
/**
* 部门
*/
private String sectionName;
/**
* 大厅名称
*/
private String hallName;
/**
* 平均等待时间,单位s
*/
private Integer waitTime;
/**
* 窗口编号
*/
private String windowFromnum;
/**
* 取号数量
*/
private Integer phCount;
/**
* 年
*/
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 PhQueueStatEntity) {
PhQueueStatEntity tmp = (PhQueueStatEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.siteId = 0L;
this.siteCode = "";
this.siteName = "";
this.business = "";
this.sectionName = "";
this.hallName = "";
this.waitTime = 0;
this.windowFromnum = "";
this.phCount = 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.ph.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
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-06-24
*/
@Data
public class PhQueueStatVo extends BaseEntityLong {
/** ID列表 */
private List <Long> idList;
}
\ No newline at end of file
package com.mortals.xhx.module.ph.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.dao.PhQueueStatDao;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
/**
* PhQueueStatService
*
* 排队叫号汇总统计 service接口
*
* @author zxfei
* @date 2024-06-24
*/
public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity,Long>{
PhQueueStatDao getDao();
Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.ph.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.ph.model.PhQueueEntity;
import com.mortals.xhx.module.ph.model.PhQueueQuery;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.ph.service.PhQueueService;
import com.mortals.xhx.module.pj.model.PjEvaluateEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.ph.dao.PhQueueStatDao;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.service.PhQueueStatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* PhQueueStatService
* 排队叫号汇总统计 service实现
*
* @author zxfei
* @date 2024-06-24
*/
@Service("phQueueStatService")
@Slf4j
public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatDao, PhQueueStatEntity, Long> implements PhQueueStatService {
@Autowired
private PhQueueService phQueueService;
@Override
public Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context) {
Calendar calendar = Calendar.getInstance();
calendar.set(entity.getYear(), entity.getMonth(), entity.getDay());
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");//yyyy-年,MM-月,dd-日,HH-时,mm-分,ss-秒
String currentDate = date.format(calendar.getTime());
PhQueueQuery phQueueQuery = new PhQueueQuery();
phQueueQuery.setSiteId(entity.getSiteId());
phQueueQuery.setTaketimeStart(currentDate);
phQueueQuery.setTaketimeEnd(currentDate);
List<PhQueueEntity> phQueueEntities = phQueueService.find(phQueueQuery);
log.info("更新站点评价统计数据,站点ID:{},站点名称:{},日期:{},评价数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size());
updateSitePhCount(entity, phQueueEntities);
updateSiteSectionNamePhCount(currentDate, entity, phQueueEntities);
return Rest.ok();
}
private void updateSitePhCount(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery()
.siteId(entity.getSiteId())
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
if (ObjectUtils.isEmpty(phQueueStatEntity)) {
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setPhCount(phQueueEntities.size());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity);
} else {
phQueueStatEntity.setPhCount(phQueueEntities.size());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
}
private void updateSiteSectionNamePhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, Long> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName(), Collectors.counting()));
collect.entrySet().stream().forEach(item -> {
String sectionName = item.getKey();
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},部门:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getSectionName(), phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery()
.siteId(entity.getSiteId())
.sectionName(sectionName)
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
if (ObjectUtils.isEmpty(phQueueStatEntity)) {
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setSectionName(sectionName);
phQueueStatEntity.setPhCount(value.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity);
} else {
phQueueStatEntity.setPhCount(value.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
}
}
\ No newline at end of file
package com.mortals.xhx.module.ph.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.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.service.PhQueueStatService;
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-06-24
*/
@RestController
@RequestMapping("ph/queue/stat")
public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQueueStatService,PhQueueStatEntity,Long> {
@Autowired
private ParamService paramService;
public PhQueueStatController(){
super.setModuleDesc( "排队叫号汇总统计");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.pj.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import java.util.List;
/**
* 评价汇总统计Dao
* 评价汇总统计 DAO接口
*
* @author zxfei
* @date 2024-06-24
*/
public interface PjEvaluateStatDao extends ICRUDDao<PjEvaluateStatEntity,Long>{
}
package com.mortals.xhx.module.pj.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.pj.dao.PjEvaluateStatDao;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 评价汇总统计DaoImpl DAO接口
*
* @author zxfei
* @date 2024-06-24
*/
@Repository("pjEvaluateStatDao")
public class PjEvaluateStatDaoImpl extends BaseCRUDDaoMybatis<PjEvaluateStatEntity,Long> implements PjEvaluateStatDao {
}
package com.mortals.xhx.module.pj.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.pj.model.vo.PjEvaluateStatVo;
import lombok.Data;
/**
* 评价汇总统计实体对象
*
* @author zxfei
* @date 2024-06-24
*/
@Data
public class PjEvaluateStatEntity extends PjEvaluateStatVo {
private static final long serialVersionUID = 1L;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点编码
*/
private String siteCode;
/**
* 站点名称
*/
private String siteName;
/**
* 部门
*/
private String sectionName;
/**
* 评价选项(非常满意,满意,基本满意,不满意,非常不满意)
*/
private String pjOption;
/**
* 窗口编号
*/
private String windowFromnum;
/**
* 大厅名称
*/
private String hallName;
/**
* 评价数量
*/
private Integer pjCount;
/**
* 年
*/
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 PjEvaluateStatEntity) {
PjEvaluateStatEntity tmp = (PjEvaluateStatEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.siteId = 0L;
this.siteCode = "";
this.siteName = "";
this.sectionName = "";
this.pjOption = "";
this.windowFromnum = "";
this.hallName = "";
this.pjCount = 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.pj.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
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-06-24
*/
@Data
public class PjEvaluateStatVo extends BaseEntityLong {
/** ID列表 */
private List <Long> idList;
}
\ No newline at end of file
package com.mortals.xhx.module.pj.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.pj.dao.PjEvaluateStatDao;
/**
* PjEvaluateStatService
*
* 评价汇总统计 service接口
*
* @author zxfei
* @date 2024-06-24
*/
public interface PjEvaluateStatService extends ICRUDService<PjEvaluateStatEntity,Long>{
PjEvaluateStatDao getDao();
/**
* 更新站点评价统计
* @param entity
* @param context
* @return
*/
Rest<Void> updateSitePjStat(PjEvaluateStatEntity entity, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.pj.service.impl;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.pj.model.PjEvaluateEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import com.mortals.xhx.module.pj.service.PjEvaluateService;
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.pj.dao.PjEvaluateStatDao;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.service.PjEvaluateStatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* PjEvaluateStatService
* 评价汇总统计 service实现
*
* @author zxfei
* @date 2024-06-24
*/
@Service("pjEvaluateStatService")
@Slf4j
public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluateStatDao, PjEvaluateStatEntity, Long> implements PjEvaluateStatService {
@Autowired
private PjEvaluateService pjEvaluateService;
@Override
public Rest<Void> updateSitePjStat(PjEvaluateStatEntity entity, Context context) {
//todo 统计站点评价 分站点--部门 ||窗口编号||评价选项 ==》评价数量
//查询指定日期当前站点所有评价数量
Calendar calendar = Calendar.getInstance();
calendar.set(entity.getYear(), entity.getMonth(), entity.getDay());
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");//yyyy-年,MM-月,dd-日,HH-时,mm-分,ss-秒
String currentDate = date.format(calendar.getTime());
PjEvaluateQuery pjEvaluateQuery = new PjEvaluateQuery();
pjEvaluateQuery.setSiteId(entity.getSiteId());
pjEvaluateQuery.setPjTimeStart(currentDate);
pjEvaluateQuery.setPjTimeEnd(currentDate);
List<PjEvaluateEntity> pjEvaluateEntities = pjEvaluateService.find(pjEvaluateQuery);
log.info("更新站点评价统计数据,站点ID:{},站点名称:{},日期:{},评价数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, pjEvaluateEntities.size());
updateSitePjCount(entity, pjEvaluateEntities);
updateSiteSectionNamePjCount(currentDate, entity, pjEvaluateEntities);
updateSiteWindowPjCount(currentDate, entity, pjEvaluateEntities);
return Rest.ok();
}
private void updateSitePjCount(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
.siteId(entity.getSiteId())
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
if (ObjectUtils.isEmpty(pjEvaluateStatEntity)) {
//统计当前站点新增所有评价数量
pjEvaluateStatEntity = new PjEvaluateStatEntity();
pjEvaluateStatEntity.initAttrValue();
pjEvaluateStatEntity.setSiteId(entity.getSiteId());
pjEvaluateStatEntity.setSiteCode(entity.getSiteCode());
pjEvaluateStatEntity.setSiteName(entity.getSiteName());
pjEvaluateStatEntity.setPjCount(pjEvaluateEntities.size());
pjEvaluateStatEntity.setYear(entity.getYear());
pjEvaluateStatEntity.setMonth(entity.getMonth());
pjEvaluateStatEntity.setDay(entity.getDay());
pjEvaluateStatEntity.setCreateTime(new Date());
pjEvaluateStatEntity.setCreateUserId(1L);
this.save(pjEvaluateStatEntity);
} else {
pjEvaluateStatEntity.setPjCount(pjEvaluateEntities.size());
pjEvaluateStatEntity.setYear(entity.getYear());
pjEvaluateStatEntity.setMonth(entity.getMonth());
pjEvaluateStatEntity.setDay(entity.getDay());
pjEvaluateStatEntity.setUpdateTime(new Date());
pjEvaluateStatEntity.setUpdateUserId(1L);
this.update(pjEvaluateStatEntity);
}
}
private void updateSiteSectionNamePjCount(String currentDate, PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> collect = pjEvaluateEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName(), Collectors.counting()));
collect.entrySet().stream().forEach(item -> {
String sectionName = item.getKey();
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},部门:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getSectionName(), pjEvaluateEntities.size());
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
.siteId(entity.getSiteId())
.sectionName(sectionName)
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
if (ObjectUtils.isEmpty(pjEvaluateStatEntity)) {
//统计当前站点新增所有评价数量
pjEvaluateStatEntity = new PjEvaluateStatEntity();
pjEvaluateStatEntity.initAttrValue();
pjEvaluateStatEntity.setSiteId(entity.getSiteId());
pjEvaluateStatEntity.setSiteCode(entity.getSiteCode());
pjEvaluateStatEntity.setSiteName(entity.getSiteName());
pjEvaluateStatEntity.setSectionName(sectionName);
pjEvaluateStatEntity.setPjCount(value.intValue());
pjEvaluateStatEntity.setYear(entity.getYear());
pjEvaluateStatEntity.setMonth(entity.getMonth());
pjEvaluateStatEntity.setDay(entity.getDay());
pjEvaluateStatEntity.setCreateTime(new Date());
pjEvaluateStatEntity.setCreateUserId(1L);
this.save(pjEvaluateStatEntity);
} else {
pjEvaluateStatEntity.setPjCount(value.intValue());
pjEvaluateStatEntity.setYear(entity.getYear());
pjEvaluateStatEntity.setMonth(entity.getMonth());
pjEvaluateStatEntity.setDay(entity.getDay());
pjEvaluateStatEntity.setUpdateTime(new Date());
pjEvaluateStatEntity.setUpdateUserId(1L);
this.update(pjEvaluateStatEntity);
}
});
}
private void updateSiteWindowPjCount(String currentDate, PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> collect = pjEvaluateEntities.stream().collect(Collectors.groupingBy(x -> x.getWindowFromnum(), Collectors.counting()));
collect.entrySet().stream().forEach(item -> {
String windowFromnum = item.getKey();
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},窗口:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getWindowFromnum(), pjEvaluateEntities.size());
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
.siteId(entity.getSiteId())
.windowFromnum(windowFromnum)
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
if (ObjectUtils.isEmpty(pjEvaluateStatEntity)) {
//统计当前站点新增所有评价数量
pjEvaluateStatEntity = new PjEvaluateStatEntity();
pjEvaluateStatEntity.initAttrValue();
pjEvaluateStatEntity.setSiteId(entity.getSiteId());
pjEvaluateStatEntity.setSiteCode(entity.getSiteCode());
pjEvaluateStatEntity.setSiteName(entity.getSiteName());
pjEvaluateStatEntity.setWindowFromnum(windowFromnum);
pjEvaluateStatEntity.setPjCount(value.intValue());
pjEvaluateStatEntity.setYear(entity.getYear());
pjEvaluateStatEntity.setMonth(entity.getMonth());
pjEvaluateStatEntity.setDay(entity.getDay());
pjEvaluateStatEntity.setCreateTime(new Date());
pjEvaluateStatEntity.setCreateUserId(1L);
this.save(pjEvaluateStatEntity);
} else {
pjEvaluateStatEntity.setPjCount(value.intValue());
pjEvaluateStatEntity.setYear(entity.getYear());
pjEvaluateStatEntity.setMonth(entity.getMonth());
pjEvaluateStatEntity.setDay(entity.getDay());
pjEvaluateStatEntity.setUpdateTime(new Date());
pjEvaluateStatEntity.setUpdateUserId(1L);
this.update(pjEvaluateStatEntity);
}
});
}
}
\ No newline at end of file
...@@ -162,50 +162,40 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv ...@@ -162,50 +162,40 @@ public class PjEvaluateController extends BaseCRUDJsonBodyMappingController<PjEv
private void getSite(PjEvaluateEntity entity) { private void getSite(PjEvaluateEntity entity) {
if (!ObjectUtils.isEmpty(entity.getSiteId())) { if (!ObjectUtils.isEmpty(entity.getSiteId())) {
RedisTemplate<String, String> baseRedisTemplate = cacheService.selectDbRedisTemplate(1); RedisTemplate<String, String> baseRedisTemplate = cacheService.selectDbRedisTemplate(1);
//com:mortals:xhx:module:site:model:SiteEntity redis调用 //com:mortals:xhx:module:site:model:SiteEntity redis调用
String siteStr = (String) baseRedisTemplate.opsForHash().get("com:mortals:xhx:module:site:model:SiteEntity", String.valueOf(entity.getSiteId())); String siteStr = (String) baseRedisTemplate.opsForHash().get("com:mortals:xhx:module:site:model:SiteEntity", String.valueOf(entity.getSiteId()));
if (!ObjectUtils.isEmpty(siteStr)) { if (!ObjectUtils.isEmpty(siteStr)) {
SitePdu sitePdu = JSON.parseObject(siteStr, SitePdu.class); SitePdu sitePdu = JSON.parseObject(siteStr, SitePdu.class);
if (!ObjectUtils.isEmpty(sitePdu)) {
entity.setSiteId(sitePdu.getId());
entity.setSiteCode(sitePdu.getSiteCode()); entity.setSiteCode(sitePdu.getSiteCode());
entity.setSiteName(sitePdu.getSiteName()); entity.setSiteName(sitePdu.getSiteName());
} else if (!ObjectUtils.isEmpty(entity.getSiteCode())) {
buildSiteBySideCode(entity);
} else { } else {
log.info("站点信息不存在,siteId={}", entity.getSiteId()); log.info("站点信息不存在,siteId={}", entity.getSiteId());
} }
} else {
if (!ObjectUtils.isEmpty(entity.getSiteCode())) {
buildSiteBySideCode(entity);
}
}
} }
//feign调用 private void buildSiteBySideCode(PjEvaluateEntity entity) {
/* Rest<SitePdu> sitePduRest = siteFeign.info(entity.getSiteId()); RedisTemplate<String, String> baseRedisTemplate = cacheService.selectDbRedisTemplate(1);
if (YesNoEnum.YES.getValue() == sitePduRest.getCode()) { String siteStr = (String) baseRedisTemplate.opsForHash().get("com:mortals:xhx:module:site:model:SiteEntity", entity.getSiteCode());
SitePdu sitePdu = sitePduRest.getData(); if (!ObjectUtils.isEmpty(siteStr)) {
SitePdu sitePdu = JSON.parseObject(siteStr, SitePdu.class);
if (!ObjectUtils.isEmpty(sitePdu)) { if (!ObjectUtils.isEmpty(sitePdu)) {
entity.setSiteId(sitePdu.getId());
entity.setSiteCode(sitePdu.getSiteCode()); entity.setSiteCode(sitePdu.getSiteCode());
entity.setSiteName(sitePdu.getSiteName()); entity.setSiteName(sitePdu.getSiteName());
} else { } else {
log.info("站点信息不存在,siteId={}", entity.getSiteId()); log.info("站点信息不存在,siteId={}", entity.getSiteId());
} }
}*/
} else {
if (!ObjectUtils.isEmpty(entity.getSiteCode())) {
SitePdu pdu = new SitePdu();
pdu.setSiteCode(entity.getSiteCode());
Rest<RespData<List<SitePdu>>> sitePduRest = siteFeign.list(pdu);
if (YesNoEnum.YES.getValue() == sitePduRest.getCode()) {
List<SitePdu> list = sitePduRest.getData().getData();
if (!ObjectUtils.isEmpty(list)) {
entity.setSiteId(list.get(0).getId());
entity.setSiteCode(list.get(0).getSiteCode());
entity.setSiteName(list.get(0).getSiteName());
} else {
log.info("站点信息不存在,siteId={}", entity.getSiteId());
}
}
}
} }
} }
......
package com.mortals.xhx.module.pj.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.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.service.PjEvaluateStatService;
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-06-24
*/
@RestController
@RequestMapping("pj/evaluate/stat")
public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<PjEvaluateStatService,PjEvaluateStatEntity,Long> {
@Autowired
private ParamService paramService;
public PjEvaluateStatController(){
super.setModuleDesc( "评价汇总统计");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "pjOption", PjOptionEnum.getEnumMap());
super.init(model, context);
}
}
\ 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}}/ph/queue/stat/list
Content-Type: application/json
{
"page":1,
"size":10
}
###排队叫号汇总统计更新与保存
POST {{baseUrl}}/ph/queue/stat/save
Authorization: {{authToken}}
Content-Type: application/json
{
"siteId":0,
"siteCode":"k0qhHd",
"siteName":"JkrTyE",
"business":"oghueH",
"sectionName":"TZvj9b",
"windowFromnum":"D2bJnu",
"pjCount":448,
"year":544,
"month":191,
"day":82,
}
> {%
client.global.set("PhQueueStat_id", JSON.parse(response.body).data.id);
%}
###排队叫号汇总统计查看
GET {{baseUrl}}/ph/queue/stat/info?id={{PhQueueStat_id}}
Accept: application/json
###排队叫号汇总统计编辑
GET {{baseUrl}}/ph/queue/stat/edit?id={{PhQueueStat_id}}
Accept: application/json
###排队叫号汇总统计删除
GET {{baseUrl}}/ph/queue/stat/delete?id={{PhQueueStat_id}}
Authorization: {{authToken}}
Accept: application/json
###登录
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}}/pj/evaluate/stat/list
Content-Type: application/json
{
"page":1,
"size":10
}
###评价汇总统计更新与保存
POST {{baseUrl}}/pj/evaluate/stat/save
Authorization: {{authToken}}
Content-Type: application/json
{
"siteId":0,
"siteCode":"Q8lhs4",
"siteName":"vxsdQP",
"sectionName":"PMhvwe",
"pjOption":"eeSBbZ",
"windowFromnum":"t4cnTV",
"pjCount":657,
"year":545,
"month":368,
"day":323,
}
> {%
client.global.set("PjEvaluateStat_id", JSON.parse(response.body).data.id);
%}
###评价汇总统计查看
GET {{baseUrl}}/pj/evaluate/stat/info?id={{PjEvaluateStat_id}}
Accept: application/json
###评价汇总统计编辑
GET {{baseUrl}}/pj/evaluate/stat/edit?id={{PjEvaluateStat_id}}
Accept: application/json
###评价汇总统计删除
GET {{baseUrl}}/pj/evaluate/stat/delete?id={{PjEvaluateStat_id}}
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