diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 26fae59d2..1ecbce4d6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,866 +5,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + diff --git a/cmd/cmd_data.go b/cmd/cmd_data.go index d055812e4..da3ac096a 100644 --- a/cmd/cmd_data.go +++ b/cmd/cmd_data.go @@ -40,8 +40,8 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { Use: "data", Aliases: []string{}, Annotations: map[string]string{"group": "Data"}, - Short: fmt.Sprintf("High-level iSolarCloud functions."), - Long: fmt.Sprintf("High-level iSolarCloud functions."), + Short: fmt.Sprintf("High-level iSolarCloud data fetching."), + Long: fmt.Sprintf("High-level iSolarCloud data fetching."), DisableFlagParsing: false, DisableFlagsInUseLine: false, PreRunE: func(cmd *cobra.Command, args []string) error { @@ -63,7 +63,7 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { cmd.AddCommand(c.SelfCmd) c.SelfCmd.Example = cmdHelp.PrintExamples(c.SelfCmd, "get ", "put ") - // ******************************************************************************** + // ******************************************************************************** // var cmdDataGet = &cobra.Command{ Use: output.StringTypeList + " <[area.]endpoint> [endpoint args ...]", Aliases: []string{"get"}, @@ -89,7 +89,7 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { c.SelfCmd.AddCommand(cmdDataGet) cmdDataGet.Example = cmdHelp.PrintExamples(cmdDataGet, "queryDeviceList", "WebAppService.showPSView", "stats") - // ******************************************************************************** + // ******************************************************************************** // var cmdDataTable = &cobra.Command{ Use: output.StringTypeTable + " <[area.]endpoint> [endpoint args ...]", Aliases: []string{}, @@ -115,7 +115,7 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { c.SelfCmd.AddCommand(cmdDataTable) cmdDataGet.Example = cmdHelp.PrintExamples(cmdDataTable, "queryDeviceList", "WebAppService.showPSView", "stats") - // ******************************************************************************** + // ******************************************************************************** // var cmdDataRaw = &cobra.Command{ Use: output.StringTypeRaw + " <[area.]endpoint> [endpoint args ...]", Aliases: []string{}, @@ -139,9 +139,9 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { Args: cobra.MinimumNArgs(0), } c.SelfCmd.AddCommand(cmdDataRaw) - cmdDataRaw.Example = cmdHelp.PrintExamples(cmdDataRaw, "[area.]") + cmdDataRaw.Example = cmdHelp.PrintExamples(cmdDataRaw, "queryDeviceList", "WebAppService.showPSView", "stats") - // ******************************************************************************** + // ******************************************************************************** // var cmdDataJson = &cobra.Command{ Use: output.StringTypeJson + " <[area.]endpoint> [endpoint args ...]", Aliases: []string{}, @@ -167,7 +167,7 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { c.SelfCmd.AddCommand(cmdDataJson) cmdDataJson.Example = cmdHelp.PrintExamples(cmdDataJson, "queryDeviceList", "WebAppService.showPSView", "stats") - // ******************************************************************************** + // ******************************************************************************** // var cmdDataCsv = &cobra.Command{ Use: output.StringTypeCsv + " <[area.]endpoint> [endpoint args ...]", Aliases: []string{}, @@ -193,7 +193,7 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { c.SelfCmd.AddCommand(cmdDataCsv) cmdDataCsv.Example = cmdHelp.PrintExamples(cmdDataCsv, "queryDeviceList", "WebAppService.showPSView", "stats") - // ******************************************************************************** + // ******************************************************************************** // var cmdDataGraph = &cobra.Command{ Use: output.StringTypeGraph + " <[area.]endpoint> [endpoint args ...]", Aliases: []string{}, @@ -219,6 +219,58 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command { c.SelfCmd.AddCommand(cmdDataGraph) cmdDataGraph.Example = cmdHelp.PrintExamples(cmdDataGraph, "queryDeviceList", "WebAppService.showPSView", "stats") + // ******************************************************************************** // + var cmdApiXML = &cobra.Command{ + Use: output.StringTypeXML + " <[area.]endpoint> [endpoint args ...]", + Aliases: []string{}, + Annotations: map[string]string{"group": "Data"}, + Short: fmt.Sprintf("Get data from iSolarCloud (xml)"), + Long: fmt.Sprintf("Get data from iSolarCloud (xml)"), + DisableFlagParsing: false, + DisableFlagsInUseLine: false, + PreRunE: func(cmd *cobra.Command, args []string) error { + cmds.Error = cmds.ProcessArgs(cmd, args) + if cmds.Error != nil { + return cmds.Error + } + cmds.Error = cmds.SunGrowArgs(cmd, args) + if cmds.Error != nil { + return cmds.Error + } + return nil + }, + RunE: c.GetEndpoints, + Args: cobra.MinimumNArgs(0), + } + c.SelfCmd.AddCommand(cmdApiXML) + cmdApiXML.Example = cmdHelp.PrintExamples(cmdApiXML, "queryDeviceList", "WebAppService.showPSView") + + // ******************************************************************************** // + var cmdApiXLSX = &cobra.Command{ + Use: output.StringTypeXLSX + " <[area.]endpoint> [endpoint args ...]", + Aliases: []string{}, + Annotations: map[string]string{"group": "Data"}, + Short: fmt.Sprintf("Get data from iSolarCloud (XLSX)"), + Long: fmt.Sprintf("Get data from iSolarCloud (XLSX)"), + DisableFlagParsing: false, + DisableFlagsInUseLine: false, + PreRunE: func(cmd *cobra.Command, args []string) error { + cmds.Error = cmds.ProcessArgs(cmd, args) + if cmds.Error != nil { + return cmds.Error + } + cmds.Error = cmds.SunGrowArgs(cmd, args) + if cmds.Error != nil { + return cmds.Error + } + return nil + }, + RunE: c.GetEndpoints, + Args: cobra.MinimumNArgs(0), + } + c.SelfCmd.AddCommand(cmdApiXLSX) + cmdApiXLSX.Example = cmdHelp.PrintExamples(cmdApiXLSX, "queryDeviceList", "WebAppService.showPSView") + // ******************************************************************************** // var cmdApiStruct = &cobra.Command{ Use: output.StringTypeStruct + " <[area.]endpoint> [endpoint args ...]", @@ -253,6 +305,10 @@ func (c *CmdData) GetEndpoints(cmd *cobra.Command, args []string) error { // endpoints string, psIds string, date string for range Only.Once { cmds.Api.SunGrow.SetOutputType(cmd.Name()) + if cmd.Name() == output.StringTypeXLSX { + cmds.Api.SaveFile = true + } + args = cmdConfig.FillArray(2, args) eps := iSolarCloud.SplitArg(args[0]) @@ -260,9 +316,8 @@ func (c *CmdData) GetEndpoints(cmd *cobra.Command, args []string) error { data.SetOutput(cmd.Name()) data.SetSaveAsFile(cmds.Api.SaveFile) data.SetEndpoints(eps...) - data.SetArgs(args[1:]...) - c.Error = data.GetData() + c.Error = data.GetData(args[1:]...) if c.Error != nil { break } diff --git a/cmd/cmd_mqtt.go b/cmd/cmd_mqtt.go index 3557b68b2..338f48776 100644 --- a/cmd/cmd_mqtt.go +++ b/cmd/cmd_mqtt.go @@ -361,9 +361,9 @@ func (ca *Cmds) MqttCron() error { break } - // All := []string{ "queryDeviceList", "getPsList", "getPsDetailWithPsType", "getPsDetail" } + All := []string{ "queryDeviceList", "getPsList", "getPsDetailWithPsType", "getPsDetail"} //, queryMutiPointDataList, getDevicePointMinuteDataList } // All := []string{ "queryDeviceList", "WebIscmAppService.queryDeviceListForBackSys", "WebIscmAppService.getDeviceModel" } - All := []string{ "WebIscmAppService.getDeviceModel" } + // All := []string{ "WebIscmAppService.getDeviceModel" } data.SetEndpoints(All...) ca.Error = data.GetData() if ca.Error != nil { diff --git a/iSolarCloud/AppService/devicePointsDataFromMySql/data.go b/iSolarCloud/AppService/devicePointsDataFromMySql/data.go index bbf90ddcc..093bc4421 100644 --- a/iSolarCloud/AppService/devicePointsDataFromMySql/data.go +++ b/iSolarCloud/AppService/devicePointsDataFromMySql/data.go @@ -30,7 +30,7 @@ type ResultData struct { AlarmCount valueTypes.Count `json:"alarm_count"` DevFaultStatus valueTypes.Integer `json:"dev_fault_status"` DevStatus valueTypes.Integer `json:"dev_status"` - DevUpdateTime valueTypes.DateTime `json:"dev_update_time"` + DevUpdateTime valueTypes.DateTime `json:"dev_update_time" PointNameDateFormat:"2006/01/02 15:04:05"` FaultCount valueTypes.Count `json:"fault_count"` InstallerAlarmCount valueTypes.Count `json:"installer_alarm_count"` InstallerDevFaultStatus valueTypes.Integer `json:"installer_dev_fault_status"` @@ -60,7 +60,7 @@ type ResultData struct { P81202 interface{} `json:"p81202"` P81203 interface{} `json:"p81203"` PsKey valueTypes.PsKey `json:"ps_key"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` UpdateUser valueTypes.Integer `json:"update_user"` UUID valueTypes.Integer `json:"uuid"` } `json:"device_point_data" DataTable:"true"` diff --git a/iSolarCloud/AppService/energyTrend/data.go b/iSolarCloud/AppService/energyTrend/data.go index badb4a31a..25a342cf7 100644 --- a/iSolarCloud/AppService/energyTrend/data.go +++ b/iSolarCloud/AppService/energyTrend/data.go @@ -25,13 +25,13 @@ func (rd RequestData) Help() string { type ResultData struct { Echartunit valueTypes.String `json:"echartunit" PointId:"echart_unit"` - EndTime valueTypes.DateTime `json:"endTime" PointId:"end_time"` + EndTime valueTypes.DateTime `json:"endTime" PointId:"end_time" PointNameDateFormat:"2006/01/02 15:04:05"` EnergyMap struct { ValStr valueTypes.String `json:"valStr" PointId:"val_str"` } `json:"energyMap" PointId:"energy_map"` Energyunit valueTypes.String `json:"energyunit" PointId:"energy_unit"` PowerMap struct { - Dates []valueTypes.DateTime `json:"dates"` + Dates []valueTypes.DateTime `json:"dates" PointNameDateFormat:"2006/01/02 15:04:05"` Units valueTypes.String `json:"units"` ValStr valueTypes.String `json:"valStr" PointId:"val_str"` } `json:"powerMap" PointId:"power_map"` diff --git a/iSolarCloud/AppService/getChnnlListByPsId/data.go b/iSolarCloud/AppService/getChnnlListByPsId/data.go index 04eef2bb8..1eb41be03 100644 --- a/iSolarCloud/AppService/getChnnlListByPsId/data.go +++ b/iSolarCloud/AppService/getChnnlListByPsId/data.go @@ -31,8 +31,8 @@ type ResultData struct { ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"` ChannelName valueTypes.String `json:"chnnl_name" PointId:"channel_name"` ChannelDesc interface{} `json:"chnnl_desc" PointId:"channel_description"` - CreateTime valueTypes.DateTime `json:"create_time"` - UpdateDate valueTypes.DateTime `json:"update_date"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + UpdateDate valueTypes.DateTime `json:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` DataFlag valueTypes.Integer `json:"data_flag"` DataFlagDetail valueTypes.Integer `json:"data_flag_detail"` IsAuto valueTypes.Bool `json:"is_auto"` diff --git a/iSolarCloud/AppService/getDeviceList/data.go b/iSolarCloud/AppService/getDeviceList/data.go index 7b507ca89..e848beb1e 100644 --- a/iSolarCloud/AppService/getDeviceList/data.go +++ b/iSolarCloud/AppService/getDeviceList/data.go @@ -39,7 +39,7 @@ type ResultData struct { DevStatus valueTypes.Integer `json:"dev_status"` DeviceArea valueTypes.Integer `json:"device_area"` DeviceCode valueTypes.Integer `json:"device_code"` - DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date"` + DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date" PointNameDateFormat:"2006/01/02 15:04:05"` DeviceId valueTypes.Integer `json:"device_id"` DeviceModel valueTypes.String `json:"device_model"` DeviceModelCode valueTypes.String `json:"device_model_code"` diff --git a/iSolarCloud/AppService/getDevicePointMinuteDataList/data.go b/iSolarCloud/AppService/getDevicePointMinuteDataList/data.go index b871e4fe7..720a5143d 100644 --- a/iSolarCloud/AppService/getDevicePointMinuteDataList/data.go +++ b/iSolarCloud/AppService/getDevicePointMinuteDataList/data.go @@ -52,12 +52,12 @@ func (e *ResultData) UnmarshalJSON(data []byte) error { type DataPoint struct { - GoStruct GoStruct.GoStruct `json:"-" PointIdReplace:"true" PointIdFrom:"TimeStamp" PointNameDateFormat:"20060102-150405" PointTimestampFrom:"TimeStamp"` + GoStruct GoStruct.GoStruct `json:"-" PointIdReplace:"true" PointIdFrom:"TimeStamp" PointNameDateFormat:"20060102-150405" PointTimestampFrom:"TimeStamp"` - TimeStamp valueTypes.DateTime `json:"time_stamp"` + TimeStamp valueTypes.DateTime `json:"time_stamp" PointNameDateFormat:"2006/01/02 15:04:05"` Points map[string]valueTypes.UnitValue `json:"points"` // P13148 valueTypes.Integer `json:"p13148"` - IsPlatformDefaultUnit valueTypes.Bool `json:"is_platform_default_unit"` + IsPlatformDefaultUnit valueTypes.Bool `json:"is_platform_default_unit"` } func (e *DataPoint) UnmarshalJSON(data []byte) error { @@ -116,10 +116,6 @@ func (e *ResultData) IsValid() error { func (e *EndPoint) GetData() api.DataMap { entries := api.NewDataMap() - - for range Only.Once { - entries.StructToDataMap(*e, e.Request.PsKey.String(), GoStruct.NewEndPointPath(e.Request.PsKey.String())) - } - + entries.StructToDataMap(*e, e.Request.PsKey.String(), GoStruct.NewEndPointPath(e.Request.PsKey.String())) return entries } diff --git a/iSolarCloud/AppService/getIncomeSettingInfos/data.go b/iSolarCloud/AppService/getIncomeSettingInfos/data.go index 1b9b1089d..ca3a92625 100644 --- a/iSolarCloud/AppService/getIncomeSettingInfos/data.go +++ b/iSolarCloud/AppService/getIncomeSettingInfos/data.go @@ -34,25 +34,25 @@ type ResultData struct { CountyAllowanceMoney interface{} `json:"county_allowance_money"` DefaultCharge valueTypes.Float `json:"default_charge"` ElectricChargeId valueTypes.Integer `json:"electric_charge_id"` - EndTime valueTypes.DateTime `json:"end_time"` + EndTime valueTypes.DateTime `json:"end_time" PointNameDateFormat:"2006/01/02 15:04:05"` IncomeStyle interface{} `json:"income_style"` IntervalTimeCharge interface{} `json:"interval_time_charge"` NationAllowanceMoney interface{} `json:"nation_allowance_money"` ParamIncomeUnit valueTypes.Integer `json:"param_income_unit"` ProvinceAllowanceMoney interface{} `json:"province_allowance_money"` PsId valueTypes.PsId `json:"ps_id"` - StartTime valueTypes.DateTime `json:"start_time"` + StartTime valueTypes.DateTime `json:"start_time" PointNameDateFormat:"2006/01/02 15:04:05"` UseSharpPeekValleyFlat interface{} `json:"use_sharp_peek_valley_flat"` ValidFlag valueTypes.Bool `json:"valid_flag"` } `json:"powerElectricalChargeMap" PointId:"power_electrical_charge_map"` PowerIntervalTimesChargeMap interface{} `json:"powerIntevalTimesChargeMap" PointId:"power_interval_times_charge_map"` PowerSelfUseTimesChargeMap struct { DefaultCharge valueTypes.Float `json:"default_charge"` - EndTime valueTypes.DateTime `json:"end_time"` + EndTime valueTypes.DateTime `json:"end_time" PointNameDateFormat:"2006/01/02 15:04:05"` IntervalTimeCharge valueTypes.String `json:"interval_time_charge"` OnlineElectricityPercent valueTypes.Float `json:"online_electricity_percent" PointUnit:"%"` PsId valueTypes.PsId `json:"ps_id"` - StartTime valueTypes.DateTime `json:"start_time"` + StartTime valueTypes.DateTime `json:"start_time" PointNameDateFormat:"2006/01/02 15:04:05"` UseElectricityDiscount valueTypes.Float `json:"use_electricity_discount" PointUnit:"%"` } `json:"powerSelfUseTimesChargeMap" PointId:"power_selfuse_times_charge_map"` PsId valueTypes.PsId `json:"ps_id"` diff --git a/iSolarCloud/AppService/getModuleLogTaskList/data.go b/iSolarCloud/AppService/getModuleLogTaskList/data.go index 7aba59b2f..7d2835b4d 100644 --- a/iSolarCloud/AppService/getModuleLogTaskList/data.go +++ b/iSolarCloud/AppService/getModuleLogTaskList/data.go @@ -30,9 +30,9 @@ type ResultData struct { BatchId valueTypes.String `json:"batch_id"` CommandStatus valueTypes.Integer `json:"command_status"` CommandType valueTypes.Integer `json:"command_type"` - CreateTime valueTypes.DateTime `json:"create_time"` - OverTime valueTypes.DateTime `json:"over_time"` - UpdateTime valueTypes.DateTime `json:"update_time"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + OverTime valueTypes.DateTime `json:"over_time" PointNameDateFormat:"2006/01/02 15:04:05"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` ExpireSecond valueTypes.Integer `json:"expire_second"` DeviceCode valueTypes.Integer `json:"device_code"` DeviceModel valueTypes.String `json:"device_model"` diff --git a/iSolarCloud/AppService/getPowerDeviceSetTaskList/data.go b/iSolarCloud/AppService/getPowerDeviceSetTaskList/data.go index a87e04457..5845df23d 100644 --- a/iSolarCloud/AppService/getPowerDeviceSetTaskList/data.go +++ b/iSolarCloud/AppService/getPowerDeviceSetTaskList/data.go @@ -39,9 +39,9 @@ type ResultData struct { OperateUserId valueTypes.Integer `json:"operate_user_id"` CommandStatus valueTypes.Integer `json:"command_status"` CommandType valueTypes.Integer `json:"command_type"` - CreateTime valueTypes.DateTime `json:"create_time"` - UpdateTime valueTypes.DateTime `json:"update_time"` - OverTime valueTypes.DateTime `json:"over_time"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` + OverTime valueTypes.DateTime `json:"over_time" PointNameDateFormat:"2006/01/02 15:04:05"` SetCancelNum valueTypes.Count `json:"set_cancel_num"` SetFailNum valueTypes.Count `json:"set_fail_num"` SetFinishNum valueTypes.Count `json:"set_finish_num"` diff --git a/iSolarCloud/AppService/getPowerStationBasicInfo/data.go b/iSolarCloud/AppService/getPowerStationBasicInfo/data.go index fa87c8fee..61b7e0165 100644 --- a/iSolarCloud/AppService/getPowerStationBasicInfo/data.go +++ b/iSolarCloud/AppService/getPowerStationBasicInfo/data.go @@ -32,7 +32,7 @@ type ResultData struct { DesignCapacity valueTypes.Float `json:"design_capacity"` Email valueTypes.String `json:"email"` EnergyScheme interface{} `json:"energy_scheme"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` FaultSendType interface{} `json:"fault_send_type"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` GcjLongitude valueTypes.Float `json:"gcj_longitude"` @@ -45,7 +45,7 @@ type ResultData struct { ParamIncome valueTypes.Float `json:"param_income"` Prov interface{} `json:"prov"` ProvCode interface{} `json:"prov_code"` - PsBuildDate valueTypes.DateTime `json:"ps_build_date"` + PsBuildDate valueTypes.DateTime `json:"ps_build_date" PointNameDateFormat:"2006/01/02 15:04:05"` PsCountryId valueTypes.Integer `json:"ps_country_id"` PsDesc interface{} `json:"ps_desc"` PsHolder valueTypes.String `json:"ps_holder"` diff --git a/iSolarCloud/AppService/getPowerStationForHousehold/data.go b/iSolarCloud/AppService/getPowerStationForHousehold/data.go index 2ec5b49f8..cd831189a 100644 --- a/iSolarCloud/AppService/getPowerStationForHousehold/data.go +++ b/iSolarCloud/AppService/getPowerStationForHousehold/data.go @@ -54,14 +54,14 @@ type ResultData struct { DivisionCode valueTypes.String `json:"division_code"` Email valueTypes.String `json:"email"` EnergyScheme interface{} `json:"energy_scheme"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` GcjLongitude valueTypes.Float `json:"gcj_longitude"` GprsLatitude valueTypes.Float `json:"gprs_latitude"` GprsLongitude valueTypes.Float `json:"gprs_longitude"` GridLevel interface{} `json:"grid_level"` - InstallDate valueTypes.DateTime `json:"install_date"` - InstallDateZone valueTypes.DateTime `json:"install_date_zone"` + InstallDate valueTypes.DateTime `json:"install_date" PointNameDateFormat:"2006/01/02 15:04:05"` + InstallDateZone valueTypes.DateTime `json:"install_date_zone" PointNameDateFormat:"2006/01/02 15:04:05"` InverterCount valueTypes.Integer `json:"inverter_count"` InvestmentType valueTypes.Integer `json:"investment_type"` InvestmentTypeDesc valueTypes.String `json:"investment_type_desc"` @@ -91,7 +91,7 @@ type ResultData struct { ParamIncomeUnitName valueTypes.String `json:"param_income_unit_name"` ProvinceCode valueTypes.String `json:"province_code"` ProvinceName valueTypes.String `json:"province_name"` - PsBuildDate valueTypes.DateTime `json:"ps_build_date"` + PsBuildDate valueTypes.DateTime `json:"ps_build_date" PointNameDateFormat:"2006/01/02 15:04:05"` PsCountryId valueTypes.Integer `json:"ps_country_id"` PsCreateUserId valueTypes.Integer `json:"ps_create_user_id"` PsCurrentTimeZone valueTypes.String `json:"ps_current_time_zone"` @@ -107,8 +107,8 @@ type ResultData struct { PsTypeDesc valueTypes.String `json:"ps_type_desc"` PsTypeName valueTypes.String `json:"ps_type_name"` PsUserId valueTypes.Integer `json:"ps_user_id"` - RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"` - SafeStartDate valueTypes.DateTime `json:"safe_start_date"` + RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + SafeStartDate valueTypes.DateTime `json:"safe_start_date" PointNameDateFormat:"2006/01/02 15:04:05"` SetUserOrg valueTypes.Integer `json:"set_user_org"` ShareType valueTypes.Integer `json:"share_type"` ShareUserType interface{} `json:"share_user_type"` diff --git a/iSolarCloud/AppService/getPowerStationInfo/data.go b/iSolarCloud/AppService/getPowerStationInfo/data.go index 74f0ae638..f0ba0c92b 100644 --- a/iSolarCloud/AppService/getPowerStationInfo/data.go +++ b/iSolarCloud/AppService/getPowerStationInfo/data.go @@ -38,7 +38,7 @@ type ResultData struct { DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"` Email valueTypes.String `json:"email"` EnergyScheme Common.Unknown `json:"energy_scheme"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` FaultSendType Common.Unknown `json:"fault_send_type"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` GcjLongitude valueTypes.Float `json:"gcj_longitude"` @@ -51,7 +51,7 @@ type ResultData struct { ParamIncome valueTypes.Float `json:"param_income"` Prov Common.Unknown `json:"prov"` ProvCode Common.Unknown `json:"prov_code"` - PsBuildDate valueTypes.DateTime `json:"ps_build_date"` + PsBuildDate valueTypes.DateTime `json:"ps_build_date" PointNameDateFormat:"2006/01/02 15:04:05"` PsCountryId valueTypes.Integer `json:"ps_country_id"` PsDesc Common.Unknown `json:"ps_desc"` PsHolder valueTypes.String `json:"ps_holder"` @@ -59,7 +59,7 @@ type ResultData struct { PsLocation valueTypes.String `json:"ps_location"` PsName valueTypes.String `json:"ps_name"` PsType valueTypes.Integer `json:"ps_type"` - RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"` + RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time" PointNameDateFormat:"2006/01/02 15:04:05"` ReportType Common.Unknown `json:"report_type"` ShippingAddress valueTypes.String `json:"shipping_address"` ShippingZipCode valueTypes.String `json:"shipping_zip_code"` @@ -84,10 +84,10 @@ type ResultData struct { CodeType valueTypes.Integer `json:"code_type"` DefaultCharge valueTypes.Float `json:"default_charge"` ElectricChargeId valueTypes.Integer `json:"electric_charge_id"` - EndTime valueTypes.DateTime `json:"end_time"` + EndTime valueTypes.DateTime `json:"end_time" PointNameDateFormat:"2006/01/02 15:04:05"` IntervalTimeCharge Common.Unknown `json:"interval_time_charge"` ParamIncomeUnitName valueTypes.String `json:"param_income_unit_name"` - StartTime valueTypes.DateTime `json:"start_time"` + StartTime valueTypes.DateTime `json:"start_time" PointNameDateFormat:"2006/01/02 15:04:05"` } `json:"powerChargeDataMap" PointId:"power_charge_data_map"` SysTimeZones []struct { diff --git a/iSolarCloud/AppService/getPsDetail/data.go b/iSolarCloud/AppService/getPsDetail/data.go index 09ad49ede..69e8271ca 100644 --- a/iSolarCloud/AppService/getPsDetail/data.go +++ b/iSolarCloud/AppService/getPsDetail/data.go @@ -66,7 +66,7 @@ type ResultData struct { P13150MapVirgin valueTypes.UnitValue `json:"p13150_map_virgin" PointIgnore:"true"` P13155 valueTypes.Float `json:"p13155" PointId:"p13155" PointDeviceFrom:"PsKey" PointUpdateFreq:"UpdateFreqInstant"` PsKey valueTypes.PsKey `json:"ps_key"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` UUID valueTypes.Integer `json:"uuid"` EnergyFlow []valueTypes.Integer `json:"energy_flow" PointName:"Energy Flow" PointIgnoreZero:"false" PointArrayFlatten:"true"` } `json:"storage_inverter_data" PointIdReplace:"true" PointIdFromChild:"PsKey" DataTable:"false"` @@ -78,7 +78,7 @@ type ResultData struct { AlarmCount valueTypes.Count `json:"alarm_count"` AreaId interface{} `json:"area_id"` AreaType valueTypes.Integer `json:"area_type"` - BuildDate valueTypes.DateTime `json:"build_date"` + BuildDate valueTypes.DateTime `json:"build_date" PointNameDateFormat:"2006/01/02 15:04:05"` Co2Reduce valueTypes.UnitValue `json:"co2_reduce"` Co2ReduceTotal valueTypes.UnitValue `json:"co2_reduce_total" PointId:"co2_reduce_total" PointUpdateFreq:"UpdateFreqTotal"` CoalReduce valueTypes.UnitValue `json:"coal_reduce"` @@ -87,14 +87,14 @@ type ResultData struct { ConnectType valueTypes.Integer `json:"connect_type"` ContactPerson valueTypes.String `json:"contact_person"` CurrPower valueTypes.UnitValue `json:"curr_power"` // Pv Power - DataLastUpdateTime valueTypes.DateTime `json:"data_last_update_time"` + DataLastUpdateTime valueTypes.DateTime `json:"data_last_update_time" PointNameDateFormat:"2006/01/02 15:04:05"` DayEqHours valueTypes.Float `json:"day_eq_hours" PointUnit:"h" PointUpdateFreq:"UpdateFreqDay"` Description interface{} `json:"description"` DesignCapacity valueTypes.UnitValue `json:"design_capacity"` DesignCapacityBattery valueTypes.UnitValue `json:"design_capacity_battery"` DiagramURL valueTypes.String `json:"diagram_url"` EnergyScheme interface{} `json:"energy_scheme"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` FaultCount valueTypes.Count `json:"fault_count"` FaultSendType valueTypes.String `json:"fault_send_type"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` @@ -102,7 +102,7 @@ type ResultData struct { GprsLatitude valueTypes.Float `json:"gprs_latitude"` GprsLongitude valueTypes.Float `json:"gprs_longitude"` HasAmmeter valueTypes.Bool `json:"has_ammeter"` - InstallDate valueTypes.DateTime `json:"install_date"` + InstallDate valueTypes.DateTime `json:"install_date" PointNameDateFormat:"2006/01/02 15:04:05"` InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"` IsHaveEsInverter valueTypes.Bool `json:"is_have_es_inverter"` IsTransformSystem valueTypes.Bool `json:"is_transform_system"` @@ -218,9 +218,9 @@ type ResultData struct { PsTypeName valueTypes.String `json:"ps_type_name"` PsWindLevel valueTypes.String `json:"ps_wind_level"` PsWindPos valueTypes.String `json:"ps_wind_pos"` - RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"` + RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time" PointNameDateFormat:"2006/01/02 15:04:05"` ReportType valueTypes.String `json:"report_type"` - SafeStartDate valueTypes.DateTime `json:"safe_start_date"` + SafeStartDate valueTypes.DateTime `json:"safe_start_date" PointNameDateFormat:"2006/01/02 15:04:05"` SelfConsumptionOffsetReminder valueTypes.Integer `json:"self_consumption_offset_reminder"` ShippingAddress valueTypes.String `json:"shipping_address"` ShippingZipCode valueTypes.String `json:"shipping_zip_code"` diff --git a/iSolarCloud/AppService/getPsList/data.go b/iSolarCloud/AppService/getPsList/data.go index 27fcb5ec1..1c4a29be5 100644 --- a/iSolarCloud/AppService/getPsList/data.go +++ b/iSolarCloud/AppService/getPsList/data.go @@ -36,7 +36,7 @@ type ResultData struct { AreaId interface{} `json:"area_id" PointId:"area_id"` AreaType valueTypes.Integer `json:"area_type" PointId:"area_type"` ArrearsStatus valueTypes.Integer `json:"arrears_status" PointId:"arrears_status"` - BuildDate valueTypes.DateTime `json:"build_date" PointId:"build_date" PointUpdateFreq:"UpdateFreqBoot"` + BuildDate valueTypes.DateTime `json:"build_date" PointId:"build_date" PointUpdateFreq:"UpdateFreqBoot" PointNameDateFormat:"2006/01/02 15:04:05"` BuildStatus valueTypes.Integer `json:"build_status" PointId:"build_status" PointUpdateFreq:"UpdateFreqBoot"` Co2Reduce valueTypes.UnitValue `json:"co2_reduce" PointId:"co2_reduce"` Co2ReduceTotal valueTypes.UnitValue `json:"co2_reduce_total" PointId:"co2_reduce_total" PointUpdateFreq:"UpdateFreqTotal"` @@ -47,7 +47,7 @@ type ResultData struct { DesignCapacityUnit valueTypes.String `json:"design_capacity_unit" PointId:"design_capacity_unit"` DesignCapacityVirgin valueTypes.Float `json:"design_capacity_virgin" PointIgnore:"true"` EquivalentHour valueTypes.UnitValue `json:"equivalent_hour" PointId:"equivalent_hour" PointUpdateFreq:"UpdateFreqDay"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointId:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointId:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` FaultAlarmOfflineDevCount valueTypes.Count `json:"fault_alarm_offline_dev_count" PointId:"fault_alarm_offline_dev_count"` FaultCount valueTypes.Count `json:"fault_count" PointId:"fault_count"` FaultDevCount valueTypes.Count `json:"fault_dev_count" PointId:"fault_dev_count"` @@ -55,7 +55,7 @@ type ResultData struct { GcjLongitude valueTypes.Float `json:"gcj_longitude" PointId:"gcj_longitude"` GprsLatitude valueTypes.Float `json:"gprs_latitude" PointId:"gprs_latitude"` GprsLongitude valueTypes.Float `json:"gprs_longitude" PointId:"gprs_longitude"` - InstallDate valueTypes.DateTime `json:"install_date" PointId:"install_date"` + InstallDate valueTypes.DateTime `json:"install_date" PointId:"install_date" PointNameDateFormat:"2006/01/02 15:04:05"` InstalledPowerMap valueTypes.UnitValue `json:"installed_power_map" PointId:"installed_power_map"` InstalledPowerVirgin valueTypes.Float `json:"installed_power_virgin" PointIgnore:"true"` InstallerAlarmCount valueTypes.Count `json:"installer_alarm_count" PointId:"installer_alarm_count"` @@ -129,8 +129,8 @@ type ResultData struct { PsType valueTypes.Integer `json:"ps_type" PointId:"ps_type"` Radiation valueTypes.UnitValue `json:"radiation" PointId:"radiation"` RadiationVirgin valueTypes.Float `json:"radiation_virgin" PointIgnore:"true"` - RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"` - SafeStartDate valueTypes.DateTime `json:"safe_start_date" PointId:"safe_start_date"` + RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + SafeStartDate valueTypes.DateTime `json:"safe_start_date" PointId:"safe_start_date" PointNameDateFormat:"2006/01/02 15:04:05"` ShareType valueTypes.Integer `json:"share_type" PointId:"share_type"` ShippingAddress valueTypes.String `json:"shipping_address" PointId:"shipping_address"` ShippingZipCode valueTypes.String `json:"shipping_zip_code" PointId:"shipping_zip_code"` diff --git a/iSolarCloud/AppService/getPsListStaticData/data.go b/iSolarCloud/AppService/getPsListStaticData/data.go index 487d873cc..e871edacf 100644 --- a/iSolarCloud/AppService/getPsListStaticData/data.go +++ b/iSolarCloud/AppService/getPsListStaticData/data.go @@ -31,7 +31,7 @@ type ResultData struct { DesignCapacity valueTypes.Float `json:"design_capacity" PointUnit:"W"` GprsLatitude valueTypes.Float `json:"gprs_latitude"` GprsLongitude valueTypes.Float `json:"gprs_longitude"` - InstallDate valueTypes.DateTime `json:"install_date"` + InstallDate valueTypes.DateTime `json:"install_date" PointNameDateFormat:"2006/01/02 15:04:05"` InstallerPsFaultStatus valueTypes.Integer `json:"installer_ps_fault_status"` Latitude valueTypes.Float `json:"latitude"` Location valueTypes.String `json:"location"` diff --git a/iSolarCloud/AppService/getPsReport/data.go b/iSolarCloud/AppService/getPsReport/data.go index c9fb07190..75e8410f4 100644 --- a/iSolarCloud/AppService/getPsReport/data.go +++ b/iSolarCloud/AppService/getPsReport/data.go @@ -55,7 +55,7 @@ type ResultData struct { } type TotalData struct { - MinDateId valueTypes.DateTime `json:"min_date_id"` + MinDateId valueTypes.DateTime `json:"min_date_id" PointNameDateFormat:"2006/01/02 15:04:05"` Co2Reduce valueTypes.Float `json:"co2_reduce" PointUnitFrom:"Co2ReduceOriginalUnit"` Co2ReduceMap valueTypes.UnitValue `json:"co2_reduce_map"` diff --git a/iSolarCloud/AppService/getPsUser/data.go b/iSolarCloud/AppService/getPsUser/data.go index f3707de19..7b144fb1d 100644 --- a/iSolarCloud/AppService/getPsUser/data.go +++ b/iSolarCloud/AppService/getPsUser/data.go @@ -28,7 +28,7 @@ type ResultData struct { BloodType valueTypes.String `json:"blood_type"` CountryId valueTypes.Integer `json:"country_id"` CountryName valueTypes.String `json:"country_name"` - CreateDate valueTypes.DateTime `json:"create_date"` + CreateDate valueTypes.DateTime `json:"create_date" PointNameDateFormat:"2006/01/02 15:04:05"` CreateUserId valueTypes.Integer `json:"create_user_id"` DiseaseHis valueTypes.String `json:"disease_his"` Email valueTypes.String `json:"email"` diff --git a/iSolarCloud/AppService/getPsWeatherList/data.go b/iSolarCloud/AppService/getPsWeatherList/data.go index 349277f46..496e50848 100644 --- a/iSolarCloud/AppService/getPsWeatherList/data.go +++ b/iSolarCloud/AppService/getPsWeatherList/data.go @@ -29,7 +29,7 @@ type ResultData struct { Chill valueTypes.Float `json:"chill"` Code valueTypes.Float `json:"code"` CodeName valueTypes.String `json:"code_name"` - DateTime valueTypes.DateTime `json:"date_time" PointIgnore:"true"` + DateTime valueTypes.DateTime `json:"date_time" PointIgnore:"true" PointNameDateFormat:"2006/01/02 15:04:05"` Direction valueTypes.Float `json:"direction"` High valueTypes.Float `json:"high" PointUnit:"F"` Highc valueTypes.Float `json:"highc" PointUnit:"C"` diff --git a/iSolarCloud/AppService/getReportData/data.go b/iSolarCloud/AppService/getReportData/data.go index b7174deeb..f96d48ce8 100644 --- a/iSolarCloud/AppService/getReportData/data.go +++ b/iSolarCloud/AppService/getReportData/data.go @@ -38,7 +38,7 @@ type DataList struct { DateId valueTypes.DateTime `json:"date_id" PointTimestampFrom:"UpdateTime" PointNameDateFormat:"20060102"` PsId valueTypes.PsId `json:"ps_id" PointTimestampFrom:"UpdateTime"` TimeStamp valueTypes.Generic `json:"time_stamp" PointTimestampFrom:"UpdateTime"` // Sad that this alternates between string and valueTypes.Integer. - UpdateTime valueTypes.DateTime `json:"update_time" PointTimestampFrom:"UpdateTime"` + UpdateTime valueTypes.DateTime `json:"update_time" PointTimestampFrom:"UpdateTime" PointNameDateFormat:"2006/01/02 15:04:05"` DeviceName interface{} `json:"device_name" PointTimestampFrom:"UpdateTime"` UUID interface{} `json:"uuid" PointTimestampFrom:"UpdateTime"` Co2Reduce valueTypes.Float `json:"co2_reduce" PointTimestampFrom:"UpdateTime"` diff --git a/iSolarCloud/AppService/getReportEmailConfigInfo/data.go b/iSolarCloud/AppService/getReportEmailConfigInfo/data.go index 228d1f773..0baa7652e 100644 --- a/iSolarCloud/AppService/getReportEmailConfigInfo/data.go +++ b/iSolarCloud/AppService/getReportEmailConfigInfo/data.go @@ -28,23 +28,23 @@ type ResultData struct { ReportEmailConfigInfoList []struct { Email valueTypes.String `json:"email"` ReportList []struct { - CreateTime valueTypes.DateTime `json:"create_time"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` CreateUserId valueTypes.Integer `json:"create_user_id"` - EmailAddTime valueTypes.DateTime `json:"email_add_time"` + EmailAddTime valueTypes.DateTime `json:"email_add_time" PointNameDateFormat:"2006/01/02 15:04:05"` Id valueTypes.Integer `json:"id"` IsAllowEmailSend valueTypes.Bool `json:"is_allow_email_send"` IsBank valueTypes.Bool `json:"is_bank"` IsCanRenewSendConfirmEmail valueTypes.Bool `json:"is_can_renew_send_confirm_email"` IsNewWeb valueTypes.Bool `json:"is_new_web"` OrderId valueTypes.Integer `json:"order_id"` - ReSendConfirmEmailTime valueTypes.DateTime `json:"re_send_confirm_email_time"` + ReSendConfirmEmailTime valueTypes.DateTime `json:"re_send_confirm_email_time" PointNameDateFormat:"2006/01/02 15:04:05"` ReportId valueTypes.Integer `json:"report_id"` ReportName valueTypes.String `json:"report_name"` SendEmail valueTypes.String `json:"send_email"` Status valueTypes.Bool `json:"status"` TimeDimension valueTypes.Integer `json:"time_dimension"` Type valueTypes.Integer `json:"type"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` UserId valueTypes.Integer `json:"user_id"` } `json:"report_list" DataTable:"true"` } `json:"report_email_config_info_list"` diff --git a/iSolarCloud/AppService/getSysMsg/data.go b/iSolarCloud/AppService/getSysMsg/data.go index 2967d5419..a103bea1c 100644 --- a/iSolarCloud/AppService/getSysMsg/data.go +++ b/iSolarCloud/AppService/getSysMsg/data.go @@ -27,10 +27,10 @@ type ResultData []struct { GoStructParent GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"CreateTime" PointIdReplace:"false"` MsgId valueTypes.Integer `json:"msg_id"` - CreateTime valueTypes.DateTime `json:"create_time"` - PublishTime valueTypes.DateTime `json:"publish_time"` - StartTime valueTypes.DateTime `json:"start_time"` - EndTime valueTypes.DateTime `json:"end_time"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + PublishTime valueTypes.DateTime `json:"publish_time" PointNameDateFormat:"2006/01/02 15:04:05"` + StartTime valueTypes.DateTime `json:"start_time" PointNameDateFormat:"2006/01/02 15:04:05"` + EndTime valueTypes.DateTime `json:"end_time" PointNameDateFormat:"2006/01/02 15:04:05"` Ispublish valueTypes.Bool `json:"ispublish" PointId:"is_publish"` UserName valueTypes.String `json:"user_name"` UserId valueTypes.Integer `json:"user_id"` diff --git a/iSolarCloud/AppService/getTemplateList/data.go b/iSolarCloud/AppService/getTemplateList/data.go index 1dd1a5356..b167d48a1 100644 --- a/iSolarCloud/AppService/getTemplateList/data.go +++ b/iSolarCloud/AppService/getTemplateList/data.go @@ -28,7 +28,7 @@ type ResultData struct { PageList []struct { TemplateId valueTypes.Integer `json:"template_id"` TemplateName valueTypes.String `json:"template_name"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` } `json:"pageList" PointId:"page_list" PointIdFromChild:"TemplateId" PointIdReplace:"true" DataTable:"true"` RowCount valueTypes.Integer `json:"rowCount" PointId:"row_count"` } diff --git a/iSolarCloud/AppService/login/data.go b/iSolarCloud/AppService/login/data.go index 1c2f1ada2..43d106d9f 100644 --- a/iSolarCloud/AppService/login/data.go +++ b/iSolarCloud/AppService/login/data.go @@ -64,15 +64,15 @@ type ResultData struct { Isdst valueTypes.Bool `json:"isdst"` Jobs interface{} `json:"jobs"` Language string `json:"language"` - LoginFirstDate valueTypes.DateTime `json:"loginFirstDate"` - LoginFirstDate2 valueTypes.DateTime `json:"loginFristDate"` - LoginLastDate valueTypes.DateTime `json:"loginLastDate"` + LoginFirstDate valueTypes.DateTime `json:"loginFirstDate" PointNameDateFormat:"2006/01/02 15:04:05"` + LoginFirstDate2 valueTypes.DateTime `json:"loginFristDate" PointNameDateFormat:"2006/01/02 15:04:05"` + LoginLastDate valueTypes.DateTime `json:"loginLastDate" PointNameDateFormat:"2006/01/02 15:04:05"` LoginLastIP string `json:"loginLastIp"` LoginTimes valueTypes.Integer `json:"loginTimes"` Logo interface{} `json:"logo"` LogoHTTPSURL interface{} `json:"logo_https_url"` MapType string `json:"map_type"` - MinDate valueTypes.DateTime `json:"min_date"` + MinDate valueTypes.DateTime `json:"min_date" PointNameDateFormat:"2006/01/02 15:04:05"` MobileTel interface{} `json:"mobile_tel"` OrgId string `json:"org_id"` OrgName string `json:"org_name"` diff --git a/iSolarCloud/AppService/powerDevicePointList/data.go b/iSolarCloud/AppService/powerDevicePointList/data.go index 9521716a0..66db0201a 100644 --- a/iSolarCloud/AppService/powerDevicePointList/data.go +++ b/iSolarCloud/AppService/powerDevicePointList/data.go @@ -26,7 +26,7 @@ func (rd RequestData) Help() string { type ResultData struct { CurrentPage valueTypes.Integer `json:"currentPage" PointIgnore:"true"` PageDataList []struct { - CreateTime valueTypes.DateTime `json:"create_time" PointIgnore:"true"` + CreateTime valueTypes.DateTime `json:"create_time" PointIgnore:"true" PointNameDateFormat:"2006/01/02 15:04:05"` DeviceType valueTypes.Integer `json:"device_type"` Id valueTypes.Integer `json:"id"` Period valueTypes.Integer `json:"period"` // 0, 1, 2, 3, 4 diff --git a/iSolarCloud/AppService/psForcastInfo/data.go b/iSolarCloud/AppService/psForcastInfo/data.go index 3a7b6dc0c..dd51b3f82 100644 --- a/iSolarCloud/AppService/psForcastInfo/data.go +++ b/iSolarCloud/AppService/psForcastInfo/data.go @@ -32,7 +32,7 @@ type ResultData struct { City valueTypes.String `json:"city"` Code valueTypes.Integer `json:"code"` CodeName valueTypes.String `json:"code_name"` - DateTime valueTypes.DateTime `json:"date_time" PointIgnore:"true"` + DateTime valueTypes.DateTime `json:"date_time" PointIgnore:"true" PointNameDateFormat:"2006/01/02 15:04:05"` Direction valueTypes.Float `json:"direction"` High valueTypes.Float `json:"high" PointUnit:"F"` Highc valueTypes.Float `json:"highc" PointUnit:"C"` diff --git a/iSolarCloud/AppService/queryDeviceList/data.go b/iSolarCloud/AppService/queryDeviceList/data.go index 7752b3f1c..c4b32147c 100644 --- a/iSolarCloud/AppService/queryDeviceList/data.go +++ b/iSolarCloud/AppService/queryDeviceList/data.go @@ -147,7 +147,7 @@ type PointStruct struct { GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PointId" PointIdReplace:"true" PointTimestampFrom:"TimeStamp" PointDeviceFromParent:"PsKey"` // GoStruct GoStruct.GoStruct `json:"-" PointDeviceFromParent:"PsKey"` - TimeStamp valueTypes.DateTime `json:"time_stamp" PointUpdateFreq:"UpdateFreq5Mins"` + TimeStamp valueTypes.DateTime `json:"time_stamp" PointUpdateFreq:"UpdateFreq5Mins" PointNameDateFormat:"2006/01/02 15:04:05"` PointId valueTypes.PointId `json:"point_id" PointUpdateFreq:"UpdateFreqBoot"` PointGroupName valueTypes.String `json:"point_group_name" PointUpdateFreq:"UpdateFreqBoot"` PointName valueTypes.String `json:"point_name" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` @@ -159,7 +159,7 @@ type PointStruct struct { CodeId valueTypes.Integer `json:"code_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` CodeIdOrderId valueTypes.String `json:"code_id_order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` CodeName valueTypes.String `json:"code_name" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` - DevPointLastUpdateTime valueTypes.DateTime `json:"dev_point_last_update_time" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreq5Mins"` + DevPointLastUpdateTime valueTypes.DateTime `json:"dev_point_last_update_time" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreq5Mins" PointNameDateFormat:"2006/01/02 15:04:05"` IsPlatformDefaultUnit valueTypes.Bool `json:"is_platform_default_unit" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` IsShow valueTypes.Bool `json:"is_show" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` OrderId valueTypes.Integer `json:"order_id" PointGroupNameFrom:"PointGroupName" PointTimestampFrom:"TimeStamp" PointUpdateFreq:"UpdateFreqBoot"` diff --git a/iSolarCloud/AppService/queryDeviceListForApp/data.go b/iSolarCloud/AppService/queryDeviceListForApp/data.go index a08620164..9492a6613 100644 --- a/iSolarCloud/AppService/queryDeviceListForApp/data.go +++ b/iSolarCloud/AppService/queryDeviceListForApp/data.go @@ -38,7 +38,7 @@ type ResultData struct { DevStatus valueTypes.Bool `json:"dev_status"` DeviceArea valueTypes.String `json:"device_area"` DeviceCode valueTypes.Integer `json:"device_code"` - DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date"` + DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date" PointNameDateFormat:"2006/01/02 15:04:05"` DeviceId valueTypes.Integer `json:"device_id"` DeviceModel valueTypes.String `json:"device_model"` DeviceModelCode valueTypes.String `json:"device_model_code"` diff --git a/iSolarCloud/AppService/queryFirmwareFilesPage/data.go b/iSolarCloud/AppService/queryFirmwareFilesPage/data.go index b5aba4dd3..3a6f0c936 100644 --- a/iSolarCloud/AppService/queryFirmwareFilesPage/data.go +++ b/iSolarCloud/AppService/queryFirmwareFilesPage/data.go @@ -29,10 +29,10 @@ type ResultData struct { FileName valueTypes.String `json:"file_name"` FileSize valueTypes.Integer `json:"file_size"` FileType valueTypes.Integer `json:"file_type"` - UploadTime valueTypes.DateTime `json:"upload_time"` + UploadTime valueTypes.DateTime `json:"upload_time" PointNameDateFormat:"2006/01/02 15:04:05"` URL valueTypes.String `json:"url"` Operation valueTypes.Integer `json:"operation"` - OperationTime valueTypes.DateTime `json:"operation_time"` + OperationTime valueTypes.DateTime `json:"operation_time" PointNameDateFormat:"2006/01/02 15:04:05"` OperatorId valueTypes.String `json:"operator_id"` OperatorName valueTypes.String `json:"operator_name"` System valueTypes.String `json:"system"` diff --git a/iSolarCloud/AppService/queryMutiPointDataList/data.go b/iSolarCloud/AppService/queryMutiPointDataList/data.go index a56eb1081..f37e7c460 100644 --- a/iSolarCloud/AppService/queryMutiPointDataList/data.go +++ b/iSolarCloud/AppService/queryMutiPointDataList/data.go @@ -3,25 +3,23 @@ package queryMutiPointDataList import ( "GoSungrow/iSolarCloud/api" "GoSungrow/iSolarCloud/api/GoStruct" - "GoSungrow/iSolarCloud/api/GoStruct/output" "GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "github.com/MickMake/GoUnify/Only" "encoding/json" "fmt" - "sort" ) const Url = "/v1/commonService/queryMutiPointDataList" const Disabled = false type RequestData struct { - PsId valueTypes.PsId `json:"ps_id" required:"true"` - PsKey valueTypes.PsKey `json:"ps_key" required:"true"` - Points valueTypes.String `json:"points" required:"true"` - MinuteInterval valueTypes.Integer `json:"minute_interval" required:"true"` - StartTimeStamp valueTypes.String `json:"start_time_stamp" required:"true"` - EndTimeStamp valueTypes.String `json:"end_time_stamp" required:"true"` + PsKeys valueTypes.PsKey `json:"ps_key" required:"true"` + PsId valueTypes.PsId `json:"ps_id" required:"true"` + Points valueTypes.PointIds `json:"points" required:"true"` + MinuteInterval valueTypes.Integer `json:"minute_interval" required:"true"` + StartTimeStamp valueTypes.String `json:"start_time_stamp" required:"true"` + EndTimeStamp valueTypes.String `json:"end_time_stamp" required:"true"` } func (rd RequestData) IsValid() error { @@ -33,57 +31,22 @@ func (rd RequestData) Help() string { return ret } + type ResultData struct { - Devices Devices `json:"devices"` + Data Data `json:"data" DataTable:"true" DataTableSortOn:"Timestamp"` } -func (e *ResultData) UnmarshalJSON(data []byte) error { - var err error +type Data map[valueTypes.DateTime]Value +type Value struct { + GoStructParent GoStruct.GoStructParent `json:"-" PointIdFrom:"PsKey.Timestamp" PointIdReplace:"true"` + // GoStruct GoStruct.GoStruct `json:"-" PointIdFrom:"PsKey" PointIdReplace:"false" PointDeviceFrom:"PsKey"` - for range Only.Once { - if len(data) == 0 { - break - } - - d := make(dDevices) - - // Store DeviceData.Points. - err = json.Unmarshal(data, &d) - if err != nil { - break - } - - e.Devices = make(Devices) - for deviceName, deviceRef := range d { - points := Points{} - for pointName, pointRef := range deviceRef { - times := Times{} - for time, value := range pointRef { - times = append(times, Time{ - Key: valueTypes.NewDateTime(time), - Value: value, - }) - } - - sort.Slice(times, func(i, j int) bool { - return times[i].Key.Before(times[j].Key.Time) - }) - points[valueTypes.SetPointIdString(pointName)] = Point{ - Name: valueTypes.SetStringValue(""), - Units: valueTypes.SetStringValue(""), - Times: times, - } - } - - e.Devices[deviceName] = Device{ - Points: points, - } - } - } - - return err + Timestamp valueTypes.DateTime `json:"timestamp" PointNameDateFormat:"2006/01/02 15:04:05"` + PsKey valueTypes.PsKey `json:"ps_key"` + Points map[string]valueTypes.Generic `json:"points" PointDeviceFrom:"PsKey"` } + func (e *ResultData) IsValid() error { var err error return err @@ -138,99 +101,204 @@ func (e *ResultData) String() string { return ret } - -type Devices map[string]Device -type Device struct { - Points Points `json:"points"` -} -type Points map[valueTypes.PointId]Point -type Point struct { - Name valueTypes.String `json:"name"` - Units valueTypes.String `json:"units"` - Times Times `json:"times"` -} -type Times []Time -type Time struct { - Key valueTypes.DateTime `json:"key"` - Value string `json:"value"` -} - -type dDevices map[string]dPoints -type dPoints map[string]dTimes -type dTimes map[string]string - -type DecodeResultData ResultData - -func (e *EndPoint) GetPointDataTable(points api.TemplatePoints) output.Table { - var table output.Table +func (e *ResultData) UnmarshalJSON(data []byte) error { + var err error for range Only.Once { - table = output.NewTable( - "Date/Time", - "Point Id", - "Point Name", - "Value", - "Units", - ) - table.SetTitle("") - table.SetJson([]byte(e.GetJsonData(false))) - table.SetRaw([]byte(e.GetJsonData(true))) - - // e.Error = table.SetHeader( - // "Date/Time", - // "Point Id", - // "Point Name", - // "Value", - // "Units", - // ) - if e.Error != nil { + if len(data) == 0 { break } - t := e.Request.RequestData.StartTimeStamp - e.SetFilenamePrefix(t.String()) - table.SetFilePrefix(t.String()) + type scan scanDevices + d := make(scan, 0) + err = json.Unmarshal(data, &d) + if err != nil { + break + } - for deviceName, deviceRef := range e.Response.ResultData.Devices { - for pointId, pointRef := range deviceRef.Points { - for _, tim := range pointRef.Times { - gp := points.GetPoint(deviceName, pointId) - _ = table.AddRow(tim.Key.PrintFull(), - fmt.Sprintf("%s.%s", deviceName, pointId), - gp.Name, - tim.Value, - gp.Unit, - ) - if table.Error != nil { + e.Data = make(Data, 0) + for device := range d { + for point := range d[device] { + for value := range d[device][point] { + d[device][point][value].PointId = valueTypes.SetPointIdString(point) + ts := d[device][point][value].Timestamp + + if _, ok := e.Data[ts]; !ok { + rdv := Value { + Timestamp: ts, + PsKey: valueTypes.SetPsKeyString(device), + Points: make(map[string]valueTypes.Generic), + } + rdv.Points[point] = d[device][point][value].Value + e.Data[ts] = rdv continue } + + e.Data[ts].Points[point] = d[device][point][value].Value } } } - - table.InitGraph(output.GraphRequest { - Title: "", - TimeColumn: output.SetString("Date/Time"), - SearchColumn: output.SetString("Point Id"), - NameColumn: output.SetString("Point Name"), - ValueColumn: output.SetString("Value"), - UnitsColumn: output.SetString("Units"), - SearchString: output.SetString(""), - MinLeftAxis: output.SetFloat(0), - MaxLeftAxis: output.SetFloat(0), - }) - } - return table + return err } + +// Scan incoming JSON. + +type scanDevices map[string]scanPoints +func (e *scanDevices) UnmarshalJSON(data []byte) error { + var err error + + for range Only.Once { + if len(data) == 0 { + break + } + + type scan scanDevices + d := make(scan, 0) + err = json.Unmarshal(data, &d) + if err != nil { + break + } + + *e = scanDevices(d) + } + + return err +} + +type scanPoints map[string]scanValues +func (e *scanPoints) UnmarshalJSON(data []byte) error { + var err error + + for range Only.Once { + if len(data) == 0 { + break + } + + type scan scanPoints + d := make(scan, 0) + err = json.Unmarshal(data, &d) + if err != nil { + break + } + + for point := range d { + for value := range d[point] { + d[point][value].PointId = valueTypes.SetPointIdString(point) + } + } + *e = scanPoints(d) + } + + return err +} + +type scanValues []scanValue +func (e *scanValues) UnmarshalJSON(data []byte) error { + var err error + + for range Only.Once { + if len(data) == 0 { + break + } + + type scan map[string]string + d := make(scan, 0) + + err = json.Unmarshal(data, &d) + if err != nil { + break + } + + *e = make(scanValues, 0) + for k, v := range d { + *e = append(*e, scanValue { + Timestamp: valueTypes.SetDateTimeString(k), + // PointId: valueTypes.SetPointIdString(v), + Value: valueTypes.SetGenericString(v), + }) + } + } + + return err +} + +type scanValue struct { + Timestamp valueTypes.DateTime `json:"timestamp"` + PointId valueTypes.PointId `json:"point_id"` + Value valueTypes.Generic `json:"value"` +} + + +// func (e *EndPoint) GetPointDataTable(points api.TemplatePoints) output.Table { +// var table output.Table +// +// // for range Only.Once { +// // table = output.NewTable( +// // "Date/Time", +// // "Point Id", +// // "Point Name", +// // "Value", +// // "Units", +// // ) +// // table.SetTitle("") +// // table.SetJson([]byte(e.GetJsonData(false))) +// // table.SetRaw([]byte(e.GetJsonData(true))) +// // +// // // e.Error = table.SetHeader( +// // // "Date/Time", +// // // "Point Id", +// // // "Point Name", +// // // "Value", +// // // "Units", +// // // ) +// // if e.Error != nil { +// // break +// // } +// // +// // t := e.Request.RequestData.StartTimeStamp +// // e.SetFilenamePrefix(t.String()) +// // table.SetFilePrefix(t.String()) +// // +// // for deviceName, deviceRef := range e.Response.ResultData.Devices { +// // for pointId, pointRef := range deviceRef.Points { +// // for _, tim := range pointRef.Times { +// // gp := points.GetPoint(deviceName, pointId) +// // _ = table.AddRow(tim.Key.PrintFull(), +// // fmt.Sprintf("%s.%s", deviceName, pointId), +// // gp.Name, +// // tim.Value, +// // gp.Unit, +// // ) +// // if table.Error != nil { +// // continue +// // } +// // } +// // } +// // } +// // +// // table.InitGraph(output.GraphRequest { +// // Title: "", +// // TimeColumn: output.SetString("Date/Time"), +// // SearchColumn: output.SetString("Point Id"), +// // NameColumn: output.SetString("Point Name"), +// // ValueColumn: output.SetString("Value"), +// // UnitsColumn: output.SetString("Units"), +// // SearchString: output.SetString(""), +// // MinLeftAxis: output.SetFloat(0), +// // MaxLeftAxis: output.SetFloat(0), +// // }) +// // +// // } +// +// return table +// } + func (e *EndPoint) GetData() api.DataMap { entries := api.NewDataMap() - - for range Only.Once { - entries.StructToDataMap(*e, e.Request.PsId.String(), GoStruct.NewEndPointPath(e.Request.PsId.String())) - } - + // entries.StructToDataMap(*e, e.Request.PsId.String(), GoStruct.NewEndPointPath(e.Request.PsId.String())) + entries.StructToDataMap(*e, e.Request.PsId.String(), GoStruct.EndPointPath{}) return entries } diff --git a/iSolarCloud/AppService/queryPowerStationInfo/data.go b/iSolarCloud/AppService/queryPowerStationInfo/data.go index e8512e723..85005dec7 100644 --- a/iSolarCloud/AppService/queryPowerStationInfo/data.go +++ b/iSolarCloud/AppService/queryPowerStationInfo/data.go @@ -55,14 +55,14 @@ type ResultData struct { DivisionCode valueTypes.String `json:"division_code"` Email valueTypes.String `json:"email"` EnergyScheme interface{} `json:"energy_scheme"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` GcjLongitude valueTypes.Float `json:"gcj_longitude"` GprsLatitude valueTypes.Float `json:"gprs_latitude"` GprsLongitude valueTypes.Float `json:"gprs_longitude"` GridLevel interface{} `json:"grid_level"` - InstallDate valueTypes.DateTime `json:"install_date"` - InstallDateZone valueTypes.DateTime `json:"install_date_zone"` + InstallDate valueTypes.DateTime `json:"install_date" PointNameDateFormat:"2006/01/02 15:04:05"` + InstallDateZone valueTypes.DateTime `json:"install_date_zone" PointNameDateFormat:"2006/01/02 15:04:05"` InverterCount valueTypes.Integer `json:"inverter_count"` InvestmentType valueTypes.Integer `json:"investment_type"` InvestmentTypeDesc valueTypes.String `json:"investment_type_desc"` @@ -92,7 +92,7 @@ type ResultData struct { ParamIncomeUnitName valueTypes.String `json:"param_income_unit_name"` ProvinceCode valueTypes.String `json:"province_code"` ProvinceName valueTypes.String `json:"province_name"` - PsBuildDate valueTypes.DateTime `json:"ps_build_date"` + PsBuildDate valueTypes.DateTime `json:"ps_build_date" PointNameDateFormat:"2006/01/02 15:04:05"` PsCountryId valueTypes.Integer `json:"ps_country_id"` PsCreateUserId valueTypes.Integer `json:"ps_create_user_id"` PsCurrentTimeZone valueTypes.String `json:"ps_current_time_zone"` @@ -108,8 +108,8 @@ type ResultData struct { PsTypeDesc valueTypes.String `json:"ps_type_desc"` PsTypeName valueTypes.String `json:"ps_type_name"` PsUserId valueTypes.Integer `json:"ps_user_id"` - RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time"` - SafeStartDate valueTypes.DateTime `json:"safe_start_date"` + RecordCreateTime valueTypes.DateTime `json:"recore_create_time" PointId:"record_create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + SafeStartDate valueTypes.DateTime `json:"safe_start_date" PointNameDateFormat:"2006/01/02 15:04:05"` SetUserOrg valueTypes.Integer `json:"set_user_org"` ShareType valueTypes.Integer `json:"share_type"` ShareUserType interface{} `json:"share_user_type"` diff --git a/iSolarCloud/AppService/queryPsProfit/data.go b/iSolarCloud/AppService/queryPsProfit/data.go index 8d9efa4b4..d773a8755 100644 --- a/iSolarCloud/AppService/queryPsProfit/data.go +++ b/iSolarCloud/AppService/queryPsProfit/data.go @@ -33,7 +33,7 @@ type ResultData struct { CuspNetPowerQuantity interface{} `json:"cusp_net_power_quantity"` CuspPowerQuantity interface{} `json:"cusp_power_quantity"` CuspUsePowerQuantity interface{} `json:"cusp_use_power_quantity"` - DateId valueTypes.DateTime `json:"date_id"` + DateId valueTypes.DateTime `json:"date_id" PointNameDateFormat:"2006/01/02 15:04:05"` FlatNetPowerQuantity valueTypes.Float `json:"flat_net_power_quantity"` FlatPowerQuantity valueTypes.Float `json:"flat_power_quantity"` FlatUsePowerQuantity valueTypes.Float `json:"flat_use_power_quantity"` @@ -45,7 +45,7 @@ type ResultData struct { PowerQuantityTotal valueTypes.Float `json:"power_quantity_total"` SubsidyProfit interface{} `json:"subsidy_profit"` TotalProfit valueTypes.Float `json:"total_profit"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` UsePowerByDiscountProfit valueTypes.Float `json:"use_power_by_discount_profit"` UsePowerProfit valueTypes.Float `json:"use_power_profit"` UsePowerQuantityTotal valueTypes.Float `json:"use_power_quantity_total"` diff --git a/iSolarCloud/AppService/reportList/data.go b/iSolarCloud/AppService/reportList/data.go index d57a928bc..b1cfed7e1 100644 --- a/iSolarCloud/AppService/reportList/data.go +++ b/iSolarCloud/AppService/reportList/data.go @@ -38,7 +38,7 @@ type DataList struct { DateId valueTypes.DateTime `json:"date_id" PointTimestampFrom:"UpdateTime" PointNameDateFormat:"20060102"` PsId valueTypes.PsId `json:"ps_id" PointTimestampFrom:"UpdateTime"` TimeStamp valueTypes.Generic `json:"time_stamp" PointTimestampFrom:"UpdateTime"` // Sad that this alternates between string and valueTypes.Integer. - UpdateTime valueTypes.DateTime `json:"update_time" PointTimestampFrom:"UpdateTime"` + UpdateTime valueTypes.DateTime `json:"update_time" PointTimestampFrom:"UpdateTime" PointNameDateFormat:"2006/01/02 15:04:05"` DeviceName interface{} `json:"device_name" PointTimestampFrom:"UpdateTime"` UUID interface{} `json:"uuid" PointTimestampFrom:"UpdateTime"` Co2Reduce valueTypes.Float `json:"co2_reduce" PointTimestampFrom:"UpdateTime"` diff --git a/iSolarCloud/WebAppService/getPsList/data.go b/iSolarCloud/WebAppService/getPsList/data.go index fb0d9af8a..448b0c096 100644 --- a/iSolarCloud/WebAppService/getPsList/data.go +++ b/iSolarCloud/WebAppService/getPsList/data.go @@ -32,7 +32,7 @@ type ResultData []struct { ArrearsStatus valueTypes.Integer `json:"arrears_status"` DesignCapacity valueTypes.Float `json:"design_capacity" PointUnitFrom:"DesignCapacityUnit"` DesignCapacityUnit valueTypes.String `json:"design_capacity_unit" PointIgnore:"true"` - InstallDate valueTypes.DateTime `json:"install_date"` + InstallDate valueTypes.DateTime `json:"install_date" PointNameDateFormat:"2006/01/02 15:04:05"` PsCode valueTypes.String `json:"ps_code"` PsCountryID valueTypes.Integer `json:"ps_country_id"` PsLocation valueTypes.String `json:"ps_location"` diff --git a/iSolarCloud/WebAppService/getPsValue/data.go b/iSolarCloud/WebAppService/getPsValue/data.go index a84b4d301..c8155d317 100644 --- a/iSolarCloud/WebAppService/getPsValue/data.go +++ b/iSolarCloud/WebAppService/getPsValue/data.go @@ -35,7 +35,7 @@ type ResultData []struct { PsStatus valueTypes.Integer `json:"ps_status"` PsType valueTypes.Integer `json:"ps_type"` State valueTypes.Bool `json:"state"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` PsFaultStatus valueTypes.Integer `json:"ps_fault_status"` ArrearsStatus valueTypes.Integer `json:"arrears_status"` @@ -44,7 +44,7 @@ type ResultData []struct { Value valueTypes.Float `json:"value" PointUnitFrom:"Unit"` } `json:"design_capacity"` DesignCapacityOriginal valueTypes.Float `json:"design_capacity_original"` - DeviceStatusUpdateTime valueTypes.DateTime `json:"device_status_update_time"` + DeviceStatusUpdateTime valueTypes.DateTime `json:"device_status_update_time" PointNameDateFormat:"2006/01/02 15:04:05"` EquivalentHour valueTypes.Integer `json:"equivalent_hour"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` GcjLongitude valueTypes.Float `json:"gcj_longitude"` diff --git a/iSolarCloud/WebAppService/getReportListByType/data.go b/iSolarCloud/WebAppService/getReportListByType/data.go index 9304eae62..83886075c 100644 --- a/iSolarCloud/WebAppService/getReportListByType/data.go +++ b/iSolarCloud/WebAppService/getReportListByType/data.go @@ -27,7 +27,7 @@ func (rd RequestData) Help() string { type ResultData []struct { GoStructParent GoStruct.GoStructParent `json:"GoStruct" DataTable:"true" DataTableSortOn:"CreateTime"` - CreateTime valueTypes.DateTime `json:"create_time"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` Cycle valueTypes.Integer `json:"cycle"` ID valueTypes.Integer `json:"id"` MonthDate valueTypes.String `json:"month_date"` @@ -35,7 +35,7 @@ type ResultData []struct { ReportName valueTypes.String `json:"report_name"` ReportType valueTypes.Integer `json:"report_type"` Status valueTypes.Bool `json:"status"` - UpdateTime valueTypes.DateTime `json:"update_time"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` } func (e *ResultData) IsValid() error { diff --git a/iSolarCloud/WebAppService/queryUserCurveTemplateData/data.go b/iSolarCloud/WebAppService/queryUserCurveTemplateData/data.go index 0ca733c29..c1c010270 100644 --- a/iSolarCloud/WebAppService/queryUserCurveTemplateData/data.go +++ b/iSolarCloud/WebAppService/queryUserCurveTemplateData/data.go @@ -36,11 +36,11 @@ func (rd RequestData) Help() string { // ResultData -> PointsData -> []dDevices -> []Points type ResultData struct { - CreateTime valueTypes.DateTime `json:"create_time"` - OpenTime valueTypes.DateTime `json:"open_time"` - UpdateTime valueTypes.DateTime `json:"update_time"` - StartTime valueTypes.DateTime `json:"start_time"` - EndTime valueTypes.DateTime `json:"end_time"` + CreateTime valueTypes.DateTime `json:"create_time" PointNameDateFormat:"2006/01/02 15:04:05"` + OpenTime valueTypes.DateTime `json:"open_time" PointNameDateFormat:"2006/01/02 15:04:05"` + UpdateTime valueTypes.DateTime `json:"update_time" PointNameDateFormat:"2006/01/02 15:04:05"` + StartTime valueTypes.DateTime `json:"start_time" PointNameDateFormat:"2006/01/02 15:04:05"` + EndTime valueTypes.DateTime `json:"end_time" PointNameDateFormat:"2006/01/02 15:04:05"` DateType valueTypes.Integer `json:"date_type"` Cycle valueTypes.Integer `json:"cycle"` TemplateId valueTypes.Integer `json:"template_id"` diff --git a/iSolarCloud/WebIscmAppService/checkDeviceModel/data.go b/iSolarCloud/WebIscmAppService/checkDeviceModel/data.go index 1df8c860f..b62fda982 100644 --- a/iSolarCloud/WebIscmAppService/checkDeviceModel/data.go +++ b/iSolarCloud/WebIscmAppService/checkDeviceModel/data.go @@ -39,7 +39,7 @@ type ResultData struct { Remark valueTypes.String `json:"remark"` SysId valueTypes.String `json:"sys_id"` SysType valueTypes.String `json:"sys_type"` - UpdateDate valueTypes.DateTime `json:"updatedate" PointId:"update_date"` + UpdateDate valueTypes.DateTime `json:"updatedate" PointId:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` UpdateUserCode valueTypes.Bool `json:"updateusercode" PointId:"update_user_code"` } diff --git a/iSolarCloud/WebIscmAppService/getDeploymentList/data.go b/iSolarCloud/WebIscmAppService/getDeploymentList/data.go index 8a4d083db..dd9c59149 100644 --- a/iSolarCloud/WebIscmAppService/getDeploymentList/data.go +++ b/iSolarCloud/WebIscmAppService/getDeploymentList/data.go @@ -26,7 +26,7 @@ func (rd RequestData) Help() string { type ResultData []struct { GoStructParent GoStruct.GoStructParent `json:"-" DataTable:"true" DataTableSortOn:"DeploymentTime"` - DeploymentTime valueTypes.DateTime `json:"deploymentTime" PointId:"deployment_time"` + DeploymentTime valueTypes.DateTime `json:"deploymentTime" PointId:"deployment_time" PointNameDateFormat:"2006/01/02 15:04:05"` Id valueTypes.String `json:"id"` Name valueTypes.String `json:"name"` } diff --git a/iSolarCloud/WebIscmAppService/getDeviceModel/data.go b/iSolarCloud/WebIscmAppService/getDeviceModel/data.go index 4f59ad868..d4741100f 100644 --- a/iSolarCloud/WebIscmAppService/getDeviceModel/data.go +++ b/iSolarCloud/WebIscmAppService/getDeviceModel/data.go @@ -70,7 +70,7 @@ type ResultData struct { Phone valueTypes.String `json:"phone"` Protocol valueTypes.String `json:"protocol"` Remark valueTypes.String `json:"remark"` - UpdateDate valueTypes.DateTime `json:"updatedate" PointId:"update_date"` + UpdateDate valueTypes.DateTime `json:"updatedate" PointId:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` UpdateUserCode valueTypes.Bool `json:"updateusercode" PointId:"update_user_code"` } `json:"powerDeviceModel"` SysTypeList []struct { @@ -100,7 +100,7 @@ type ResultData struct { SysId valueTypes.String `json:"sys_id"` SysName valueTypes.String `json:"sys_name"` IsRemoteUpgrade valueTypes.Bool `json:"is_remote_upgrade"` - UpdateDate valueTypes.DateTime `json:"update_date"` + UpdateDate valueTypes.DateTime `json:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` ValidFlag valueTypes.Bool `json:"valid_flag"` } `json:"deviceTypeList" PointId:"device_type_list" DataTable:"true" DataTableSortOn:"TypeId"` } diff --git a/iSolarCloud/WebIscmAppService/getDeviceTechnical/data.go b/iSolarCloud/WebIscmAppService/getDeviceTechnical/data.go index 4c5b1b6ed..8274a9a64 100644 --- a/iSolarCloud/WebIscmAppService/getDeviceTechnical/data.go +++ b/iSolarCloud/WebIscmAppService/getDeviceTechnical/data.go @@ -36,12 +36,12 @@ type ResultData struct { TechCode valueTypes.String `json:"tech_code"` TechContent valueTypes.String `json:"tech_content"` TechContentTransId valueTypes.Integer `json:"tech_content_trans_id"` - TechCreateTime valueTypes.DateTime `json:"tech_createtime" PointId:"tech_create_time"` + TechCreateTime valueTypes.DateTime `json:"tech_createtime" PointId:"tech_create_time" PointNameDateFormat:"2006/01/02 15:04:05"` TechCreator valueTypes.String `json:"tech_creator"` TechDescription interface{} `json:"tech_description"` TechId valueTypes.Integer `json:"tech_id"` TechModifier interface{} `json:"tech_modifier"` - TechModifyTime valueTypes.DateTime `json:"tech_modifytime" PointId:"tech_modify_time"` + TechModifyTime valueTypes.DateTime `json:"tech_modifytime" PointId:"tech_modify_time" PointNameDateFormat:"2006/01/02 15:04:05"` TechName valueTypes.String `json:"tech_name"` TypeId valueTypes.Integer `json:"type_id"` TypeName valueTypes.String `json:"type_name"` diff --git a/iSolarCloud/WebIscmAppService/getDeviceTypeInfoById/data.go b/iSolarCloud/WebIscmAppService/getDeviceTypeInfoById/data.go index 50e811b28..67128a70b 100644 --- a/iSolarCloud/WebIscmAppService/getDeviceTypeInfoById/data.go +++ b/iSolarCloud/WebIscmAppService/getDeviceTypeInfoById/data.go @@ -26,7 +26,7 @@ func (rd RequestData) Help() string { type ResultData struct { PowerDeviceTypeMap struct { - UpdateDate valueTypes.DateTime `json:"update_date"` + UpdateDate valueTypes.DateTime `json:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` SysId valueTypes.String `json:"sys_id"` SysName valueTypes.String `json:"sys_name"` TypeCode valueTypes.Integer `json:"type_code"` diff --git a/iSolarCloud/WebIscmAppService/getGroupManSettings/data.go b/iSolarCloud/WebIscmAppService/getGroupManSettings/data.go index d1fa194b1..b2fc01194 100644 --- a/iSolarCloud/WebIscmAppService/getGroupManSettings/data.go +++ b/iSolarCloud/WebIscmAppService/getGroupManSettings/data.go @@ -12,7 +12,7 @@ const Url = "/v1/faultService/getGroupManSettings" const Disabled = false type RequestData struct { - } +} func (rd RequestData) IsValid() error { return GoStruct.VerifyOptionsRequired(rd) diff --git a/iSolarCloud/WebIscmAppService/getOrgList/data.go b/iSolarCloud/WebIscmAppService/getOrgList/data.go index 7da504dc1..f6b169f29 100644 --- a/iSolarCloud/WebIscmAppService/getOrgList/data.go +++ b/iSolarCloud/WebIscmAppService/getOrgList/data.go @@ -55,7 +55,7 @@ type ResultData []struct { RegisteredAddress valueTypes.String `json:"registered_address"` RegisteredArea valueTypes.String `json:"registered_area"` RegisteredCapital valueTypes.Integer `json:"registered_capital"` - RegisteredDate valueTypes.DateTime `json:"registered_date"` + RegisteredDate valueTypes.DateTime `json:"registered_date" PointNameDateFormat:"2006/01/02 15:04:05"` ServiceEmail valueTypes.String `json:"service_emaill" PointId:"service_email"` TaxCertificate valueTypes.String `json:"tax_certificate"` TelNo valueTypes.String `json:"tel_no"` diff --git a/iSolarCloud/WebIscmAppService/getPowerDevice/data.go b/iSolarCloud/WebIscmAppService/getPowerDevice/data.go index d62648eb5..2af8ea01a 100644 --- a/iSolarCloud/WebIscmAppService/getPowerDevice/data.go +++ b/iSolarCloud/WebIscmAppService/getPowerDevice/data.go @@ -38,7 +38,7 @@ type ResultData struct { PsGUID valueTypes.String `json:"psGuid" PointId:"ps_guid"` SnCode interface{} `json:"snCode" PointId:"sn_code"` SyncDate interface{} `json:"syncDate" PointId:"sync_date"` - UpdateDate valueTypes.DateTime `json:"updateDate" PointId:"update_date"` + UpdateDate valueTypes.DateTime `json:"updateDate" PointId:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` UpdateUserCode interface{} `json:"updateUserCode" PointId:"update_user_code"` } diff --git a/iSolarCloud/WebIscmAppService/getPowerDeviceTypeList/data.go b/iSolarCloud/WebIscmAppService/getPowerDeviceTypeList/data.go index db08cfa50..ae7044e30 100644 --- a/iSolarCloud/WebIscmAppService/getPowerDeviceTypeList/data.go +++ b/iSolarCloud/WebIscmAppService/getPowerDeviceTypeList/data.go @@ -27,7 +27,7 @@ func (rd RequestData) Help() string { type ResultData []struct { GoStructParent GoStruct.GoStructParent `json:"GoStruct" PointIdReplace:"true" DataTable:"true" DataTableSortOn:"UpdateDate"` - UpdateDate valueTypes.DateTime `json:"update_date"` + UpdateDate valueTypes.DateTime `json:"update_date" PointNameDateFormat:"2006/01/02 15:04:05"` SysId valueTypes.String `json:"sys_id"` SysName valueTypes.String `json:"sys_name"` TypeId valueTypes.Integer `json:"type_id"` diff --git a/iSolarCloud/WebIscmAppService/getPowerStationInfo/data.go b/iSolarCloud/WebIscmAppService/getPowerStationInfo/data.go index 487ae82ce..da231cad9 100644 --- a/iSolarCloud/WebIscmAppService/getPowerStationInfo/data.go +++ b/iSolarCloud/WebIscmAppService/getPowerStationInfo/data.go @@ -81,7 +81,7 @@ type ResultData struct { AccessType Common.Unknown `json:"access_type"` AreaType Common.Unknown `json:"area_type"` AreaId Common.Unknown `json:"areaid" PointId:"area_id"` - BuildDate valueTypes.DateTime `json:"build_date"` + BuildDate valueTypes.DateTime `json:"build_date" PointNameDateFormat:"2006/01/02 15:04:05"` BuildStatus valueTypes.Integer `json:"buildstatus" PointId:"build_status"` CapitalType valueTypes.Integer `json:"capitaltype" PointId:"capital_type"` City Common.Unknown `json:"city"` @@ -90,13 +90,13 @@ type ResultData struct { DistrictFlag valueTypes.Integer `json:"district_flag"` DivisionCode Common.Unknown `json:"division_code"` Email valueTypes.String `json:"email"` - ExpectInstallDate valueTypes.DateTime `json:"expect_install_date"` + ExpectInstallDate valueTypes.DateTime `json:"expect_install_date" PointNameDateFormat:"2006/01/02 15:04:05"` FaultSendType Common.Unknown `json:"fault_send_type"` GcjLatitude valueTypes.Float `json:"gcj_latitude"` GcjLongitude valueTypes.Float `json:"gcj_longitude"` GprsLatitude valueTypes.Float `json:"gprs_latitude"` GprsLongitude valueTypes.Float `json:"gprs_longitude"` - InstallDate valueTypes.DateTime `json:"installdate"` + InstallDate valueTypes.DateTime `json:"installdate" PointNameDateFormat:"2006/01/02 15:04:05"` InvestmentType valueTypes.Integer `json:"investment_type"` Latitude valueTypes.Float `json:"latitude"` Longitude valueTypes.Float `json:"longitude"` @@ -118,7 +118,7 @@ type ResultData struct { Producer Common.Unknown `json:"producer"` Prov Common.Unknown `json:"prov"` ProvCode Common.Unknown `json:"prov_code"` - PsBuildDate valueTypes.DateTime `json:"ps_build_date"` + PsBuildDate valueTypes.DateTime `json:"ps_build_date" PointNameDateFormat:"2006/01/02 15:04:05"` PsCountryId valueTypes.Integer `json:"ps_country_id"` PsCode valueTypes.String `json:"pscode" PointId:"ps_code"` PsDesc Common.Unknown `json:"psdesc" PointId:"ps_desc"` @@ -129,7 +129,7 @@ type ResultData struct { PsNameEnus Common.Unknown `json:"psnameenus" PointId:"ps_name_enus"` PsOrgId Common.Unknown `json:"psorgid" PointId:"ps_org_id"` PsOrgName Common.Unknown `json:"psorgname" PointId:"ps_org_name"` - SafeStartDate valueTypes.DateTime `json:"safe_start_date"` + SafeStartDate valueTypes.DateTime `json:"safe_start_date" PointNameDateFormat:"2006/01/02 15:04:05"` SchedulingType valueTypes.Integer `json:"schedulingtype" PointId:"scheduling_type"` Shortname valueTypes.String `json:"shortname"` Sn valueTypes.String `json:"sn"` @@ -153,7 +153,7 @@ type ResultData struct { ChannelDesc Common.Unknown `json:"chnnl_desc" PointId:"channel_description"` ChannelId valueTypes.Integer `json:"chnnl_id" PointId:"channel_id"` ChannelName valueTypes.String `json:"chnnl_name" PointId:"channel_name"` - CrtDate valueTypes.DateTime `json:"crt_date" PointId:"create_date"` + CrtDate valueTypes.DateTime `json:"crt_date" PointId:"create_date" PointNameDateFormat:"2006/01/02 15:04:05"` CrtUserName Common.Unknown `json:"crt_user_name" PointId:"create_username"` DataFlag valueTypes.Integer `json:"data_flag"` FlagServer Common.Unknown `json:"flag_server"` diff --git a/iSolarCloud/api/GoStruct/output/struct_output.go b/iSolarCloud/api/GoStruct/output/struct_output.go index f86da825f..355cbbcdf 100644 --- a/iSolarCloud/api/GoStruct/output/struct_output.go +++ b/iSolarCloud/api/GoStruct/output/struct_output.go @@ -15,6 +15,8 @@ const ( TypeRaw = iota TypeGraph = iota TypeStruct = iota + TypeXML = iota + TypeXLSX = iota StringTypeNone = "" StringTypeJson = "json" @@ -24,6 +26,8 @@ const ( StringTypeRaw = "raw" StringTypeGraph = "graph" StringTypeStruct = "struct" + StringTypeXML = "xml" + StringTypeXLSX = "xlsx" ) //goland:noinspection GoNameStartsWithPackageName @@ -54,6 +58,12 @@ func (out *OutputType) SetGraph() { func (out *OutputType) SetStruct() { *out = TypeStruct } +func (out *OutputType) SetXML() { + *out = TypeXML +} +func (out *OutputType) SetXLSX() { + *out = TypeXLSX +} func (out *OutputType) IsNone() bool { @@ -104,6 +114,18 @@ func (out *OutputType) IsStruct() bool { } return false } +func (out *OutputType) IsXML() bool { + if *out == TypeXML { + return true + } + return false +} +func (out *OutputType) IsXLSX() bool { + if *out == TypeXLSX { + return true + } + return false +} func (out *OutputType) IsStrNone(t string) bool { @@ -148,8 +170,14 @@ func (out *OutputType) IsStrGraph(t string) bool { } return false } -func (out *OutputType) IsStrStruct(t string) bool { - if t == StringTypeStruct { +func (out *OutputType) IsStrXML(t string) bool { + if t == StringTypeXML { + return true + } + return false +} +func (out *OutputType) IsStrXLSX(t string) bool { + if t == StringTypeXLSX { return true } return false @@ -178,6 +206,10 @@ func (out *OutputType) Set(outputType string) { out.SetGraph() case StringTypeStruct: out.SetStruct() + case StringTypeXML: + out.SetXML() + case StringTypeXLSX: + out.SetXLSX() case StringTypeList: fallthrough default: diff --git a/iSolarCloud/api/GoStruct/output/struct_table.go b/iSolarCloud/api/GoStruct/output/struct_table.go index 5e0eaa9a6..d033ab238 100644 --- a/iSolarCloud/api/GoStruct/output/struct_table.go +++ b/iSolarCloud/api/GoStruct/output/struct_table.go @@ -15,10 +15,6 @@ import ( // "github.com/jbub/tabular" -// type DataSet []DataRow -// type DataRow map[string]string - - type Tables map[string]Table func NewTables() Tables { @@ -167,10 +163,6 @@ func (t *Table) writeFile(data string, perm os.FileMode) error { return t.Error } -// func (t *Table) AllRows() []*tabular.Row { -// return t.table.AllRows() -// } - func (t *Table) SetTitle(title string, args ...interface{}) { t.title = fmt.Sprintf(title, args...) } @@ -245,7 +237,6 @@ func (t *Table) GetName() string { return t.name } - func (t *Table) Output() error { for range Only.Once { if t == nil { @@ -264,6 +255,12 @@ func (t *Table) Output() error { case t.OutputType.IsCsv(): t.Error = t.WriteCsv() + case t.OutputType.IsXML(): + t.Error = t.WriteXml() + + case t.OutputType.IsXLSX(): + t.Error = t.WriteXLSX() + case t.OutputType.IsRaw(): t.Error = t.WriteRaw() @@ -290,6 +287,7 @@ func (t *Table) Output() error { return t.Error } + func (t *Table) GetTable() string { return t.String() } @@ -301,7 +299,7 @@ func (t *Table) WriteTable() error { } if t.saveAsFile { - t.filePrefix += "-table.txt" + t.filePrefix += "." + StringTypeTable t.Error = t.writeFile(t.String(), DefaultFileMode) break } @@ -318,7 +316,7 @@ func (t *Table) WriteList() error { } if t.saveAsFile { - t.filePrefix += "-list.txt" + t.filePrefix += "." + StringTypeList t.Error = t.writeFile(t.String(), DefaultFileMode) break } @@ -353,7 +351,7 @@ func (t *Table) WriteCsv() error { } if t.saveAsFile { - t.filePrefix += ".csv" + t.filePrefix += "." + StringTypeCsv t.Error = t.writeFile(t.GetCsv(), DefaultFileMode) break } @@ -371,7 +369,7 @@ func (t *Table) GetXml() string { } var result *tabular.Exportable - result, t.Error = t.table.CSV() + result, t.Error = t.table.XML() if t.Error != nil { break } @@ -387,7 +385,7 @@ func (t *Table) WriteXml() error { } if t.saveAsFile { - t.filePrefix += ".xml" + t.filePrefix += "." + StringTypeXML t.Error = t.writeFile(t.GetXml(), DefaultFileMode) break } @@ -397,6 +395,40 @@ func (t *Table) WriteXml() error { } +func (t *Table) GetXLSX() string { + var ret string + for range Only.Once { + if t.IsNotValid() { + break + } + + var result *tabular.Exportable + result, t.Error = t.table.XLSX() + if t.Error != nil { + break + } + ret = result.String() + } + return ret +} + +func (t *Table) WriteXLSX() error { + for range Only.Once { + if t.IsNotValid() { + break + } + + // if t.saveAsFile { + t.filePrefix += "." + StringTypeXLSX + t.Error = t.writeFile(t.GetXLSX(), DefaultFileMode) + // break + // } + // fmt.Print(t.GetXml()) + } + return t.Error +} + + func (t *Table) GetJson() string { return string(t.raw) } @@ -408,7 +440,7 @@ func (t *Table) WriteJson() error { } if t.saveAsFile { - t.filePrefix += ".json" + t.filePrefix += "." + StringTypeJson t.Error = t.writeFile(string(t.json), DefaultFileMode) break } @@ -433,7 +465,7 @@ func (t *Table) WriteRaw() error { // } if t.saveAsFile { - t.filePrefix += ".raw" + t.filePrefix += "." + StringTypeRaw t.Error = t.writeFile(string(t.raw), DefaultFileMode) break } diff --git a/iSolarCloud/api/GoStruct/struct_reflect.go b/iSolarCloud/api/GoStruct/struct_reflect.go index 48f5940a3..0fab67391 100644 --- a/iSolarCloud/api/GoStruct/struct_reflect.go +++ b/iSolarCloud/api/GoStruct/struct_reflect.go @@ -740,6 +740,10 @@ func (r *Reflect) SetByIndex(parent *Reflect, current *Reflect, index int, index } r.Valid = true + + + + switch current.TypeOf.Kind() { case reflect.Struct: r.FieldTo = current.TypeOf.Field(index) @@ -823,9 +827,15 @@ func (r *Reflect) SetByIndex(parent *Reflect, current *Reflect, index int, index } r.IsExported = true r.FieldVo = current.ValueOf.MapIndex(indexName) - r.FieldName = current.FieldName + ":" + indexName.String() // mk[index].String() + name := valueTypes.AnyToValueString(indexName.Interface(), valueTypes.IgnoreLength, "") // map key could be anything. + r.FieldName = name // current.FieldName + ":" + indexName.String() + + + + + r.FieldPath = r.CurrentReflect.FieldPath.Copy() - r.FieldPath.Append("[" + indexName.String() + "]") + r.FieldPath.Append("[" + name + "]") // indexName.String() current.ChildReflect = append(current.ChildReflect, r) current.ChildReflectMap[r.FieldName] = r @@ -844,8 +854,8 @@ func (r *Reflect) SetByIndex(parent *Reflect, current *Reflect, index int, index } } r.SetGoStructOptions(1) - r.DataStructure.Json = indexName.String() // current.ValueOf.MapIndex(indexName).String() || r.FieldVo.String() - r.DataStructure.PointId = indexName.String() // current.ValueOf.MapIndex(indexName).String() || r.FieldVo.String() + r.DataStructure.Json = name // indexName.String() // current.ValueOf.MapIndex(indexName).String() || r.FieldVo.String() + r.DataStructure.PointId = name // indexName.String() // current.ValueOf.MapIndex(indexName).String() || r.FieldVo.String() r.DataStructure.UpdateTags(parent, current) // Value @@ -951,6 +961,9 @@ func (r *Reflect) SetPointId() EndPointPath { // fmt.Printf("EPP(BEFORE): %s\n", r.DataStructure.Endpoint.String()) // fmt.Printf("[ ] EPP: %s - FP: %s\n", r.DataStructure.Endpoint, r.FieldPath) var pn string + if strings.Contains(r.EndPointPath().String(), "Points") || strings.Contains(r.DataStructure.Endpoint.String(), "values") { + fmt.Printf("") + } switch { case r.DataStructure.PointIdFromChild != "": diff --git a/iSolarCloud/api/GoStruct/structmap.go b/iSolarCloud/api/GoStruct/structmap.go index 0eea3e52b..394ebf388 100644 --- a/iSolarCloud/api/GoStruct/structmap.go +++ b/iSolarCloud/api/GoStruct/structmap.go @@ -152,14 +152,14 @@ func (sm *StructMap) ScanMap(Parent *Reflect, Current *Reflect) bool { Child.SetByIndex(Parent, Current, index, key) sm.PrintDebug("# ScanMap().SetByIndex() Child: %s\n", Child) - if strings.Contains(Child.FieldPath.String(), "DevTypeDefinition") { - for index2, key2 := range Child.FieldVo.MapKeys() { - var Child2 Reflect - Child2.SetByIndex(Current, &Child, index2, key2) - sm.Add(&Child2) - } - fmt.Println("") - } + // if strings.Contains(Child.FieldPath.String(), "DevTypeDefinition") { + // for index2, key2 := range Child.FieldVo.MapKeys() { + // var Child2 Reflect + // Child2.SetByIndex(Current, &Child, index2, key2) + // sm.Add(&Child2) + // } + // fmt.Println("") + // } if sm.Process(&Child) { continue @@ -191,14 +191,14 @@ func (sm *StructMap) ScanSlice(Parent *Reflect, Current *Reflect) bool { Child.SetByIndex(Parent, Current, index, reflect.Value{}) sm.PrintDebug("# ScanSlice().SetByIndex() Child: %s\n", Child) - if strings.Contains(Child.FieldPath.String(), "DevTypeDefinition") { - for index2, key2 := range Child.FieldVo.MapKeys() { - var Child2 Reflect - Child2.SetByIndex(Current, &Child, index2, key2) - sm.Add(&Child2) - } - fmt.Println("") - } + // if strings.Contains(Child.FieldPath.String(), "DevTypeDefinition") { + // for index2, key2 := range Child.FieldVo.MapKeys() { + // var Child2 Reflect + // Child2.SetByIndex(Current, &Child, index2, key2) + // sm.Add(&Child2) + // } + // fmt.Println("") + // } if sm.Process(&Child) { continue @@ -230,14 +230,14 @@ func (sm *StructMap) ScanStruct(Parent *Reflect, Current *Reflect) bool { Child.SetByIndex(Parent, Current, index, reflect.Value{}) sm.PrintDebug("# ScanStruct().SetByIndex() Child: %s\n", Child) - if strings.Contains(Child.FieldPath.String(), "DevTypeDefinition") { - for index2, key2 := range Child.FieldVo.MapKeys() { - var Child2 Reflect - Child2.SetByIndex(Current, &Child, index2, key2) - sm.Add(&Child2) - } - fmt.Println("") - } + // if strings.Contains(Child.FieldPath.String(), "DevTypeDefinition") { + // for index2, key2 := range Child.FieldVo.MapKeys() { + // var Child2 Reflect + // Child2.SetByIndex(Current, &Child, index2, key2) + // sm.Add(&Child2) + // } + // fmt.Println("") + // } if sm.Process(&Child) { continue @@ -859,6 +859,10 @@ func (sm *StructMap) GetTableData(name string) StructTable { refs = refs.AddRow(Child) } + if refs == nil { + break + } + if !isPivot { ret.Reflects = refs // ret.AddHeader(ret.Reflects[0]...) @@ -1108,7 +1112,7 @@ func (ta *StructTable) GetValues() StructValues { // addCol(name) // } // - // cm[name] = sub.Range(valueTypes.LoadOrder) + // cm[name] = sub.Range(valueTypes.SortOrder) // l := sub.Value.Length() // if l > length { // length = l @@ -1135,7 +1139,7 @@ func (ta *StructTable) GetValues() StructValues { // ta.Columns = sortMapByValues(colOrder) // cm := make(map[string][]valueTypes.UnitValue) - // cm[ta.Current.DataStructure.PointName] = ta.Current.Value.Range(valueTypes.LoadOrder) + // cm[ta.Current.DataStructure.PointName] = ta.Current.Value.Range(valueTypes.SortOrder) // length := ta.Current.Value.Length() // addCol("Key") // addCol("Value") @@ -1180,10 +1184,10 @@ func (ta *StructTable) GetValues() StructValues { } else { // addCol(name) // addCol("Units") - // cm[name] = sub.Value.Range(valueTypes.LoadOrder) + // cm[name] = sub.Value.Range(valueTypes.SortOrder) } - cm[name] = sub.Value.Range(valueTypes.LoadOrder) + cm[name] = sub.Value.Range(valueTypes.SortOrder) l := sub.Value.Length() if l > length { length = l @@ -1251,7 +1255,7 @@ func (ta *StructTable) GetValues() StructValues { if len(col.ChildReflect) > 0 { // Handles for _, sub := range col.ChildReflect { - for _, val := range sub.Value.Range(valueTypes.LoadOrder) { + for _, val := range sub.Value.Range(valueTypes.SortOrder) { name := colName(sub, &val, len(data)) data[name] = val addCol(name) @@ -1263,7 +1267,7 @@ func (ta *StructTable) GetValues() StructValues { if col.IsKnown() { value := ta.Reflects[rowIndex][colIndex].Value // data = append(data, value.Range(valueTypes.SortOrder)...) - for _, val := range value.Range(valueTypes.LoadOrder) { + for _, val := range value.Range(valueTypes.SortOrder) { name := colName(col, &val, len(data)) data[name] = val addCol(name) @@ -1279,7 +1283,7 @@ func (ta *StructTable) GetValues() StructValues { col.DataStructure.PointValueType, dateFormat) // data = append(data, value.Range(valueTypes.SortOrder)...) - for _, val := range value.Range(valueTypes.LoadOrder) { + for _, val := range value.Range(valueTypes.SortOrder) { name := colName(col, &val, len(data)) data[name] = val addCol(name) diff --git a/iSolarCloud/api/GoStruct/valueTypes/point.go b/iSolarCloud/api/GoStruct/valueTypes/point.go index cf8cc200b..784126046 100644 --- a/iSolarCloud/api/GoStruct/valueTypes/point.go +++ b/iSolarCloud/api/GoStruct/valueTypes/point.go @@ -2,6 +2,7 @@ package valueTypes import ( "encoding/json" + "fmt" "github.com/MickMake/GoUnify/Only" "regexp" "strconv" @@ -78,7 +79,12 @@ func (t *PsKey) Value() string { } func (t PsKey) String() string { - return t.string + // PsKey can only handle one. So strip the others out. + a := strings.Split(t.string, ",") + if len(a) == 0 { + return t.string + } + return a[0] } func (t *PsKey) Match(comp string) bool { @@ -101,11 +107,11 @@ func (t *PsKey) SetValue(value string) PsKey { s := strings.Split(value, "_") switch { - case len(s) == 1: - t.psId = s[0] - case len(s) >= 2: - t.psId = s[0] - t.deviceType = s[1] + case len(s) == 1: + t.psId = s[0] + case len(s) >= 2: + t.psId = s[0] + t.deviceType = s[1] } } @@ -120,7 +126,7 @@ func (t *PsKey) GetPsId() string { return t.psId } -func SetPsKeyValue(value string) PsKey { +func SetPsKeyString(value string) PsKey { var t PsKey return t.SetValue(value) } @@ -287,13 +293,12 @@ func (t *PsIds) Strings() []string { type PointId struct { - string `json:"string,omitempty"` - int64 `json:"integer,omitempty"` - isInt bool + // string `json:"string,omitempty"` + // int64 `json:"integer,omitempty"` + // isInt bool - // PointName String `json:"point_name"` - // PsId String `json:"ps_id"` - // PsKey String `json:"ps_key"` + Point string `json:"point"` + PsKey PsKey `json:"ps_key"` Valid bool `json:"valid"` Error error `json:"-"` @@ -308,21 +313,14 @@ func (t *PointId) UnmarshalJSON(data []byte) error { break } - // Store result from int - t.Error = json.Unmarshal(data, &t.int64) - if t.Error == nil { - t.SetValue(t.int64) + // pid := strings.TrimPrefix(string(data), "p") + var d string + t.Error = json.Unmarshal(data, &d) + if t.Error != nil { break } - // Store result from string - t.Error = json.Unmarshal(data, &t.string) - if t.Error == nil { - t.SetString(t.string) - break - } - - t.SetString(string(data)) + t.Set(d) } return t.Error @@ -333,39 +331,38 @@ func (t PointId) MarshalJSON() ([]byte, error) { var data []byte for range Only.Once { - if t.isInt { - data, t.Error = json.Marshal(t.int64) + t.Error = nil + if t.PsKey.String() != "" { + d := fmt.Sprintf(`"%s.%s"`, t.PsKey.String(), t.Point) + data = []byte(d) break } - - data, t.Error = json.Marshal(t.string) + data = []byte(t.Point) } return data, t.Error } -func (t PointId) Value() int64 { - return t.int64 -} - func (t PointId) String() string { - if t.isInt { - return "p" + t.string - } - return t.string + return t.Point } -func (t PointId) Match(comp int64) bool { - if t.int64 == comp { - return true - } - return false -} - -func (t *PointId) SetString(value string) PointId { +func (t *PointId) Full() string { + var ret string for range Only.Once { - t.string = value - t.int64 = 0 + if t.PsKey.String() != "" { + ret = fmt.Sprintf(`"%s.%s"`, t.PsKey.String(), t.Point) + break + } + ret = t.Point + } + return ret +} + +func (t *PointId) Set(value string) PointId { + for range Only.Once { + t.PsKey = PsKey{} + t.Point = "" t.Valid = false if value == "" { @@ -376,45 +373,48 @@ func (t *PointId) SetString(value string) PointId { // value = "" break } - t.Valid = true - var v int - v, t.Error = strconv.Atoi(t.string) - if t.Error != nil { - break - } - t.int64 = int64(v) - t.isInt = true - } - - return *t -} - -func (t *PointId) SetValue(value int64) PointId { - for range Only.Once { - t.string = "" - t.int64 = value - t.Valid = true - t.isInt = true - t.string = strconv.FormatInt(t.int64, 10) - } - - return *t -} - - -func (t *PointId) Fix() PointId { - for range Only.Once { - p := strings.TrimPrefix(t.string, "p") - _, t.Error = strconv.ParseInt(p, 10, 64) - if t.Error != nil { - t.Valid = false - break + a := strings.Split(value, ".") + switch { + case len(a) == 0: + case len(a) == 1: + t.Point = a[0] + t.Valid = true + case len(a) >= 2: + t.PsKey.SetValue(a[0]) + t.Point = a[1] + t.Valid = true } } + return *t } +// func (t *PointId) SetValue(value int64) PointId { +// for range Only.Once { +// t.string = "" +// t.int64 = value +// t.Valid = true +// t.isInt = true +// t.string = strconv.FormatInt(t.int64, 10) +// } +// +// return *t +// } + + +// func (t *PointId) Fix() PointId { +// for range Only.Once { +// p := strings.TrimPrefix(t.string, "p") +// _, t.Error = strconv.ParseInt(p, 10, 64) +// if t.Error != nil { +// t.Valid = false +// break +// } +// } +// return *t +// } + func (t *PointId) PointToName() string { return PointToName(t.String()) } @@ -459,10 +459,147 @@ func PointToName(ret string) string { func SetPointIdString(value string) PointId { var t PointId - return t.SetString(value) + return t.Set(value) } -func SetPointIdValue(value int64) PointId { - var t PointId - return t.SetValue(value) +// func SetPointIdValue(value int64) PointId { +// var t PointId +// return t.SetValue(value) +// } + + +type PsKeys struct { + PsKeys []PsKey `json:"ps_keys,omitempty"` + + Valid bool `json:"valid"` + Error error `json:"-"` +} + +// UnmarshalJSON - Convert JSON to value +func (t *PsKeys) UnmarshalJSON(data []byte) error { + for range Only.Once { + t.Valid = false + + if len(data) == 0 { + break + } + + var pid string + t.Error = json.Unmarshal(data, &pid) + if t.Error != nil { + break + } + + t.Set(strings.Split(pid, ",")...) + t.Valid = true + } + return t.Error +} + +// MarshalJSON - Convert value to JSON +func (t PsKeys) MarshalJSON() ([]byte, error) { + var a []string + for _, pid := range t.PsKeys { + a = append(a, pid.String()) + } + ret := `"` + strings.Join(a, ",") + `"` + + return []byte(ret), nil +} + +func (t PsKeys) String() string { + var ret string + for index := range t.PsKeys { + ret += t.PsKeys[index].String() + "," + } + ret = strings.TrimSuffix(ret, ",") + return ret +} + +func (t *PsKeys) Set(values ...string) PsKeys { + for _, value := range values { + for _, v := range strings.Split(value, ",") { + var pid PsKey + pid.SetValue(v) + t.PsKeys = append(t.PsKeys, pid) + } + } + + return *t +} + +func SetPsKeysString(values string) PsKeys { + var t PsKeys + t.Set(strings.Split(values, ",")...) + return t +} + + +type PointIds struct { + PointIds []PointId `json:"points,omitempty"` + + Valid bool `json:"valid"` + Error error `json:"-"` +} + +// UnmarshalJSON - Convert JSON to value +func (t *PointIds) UnmarshalJSON(data []byte) error { + for range Only.Once { + t.Valid = false + + if len(data) == 0 { + break + } + + var pid string + t.Error = json.Unmarshal(data, &pid) + if t.Error != nil { + break + } + + t.Set(strings.Split(pid, ",")...) + t.Valid = true + } + return t.Error +} + +// MarshalJSON - Convert value to JSON +func (t PointIds) MarshalJSON() ([]byte, error) { + var a []string + // Some endpoints can't handle the pskey, so we need to strip it out. + for _, pid := range t.PointIds { + a = append(a, pid.String()) + } + ret := `"` + strings.Join(a, ",") + `"` + + // Can't use this method as some endpoints can't handle the pskey. + // data, err := json.Marshal(t.PointIds) + return []byte(ret), nil +} + +func (t PointIds) String() string { + var ret string + for index := range t.PointIds { + ret += t.PointIds[index].String() + "," + } + ret = strings.TrimSuffix(ret, ",") + return ret +} + +func (t *PointIds) Set(values ...string) PointIds { + for _, value := range values { + for _, v := range strings.Split(value, ",") { + var pid PointId + pid.Set(v) + t.PointIds = append(t.PointIds, pid) + } + } + + return *t +} + +func SetPointIdsString(values string) PointIds { + var t PointIds + t.Set(strings.Split(values, ",")...) + return t } diff --git a/iSolarCloud/api/GoStruct/valueTypes/types.go b/iSolarCloud/api/GoStruct/valueTypes/types.go index 0606126af..4cbad47cc 100644 --- a/iSolarCloud/api/GoStruct/valueTypes/types.go +++ b/iSolarCloud/api/GoStruct/valueTypes/types.go @@ -472,12 +472,12 @@ func AnyToUnitValue(ref interface{}, key string, unit string, typeString string, case TypeGeneric: v := ref.(Generic) - uvs.AddFloat(key, unit, typeString, v.Value()) + uvs.AddString(key, unit, typeString, v.String()) case TypeArrayGeneric: v := ref.([]Generic) for _, val := range v { - uvs.AddFloat(key, unit, typeString, val.Value()) + uvs.AddString(key, unit, typeString, val.String()) } default: diff --git a/iSolarCloud/api/struct_data.go b/iSolarCloud/api/struct_data.go index e9e34edaa..660ddc4c3 100644 --- a/iSolarCloud/api/struct_data.go +++ b/iSolarCloud/api/struct_data.go @@ -740,7 +740,13 @@ func CreatePointDataEntries(Current *GoStruct.Reflect, parentDeviceId string, po sorted := Current.Value.Range(valueTypes.SortOrder) res := valueTypes.SizeOfInt(sorted) for i, uv := range sorted { - epn := JoinWithDots(res, valueTypes.DateTimeLayoutDay, Current.EndPointPath().String(), i) + var epn string + if uv.ValueKey() == "" { + epn = JoinWithDots(res, valueTypes.DateTimeLayoutDay, Current.EndPointPath().String(), i) + } else { + epn = JoinWithDots(res, valueTypes.DateTimeLayoutDay, Current.EndPointPath().String(), uv.ValueKey()) + } + ret.Entries = append(ret.Entries, DataEntry{ Current: Current, EndPoint: epn, // Current.EndPointPath().String(), diff --git a/iSolarCloud/data.go b/iSolarCloud/data.go index 33b3f0147..8e38322a9 100644 --- a/iSolarCloud/data.go +++ b/iSolarCloud/data.go @@ -101,20 +101,57 @@ func (sgd *SunGrowDataResponse) GetOutput(outputType output.OutputType, saveAsFi break } - if !outputType.IsTable() { + if outputType.IsXLSX() { + table := sgd.Data.CreateResultTable(false) + table.OutputType = outputType + table.SetSaveFile(saveAsFile) + table.AppendFilePrefix(sgd.Filename) + table.SetTitle(table.GetName() + " - " + sgd.Title) + sgd.Error = table.Output() break } - table := sgd.Data.CreateResultTable(false) - table.OutputType = outputType - table.SetSaveFile(saveAsFile) - table.AppendFilePrefix(sgd.Filename) - table.SetTitle(table.GetName() + " - " + sgd.Title) - sgd.Error = table.Output() - if sgd.Error != nil { - break + + if outputType.IsCsv() { + table := sgd.Data.CreateResultTable(false) + table.OutputType = outputType + table.SetSaveFile(saveAsFile) + table.AppendFilePrefix(sgd.Filename) + table.SetTitle(table.GetName() + " - " + sgd.Title) + sgd.Error = table.Output() + if sgd.Error != nil { + break + } + // break } + if outputType.IsXML() { + table := sgd.Data.CreateResultTable(false) + table.OutputType = outputType + table.SetSaveFile(saveAsFile) + table.AppendFilePrefix(sgd.Filename) + table.SetTitle(table.GetName() + " - " + sgd.Title) + sgd.Error = table.Output() + if sgd.Error != nil { + break + } + // break + } + + if outputType.IsTable() { + table := sgd.Data.CreateResultTable(false) + table.OutputType = outputType + table.SetSaveFile(saveAsFile) + table.AppendFilePrefix(sgd.Filename) + table.SetTitle(table.GetName() + " - " + sgd.Title) + sgd.Error = table.Output() + if sgd.Error != nil { + break + } + // break + } + + tables := sgd.Data.CreateDataTables() if len(tables) == 0 { fmt.Printf("No data table results for '%s'\n", sgd.Title) @@ -235,7 +272,7 @@ func (sgd *SunGrowData) SetPsIds(psids ...string) { } } -func (sgd *SunGrowData) GetData() error { +func (sgd *SunGrowData) GetData(args ...string) error { for range Only.Once { if len(sgd.endPoints) == 0 { sgd.Error = errors.New("need an endpoint") @@ -251,6 +288,8 @@ func (sgd *SunGrowData) GetData() error { } sgd.request.SetRequired(ep.GetRequestArgNames()) + sgd.SetArgs(args...) + // PsId not required. if sgd.request.IsPsIdNotRequired() { var result SunGrowDataResult @@ -277,9 +316,6 @@ func (sgd *SunGrowData) GetData() error { result.Request = sgd.request result.Request.SetPsId(psId.String()) - // result.Request.SetIfRequired(NamePsIds, psId.String()) - // result.Request.SetIfRequired(NameDay, "") - // result.Request.SetIfRequired(NameDateId, "") result.EndPointName = ep.GetName() result.EndPoint = ep diff --git a/iSolarCloud/data_request.go b/iSolarCloud/data_request.go index f3520232a..6f5dba2ff 100644 --- a/iSolarCloud/data_request.go +++ b/iSolarCloud/data_request.go @@ -38,7 +38,13 @@ type RequestArgs struct { Uuid *valueTypes.String `json:"uuid,omitempty"` TemplateId *valueTypes.String `json:"template_id,omitempty"` DeviceModelId *valueTypes.String `json:"device_model_id,omitempty"` - PsKey *valueTypes.PsKey `json:"ps_key,omitempty"` + + // Points + PsKeyList *valueTypes.String `json:"ps_key_list,omitempty"` + PsKeys *valueTypes.PsKeys `json:"-,omitempty"` // Used by queryMutiPointDataList + PsKey *valueTypes.PsKey `json:"ps_key,omitempty"` + Point *valueTypes.PointId `json:"point_id,omitempty"` + Points *valueTypes.PointIds `json:"points,omitempty"` // DateTime DateId *valueTypes.DateTime `json:"date_id,omitempty"` @@ -60,11 +66,8 @@ type RequestArgs struct { MinuteInterval *valueTypes.Integer `json:"minute_interval,omitempty"` OrderId *valueTypes.String `json:"order_id,omitempty"` OrgId *valueTypes.String `json:"org_id,omitempty"` - PointId *valueTypes.PointId `json:"point_id,omitempty"` - Points *valueTypes.String `json:"points,omitempty"` Prefix *valueTypes.String `json:"prefix,omitempty"` PrimaryKey *valueTypes.String `json:"primaryKey,omitempty"` - PsKeyList *valueTypes.String `json:"ps_key_list,omitempty"` QueryType *valueTypes.String `json:"query_type,omitempty"` Sn *valueTypes.String `json:"sn,omitempty"` Table *valueTypes.String `json:"table,omitempty"` @@ -120,7 +123,12 @@ const ( NameUuid = "Uuid" NameTemplateId = "TemplateId" NameDeviceModelId = "DeviceModelId" + + NamePsKeyList = "PsKeyList" + NamePsKeys = "PsKeys" NamePsKey = "PsKey" + NamePointId = "PointId" + NamePoints = "Points" // DateTime NameDateId = "DateId" @@ -142,11 +150,8 @@ const ( NameMinuteInterval = "MinuteInterval" NameOrderId = "OrderId" NameOrgId = "OrgId" - NamePointId = "PointId" - NamePoints = "Points" NamePrefix = "Prefix" NamePrimaryKey = "PrimaryKey" - NamePsKeyList = "PsKeyList" NameQueryType = "QueryType" NameSn = "Sn" NameTable = "Table" @@ -172,7 +177,11 @@ var Help = map[string]string{ NameUuid: "Uuid - ", NameTemplateId: "TemplateId - ", NameDeviceModelId: "DeviceModelId - ", + + NamePsKeyList: "PsKeyList - ", NamePsKey: "PsKey - ", + NamePointId: "PointId - ", + NamePoints: "Points - ", // DateTime NameDateId: "DateId - Date in format YYYYMMDD or YYYYMM or YYYY", @@ -194,11 +203,8 @@ var Help = map[string]string{ NameMinuteInterval: "MinuteInterval - ", NameOrderId: "OrderId - ", NameOrgId: "OrgId - ", - NamePointId: "PointId - ", - NamePoints: "Points - ", NamePrefix: "Prefix - ", NamePrimaryKey: "PrimaryKey - ", - NamePsKeyList: "PsKeyList - ", NameQueryType: "QueryType - ", NameSn: "Sn - ", NameTable: "Table - ", @@ -218,6 +224,14 @@ func (sgd SunGrowDataRequest) MarshalJSON() ([]byte, error) { dt = &sgd.args.DateId.DateType } + if sgd.IsRequired(NamePsKeys) { + // queryMutiPointDataList - expects multiple pskeys separated by comma. + // getDevicePointMinuteDataList - expects a single pskey. + pskey := valueTypes.SetPsKeyString(sgd.args.PsKeys.String()) + sgd.args.PsKey = &pskey + sgd.args.PsKeys = nil + } + type Parse RequestArgs // Store result from string data, err = json.Marshal(Parse { @@ -237,7 +251,13 @@ func (sgd SunGrowDataRequest) MarshalJSON() ([]byte, error) { Uuid: sgd.args.Uuid, TemplateId: sgd.args.TemplateId, DeviceModelId: sgd.args.DeviceModelId, + + // Points + PsKeyList: sgd.args.PsKeyList, PsKey: sgd.args.PsKey, + PsKeys: sgd.args.PsKeys, + Point: sgd.args.Point, + Points: sgd.args.Points, // DateTime DateId: sgd.args.DateId, @@ -259,11 +279,8 @@ func (sgd SunGrowDataRequest) MarshalJSON() ([]byte, error) { MinuteInterval: sgd.args.MinuteInterval, OrderId: sgd.args.OrderId, OrgId: sgd.args.OrgId, - PointId: sgd.args.PointId, - Points: sgd.args.Points, Prefix: sgd.args.Prefix, PrimaryKey: sgd.args.PrimaryKey, - PsKeyList: sgd.args.PsKeyList, QueryType: sgd.args.QueryType, Sn: sgd.args.Sn, Table: sgd.args.Table, @@ -316,8 +333,19 @@ func (sgd *SunGrowDataRequest) Set(arg string, value string) { val := valueTypes.SetStringValue(value); sgd.args.TemplateId = &val case NameDeviceModelId: val := valueTypes.SetStringValue(value); sgd.args.DeviceModelId = &val + + // Points + case NamePsKeyList: + val := valueTypes.SetStringValue(value); sgd.args.PsKeyList = &val + case NamePsKeys: + val := valueTypes.SetPsKeysString(value); sgd.args.PsKeys = &val case NamePsKey: - val := valueTypes.SetPsKeyValue(value); sgd.args.PsKey = &val + val := valueTypes.SetPsKeyString(value); sgd.args.PsKey = &val + case NamePointId: + val := valueTypes.SetPointIdString(value); sgd.args.Point = &val + case NamePoints: + sgd.SetPoints(value) + // val := valueTypes.SetPointIdsString(value); sgd.args.Points = &val // DateTime case NameDateId: @@ -354,16 +382,10 @@ func (sgd *SunGrowDataRequest) Set(arg string, value string) { val := valueTypes.SetStringValue(value); sgd.args.OrderId = &val case NameOrgId: val := valueTypes.SetStringValue(value); sgd.args.OrgId = &val - case NamePointId: - val := valueTypes.SetPointIdString(value); sgd.args.PointId = &val - case NamePoints: - val := valueTypes.SetStringValue(value); sgd.args.Points = &val case NamePrefix: val := valueTypes.SetStringValue(value); sgd.args.Prefix = &val case NamePrimaryKey: val := valueTypes.SetStringValue(value); sgd.args.PrimaryKey = &val - case NamePsKeyList: - val := valueTypes.SetStringValue(value); sgd.args.PsKeyList = &val case NameQueryType: val := valueTypes.SetStringValue(value); sgd.args.QueryType = &val case NameSn: @@ -416,8 +438,18 @@ func (sgd *SunGrowDataRequest) Get(arg string) string { value = sgd.args.TemplateId.String() case NameDeviceModelId: value = sgd.args.DeviceModelId.String() + + // Points + case NamePsKeyList: + value = sgd.args.PsKeyList.String() + case NamePsKeys: + value = sgd.args.PsKeys.String() case NamePsKey: value = sgd.args.PsKey.String() + case NamePointId: + value = sgd.args.Point.String() + case NamePoints: + value = sgd.args.Points.String() // DateTime @@ -455,16 +487,10 @@ func (sgd *SunGrowDataRequest) Get(arg string) string { value = sgd.args.OrderId.String() case NameOrgId: value = sgd.args.OrgId.String() - case NamePointId: - value = sgd.args.PointId.String() - case NamePoints: - value = sgd.args.Points.String() case NamePrefix: value = sgd.args.Prefix.String() case NamePrimaryKey: value = sgd.args.PrimaryKey.String() - case NamePsKeyList: - value = sgd.args.PsKeyList.String() case NameQueryType: value = sgd.args.QueryType.String() case NameSn: @@ -522,8 +548,19 @@ func (sgd *SunGrowDataRequest) IsSet(arg string) bool { if sgd.args.TemplateId != nil { ok = true } case NameDeviceModelId: if sgd.args.DeviceModelId != nil { ok = true } + + + // Points + case NamePsKeyList: + if sgd.args.PsKeyList != nil { ok = true } + case NamePsKeys: + if sgd.args.PsKeys != nil { ok = true } case NamePsKey: if sgd.args.PsKey != nil { ok = true } + case NamePointId: + if sgd.args.Point != nil { ok = true } + case NamePoints: + if sgd.args.Points != nil { ok = true } // UNVERIFIED @@ -553,16 +590,10 @@ func (sgd *SunGrowDataRequest) IsSet(arg string) bool { if sgd.args.OrderId != nil { ok = true } case NameOrgId: if sgd.args.OrgId != nil { ok = true } - case NamePointId: - if sgd.args.PointId != nil { ok = true } - case NamePoints: - if sgd.args.Points != nil { ok = true } case NamePrefix: if sgd.args.Prefix != nil { ok = true } case NamePrimaryKey: if sgd.args.PrimaryKey != nil { ok = true } - case NamePsKeyList: - if sgd.args.PsKeyList != nil { ok = true } case NameQueryType: if sgd.args.QueryType != nil { ok = true } case NameSn: @@ -890,6 +921,29 @@ func (sgd *SunGrowDataRequest) SetPsId(psId string) { } } +func (sgd *SunGrowDataRequest) SetPoints(points string) { + for range Only.Once { + pids := valueTypes.SetPointIdsString(points) + if pids.Error != nil { + fmt.Printf("Error: %s - %s\n", NamePsId, sgd.args.Points.Error) + break + } + + var pskeys []string + for _, pskey := range pids.PointIds { + pskeys = append(pskeys, pskey.PsKey.String()) + } + sgd.args.Points = &pids + psk := valueTypes.SetPsKeysString(strings.Join(pskeys, ",")) + if sgd.IsRequired(NamePsKey) { + sgd.args.PsKey = &psk.PsKeys[0] + } + if sgd.IsRequired(NamePsKeys) { + sgd.args.PsKeys = &psk + } + } +} + func (sgd *SunGrowDataRequest) IsRequired(req string) bool { var yes bool if _, ok := sgd.Required[req]; ok { diff --git a/iSolarCloud/highlevel.go b/iSolarCloud/highlevel.go index 13b735ba7..f0a48669a 100644 --- a/iSolarCloud/highlevel.go +++ b/iSolarCloud/highlevel.go @@ -1,7 +1,6 @@ package iSolarCloud import ( - "github.com/MickMake/GoUnify/Only" "GoSungrow/iSolarCloud/AppService/getDeviceList" "GoSungrow/iSolarCloud/AppService/getDeviceModelInfoList" "GoSungrow/iSolarCloud/AppService/getHouseholdStoragePsReport" @@ -23,6 +22,7 @@ import ( "GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "errors" "fmt" + "github.com/MickMake/GoUnify/Only" "math" "strings" "time" @@ -94,14 +94,14 @@ func (sg *SunGrow) GetTemplateData(template string, date string, filter string) break } - pskeys := valueTypes.SetPsKeyValue(pointNames.PrintKeys()) + pskeys := valueTypes.SetPsKeyString(pointNames.PrintKeys()) ep := sg.GetByStruct( "AppService.queryMutiPointDataList", queryMutiPointDataList.RequestData { // PsId: api.SetIntegerValue(psId), PsId: psId, - PsKey: pskeys, - Points: valueTypes.SetStringValue(pointNames.PrintPoints()), // @TODO - Fixup! + PsKeys: pskeys, + Points: valueTypes.SetPointIdsString(pointNames.PrintPoints()), // @TODO - Fixup! MinuteInterval: valueTypes.SetIntegerValue(5), StartTimeStamp: valueTypes.SetStringValue(when.GetDayStartTimestamp()), // @TODO - Fixup! EndTimeStamp: valueTypes.SetStringValue(when.GetDayEndTimestamp()), // @TODO - Fixup! @@ -111,25 +111,28 @@ func (sg *SunGrow) GetTemplateData(template string, date string, filter string) if sg.IsError() { break } + if ep == nil { + break + } // data := queryMutiPointDataList.AssertResultData(ep) - data := queryMutiPointDataList.Assert(ep) - data.GetData() - table := data.GetPointDataTable(pointNames) - if table.Error != nil { - sg.Error = table.Error - break - } - - table.SetTitle("Template %s on %s for %d", template, when.String(), psId) - table.SetFilePrefix(data.SetFilenamePrefix("%s-%s-%d", when.String(), template, psId)) - table.SetGraphFilter(filter) - table.SetSaveFile(sg.SaveAsFile) - table.OutputType = sg.OutputType - sg.Error = table.Output() - if sg.IsError() { - break - } + // data := queryMutiPointDataList.Assert(ep) + // data.GetData() + // table := data.GetPointDataTable(pointNames) + // if table.Error != nil { + // sg.Error = table.Error + // break + // } + // + // table.SetTitle("Template %s on %s for %d", template, when.String(), psId) + // table.SetFilePrefix(data.SetFilenamePrefix("%s-%s-%d", when.String(), template, psId)) + // table.SetGraphFilter(filter) + // table.SetSaveFile(sg.SaveAsFile) + // table.OutputType = sg.OutputType + // sg.Error = table.Output() + // if sg.IsError() { + // break + // } } } @@ -521,34 +524,37 @@ func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints, psId "AppService.queryMutiPointDataList", queryMutiPointDataList.RequestData{ PsId: psId, - PsKey: valueTypes.SetPsKeyValue(pointNames.PrintKeys()), // @TODO - Fixup! - Points: valueTypes.SetStringValue(pointNames.PrintPoints()), // @TODO - Fixup! - MinuteInterval: valueTypes.SetIntegerValue(5), // @TODO - Fixup! - StartTimeStamp: valueTypes.SetStringValue(when.GetDayStartTimestamp()), // @TODO - Fixup! - EndTimeStamp: valueTypes.SetStringValue(when.GetDayEndTimestamp()), // @TODO - Fixup! + PsKeys: valueTypes.SetPsKeyString(pointNames.PrintKeys()), // @TODO - Fixup! + Points: valueTypes.SetPointIdsString(pointNames.PrintPoints()), // @TODO - Fixup! + MinuteInterval: valueTypes.SetIntegerValue(5), // @TODO - Fixup! + StartTimeStamp: valueTypes.SetStringValue(when.GetDayStartTimestamp()), // @TODO - Fixup! + EndTimeStamp: valueTypes.SetStringValue(when.GetDayEndTimestamp()), // @TODO - Fixup! }, DefaultCacheTimeout, ) if sg.IsError() { break } - - data := queryMutiPointDataList.Assert(ep) - table := data.GetPointDataTable(pointNames) - if table.Error != nil { - sg.Error = table.Error + if ep == nil { break } - table.SetTitle("Point Data %s", psId) - table.SetFilePrefix(data.SetFilenamePrefix("%d", psId)) - table.SetGraphFilter("") - table.SetSaveFile(sg.SaveAsFile) - table.OutputType = sg.OutputType - sg.Error = table.Output() - if sg.IsError() { - break - } + // data := queryMutiPointDataList.Assert(ep) + // table := data.GetPointDataTable(pointNames) + // if table.Error != nil { + // sg.Error = table.Error + // break + // } + // + // table.SetTitle("Point Data %s", psId) + // table.SetFilePrefix(data.SetFilenamePrefix("%d", psId)) + // table.SetGraphFilter("") + // table.SetSaveFile(sg.SaveAsFile) + // table.OutputType = sg.OutputType + // sg.Error = table.Output() + // if sg.IsError() { + // break + // } } } @@ -1072,7 +1078,7 @@ func (sg *SunGrow) GetDevices(print bool) (getDeviceList.Devices, error) { ret = append(ret, getDeviceList.Device{ Vendor: valueTypes.SetStringValue(""), PsId: psId.PsId, - PsKey: valueTypes.SetPsKeyValue(psId.PsId.String()), + PsKey: valueTypes.SetPsKeyString(psId.PsId.String()), DeviceName: psId.PsName, DeviceProSn: psId.PsShortName, DeviceModel: valueTypes.SetStringValue(""),