|
|
|
|
@@ -1,22 +1,24 @@
|
|
|
|
|
package org.nl.wms.flow_manage.flow.framework.engine.behavior.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 org.apache.commons.lang3.StringUtils;
|
|
|
|
|
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.nl.wms.pm_manage.form_data.service.IPmFormDataService;
|
|
|
|
|
import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @author ZZQ
|
|
|
|
|
* @Date 2024/3/18 13:17
|
|
|
|
|
@@ -26,27 +28,50 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
public class ExecuteFlowActivityBehavior extends FlowNodeActivityBehavior<JSONObject> {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IActHiExecutionService actHiExecutionService;
|
|
|
|
|
private IActHiExecutionService iActHiExecutionService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPmFormDataService iPmFormDataService;
|
|
|
|
|
|
|
|
|
|
@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>()
|
|
|
|
|
ActHiExecution one = iActHiExecutionService.getOne(new QueryWrapper<ActHiExecution>()
|
|
|
|
|
.eq("activity_id", source_data)
|
|
|
|
|
.eq("proc_inst_id", entity.getProc_inst_id()));
|
|
|
|
|
executeFlow.getDataSource();
|
|
|
|
|
JSONObject sourceData;
|
|
|
|
|
ExecuteFlow.DataSourceEnum dataSource = executeFlow.getDataSource();
|
|
|
|
|
switch (dataSource){
|
|
|
|
|
case FLOWNODE:
|
|
|
|
|
sourceData = one.getForm_data().getJSONObject("t");
|
|
|
|
|
break;
|
|
|
|
|
case DATASORUCE:
|
|
|
|
|
PmFormData formData = iPmFormDataService.getOne(new QueryWrapper<PmFormData>()
|
|
|
|
|
.eq("id", one.getForm_id()).eq("form_type", one.getForm_type()));
|
|
|
|
|
sourceData = (JSONObject) JSON.toJSON(formData);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new IllegalStateException("Unexpected value: " + dataSource);
|
|
|
|
|
}
|
|
|
|
|
String skipExpression = executeFlow.getSkipExpression();
|
|
|
|
|
if (StringUtils.isNotEmpty(skipExpression)) {
|
|
|
|
|
Boolean parse = SpelUtil.parse(sourceData, skipExpression, Boolean.class);
|
|
|
|
|
if (!parse){
|
|
|
|
|
throw new BadRequestException("当前中转节点数据校验不通过"+skipExpression+",无法跳转到下个节点");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//处理流程线:将结果值封装
|
|
|
|
|
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\"}";
|
|
|
|
|
String data = "{\"item\":null,\"t\":{\"source_form_date\":null,\"code\":null,\"assign_qty\":0,\"create_time\":\"2024-06-28 15:43:54\",\"remark\":null,\"form_type\":\"st_ivt_checkdtl\",\"update_name\":null,\"update_time\":null,\"form_data\":{\"stor_code\":\"FStockId\",\"check_qty\":\"\",\"profit_loss\":\"\",\"struct_code\":\"L07-15-01\"},\"parent_id\":\"1806594357017579520\",\"qty\":150,\"proc_inst_id\":null,\"pcsn\":\"11\",\"material_id\":\"1744270387455332362\",\"id\":\"1806594357176963072\",\"vehicle_code\":\"D00005\",\"source_form_id\":null,\"unit_id\":\"16\",\"source_form_type\":null,\"status\":\"10\",\"create_name\":\"管理员\"},\"form_id\":\"1806594357176963072\",\"form_type\":\"st_ivt_checkdtl\",\"source_form_id\":null,\"source_form_type\":null}\n";
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
|
|
System.out.println(jsonObject.toJSONString());
|
|
|
|
|
JSONObject dataj = jsonObject.getJSONObject("t");
|
|
|
|
|
// "#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);
|
|
|
|
|
String parse = SpelUtil.parse(dataj, "#M['form_data']['check_qty'] != ''", String.class);
|
|
|
|
|
System.out.println(parse);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|