diff --git a/db/jeecgboot-mysql-5.7.sql b/db/jeecgboot-mysql-5.7.sql index 82eaf1f..1f1755c 100644 --- a/db/jeecgboot-mysql-5.7.sql +++ b/db/jeecgboot-mysql-5.7.sql @@ -1,5 +1,5 @@ -CREATE database if NOT EXISTS `jeecg-boot` default character set utf8mb4 collate utf8mb4_general_ci; -USE `jeecg-boot`; +CREATE database if NOT EXISTS `guoyan_huozhou` default character set utf8mb4 collate utf8mb4_general_ci; +USE `guoyan_huozhou`; /* Navicat Premium Data Transfer diff --git a/huzhou/pom.xml b/huzhou/pom.xml index 2d8d7d0..c3c8cd5 100644 --- a/huzhou/pom.xml +++ b/huzhou/pom.xml @@ -17,6 +17,10 @@ org.jeecgframework.boot jeecg-boot-base-core + + org.jeecgframework.boot + jeecg-system-biz + org.activiti activiti-spring-boot-starter @@ -29,4 +33,16 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + + 9 + 9 + + + + \ No newline at end of file diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/common/HuzhouCommonUtils.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/common/HuzhouCommonUtils.java new file mode 100644 index 0000000..3ab14a3 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/common/HuzhouCommonUtils.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.huzhou.common; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +public class HuzhouCommonUtils { + public static List extractObjectAttributes(Object user) { + List attributes = new ArrayList<>(); + Class clazz = user.getClass(); + Method[] methods = clazz.getDeclaredMethods(); + + for (Method method : methods) { + try { + String name = method.getName(); + if (name.startsWith("get")) { // 假设所有的getter方法都不带参数,并且返回一个基本数据类型或其包装类 + Object value = method.invoke(user); + if (value != null) { // 过滤掉null值 + attributes.add(name.substring(3) + "=" + value); // 去掉"get"并添加等号和值 + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return attributes; + } +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouPlanController.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouPlanController.java new file mode 100644 index 0000000..3b32ac2 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouPlanController.java @@ -0,0 +1,148 @@ +package org.jeecg.modules.huzhou.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.commons.lang.StringUtils; +import org.checkerframework.checker.units.qual.A; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.huzhou.entity.*; +import org.jeecg.modules.huzhou.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@RestController +@RequestMapping("/huzhouPlan") +public class HuzhouPlanController { + @Autowired + private IHuzhouPlaninfoService planinfoService; + @Autowired + private IHuzhouPlanmoduleService planmoduleService; + @Autowired + private IHuzhouPlanmoduledetailService planmoduledetailService; + @Autowired + private IWorkflowService workflowService; + @Autowired + private IHuzhouProcessinfoService processinfoService; + @Autowired + private IHuzhouProjectinfoService projectinfoService; + @GetMapping("/queryPlanModulePage") + public Result> queryPlanModulePage(HuzhouPlanmodule planmodule,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + String moduleName = planmodule.getModuleName(); + String projectType = planmodule.getProjectType(); + queryWrapper.eq(StringUtils.isNotBlank(moduleName), HuzhouPlanmodule::getModuleName,moduleName) + .eq(StringUtils.isNotBlank(projectType),HuzhouPlanmodule::getProjectType,projectType); + Page planmodulePage = new Page<>(pageNo,pageSize); + + Page page = planmoduleService.page(planmodulePage, queryWrapper); + return Result.OK(page); + } + + @GetMapping("/queryPlanModuleone") + public Result queryPlanModuleByid(HuzhouPlanmodule planmodule){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + int planmoduleId = planmodule.getId(); + String projectType = planmodule.getProjectType(); + queryWrapper.eq(planmoduleId!=0,HuzhouPlanmodule::getId,planmoduleId) + .eq(StringUtils.isNotBlank(projectType),HuzhouPlanmodule::getProjectType,projectType); + HuzhouPlanmodule one = planmoduleService.getOne(queryWrapper); + return Result.OK(one); + } + @PostMapping("/savePlanModule") + public Result savePlanModule(@RequestBody HuzhouPlanmodule planmodule){ + String projectType = planmodule.getProjectType(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouPlanmodule::getProjectType,projectType); + int size = planmoduleService.list(queryWrapper).size(); + if(size>0){ + return Result.error("此项目类型已存在模板,无法新增"); + } + planmoduleService.save(planmodule); + return Result.ok("新增项目模板成功"); + } + @PostMapping("/modifyPlanModule") + public Result modifyPlanModule(@RequestBody HuzhouPlanmodule planmodule){ + String projectType = planmodule.getProjectType(); + int planmoduleId = planmodule.getId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouPlanmodule::getProjectType,projectType); + queryWrapper.ne(HuzhouPlanmodule::getId,planmoduleId); + int size = planmoduleService.list(queryWrapper).size(); + if(size>0){ + return Result.error("此项目类型已存在模板"); + } + planmoduleService.updateById(planmodule); + return Result.ok("修改项目模板成功"); + } + @DeleteMapping("/deletePlanModule") + public Result deletePlanModule(@RequestParam("id") Integer id){ + planmoduleService.removeById(id); + return Result.ok("删除项目模板成功"); + } + @GetMapping("/queryPlanModuleDetailPage") + public Result> queryPlanModuleDetailPage(HuzhouPlanmoduledetail planmoduledetail){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + String moduleId = planmoduledetail.getModuleId(); + queryWrapper.eq(StringUtils.isNotBlank(moduleId), HuzhouPlanmoduledetail::getModuleId,moduleId); + List list = planmoduledetailService.list(queryWrapper); + return Result.OK(list); + } + @PostMapping("/savePlanModuleDatail") + public Result savePlanModuleDatail(@RequestBody() List planmoduledetails){ + //先删除后增加 + String moduleId = planmoduledetails.get(0).getModuleId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouPlanmoduledetail::getModuleId,moduleId); + boolean remove = planmoduledetailService.remove(queryWrapper); + for (HuzhouPlanmoduledetail p:planmoduledetails + ) { + planmoduledetailService.save(p); + } + return Result.ok("新增项目模板成功"); + } + @PostMapping("/saveProjectPlan") + public Result saveProjectPlan(@RequestBody List planinfos){ + if(planinfos.size()==0){ + return Result.error("数量为0"); + } + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752895307869614081"); + arrayList.add("1752895591849160705"); + WorkFlow workFlow = workflowService.createFlow("项目计划审批流程", arrayList); + String processInstanceId = workFlow.getProcessInstanceId(); + String businessKey = workFlow.getBusinessKey(); + planinfos.forEach(item->{ + planinfoService.save(item); + }); + String projectId = planinfos.get(0).getProjectId(); + //保存项目信息 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"5");//3表示项目资料流程审批阶段 + updateWrapper.eq(HuzhouProjectinfo::getId,projectId); + projectinfoService.update(null,updateWrapper); + HuzhouProcessinfo huzhouProcessinfo = new HuzhouProcessinfo(); + huzhouProcessinfo.setBusinesskey(businessKey); + huzhouProcessinfo.setStatus("3");//该项目的第一个流程 + huzhouProcessinfo.setProcessinstanceid(processInstanceId); + huzhouProcessinfo.setProjectid(projectId); + processinfoService.save(huzhouProcessinfo); + return Result.OK("保存成功"); + } + @GetMapping("/queryProjectPlan") + public Result< List> queryProjectPlan(HuzhouPlaninfo planinfo){ + String projectId = planinfo.getProjectId(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotBlank(projectId),HuzhouPlaninfo::getProjectId,projectId); + queryWrapper.orderByAsc(HuzhouPlaninfo::getOrderNumber); + List list = planinfoService.list(queryWrapper); + return Result.OK(list); + } +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouProjectController.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouProjectController.java new file mode 100644 index 0000000..518cf0e --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouProjectController.java @@ -0,0 +1,396 @@ +package org.jeecg.modules.huzhou.controller; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.activiti.bpmn.model.BpmnModel; +import org.activiti.bpmn.model.FlowElement; +import org.activiti.bpmn.model.SequenceFlow; +import org.activiti.bpmn.model.UserTask; +import org.activiti.engine.*; + +import org.activiti.engine.impl.identity.Authentication; + +import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.Task; +import org.apache.commons.beanutils.BeanMap; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.checkerframework.checker.units.qual.A; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.SymbolConstant; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.common.util.CommonUtils; +import org.jeecg.modules.huzhou.common.HuzhouCommonUtils; +import org.jeecg.modules.huzhou.entity.*; +import org.jeecg.modules.huzhou.service.*; +import org.jeecg.modules.huzhou.vo.ProjectApproveOV; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.core.parameters.P; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.FileCopyUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.*; + +@RestController +@RequestMapping("/huzhouProject") +public class HuzhouProjectController { + @Autowired + private RuntimeService runtimeService; + @Autowired + private TaskService taskService; + @Autowired + private RepositoryService repositoryService; + @Autowired + private HistoryService historyService; + + @Autowired + private IWorkflowService workflowService; + @Autowired + private IHuzhouProcessinfoService processinfoService; + @Autowired + private IHuzhouProjectinfoService projectinfoService; + @Autowired + private IHuzhouUserprojectService userprojectService; + @Autowired + private IHuzhouUploadfileinfoService uploadfileinfoService; + @Value(value = "${jeecg.path.upload}") + private String uploadpath; + @Autowired + private ISysUserService userService; + /** + * 本地:local minio:minio 阿里:alioss + */ + @Value(value="${jeecg.uploadType}") + private String uploadType; + @PostMapping("/submitProject") + public Result submitProject(@RequestBody HuzhouProjectinfo info){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752895307869614081"); + arrayList.add("1752895591849160705"); + WorkFlow workFlow = workflowService.createFlow("initiatesProjects", arrayList); + String processInstanceId = workFlow.getProcessInstanceId(); + String businessKey = workFlow.getBusinessKey(); + //保存项目信息 + info.setStatus("1");//最开始的状态 + projectinfoService.save(info); + //保存项目流程相关的信息 + //设置businessKey + //设置项目状态 + //新增项目人员关系表 + List extractObjectAttributes = HuzhouCommonUtils.extractObjectAttributes(info); + for (String s:extractObjectAttributes) { + if(s.contains("Contactor")){ + String s1 = s.split("=")[1]; + HuzhouUserproject huzhouUserproject = new HuzhouUserproject(); + huzhouUserproject.setProjectId(info.getId()); + huzhouUserproject.setUserId(s1); + userprojectService.save(huzhouUserproject); + } + } + HuzhouProcessinfo huzhouProcessinfo = new HuzhouProcessinfo(); + huzhouProcessinfo.setBusinesskey(businessKey); + huzhouProcessinfo.setStatus("1");//该项目的第一个流程 + huzhouProcessinfo.setProcessinstanceid(processInstanceId); + huzhouProcessinfo.setProjectid(info.getId()); + processinfoService.save(huzhouProcessinfo); + return Result.ok("项目入库申请已发起成功"); + } + @PostMapping("/approveProjectInfo") + public Result approveProjectInfo(@RequestBody HashMap param){ + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + String taskId = (String) param.get("taskId"); + String flag = (String) param.get("flag"); + String comment = (String) param.get("comment"); + String projectid = (String) param.get("projectid"); + String status = (String) param.get("status"); + String isEdit = (String) param.get("isEdit"); + Map projectInfoMap = (Map) param.get("projectInfo"); + String jsonString = JSON.toJSONString(projectInfoMap); + HuzhouProjectinfo projectinfo = JSON.parseObject(jsonString, HuzhouProjectinfo.class); + if("3".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"0");//表示作废 + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + return Result.OK("流程作废成功"); + } + if("1".equals(isEdit)&&"1".equals(flag)&&"1".equals(status)){ + if(null!=projectinfo){ + projectinfoService.updateById(projectinfo); + //删除此项目原来的人员和项目对应信息 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouUserproject::getProjectId,projectid); + boolean remove = userprojectService.remove(queryWrapper); + //保存新的人员和项目对应信息 + List extractObjectAttributes = HuzhouCommonUtils.extractObjectAttributes(projectinfo); + for (String s:extractObjectAttributes) { + if(s.contains("Contactor")){ + String s1 = s.split("=")[1]; + HuzhouUserproject huzhouUserproject = new HuzhouUserproject(); + huzhouUserproject.setProjectId(projectinfo.getId()); + huzhouUserproject.setUserId(s1); + userprojectService.save(huzhouUserproject); + } + } + } + } + WorkFlow workFlow = workflowService.approveProjectInfo(taskId, flag, comment, status); + String userTaskName = workFlow.getUserTask(); + + //管理单位审批通过,最后一个节点流程通过 + if("管理单位审批".equals(userTaskName)&&"1".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"2"); + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + } + if("流程审批二".equals(userTaskName)&&"1".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"4"); + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + } + if("计划审批二".equals(userTaskName)&&"1".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"6"); + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + } + return Result.ok("审批成功"); + } + @PostMapping("/approveUploadFile") + public Result approveUploadFile(@RequestParam(value = "file",required = false) MultipartFile[] file, + @RequestParam String taskId, + @RequestParam String flag, + @RequestParam String projectid, + @RequestParam String comment, + @RequestParam String status) throws IOException { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + + + WorkFlow workFlow = workflowService.approveProjectInfo(taskId, flag, comment, status); + String userTaskName = workFlow.getUserTask(); + if("发起人".equals(workFlow.getUserTask())&&null != file){ + uploadfileinfoService.modifyUploadFile(file,projectid,status); + } + //管理单位审批通过,最后一个节点流程通过 + if("管理单位审批".equals(userTaskName)&&"1".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"2"); + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + } + if("流程审批二".equals(userTaskName)&&"1".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"4"); + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + } + if("计划审批二".equals(userTaskName)&&"1".equals(flag)){ + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"6"); + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(updateWrapper); + } + return Result.ok("审批成功"); + } + @PostMapping("/deleteProcesss") + public Result deleteProcesss(String processInstanceId){ + runtimeService.deleteProcessInstance(processInstanceId,"发起人删除"); + return Result.OK("流程删除成功"); + } + @GetMapping("/projectInfoPageList") + public Result> queryPageList(@RequestParam Map params, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + IPage page = new Page(pageNo, pageSize); + LambdaQueryWrapper huzhouProjectinfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); + String projectName = (String) params.get("projectName"); + String projectId = (String) params.get("projectId"); + huzhouProjectinfoLambdaQueryWrapper.like(StringUtils.isNotBlank(projectName),HuzhouProjectinfo::getProjectName,projectName); + huzhouProjectinfoLambdaQueryWrapper.like(StringUtils.isNotBlank(projectId),HuzhouProjectinfo::getId,projectId); + IPage pageList = projectinfoService.page(page, huzhouProjectinfoLambdaQueryWrapper); + return Result.OK(pageList); + + } + @GetMapping("/queryProjectInfoById") + public Result queryProjectInfoById(String projectid){ + //获取项目入库数据 + HuzhouProjectinfo projectinfo = projectinfoService.getById(projectid); +// List attributes = new ArrayList<>(); +// +// List extractObjectAttributes = HuzhouCommonUtils.extractObjectAttributes(projectinfo); +// for (String s:extractObjectAttributes) { +// if(s.contains("Contactor")){ +// String s1 = s.split("=")[1]; +// SysUser user = userService.getById(s1); +// String realname = user.getRealname(); +// Class clazz = projectinfo.getClass(); +// Method[] methods = clazz.getDeclaredMethods(); +// +// for (Method method : methods) { +// try { +// String name = method.getName(); +// if (name.contains(s.split("=")[0])) { // 假设所有的getter方法都不带参数,并且返回一个基本数据类型或其包装类 +// method.invoke(projectinfo,realname); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +// } +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(HuzhouProcessinfo::getProjectid,projectid); +// HuzhouProcessinfo processinfo = processinfoService.getOne(queryWrapper); + //获取项目入库流程数据 + + return Result.OK(projectinfo); + + } + @GetMapping("/queryprocessinfoById") + public Result queryprocessinfoById(String projectid){ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouProcessinfo::getProjectid,projectid); + queryWrapper.orderByDesc(HuzhouProcessinfo::getStatus); + HuzhouProcessinfo processinfo = processinfoService.list(queryWrapper).get(0); + + return Result.OK(processinfo); + + } + @PostMapping("/uploadFile") + @Transactional() + public Result uploadFile(@RequestParam(value = "file") + MultipartFile[] files,@RequestParam(value = "projectid") String projectid, + @RequestParam(value = "status") String status) throws IOException { + //获取当前时间 + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String currentDay = dateFormat.format(new Date()); + File filePath = new File(uploadpath + File.separator + currentDay + File.separator); + //文件夹不存在则创建 + if (!filePath.exists()) { + // 创建文件根目录 + filePath.mkdirs(); + }else { +// return modifyUploadFile(files,projectid,status); + } + for (MultipartFile item:files) { + String fileName =null; + String originalFilename = item.getOriginalFilename(); + originalFilename = CommonUtils.getFileName(originalFilename); + if(originalFilename.indexOf(SymbolConstant.SPOT)!=-1){ + fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")) + "_" + System.currentTimeMillis() + originalFilename.substring(originalFilename.lastIndexOf(".")); + }else{ + fileName = originalFilename+ "_" + System.currentTimeMillis(); + } + String savePath = filePath.getPath() + File.separator + fileName; + File savefile = new File(savePath); + FileCopyUtils.copy(item.getBytes(), savefile);//保存文件 + HuzhouUploadfileinfo huzhouUploadfileinfo = new HuzhouUploadfileinfo(); + huzhouUploadfileinfo.setDocumentName(originalFilename);//未加工过的文件名称 + huzhouUploadfileinfo.setDocumentType(item.getContentType()); + huzhouUploadfileinfo.setDocumentPath(savePath); + huzhouUploadfileinfo.setStatus(status); + huzhouUploadfileinfo.setSize(item.getSize()); + huzhouUploadfileinfo.setProjectid(projectid); + boolean save = uploadfileinfoService.save(huzhouUploadfileinfo); + } + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752895307869614081"); + arrayList.add("1752895591849160705"); + WorkFlow workFlow = workflowService.createFlow("项目资料上传流程", arrayList); + String businessKey = workFlow.getBusinessKey(); + String processInstanceId = workFlow.getProcessInstanceId(); + //保存项目信息 + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(HuzhouProjectinfo::getStatus,"3");//3表示项目资料流程审批阶段 + updateWrapper.eq(HuzhouProjectinfo::getId,projectid); + projectinfoService.update(null,updateWrapper); + + //保存项目流程相关的信息 + //设置businessKey + //设置项目状态 + HuzhouProcessinfo huzhouProcessinfo = new HuzhouProcessinfo(); + huzhouProcessinfo.setBusinesskey(businessKey); + huzhouProcessinfo.setStatus("2");//该项目的第一个流程 + huzhouProcessinfo.setProcessinstanceid(processInstanceId); + huzhouProcessinfo.setProjectid(projectid); + processinfoService.save(huzhouProcessinfo); + return Result.OK("上传成功!!"); + } + @GetMapping("/downloadfile") + public void downloadfile(HttpServletResponse response,String path,String fileName) throws IOException { + FileInputStream fileInputStream = new FileInputStream(path); + response.setContentType("application/octet-stream"); +// response.setHeader("Content-disposition", "attachment;filename=" + fileName); + BufferedInputStream inputStream =null; + try { + ServletOutputStream outputStream = response.getOutputStream(); + inputStream = new BufferedInputStream(fileInputStream); + byte[] bytes = new byte[1024]; + int len =inputStream.read(bytes); + while (len!=-1){ + outputStream.write(bytes,0,bytes.length); + outputStream.flush(); + len=inputStream.read(bytes); + } + }finally { + if(inputStream!=null){ + inputStream.close(); + } + } + } + + @GetMapping("/queryResourceInfo") + public Result> queryResourceInfo(@RequestParam Map params, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + String projectid = (String) params.get("projectid"); + String status = (String) params.get("status"); + IPage huzhouUploadfileinfoIPage = new Page<>(pageNo,pageSize); + LambdaUpdateWrapper huzhouUploadfileinfoLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + huzhouUploadfileinfoLambdaUpdateWrapper.eq(HuzhouUploadfileinfo::getProjectid,projectid); + huzhouUploadfileinfoLambdaUpdateWrapper.eq(HuzhouUploadfileinfo::getStatus,status); + IPage uploadfileinfoIPage = uploadfileinfoService.page(huzhouUploadfileinfoIPage, huzhouUploadfileinfoLambdaUpdateWrapper); + return Result.OK(uploadfileinfoIPage); + } + + @GetMapping("/queryProjectApprovedPage") + public Result> queryProjectApprovedPage(HuzhouProjectinfo projectinfo, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + Page projectinfoPage = new Page<>(pageNo, pageSize); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + String projectName = projectinfo.getProjectName(); + String projectinfoId = projectinfo.getId(); + queryWrapper.like(StringUtils.isNotBlank(projectName),HuzhouProjectinfo::getProjectName,projectName); + queryWrapper.like(StringUtils.isNotBlank(projectinfoId),HuzhouProjectinfo::getId,projectinfoId); + queryWrapper.ge(HuzhouProjectinfo::getStatus,"4"); + Page page = projectinfoService.page(projectinfoPage, queryWrapper); + return Result.OK(page); + } + + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouUserController.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouUserController.java new file mode 100644 index 0000000..d6f9cad --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/HuzhouUserController.java @@ -0,0 +1,118 @@ +package org.jeecg.modules.huzhou.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.huzhou.entity.BaseEntity; +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; +import org.jeecg.modules.huzhou.service.IHuzhouProjectinfoService; +import org.jeecg.modules.system.entity.SysUser; +import org.jeecg.modules.system.service.ISysUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/huzhouUser") +public class HuzhouUserController { + @Autowired + private ISysUserService userService; + @Autowired + private IHuzhouProjectinfoService projectinfoService; + @GetMapping("/getMyAddressBook") + public Result> getMyAddressBook(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + //先查询当前参与的项目 + //获取当前登录人 + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = loginUser.getId(); + //查询参与的项目 + LambdaQueryWrapper projectinfoQueryWrapper = new LambdaQueryWrapper<>(); + projectinfoQueryWrapper.eq(HuzhouProjectinfo::getManageContactor,userId) + .or() + .eq(HuzhouProjectinfo::getControlerContactor,userId) + .or() + .eq(HuzhouProjectinfo::getOwnerContactor,userId) + .or() + .eq(HuzhouProjectinfo::getContructorContactor,userId) + .or() + .eq(HuzhouProjectinfo::getSupervisorContactor,userId) + .or() + .eq(HuzhouProjectinfo::getConsultContactor,userId) + .or() + .eq(BaseEntity::getCreator,userId); + //projectinfoQueryWrapper.eq(BaseEntity::getCreator,userId); + List projectinfoList = projectinfoService.list(projectinfoQueryWrapper); + List manageContactors = projectinfoList.stream() + .map(HuzhouProjectinfo::getManageContactor) + .collect(Collectors.toList()); + List controlerContactors = projectinfoList.stream() + .map(HuzhouProjectinfo::getControlerContactor) + .collect(Collectors.toList()); + List ownerContactors = projectinfoList.stream() + .map(HuzhouProjectinfo::getOwnerContactor) + .collect(Collectors.toList()); + List contructorContactor = projectinfoList.stream() + .map(HuzhouProjectinfo::getContructorContactor) + .collect(Collectors.toList()); + List supervisorContactor = projectinfoList.stream().map(HuzhouProjectinfo::getSupervisorContactor).collect(Collectors.toList()); + List consultContactor = projectinfoList.stream().map(HuzhouProjectinfo::getConsultContactor).collect(Collectors.toList()); + HashSet hashSet = new HashSet<>(); + hashSet.addAll(manageContactors); + hashSet.addAll(controlerContactors); + hashSet.addAll(ownerContactors); + hashSet.addAll(contructorContactor); + hashSet.addAll(supervisorContactor); + hashSet.addAll(consultContactor); + Page sysUserPage = new Page<>(pageNo,pageSize); + LambdaQueryWrapper sysUserQueryWrapper = new LambdaQueryWrapper<>(); + sysUserQueryWrapper.in(hashSet.size()>0,SysUser::getId,hashSet) + .or().eq(SysUser::getId,userId); + Page userPage = userService.page(sysUserPage, sysUserQueryWrapper); + return Result.OK(userPage); + } + @GetMapping("/getWorkPlaceTypeDict") + public Result getWorkPlaceDict(String workPlaceType){ + LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sysUserLambdaQueryWrapper.eq(SysUser::getWorkplaceType,workPlaceType) + .select(SysUser::getWorkplaceType,SysUser::getWorkplace); + List> mapList = userService.list(sysUserLambdaQueryWrapper) + .stream() + .distinct() + .map(sysUser -> Map.of( + "value", sysUser.getWorkplace(), + "label", sysUser.getWorkplace() + )).collect(Collectors.toList()); + return Result.OK(mapList); + } + @GetMapping("/getContactorDict") + public Result getContactorDict(String workPlace,String workPlaceType){ + LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sysUserLambdaQueryWrapper.eq(StringUtils.isNotBlank(workPlace),SysUser::getWorkplace,workPlace) + .eq(StringUtils.isNotBlank(workPlaceType),SysUser::getWorkplaceType,workPlaceType); + List> mapList = userService.list(sysUserLambdaQueryWrapper) + .stream() + .map(sysUser -> Map.of( + "value", sysUser.getId(), + "label", sysUser.getRealname() + )).collect(Collectors.toList()); + return Result.OK(mapList); + } + @GetMapping("/getUserInfoByid") + public Result getUserInfoByid(String id){ + + SysUser byId = userService.getById(id); + return Result.ok(byId); + } +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/WorkflowController.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/WorkflowController.java new file mode 100644 index 0000000..eb5310a --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/controller/WorkflowController.java @@ -0,0 +1,367 @@ +package org.jeecg.modules.huzhou.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fasterxml.jackson.module.kotlin.ReflectionCache; +import org.activiti.bpmn.model.*; +import org.activiti.engine.HistoryService; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; +import org.activiti.engine.history.*; +import org.activiti.engine.impl.identity.Authentication; +import org.activiti.engine.impl.persistence.entity.TaskEntityImpl; +import org.activiti.engine.repository.ProcessDefinition; +import org.activiti.engine.runtime.Execution; +import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.Comment; +import org.activiti.engine.task.Task; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.checkerframework.checker.units.qual.A; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.huzhou.entity.HuzhouProcessinfo; +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; +import org.jeecg.modules.huzhou.mapper.WorkflowMapper; +import org.jeecg.modules.huzhou.service.IHuzhouProcessinfoService; +import org.jeecg.modules.huzhou.service.IHuzhouProjectinfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/workflow") +public class WorkflowController { + @Autowired + private TaskService taskService; + @Autowired + private HistoryService historyService; + @Autowired + private RepositoryService repositoryService; + @Autowired + private RuntimeService runtimeService; + @Autowired + private IHuzhouProcessinfoService processinfoService; + @Autowired + private IHuzhouProjectinfoService projectinfoService; + @Autowired + private WorkflowMapper workflowMapper; + @GetMapping("/myTaskList") + public Result>> myTaskList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + List> taskMapList = new ArrayList<>(); + List taskList = taskService.createTaskQuery() + .orderByTaskCreateTime() + .desc() + .taskCandidateOrAssigned(userId) + .listPage((pageNo-1)*pageSize,pageSize); + if (!CollectionUtils.isEmpty(taskList)) { + for (Task task:taskList) { + HashMap stringObjectHashMap = new HashMap<>(); + stringObjectHashMap.put("taskId",task.getId()); + stringObjectHashMap.put("taskName",task.getName()); + String processInstanceId = task.getProcessInstanceId(); + + String processDefinitionId = task.getProcessDefinitionId(); + //获取当前流程名称 + ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(processDefinitionId).singleResult(); + if(processDefinition!=null){ + String processName = processDefinition.getName(); + stringObjectHashMap.put("processName",processName); + } + //获取项目id + LambdaQueryWrapper processQueryWrapper = new LambdaQueryWrapper<>(); + processQueryWrapper.eq(HuzhouProcessinfo::getProcessinstanceid,processInstanceId); + HuzhouProcessinfo processinfo = processinfoService.getOne(processQueryWrapper); + if(processinfo!=null){ + String projectid = processinfo.getProjectid(); + stringObjectHashMap.put("projectid",projectid); + //获取项目名称 + LambdaQueryWrapper projetcQueryWrapper = new LambdaQueryWrapper<>(); + projetcQueryWrapper.eq(HuzhouProjectinfo::getId,projectid); + HuzhouProjectinfo projectInfo = projectinfoService.getOne(projetcQueryWrapper); + stringObjectHashMap.put("projectName",projectInfo.getProjectName()); + stringObjectHashMap.put("createTime",projectInfo.getCreatetime()); + stringObjectHashMap.put("status",processinfo.getStatus()); + + } + + stringObjectHashMap.put("processInstanceId",processInstanceId); + stringObjectHashMap.put("processDefinitionId",task.getProcessDefinitionId()); + taskMapList.add(stringObjectHashMap); + } + } +// //由于activiti7的懒加载机制,无法将结果直接返回.先强转成Task实现类,在调用其方法 +// List taskImpls = taskList.stream().map(x -> (TaskEntityImpl) x).collect(Collectors.toList()); +// //返回的结果相同 +// List collect = taskImpls.stream().map(TaskEntityImpl::getPersistentState).collect(Collectors.toList()); + + int taskCount = taskService.createTaskQuery() + .taskCandidateOrAssigned(userId) + .list() + .size(); + Page> taskPage = new Page<>(); + taskPage.setCurrent(pageNo); + taskPage.setSize(pageSize); + taskPage.setTotal(taskCount); + taskPage.setRecords(taskMapList); + return Result.ok(taskPage); + } + @GetMapping("/myCompleteTask") + public Result>> myCompleteTask(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + //历史任务查询暂定这样(一条流程处理两次会有两条记录),后面通过sql + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + ArrayList> resList = new ArrayList<>(); +// List historicTaskInstances = historyService.createHistoricTaskInstanceQuery() +// .taskAssignee(userId) +// .orderByTaskCreateTime() +// .desc() +// .listPage((pageNo-1)*pageSize, pageSize); + Page> mapPage = new Page<>(pageNo,pageSize); + Page> completeTaskByAssignee = workflowMapper.getCompleteTaskByAssignee(mapPage, userId); + List> records = completeTaskByAssignee.getRecords(); +// for (HistoricTaskInstance his: historicTaskInstances) { + for (Map his: records) { + HashMap reshashMap = new HashMap<>(); + String processInstanceId = his.get("processInstanceId"); + String processDefinitionId = his.get("processDefinitionId"); + reshashMap.put("processInstanceId",processInstanceId); + //获取taskid + List list = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processInstanceId) + .orderByTaskCreateTime().desc().list(); + reshashMap.put("taskId",list.get(0).getId()); + //根据流程实例查询当前流所在位置 + Task task = taskService.createTaskQuery() + .processInstanceId(processInstanceId) + .active() + .singleResult(); + if(task!=null){ + String currentTaskName = task.getName(); + reshashMap.put("currentTaskName",currentTaskName); + } + + //获取当前流程名称 + ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(processDefinitionId).singleResult(); + if(processDefinition!=null){ + String processName = processDefinition.getName(); + reshashMap.put("processName",processName); + } + //获取项目id + LambdaQueryWrapper processQueryWrapper = new LambdaQueryWrapper<>(); + processQueryWrapper.eq(HuzhouProcessinfo::getProcessinstanceid,processInstanceId); + HuzhouProcessinfo processinfo = processinfoService.getOne(processQueryWrapper); + if(processinfo!=null){ + String projectid = processinfo.getProjectid(); + reshashMap.put("projectid",projectid); + //获取项目名称 + LambdaQueryWrapper projetcQueryWrapper = new LambdaQueryWrapper<>(); + projetcQueryWrapper.eq(HuzhouProjectinfo::getId,projectid); + HuzhouProjectinfo projectInfo = projectinfoService.getOne(projetcQueryWrapper); + reshashMap.put("projectName",projectInfo.getProjectName()); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String createtime = dateFormat.format(projectInfo.getCreatetime()); + reshashMap.put("createTime",createtime); + reshashMap.put("status",processinfo.getStatus()); + } + resList.add(reshashMap); + HistoricProcessInstance historicProcessInstance =historyService.createHistoricProcessInstanceQuery() + .processInstanceId(processInstanceId) + .singleResult(); + if(Objects.isNull(historicProcessInstance)) + { + reshashMap.put("processStatus","流程不存在"); + } + if(Objects.isNull(historicProcessInstance.getEndTime())){ + reshashMap.put("processStatus","审批中"); + } + else { + if(StringUtils.isNotBlank(historicProcessInstance.getDeleteReason())){ + reshashMap.put("processStatus","已作废"); + }else { + reshashMap.put("processStatus","已完成"); + } + } +// //获取流程的状态是否完成 +// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() +// .processInstanceId(processInstanceId) +// .singleResult(); +// if(processinfo==null){ +// reshashMap.put("processStatus","已完成"); +// }else { +// reshashMap.put("processStatus","审判中"); +// } + } + int taskCount = historyService.createHistoricTaskInstanceQuery() + .taskAssignee(userId) + .list() + .size(); + Page> taskPage = new Page<>(); + taskPage.setCurrent(pageNo); + taskPage.setSize(pageSize); + taskPage.setTotal(taskCount); + taskPage.setRecords(resList); + return Result.ok(taskPage); + } + @GetMapping("/getprocessInfo") + public Result>> getprocessInfo(String projectid,String status, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ + //通过项目id查询流程id + HuzhouProjectinfo projectinfo = projectinfoService.getById(projectid); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouProcessinfo::getProjectid,projectid); + queryWrapper.eq(HuzhouProcessinfo::getStatus,status);//属于第几部流程 + HuzhouProcessinfo processinfo = processinfoService.getOne(queryWrapper); + String processinstanceid = processinfo.getProcessinstanceid(); + List list = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processinstanceid) + .orderByTaskCreateTime().asc().listPage((pageNo-1)*pageSize,pageSize); + List> approvalEntityList = new ArrayList<>(); + String approvalSuggestion = ""; + HistoricVariableInstance historicVariableInstance = null; + List commentList = null; + for(HistoricTaskInstance item : list) { + HashMap hashMap = new HashMap<>(); + commentList = taskService.getTaskComments(item.getId()); + if (commentList != null && !commentList.isEmpty()) { + approvalSuggestion = commentList.get(0).getFullMessage(); + } else { + approvalSuggestion = ""; + } + Map taskLocalVariables = item.getTaskLocalVariables(); + //获取当前节点的任务变量 + List variablelist = historyService.createHistoricVariableInstanceQuery() + .taskId(item.getId()) + .list(); + if (variablelist.size()>0) { + for (HistoricVariableInstance hisvar:variablelist) { + hashMap.put(hisvar.getVariableName(),hisvar.getValue()); + + } + + } + hashMap.put("operateDate", item.getEndTime()); + hashMap.put("operator", item.getAssignee()); + hashMap.put("taskName", item.getName()); + hashMap.put("comment", approvalSuggestion); + approvalEntityList.add(hashMap); + } + int countSize = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processinstanceid) + .orderByTaskCreateTime().asc().list().size(); + IPage> listIPage = new Page<>(); + listIPage.setRecords(approvalEntityList); + listIPage.setTotal(countSize); + listIPage.setSize(pageSize); + listIPage.setCurrent(pageNo); + return Result.OK(listIPage); + } + + + @GetMapping("/getActionParam") + public Result getActionParam(String projectid,String status,String taskId,String procesType){ + HashMap outRes = new HashMap<>(); + ArrayList actionButtons = new ArrayList<>(); + //如果是已办 + if("1".equals(procesType)){ + outRes.put("buttons",actionButtons); + outRes.put("showApprovalForm",false); + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String currentLoginuserId = currentUser.getId(); + HuzhouProjectinfo projectinfo = projectinfoService.getById(projectid); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouProcessinfo::getProjectid,projectid); + queryWrapper.eq(HuzhouProcessinfo::getStatus,status);//属于第几部流程 + HuzhouProcessinfo processinfo = processinfoService.getOne(queryWrapper); + String processinstanceid = processinfo.getProcessinstanceid(); + List list = historyService + .createHistoricTaskInstanceQuery() + .processInstanceId(processinstanceid) + .orderByHistoricTaskInstanceEndTime() + .desc() + .list(); + HistoricTaskInstance taskInstance = null; + if (!list.isEmpty()) { + if (list.get(0).getEndTime() != null) { + taskInstance = list.get(0); + String userid = taskInstance.getAssignee(); + //上一个节点是你处理的(已办可以撤回) + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + if(task==null){ + return Result.OK(outRes); + } + String processInstanceId = task.getProcessInstanceId(); + //获取当前模型 + BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); + // 获取当前节点 + FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); + + UserTask userTask = (UserTask) flowElement; + String name = userTask.getName(); + if(currentLoginuserId.equals(userid)&&!"发起人".equals(name)){ + HashMap hashMap = new HashMap<>(); + hashMap.put("label","撤回"); + hashMap.put("value","2"); + actionButtons.add(hashMap); + outRes.put("buttons",actionButtons); + outRes.put("showApprovalForm",true); + } + } + } + }else{ + //代办 发起人可以作废,还要可以修改,加一个修改表示(前端也行) + + outRes.put("showApprovalForm",true); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + String processInstanceId = task.getProcessInstanceId(); + //获取当前模型 + BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); + // 获取当前节点 + FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); + + UserTask userTask = (UserTask) flowElement; + String name = userTask.getName(); + if("发起人".equals(name)){ + HashMap hashMap1 = new HashMap<>(); + hashMap1.put("label","同意"); + hashMap1.put("value","1"); + actionButtons.add(hashMap1); + HashMap hashMap = new HashMap<>(); + hashMap.put("label","作废"); + hashMap.put("value","3"); + outRes.put("IsEdit",true); + actionButtons.add(hashMap); + }else { + HashMap hashMap1 = new HashMap<>(); + hashMap1.put("label","同意"); + hashMap1.put("value","1"); + actionButtons.add(hashMap1); + HashMap hashMap = new HashMap<>(); + + hashMap.put("label","拒绝"); + hashMap.put("value","0"); + actionButtons.add(hashMap); + } + } + //获取上一个处理人 + outRes.put("buttons",actionButtons); + return Result.OK(outRes); + + } +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/BaseEntity.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/BaseEntity.java new file mode 100644 index 0000000..6ebc0e5 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/BaseEntity.java @@ -0,0 +1,31 @@ +package org.jeecg.modules.huzhou.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +import java.util.Date; +@Data +public class BaseEntity { + @TableField(fill = FieldFill.INSERT) + + private String creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createtime; + /** + * 最后更新时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updatetime; + + /** + * 更新者,目前使用 SysUser 的 id 编号 + * + * 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。 + */ + @TableField(fill = FieldFill.UPDATE) + private String updater; +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlaninfo.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlaninfo.java new file mode 100644 index 0000000..127f621 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlaninfo.java @@ -0,0 +1,57 @@ +package org.jeecg.modules.huzhou.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * (HuzhouPlaninfo)实体类 + * + * @author makejava + * @since 2024-01-30 16:01:09 + */ +@Data +public class HuzhouPlaninfo extends BaseEntity implements Serializable { + private static final long serialVersionUID = -76445082989108429L; + /** + * 项目计划id + */ + private String id; + /** + * 项目id + */ + private String projectId; + /** + * 任务名称 + */ + private String taskName; + /** + * 任务启动顺序序号 + */ + private String orderNumber; + /** + * 计划开始时间 + */ + @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") + private Date scheduledStartTime; + /** + * 计划结束时间 + */ + @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd") + + private Date scheduledEndTime; + /** + * 实际开始时间 + */ + private Date actualStartTime; + /** + * 实际结束时间 + */ + private Date actualEndTime; + + + +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlanmodule.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlanmodule.java new file mode 100644 index 0000000..baed053 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlanmodule.java @@ -0,0 +1,34 @@ +package org.jeecg.modules.huzhou.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * (HuzhouPlanmodule)实体类 + * + * @author makejava + * @since 2024-01-30 16:02:30 + */ +@Data +public class HuzhouPlanmodule extends BaseEntity implements Serializable { + private static final long serialVersionUID = 808500478305209789L; + /** + * 计划模板id + */ + @TableId(type = IdType.AUTO) + private int id; + /** + * 模板名称 + */ + private String moduleName; + /** + * 项目类型 + */ + private String projectType; + +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlanmoduledetail.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlanmoduledetail.java new file mode 100644 index 0000000..c3d7671 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouPlanmoduledetail.java @@ -0,0 +1,39 @@ +package org.jeecg.modules.huzhou.entity; + +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * (HuzhouPlanmoduledetail)实体类 + * + * @author makejava + * @since 2024-01-30 16:02:46 + */ +@Data +public class HuzhouPlanmoduledetail extends BaseEntity implements Serializable { + private static final long serialVersionUID = -22580960950467884L; + /** + * 计划模板详情id + */ + private String id; + /** + * 模板id + */ + private String moduleId; + /** + * 任务名称 + */ + private String taskName; + /** + * 任务启动顺序序号 + */ + private String orderNumber; + /** + * 阶段最长时间 + */ + private String maxDays; + +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouProcessinfo.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouProcessinfo.java new file mode 100644 index 0000000..a28d970 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouProcessinfo.java @@ -0,0 +1,34 @@ +package org.jeecg.modules.huzhou.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * (HuzhoouProcessinfo)实体类 + * + * @author makejava + * @since 2024-01-23 19:06:12 + */ +@Data +public class HuzhouProcessinfo extends BaseEntity implements Serializable { + private static final long serialVersionUID = 641518690443763605L; + /** + * 流程实例id + */ + private String processinstanceid; + /** + * 业务key + */ + private String businesskey; + /** + * 流程所属项目id + */ + private String projectid; + /** + * 当前流程属于项目的哪个阶段 + */ + private String status; + +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouProjectinfo.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouProjectinfo.java new file mode 100644 index 0000000..43f3fd0 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouProjectinfo.java @@ -0,0 +1,173 @@ +package org.jeecg.modules.huzhou.entity; + +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * (HuzhouProjectinfo)实体类 + * + * @author makejava + * @since 2024-02-05 14:14:53 + */ +@Data +public class HuzhouProjectinfo extends BaseEntity implements Serializable{ + private static final long serialVersionUID = 952171041224600588L; + /** + * 项目id + */ + private String id; + /** + * 项目名称 + */ + private String projectName; + /** + * 行政区划 + */ + private String adminDivision; + /** + * 主要任务及标志性成果 + */ + private String description; + /** + * 项目类型 + */ + private String projectType; + /** + * 责任单位 + */ + private String dutyWorkplace; + /** + * 建设年限 + */ + private String constructionPeriod; + /** + * 中央资金 + */ + private Double centralMoney; + /** + * 省级资金 + */ + private Double provincialMoney; + /** + * 市级资金 + */ + private Double cityMoney; + /** + * 区县级资金 + */ + private Double countyMoney; + /** + * 所属改革任务 + */ + private String reformName; + /** + * 上级指导处室 + */ + private String superLeader; + /** + * 项目联系人 + */ + private String projectContacts; + /** + * 联系电话 + */ + private String phone; + /** + * 管理单位 + */ + private String manageOrg; + /** + * 管理单位负责人 + */ + private String manageContactor; + /** + * 监理单位 + */ + private String controler; + /** + * 监理单位负责人 + */ + private String controlerContactor; + /** + * 监管单位 + */ + private String supervisor; + /** + * 监管单位负责人 + */ + private String supervisorContactor; + /** + * 建设单位 + */ + private String owner; + /** + * 建设单位负责人 + */ + private String ownerContactor; + /** + * 咨询单位 + */ + private String consult; + /** + * 咨询单位负责人 + */ + private String consultContactor; + /** + * 承建单位 + */ + private String contructor; + /** + * 承建单位负责人 + */ + private String contructorContactor; + /** + * 项目状态 + */ + private String status; + /** + * 创建时间 + */ + private Date createtime; + /** + * 创建人 + */ + private String creator; + /** + * 修改时间 + */ + private Date updatetime; + /** + * 修改人 + */ + private String updater; + /** + * 单位属性 + */ + private String workplaceProperties; + /** + * 总投资 + */ + private String totalInvestment; + /** + * 自筹资金 + */ + private String selfFunding; + /** + * 2023年支付 + */ + private Double payamount2023; + /** + * 2024年支付 + */ + private Double payamount2024; + /** + * 2025年支付 + */ + private Double payamount2025; + + + +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouUploadfileinfo.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouUploadfileinfo.java new file mode 100644 index 0000000..5bfb95b --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouUploadfileinfo.java @@ -0,0 +1,45 @@ +package org.jeecg.modules.huzhou.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * (HuzhouUploadfileinfo)实体类 + * + * @author makejava + * @since 2024-01-29 14:21:06 + */ +@Data +public class HuzhouUploadfileinfo extends BaseEntity implements Serializable { + private static final long serialVersionUID = -47951391694982856L; + /** + * 文档编号 + */ + private Integer id; + /** + * 项目id + */ + private String projectid; + /** + * 文档名称 + */ + private String documentName; + /** + * 文档类型 + */ + private String documentType; + /** + * 文档位置 + */ + private String documentPath; + /** + * 文档属于项目的哪个阶段 + */ + private String status; + /** + * 文件大小 + */ + private long size; +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouUserproject.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouUserproject.java new file mode 100644 index 0000000..480a90f --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/HuzhouUserproject.java @@ -0,0 +1,32 @@ +package org.jeecg.modules.huzhou.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * (HuzhouUserproject)实体类 + * + * @author makejava + * @since 2024-02-01 09:57:56 + */ +@Data +public class HuzhouUserproject implements Serializable { + private static final long serialVersionUID = 234624016576325502L; + /** + * 表id + */ + private Integer id; + /** + * 用户id + */ + private String userId; + /** + * 项目id + */ + private String projectId; + + + +} + diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/WorkFlow.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/WorkFlow.java new file mode 100644 index 0000000..d67638b --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/entity/WorkFlow.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.huzhou.entity; + +import lombok.Data; + +@Data +public class WorkFlow { + /** + * 流程实例id + */ + private String processInstanceId; + /** + * 业务表流程key值 + */ + private String businessKey; + /** + * 当前节点名称 + */ + private String userTask; +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/handler/MyMetaObjectHandler.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/handler/MyMetaObjectHandler.java new file mode 100644 index 0000000..7d5e744 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/handler/MyMetaObjectHandler.java @@ -0,0 +1,41 @@ +package org.jeecg.modules.huzhou.handler; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.system.vo.LoginUser; +import org.springframework.stereotype.Component; + +import java.util.Date; + +@Component +public class MyMetaObjectHandler implements MetaObjectHandler { + /** + * 插入时的填充策略 + * + * @param metaObject + */ + @Override + public void insertFill(MetaObject metaObject) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + this.setFieldValByName("createtime", new Date(), metaObject); + this.setFieldValByName("updatetime", new Date(), metaObject); + this.setFieldValByName("creator",userId,metaObject); + + } + + /** + * 更新时的填充策略 + * + * @param metaObject + */ + @Override + public void updateFill(MetaObject metaObject) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + this.setFieldValByName("updatetime", new Date(), metaObject); + this.setFieldValByName("updater",userId,metaObject); + + } +} \ No newline at end of file diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlaninfoMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlaninfoMapper.java new file mode 100644 index 0000000..4fbb864 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlaninfoMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouPlaninfo; + +@Mapper +public interface HuzhouPlaninfoMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlanmoduleMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlanmoduleMapper.java new file mode 100644 index 0000000..d6f0979 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlanmoduleMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouPlanmodule; + +@Mapper +public interface HuzhouPlanmoduleMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlanmoduledetailMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlanmoduledetailMapper.java new file mode 100644 index 0000000..b89cda8 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouPlanmoduledetailMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouPlanmoduledetail; + +@Mapper +public interface HuzhouPlanmoduledetailMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouProcessinfoMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouProcessinfoMapper.java new file mode 100644 index 0000000..7b9612f --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouProcessinfoMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouProcessinfo; + +@Mapper +public interface HuzhouProcessinfoMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouProjectinfoMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouProjectinfoMapper.java new file mode 100644 index 0000000..2d285b1 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouProjectinfoMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; + +@Mapper +public interface HuzhouProjectinfoMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouUploadfileinfoMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouUploadfileinfoMapper.java new file mode 100644 index 0000000..354fec8 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouUploadfileinfoMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouUploadfileinfo; + +@Mapper +public interface HuzhouUploadfileinfoMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouUserprojectMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouUserprojectMapper.java new file mode 100644 index 0000000..13cea1b --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/HuzhouUserprojectMapper.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.jeecg.modules.huzhou.entity.HuzhouUserproject; + +@Mapper +public interface HuzhouUserprojectMapper extends BaseMapper { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/WorkflowMapper.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/WorkflowMapper.java new file mode 100644 index 0000000..8966f42 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/WorkflowMapper.java @@ -0,0 +1,13 @@ +package org.jeecg.modules.huzhou.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +@Mapper +public interface WorkflowMapper extends BaseMapper { + Page> getCompleteTaskByAssignee(Page page, @Param("userid") String id); +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/xml/WorkflowMapper.xml b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/xml/WorkflowMapper.xml new file mode 100644 index 0000000..e3ce965 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/mapper/xml/WorkflowMapper.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlaninfoService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlaninfoService.java new file mode 100644 index 0000000..32a98df --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlaninfoService.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.huzhou.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.huzhou.entity.HuzhouPlaninfo; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +/** + * (HuzhouPlaninfo)表服务接口 + * + * @author makejava + * @since 2024-01-30 16:01:09 + */ +public interface IHuzhouPlaninfoService extends IService { + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlanmoduleService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlanmoduleService.java new file mode 100644 index 0000000..471b8a4 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlanmoduleService.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.huzhou.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.huzhou.entity.HuzhouPlanmodule; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +/** + * (HuzhouPlanmodule)表服务接口 + * + * @author makejava + * @since 2024-01-30 16:02:30 + */ +public interface IHuzhouPlanmoduleService extends IService { + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlanmoduledetailService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlanmoduledetailService.java new file mode 100644 index 0000000..1d5a3c3 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouPlanmoduledetailService.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.huzhou.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.huzhou.entity.HuzhouPlanmoduledetail; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +/** + * (HuzhouPlanmoduledetail)表服务接口 + * + * @author makejava + * @since 2024-01-30 16:02:46 + */ +public interface IHuzhouPlanmoduledetailService extends IService { + + + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProcessinfoService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProcessinfoService.java index c5f076d..1b25366 100644 --- a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProcessinfoService.java +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProcessinfoService.java @@ -5,4 +5,5 @@ import org.jeecg.modules.huzhou.entity.HuzhouProcessinfo; import org.springframework.stereotype.Service; public interface IHuzhouProcessinfoService extends IService { + void callBack(String processId,String flag); } diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProjectinfoService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProjectinfoService.java new file mode 100644 index 0000000..4a74d29 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouProjectinfoService.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.huzhou.service; + +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; +import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.stereotype.Service; + + +/** + * (HuzhouProjectinfo)表服务接口 + * + * @author makejava + * @since 2024-01-23 09:33:31 + */ +public interface IHuzhouProjectinfoService extends IService{ + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouUploadfileinfoService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouUploadfileinfoService.java new file mode 100644 index 0000000..0760ef9 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouUploadfileinfoService.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.huzhou.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.huzhou.entity.HuzhouUploadfileinfo; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +/** + * (HuzhouUploadfileinfo)表服务接口 + * + * @author makejava + * @since 2024-01-29 14:21:06 + */ +public interface IHuzhouUploadfileinfoService extends IService { + void modifyUploadFile(MultipartFile[] files, String projectid, String status) throws IOException; +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouUserprojectService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouUserprojectService.java new file mode 100644 index 0000000..3f8f69d --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IHuzhouUserprojectService.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.huzhou.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.huzhou.entity.HuzhouUserproject; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +/** + * (HuzhouUserproject)表服务接口 + * + * @author makejava + * @since 2024-02-01 09:59:12 + */ +public interface IHuzhouUserprojectService extends IService { + + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IWorkflowService.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IWorkflowService.java new file mode 100644 index 0000000..7e67239 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/IWorkflowService.java @@ -0,0 +1,11 @@ +package org.jeecg.modules.huzhou.service; + +import org.jeecg.modules.huzhou.entity.WorkFlow; + +import java.util.ArrayList; + +public interface IWorkflowService { + WorkFlow createFlow(String processDefinitionKey, ArrayList nextList); + void callBack(String processId,String flag); + WorkFlow approveProjectInfo(String taskId,String flag,String comment,String status); +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlaninfoServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlaninfoServiceImpl.java new file mode 100644 index 0000000..587b764 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlaninfoServiceImpl.java @@ -0,0 +1,20 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.huzhou.entity.HuzhouPlaninfo; +import org.jeecg.modules.huzhou.mapper.HuzhouPlaninfoMapper; +import org.jeecg.modules.huzhou.service.IHuzhouPlaninfoService; +import org.springframework.stereotype.Service; + + +import javax.annotation.Resource; + +/** + * (HuzhouPlaninfo)表服务实现类 + * + * @author makejava + * @since 2024-01-30 16:01:09 + */ +@Service +public class HuzhouPlaninfoServiceImpl extends ServiceImpl implements IHuzhouPlaninfoService { +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlanmoduleServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlanmoduleServiceImpl.java new file mode 100644 index 0000000..1cb1545 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlanmoduleServiceImpl.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.huzhou.entity.HuzhouPlanmodule; +import org.jeecg.modules.huzhou.mapper.HuzhouPlanmoduleMapper; +import org.jeecg.modules.huzhou.service.IHuzhouPlanmoduleService; +import org.springframework.stereotype.Service; + + +/** + * (HuzhouPlanmodule)表服务实现类 + * + * @author makejava + * @since 2024-01-30 16:02:30 + */ +@Service +public class HuzhouPlanmoduleServiceImpl extends ServiceImpl implements IHuzhouPlanmoduleService { + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlanmoduledetailServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlanmoduledetailServiceImpl.java new file mode 100644 index 0000000..87c2787 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouPlanmoduledetailServiceImpl.java @@ -0,0 +1,21 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.huzhou.entity.HuzhouPlanmoduledetail; +import org.jeecg.modules.huzhou.mapper.HuzhouPlanmoduledetailMapper; +import org.jeecg.modules.huzhou.service.IHuzhouPlanmoduledetailService; +import org.springframework.stereotype.Service; + + +import javax.annotation.Resource; + +/** + * (HuzhouPlanmoduledetail)表服务实现类 + * + * @author makejava + * @since 2024-01-30 16:02:46 + */ +@Service +public class HuzhouPlanmoduledetailServiceImpl extends ServiceImpl implements IHuzhouPlanmoduledetailService { + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouProcessinfoServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouProcessinfoServiceImpl.java new file mode 100644 index 0000000..ff5377d --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouProcessinfoServiceImpl.java @@ -0,0 +1,165 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.activiti.bpmn.model.BpmnModel; +import org.activiti.bpmn.model.FlowNode; +import org.activiti.bpmn.model.SequenceFlow; +import org.activiti.engine.HistoryService; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; +import org.activiti.engine.history.HistoricActivityInstance; +import org.activiti.engine.history.HistoricTaskInstance; +import org.activiti.engine.impl.identity.Authentication; +import org.activiti.engine.runtime.Execution; +import org.activiti.engine.task.Task; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.huzhou.entity.HuzhouProcessinfo; +import org.jeecg.modules.huzhou.mapper.HuzhouProcessinfoMapper; +import org.jeecg.modules.huzhou.service.IHuzhouProcessinfoService; +import org.jeecg.modules.huzhou.service.IHuzhouProjectinfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +@Service + +public class HuzhouProcessinfoServiceImpl extends ServiceImpl implements IHuzhouProcessinfoService { + @Autowired + private TaskService taskService; + @Autowired + private HistoryService historyService; + @Autowired + private RepositoryService repositoryService; + @Autowired + private RuntimeService runtimeService; + + @Override + public void callBack(String processId, String flag) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + //通过流程id查找到当前的任务 + List tasks= taskService.createTaskQuery() + .processInstanceId(processId).orderByTaskCreateTime().desc() + .list(); + //tasks.get(0).setAssignee("1748190800971665409"); + //如果为空或者小于等于0则证明没有可查看到的任务 + if (tasks == null||tasks.size()<=0) { + System.out.println("当前没有任务或者任务已执行完了"); + } + //查看所有走过的历史任务 + List htlist = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processId) + .finished().orderByHistoricTaskInstanceEndTime().desc() + .list(); + if (htlist == null||htlist.size()<=0) { + System.out.println("请先提交任务"); + } + String myTaskId = null; + HistoricTaskInstance myTask = null; + //前一个任务节点,也就是提交人 拿到前一个任务 + for (HistoricTaskInstance hti : htlist) { + //回退到zhangsan也就是任务A,业务中这里就是当前登录的用户名 TODO:从登录名拿 + if (userId.equals(hti.getAssignee())) { + myTaskId = hti.getId(); +// taskService.set +// tasks.get(0).setName(""); + myTask = hti; + break; + } + } + + if (myTask == null) { + System.out.println("这个任务不是你的任务"); + } + //流程定义id + String processDefinitionId = myTask.getProcessDefinitionId(); + + //整个流程节点对象 + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + + //我的节点 + String myActivityId = null; + //历史节点完成节点 + List haiList = + historyService + .createHistoricActivityInstanceQuery() + .executionId(myTask.getExecutionId()) + .finished() + .list(); + //拿到我的节点 _3 + for (HistoricActivityInstance hai : haiList) { + if (myTaskId.equals(hai.getTaskId())) { + myActivityId = hai.getActivityId(); + break; + } + } + //我的流程节点 + FlowNode myFlowNode = + (FlowNode) bpmnModel.getMainProcess().getFlowElement(myActivityId); + //当前执行对象 + Execution execution = runtimeService.createExecutionQuery() + .executionId(tasks.get(0).getExecutionId()).singleResult(); + //当任务执行节点_4 + String activityId = execution.getActivityId(); + + System.out.println(activityId); + //当前流程节点对象 + FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess() + .getFlowElement(activityId); +// flowNode.getName() 节点名称 + //记录原活动方向出方向 + List oriSequenceFlows = new ArrayList(); + oriSequenceFlows.addAll(flowNode.getOutgoingFlows()); + + //清理活动方向 + flowNode.getOutgoingFlows().clear(); + + //建立新方向 + List newSequenceFlowList = new ArrayList(); + SequenceFlow newSequenceFlow = new SequenceFlow(); + newSequenceFlow.setId("newSequenceFlowId"); + newSequenceFlow.setSourceFlowElement(flowNode); + newSequenceFlow.setTargetFlowElement(myFlowNode); + newSequenceFlowList.add(newSequenceFlow); + flowNode.setOutgoingFlows(newSequenceFlowList); + //设置操作人记录 和备注信息 + Authentication.setAuthenticatedUserId(userId); + taskService.claim(tasks.get(0).getId(),userId); + taskService.setVariableLocal(tasks.get(0).getId(),"approvalStatue",flag); + taskService.addComment(tasks.get(0).getId(), tasks.get(0).getProcessInstanceId(), "上一节点撤回"); + String taskId= tasks.get(0).getId(); + //完成任务 +// if (tasks.size() > 1) { +// //会签撤回 +// HashMap variables = new HashMap<>(); +// variables.put("pass",true); +//// variables.put("param","y"); +// taskService.complete(taskId,variables); +// //恢复原方向 +// flowNode.setOutgoingFlows(oriSequenceFlows); +// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(tasks.get(0).getProcessInstanceId()).singleResult(); +// //更新数据库 从新设置state为未提交状态 +// Apply apply = new Apply(); +// apply.setCode(processInstance.getBusinessKey()); +// apply.setState(0); +// +// +// return applyService.updateByCode(apply); +// } + //普通撤回 + ArrayList arrayList = new ArrayList<>(); + HashMap hashMap = new HashMap<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add(userId); + hashMap.put("users",arrayList); + taskService.complete(taskId,hashMap); + //恢复原方向 + flowNode.setOutgoingFlows(oriSequenceFlows); + } +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java new file mode 100644 index 0000000..489f5d6 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; +import org.jeecg.modules.huzhou.mapper.HuzhouProjectinfoMapper; +import org.jeecg.modules.huzhou.service.IHuzhouProjectinfoService; +import org.springframework.stereotype.Service; + +@Service + +public class HuzhouProjectinfoServiceImpl extends ServiceImpl + implements IHuzhouProjectinfoService { + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouUploadfileinfoServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouUploadfileinfoServiceImpl.java new file mode 100644 index 0000000..b61a639 --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouUploadfileinfoServiceImpl.java @@ -0,0 +1,75 @@ +package org.jeecg.modules.huzhou.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.SymbolConstant; +import org.jeecg.common.util.CommonUtils; +import org.jeecg.modules.huzhou.entity.HuzhouUploadfileinfo; +import org.jeecg.modules.huzhou.mapper.HuzhouUploadfileinfoMapper; +import org.jeecg.modules.huzhou.service.IHuzhouUploadfileinfoService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.util.FileCopyUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * (HuzhouUploadfileinfo)表服务实现类 + * + * @author makejava + * @since 2024-01-29 14:21:06 + */ +@Service +public class HuzhouUploadfileinfoServiceImpl extends ServiceImpl implements IHuzhouUploadfileinfoService { + @Value(value = "${jeecg.path.upload}") + private String uploadpath; + public void modifyUploadFile(MultipartFile[] files, String projectid, String status) throws IOException { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(HuzhouUploadfileinfo::getProjectid,projectid); + queryWrapper.eq(HuzhouUploadfileinfo::getStatus,status); + List list = this.list(queryWrapper); + list.forEach(item->{ + File file = new File(item.getDocumentPath()); + file.delete(); + }); + this.remove(queryWrapper); + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + String currentDay = dateFormat.format(new Date()); + File filePath = new File(uploadpath + File.separator + currentDay + File.separator); + //文件夹不存在则创建 + if (!filePath.exists()) { + // 创建文件根目录 + filePath.mkdirs(); + } + for (MultipartFile item:files) { + String fileName =null; + String originalFilename = item.getOriginalFilename(); + originalFilename = CommonUtils.getFileName(originalFilename); + if(originalFilename.indexOf(SymbolConstant.SPOT)!=-1){ + fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")) + "_" + System.currentTimeMillis() + originalFilename.substring(originalFilename.lastIndexOf(".")); + }else{ + fileName = originalFilename+ "_" + System.currentTimeMillis(); + } + String savePath = filePath.getPath() + File.separator + fileName; + File savefile = new File(savePath); + FileCopyUtils.copy(item.getBytes(), savefile);//保存文件 + HuzhouUploadfileinfo huzhouUploadfileinfo = new HuzhouUploadfileinfo(); + huzhouUploadfileinfo.setDocumentName(originalFilename);//未加工过的文件名称 + huzhouUploadfileinfo.setDocumentType(item.getContentType()); + huzhouUploadfileinfo.setDocumentPath(savePath); + huzhouUploadfileinfo.setStatus(status); + huzhouUploadfileinfo.setSize(item.getSize()); + huzhouUploadfileinfo.setProjectid(projectid); + boolean save = this.save(huzhouUploadfileinfo); + } + } + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouUserprojectServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouUserprojectServiceImpl.java new file mode 100644 index 0000000..b566c1c --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/HuzhouUserprojectServiceImpl.java @@ -0,0 +1,23 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.huzhou.entity.HuzhouUserproject; +import org.jeecg.modules.huzhou.mapper.HuzhouUserprojectMapper; +import org.jeecg.modules.huzhou.service.IHuzhouUserprojectService; +import org.springframework.stereotype.Service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; + +import javax.annotation.Resource; + +/** + * (HuzhouUserproject)表服务实现类 + * + * @author makejava + * @since 2024-02-01 09:59:12 + */ +@Service("huzhouUserprojectService") +public class HuzhouUserprojectServiceImpl extends ServiceImpl implements IHuzhouUserprojectService { + +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/WorkflowServiceImpl.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/WorkflowServiceImpl.java new file mode 100644 index 0000000..9b3a5dd --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/service/impl/WorkflowServiceImpl.java @@ -0,0 +1,327 @@ +package org.jeecg.modules.huzhou.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import org.activiti.bpmn.model.*; +import org.activiti.engine.HistoryService; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; +import org.activiti.engine.history.HistoricActivityInstance; +import org.activiti.engine.history.HistoricTaskInstance; +import org.activiti.engine.impl.identity.Authentication; +import org.activiti.engine.runtime.Execution; +import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.Task; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.huzhou.entity.HuzhouProcessinfo; +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; +import org.jeecg.modules.huzhou.entity.WorkFlow; +import org.jeecg.modules.huzhou.service.IWorkflowService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestBody; + +import java.text.SimpleDateFormat; +import java.util.*; +@Service +public class WorkflowServiceImpl implements IWorkflowService { + @Autowired + private TaskService taskService; + @Autowired + private HistoryService historyService; + @Autowired + private RepositoryService repositoryService; + @Autowired + private RuntimeService runtimeService; + public WorkFlow createFlow(String processDefinitionKey,ArrayList nextList){ + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + //流程的创建 + // 流程定义KEY(流程名字) + // 业务表KEY(用于把业务数据与Activiti7流程数据相关联) + String businessKey = UUID.randomUUID().toString().replace("-",""); + // 参数 + Map variables = new HashMap<>(); + //设置流程发起人参数 + variables.put("start",userId); + ProcessInstance processInstance = this.runtimeService + .startProcessInstanceByKey(processDefinitionKey, businessKey, variables); + String processInstanceId = processInstance.getProcessInstanceId();//流程实例id要存下来 + System.out.println("流程实例ID:" + processInstanceId); + + //发起人处理流程 + Task task = taskService.createTaskQuery() + .processInstanceId(processInstanceId) + .orderByTaskCreateTime() + .desc() + .list() + .get(0); + String taskId = task.getId(); + variables.clear(); + Authentication.setAuthenticatedUserId(userId);//添加审批人 + taskService.setVariableLocal(taskId,"approvalStatue","1");//添加审批状态 + String comment = "同意"; + taskService.addComment(taskId,processInstanceId,comment);//添加审批意见 + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + //下一个节点处理人 可以配置(测试默认这个) + variables.put("users",nextList); + taskService.complete(taskId, variables); + WorkFlow workFlow = new WorkFlow(); + workFlow.setBusinessKey(businessKey); + workFlow.setProcessInstanceId(processInstanceId); + return workFlow; + } + public WorkFlow approveProjectInfo(String taskId,String flag,String comment,String status){ + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + // 获取当前任务 + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + String processInstanceId = task.getProcessInstanceId(); + //获取当前模型 + BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); + // 获取当前节点 + FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); + + UserTask userTask = (UserTask) flowElement; + WorkFlow workFlow = new WorkFlow(); + workFlow.setUserTask(userTask.getName()); + HashMap hashMap = new HashMap<>(); + if("3".equals(flag)){ + taskService.setVariableLocal(taskId,"approvalStatue",flag); + taskService.addComment(taskId,processInstanceId,comment);//添加审批意见 + runtimeService.deleteProcessInstance(processInstanceId,"发起人删除"); + return workFlow; + }else if("2".equals(flag)){ + callBack(processInstanceId,flag); + + return workFlow; + } + if("1".equals(status)){ + if(!"管理单位审批".equals(userTask.getName())){ + //搞到当前userTask的出处 + List outgoingFlows = userTask.getOutgoingFlows(); + //直接获得目标元素 + FlowElement targetFlowElement = outgoingFlows.get(0).getTargetFlowElement(); + //转换一下类型 + UserTask nextUserTask = (UserTask) targetFlowElement; + String nextUserTaskName = nextUserTask.getName(); + + if("监管单位审批".equals(nextUserTaskName)){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752895307869614081"); + arrayList.add("1752895591849160705"); + hashMap.put("users",arrayList); + }else if("管理单位审批".equals(nextUserTaskName)){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752893978598207490"); + hashMap.put("users",arrayList); + //TODO 流程审批通过,需要改变项目状态 + }else { + if(!"管理单位审批".equals(userTask.getName())){ + throw new RuntimeException("找不到下一个节点"); + } + } + } + }else if("2".equals(status)){ + if(!"流程审批二".equals(userTask.getName())){ + //搞到当前userTask的出处 + List outgoingFlows = userTask.getOutgoingFlows(); + //直接获得目标元素 + FlowElement targetFlowElement = outgoingFlows.get(0).getTargetFlowElement(); + //转换一下类型 + UserTask nextUserTask = (UserTask) targetFlowElement; + String nextUserTaskName = nextUserTask.getName(); + + if("流程审批一".equals(nextUserTaskName)){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752895307869614081"); + arrayList.add("1752895591849160705"); + hashMap.put("users",arrayList); + }else if("流程审批二".equals(nextUserTaskName)){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752893978598207490"); + hashMap.put("users",arrayList); + //TODO 流程审批通过,需要改变项目状态 + }else { + if(!"流程审批二".equals(userTask.getName())){ + throw new RuntimeException("找不到下一个节点"); + } + } + } + }else if("3".equals(status)){ + if(!"计划审批二".equals(userTask.getName())){ + //搞到当前userTask的出处 + List outgoingFlows = userTask.getOutgoingFlows(); + //直接获得目标元素 + FlowElement targetFlowElement = outgoingFlows.get(0).getTargetFlowElement(); + //转换一下类型 + UserTask nextUserTask = (UserTask) targetFlowElement; + String nextUserTaskName = nextUserTask.getName(); + + if("计划审批一".equals(nextUserTaskName)){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752895307869614081"); + arrayList.add("1752895591849160705"); + hashMap.put("users",arrayList); + }else if("计划审批二".equals(nextUserTaskName)){ + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1752893978598207490"); + hashMap.put("users",arrayList); + //TODO 流程审批通过,需要改变项目状态 + }else { + if(!"计划审批二".equals(userTask.getName())){ + throw new RuntimeException("找不到下一个节点"); + } + } + } + } + taskService.claim(task.getId(), userId);//拾取任务 + Authentication.setAuthenticatedUserId(userId);//添加审批人 + taskService.setVariableLocal(taskId,"approvalStatue",flag); + taskService.addComment(taskId,processInstanceId,comment);//添加审批意见 + hashMap.put("type",flag); + taskService.complete(taskId, hashMap); + //Comment comment1 = taskService.getComment(taskId); + return workFlow; + } + public void callBack(String processId,String flag) { + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + String userId = currentUser.getId(); + //通过流程id查找到当前的任务 + List tasks= taskService.createTaskQuery() + .processInstanceId(processId).orderByTaskCreateTime().desc() + .list(); + //tasks.get(0).setAssignee("1748190800971665409"); + //如果为空或者小于等于0则证明没有可查看到的任务 + if (tasks == null||tasks.size()<=0) { + System.out.println("当前没有任务或者任务已执行完了"); + } + //查看所有走过的历史任务 + List htlist = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processId) + .finished().orderByHistoricTaskInstanceEndTime().desc() + .list(); + if (htlist == null||htlist.size()<=0) { + System.out.println("请先提交任务"); + } + String myTaskId = null; + HistoricTaskInstance myTask = null; + //前一个任务节点,也就是提交人 拿到前一个任务 + for (HistoricTaskInstance hti : htlist) { + //回退到zhangsan也就是任务A,业务中这里就是当前登录的用户名 TODO:从登录名拿 + if (userId.equals(hti.getAssignee())) { + myTaskId = hti.getId(); +// taskService.set +// tasks.get(0).setName(""); + myTask = hti; + break; + } + } + + if (myTask == null) { + System.out.println("这个任务不是你的任务"); + } + //流程定义id + String processDefinitionId = myTask.getProcessDefinitionId(); + + //整个流程节点对象 + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + + //我的节点 + String myActivityId = null; + //历史节点完成节点 + List haiList = + historyService + .createHistoricActivityInstanceQuery() + .executionId(myTask.getExecutionId()) + .finished() + .list(); + //拿到我的节点 _3 + for (HistoricActivityInstance hai : haiList) { + if (myTaskId.equals(hai.getTaskId())) { + myActivityId = hai.getActivityId(); + break; + } + } + //我的流程节点 + FlowNode myFlowNode = + (FlowNode) bpmnModel.getMainProcess().getFlowElement(myActivityId); + //当前执行对象 + Execution execution = runtimeService.createExecutionQuery() + .executionId(tasks.get(0).getExecutionId()).singleResult(); + //当任务执行节点_4 + String activityId = execution.getActivityId(); + + System.out.println(activityId); + //当前流程节点对象 + FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess() + .getFlowElement(activityId); +// flowNode.getName() 节点名称 + //记录原活动方向出方向 + List oriSequenceFlows = new ArrayList(); + oriSequenceFlows.addAll(flowNode.getOutgoingFlows()); + + //清理活动方向 + flowNode.getOutgoingFlows().clear(); + + //建立新方向 + List newSequenceFlowList = new ArrayList(); + SequenceFlow newSequenceFlow = new SequenceFlow(); + newSequenceFlow.setId("newSequenceFlowId"); + newSequenceFlow.setSourceFlowElement(flowNode); + newSequenceFlow.setTargetFlowElement(myFlowNode); + newSequenceFlowList.add(newSequenceFlow); + flowNode.setOutgoingFlows(newSequenceFlowList); + //设置操作人记录 和备注信息 + Authentication.setAuthenticatedUserId(userId); + taskService.claim(tasks.get(0).getId(),userId); + taskService.setVariableLocal(tasks.get(0).getId(),"approvalStatue",flag); + taskService.addComment(tasks.get(0).getId(), tasks.get(0).getProcessInstanceId(), "上一节点撤回"); + String taskId= tasks.get(0).getId(); + //完成任务 +// if (tasks.size() > 1) { +// //会签撤回 +// HashMap variables = new HashMap<>(); +// variables.put("pass",true); +//// variables.put("param","y"); +// taskService.complete(taskId,variables); +// //恢复原方向 +// flowNode.setOutgoingFlows(oriSequenceFlows); +// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(tasks.get(0).getProcessInstanceId()).singleResult(); +// //更新数据库 从新设置state为未提交状态 +// Apply apply = new Apply(); +// apply.setCode(processInstance.getBusinessKey()); +// apply.setState(0); +// +// +// return applyService.updateByCode(apply); +// } + //普通撤回 + ArrayList arrayList = new ArrayList<>(); + HashMap hashMap = new HashMap<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add(userId); + hashMap.put("users",arrayList); + taskService.complete(taskId,hashMap); + //恢复原方向 + flowNode.setOutgoingFlows(oriSequenceFlows); + } +} diff --git a/huzhou/src/main/java/org/jeecg/modules/huzhou/vo/ProjectApproveOV.java b/huzhou/src/main/java/org/jeecg/modules/huzhou/vo/ProjectApproveOV.java new file mode 100644 index 0000000..61d0d7d --- /dev/null +++ b/huzhou/src/main/java/org/jeecg/modules/huzhou/vo/ProjectApproveOV.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.huzhou.vo; + +import lombok.Data; +import org.jeecg.modules.huzhou.entity.HuzhouProjectinfo; +import org.springframework.web.multipart.MultipartFile; +@Data +public class ProjectApproveOV { + private String taskId; + private String flag; + private String comment; + private String projectid; + private String status; + private String isEdit; + private HuzhouProjectinfo projectInfo; + + private MultipartFile[] file; +} diff --git a/huzhou/src/main/resources/mapper/HuzhouUserprojectMapper.xml b/huzhou/src/main/resources/mapper/HuzhouUserprojectMapper.xml new file mode 100644 index 0000000..4a05c24 --- /dev/null +++ b/huzhou/src/main/resources/mapper/HuzhouUserprojectMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/pom.xml b/jeecg-module-system/jeecg-system-biz/pom.xml index 31c7899..b044951 100644 --- a/jeecg-module-system/jeecg-system-biz/pom.xml +++ b/jeecg-module-system/jeecg-system-biz/pom.xml @@ -39,11 +39,15 @@ drag-free 1.0.2 - + + org.springframework.security + spring-security-core + + diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java index a33f506..7b5fb98 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/ISysUserService.java @@ -14,6 +14,7 @@ import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.model.SysUserSysDepartModel; import org.jeecg.modules.system.vo.lowapp.DepartAndUserInfo; import org.jeecg.modules.system.vo.lowapp.UpdateDepartInfo; +import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.ModelAndView; @@ -31,7 +32,7 @@ import java.util.Set; * @Author scott * @since 2018-12-20 */ -public interface ISysUserService extends IService { +public interface ISysUserService extends IService, UserDetailsService { /** * 查询用户数据列表 diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java index bb64c87..0003506 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java @@ -55,6 +55,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -1798,6 +1802,19 @@ public class SysUserServiceImpl extends ServiceImpl impl systemSendMsgHandle.sendMessage(messageDTO); //update-end---author:wangshuai ---date:20230710 for:【QQYUN-5731】导入用户时,没有提醒------------ } + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + SysUser sysUser = userMapper.selectById(username); + if(sysUser!=null){ + Collection authorities = new ArrayList<>(); + User user = new User(sysUser.getUsername(), sysUser.getPassword(), authorities); + return user; + }else { + return null; + } + + } //======================================= end 用户与部门 用户列表导入 ========================================= } diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index 288375b..2649774 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -7,7 +7,7 @@ server: include-stacktrace: ALWAYS include-message: ALWAYS servlet: - context-path: /jeecg-boot #可以修改 + context-path: /guoyan #可以修改/jeecg-boot compression: enabled: true min-response-size: 1024 @@ -174,7 +174,7 @@ mybatis-plus: table-underline: true configuration: # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 - #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 返回类型为Map,显示null对应的字段 call-setters-on-nulls: true #jeecg专用配置 @@ -199,7 +199,8 @@ jeecg: app: http://localhost:8051 path: #文件上传根目录 设置 - upload: /opt/upFiles +# upload: /opt/upFiles + upload: D:/ce #webapp文件路径 webapp: /opt/webapp shiro: @@ -245,14 +246,14 @@ jeecg: logPath: logs/jeecg/job/jobhandler/ logRetentionDays: 30 #分布式锁配置 - redisson: - address: 127.0.0.1:6379 - password: - type: STANDALONE - enabled: true +# redisson: +# address: 127.0.0.1:6379 +# password: +# type: STANDALONE +# enabled: true #cas单点登录 cas: - prefixUrl: http://cas.example.org:8443/cas + prefixUrl: aaaaa #http://cas.example.org:8443/cas #Mybatis输出sql日志 logging: level: diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml index 092e517..caa4dd5 100644 --- a/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/application-prod.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 9001 tomcat: max-swallow-size: -1 error: @@ -7,7 +7,7 @@ server: include-stacktrace: ALWAYS include-message: ALWAYS servlet: - context-path: /jeecg-boot + context-path: /guoyan compression: enabled: true min-response-size: 1024 @@ -24,17 +24,29 @@ spring: multipart: max-file-size: 10MB max-request-size: 10MB - mail: - host: smtp.163.com - username: ?? - password: ?? - properties: - mail: - smtp: - auth: true - starttls: - enable: true - required: true + activiti: + #1.flase:默认值。activiti在启动时,对比数据库表中保存的版本,如果没有表或者版本不匹配,将抛出异常 + #2.true: activiti会对数据库中所有表进行更新操作。如果表不存在,则自动创建 + #3.create_drop: 在activiti启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表) + #4.drop-create: 在activiti启动时删除原来的旧表,然后在创建新表(不需要手动关闭引擎) + database-schema-update: true + # 检测历史信息表是否存在,activiti7默认不生成历史信息表,开启历史表 + db-history-used: true + # 历史记录存储等级 + history-level: full + check-process-definitions: true + process-definition-location-prefix: classpath:/processes/ +# mail: +# host: smtp.163.com +# username: ?? +# password: ?? +# properties: +# mail: +# smtp: +# auth: true +# starttls: +# enable: true +# required: true ## quartz定时任务,采用数据库方式 quartz: job-store-type: jdbc @@ -133,9 +145,9 @@ spring: slow-sql-millis: 5000 datasource: master: - url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://218.246.6.173:3306/guoyan_huozhou?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root - password: root + password: '1q2w#E$R1qaz@WSX' driver-class-name: com.mysql.cj.jdbc.Driver # 多数据源配置 #multi-datasource1: @@ -148,7 +160,7 @@ spring: database: 0 host: 127.0.0.1 port: 6379 - password: '' + password: 1q2wE$R1qaz@WSX #mybatis plus 设置 mybatis-plus: mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml @@ -180,48 +192,48 @@ jeecg: #签名拦截接口 signUrls: /sys/dict/getDictItems/*,/sys/dict/loadDict/*,/sys/dict/loadDictOrderByValue/*,/sys/dict/loadDictItem/*,/sys/dict/loadTreeData,/sys/api/queryTableDictItemsByCode,/sys/api/queryFilterTableDictInfo,/sys/api/queryTableDictByKeys,/sys/api/translateDictFromTable,/sys/api/translateDictFromTableByKeys # local\minio\alioss - uploadType: alioss + uploadType: local # 前端访问地址 domainUrl: pc: http://localhost:3100 app: http://localhost:8051 path: #文件上传根目录 设置 - upload: /opt/jeecg-boot/upload + upload: /opt/guoyan/upload #webapp文件路径 - webapp: /opt/jeecg-boot/webapp + webapp: /opt/guoyan/webapp shiro: excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/jmreport/bigscreen2/**,/api/getUserInfo #阿里云oss存储和大鱼短信秘钥配置 - oss: - accessKey: ?? - secretKey: ?? - endpoint: oss-cn-beijing.aliyuncs.com - bucketName: jeecgdev - staticDomain: https://static.jeecg.com - # ElasticSearch 设置 - elasticsearch: - cluster-name: jeecg-ES - cluster-nodes: 127.0.0.1:9200 - check-enabled: true - # 在线预览文件服务器地址配置 - file-view-domain: http://fileview.jeecg.com - # minio文件上传 - minio: - minio_url: http://minio.jeecg.com - minio_name: ?? - minio_pass: ?? - bucketName: otatest +# oss: +# accessKey: ?? +# secretKey: ?? +# endpoint: oss-cn-beijing.aliyuncs.com +# bucketName: jeecgdev +# staticDomain: https://static.jeecg.com +# # ElasticSearch 设置 +# elasticsearch: +# cluster-name: jeecg-ES +# cluster-nodes: 127.0.0.1:9200 +# check-enabled: true +# # 在线预览文件服务器地址配置 + file-view-domain: aaaa #http://fileview.jeecg.com +# # minio文件上传 +# minio: +# minio_url: http://minio.jeecg.com +# minio_name: ?? +# minio_pass: ?? +# bucketName: otatest #大屏报表参数设置 - jmreport: - #多租户模式,默认值为空(created:按照创建人隔离、tenant:按照租户隔离) (v1.6.2+ 新增) - saasMode: created - # 平台上线安全配置(v1.6.2+ 新增) - firewall: - # 数据源安全 (开启后,不允许使用平台数据源、SQL解析加签并且不允许查询数据库) - dataSourceSafe: true - # 低代码开发模式(dev:开发模式,prod:发布模式—关闭在线报表设计功能,分配角色admin、lowdeveloper可以放开限制) - lowCodeMode: prod +# jmreport: +# #多租户模式,默认值为空(created:按照创建人隔离、tenant:按照租户隔离) (v1.6.2+ 新增) +# saasMode: created +# # 平台上线安全配置(v1.6.2+ 新增) +# firewall: +# # 数据源安全 (开启后,不允许使用平台数据源、SQL解析加签并且不允许查询数据库) +# dataSourceSafe: true +# # 低代码开发模式(dev:开发模式,prod:发布模式—关闭在线报表设计功能,分配角色admin、lowdeveloper可以放开限制) +# lowCodeMode: prod #xxl-job配置 xxljob: enabled: false @@ -234,14 +246,14 @@ jeecg: logPath: logs/jeecg/job/jobhandler/ logRetentionDays: 30 #分布式锁配置 - redisson: - address: 127.0.0.1:6379 - password: - type: STANDALONE - enabled: true +# redisson: +# address: 127.0.0.1:6379 +# password: +# type: STANDALONE +# enabled: true #cas单点登录 cas: - prefixUrl: http://cas.example.org:8443/cas + prefixUrl: aaaaaaa #http://cas.example.org:8443/cas #Mybatis输出sql日志 logging: level: @@ -257,27 +269,27 @@ knife4j: username: jeecg password: jeecg1314 #第三方登录 -justauth: - enabled: true - type: - GITHUB: - client-id: ?? - client-secret: ?? - redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/github/callback - WECHAT_ENTERPRISE: - client-id: ?? - client-secret: ?? - redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/wechat_enterprise/callback - agent-id: ?? - DINGTALK: - client-id: ?? - client-secret: ?? - redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/dingtalk/callback - WECHAT_OPEN: - client-id: ?? - client-secret: ?? - redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/wechat_open/callback - cache: - type: default - prefix: 'demo::' - timeout: 1h +#justauth: +# enabled: true +# type: +# GITHUB: +# client-id: ?? +# client-secret: ?? +# redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/github/callback +# WECHAT_ENTERPRISE: +# client-id: ?? +# client-secret: ?? +# redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/wechat_enterprise/callback +# agent-id: ?? +# DINGTALK: +# client-id: ?? +# client-secret: ?? +# redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/dingtalk/callback +# WECHAT_OPEN: +# client-id: ?? +# client-secret: ?? +# redirect-uri: http://sso.test.com:8080/jeecg-boot/sys/thirdLogin/wechat_open/callback +# cache: +# type: default +# prefix: 'demo::' +# timeout: 1h diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/process/initiatesProjects.bpmn20.xml b/jeecg-module-system/jeecg-system-start/src/main/resources/process/initiatesProjects.bpmn20.xml new file mode 100644 index 0000000..cb85e58 --- /dev/null +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/process/initiatesProjects.bpmn20.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + ${type==1} + + + ${type==0} + + + ${type==0} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/process/initiatesProjects.png b/jeecg-module-system/jeecg-system-start/src/main/resources/process/initiatesProjects.png new file mode 100644 index 0000000..a17195e Binary files /dev/null and b/jeecg-module-system/jeecg-system-start/src/main/resources/process/initiatesProjects.png differ diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目计划审批流程.bpmn20.xml b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目计划审批流程.bpmn20.xml new file mode 100644 index 0000000..6aaac69 --- /dev/null +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目计划审批流程.bpmn20.xml @@ -0,0 +1,68 @@ + + + + + + + + + + ${type==1} + + + ${type==0} + + + + ${type==1} + + + ${type==0} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目计划审批流程.png b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目计划审批流程.png new file mode 100644 index 0000000..0b3183e Binary files /dev/null and b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目计划审批流程.png differ diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目资料上传流程.bpmn20.xml b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目资料上传流程.bpmn20.xml new file mode 100644 index 0000000..367e488 --- /dev/null +++ b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目资料上传流程.bpmn20.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + ${type==1} + + + + ${type==0} + + + ${type==0} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目资料上传流程.png b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目资料上传流程.png new file mode 100644 index 0000000..9fc5e02 Binary files /dev/null and b/jeecg-module-system/jeecg-system-start/src/main/resources/process/项目资料上传流程.png differ diff --git a/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/message/test/SendMessageTest.java b/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/message/test/SendMessageTest.java index 204f2f5..6ac2dd6 100644 --- a/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/message/test/SendMessageTest.java +++ b/jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/modules/message/test/SendMessageTest.java @@ -2,20 +2,21 @@ package org.jeecg.modules.message.test; import com.alibaba.fastjson.JSONObject; import com.aliyuncs.exceptions.ClientException; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.bpmn.model.FlowElement; -import org.activiti.bpmn.model.SequenceFlow; -import org.activiti.bpmn.model.UserTask; +import org.activiti.bpmn.model.*; import org.activiti.engine.HistoryService; import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; import org.activiti.engine.TaskService; import org.activiti.engine.history.HistoricActivityInstance; +import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.history.HistoricTaskInstance; +import org.activiti.engine.history.HistoricVariableInstance; +import org.activiti.engine.impl.identity.Authentication; import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.Execution; import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.Comment; import org.activiti.engine.task.Task; import org.activiti.spring.integration.Activiti; import org.apache.shiro.SecurityUtils; @@ -32,16 +33,14 @@ import org.jeecg.common.constant.enums.SysAnnmentTypeEnum; import org.jeecg.common.system.api.ISysBaseAPI; import org.jeecg.common.util.DySmsHelper; import org.junit.Test; +import org.junit.platform.commons.util.StringUtils; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.CollectionUtils; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; /** * @Description: 消息推送测试 @@ -65,9 +64,9 @@ public class SendMessageTest { public void createproess(){ Deployment deployment = repositoryService .createDeployment() - .addClasspathResource("process/initiatesProjects.bpmn20.xml") - .addClasspathResource("process/initiatesProjects.png") - .name("项目入库申请流程") + .addClasspathResource("process/项目计划审批流程.bpmn20.xml") + .addClasspathResource("process/项目计划审批流程.png") + .name("项目资料上传流程") .deploy(); System.out.println("deployment.getId() = " + deployment.getId()); System.out.println("deployment.getName() = " + deployment.getName()); @@ -120,14 +119,22 @@ public class SendMessageTest { */ @Test public void getProcessInstance() { - String processInstanceId = "1d1d364f-b9ca-11ee-a2e6-f43bd81684b1"; - ProcessInstance processInstance = this.runtimeService.createProcessInstanceQuery() - .processInstanceId(processInstanceId) - .singleResult(); - System.out.println("ProcessInstanceId:" + processInstance.getProcessInstanceId()); - System.out.println("ProcessDefinitionId:" + processInstance.getProcessDefinitionId()); - System.out.println("isEnded:" + processInstance.isEnded()); - System.out.println("isSuspended:" + processInstance.isSuspended()); +// String processInstanceId = "c5d4854b-b9e6-11ee-bec0-f43bd81684b1"; +// ProcessInstance processInstance = this.runtimeService.createProcessInstanceQuery() +// .processInstanceId(processInstanceId) +// .singleResult(); +// System.out.println("ProcessInstanceId:" + processInstance.getProcessInstanceId()); +// System.out.println("ProcessDefinitionId:" + processInstance.getProcessDefinitionId()); +// System.out.println("isEnded:" + processInstance.isEnded()); +// System.out.println("isSuspended:" + processInstance.isSuspended()); + Task task = taskService.createTaskQuery().taskId("139023df-c28b-11ee-80e5-f43bd81684b1").singleResult(); + String processInstanceId = task.getProcessInstanceId(); + //获取当前模型 + BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId()); + // 获取当前节点 + FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); + + UserTask userTask = (UserTask) flowElement; } /** * 查询流程实例列表 @@ -141,6 +148,18 @@ public class SendMessageTest { System.out.println("ProcessDefinitionId:" + processInstance.getProcessDefinitionId()); System.out.println("isEnded:" + processInstance.isEnded()); System.out.println("isSuspended:" + processInstance.isSuspended()); + runtimeService.deleteProcessInstance(processInstance.getProcessInstanceId(),"发起人删除"); + + }); + } + } + @Test + public void ldetel() { + List list = this.historyService.createHistoricProcessInstanceQuery().list(); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(processInstance -> { + + }); } } @@ -220,11 +239,38 @@ public class SendMessageTest { */ @Test public void completeTask() { - String taskId = "c594f43d-b9d5-11ee-91b9-f43bd81684b1"; + String taskId = "cb4ad75c-bb3e-11ee-b45e-f43bd81684b1"; Map variables = new HashMap<>(); variables.put("type",1); + ArrayList arrayList = new ArrayList<>(); + //设置下一个节点处理人 + //使用角色查询 + Authentication.setAuthenticatedUserId("12314");//添加审批人 + String comment = "同意"; + taskService.addComment(taskId,"278f4341-ba89-11ee-8201-f43bd81684b1",comment); + arrayList.add("1748190800971665409"); + arrayList.add("1749362824117030913"); + variables.put("users",arrayList); this.taskService.complete(taskId, variables); } + @Test + public void testClaimTask(){ + //返回所有的任务 + List tasks = taskService.createTaskQuery().taskId("75d63248-bbf4-11ee-ab92-f43bd81684b1").list(); +// taskService.setAssignee("c42917dc-bc10-11ee-8f67-f43bd81684b1","1748190800971665409"); + for (Task task : tasks) { + System.out.println("task.getId() = " + task.getId()); + System.out.println("task.getName() = " + task.getName()); + task.setName("监管单位撤回"); +// taskService.claim(task.getId(), "1748190800971665409");//拾取任务 + + + } + } + @Test + public void deleteprocess(){ + runtimeService.deleteProcessInstance("c5d4854b-b9e6-11ee-bec0-f43bd81684b1","发起人删除"); + } /** * 根据用户名查询历史记录 */ @@ -242,8 +288,173 @@ public class SendMessageTest { }); } } +@Test + public void getlishijilv(){ + String processinstanceid = "c5d4854b-b9e6-11ee-bec0-f43bd81684b1"; + List list = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processinstanceid) + .orderByTaskCreateTime().asc().list(); + List> approvalEntityList = new ArrayList<>(); +// HashMap hashMap = new HashMap<>(); + String approvalSuggestion = ""; + Object approvalStatus = ""; + HistoricVariableInstance historicVariableInstance = null; + List commentList = null; + for(HistoricTaskInstance item : list){ + HashMap hashMap = new HashMap<>(); + commentList = taskService.getTaskComments(item.getId()); + if(commentList != null && !commentList.isEmpty()) { + approvalSuggestion = commentList.get(0).getFullMessage(); + }else{ + approvalSuggestion = ""; + } + historicVariableInstance = historyService.createHistoricVariableInstanceQuery() + .taskId(item.getId()).variableName("approvalStatus").singleResult(); + if(historicVariableInstance != null) { + approvalStatus = historicVariableInstance.getValue(); + hashMap.put("approvalStatue",StringUtils.isBlank(approvalStatus.toString()) ? "0" : approvalStatus.toString()); + + } + hashMap.put("operateDate",item.getEndTime()); + hashMap.put("operator",item.getAssignee()); + hashMap.put("taskName",item.getName()); + hashMap.put("comment",approvalSuggestion); + approvalEntityList.add(hashMap); + } + System.out.println(approvalEntityList.toString()); + HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId("c5d4854b-b9e6-11ee-bec0-f43bd81684b1").singleResult(); + System.out.println(historicProcessInstance.toString()); +} +@Test + public void callBack() { + String processId="ee972c54-bbea-11ee-8413-f43bd81684b1"; + //通过流程id查找到当前的任务 + List tasks= taskService.createTaskQuery() + .processInstanceId(processId).orderByTaskCreateTime().desc() + .list(); + //tasks.get(0).setAssignee("1748190800971665409"); + //如果为空或者小于等于0则证明没有可查看到的任务 + if (tasks == null||tasks.size()<=0) { + System.out.println("当前没有任务或者任务已执行完了"); + } + //查看所有走过的历史任务 + List htlist = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processId) + .finished().orderByHistoricTaskInstanceEndTime().desc() + .list(); + if (htlist == null||htlist.size()<=0) { + System.out.println("请先提交任务"); + } + String myTaskId = null; + HistoricTaskInstance myTask = null; + //前一个任务节点,也就是提交人 拿到前一个任务 + for (HistoricTaskInstance hti : htlist) { + //回退到zhangsan也就是任务A,业务中这里就是当前登录的用户名 TODO:从登录名拿 + if ("1748190800971665409".equals(hti.getAssignee())) { + myTaskId = hti.getId(); +// taskService.set +// tasks.get(0).setName(""); + myTask = hti; + break; + } + } + if (myTask == null) { + System.out.println("这个任务不是你的任务"); + } + //流程定义id + String processDefinitionId = myTask.getProcessDefinitionId(); + + //整个流程节点对象 + BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); + + //我的节点 + String myActivityId = null; + //历史节点完成节点 + List haiList = + historyService + .createHistoricActivityInstanceQuery() + .executionId(myTask.getExecutionId()) + .finished() + .list(); + //拿到我的节点 _3 + for (HistoricActivityInstance hai : haiList) { + if (myTaskId.equals(hai.getTaskId())) { + myActivityId = hai.getActivityId(); + break; + } + } + //我的流程节点 + FlowNode myFlowNode = + (FlowNode) bpmnModel.getMainProcess().getFlowElement(myActivityId); + //当前执行对象 + Execution execution = runtimeService.createExecutionQuery() + .executionId(tasks.get(0).getExecutionId()).singleResult(); + //当任务执行节点_4 + String activityId = execution.getActivityId(); + + System.out.println(activityId); + //当前流程节点对象 + FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess() + .getFlowElement(activityId); +// flowNode.getName() 节点名称 + //记录原活动方向出方向 + List oriSequenceFlows = new ArrayList(); + oriSequenceFlows.addAll(flowNode.getOutgoingFlows()); + + //清理活动方向 + flowNode.getOutgoingFlows().clear(); + + //建立新方向 + List newSequenceFlowList = new ArrayList(); + SequenceFlow newSequenceFlow = new SequenceFlow(); + newSequenceFlow.setId("newSequenceFlowId"); + newSequenceFlow.setSourceFlowElement(flowNode); + newSequenceFlow.setTargetFlowElement(myFlowNode); + newSequenceFlowList.add(newSequenceFlow); + flowNode.setOutgoingFlows(newSequenceFlowList); + //设置操作人记录 和备注信息 + Authentication.setAuthenticatedUserId("1748190800971665409"); + taskService.claim(tasks.get(0).getId(),"1748190800971665409"); + taskService.setVariableLocal(tasks.get(0).getId(),"approvalStatue","2"); + taskService.addComment(tasks.get(0).getId(), tasks.get(0).getProcessInstanceId(), "撤回一下下"); + String taskId= tasks.get(0).getId(); + //完成任务 +// if (tasks.size() > 1) { +// //会签撤回 +// HashMap variables = new HashMap<>(); +// variables.put("pass",true); +//// variables.put("param","y"); +// taskService.complete(taskId,variables); +// //恢复原方向 +// flowNode.setOutgoingFlows(oriSequenceFlows); +// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(tasks.get(0).getProcessInstanceId()).singleResult(); +// //更新数据库 从新设置state为未提交状态 +// Apply apply = new Apply(); +// apply.setCode(processInstance.getBusinessKey()); +// apply.setState(0); +// +// +// return applyService.updateByCode(apply); +// } + //普通撤回 + ArrayList arrayList = new ArrayList<>(); + HashMap hashMap = new HashMap<>(); + //设置下一个节点处理人 + //使用角色查询 + arrayList.add("1748190800971665409"); + hashMap.put("users",arrayList); + tasks.get(0).setName("dddddd"); + taskService.complete(taskId,hashMap); + //恢复原方向 + flowNode.setOutgoingFlows(oriSequenceFlows); + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(tasks.get(0).getProcessInstanceId()).singleResult(); +// //更新数据库 从新设置state为未提交状态 +// Apply apply = new Apply(); +// apply.setCode(processInstance.getBusinessKey()); +// apply.setState(0); + } diff --git a/pom.xml b/pom.xml index ebe0a77..9481703 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 3.6.1 - 1.8 + 11 UTF-8 @@ -405,8 +405,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + 11 + 11 UTF-8