mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-15 10:24:57 +03:00
feat(skd): StandardPeriod с явными datами в dataParameters
Когда v8:StandardPeriod имеет non-default startDate/endDate, decompile
выдаёт object form {parameter, value:{variant, startDate, endDate}, ...}
вместо shorthand "P = Custom". Compile использует переданные даты
вместо boilerplate 0001-01-01.
sample30: −24 строки (2690 → 2666).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.69 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.70 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -2520,19 +2520,22 @@ function Emit-DataParameters {
|
||||
Emit-EmptyValue -type "$($dp.valueType)" -indent "$indent`t`t" -tagPrefix "dcscor:" -valueListAllowed $false
|
||||
} elseif ($null -ne $dp.value) {
|
||||
$vtype = "$($dp.valueType)"
|
||||
if ($dp.value -is [PSCustomObject] -and $dp.value.variant) {
|
||||
# StandardPeriod (object form from JSON)
|
||||
if (($dp.value -is [PSCustomObject] -or $dp.value -is [hashtable]) -and ($dp.value.variant)) {
|
||||
# StandardPeriod (PSCustomObject from JSON / hashtable from shorthand parser)
|
||||
$_sd = $null; $_ed = $null
|
||||
if ($dp.value -is [PSCustomObject]) {
|
||||
if ($dp.value.PSObject.Properties['startDate']) { $_sd = "$($dp.value.startDate)" }
|
||||
if ($dp.value.PSObject.Properties['endDate']) { $_ed = "$($dp.value.endDate)" }
|
||||
} else {
|
||||
if ($dp.value.Contains('startDate')) { $_sd = "$($dp.value['startDate'])" }
|
||||
if ($dp.value.Contains('endDate')) { $_ed = "$($dp.value['endDate'])" }
|
||||
}
|
||||
if (-not $_sd) { $_sd = '0001-01-01T00:00:00' }
|
||||
if (-not $_ed) { $_ed = '0001-01-01T00:00:00' }
|
||||
X "$indent`t`t<dcscor:value xsi:type=`"v8:StandardPeriod`">"
|
||||
X "$indent`t`t`t<v8:variant xsi:type=`"v8:StandardPeriodVariant`">$(Esc-Xml "$($dp.value.variant)")</v8:variant>"
|
||||
X "$indent`t`t`t<v8:startDate>0001-01-01T00:00:00</v8:startDate>"
|
||||
X "$indent`t`t`t<v8:endDate>0001-01-01T00:00:00</v8:endDate>"
|
||||
X "$indent`t`t</dcscor:value>"
|
||||
} elseif ($dp.value -is [hashtable] -and $dp.value.variant) {
|
||||
# StandardPeriod (hashtable from shorthand parser)
|
||||
X "$indent`t`t<dcscor:value xsi:type=`"v8:StandardPeriod`">"
|
||||
X "$indent`t`t`t<v8:variant xsi:type=`"v8:StandardPeriodVariant`">$(Esc-Xml "$($dp.value.variant)")</v8:variant>"
|
||||
X "$indent`t`t`t<v8:startDate>0001-01-01T00:00:00</v8:startDate>"
|
||||
X "$indent`t`t`t<v8:endDate>0001-01-01T00:00:00</v8:endDate>"
|
||||
X "$indent`t`t`t<v8:startDate>$(Esc-Xml $_sd)</v8:startDate>"
|
||||
X "$indent`t`t`t<v8:endDate>$(Esc-Xml $_ed)</v8:endDate>"
|
||||
X "$indent`t`t</dcscor:value>"
|
||||
} elseif ($vtype -eq 'boolean' -or $dp.value -is [bool]) {
|
||||
$bv = "$($dp.value)".ToLower()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.69 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.70 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -2054,11 +2054,13 @@ def emit_data_parameters(lines, items, indent):
|
||||
val = dp['value']
|
||||
vtype = str(dp.get('valueType') or '')
|
||||
if isinstance(val, dict) and val.get('variant'):
|
||||
# StandardPeriod
|
||||
# StandardPeriod (с явными датами или boilerplate)
|
||||
sd = str(val.get('startDate') or '0001-01-01T00:00:00')
|
||||
ed = str(val.get('endDate') or '0001-01-01T00:00:00')
|
||||
lines.append(f'{indent}\t\t<dcscor:value xsi:type="v8:StandardPeriod">')
|
||||
lines.append(f'{indent}\t\t\t<v8:variant xsi:type="v8:StandardPeriodVariant">{esc_xml(str(val["variant"]))}</v8:variant>')
|
||||
lines.append(f'{indent}\t\t\t<v8:startDate>0001-01-01T00:00:00</v8:startDate>')
|
||||
lines.append(f'{indent}\t\t\t<v8:endDate>0001-01-01T00:00:00</v8:endDate>')
|
||||
lines.append(f'{indent}\t\t\t<v8:startDate>{esc_xml(sd)}</v8:startDate>')
|
||||
lines.append(f'{indent}\t\t\t<v8:endDate>{esc_xml(ed)}</v8:endDate>')
|
||||
lines.append(f'{indent}\t\t</dcscor:value>')
|
||||
elif vtype == 'boolean' or isinstance(val, bool):
|
||||
bv = str(val).lower()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.53 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.54 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -1751,9 +1751,20 @@ function Build-DataParameters {
|
||||
if ($use -eq 'false') { $flags += '@off' }
|
||||
$vt = Get-LocalXsiType $valNode
|
||||
$vDisplay = $null
|
||||
$stdPeriodObj = $null
|
||||
if ($vt -eq 'StandardPeriod') {
|
||||
$variant = Get-Text $valNode "v8:variant"
|
||||
if ($variant) { $vDisplay = $variant }
|
||||
$sd = Get-Text $valNode "v8:startDate"
|
||||
$ed = Get-Text $valNode "v8:endDate"
|
||||
$hasExplicitDates = ($sd -and $sd -ne '0001-01-01T00:00:00') -or ($ed -and $ed -ne '0001-01-01T00:00:00')
|
||||
if ($hasExplicitDates) {
|
||||
$stdPeriodObj = [ordered]@{ variant = $variant }
|
||||
if ($sd) { $stdPeriodObj['startDate'] = $sd }
|
||||
if ($ed) { $stdPeriodObj['endDate'] = $ed }
|
||||
$canAuto = $false
|
||||
} elseif ($variant) {
|
||||
$vDisplay = $variant
|
||||
}
|
||||
} elseif ($vt -eq 'DesignTimeValue') {
|
||||
$vDisplay = $valNode.InnerText
|
||||
} elseif ($vt -eq 'LocalStringType') {
|
||||
@@ -1764,11 +1775,19 @@ function Build-DataParameters {
|
||||
# Compare to top-level default
|
||||
if ($tp -and $tp.valueDisplay -ne $vDisplay) { $canAuto = $false }
|
||||
if (-not $tp) { $canAuto = $false } # extra param not in top-level
|
||||
# Build shorthand entry
|
||||
$s = $pn
|
||||
if ($null -ne $vDisplay -and $vDisplay -ne '') { $s += " = $vDisplay" }
|
||||
if ($flags) { $s += ' ' + ($flags -join ' ') }
|
||||
$entries += $s
|
||||
if ($stdPeriodObj) {
|
||||
# Object form для StandardPeriod с явными датами
|
||||
$obj = [ordered]@{ parameter = $pn; value = $stdPeriodObj }
|
||||
if ($use -eq 'false') { $obj['use'] = $false }
|
||||
if ($usid) { $obj['userSettingID'] = 'auto' }
|
||||
$entries += $obj
|
||||
} else {
|
||||
# Build shorthand entry
|
||||
$s = $pn
|
||||
if ($null -ne $vDisplay -and $vDisplay -ne '') { $s += " = $vDisplay" }
|
||||
if ($flags) { $s += ' ' + ($flags -join ' ') }
|
||||
$entries += $s
|
||||
}
|
||||
}
|
||||
# Check that all visible top-level params are present
|
||||
foreach ($vn in $visibleTop.Keys) { if (-not $presentNames.ContainsKey($vn)) { $canAuto = $false } }
|
||||
|
||||
Reference in New Issue
Block a user