嘿,我想知道我能如何防止ouptut显示两次相同的日期或相同的合同类型。而且我不知道如何在最后一个日期/合同类型后面加上逗号...
目前输出为:
我希望如何获得输出:
因此,如果有两次相同的日期或同一份合同,我只希望在列表中一次。如果不同,则应显示所有这些内容,并且在两种情况下都应在列表的最后输出后面显示一个逗号。如果您知道如何根据紧随其后的0、1或2个日期来更改标题,那就太好了。
<#assign translations = {
"de": {
"bbo": "Per {0}",
"sqm":"m²",
"contract00":"Vertragstyp:",
"contract01":"Befristet",
"contract02":"Unbefristet",
"contract03":"Befristet mit echter Option",
"contract04":"Befristet mit unechter Option",
"contract05":"Amortisation Mieterausbau",
"contract06":"Umsatzmiete",
"contract07":"Andere",
"contract08":"Unbekannt",
"start00":"Vertragsstart:",
"end00":"Vertragsende"
},
"en":{
"bbo": "Per {0}",
"sqm":"m²",
"contract00":"Contract type:",
"contract01":"Limited",
"contract02":"Unlimited",
"contract03":"Limited with real option",
"contract04":"Limited with unreal option",
"contract05":"Amortisation Mieterausbau",
"contract06":"Umsatzmiete",
"contract07":"Other",
"contract08":"Unknown",
"start00":"Start of contract:",
"end00":"End of contract:"
}
}>
<br>
<#assign msg = translations[.lang]>
<#assign currency = valuation.valuationSettings.valuationCurrency>
<#assign rentalUnits = valuation.draftRul.rentalUnits>
<#assign rentalUnitsWithTenant = []>
<#list rentalUnits as ru>
<#if ru.currentLease?? && ru.currentLease.tenant?? >
<#assign rentalUnitsWithTenant = rentalUnitsWithTenant + [ru]>
</#if>
</#list>
<#assign rentalUnitsByTenant = groupBy(rentalUnitsWithTenant, "currentLease.tenant")>
<ul>
<#list rentalUnitsByTenant?keys?sort as tenant>
<#assign rentalUnitsOfTenant = rentalUnitsByTenant[tenant]>
<#assign area=sum(rentalUnitsOfTenant, "areaPerUnitValue")>
<#assign income = sum(rentalUnitsOfTenant, "currentLease.income.income")>
<#assign units = sum(rentalUnitsOfTenant, "units")>
<#if income gte 100000>
<li>
${tenant}: ${area} ${msg["sqm"]}, ${currency} ${income?string[",##0"]},
${msg["contract00"]}
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease??>
<#if ru.currentLease.contractType= "LIMITED">
<#assign contract = msg["contract01"]>
<#elseif ru.currentLease.contractType="UNLIMITED">
<#assign contract = msg["contract02"]>
<#elseif ru.currentLease.contractType="LIMITED_WITH_REAL_OPTION">
<#assign contract = msg["contract03"]>
<#elseif ru.currentLease.contractType="LIMITED_WITH_UNREAL_OPTION">
<#assign contract = msg["contract04"]>
<#elseif ru.currentLease.contractType="AMORTISATION">
<#assign contract = msg["contract05"]>
<#elseif ru.currentLease.contractType="UMSATZMIETE">
<#assign contract = msg["contract06"]>
<#elseif ru.currentLease.contractType="OTHER">
<#assign contract = msg["contract07"]>
<#elseif ru.currentLease.contractType="UNKNOWN">
<#assign contract = msg["contract08"]>
</#if>
${contract}<#sep>/</#sep>
</#if>
</#list>
${msg["start00"]}
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease??>
${ru.currentLease.start!}<#sep>/</#sep>
</#if>
</#list>
Enddaten:
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease.end??>
${ru.currentLease.end!}<#sep>/</#sep>
</#if>
</#list>
</li>
</#if>
</#list>
</ul>
如果您能解决我的一个问题,我已经很感激。
答案 0 :(得分:0)
在打印值之前尝试构建唯一列表,这可能类似于下面的示例。关键是seq_contains方法。
<#assign uniqueList = []>
<#list rentalUnitsOfTenant as ru>
<#if ru.currentLease??>
<#if ru.currentLease.contractType= "LIMITED">
<#assign contract = msg["contract01"]>
...
</#if>
<#if !uniqueList?seq_contains(contract) >
<#assign uniqueList = uniqueList + [contract]>
</#if>
</#if>
</#list>
<#list uniqueList as contract>
${contract}<#sep>/</#sep>
</#list>