Browse Source

Merge remote-tracking branch 'origin/eta/1.0.2' into debug

# Conflicts:
#	controllers/data_manage/excel/excel_info.go
Roc 1 year ago
parent
commit
9e15c1e3bc

+ 56 - 2
controllers/data_manage/excel/custom_analysis.go

@@ -67,7 +67,23 @@ func (c *CustomAnalysisController) ExcelByName() {
 	}
 
 	resp.IsFind = true
-	resp.ExcelInfo = excelDetail
+	resp.ExcelInfo = response.FindExcelInfo{
+		ExcelInfoId:     excelDetail.ExcelInfoId,
+		Source:          excelDetail.Source,
+		ExcelType:       excelDetail.ExcelType,
+		ExcelName:       excelDetail.ExcelName,
+		UniqueCode:      excelDetail.UniqueCode,
+		ExcelClassifyId: excelDetail.ExcelClassifyId,
+		SysUserId:       excelDetail.SysUserId,
+		SysUserRealName: excelDetail.SysUserRealName,
+		ExcelImage:      excelDetail.ExcelImage,
+		FileUrl:         excelDetail.FileUrl,
+		Sort:            excelDetail.Sort,
+		ModifyTime:      excelDetail.ModifyTime,
+		CreateTime:      excelDetail.CreateTime,
+		Button:          excel.GetExcelInfoOpButton(sysUser, excelDetail.SysUserId, excelDetail.Source),
+	}
+
 	if excelDetail != nil {
 		sheetList, err := excelModel.GetAllSheetItemList(excelDetail.ExcelInfoId)
 		if err != nil {
@@ -137,6 +153,29 @@ func (c *CustomAnalysisController) Add() {
 		return
 	}
 
+	// 获取是否存在该表格名称
+	{
+		var condition string
+		var pars []interface{}
+		condition += " AND source=? "
+		pars = append(pars, utils.CUSTOM_ANALYSIS_TABLE)
+
+		condition += " AND excel_name=? "
+		pars = append(pars, req.ExcelName)
+
+		count, err := excelModel.GetExcelInfoCountByCondition(condition, pars)
+		if err != nil {
+			br.Msg = "判断表格名称是否存在失败"
+			br.ErrMsg = "判断表格名称是否存在失败,Err:" + err.Error()
+			return
+		}
+		if count > 0 {
+			br.Msg = "表格名称已存在,请重新填写表格名称"
+			br.IsSendEmail = false
+			return
+		}
+	}
+
 	if req.ExcelClassifyId <= 0 {
 		br.Msg = "分类参数错误!"
 		br.IsSendEmail = false
@@ -357,7 +396,22 @@ func (c *CustomAnalysisController) BaseExcelDetail() {
 	}
 
 	resp.IsFind = true
-	resp.ExcelInfo = excelDetail
+	resp.ExcelInfo = response.FindExcelInfo{
+		ExcelInfoId:     excelDetail.ExcelInfoId,
+		Source:          excelDetail.Source,
+		ExcelType:       excelDetail.ExcelType,
+		ExcelName:       excelDetail.ExcelName,
+		UniqueCode:      excelDetail.UniqueCode,
+		ExcelClassifyId: excelDetail.ExcelClassifyId,
+		SysUserId:       excelDetail.SysUserId,
+		SysUserRealName: excelDetail.SysUserRealName,
+		ExcelImage:      excelDetail.ExcelImage,
+		FileUrl:         excelDetail.FileUrl,
+		Sort:            excelDetail.Sort,
+		ModifyTime:      excelDetail.ModifyTime,
+		CreateTime:      excelDetail.CreateTime,
+		Button:          excel.GetExcelInfoOpButton(sysUser, excelDetail.SysUserId, excelDetail.Source),
+	}
 	if excelDetail != nil {
 		sheetList, err := excelModel.GetAllSheetItemList(excelDetail.ExcelInfoId)
 		if err != nil {

+ 6 - 6
controllers/data_manage/excel/excel_classify.go

@@ -6,7 +6,7 @@ import (
 	"eta/eta_api/models"
 	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/data_manage/excel/request"
-	"eta/eta_api/models/data_manage/response"
+	response2 "eta/eta_api/models/data_manage/excel/response"
 	excel2 "eta/eta_api/services/data/excel"
 	"eta/eta_api/utils"
 	"strconv"
@@ -84,7 +84,7 @@ func (this *ExcelClassifyController) List() {
 		v.Children = items
 		nodeAll = append(nodeAll, v)
 	}
-	resp := response.ExcelClassifyListResp{
+	resp := response2.ExcelClassifyListResp{
 		AllNodes: nodeAll,
 	}
 	br.Ret = 200
@@ -116,7 +116,7 @@ func (this *ExcelClassifyController) ExcelClassifyItems() {
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
-	resp := response.ExcelClassifyListResp{
+	resp := response2.ExcelClassifyListResp{
 		AllNodes: rootList,
 	}
 	br.Ret = 200
@@ -354,7 +354,7 @@ func (this *ExcelClassifyController) DeleteExcelClassifyCheck() {
 		tipsMsg = "可删除,进行删除操作"
 	}
 
-	resp := response.ExcelClassifyDeleteCheckResp{
+	resp := response2.ExcelClassifyDeleteCheckResp{
 		DeleteStatus: deleteStatus,
 		TipsMsg:      tipsMsg,
 	}
@@ -434,7 +434,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 		}
 	}
 
-	resp := response.AddExcelInfoResp{}
+	resp := response2.AddExcelInfoResp{}
 	//删除表格
 	if req.ExcelInfoId > 0 {
 		excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
@@ -503,7 +503,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 
 			// 如果找到下一个表格了,那么就返回
 			if nextItem != nil {
-				resp = response.AddExcelInfoResp{
+				resp = response2.AddExcelInfoResp{
 					ExcelInfoId: nextItem.ExcelInfoId,
 					UniqueCode:  nextItem.UniqueCode,
 				}

+ 1 - 1
controllers/data_manage/excel/excel_info.go

@@ -8,7 +8,7 @@ import (
 	"eta/eta_api/models/data_manage"
 	excel3 "eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/data_manage/excel/request"
-	"eta/eta_api/models/data_manage/response"
+	"eta/eta_api/models/data_manage/excel/response"
 	"eta/eta_api/services"
 	"eta/eta_api/services/alarm_msg"
 	"eta/eta_api/services/data"

+ 0 - 0
models/data_manage/response/excel_classify.go → models/data_manage/excel/response/excel_classify.go


+ 7 - 5
models/data_manage/response/excel_info.go → models/data_manage/excel/response/excel_info.go

@@ -70,9 +70,11 @@ type ExcelInfoDetail struct {
 
 // ExcelInfoDetailButton 操作按钮
 type ExcelInfoDetailButton struct {
-	RefreshButton  bool `description:"是否可编辑"`
-	CopyButton     bool `description:"是否可另存为"`
-	DownloadButton bool `description:"是否可下载"`
-	OpButton       bool `description:"是否可编辑"`
-	DeleteButton   bool `description:"是否可删除"`
+	RefreshButton    bool `description:"是否可刷新"`
+	CopyButton       bool `description:"是否可另存为"`
+	DownloadButton   bool `description:"是否可下载"`
+	OpButton         bool `description:"是否可编辑"`
+	DeleteButton     bool `description:"是否可删除"`
+	OpEdbButton      bool `description:"是否可生成指标"`
+	RefreshEdbButton bool `description:"是否可刷新指标"`
 }

+ 20 - 7
models/data_manage/excel/response/sheet.go

@@ -2,17 +2,30 @@ package response
 
 import (
 	"eta/eta_api/models/data_manage/excel"
+	"time"
 )
 
 // FindExcelInfoResp 根据名称获取excel的信息
 type FindExcelInfoResp struct {
-	IsFind    bool                   `description:"是否存在同名文件"`
-	ExcelInfo *excel.MyExcelInfoList `description:"图表详情"`
-	SheetList []*excel.SheetItem     `description:"sheet列表"`
+	IsFind    bool               `description:"是否存在同名文件"`
+	ExcelInfo FindExcelInfo      `description:"表格详情"`
+	SheetList []*excel.SheetItem `description:"sheet列表"`
 }
 
-// AddExcelInfoResp 添加excel表格的返回
-type AddExcelInfoResp struct {
-	ExcelInfoId int    `description:"表格id"`
-	UniqueCode  string `description:"表格唯一编码"`
+// FindExcelInfo excel的数据详情
+type FindExcelInfo struct {
+	ExcelInfoId     int                   `orm:"column(excel_info_id);pk"`
+	Source          int                   `description:"表格来源,1:excel插件的表格,2:自定义表格,默认:1"`
+	ExcelType       int                   `description:"表格类型,1:指标列,2:日期列,默认:1"`
+	ExcelName       string                `description:"表格名称"`
+	UniqueCode      string                `description:"表格唯一编码"`
+	ExcelClassifyId int                   `description:"表格分类id"`
+	SysUserId       int                   `description:"操作人id"`
+	SysUserRealName string                `description:"操作人真实姓名"`
+	ExcelImage      string                `description:"表格图片"`
+	FileUrl         string                `description:"表格下载地址"`
+	Sort            int                   `description:"排序字段,数字越小越排前面"`
+	ModifyTime      time.Time             `description:"最近修改日期"`
+	CreateTime      time.Time             `description:"创建日期"`
+	Button          ExcelInfoDetailButton `description:"操作权限"`
 }

+ 8 - 2
services/data/excel/excel_info.go

@@ -6,7 +6,7 @@ import (
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/data_manage/excel/request"
-	"eta/eta_api/models/data_manage/response"
+	"eta/eta_api/models/data_manage/excel/response"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
@@ -92,7 +92,7 @@ func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int) (butt
 	button.CopyButton = true
 	button.DownloadButton = true
 
-	if source == 1 {
+	if source == utils.EXCEL_DEFAULT {
 		button.OpButton = true
 	}
 
@@ -103,6 +103,12 @@ func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int) (butt
 		button.DeleteButton = true
 	}
 
+	// 自定义分析
+	if source == utils.CUSTOM_ANALYSIS_TABLE {
+		button.OpEdbButton = true      // 生成、查看指标按钮
+		button.RefreshEdbButton = true // 刷新指标按钮
+	}
+
 	return
 }