|
@@ -11,6 +11,7 @@ import com.flow.common.mybatis.service.impl.BaseServiceImpl;
|
|
|
import com.flow.common.redis.service.RedisService;
|
|
|
import com.flow.dao.FlowDefineDao;
|
|
|
import com.flow.entity.FlowDefine;
|
|
|
+import com.flow.entity.FlowTemp;
|
|
|
import com.flow.entity.FormModel;
|
|
|
import com.flow.entity.form.Field;
|
|
|
import com.flow.entity.form.serial.SerialRule;
|
|
@@ -22,6 +23,7 @@ import com.flow.enums.ProcessStatus;
|
|
|
import com.flow.model.FormInfo;
|
|
|
import com.flow.model.StartProcess;
|
|
|
import com.flow.service.FlowDefineService;
|
|
|
+import com.flow.service.FlowTempService;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.flowable.common.engine.impl.identity.Authentication;
|
|
@@ -41,6 +43,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -57,6 +60,8 @@ public class FlowDefineServiceImpl extends BaseServiceImpl<FlowDefineDao, FlowDe
|
|
|
private RedisService<Long> redisService;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
+ @Autowired
|
|
|
+ private FlowTempService flowTempService;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@@ -142,6 +147,8 @@ public class FlowDefineServiceImpl extends BaseServiceImpl<FlowDefineDao, FlowDe
|
|
|
.businessStatus(ProcessStatus.RUNNING.toString())
|
|
|
.variables(values)
|
|
|
.start();
|
|
|
+ // 删除暂存
|
|
|
+ flowTempService.deleteByBusinessId(startProcess.getDefineId());
|
|
|
try {
|
|
|
runtimeService.setVariable(instanceId, "_SKIP_INITIATOR", false);
|
|
|
} catch (Exception ignored) {
|
|
@@ -154,7 +161,7 @@ public class FlowDefineServiceImpl extends BaseServiceImpl<FlowDefineDao, FlowDe
|
|
|
List<SerialRule> serialRules = objectMapper.convertValue(rules, new TypeReference<List<SerialRule>>() {
|
|
|
});
|
|
|
String key = String.format("flow:serial:%s:%s", modelKey, field.getId());
|
|
|
- return serialRules.stream().map(e->e.generate(key)).collect(Collectors.joining());
|
|
|
+ return serialRules.stream().map(e -> e.generate(key)).collect(Collectors.joining());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -194,4 +201,32 @@ public class FlowDefineServiceImpl extends BaseServiceImpl<FlowDefineDao, FlowDe
|
|
|
List<FieldProperty> formProperties = rootNode.getFormProperties();
|
|
|
return new FormInfo(define, formProperties, null);
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void storeFormDataTemporarily(StartProcess startProcess) {
|
|
|
+ Optional<FlowTemp> optional = flowTempService.lambdaQuery()
|
|
|
+ .eq(FlowTemp::getBusinessId, startProcess.getDefineId())
|
|
|
+ .eq(FlowTemp::getUserId, SecurityContextUtil.getUserId())
|
|
|
+ .oneOpt();
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ FlowTemp flowTemp = optional.get();
|
|
|
+ flowTemp.setData(startProcess.getValues());
|
|
|
+ flowTempService.updateById(flowTemp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FlowTemp flowTemp = new FlowTemp();
|
|
|
+ flowTemp.setBusinessId(startProcess.getDefineId());
|
|
|
+ flowTemp.setUserId(SecurityContextUtil.getUserId());
|
|
|
+ flowTemp.setData(startProcess.getValues());
|
|
|
+ flowTempService.saveData(flowTemp);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getFormDataTemporarily(String defineId) {
|
|
|
+ FlowTemp flowTemp = flowTempService.getByBusinessId(defineId);
|
|
|
+ return Optional.ofNullable(flowTemp)
|
|
|
+ .map(FlowTemp::getData)
|
|
|
+ .orElse(null);
|
|
|
+ }
|
|
|
}
|