|
|
@@ -4,23 +4,29 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.domain.DateRange;
|
|
|
+import com.xunmei.common.core.enums.CycleCommonEnum;
|
|
|
import com.xunmei.common.core.exception.ServiceException;
|
|
|
+import com.xunmei.common.core.utils.DateUtils;
|
|
|
+import com.xunmei.common.core.utils.NumberUtils;
|
|
|
+import com.xunmei.common.core.utils.StringUtils;
|
|
|
import com.xunmei.core.board.dto.web.TaskStatisticDto;
|
|
|
+import com.xunmei.core.board.dto.web.WebGA38InfoDto;
|
|
|
+import com.xunmei.core.board.dto.web.WebSyntheticQuestionDto;
|
|
|
import com.xunmei.core.board.enums.PeriodEnum;
|
|
|
import com.xunmei.core.board.mapper.CockpitMapper;
|
|
|
import com.xunmei.core.board.service.CockpitService;
|
|
|
-import com.xunmei.core.board.vo.web.OrgGA38StatisticVo;
|
|
|
-import com.xunmei.core.board.vo.web.QuestionStatisticVo;
|
|
|
-import com.xunmei.core.board.vo.web.TaskStatisticVo;
|
|
|
+import com.xunmei.core.board.vo.web.*;
|
|
|
+import com.xunmei.system.api.RemoteDictDataService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.domain.SysDictData;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import org.apache.http.annotation.Obsolete;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class CockpitServiceImpl implements CockpitService {
|
|
|
@@ -30,90 +36,223 @@ public class CockpitServiceImpl implements CockpitService {
|
|
|
@Resource
|
|
|
RemoteOrgService remoteOrgService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ RemoteDictDataService remoteDictDataService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<TaskStatisticVo> resumption(TaskStatisticDto dto) {
|
|
|
Date date = getStartDate(dto.getPeriod());
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(dto.getOrgId(), SecurityConstants.INNER);
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
String orgPath = org.getPath();
|
|
|
List<TaskStatisticVo> list = cockpitMapper.resumption(date, DateUtil.endOfDay(new Date()), orgPath);
|
|
|
- return taskStatistic(list, dto, org);
|
|
|
+ return taskStatistic(list, dto.getOrgId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TaskStatisticVo> safetyCheck(TaskStatisticDto dto) {
|
|
|
+ public List<WebSafetyCheckVo> safetyCheck(TaskStatisticDto dto) {
|
|
|
Date date = getStartDate(dto.getPeriod());
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(dto.getOrgId(), SecurityConstants.INNER);
|
|
|
- String orgPath = org.getPath();
|
|
|
- List<TaskStatisticVo> list = cockpitMapper.safetyCheck(date, DateUtil.endOfDay(new Date()), orgPath);
|
|
|
- return taskStatistic(list, dto, org);
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
+
|
|
|
+// String orgPath = org.getPath();
|
|
|
+ List<WebSafetyCheckVo> list = cockpitMapper.safetyCheck(date, DateUtil.endOfDay(new Date()), org.getPath());
|
|
|
+ List<SysDictData> dicts = remoteDictDataService.selectDictByeType("check_type", SecurityConstants.INNER);
|
|
|
+ dicts.sort(Comparator.comparing(SysDictData::getDictSort));
|
|
|
+ List<WebSafetyCheckVo> r = dicts.stream()
|
|
|
+ .filter(d->ObjectUtil.notEqual(d.getDictValue(),"1") && ObjectUtil.notEqual(d.getDictValue(),"2") )
|
|
|
+ .map(d -> {
|
|
|
+ Optional<WebSafetyCheckVo> voOpt = list.stream().filter(i -> ObjectUtil.equal(i.getType(), d.getDictValue())).findFirst();
|
|
|
+ WebSafetyCheckVo vo;
|
|
|
+ if (voOpt.isPresent()) {
|
|
|
+ vo = voOpt.get();
|
|
|
+ } else {
|
|
|
+ vo = new WebSafetyCheckVo();
|
|
|
+ }
|
|
|
+ String label = d.getDictLabel();
|
|
|
+ switch (d.getDictValue()) {
|
|
|
+ case "1":
|
|
|
+ label = "省联社检查";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ label = "办事处检查";
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ label = "网点自查";
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ label = "全面检查";
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ label = "阶段性检查";
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ label = "专项检查";
|
|
|
+ break;
|
|
|
+ case "7":
|
|
|
+ label = "其它检查";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ vo.setType(label);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return r;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Obsolete
|
|
|
public List<TaskStatisticVo> monitor(TaskStatisticDto dto) {
|
|
|
Date date = getStartDate(dto.getPeriod());
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(dto.getOrgId(), SecurityConstants.INNER);
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
String orgPath = org.getPath();
|
|
|
List<TaskStatisticVo> list = cockpitMapper.monitor(date, DateUtil.endOfDay(new Date()), orgPath);
|
|
|
- return taskStatistic(list, dto, org);
|
|
|
+ return taskStatistic(list, dto.getOrgId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<TaskStatisticVo> edu(TaskStatisticDto dto) {
|
|
|
Date date = getStartDate(dto.getPeriod());
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(dto.getOrgId(), SecurityConstants.INNER);
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
String orgPath = org.getPath();
|
|
|
List<TaskStatisticVo> list = cockpitMapper.edu(date, DateUtil.endOfDay(new Date()), orgPath);
|
|
|
- return taskStatistic(list, dto, org);
|
|
|
+ return taskStatistic(list, dto.getOrgId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TaskStatisticVo> drill(TaskStatisticDto dto) {
|
|
|
+ public List<WebDrillInfoVo> drill(TaskStatisticDto dto) {
|
|
|
Date date = getStartDate(dto.getPeriod());
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(dto.getOrgId(), SecurityConstants.INNER);
|
|
|
- String orgPath = org.getPath();
|
|
|
- List<TaskStatisticVo> list = cockpitMapper.drill(date, DateUtil.endOfDay(new Date()), orgPath);
|
|
|
- return taskStatistic(list, dto, org);
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
+// String orgPath = org.getPath();
|
|
|
+ List<TaskStatisticVo> list = cockpitMapper.drill(date, DateUtil.endOfDay(new Date()), org.getPath());
|
|
|
+ list = taskStatistic(list, dto.getOrgId());
|
|
|
+
|
|
|
+ List<WebDrillInfoVo> r = list.stream().map(i -> {
|
|
|
+ WebDrillInfoVo vo = new WebDrillInfoVo();
|
|
|
+ vo.setOrgName(i.getOrgName());
|
|
|
+ vo.setTotal((int) i.getTaskTotal());
|
|
|
+ vo.setCompleted((int) i.getCompletedCount());
|
|
|
+ vo.setCompletedRate(i.getCompletedRate());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return r;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<OrgGA38StatisticVo> orgGA38(Long orgId) {
|
|
|
- List<OrgGA38StatisticVo> data = cockpitMapper.orgGA38(orgId);
|
|
|
- List<OrgGA38StatisticVo> r = getGA38Children(orgId);
|
|
|
- for (OrgGA38StatisticVo orgVo : data) {
|
|
|
+ public List<OrgGA38StatisticVo> orgGA38(TaskStatisticDto dto) {
|
|
|
+ Date date = getStartDate(dto.getPeriod());
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
+ List<WebGA38InfoDto> data = cockpitMapper.orgGA38(org.getPath(), date);
|
|
|
+ List<OrgGA38StatisticVo> r = getGA38Children(dto.getOrgId());
|
|
|
+ for (WebGA38InfoDto orgVo : data) {
|
|
|
for (OrgGA38StatisticVo statisticVo : r) {
|
|
|
- if (orgVo.getOrgPath().startsWith(statisticVo.getOrgPath())) {
|
|
|
+ if (orgVo.getPath().startsWith(statisticVo.getOrgPath())) {
|
|
|
statisticVo.setTotal(1 + statisticVo.getTotal());
|
|
|
- statisticVo.setReachCount(orgVo.getReachCount() + statisticVo.getReachCount());
|
|
|
+ statisticVo.setGa382021(orgVo.getGa382021() + statisticVo.getGa382021());
|
|
|
+ statisticVo.setGa382015(orgVo.getGa382015() + statisticVo.getGa382015());
|
|
|
+ if (orgVo.getGa382021() > 0 || orgVo.getGa382015() > 0) {
|
|
|
+ statisticVo.setReachCount(1 + statisticVo.getReachCount());
|
|
|
+ }
|
|
|
+// statisticVo.setReachCount(orgVo.getReachCount() + statisticVo.getReachCount());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
r.forEach(i -> {
|
|
|
- if (ObjectUtil.equal(i.getTotal(), 0F)) {
|
|
|
- i.setReachRate(1F);
|
|
|
- } else {
|
|
|
- i.setReachRate(i.getReachCount() / i.getTotal());
|
|
|
- }
|
|
|
+ i.setReachRate(NumberUtils.computeRate(i.getTotal(), i.getReachCount()));
|
|
|
});
|
|
|
+
|
|
|
r.sort(new Comparator<OrgGA38StatisticVo>() {
|
|
|
@Override
|
|
|
public int compare(OrgGA38StatisticVo o1, OrgGA38StatisticVo o2) {
|
|
|
- return NumberUtil.compare(o2.getReachRate(),o1.getReachRate());
|
|
|
+ return NumberUtil.compare(o2.getReachRate(), o1.getReachRate());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 机构信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public OrgInfoVo orgInfo(Long orgId) {
|
|
|
+ SysOrg org = getOrgThrowIfNull(orgId);
|
|
|
+ return cockpitMapper.orgInfo(org.getPath());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public OrgSecurityInfoVo orgSecurityInfo(Long orgId) {
|
|
|
+ SysOrg org = getOrgThrowIfNull(orgId);
|
|
|
+ OrgSecurityInfoVo vo = cockpitMapper.orgSecurityInfo(org.getPath());
|
|
|
+ vo.setEquippedRate(NumberUtils.computeRate(vo.getEquippedCount() + vo.getUnequippedCount(), vo.getEquippedCount()));
|
|
|
+ vo.setUnequippedRate(NumberUtils.computeRate(vo.getEquippedCount() + vo.getUnequippedCount(), vo.getUnequippedCount()));
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本月来访
|
|
|
+ *
|
|
|
+ * @param orgPath
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public VisitInfoVo currentMonthVisitInfo(Long orgId) {
|
|
|
+ SysOrg org = getOrgThrowIfNull(orgId);
|
|
|
+ DateRange range = DateUtils.getStartAndEnd(new Date(), CycleCommonEnum.MONTHLY);
|
|
|
+ VisitInfoVo vo = cockpitMapper.currentMonthVisitInfo(org.getPath(), range.getStartTime());
|
|
|
+ int total = 0;
|
|
|
+ if (ObjectUtil.isNotNull(vo)) {
|
|
|
+ total = vo.getPaperCount() + vo.getElectronicCount() + vo.getUrgencyCount();
|
|
|
+ vo.setElectronicRate(NumberUtils.computeRate(total, vo.getElectronicCount()));
|
|
|
+ vo.setUrgencyRate(NumberUtils.computeRate(total, vo.getUrgencyCount()));
|
|
|
+ vo.setPaperRate(NumberUtils.computeRate(total, vo.getPaperCount()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public QuestionStatisticVo question(TaskStatisticDto dto) {
|
|
|
+ SysOrg org = getOrgThrowIfNull(dto.getOrgId());
|
|
|
Date date = getStartDate(dto.getPeriod());
|
|
|
- String orgPath = remoteOrgService.selectOrgById(dto.getOrgId(), SecurityConstants.INNER).getPath();
|
|
|
- return cockpitMapper.question(date, orgPath);
|
|
|
+
|
|
|
+ WebSyntheticQuestionDto questionDto = cockpitMapper.selectQuestion(org.getPath(), date);
|
|
|
+ if (ObjectUtil.isNull(questionDto)) {
|
|
|
+ questionDto = new WebSyntheticQuestionDto();
|
|
|
+ }
|
|
|
+ Map<String, Long> overdueCount = cockpitMapper.selectOverDueQuestionCount(org.getPath(), date);
|
|
|
+
|
|
|
+ QuestionStatisticVo vo = new QuestionStatisticVo();
|
|
|
+ vo.setTotal(questionDto.getTotal());
|
|
|
+ vo.setUnconfirm(NumberUtils.computeRate(questionDto.getTotal(), questionDto.getUnconfirmedCount()));
|
|
|
+ vo.setDissent(NumberUtils.computeRate(questionDto.getTotal(), questionDto.getDissentCount()));
|
|
|
+ vo.setClosed(NumberUtils.computeRate(questionDto.getTotal(), questionDto.getClosedCount()));
|
|
|
+ vo.setUnreform(NumberUtils.computeRate(questionDto.getTotal(), questionDto.getUnconfirmedCount()));
|
|
|
+ vo.setReformed(NumberUtils.computeRate(questionDto.getTotal(), questionDto.getReformedCount()));
|
|
|
+
|
|
|
+ if (overdueCount.size() > 0) {
|
|
|
+ Long count = overdueCount.get("count");
|
|
|
+ Long overdue = overdueCount.get("overdueCount");
|
|
|
+ vo.setClosed(NumberUtils.computeRate(count.intValue(), overdue.intValue()));
|
|
|
+ } else {
|
|
|
+ vo.setClosed(1f);
|
|
|
+ }
|
|
|
+
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
- private List<TaskStatisticVo> taskStatistic(List<TaskStatisticVo> data, TaskStatisticDto dto,SysOrg org) {
|
|
|
- List<TaskStatisticVo> r = getTaskChildren(org);
|
|
|
+ private List<TaskStatisticVo> taskStatistic(List<TaskStatisticVo> data, Long orgId) {
|
|
|
+ List<TaskStatisticVo> r = getTaskChildren(orgId);
|
|
|
for (TaskStatisticVo orgVo : data) {
|
|
|
for (TaskStatisticVo statisticVo : r) {
|
|
|
if (orgVo.getOrgPath().startsWith(statisticVo.getOrgPath())) {
|
|
|
@@ -150,15 +289,25 @@ public class CockpitServiceImpl implements CockpitService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<TaskStatisticVo> getTaskChildren(SysOrg org) {
|
|
|
- List<SysOrg> children=remoteOrgService.selectOrgTreeListByCurOrgId(org.getId(), SecurityConstants.INNER);
|
|
|
+// private DateRange getStartAndEnd(Integer period) {
|
|
|
+// Date start = getStartDate(period);
|
|
|
+// Date end = DateUtil.endOfDay(new Date());
|
|
|
+// return new DateRange(start, end);
|
|
|
+// }
|
|
|
+
|
|
|
+ private List<TaskStatisticVo> getTaskChildren(Long orgId) {
|
|
|
+ List<SysOrg> children = remoteOrgService.selectChildrenFromDb(orgId, SecurityConstants.INNER);
|
|
|
List<TaskStatisticVo> list = new ArrayList<>();
|
|
|
|
|
|
for (SysOrg child : children) {
|
|
|
TaskStatisticVo vo = new TaskStatisticVo();
|
|
|
vo.setOrgPath(child.getPath());
|
|
|
vo.setOrgId(child.getId());
|
|
|
- vo.setOrgName(child.getName());
|
|
|
+ if (StringUtils.isEmpty(child.getBreviary())) {
|
|
|
+ vo.setOrgName(child.getShortName());
|
|
|
+ } else {
|
|
|
+ vo.setOrgName(child.getBreviary());
|
|
|
+ }
|
|
|
vo.setTaskTotal(0F);
|
|
|
vo.setCompletedCount(0F);
|
|
|
list.add(vo);
|
|
|
@@ -168,20 +317,34 @@ public class CockpitServiceImpl implements CockpitService {
|
|
|
}
|
|
|
|
|
|
private List<OrgGA38StatisticVo> getGA38Children(Long orgId) {
|
|
|
- List<SysOrg> children=remoteOrgService.selectOrgTreeListByCurOrgId(orgId, SecurityConstants.INNER);
|
|
|
+ List<SysOrg> children = remoteOrgService.selectChildrenFromDb(orgId, SecurityConstants.INNER);
|
|
|
List<OrgGA38StatisticVo> list = new ArrayList<>();
|
|
|
for (SysOrg child : children) {
|
|
|
OrgGA38StatisticVo vo = new OrgGA38StatisticVo();
|
|
|
vo.setOrgPath(child.getPath());
|
|
|
vo.setOrgId(child.getId());
|
|
|
- vo.setOrgName(child.getName());
|
|
|
- vo.setTotal(0F);
|
|
|
- vo.setReachCount(0F);
|
|
|
+ if (StringUtils.isEmpty(child.getBreviary())) {
|
|
|
+ vo.setOrgName(child.getShortName());
|
|
|
+ } else {
|
|
|
+ vo.setOrgName(child.getBreviary());
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setTotal(0);
|
|
|
+ vo.setReachCount(0);
|
|
|
list.add(vo);
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ private SysOrg getOrgThrowIfNull(Long orgId) {
|
|
|
+ SysOrg org = remoteOrgService.selectOrgById(orgId, SecurityConstants.INNER);
|
|
|
+ if (ObjectUtil.isNull(org)) {
|
|
|
+ throw new ServiceException("机构不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ return org;
|
|
|
+ }
|
|
|
//
|
|
|
// private List<SysOrg> getChildren(SysOrg org) {
|
|
|
// List<SysOrg> children=remoteOrgService.selectOrgTreeListByCurOrgId(org.getId(), SecurityConstants.INNER);
|