add:流程添加回调透传:子流程载具修改流程实例流程
This commit is contained in:
@@ -36,7 +36,7 @@ public class TableDataInfo<T> implements Serializable {
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private int code;
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
@@ -56,7 +56,7 @@ public class TableDataInfo<T> implements Serializable {
|
||||
|
||||
public static <T> TableDataInfo<T> build(IPage<T> page) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setContent(page.getRecords());
|
||||
rspData.setTotalElements(page.getTotal());
|
||||
@@ -65,7 +65,7 @@ public class TableDataInfo<T> implements Serializable {
|
||||
|
||||
public static TableDataInfo<Map> buildByDivForm(IPage<Map> page,String json_field) {
|
||||
TableDataInfo<Map> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
|
||||
rspData.setMsg("查询成功");
|
||||
List<Map> records = page.getRecords();
|
||||
records.forEach(a->{
|
||||
@@ -86,7 +86,7 @@ public class TableDataInfo<T> implements Serializable {
|
||||
|
||||
public static <T> TableDataInfo<T> build(List<T> list) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setContent(list);
|
||||
rspData.setTotalElements(list.size());
|
||||
@@ -95,7 +95,7 @@ public class TableDataInfo<T> implements Serializable {
|
||||
|
||||
public static <T> TableDataInfo<T> build() {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setCode(HttpStatus.HTTP_OK);
|
||||
rspData.setCode(String.valueOf(HttpStatus.HTTP_OK));
|
||||
rspData.setMsg("操作成功");
|
||||
return rspData;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
class ApiError {
|
||||
|
||||
private String code = "400";
|
||||
private String status = "400";
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime timestamp;
|
||||
private String message;
|
||||
@@ -47,7 +47,7 @@ class ApiError {
|
||||
|
||||
public static ApiError error(Integer status, String message){
|
||||
ApiError apiError = new ApiError();
|
||||
apiError.setCode(String.valueOf(status));
|
||||
apiError.setStatus(String.valueOf(status));
|
||||
apiError.setMessage(message);
|
||||
return apiError;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,6 @@ public class GlobalExceptionHandler {
|
||||
* 统一返回
|
||||
*/
|
||||
private ResponseEntity<ApiError> buildResponseEntity(ApiError apiError) {
|
||||
return new ResponseEntity<>(apiError, HttpStatus.valueOf(Integer.valueOf(apiError.getCode())));
|
||||
return new ResponseEntity<>(apiError, HttpStatus.valueOf(Integer.valueOf(apiError.getStatus())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.nl.common.function;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.api.R;
|
||||
import org.nl.common.utils.MapOf;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/6/19 17:44
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface PermeateFunction<T,U > {
|
||||
|
||||
|
||||
void accept(T t,U u);
|
||||
|
||||
//函数透传方式
|
||||
default PermeateFunction<T,U> andThen(Supplier<U> middle) {
|
||||
Objects.requireNonNull(middle);
|
||||
return (inst_id,vehicle)->{
|
||||
accept(inst_id,middle.get());
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class BussEventMulticaster implements BeanPostProcessor {
|
||||
if (sync){
|
||||
String result= listener.doEvent(event);
|
||||
if (event.getCallback() !=null && result !=null){
|
||||
event.getCallback().accept(result);
|
||||
event.getCallback().accept(result,null);
|
||||
};
|
||||
}else {
|
||||
//TODO:异步回调
|
||||
|
||||
@@ -4,7 +4,9 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
@@ -18,4 +20,5 @@ import java.util.function.Consumer;
|
||||
public abstract class PublishEvent {
|
||||
|
||||
private Consumer callback = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,14 +12,19 @@ import org.nl.common.publish.BussEventMulticaster;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.wms.dispatch_manage.task.handler.AbstractTask;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionDto;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.IActReProcdefService;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.dao.ActReProcdef;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IActRuExecutionService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.nl.wms.flow_manage.monitor.event.FlowContinueEvent;
|
||||
import org.nl.wms.flow_manage.monitor.event.FlowStartEvent;
|
||||
import org.nl.wms.md_manage.group_dick.service.IMdGruopDickService;
|
||||
import org.nl.wms.md_manage.group_dick.service.dao.MdGruopDick;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.IMdPbVehicleMaterService;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.dao.MdPbVehicleMater;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.dto.MdPbVehicleMaterVo;
|
||||
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -45,7 +50,7 @@ public class GroupDickInStorageTask extends AbstractTask {
|
||||
@Autowired
|
||||
private IMdGruopDickService iMdGruopDickService;
|
||||
@Autowired
|
||||
private IActReProcdefService iActReProcdefService;
|
||||
private IActRuExecutionService iActRuExecutionService;
|
||||
|
||||
@Override
|
||||
public JSONObject createTask(JSONObject data) {
|
||||
@@ -67,20 +72,21 @@ public class GroupDickInStorageTask extends AbstractTask {
|
||||
mstJ.put("stor_code", vehicleMater.getStor_code());
|
||||
//更新载具proc_inst_id
|
||||
String currentInstId = vehicleMater.getProc_inst_id();
|
||||
String model_key = "md_group";
|
||||
if (StringUtils.isNotEmpty(currentInstId)){
|
||||
ActReProcdef procdefByInst = iActReProcdefService.getProcdefByInst(currentInstId);
|
||||
if (procdefByInst!=null){
|
||||
model_key = procdefByInst.getModel_key();
|
||||
ActRuExecution execution = iActRuExecutionService.getById(currentInstId);
|
||||
if (execution == null){
|
||||
throw new BadRequestException("申请任务失败:载具"+vehicle_code+"任务流程信息不存在"+currentInstId);
|
||||
}
|
||||
BussEventMulticaster.Publish(new FlowContinueEvent(currentInstId,null , new JSONObject(MapOf.of("start_point", point_code1))));
|
||||
}else {
|
||||
BussEventMulticaster.Publish(
|
||||
new FlowStartEvent("md_group",
|
||||
(proc_inst_id,empPlace) -> iMdPbVehicleMaterService.update(new UpdateWrapper<MdPbVehicleMater>().set("proc_inst_id",proc_inst_id).eq("vehicle_code",vehicle_code))
|
||||
,new JSONObject(MapOf.of("start_point", point_code1)))
|
||||
.build("md_group_dick",mst.getId(),mst.getSource_form_type(),mst.getSource_form_id(), mstJ)
|
||||
.build("md_pb_vehicleMater",item)
|
||||
);
|
||||
}
|
||||
BussEventMulticaster.Publish(
|
||||
new FlowStartEvent(model_key,
|
||||
proc_inst_id -> iMdPbVehicleMaterService.update(new UpdateWrapper<MdPbVehicleMater>().set("proc_inst_id",proc_inst_id).eq("vehicle_code",vehicle_code))
|
||||
,new JSONObject(MapOf.of("start_point", point_code1)))
|
||||
.build("md_group_dick",mst.getId(),mst.getSource_form_type(),mst.getSource_form_id(), mstJ)
|
||||
.build("md_pb_vehicleMater",item)
|
||||
);
|
||||
//执行流程//
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -28,6 +28,7 @@ public class SubProcessConverter extends BaseNodeConverter {
|
||||
subProcess.setName(properties.getString("name"));
|
||||
subProcess.setSplit(properties.getString("split"));
|
||||
subProcess.setSplitSwitch(properties.getBoolean("splitSwitch"));
|
||||
subProcess.setPermeate(properties.getBoolean("permeate"));
|
||||
subProcess.setDocumentation(properties.getString("documentation"));
|
||||
//设置触发事件
|
||||
subProcess.setExecutionListeners(null);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.wms.config_manage.form_struc.service.IBmFormStrucService;
|
||||
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
|
||||
@@ -27,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -69,9 +71,9 @@ public class StartEventActivityBehavior extends FlowNodeActivityBehavior {
|
||||
.append(" where id = ")
|
||||
.append("'"+entity.getForm_id()+"'");
|
||||
iPmFormDataService.dynamicSql(sql.toString());
|
||||
Consumer callback = entity.getCallback();
|
||||
PermeateFunction callback = entity.getCallback();
|
||||
if (callback!=null){
|
||||
callback.accept(proc_inst_id);
|
||||
callback.accept(proc_inst_id,null);
|
||||
}
|
||||
ActRuExecution execution = new ActRuExecution();
|
||||
execution.setProc_inst_id(proc_inst_id);
|
||||
|
||||
@@ -13,29 +13,30 @@ import org.nl.wms.flow_manage.flow.framework.entity.node.base.impl.FlowElement;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.EventNode.StartEvent;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.SubProcess.SubProcess;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.IActReProcdefService;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.IMdPbVehicleMaterService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.security.auth.callback.Callback;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/5/6 17:47
|
||||
* 后续可以定义规则
|
||||
* 后续可以定义规则:子流程如果根据vehicle_code拆分的话,每个载具都有一个自己的流程,所以需要跟新载具流程实例id
|
||||
*/
|
||||
@Service("subProcess")
|
||||
public class SubProcessActivityBehavior extends FlowNodeActivityBehavior<JSONObject> {
|
||||
|
||||
@Autowired
|
||||
private IActReProcdefService reProcdefService;
|
||||
@Autowired
|
||||
private BpmnJSONConverter bpmnJSONConverter;
|
||||
@Autowired
|
||||
private CommandExecutor commandExecutor;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(ExecutionEntity<JSONObject> entity) {
|
||||
//两种方式:一种根据明细生成多个子流程并行,还有个顺序执行
|
||||
@@ -94,6 +95,9 @@ public class SubProcessActivityBehavior extends FlowNodeActivityBehavior<JSONObj
|
||||
subEntity.setForm_type(entity.getForm_type());
|
||||
subEntity.setDeploymentId(entity.getDeploymentId());
|
||||
subEntity.setCurrentFlowElement(startEvent);
|
||||
if (subProcess.getPermeate()){
|
||||
subEntity.setCallback(entity.getCallback().andThen(() -> ((JSONObject) o).getJSONObject("t").getString("vehicle_code")));
|
||||
}
|
||||
subEntity.setT(o);
|
||||
//在endEvent中有个所有子流程结束的判断:如果判断成功会触发父流程:startEvent暂时通过等待处理防止自动流程导致endEvent判断出错
|
||||
commandExecutor.execute(new StartInstanceCmd(), subEntity);
|
||||
|
||||
@@ -5,9 +5,12 @@ import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.node.base.impl.FlowElement;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
@@ -61,7 +64,7 @@ public class ExecutionEntity<T> implements Cloneable{
|
||||
protected JSONObject auxParam = new JSONObject();
|
||||
|
||||
//回调执行
|
||||
protected Consumer callback = null;
|
||||
protected PermeateFunction<String, String> callback = null;
|
||||
|
||||
protected T t;
|
||||
|
||||
|
||||
@@ -28,10 +28,18 @@ public class SubProcess extends FlowNode {
|
||||
protected Map<String, FlowElement> flowElementMap = new LinkedHashMap<>();
|
||||
|
||||
protected List<FlowElement> flowElementList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 基于字段拆分
|
||||
*/
|
||||
protected String split;
|
||||
|
||||
/**
|
||||
* 数据拆分
|
||||
*/
|
||||
protected Boolean splitSwitch;
|
||||
/**
|
||||
* 透传回调函数
|
||||
*/
|
||||
protected Boolean permeate;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package org.nl.wms.flow_manage.flow.service.classprocessimpl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.flow_manage.flow.framework.process.nodeType.excess.impl.process.classprocess.ClassProcess;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.IMdPbVehicleMaterService;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.dao.MdPbVehicleMater;
|
||||
import org.nl.wms.stor_manage.struct.service.IStIvtStructattrService;
|
||||
import org.nl.wms.stor_manage.struct.service.dao.StIvtStructattr;
|
||||
import org.nl.wms.system_manage.service.param.ISysParamService;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/5/6 14:34
|
||||
* 出库任务入库任务
|
||||
*/
|
||||
public class OutStorageTaskHandler implements ClassProcess {
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private ISysParamService iSysParamService;
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructattrService iStIvtStructattrService;
|
||||
@Autowired
|
||||
private IMdPbVehicleMaterService iMdPbVehicleMaterService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public JSONObject process(JSONObject from, JSONObject param) {
|
||||
//区分出库还是入库
|
||||
//根据不同的仓位设置不同的终点
|
||||
Param outStorage = iSysParamService.findByCode("OutStorage");
|
||||
if (outStorage==null || StringUtils.isEmpty(outStorage.getValue())){
|
||||
throw new BadRequestException("创建任务失败:OutStorageTaskHandler#process()未配置出库对应点位");
|
||||
}
|
||||
JSONObject outStorageConfig = JSONObject.parseObject(outStorage.getValue());
|
||||
String end_point = outStorageConfig.getString(from.getString("stor_code"));
|
||||
|
||||
String vehicle_code = from.getString("vehicle_code");
|
||||
StIvtStructattr struct = iStIvtStructattrService.getOne(new QueryWrapper<StIvtStructattr>().eq("vehicle_code", vehicle_code));
|
||||
String struct_code = struct.getStruct_code();
|
||||
if (StringUtils.isEmpty(vehicle_code) ||StringUtils.isEmpty(end_point)||StringUtils.isEmpty(struct_code)){
|
||||
throw new BadRequestException("创建任务失败:OutStorageTaskHandler#process()方法请求参数不能为空");
|
||||
}
|
||||
List<SchBaseTask> list = taskService.list(new QueryWrapper<SchBaseTask>().eq("vehicle_code", vehicle_code)
|
||||
.ne("status", StatusEnum.FORM_STATUS.code("完成")));
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
throw new BadRequestException("当前载具存在任务:"+list.stream().map(SchBaseTask::getTask_code).collect(Collectors.joining(",")));
|
||||
}
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
task.setId(IdUtil.getStringId());
|
||||
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.setStatus(StatusEnum.FORM_STATUS.code("生成"));
|
||||
task.setHandle_class(this.getClass().getName());
|
||||
task.setAcs_type("");
|
||||
task.setCreate_time(DateUtil.now());
|
||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
task.setTask_type(param.getString("task_type"));
|
||||
task.setVehicle_code(vehicle_code);
|
||||
task.setPoint_code1(struct_code);
|
||||
task.setPoint_code2(end_point);
|
||||
taskService.save(task);
|
||||
iMdPbVehicleMaterService.update(new LambdaUpdateWrapper<MdPbVehicleMater>()
|
||||
.set(MdPbVehicleMater::getTask_code,task.getTask_code())
|
||||
.eq(MdPbVehicleMater::getVehicle_code,task.getVehicle_code()));
|
||||
Boolean isSend = param.getBoolean("is_send");
|
||||
if (isSend){
|
||||
//参数封装,调acs接口
|
||||
}
|
||||
return (JSONObject)JSON.toJSON(task);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package org.nl.wms.flow_manage.flow.service.classprocessimpl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
|
||||
import org.nl.wms.flow_manage.flow.framework.process.nodeType.excess.impl.process.classprocess.ClassProcess;
|
||||
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.IMdPbVehicleMaterService;
|
||||
import org.nl.wms.md_manage.vehicleMater.service.dao.MdPbVehicleMater;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/5/6 14:34
|
||||
* 堆垛机入库任务
|
||||
*/
|
||||
@Service
|
||||
public class StackingTaskHandler implements ClassProcess {
|
||||
|
||||
@Autowired
|
||||
ISchBaseTaskService taskService;
|
||||
|
||||
@Autowired
|
||||
IMdPbVehicleMaterService iMdPbVehicleMaterService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public JSONObject process(JSONObject from, JSONObject param) {
|
||||
//区分出库还是入库
|
||||
String vehicle_code = from.getString("vehicle_code");
|
||||
String struct_code = from.getString("struct_code");
|
||||
String start_point = param.getString("start_point");
|
||||
if (StringUtils.isEmpty(vehicle_code) ||StringUtils.isEmpty(start_point)||StringUtils.isEmpty(struct_code)){
|
||||
throw new BadRequestException("创建任务失败:StackingTaskHandler#process()方法请求参数不能为空");
|
||||
}
|
||||
List<SchBaseTask> list = taskService.list(new QueryWrapper<SchBaseTask>().eq("vehicle_code", vehicle_code)
|
||||
.ne("status", StatusEnum.FORM_STATUS.code("完成")));
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
throw new BadRequestException("当前载具存在任务:"+list.stream().map(SchBaseTask::getTask_code).collect(Collectors.joining(",")));
|
||||
}
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
task.setId(IdUtil.getStringId());
|
||||
task.setSource_form_id(from.getString("id"));
|
||||
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.setStatus(StatusEnum.FORM_STATUS.code("生成"));
|
||||
task.setHandle_class(this.getClass().getName());
|
||||
task.setAcs_type("");
|
||||
task.setCreate_time(DateUtil.now());
|
||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
task.setTask_type(param.getString("task_type"));
|
||||
task.setVehicle_code(vehicle_code);
|
||||
task.setPoint_code1(start_point);
|
||||
task.setPoint_code2(struct_code);
|
||||
taskService.create(task);
|
||||
iMdPbVehicleMaterService.update(new LambdaUpdateWrapper<MdPbVehicleMater>()
|
||||
.set(MdPbVehicleMater::getTask_code,task.getTask_code())
|
||||
.eq(MdPbVehicleMater::getVehicle_code,task.getVehicle_code()));
|
||||
|
||||
return (JSONObject)JSON.toJSON(task);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package org.nl.wms.flow_manage.flow.service.execution;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionDto;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -14,7 +16,7 @@ import java.util.function.Consumer;
|
||||
**/
|
||||
public interface IFlowOperationService {
|
||||
|
||||
String startUp(String model_key, Consumer callback,ExecutionDto dto,JSONObject auxParam);
|
||||
String startUp(String model_key, PermeateFunction callback, ExecutionDto dto, JSONObject auxParam);
|
||||
|
||||
|
||||
Boolean flowConfirm(String proc_inst_id,JSONObject auxParam,ExecutionDto dto);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
import org.nl.wms.flow_manage.flow.framework.BpmnModel;
|
||||
import org.nl.wms.flow_manage.flow.framework.converter.BpmnJSONConverter;
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.cmd.CommandExecutor;
|
||||
@@ -26,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
@@ -47,7 +49,7 @@ public class FlowOperationServiceImpl implements IFlowOperationService {
|
||||
private CommandExecutor commandExecutor;
|
||||
|
||||
@Override
|
||||
public String startUp(String model_key, Consumer callback, ExecutionDto dto, JSONObject auxParam) {
|
||||
public String startUp(String model_key, PermeateFunction callback, ExecutionDto dto, JSONObject auxParam) {
|
||||
ActRuExecution one = iActRuExecutionService.getOne(new QueryWrapper<ActRuExecution>()
|
||||
.eq("form_type", dto.getForm_type())
|
||||
.eq("form_id", dto.getForm_id())
|
||||
|
||||
@@ -23,6 +23,6 @@ public class FlowEventListener extends AbstraceListener<FlowStartEvent> {
|
||||
protected String doEvent(FlowStartEvent event) {
|
||||
String s = JSON.toJSONString(event.getDto());
|
||||
log.info("触发流程"+ s);
|
||||
return flowOperationService.startUp(event.getModel_key(), event.getCallback(), event.getDto(), event.getAuxParam());
|
||||
return flowOperationService.startUp(event.getModel_key(), event.getFlowStartCallback(), event.getDto(), event.getAuxParam());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package org.nl.wms.flow_manage.monitor.event;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
import org.nl.common.publish.event.PublishEvent;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
@@ -23,15 +25,17 @@ public class FlowContinueEvent extends PublishEvent {
|
||||
* 实例id
|
||||
*/
|
||||
private String proc_inst_id;
|
||||
|
||||
private PermeateFunction flowStartCallback;
|
||||
/**
|
||||
* 流程实例全局数据
|
||||
*/
|
||||
private JSONObject auxParam;
|
||||
|
||||
public FlowContinueEvent(String proc_inst_id, Consumer callback, JSONObject auxParam) {
|
||||
public FlowContinueEvent(String proc_inst_id,PermeateFunction flowStartCallback, JSONObject auxParam) {
|
||||
this.proc_inst_id = proc_inst_id;
|
||||
this.auxParam = auxParam;
|
||||
this.setCallback(callback);
|
||||
this.flowStartCallback = flowStartCallback;
|
||||
}
|
||||
|
||||
public FlowContinueEvent setDto(ExecutionDto dto) {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package org.nl.wms.flow_manage.monitor.event;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.function.PermeateFunction;
|
||||
import org.nl.common.publish.event.PublishEvent;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
@@ -22,15 +20,18 @@ public class FlowStartEvent extends PublishEvent {
|
||||
|
||||
private String model_key;
|
||||
|
||||
private PermeateFunction flowStartCallback;
|
||||
|
||||
|
||||
/**
|
||||
* 流程实例全局数据
|
||||
*/
|
||||
private JSONObject auxParam;
|
||||
|
||||
public FlowStartEvent(String model_key, Consumer callback,JSONObject auxParam) {
|
||||
public FlowStartEvent(String model_key, PermeateFunction biCallback, JSONObject auxParam) {
|
||||
this.model_key = model_key;
|
||||
this.auxParam = auxParam;
|
||||
this.setCallback(callback);
|
||||
this.flowStartCallback = biCallback;
|
||||
}
|
||||
|
||||
public String getModel_key() {
|
||||
@@ -72,6 +73,10 @@ public class FlowStartEvent extends PublishEvent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PermeateFunction getFlowStartCallback() {
|
||||
return flowStartCallback;
|
||||
}
|
||||
|
||||
public ExecutionDto getDto() {
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.publish.BussEventMulticaster;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.base_manage.vehicle.service.IBmVehicleInfoService;
|
||||
import org.nl.wms.base_manage.vehicle.service.dao.BmVehicleInfo;
|
||||
@@ -230,11 +227,13 @@ public class StIvtIostorinvServiceImpl extends ServiceImpl<StIvtIostorinvOutMapp
|
||||
StIvtIostorinv iostorinv = form.toJavaObject(StIvtIostorinv.class);
|
||||
//查询明细/api/bmFormStruc/getTypes
|
||||
List<StIvtIostorinvdtlVo> dtlVo = iStIvtIostorinvDtlService.getDtlVo(iostorinv.getId());
|
||||
Set<String> vechiles = dtlVo.stream().map(StIvtIostorinvdtlVo::getVehicle_code).collect(Collectors.toSet());
|
||||
List<String> vechiles = dtlVo.stream().map(StIvtIostorinvdtlVo::getVehicle_code).collect(Collectors.toList());
|
||||
//扔一个物料信息进去
|
||||
BussEventMulticaster.Publish(new FlowStartEvent("st_ivt_iostorinv_"+(iostorinv.getIn_storage()?"in":"out"),
|
||||
proc_inst_id -> iMdPbVehicleMaterService.update(new UpdateWrapper<MdPbVehicleMater>()
|
||||
.set("proc_inst_id",proc_inst_id).in("vehicle_code",vechiles)),null)
|
||||
BussEventMulticaster.Publish(new FlowStartEvent("st_ivt_iostorinv_"+(iostorinv.getIn_storage()?"in":"out")
|
||||
, (proc_inst_id,innerVehicle) -> iMdPbVehicleMaterService.update(new UpdateWrapper<MdPbVehicleMater>()
|
||||
.set("proc_inst_id",proc_inst_id)
|
||||
.in("vehicle_code",innerVehicle==null?vechiles: ListOf.of(innerVehicle)))
|
||||
,null)
|
||||
.build("st_ivt_iostorinv",iostorinv.getId(),iostorinv.getSource_form_type(),iostorinv.getSource_form_id(),form)
|
||||
.build("st_ivt_iostorinvdtl",dtlVo)
|
||||
);
|
||||
|
||||
@@ -148,10 +148,14 @@ public class PickingService {
|
||||
dto.setT(mstJ);
|
||||
dto.setItem(packageT(mstJ,"id"));
|
||||
|
||||
BussEventMulticaster.Publish(new FlowContinueEvent(mst.getProc_inst_id(), o -> iFormDataService.update(new UpdateWrapper<PmFormData>()
|
||||
FlowContinueEvent continueEvent = new FlowContinueEvent(mst.getProc_inst_id(), null,null)
|
||||
.setDto(dto);
|
||||
continueEvent.setCallback(emp->{
|
||||
iFormDataService.update(new UpdateWrapper<PmFormData>()
|
||||
.set("status",StatusEnum.FORM_STATUS.code("执行中"))
|
||||
.eq("id",mst.getId())), null)
|
||||
.setDto(dto));
|
||||
.eq("id",mst.getId()));
|
||||
});
|
||||
BussEventMulticaster.Publish(continueEvent);
|
||||
|
||||
}
|
||||
private List<ExecutionDto> packageT(JSONObject current,String itemField){
|
||||
|
||||
Reference in New Issue
Block a user