|
@@ -2109,7 +2109,7 @@ func (this *TargetController) TargetItemList() {
|
|
|
classifyId, _ := this.GetInt("ClassifyId")
|
|
|
edbShowType, _ := this.GetInt("EdbShowType")
|
|
|
|
|
|
- list, err := models.GetTargetItemListSort(classifyId, edbShowType, frequency, keyword, tradeCode, classifyIdStrList)
|
|
|
+ list, err := models.GetTargetItemList(classifyId, edbShowType, frequency, keyword, tradeCode, classifyIdStrList)
|
|
|
if err != nil {
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
br.Msg = "获取失败"
|
|
@@ -3333,14 +3333,6 @@ 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]
|
|
@@ -3446,14 +3438,6 @@ 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{
|
|
@@ -3466,309 +3450,6 @@ func (this *TargetController) ExcelDataAdd() {
|
|
|
//br.Data = list
|
|
|
}
|
|
|
|
|
|
-// ExcelDataAdd
|
|
|
-// @Title 复制EXCEL数据保存
|
|
|
-// @Description 复制EXCEL数据保存
|
|
|
-// @Param request body models.ExcelStyleReq true "type json string"
|
|
|
-// @Success 200
|
|
|
-//// @router /target/excel_style/add [post]
|
|
|
-// func (this *TargetController) ExcelDataAdd() {
|
|
|
-// br := new(models.BaseResponse).Init()
|
|
|
-// var err error
|
|
|
-// errs := make([]string, 0)
|
|
|
-// defer func() {
|
|
|
-// if len(errs) > 0 {
|
|
|
-// go alarm_msg.SendAlarmMsg("新增复制EXCEL数据 新增或修改数据失败,Err:"+strings.Join(errs, ","), 3)
|
|
|
-// }
|
|
|
-// this.Data["json"] = br
|
|
|
-// this.ServeJSON()
|
|
|
-// }()
|
|
|
-
|
|
|
-// sysUser := this.SysUser
|
|
|
-// if sysUser == nil {
|
|
|
-// br.Msg = "请重新登录"
|
|
|
-// return
|
|
|
-// }
|
|
|
-
|
|
|
-// var req data_manage.ExcelStyleReq
|
|
|
-// err = json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "参数解析异常!"
|
|
|
-// br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// //指标map
|
|
|
-// var dataList [][]map[string]interface{}
|
|
|
-
|
|
|
-// var secNameList []string
|
|
|
-// var frequencyList []string
|
|
|
-// var unitList []string
|
|
|
-
|
|
|
-// secNameToDateMap := make(map[string]map[string]string)
|
|
|
-// //取到所有数据
|
|
|
-// for i := range req.Data {
|
|
|
-// //取到一行
|
|
|
-// if i > 4 {
|
|
|
-// //先拿下日期列表
|
|
|
-// if req.Data[i] == nil || req.Data[i][0] == nil {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// dateMap := req.Data[i][0].(map[string]interface{})
|
|
|
-// _, ok := dateMap["m"]
|
|
|
-// date := dateMap["m"].(string)
|
|
|
-// if !ok {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// // 存储数据
|
|
|
-// for j := 1; j <= len(secNameList); j++ {
|
|
|
-// closeVal := req.Data[i][j].(map[string]interface{})
|
|
|
-// if item, ok := secNameToDateMap[secNameList[j-1]]; ok {
|
|
|
-// tmpVal, ok := closeVal["m"].(string)
|
|
|
-// if !ok || tmpVal == "" {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// item[date] = tmpVal
|
|
|
-// } else {
|
|
|
-// tmpVal, ok := closeVal["m"].(string)
|
|
|
-// if !ok || tmpVal == "" {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// secNameToDateMap[secNameList[j-1]] = map[string]string{
|
|
|
-// date: tmpVal,
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// } else {
|
|
|
-// for j, dataArr := range req.Data[i] {
|
|
|
-// //每一列
|
|
|
-// if dataArr == nil {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// dataMap := dataArr.(map[string]interface{})
|
|
|
-// if dataList == nil {
|
|
|
-// dataList = make([][]map[string]interface{}, len(req.Data))
|
|
|
-// }
|
|
|
-// if dataList[i] == nil {
|
|
|
-// dataList[i] = make([]map[string]interface{}, len(req.Data[i]))
|
|
|
-// }
|
|
|
-// dataList[i][j] = dataMap
|
|
|
-// //fmt.Println("dataMap", dataMap["m"])
|
|
|
-// v, _ := dataMap["m"]
|
|
|
-// //指标名称列表
|
|
|
-// if v == "指标名称" {
|
|
|
-// for nameIndex := 1; nameIndex < len(req.Data[i]); nameIndex++ {
|
|
|
-// if req.Data[i][nameIndex] == nil {
|
|
|
-// break
|
|
|
-// }
|
|
|
-// secNameMap := req.Data[i][nameIndex].(map[string]interface{})
|
|
|
-// secName, _ := secNameMap["m"]
|
|
|
-// if secName == nil {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// secNameList = append(secNameList, secNameMap["m"].(string))
|
|
|
-// //fmt.Println("secName:", secNameList)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //频度列表
|
|
|
-// if v == "频度" {
|
|
|
-// for nameIndex := 1; nameIndex < len(req.Data[i]); nameIndex++ {
|
|
|
-// if req.Data[i][nameIndex] == nil {
|
|
|
-// break
|
|
|
-// }
|
|
|
-// frequencyMap := req.Data[i][nameIndex].(map[string]interface{})
|
|
|
-// frequency, _ := frequencyMap["m"]
|
|
|
-// if frequency == nil {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// frequencyList = append(frequencyList, frequencyMap["m"].(string))
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //单位列表
|
|
|
-// if v == "单位" {
|
|
|
-// for nameIndex := 1; nameIndex < len(req.Data[i]); nameIndex++ {
|
|
|
-// if req.Data[i][nameIndex] == nil {
|
|
|
-// break
|
|
|
-// }
|
|
|
-// unitMap := req.Data[i][nameIndex].(map[string]interface{})
|
|
|
-// unit, _ := unitMap["m"]
|
|
|
-// if unit == nil {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-// unitList = append(unitList, unitMap["m"].(string))
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// // 所有的指标数据map
|
|
|
-// edbCodeInfoMap := make(map[string]*models.EdbInfoItem)
|
|
|
-
|
|
|
-// if len(frequencyList) == 0 {
|
|
|
-// br.Ret = 200
|
|
|
-// br.Success = true
|
|
|
-// br.Msg = "保存成功"
|
|
|
-// return
|
|
|
-// }
|
|
|
-
|
|
|
-// //获取账户所拥有权限的分类id集合
|
|
|
-// classifyIdStrList, err := data.GetEdbClassifyListByAdminId(int64(sysUser.AdminId))
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取分类数据失败"
|
|
|
-// return
|
|
|
-// }
|
|
|
-// IsVaild := 0
|
|
|
-// for _, classifyId := range classifyIdStrList {
|
|
|
-// if strconv.Itoa(req.ClassifyId) == classifyId {
|
|
|
-// IsVaild += 1
|
|
|
-// }
|
|
|
-// if strconv.Itoa(req.OldClassifyId) == classifyId {
|
|
|
-// IsVaild += 1
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if IsVaild != 2 {
|
|
|
-// br.Msg = "操作权限不足,请检查分类操作权限"
|
|
|
-// br.ErrMsg = "操作权限不足"
|
|
|
-// return
|
|
|
-// }
|
|
|
-
|
|
|
-// // 获取当前类所有的有效指标
|
|
|
-// list, err := models.GetTargetItemListSort(req.ClassifyId, 1, req.Frequence, "", "", classifyIdStrList)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取指标失败"
|
|
|
-// br.ErrMsg = "获取有效指标失败,系统错误,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-
|
|
|
-// for _, item := range list {
|
|
|
-// edbCodeInfoMap[item.SecName] = item
|
|
|
-// }
|
|
|
-// //历史的类别下的指标
|
|
|
-// oldEdbCodeInfoMap := make(map[string]*models.EdbInfoItem)
|
|
|
-// if req.ClassifyId != req.OldClassifyId || req.Frequence != req.OldFrequence {
|
|
|
-// // 获取历史类所有的有效指标
|
|
|
-// oldList, err := models.GetTargetItemListSort(req.OldClassifyId, 1, req.OldFrequence, "", "", classifyIdStrList)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取指标失败"
|
|
|
-// br.ErrMsg = "获取有效指标失败,系统错误,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// for _, item := range oldList {
|
|
|
-// edbCodeInfoMap[item.SecName] = item
|
|
|
-// oldEdbCodeInfoMap[item.SecName] = item
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// // 如果没有更换指标类别和频度,那就保持一致
|
|
|
-// oldEdbCodeInfoMap = edbCodeInfoMap
|
|
|
-// }
|
|
|
-
|
|
|
-// // 删除历史类别下的指标及数据
|
|
|
-// if req.TradeCode == "" {
|
|
|
-// // TradeCode == "" 表示当前数据不是经过搜索的数据,可以进行删除指标操作
|
|
|
-// deleteTraceCodeList := make([]string, 0)
|
|
|
-// for k, v := range oldEdbCodeInfoMap {
|
|
|
-// if _, ok := secNameToDateMap[k]; !ok {
|
|
|
-// deleteTraceCodeList = append(deleteTraceCodeList, v.TradeCode)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 删除指标
|
|
|
-// err = models.DeleteEdbinfoByTraceCodeList(deleteTraceCodeList)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "excel保存失败"
|
|
|
-// br.ErrMsg = "指标及指标数据删除失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// // 获得需要新增的指标
|
|
|
-// addEdbInfoList := make([]*models.Edbinfo, 0)
|
|
|
-// sortEdbInfoList := make([]*models.Edbinfo, 0)
|
|
|
-// for i, v := range secNameList {
|
|
|
-// if item, ok := edbCodeInfoMap[v]; !ok {
|
|
|
-// t := new(models.Edbinfo)
|
|
|
-// t.SecName = v
|
|
|
-// t.Unit = unitList[i]
|
|
|
-// t.Remark = "手动"
|
|
|
-// t.Frequency = frequencyList[i]
|
|
|
-// t.ClassifyId = req.ClassifyId
|
|
|
-// t.UserId = sysUser.AdminId
|
|
|
-// t.Sort = len(list) + i
|
|
|
-// addEdbInfoList = append(addEdbInfoList, t)
|
|
|
-// edbCodeInfoMap[t.SecName] = &models.EdbInfoItem{
|
|
|
-// TradeCode: t.TradeCode,
|
|
|
-// SecName: t.SecName,
|
|
|
-// Unit: t.Unit,
|
|
|
-// Frequency: t.Frequency,
|
|
|
-// UserId: t.UserId,
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// t := new(models.Edbinfo)
|
|
|
-// t.TradeCode = item.TradeCode
|
|
|
-// if req.Frequence != req.OldFrequence || req.ClassifyId != req.OldClassifyId {
|
|
|
-// t.Sort = len(list) + i
|
|
|
-// } else {
|
|
|
-// if req.TradeCode != "" {
|
|
|
-// // 如果是搜索的指标,那就保存原来的排序
|
|
|
-// t.Sort = item.Sort
|
|
|
-// } else {
|
|
|
-// t.Sort = i
|
|
|
-// }
|
|
|
-// }
|
|
|
-// t.Frequency = req.Frequence
|
|
|
-// t.ClassifyId = req.ClassifyId
|
|
|
-// sortEdbInfoList = append(sortEdbInfoList, t)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 更新指标频度,分类,顺序
|
|
|
-// for _, v := range sortEdbInfoList {
|
|
|
-// err = v.Update([]string{"frequency", "classify_id", "sort"})
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "excel保存失败"
|
|
|
-// br.ErrMsg = "excel更新顺序失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 新增指标
|
|
|
-// msg, err := data.MultiAddEdbInfo(addEdbInfoList, sysUser.Mobile)
|
|
|
-// if err != nil {
|
|
|
-// if msg != "" {
|
|
|
-// br.Msg = msg
|
|
|
-// } else {
|
|
|
-// br.Msg = "指标保存失败"
|
|
|
-// }
|
|
|
-// br.ErrMsg = "新增指标失败,系统错误,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// for _, v := range addEdbInfoList {
|
|
|
-// edbCodeInfoMap[v.SecName].TradeCode = v.TradeCode
|
|
|
-// }
|
|
|
-// // 新增指标数据
|
|
|
-// addEdbDataList := make([]*models.Edbdata, 0)
|
|
|
-// for _, v := range secNameList {
|
|
|
-// // 指标数据
|
|
|
-// for date, closeVal := range secNameToDateMap[v] {
|
|
|
-// t := new(models.Edbdata)
|
|
|
-// // 理论上这里面不应该出现空值
|
|
|
-// t.TradeCode = edbCodeInfoMap[v].TradeCode
|
|
|
-// t.Dt = date
|
|
|
-// t.Close = closeVal
|
|
|
-// t.ModifyTime = time.Now()
|
|
|
-// addEdbDataList = append(addEdbDataList, t)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// err = models.MultiAddEdbdata(addEdbDataList)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "excel保存失败"
|
|
|
-// br.ErrMsg = "新增指标数据失败,系统错误,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-
|
|
|
-// br.Ret = 200
|
|
|
-// br.Success = true
|
|
|
-// br.Msg = "保存成功"
|
|
|
-// }
|
|
|
-
|
|
|
// ExcelDataEdit
|
|
|
// @Title 在线Excel编辑
|
|
|
// @Description 在线Excel编辑
|