dengzedong
2024-09-20 a27351e4827eb1a340b834fe80c149806f819bd5
项目打包生成xml文件
已添加1个文件
已修改1个文件
154 ■■■■■ 文件已修改
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/template/menu.xml.vm 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java
@@ -25,6 +25,7 @@
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -67,7 +68,8 @@
    @Autowired
    private ConfigApi configApi;
    private String mpkBakFilePath = "";
    @Value("${mpk.bakFilePath}")
    private String mpkBakFilePath;
    /*@PostConstruct
    public void init() {
@@ -296,6 +298,13 @@
        prop.put("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        Velocity.init(prop);
        //生成menu.xml文件
        Map<String, Map<String, List<MpkFileDTO>>> collect = entities.stream().collect(Collectors.groupingBy(MpkFileDTO::getMenuName, Collectors.groupingBy(e -> StringUtils.isNotBlank(e.getGroupName()) ? e.getGroupName() : "default_group")));
        Map<String, Object> map1 = new HashMap<>();
        map1.put("collects",collect);
        File xmlFile = new File(dirPath.getAbsolutePath() + File.separator + "menu.xml");
        GenUtils.drawTemplate("menu.xml.vm",new VelocityContext(map1),xmlFile);
        //生成cpp文件
        File cppFile = new File(dirPath.getAbsolutePath() + File.separator + UUID.randomUUID() + ".cpp");
        GenUtils.drawTemplate("pkg.cpp.vm",context,cppFile);
iailab-module-model/iailab-module-model-biz/src/main/resources/template/menu.xml.vm
对比新文件
@@ -0,0 +1,143 @@
<root version="企业版">
    <menu name="数据模型">
        <sub-menu name="数据源">
            <item name="数据库" shortName="数据库" class="DatabaseUnit" isContant="true" icon="database.png" width="70"
                  height="70"/>
            <item name="数据文件" shortName="数据文件" class="OtherDetailDataUnit" isContant="true" icon="txt.png" width="70"
                  height="70"/>
        </sub-menu>
#{foreach} ($collect in $collects.entrySet())
        <sub-menu name="${collect.getKey()}">
#{foreach} ($collect1 in $collect.getValue().entrySet())
            <group name="${collect1.getKey()}">
#{foreach} ($model in $collect1.getValue())
                <group-item name="${model.pyChineseName}" shortName="${model.pyChineseName}" isContant="false"
                    icon="$!{model.icon}" width="70" height="70" isFactor="true">
#{if}($model.pyType=="predict")
#{foreach} ($method in $model.modelMethods)
#{if}($method.methodName=="train")
                    <tab-train class="${model.pkgName}.impl.${model.pyName}Impl" method="train"
                               params="#{foreach} ($column in [1..$method.dataLength])double[][],#{end}#{if}($method.model==1)java.util.HashMap,#{end}java.util.HashMap">
                        <property key="data1" name="数据路径" type="file" valueType="file" min="" max=""/>
#{foreach} ($setting in $method.methodSettings)
#{if}($setting.type=="select")
                        <property key="${setting.settingKey}" name="${setting.name}" type="select" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}">
#{foreach} ($select in $setting.settingSelects)
                            <select key="$!{select.selectKey}" name="$!{select.name}"/>
#{end}
                        </property>
#{else}
                        <property key="${setting.settingKey}" name="${setting.name}" value="$!{setting.value}" type="${setting.type}" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}"/>
#{end}
#{end}
                    </tab-train>
#{elseif}($method.methodName=="predict")
                    <tab-load class="${model.pkgName}.impl.${model.pyName}Impl" method="predict"
                              params="#{foreach} ($column in [1..$method.dataLength])double[][],#{end}#{if}($method.model==1)java.util.HashMap,#{end}java.util.HashMap" resultKey="$!{method.resultKey}"
                              modelRules="${model.pkgName}.impl.${model.pyName}Impl.predict">
                        <property key="data1" name="数据路径" type="file" valueType="file" min="" max=""/>
#{foreach} ($setting in $method.methodSettings)
#{if}($setting.type=="select")
                        <property key="${setting.settingKey}" name="${setting.name}" type="select" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}">
#{foreach} ($select in $setting.settingSelects)
                            <select key="$!{select.selectKey}" name="$!{select.name}"/>
#{end}
                        </property>
#{else}
                        <property key="${setting.settingKey}" name="${setting.name}" value="$!{setting.value}" type="${setting.type}" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}"/>
#{end}
#{end}
                    </tab-load>
#{else}
                    <tab-logic class="${model.pkgName}.impl.${model.pyName}Impl" method="$!{method.methodName}"
                               params="#{foreach} ($column in [1..$method.dataLength])double[][],#{end}#{if}($method.model==1)java.util.HashMap,#{end}java.util.HashMap"
                               resultKey="$!{method.resultKey}">
                        <fieldset name="基本参数">
#{foreach} ($setting in $method.methodSettings)
#{if}($setting.type=="select")
                            <property key="${setting.settingKey}" name="${setting.name}" type="select" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}">
#{foreach} ($select in $setting.settingSelects)
                                <select key="$!{select.selectKey}" name="$!{select.name}"/>
#{end}
                            </property>
#{else}
                            <property key="${setting.settingKey}" name="${setting.name}" value="$!{setting.value}" type="${setting.type}" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}"/>
#{end}
#{end}
                        </fieldset>
                    </tab-logic>
#{end}
#{end}
#{elseif}($model.pyType=="schedul")
#{foreach} ($method in $model.modelMethods)
                    <tab-logic class="${model.pkgName}.impl.${model.pyName}Impl" method="$!{method.methodName}"
                               params="#{foreach} ($column in [1..$method.dataLength])double[][],#{end}#{if}($method.model==1)java.util.HashMap,#{end}java.util.HashMap"
                               resultKey="$!{method.resultKey}">
                        <fieldset name="基本参数">
#{foreach} ($setting in $method.methodSettings)
#{if}($setting.type=="select")
                            <property key="${setting.settingKey}" name="${setting.name}" type="select" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}">
#{foreach} ($select in $setting.settingSelects)
                                <select key="$!{select.selectKey}" name="$!{select.name}"/>
#{end}
                             </property>
#{else}
                             <property key="${setting.settingKey}" name="${setting.name}" value="$!{setting.value}" type="${setting.type}" valueType="${setting.valueType}" min="$!{setting.min}" max="$!{setting.max}"/>
#{end}
#{end}
                        </fieldset>
                    </tab-logic>
#{end}
#{end}
                </group-item>
#{end}
            </group>
#{end}
        </sub-menu>
#{end}
        <sub-menu name="流程控制">
            <item name="控制" shortName="控制" class="TimeControlUnit" isContant="true" icon="control.png" width="50"
                  height="50" isControl="true"/>
            <item name="起始时间" shortName="时间" class="StartTimeUnit" isContant="true" icon="time.png" width="50"
                  height="50" isStartTime="true"/>
            <item name="延时" shortName="延时" class="DelayUnit" isContant="true" icon="delay.png" width="50" height="50"/>
        </sub-menu>
        <sub-menu name="运算方法">
            <item name="加" shortName="加" class="PlusUnit" isContant="true" icon="plus.png" width="50" height="50"
                  set="false"/>
            <item name="减" shortName="减" class="MinusUnit" isContant="true" icon="minus.png" width="50" height="50"
                  set="false"/>
            <item name="乘" shortName="乘" class="MultiplyUnit" isContant="true" icon="multiply.png" width="50"
                  height="50" set="false"/>
            <item name="除" shortName="除" class="DivideUnit" isContant="true" icon="divide.png" width="50" height="50"
                  set="false"/>
            <item name="积分器" shortName="积分器" class="IntegratorUnit" isContant="true" icon="integrator.png" width="50"
                  height="50"/>
        </sub-menu>
        <sub-menu name="图表显示">
            <item name="图" shortName="图" class="ChartUnit" isContant="true" icon="tu.png" width="70" height="70"
                  set="false"/>
            <item name="结果图" shortName="结果图" class="ChartResultUnit" isContant="true" icon="jieguotu.png" width="70"
                  height="70" set="false"/>
            <item name="预测图" shortName="预测图" class="RealTimeChartUnit" isContant="true" icon="yucetu.png" width="70"
                  height="70"/>
            <item name="散点图" shortName="散点图" class="ScatterPlotChartUnit" isContant="true" icon="sandiantu.png"
                  width="70" height="70" set="false"/>
            <item name="表" shortName="表" class="TableUnit" isContant="true" icon="biaoge.png" width="70" height="70"
                  set="false"/>
            <item name="文本显示器" shortName="文本显示器" class="TextShowUnit" isContant="true" icon="wenbenxianshi.png"
                  width="70" height="70"/>
        </sub-menu>
        <sub-menu name="其他">
            <item name="常数" shortName="常数" class="ConstantUnit" isContant="true" icon="changshu.png" width="50"
                  height="50" runningSet="true"/>
            <item name="总线" shortName="总线" class="IBusUnit" isContant="true" icon="zongxian.png" width="70"
                  height="70"/>
            <item name="行总线" shortName="行总线" class="HIBusUnit" isContant="true" icon="zongxian.png" width="70"
                  height="70"/>
            <item name="选择" shortName="选择" class="IKeyUnit" isContant="true" icon="xuanze.png" width="50" height="50"/>
        </sub-menu>
    </menu>
</root>