huangxingxing 5 месяцев назад
Родитель
Сommit
eac0fb7c7e

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

@@ -68,6 +68,7 @@ INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('MD
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('MDO0069', '西工大系统','FSI参数查询',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('MDO0070', '西工大系统','FSI添加修改',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('MDO0071', '西工大系统','FSI删除',true);
+INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('MDO0072', '西工大系统','bdf文件解析',true);
 -- 基础系统
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('A00000', '基础系统','获取图片验证码',true);
 INSERT INTO SYS_FUNCTION(FUNCTIONID, CLASSNAME, FUNCTIONNAME ,ENABLE)VALUES ('A00001', '基础系统','获取短信验证码',true);

+ 112 - 0
generated/com/miniframe/generate/business/mdo/model/MDO0072BaseModel.java

@@ -0,0 +1,112 @@
+package com.miniframe.generate.business.mdo.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.mdo.A_MDOHEAD;
+import com.miniframe.generate.comm.mdo.D_MDOHEAD;
+import com.miniframe.generate.comm.mdo.A_MDO0072;
+import com.miniframe.generate.comm.mdo.D_MDO0072;
+
+/**
+ * 系统服务,“bdf文件解析”模型类(不要维护,重新生成将覆盖)。
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class MDO0072BaseModel extends BaseMapModel {
+
+	private static final long serialVersionUID = -1326184831746814093L;
+
+	A_MDOHEAD a_mdohead;//上行头
+	D_MDOHEAD d_mdohead;//下行头
+	A_MDO0072 a_mdo0072;//上行体
+	D_MDO0072 d_mdo0072;//下行体
+
+	public MDO0072BaseModel(){
+		a_mdohead=new A_MDOHEAD();
+		d_mdohead=new D_MDOHEAD();
+		a_mdo0072=new A_MDO0072();
+		d_mdo0072=new D_MDO0072();
+	}
+
+	public void validater() throws Exception {
+		this.a_mdohead.validater();
+		this.a_mdo0072.validater();
+	}
+
+	public void setTransMap(Map map) throws Exception {
+		Map headMap = HttpMapFormater.format(map, A_MDOHEAD.class);
+		this.a_mdohead = UtilTools.map2Obj(headMap, A_MDOHEAD.class);
+		Map bodyMap = HttpMapFormater.format(map, A_MDO0072.class);
+		this.a_mdo0072 = UtilTools.map2Obj(bodyMap, A_MDO0072.class);
+	}
+
+	public Map getTransMap() throws Exception {
+		Map reMap = new LinkedHashMap();
+
+		if(UtilTools.isNullOrBlank((this.d_mdohead).getTransCode())){
+			(this.d_mdohead).setTransCode((this.a_mdohead).getTransCode());
+		}
+		if(UtilTools.isNullOrBlank((this.d_mdohead).getChannelNo())){
+			(this.d_mdohead).setChannelNo((this.a_mdohead).getChannelNo());
+		}
+		if(UtilTools.isNullOrBlank((this.d_mdohead).getUserId())){
+			(this.d_mdohead).setUserId((this.a_mdohead).getUserId());
+		}
+        if(UtilTools.isNullOrBlank((this.d_mdohead).getTransTime())){
+            (this.d_mdohead).setTransTime(DateTimeFormatter.ofPattern(AppGlobalVariableSysconfig.DATETIMEFORMAT).format(ZonedDateTime.now()));
+        }
+
+		reMap.putAll(UtilTools.obj2Map(this.d_mdohead));
+		reMap.putAll(UtilTools.obj2Map(this.d_mdo0072));
+
+		return reMap;
+	}
+
+	public A_MDOHEAD getA_mdohead() {
+		return this.a_mdohead;
+	}
+
+	public void setA_mdohead(A_MDOHEAD a_mdohead) {
+		this.a_mdohead=a_mdohead;
+	}
+
+	public D_MDOHEAD getD_mdohead() {
+		return d_mdohead;
+	}
+
+	public void setD_mdohead(D_MDOHEAD d_mdohead) {
+		this.d_mdohead=d_mdohead;
+	}
+
+	public A_MDO0072 getA_mdo0072() {
+		return a_mdo0072;
+	}
+
+	public void setA_mdo0072(A_MDO0072 a_mdo0072) {
+		this.a_mdo0072=a_mdo0072;
+	}
+
+	public D_MDO0072 getD_mdo0072() {
+		return this.d_mdo0072;
+	}
+
+	public void setD_mdo0072(D_MDO0072 d_mdo0072) {
+		this.d_mdo0072=d_mdo0072;
+	}
+
+	@Override
+	public String toString() {
+		try {
+			return UtilTools.obj2Json(this,true);
+		} catch (IOException e) {
+			return "";
+		}
+	}
+}

+ 99 - 0
generated/com/miniframe/generate/comm/httpmdoapater/MDO0072Client.java

@@ -0,0 +1,99 @@
+package com.miniframe.generate.comm.httpmdoapater;
+
+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.mdo.D_MDO0072;
+import com.miniframe.generate.comm.mdo.D_MDOHEAD;
+
+import com.miniframe.generate.business.mdo.model.MDO0072BaseModel;
+
+public class MDO0072Client {
+
+	private static final Logger logger = LoggerFactory.getLogger(MDO0072Client.class);
+	private MFHttpRespInfo respInfo;
+
+	public MFHttpRespInfo getRespInfo(){
+		return respInfo;
+	}
+
+	/**
+	 * 调用 [系统服务->bdf文件解析((MDO0072)]的通讯接口
+	 * @param model 接口模型
+	 * @param extMap 扩展输入
+	 * @param url 请求地址
+	 * @return model 接口模型
+	 * @throws Exception
+	 */
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MDO0072BaseModel execute(MDO0072BaseModel model,final Map extMap,final String url) throws Exception {
+		this.executeToRespInfo(model,extMap,url);
+		return model;
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MDO0072BaseModel execute(MDO0072BaseModel model,final Map extMap) throws Exception {
+		this.executeToRespInfo(model,extMap,null);
+		return model;
+	}
+
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MFHttpRespInfo executeToRespInfo(MDO0072BaseModel model,final Map extMap,final String url) throws Exception {
+		if (logger.isDebugEnabled()) {
+			logger.debug("execute(MDO0072BaseModel) - start");
+		}
+
+		if(UtilTools.isNullOrBlank(model.getA_mdohead().getTransCode())){
+			model.getA_mdohead().setTransCode("MDO0072");
+		}
+
+		Map inMap = new LinkedHashMap();
+		inMap.putAll(UtilTools.obj2Map(model.getA_mdohead()));
+		inMap.putAll(UtilTools.obj2Map(model.getA_mdo0072()));
+		if(extMap!=null && extMap.size()>0){
+			inMap.putAll(extMap);
+		}
+
+		Transmitter httpmdoApater = (Transmitter) UtilTools.getBean("httpmdoApater");
+		MFHttpRespInfo respInfo;
+		if(UtilTools.isNotNullAndBlank(url)){
+			respInfo = httpmdoApater.doPostDataToRespInfo(inMap,url);
+		}else{
+			respInfo = httpmdoApater.doPostDataToRespInfo(inMap);
+		}
+
+		if(respInfo!=null) {
+			Map outMap=respInfo.getParamMap();
+			D_MDOHEAD d_mdohead =  UtilTools.map2Obj(outMap, D_MDOHEAD.class);
+			D_MDO0072 d_mdo0072 =  UtilTools.map2Obj(outMap, D_MDO0072.class);
+			model.setD_mdohead(d_mdohead);
+			model.setD_mdo0072(d_mdo0072);
+
+
+		}
+
+		if (logger.isDebugEnabled()) {
+			logger.debug("execute(MDO0072BaseModel) - end");
+		}
+
+        this.respInfo=respInfo;
+
+		return respInfo;
+	}
+
+
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MDO0072BaseModel execute(MDO0072BaseModel model) throws Exception {
+		return this.execute(model,null,null);
+	}
+
+
+}

+ 25 - 0
generated/com/miniframe/generate/comm/mdo/A_MDO0072.java

@@ -0,0 +1,25 @@
+/**
+ * 系统服务
+ */
+package com.miniframe.generate.comm.mdo;
+import com.miniframe.core.BaseMapModel;
+import java.io.Serializable;
+/**
+ * bdf文件解析
+ */
+public class A_MDO0072 extends BaseMapModel implements Serializable {
+	private static final long serialVersionUID = -1463838678425832212L;
+	String fid;//文件id
+	/**
+	 *文件id
+	 */
+	public void setFid(String fid) {
+		this.fid=fid;
+	}
+	/**
+	 *文件id
+	 */
+	public String getFid() {
+		return this.fid;
+	}
+}

+ 25 - 0
generated/com/miniframe/generate/comm/mdo/D_MDO0072.java

@@ -0,0 +1,25 @@
+/**
+ * 系统服务
+ */
+package com.miniframe.generate.comm.mdo;
+import com.miniframe.core.BaseMapModel;
+import java.io.Serializable;
+/**
+ * bdf文件解析
+ */
+public class D_MDO0072 extends BaseMapModel implements Serializable {
+	private static final long serialVersionUID = -1463838678425832212L;
+	String fid;//文件id
+	/**
+	 *文件id
+	 */
+	public void setFid(String fid) {
+		this.fid=fid;
+	}
+	/**
+	 *文件id
+	 */
+	public String getFid() {
+		return this.fid;
+	}
+}

+ 12 - 0
generated/validateform/a_mdo0072Form.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">
+<!-- bdf文件解析Form配置文件系统生成请勿修改,否则重新生成将覆盖 -->
+<form-validation>
+<formset>
+<form name="a_mdo0072Form">
+<field property="fid" depends="required">
+    <arg0 key="a_mdo0072.fid"/>
+</field>
+</form>
+</formset>
+</form-validation>

+ 12 - 0
generated/validateform/d_mdo0072Form.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">
+<!-- bdf文件解析Form配置文件系统生成请勿修改,否则重新生成将覆盖 -->
+<form-validation>
+<formset>
+<form name="d_mdo0072Form">
+<field property="fid" depends="required">
+    <arg0 key="d_mdo0072.fid"/>
+</field>
+</form>
+</formset>
+</form-validation>

+ 2 - 0
generated/validator/resources_a_mdo0072Form_validator.properties

@@ -0,0 +1,2 @@
+a_mdo0072.fid = \u6587\u4EF6id
+a_mdo0072Form = true

+ 2 - 0
generated/validator/resources_a_mdo0072Form_validator_zh_CN.properties

@@ -0,0 +1,2 @@
+a_mdo0072.fid = \u6587\u4EF6id
+a_mdo0072Form = true

+ 2 - 0
generated/validator/resources_d_mdo0072Form_validator.properties

@@ -0,0 +1,2 @@
+d_mdo0072.fid = \u6587\u4EF6id
+d_mdo0072Form = true

+ 2 - 0
generated/validator/resources_d_mdo0072Form_validator_zh_CN.properties

@@ -0,0 +1,2 @@
+d_mdo0072.fid = \u6587\u4EF6id
+d_mdo0072Form = true

+ 1 - 1
src/main/java/com/miniframe/bisiness/mdo/MDO0061Service.java

@@ -61,7 +61,7 @@ public class MDO0061Service extends MDO0061BaseModel implements ExecProcessFlow
 
 	private void run(SysFile file) throws Exception {
 		DockerExe.stopDocker(file.getId());
-		DockerExe.cgnsToJson(file);
+		DockerExe.bdfToJson(file);
 		final int[] con = {0};
 		final String[] line = {""};
 		CompletableFuture<Void> cf = CompletableFuture.supplyAsync(()-> {

+ 126 - 0
src/main/java/com/miniframe/bisiness/mdo/MDO0072Service.java

@@ -0,0 +1,126 @@
+package com.miniframe.bisiness.mdo;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import com.github.dockerjava.api.async.ResultCallback;
+import com.github.dockerjava.api.model.Frame;
+import com.miniframe.core.ExecProcessFlow;
+import com.miniframe.core.ext.UtilTools;
+import com.miniframe.generate.business.mdo.model.MDO0072BaseModel;
+import com.miniframe.model.system.SysFile;
+import com.miniframe.model.system.SysFileSQLBuilder;
+import com.miniframe.model.system.dao.SysFileMapper;
+import com.miniframe.tools.XIFileUtils;
+import com.miniframe.tools.docker.DockerExe;
+import com.miniframe.websocket.WebsocketEndPoint;
+
+/**
+ * 西工大系统,“bdf文件解析”逻辑处理(重新生成不覆盖)。
+ */
+public class MDO0072Service extends MDO0072BaseModel implements ExecProcessFlow {
+	
+	private static final long serialVersionUID = -7051358269847459502L;
+		
+	/**
+	 * 西工大系统,“bdf文件解析”业务核心处理
+ 	 */
+	public void transExecute() throws Exception {
+		String fid =this.getA_mdo0072().getFid();
+		Map<String, Object> result = new HashMap<>();
+		SysFileMapper sysFileDAO = UtilTools.getBean(SysFileMapper.class);
+		SysFile sysFile = sysFileDAO.selectByPrimaryKey(fid);
+
+		//删除上次解析数据
+		SysFileSQLBuilder fsb  =new SysFileSQLBuilder();
+		SysFileSQLBuilder.Criteria fsc = fsb.createCriteria();
+		fsc.andParentidEqualTo(fid);
+		List<SysFile> fList = sysFileDAO.selectByExample(fsb);
+		for (SysFile f:fList) {
+			XIFileUtils.delete(XIFileUtils.getRootPathStr()+"/"+f.getFilepath());
+		}
+		sysFileDAO.deleteByExample(fsb);
+		run(sysFile);
+	}
+	private  void sendMsg(String fid,String log){
+		CompletableFuture<Void> cf = CompletableFuture.supplyAsync(()->{
+			WebsocketEndPoint webs =  (WebsocketEndPoint) UtilTools.getBean("websocketEndPoint");
+			webs.sendMessageToUser(fid,log);
+			return null;
+		});
+	}
+
+	private void run(SysFile file) throws Exception {
+		DockerExe.stopDocker(file.getId());
+		DockerExe.cgnsToJson(file);
+		final int[] con = {0};
+		final String[] line = {""};
+		CompletableFuture<Void> cf = CompletableFuture.supplyAsync(()-> {
+			try {
+				DockerExe.getDockerLogs(file.getId(),new ResultCallback.Adapter<Frame>() {
+					@Override
+					public void onNext(Frame frame) {
+						if(con[0] <100){
+							line[0]+=new String(frame.getPayload());
+							con[0]++;
+						}else{
+							sendMsg(file.getId(), line[0]);
+							line[0]="";
+							con[0] =0;
+						}
+						sendMsg(file.getId(), line[0]);
+						System.out.print(new String(frame.getPayload()));
+						super.onNext(frame);
+					}
+
+					@Override
+					public void onError(Throwable throwable) {
+						System.err.println("日志获取失败");
+						throwable.printStackTrace();
+						super.onError(throwable);
+					}
+					@Override
+					public void onComplete() {
+						System.out.println("日志获取完成");
+						super.onComplete();
+					}
+				});
+
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			DockerExe.stopDocker(file.getId());
+			return null;
+		});
+	}
+	
+	/**
+	 * 西工大系统,“bdf文件解析”业务前处理
+ 	 */
+	public void preTransFlow() throws Exception {
+		this.validater();
+	}
+	
+	/**
+	 * 西工大系统,“bdf文件解析”业务后处理
+ 	 */
+	public void afterTransFlow() throws Exception {
+	
+	}
+	
+	/**
+	 * 西工大系统,“bdf文件解析”逻辑入口处理方法
+ 	 */
+ 	@SuppressWarnings("rawtypes")
+	@Override
+	public Map execute(Map vars) throws Exception {
+		this.setTransMap(vars);
+		preTransFlow();// 执行业务开始的规则检查和校验
+		transExecute();// 执行核心业务段
+		afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
+		return this.getTransMap();
+	}
+
+}

+ 48 - 0
src/main/java/com/miniframe/tools/docker/DockerExe.java

@@ -284,6 +284,54 @@ public class DockerExe {
         System.out.println("容器启动成功,ID: " + container.getId());
     }
 
+    public static void bdfToJson(SysFile file) throws Exception {
+        DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
+                .withDockerHost(DOCKERHOST) // 设置 Docker 主机地址
+                .withDockerTlsVerify(false) // 启用 TLS 验证
+                .withApiVersion(APIVERSION) // 设置 API 版本
+                .build();
+        DockerHttpClient httpClient = new ApacheDockerHttpClient.Builder()
+                .dockerHost(config.getDockerHost())
+                .sslConfig(config.getSSLConfig())
+                .build();
+        DockerClient dockerClient = DockerClientBuilder.getInstance(config)
+                .withDockerHttpClient(httpClient)
+                .build();
+
+        Path path = Paths.get(XIFileUtils.getRootPathStr()+"/"+file.getFilepath());
+        // 获取文件夹路径
+        String directory = path.getParent().toString();
+        Mount wokerMount = new Mount()
+                .withType(MountType.BIND)
+                .withSource(directory)
+                .withTarget(directory)
+                .withReadOnly(false);
+        List<Mount> am =new ArrayList<>();
+        am.add(wokerMount);
+
+        String jsonFile =directory+"/"+file.getFilename().replace(".cgns","_data.json");
+        File json =new File(jsonFile);
+        if(!json.exists()){
+            json.createNewFile();
+        }
+        XIFileUtils.saveUploadFiles(jsonFile, "uid","json",file.getId());
+        //创建容器
+        CreateContainerResponse container = dockerClient
+                .createContainerCmd("cgnsconver:1.0")//镜像名称
+                .withName(file.getId())//容器名称
+                .withHostConfig(
+                        HostConfig.newHostConfig()
+                                .withMounts(am)
+                ).withCmd("bash", "-c", "source /root/miniconda3/etc/profile.d/conda.sh" +
+                        " && conda activate pycgns-env" +
+                        " && cd /home/python/mdo/" +
+                        " && python bdfConver.py" +
+                        " "+XIFileUtils.getRootPathStr()+"/"+file.getFilepath() +
+                        " " +jsonFile)
+                .exec();
+        dockerClient.startContainerCmd(container.getId()).exec();
+        System.out.println("容器启动成功,ID: " + container.getId());
+    }
 
     public static void main(String[] args) {
         stopDocker("6cb37eea2845457ca17ba6441804af43");

+ 44 - 0
src/test/java/com/miniframe/comm/httpmdoapater/MDO0072Test.java

@@ -0,0 +1,44 @@
+package com.miniframe.comm.httpmdoapater;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.miniframe.comm.httpmdoapater.HttpmdoapaterUtil;
+import com.miniframe.generate.comm.mdo.A_MDO0072;
+import com.miniframe.generate.comm.httpmdoapater.MDO0072Client;
+import com.miniframe.generate.business.mdo.model.MDO0072BaseModel;
+
+public class MDO0072Test {
+
+	private static final Logger logger = LoggerFactory.getLogger(MDO0072Test.class);
+
+	/**
+	 * BDF文件解析,获取报文体
+	 * @return
+	 */
+	public static A_MDO0072 getA_mdo0072() {
+		A_MDO0072 a_mdo0072 = new A_MDO0072();
+
+		// ----------以下增加【BDF文件解析】上行体赋值-------------
+
+
+
+		// ---------------------------------------------------
+		return a_mdo0072;
+	}
+	
+	/**
+	 * 运行客户端测试,BDF文件解析
+	 * 
+	 * @param args
+	 * @throws Exception
+	 */
+	public static void main(String[] args) throws Exception {
+		MDO0072BaseModel model = new MDO0072BaseModel();
+		model.setA_mdohead(HttpmdoapaterUtil.getA_mdohead("MDO0072"));
+		model.setA_mdo0072(MDO0072Test.getA_mdo0072());
+		MDO0072Client client = new MDO0072Client();
+		logger.error("客户端发送前总线:\r\n"+model);
+		model = client.execute(model);
+		logger.error("客户端发送后总线:\r\n"+model);
+	}
+}

+ 3 - 1
系统设计/系统模块/MDO(西工大系统).csv

@@ -77,4 +77,6 @@
 
 100069,MDO0069,FSI参数查询,service,
 100070,MDO0070,FSI添加修改,service,
-100071,MDO0071,FSI删除,service,
+100071,MDO0071,FSI删除,service,
+
+100072,MDO0072,bdf文件解析,service,

+ 2 - 0
系统设计/通信设计/通讯报文/mdo(系统服务)/报文体/MDO0072_A(bdf文件解析).csv

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

+ 2 - 0
系统设计/通信设计/通讯报文/mdo(系统服务)/报文体/MDO0072_D(bdf文件解析).csv

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