|
@@ -1,8 +1,9 @@
|
|
package org.jeecg.modules.activiti.web;
|
|
package org.jeecg.modules.activiti.web;
|
|
|
|
|
|
-import cn.hutool.core.map.MapUtil;
|
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
|
|
+import cn.com.ctop.common.module.utils.StatusCode;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.activiti.engine.RuntimeService;
|
|
import org.activiti.engine.RuntimeService;
|
|
@@ -19,13 +20,11 @@ import org.jeecg.modules.activiti.service.Impl.ActBusinessServiceImpl;
|
|
import org.jeecg.modules.activiti.service.Impl.ActZprocessServiceImpl;
|
|
import org.jeecg.modules.activiti.service.Impl.ActZprocessServiceImpl;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -52,27 +51,26 @@ public class ActBusinessController {
|
|
ISysBaseApi sysBaseAPI;
|
|
ISysBaseApi sysBaseAPI;
|
|
/*添加申请草稿状态*/
|
|
/*添加申请草稿状态*/
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
|
- public Result add(HttpServletRequest request){
|
|
|
|
- String procDefId = request.getParameter("procDefId");
|
|
|
|
- String procDeTitle = request.getParameter("procDeTitle");
|
|
|
|
- String tableName = request.getParameter("tableName");
|
|
|
|
- /*保存业务表单数据到数据库表*/
|
|
|
|
- String tableId = IdUtil.simpleUUID();
|
|
|
|
- actBusinessService.saveApplyForm(tableId,request);
|
|
|
|
|
|
+ public Result add(@RequestBody JSONObject data){
|
|
|
|
+ String procDefId = data.getString("procDefId");
|
|
|
|
+ String procDeTitle = data.getString("procDeTitle");
|
|
|
|
+ Long tableId = data.getLong("tableId");
|
|
|
|
+ String formText = data.getString("formText");
|
|
|
|
+
|
|
// 保存至我的申请业务
|
|
// 保存至我的申请业务
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
String username = sysUser.getUsername();
|
|
String username = sysUser.getUsername();
|
|
ActBusiness actBusiness = new ActBusiness();
|
|
ActBusiness actBusiness = new ActBusiness();
|
|
actBusiness.setUserId(username);
|
|
actBusiness.setUserId(username);
|
|
- actBusiness.setTableId(tableId);
|
|
|
|
|
|
+ actBusiness.setTableId(tableId+"");
|
|
actBusiness.setProcDefId(procDefId);
|
|
actBusiness.setProcDefId(procDefId);
|
|
- String title = request.getParameter(ActivitiConstant.titleKey);
|
|
|
|
|
|
+ String title = data.getString(ActivitiConstant.titleKey);
|
|
if (StrUtil.isNotBlank(title)){
|
|
if (StrUtil.isNotBlank(title)){
|
|
actBusiness.setTitle(title);
|
|
actBusiness.setTitle(title);
|
|
}else {
|
|
}else {
|
|
actBusiness.setTitle(procDeTitle);
|
|
actBusiness.setTitle(procDeTitle);
|
|
}
|
|
}
|
|
- actBusiness.setTableName(tableName);
|
|
|
|
|
|
+ actBusiness.setTableName(formText);
|
|
actBusinessService.save(actBusiness);
|
|
actBusinessService.save(actBusiness);
|
|
return Result.ok();
|
|
return Result.ok();
|
|
}
|
|
}
|
|
@@ -99,14 +97,11 @@ public class ActBusinessController {
|
|
/*通过id删除草稿状态申请*/
|
|
/*通过id删除草稿状态申请*/
|
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
|
|
public Result delByIds(String ids){
|
|
public Result delByIds(String ids){
|
|
-
|
|
|
|
for(String id : ids.split(",")){
|
|
for(String id : ids.split(",")){
|
|
ActBusiness actBusiness = actBusinessService.getById(id);
|
|
ActBusiness actBusiness = actBusinessService.getById(id);
|
|
- if(actBusiness.getStatus()!=ActivitiConstant.STATUS_TO_APPLY){
|
|
|
|
|
|
+ if(!actBusiness.getStatus().equals(ActivitiConstant.STATUS_TO_APPLY)){
|
|
return Result.error("删除失败, 仅能删除草稿状态的申请");
|
|
return Result.error("删除失败, 仅能删除草稿状态的申请");
|
|
}
|
|
}
|
|
- // 删除关联业务表
|
|
|
|
- actBusinessService.deleteBusiness(actBusiness.getTableName(), actBusiness.getTableId());
|
|
|
|
actBusinessService.removeById(id);
|
|
actBusinessService.removeById(id);
|
|
}
|
|
}
|
|
return Result.ok("删除成功");
|
|
return Result.ok("删除成功");
|
|
@@ -120,22 +115,13 @@ public class ActBusinessController {
|
|
return Result.error("actBusiness表中该id不存在");
|
|
return Result.error("actBusiness表中该id不存在");
|
|
}
|
|
}
|
|
String tableId = actBusiness.getTableId();
|
|
String tableId = actBusiness.getTableId();
|
|
- String tableName = actBusiness.getTableName();
|
|
|
|
act.setTableId(tableId);
|
|
act.setTableId(tableId);
|
|
- Map<String, Object> busiData = actBusinessService.getBaseMapper().getBusiData(tableId, tableName);
|
|
|
|
-
|
|
|
|
- if (MapUtil.isNotEmpty(busiData)&&busiData.get(ActivitiConstant.titleKey)!=null){
|
|
|
|
- //如果表单里有 标题 更新一下
|
|
|
|
- actBusiness.setTitle(busiData.get(ActivitiConstant.titleKey)+"");
|
|
|
|
- }
|
|
|
|
String processInstanceId = actZprocessService.startProcess(act);
|
|
String processInstanceId = actZprocessService.startProcess(act);
|
|
actBusiness.setProcInstId(processInstanceId);
|
|
actBusiness.setProcInstId(processInstanceId);
|
|
actBusiness.setStatus(ActivitiConstant.STATUS_DEALING);
|
|
actBusiness.setStatus(ActivitiConstant.STATUS_DEALING);
|
|
actBusiness.setResult(ActivitiConstant.RESULT_DEALING);
|
|
actBusiness.setResult(ActivitiConstant.RESULT_DEALING);
|
|
actBusiness.setApplyTime(new Date());
|
|
actBusiness.setApplyTime(new Date());
|
|
actBusinessService.updateById(actBusiness);
|
|
actBusinessService.updateById(actBusiness);
|
|
- //修改业务表的流程字段
|
|
|
|
- actBusinessService.updateBusinessStatus(actBusiness.getTableName(), actBusiness.getTableId(),"启动");
|
|
|
|
return Result.ok("操作成功");
|
|
return Result.ok("操作成功");
|
|
}
|
|
}
|
|
/*撤回申请*/
|
|
/*撤回申请*/
|
|
@@ -161,11 +147,22 @@ public class ActBusinessController {
|
|
public Result listData(ActBusiness param, HttpServletRequest request){
|
|
public Result listData(ActBusiness param, HttpServletRequest request){
|
|
LambdaQueryWrapper<ActBusiness> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ActBusiness> queryWrapper = new LambdaQueryWrapper<>();
|
|
queryWrapper.orderByDesc(ActBusiness::getCreateTime);
|
|
queryWrapper.orderByDesc(ActBusiness::getCreateTime);
|
|
- if (StrUtil.isNotBlank(param.getTitle())) queryWrapper.like(ActBusiness::getTitle,param.getTitle());
|
|
|
|
- if (param.getStatus()!=null) queryWrapper.eq(ActBusiness::getStatus,param.getStatus());
|
|
|
|
- if (param.getResult()!=null) queryWrapper.eq(ActBusiness::getResult,param.getResult());
|
|
|
|
- if (StrUtil.isNotBlank(request.getParameter("createTime_begin"))) queryWrapper.ge(ActBusiness::getTitle,param.getTitle());
|
|
|
|
- if (StrUtil.isNotBlank(request.getParameter("createTime_end"))) queryWrapper.le(ActBusiness::getTitle,param.getTitle());
|
|
|
|
|
|
+ if (StrUtil.isNotBlank(param.getTitle())) {
|
|
|
|
+ queryWrapper.like(ActBusiness::getTitle,param.getTitle());
|
|
|
|
+ }
|
|
|
|
+ if (param.getStatus()!=null){
|
|
|
|
+ queryWrapper.eq(ActBusiness::getStatus,param.getStatus());
|
|
|
|
+ }
|
|
|
|
+ if (param.getResult()!=null){
|
|
|
|
+ queryWrapper.eq(ActBusiness::getResult,param.getResult());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank(request.getParameter("createTime_begin"))) {
|
|
|
|
+ queryWrapper.ge(ActBusiness::getTitle,param.getTitle());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank(request.getParameter("createTime_end"))) {
|
|
|
|
+ queryWrapper.le(ActBusiness::getTitle,param.getTitle());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
queryWrapper.eq(ActBusiness::getUserId,loginUser.getUsername());
|
|
queryWrapper.eq(ActBusiness::getUserId,loginUser.getUsername());
|
|
@@ -194,4 +191,36 @@ public class ActBusinessController {
|
|
});
|
|
});
|
|
return Result.ok(actBusinessList);
|
|
return Result.ok(actBusinessList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @PostMapping("update")
|
|
|
|
+ public Map<String,Object>updateBusiness(@RequestBody JSONObject data){
|
|
|
|
+ Map<String,Object>result = new HashMap<>();
|
|
|
|
+ Long id = data.getLong("id");
|
|
|
|
+ String tableName = data.getString("tableName");
|
|
|
|
+ ActBusiness business = actBusinessService.getById(id);
|
|
|
|
+ if(null == business){
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ business.setTableName(tableName);
|
|
|
|
+ actBusinessService.updateById(business);
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("delete")
|
|
|
|
+ public Map<String,Object>delete(@RequestBody JSONObject data){
|
|
|
|
+ Map<String,Object>result = new HashMap<>();
|
|
|
|
+ Long id = data.getLong("id");
|
|
|
|
+ String tableName = data.getString("tableName");
|
|
|
|
+ ActBusiness business = actBusinessService.getById(id);
|
|
|
|
+ if(null == business){
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ business.setTableName(tableName);
|
|
|
|
+ actBusinessService.updateById(business);
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|