Commit 2618c5f1 authored by 赵啸非's avatar 赵啸非

添加排号与评价统计报表

parent 8264ee31
...@@ -9,6 +9,7 @@ import com.mortals.xhx.common.code.PlatformTypeEnum; ...@@ -9,6 +9,7 @@ import com.mortals.xhx.common.code.PlatformTypeEnum;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu; import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.service.PhQueueService; import com.mortals.xhx.module.ph.service.PhQueueService;
import com.mortals.xhx.module.ph.service.PhQueueStatService; import com.mortals.xhx.module.ph.service.PhQueueStatService;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity; import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
...@@ -41,13 +42,12 @@ public class SitePjStatTaskImpl implements ITaskExcuteService { ...@@ -41,13 +42,12 @@ public class SitePjStatTaskImpl implements ITaskExcuteService {
private PhQueueStatService phQueueStatService; private PhQueueStatService phQueueStatService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("站点评价统计任务"); log.info("站点评价统计任务");
int year = DateUtil.date().year(); int year = DateUtil.date().year();
int month = DateUtil.date().month()+1; int month = DateUtil.date().month() + 1;
int day = DateUtil.date().dayOfMonth(); int day = DateUtil.date().dayOfMonth();
SitePdu sitePdu = new SitePdu(); SitePdu sitePdu = new SitePdu();
...@@ -68,6 +68,19 @@ public class SitePjStatTaskImpl implements ITaskExcuteService { ...@@ -68,6 +68,19 @@ public class SitePjStatTaskImpl implements ITaskExcuteService {
sitestatEntity.setDay(day); sitestatEntity.setDay(day);
//设置年月日 //设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, null); pjEvaluateStatService.updateSitePjStat(sitestatEntity, null);
//设置排号
PhQueueStatEntity phQueueStatEntity = new PhQueueStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(year);
sitestatEntity.setMonth(month);
sitestatEntity.setDay(day);
phQueueStatService.updateSitePhStat(phQueueStatEntity, null);
}); });
} }
...@@ -84,7 +97,7 @@ public class SitePjStatTaskImpl implements ITaskExcuteService { ...@@ -84,7 +97,7 @@ public class SitePjStatTaskImpl implements ITaskExcuteService {
public static void main(String[] args) { public static void main(String[] args) {
int year = DateUtil.date().year(); int year = DateUtil.date().year();
int month = DateUtil.date().month()+1; int month = DateUtil.date().month() + 1;
int day = DateUtil.date().dayOfMonth(); int day = DateUtil.date().dayOfMonth();
System.out.println(year + "年" + month + "月" + day + "日"); System.out.println(year + "年" + month + "月" + day + "日");
......
package com.mortals.xhx.module.ph.dao; package com.mortals.xhx.module.ph.dao;
import com.mortals.framework.dao.ICRUDDao; import com.mortals.framework.dao.ICRUDDao;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity; import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import java.util.List; import java.util.List;
/** /**
* 排队叫号汇总统计Dao * 排队叫号汇总统计Dao
...@@ -14,4 +20,8 @@ import java.util.List; ...@@ -14,4 +20,8 @@ import java.util.List;
public interface PhQueueStatDao extends ICRUDDao<PhQueueStatEntity,Long>{ public interface PhQueueStatDao extends ICRUDDao<PhQueueStatEntity,Long>{
String SQLID_GET_STATLIST = "getStatList";
List<PhQueueStatEntity> getStatList(PhQueueStatQuery query, PageInfo pageInfo);
} }
package com.mortals.xhx.module.ph.dao.ibatis; package com.mortals.xhx.module.ph.dao.ibatis;
import org.springframework.stereotype.Repository; import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.module.ph.dao.PhQueueStatDao; import com.mortals.xhx.module.ph.dao.PhQueueStatDao;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity; import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import java.util.Date; import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis; import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
/** /**
* 排队叫号汇总统计DaoImpl DAO接口 * 排队叫号汇总统计DaoImpl DAO接口
* *
* @author zxfei * @author zxfei
* @date 2024-06-24 * @date 2024-06-24
*/ */
@Repository("phQueueStatDao") @Repository("phQueueStatDao")
public class PhQueueStatDaoImpl extends BaseCRUDDaoMybatis<PhQueueStatEntity,Long> implements PhQueueStatDao { public class PhQueueStatDaoImpl extends BaseCRUDDaoMybatis<PhQueueStatEntity, Long> implements PhQueueStatDao {
@Override
public List<PhQueueStatEntity> getStatList(PhQueueStatQuery 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.ph.service; package com.mortals.xhx.module.ph.service;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity; import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.dao.PhQueueStatDao; import com.mortals.xhx.module.ph.dao.PhQueueStatDao;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity; import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import java.util.List;
/** /**
* PhQueueStatService * PhQueueStatService
* *
...@@ -19,4 +23,9 @@ public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity,Long> ...@@ -19,4 +23,9 @@ public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity,Long>
PhQueueStatDao getDao(); PhQueueStatDao getDao();
Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context); Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context);
List<PhQueueStatEntity> getBillInfos(PhQueueStatQuery query, Integer datePattern, PageInfo pageInfo, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.ph.service.impl; package com.mortals.xhx.module.ph.service.impl;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.common.code.TimeUnitEnum;
import com.mortals.xhx.module.ph.model.PhQueueEntity; import com.mortals.xhx.module.ph.model.PhQueueEntity;
import com.mortals.xhx.module.ph.model.PhQueueQuery; import com.mortals.xhx.module.ph.model.PhQueueQuery;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery; import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
...@@ -19,10 +23,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -19,10 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -58,8 +59,15 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -58,8 +59,15 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
log.info("更新站点评价统计数据,站点ID:{},站点名称:{},日期:{},评价数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size()); log.info("更新站点评价统计数据,站点ID:{},站点名称:{},日期:{},评价数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size());
updateSitePhCount(entity, phQueueEntities); updateSitePhCount(entity, phQueueEntities);
//部门
updateSiteSectionNamePhCount(currentDate, entity, phQueueEntities); updateSiteSectionNamePhCount(currentDate, entity, phQueueEntities);
//大厅
updateSiteHallPhCount(currentDate, entity, phQueueEntities);
//业务
updateSiteBussinessPhCount(currentDate, entity, phQueueEntities);
//窗口
updateSiteWindowPhCount(currentDate, entity, phQueueEntities);
//平均等待时间
return Rest.ok(); return Rest.ok();
...@@ -72,6 +80,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -72,6 +80,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
.year(entity.getYear()) .year(entity.getYear())
.month(entity.getMonth()) .month(entity.getMonth())
.day(entity.getDay())); .day(entity.getDay()));
Double intAvg = phQueueEntities.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
if (ObjectUtils.isEmpty(phQueueStatEntity)) { if (ObjectUtils.isEmpty(phQueueStatEntity)) {
//统计当前站点新增所有评价数量 //统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity(); phQueueStatEntity = new PhQueueStatEntity();
...@@ -80,6 +90,9 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -80,6 +90,9 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity.setSiteCode(entity.getSiteCode()); phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName()); phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setPhCount(phQueueEntities.size()); phQueueStatEntity.setPhCount(phQueueEntities.size());
//计算平均等待时间
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear()); phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth()); phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay()); phQueueStatEntity.setDay(entity.getDay());
...@@ -88,6 +101,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -88,6 +101,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
this.save(phQueueStatEntity); this.save(phQueueStatEntity);
} else { } else {
phQueueStatEntity.setPhCount(phQueueEntities.size()); phQueueStatEntity.setPhCount(phQueueEntities.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear()); phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth()); phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay()); phQueueStatEntity.setDay(entity.getDay());
...@@ -97,13 +111,14 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -97,13 +111,14 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
} }
} }
private void updateSiteSectionNamePhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSiteSectionNamePhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, Long> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName(), Collectors.counting())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName()));
collect.entrySet().stream().forEach(item -> { collect.entrySet().stream().forEach(item -> {
String sectionName = item.getKey(); String sectionName = item.getKey();
Long value = item.getValue(); List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
log.info("更新站点评价统计数据,站点名称:{},日期:{},部门:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getSectionName(), phQueueEntities.size()); log.info("更新站点评价统计数据,站点名称:{},日期:{},部门:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getSectionName(), phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery() PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery()
.siteId(entity.getSiteId()) .siteId(entity.getSiteId())
...@@ -119,7 +134,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -119,7 +134,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity.setSiteCode(entity.getSiteCode()); phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName()); phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setSectionName(sectionName); phQueueStatEntity.setSectionName(sectionName);
phQueueStatEntity.setPhCount(value.intValue()); phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear()); phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth()); phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay()); phQueueStatEntity.setDay(entity.getDay());
...@@ -127,7 +143,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -127,7 +143,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
phQueueStatEntity.setCreateUserId(1L); phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity); this.save(phQueueStatEntity);
} else { } else {
phQueueStatEntity.setPhCount(value.intValue()); phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear()); phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth()); phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay()); phQueueStatEntity.setDay(entity.getDay());
...@@ -139,4 +156,156 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -139,4 +156,156 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
} }
private void updateSiteHallPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName()));
collect.entrySet().stream().forEach(item -> {
String hallName = item.getKey();
List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
log.info("更新站点评价统计数据,站点名称:{},日期:{},大厅:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getHallName(), phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery()
.siteId(entity.getSiteId())
.hallName(hallName)
.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.setHallName(hallName);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.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.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
}
private void updateSiteBussinessPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName()));
collect.entrySet().stream().forEach(item -> {
String bussiness = item.getKey();
List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
log.info("更新站点评价统计数据,站点名称:{},日期:{},业务:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getBusiness(), phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery()
.siteId(entity.getSiteId())
.business(bussiness)
.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.setBusiness(bussiness);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.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.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
}
private void updateSiteWindowPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName()));
collect.entrySet().stream().forEach(item -> {
String window = item.getKey();
List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
log.info("更新站点评价统计数据,站点名称:{},日期:{},业务:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getBusiness(), phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery()
.siteId(entity.getSiteId())
.windowFromnum(window)
.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.setWindowFromnum(window);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.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.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
}
@Override
public List<PhQueueStatEntity> getBillInfos(PhQueueStatQuery query, Integer datePattern, PageInfo pageInfo, Context context) {
List<PhQueueStatEntity> statList = new ArrayList<>();
if (datePattern == TimeUnitEnum.DAY.getValue()) {
query.setGroupList(Arrays.asList("day"));
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("day", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.MONTH.getValue()) {
query.setGroupList(Arrays.asList("month"));
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.YEAR.getValue()) {
query.setGroupList(Arrays.asList("year"));
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else {
throw new AppException("不支持当前日期格式查询统计!");
}
return statList;
}
} }
\ No newline at end of file
package com.mortals.xhx.module.ph.web; package com.mortals.xhx.module.ph.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.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; 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.ph.model.PhQueueQuery;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity; import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.service.PhQueueStatService; import com.mortals.xhx.module.ph.service.PhQueueStatService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays; import java.util.Arrays;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*; import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
/** /**
* * 排队叫号汇总统计
* 排队叫号汇总统计 *
* * @author zxfei
* @author zxfei * @date 2024-06-24
* @date 2024-06-24 */
*/
@RestController @RestController
@RequestMapping("ph/queue/stat") @RequestMapping("ph/queue/stat")
public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQueueStatService,PhQueueStatEntity,Long> { @Slf4j
public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQueueStatService, PhQueueStatEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
public PhQueueStatController(){ @Autowired
super.setModuleDesc( "排队叫号汇总统计"); private ISiteFeign siteFeign;
public PhQueueStatController() {
super.setModuleDesc("排队叫号汇总统计");
} }
@Override @Override
...@@ -46,5 +73,60 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -46,5 +73,60 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
super.init(model, context); super.init(model, context);
} }
@PostMapping(value = "/stat")
@UnAuth
public Rest<String> addAttendanceRecordCustom(@RequestBody PhQueueQuery phQueueQuery) {
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(phQueueQuery.getTaketimeStart());
DateTime attendEnd = DateUtil.parseDate(phQueueQuery.getTaketimeEnd());
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 -> {
PhQueueStatEntity sitestatEntity = new PhQueueStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(curDate.year());
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
this.service.updateSitePhStat(sitestatEntity, 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
...@@ -73,7 +73,7 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -73,7 +73,7 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
} }
@PostMapping(value = "/pjstat") @PostMapping(value = "/stat")
@UnAuth @UnAuth
public Rest<String> addAttendanceRecordCustom(@RequestBody PjEvaluateQuery pjEvaluateQuery) { public Rest<String> addAttendanceRecordCustom(@RequestBody PjEvaluateQuery pjEvaluateQuery) {
Rest<String> ret = new Rest(); Rest<String> ret = new Rest();
......
<?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="getStatList" parameterType="paramDto" resultMap="PhQueueStatEntity-Map">
select
<!-- 获取分组字段 -->
<if test="groupList != null and !groupList.isEmpty()">
<foreach collection="groupList" open="" close="" index="index" item="item">
${item},
</foreach>
</if>
id,
year,
month,
day,
<!-- 评价数量-->
sum(IFNULL(a.ph_count,0)) ph_count
from mortals_xhx_ph_queue_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
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
</foreach> </foreach>
</if> </if>
id, id,
site_id,
createTime,
year, year,
month, month,
day, day,
......
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