我看过几篇文章,您可能已经回答了我的问题,但是我仍然做不到。可能是因为我两周前开始使用freemarker。
<#assign translations = {
"de":{
"BBO":"Per {0}",
"year01":"Baujahr",
"refurbishment01":"Abgeschlossene Instandsetzungen:",
"refurbishment02":"Instandsetzungen Jahre 1-10",
"Detail00":"Konstruktion",
"Detail01":"Dach",
"Detail02":"Fassade",
"Detail03":"Fenster",
"Detail04":"Sanitär/Bäder",
"Detail05":"Bodenbeläge",
"Detail06":"Wand-/Deckenverkleidung",
"Detail07":"Küche",
"Detail08":"Wärmeverteilung",
"Detail09":"Wärmeerzeugung",
"Detail10":"Sanitärleitungen",
"Detail11":"Elektrische Verteilung",
"Detail12":"Lüftung",
"Detail13":"Transportanlagen",
"Detail14":"Parkierung",
"Detail15":"",
"totalinvest":"Total Investitionen:"
},
"en":{
"BBO":"Per {0}",
"year01":"Construction year",
"refurbishment01":"Previous CAPEX:",
"refurbishment02":"CAPEX years 1-10",
"Detail00":"Construction",
"Detail01":"Roof",
"Detail02":"Facade",
"Detail03":"Window",
"Detail04":"Bathrooms",
"Detail05":"Floor coverings",
"Detail06":"Wall coverings",
"Detail07":"Kitchen",
"Detail08":"Heat distribution",
"Detail09":"Heat production",
"Detail10":"Sanitary line",
"Detail11":"Electricity distribution",
"Detail12":"Ventilation",
"Detail13":"Transport system",
"Detail14":"Parking",
"Detail15":"Miscellaneous",
"totalinvest":"Total CAPEX:"
},
"fr":{
"BBO":"Per {0}",
"Detail00":"Constuction",
"Detail01":"Toit",
"Detail15":"Diverses"
}
}>
<#assign msg= translations[.lang]>
<#assign currency = valuation.valuationSettings.valuationCurrency>
<#assign BewJahr = valuation.valuationSettings.valuationDate.year>
<#assign buildings = valuation.valuationObject.buildings[0].buildingConstructions>
${msg["year01"]}:
<#list buildings as constructions>
${constructions.constructionYear?string["#####"]}
<#if constructions.comment??>
<#assign comment= "("+constructions.comment+")">
<#else>
<#assign comment = " ">
</#if>
${comment}
<br> <br>
</#list>
<#if (valuation.valuationObject.buildings[0].buildingRenovations[0].lastTotalRenovationYear)??>
<#assign titlerenovations= msg["refurbishment01"]>
<#else>
<#assign titlerenovations= "">
</#if>
${titlerenovations}
<#assign renovations= valuation.valuationObject.buildings[0].buildingRenovations>
<#if renovations??>
<#list renovations as renovation>
<li>${renovation.lastTotalRenovationYear?string["0000"]} ${renovation.comment!}</li>
</#list>
</#if>
<#assign reco = valuation.valuationObject.reco>
<#list reco.buildings as building>
<#if building??>
<#assign intro01 = msg["refurbishment02"]+":">
<#else> <#assign intro01= "">
</#if>
<br>${intro01}
<#list building.componentGroups as group>
<#list group.components as component>
<#if component.componentType?? && component.componentType= "BATHROOMS">
<#assign type = msg["Detail04"]>
<#elseif component.componentType?? && component.componentType= "WALL_COVERINGS">
<#assign type = msg["Detail06"]>
<#elseif component.componentType?? && component.componentType= "FLOOR_COVERINGS">
<#assign type = msg["Detail05"]>
<#elseif component.componentType?? && component.componentType= "KITCHEN">
<#assign type = msg["Detail07"]>
<#elseif component.componentType?? && component.componentType= "TRANSPORT_SYSTEM">
<#assign type = msg["Detail13"]>
<#elseif component.componentType?? && component.componentType= "ROOF">
<#assign type = msg["Detail01"]>
<#elseif component.componentType?? && component.componentType= "WINDOW">
<#assign type = msg["Detail03"]>
<#elseif component.componentType?? && component.componentType= "FACADE">
<#assign type = msg["Detail02"]>
<#elseif component.componentType?? && component.componentType= "MISCELLANEOUS">
<#assign type = msg["Detail15"]>
<#elseif component.componentType?? && component.componentType= "ELECTRICITY_DISTRIBUTION">
<#assign type = msg["Detail11"]>
<#elseif component.componentType?? && component.componentType= "VENTILATION">
<#assign type = msg["Detail12"]>
<#elseif component.componentType?? && component.componentType= "SANITARY_LINE">
<#assign type = msg["Detail10"]>
<#elseif component.componentType?? && component.componentType= "HEAT_PRODUCTION">
<#assign type = msg["Detail09"]>
<#elseif component.componentType?? && component.componentType= "HEAT_DISTRIBUTION">
<#assign type = msg["Detail08"]>
<#elseif component.componentType?? && component.componentType= "PARKING">
<#assign type = msg["Detail14"]>
<#elseif component.componentType?? && component.componentType= "CONSTRUCTION">
<#assign type = msg["Detail00"]>
</#if>
<#if component.details.firstRefurbishmentBudget?? && component.details.firstRefurbishmentBudget gte 0.1
&& (component.details.firstRefurbishmentStart.year)?? && component.details.firstRefurbishmentEnd.year??
&& component.details.firstRefurbishmentStart.year <= BewJahr+10>
<#assign start= component.details.firstRefurbishmentStart.year?string["0000"]>
<#assign end = component.details.firstRefurbishmentEnd.year?string["0000"]>
<#if start = end>
<#assign years = start+":">
<#elseif start != end>
<#assign years = start + "/" + end+":">
</#if>
<#if type??>
<#assign refurb = msg["refurbishment02"]>
</#if>
<#if component.details.firstRefurbishmentComment??>
<#assign comment="("+component.details.firstRefurbishmentComment+")">
<#else>
<#assign comment="">
</#if>
<li> ${years} ${type} ${currency} ${component.details.firstRefurbishmentBudget} ${comment}
</#if>
</#list>
</#list>
<#list reco.buildings as total>
<br><br> ${msg["totalinvest"]} ${currency} ${total.details.firstRefurbishmentBudget!}
</#list>
</#list>
<#assign BewJahr = valuation.valuationSettings.valuationDate.year>
输出为: CAPEX 1-10年:
从第一年(2017、2018 / 2019、2025 / 2026、2029)开始,我需要有序地安排这些年。
谢谢
答案 0 :(得分:0)
创建临时列表并将所有行添加到其中。打印循环后排序的内容:
<#assign templist = []/>
<#list building.componentGroups as group>
....
<#assign templist = templist + ["${years} ${type} ${currency} ${component.details.firstRefurbishmentBudget} ${comment}"]/>
</#list>
<#list templist?sort as item>
<li> ${item} </li>
</#list>