Skip to content

Commit

Permalink
v2.3.2 - Refactor #2
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Oct 28, 2022
1 parent 19351d5 commit 6711382
Show file tree
Hide file tree
Showing 92 changed files with 2,151 additions and 3,399 deletions.
1,283 changes: 196 additions & 1,087 deletions .idea/workspace.xml

Large diffs are not rendered by default.

42 changes: 8 additions & 34 deletions cmd/cmd_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package cmd
import (
"GoSungrow/Only"
"GoSungrow/iSolarCloud/api/output"
"GoSungrow/iSolarCloud/api/valueTypes"
"fmt"
"github.com/MickMake/GoUnify/cmdConfig"
"github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra"
"strings"
Expand Down Expand Up @@ -222,41 +220,17 @@ const (
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.Use)
args = cmdConfig.FillArray(5, args)
cmds.Api.SunGrow.SetOutputType(cmd.Name())

for i := range args {
if args[i] == "." {
args[i] = ""
}
}

var e []string
if args[argEndpoints] != "" {
e = SplitArg(args[argEndpoints])
}

var p []valueTypes.Integer
for _, psId := range SplitArg(args[argPsIds]) {
if psId == "" {
continue
}
p = append(p, valueTypes.SetIntegerString(psId))
}

d := valueTypes.SetDateTimeString(args[argDate])

rt := args[argReportType]
if rt == "" {
rt = "1"
}

ftc := args[argFaultTypeCode]
// if ftc == "" {
// ftc = "1"
// args = cmdConfig.FillArray(5, args)
// for i := range args {
// if args[i] == "." {
// args[i] = ""
// }
// }
// c.Error = cmds.Api.SunGrow.GetEndpoints(SplitArg(args[argEndpoints]), SplitArg(args[argPsIds]), args[argDate], args[argReportType], args[argFaultTypeCode])

c.Error = cmds.Api.SunGrow.GetEndpoints(e, p, *d, rt, ftc)
c.Error = cmds.Api.SunGrow.GetEndpoints(SplitArg(args[argEndpoints]), args[1:]...)
}

return c.Error
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (ca *Cmds) MqttCron() error {
}

for _, endpoint := range All {
response := data.GetByApi(endpoint, iSolarCloud.SunGrowDataRequest{ PsId: psId })
response := data.GetByEndPointName(endpoint, iSolarCloud.SunGrowDataRequest{ PsId: &psId })
ca.Error = ca.Update(endpoint, response.Data, newDay)
if ca.Error != nil {
break
Expand Down
2 changes: 1 addition & 1 deletion iSolarCloud/AppService/findCodeValueList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Url = "/v1/commonService/findCodeValueList"
const Disabled = false

type RequestData struct {
CodeType string `json:"code_type" required:"true"`
CodeType valueTypes.String `json:"code_type" required:"true"`
}

func (rd RequestData) IsValid() error {
Expand Down
10 changes: 3 additions & 7 deletions iSolarCloud/AppService/findPsType/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Url = "/v1/powerStationService/findPsType"
const Disabled = false

type RequestData struct {
PsId valueTypes.Integer `json:"ps_id" required:"true"`
PsId valueTypes.PsId `json:"ps_id" required:"true"`
}

func (rd RequestData) IsValid() error {
Expand Down Expand Up @@ -46,12 +46,8 @@ func (e *EndPoint) GetData() api.DataMap {
for range Only.Once {
pkg := apiReflect.GetName("", *e)
dt := valueTypes.NewDateTime(valueTypes.Now)
entries.StructToPoints(e.Response.ResultData, pkg, e.Request.PsId.String(), dt)

// for _, d := range e.Response.ResultData {
// name := fmt.Sprintf("%s.%s", pkg, e.Request.PsId.String())
// entries.StructToPoints(d, name, e.Request.PsId.String(), dt)
// }
name := pkg + "." + e.Request.PsId.String()
entries.StructToPoints(e.Response.ResultData, name, e.Request.PsId.String(), dt)
}

return entries
Expand Down
2 changes: 1 addition & 1 deletion iSolarCloud/AppService/getAllDeviceByPsId/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Url = "/v1/devService/getAllDeviceByPsId"
const Disabled = false

type RequestData struct {
PsId valueTypes.Integer `json:"ps_id" required:"true"`
PsId valueTypes.PsId `json:"ps_id" required:"true"`
}

func (rd RequestData) IsValid() error {
Expand Down
2 changes: 1 addition & 1 deletion iSolarCloud/AppService/getAllPowerDeviceSetName/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (rd RequestData) Help() string {

type ResultData []struct {
Remark string `json:"remark"`
SetID valueTypes.Integer `json:"set_id"`
SetId valueTypes.Integer `json:"set_id"`
SetName string `json:"set_name"`
}

Expand Down
4 changes: 2 additions & 2 deletions iSolarCloud/AppService/getAreaList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ResultData struct {
FaultStationCount valueTypes.Integer `json:"fault_station_count"`
IsHaveEsPs valueTypes.Bool `json:"is_have_es_ps"`
IsLeaf valueTypes.Bool `json:"is_leaf"`
OrgID valueTypes.Integer `json:"org_id"`
OrgId valueTypes.Integer `json:"org_id"`
OrgName valueTypes.String `json:"org_name"`
P83048 valueTypes.UnitValue `json:"p83048"`
P83049 valueTypes.UnitValue `json:"p83049"`
Expand All @@ -38,7 +38,7 @@ type ResultData struct {
StationCount valueTypes.Integer `json:"station_count"`
TodayEnergy valueTypes.UnitValue `json:"today_energy"`
TotalEnergy valueTypes.UnitValue `json:"total_energy"`
} `json:"pageList" PointId:"page_list" PointNameFromChild:"OrgID" PointNameFromAppend:"false"`
} `json:"pageList" PointId:"page_list" PointNameFromChild:"OrgId" PointNameFromAppend:"false"`
RowCount valueTypes.Integer `json:"rowCount" PointIgnore:"true"`
}

Expand Down
2 changes: 1 addition & 1 deletion iSolarCloud/AppService/getChnnlListByPsId/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Url = "/v1/devService/getChnnlListByPsId"
const Disabled = false

type RequestData struct {
PsId valueTypes.Integer `json:"ps_id" required:"true"`
PsId valueTypes.PsId `json:"ps_id" required:"true"`
}

func (rd RequestData) IsValid() error {
Expand Down
8 changes: 4 additions & 4 deletions iSolarCloud/AppService/getCloudList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func (rd RequestData) Help() string {

type ResultData struct {
CloudList []struct {
CloudID valueTypes.Integer `json:"cloud_id"`
CloudId valueTypes.Integer `json:"cloud_id"`
CloudName string `json:"cloud_name"`
GatewayURL string `json:"gateway_url"`
OrderID valueTypes.Integer `json:"order_id"`
OrderId valueTypes.Integer `json:"order_id"`
ServiceURL string `json:"service_url"`
Value string `json:"value"`
ValueDeDe string `json:"value_de_de"`
Expand All @@ -49,10 +49,10 @@ type ResultData struct {
WebURL string `json:"web_url"`
} `json:"cloud_list"`
CurrentCloud struct {
CloudID valueTypes.Integer `json:"cloud_id"`
CloudId valueTypes.Integer `json:"cloud_id"`
CloudName string `json:"cloud_name"`
GatewayURL string `json:"gateway_url"`
OrderID valueTypes.Integer `json:"order_id"`
OrderId valueTypes.Integer `json:"order_id"`
ServiceURL string `json:"service_url"`
Value string `json:"value"`
ValueDeDe string `json:"value_de_de"`
Expand Down
22 changes: 11 additions & 11 deletions iSolarCloud/AppService/getDeviceList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Url = "/v1/devService/getDeviceList"
const Disabled = false

type RequestData struct {
PsId valueTypes.Integer `json:"ps_id" required:"true"`
PsId valueTypes.PsId `json:"ps_id" required:"true"`
}

func (rd RequestData) IsValid() error {
Expand All @@ -38,7 +38,7 @@ type ResultData struct {
DeviceArea valueTypes.Integer `json:"device_area"`
DeviceCode valueTypes.Integer `json:"device_code"`
DeviceFactoryDate valueTypes.DateTime `json:"device_factory_date"`
DeviceID valueTypes.Integer `json:"device_id"`
DeviceId valueTypes.Integer `json:"device_id"`
DeviceModel valueTypes.String `json:"device_model"`
DeviceModelCode valueTypes.String `json:"device_model_code"`
DeviceModelId valueTypes.Integer `json:"device_model_id"`
Expand All @@ -65,7 +65,7 @@ type ResultData struct {
P24 interface{} `json:"p24"`
Posx interface{} `json:"posx"`
Posy interface{} `json:"posy"`
PsId valueTypes.Integer `json:"ps_id"`
PsId valueTypes.PsId `json:"ps_id"`
PsKey valueTypes.PsKey `json:"ps_key"`
RelState valueTypes.Integer `json:"rel_state"`
Sn valueTypes.String `json:"sn" PointName:"Serial Number"`
Expand All @@ -88,15 +88,15 @@ func (e *ResultData) IsValid() error {

type Device struct {
Vendor valueTypes.String
PsId valueTypes.Integer
PsId valueTypes.PsId
PsKey valueTypes.PsKey
DeviceName valueTypes.String
DeviceProSn valueTypes.String
DeviceModel valueTypes.String
DeviceType valueTypes.Integer
DeviceCode valueTypes.Integer
ChannelId valueTypes.Integer
DeviceModelID valueTypes.Integer
DeviceModelId valueTypes.Integer
TypeName valueTypes.String
DeviceState valueTypes.Integer
DevStatus valueTypes.Integer
Expand All @@ -117,7 +117,7 @@ func (e *EndPoint) GetDevices() Devices {
TypeName: d.TypeName,
DeviceProSn: d.DeviceProSn,
DeviceModel: d.DeviceModel,
DeviceModelID: d.DeviceModelId,
DeviceModelId: d.DeviceModelId,
DeviceName: d.DeviceName,
DeviceState: d.DeviceState,
DevStatus: d.DevStatus,
Expand Down Expand Up @@ -153,14 +153,14 @@ func (e *EndPoint) GetDevicesTable() output.Table {
// for _, d := range e.Response.ResultData.PageList {
// _ = table.AddRow(
// d.PsKey.Value(),
// d.PsID.Value(),
// d.PsId.Value(),
// d.DeviceType.Value(),
// d.DeviceCode.Value(),
// d.ChannelId.Value(),
// d.TypeName.Value(),
// d.DeviceProSn.Value(),
// d.DeviceModel.Value(),
// d.DeviceModelID.Value(),
// d.DeviceModelId.Value(),
// d.DeviceName.Value(),
// d.DeviceState,
// d.DevStatus,
Expand Down Expand Up @@ -200,14 +200,14 @@ func GetDevicesTable(data Devices) output.Table {
// for _, d := range e.Response.ResultData.PageList {
// _ = table.AddRow(
// d.PsKey.Value(),
// d.PsID.Value(),
// d.PsId.Value(),
// d.DeviceType.Value(),
// d.DeviceCode.Value(),
// d.ChannelId.Value(),
// d.TypeName.Value(),
// d.DeviceProSn.Value(),
// d.DeviceModel.Value(),
// d.DeviceModelID.Value(),
// d.DeviceModelId.Value(),
// d.DeviceName.Value(),
// d.DeviceState,
// d.DevStatus,
Expand Down Expand Up @@ -247,7 +247,7 @@ func GetDevicesTable(data Devices) output.Table {
d.TypeName.Value(),
d.DeviceProSn.Value(),
d.DeviceModel.Value(),
d.DeviceModelID.Value(),
d.DeviceModelId.Value(),
d.DeviceName.Value(),
d.DeviceState,
d.DevStatus,
Expand Down
10 changes: 5 additions & 5 deletions iSolarCloud/AppService/getDeviceModelInfoList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package getDeviceModelInfoList
import (
"GoSungrow/iSolarCloud/api"
"GoSungrow/iSolarCloud/api/apiReflect"
"GoSungrow/iSolarCloud/api/valueTypes"
"GoSungrow/iSolarCloud/api/output"
"GoSungrow/iSolarCloud/api/valueTypes"
"fmt"
"github.com/MickMake/GoUnify/Only"
)
Expand All @@ -27,11 +27,11 @@ func (rd RequestData) Help() string {

type ResultData []struct {
ComType string `json:"com_type"`
DeviceFactoryID string `json:"device_factory_id"`
DeviceFactoryId string `json:"device_factory_id"`
DeviceFactoryName string `json:"device_factory_name"`
DeviceModel string `json:"device_model"`
DeviceModelCode string `json:"device_model_code"`
DeviceModelID valueTypes.Integer `json:"device_model_id"`
DeviceModelId valueTypes.Integer `json:"device_model_id"`
DeviceType valueTypes.Integer `json:"device_type"`
IsRemoteUpgrade valueTypes.Bool `json:"is_remote_upgrade"`
}
Expand Down Expand Up @@ -89,10 +89,10 @@ func (e *EndPoint) GetPointDataTable() output.Table {
d.DeviceModelCode = ""
}
_ = table.AddRow(
d.DeviceModelID,
d.DeviceModelId,
d.DeviceType,
d.ComType,
d.DeviceFactoryID,
d.DeviceFactoryId,
d.DeviceFactoryName,
d.DeviceModel,
d.DeviceModelCode,
Expand Down
2 changes: 1 addition & 1 deletion iSolarCloud/AppService/getDeviceTypeList/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (rd RequestData) Help() string {

type ResultData struct {
DeviceTypeList []struct {
DevListOrderID valueTypes.Integer `json:"dev_list_order_id"`
DevListOrderId valueTypes.Integer `json:"dev_list_order_id"`
DeviceType valueTypes.Integer `json:"device_type"`
TypeName valueTypes.String `json:"type_name"`
} `json:"deviceTypeList"`
Expand Down
4 changes: 2 additions & 2 deletions iSolarCloud/AppService/getFaultMsgListWithYYYYMM/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type ResultData []struct {
FaultReason valueTypes.String `json:"fault_reason"`
FaultType valueTypes.Integer `json:"fault_type"`
FaultTypeCode valueTypes.Integer `json:"fault_type_code"`
ID valueTypes.Integer `json:"id"`
PsID valueTypes.Integer `json:"ps_id"`
Id valueTypes.Integer `json:"id"`
PsId valueTypes.PsId `json:"ps_id"`
PsKey valueTypes.PsKey `json:"ps_key"`
UUID valueTypes.Integer `json:"uuid"`
}
Expand Down
2 changes: 1 addition & 1 deletion iSolarCloud/AppService/getHistoryInfo/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Disabled = false

type RequestData struct {
DateType string `json:"date_type" required:"true"`
DateID string `json:"date_id" required:"true"`
DateId string `json:"date_id" required:"true"`
}

func (rd RequestData) IsValid() error {
Expand Down
Loading

0 comments on commit 6711382

Please sign in to comment.