Merge remote-tracking branch 'origin/1.2.0' into 1.2.0
commit
3065c34964
|
@ -85,4 +85,19 @@ public class ActConstant {
|
|||
|
||||
public static final String KEY_PROJECT_ID = "projectId";
|
||||
public static final String KEY_PROJECT_TYPE = "projectType";
|
||||
|
||||
public static final String PROCESS_DEFKEY_SALE_CONTRACT = "saleContract";
|
||||
public static final String PROCESS_DEFKEY_BUSINESS_PURCHASE = "businessPurchase";
|
||||
|
||||
|
||||
//发起人部门主管
|
||||
public static final int CANDIDATE_TYPE_START_USER_LEADER = 1;
|
||||
|
||||
|
||||
//四算项目
|
||||
public static final int PROJECT_TYPE_FOURCAL = 0;
|
||||
//销售合同
|
||||
public static final int PROJECT_TYPE_SALE_CONTRACT = 1;
|
||||
//业务采购
|
||||
public static final int PROJECT_TYPE_BUSINESS_PURCHASE = 2;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.palmte.work.controller.backend;
|
|||
import cn.palmte.work.bean.ResponseMsg;
|
||||
import cn.palmte.work.config.Constant;
|
||||
import cn.palmte.work.model.Admin;
|
||||
import cn.palmte.work.model.Dept;
|
||||
import cn.palmte.work.model.DeptRepository;
|
||||
import cn.palmte.work.model.UserPositionRepository;
|
||||
import cn.palmte.work.pojo.ModifyPasswordRequest;
|
||||
|
@ -28,12 +29,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.jfunc.common.crypto.symmetric.DESAS;
|
||||
import top.jfunc.common.db.bean.Page;
|
||||
import top.jfunc.common.utils.CollectionUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -83,9 +87,18 @@ public class AccountController extends BaseController {
|
|||
setModel(keywords, model);
|
||||
ConcurrentHashMap<String, String> searchInfo = getSearchInfo(keywords, model);
|
||||
model.put("roleList", sysRoleService.getAllEnableSysRole());
|
||||
model.put("deptList", deptRepository.findAll());
|
||||
model.put("deptList", deptRepository.findFirstLevelDept());
|
||||
model.put("positionList", userPositionRepository.findAll());
|
||||
model.put("pager", accountService.list(searchInfo, pageNumber, pageSize));
|
||||
Page<Admin> page = accountService.list(searchInfo, pageNumber, pageSize);
|
||||
List<Admin> list = page.getList();
|
||||
if(CollectionUtil.isNotEmpty(list)){
|
||||
|
||||
int offset = (pageNumber - 1) * pageSize;
|
||||
for (int i = 0 , size = list.size(); i < size; i++) {
|
||||
list.get(i).setTempId(i+1 + offset);
|
||||
}
|
||||
}
|
||||
model.put("pager", page);
|
||||
return "/admin/account_list";
|
||||
}
|
||||
|
||||
|
@ -223,8 +236,8 @@ public class AccountController extends BaseController {
|
|||
public void export(@RequestParam(value = "keywords", required = false) String keywords, HttpServletResponse httpServletResponse) throws IOException {
|
||||
Map<String, String> searchInfo = getSearchInfo(keywords);
|
||||
downloadHeader(httpServletResponse, Utils.generateExcelName("人员信息"), "application/octet-stream");
|
||||
String[] headers = {"工号", "手机号码", "姓名", "常驻地", "一级部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
String[] exportColumns = {"userName", "telephone", "realName", "workLocation", "deptName", "directManager", "positionName", "roleName", "companyEmail"};
|
||||
String[] headers = {"四算系统登录账号", "手机号码", "姓名", "常驻地", "一级部门", "二级部门", "三级部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
String[] exportColumns = {"userName", "telephone", "realName", "workLocation", "deptFirstName", "deptSecondName", "deptThirdName", "directManager", "positionName", "roleName", "companyEmail"};
|
||||
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
|
||||
httpServletResponse.getOutputStream(), (pN, pS) -> accountService.list(searchInfo, pN, pS).getList());
|
||||
}
|
||||
|
@ -235,7 +248,7 @@ public class AccountController extends BaseController {
|
|||
@RequestMapping("/template")
|
||||
public void template(HttpServletResponse response) throws Exception {
|
||||
|
||||
String[] headers = new String[]{"工号", "手机号码", "姓名", "常驻地", "一级部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
String[] headers = new String[]{"四算系统登录账号", "手机号码", "姓名", "常驻地", "所属部门", "直接主管", "职位", "角色名称", "公司邮件地址"};
|
||||
downloadHeader(response, Utils.generateExcelName("人员信息批量导入模板"));
|
||||
ExportUtils exportUtils = new ExportUtils(headers);
|
||||
exportUtils.write(response.getOutputStream());
|
||||
|
|
|
@ -4,6 +4,7 @@ package cn.palmte.work.controller.backend;
|
|||
import cn.palmte.work.bean.ResponseMsg;
|
||||
import cn.palmte.work.service.ActModelService;
|
||||
|
||||
import cn.palmte.work.utils.ActUtil;
|
||||
import cn.palmte.work.utils.InterfaceUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -24,6 +25,9 @@ public class ActModelController extends BaseController {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActModelController.class);
|
||||
|
||||
@Autowired
|
||||
ActUtil actUtil;
|
||||
|
||||
@Autowired
|
||||
private ActModelService activitiModelService;
|
||||
|
||||
|
@ -45,9 +49,14 @@ public class ActModelController extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public String save(HttpServletRequest request) {
|
||||
public String save(HttpServletRequest request, Map<String, Object> model) {
|
||||
String procDefKey = request.getParameter("procDefKey");
|
||||
if (activitiModelService.findByProcDefKey(procDefKey) != null) {
|
||||
model.put("errorMessage", "流程标识已经存在!");
|
||||
return "/common/error";
|
||||
}
|
||||
try {
|
||||
activitiModelService.createModel(request.getParameter("procDefKey"), request.getParameter("modelName"));
|
||||
activitiModelService.createModel(procDefKey, request.getParameter("modelName"));
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ public class DepartmentController extends BaseController{
|
|||
@Autowired
|
||||
private DeptRepository deptRepository;
|
||||
|
||||
@Autowired
|
||||
private AdminRepository adminRepository;
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
* @param keywords
|
||||
|
@ -57,6 +60,8 @@ public class DepartmentController extends BaseController{
|
|||
}
|
||||
}
|
||||
model.put("pager", page);
|
||||
List<Dept> deptList = deptRepository.findEnableParent();
|
||||
model.put("parentList", deptList);
|
||||
return "/admin/department_list";
|
||||
}
|
||||
|
||||
|
@ -70,6 +75,10 @@ public class DepartmentController extends BaseController{
|
|||
Dept department = new Dept();
|
||||
model.put("deptId",-1);
|
||||
model.put("department",department);
|
||||
List<Admin> adminList = adminRepository.getAllEnableWoAdmin();
|
||||
model.put("userList", adminList);
|
||||
List<Dept> deptList = deptRepository.findEnableParent();
|
||||
model.put("parentList", deptList);
|
||||
return "/admin/department_input";
|
||||
}
|
||||
|
||||
|
@ -83,6 +92,10 @@ public class DepartmentController extends BaseController{
|
|||
Dept dept = deptRepository.findOne(id);
|
||||
model.put("deptId", id);
|
||||
model.put("department", dept);
|
||||
List<Admin> adminList = adminRepository.getAllEnableWoAdmin();
|
||||
model.put("userList", adminList);
|
||||
List<Dept> deptList = deptRepository.findEnableParent();
|
||||
model.put("parentList", deptList);
|
||||
return "/admin/department_input";
|
||||
}
|
||||
|
||||
|
@ -142,8 +155,8 @@ public class DepartmentController extends BaseController{
|
|||
public void export(@RequestParam(value = "keywords",required = false) String keywords, HttpServletResponse httpServletResponse) throws IOException {
|
||||
Map<String, String> searchInfo = getSearchInfo(keywords);
|
||||
downloadHeader(httpServletResponse , Utils.generateExcelName("部门表"), "application/octet-stream");
|
||||
String[] headers = {"部门名称","创建人","创建时间", "状态"};
|
||||
String[] exportColumns = {"name","createdBy","createdTime", "status"};
|
||||
String[] headers = {"部门名称", "部门领导", "所属上级", "创建人","创建时间", "状态"};
|
||||
String[] exportColumns = {"name", "realName", "parentName", "createdBy","createdTime", "status"};
|
||||
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
|
||||
httpServletResponse.getOutputStream(), (pN, pS) -> deptService.list(searchInfo, pN, pS).getList());
|
||||
}
|
||||
|
|
|
@ -69,16 +69,11 @@ public class ActTaskDef {
|
|||
|
||||
|
||||
/**
|
||||
* 审批通过执行的脚本 act_script(弃用)表id 弃用
|
||||
* 按类型查询
|
||||
*/
|
||||
@Column(name = "end_script")
|
||||
private int endScript;
|
||||
@Column(name = "candidate_types")
|
||||
private String candidateTypes;
|
||||
|
||||
/**
|
||||
* 审批驳回执行的脚本 act_script(弃用)表id 弃用
|
||||
*/
|
||||
@Column(name = "rollback_script")
|
||||
private int rollbackScript;
|
||||
|
||||
@Column(name = "created_time")
|
||||
private Date createdTime;
|
||||
|
@ -94,4 +89,7 @@ public class ActTaskDef {
|
|||
@Transient
|
||||
private List<String> candidateRoleList;
|
||||
|
||||
@Transient
|
||||
private List<String> candidateTypeList;
|
||||
|
||||
}
|
||||
|
|
|
@ -90,6 +90,18 @@ public class Admin{
|
|||
@Column(name = "company_email")
|
||||
private String companyEmail;
|
||||
|
||||
@Transient
|
||||
private Integer tempId;
|
||||
|
||||
@Transient
|
||||
private String deptFirstName;
|
||||
|
||||
@Transient
|
||||
private String deptSecondName;
|
||||
|
||||
@Transient
|
||||
private String deptThirdName;
|
||||
|
||||
public String getEmpCode() {
|
||||
return empCode;
|
||||
}
|
||||
|
@ -346,6 +358,35 @@ public class Admin{
|
|||
}
|
||||
|
||||
|
||||
public Integer getTempId() {
|
||||
return tempId;
|
||||
}
|
||||
|
||||
public void setTempId(Integer tempId) {
|
||||
this.tempId = tempId;
|
||||
}
|
||||
|
||||
public String getDeptFirstName() {
|
||||
return deptFirstName;
|
||||
}
|
||||
|
||||
public void setDeptFirstName(String deptFirstName) {
|
||||
this.deptFirstName = deptFirstName;
|
||||
}
|
||||
|
||||
public String getDeptSecondName() {
|
||||
return deptSecondName;
|
||||
}
|
||||
|
||||
public void setDeptSecondName(String deptSecondName) {
|
||||
this.deptSecondName = deptSecondName;
|
||||
}
|
||||
|
||||
public String getDeptThirdName() {
|
||||
return deptThirdName;
|
||||
}
|
||||
|
||||
public void setDeptThirdName(String deptThirdName) {
|
||||
this.deptThirdName = deptThirdName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public interface AdminRepository extends JpaRepository<Admin, Integer> {
|
|||
@Query("from Admin where isDeleted=0 AND enabled=1")
|
||||
List<Admin> getAllEnable();
|
||||
|
||||
@Query("from Admin where isDeleted=0 AND enabled=1 AND id>1")
|
||||
List<Admin> getAllEnableWoAdmin();
|
||||
|
||||
@Query("from Admin where isDeleted=0 AND enabled=1 AND roleId=?1")
|
||||
List<Admin> findByRoleId(int roleId);
|
||||
|
||||
|
|
|
@ -23,6 +23,14 @@ public class Dept {
|
|||
|
||||
private String name;
|
||||
|
||||
@Column(name = "manager_id")
|
||||
private Integer managerId = 0;
|
||||
|
||||
private Integer level;
|
||||
|
||||
@Column(name = "parent_id")
|
||||
private Integer parentId = 0;
|
||||
|
||||
private int enabled;
|
||||
|
||||
@Column(name = "created_by")
|
||||
|
@ -41,6 +49,12 @@ public class Dept {
|
|||
@Transient
|
||||
private String status;
|
||||
|
||||
@Transient
|
||||
private String realName;
|
||||
|
||||
@Transient
|
||||
private String parentName;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -57,6 +71,30 @@ public class Dept {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getManagerId() {
|
||||
return managerId;
|
||||
}
|
||||
|
||||
public void setManagerId(Integer managerId) {
|
||||
this.managerId = managerId;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public Integer getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Integer parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public int getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
@ -96,4 +134,20 @@ public class Dept {
|
|||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRealName() {
|
||||
return realName;
|
||||
}
|
||||
|
||||
public void setRealName(String realName) {
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,12 @@ public interface DeptRepository extends JpaRepository<Dept,Integer> {
|
|||
|
||||
Dept findByNameEquals(String name);
|
||||
|
||||
@Query(value = "select * from dept where level = 1", nativeQuery = true)
|
||||
List<Dept> findFirstLevelDept();
|
||||
|
||||
@Query(value = "select * from dept where enabled = 1", nativeQuery = true)
|
||||
List<Dept> findEnable();
|
||||
|
||||
@Query(value = "select * from dept where enabled = 1 and level <= 2", nativeQuery = true)
|
||||
List<Dept> findEnableParent();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ public class ProjectInstanceRelation {
|
|||
@Column(name = "project_id")
|
||||
private int projectId;
|
||||
|
||||
/**
|
||||
* 项目类型 0-四算项目 1-销售合同流程 2-业务采购流程
|
||||
*/
|
||||
@Column(name = "project_type")
|
||||
private int projectType = 0;
|
||||
|
||||
/**
|
||||
* 流程类型:estimate、budget、settle、final
|
||||
*/
|
||||
|
@ -77,4 +83,12 @@ public class ProjectInstanceRelation {
|
|||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getProjectType() {
|
||||
return projectType;
|
||||
}
|
||||
|
||||
public void setProjectType(int projectType) {
|
||||
this.projectType = projectType;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectInstanceRelationRepository extends JpaRepository<ProjectInstanceRelation,Integer> {
|
||||
/**
|
||||
* 根据项目id和类型找到流程实例id
|
||||
*/
|
||||
List<ProjectInstanceRelation> findAllByProjectIdEqualsAndProcessTypeEqualsOrderByCreateTimeDesc(int projectId, String processType);
|
||||
|
||||
@Query(value = "select * from project_instance_relation where project_id = ? and project_type=0 order by create_time desc", nativeQuery = true)
|
||||
List<ProjectInstanceRelation> findByProjectIdOrderByCreateTimeDesc(int projectId);
|
||||
|
||||
@Query(value = "select * from project_instance_relation where project_id = ? and project_type=? order by create_time desc limit 1", nativeQuery = true)
|
||||
ProjectInstanceRelation findByProjectIdAndProjectType(int projectId, int projectType);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ public class ProjectTaskRecord {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 项目类型 0-四算项目 1-销售合同流程 2-业务采购流程
|
||||
*/
|
||||
@Column(name = "project_type")
|
||||
private int projectType = 0;
|
||||
|
||||
@Column(name = "project_id")
|
||||
private int projectId;
|
||||
|
||||
|
|
|
@ -56,7 +56,10 @@ public class AccountService {
|
|||
}
|
||||
|
||||
public Page<Admin> list(Map<String, String> searchInfo, int pageNumber, int pageSize) {
|
||||
QueryHelper queryHelper = new QueryHelper("*", "sys_user u");
|
||||
QueryHelper queryHelper = new QueryHelper("u.*, (CASE d.level WHEN 1 THEN d.name WHEN 2 THEN d2.name ELSE d3.name END) AS deptFirstName, (CASE d.level WHEN 1 THEN '' WHEN 2 THEN d.name WHEN 3 THEN d2.name END) AS deptSecondName, (CASE d.level WHEN 3 THEN d.name ELSE '' END) AS deptThirdName", "sys_user u");
|
||||
queryHelper.leftJoin("dept d", "u.dept_id = d.id");
|
||||
queryHelper.leftJoin("dept d2", "d.parent_id = d2.id");
|
||||
queryHelper.leftJoin("dept d3", "d2.parent_id = d3.id");
|
||||
queryHelper.addCondition("u.is_deleted = 0");
|
||||
queryHelper.addCondition("u.id > 1");
|
||||
queryHelper.addCondition(searchInfo.containsKey("realName"), "u.real_name like ?", "%" +
|
||||
|
@ -198,18 +201,18 @@ public class AccountService {
|
|||
}
|
||||
|
||||
if (StringUtils.isEmpty(admin.getUserName())) {
|
||||
message = "工号不能为空!";
|
||||
message = "四算系统登录账号不能为空!";
|
||||
return message;
|
||||
}
|
||||
Admin existAdmin = adminRepository.getAdminByUsername(admin.getUserName());
|
||||
if (userId == -1) {
|
||||
if (existAdmin != null) {
|
||||
message = "该工号已存在!";
|
||||
message = "该四算系统登录账号已存在!";
|
||||
return message;
|
||||
}
|
||||
} else {
|
||||
if (existAdmin != null && existAdmin.getId() != userId) {
|
||||
message = "该工号已存在!";
|
||||
message = "该四算系统登录账号已存在!";
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
@ -295,15 +298,15 @@ public class AccountService {
|
|||
for (Map m : excelMap) {
|
||||
|
||||
try {
|
||||
Object empCode = m.get("工号");
|
||||
Object empCode = m.get("四算系统登录账号");
|
||||
if (empCode == null || StrKit.isBlank(empCode.toString())) {
|
||||
throw new Exception("工号不能为空");
|
||||
throw new Exception("四算系统登录账号不能为空");
|
||||
}
|
||||
|
||||
Admin byEmpCode = adminRepository.getAdminByUsername(empCode.toString());
|
||||
|
||||
if (null != byEmpCode) {
|
||||
throw new Exception("工号" + empCode.toString() + "已存在");
|
||||
throw new Exception("四算系统登录账号" + empCode.toString() + "已存在");
|
||||
}
|
||||
|
||||
Object telephone = m.get("手机号码");
|
||||
|
@ -341,15 +344,15 @@ public class AccountService {
|
|||
throw new Exception("常驻地不能为空");
|
||||
}
|
||||
|
||||
Object deptName = m.get("一级部门");
|
||||
Object deptName = m.get("所属部门");
|
||||
if (deptName == null || StrKit.isBlank(deptName.toString())) {
|
||||
throw new Exception("一级部门不能为空");
|
||||
throw new Exception("所属部门不能为空");
|
||||
}
|
||||
|
||||
Dept dept = deptRepository.findByNameEquals(deptName.toString());
|
||||
|
||||
if (null == dept) {
|
||||
throw new Exception("一级部门" + deptName.toString() + "不存在");
|
||||
throw new Exception("所属部门" + deptName.toString() + "不存在");
|
||||
}
|
||||
|
||||
Object directManager = m.get("直接主管");
|
||||
|
@ -472,4 +475,31 @@ public class AccountService {
|
|||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询部门主管(一级部门领导)
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public int getOneLevelDeptManagerId(int userId) {
|
||||
Admin admin = adminRepository.findOne(userId);
|
||||
Record record = getDept(admin.getDeptId());
|
||||
if (record == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1 != record.getInt("level")) {
|
||||
//不是一级 往上找
|
||||
record = getDept(record.getInt("parent_id"));
|
||||
}
|
||||
|
||||
return record.getInt("manager_id");
|
||||
}
|
||||
|
||||
private Record getDept(int deptId) {
|
||||
String sql = "SELECT level, manager_id, parent_id from dept where id=?";
|
||||
return pagination.findFirst(sql, deptId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,7 +48,7 @@ public class ActListenerService {
|
|||
* @param delegateTask
|
||||
* @throws Exception
|
||||
*/
|
||||
public void create(DelegateTask delegateTask) throws Exception {
|
||||
public void create(DelegateTask delegateTask) {
|
||||
String procInsId = delegateTask.getProcessInstanceId();
|
||||
logger.info("--节点创建后监听-- procInsId:{}, {}", procInsId, delegateTask);
|
||||
logger.info("**** rwcjjt【{}】任务创建监听 procInsId:{} **** ", delegateTask, procInsId);
|
||||
|
@ -58,44 +59,69 @@ public class ActListenerService {
|
|||
logger.info("**** rwcjjt 任务创建监听 查询候选人 procInsId:{},任务名称:{},候选人:{} **** ", procInsId, delegateTask.getName(), candidateUsers);
|
||||
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(procInsId).singleResult();
|
||||
updateProjectApprover(candidateUsers, processInstance, procDefId, taskDefKey);
|
||||
if (processInstance != null) {
|
||||
try {
|
||||
updateProjectApprover(candidateUsers, processInstance, procDefId, taskDefKey);
|
||||
} catch (Exception e) {
|
||||
logger.error("updateProjectApproverError", e);
|
||||
}
|
||||
}
|
||||
|
||||
delegateTask.addCandidateUsers(candidateUsers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新项目审批人 四算业务需要
|
||||
* 流程结束监听 更新项目状态为审批通过
|
||||
*
|
||||
* @param delegateExecution
|
||||
*/
|
||||
public void end(DelegateExecution delegateExecution) {
|
||||
String procInsId = delegateExecution.getProcessInstanceId();
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(procInsId).singleResult();
|
||||
int projectId = Integer.parseInt(processInstance.getBusinessKey());
|
||||
|
||||
String procDefId = processInstance.getProcessDefinitionId();
|
||||
if (actUtil.isNewProcess(procDefId)) {
|
||||
logger.info("**** lcjsjt 流程结束监听 更新项目状态为审批通过 **** procInsId:{}, procDefId:{}, projectId:{}", procInsId, procDefId, projectId);
|
||||
//todo updateNewProcess 更新项目状态为审批通过
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新项目审批人
|
||||
*
|
||||
* @param candidateUsers
|
||||
* @param processInstance
|
||||
*/
|
||||
private void updateProjectApprover(List<String> candidateUsers, ProcessInstance processInstance, String procDefId, String taskDefKey) {
|
||||
if (processInstance == null) {
|
||||
return;
|
||||
}
|
||||
private void updateProjectApprover(List<String> candidateUsers, ProcessInstance processInstance,
|
||||
String procDefId, String taskDefKey) {
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
ActTaskDef actTaskDef = actTaskDefService.findFirstByProcDefIdAndTaskKey(procDefId, taskDefKey);
|
||||
//找到当前有效的用户
|
||||
List<Integer> enableUsers = currentEnableUsers(candidateUsers);
|
||||
boolean isFirstUserTask = actTaskDef != null && actTaskDef.getTaskIndex() != ActConstant.TASK_INDEX_FIRST_USER_TASK;
|
||||
|
||||
try {
|
||||
String businessKey = processInstance.getBusinessKey();
|
||||
ActTaskDef actTaskDef = actTaskDefService.findFirstByProcDefIdAndTaskKey(procDefId, taskDefKey);
|
||||
int adminId = 0;
|
||||
if (!candidateUsers.isEmpty() && actTaskDef!=null && actTaskDef.getTaskIndex() != ActConstant.TASK_INDEX_FIRST_USER_TASK) {
|
||||
//回退到发起节点 审批人设置为空
|
||||
for (String id : candidateUsers) {
|
||||
Admin one = adminRepository.findOne(Integer.parseInt(id));
|
||||
if (!one.isDeleted() && one.getEnabled() == 1) {
|
||||
//找到有效账号 发送任务
|
||||
adminId = one.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (actUtil.isFourcalProcess(procDefId)) {
|
||||
int adminId = 0;//默认审批人设置为空
|
||||
if (!isFirstUserTask && !enableUsers.isEmpty()) {
|
||||
adminId = enableUsers.get(0);//四算项目只支持一个审批人
|
||||
}
|
||||
logger.info("**** rwcjjt 任务创建监听 更新审批人 procInsId:{}, projectId:{}, adminId:{} **** ",
|
||||
logger.info("**** rwcjjt 任务创建监听 更新审批人1 procInsId:{}, projectId:{}, adminId:{} **** ",
|
||||
processInstance.getProcessInstanceId(), businessKey, adminId);
|
||||
projectInstanceService.updateApprover(Integer.parseInt(businessKey), adminId);
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
} else if (actUtil.isNewProcess(procDefId)) {
|
||||
//todo updateNewProcess 更新流程审批人
|
||||
logger.info("**** rwcjjt 任务创建监听 更新审批2 procInsId:{}, projectId:{}, enableUsers:{} **** ",
|
||||
processInstance.getProcessInstanceId(), businessKey, enableUsers);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Integer> currentEnableUsers(List<String> candidateUsers) {
|
||||
return candidateUsers.stream().map(ele -> adminRepository.findOne(Integer.parseInt(ele)))
|
||||
.filter(ele -> !ele.isDeleted() && ele.getEnabled() == 1)
|
||||
.map(Admin::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.activiti.bpmn.model.*;
|
|||
import org.activiti.bpmn.model.Process;
|
||||
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.delegate.BaseExecutionListener;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.DeploymentBuilder;
|
||||
|
@ -55,6 +56,10 @@ public class ActModelService {
|
|||
return pagination.paginate(queryHelper.getSql(), ActModel.class, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
public ActModel findByProcDefKey(String procDefKey) {
|
||||
return pagination.findFirst("select * from act_re_model where KEY_=? ", ActModel.class, procDefKey);
|
||||
}
|
||||
|
||||
public void createModel(String processId, String modelName) throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ObjectNode editorNode = objectMapper.createObjectNode();
|
||||
|
@ -114,18 +119,13 @@ public class ActModelService {
|
|||
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
|
||||
BpmnModel model = jsonConverter.convertToBpmnModel(modelNode);
|
||||
|
||||
//任务创建后监听器
|
||||
ActivitiListener activitiListener = new ActivitiListener();
|
||||
activitiListener.setEvent(TaskListener.EVENTNAME_CREATE);
|
||||
activitiListener.setImplementation("${actListenerService.create(task)}");
|
||||
activitiListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
||||
List<ActivitiListener> activitiListenerList = new ArrayList<>(1);
|
||||
activitiListenerList.add(activitiListener);
|
||||
|
||||
List<ActTaskDef> taskList = new ArrayList<>();
|
||||
Process process = model.getMainProcess();
|
||||
Collection<FlowElement> flowElements = process.getFlowElements();
|
||||
|
||||
//设置流程监听器
|
||||
setExecutionListener(process);
|
||||
|
||||
int i = 0;
|
||||
ActTaskDef taskDef;
|
||||
ActTaskDef first = null;
|
||||
|
@ -139,16 +139,12 @@ public class ActModelService {
|
|||
|
||||
MultiInstanceLoopCharacteristics loopCharacteristics = userTaskElement.getLoopCharacteristics();
|
||||
if (loopCharacteristics != null) { //多实列
|
||||
loopCharacteristics.setInputDataItem("${actListenerService.getMultiCandidateUsers(execution)}");
|
||||
loopCharacteristics.setElementVariable("assignee");
|
||||
userTaskElement.setAssignee("${assignee}");
|
||||
|
||||
taskDef.setTaskType(ActConstant.TASK_TYPE_MULTI);
|
||||
}else {
|
||||
userTaskElement.setTaskListeners(activitiListenerList);
|
||||
|
||||
taskDef.setTaskType(ActConstant.TASK_TYPE_SINGE);
|
||||
}
|
||||
//任务监听器
|
||||
setTaskListener(userTaskElement);
|
||||
|
||||
if (i == 1) {//画流程图时,要保证第一个用户任务一定要先画
|
||||
taskDef.setTaskIndex(ActConstant.TASK_INDEX_FIRST_USER_TASK);
|
||||
|
@ -183,4 +179,24 @@ public class ActModelService {
|
|||
logger.info("deploy success: deploymentId:{}, procDefName:{}, procDefKey:{}", deployment.getId(), processDefinition.getName(), processDefinition.getKey());
|
||||
}
|
||||
|
||||
|
||||
private void setTaskListener(UserTask userTaskElement) {
|
||||
ActivitiListener taskListener = new ActivitiListener();
|
||||
taskListener.setEvent(TaskListener.EVENTNAME_CREATE);
|
||||
taskListener.setImplementation("${actListenerService.create(task)}");
|
||||
taskListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
||||
List<ActivitiListener> taskListenerList = new ArrayList<>(1);
|
||||
taskListenerList.add(taskListener);
|
||||
userTaskElement.setTaskListeners(taskListenerList);
|
||||
}
|
||||
|
||||
private void setExecutionListener(Process process) {
|
||||
ActivitiListener executionListener = new ActivitiListener();
|
||||
executionListener.setEvent(BaseExecutionListener.EVENTNAME_END);
|
||||
executionListener.setImplementation("${actListenerService.end(execution)}");
|
||||
executionListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
|
||||
List<ActivitiListener> executionListenerList = new ArrayList<>(1);
|
||||
executionListenerList.add(executionListener);
|
||||
process.setExecutionListeners(executionListenerList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ActProcDefService {
|
|||
QueryHelper queryHelper = new QueryHelper(select, " act_re_procdef p LEFT JOIN act_re_deployment d on p.DEPLOYMENT_ID_ = d.ID_");
|
||||
String name = searchInfo.get("name");
|
||||
queryHelper.addCondition(StringUtils.isNotEmpty(name), "(p.NAME_=? or p.KEY_=?)", name, name);
|
||||
queryHelper.addOrderProperty("p.VERSION_", false);
|
||||
queryHelper.addOrderProperty("d.DEPLOY_TIME_", false);
|
||||
return pagination.paginate(queryHelper.getSql(), ActProcDef.class, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import cn.palmte.work.utils.InterfaceUtil;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.activiti.engine.*;
|
||||
import org.activiti.engine.impl.identity.Authentication;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -99,6 +98,7 @@ public class ActTaskDefService {
|
|||
|
||||
/**
|
||||
* 预算跳过剩下审批任务直接到执行董事节点
|
||||
*
|
||||
* @param procInsId
|
||||
*/
|
||||
public ResponseMsg skipTaskByProcInsId(String procInsId, String fileUrl, String comment) {
|
||||
|
@ -176,8 +176,10 @@ public class ActTaskDefService {
|
|||
//审批通过
|
||||
taskService.complete(taskId);
|
||||
|
||||
//最后一个任务完成后 更新项目状态为审批通过
|
||||
updateProjectPassed(processInstance, actTaskDef, procDefKey);
|
||||
if (actUtil.isFourcalProcess(processInstance.getProcessDefinitionId())) {
|
||||
//四算项目 最后一个任务完成后 更新项目状态为审批通过 其他项目通过监听器更新
|
||||
updateProjectPassed(processInstance, actTaskDef, procDefKey);
|
||||
}
|
||||
} else if (ApproveStatusEnum.APPROVAL_UNPASS.getApproveStatus() == type) {
|
||||
//驳回
|
||||
String rollbackTaskKey = actTaskDef.getRollbackTaskKey();
|
||||
|
@ -185,7 +187,11 @@ public class ActTaskDefService {
|
|||
|
||||
//驳回后 更新项目状态为审批不通过
|
||||
int projectId = Integer.parseInt(processInstance.getBusinessKey());
|
||||
projectInstanceService.updateApproveStatus(projectId, procDefKey, ApproveStatusEnum.APPROVAL_UNPASS);
|
||||
if (actUtil.isFourcalProcess(processInstance.getProcessDefinitionId())) {
|
||||
projectInstanceService.updateApproveStatus(projectId, procDefKey, ApproveStatusEnum.APPROVAL_UNPASS);
|
||||
} else if (actUtil.isNewProcess(processInstance.getProcessDefinitionId())) {
|
||||
//todo updateNewProcess 更新流程状态为不通过
|
||||
}
|
||||
logger.info("updateProjectUnPassed projectId:{}, proDefKey:{}", projectId, procDefKey);
|
||||
|
||||
}
|
||||
|
@ -295,7 +301,8 @@ public class ActTaskDefService {
|
|||
ActTaskDef one = actTaskDefRepository.findOne(taskDef.getId());
|
||||
one.setCandidateUsers(taskDef.getCandidateUsers());
|
||||
one.setCandidateRoles(taskDef.getCandidateRoles());
|
||||
one.setRollbackTaskKey(taskDef.getRollbackTaskKey());
|
||||
one.setCandidateTypes(taskDef.getCandidateTypes());
|
||||
//one.setRollbackTaskKey(taskDef.getRollbackTaskKey());
|
||||
one.setLastUpdatedTime(new Date());
|
||||
|
||||
actTaskDefRepository.save(one);
|
||||
|
@ -341,11 +348,40 @@ public class ActTaskDefService {
|
|||
res.addAll(list);
|
||||
}
|
||||
|
||||
//通过特殊类型查询
|
||||
List<String> candidateTypeList = taskDef.getCandidateTypeList();
|
||||
logger.info("findCandidateUsers-type-task:{}, typeList:{}", taskDef.getTaskName(), candidateTypeList);
|
||||
List<String> userListByType = queryCandidatesByTypes(candidateRoleList, procInsId);
|
||||
logger.info("findCandidateUsers-type-task:{}, userListByType:{}", taskDef.getTaskName(), userListByType);
|
||||
if (!userListByType.isEmpty()) {
|
||||
res.addAll(userListByType);
|
||||
}
|
||||
|
||||
List<String> resList = new ArrayList<>(res);
|
||||
logger.info("findCandidateUsers-4-task:{}, resIds:{}", taskDef.getTaskName(), resList);
|
||||
return resList;
|
||||
}
|
||||
|
||||
private List<String> queryCandidatesByTypes(List<String> types, String procInsId) {
|
||||
if (types == null || types.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
for (String typeStr : types) {
|
||||
if (ActConstant.CANDIDATE_TYPE_START_USER_LEADER == Integer.parseInt(typeStr)) {
|
||||
//查找发起人部门主管
|
||||
String startUserId = actUtil.getStartUserId(procInsId);
|
||||
int leaderId = accountService.getOneLevelDeptManagerId(Integer.parseInt(startUserId));
|
||||
if (leaderId != 0) {
|
||||
userIdList.add(String.valueOf(leaderId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return userIdList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 任务审批人列表从sring转成list
|
||||
|
@ -366,6 +402,13 @@ public class ActTaskDefService {
|
|||
roleIdList = Arrays.asList(candidateRoles.split("#"));
|
||||
}
|
||||
actTaskDef.setCandidateRoleList(roleIdList);
|
||||
|
||||
String candidateTypes = actTaskDef.getCandidateTypes();
|
||||
List<String> typeIdList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(candidateTypes)) {
|
||||
typeIdList = Arrays.asList(candidateTypes.split("#"));
|
||||
}
|
||||
actTaskDef.setCandidateTypeList(typeIdList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,7 +452,7 @@ public class ActTaskDefService {
|
|||
//保存一条指定承接人记录
|
||||
projectTaskRecordService.saveTaskRecord(projectId, currentTask, ProjectTaskRecord.STATUS_RE_ASSIGNEE, ActConstant.TASK_INDEX_OTHER,
|
||||
"指定承接人【" + targetAdmin.getRealName() + "]");
|
||||
}else{
|
||||
} else {
|
||||
logger.error("setTaskAssignAndSaveRecordError task is null, projectId:{}", projectId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,14 +36,18 @@ public class DeptService {
|
|||
}
|
||||
|
||||
public Page<Dept> list(Map<String, String> searchInfo, int pageNumber, int pageSize){
|
||||
QueryHelper queryHelper = new QueryHelper("SELECT *, (CASE enabled WHEN 0 THEN '已禁用' WHEN 1 THEN '已启用' END) as status","dept");
|
||||
queryHelper.addCondition(searchInfo.containsKey("name"), "name like ?", "%" +
|
||||
QueryHelper queryHelper = new QueryHelper("SELECT d.*, (CASE d.enabled WHEN 0 THEN '已禁用' WHEN 1 THEN '已启用' END) as status, su.real_name as realName, (CASE WHEN d.level = 1 THEN '' ELSE p.name END) as parentName","dept d");
|
||||
queryHelper.leftJoin("dept p", "d.parent_id = p.id");
|
||||
queryHelper.leftJoin("sys_user su", "d.manager_id = su.id");
|
||||
queryHelper.addCondition(searchInfo.containsKey("name"), "d.name like ?", "%" +
|
||||
searchInfo.get("name") + "%");
|
||||
queryHelper.addCondition(searchInfo.containsKey("enabled") && !"-1".equals(searchInfo.get("enabled")),
|
||||
"enabled=" + searchInfo.get("enabled"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("startTime"), "created_time >= ?", searchInfo.get("startTime") + " 00:00:00");
|
||||
queryHelper.addCondition(searchInfo.containsKey("endTime"), "created_time <= ?", searchInfo.get("endTime") + " 23:59:59");
|
||||
queryHelper.addOrderProperty("created_time", false);
|
||||
"d.enabled=" + searchInfo.get("enabled"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("parentId") && !"-1".equals(searchInfo.get("parentId")),
|
||||
"d.parent_id=" + searchInfo.get("parentId"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("startTime"), "d.created_time >= ?", searchInfo.get("startTime") + " 00:00:00");
|
||||
queryHelper.addCondition(searchInfo.containsKey("endTime"), "d.created_time <= ?", searchInfo.get("endTime") + " 23:59:59");
|
||||
queryHelper.addOrderProperty("d.id", false);
|
||||
Page<Dept> paginate = pagination.paginate(queryHelper.getSql(), Dept.class, pageNumber, pageSize);
|
||||
return paginate;
|
||||
}
|
||||
|
@ -57,11 +61,27 @@ public class DeptService {
|
|||
if(null == obj){
|
||||
obj = new Dept();
|
||||
obj.setName(dept.getName());
|
||||
obj.setManagerId(dept.getManagerId());
|
||||
obj.setParentId(dept.getParentId());
|
||||
if (obj.getParentId() == 0) {
|
||||
obj.setLevel(0);
|
||||
} else {
|
||||
Dept one = deptRepository.findOne(obj.getParentId());
|
||||
obj.setLevel(one.getLevel() + 1);
|
||||
}
|
||||
obj.setEnabled(dept.getEnabled());
|
||||
obj.setCreatedBy(InterfaceUtil.getAdmin().getRealName());
|
||||
obj.setCreatedTime(new Date());
|
||||
}else {
|
||||
obj.setName(dept.getName());
|
||||
obj.setManagerId(dept.getManagerId());
|
||||
obj.setParentId(dept.getParentId());
|
||||
if (obj.getParentId() == 0) {
|
||||
obj.setLevel(0);
|
||||
} else {
|
||||
Dept one = deptRepository.findOne(obj.getParentId());
|
||||
obj.setLevel(one.getLevel() + 1);
|
||||
}
|
||||
obj.setEnabled(dept.getEnabled());
|
||||
}
|
||||
deptRepository.saveAndFlush(obj);
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
package cn.palmte.work.service;
|
||||
|
||||
import cn.palmte.work.bean.ApproveStatusEnum;
|
||||
import cn.palmte.work.bean.StatusEnum;
|
||||
import cn.palmte.work.config.activiti.ActConstant;
|
||||
import cn.palmte.work.model.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.jfunc.common.utils.CollectionUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiongshiyan at 2021/10/29 , contact me with email yanshixiong@126.com or phone 15208384257
|
||||
|
@ -30,6 +25,8 @@ public class ProjectInstanceService {
|
|||
private ActProcInsService actProcInsService;
|
||||
@Autowired
|
||||
private ProjectInstanceRelationRepository projectInstanceRelationRepository;
|
||||
@Autowired
|
||||
private ActTaskDefService actTaskDefService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -39,25 +36,12 @@ public class ProjectInstanceService {
|
|||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_ESTIMATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回概算的所有的实例id,没有则空集合
|
||||
*/
|
||||
public List<String> getEstimateProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_ESTIMATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个预算流程实例
|
||||
*/
|
||||
public void startBudgetProcessInstance(Project project, Admin admin) throws Exception {
|
||||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_BUDGET);
|
||||
}
|
||||
/**
|
||||
* 返回预算的所有的实例id,没有则空集合
|
||||
*/
|
||||
public List<String> getBudgetProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_BUDGET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个结算流程实例
|
||||
|
@ -65,12 +49,6 @@ public class ProjectInstanceService {
|
|||
public void startSettleProcessInstance(Project project, Admin admin) throws Exception {
|
||||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_SETTLE);
|
||||
}
|
||||
/**
|
||||
* 返回结算的所有的实例id,没有则空集合
|
||||
*/
|
||||
public List<String> getSettleProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_SETTLE);
|
||||
}
|
||||
/**
|
||||
* 开启一个决算流程实例
|
||||
*/
|
||||
|
@ -78,18 +56,87 @@ public class ProjectInstanceService {
|
|||
Project project = projectRepository.findOne(projectId);
|
||||
startProcess(project, admin, ActConstant.PROCESS_DEFKEY_FINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回决算的所有的实例id,没有则空集合
|
||||
* 发起销售合同流程实例
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param map 流程变量
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<String> getFinalProcessInsIds(Project project){
|
||||
return getApproveInstanceIds(project, ActConstant.PROCESS_DEFKEY_FINAL);
|
||||
public void startSaleContractProcess(int projectId, Map<String, Object> map) throws Exception {
|
||||
String processDefkey = ActConstant.PROCESS_DEFKEY_SALE_CONTRACT;
|
||||
String businessKey = String.valueOf(projectId);
|
||||
logger.info("startSaleContractProcess processDefkey:{}, businessKey:{}", processDefkey, businessKey);
|
||||
String processInstanceId = actProcInsService.startProcessInstance(processDefkey, businessKey, map);
|
||||
saveRelation(projectId, processDefkey, processInstanceId);
|
||||
|
||||
}
|
||||
private List<String> getApproveInstanceIds(Project project, String processDefkey) {
|
||||
List<ProjectInstanceRelation> all = projectInstanceRelationRepository.findAllByProjectIdEqualsAndProcessTypeEqualsOrderByCreateTimeDesc(project.getId(), processDefkey);
|
||||
if (CollectionUtil.isEmpty(all)) {
|
||||
return Collections.emptyList();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发起业务采购流程实例
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param map 流程变量
|
||||
* @throws Exception
|
||||
*/
|
||||
public void startBusinessPurchaseProcess(int projectId, Map<String, Object> map) throws Exception {
|
||||
String processDefkey = ActConstant.PROCESS_DEFKEY_BUSINESS_PURCHASE;
|
||||
String businessKey = String.valueOf(projectId);
|
||||
logger.info("startBusinessPurchaseProcess processDefkey:{}, businessKey:{}", processDefkey, businessKey);
|
||||
String processInstanceId = actProcInsService.startProcessInstance(processDefkey, businessKey, map);
|
||||
|
||||
//保存流程实例id与项目的关联关系
|
||||
saveRelation(projectId, processDefkey, processInstanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售合同流程 审批(通过或者不通过)
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param approveType 2-通过 3-不通过
|
||||
* @param message 审批意见
|
||||
* @return
|
||||
*/
|
||||
public boolean completeSaleContractTask(int projectId, int approveType, String message) {
|
||||
ProjectInstanceRelation projectInstance = projectInstanceRelationRepository.findByProjectIdAndProjectType(projectId, ActConstant.PROJECT_TYPE_SALE_CONTRACT);
|
||||
if (projectInstance == null) {
|
||||
return false;
|
||||
}
|
||||
return all.stream().map(ProjectInstanceRelation::getProcessInsId).collect(Collectors.toList());
|
||||
actTaskDefService.completeTaskByProcInsId(projectInstance.getProcessInsId(), approveType, message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 业务采购流程 审批(通过或者不通过)
|
||||
*
|
||||
* @param projectId 项目唯一id
|
||||
* @param approveType 2-通过 3-不通过
|
||||
* @param message 审批意见
|
||||
* @return
|
||||
*/
|
||||
public boolean completeBusinessPurchaseTask(int projectId, int approveType, String message) {
|
||||
ProjectInstanceRelation projectInstance = projectInstanceRelationRepository.findByProjectIdAndProjectType(projectId, ActConstant.PROJECT_TYPE_SALE_CONTRACT);
|
||||
if (projectInstance == null) {
|
||||
return false;
|
||||
}
|
||||
actTaskDefService.completeTaskByProcInsId(projectInstance.getProcessInsId(), approveType, message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void saveRelation(int projectId, String processDefkey, String processInstanceId) {
|
||||
//保存流程实例id与项目的关联关系
|
||||
ProjectInstanceRelation relation = new ProjectInstanceRelation();
|
||||
relation.setProjectId(projectId);
|
||||
relation.setProjectType(ActConstant.PROJECT_TYPE_SALE_CONTRACT);
|
||||
relation.setProcessType(processDefkey);
|
||||
relation.setProcessInsId(processInstanceId);
|
||||
relation.setCreateTime(new Date());
|
||||
projectInstanceRelationRepository.saveAndFlush(relation);
|
||||
}
|
||||
|
||||
private void startProcess(Project project, Admin admin, String processDefkey) throws Exception {
|
||||
|
|
|
@ -80,8 +80,17 @@ public class ProjectTaskRecordService {
|
|||
private ProjectTaskRecord getProjectTaskRecord(int projectId, Task task, int status, int taskIndex, String comment) {
|
||||
ProjectTaskRecord record = new ProjectTaskRecord();
|
||||
record.setProjectId(projectId);
|
||||
record.setProcDefId(task.getProcessDefinitionId());
|
||||
String procDefId = task.getProcessDefinitionId();
|
||||
record.setProcDefId(procDefId);
|
||||
record.setProcInsId(task.getProcessInstanceId());
|
||||
|
||||
int projectType = ActConstant.PROJECT_TYPE_FOURCAL;
|
||||
if (procDefId.startsWith(ActConstant.PROCESS_DEFKEY_SALE_CONTRACT)) {
|
||||
projectType = ActConstant.PROJECT_TYPE_SALE_CONTRACT;
|
||||
} else if (procDefId.startsWith(ActConstant.PROCESS_DEFKEY_BUSINESS_PURCHASE)) {
|
||||
projectType = ActConstant.PROJECT_TYPE_BUSINESS_PURCHASE;
|
||||
}
|
||||
record.setProjectType(projectType);
|
||||
record.setTaskDefKey(task.getTaskDefinitionKey());
|
||||
record.setTaskName(task.getName());
|
||||
record.setTaskComment(comment);
|
||||
|
|
|
@ -52,6 +52,19 @@ public class ActUtil {
|
|||
@Autowired
|
||||
private ProjectInstanceRelationRepository projectInstanceRelationRepository;
|
||||
|
||||
|
||||
public boolean isFourcalProcess(String procDefId) {
|
||||
return procDefId.startsWith(ActConstant.PROCESS_DEFKEY_ESTIMATE)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_BUDGET)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_SETTLE)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_FINAL);
|
||||
}
|
||||
|
||||
public boolean isNewProcess(String procDefId) {
|
||||
return procDefId.startsWith(ActConstant.PROCESS_DEFKEY_SALE_CONTRACT)
|
||||
|| procDefId.startsWith(ActConstant.PROCESS_DEFKEY_BUSINESS_PURCHASE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个节点间顺序
|
||||
*
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<div class="pull-right">
|
||||
<button type="button" class="btn" ng-click="close()" ng-disabled="status.loading" translate>ACTION.CANCEL</button>
|
||||
<button class="btn btn-primary" ng-click="saveAndClose()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE-AND-CLOSE</button>
|
||||
<!--<button class="btn btn-primary" ng-click="saveAndClose()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE-AND-CLOSE</button>-->
|
||||
<button class="btn btn-primary" ng-click="save()" ng-disabled="status.loading" ng-show="!error" translate>ACTION.SAVE</button>
|
||||
</div>
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -25,15 +25,15 @@
|
|||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
工号
|
||||
四算系统登录账号
|
||||
</div>
|
||||
<div class="am-u-sm-6 am-u-md-6">
|
||||
<input name="userName" class="js-ajax-validate"
|
||||
data-validate-async data-validation-message="请输入工号"
|
||||
data-validate-async data-validation-message="请输入四算系统登录账号"
|
||||
type="text" id="userName" value="${account.userName!}" minlength="1"
|
||||
maxlength="20"
|
||||
required <#if userId!=-1>readonly</#if>
|
||||
placeholder="请输入工号"/>
|
||||
placeholder="请输入四算系统登录账号"/>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
一级部门
|
||||
所属部门
|
||||
</div>
|
||||
<div class="am-u-sm-8 am-u-md-10">
|
||||
<select id="deptId" name="deptId"
|
||||
|
|
|
@ -142,11 +142,14 @@
|
|||
<table class="am-table am-table-striped am-table-hover table-main">
|
||||
<thead>
|
||||
<tr class="am-text-nowrap">
|
||||
<th class="table-title">工号</th>
|
||||
<th class="table-title">序号</th>
|
||||
<th class="table-title">四算系统登录账号</th>
|
||||
<th class="table-title">手机号码</th>
|
||||
<th class="table-title">姓名</th>
|
||||
<th class="table-title">常驻地</th>
|
||||
<th class="table-title">一级部门</th>
|
||||
<th class="table-title">二级部门</th>
|
||||
<th class="table-title">三级部门</th>
|
||||
<th class="table-title">直接主管</th>
|
||||
<th class="table-title">职位</th>
|
||||
<th class="table-title">角色名称</th>
|
||||
|
@ -157,11 +160,14 @@
|
|||
<tbody>
|
||||
<#list pager.list as list>
|
||||
<tr>
|
||||
<td>${list.tempId!}</td>
|
||||
<td>${list.userName!}</td>
|
||||
<td>${list.telephone!}</td>
|
||||
<td>${list.realName!}</td>
|
||||
<td>${list.workLocation!}</td>
|
||||
<td>${list.deptName!}</td>
|
||||
<td>${list.deptFirstName!}</td>
|
||||
<td>${list.deptSecondName!}</td>
|
||||
<td>${list.deptThirdName!}</td>
|
||||
<td>${list.directManager!}</td>
|
||||
<td>${list.positionName!}</td>
|
||||
<td>${list.roleName!}</td>
|
||||
|
|
|
@ -74,7 +74,9 @@
|
|||
<td>
|
||||
<div class="am-btn-toolbar">
|
||||
<div class="am-btn-group am-btn-group-xs">
|
||||
<#if userName! == 'admin'>
|
||||
<#if list.procDefKey == 'saleContract'
|
||||
|| list.procDefKey == 'businessPurchase'
|
||||
>
|
||||
<button type="button"
|
||||
class="am-btn am-btn-default am-btn-xs am-text-secondary"
|
||||
onclick="design(${list.id?c})" >
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
<tr class="am-text-nowrap">
|
||||
<th class="table-title">序号</th>
|
||||
<th class="table-title">任务节点名称</th>
|
||||
<th class="table-date">回退任务节点</th>
|
||||
<#-- <th class="table-date">回退任务节点</th>-->
|
||||
<th class="table-set ">按人员设置审批人</th>
|
||||
<th class="table-set ">按角色设置审批人</th>
|
||||
<th class="table-set ">按类型设置审批人</th>
|
||||
<th class="table-set am-text-center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -31,7 +32,7 @@
|
|||
<td>${list_index+1}</td>
|
||||
<td>${list.taskName!}</td>
|
||||
|
||||
<td>
|
||||
<#-- <td>
|
||||
|
||||
<select data-am-selected="{btnSize: 'sm',btnWidth: '150px', maxHeight: 500}"
|
||||
id="rollbackTask_${list.id}">
|
||||
|
@ -41,7 +42,7 @@
|
|||
</#list>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
</td>-->
|
||||
|
||||
<td>
|
||||
|
||||
|
@ -70,6 +71,16 @@
|
|||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
<select multiple
|
||||
data-am-selected="{btnSize: 'sm',btnWidth: '150px',maxHeight: 500,searchBox: 1}"
|
||||
id="typeSelect_${list.id}">
|
||||
<option value="1" <#if list.candidateTypeList?seq_contains('1')>selected</#if> >发起人部门主管</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
|
||||
|
@ -137,6 +148,16 @@
|
|||
}
|
||||
});
|
||||
|
||||
var $typeSelected = $("#typeSelect_" + taskId + " option:selected");
|
||||
var typeIds = '';
|
||||
$typeSelected.each(function () {
|
||||
if (typeIds == '') {
|
||||
typeIds = $(this).val();
|
||||
} else {
|
||||
typeIds = typeIds + "#" + $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
var params = {
|
||||
id: taskId,
|
||||
procDefId: $("#procDefId").val(),
|
||||
|
@ -144,7 +165,8 @@
|
|||
endScript: endScript,
|
||||
rollbackScript: rollbackScript,
|
||||
candidateUsers: userIds,
|
||||
candidateRoles: roleIds
|
||||
candidateRoles: roleIds,
|
||||
candidateTypes: typeIds
|
||||
};
|
||||
$.ajax({
|
||||
url: '${base}/actTaskDef/saveConfig',
|
||||
|
|
|
@ -33,6 +33,46 @@
|
|||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
||||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
所属上级
|
||||
</div>
|
||||
<div class="am-u-sm-8 am-u-md-10">
|
||||
<select id="parentId" name="parentId"
|
||||
data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}" required>
|
||||
<option value="0">无</option>
|
||||
<#if parentList??>
|
||||
<#list parentList as parent>
|
||||
<option value="${parent.id!}" <#if department.parentId == parent.id >
|
||||
selected </#if>>${parent.name}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
||||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>
|
||||
部门领导
|
||||
</div>
|
||||
<div class="am-u-sm-8 am-u-md-10">
|
||||
<select id="managerId" name="managerId"
|
||||
data-am-selected="{btnSize: 'sm',maxHeight: 200,searchBox: 1}" required>
|
||||
<option value="0">无</option>
|
||||
<#if userList??>
|
||||
<#list userList as user>
|
||||
<option value="${user.id!}" <#if department.managerId == user.id >
|
||||
selected </#if>>${user.realName}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
</div>
|
||||
|
||||
<div class="am-g am-form-group am-margin-top">
|
||||
<div class="am-u-sm-4 am-u-md-2 am-text-right">启用/禁用</div>
|
||||
|
||||
|
|
|
@ -33,10 +33,25 @@
|
|||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<th class="am-text-middle">所属上级</th>
|
||||
<td>
|
||||
<div class="am-u-sm-10">
|
||||
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="parentId">
|
||||
<option value="-1">全部</option>
|
||||
<option value="0" <#if parentId! == "0">selected</#if>>无</option>
|
||||
<#if parentList??>
|
||||
<#list parentList as parent>
|
||||
<option value="${parent.id!}" <#if parentId! == parent.id + "" >
|
||||
selected </#if>>${parent.name}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="am-text-middle">创建时间</th>
|
||||
<td>
|
||||
<td colspan="3">
|
||||
<div class="am-u-sm-10">
|
||||
<div class="am-form am-form-inline">
|
||||
<div class="am-form-group am-form-icon">
|
||||
|
@ -91,6 +106,8 @@
|
|||
<tr class="am-text-nowrap">
|
||||
<th class="table-title">序号</th>
|
||||
<th class="table-title">部门名称</th>
|
||||
<th class="table-title">部门领导</th>
|
||||
<th class="table-title">所属上级</th>
|
||||
<th class="table-title">创建人</th>
|
||||
<th class="table-title">创建时间</th>
|
||||
<th class="table-title">操作</th>
|
||||
|
@ -102,6 +119,8 @@
|
|||
<tr>
|
||||
<td>${list.tempId!}</td>
|
||||
<td>${list.name!}</td>
|
||||
<td>${list.realName!}</td>
|
||||
<td>${list.parentName!}</td>
|
||||
<td>${list.createdBy!}</td>
|
||||
<td><#if list.createdTime??>${list.createdTime?datetime}</#if></td>
|
||||
<td>
|
||||
|
@ -165,6 +184,8 @@
|
|||
keywordsObj.name = $("#name").val();
|
||||
if ($("#type").val())
|
||||
keywordsObj.type = $("#type").val();
|
||||
if ($("#parentId").val())
|
||||
keywordsObj.parentId = $("#parentId").val();
|
||||
if ($("#enabled").val())
|
||||
keywordsObj.enabled = $("#enabled").val();
|
||||
if ($("#startTime").val())
|
||||
|
|
Loading…
Reference in New Issue