|
@@ -5,10 +5,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.wtkj.dto.ProjectPageDTO;
|
|
|
import com.wtkj.entity.Project;
|
|
|
import com.wtkj.entity.ProjectAuth;
|
|
|
+import com.wtkj.entity.Task;
|
|
|
+import com.wtkj.entity.TaskContract;
|
|
|
import com.wtkj.mapper.ProjectMapper;
|
|
|
-import com.wtkj.service.IAsyncService;
|
|
|
-import com.wtkj.service.IProjectAuthService;
|
|
|
-import com.wtkj.service.IProjectService;
|
|
|
+import com.wtkj.service.*;
|
|
|
+import com.wtkj.vo.ProjectStatisticsVO;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
@@ -20,7 +21,10 @@ import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -38,12 +42,16 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
|
|
|
private final IAsyncService asyncService;
|
|
|
private final ISysClient sysClient;
|
|
|
private final IProjectAuthService projectAuthService;
|
|
|
+ private final ITaskService taskService;
|
|
|
+ private final ITaskContractService taskContractService;
|
|
|
|
|
|
@Override
|
|
|
public boolean submit(Project project) {
|
|
|
boolean flag = false;
|
|
|
BladeUser user = AuthUtil.getUser();
|
|
|
if (project.getId() == null) {
|
|
|
+ LocalDate date = LocalDate.now();
|
|
|
+ project.setYear(String.valueOf(date.getYear()));
|
|
|
flag = this.save(project);
|
|
|
asyncService.createProject(project, user);
|
|
|
} else {
|
|
@@ -97,20 +105,84 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //待完成任务数排序
|
|
|
- if (dto.getTodoAsc().equals(1)) {
|
|
|
- lqw.orderByAsc(Project::getTodoTask);
|
|
|
- } else {
|
|
|
- lqw.orderByDesc(Project::getTodoTask);
|
|
|
- }
|
|
|
- //截止时间排序
|
|
|
- if (dto.getEndTimeAsc().equals(1)) {
|
|
|
- lqw.orderByAsc(Project::getEndTime);
|
|
|
+ }
|
|
|
+ return this.page(page, lqw);
|
|
|
+
|
|
|
+ /*Long deptId = Func.firstLong(AuthUtil.getDeptId());
|
|
|
+ LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
|
|
|
+ //判断当前登录用户的身份 是业主还是服务机构
|
|
|
+ //年份
|
|
|
+ if (StringUtil.isNotBlank(dto.getYear())) {
|
|
|
+ lqw.like(Project::getYear, dto.getYear());
|
|
|
+ }
|
|
|
+ //项目名称
|
|
|
+ if (StringUtil.isNotBlank(dto.getName())) {
|
|
|
+ lqw.eq(Project::getName, dto.getName());
|
|
|
+ }
|
|
|
+ //区域
|
|
|
+ if (StringUtil.isNotBlank(dto.getAreaCode())) {
|
|
|
+ lqw.eq(Project::getAreaCode, dto.getAreaCode());
|
|
|
+ }
|
|
|
+ Integer deptCategory = dto.getDeptCategory();
|
|
|
+ if (deptCategory != null) {
|
|
|
+ //1.如果是业主 即查询主管单位是该deptId的项目
|
|
|
+ if (deptCategory.equals(3)) {
|
|
|
+ //主管单位 业主自己
|
|
|
+ lqw.eq(Project::getCompetentUnit, dto.getTopDept());
|
|
|
+ //协作单位
|
|
|
+ lqw.like(StringUtil.isNotBlank(dto.getCooperationUint()), Project::getCooperationUint, dto.getCooperationUint());
|
|
|
+
|
|
|
+
|
|
|
} else {
|
|
|
- lqw.orderByDesc(Project::getEndTime);
|
|
|
+ //2.非业主
|
|
|
+ //主管单位
|
|
|
+ if (dto.getCompetentUnit() != null) {
|
|
|
+ lqw.eq(Project::getCompetentUnit, dto.getCompetentUnit());
|
|
|
+ }
|
|
|
+ //如果不是业主 ---> 判断是否是服务商
|
|
|
+ String userRole = AuthUtil.getUserRole();
|
|
|
+ if (userRole != null) {
|
|
|
+ //2.1 机构管理员 ---> 项目来源 机构自建的,做任务
|
|
|
+ if (userRole.contains(STAFF_ADMIN)) {
|
|
|
+ //服务商自己建的项目主管单位就是自己
|
|
|
+ lqw.eq(Project::getCreateTopDept,dto.getTopDept());
|
|
|
+ List<Task> tasks = taskService.getByOrgDeptId(dto.getTopDept(), null);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)){
|
|
|
+ Set<Long> projectIds = tasks.stream().map(Task::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ lqw.in(Project::getId,projectIds);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //2.2非机构管理员 是主管 执行机构是自己 和任务执行机构是自己
|
|
|
+ if (userRole.contains(STAFF_SECOND_ADMIN)) {
|
|
|
+ lqw.eq(Project::getCreateDept, deptId);
|
|
|
+ List<Task> tasks = taskService.getByExecuteDept(deptId);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (userRole.contains(STAFF_PROJECT_MANAGER)) {
|
|
|
+ //是项目经理
|
|
|
+ } else if (userRole.contains(STAFF_USER)) {
|
|
|
+ //是普通员工
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return this.page(page, lqw);
|
|
|
+ //待完成任务数排序
|
|
|
+ if (dto.getTodoAsc().equals(1)) {
|
|
|
+ lqw.orderByAsc(Project::getTodoTask);
|
|
|
+ } else {
|
|
|
+ lqw.orderByDesc(Project::getTodoTask);
|
|
|
+ }
|
|
|
+ //截止时间排序
|
|
|
+ if (dto.getEndTimeAsc().equals(1)) {
|
|
|
+ lqw.orderByAsc(Project::getEndTime);
|
|
|
+ } else {
|
|
|
+ lqw.orderByDesc(Project::getEndTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.page(page, lqw);*/
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -118,4 +190,64 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
|
|
|
return baseMapper.selectByCreate(createDept, createUser);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ProjectStatisticsVO projectStatistics(Long topDept, Integer deptCategory, String year) {
|
|
|
+ ProjectStatisticsVO vo = new ProjectStatisticsVO();
|
|
|
+ if (deptCategory != null) {
|
|
|
+ LambdaQueryWrapper<Project> lqw = new LambdaQueryWrapper<>();
|
|
|
+ if (deptCategory.equals(3)) {
|
|
|
+ //是业主 --> 主管单位是topDept
|
|
|
+ lqw.eq(Project::getCompetentUnit, topDept);
|
|
|
+ List<Project> list = this.list(lqw);
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ Set<Long> projectIds = list.stream().map(Project::getId).collect(Collectors.toSet());
|
|
|
+ //项目总数
|
|
|
+ vo.setProjectCount(list.size());
|
|
|
+ //项目总投
|
|
|
+ BigDecimal amount = list.stream().map(Project::getTotalAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setTotalAmount(amount);
|
|
|
+ //服务合同金额 -->所有业主的项目的任务下的所有合同
|
|
|
+ List<TaskContract> contracts = taskContractService.getByProjectIds(projectIds);
|
|
|
+ if (!CollectionUtils.isEmpty(contracts)) {
|
|
|
+ BigDecimal reduce = contracts.stream().map(TaskContract::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setContractAmount(reduce);
|
|
|
+ }
|
|
|
+ //待完成任务总数
|
|
|
+ List<Task> tasks = taskService.getTodoByYear(projectIds, year);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
+ vo.setTodoTask(tasks.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //是服务机构 -->执行机构是topDept
|
|
|
+ List<Task> tasks = taskService.getByOrgDeptId(topDept, null);
|
|
|
+ if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
+ Set<Long> projectIds = tasks.stream().map(Task::getProjectId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
+ lqw.in(Project::getId, projectIds);
|
|
|
+ List<Project> projects = this.list(lqw);
|
|
|
+ if (!CollectionUtils.isEmpty(projects)) {
|
|
|
+ //项目总数
|
|
|
+ vo.setProjectCount(projects.size());
|
|
|
+ //项目总投
|
|
|
+ BigDecimal amount = projects.stream().map(Project::getTotalAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setTotalAmount(amount);
|
|
|
+ //服务合同金额 --> 任务合同乙方是当前机构的
|
|
|
+ List<TaskContract> contracts = taskContractService.getByOrgDeptId(topDept);
|
|
|
+ if (!CollectionUtils.isEmpty(contracts)) {
|
|
|
+ BigDecimal reduce = contracts.stream().map(TaskContract::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setContractAmount(reduce);
|
|
|
+ }
|
|
|
+ //待完成任务数量
|
|
|
+ Set<Task> collect = tasks.stream().filter(f -> f.getYear().equals(Integer.valueOf(year)) && f.getIsConfirmed() == 0).collect(Collectors.toSet());
|
|
|
+ if (!CollectionUtils.isEmpty(collect)) {
|
|
|
+ vo.setTodoTask(collect.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
}
|