import { Injectable } from '@angular/core'; import { RhApiUrlsService, RhWmsSysConfigService } from 'rh-base/core'; import { RhParaSettingEntryDto, DataResultT, sysConfigParaMappedKeys, RhSafeAny } from 'rh-base/model'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class LabelConfigService { constructor(private apiUrls: RhApiUrlsService, private wmsSysConfigSer: RhWmsSysConfigService) { this.GetSysConfigParameterDatas().subscribe((result) => { if (result.Success) { this.handleWmsSysConfig(result.Attach); } }); } /** * 获取全局系统配置参数 */ GetSysConfigParameterDatas(): Observable> { return this.apiUrls.GetRdp('SysConfigApi', 'GetSysConfigParameterDatas'); } private handleWmsSysConfig(dataset: RhParaSettingEntryDto[]) { const mappedKeys = sysConfigParaMappedKeys; Object.keys(mappedKeys).forEach((modKey) => { const paras = dataset.filter((f) => f.ModuleKey === modKey); mappedKeys[modKey].forEach((value) => { const data = paras.find((para) => para.GroupKey === value); if (data) { switch (value) { case 'WarehouseSysConfig': this.wmsSysConfigSer.setWarehouseSysConfig(JSON.parse(data.ParameterEntryValue as string) as RhSafeAny); break; case 'WmsConfiguration': this.wmsSysConfigSer.setWmsSysConfig(JSON.parse(data.ParameterEntryValue as string) as RhSafeAny); break; default: break; } } }); }); } }