Explorar o código

求解日志获取

huangxingxing hai 11 meses
pai
achega
7b589b9397

+ 112 - 0
generated/com/miniframe/generate/business/mdo/model/MDO0025BaseModel.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_MDO0025;
+import com.miniframe.generate.comm.mdo.D_MDO0025;
+
+/**
+ * 系统服务,“求解日志获取”模型类(不要维护,重新生成将覆盖)。
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class MDO0025BaseModel extends BaseMapModel {
+
+	private static final long serialVersionUID = -1326184831746814093L;
+
+	A_MDOHEAD a_mdohead;//上行头
+	D_MDOHEAD d_mdohead;//下行头
+	A_MDO0025 a_mdo0025;//上行体
+	D_MDO0025 d_mdo0025;//下行体
+
+	public MDO0025BaseModel(){
+		a_mdohead=new A_MDOHEAD();
+		d_mdohead=new D_MDOHEAD();
+		a_mdo0025=new A_MDO0025();
+		d_mdo0025=new D_MDO0025();
+	}
+
+	public void validater() throws Exception {
+		this.a_mdohead.validater();
+		this.a_mdo0025.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_MDO0025.class);
+		this.a_mdo0025 = UtilTools.map2Obj(bodyMap, A_MDO0025.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_mdo0025));
+
+		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_MDO0025 getA_mdo0025() {
+		return a_mdo0025;
+	}
+
+	public void setA_mdo0025(A_MDO0025 a_mdo0025) {
+		this.a_mdo0025=a_mdo0025;
+	}
+
+	public D_MDO0025 getD_mdo0025() {
+		return this.d_mdo0025;
+	}
+
+	public void setD_mdo0025(D_MDO0025 d_mdo0025) {
+		this.d_mdo0025=d_mdo0025;
+	}
+
+	@Override
+	public String toString() {
+		try {
+			return UtilTools.obj2Json(this,true);
+		} catch (IOException e) {
+			return "";
+		}
+	}
+}

+ 99 - 0
generated/com/miniframe/generate/comm/httpmdoapater/MDO0025Client.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_MDO0025;
+import com.miniframe.generate.comm.mdo.D_MDOHEAD;
+
+import com.miniframe.generate.business.mdo.model.MDO0025BaseModel;
+
+public class MDO0025Client {
+
+	private static final Logger logger = LoggerFactory.getLogger(MDO0025Client.class);
+	private MFHttpRespInfo respInfo;
+
+	public MFHttpRespInfo getRespInfo(){
+		return respInfo;
+	}
+
+	/**
+	 * 调用 [系统服务->求解日志获取((MDO0025)]的通讯接口
+	 * @param model 接口模型
+	 * @param extMap 扩展输入
+	 * @param url 请求地址
+	 * @return model 接口模型
+	 * @throws Exception
+	 */
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MDO0025BaseModel execute(MDO0025BaseModel model,final Map extMap,final String url) throws Exception {
+		this.executeToRespInfo(model,extMap,url);
+		return model;
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MDO0025BaseModel execute(MDO0025BaseModel model,final Map extMap) throws Exception {
+		this.executeToRespInfo(model,extMap,null);
+		return model;
+	}
+
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MFHttpRespInfo executeToRespInfo(MDO0025BaseModel model,final Map extMap,final String url) throws Exception {
+		if (logger.isDebugEnabled()) {
+			logger.debug("execute(MDO0025BaseModel) - start");
+		}
+
+		if(UtilTools.isNullOrBlank(model.getA_mdohead().getTransCode())){
+			model.getA_mdohead().setTransCode("MDO0025");
+		}
+
+		Map inMap = new LinkedHashMap();
+		inMap.putAll(UtilTools.obj2Map(model.getA_mdohead()));
+		inMap.putAll(UtilTools.obj2Map(model.getA_mdo0025()));
+		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_MDO0025 d_mdo0025 =  UtilTools.map2Obj(outMap, D_MDO0025.class);
+			model.setD_mdohead(d_mdohead);
+			model.setD_mdo0025(d_mdo0025);
+
+
+		}
+
+		if (logger.isDebugEnabled()) {
+			logger.debug("execute(MDO0025BaseModel) - end");
+		}
+
+        this.respInfo=respInfo;
+
+		return respInfo;
+	}
+
+
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	public MDO0025BaseModel execute(MDO0025BaseModel model) throws Exception {
+		return this.execute(model,null,null);
+	}
+
+
+}

+ 13 - 2
src/main/java/com/miniframe/bisiness/mdo/MDO0025Service.java

@@ -1,6 +1,9 @@
 package com.miniframe.bisiness.mdo;
 
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 
@@ -24,8 +27,16 @@ public class MDO0025Service extends MDO0025BaseModel implements ExecProcessFlow
 	public void transExecute() throws Exception {
 		String pid =this.getA_mdo0025().getPid();
 		String filePath =LogService.BPATH+"/"+pid+"/log.txt";
-		String logs = XIFileUtils.readFileAsString(filePath);
-		this.getD_mdo0025().setLogs(logs);
+
+		Path path = Paths.get(filePath);
+		if (Files.notExists(path)) {
+			this.getD_mdo0025().setLogs("");
+		}else{
+			String logs = XIFileUtils.readFileAsString(filePath);
+			this.getD_mdo0025().setLogs(logs);
+		}
+
+
 	}
 	
 	/**

+ 44 - 0
src/test/java/com/miniframe/comm/httpmdoapater/MDO0025Test.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_MDO0025;
+import com.miniframe.generate.comm.httpmdoapater.MDO0025Client;
+import com.miniframe.generate.business.mdo.model.MDO0025BaseModel;
+
+public class MDO0025Test {
+
+	private static final Logger logger = LoggerFactory.getLogger(MDO0025Test.class);
+
+	/**
+	 * 求解日志获取,获取报文体
+	 * @return
+	 */
+	public static A_MDO0025 getA_mdo0025() {
+		A_MDO0025 a_mdo0025 = new A_MDO0025();
+
+		// ----------以下增加【求解日志获取】上行体赋值-------------
+
+
+
+		// ---------------------------------------------------
+		return a_mdo0025;
+	}
+	
+	/**
+	 * 运行客户端测试,求解日志获取
+	 * 
+	 * @param args
+	 * @throws Exception
+	 */
+	public static void main(String[] args) throws Exception {
+		MDO0025BaseModel model = new MDO0025BaseModel();
+		model.setA_mdohead(HttpmdoapaterUtil.getA_mdohead("MDO0025"));
+		model.setA_mdo0025(MDO0025Test.getA_mdo0025());
+		MDO0025Client client = new MDO0025Client();
+		logger.error("客户端发送前总线:\r\n"+model);
+		model = client.execute(model);
+		logger.error("客户端发送后总线:\r\n"+model);
+	}
+}