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

添加首页统计模块 统计近一周

parent 811e808f
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -40,46 +42,55 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -40,46 +42,55 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
@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 month = DateUtil.date().month() + 1;
int day = DateUtil.date().dayOfMonth();
SitePdu sitePdu = new SitePdu(); for (int i = 1; i < 7; i++) {
sitePdu.setSize(-1); DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) { int year = beforeDate.year();
List<SitePdu> sitePduList = resp.getData().getData(); int month = beforeDate.month() + 1;
sitePduList.stream().forEach(site -> { int day = beforeDate.dayOfMonth();
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);
//设置排号
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);
});
}
/* 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);
//设置排号
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);
});
}
}
} }
...@@ -95,7 +106,11 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -95,7 +106,11 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
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 + "日");
System.out.println(DateUtil.offsetDay(new Date(), -0).toString("yyyy-MM-dd"));
} }
......
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