@@ -0,0 +1,50 @@ | |||
package com.ningdatech.pmapi.projectdeclared.controller; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | |||
import com.ningdatech.pmapi.projectdeclared.manage.DelayedApplyManage; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | |||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.servlet.http.HttpServletResponse; | |||
/** | |||
* @Classname DelayedProjectController | |||
* @Description | |||
* @Date 2023/6/7 18:50 | |||
* @Author PoffyZhang | |||
*/ | |||
@Slf4j | |||
@Validated | |||
@RestController | |||
@RequestMapping("/api/v1/declared/delayed") | |||
@Api(value = "DelayedProjectController", tags = "申报管理-延期项目") | |||
@RequiredArgsConstructor | |||
public class DelayedApplyController { | |||
private final DelayedApplyManage delayedApplyManage; | |||
@ApiOperation(value = "过期的项目列表", notes = "过期的项目列表") | |||
@GetMapping("/project-list") | |||
public PageVo<ProjectLibListItemVO> projectlist(@ModelAttribute ProjectListReq req) { | |||
return delayedApplyManage.projectLibList(req); | |||
} | |||
@GetMapping("/export") | |||
@ApiOperation("过期的项目列表导出") | |||
public void exportList(ProjectListReq req, HttpServletResponse response){ | |||
ExcelDownUtil.downXls(response,req,delayedApplyManage::exportList); | |||
} | |||
@ApiOperation(value = "延期申报", notes = "延期申报") | |||
@PostMapping("/delayed-apply") | |||
public String delayedApply(@Validated @RequestBody DelayedApplyDTO dto) { | |||
return delayedApplyManage.delayedApply(dto); | |||
} | |||
} |
@@ -0,0 +1,180 @@ | |||
package com.ningdatech.pmapi.projectdeclared.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.ningdatech.pmapi.common.constant.BizConst; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | |||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | |||
import com.ningdatech.pmapi.common.util.ExcelExportStyle; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.PaymentPlan; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Classname DelayedManage | |||
* @Description | |||
* @Date 2023/5/29 14:48 | |||
* @Author PoffyZhang | |||
*/ | |||
@Component | |||
@Slf4j | |||
@RequiredArgsConstructor | |||
public class DelayedApplyManage { | |||
private final IProjectService projectService; | |||
private final UserInfoHelper userInfoHelper; | |||
private final StateMachineUtils stateMachineUtils; | |||
/** | |||
* 延期的-项目列表 | |||
* @param req | |||
* @return | |||
*/ | |||
public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) { | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | |||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | |||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | |||
//待终验 并且已经过期 | |||
query.eq(Project::getStatus,ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); | |||
query.eq(Project::getStage,ProjectStatusEnum.PROJECT_APPROVED.getCode()); | |||
query.lt(Project::getPlanAcceptanceTime, LocalDateTime.now()); | |||
query.eq(Project::getNewest,Boolean.TRUE); | |||
query.isNotNull(Project::getApprovalDate); | |||
query.isNotNull(Project::getBuildCycle); | |||
query.orderByAsc(Project::getApprovalDate); | |||
Page<Project> page = projectService.page(req.page(), query); | |||
long total; | |||
if ((total = page.getTotal()) == 0) { | |||
return PageVo.empty(); | |||
} | |||
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { | |||
ProjectLibListItemVO item = new ProjectLibListItemVO(); | |||
item.setId(w.getId()); | |||
item.setProjectName(w.getProjectName()); | |||
item.setCreateOn(w.getCreateOn()); | |||
item.setDeclaredAmount(w.getDeclareAmount()); | |||
item.setStage(w.getStage()); | |||
item.setStatus(w.getStatus()); | |||
item.setProjectType(w.getProjectType()); | |||
item.setProjectYear(w.getProjectYear()); | |||
item.setBuildOrg(w.getBuildOrgName()); | |||
item.setBizDomain(w.getBizDomain()); | |||
item.setProcessStatus(w.getProcessStatus()); | |||
item.setInstCode(w.getInstCode()); | |||
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); | |||
item.setApprovedAmount(w.getApprovalAmount()); | |||
item.setApprovalDate(w.getApprovalDate()); | |||
item.setBuildCycle(StringUtils.isNotBlank(w.getBuildCycle()) ? | |||
Integer.valueOf(w.getBuildCycle()) : null); | |||
item.setPlanAcceptanceTime(w.getPlanAcceptanceTime()); | |||
return item; | |||
}); | |||
return PageVo.of(records, total); | |||
} | |||
public void exportList(HttpServletResponse response, ProjectListReq param) { | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | |||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | |||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(param); | |||
//待终验 | |||
query.eq(Project::getStatus,ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); | |||
query.eq(Project::getStage,ProjectStatusEnum.PROJECT_APPROVED.getCode()); | |||
query.eq(Project::getNewest,Boolean.TRUE); | |||
query.isNotNull(Project::getApprovalDate); | |||
query.isNotNull(Project::getBuildCycle); | |||
query.orderByAsc(Project::getApprovalDate); | |||
List<Project> records = projectService.list(query); | |||
AtomicInteger serialNumber = new AtomicInteger(0); | |||
List<DeclaredProjectExportDTO> collect = Lists.newArrayList(); | |||
if(CollUtil.isNotEmpty(records)){ | |||
collect = records.stream().map(r -> { | |||
DeclaredProjectExportDTO exportDTO = new DeclaredProjectExportDTO(); | |||
BeanUtils.copyProperties(r, exportDTO); | |||
exportDTO.setProjectTypeName(ProjectTypeEnum.getDesc(r.getProjectType())); | |||
exportDTO.setStatusName(ProjectStatusEnum.getDesc(r.getStatus())); | |||
String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); | |||
exportDTO.setCreateOn(createOnStr); | |||
exportDTO.setSerialNumber(serialNumber.incrementAndGet()); | |||
exportDTO.setPlanAcceptanceTime(Objects.nonNull(r.getPlanAcceptanceTime()) ? | |||
NdDateUtils.format(r.getPlanAcceptanceTime(), "yyyy-MM-dd") : StringUtils.EMPTY); | |||
return exportDTO; | |||
}).collect(Collectors.toList()); | |||
} | |||
String fileName = "待终验申请项目列表"; | |||
ExcelDownUtil.setFileName(fileName,response); | |||
//数据导出处理函数 | |||
try { | |||
EasyExcel.write(response.getOutputStream(), DeclaredProjectExportDTO.class) | |||
.autoCloseStream(false) | |||
.registerWriteHandler(ExcelExportStyle.formalStyle()) | |||
.sheet(fileName) | |||
.doWrite(collect); | |||
} catch (IOException e) { | |||
throw new RuntimeException(e); | |||
} catch (Exception e) { | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
/** | |||
* 延期申请 | |||
* @param dto | |||
* @return | |||
*/ | |||
public String delayedApply(DelayedApplyDTO dto) { | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | |||
String employeeCode = user.getEmployeeCode(); | |||
VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); | |||
Long projectId = dto.getProjectId(); | |||
Project project = projectService.getNewProject(projectId); | |||
VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); | |||
//首先要判断 项目当前状态 是不是 以终验 | |||
VUtils.isTrue(!ProjectStatusEnum.ACCEPTED.getCode().equals(project.getStatus()) || | |||
!ProjectStatusEnum.ARCHIVED.getCode().equals(project.getStage())) | |||
.throwMessage("提交失败 该项目不是 已归档"); | |||
VUtils.isTrue(project.getPlanAcceptanceTime().compareTo(LocalDateTime.now()) <= 0) | |||
.throwMessage("当前项目还未过期验收"); | |||
return "申请发起成功"; | |||
} | |||
} |
@@ -46,6 +46,7 @@ import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -86,9 +87,10 @@ public class FinalAcceptanceManage { | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | |||
VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); | |||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | |||
//待终验 | |||
//待终验 并且还未过期 | |||
query.eq(Project::getStatus,ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); | |||
query.eq(Project::getStage,ProjectStatusEnum.PROJECT_APPROVED.getCode()); | |||
query.ge(Project::getPlanAcceptanceTime, LocalDateTime.now()); | |||
query.eq(Project::getNewest,Boolean.TRUE); | |||
query.isNotNull(Project::getApprovalDate); | |||
query.isNotNull(Project::getBuildCycle); | |||
@@ -118,6 +120,7 @@ public class FinalAcceptanceManage { | |||
item.setApprovalDate(w.getApprovalDate()); | |||
item.setBuildCycle(StringUtils.isNotBlank(w.getBuildCycle()) ? | |||
Integer.valueOf(w.getBuildCycle()) : null); | |||
item.setPlanAcceptanceTime(w.getPlanAcceptanceTime()); | |||
return item; | |||
}); | |||
return PageVo.of(records, total); | |||
@@ -147,7 +150,8 @@ public class FinalAcceptanceManage { | |||
String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); | |||
exportDTO.setCreateOn(createOnStr); | |||
exportDTO.setSerialNumber(serialNumber.incrementAndGet()); | |||
exportDTO.setPlanAcceptanceTime(convertPlanAcceptanceTime(r)); | |||
exportDTO.setPlanAcceptanceTime(Objects.nonNull(r.getPlanAcceptanceTime()) ? | |||
NdDateUtils.format(r.getPlanAcceptanceTime(), "yyyy-MM-dd") : StringUtils.EMPTY); | |||
return exportDTO; | |||
}).collect(Collectors.toList()); | |||
} | |||
@@ -168,14 +172,6 @@ public class FinalAcceptanceManage { | |||
} | |||
} | |||
private String convertPlanAcceptanceTime(Project project) { | |||
if (Objects.nonNull(project.getApprovalDate()) && StringUtils.isNotBlank(project.getBuildCycle())) { | |||
Integer buidCycle = Integer.valueOf(project.getBuildCycle()); | |||
return NdDateUtils.format(project.getApprovalDate().plusMonths(buidCycle), "yyyy-MM-dd"); | |||
} | |||
return StringUtils.EMPTY; | |||
} | |||
public FinalAcceptanceVO detailByProjectId(Long projectId) { | |||
FinalAcceptanceVO vo = new FinalAcceptanceVO(); | |||
@@ -0,0 +1,33 @@ | |||
package com.ningdatech.pmapi.projectdeclared.model.dto; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @Classname DelayedApplyDTO | |||
* @Description | |||
* @Date 2023/5/30 15:35 | |||
* @Author PoffyZhang | |||
*/ | |||
@Data | |||
@ApiModel(value = "DelayedApplyDTO", description = "延期申请") | |||
public class DelayedApplyDTO { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty("项目ID") | |||
@NotNull(message = "项目ID不能为空") | |||
private Long projectId; | |||
@ApiModelProperty("延期时长 月") | |||
@NotNull(message = "请填写时长") | |||
private Integer delayedMonth; | |||
@ApiModelProperty("延期理由") | |||
private String delayedReason; | |||
@ApiModelProperty("佐证材料") | |||
private String supportingMaterials; | |||
} |
@@ -161,15 +161,26 @@ public class AnnualPlanLibManage { | |||
public void projectApproved(ProjectApprovedReq req) { | |||
Project project = projectService.getById(req.getProjectId()); | |||
stateMachine.pass(project); | |||
//计划出 计划验收时间 | |||
LocalDateTime planAcceptanceTime = getPlanAcceptanceTime(req); | |||
LambdaUpdateWrapper<Project> update = | |||
Wrappers.lambdaUpdate(Project.class).set(Project::getApprovalAmount, req.getApprovedAmount()) | |||
.set(Project::getApprovedFile, req.getApprovedFileId()).set(Project::getBuildCycle, req.getBuildCycle()) | |||
.set(Project::getApprovedConstructionPlanFile, req.getBuildPlanFileId()) | |||
.set(Project::getApprovalDate, req.getApprovedDate()).set(Project::getStatus, project.getStatus()) | |||
.set(Project::getStage, project.getStage()).eq(Project::getId, req.getProjectId()); | |||
.set(Project::getStage, project.getStage()) | |||
.set(Objects.nonNull(planAcceptanceTime),Project::getPlanAcceptanceTime,planAcceptanceTime) | |||
.eq(Project::getId, req.getProjectId()); | |||
projectService.update(update); | |||
} | |||
public LocalDateTime getPlanAcceptanceTime(ProjectApprovedReq req){ | |||
if (Objects.nonNull(req.getApprovedDate()) && Objects.nonNull(req.getBuildCycle())) { | |||
return req.getApprovedDate().plusMonths(req.getBuildCycle()); | |||
} | |||
return null; | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public void suspendAnnualPlan(ProjectIdReq req) { | |||
Project project = projectService.getById(req.getProjectId()); | |||
@@ -1,5 +1,6 @@ | |||
package com.ningdatech.pmapi.projectlib.model.entity; | |||
import com.alibaba.fastjson.annotation.JSONField; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
@@ -347,4 +348,7 @@ public class Project implements Serializable { | |||
@ApiModelProperty("合同总金额") | |||
private BigDecimal contractAmount; | |||
@ApiModelProperty("计划验收时间") | |||
private LocalDateTime planAcceptanceTime; | |||
} |
@@ -108,13 +108,6 @@ public class ProjectLibListItemVO { | |||
@JSONField(format = "yyyy-MM-dd") | |||
private LocalDateTime planAcceptanceTime; | |||
public LocalDateTime getPlanAcceptanceTime(){ | |||
if (Objects.nonNull(this.approvalDate) && Objects.nonNull(this.buildCycle)) { | |||
planAcceptanceTime = this.approvalDate.plusMonths(buildCycle); | |||
} | |||
return planAcceptanceTime; | |||
} | |||
public String getProjectTypeName() { | |||
if (Objects.nonNull(this.projectType)) { | |||
Optional.ofNullable(ProjectTypeEnum.getDesc(this.projectType)) | |||
@@ -18,9 +18,12 @@ import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import lombok.RequiredArgsConstructor; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.scheduling.annotation.Scheduled; | |||
import org.springframework.stereotype.Component; | |||
import java.net.InetAddress; | |||
import java.net.UnknownHostException; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
@@ -41,8 +44,16 @@ public class CommonLogTask { | |||
private final static String LOG_RECORD_ADDRESS = "/opt/log/"; | |||
private final static String LOG_ID_FILE = "logId.txt"; | |||
private final static String LOG_FILE = "common_log_"; | |||
@Value("${hostname}") | |||
private String HOST_NAME; | |||
@Scheduled(fixedDelay = 120000) | |||
public void writeLog(){ | |||
public void writeLog() throws UnknownHostException { | |||
// | |||
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | |||
return; | |||
} | |||
//获取记录ID文件 | |||
boolean idFileExist = FileUtil.exist(LOG_RECORD_ADDRESS + LOG_ID_FILE); | |||
if (!idFileExist){ | |||