Commit 5c9cd9bc authored by 赵啸非's avatar 赵啸非

添加排号与评价统计报表

parent 7422e1ac
......@@ -60,12 +60,18 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
updateSiteSectionNamePjCount(currentDate, entity, pjEvaluateEntities);
updateSiteHallPjCount(currentDate, entity, pjEvaluateEntities);
updateSiteWindowPjCount(currentDate, entity, pjEvaluateEntities);
updateSiteOptionPjCount(currentDate, entity, pjEvaluateEntities);
return Rest.ok();
}
private void updateSitePjCount(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
if (ObjectUtils.isEmpty(entity.getSiteId())) return;
if (0L >= entity.getSiteId()) return;
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
.siteId(entity.getSiteId())
.year(entity.getYear())
......@@ -102,6 +108,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
Map<String, Long> collect = pjEvaluateEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName(), Collectors.counting()));
collect.entrySet().stream().forEach(item -> {
String sectionName = item.getKey();
if (ObjectUtils.isEmpty(sectionName)) return;
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},部门:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getSectionName(), pjEvaluateEntities.size());
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
......@@ -138,11 +145,56 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
}
private void updateSiteHallPjCount(String currentDate, PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> collect = pjEvaluateEntities.stream().collect(Collectors.groupingBy(x -> x.getHallName(), Collectors.counting()));
collect.entrySet().stream().forEach(item -> {
String hallName = item.getKey();
if (ObjectUtils.isEmpty(hallName)) return;
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},部门:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getSectionName(), pjEvaluateEntities.size());
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
.siteId(entity.getSiteId())
.hallName(hallName)
.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.setHallName(hallName);
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();
if (ObjectUtils.isEmpty(windowFromnum)) return;
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},窗口:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getWindowFromnum(), pjEvaluateEntities.size());
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
......@@ -177,4 +229,46 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
}
});
}
private void updateSiteOptionPjCount(String currentDate, PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> collect = pjEvaluateEntities.stream().collect(Collectors.groupingBy(x -> x.getPjOption(), Collectors.counting()));
collect.entrySet().stream().forEach(item -> {
String pjOption = item.getKey();
if (ObjectUtils.isEmpty(pjOption)) return;
Long value = item.getValue();
log.info("更新站点评价统计数据,站点名称:{},日期:{},窗口:{},评价数量:{}", entity.getSiteName(), currentDate, entity.getWindowFromnum(), pjEvaluateEntities.size());
PjEvaluateStatEntity pjEvaluateStatEntity = this.selectOne(new PjEvaluateStatQuery()
.siteId(entity.getSiteId())
.pjOption(pjOption)
.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.setPjOption(pjOption);
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
package com.mortals.xhx.module.pj.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.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.pj.model.PjEvaluateEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateQuery;
import lombok.extern.slf4j.Slf4j;
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.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
*/
* 评价汇总统计
*
* @author zxfei
* @date 2024-06-24
*/
@RestController
@RequestMapping("pj/evaluate/stat")
public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<PjEvaluateStatService,PjEvaluateStatEntity,Long> {
@Slf4j
public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<PjEvaluateStatService, PjEvaluateStatEntity, Long> {
@Autowired
private ParamService paramService;
public PjEvaluateStatController(){
super.setModuleDesc( "评价汇总统计");
@Autowired
private ISiteFeign siteFeign;
public PjEvaluateStatController() {
super.setModuleDesc("评价汇总统计");
}
@Override
......@@ -48,4 +73,62 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
}
@PostMapping(value = "/pjstat")
@UnAuth
public Rest<String> addAttendanceRecordCustom(@RequestBody PjEvaluateQuery pjEvaluateQuery) {
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(pjEvaluateQuery.getPjTimeStart());
DateTime attendEnd = DateUtil.parseDate(pjEvaluateQuery.getPjTimeEnd());
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 -> {
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
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.updateSitePjStat(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
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