|
|
@ -2,15 +2,20 @@ package com.iflytop.digester.underframework; |
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.iflytop.digester.deviceinstance.HeatingTurntableSlotTube; |
|
|
|
import freemarker.template.Configuration; |
|
|
|
import freemarker.template.Template; |
|
|
|
import freemarker.template.TemplateException; |
|
|
|
import com.iflytop.digester.underframework.dao.model.UfMdbActuatorCmd; |
|
|
|
import com.iflytop.digester.underframework.dao.model.UfMdbSnippet; |
|
|
|
import com.iflytop.digester.underframework.dao.record.UfActiveRecord; |
|
|
|
import com.iflytop.digester.underframework.util.UfJsonHelper; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.io.StringWriter; |
|
|
|
public class UfCmdSnippetExecutor { |
|
|
|
// logger |
|
|
|
public static final Logger LOG = LoggerFactory.getLogger(UfCmdSnippetExecutor.class); |
|
|
@ -76,7 +81,22 @@ public class UfCmdSnippetExecutor { |
|
|
|
if (null == cmd) { |
|
|
|
throw new RuntimeException("无效的指令ID : " + cmdId); |
|
|
|
} |
|
|
|
cmd.parameters = cmdParams; |
|
|
|
|
|
|
|
// 编译参数为模板 |
|
|
|
freemarker.template.Configuration cfg = new Configuration(Configuration.VERSION_2_3_31); |
|
|
|
Template template = null; |
|
|
|
try { |
|
|
|
template = new Template("", cmdParams, cfg); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
StringWriter paramStrWriter = new StringWriter(); |
|
|
|
try { |
|
|
|
template.process(this.params, paramStrWriter); |
|
|
|
} catch (TemplateException | IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
cmd.parameters = paramStrWriter.toString(); |
|
|
|
UfActuatorCmdExecutor.execute(cmd); |
|
|
|
} |
|
|
|
} |