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

添加统计子站点

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