|
@@ -2,6 +2,7 @@ package excel
|
|
|
|
|
|
import (
|
|
|
"eta/eta_api/models/data_manage/excel"
|
|
|
+ "eta/eta_api/models/data_manage/excel/request"
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
"sort"
|
|
@@ -106,42 +107,42 @@ func handleCellVal(tmpTableColData LuckySheetDataValue) (valueStr string) {
|
|
|
}
|
|
|
|
|
|
// HandleRuleToTableCell 根据管理规则渲染单元格数据
|
|
|
-func HandleRuleToTableCell(excelInfoId int, oldTableData TableData) (newTableData TableData, err error) {
|
|
|
- newTableData = oldTableData
|
|
|
- excelRuleMappingList, err := excel.GetExcelRuleMappingByExcelInfoId(excelInfoId)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- if len(excelRuleMappingList) == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- tableDataList := oldTableData.TableDataList
|
|
|
- excelRuleMap := make(map[int]*excel.ExcelInfoRuleMappingView)
|
|
|
- for _, v := range excelRuleMappingList {
|
|
|
- excelRuleMap[v.ExcelInfoRuleMappingId] = v
|
|
|
- }
|
|
|
- ruleScopeMap := generateRuleScopeIndexMap(excelRuleMappingList)
|
|
|
- for row, scopeValues := range ruleScopeMap {
|
|
|
- for col, ruleId := range scopeValues {
|
|
|
- if v, ok := excelRuleMap[ruleId]; ok {
|
|
|
- if len(tableDataList) > row && len(tableDataList[row]) > col {
|
|
|
- // 符合管理规则要求,则进行字体和背景颜色的渲染
|
|
|
- if checkCellRule(v, tableDataList[row][col].Monitor, tableDataList) {
|
|
|
- tableDataList[row][col].Background = v.BackgroundColor
|
|
|
- tableDataList[row][col].FontColor = v.FontColor
|
|
|
- }
|
|
|
- } else {
|
|
|
- continue
|
|
|
- }
|
|
|
- } else {
|
|
|
- continue
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
+// func HandleRuleToTableCell(excelInfoId int, oldTableData TableData) (newTableData TableData, err error) {
|
|
|
+// newTableData = oldTableData
|
|
|
+// excelRuleMappingList, err := excel.GetExcelRuleMappingByExcelInfoId(excelInfoId)
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if len(excelRuleMappingList) == 0 {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// tableDataList := oldTableData.TableDataList
|
|
|
+// excelRuleMap := make(map[int]*excel.ExcelInfoRuleMappingView)
|
|
|
+// for _, v := range excelRuleMappingList {
|
|
|
+// excelRuleMap[v.ExcelInfoRuleMappingId] = v
|
|
|
+// }
|
|
|
+// ruleScopeMap := generateRuleScopeIndexMap(excelRuleMappingList)
|
|
|
+// for row, scopeValues := range ruleScopeMap {
|
|
|
+// for col, ruleId := range scopeValues {
|
|
|
+// if v, ok := excelRuleMap[ruleId]; ok {
|
|
|
+// if len(tableDataList) > row && len(tableDataList[row]) > col {
|
|
|
+// // 符合管理规则要求,则进行字体和背景颜色的渲染
|
|
|
+// if checkCellRule(v, tableDataList[row][col].Monitor, tableDataList) {
|
|
|
+// tableDataList[row][col].Background = v.BackgroundColor
|
|
|
+// tableDataList[row][col].FontColor = v.FontColor
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// continue
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// continue
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
|
|
|
-func getCellValueByType(value string, valueType int, tableDataList [][]LuckySheetDataValue) (float64, bool) {
|
|
|
+func getCellValueByType(value string, valueType int, tableDataList [][]request.MixedTableCellDataReq) (float64, bool) {
|
|
|
if valueType == 2 {
|
|
|
coords := strings.Split(value, ",")
|
|
|
var coordIntArr []int
|
|
@@ -151,7 +152,7 @@ func getCellValueByType(value string, valueType int, tableDataList [][]LuckyShee
|
|
|
}
|
|
|
if len(coordIntArr) == 2 {
|
|
|
x, y := coordIntArr[0]-1, coordIntArr[1]-1
|
|
|
- conditionValue, err := strconv.ParseFloat(tableDataList[y][x].Monitor, 64)
|
|
|
+ conditionValue, err := strconv.ParseFloat(tableDataList[y][x].ShowValue, 64)
|
|
|
if err != nil {
|
|
|
return 0, false
|
|
|
}
|
|
@@ -167,7 +168,7 @@ func getCellValueByType(value string, valueType int, tableDataList [][]LuckyShee
|
|
|
return 0, false
|
|
|
}
|
|
|
|
|
|
-func checkCellRule(ruleInfo *excel.ExcelInfoRuleMappingView, value string, tableDataList [][]LuckySheetDataValue) bool {
|
|
|
+func checkCellRule(ruleInfo *excel.ExcelInfoRuleMappingView, value string, tableDataList [][]request.MixedTableCellDataReq) bool {
|
|
|
var tableValue float64
|
|
|
var tableTime time.Time
|
|
|
var err error
|
|
@@ -292,8 +293,8 @@ func checkCellRule(ruleInfo *excel.ExcelInfoRuleMappingView, value string, table
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-func generateRuleScopeIndexMap(items []*excel.ExcelInfoRuleMappingView) (ruleScopeMap map[int]map[int]int) {
|
|
|
- ruleScopeMap = make(map[int]map[int]int)
|
|
|
+func generateRuleScopeIndexMap(items []*excel.ExcelInfoRuleMappingView) (ruleScopeMap map[int]map[int][]int) {
|
|
|
+ ruleScopeMap = make(map[int]map[int][]int)
|
|
|
for _, item := range items {
|
|
|
coords := strings.Split(item.ScopeCoord, ",")
|
|
|
var coordIntArr []int
|
|
@@ -307,18 +308,20 @@ func generateRuleScopeIndexMap(items []*excel.ExcelInfoRuleMappingView) (ruleSco
|
|
|
for i := ymin; i <= ymax; i++ {
|
|
|
for j := xmin; j <= xmax; j++ {
|
|
|
if _, ok := ruleScopeMap[i]; !ok {
|
|
|
- ruleScopeMap[i] = make(map[int]int)
|
|
|
+ ruleScopeMap[i] = make(map[int][]int)
|
|
|
}
|
|
|
- ruleScopeMap[i][j] = item.ExcelInfoRuleMappingId
|
|
|
+ ruleScopeMap[i][j] = append(ruleScopeMap[i][j], item.ExcelInfoRuleMappingId)
|
|
|
+ // ruleScopeMap[i][j] = item.ExcelInfoRuleMappingId
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if len(coords) == 2 {
|
|
|
x, y := coordIntArr[0]-1, coordIntArr[1]-1
|
|
|
if _, ok := ruleScopeMap[y]; !ok {
|
|
|
- ruleScopeMap[y] = make(map[int]int)
|
|
|
+ ruleScopeMap[y] = make(map[int][]int)
|
|
|
}
|
|
|
- ruleScopeMap[y][x] = item.ExcelInfoRuleMappingId
|
|
|
+ ruleScopeMap[y][x] = append(ruleScopeMap[y][x], item.ExcelInfoRuleMappingId)
|
|
|
+ // ruleScopeMap[y][x] = item.ExcelInfoRuleMappingId
|
|
|
}
|
|
|
}
|
|
|
return
|