|
|
@@ -1,21 +1,37 @@ |
|
|
|
package com.ningdatech.pmapi.projectlib.manage; |
|
|
|
|
|
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelReader; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent; |
|
|
|
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectApprovedReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectIdReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.req.StartProjectDeclareReq; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; |
|
|
|
|
|
|
@@ -32,13 +48,13 @@ import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*; |
|
|
|
public class AnnualPlanLibManage { |
|
|
|
|
|
|
|
private final IProjectService projectService; |
|
|
|
private final StateMachineUtils stateMachine; |
|
|
|
|
|
|
|
/** |
|
|
|
* 年度计划查询状态 |
|
|
|
*/ |
|
|
|
private static final List<ProjectStatusEnum> ANNUAL_PLAN_LIST_STATUS = Arrays.asList( |
|
|
|
IN_THE_ANNUAL_PLAN, |
|
|
|
BE_SUSPENDED, |
|
|
|
SCHEME_UNDER_REVIEW, |
|
|
|
SCHEME_REVIEW_FAILED, |
|
|
|
TO_BE_APPROVED, |
|
|
@@ -57,6 +73,7 @@ public class AnnualPlanLibManage { |
|
|
|
|
|
|
|
public PageVo<AnnualPlanListItemVO> annulPlanLibList(ProjectListReq req) { |
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
query.eq(Project::getIsTemporaryAugment, 0); |
|
|
|
query.orderByDesc(Project::getAnnualPlanAddTime); |
|
|
|
query.in(Project::getStatus, CollUtils.fieldList(ANNUAL_PLAN_LIST_STATUS, ProjectStatusEnum::getCode)); |
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
@@ -76,11 +93,56 @@ public class AnnualPlanLibManage { |
|
|
|
item.setDeclaredAmount(w.getDeclareAmount()); |
|
|
|
item.setBuildOrg(w.getBuildOrgName()); |
|
|
|
item.setCreateOn(w.getCreateOn()); |
|
|
|
// TODO 是否开启项目申报 |
|
|
|
item.setIsStartDeclaredProject(true); |
|
|
|
item.setIsStartDeclaredProject(!IN_THE_ANNUAL_PLAN.eq(w.getStatus())); |
|
|
|
result.getRecords().add(item); |
|
|
|
}); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void startProjectDeclared(StartProjectDeclareReq req) { |
|
|
|
List<Project> projects = projectService.listByIds(req.getProjectIds()); |
|
|
|
projects.forEach(w -> { |
|
|
|
if (!IN_THE_ANNUAL_PLAN.eq(w.getStatus())) { |
|
|
|
throw BizException.wrap("开启方案申报失败"); |
|
|
|
} |
|
|
|
}); |
|
|
|
projects.forEach(project -> { |
|
|
|
try { |
|
|
|
stateMachine.execute(project, ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new BizException("开启方案申报失败"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void projectApproved(ProjectApprovedReq req) throws Exception { |
|
|
|
Project project = projectService.getById(req.getProjectId()); |
|
|
|
stateMachine.execute(project, ProjectStatusChangeEvent.PROJECT_APPROVAL); |
|
|
|
LambdaUpdateWrapper<Project> update = Wrappers.lambdaUpdate(Project.class) |
|
|
|
.set(Project::getApprovalAmount, req.getApprovedAmount()) |
|
|
|
.set(Project::getApprovedFile, req.getApprovedFileId()) |
|
|
|
.set(Project::getBuildCycle, req.getBuildCycle()) |
|
|
|
.set(Project::getConstructionPlanFile, req.getBuildPlanFileId()) |
|
|
|
.set(Project::getApprovalDate, req.getApprovedDate()) |
|
|
|
.eq(Project::getId, req.getProjectId()); |
|
|
|
projectService.update(update); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void suspendAnnualPlan(ProjectIdReq req) throws Exception { |
|
|
|
Project project = projectService.getById(req.getProjectId()); |
|
|
|
stateMachine.execute(project, ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void importAnnualPlan(MultipartFile file) { |
|
|
|
try (InputStream inputStream = file.getInputStream()) { |
|
|
|
EasyExcel.read(inputStream).sheet(0); |
|
|
|
} catch (IOException e) { |
|
|
|
throw BizException.wrap("导入年度计划失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |