v3.0.0-alpha - tidy ups

This commit is contained in:
MickMake 2022-11-20 09:09:48 +11:00
parent 583f6f16dc
commit 8659a64ad8
7 changed files with 173 additions and 77 deletions

112
.idea/workspace.xml generated
View File

@ -6,11 +6,12 @@
<component name="ChangeListManager">
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getInstallerInfoByDealerOrgCodeOrId/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getInstallerInfoByDealerOrgCodeOrId/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getPowerDeviceSetTaskList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getPowerDeviceSetTaskList/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -84,7 +85,7 @@
<configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="GoSungrow" />
<working_directory value="$PROJECT_DIR$" />
<parameters value="data list AppService.getSysMsg" />
<parameters value="data table getUpTimePoint" />
<envs>
<env name="GOCACHE" value="/Volumes/Media/GoCache" />
</envs>
@ -326,11 +327,6 @@
<line>52</line>
<option name="timeStamp" value="3787" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>407</line>
<option name="timeStamp" value="3848" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>91</line>
@ -486,11 +482,6 @@
<line>85</line>
<option name="timeStamp" value="5873" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>817</line>
<option name="timeStamp" value="5907" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>148</line>
@ -526,16 +517,6 @@
<line>250</line>
<option name="timeStamp" value="5999" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>411</line>
<option name="timeStamp" value="6019" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>1002</line>
<option name="timeStamp" value="6037" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>776</line>
@ -556,11 +537,6 @@
<line>620</line>
<option name="timeStamp" value="6085" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>612</line>
<option name="timeStamp" value="6096" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>632</line>
@ -581,31 +557,11 @@
<line>846</line>
<option name="timeStamp" value="6103" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>261</line>
<option name="timeStamp" value="6110" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go</url>
<line>291</line>
<option name="timeStamp" value="6115" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go</url>
<line>606</line>
<option name="timeStamp" value="6186" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>389</line>
<option name="timeStamp" value="6202" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1029</line>
<option name="timeStamp" value="6221" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>62</line>
@ -616,6 +572,66 @@
<line>90</line>
<option name="timeStamp" value="6233" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>110</line>
<option name="timeStamp" value="6258" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>108</line>
<option name="timeStamp" value="6259" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>113</line>
<option name="timeStamp" value="6260" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1092</line>
<option name="timeStamp" value="6267" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1120</line>
<option name="timeStamp" value="6268" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1103</line>
<option name="timeStamp" value="6269" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1046</line>
<option name="timeStamp" value="6278" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_data.go</url>
<line>210</line>
<option name="timeStamp" value="6290" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1003</line>
<option name="timeStamp" value="6302" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1095</line>
<option name="timeStamp" value="6305" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1083</line>
<option name="timeStamp" value="6306" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/structmap.go</url>
<line>1087</line>
<option name="timeStamp" value="6307" />
</line-breakpoint>
</breakpoints>
<default-breakpoints>
<breakpoint type="DlvErrorBreakpoint" />

View File

@ -38,7 +38,7 @@ type ResultData struct {
UserId valueTypes.Integer `json:"user_id"`
UserName valueTypes.String `json:"user_name"`
UserTelNationCode interface{} `json:"user_tel_nation_code"`
} `json:"user_info_list" DataTable:"true" DataTable:"true"`
} `json:"user_info_list" DataTable:"true"`
}
func (e *ResultData) IsValid() error {

View File

@ -27,14 +27,21 @@ func (rd RequestData) Help() string {
type ResultData struct {
PageList []struct {
GoStruct GoStruct.GoStruct `json:"GoStruct" PointDeviceFrom:"PsId"`
GoStruct GoStruct.GoStruct `json:"GoStruct" PointIdFrom:"TaskId" PointIdReplace:"true" PointDeviceFrom:"PsId"`
TaskId valueTypes.Integer `json:"task_id"`
TaskType valueTypes.Integer `json:"task_type"`
TaskName valueTypes.String `json:"task_name"`
UUID valueTypes.Integer `json:"uuid"`
PsId valueTypes.PsId `json:"ps_id"`
UserEnglishName interface{} `json:"user_english_name"`
UserName valueTypes.String `json:"user_name"`
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"`
OperateUserId valueTypes.Integer `json:"operate_user_id"`
UpdateTime valueTypes.DateTime `json:"update_time"`
OverTime valueTypes.DateTime `json:"over_time"`
PsId valueTypes.PsId `json:"ps_id"`
SetCancelNum valueTypes.Count `json:"set_cancel_num"`
SetFailNum valueTypes.Count `json:"set_fail_num"`
SetFinishNum valueTypes.Count `json:"set_finish_num"`
@ -42,15 +49,8 @@ type ResultData struct {
SetSuccessNum valueTypes.Count `json:"set_success_num"`
SetTotalNum valueTypes.Count `json:"set_total_num"`
SweepDevParamSetType valueTypes.Integer `json:"sweep_dev_param_set_type"`
TaskId valueTypes.Integer `json:"task_id"`
TaskName valueTypes.String `json:"task_name"`
TaskType valueTypes.Integer `json:"task_type"`
TemplateType valueTypes.Integer `json:"template_type"`
UpdateTime valueTypes.DateTime `json:"update_time"`
UserEnglishName interface{} `json:"user_english_name"`
UserName valueTypes.String `json:"user_name"`
UUID valueTypes.Integer `json:"uuid"`
} `json:"pageList" PointId:"page_list" PointIdFromChild:"PsId.CreateTime" PointIdReplace:"true" DataTable:"true"`
} `json:"pageList" PointId:"page_list" PointIdFromChild:"PsId" PointIdReplace:"true" DataTable:"true"`
RowCount valueTypes.Integer `json:"rowCount" PointId:"row_count"`
}

View File

@ -291,7 +291,7 @@ func (t *Table) WriteList() error {
}
if t.saveAsFile {
t.Error = t.writeFile(t.filePrefix + ".txt", t.String(), DefaultFileMode)
t.Error = t.writeFile(t.filePrefix + "-list.txt", t.String(), DefaultFileMode)
break
}
fmt.Printf("# %s\n", t.title)

View File

@ -771,7 +771,15 @@ func (sm *StructMap) GetTableData(name string) StructTable {
if len(refRow) > 0 {
refs = refs.AddRow(refRow...)
continue
}
// Single column.
ret.ShowIndex = true
if Child.IsPointIgnore() {
continue
}
refs = refs.AddRow(Child)
}
if !ret.Current.DataStructure.DataTablePivot {
@ -790,7 +798,6 @@ func (sm *StructMap) GetTableData(name string) StructTable {
ret.Reflects = ret.Reflects.AddRow(refRow...)
}
}
// ret.AddHeader(ret.Reflects[0]...)
}
return ret
@ -967,6 +974,7 @@ func (ta *StructTable) GetValues() StructValues {
colOrder := make(map[string]int)
var colOrderIndex int
var addCol = func(name string) {
if _, ok := colOrder[name]; !ok {
colOrder[name] = colOrderIndex
@ -992,6 +1000,58 @@ func (ta *StructTable) GetValues() StructValues {
return name
}
if len(ta.Reflects) == 1 {
// Probs an array of values.
cm := make(map[string][]valueTypes.UnitValue)
var length int
if ta.ShowIndex {
addCol(ta.IndexTitle)
}
for _, sub := range ta.Reflects[0] {
name := sub.DataStructure.PointName
switch sub.Value.Unit() {
case "--":
case "":
default:
name += " (" + sub.Value.Unit() + ")"
}
addCol(name)
cm[name] = sub.Value.Range(valueTypes.LoadOrder)
l := sub.Value.Length()
if l > length {
length = l
}
}
for index := 0; index < length; index++ {
data := make(StructValue)
if ta.ShowIndex {
vi := valueTypes.SetUnitValueInteger(int64(index), ta.IndexTitle, "")
data[ta.IndexTitle] = vi
}
for name, value := range cm {
if index >= len(value) {
data[name] = valueTypes.UnitValue{}
}
data[name] = value[index]
}
ret = append(ret, data)
}
ta.Columns = sortMapByValues(colOrder)
break
}
if ta.ShowIndex {
addCol(ta.IndexTitle)
}
for rowIndex := range ta.Reflects {
// fmt.Printf("ROW[%d] - size:%d\n", rowIndex, len(ta.Reflects[rowIndex]))
data := make(StructValue)
@ -1016,7 +1076,6 @@ func (ta *StructTable) GetValues() StructValues {
if ta.ShowIndex {
vi := valueTypes.SetUnitValueInteger(int64(rowIndex), ta.IndexTitle, "")
data[ta.IndexTitle] = vi
addCol(ta.IndexTitle)
}
for colIndex, col := range ta.Reflects[rowIndex] {

View File

@ -700,6 +700,14 @@ func (t *UnitValues) SetUnit(unit string) *UnitValues {
return t
}
func (t *UnitValues) Get(index int) *UnitValue {
if len(t.order) == 0 {
return &UnitValue{}
}
return t.order[0]
}
func (t *UnitValues) First() *UnitValue {
if len(t.order) == 0 {
return &UnitValue{}
@ -717,17 +725,31 @@ func (t *UnitValues) Last() *UnitValue {
return t.order[last]
}
func (t *UnitValues) nextKey() string {
return strconv.Itoa(len(t.values))
// nextKey - Generates the next key in the sequence. If we're given one, use it OR use an index.
func (t *UnitValues) nextKey(key string) string {
for range Only.Once {
if key == "" {
// Empty - assume the next index as the key.
key = strconv.Itoa(len(t.values))
break
}
val, err := strconv.Atoi(strings.TrimPrefix(key, "INDEX:"))
if err != nil {
// Probs not an integer.
break
}
// @TODO - Could be potentially dangerous.
key = "INDEX:" + strconv.Itoa(len(t.values) + val)
}
return key
}
// add - Simulate an array, but we're storing everything as a map.
// Makes it easier to code, not having to deal with either array or map.
func (t *UnitValues) add(value UnitValue) *UnitValues {
key := value.key
if key == "" {
key = t.nextKey()
}
key := t.nextKey(value.key)
t.order = append(t.order, &value) // Keep track of the order.
if t.values == nil {
t.values = make(map[string]UnitValue)
@ -741,10 +763,6 @@ func (t *UnitValues) Append(uvs ...UnitValues) *UnitValues {
for key, v := range uv.values {
v.key = key
t.add(v)
// if key == "" {
// key = t.nextKey()
// }
// t.values[key] = v
}
}
return t

View File

@ -208,13 +208,16 @@ func (dm *DataMap) CreateResultTable(endpoint EndPoint, sm GoStruct.StructMap, f
}
}
var title string
// var title string
// title = sm.Name.String()
// title = valueTypes.PointToName(sm.Start.DataStructure.DataTableId)
// title = valueTypes.PointToName(sm.Start.DataStructure.DataTableName)
// ret.SetTitle("EndPoint Data: %s.%s", endpoint.GetArea(), endpoint.GetName())
ret.SetTitle("EndPoint Data %s - %s", sm.Name.String(), title)
// ret.SetFilePrefix("%s_%s", endpoint.GetArea(), endpoint.GetName())
ret.SetTitle("EndPoint Data %s", sm.Name.String())
if sm.Start.DataStructure.DataTableName != "" {
ret.SetTitle("EndPoint Data %s - %s", sm.Name.String(), sm.Start.DataStructure.DataTableName)
}
ret.SetFilePrefix(sm.Name.String())
ret.SetGraphFilter("")
ret.Sort("Point Id")
@ -555,7 +558,7 @@ func CreatePointDataEntries(Current *GoStruct.Reflect, parentDeviceId string, po
// res := valueTypes.SizeOfArrayLength(Current.Value.Length())
// res := Current.Value.Length()
sorted := Current.Value.Range(valueTypes.SortOrder)
res := len(sorted)
res := valueTypes.SizeOfInt(sorted)
for i, uv := range sorted {
epn := JoinWithDots(res, valueTypes.DateTimeLayoutDay, Current.EndPointPath().String(), i)
ret.Entries = append(ret.Entries, DataEntry{