add:拣选页面机功能
This commit is contained in:
@@ -123,6 +123,10 @@ public class BmFormStruc implements Serializable {
|
||||
* 关联上级表单id
|
||||
*/
|
||||
private String parent_id;
|
||||
/**
|
||||
* 关联上级表单id
|
||||
*/
|
||||
private Boolean auto_mapping;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package org.nl.wms.dispatch_manage.task.handler.impl;
|
||||
|
||||
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.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.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.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 ConveyorOutStorageTask extends AbstractTask {
|
||||
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private ISysParamService iSysParamService;
|
||||
|
||||
@Autowired
|
||||
private IStIvtStructattrService iStIvtStructattrService;
|
||||
@Autowired
|
||||
private IMdPbVehicleMaterService iMdPbVehicleMaterService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public JSONObject createTask(JSONObject from) {
|
||||
String vehicle_code = from.getString("vehicle_code");
|
||||
String outbound = from.getJSONObject("form_data").getString("outbound");
|
||||
String start_point = from.getString("start_point");
|
||||
String task_type = from.getString("task_type");
|
||||
if (StringUtils.isEmpty(vehicle_code) ||StringUtils.isEmpty(start_point)||StringUtils.isEmpty(outbound)){
|
||||
throw new BadRequestException("创建任务失败:方法请求参数不能为空");
|
||||
}
|
||||
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(StatusEnum.ACS_TYPE.code("立库"));
|
||||
task.setCreate_time(DateUtil.now());
|
||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
task.setTask_type(task_type);
|
||||
task.setVehicle_code(vehicle_code);
|
||||
task.setPoint_code1(start_point);
|
||||
task.setPoint_code2(outbound);
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(JSONObject data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,9 +44,9 @@ public class InStorageTask extends AbstractTask {
|
||||
public JSONObject createTask(JSONObject from) {
|
||||
String vehicle_code = from.getString("vehicle_code");
|
||||
String struct_code = from.getString("struct_code");
|
||||
String target_point = from.getString("target_point");
|
||||
String start_point = from.getString("start_point");
|
||||
String task_type = from.getString("task_type");
|
||||
if (StringUtils.isEmpty(vehicle_code) ||StringUtils.isEmpty(target_point)||StringUtils.isEmpty(struct_code)){
|
||||
if (StringUtils.isEmpty(vehicle_code) ||StringUtils.isEmpty(start_point)||StringUtils.isEmpty(struct_code)){
|
||||
throw new BadRequestException("创建任务失败:方法请求参数不能为空");
|
||||
}
|
||||
List<SchBaseTask> list = taskService.list(new QueryWrapper<SchBaseTask>().eq("vehicle_code", vehicle_code)
|
||||
@@ -65,7 +65,7 @@ public class InStorageTask extends AbstractTask {
|
||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
task.setTask_type(task_type);
|
||||
task.setVehicle_code(vehicle_code);
|
||||
task.setPoint_code1(target_point);
|
||||
task.setPoint_code1(start_point);
|
||||
task.setPoint_code2(struct_code);
|
||||
taskService.create(task);
|
||||
iMdPbVehicleMaterService.update(new LambdaUpdateWrapper<MdPbVehicleMater>()
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.nl.wms.flow_manage.flow.controller.execution;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -10,14 +9,11 @@ import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.base_manage.material.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.early_manage.service.early_dtl.dao.AlmEarlyDtl;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.IActReProcdefService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IActRuExecutionService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IFlowOperationService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.ExecutionQuery;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.StartProcessInstanceVo;
|
||||
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;
|
||||
@@ -98,7 +94,7 @@ public class ExecutionController {
|
||||
|
||||
@GetMapping(value = "/confirm/{proc_inst_id}")
|
||||
public ResponseEntity<Object> flowConfirm(@PathVariable String proc_inst_id) {
|
||||
return new ResponseEntity<>(flowOperationService.flowConfirm(proc_inst_id, null), HttpStatus.OK);
|
||||
return new ResponseEntity<>(flowOperationService.flowConfirm(proc_inst_id, null, null), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/queryByParentId/{id}")
|
||||
|
||||
@@ -23,6 +23,7 @@ public class StartEventConverter extends BaseNodeConverter {
|
||||
start.setName(properties.getString("name"));
|
||||
start.setDocumentation(properties.getString("documentation"));
|
||||
//设置触发事件
|
||||
start.setForm_type(properties.getString("form_type"));
|
||||
start.setPassNode(properties.getBoolean("passNode"));
|
||||
start.setExecutionListeners(null);
|
||||
start.setSkipExpression(properties.getString("skipExpression"));
|
||||
|
||||
@@ -26,6 +26,8 @@ public class SubProcessConverter extends BaseNodeConverter {
|
||||
subProcess.setType(node.getString("type"));
|
||||
subProcess.setChildren(node.getJSONArray("children").toJavaList(String.class));
|
||||
subProcess.setName(properties.getString("name"));
|
||||
subProcess.setSplit(properties.getString("split"));
|
||||
subProcess.setSplitSwitch(properties.getBoolean("splitSwitch"));
|
||||
subProcess.setDocumentation(properties.getString("documentation"));
|
||||
//设置触发事件
|
||||
subProcess.setExecutionListeners(null);
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.flow_manage.flow.framework.engine.behavior.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
@@ -9,7 +10,9 @@ import org.nl.wms.flow_manage.flow.framework.engine.behavior.FlowNodeActivityBeh
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.cmd.CommandExecutor;
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.operation.impl.SequenceFlowOperation;
|
||||
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.base.impl.FlowNode;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.node.impl.EventNode.StartEvent;
|
||||
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;
|
||||
@@ -57,14 +60,18 @@ public class StartEventActivityBehavior extends FlowNodeActivityBehavior {
|
||||
execution.setCreate_time(DateUtil.now());
|
||||
execution.setStatus(StatusEnum.FLOW_STATUS.code("启动"));
|
||||
iActRuExecutionService.save(execution);
|
||||
StringBuffer sql = new StringBuffer();
|
||||
sql.append("update ")
|
||||
.append(entity.getForm_type())
|
||||
.append(" set status = ")
|
||||
.append("'"+StatusEnum.FORM_STATUS.code("执行中")+"'")
|
||||
.append(" where id = ")
|
||||
.append("'"+entity.getForm_id()+"'");
|
||||
iPmFormDataService.dynamicSql(sql.toString());
|
||||
StartEvent currentFlowElement = (StartEvent)entity.getCurrentFlowElement();
|
||||
String form_type = currentFlowElement.getForm_type();
|
||||
if (StringUtils.isNotEmpty(form_type)){
|
||||
StringBuffer sql = new StringBuffer();
|
||||
sql.append("update ")
|
||||
.append(entity.getForm_type())
|
||||
.append(" set status = ")
|
||||
.append("'"+StatusEnum.FORM_STATUS.code("执行中")+"'")
|
||||
.append(" where id = ")
|
||||
.append("'"+entity.getForm_id()+"'");
|
||||
iPmFormDataService.dynamicSql(sql.toString());
|
||||
}
|
||||
Consumer callback = entity.getCallback();
|
||||
if (callback!=null){
|
||||
callback.accept(execution.getProc_inst_id());
|
||||
|
||||
@@ -1,38 +1,25 @@
|
||||
package org.nl.wms.flow_manage.flow.framework.engine.behavior.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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.apache.poi.ss.formula.functions.T;
|
||||
import org.nl.common.domain.exception.BadRequestException;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
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.behavior.FlowNodeActivityBehavior;
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.cmd.CommandExecutor;
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.cmd.unify.impl.StartInstanceCmd;
|
||||
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.base.impl.FlowNode;
|
||||
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.flow_manage.flow.service.deployment.dao.ActReProcdef;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
@@ -62,30 +49,32 @@ public class SubProcessActivityBehavior extends FlowNodeActivityBehavior<JSONObj
|
||||
|
||||
JSONObject form = entity.getT();
|
||||
JSONArray items = (JSONArray)form.get("item");
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
//基于明细id拆分还是继续vehicle_code拆分
|
||||
List<JSONObject> subList = new ArrayList<>();
|
||||
Map<String, JSONObject> tmpMap = new HashMap<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
JSONObject item = items.getJSONObject(i);
|
||||
JSONObject t = (JSONObject)item.remove("t");
|
||||
String[] vehicle_codes = t.getString("vehicle_code").split(",");
|
||||
for (String vehicle_code : vehicle_codes) {
|
||||
JSONObject subt = new JSONObject();
|
||||
subt.putAll(t);
|
||||
subt.put("vehicle_code",vehicle_code);
|
||||
JSONObject sub = new JSONObject();
|
||||
sub.putAll(item);
|
||||
sub.put("t",subt);
|
||||
subList.add(sub);
|
||||
if (tmpMap.get(vehicle_code) == null){
|
||||
tmpMap.put(vehicle_code,sub);
|
||||
List<Object> subList = new ArrayList<>();
|
||||
String splitParam = subProcess.getSplit();
|
||||
if (StringUtils.isNotEmpty(splitParam)){
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
JSONObject item = items.getJSONObject(i);
|
||||
JSONObject t = (JSONObject)item.remove("t");
|
||||
String[] splits = t.getString(splitParam).split(",");
|
||||
for (String splitValue : splits) {
|
||||
JSONObject subt = new JSONObject();
|
||||
subt.putAll(t);
|
||||
subt.put(splitParam,splitValue);
|
||||
JSONObject sub = new JSONObject();
|
||||
sub.putAll(item);
|
||||
sub.put("t",subt);
|
||||
subList.add(sub);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
subList.addAll(items);
|
||||
}
|
||||
|
||||
//现在子流程跟载具有关后续可以通过配置拆分字段:vehicle_code跟拆分规则实现
|
||||
System.out.println("子流程数据合并结果:"+subList.size()+"__"+tmpMap.size());
|
||||
if (!CollectionUtils.isEmpty(tmpMap)){
|
||||
System.out.println("子流程数据合并结果:"+subList.size());
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (!CollectionUtils.isEmpty(subList)){
|
||||
// for (JSONObject o : subList) {
|
||||
// ExecutionEntity subEntity = new ExecutionEntity();
|
||||
// subEntity.setParent_id(entity.getProc_inst_id());
|
||||
@@ -98,7 +87,7 @@ public class SubProcessActivityBehavior extends FlowNodeActivityBehavior<JSONObj
|
||||
// commandExecutor.execute(new StartInstanceCmd(), subEntity);
|
||||
// }
|
||||
//子流程并行,子流程单一的时候直接串行
|
||||
tmpMap.values().stream().map((Function<Object, CompletableFuture>) o -> CompletableFuture.runAsync(() -> {
|
||||
subList.stream().map((Function<Object, CompletableFuture>) o -> CompletableFuture.runAsync(() -> {
|
||||
ExecutionEntity subEntity = new ExecutionEntity();
|
||||
subEntity.setParent_id(entity.getProc_inst_id());
|
||||
subEntity.setForm_id(entity.getForm_id());
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.nl.wms.flow_manage.flow.framework.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.*;
|
||||
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.base.impl.FlowElement;
|
||||
@@ -17,6 +14,7 @@ import java.util.List;
|
||||
* 流程传输数据
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
public class ExecutionDto {
|
||||
|
||||
@@ -22,6 +22,7 @@ public class StartEvent extends FlowNode {
|
||||
|
||||
protected String skipExpression;
|
||||
protected FlowElement targetFlowElement;
|
||||
protected String form_type;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ public class SubProcess extends FlowNode {
|
||||
|
||||
protected List<FlowElement> flowElementList = new ArrayList<>();
|
||||
|
||||
protected String split;
|
||||
|
||||
protected Boolean splitSwitch;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MappingHandler extends TypeHandler<JSONObject, JSONObject> {
|
||||
item = data.getJSONArray("item");
|
||||
}
|
||||
BmFormStruc item_struc = iBmFormStrucService.getOne(new QueryWrapper<BmFormStruc>().eq("parent_id",form_struc.getId()));
|
||||
if (item_struc != null){
|
||||
if (item_struc != null && item_struc.getAuto_mapping()){
|
||||
if (item==null){
|
||||
//暂定:强制校验
|
||||
throw new BadRequestException("当前数据存在明细且目标单据:"+form_struc.getForm_type()+" 未配置明细表");
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.nl.wms.flow_manage.flow.service.execution;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionDto;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.StartProcessInstanceVo;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -18,5 +17,5 @@ public interface IFlowOperationService {
|
||||
String startUp(String model_key, Consumer callback,ExecutionDto dto,JSONObject auxParam);
|
||||
|
||||
|
||||
Boolean flowConfirm(String proc_inst_id,JSONObject auxParam);
|
||||
Boolean flowConfirm(String proc_inst_id,JSONObject auxParam,ExecutionDto dto);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.flow_manage.flow.service.execution.impl;
|
||||
|
||||
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;
|
||||
@@ -19,7 +20,6 @@ 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.IFlowOperationService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.StartProcessInstanceVo;
|
||||
import org.nl.wms.flow_manage.flow.service.model.IActDeModelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -79,7 +79,7 @@ public class FlowOperationServiceImpl implements IFlowOperationService {
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean flowConfirm(String proc_inst_id,JSONObject auxParam) {
|
||||
public Boolean flowConfirm(String proc_inst_id, JSONObject auxParam, ExecutionDto dto) {
|
||||
if (StringUtils.isNotEmpty(proc_inst_id)){
|
||||
//当前流程
|
||||
ActRuExecution execution = iActRuExecutionService.getOne(new QueryWrapper<ActRuExecution>()
|
||||
@@ -109,14 +109,18 @@ public class FlowOperationServiceImpl implements IFlowOperationService {
|
||||
flowNode.setAuxParam(auxParam);
|
||||
}
|
||||
ExecutionEntity entity = new ExecutionEntity();
|
||||
entity.setCurrentFlowElement(flowNode);
|
||||
entity.setCurrentFlowElement(flowNode);
|
||||
entity.setProc_inst_id(execution.getProc_inst_id());
|
||||
entity.setParent_id(execution.getParent_id());
|
||||
entity.setForm_type(execution.getForm_type());
|
||||
entity.setForm_id(execution.getForm_id());
|
||||
entity.setStartActivityId(execution.getActivity_id());
|
||||
entity.setDeploymentId(execution.getDeployment_id());
|
||||
if (dto!=null){
|
||||
entity.setT(JSON.toJSON(dto));
|
||||
}else {
|
||||
entity.setT(execution.getForm_data());
|
||||
entity.setProc_inst_id(execution.getProc_inst_id());
|
||||
entity.setParent_id(execution.getParent_id());
|
||||
entity.setForm_type(execution.getForm_type());
|
||||
entity.setForm_id(execution.getForm_id());
|
||||
entity.setStartActivityId(execution.getActivity_id());
|
||||
entity.setDeploymentId(execution.getDeployment_id());
|
||||
}
|
||||
//如果流程执行异常:需要重新执行,如果执行中则走下一步
|
||||
commandExecutor.execute(new ExeInstanceCmd(execution.getStatus()),entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.nl.wms.flow_manage.monitor;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.publish.AbstraceListener;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IFlowOperationService;
|
||||
import org.nl.wms.flow_manage.monitor.event.FlowContinueEvent;
|
||||
import org.nl.wms.flow_manage.monitor.event.FlowStartEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/5/17 15:27
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FlowContinueEventListener extends AbstraceListener<FlowContinueEvent> {
|
||||
|
||||
@Autowired
|
||||
private IFlowOperationService flowOperationService;
|
||||
|
||||
@Override
|
||||
protected String doEvent(FlowContinueEvent event) {
|
||||
String s = JSON.toJSONString(event.getDto());
|
||||
log.info("触发流程"+ s);
|
||||
flowOperationService.flowConfirm(event.getProc_inst_id(), event.getAuxParam(),event.getDto());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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.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.Consumer;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/5/17 15:02
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class FlowContinueEvent extends PublishEvent {
|
||||
//数据传输
|
||||
private ExecutionDto dto;
|
||||
/**
|
||||
* 实例id
|
||||
*/
|
||||
private String proc_inst_id;
|
||||
/**
|
||||
* 流程实例全局数据
|
||||
*/
|
||||
private JSONObject auxParam;
|
||||
|
||||
public FlowContinueEvent(String proc_inst_id, Consumer callback, JSONObject auxParam) {
|
||||
this.proc_inst_id = proc_inst_id;
|
||||
this.auxParam = auxParam;
|
||||
this.setCallback(callback);
|
||||
}
|
||||
|
||||
public FlowContinueEvent setDto(ExecutionDto dto) {
|
||||
this.dto = dto;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,14 @@ public class PmFormDataController {
|
||||
return new ResponseEntity<>(TableDataInfo.build(formDataService.queryTree(query,page)), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
if (ids.length > 0) {
|
||||
formDataService.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getSonFormData/{id}")
|
||||
public ResponseEntity<Object> getSonDtlFormData(@PathVariable String id){
|
||||
//参数判读,参数解析,调用参数入库
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.nl.wms.pm_manage.form_data.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
|
||||
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||
@@ -38,4 +37,7 @@ public interface IPmFormDataService extends IService<PmFormData> {
|
||||
Object getSonDtlFormData(String id);
|
||||
|
||||
void dynamicSql(String sql);
|
||||
|
||||
List<PmFormData> getByParentId(String parent_id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package org.nl.wms.pm_manage.form_data.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -224,5 +222,11 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
|
||||
this.baseMapper.dynamicSql(sql);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmFormData> getByParentId(String parent_id) {
|
||||
Assert.notNull(parent_id,"请求参数不能为空");
|
||||
return this.list(new QueryWrapper<PmFormData>().eq("parent_id",parent_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package org.nl.wms.stor_manage.pick.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
||||
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||
import org.nl.wms.pm_manage.form_data.service.dto.FormDataQuery;
|
||||
import org.nl.wms.stor_manage.pick.service.PickingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -23,26 +28,46 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class PickingController {
|
||||
|
||||
@Autowired
|
||||
private IPmFormDataService formDataService;
|
||||
private IPmFormDataService iPmFormDataService;
|
||||
@Autowired
|
||||
private PickingService pickingService;
|
||||
|
||||
|
||||
@GetMapping()
|
||||
public ResponseEntity<Object> queryAll(FormDataQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(formDataService.queryTree(query,page)), HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(TableDataInfo.build(iPmFormDataService.queryTree(query,page)), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping("/getSonFormData/{id}")
|
||||
public ResponseEntity<Object> getSonDtlFormData(@PathVariable String id){
|
||||
//参数判读,参数解析,调用参数入库
|
||||
//Page<BmFormStruc> page = iBmFormStrucService.page(pageQuery.build(), query.build());
|
||||
return new ResponseEntity<>(formDataService.getSonDtlFormData(id),HttpStatus.OK);
|
||||
return new ResponseEntity<>(iPmFormDataService.getSonDtlFormData(id),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/sync/{type}")
|
||||
public ResponseEntity<Object> sync(@RequestParam String type, String formDtl) {
|
||||
//参数判读,参数解析,调用参数入库
|
||||
formDataService.syncFormData("type", formDtl);
|
||||
iPmFormDataService.syncFormData("type", formDtl);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@PostMapping("/savePickTask")
|
||||
public ResponseEntity<Object> savePickTask(@RequestBody JSONArray params) {
|
||||
pickingService.savePickTask(params);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@PostMapping("/updateStatus")
|
||||
public ResponseEntity<Object> updateStatus(@RequestBody JSONObject param) {
|
||||
//TODO:明细校验
|
||||
iPmFormDataService.update(new UpdateWrapper<PmFormData>()
|
||||
.set("status",param.getString("status"))
|
||||
.eq("id",param.getString("id")));
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@PostMapping("/taskOpen")
|
||||
public ResponseEntity<Object> taskOpen(@RequestBody JSONObject param) {
|
||||
pickingService.taskOpen(param);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package org.nl.wms.stor_manage.pick.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
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.SecurityUtils;
|
||||
import org.nl.wms.base_manage.vehicle.service.IBmVehicleInfoService;
|
||||
import org.nl.wms.base_manage.vehicle.service.dao.BmVehicleInfo;
|
||||
import org.nl.wms.flow_manage.flow.framework.entity.ExecutionDto;
|
||||
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.pm_manage.form_data.service.IPmFormDataService;
|
||||
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
||||
import org.nl.wms.stor_manage.io.service.iostor.dao.StIvtIostorinv;
|
||||
import org.nl.wms.stor_manage.io.service.iostor_dtl.dto.StIvtIostorinvdtlVo;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2024/6/17 21:25
|
||||
*/
|
||||
@Service
|
||||
public class PickingService {
|
||||
@Autowired
|
||||
private IPmFormDataService iFormDataService;
|
||||
@Autowired
|
||||
private IMdPbVehicleMaterService iMdPbVehicleMaterService;
|
||||
@Autowired
|
||||
private IMdGruopDickService iMdGruopDickService;
|
||||
@Autowired
|
||||
private IBmVehicleInfoService iBmVehicleInfoService;
|
||||
|
||||
/**
|
||||
* 生成拣选任务
|
||||
* @param params
|
||||
*/
|
||||
@Transactional
|
||||
public void savePickTask(JSONArray params){
|
||||
String now = DateUtil.now();
|
||||
String user = SecurityUtils.getCurrentNickName();
|
||||
PmFormData dtl = iFormDataService.getById((String)((Map) params.get(0)).get("parent_id"));
|
||||
MdPbVehicleMater one = iMdPbVehicleMaterService.getOne(new QueryWrapper<MdPbVehicleMater>()
|
||||
.eq("vehicle_code", dtl.getVehicle_code()).eq("material_id", dtl.getMaterial_id()));
|
||||
if (one==null){
|
||||
throw new BadRequestException("拣选明细载具物料信息不存在");
|
||||
}
|
||||
Set<Object> vehicleCodes = params.stream().map(a -> ((Map) a).get("vehicle_code")).collect(Collectors.toSet());
|
||||
int vCode = iBmVehicleInfoService.count(new QueryWrapper<BmVehicleInfo>().in("vehicle_code", vehicleCodes));
|
||||
if (vCode!=vehicleCodes.size()){
|
||||
throw new BadRequestException("载具编码不存在");
|
||||
}
|
||||
vehicleCodes.remove(one.getVehicle_code());
|
||||
int mCode = iMdPbVehicleMaterService.count(new QueryWrapper<MdPbVehicleMater>().in("vehicle_code", vehicleCodes));
|
||||
if (mCode>0){
|
||||
throw new BadRequestException("当前载具以存在载具物料信息");
|
||||
}
|
||||
for (Object param : params) {
|
||||
JSONObject task = new JSONObject((Map) param);
|
||||
PmFormData data = task.toJavaObject(PmFormData.class);
|
||||
if (StringUtils.isEmpty(data.getParent_id())||StringUtils.isEmpty(data.getVehicle_code())){
|
||||
throw new BadRequestException("创建失败:缺少参数");
|
||||
}
|
||||
String task_type = data.getForm_data().getString("task_type");
|
||||
if (StringUtils.isEmpty(task_type)){
|
||||
throw new BadRequestException("创建失败:未配置任务类型");
|
||||
}
|
||||
data.setCreate_time(now);
|
||||
data.setCreate_name(user);
|
||||
data.setId(IdUtil.getStringId());
|
||||
iFormDataService.save(data);
|
||||
String vehicle_code = data.getVehicle_code();
|
||||
if (dtl.getVehicle_code().equals(vehicle_code)){
|
||||
iMdPbVehicleMaterService.update(new UpdateWrapper<MdPbVehicleMater>()
|
||||
.set("frozen_qty",0).set("update_time",now)
|
||||
.set("update_name", user)
|
||||
.set("qty",data.getQty())
|
||||
.eq("vehicle_code",vehicle_code));
|
||||
}else {
|
||||
MdGruopDick dick = new MdGruopDick();
|
||||
dick.setVehicle_code(vehicle_code);
|
||||
dick.setSource_form_type("Picking_Task");
|
||||
dick.setSource_form_id(data.getId());
|
||||
dick.setCreate_name(user);
|
||||
dick.setCreate_time(now);
|
||||
dick.setStatus(StatusEnum.FORM_STATUS.code("完成"));
|
||||
dick.setCode(CodeUtil.getNewCode("md_group_dick"));
|
||||
dick.setId(IdUtil.getStringId());
|
||||
MdPbVehicleMater mater = new MdPbVehicleMater();
|
||||
mater.setMaterial_id(one.getMaterial_id());
|
||||
mater.setPcsn(one.getPcsn());
|
||||
mater.setQty(data.getQty());
|
||||
mater.setUnit_id(data.getUnit_id());
|
||||
mater.setVehicle_code(vehicle_code);
|
||||
//设置目标仓库
|
||||
mater.setStor_code(data.getForm_data().getString("stor_code"));
|
||||
mater.setHas_child(false);
|
||||
mater.setId(IdUtil.getStringId());
|
||||
mater.setGroup_id(dick.getId());
|
||||
mater.setCreate_name(user);
|
||||
mater.setCreate_time(now);
|
||||
mater.setSource_form_type("Picking_Task");
|
||||
mater.setSource_form_id(data.getId());
|
||||
mater.setForm_data(one.getForm_data());
|
||||
mater.setStor_code(one.getStor_code());
|
||||
iMdPbVehicleMaterService.save(mater);
|
||||
iMdGruopDickService.save(dick);
|
||||
}
|
||||
}
|
||||
iFormDataService.update(new UpdateWrapper<PmFormData>()
|
||||
.set("status",StatusEnum.FORM_STATUS.code("已分配")));
|
||||
}
|
||||
|
||||
|
||||
public void taskOpen(JSONObject form){
|
||||
PmFormData mst = form.toJavaObject(PmFormData.class);
|
||||
if (StringUtils.isEmpty(mst.getProc_inst_id())){
|
||||
throw new BadRequestException("当前单据不存在流程实例id");
|
||||
}
|
||||
JSONObject mstJ = (JSONObject) JSON.toJSON(mst);
|
||||
ExecutionDto dto = new ExecutionDto();
|
||||
dto.setForm_id(mst.getId());
|
||||
dto.setForm_type(mst.getForm_type());
|
||||
dto.setSource_form_type(mst.getSource_form_type());
|
||||
dto.setSource_form_id(mst.getSource_form_id());
|
||||
dto.setT(mstJ);
|
||||
dto.setItem(packageT(mstJ,"id"));
|
||||
|
||||
BussEventMulticaster.Publish(new FlowContinueEvent(mst.getProc_inst_id(), o -> iFormDataService.update(new UpdateWrapper<PmFormData>()
|
||||
.set("status",StatusEnum.FORM_STATUS.code("执行中"))
|
||||
.eq("id",mst.getId())), null)
|
||||
.setDto(dto));
|
||||
|
||||
}
|
||||
private List<ExecutionDto> packageT(JSONObject current,String itemField){
|
||||
String id = current.getString(itemField);
|
||||
List<PmFormData> items = iFormDataService.getByParentId(id);
|
||||
if (!CollectionUtils.isEmpty(items)){
|
||||
List<ExecutionDto> list = new ArrayList<>();
|
||||
for (PmFormData item : items) {
|
||||
JSONObject itemJ = (JSONObject) JSON.toJSON(item);
|
||||
ExecutionDto itemDto = new ExecutionDto();
|
||||
itemDto.setT(itemJ);
|
||||
itemDto.setForm_id(item.getId());
|
||||
itemDto.setForm_type(item.getForm_type());
|
||||
itemDto.setSource_form_type(item.getSource_form_type());
|
||||
itemDto.setSource_form_id(item.getSource_form_id());
|
||||
itemDto.setItem(packageT(itemJ,itemField));
|
||||
list.add(itemDto);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user