Bladeren bron

docker stop

huangxingxing 8 maanden geleden
bovenliggende
commit
6450e46624

+ 1 - 0
dbscript/init/generate/03-functionInit.sql

@@ -94,6 +94,7 @@ INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('D2
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('D30001', '基础系统','一维瓦斯灾源查询',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('D30002', '基础系统','一维瓦斯灾源添加修改',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('D30003', '基础系统','一维瓦斯灾源删除',true);
+INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('D30004', '基础系统','求解停止',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('M00001', '基础系统','平台对接事故数据',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('M00002', '基础系统','平台对接预设路径',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('M00003', '基础系统','平台对接求解状态',true);

+ 112 - 0
generated/com/miniframe/generate/business/system/model/D30004BaseModel.java

@@ -0,0 +1,112 @@
+package com.miniframe.generate.business.system.model;
+
+import java.util.Map;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import com.miniframe.core.BaseMapModel;
+import com.miniframe.core.ext.UtilTools;
+import com.miniframe.core.ext.HttpMapFormater;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import com.miniframe.generate.global.AppGlobalVariableSysconfig;
+
+import com.miniframe.generate.comm.system.A_SYSTEMHEAD;
+import com.miniframe.generate.comm.system.D_SYSTEMHEAD;
+import com.miniframe.generate.comm.system.A_D30004;
+import com.miniframe.generate.comm.system.D_D30004;
+
+/**
+ * 系统服务,“求解停止”模型类(不要维护,重新生成将覆盖)。
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class D30004BaseModel extends BaseMapModel {
+
+	private static final long serialVersionUID = -1326184831746814093L;
+
+	A_SYSTEMHEAD a_systemhead;//上行头
+	D_SYSTEMHEAD d_systemhead;//下行头
+	A_D30004 a_d30004;//上行体
+	D_D30004 d_d30004;//下行体
+
+	public D30004BaseModel(){
+		a_systemhead=new A_SYSTEMHEAD();
+		d_systemhead=new D_SYSTEMHEAD();
+		a_d30004=new A_D30004();
+		d_d30004=new D_D30004();
+	}
+
+	public void validater() throws Exception {
+		this.a_systemhead.validater();
+		this.a_d30004.validater();
+	}
+
+	public void setTransMap(Map map) throws Exception {
+		Map headMap = HttpMapFormater.format(map, A_SYSTEMHEAD.class);
+		this.a_systemhead = UtilTools.map2Obj(headMap, A_SYSTEMHEAD.class);
+		Map bodyMap = HttpMapFormater.format(map, A_D30004.class);
+		this.a_d30004 = UtilTools.map2Obj(bodyMap, A_D30004.class);
+	}
+
+	public Map getTransMap() throws Exception {
+		Map reMap = new LinkedHashMap();
+
+		if(UtilTools.isNullOrBlank((this.d_systemhead).getTransCode())){
+			(this.d_systemhead).setTransCode((this.a_systemhead).getTransCode());
+		}
+		if(UtilTools.isNullOrBlank((this.d_systemhead).getChannelNo())){
+			(this.d_systemhead).setChannelNo((this.a_systemhead).getChannelNo());
+		}
+		if(UtilTools.isNullOrBlank((this.d_systemhead).getUserId())){
+			(this.d_systemhead).setUserId((this.a_systemhead).getUserId());
+		}
+        if(UtilTools.isNullOrBlank((this.d_systemhead).getTransTime())){
+            (this.d_systemhead).setTransTime(DateTimeFormatter.ofPattern(AppGlobalVariableSysconfig.DATETIMEFORMAT).format(ZonedDateTime.now()));
+        }
+
+		reMap.putAll(UtilTools.obj2Map(this.d_systemhead));
+		reMap.putAll(UtilTools.obj2Map(this.d_d30004));
+
+		return reMap;
+	}
+
+	public A_SYSTEMHEAD getA_systemhead() {
+		return this.a_systemhead;
+	}
+
+	public void setA_systemhead(A_SYSTEMHEAD a_systemhead) {
+		this.a_systemhead=a_systemhead;
+	}
+
+	public D_SYSTEMHEAD getD_systemhead() {
+		return d_systemhead;
+	}
+
+	public void setD_systemhead(D_SYSTEMHEAD d_systemhead) {
+		this.d_systemhead=d_systemhead;
+	}
+
+	public A_D30004 getA_d30004() {
+		return a_d30004;
+	}
+
+	public void setA_d30004(A_D30004 a_d30004) {
+		this.a_d30004=a_d30004;
+	}
+
+	public D_D30004 getD_d30004() {
+		return this.d_d30004;
+	}
+
+	public void setD_d30004(D_D30004 d_d30004) {
+		this.d_d30004=d_d30004;
+	}
+
+	@Override
+	public String toString() {
+		try {
+			return UtilTools.obj2Json(this,true);
+		} catch (IOException e) {
+			return "";
+		}
+	}
+}

+ 99 - 0
generated/com/miniframe/generate/comm/httpclientapater/D30004Client.java

@@ -0,0 +1,99 @@
+package com.miniframe.generate.comm.httpclientapater;
+
+import com.miniframe.spring.httpclient.MFHttpRespInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import com.miniframe.core.Transmitter;
+import com.miniframe.core.ext.UtilTools;
+import com.miniframe.generate.comm.system.D_D30004;
+import com.miniframe.generate.comm.system.D_SYSTEMHEAD;
+
+import com.miniframe.generate.business.system.model.D30004BaseModel;
+
+public class D30004Client {
+
+	private static final Logger logger = LoggerFactory.getLogger(D30004Client.class);
+	private MFHttpRespInfo respInfo;
+
+	public MFHttpRespInfo getRespInfo(){
+		return respInfo;
+	}
+
+	/**
+	 * 调用 [系统服务->求解停止((D30004)]的通讯接口
+	 * @param model 接口模型
+	 * @param extMap 扩展输入
+	 * @param url 请求地址
+	 * @return model 接口模型
+	 * @throws Exception
+	 */
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public D30004BaseModel execute(D30004BaseModel model,final Map extMap,final String url) throws Exception {
+		this.executeToRespInfo(model,extMap,url);
+		return model;
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public D30004BaseModel execute(D30004BaseModel model,final Map extMap) throws Exception {
+		this.executeToRespInfo(model,extMap,null);
+		return model;
+	}
+
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MFHttpRespInfo executeToRespInfo(D30004BaseModel model,final Map extMap,final String url) throws Exception {
+		if (logger.isDebugEnabled()) {
+			logger.debug("execute(D30004BaseModel) - start");
+		}
+
+		if(UtilTools.isNullOrBlank(model.getA_systemhead().getTransCode())){
+			model.getA_systemhead().setTransCode("D30004");
+		}
+
+		Map inMap = new LinkedHashMap();
+		inMap.putAll(UtilTools.obj2Map(model.getA_systemhead()));
+		inMap.putAll(UtilTools.obj2Map(model.getA_d30004()));
+		if(extMap!=null && extMap.size()>0){
+			inMap.putAll(extMap);
+		}
+
+		Transmitter httpclientApater = (Transmitter) UtilTools.getBean("httpclientApater");
+		MFHttpRespInfo respInfo;
+		if(UtilTools.isNotNullAndBlank(url)){
+			respInfo = httpclientApater.doPostDataToRespInfo(inMap,url);
+		}else{
+			respInfo = httpclientApater.doPostDataToRespInfo(inMap);
+		}
+
+		if(respInfo!=null) {
+			Map outMap=respInfo.getParamMap();
+			D_SYSTEMHEAD d_systemhead =  UtilTools.map2Obj(outMap, D_SYSTEMHEAD.class);
+			D_D30004 d_d30004 =  UtilTools.map2Obj(outMap, D_D30004.class);
+			model.setD_systemhead(d_systemhead);
+			model.setD_d30004(d_d30004);
+
+
+		}
+
+		if (logger.isDebugEnabled()) {
+			logger.debug("execute(D30004BaseModel) - end");
+		}
+
+        this.respInfo=respInfo;
+
+		return respInfo;
+	}
+
+
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public D30004BaseModel execute(D30004BaseModel model) throws Exception {
+		return this.execute(model,null,null);
+	}
+
+
+}

+ 25 - 0
generated/com/miniframe/generate/comm/system/A_D30004.java

@@ -0,0 +1,25 @@
+/**
+ * 系统服务
+ */
+package com.miniframe.generate.comm.system;
+import com.miniframe.core.BaseMapModel;
+import java.io.Serializable;
+/**
+ * 求解停止
+ */
+public class A_D30004 extends BaseMapModel implements Serializable {
+	private static final long serialVersionUID = -1463838678425832212L;
+	int aid;//事故id
+	/**
+	 *事故id
+	 */
+	public void setAid(int aid) {
+		this.aid=aid;
+	}
+	/**
+	 *事故id
+	 */
+	public int getAid() {
+		return this.aid;
+	}
+}

+ 12 - 0
generated/com/miniframe/generate/comm/system/D_D30004.java

@@ -0,0 +1,12 @@
+/**
+ * 系统服务
+ */
+package com.miniframe.generate.comm.system;
+import com.miniframe.core.BaseMapModel;
+import java.io.Serializable;
+/**
+ * 求解停止
+ */
+public class D_D30004 extends BaseMapModel implements Serializable {
+	private static final long serialVersionUID = -1463838678425832212L;
+}

+ 12 - 0
generated/validateform/a_d30004Form.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd">
+<!-- 求解停止Form配置文件系统生成请勿修改,否则重新生成将覆盖 -->
+<form-validation>
+<formset>
+<form name="a_d30004Form">
+<field property="aid" depends="required">
+    <arg0 key="a_d30004.aid"/>
+</field>
+</form>
+</formset>
+</form-validation>

+ 2 - 0
generated/validator/resources_a_d30004Form_validator.properties

@@ -0,0 +1,2 @@
+a_d30004.aid = \u4E8B\u6545id
+a_d30004Form = true

+ 2 - 0
generated/validator/resources_a_d30004Form_validator_zh_CN.properties

@@ -0,0 +1,2 @@
+a_d30004.aid = \u4E8B\u6545id
+a_d30004Form = true

+ 1 - 0
generated/validator/resources_d_d30004Form_validator.properties

@@ -0,0 +1 @@
+d_d30004Form = false

+ 1 - 0
generated/validator/resources_d_d30004Form_validator_zh_CN.properties

@@ -0,0 +1 @@
+d_d30004Form = false

+ 71 - 0
src/main/java/com/miniframe/bisiness/system/D30004Service.java

@@ -0,0 +1,71 @@
+package com.miniframe.bisiness.system;
+
+import java.util.Map;
+import com.miniframe.core.ExecProcessFlow;
+import com.miniframe.core.exception.BusinessException;
+import com.miniframe.core.ext.UtilTools;
+import com.miniframe.generate.business.system.model.D30004BaseModel;
+import com.miniframe.model.system.DAccident;
+import com.miniframe.model.system.dao.DAccidentMapper;
+import com.miniframe.solverjob.DockerExe;
+
+/**
+ * 基础系统,“求解停止”逻辑处理(重新生成不覆盖)。
+ */
+public class D30004Service extends D30004BaseModel implements ExecProcessFlow {
+	
+	private static final long serialVersionUID = -7051358269847459502L;
+		
+	/**
+	 * 基础系统,“求解停止”业务核心处理
+ 	 */
+	public void transExecute() throws Exception {
+
+		Integer aid =this.getA_d30004().getAid();
+		DAccidentMapper aDao = UtilTools.getBean(DAccidentMapper.class);
+		DAccident acc =aDao.selectByPrimaryKey(aid);
+		if(acc==null){
+			throw new BusinessException("EB3100038",new String[]{aid.toString()});
+		}
+		String stype="gass";
+		if(acc.getStype().equals("Water")){
+			stype="Water";
+		}else if(acc.getStype().equals("Fire")){
+			stype ="Fire";
+		}else if(acc.getStype().equals("Gass")){
+			stype ="gass";
+		}else if(acc.getStype().equals("Gass1")){
+			stype ="gass";
+		}
+		DockerExe.stopDocker(aid,stype);
+
+	}
+	
+	/**
+	 * 基础系统,“求解停止”业务前处理
+ 	 */
+	public void preTransFlow() throws Exception {
+		this.validater();
+	}
+	
+	/**
+	 * 基础系统,“求解停止”业务后处理
+ 	 */
+	public void afterTransFlow() throws Exception {
+	
+	}
+	
+	/**
+	 * 基础系统,“求解停止”逻辑入口处理方法
+ 	 */
+ 	@SuppressWarnings("rawtypes")
+	@Override
+	public Map execute(Map vars) throws Exception {
+		this.setTransMap(vars);
+		preTransFlow();// 执行业务开始的规则检查和校验
+		transExecute();// 执行核心业务段
+		afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
+		return this.getTransMap();
+	}
+
+}

+ 2 - 1
src/test/java/com/miniframe/DockerTest.java

@@ -13,6 +13,7 @@ import com.github.dockerjava.core.DockerClientConfig;
 import com.github.dockerjava.core.command.LogContainerResultCallback;
 import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
 import com.github.dockerjava.transport.DockerHttpClient;
+import com.miniframe.solverjob.DockerExe;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -27,7 +28,7 @@ public class DockerTest {
     public static void main(String[] args) throws InterruptedException {
         // 初始化 Docker 客户端
 //        System.out.println("容器已成功停止: " + getDocker(7182031)); ;
-        getLogs();
+        DockerExe.stopDocker(982,"Water");
     }
     public static String getDocker(Integer aid){
         DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()

+ 43 - 0
src/test/java/com/miniframe/PtDj.java

@@ -0,0 +1,43 @@
+package com.miniframe;
+
+
+
+import com.alibaba.nacos.shaded.com.google.gson.JsonArray;
+import com.miniframe.tools.XiJsonUtil;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class PtDj {
+    public static void main(String[] args) throws IOException {
+        File file = new File("D://ptp.json");
+        String jsonstr =new String (Files.readAllBytes(Paths.get(file.getPath())));
+
+        JSONArray jsonArray = new JSONArray(jsonstr);
+        List<PtPipe> ps =new ArrayList<>();
+        // 处理jsonArray
+        for (int i = 0; i < jsonArray.length(); i++) {
+//            System.out.println(jsonArray.get(i));
+            PtPipe pipe= XiJsonUtil.jsonToPojo( jsonArray.get(i).toString(),PtPipe.class);
+//            System.out.println(pipe.getTunnelName()+","+pipe.getPositionA().getX()+","+pipe.getPositionB().getZ());
+//            System.out.println(pipe.getTunnelName()+","+pipe.getPositionA().getX()+","+pipe.getPositionB().getZ());
+            System.out.println(pipe.getPositionA().getX()+"\t"+pipe.getPositionA().getY()+"\t"+pipe.getPositionA().getZ());
+            System.out.println(pipe.getPositionB().getX()+"\t"+pipe.getPositionB().getY()+"\t"+pipe.getPositionB().getZ());
+            ps.add(pipe);
+        }
+
+
+
+    }
+}
+
+

+ 31 - 0
src/test/java/com/miniframe/PtNode.java

@@ -0,0 +1,31 @@
+package com.miniframe;
+
+public class PtNode {
+    private double x;
+    private double y;
+    private double z;
+
+    public double getX() {
+        return x;
+    }
+
+    public void setX(double x) {
+        this.x = x;
+    }
+
+    public double getY() {
+        return y;
+    }
+
+    public void setY(double y) {
+        this.y = y;
+    }
+
+    public double getZ() {
+        return z;
+    }
+
+    public void setZ(double z) {
+        this.z = z;
+    }
+}

+ 31 - 0
src/test/java/com/miniframe/PtPipe.java

@@ -0,0 +1,31 @@
+package com.miniframe;
+
+public class PtPipe {
+    private  String tunnelName;
+    private PtNode positionA;
+    private PtNode positionB;
+
+    public String getTunnelName() {
+        return tunnelName;
+    }
+
+    public void setTunnelName(String tunnelName) {
+        this.tunnelName = tunnelName;
+    }
+
+    public PtNode getPositionA() {
+        return positionA;
+    }
+
+    public void setPositionA(PtNode positionA) {
+        this.positionA = positionA;
+    }
+
+    public PtNode getPositionB() {
+        return positionB;
+    }
+
+    public void setPositionB(PtNode positionB) {
+        this.positionB = positionB;
+    }
+}

+ 44 - 0
src/test/java/com/miniframe/comm/httpclientapater/D30004Test.java

@@ -0,0 +1,44 @@
+package com.miniframe.comm.httpclientapater;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.miniframe.comm.httpclientapater.HttpclientapaterUtil;
+import com.miniframe.generate.comm.system.A_D30004;
+import com.miniframe.generate.comm.httpclientapater.D30004Client;
+import com.miniframe.generate.business.system.model.D30004BaseModel;
+
+public class D30004Test {
+
+	private static final Logger logger = LoggerFactory.getLogger(D30004Test.class);
+
+	/**
+	 * 求解停止,获取报文体
+	 * @return
+	 */
+	public static A_D30004 getA_d30004() {
+		A_D30004 a_d30004 = new A_D30004();
+
+		// ----------以下增加【求解停止】上行体赋值-------------
+
+
+
+		// ---------------------------------------------------
+		return a_d30004;
+	}
+	
+	/**
+	 * 运行客户端测试,求解停止
+	 * 
+	 * @param args
+	 * @throws Exception
+	 */
+	public static void main(String[] args) throws Exception {
+		D30004BaseModel model = new D30004BaseModel();
+		model.setA_systemhead(HttpclientapaterUtil.getA_systemhead("D30004"));
+		model.setA_d30004(D30004Test.getA_d30004());
+		D30004Client client = new D30004Client();
+		logger.error("客户端发送前总线:\r\n"+model);
+		model = client.execute(model);
+		logger.error("客户端发送后总线:\r\n"+model);
+	}
+}

+ 2 - 0
系统设计/数据定义/返 回 码/business(业务系统).csv

@@ -112,6 +112,8 @@
 3100036,EB3100036,fanid:{0}风机不存在!,
 3100037,EB3100037,doorid:{0}风门不存在!,
 
+3100038,EB3100038,aid:{0}事故不存在!,
+
 
 
 4000001,EMB00001,计算未完成!,

+ 3 - 0
系统设计/系统模块/SYSTEM(基础系统).csv

@@ -104,6 +104,9 @@
 320002,D30002,一维瓦斯灾源添加修改,service,,
 320003,D30003,一维瓦斯灾源删除,service,,
 
+320004,D30004,求解停止,service,,
+
+
 400001,M00001,平台对接事故数据,service,,
 400002,M00002,平台对接预设路径,service,,
 400003,M00003,平台对接求解状态,service,,

+ 2 - 0
系统设计/通信设计/通讯报文/system(系统服务)/报文体/D30004_A(求解停止).csv

@@ -0,0 +1,2 @@
+序号,英文名称,中文名称,数据类型,默认值,格式化,非空/引用,最小(长度/值),最大(长度/值),验证规则,标准数据ID,XML样式,TAG标签,映射/子标签,CDATA
+1,aid,事故id,int,,,是,,,,,,,,

+ 1 - 0
系统设计/通信设计/通讯报文/system(系统服务)/报文体/D30004_D(求解停止).csv

@@ -0,0 +1 @@
+序号,英文名称,中文名称,数据类型,默认值,格式化,非空/引用,最小(长度/值),最大(长度/值),验证规则,标准数据ID,XML样式,TAG标签,映射/子标签,CDATA