feat(training): 完善培训申请审批流程功能
parent
fe8d01ed72
commit
9ee765bf4f
|
|
@ -33,7 +33,7 @@ import java.util.ArrayList;
|
|||
public class TrainingApplyProcessController {
|
||||
private final TrainingApplyProcessServiceI trainingApplyProcessService;
|
||||
|
||||
@ApiOperation("新增")
|
||||
@ApiOperation("新增(委托)")
|
||||
@PostMapping("/save")
|
||||
public SingleResponse<TrainingApplyProcessCO> add(@Validated @RequestBody TrainingApplyProcessAddCmd cmd) {
|
||||
SSOUser ssoUser = AuthContext.getCurrentUser();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.zcloud.edu.command.query.training;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.zcloud.edu.command.convertor.training.TrainingApplyProcessCoConvertor;
|
||||
import com.zcloud.edu.domain.enums.ApplyTypeEnum;
|
||||
import com.zcloud.edu.domain.model.training.TrainingApplyProcessNodeE;
|
||||
import com.zcloud.edu.dto.clientobject.training.FlowCO;
|
||||
import com.zcloud.edu.dto.clientobject.training.TrainingApplyProcessFlowVO;
|
||||
|
|
@ -9,7 +10,10 @@ import com.zcloud.edu.dto.clientobject.training.TrainingApplyProcessNodeCO;
|
|||
import com.zcloud.edu.dto.training.TrainingApplyProcessPageQry;
|
||||
import com.zcloud.edu.dto.clientobject.training.TrainingApplyProcessCO;
|
||||
import com.zcloud.edu.persistence.dataobject.TrainingApplyProcessDO;
|
||||
import com.zcloud.edu.persistence.dataobject.TrainingApplyRecordDO;
|
||||
import com.zcloud.edu.persistence.repository.training.TrainingApplyProcessRepository;
|
||||
import com.zcloud.edu.persistence.repository.training.TrainingApplyRecordRepository;
|
||||
import com.zcloud.gbscommon.utils.DateUtil;
|
||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||
import com.alibaba.cola.dto.PageResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -29,6 +33,7 @@ import java.util.stream.Collectors;
|
|||
public class TrainingApplyProcessQueryExe {
|
||||
private final TrainingApplyProcessRepository trainingApplyProcessRepository;
|
||||
private final TrainingApplyProcessCoConvertor trainingApplyProcessCoConvertor;
|
||||
private final TrainingApplyRecordRepository trainingApplyRecordRepository;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
|
|
@ -49,6 +54,7 @@ public class TrainingApplyProcessQueryExe {
|
|||
List<TrainingApplyProcessNodeE> processList =
|
||||
trainingApplyProcessRepository.getProcessNodeByRecordId(qry.getEqTrainingApplyRecordId());
|
||||
|
||||
TrainingApplyRecordDO byTrainingRecordId = trainingApplyRecordRepository.getByTrainingRecordId(qry.getEqTrainingApplyRecordId());
|
||||
List<FlowCO> flowList = Optional.ofNullable(processList).orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.map(e -> {
|
||||
|
|
@ -59,8 +65,10 @@ public class TrainingApplyProcessQueryExe {
|
|||
|
||||
String nodeName = e.getNodeName() == null ? "" : e.getNodeName();
|
||||
String username = e.getUsername() == null ? "" : e.getUsername();
|
||||
String time = e.getTime();
|
||||
|
||||
String time =null;
|
||||
if(e.getApplyType()!=null && ApplyTypeEnum.APPROVAL.getCode().equals(e.getApplyType().longValue())){
|
||||
time = byTrainingRecordId.getApprovalTime().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
String secondLine = StrUtil.isNotBlank(time) ? (username + " " + time) : username;
|
||||
item.setFlowList(Arrays.asList(nodeName, secondLine));
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ public class TrainingApplyRecordQueryExe {
|
|||
|
||||
|
||||
boolean isCorrectCorp = corpInfoRepository.checkCorp();
|
||||
//只有审批人和审批人的企业能进行审批
|
||||
examCenterCOS.forEach(info->{
|
||||
//只有审批人和审批人的企业能进行审批 ,暂时不用
|
||||
/* examCenterCOS.forEach(info->{
|
||||
//只有审批人和审批人的企业能进行审批 ,还有委托人
|
||||
boolean hasApprovalPermission;
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public class TrainingApplyRecordQueryExe {
|
|||
if (hasApprovalPermission) {
|
||||
info.setIsApproval(true);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
|
||||
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@ package com.zcloud.edu.command.training;
|
|||
|
||||
import com.zcloud.edu.domain.gateway.training.TrainingApplyProcessGateway;
|
||||
import com.zcloud.edu.domain.model.training.TrainingApplyProcessE;
|
||||
import com.zcloud.edu.domain.model.training.TrainingApplyProcessNodeE;
|
||||
import com.zcloud.edu.dto.training.TrainingApplyProcessAddCmd;
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.edu.persistence.dataobject.TrainingApplyProcessDO;
|
||||
import com.zcloud.edu.persistence.repository.training.TrainingApplyProcessRepository;
|
||||
import com.zcloud.edu.persistence.repository.training.TrainingApplyRecordRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -21,11 +26,20 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@AllArgsConstructor
|
||||
public class TrainingApplyProcessAddExe {
|
||||
private final TrainingApplyProcessGateway trainingApplyProcessGateway;
|
||||
private final TrainingApplyProcessRepository trainingApplyProcessRepository;
|
||||
private final TrainingApplyRecordRepository trainingApplyRecordRepository;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(TrainingApplyProcessAddCmd cmd) {
|
||||
TrainingApplyProcessE trainingApplyProcessE = new TrainingApplyProcessE();
|
||||
BeanUtils.copyProperties(cmd, trainingApplyProcessE);
|
||||
//将上一个没有审批时间的节点的审批时间设置为当前时间
|
||||
|
||||
List<TrainingApplyProcessDO> trainingApplyProcessDOList = trainingApplyProcessRepository.getApproveDetailList(cmd.getTrainingApplyRecordId());
|
||||
//获取ttrainingApplyProcessDOList 中按照创建时间最后一条数据,将审批时间设置为当前时间
|
||||
TrainingApplyProcessDO trainingApplyProcessDO = trainingApplyProcessDOList.stream().max((o1, o2) -> o1.getCreateTime().compareTo(o2.getCreateTime())).get();
|
||||
trainingApplyProcessDO.setApprovalTime(LocalDateTime.now());
|
||||
trainingApplyProcessRepository.updateById(trainingApplyProcessDO);
|
||||
boolean res = false;
|
||||
try {
|
||||
res = trainingApplyProcessGateway.add(trainingApplyProcessE);
|
||||
|
|
@ -35,6 +49,7 @@ public class TrainingApplyProcessAddExe {
|
|||
if (!res) {
|
||||
throw new BizException("保存失败");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,15 @@ import com.zcloud.edu.domain.gateway.training.TrainingApplyUserGateway;
|
|||
import com.zcloud.edu.domain.gateway.training.TrainingUserGateway;
|
||||
import com.zcloud.edu.domain.model.training.TrainingApplyRecordE;
|
||||
import com.zcloud.edu.dto.training.TrainingApplyRecordUpdateCmd;
|
||||
import com.zcloud.edu.persistence.dataobject.TrainingApplyProcessDO;
|
||||
import com.zcloud.edu.persistence.repository.training.TrainingApplyProcessRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* web-app
|
||||
|
|
@ -24,6 +27,7 @@ public class TrainingApplyRecordUpdateExe {
|
|||
private final TrainingApplyRecordGateway trainingApplyRecordGateway;
|
||||
private final TrainingApplyUserGateway trainingApplyUserGateway;
|
||||
private final TrainingUserGateway trainingUserGateway;
|
||||
private final TrainingApplyProcessRepository trainingApplyProcessRepository;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void execute(TrainingApplyRecordUpdateCmd trainingApplyRecordUpdateCmd) {
|
||||
|
|
@ -61,5 +65,14 @@ public class TrainingApplyRecordUpdateExe {
|
|||
if (!res) {
|
||||
throw new BizException("修改失败");
|
||||
}
|
||||
//修改最后一个的审批时间
|
||||
//将上一个没有审批时间的节点的审批时间设置为当前时间
|
||||
|
||||
List<TrainingApplyProcessDO> trainingApplyProcessDOList = trainingApplyProcessRepository.getApproveDetailList(oldTrainingRecord.getTrainingApplyRecordId());
|
||||
//获取ttrainingApplyProcessDOList 中按照创建时间最后一条数据,将审批时间设置为当前时间
|
||||
TrainingApplyProcessDO trainingApplyProcessDO = trainingApplyProcessDOList.stream().max((o1, o2) -> o1.getCreateTime().compareTo(o2.getCreateTime())).get();
|
||||
trainingApplyProcessDO.setApprovalTime(LocalDateTime.now());
|
||||
trainingApplyProcessRepository.updateById(trainingApplyProcessDO);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ import com.jjb.saas.framework.domain.model.BaseE;
|
|||
import com.zcloud.edu.domain.enums.ApplyTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* web-domain
|
||||
* @Author makejava
|
||||
|
|
@ -18,6 +20,8 @@ public class TrainingApplyProcessE extends BaseE {
|
|||
private String trainingApplyRecordId;
|
||||
//审批类型(1:发起,2:审批,3:委托)
|
||||
private Long applyType;
|
||||
|
||||
private LocalDateTime approvalTime;
|
||||
//手机号
|
||||
private String phone;
|
||||
//企业id
|
||||
|
|
@ -31,7 +35,7 @@ public class TrainingApplyProcessE extends BaseE {
|
|||
* 创建发起流程
|
||||
*/
|
||||
public static TrainingApplyProcessE createInitiate(
|
||||
String recordId, Long applyType, Long corpinfoId, Long departmentId, Long userId, String remarks) {
|
||||
String recordId, Long applyType, Long corpinfoId, Long departmentId, Long userId, String remarks,LocalDateTime approvalTime) {
|
||||
|
||||
TrainingApplyProcessE process = new TrainingApplyProcessE();
|
||||
process.setTrainingApplyProcessId(IdUtil.simpleUUID());
|
||||
|
|
@ -41,6 +45,9 @@ public class TrainingApplyProcessE extends BaseE {
|
|||
process.setDepartmentId(departmentId);
|
||||
process.setUserId(userId);
|
||||
process.setRemarks(remarks);
|
||||
if(approvalTime!= null){
|
||||
process.setApprovalTime(approvalTime);
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.zcloud.edu.domain.model.training;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class TrainingApplyProcessNodeE {
|
||||
|
||||
|
|
@ -18,10 +20,7 @@ public class TrainingApplyProcessNodeE {
|
|||
@ApiModelProperty(value = "审批类型")
|
||||
private Integer applyType;
|
||||
|
||||
@ApiModelProperty(value = "时间")
|
||||
private String time;
|
||||
|
||||
@ApiModelProperty(value = "审批时间")
|
||||
private String approvalTime;
|
||||
private LocalDateTime approvalTime;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ public class TrainingApplyRecordE extends BaseE {
|
|||
this.applyCorpinfoId,
|
||||
this.applyDepartmentId,
|
||||
this.applyUserId,
|
||||
"发起培训申请"
|
||||
"发起培训申请",
|
||||
LocalDateTime.now()
|
||||
);
|
||||
|
||||
this.processes.add(initiateProcess);
|
||||
|
|
@ -121,7 +122,8 @@ public class TrainingApplyRecordE extends BaseE {
|
|||
this.approvalCorpinfoId,
|
||||
this.approvalDepartmentId,
|
||||
this.approvalUserId,
|
||||
"审批中"
|
||||
"审批中",
|
||||
null
|
||||
);
|
||||
this.processes.add(process);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* web-infrastructure
|
||||
* @Author makejava
|
||||
|
|
@ -26,6 +28,8 @@ public class TrainingApplyProcessDO extends BaseDO {
|
|||
//审批类型(1:发起,2:审批,3:委托)
|
||||
@ApiModelProperty(value = "审批类型(1:发起,2:审批,3:委托)")
|
||||
private Long applyType;
|
||||
@ApiModelProperty(value = "审批时间")
|
||||
private LocalDateTime approvalTime;
|
||||
//手机号
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phone;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
tar.approval_status AS approvalStatus,
|
||||
u.name AS username,
|
||||
tap.apply_type AS applyType,
|
||||
DATE_FORMAT(tap.create_time, '%Y-%m-%d %H:%i:%s') AS time,
|
||||
DATE_FORMAT(tap.update_time, '%Y-%m-%d %H:%i:%s') as approvalTime
|
||||
<!-- DATE_FORMAT(tap.create_time, '%Y-%m-%d %H:%i:%s') AS time,-->
|
||||
DATE_FORMAT(tap.approval_time, '%Y-%m-%d %H:%i:%s') as approvalTime
|
||||
FROM
|
||||
training_apply_process tap
|
||||
LEFT JOIN
|
||||
|
|
|
|||
Loading…
Reference in New Issue