李永德
1 year ago
37 changed files with 307 additions and 231 deletions
@ -0,0 +1,13 @@ |
|||
package org.nl.wms.ext.acs.service.dto.to.acs; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: |
|||
* @Date: 2023/8/4 |
|||
*/ |
|||
@Data |
|||
public class DeviceInfoDto { |
|||
private String device_code; |
|||
} |
@ -1,108 +0,0 @@ |
|||
//package org.nl.wms.sch.task_manage.task.tasks.auto;
|
|||
//
|
|||
//import cn.hutool.core.util.ObjectUtil;
|
|||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
//import org.nl.common.exception.BadRequestException;
|
|||
//import org.nl.system.service.param.ISysParamService;
|
|||
//import org.nl.system.service.param.dao.Param;
|
|||
//import org.nl.wms.sch.point.service.ISchBasePointService;
|
|||
//import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
|||
//import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
|||
//import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
|||
//import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
|||
//import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
|
|||
//import org.nl.wms.sch.task_manage.AbstractTask;
|
|||
//import org.nl.wms.sch.task_manage.GeneralDefinition;
|
|||
//import org.nl.wms.sch.task_manage.task.TaskType;
|
|||
//import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.stereotype.Component;
|
|||
//
|
|||
//import java.util.Arrays;
|
|||
//import java.util.List;
|
|||
//import java.util.stream.Collectors;
|
|||
//
|
|||
///**
|
|||
// * @Author: lyd
|
|||
// * @Description: 混料压制物料输送任务
|
|||
// * @Date: 2023/7/27
|
|||
// */
|
|||
//@Component
|
|||
//@TaskType("HLYZTask")
|
|||
//public class HLYZTask extends AbstractTask {
|
|||
// private static String TASK_CONFIG_CODE = "HLYZTask";
|
|||
// @Autowired
|
|||
// private ISchBasePointService pointService;
|
|||
// @Autowired
|
|||
// private ISchBaseTaskService taskService;
|
|||
// @Autowired
|
|||
// private ISchBaseTaskconfigService taskConfigService;
|
|||
// @Autowired
|
|||
// private ISysParamService paramService;
|
|||
// @Override
|
|||
// protected void create() throws BadRequestException {
|
|||
//
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// protected void autoCreate() {
|
|||
// // 自动创建任务
|
|||
//// Param autoKilnCall = paramService.findByCode(GeneralDefinition.AUTO_KILN_CALL);
|
|||
//// if (autoKilnCall.getValue().equals(GeneralDefinition.NO)) {
|
|||
//// return;
|
|||
//// }
|
|||
// // 判断当前点位有没有任务执行
|
|||
// List<SchBaseTask> unFinishTasksByTaskConfig = taskService.findUnFinishTasksByTaskConfig(TASK_CONFIG_CODE);
|
|||
// if (unFinishTasksByTaskConfig.size() > 0) {
|
|||
// // 有任务在执行就不创建
|
|||
// return;
|
|||
// }
|
|||
// // 获取任务配置
|
|||
// SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
|||
// .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
|||
// // 创建任务
|
|||
// SchBaseTask task = new SchBaseTask(); // 任务实体
|
|||
// // 2、创建申请任务
|
|||
// task.setConfig_code(TASK_CONFIG_CODE);
|
|||
// task.setCreate_mode(GeneralDefinition.AUTO_CREATION);
|
|||
// task.setTask_status(TaskStatus.APPLY.getCode());
|
|||
// task.setWorkshop_code(taskConfig.getWorkshop_code()); // 车间编码
|
|||
// // 设置起/终点
|
|||
// this.setTaskPoint(taskConfig, task, "***");
|
|||
// // 找起点
|
|||
// List<String> nextRegionStr = Arrays
|
|||
// .stream(taskConfig.getNext_region_str().split(","))
|
|||
// .collect(Collectors.toList());
|
|||
// SchBasePoint point = findNextPoint(nextRegionStr);
|
|||
// if (ObjectUtil.isEmpty(point)) {
|
|||
// task.setRemark("未找到所需点位!");
|
|||
// taskService.create(task);
|
|||
// // 消息通知
|
|||
// return;
|
|||
// }
|
|||
// // 设置终点并修改创建成功状态
|
|||
// task.setPoint_code2(point.getPoint_code());
|
|||
// task.setRemark("");
|
|||
// task.setTask_status(TaskStatus.CREATED.getCode());
|
|||
// taskService.create(task);
|
|||
// point.setIng_task_code(task.getTask_code());
|
|||
// pointService.update(point);
|
|||
// //下发
|
|||
//// this.renotifyAcs(task);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// protected void updateStatus(String task_code, TaskStatus status) {
|
|||
//
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void forceFinish(String task_code) {
|
|||
//
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void cancel(String task_code) {
|
|||
//
|
|||
// }
|
|||
//}
|
@ -0,0 +1,100 @@ |
|||
package org.nl.wms.util; |
|||
|
|||
import java.io.File; |
|||
import java.io.FileWriter; |
|||
import java.io.IOException; |
|||
|
|||
import javax.xml.parsers.DocumentBuilder; |
|||
import javax.xml.parsers.DocumentBuilderFactory; |
|||
import javax.xml.parsers.ParserConfigurationException; |
|||
import javax.xml.transform.OutputKeys; |
|||
import javax.xml.transform.Transformer; |
|||
import javax.xml.transform.TransformerException; |
|||
import javax.xml.transform.TransformerFactory; |
|||
import javax.xml.transform.dom.DOMSource; |
|||
import javax.xml.transform.stream.StreamResult; |
|||
|
|||
import org.w3c.dom.Document; |
|||
import org.xml.sax.InputSource; |
|||
import org.xml.sax.SAXException; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 将xml字符串存入xml文件中 |
|||
* @Date: 2023/8/7 |
|||
*/ |
|||
public class XmlFormatter { |
|||
public static void main(String[] args) { |
|||
String xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
|||
"<definitions>\n" + |
|||
" <process id=\"JGXL\" name=\"机关下料\">\n" + |
|||
" <start id=\"start\" name=\"Starter\" targetRef=\"A1_JGXL\"></start>\n" + |
|||
" <flow id=\"A1_JGXL\" name=\"机关下料工序\" has=\"1\" sourceRef=\"start\" targetRef=\"A1_TWYTJ\">\n" + |
|||
" <param id=\"cacheLine\" has=\"2\">\n" + |
|||
" <item spec=\"15\" value=\"A1_HCX_01\"></item>\n" + |
|||
" <item spec=\"22\" value=\"A1_HCX_02\"></item>\n" + |
|||
" </param>\n" + |
|||
" </flow>\n" + |
|||
" <flow id=\"A1_TWYTJ\" name=\"推弯一体工序\" sourceRef=\"A1_JGXL\" targetRef=\"A1_SKQX\">\n" + |
|||
" </flow>\n" + |
|||
" <flow id=\"A1_SKQX\" name=\"深坑清洗\" sourceRef=\"A1_TWYTJ\" targetRef=\"end\"></flow>\n" + |
|||
" <end id=\"end\" name=\"Junior Reject End\" sourceRef=\"A1_SKQX\"></end>\n" + |
|||
" </process>\n" + |
|||
" <process id=\"WXXL\" name=\"直管无屑下料\">\n" + |
|||
" <start id=\"start\" name=\"Starter\" targetRef=\"A1_WXXL\"></start>\n" + |
|||
" <flow id=\"A1_WXXL\" name=\"无屑下料工序\" has=\"1\" sourceRef=\"starter\" targetRef=\"A1_STLS\">\n" + |
|||
" <param id=\"cacheLine\" value=\"A1_HCX_03\"/>\n" + |
|||
" </flow>\n" + |
|||
" <flow id=\"A1_STLS\" name=\"三通拉伸工序\" sourceRef=\"A1_WXXL\" targetRef=\"A1_TK\"></flow>\n" + |
|||
" <flow id=\"A1_TK\" name=\"镗孔\" sourceRef=\"A1_TK\" targetRef=\"A1_SKQX\"></flow>\n" + |
|||
" <flow id=\"A1_SKQX\" name=\"深坑清洗\" sourceRef=\"A1_STLS\" targetRef=\"end\"></flow>\n" + |
|||
" <end id=\"end\" name=\"Junior Reject End\" sourceRef=\"A1_SKQX\"></end>\n" + |
|||
" </process>\n" + |
|||
"</definitions>\n"; |
|||
|
|||
// 格式化XML字符串
|
|||
String formattedXmlString = formatXmlString(xmlString); |
|||
|
|||
// 将格式化后的XML字符串存储到文件中
|
|||
String fileName = "xx.xml"; |
|||
saveXmlToFile(fileName, formattedXmlString); |
|||
} |
|||
|
|||
public static String formatXmlString(String xmlString) { |
|||
try { |
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
|||
DocumentBuilder builder = factory.newDocumentBuilder(); |
|||
Document document = builder.parse(new InputSource(new java.io.StringReader(xmlString))); |
|||
|
|||
// 格式化XML
|
|||
TransformerFactory transformerFactory = TransformerFactory.newInstance(); |
|||
Transformer transformer = transformerFactory.newTransformer(); |
|||
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); |
|||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); |
|||
DOMSource source = new DOMSource(document); |
|||
|
|||
java.io.StringWriter sw = new java.io.StringWriter(); |
|||
StreamResult result = new StreamResult(sw); |
|||
transformer.transform(source, result); |
|||
|
|||
return sw.toString(); |
|||
} catch (ParserConfigurationException | IOException | SAXException | TransformerException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return xmlString; |
|||
} |
|||
|
|||
public static void saveXmlToFile(String fileName, String xmlString) { |
|||
try { |
|||
File file = new File(fileName); |
|||
FileWriter writer = new FileWriter(file); |
|||
writer.write(xmlString); |
|||
writer.flush(); |
|||
writer.close(); |
|||
System.out.println("XML file saved successfully."); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue