Browse Source

Merge branch 'bzq1/execl-edit_conflict' of eta_server/eta_api into debug

鲍自强 9 months ago
parent
commit
75cec661a0

+ 1 - 1
controllers/ppt_v2.go

@@ -739,8 +739,8 @@ func (this *PptV2Controller) SaveLog() {
 	pptItem.PptDate = req.FirstPage.PptDate
 	pptItem.Content = req.Content
 	pptItem.ModifyTime = time.Now()
-	pptItem.PptPage = len(pptContent)
 	pptItem.TitleSetting = req.TitleSetting
+	pptItem.PptPage = len(pptContent)
 
 	err = pptItem.Update([]string{"TemplateType", "BackgroundImg", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "ppt_page", "TitleSetting"})
 

+ 21 - 4
controllers/target.go

@@ -18,9 +18,6 @@ import (
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
-	"github.com/shopspring/decimal"
-	"github.com/tealeg/xlsx"
 	"os"
 	"path/filepath"
 	"reflect"
@@ -28,6 +25,10 @@ import (
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"github.com/shopspring/decimal"
+	"github.com/tealeg/xlsx"
 )
 
 // TargetController 手工指标服务(鉴权)
@@ -2548,7 +2549,7 @@ func (this *TargetController) TargetItemList() {
 	classifyId, _ := this.GetInt("ClassifyId")
 	edbShowType, _ := this.GetInt("EdbShowType")
 
-	list, err := models.GetTargetItemList(classifyId, edbShowType, frequency, keyword, tradeCode, classifyIdStrList)
+	list, err := models.GetTargetItemListSort(classifyId, edbShowType, frequency, keyword, tradeCode, classifyIdStrList)
 	if err != nil {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		br.Msg = "获取失败"
@@ -3772,6 +3773,14 @@ func (this *TargetController) ExcelDataAdd() {
 							targetMap[secName] = target
 						}
 					}
+					// 判断指标的顺序是否发生改变
+					if targetMap[secName].Sort != i {
+						edbinfo := models.Edbinfo{TradeCode: target.TradeCode, Sort: i}
+						er := edbinfo.Update([]string{"sort"})
+						if er != nil {
+							fmt.Println("sort update err:", er.Error())
+						}
+					}
 
 					//判断指标数据是否已经存在
 					tmpDataMap, ok2 := edbCodeDataMap[target.TradeCode]
@@ -3877,6 +3886,14 @@ func (this *TargetController) ExcelDataAdd() {
 				}
 			}
 		}
+
+		list, err := models.GetTargetItemList(req.ClassifyId, 1, req.Frequency, "", "", []string{})
+		if err != nil {
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			br.Msg = "获取失败"
+			return
+		}
+		fmt.Println(list)
 	}
 
 	//resp := models.TargetItemListResp{

+ 1 - 1
models/ppt_english/ppt_english.go

@@ -26,7 +26,7 @@ type PptEnglish struct {
 	IsShare       int8      `description:"是否分享,0:不分享,1:分享"`
 	PublishTime   time.Time `description:"发布时间"`
 	CoverContent  string    `description:"PPT内容-JSON"`
-	PptPage       int       `description:"PPT正文页数"`
+	PptPage       int       `description:"PPT页数"`
 	TitleSetting  string    `description:"PPT标题设置"`
 }
 

+ 2 - 2
models/ppt_v2.go

@@ -29,7 +29,7 @@ type PptV2 struct {
 	IsShare       int8      `description:"是否分享,0:不分享,1:分享"`
 	PublishTime   time.Time `description:"发布时间"`
 	CoverContent  string    `description:"PPT内容-JSON"`
-	PptPage       int       `description:"PPT的总页数"`
+	PptPage       int       `description:"PPT页数"`
 	TitleSetting  string    `description:"PPT标题设置"`
 }
 
@@ -54,7 +54,7 @@ type PptV2Item struct {
 	IsShare       int8      `description:"是否分享,0:不分享,1:分享"`
 	PublishTime   time.Time `description:"发布时间"`
 	CoverContent  string    `description:"PPT内容-JSON"`
-	PptPage       int       `description:"PPT的总页数"`
+	PptPage       int       `description:"PPT页数"`
 	TitleSetting  string    `description:"PPT标题设置"`
 }
 

+ 63 - 2
models/target.go

@@ -4,12 +4,13 @@ import (
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"sort"
 	"strconv"
 	"strings"
 	"time"
+
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 type DataList struct {
@@ -150,6 +151,7 @@ type Edbinfo struct {
 	UserName     string `description:"录入用户名称"`
 	NoticeTime   string `description:"通知时间"`
 	Mobile       string `description:"录入者手机号"`
+	Sort         int    `description:"排序"`
 }
 
 func GetEdbinfoListCount(condition string, pars []interface{}, mobile string, roleType int) (count int, err error) {
@@ -275,6 +277,14 @@ func AddEdbinfo(tradeCode, secName, unit, remark, frequency, noticeTime string,
 	return
 }
 
+func AddEdbinfoV2(tradeCode, secName, unit, remark, frequency, noticeTime string, classifyId int, userId, sort int) (err error) {
+	sql := `INSERT INTO edbinfo(TRADE_CODE, SEC_NAME,UNIT, REMARK,frequency, classify_id,notice_time,user_id,create_date, sort) 
+			VALUES(?,?,?,?,?,?,?,?,now(), ?) `
+	o := orm.NewOrmUsingDB("edb")
+	_, err = o.Raw(sql, tradeCode, secName, unit, remark, frequency, classifyId, noticeTime, userId, sort).Exec()
+	return
+}
+
 func AddEdbinfoUser(tradeCode, mobile string) (err error) {
 	o := orm.NewOrmUsingDB("edb")
 	sql := `INSERT INTO edbinfo_user(TRADE_CODE, mobile) VALUES (?,?)`
@@ -1243,6 +1253,57 @@ left join edbdata b on a.TRADE_CODE=b.TRADE_CODE `
 
 }
 
+// GetTargetItemList 获取指标列表数据
+func GetTargetItemListSort(classifyId, edbShowType int, frequency, keyword, tradeCode string, classifyIdStrList []string) (items []*EdbInfoItem, err error) {
+	o := orm.NewOrmUsingDB("edb")
+
+	pars := make([]interface{}, 0)
+
+	sql := ` SELECT a.*,'' modify_date,'' STATUS FROM edbinfo AS a `
+	if edbShowType != 0 {
+		sql = ` SELECT a.*,b.DT,'' modify_date,'' STATUS FROM edbinfo AS a 
+left join edbdata b on a.TRADE_CODE=b.TRADE_CODE `
+	}
+	sql += ` WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
+
+	//如果没有分类id集合列表,那么就没有数据了,不用往下执行了,直接返回好了
+	if len(classifyIdStrList) <= 0 {
+		return
+	}
+	if len(classifyIdStrList) > 0 {
+		sql += ` AND a.classify_id in (` + strings.Join(classifyIdStrList, ",") + `)  `
+	}
+	if classifyId > 0 {
+		sql += ` AND a.classify_id=` + strconv.Itoa(classifyId) + ` `
+	}
+	//频度
+	if frequency != "" {
+		sql += ` AND a.frequency="` + frequency + `" `
+	}
+	//关键字
+	if keyword != "" {
+		sql += ` AND (a.SEC_NAME like ?  or a.TRADE_CODE like ? )`
+		pars = utils.GetLikeKeywordPars(pars, keyword, 2)
+	}
+	//指定指标
+	if tradeCode != "" {
+		sql += ` AND a.TRADE_CODE = "` + tradeCode + `" `
+	}
+	//指标里面是否有数据
+	switch edbShowType {
+	case 1:
+		sql += ` AND b.CLOSE is not null `
+	case 2:
+		sql += ` AND b.CLOSE is null `
+	}
+	sql += ` GROUP BY a.TRADE_CODE `
+
+	sql = sql + ` ORDER BY sort ASC, CONVERT(a.SEC_NAME USING gbk )  COLLATE gbk_chinese_ci ASC `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+
+}
+
 // GetLzItemList 模糊查询隆众数据库指标列表
 func GetLzItemList(keyword string) (items []*data_manage.LongzhongSurveyProduct, err error) {
 	o := orm.NewOrmUsingDB("edb")

+ 0 - 1
services/ppt/ppt_group.go

@@ -1588,7 +1588,6 @@ func GetMyPptList(adminId int, keyword string) (ret models.RespGroupPptList, err
 	if len(pptList) <= 0 {
 		return
 	}
-
 	var pptContent []services.PPTContent
 	for _, v := range pptList {
 		if v.PptPage == 0 && v.Content != "" {