add:调度线路
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,39 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.controller.scheduler;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/22 14:27
|
||||||
|
*/
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.SchedulerService;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl.FlowElement;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/shceduler")
|
||||||
|
@SaIgnore
|
||||||
|
public class SchedulerController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SchedulerService schedulerService;
|
||||||
|
|
||||||
|
@GetMapping("/all")
|
||||||
|
public ResponseEntity<Object> allprocess(){
|
||||||
|
return new ResponseEntity<>(schedulerService.all(), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
@GetMapping("/process")
|
||||||
|
public ResponseEntity<Object> allprocess(String process){
|
||||||
|
return new ResponseEntity<>(schedulerService.getProcess(process), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
@GetMapping("/processFlow")
|
||||||
|
public ResponseEntity<Object> allprocess(String process,String flow){
|
||||||
|
FlowElement element = schedulerService.currentFlow(process, flow);
|
||||||
|
return new ResponseEntity<>(element, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,21 @@
|
|||||||
package org.nl.wms.scheduler_manage.service.region.impl;
|
package org.nl.wms.scheduler_manage.service.region.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.nl.common.TableDataInfo;
|
import org.nl.common.TableDataInfo;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.wql.WQL;
|
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
import org.nl.modules.wql.util.WqlUtil;
|
|
||||||
import org.nl.wms.product_manage.sch.service.dto.RegionDto;
|
|
||||||
import org.nl.wms.scheduler_manage.service.point.dao.SchBasePoint;
|
|
||||||
import org.nl.wms.scheduler_manage.service.region.ISchBaseRegionService;
|
import org.nl.wms.scheduler_manage.service.region.ISchBaseRegionService;
|
||||||
import org.nl.wms.scheduler_manage.service.region.dao.SchBaseRegion;
|
import org.nl.wms.scheduler_manage.service.region.dao.SchBaseRegion;
|
||||||
import org.nl.wms.scheduler_manage.service.region.dao.mapper.SchBaseRegionMapper;
|
import org.nl.wms.scheduler_manage.service.region.dao.mapper.SchBaseRegionMapper;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl.ProcessElement;
|
||||||
import org.nl.wms.system_manage.service.dict.ISysDictService;
|
import org.nl.wms.system_manage.service.dict.ISysDictService;
|
||||||
import org.nl.wms.system_manage.service.dict.dao.Dict;
|
import org.nl.wms.system_manage.service.dict.dao.Dict;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -31,7 +24,6 @@ import org.springframework.util.Assert;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -169,4 +161,9 @@ public class SchBaseRegionServiceImpl extends ServiceImpl<SchBaseRegionMapper, S
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ProcessElement element = new ProcessElement();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.nl.common.publish.AbstraceListener;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseConverter;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl.FlowElement;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl.ProcessElement;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
|
import org.springframework.core.io.FileSystemResourceLoader;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/22 13:38
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SchedulerService implements BeanPostProcessor {
|
||||||
|
@Value("${schedulerFile}")
|
||||||
|
|
||||||
|
private static Map<String,BaseConverter> converterMap =new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
public List<BaseElement> all(){
|
||||||
|
List<BaseElement> readall = XmlReadUtil.readall();
|
||||||
|
return readall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProcessElement getProcess(String processId){
|
||||||
|
ProcessElement processElement = XmlReadUtil.readProcess(processId);
|
||||||
|
return processElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlowElement currentFlow(String processId,String flowId){
|
||||||
|
ProcessElement processElement = XmlReadUtil.readProcess(processId);
|
||||||
|
if (processElement!=null){
|
||||||
|
return processElement.flowId(flowId);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class XmlReadUtil{
|
||||||
|
|
||||||
|
static FileSystemResourceLoader loader = new FileSystemResourceLoader();
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public static ProcessElement readProcess(String processId){//生成参数:
|
||||||
|
Function<XMLStreamReader, ProcessElement> function = xtr -> {
|
||||||
|
try {
|
||||||
|
while (xtr.hasNext()){
|
||||||
|
if (XMLStreamConstants.START_ELEMENT == xtr.next()){
|
||||||
|
System.out.println(xtr.getLocalName()+"___"+processId);
|
||||||
|
if (xtr.getLocalName().equals("process") && xtr.getAttributeValue(0).equals(processId)){
|
||||||
|
BaseConverter converter = converterMap.get(xtr.getLocalName());
|
||||||
|
return (ProcessElement)converter.process(xtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
throw new BadRequestException(ex.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
ProcessElement processElement = readXml("classpath:/scheduler.xml", function);
|
||||||
|
return processElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public static List<BaseElement> readall() {
|
||||||
|
//生成参数:
|
||||||
|
Function<XMLStreamReader, List> function = xtr -> {
|
||||||
|
List<BaseElement> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
while (xtr.hasNext()) {
|
||||||
|
if (XMLStreamConstants.START_ELEMENT == xtr.next()) {
|
||||||
|
System.out.println(xtr.getLocalName());
|
||||||
|
BaseConverter converter = converterMap.get(xtr.getLocalName());
|
||||||
|
if (converter != null) {
|
||||||
|
list.add(converter.process(xtr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
throw new BadRequestException(ex.getMessage());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
};
|
||||||
|
List<BaseElement> baseElements = readXml("classpath:/scheduler.xml", function);
|
||||||
|
return baseElements;
|
||||||
|
}
|
||||||
|
private static<T> T readXml(String path, Function<XMLStreamReader, T> function) throws IOException, XMLStreamException {
|
||||||
|
FileInputStream inputStream = null;
|
||||||
|
InputStreamReader streamReader = null;
|
||||||
|
Resource resource = loader.getResource(path);
|
||||||
|
try {
|
||||||
|
inputStream = new FileInputStream(resource.getFile());
|
||||||
|
streamReader = new InputStreamReader(inputStream, "UTF-8");
|
||||||
|
//TODO:schama校验
|
||||||
|
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(streamReader);
|
||||||
|
return function.apply(reader);
|
||||||
|
}finally {
|
||||||
|
if (streamReader!=null){
|
||||||
|
streamReader.close();
|
||||||
|
}
|
||||||
|
if (inputStream!=null){
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object postProcessAfterInitialization(@NotNull Object bean, String beanName) throws BeansException {
|
||||||
|
if (bean instanceof BaseConverter){
|
||||||
|
converterMap.put(beanName,(BaseConverter)bean);
|
||||||
|
}
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/19 11:00
|
||||||
|
*/
|
||||||
|
public interface BaseConverter {
|
||||||
|
BaseElement process(XMLStreamReader xtr) throws XMLStreamException;
|
||||||
|
|
||||||
|
default void setBaseLabel(BaseElement element,XMLStreamReader xtr,String...labels){
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
for (String label : labels) {
|
||||||
|
map.put(label,xtr.getAttributeValue(null,label));
|
||||||
|
}
|
||||||
|
element.setAttributeValue(map);
|
||||||
|
element.setId(xtr.getAttributeValue(null,"id"));
|
||||||
|
element.setName(xtr.getAttributeValue(null,"name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/21 18:03
|
||||||
|
*/
|
||||||
|
public class BaseElement implements Serializable {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private int xmlRowNumber;
|
||||||
|
private int xmlColumnNumber;
|
||||||
|
private Map<String,String> attributeValue;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXmlRowNumber() {
|
||||||
|
return xmlRowNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXmlRowNumber(int xmlRowNumber) {
|
||||||
|
this.xmlRowNumber = xmlRowNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXmlColumnNumber() {
|
||||||
|
return xmlColumnNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXmlColumnNumber(int xmlColumnNumber) {
|
||||||
|
this.xmlColumnNumber = xmlColumnNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getAttributeValue() {
|
||||||
|
return attributeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttributeValue(Map<String, String> attributeValue) {
|
||||||
|
this.attributeValue = attributeValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseConverter;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/19 11:00
|
||||||
|
*/
|
||||||
|
@Service("end")
|
||||||
|
public class EndConverter implements BaseConverter {
|
||||||
|
String[] labels = new String[]{"id","name","sourceRef"};
|
||||||
|
@Override
|
||||||
|
public BaseElement process(XMLStreamReader xtr) {
|
||||||
|
EndElement element = new EndElement();
|
||||||
|
setBaseLabel(element,xtr,labels);
|
||||||
|
element.setSourceRefId(xtr.getAttributeValue(null,"sourceRef"));
|
||||||
|
element.setTargetRefId(xtr.getAttributeValue(null,"targetRef"));
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/21 18:03
|
||||||
|
*/
|
||||||
|
public class EndElement extends FlowElement {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseConverter;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/19 11:00
|
||||||
|
*/
|
||||||
|
@Service("flow")
|
||||||
|
public class FlowConverter implements BaseConverter {
|
||||||
|
String[] labels = new String[]{"id","name","sourceRef","targetRef"};
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public BaseElement process(XMLStreamReader xtr) {
|
||||||
|
FlowElement element = new FlowElement();
|
||||||
|
setBaseLabel(element,xtr,labels);
|
||||||
|
element.setSourceRefId(xtr.getAttributeValue(null,"sourceRef"));
|
||||||
|
element.setTargetRefId(xtr.getAttributeValue(null,"targetRef"));
|
||||||
|
String has = xtr.getAttributeValue(null, "has");
|
||||||
|
if (StringUtils.isNotEmpty(has)){
|
||||||
|
int i = 0;
|
||||||
|
while (true){
|
||||||
|
if (i == Integer.valueOf(has)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (XMLStreamConstants.START_ELEMENT == xtr.next()){
|
||||||
|
System.out.println(xtr.getLocalName());
|
||||||
|
Map<String, String> param = new HashMap();
|
||||||
|
param.put(xtr.getAttributeValue(null,"id"),xtr.getAttributeValue(null,"value"));
|
||||||
|
element.getParams().add(param);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/21 18:03
|
||||||
|
*/
|
||||||
|
public class FlowElement extends BaseElement {
|
||||||
|
|
||||||
|
private FlowElement sourceRef;
|
||||||
|
private FlowElement targetRef;
|
||||||
|
private String sourceRefId;
|
||||||
|
private String targetRefId;
|
||||||
|
private List<Map<String,String>> params = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public FlowElement pre() {
|
||||||
|
return sourceRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlowElement next() {
|
||||||
|
return targetRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void setSourceRef(FlowElement sourceRef) {
|
||||||
|
this.sourceRef = sourceRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void setTargetRef(FlowElement targetRef) {
|
||||||
|
this.targetRef = targetRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getSourceRefId() {
|
||||||
|
return sourceRefId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSourceRefId(String sourceRefId) {
|
||||||
|
this.sourceRefId = sourceRefId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getTargetRefId() {
|
||||||
|
return targetRefId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setTargetRefId(String targetRefId) {
|
||||||
|
this.targetRefId = targetRefId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, String>> getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(List<Map<String, String>> params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseConverter;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/19 11:00
|
||||||
|
*/
|
||||||
|
@Service("gatway")
|
||||||
|
public class GatwayConverter implements BaseConverter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseElement process(XMLStreamReader xtr) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseConverter;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/19 11:00
|
||||||
|
*/
|
||||||
|
@Service("process")
|
||||||
|
public class ProcessConverter implements BaseConverter {
|
||||||
|
String[] labels = new String[]{"id","name"};
|
||||||
|
@Autowired
|
||||||
|
private Map<String,BaseConverter> converterMap;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseElement process(XMLStreamReader xtr) throws XMLStreamException {
|
||||||
|
ProcessElement element = new ProcessElement();
|
||||||
|
setBaseLabel(element,xtr,labels);
|
||||||
|
while (xtr.hasNext()){
|
||||||
|
if (XMLStreamConstants.START_ELEMENT == xtr.next()){
|
||||||
|
String localName = xtr.getLocalName();
|
||||||
|
element.getFlowElements().add((FlowElement) converterMap.get(localName).process(xtr));
|
||||||
|
if (localName.equals("end")){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, FlowElement> eleMap = element.getFlowElements().stream().collect(HashMap::new, (k, v) -> k.put(v.getId(), v), HashMap::putAll);
|
||||||
|
for (FlowElement flowElement : element.getFlowElements()) {
|
||||||
|
flowElement.setTargetRef(eleMap.get(flowElement.getTargetRefId()));
|
||||||
|
flowElement.setSourceRef(eleMap.get(flowElement.getSourceRefId()));
|
||||||
|
}
|
||||||
|
element.setStartElement(eleMap.get("start"));
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/21 18:03
|
||||||
|
*/
|
||||||
|
public class ProcessElement extends BaseElement {
|
||||||
|
|
||||||
|
private StartElement startElement;
|
||||||
|
|
||||||
|
private List<FlowElement> flowElements = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<FlowElement> getFlowElements() {
|
||||||
|
return flowElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlowElement flowId(String flowId){
|
||||||
|
for (FlowElement flowElement : flowElements) {
|
||||||
|
if (flowElement.getId().equals(flowId)){
|
||||||
|
return flowElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlowElements(List<FlowElement> flowElements) {
|
||||||
|
this.flowElements = flowElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StartElement getStartElement() {
|
||||||
|
return startElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setStartElement(BaseElement startElement) {
|
||||||
|
this.startElement = (StartElement)startElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseConverter;
|
||||||
|
import org.nl.wms.scheduler_manage.service.scheduler.labelConverter.BaseElement;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLStreamReader;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/19 11:00
|
||||||
|
*/
|
||||||
|
@Service("start")
|
||||||
|
public class StartConverter implements BaseConverter {
|
||||||
|
String[] labels = new String[]{"id","name","targetRef"};
|
||||||
|
@Override
|
||||||
|
public BaseElement process(XMLStreamReader xtr) {
|
||||||
|
StartElement element = new StartElement();
|
||||||
|
setBaseLabel(element,xtr,labels);
|
||||||
|
element.setSourceRefId(xtr.getAttributeValue(null,"sourceRef"));
|
||||||
|
element.setTargetRefId(xtr.getAttributeValue(null,"targetRef"));
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.nl.wms.scheduler_manage.service.scheduler.labelConverter.impl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2023/5/21 18:03
|
||||||
|
*/
|
||||||
|
public class StartElement extends FlowElement {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -92,3 +92,4 @@ mybatis-plus:
|
|||||||
db-config:
|
db-config:
|
||||||
id-type: INPUT
|
id-type: INPUT
|
||||||
banner: false
|
banner: false
|
||||||
|
schedulerFile: classpath:/scheduler.xml
|
||||||
|
|||||||
22
mes/hd/nladmin-system/src/main/resources/scheduler.xml
Normal file
22
mes/hd/nladmin-system/src/main/resources/scheduler.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<definitions>
|
||||||
|
<process id="JGXJ" name="机关下料">
|
||||||
|
<start id="start" name="Starter" targetRef="A1_JGXJ"></start>
|
||||||
|
<flow id="A1_JGXJ" name="机关下料工序" sourceRef="start" targetRef="A1_TWYTJ"></flow>
|
||||||
|
<flow id="A1_TWYTJ" name="推弯工序" sourceRef="A1_JGXJ" targetRef="A1_SKQX"></flow>
|
||||||
|
<flow id="A1_SKQX" name="深坑清洗" sourceRef="A1_TWYTJ" targetRef="end"></flow>
|
||||||
|
<end id="end" name="Junior Reject End" sourceRef="A1_SKQX"></end>
|
||||||
|
</process>
|
||||||
|
<process id="WXXL" name="直管无屑下料">
|
||||||
|
<start id="start" name="Starter" targetRef="A1_WXXL"></start>
|
||||||
|
<flow id="A1_WXXL" name="无屑下料工序" has="3" sourceRef="starter" targetRef="A1_STLS">
|
||||||
|
<param id="param1" value="param1"/>
|
||||||
|
<param id="param2" value="param2"/>
|
||||||
|
<param id="param3" value="param3"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="A1_STLS" name="三通拉伸工序" sourceRef="A1_WXXL" targetRef="A1_TK"></flow>
|
||||||
|
<flow id="A1_TK" name="镗孔" sourceRef="A1_TK" targetRef="end"></flow>
|
||||||
|
<flow id="A1_SKQX" name="深坑清洗" sourceRef="A1_TK" targetRef="end"></flow>
|
||||||
|
<end id="end" name="Junior Reject End" sourceRef="A1_SKQX"></end>
|
||||||
|
</process>
|
||||||
|
</definitions>
|
||||||
Reference in New Issue
Block a user