新增记录审核记录 在已办流程需要

master
Harry Yang 2023-01-05 20:58:11 +08:00
parent f41c8ecf9c
commit b10654376d
4 changed files with 68 additions and 25 deletions

View File

@ -31,6 +31,7 @@ import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@ -101,7 +102,6 @@ import lombok.RequiredArgsConstructor;
public class ProcessController {
static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private final DeptRepository deptRepository;
private final ProjectRepository projectRepository;
private final ProjectBudgetService projectBudgetService;
@ -177,6 +177,10 @@ public class ProcessController {
*/
@GetMapping("/review")
public String review(Model model) {
Admin admin = getLoginUser();
// 超级管理员,只有查看权限,不能编辑和删除除非是自己的
model.addAttribute("adminId", admin.getId());
model.addAttribute("isAdmin", isAdministrator(admin));
model.addAttribute("processTypes", ProcessType.values());
return "/admin/business/process-review";
}
@ -673,7 +677,22 @@ public class ProcessController {
}, pageRequest);
}
else {
projectProcess.setApplyPersonId(loginUserId);
// 已办流程
return repository.findAll((root, query, cb) -> {
Predicate predicate = QueryByExamplePredicateBuilder.getPredicate(root, cb, Example.of(projectProcess, exampleMatcher));
// 添加新的条件
Predicate applyPersonId = cb.equal(root.get("applyPersonId"), loginUserId);
// 待自己审的
Expression<Integer> findInSet = cb.function("find_in_set", Integer.class, cb.literal(loginUserId), root.get("currentAuditId"));
Expression<Integer> reviewedIdFindInSet = cb.function("find_in_set", Integer.class, cb.literal(loginUserId), root.get("reviewedId"));
Predicate or = cb.or(applyPersonId,
cb.greaterThan(reviewedIdFindInSet, 0),
cb.greaterThan(findInSet, 0));
return cb.and(predicate, or);
}, pageRequest);
}
}
@ -702,11 +721,27 @@ public class ProcessController {
}
@ResponseBody
@Transactional
@PostMapping("/audit")
public void audit(@RequestBody @Valid AuditForm form) {
ProjectProcess process = repository.findOne(form.processId);
ProjectProcess process = obtainProjectProcess(form.processId);
ActApproveTypeEnum approveType = form.processStatus == ProcessStatus.audit_passed ? ActApproveTypeEnum.APPROVAL_PASSED :
ActApproveTypeEnum.APPROVAL_UN_PASS;
Admin admin = getLoginUser();
String reviewedId = process.getReviewedId();
ArrayList<String> reviewed = new ArrayList<>();
if (reviewedId != null) {
String[] split = reviewedId.split(",");
Collections.addAll(reviewed, split);
}
reviewed.add(String.valueOf(admin.getId()));
reviewedId = String.join(",", reviewed);
process.setReviewedId(reviewedId);
entityManager.merge(process);
// jdbcTemplate.update("update project_process set reviewed_id =? where id=?", reviewed, process.getId());
switch (process.getProcessType()) {
case procurement_contract:
projectInstanceService.completeTaskByProjectId(process.getId(), ActProjectTypeEnum.BUSINESS_PURCHASE, approveType, form.auditOpinion);

View File

@ -96,6 +96,9 @@ public class ProjectProcess implements Serializable {
// 当前审核人ID
private String currentAuditId;
// 当前审核人ID (逗号分割) find_in_set
private String reviewedId;
// 最后更新时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -4,27 +4,28 @@
create table project_process
(
id int auto_increment primary key comment 'ID',
apply_date date null comment '申请时间',
apply_dept varchar(255) null comment '申请部门(逗号分割)',
apply_dept_id varchar(255) null comment '申请部门ID(逗号分割)',
apply_dept_leader_id int null comment '申请部门领导ID',
apply_dept_leader_name varchar(255) null comment '申请人领导',
apply_person_name varchar(255) null comment '申请人姓名',
apply_person_id int null comment '申请人ID',
contract_name varchar(255) null comment '合同名称',
contract_no varchar(255) null comment '合同编号',
project_id int null comment '项目ID',
project_no varchar(255) null comment '项目编号',
project_title varchar(255) null comment '标题',
seal_types varchar(255) null comment '印章类型',
`status` varchar(255) null comment '流程状态',
tax_rate varchar(255) null comment '税率',
process_type varchar(255) null comment '流程类型',
remark text null comment '备注',
attachment_uri text null comment '附件 JSON Array',
apply_date date null comment '申请时间',
apply_dept varchar(255) null comment '申请部门(逗号分割)',
apply_dept_id varchar(255) null comment '申请部门ID(逗号分割)',
apply_dept_leader_id int null comment '申请部门领导ID',
apply_dept_leader_name varchar(255) null comment '申请人领导',
apply_person_name varchar(255) null comment '申请人姓名',
apply_person_id int null comment '申请人ID',
contract_name varchar(255) null comment '合同名称',
contract_no varchar(255) null comment '合同编号',
project_id int null comment '项目ID',
project_no varchar(255) null comment '项目编号',
project_title varchar(255) null comment '标题',
seal_types varchar(255) null comment '印章类型',
`status` varchar(255) null comment '流程状态',
tax_rate varchar(255) null comment '税率',
process_type varchar(255) null comment '流程类型',
remark text null comment '备注',
attachment_uri text null comment '附件 JSON Array',
current_audit varchar(255) null comment '当前审核人',
current_audit_id varchar(255) null comment '当前审核人ID逗号分割',
reviewed_id varchar(1024) null comment '审核过的人的ID',
current_audit varchar(255) null comment '当前审核人',
current_audit_id varchar(255) null comment '当前审核人ID逗号分割',
create_at datetime default CURRENT_TIMESTAMP comment '创建时间',
last_update_at datetime default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '最后更新时间'
@ -32,7 +33,7 @@ create table project_process
) comment '项目对应的流程';
alter table project_process
add apply_dept_leader_id int null comment '申请部门领导ID';
add reviewed_id varchar(1024) null comment '审核过的人的ID';
# 采购合同
create table procurement_contract

View File

@ -114,7 +114,11 @@
<el-table-column label="操作" fixed="right" width="140">
<template slot-scope="scope">
<el-button type="text" @click="showDetail(scope.row, scope)">查看详情</el-button>
<el-button type="text" @click="auditProcess(scope.row, scope)">审核</el-button>
<#if isAdmin>
<el-button type="text" @click="auditProcess(scope.row, scope)">审核</el-button>
<#else>
<el-button type="text" @click="auditProcess(scope.row, scope)">审核</el-button>
</#if>
</template>
</el-table-column>