|
@@ -10,13 +10,17 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
import com.ruoyi.project.apply.domain.TApplySafetychange;
|
|
|
import com.ruoyi.project.apply.service.ITApplySafetychangeService;
|
|
|
+import com.ruoyi.project.approve.damain.DevTask;
|
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
import com.ruoyi.project.system.service.ISysUserService;
|
|
|
+import org.activiti.engine.ProcessEngine;
|
|
|
+import org.activiti.engine.ProcessEngines;
|
|
|
import org.activiti.engine.RuntimeService;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.impl.identity.Authentication;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
|
+import org.activiti.engine.task.Task;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -34,8 +38,7 @@ import java.util.Map;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/apply/safetychange")
|
|
|
-public class TApplySafetychangeController extends BaseController
|
|
|
-{
|
|
|
+public class TApplySafetychangeController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITApplySafetychangeService tApplySafetychangeService;
|
|
|
|
|
@@ -54,8 +57,7 @@ public class TApplySafetychangeController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('apply:safetychange:list')")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(TApplySafetychange tApplySafetychange)
|
|
|
- {
|
|
|
+ public TableDataInfo list(TApplySafetychange tApplySafetychange) {
|
|
|
startPage();
|
|
|
List<TApplySafetychange> list = tApplySafetychangeService.selectTApplySafetychangeList(tApplySafetychange);
|
|
|
return getDataTable(list);
|
|
@@ -67,8 +69,7 @@ public class TApplySafetychangeController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('apply:safetychange:export')")
|
|
|
@Log(title = "组织保护措施状态变更申请", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(TApplySafetychange tApplySafetychange)
|
|
|
- {
|
|
|
+ public AjaxResult export(TApplySafetychange tApplySafetychange) {
|
|
|
List<TApplySafetychange> list = tApplySafetychangeService.selectTApplySafetychangeList(tApplySafetychange);
|
|
|
ExcelUtil<TApplySafetychange> util = new ExcelUtil<TApplySafetychange>(TApplySafetychange.class);
|
|
|
return util.exportExcel(list, "safetychange");
|
|
@@ -79,8 +80,7 @@ public class TApplySafetychangeController extends BaseController
|
|
|
*/
|
|
|
// @PreAuthorize("@ss.hasPermi('apply:safetychange:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return AjaxResult.success(tApplySafetychangeService.selectTApplySafetychangeById(id));
|
|
|
}
|
|
|
|
|
@@ -90,8 +90,7 @@ public class TApplySafetychangeController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('apply:safetychange:add')")
|
|
|
@Log(title = "组织保护措施状态变更申请", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody TApplySafetychange tApplySafetychange)
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody TApplySafetychange tApplySafetychange) {
|
|
|
String userId = getUserId().toString();
|
|
|
tApplySafetychange.setApplicant(userId);
|
|
|
tApplySafetychange.setApplicantName(getNickName());
|
|
@@ -100,16 +99,17 @@ public class TApplySafetychangeController extends BaseController
|
|
|
tApplySafetychange.setCreaterCode(getUserId().toString());
|
|
|
tApplySafetychange.setConfirmer(tApplySafetychange.getSafaer());
|
|
|
tApplySafetychange.setConfirmerName(tApplySafetychange.getSafaerName());
|
|
|
+ if(StringUtils.isNotEmpty(tApplySafetychange.getRemarks())&&(!tApplySafetychange.getRemarks().endsWith(";")||!tApplySafetychange.getRemarks().endsWith(";")))
|
|
|
+ tApplySafetychange.setRemarks(tApplySafetychange.getRemarks()+";");
|
|
|
tApplySafetychangeService.insertTApplySafetychange(tApplySafetychange);
|
|
|
|
|
|
// 开始申请流程
|
|
|
tApplySafetychange.setApNo(DateUtils.dateTimeNow() + userId);
|
|
|
long businessKey = tApplySafetychange.getId();
|
|
|
- String applyUser = userId;
|
|
|
//开始工作流、监听
|
|
|
- Authentication.setAuthenticatedUserId(applyUser);//设置当前申请人
|
|
|
+ Authentication.setAuthenticatedUserId(userId);//设置当前申请人
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
- variables.put("applyuser", applyUser);
|
|
|
+ variables.put("applyuser", userId);
|
|
|
variables.put("confirmer", tApplySafetychange.getConfirmer());
|
|
|
variables.put("executor", tApplySafetychange.getExecutor());
|
|
|
variables.put("safaer", tApplySafetychange.getSafaer());
|
|
@@ -143,14 +143,101 @@ public class TApplySafetychangeController extends BaseController
|
|
|
return toAjax(1);
|
|
|
}
|
|
|
|
|
|
+ @Log(title = "组织保护措施状态变更申请审核处理", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/handle")
|
|
|
+ public AjaxResult handle(@RequestBody DevTask devTask) {
|
|
|
+ TApplySafetychange form = devTask.getSafetychange();
|
|
|
+ //使用任务服务完成任务(提交任务)
|
|
|
+ String taskId = devTask.getTaskId();
|
|
|
+ // 使用任务id,获取任务对象,获取流程实例id
|
|
|
+ Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
|
+ //利用任务对象,获取流程实例id
|
|
|
+ String processInstancesId = task.getProcessInstanceId();
|
|
|
+ TApplySafetychange tApplySafetychange = tApplySafetychangeService.selectTApplySafetychangeById(form.getId());
|
|
|
+ String taskName = task.getName();//实例名
|
|
|
+ // 添加备注
|
|
|
+ String remarks = StringUtils.isEmpty(tApplySafetychange.getRemarks()) ? "" : tApplySafetychange.getRemarks();
|
|
|
+ if (taskName.contains("安全评估人")) {
|
|
|
+ taskName = "安全评估人";
|
|
|
+ }
|
|
|
+ //流程审批意见
|
|
|
+ String symbol = "";
|
|
|
+ String text = "";
|
|
|
+ if (StringUtils.isNotEmpty(form.getRemarks())) {
|
|
|
+ text = form.getRemarks();
|
|
|
+ symbol = ",";
|
|
|
+ form.setRemarks(remarks + taskName + "-" + getNickName() + ":" + form.getRemarks() + ";");
|
|
|
+ } else
|
|
|
+ form.setRemarks("");
|
|
|
+ // 判断流程
|
|
|
+ if ("1".equals(devTask.getCondition())) {
|
|
|
+ devTask.setComment("通过" + symbol + text);
|
|
|
+ } else if ("0".equals(devTask.getCondition())) {
|
|
|
+ devTask.setComment("拒绝" + symbol + text);
|
|
|
+ form.setStatus(1L);
|
|
|
+ form.setApproveStatus("3");
|
|
|
+ } else if ("2".equals(devTask.getCondition())) {
|
|
|
+ devTask.setComment("驳回" + symbol + text);
|
|
|
+ }
|
|
|
+ // 根据实例名判断当前流程节点
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ switch (task.getName()) {
|
|
|
+ case "安全评估人1":
|
|
|
+ form.setSafaTime(new Date());
|
|
|
+ break;
|
|
|
+ case "批准人":
|
|
|
+ form.setApprover(getUserId().toString());
|
|
|
+ form.setApproverName(getNickName());
|
|
|
+ form.setApproveTime(new Date());
|
|
|
+ if ("1".equals(devTask.getCondition()))
|
|
|
+ form.setApproveStatus("2");
|
|
|
+ break;
|
|
|
+ case "措施执行人":
|
|
|
+ form.setExecutionTime(new Date());
|
|
|
+ break;
|
|
|
+ case "措施确认人":
|
|
|
+ form.setConfirmTime(new Date());
|
|
|
+ break;
|
|
|
+ case "变更执行人":
|
|
|
+ form.setChangeExecutor(getUserId().toString());
|
|
|
+ form.setChangeExecutorName(getNickName());
|
|
|
+ form.setChangeExecutorTime(new Date());
|
|
|
+ break;
|
|
|
+ case "安全评估人2":
|
|
|
+ param.put("resetConfirmer1", form.getResetConfirmer1());
|
|
|
+ break;
|
|
|
+ case "确认人1":
|
|
|
+ param.put("resetConfirmer2", tApplySafetychange.getConfirmer());
|
|
|
+ form.setResetConfirmer1(getUserId().toString());
|
|
|
+ form.setResetConfirmTime1(new Date());
|
|
|
+ form.setResetConfirmerName1(getNickName());
|
|
|
+ break;
|
|
|
+ case "确认人2":
|
|
|
+ form.setResetConfirmer2(getUserId().toString());
|
|
|
+ form.setResetConfirmTime2(new Date());
|
|
|
+ form.setResetConfirmerName2(getNickName());
|
|
|
+ form.setStatus(1L);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ param.put("condition", devTask.getCondition());
|
|
|
+ ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
|
|
|
+ TaskService taskService = processEngine.getTaskService();
|
|
|
+ //认领任务
|
|
|
+ processEngine.getTaskService().claim(taskId, getUserId().toString());
|
|
|
+ taskService.addComment(taskId, processInstancesId, devTask.getComment());
|
|
|
+ taskService.complete(taskId, param);
|
|
|
+ // 更新任务
|
|
|
+ tApplySafetychangeService.updateTApplySafetychange(form);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改组织保护措施状态变更申请
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('apply:safetychange:edit')")
|
|
|
@Log(title = "组织保护措施状态变更申请", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody TApplySafetychange tApplySafetychange)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody TApplySafetychange tApplySafetychange) {
|
|
|
tApplySafetychange.setUpdatedate(new Date());
|
|
|
tApplySafetychange.setUpdaterCode(getUserId());
|
|
|
return toAjax(tApplySafetychangeService.updateTApplySafetychange(tApplySafetychange));
|
|
@@ -161,9 +248,8 @@ public class TApplySafetychangeController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('apply:safetychange:remove')")
|
|
|
@Log(title = "组织保护措施状态变更申请", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(tApplySafetychangeService.deleteTApplySafetychangeByIds(ids));
|
|
|
}
|
|
|
}
|