feat(web): 适配flowable
This commit is contained in:
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -1,6 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="mavenCentral" />
|
<option name="id" value="mavenCentral" />
|
||||||
<option name="name" value="mavenCentral" />
|
<option name="name" value="mavenCentral" />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.eshore.gringotts.web.domain.controller;
|
package com.eshore.gringotts.web.domain.controller;
|
||||||
|
|
||||||
|
import com.eshore.gringotts.web.configuration.amis.AmisResponse;
|
||||||
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
import com.eshore.gringotts.web.domain.base.controller.SimpleControllerSupport;
|
||||||
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
import com.eshore.gringotts.web.domain.base.entity.FileInfo;
|
||||||
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
import com.eshore.gringotts.web.domain.base.entity.SimpleListItem;
|
||||||
@@ -8,12 +9,15 @@ import com.eshore.gringotts.web.domain.entity.Confirmation;
|
|||||||
import com.eshore.gringotts.web.domain.service.ConfirmationService;
|
import com.eshore.gringotts.web.domain.service.ConfirmationService;
|
||||||
import com.eshore.gringotts.web.domain.service.DataFileService;
|
import com.eshore.gringotts.web.domain.service.DataFileService;
|
||||||
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
import com.eshore.gringotts.web.domain.service.DataResourceService;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.collections.api.factory.Sets;
|
import org.eclipse.collections.api.factory.Sets;
|
||||||
import org.eclipse.collections.api.set.ImmutableSet;
|
import org.eclipse.collections.api.set.ImmutableSet;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -25,15 +29,23 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("confirmation")
|
@RequestMapping("confirmation")
|
||||||
public class ConfirmationController extends SimpleControllerSupport<Confirmation, ConfirmationController.SaveItem, ConfirmationController.ListItem, ConfirmationController.DetailItem> {
|
public class ConfirmationController extends SimpleControllerSupport<Confirmation, ConfirmationController.SaveItem, ConfirmationController.ListItem, ConfirmationController.DetailItem> {
|
||||||
|
private final ConfirmationService confirmationService;
|
||||||
private final DataResourceService dataResourceService;
|
private final DataResourceService dataResourceService;
|
||||||
private final DataFileService dataFileService;
|
private final DataFileService dataFileService;
|
||||||
|
|
||||||
public ConfirmationController(ConfirmationService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
public ConfirmationController(ConfirmationService service, DataResourceService dataResourceService, DataFileService dataFileService) {
|
||||||
super(service);
|
super(service);
|
||||||
|
this.confirmationService = service;
|
||||||
this.dataResourceService = dataResourceService;
|
this.dataResourceService = dataResourceService;
|
||||||
this.dataFileService = dataFileService;
|
this.dataFileService = dataFileService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("submit/{id}")
|
||||||
|
public AmisResponse<Object> submit(@PathVariable Long id) throws JsonProcessingException {
|
||||||
|
confirmationService.submit(id);
|
||||||
|
return AmisResponse.responseSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Confirmation fromSaveItem(SaveItem item) throws Exception {
|
protected Confirmation fromSaveItem(SaveItem item) throws Exception {
|
||||||
Confirmation confirmation = new Confirmation();
|
Confirmation confirmation = new Confirmation();
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class CheckOrder extends SimpleEntity {
|
|||||||
* JSON 结构 Map<String, Object>
|
* JSON 结构 Map<String, Object>
|
||||||
*/
|
*/
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String context;
|
private String context = "{}";
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public class FlowDatabaseRepository implements FlowRepository {
|
|||||||
return checkOrderNodeRepository.findById(Long.valueOf(source.getNodeId())).orElseThrow(() -> new RuntimeException(""));
|
return checkOrderNodeRepository.findById(Long.valueOf(source.getNodeId())).orElseThrow(() -> new RuntimeException(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mapTo(CheckOrder order, Flow flow) throws JsonProcessingException {
|
private Flow mapTo(CheckOrder order) throws JsonProcessingException {
|
||||||
|
Flow flow = new Flow();
|
||||||
flow.setName(order.getName());
|
flow.setName(order.getName());
|
||||||
flow.setDescription(order.getDescription());
|
flow.setDescription(order.getDescription());
|
||||||
flow.setNodes(order.getNodes()
|
flow.setNodes(order.getNodes()
|
||||||
@@ -75,6 +76,7 @@ public class FlowDatabaseRepository implements FlowRepository {
|
|||||||
flow.setContextVariables(mapper.readValue(order.getContext(), new TypeReference<>() {}));
|
flow.setContextVariables(mapper.readValue(order.getContext(), new TypeReference<>() {}));
|
||||||
flow.setCreateTime(order.getCreatedTime());
|
flow.setCreateTime(order.getCreatedTime());
|
||||||
flow.setUpdateTime(order.getModifiedTime());
|
flow.setUpdateTime(order.getModifiedTime());
|
||||||
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mapTo(Flow flow, CheckOrder order) throws JsonProcessingException {
|
private void mapTo(Flow flow, CheckOrder order) throws JsonProcessingException {
|
||||||
@@ -119,8 +121,6 @@ public class FlowDatabaseRepository implements FlowRepository {
|
|||||||
@Override
|
@Override
|
||||||
public Flow findById(String id) {
|
public Flow findById(String id) {
|
||||||
CheckOrder order = checkOrderService.detailOrThrow(Long.parseLong(id));
|
CheckOrder order = checkOrderService.detailOrThrow(Long.parseLong(id));
|
||||||
Flow flow = new Flow();
|
return mapTo(order);
|
||||||
mapTo(order, flow);
|
|
||||||
return flow;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.eshore.gringotts.web.domain.flowable.node;
|
package com.eshore.gringotts.web.domain.flowable.node;
|
||||||
|
|
||||||
import com.eshore.gringotts.web.domain.entity.User;
|
import com.eshore.gringotts.web.domain.entity.User;
|
||||||
|
import com.eshore.gringotts.web.domain.service.ConfirmationService;
|
||||||
|
import com.lanyuanxiaoyao.flowable.model.FlowContext;
|
||||||
import com.lanyuanxiaoyao.flowable.node.AbstractFlowNode;
|
import com.lanyuanxiaoyao.flowable.node.AbstractFlowNode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -11,9 +13,22 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public class UserCheckFlowNode extends AbstractFlowNode {
|
public class UserCheckFlowNode extends AbstractFlowNode {
|
||||||
private final User user;
|
private final User user;
|
||||||
|
private final ConfirmationService confirmationService;
|
||||||
|
|
||||||
public UserCheckFlowNode(String nodeId, User user) {
|
public UserCheckFlowNode(String nodeId, User user, ConfirmationService confirmationService) {
|
||||||
super(nodeId);
|
super(nodeId);
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
this.confirmationService = confirmationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApprove(FlowContext context) {
|
||||||
|
super.onApprove(context);
|
||||||
|
Long confirmationId = context.getVariable("confirmationId", Long.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReject(FlowContext context) {
|
||||||
|
super.onReject(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ public class CheckOrderService extends SimpleServiceSupport<CheckOrder> {
|
|||||||
|
|
||||||
@Transactional(rollbackOn = Throwable.class)
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
public void startFlow(CheckOrder order) {
|
public void startFlow(CheckOrder order) {
|
||||||
Long id = save(order);
|
startFlow(order.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
|
public void startFlow(Long id) {
|
||||||
flowService.startFlow(id.toString());
|
flowService.startFlow(id.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,18 @@ package com.eshore.gringotts.web.domain.service;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.eshore.gringotts.web.domain.base.service.LogicDeleteService;
|
import com.eshore.gringotts.web.domain.base.service.LogicDeleteService;
|
||||||
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
import com.eshore.gringotts.web.domain.entity.Confirmation;
|
||||||
|
import com.eshore.gringotts.web.domain.entity.User;
|
||||||
|
import com.eshore.gringotts.web.domain.entity.order.CheckOrder;
|
||||||
|
import com.eshore.gringotts.web.domain.entity.order.node.RoleCheckOrderNode;
|
||||||
import com.eshore.gringotts.web.domain.repository.ConfirmationRepository;
|
import com.eshore.gringotts.web.domain.repository.ConfirmationRepository;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.collections.api.factory.Lists;
|
||||||
|
import org.eclipse.collections.api.factory.Maps;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,10 +25,14 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class ConfirmationService extends LogicDeleteService<Confirmation> {
|
public class ConfirmationService extends LogicDeleteService<Confirmation> {
|
||||||
private final ConfirmationRepository confirmationRepository;
|
private final ConfirmationRepository confirmationRepository;
|
||||||
|
private final CheckOrderService checkOrderService;
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService, EntityManager entityManager) {
|
public ConfirmationService(ConfirmationRepository confirmationRepository, UserService userService, EntityManager entityManager, CheckOrderService checkOrderService, Jackson2ObjectMapperBuilder builder) {
|
||||||
super(confirmationRepository, userService, entityManager);
|
super(confirmationRepository, userService, entityManager);
|
||||||
this.confirmationRepository = confirmationRepository;
|
this.confirmationRepository = confirmationRepository;
|
||||||
|
this.checkOrderService = checkOrderService;
|
||||||
|
this.mapper = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -30,6 +43,19 @@ public class ConfirmationService extends LogicDeleteService<Confirmation> {
|
|||||||
return super.save(entity);
|
return super.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackOn = Throwable.class)
|
||||||
|
public void submit(Long id) throws JsonProcessingException {
|
||||||
|
CheckOrder order = new CheckOrder();
|
||||||
|
order.setName("确权申请");
|
||||||
|
order.setDescription("确权申请");
|
||||||
|
order.setNodes(Lists.mutable.of(
|
||||||
|
new RoleCheckOrderNode(User.Role.CHECKER)
|
||||||
|
));
|
||||||
|
order.setContext(mapper.writeValueAsString(Maps.immutable.of("confirmationId", id)));
|
||||||
|
checkOrderService.save(order);
|
||||||
|
checkOrderService.startFlow(order);
|
||||||
|
}
|
||||||
|
|
||||||
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
public static final class ConfirmationDuplicatedException extends RuntimeException {
|
||||||
public ConfirmationDuplicatedException() {
|
public ConfirmationDuplicatedException() {
|
||||||
super("数据资源已绑定确权申请,无法再次申请");
|
super("数据资源已绑定确权申请,无法再次申请");
|
||||||
|
|||||||
Reference in New Issue
Block a user