|
|
@@ -12,10 +12,7 @@ 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.security.utils.SecurityUtils;
|
|
|
-import com.xunmei.core.board.dto.app.AppGA38InfoDto;
|
|
|
-import com.xunmei.core.board.dto.app.AppOrgBaseInfoDto;
|
|
|
-import com.xunmei.core.board.dto.app.AppOverviewTaskInfoDto;
|
|
|
-import com.xunmei.core.board.dto.app.AppTaskRankingDto;
|
|
|
+import com.xunmei.core.board.dto.app.*;
|
|
|
import com.xunmei.core.board.mapper.AppCockpitMapper;
|
|
|
import com.xunmei.core.board.mapper.CockpitMapper;
|
|
|
import com.xunmei.core.board.service.AppCockpitService;
|
|
|
@@ -30,13 +27,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import reactor.function.Predicate3;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.swing.*;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.TimeoutException;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class AppCockpitServiceImpl implements AppCockpitService {
|
|
|
@@ -115,10 +115,7 @@ public class AppCockpitServiceImpl implements AppCockpitService {
|
|
|
*/
|
|
|
@Override
|
|
|
public AppBaseInfoVo baseInfo() {
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
- if (ObjectUtil.isNull(org)) {
|
|
|
- throw new ServiceException("登录机构不存在");
|
|
|
- }
|
|
|
+ SysOrg org = getLoginOrg();
|
|
|
|
|
|
AppBaseInfoVo vo = new AppBaseInfoVo();
|
|
|
AppOrgBaseInfoDto baseInfoDto = appCockpitMapper.selectOrgBaseInfo(org.getPath());
|
|
|
@@ -170,11 +167,8 @@ public class AppCockpitServiceImpl implements AppCockpitService {
|
|
|
*/
|
|
|
@Override
|
|
|
public AppOverviewVo overview() throws ExecutionException, InterruptedException, TimeoutException {
|
|
|
- SysOrg org = remoteOrgService.selectOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
+ SysOrg org = getLoginOrg();
|
|
|
AppOverviewVo vo = new AppOverviewVo();
|
|
|
- if (ObjectUtil.isNull(org)) {
|
|
|
- return vo;
|
|
|
- }
|
|
|
|
|
|
Date currentMonth = DateUtil.beginOfMonth(new Date());
|
|
|
Date prevMonth = DateUtil.beginOfMonth(new Date()).offset(DateField.MONTH, -1);
|
|
|
@@ -248,6 +242,33 @@ public class AppCockpitServiceImpl implements AppCockpitService {
|
|
|
|
|
|
@Override
|
|
|
public AppSyntheticResumptionVo syntheticResumption(Date month) {
|
|
|
+ SysOrg org = getLoginOrg();
|
|
|
+ DateRange range = DateUtils.getStartAndEnd(month, CycleCommonEnum.MONTHLY);
|
|
|
+ List<AppSyntheticTaskCategoryDto> taskCategoryDtos = appCockpitMapper.selectSyntheticResumption( org.getPath(), range.getStartTime(), range.getEndTime());
|
|
|
+
|
|
|
+ AppSyntheticResumptionVo vo=new AppSyntheticResumptionVo();
|
|
|
+ vo.setInfoByType(new HashMap<>());
|
|
|
+ vo.setRateByType(new HashMap<>());
|
|
|
+ Predicate3<List<String>,String,String> predicate3=(List<String> types,String label,String no)->{
|
|
|
+ List<AppSyntheticTaskCategoryDto> used= taskCategoryDtos.stream().filter(d->types.contains(d.getPlanType())).collect(Collectors.toList());
|
|
|
+ int total=used.stream().mapToInt(AppSyntheticTaskCategoryDto::getTotal).sum();
|
|
|
+ int completed=used.stream().mapToInt(AppSyntheticTaskCategoryDto::getCompleted).sum();
|
|
|
+ Float rate=computeRate(total,completed);
|
|
|
+
|
|
|
+ vo.getRateByType().put(label,rate);
|
|
|
+ vo.getInfoByType().put(label,AppSyntheticTaskInfoVo.builder()
|
|
|
+ .completedCount(completed).shouldCompleteCount(total).completedRate(rate)
|
|
|
+ .build());
|
|
|
+
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
+ predicate3.test(Arrays.asList("1","2","3"),"每日履职",null);
|
|
|
+ predicate3.test(Arrays.asList("4"),"报警测试",null);
|
|
|
+ predicate3.test(Arrays.asList("5"),"UPS维护",null);
|
|
|
+ predicate3.test(Arrays.asList("6"),"夜间值守",null);
|
|
|
+ predicate3.test(Arrays.asList("7"),"离行巡检",null);
|
|
|
+
|
|
|
return new AppSyntheticResumptionVo();
|
|
|
}
|
|
|
|
|
|
@@ -288,6 +309,14 @@ public class AppCockpitServiceImpl implements AppCockpitService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private SysOrg getLoginOrg() {
|
|
|
+ SysOrg org = remoteOrgService.selectOrgById(SecurityUtils.getLoginUser().getOrgId(), SecurityConstants.INNER);
|
|
|
+ if (ObjectUtil.isNull(org)) {
|
|
|
+ throw new ServiceException("未获取到登录机构");
|
|
|
+ }
|
|
|
+ return org;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param total 应完成
|
|
|
* @param completed 已完成
|