master
parent
00ad42b448
commit
fa29d77234
|
@ -5,6 +5,7 @@ import cn.palmte.work.model.*;
|
|||
import cn.palmte.work.service.ProjectBudgetService;
|
||||
import cn.palmte.work.service.ProjectEstimateService;
|
||||
import cn.palmte.work.service.ProjectService;
|
||||
import cn.palmte.work.service.ProjectTaskRecordService;
|
||||
import cn.palmte.work.utils.FreeMarkerUtil;
|
||||
import cn.palmte.work.utils.InterfaceUtil;
|
||||
import cn.palmte.work.utils.Utils;
|
||||
|
@ -19,10 +20,7 @@ import org.springframework.format.datetime.DateFormatter;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.jfunc.common.db.bean.Page;
|
||||
import top.jfunc.common.utils.CollectionUtil;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -48,6 +46,8 @@ public class ProjectController extends BaseController {
|
|||
private ProjectEstimateService projectEstimateService;
|
||||
@Autowired
|
||||
private ProjectBudgetService projectBudgetService;
|
||||
@Autowired
|
||||
private ProjectTaskRecordService projectTaskRecordService;
|
||||
|
||||
/**
|
||||
* 项目列表
|
||||
|
@ -372,6 +372,33 @@ public class ProjectController extends BaseController {
|
|||
return "admin/project_approve";
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批完成任务
|
||||
* @param projectId
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping("/completeTask/{projectId}")
|
||||
public ResponseMsg completeTask(@PathVariable int projectId, @RequestBody String json) {
|
||||
return projectService.completeTask(projectId, json);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看审核流程
|
||||
* @param projectId
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/taskRecords/{projectId}")
|
||||
public String taskRecords(@PathVariable int projectId, Map<String, Object> model) {
|
||||
List<ProjectTaskRecord> list = projectTaskRecordService.list(projectId);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
model.put("list", list);
|
||||
}
|
||||
return "admin/project_task_record_list";
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder webDataBinder) {
|
||||
|
|
|
@ -9,4 +9,6 @@ public interface ProjectInstanceRelationRepository extends JpaRepository<Project
|
|||
* 根据项目id和类型找到流程实例id
|
||||
*/
|
||||
List<ProjectInstanceRelation> findAllByProjectIdEqualsAndProcessTypeEqualsOrderByCreateTimeDesc(int projectId, String processType);
|
||||
|
||||
List<ProjectInstanceRelation> findByProjectIdOrderByCreateTimeDesc(int projectId);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package cn.palmte.work.service;
|
||||
|
||||
|
||||
import cn.palmte.work.bean.ApproveStatusEnum;
|
||||
import cn.palmte.work.config.activiti.ActConstant;
|
||||
import cn.palmte.work.utils.ActUtil;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -19,27 +14,15 @@ import java.util.*;
|
|||
@Service
|
||||
public class ActCallbackScript {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActCallbackScript.class);
|
||||
@Autowired
|
||||
private ActUtil actUtil;
|
||||
@Autowired
|
||||
private ProjectInstanceService projectInstanceService;
|
||||
|
||||
|
||||
/**
|
||||
* 更新流程审批通过
|
||||
* 示例
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void updateApproveStatus(Map map) {
|
||||
public void demo(Map map) {
|
||||
logger.info("--- updateApproveStatus--- : {} ", map);
|
||||
//String startUserId = (String) map.get(ActConstant.START_PROCESS_USERID);
|
||||
String procInsId = (String) map.get(ActConstant.PROC_INS_ID);
|
||||
String procDefKey = (String) map.get(ActConstant.PROC_DEF_KEY);
|
||||
logger.info(" updateApproveStatus procInsId:{}, procDefKey:{}", procInsId, procDefKey);
|
||||
|
||||
int projectId = actUtil.getProjectId(procInsId);
|
||||
if (projectId > 0) {
|
||||
projectInstanceService.updateApproveStatus(projectId, ApproveStatusEnum.APPROVAL_PASSED, procDefKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -98,9 +98,9 @@ public class ActTaskDefService {
|
|||
List<String> assignUserList;
|
||||
for (Task task : taskList) {
|
||||
assignUserList = actUtil.getAssignUserList(task.getId());
|
||||
if (assignUserList.contains(String.valueOf(adminId))) {
|
||||
completeTask(task.getId(), procInsId, comment, type);
|
||||
}
|
||||
//if (assignUserList.contains(String.valueOf(adminId))) {
|
||||
completeTask(task.getId(), procInsId, comment, type);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,6 +146,7 @@ public class ActTaskDefService {
|
|||
* @param actTaskDef
|
||||
*/
|
||||
private void handleSinge(ProcessInstance processInstance, String taskId, int type, ActTaskDef actTaskDef) {
|
||||
String procDefKey = actTaskDef.getProcDefKey();
|
||||
if (ApproveStatusEnum.APPROVAL_PASSED.getApproveStatus() == type) {
|
||||
//审批通过
|
||||
taskService.complete(taskId);
|
||||
|
@ -158,6 +159,10 @@ public class ActTaskDefService {
|
|||
logger.info("未配置审批通过脚本 task:{}", actTaskDef.getTaskName());
|
||||
}
|
||||
|
||||
if (actUtil.isProjectProcessIns(procDefKey)) {
|
||||
updateProjectPassed(processInstance, actTaskDef, procDefKey);
|
||||
}
|
||||
|
||||
} else if (ApproveStatusEnum.APPROVAL_UNPASS.getApproveStatus() == type) {
|
||||
//驳回
|
||||
String rollbackTaskKey = actTaskDef.getRollbackTaskKey();
|
||||
|
@ -172,12 +177,25 @@ public class ActTaskDefService {
|
|||
}
|
||||
|
||||
|
||||
if (actUtil.isProjectProcessIns(processInstance)) {
|
||||
projectInstanceService.updateApproveStatus(Integer.parseInt(processInstance.getBusinessKey()), ApproveStatusEnum.APPROVAL_UNPASS, actTaskDef.getProcDefKey());
|
||||
if (actUtil.isProjectProcessIns(procDefKey)) {
|
||||
projectInstanceService.updateApproveStatus(Integer.parseInt(processInstance.getBusinessKey()), ApproveStatusEnum.APPROVAL_UNPASS, procDefKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateProjectPassed(ProcessInstance processInstance, ActTaskDef actTaskDef, String procDefKey) {
|
||||
if (ActConstant.PROCESS_DEFKEY_FINAL.equals(procDefKey)) {
|
||||
if ("财务总监".equals(actTaskDef.getTaskName())) {
|
||||
projectInstanceService.updateApproveStatus(Integer.parseInt(processInstance.getBusinessKey()), ApproveStatusEnum.APPROVAL_PASSED, procDefKey);
|
||||
}
|
||||
} else {
|
||||
if ("执行董事".equals(actTaskDef.getTaskName())) {
|
||||
projectInstanceService.updateApproveStatus(Integer.parseInt(processInstance.getBusinessKey()), ApproveStatusEnum.APPROVAL_PASSED, procDefKey);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批过程任务查询
|
||||
*
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package cn.palmte.work.service;
|
||||
|
||||
import cn.palmte.work.bean.*;
|
||||
import cn.palmte.work.model.Admin;
|
||||
import cn.palmte.work.model.Project;
|
||||
import cn.palmte.work.model.ProjectRepository;
|
||||
import cn.palmte.work.model.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -34,6 +34,8 @@ public class ProjectService {
|
|||
private ProjectInstanceService projectInstanceService;
|
||||
@Autowired
|
||||
private ActTaskDefService actTaskDefService;
|
||||
@Autowired
|
||||
private ProjectInstanceRelationRepository projectInstanceRelationRepository;
|
||||
|
||||
|
||||
private QueryHelper getQueryHelper(Map<String, String> searchInfo, int pageNumber, int pageSize) {
|
||||
|
@ -278,4 +280,17 @@ public class ProjectService {
|
|||
projectBudgetService.saveBudget(p, budgetBean);
|
||||
return p;
|
||||
}
|
||||
|
||||
public ResponseMsg completeTask(int projectId, String json) {
|
||||
List<ProjectInstanceRelation> relationList = projectInstanceRelationRepository.findByProjectIdOrderByCreateTimeDesc(projectId);
|
||||
if (relationList == null || relationList.isEmpty()) {
|
||||
return ResponseMsg.buildFailedMsg("审核失败");
|
||||
}
|
||||
ProjectInstanceRelation projectInstanceRelation = relationList.get(0);
|
||||
JSONObject obj = JSON.parseObject(json);
|
||||
actTaskDefService.completeTaskByProcInsId(projectInstanceRelation.getProcessInsId(),
|
||||
obj.getIntValue("type"), obj.getString("message"));
|
||||
|
||||
return ResponseMsg.buildSuccessMsg("审核成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,14 +77,6 @@ public class ActUtil {
|
|||
return "0";
|
||||
}
|
||||
|
||||
public int getProjectId(String procInsId) {
|
||||
Record record = getVariable(ActConstant.KEY_PROJECT_ID, procInsId);
|
||||
if (record != null) {
|
||||
return Integer.valueOf(record.get("text"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取流程实列里的所有变量
|
||||
|
@ -257,6 +249,10 @@ public class ActUtil {
|
|||
}
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
|
||||
String procDefKey = processDefinition.getKey();
|
||||
return isProjectProcessIns(procDefKey);
|
||||
}
|
||||
|
||||
public boolean isProjectProcessIns(String procDefKey) {
|
||||
return procDefKey.equals(ActConstant.PROCESS_DEFKEY_ESTIMATE)
|
||||
|| procDefKey.equals(ActConstant.PROCESS_DEFKEY_BUDGET)
|
||||
|| procDefKey.equals(ActConstant.PROCESS_DEFKEY_SETTLE)
|
||||
|
|
|
@ -2004,10 +2004,10 @@
|
|||
|
||||
<div class="am-u-sm-12 am-u-md-4 switch-button" style="height: 25px;">
|
||||
<label class="am-radio-inline">
|
||||
<input type="radio" value="" name="docVlGender" required> 审核通过
|
||||
<input type="radio" value="2" name="docVlGender" required> 审核通过
|
||||
</label>
|
||||
<label class="am-radio-inline">
|
||||
<input type="radio" name="docVlGender"> 审核不通过
|
||||
<input type="radio" value="3" name="docVlGender"> 审核不通过
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
@ -2031,7 +2031,7 @@
|
|||
</div>
|
||||
<div class="am-modal-footer">
|
||||
<span class="am-modal-btn" data-am-modal-cancel>取消</span>
|
||||
<span class="am-modal-btn" data-am-modal-confirm>保存</span>
|
||||
<span class="am-modal-btn" data-am-modal-confirm onclick="completeTask('${project.id}')">确定</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2077,6 +2077,32 @@
|
|||
appendTrIncome();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var completeTask = function (projectId) {
|
||||
var message = $("#doc-vld-ta-2").val();
|
||||
var type = $("input[name='docVlGender']:checked").val();
|
||||
var params = {
|
||||
type: type,
|
||||
message: message
|
||||
};
|
||||
$.ajax({
|
||||
url: '${base}/project/completeTask/' + projectId,
|
||||
data: JSON.stringify(params),
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
type: 'post',
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data.status == 0) {
|
||||
alert(data.msg);
|
||||
window.location.href = '${base}/project/list';
|
||||
} else if (data.status == 1) {
|
||||
alert(data.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
@ -229,6 +229,13 @@
|
|||
onclick="location.href='${base}/project/approve?id=${list.id}'"><span
|
||||
class="am-icon-pencil-square-o"></span>审核
|
||||
</button>
|
||||
|
||||
<button type="button"
|
||||
class="am-btn am-btn-default am-btn-xs am-text-secondary"
|
||||
onclick="location.href='${base}/project/taskRecords/${list.id?c}'"><span
|
||||
class="am-icon-pencil-square-o"></span>查看审核流程
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<#assign base=request.contextPath />
|
||||
<#import "../common/defaultLayout.ftl" as defaultLayout>
|
||||
<@defaultLayout.layout>
|
||||
<link rel="stylesheet" type="text/css" href="${base}/common/css/time-axis.css">
|
||||
<div class="admin-content">
|
||||
<div class="am-cf am-padding" style="padding:1rem 1.6rem 1.6rem 1rem;margin:0px;">
|
||||
<!-- padding:1px 2px 3px 4px;上、右、下,和左 -->
|
||||
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">项目管理</strong> /
|
||||
<small>审核流程</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<ul class="time-axis">
|
||||
<#if list?exists >
|
||||
|
||||
<#list list as node>
|
||||
<li class="time-axis-item">
|
||||
<div class="time-axis-date" style="margin-left: -96px"> ${node.createTime} <span></span>
|
||||
</div>
|
||||
<div class="time-axis-title"> ${node.roleName}-${node.assigneeName}:
|
||||
<#if node.taskStatus==2>审批通过</#if>
|
||||
<#if node.taskStatus==3>审批不通过</#if>
|
||||
</div>
|
||||
<div class="time-axis-title">
|
||||
${node.taskComment}
|
||||
</div>
|
||||
</li>
|
||||
</#list>
|
||||
<#else>
|
||||
<div class="am-kai" align="center">
|
||||
<h3>没有找到任何记录!</h3>
|
||||
</div>
|
||||
</#if>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="am-margin">
|
||||
<button type="button" class="am-btn am-btn-warning am-btn-xs" onclick="javascript:history.go(-1);">
|
||||
返回上一级
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</@defaultLayout.layout>
|
||||
|
||||
<script type="text/javascript" src="${base}/assets/js/jquery-3.4.1.min.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue