|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.control.dto.ControlProjectInfoDTO;
|
|
@@ -23,12 +24,14 @@ import org.springblade.control.vo.*;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -418,8 +421,128 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 任务统计-计划统计图
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<PlanStatisticVO> MonthOfYearPlanOverview2(Long deptId, Long UserId, LocalDate start, LocalDate end) {
|
|
|
+ public PlanStatisticVO2 MonthOfYearPlanOverview2(Long deptId, Long userId, String start, String end) {
|
|
|
+ LocalDate startDate;
|
|
|
+ LocalDate endDate;
|
|
|
+ //判断是否选择部门,如果选择了部门再判断是否选择了具体的人,如果没有选择具体的人则查询整个部门
|
|
|
+ if (StringUtils.isBlank(start) || StringUtils.isBlank(end)){
|
|
|
+ startDate = LocalDate.of(LocalDate.now().getYear(),1,1);
|
|
|
+ endDate = LocalDate.of(LocalDate.now().getYear(),12,31);
|
|
|
+ }else {
|
|
|
+ String[] s1 = start.split("-");
|
|
|
+ startDate = LocalDate.of(Integer.parseInt(s1[0]),Integer.parseInt(s1[1]),1);
|
|
|
+ String[] s2 = end.split("-");
|
|
|
+ endDate = LocalDate.of(Integer.parseInt(s2[0]),Integer.parseInt(s2[1]),1);
|
|
|
+ endDate = endDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }
|
|
|
+ //获取时间段中的计划,默认是今年
|
|
|
+ List<ProjectCostBudget> plans = baseMapper.getPlanByDeptOrUserOrTime(deptId, userId, startDate, endDate);
|
|
|
+ if (plans != null && plans.size() > 0) {
|
|
|
+ //结果
|
|
|
+ PlanStatisticVO2 vo2 = new PlanStatisticVO2();
|
|
|
+ List<PlanStatisticVO> list = new ArrayList<>();
|
|
|
+ //任务总量
|
|
|
+ PlanStatisticVO planTotal = new PlanStatisticVO();
|
|
|
+ planTotal.setName("任务总量");
|
|
|
+ List<Integer> l1 = new ArrayList<>();
|
|
|
+ //已完成
|
|
|
+ PlanStatisticVO finished = new PlanStatisticVO();
|
|
|
+ finished.setName("已完成");
|
|
|
+ List<Integer> l2 = new ArrayList<>();
|
|
|
+ //未完成
|
|
|
+ PlanStatisticVO unfinished = new PlanStatisticVO();
|
|
|
+ unfinished.setName("未完成");
|
|
|
+ List<Integer> l3 = new ArrayList<>();
|
|
|
+ //获取月数组
|
|
|
+ List<String> dateList = new ArrayList<>();
|
|
|
+
|
|
|
+ //风险计划集合
|
|
|
+ List<PlanStatisticVO2.RiskPlan> riskPlans = new ArrayList<>();
|
|
|
+ PlanStatisticVO2.RiskPlan riskPlan = new PlanStatisticVO2.RiskPlan();
|
|
|
+ riskPlan.setName("风险暂停计划");
|
|
|
+ riskPlan.setType("line");
|
|
|
+ riskPlan.setStack("Total");
|
|
|
+ List<Integer> list1 = new ArrayList<>();
|
|
|
+ PlanStatisticVO2.RiskPlan normalPlan = new PlanStatisticVO2.RiskPlan();
|
|
|
+ normalPlan.setName("正常计划");
|
|
|
+ normalPlan.setType("line");
|
|
|
+ normalPlan.setStack("Total");
|
|
|
+ List<Integer> list2 = new ArrayList<>();
|
|
|
+
|
|
|
+// endDate = endDate.plusMonths(1);
|
|
|
+ while (startDate.isBefore(endDate)) {
|
|
|
+ //循环月,并且计算任务总量,已完成,未完成
|
|
|
+ Integer total = 0;
|
|
|
+ Integer finish = 0;
|
|
|
+ Integer unfinish = 0;
|
|
|
+
|
|
|
+ Integer risk = 0;
|
|
|
+ Integer normal = 0;
|
|
|
+ for (ProjectCostBudget plan : plans) {
|
|
|
+ if ((plan.getPlanStartTime().getYear() == startDate.getYear() && plan.getPlanStartTime().getMonthValue() == startDate.getMonthValue())
|
|
|
+ || (plan.getPlanEndTime().getYear() == startDate.getYear() && plan.getPlanEndTime().getMonthValue() == startDate.getMonthValue())) {
|
|
|
+ //计划统计图
|
|
|
+ total++;
|
|
|
+ if (plan.getTaskApprove() == 1){
|
|
|
+ finish++;
|
|
|
+ }else {
|
|
|
+ unfinish++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //风险计划统计图
|
|
|
+ if (plan.getStatus() == 4){
|
|
|
+ if (plan.getPlanEndTime().isBefore(plan.getPracticalFinishTime())){
|
|
|
+ //风险计划
|
|
|
+ risk++;
|
|
|
+ }else {
|
|
|
+ normal++;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (plan.getPlanEndTime().isBefore(LocalDate.now())){
|
|
|
+ //风险计划
|
|
|
+ risk++;
|
|
|
+ }else {
|
|
|
+ normal++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list1.add(risk);
|
|
|
+ list2.add(normal);
|
|
|
+
|
|
|
+ l1.add(total);
|
|
|
+ l2.add(finish);
|
|
|
+ l3.add(unfinish);
|
|
|
+ dateList.add(startDate.getYear()+"年"+startDate.getMonthValue()+"月");
|
|
|
+ startDate = startDate.plusMonths(1);
|
|
|
+ }
|
|
|
+ //统计图集合
|
|
|
+ planTotal.setValue(l1);
|
|
|
+ finished.setValue(l2);
|
|
|
+ unfinished.setValue(l3);
|
|
|
+ list.add(planTotal);
|
|
|
+ list.add(finished);
|
|
|
+ list.add(unfinished);
|
|
|
+ vo2.setDataList(list);
|
|
|
+
|
|
|
+ //统计日期
|
|
|
+ vo2.setDateList(dateList);
|
|
|
+
|
|
|
+ //统计风险计划
|
|
|
+ riskPlan.setData(list1);
|
|
|
+ normalPlan.setData(list2);
|
|
|
+ riskPlans.add(riskPlan);
|
|
|
+ riskPlans.add(normalPlan);
|
|
|
+ vo2.setRiskPlans(riskPlans);
|
|
|
+
|
|
|
+ return vo2;
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -504,6 +627,81 @@ public class ProjectCostBudgetServiceImpl extends BaseServiceImpl<ProjectCostBud
|
|
|
return baseMapper.getPlanPracticalCostByMonth(date);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 任务统计-任务完成率
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public PlanFinishedRatioVO planFinishedRatio(Long deptId, Long userId, String start, String end) {
|
|
|
+ String tenantId = SecureUtil.getTenantId();
|
|
|
+ List<User> Employees = new ArrayList<>();
|
|
|
+ if (deptId == null){
|
|
|
+ //查询所有员工
|
|
|
+ Employees = baseMapper.getAllEmployees(tenantId,null,null);
|
|
|
+ }else if (userId == null){
|
|
|
+ //查询整个部门的员工
|
|
|
+ Employees = baseMapper.getAllEmployees(tenantId,deptId,null);
|
|
|
+ }else {
|
|
|
+ //查询指定员工
|
|
|
+ Employees = baseMapper.getAllEmployees(tenantId,deptId,userId);
|
|
|
+ }
|
|
|
+ if (Employees != null && Employees.size() > 0 ){
|
|
|
+ PlanFinishedRatioVO vo = new PlanFinishedRatioVO();
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
+ List<Integer> ratios = new ArrayList<>();
|
|
|
+ LocalDate startDate;
|
|
|
+ LocalDate endDate;
|
|
|
+ //判断是否选择部门,如果选择了部门再判断是否选择了具体的人,如果没有选择具体的人则查询整个部门
|
|
|
+ if (StringUtils.isBlank(start) || StringUtils.isBlank(end)){
|
|
|
+ startDate = LocalDate.of(LocalDate.now().getYear(),1,1);
|
|
|
+ endDate = LocalDate.of(LocalDate.now().getYear(),12,31);
|
|
|
+ }else {
|
|
|
+ String[] s1 = start.split("-");
|
|
|
+ startDate = LocalDate.of(Integer.parseInt(s1[0]),Integer.parseInt(s1[1]),1);
|
|
|
+ String[] s2 = end.split("-");
|
|
|
+ endDate = LocalDate.of(Integer.parseInt(s2[0]),Integer.parseInt(s2[1]),1);
|
|
|
+ endDate = endDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ }
|
|
|
+ //获取员工id集合
|
|
|
+ Set<Long> ids = Employees.stream().map(l -> l.getId()).collect(Collectors.toSet());
|
|
|
+ //根据员工id查询时间范围内的任务
|
|
|
+ //获取时间段中的计划,默认是今年
|
|
|
+ List<ProjectCostBudget> plans = baseMapper.getPlanByDeptOrUserOrTime2(ids, startDate, endDate);
|
|
|
+ if (plans != null && plans.size() > 0) {
|
|
|
+ //通过员工id分组
|
|
|
+ Map<Long, List<ProjectCostBudget>> listMap = plans.parallelStream()
|
|
|
+ .collect(Collectors.groupingBy(ProjectCostBudget::getTaskUser));
|
|
|
+ for (User employee : Employees) {
|
|
|
+ names.add(employee.getName());
|
|
|
+ BigDecimal total = new BigDecimal(0);
|
|
|
+ BigDecimal finished = new BigDecimal(0);
|
|
|
+ List<ProjectCostBudget> list = listMap.get(employee.getId());
|
|
|
+ //判断此用户是否存在任务,不存在则直接比例为0
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ for (ProjectCostBudget plan : list) {
|
|
|
+ if (plan.getTaskUser().equals(employee.getId())) {
|
|
|
+ total = total.add(new BigDecimal(1));
|
|
|
+ if (plan.getTaskApprove() == 1) {
|
|
|
+ finished = finished.add(new BigDecimal(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (total.compareTo(new BigDecimal(0)) != 0) {
|
|
|
+ ratios.add(finished.divide(total, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue());
|
|
|
+ } else {
|
|
|
+ ratios.add(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ ratios.add(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setUserList(names);
|
|
|
+ vo.setRatioList(ratios);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统计一行的几个总金额
|
|
|
*/
|