Commit ebca163f authored by 赵啸非's avatar 赵啸非

添加统计子站点

parent 2d32c02b
package com.mortals.xhx.module.ph.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
......@@ -11,21 +12,22 @@ import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import java.util.List;
/**
* PhQueueStatService
*
* 排队叫号汇总统计 service接口
*
* @author zxfei
* @date 2024-06-24
*/
public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity,Long>{
* PhQueueStatService
* <p>
* 排队叫号汇总统计 service接口
*
* @author zxfei
* @date 2024-06-24
*/
public interface PhQueueStatService extends ICRUDService<PhQueueStatEntity, Long> {
PhQueueStatDao getDao();
Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context);
Rest<List<PhQueueStatEntity>> updateSitePhStat(PhQueueStatEntity entity, Context context);
List<PhQueueStatEntity> getBillInfos(PhQueueStatQuery query, PageInfo pageInfo, Context context);
void saveUpdatePhStatList(List<PhQueueStatEntity> saveAndUpdatelist);
}
\ No newline at end of file
......@@ -42,7 +42,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
@Override
public Rest<Void> updateSitePhStat(PhQueueStatEntity entity, Context context) {
public Rest<List<PhQueueStatEntity>> updateSitePhStat(PhQueueStatEntity entity, Context context) {
Calendar calendar = Calendar.getInstance();
calendar.set(entity.getYear(), entity.getMonth() - 1, entity.getDay());
......@@ -81,8 +81,8 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
saveOrUpdateList.addAll(phQueueStatEntities3);
saveOrUpdateList.addAll(phQueueStatEntities4);
saveUpdatePhStatList(saveOrUpdateList);
return Rest.ok();
//saveUpdatePhStatList(saveOrUpdateList);
return Rest.ok(saveOrUpdateList);
}
......@@ -364,7 +364,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
}
private void saveUpdatePhStatList(List<PhQueueStatEntity> saveAndUpdatelist) {
public void saveUpdatePhStatList(List<PhQueueStatEntity> saveAndUpdatelist) {
if (!ObjectUtils.isEmpty(saveAndUpdatelist)) {
Map<Boolean, List<PhQueueStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity()));
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......@@ -40,6 +41,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
......@@ -194,18 +197,18 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);
List<SitePdu> sitePduList=new ArrayList<>();
List<SitePdu> sitePduList = new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if(YesNoEnum.YES.getValue()==sitesRest.getCode()){
if (YesNoEnum.YES.getValue() == sitesRest.getCode()) {
sitePduList.addAll(sitesRest.getData());
}
}
if(!ObjectUtils.isEmpty(sitePduList)){
sitePduList=sitePduList.stream().collect(
if (!ObjectUtils.isEmpty(sitePduList)) {
sitePduList = sitePduList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
for (SitePdu site : sitePduList) {
......@@ -285,6 +288,8 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
statLogEntity.setAccessId(accessEntity.getId());
}
List<PhQueueStatEntity> saveOrUpdateList = new ArrayList<>();
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
......@@ -299,8 +304,16 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
phQueueStatService.updateSitePhStat(sitestatEntity, context);
Rest<List<PhQueueStatEntity>> listRest = phQueueStatService.updateSitePhStat(sitestatEntity, context);
saveOrUpdateList.addAll(listRest.getData());
}
List<List<PhQueueStatEntity>> partition = Lists.partition(saveOrUpdateList, 1000);
for (List<PhQueueStatEntity> phQueueStatEntities : partition) {
this.service.saveUpdatePhStatList(phQueueStatEntities);
}
stopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(stopWatch.getLastTaskTimeMillis());
......
......@@ -27,10 +27,10 @@ public interface PjEvaluateStatService extends ICRUDService<PjEvaluateStatEntity
* @param context
* @return
*/
Rest<Void> updateSitePjStat(PjEvaluateStatEntity entity, Context context);
Rest<List<PjEvaluateStatEntity>> updateSitePjStat(PjEvaluateStatEntity entity, Context context);
List<PjEvaluateStatEntity> getBillInfos(PjEvaluateStatQuery query, PageInfo pageInfo, Context context);
void saveUpdatePjEvaluateStatList(List<PjEvaluateStatEntity> saveAndUpdatelist);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......@@ -285,6 +286,8 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
statLogEntity.setAccessId(accessEntity.getId());
}
List<PjEvaluateStatEntity> saveAndUpdatelist = new ArrayList<>();
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
......@@ -297,8 +300,17 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, context);
Rest<List<PjEvaluateStatEntity>> rest = pjEvaluateStatService.updateSitePjStat(sitestatEntity, context);
saveAndUpdatelist.addAll(rest.getData());
}
List<List<PjEvaluateStatEntity>> partition = Lists.partition(saveAndUpdatelist, 1000);
for (List<PjEvaluateStatEntity> pjEvaluateStatEntities : partition) {
this.service.saveUpdatePjEvaluateStatList(pjEvaluateStatEntities);
}
stopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(stopWatch.getLastTaskTimeMillis());
......
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