add:过度流程节点;外部系统接口修改
This commit is contained in:
@@ -26,7 +26,7 @@ public enum StatusEnum {
|
|||||||
/**
|
/**
|
||||||
* 单据状态
|
* 单据状态
|
||||||
*/
|
*/
|
||||||
FORM_STATUS(ForkMap.of("生成", "10",null,"已分配", "13", null,"执行中", "20",null,"完成", "90",null,"取消", "100",null)),
|
FORM_STATUS(ForkMap.of("生成", "10",null,"已分配", "13", null,"执行中", "20",null,"暂停", "30",null,"完成", "90",null,"取消", "100",null)),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出入库单据类型
|
* 出入库单据类型
|
||||||
|
|||||||
@@ -28,12 +28,16 @@ import java.util.Enumeration;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class IPUtil {
|
public class IPUtil {
|
||||||
|
|
||||||
|
public static String IP = null;
|
||||||
/**
|
/**
|
||||||
* 获取当前机器的IP
|
* 获取当前机器的IP
|
||||||
*
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static String getLocalIp() {
|
public static String getLocalIp() {
|
||||||
|
if (IP!=null){
|
||||||
|
return IP;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
InetAddress candidateAddress = null;
|
InetAddress candidateAddress = null;
|
||||||
// 遍历所有的网络接口
|
// 遍历所有的网络接口
|
||||||
@@ -62,6 +66,7 @@ public class IPUtil {
|
|||||||
if (jdkSuppliedAddress == null) {
|
if (jdkSuppliedAddress == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
IP = jdkSuppliedAddress.getHostAddress();
|
||||||
return jdkSuppliedAddress.getHostAddress();
|
return jdkSuppliedAddress.getHostAddress();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.http.HttpRequest;
|
|||||||
import cn.hutool.http.HttpStatus;
|
import cn.hutool.http.HttpStatus;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.common.TableDataInfo;
|
||||||
import org.nl.common.domain.exception.BadRequestException;
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
|
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
|
||||||
|
|
||||||
@@ -24,29 +25,24 @@ public class InterationUtil {
|
|||||||
* @param param
|
* @param param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static JSONObject notifyExt(String api, JSONObject param) {
|
public static TableDataInfo notifyExt(String api, JSONObject param) {
|
||||||
log.info("下发ACS参数----------------------------------------+"+api+",---"+param.toString());
|
log.info("下发ACS参数----------------------------------------+"+api+",---"+param.toString());
|
||||||
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("IS_CONNECT_ACS").getValue();
|
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("IS_CONNECT_ACS").getValue();
|
||||||
JSONObject result = new JSONObject();
|
|
||||||
if (STATUS_FLASE.equals(isConnect)) {
|
if (STATUS_FLASE.equals(isConnect)) {
|
||||||
result.put("status", HttpStatus.HTTP_OK);
|
return TableDataInfo.build();
|
||||||
result.put("message", "下发成功,但未连接ACS!");
|
|
||||||
result.put("data", new JSONObject());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
//ACS地址:127.0.0.1:8010
|
|
||||||
String acsUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("acs_url").getValue();
|
String acsUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("acs_url").getValue();
|
||||||
String url = acsUrl + api;
|
String url = acsUrl + api;
|
||||||
try {
|
try {
|
||||||
String resultMsg = HttpRequest.post(url)
|
String resultMsg = HttpRequest.post(url)
|
||||||
.body(String.valueOf(param))
|
.body(String.valueOf(param))
|
||||||
.execute().body();
|
.execute().body();
|
||||||
result = JSONObject.parseObject(resultMsg);
|
JSONObject response = JSONObject.parseObject(resultMsg);
|
||||||
log.info("ACS相应参数----------------------------------------+"+api+",---"+result.toString());
|
log.info("ACS相应参数----------------------------------------+"+api+",---"+response.toString());
|
||||||
} catch (Exception e) {
|
return response.toJavaObject(TableDataInfo.class);
|
||||||
log.info("ACS反馈异常----------------------------------------+"+api+",---"+e.getMessage());
|
} catch (Exception ex) {
|
||||||
throw new BadRequestException("acs:网络不同");
|
log.info("ACS反馈异常----------------------------------------+"+api+",---"+ex.getMessage());
|
||||||
|
throw new BadRequestException("acs网络不通:"+ex.getMessage());
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package org.nl.wms.dispatch_manage.task.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.common.enums.StatusEnum;
|
||||||
|
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||||
|
import org.nl.wms.external_system.acs.service.WmsToAcsService;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/3/22 17:14
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class TaskScheduleService {
|
||||||
|
|
||||||
|
private ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISchBaseTaskService taskService;
|
||||||
|
@Autowired
|
||||||
|
private WmsToAcsService wmsToAcsService;
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
// @Scheduled(cron = "0/30 * * * * ?")
|
||||||
|
public void taskPublish(){
|
||||||
|
boolean islock = lock.tryLock();
|
||||||
|
try {
|
||||||
|
if (islock){
|
||||||
|
//查询所有自动下发的任务
|
||||||
|
List<SchBaseTask> list = taskService.list(new QueryWrapper<SchBaseTask>().eq("is_send", true)
|
||||||
|
.eq("status", StatusEnum.FORM_STATUS.code("生成")));
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
wmsToAcsService.interationToExt(list,"createTask");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}finally {
|
||||||
|
if (islock){
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package org.nl.wms.external_system.acs.service;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import org.nl.common.domain.exception.BadRequestException;
|
|
||||||
import org.nl.common.enums.StatusEnum;
|
|
||||||
import org.nl.common.utils.InterationUtil;
|
|
||||||
import org.nl.common.utils.SpringContextHolder;
|
|
||||||
import org.nl.wms.dispatch_manage.task.handler.AbstractTask;
|
|
||||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
|
||||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
|
||||||
import org.nl.wms.external_system.acs.service.dto.TransferDto;
|
|
||||||
import org.nl.wms.flow_manage.flow.framework.process.nodeType.source.impl.MappingSourceDataTypeHandler;
|
|
||||||
import org.nl.wms.sync_manage.service.form_mapping.ISyncFormMappingService;
|
|
||||||
import org.nl.wms.sync_manage.service.form_mapping.dao.SyncFormMapping;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @author ZZQ
|
|
||||||
* @Date 2024/5/6 14:53
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class AcsToWmsService implements InitializingBean {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Map<String, AbstractTask> applyTaskMap;
|
|
||||||
@Autowired
|
|
||||||
private ISchBaseTaskService iSchBaseTaskService;
|
|
||||||
|
|
||||||
private SyncFormMapping mapping;
|
|
||||||
|
|
||||||
public void applyTask(String service,String type,JSONObject data){
|
|
||||||
if (service.equals("InStorage")){
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
"service": "ZPInStorage",
|
|
||||||
"ip": "ip_7va9w",
|
|
||||||
"request_time": "request_time_pbi5u",
|
|
||||||
"trace_id": "trace_id_xl8dk",
|
|
||||||
"data": {
|
|
||||||
"D00018": "start001"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
* */
|
|
||||||
applyTaskMap.get(type).createTask(data);
|
|
||||||
}
|
|
||||||
if (service.equals("TaskStatus")){
|
|
||||||
String task_code = data.getString("task_code");
|
|
||||||
SchBaseTask task = iSchBaseTaskService.getOne(new QueryWrapper<SchBaseTask>().eq("task_code", task_code)
|
|
||||||
.lt("status", StatusEnum.FORM_STATUS.code("完成")));
|
|
||||||
if (task == null){
|
|
||||||
throw new BadRequestException("更新失败:当前执行中的任务不存在");
|
|
||||||
}
|
|
||||||
applyTaskMap.get(task.getTask_type()).updateStatus(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPropertiesSet(){
|
|
||||||
this.mapping = SpringContextHolder.getBean(ISyncFormMappingService.class).getOne(new QueryWrapper<SyncFormMapping>()
|
|
||||||
.eq("form_type","sch_base_task"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统交互
|
|
||||||
*/
|
|
||||||
public JSONObject interationToExt(List<SchBaseTask> arr) {
|
|
||||||
//封装数据:
|
|
||||||
TransferDto dto = new TransferDto();
|
|
||||||
MappingSourceDataTypeHandler<JSONObject> typeHandler = new MappingSourceDataTypeHandler<>();
|
|
||||||
List<JSONObject> items = typeHandler.sourceHandler((JSONArray)JSONArray.toJSON(arr), mapping);
|
|
||||||
dto.setModel(items);
|
|
||||||
|
|
||||||
JSONObject result = InterationUtil.notifyExt(mapping.getSync_url(), (JSONObject) JSON.toJSON(dto));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,13 +4,14 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import org.nl.common.TableDataInfo;
|
||||||
import org.nl.common.utils.InterationUtil;
|
import org.nl.common.utils.InterationUtil;
|
||||||
import org.nl.common.utils.SpringContextHolder;
|
import org.nl.common.utils.SpringContextHolder;
|
||||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||||
import org.nl.wms.external_system.acs.service.dto.TransferDto;
|
import org.nl.wms.external_system.dto.InteracteDto;
|
||||||
import org.nl.wms.flow_manage.flow.framework.process.nodeType.source.impl.MappingSourceDataTypeHandler;
|
|
||||||
import org.nl.wms.sync_manage.service.form_mapping.ISyncFormMappingService;
|
import org.nl.wms.sync_manage.service.form_mapping.ISyncFormMappingService;
|
||||||
import org.nl.wms.sync_manage.service.form_mapping.dao.SyncFormMapping;
|
import org.nl.wms.sync_manage.service.form_mapping.dao.SyncFormMapping;
|
||||||
|
import org.slf4j.MDC;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -34,18 +35,15 @@ public class WmsToAcsService implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* 系统交互
|
* 系统交互
|
||||||
*/
|
*/
|
||||||
public JSONObject interationToExt(List<SchBaseTask> arr) {
|
public TableDataInfo interationToExt(List<SchBaseTask> arr,String type) {
|
||||||
//封装数据:
|
//封装数据:
|
||||||
TransferDto dto = new TransferDto();
|
InteracteDto dto = InteracteDto.builder()
|
||||||
MappingSourceDataTypeHandler<JSONObject> typeHandler = new MappingSourceDataTypeHandler<>();
|
.service("wmsToAcsService")
|
||||||
List<JSONObject> items = typeHandler.sourceHandler((JSONArray)JSONArray.toJSON(arr), mapping);
|
.trace_id(MDC.get("trace_id"))
|
||||||
dto.setModel(items);
|
.type(type)
|
||||||
|
.data(arr).build();
|
||||||
|
|
||||||
JSONObject result = InterationUtil.notifyExt(mapping.getSync_url(), (JSONObject) JSON.toJSON(dto));
|
TableDataInfo tableDataInfo = InterationUtil.notifyExt(mapping.getSync_url(), (JSONObject) JSON.toJSON(dto));
|
||||||
return result;
|
return tableDataInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
package org.nl.wms.external_system.acs.service.dto;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.nl.common.utils.IPUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @author ZZQ
|
|
||||||
* @Date 2024/5/6 15:32
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class TransferDto {
|
|
||||||
/**
|
|
||||||
* 交互时间
|
|
||||||
*/
|
|
||||||
private String InterationTime = DateUtil.now();
|
|
||||||
/**
|
|
||||||
* 交互ip
|
|
||||||
*/
|
|
||||||
private String Ip = IPUtil.getLocalIp();
|
|
||||||
/**
|
|
||||||
* 是否交互:false
|
|
||||||
*/
|
|
||||||
private Boolean IgnoreInteration = Boolean.TRUE;
|
|
||||||
/**
|
|
||||||
* 是否重复提交
|
|
||||||
*/
|
|
||||||
private Boolean ValidateRepeat = Boolean.FALSE;
|
|
||||||
/**
|
|
||||||
* 表单类型
|
|
||||||
*/
|
|
||||||
private String ModelType;
|
|
||||||
/**
|
|
||||||
* 具体参数
|
|
||||||
*/
|
|
||||||
private List Model;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,31 @@
|
|||||||
package org.nl.wms.external_system.dto;
|
package org.nl.wms.external_system.dto;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.nl.common.utils.IPUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author ZZQ
|
* @author ZZQ
|
||||||
* @Date 2024/5/29 16:26
|
* @Date 2024/5/29 16:26
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
public class InteracteDto {
|
public class InteracteDto {
|
||||||
|
|
||||||
String service;
|
String service;
|
||||||
String type;
|
String type;
|
||||||
String ip;
|
String ip = IPUtil.getLocalIp();
|
||||||
String request_time;
|
String request_time = DateUtil.now();
|
||||||
String trace_id;
|
String trace_id;
|
||||||
JSONObject data;
|
/**
|
||||||
|
* 要么JSONArray要么JSONObject
|
||||||
|
*/
|
||||||
|
Object data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class BpmnJSONConverter {
|
|||||||
Node_Converter.put("sequenceFlow",new SequenceFlowConverter());
|
Node_Converter.put("sequenceFlow",new SequenceFlowConverter());
|
||||||
Node_Converter.put("sendMsg",new SendMsgConverter());
|
Node_Converter.put("sendMsg",new SendMsgConverter());
|
||||||
Node_Converter.put("subProcess",new SubProcessConverter());
|
Node_Converter.put("subProcess",new SubProcessConverter());
|
||||||
|
Node_Converter.put("executeFlow",new ExecuteFlowConverter());
|
||||||
}
|
}
|
||||||
public BpmnModel convertToBpmnModel(String model,String version,JSONObject model_json) {
|
public BpmnModel convertToBpmnModel(String model,String version,JSONObject model_json) {
|
||||||
return this.convertToBpmnModel(model,version,model_json,null);
|
return this.convertToBpmnModel(model,version,model_json,null);
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.nl.wms.flow_manage.flow.framework.converter.node.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.BpmnModel;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.converter.node.BaseNodeConverter;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.base.impl.FlowNode;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.gateway.GateWay;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.task.impl.ExecuteFlow;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2024/4/26 11:08
|
||||||
|
*/
|
||||||
|
public class ExecuteFlowConverter extends BaseNodeConverter {
|
||||||
|
@Override
|
||||||
|
public FlowNode convertToBpmnModel(Iterator<JSONObject> iterator, JSONObject node, BpmnModel model) {
|
||||||
|
JSONObject properties = node.getJSONObject("properties");
|
||||||
|
String type = node.getString("type");
|
||||||
|
Boolean pass = properties.getBoolean("passNode");
|
||||||
|
|
||||||
|
ExecuteFlow executeFlow = new ExecuteFlow();
|
||||||
|
executeFlow.setPassNode(pass);
|
||||||
|
executeFlow.setId(node.getString("id"));
|
||||||
|
executeFlow.setType(node.getString("type"));
|
||||||
|
executeFlow.setForm_type(properties.getString("form_type"));
|
||||||
|
executeFlow.setSource_data(properties.getString("sourceData"));
|
||||||
|
executeFlow.setDataSource(properties.getString("dataSource"));
|
||||||
|
executeFlow.setName(properties.getString("name"));
|
||||||
|
executeFlow.setDocumentation(properties.getString("documentation"));
|
||||||
|
//设置触发事件
|
||||||
|
executeFlow.setExecutionListeners(null);
|
||||||
|
JSONArray skipExpressions = properties.getJSONArray("skipExpression");
|
||||||
|
if (skipExpressions!=null){
|
||||||
|
for (int i = 0; i < skipExpressions.size(); i++) {
|
||||||
|
executeFlow.getSkipExpression().add(skipExpressions.getString(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pass!=null && pass){
|
||||||
|
model.getPassNode().add(type);
|
||||||
|
}
|
||||||
|
model.getNodeFlow().add(type);
|
||||||
|
model.getNodeProperties().put(type,properties);
|
||||||
|
model.getProcesses().put(executeFlow.getId(),executeFlow);
|
||||||
|
return executeFlow;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package org.nl.wms.flow_manage.flow.framework.engine.behavior.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
|
import org.nl.common.utils.SpelUtil;
|
||||||
|
import org.nl.common.utils.SpringContextHolder;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.engine.behavior.FlowNodeActivityBehavior;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionEntity;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.base.impl.FlowElement;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.Sequence.SequenceFlow;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.gateway.GateWay;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.task.impl.ExecuteFlow;
|
||||||
|
import org.nl.wms.flow_manage.flow.service.history.IActHiExecutionService;
|
||||||
|
import org.nl.wms.flow_manage.flow.service.history.dao.ActHiExecution;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2024/3/18 13:17
|
||||||
|
* 中转节点
|
||||||
|
*/
|
||||||
|
@Service("executeFlow")
|
||||||
|
public class ExecuteFlowActivityBehavior extends FlowNodeActivityBehavior<JSONObject> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IActHiExecutionService actHiExecutionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(ExecutionEntity<JSONObject> entity) {
|
||||||
|
FlowElement element = entity.getCurrentFlowElement();
|
||||||
|
ExecuteFlow executeFlow = (ExecuteFlow) element;
|
||||||
|
String source_data = executeFlow.getSource_data();
|
||||||
|
ActHiExecution one = actHiExecutionService.getOne(new QueryWrapper<ActHiExecution>()
|
||||||
|
.eq("activity_id", source_data)
|
||||||
|
.eq("proc_inst_id", entity.getProc_inst_id()));
|
||||||
|
executeFlow.getDataSource()
|
||||||
|
//处理流程线:将结果值封装
|
||||||
|
super.execute(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String data = "{\"stor_code\":\"FStockId\",\"vehicleMaterMap\":{\"D00001\":{\"stor_code\":\"FStockId\",\"create_time\":\"2024-06-11 15:39:47\",\"task_code\":\"28457\",\"form_data\":{\"FMoBillNo\":\"\",\"single_weight\":\"\"},\"group_id\":\"1800432729389666304\",\"qty\":333,\"proc_inst_id\":\"1800433990847565824\",\"is_lock\":true,\"pcsn\":\"11\",\"material_id\":\"FMaterialId\",\"id\":\"1800432729389666305\",\"has_child\":false,\"frozen_qty\":333,\"vehicle_code\":\"D00001\",\"source_form_id\":\"1798554623695523840\",\"source_form_type\":\"PRD_FeedMtrl\",\"create_name\":\"管理员\"},\"D00002\":{\"stor_code\":\"FStockId\",\"create_time\":\"2024-06-11 15:41:39\",\"task_code\":\"28458\",\"form_data\":{\"FMoBillNo\":\"\",\"single_weight\":\"\"},\"group_id\":\"1800433197683707904\",\"qty\":222,\"proc_inst_id\":\"1800435270215143424\",\"is_lock\":true,\"pcsn\":\"11\",\"material_id\":\"FMaterialId\",\"id\":\"1800433197683707905\",\"has_child\":false,\"frozen_qty\":67,\"vehicle_code\":\"D00002\",\"source_form_id\":\"1798554665118470144\",\"source_form_type\":\"PRD_FeedMtrl\",\"create_name\":\"管理员\"}},\"form_data\":{\"order\":\"\"},\"qty\":400,\"pcsn\":\"11\",\"material_id\":\"FMaterialId\",\"id\":\"1800435564550426624\",\"inv_id\":\"1800435564521066496\",\"vehicle_code\":\"D00002\",\"source_form_id\":\"1798554623695523840\",\"unit_id\":\"16\",\"source_form_type\":\"PRD_FeedMtrl\",\"status\":\"10\"}";
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
|
System.out.println(jsonObject.toJSONString());
|
||||||
|
// "#M['vehicleMaterMap'][M['vehicle_code']]['qty']"
|
||||||
|
Boolean parse = SpelUtil.parse(jsonObject, "#M['vehicleMaterMap'][#M['vehicle_code']]['frozen_qty'] < #M['vehicleMaterMap'][#M['vehicle_code']]['qty']", Boolean.class);
|
||||||
|
System.out.println(parse);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package org.nl.wms.flow_manage.flow.framework.entity.node.impl.task.impl;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.nl.common.domain.exception.BadRequestException;
|
||||||
|
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
|
||||||
|
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.task.ExecuteTask;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2024/3/18 11:30
|
||||||
|
* 数据中转节点
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExecuteFlow extends ExecuteTask {
|
||||||
|
/**
|
||||||
|
* 表单类型
|
||||||
|
*/
|
||||||
|
private String form_type;
|
||||||
|
/**
|
||||||
|
* 数据源类型:0实时数据库1节点数据
|
||||||
|
*/
|
||||||
|
private DataSourceEnum dataSource;
|
||||||
|
/**
|
||||||
|
* 跳过表达式:逐级
|
||||||
|
*/
|
||||||
|
private List<String> skipExpression = new ArrayList<>();
|
||||||
|
|
||||||
|
public void setDataSource(String dataSource) {
|
||||||
|
this.dataSource = DataSourceEnum.getByCode(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum DataSourceEnum{
|
||||||
|
/**
|
||||||
|
* 实时数据库
|
||||||
|
*/
|
||||||
|
DATASORUCE("0"),
|
||||||
|
/**
|
||||||
|
* 节点数据
|
||||||
|
*/
|
||||||
|
FLOWNODE("1");
|
||||||
|
/**
|
||||||
|
* 编码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
DataSourceEnum(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
public static DataSourceEnum getByCode(String code){
|
||||||
|
for (DataSourceEnum value : DataSourceEnum.values()) {
|
||||||
|
if (value.getCode().equals(code)){
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new BadRequestException("编码异常");
|
||||||
|
}
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -100,7 +100,7 @@ public class CheckStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void taskOpen(JSONObject form){
|
public void taskOpen(JSONObject form){
|
||||||
PmFormData mst = form.toJavaObject(PmFormData.class);
|
PmFormData mst = form.toJavaObject(PmFormData.class);
|
||||||
if (StringUtils.isNotEmpty(mst.getProc_inst_id())){
|
if (StringUtils.isNotEmpty(mst.getProc_inst_id())){
|
||||||
throw new BadRequestException("下发失败:当前单据已存在流程,请勿重新下发");
|
throw new BadRequestException("下发失败:当前单据已存在流程,请勿重新下发");
|
||||||
|
|||||||
Reference in New Issue
Block a user