提交 c3cbe18c authored 作者: zhoushaopan's avatar zhoushaopan

新增页面和实体的绑定

上级 5088737b
......@@ -13,6 +13,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileNotFoundException;
import java.util.ArrayList;
......
package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import com.tykj.workflowcore.workflow_editer.service.FormPageService;
import com.tykj.workflowcore.workflow_editer.vo.FormPageVo;
import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -25,22 +28,32 @@ public class FormPageController {
@Autowired
private FormPageService formPageService;
@Autowired
private PageEntityService pageEntityService;
@ApiOperation("保存页面")
@PostMapping("/savePage")
public Long savePage(@RequestBody FormPage formPage){
return formPageService.savePage(formPage);
public Long savePage(@RequestBody InFormPageVo inFormPageVo){
List<String> entityIds = inFormPageVo.getEntityIds();
for (String entityId : entityIds) {
PageEntity pageEntity = new PageEntity();
pageEntity.setEntityId(entityId);
pageEntity.setPageId(formPageService.savePage(inFormPageVo));
pageEntityService.savePageEntity(pageEntity);
}
return formPageService.savePage(inFormPageVo);
}
@ApiOperation("回显页面")
@GetMapping("/EchoPage/{id}")
public FormPageVo EchoPage(@PathVariable("id") Long id){
public FormPage EchoPage(@PathVariable("id") Long id){
return formPageService.getPage(id);
}
@ApiOperation("查看页面")
@GetMapping("/findPages")
public List<FormPageVo> findPages(){
public List<OutFormPageVo> findPages(){
return formPageService.getAllPages();
}
......
package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
import io.swagger.annotations.Api;
......@@ -9,6 +10,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* ClassName: PageEntityController
* Package: com.tykj.controller
......@@ -31,4 +34,9 @@ public class PageEntityController {
pageEntityService.savePageEntity(pageEntity);
}
@PostMapping("/findByPages")
public List<TableInfo> findByPages(List<Integer> pageIds){
return pageEntityService.findByPageIds(pageIds);
}
}
......@@ -73,6 +73,18 @@ public class WorkFlowController {
workFlowService.completeTask(taskVo);
}
@PostMapping("/getVariable")
@ApiOperation("获取变量池")
public void getVariable(){
// workFlowService.setVariables()
}
@PostMapping("/isTransferTask")
@ApiOperation("是否转交任务")
public void isTransferTask(@RequestBody TransferTask transferTask){
workFlowService.transferTask(transferTask);
}
@PostMapping("/isSuspension")
@ApiOperation("是否挂起")
public void isSuspension(@RequestBody SuspendVo suspendVo){
......
package com.tykj.workflowcore.workflow_editer.entity;
import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import javax.persistence.*;
import java.util.Date;
......@@ -50,4 +53,15 @@ public class FormPage {
@ApiModelProperty("创建的时间")
private Date createTime;
@ApiModelProperty("修改的时间")
private Date updateTime;
@ApiModelProperty("json描述文件")
private String descFile;
public OutFormPageVo toEntityVo(){
OutFormPageVo outFormPageVo = new OutFormPageVo();
BeanUtils.copyProperties(this,outFormPageVo);
return outFormPageVo;
}
}
......@@ -10,6 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.ArrayList;
import java.util.List;
/**
* ClassName: PageEntity
......@@ -35,6 +37,5 @@ public class PageEntity {
private Long pageId;
@ApiModelProperty("实体类Id")
private Long entityId;
private String entityId;
}
package com.tykj.workflowcore.workflow_editer.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* ClassName: PageEntityVo
* Package: com.tykj.workflowcore.workflow_editer.entity
* Description:
* Datetime: 2021/3/9 10:32
*
* @Author: zsp
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class PageEntityVo {
private Long pageId;
private List<String> entityIds;
}
package com.tykj.workflowcore.workflow_editer.mapper;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* ClassName: PageEntityMapper
* Package: com.tykj.mapper
......@@ -13,4 +16,12 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @Author: zsp
*/
public interface PageEntityMapper extends JpaRepository<PageEntity,Long>, JpaSpecificationExecutor<PageEntity> {
/**
* 根据页面id查询
* @param pageId 页面id
* @return
*/
PageEntity findByPageId(Integer pageId);
}
package com.tykj.workflowcore.workflow_editer.service;
import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.vo.FormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -19,17 +20,17 @@ public interface FormPageService {
/**
* 保存页面
* @param formPage 页面实体
* @param inFormPageVo 页面实体
* @return 主键id
*/
Long savePage(@RequestBody FormPage formPage);
Long savePage(@RequestBody InFormPageVo inFormPageVo);
/**
* 根据页面id来进行回显
* @param id 页面id
* @return 页面信息
*/
FormPageVo getPage(@PathVariable("id") Long id);
FormPage getPage(@PathVariable("id") Long id);
/**
* 根据页面id删除页面
......@@ -41,6 +42,6 @@ public interface FormPageService {
* 查询全部页面
* @return 全部集合
*/
List<FormPageVo> getAllPages();
List<OutFormPageVo> getAllPages();
}
package com.tykj.workflowcore.workflow_editer.service;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import java.util.List;
/**
* ClassName: PageEntityService
* Package: com.tykj.service
......@@ -18,5 +21,12 @@ public interface PageEntityService {
*/
void savePageEntity(PageEntity pageEntity);
/**
* 根据页面id查询tableInfo
* @param pageIds 页面id
* @return
*/
List<TableInfo> findByPageIds(List<Integer> pageIds);
}
......@@ -98,10 +98,9 @@ public interface WorkFlowService {
/**
* 任务的转交
* @param taskId 任务id
* @param userId 转交人的id
* @param transferTask
*/
void transferTask(String taskId, Long userId);
void transferTask(TransferTask transferTask);
/**
* 是否挂起
......
......@@ -4,15 +4,15 @@ package com.tykj.workflowcore.workflow_editer.service.impl;
import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.mapper.FormPageMapper;
import com.tykj.workflowcore.workflow_editer.service.FormPageService;
import com.tykj.workflowcore.workflow_editer.vo.FormPageVo;
import org.springframework.beans.BeanUtils;
import com.tykj.workflowcore.workflow_editer.vo.InFormPageVo;
import com.tykj.workflowcore.workflow_editer.vo.OutFormPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import springfox.documentation.swagger2.mappers.ModelMapper;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -30,19 +30,20 @@ public class FormPageServiceImpl implements FormPageService {
private FormPageMapper formPageMapper;
@Override
public Long savePage(@RequestBody FormPage formPage) {
public Long savePage(@RequestBody InFormPageVo inFormPageVo) {
inFormPageVo.setCreateTime(new Date());
FormPage formPage = inFormPageVo.toEntity();
FormPage formPage1 = formPageMapper.save(formPage);
Long id = formPage1.getId();
return id;
}
@Override
public FormPageVo getPage(@PathVariable("id") Long id) {
public FormPage getPage(@PathVariable("id") Long id) {
FormPage formPage = formPageMapper.findById(id).get();
FormPageVo formPageVo = new FormPageVo();
BeanUtils.copyProperties(formPage,formPageVo);
return formPageVo;
//时间排序
return formPage;
}
@Override
......@@ -51,15 +52,16 @@ public class FormPageServiceImpl implements FormPageService {
}
@Override
public List<FormPageVo> getAllPages() {
public List<OutFormPageVo> getAllPages() {
ArrayList<FormPageVo> formPageVos = new ArrayList<>();
ArrayList<OutFormPageVo> formPageVos = new ArrayList<>();
List<FormPage> formPages = formPageMapper.findAll();
for (FormPage formPage : formPages) {
FormPageVo formPageVo = new FormPageVo();
BeanUtils.copyProperties(formPage,formPageVo);
formPageVos.add(formPageVo);
// FormPageVo formPageVo = new FormPageVo();
// BeanUtils.copyProperties(formPage,formPageVo);
// formPageVos.add(formPageVo);
OutFormPageVo outFormPageVo = formPage.toEntityVo();
formPageVos.add(outFormPageVo);
}
return formPageVos;
}
......
package com.tykj.workflowcore.workflow_editer.service.impl;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import com.tykj.workflowcore.workflow_editer.mapper.PageEntityMapper;
import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* ClassName: PageEntityServiceImpl
* Package: com.tykj.service.impl
......@@ -19,10 +24,22 @@ public class PageEntityServiceImpl implements PageEntityService {
@Autowired
private PageEntityMapper pageEntityMapper;
@Autowired
private TableInfoDao tableInfoDao;
@Override
public void savePageEntity(PageEntity pageEntity) {
pageEntityMapper.save(pageEntity);
}
@Override
public List<TableInfo> findByPageIds(List<Integer> pageIds) {
ArrayList<TableInfo> list = new ArrayList<>();
for (Integer pageId : pageIds) {
Long entityId = pageEntityMapper.findByPageId(pageId).getEntityId();
//根据entityId查询出实体类
TableInfo tableInfo = tableInfoDao.findById(entityId).get();
list.add(tableInfo);
}
return list;
}
}
......@@ -212,15 +212,14 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override
public void startFlow(@RequestBody StartFlowVo startFlowVo) {
//获取流程主键
String flowKey = startFlowVo.getFlowKey();
//设置流程发起人
WorkFlowUser currentUser = userService.getCurrentUser();
//调用业务服务接口 插入数据到记录表中 例如请假是插入请假表
Authentication.setAuthenticatedUserId(currentUser.getId()+"");
//获取变量池
Map<String, Object> map = startFlowVo.getMap();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(flowKey, map);
runtimeService.startProcessInstanceByKey(startFlowVo.getFlowKey(), startFlowVo.getMap());
}
......@@ -241,11 +240,10 @@ public class WorkFlowServiceImpl implements WorkFlowService {
Map<String, Object> map = new HashMap<>();
ProcessInstance processInstance =
runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
String startUserId = processInstance.getStartUserId();
map.put("taskName",task.getName());
map.put("taskDesc",task.getDescription());
map.put("createTime",task.getCreateTime());
map.put("promoter",startUserId);
map.put("promoter",processInstance.getStartUserId());
listMap.add(map);
}
return listMap;
......@@ -271,9 +269,11 @@ public class WorkFlowServiceImpl implements WorkFlowService {
taskService.addComment(task.getId(),processInstanceId,taskVo.getComments());
//先判断是不是表达式
if (taskVo.getConditionalExpression()!= null){
claimTask(task.getId(),userService.getCurrentUser().getId());
taskService.complete(task.getId());
}else {
map.put("handlingOpinion",taskVo.getHandlingOpinion());
claimTask(task.getId(),userService.getCurrentUser().getId());
taskService.complete(task.getId(),map);
}
......@@ -286,10 +286,11 @@ public class WorkFlowServiceImpl implements WorkFlowService {
}
@Override
public void transferTask(String taskId,Long userId) {
taskService.setAssignee(taskId,Long.toString(userId));
public void transferTask(TransferTask transferTask) {
taskService.setAssignee(transferTask.getTaskId(),transferTask.getUserId());
}
@Override
public void suspendOrActivateProcessDefinitionByKey(SuspendVo suspendVo) {
if (suspendVo.getSuspensionState() == 1){
......@@ -305,7 +306,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
}
@Override
public Map<String,Object> setVariables(@RequestBody Map<String,Object> maxMap) {
public Map<String,Object> setVariables(@RequestBody Map<String,Object> maxMap) {
Map<String, Object> map = new HashMap<>();
map.putAll(maxMap);
......
package com.tykj.workflowcore.workflow_editer.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ClassName: DeployedVo
* Package: com.tykj.vo
......@@ -31,4 +33,6 @@ public class DeployedVo {
@ApiModelProperty("流程名称")
private String flowName;
}
package com.tykj.workflowcore.workflow_editer.vo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import javax.persistence.Lob;
import java.util.Date;
import java.util.List;
/**
* ClassName: FormPageVo
......@@ -18,13 +22,13 @@ import javax.persistence.Lob;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FormPageVo {
public class InFormPageVo {
@ApiModelProperty("页面名称")
private String pageName;
@ApiModelProperty("创建的时间")
private String createTime;
@ApiModelProperty("页面描述")
private String pageDesc;
@ApiModelProperty("模板")
@Lob
......@@ -37,4 +41,24 @@ public class FormPageVo {
@ApiModelProperty("页面css")
@Lob
private String css;
@ApiModelProperty("创建的时间")
private Date createTime;
@ApiModelProperty("修改的时间")
private Date updateTime;
@ApiModelProperty("json描述文件")
private String descFile;
@ApiModelProperty("实体类")
private List<String> entityIds;
public FormPage toEntity(){
FormPage formPage = new FormPage();
BeanUtils.copyProperties(this,formPage);
return formPage;
}
}
package com.tykj.workflowcore.workflow_editer.vo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import java.util.Date;
import java.util.List;
/**
* ClassName: FormPageVo
* Package: com.tykj.vo
* Description:
* Datetime: 2021/3/3 13:32
*
* @Author: zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OutFormPageVo {
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("页面名称")
private String pageName;
@ApiModelProperty("页面描述")
private String pageDesc;
@ApiModelProperty("创建的时间")
private Date createTime;
@ApiModelProperty("修改的时间")
private Date updateTime;
public FormPage toEntity(){
FormPage formPage = new FormPage();
BeanUtils.copyProperties(this,formPage);
return formPage;
}
}
package com.tykj.workflowcore.workflow_editer.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ClassName: TransferTask
* Package: com.tykj.workflowcore.workflow_editer.vo
* Description:
* Datetime: 2021/3/8 13:56
*
* @Author: zsp
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class TransferTask {
private String userId;
private String taskId;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论