123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package controllers
- import (
- "eta/eta_hub/models"
- "eta/eta_hub/models/data_manage"
- "eta/eta_hub/utils"
- )
- // SupplyAnalysisController 供应分析
- type SupplyAnalysisController struct {
- BaseAuthController
- }
- // StockPlantVarietyList
- // @Title 装置检修-品种分类
- // @Description 装置检修-品种分类
- // @Success 200 {object} data_manage.VarietyItem
- // @router /stock_plant/variety/list [get]
- func (this *SupplyAnalysisController) StockPlantVarietyList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- varietyOb := new(data_manage.Variety)
- cond := ``
- pars := make([]interface{}, 0)
- list, e := varietyOb.GetItemsByCondition(cond, pars, []string{}, "create_time ASC")
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "StockPlantVarietyList GetItemsByCondition err: " + e.Error()
- return
- }
- resp := make([]*data_manage.VarietyItem, 0)
- for _, v := range list {
- resp = append(resp, data_manage.FormatVariety2Item(v))
- }
- br.Data = resp
- br.Ret = 200
- br.Msg = "获取成功"
- }
- // StockPlantEdbList
- // @Title 装置检修-指标列表
- // @Description 装置检修-指标列表
- // @Param VarietyId query int false "品种ID"
- // @Success 200 {object} data_manage.ChartInfoItem
- // @router /stock_plant/edb/list [get]
- func (this *SupplyAnalysisController) StockPlantEdbList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- varietyId, _ := this.GetInt("VarietyId", 0)
- // 只取加入指标库中的
- cond := ` AND edb_info_id > 0`
- pars := make([]interface{}, 0)
- if varietyId > 0 {
- cond += ` AND variety_id = ?`
- pars = append(pars, varietyId)
- }
- edbOb := new(data_manage.VarietyEdbInfo)
- list, e := edbOb.GetItemsByCondition(cond, pars, []string{}, "")
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "StockPlantEdbList GetItemsByCondition err: " + e.Error()
- return
- }
- resp := make([]*data_manage.VarietyEdbInfoItem, 0)
- for _, v := range list {
- resp = append(resp, data_manage.FormatVarietyEdbInfo2Item(v))
- }
- br.Data = resp
- br.Ret = 200
- br.Msg = "获取成功"
- }
- // StockPlantEdbDetail
- // @Title 装置检修-指标详情
- // @Description 装置检修-指标详情
- // @Param EdbCode query string true "指标编码"
- // @Success 200 {object} data_manage.EdbInfoItem
- // @router /stock_plant/edb/detail [get]
- func (this *SupplyAnalysisController) StockPlantEdbDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- edbCode := this.GetString("EdbCode")
- if edbCode == "" {
- br.Msg = "参数有误"
- return
- }
- edbOb := new(data_manage.EdbInfo)
- edb, e := edbOb.GetItemByEdbCode(edbCode)
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Msg = "指标不存在"
- return
- }
- br.Msg = "获取失败"
- br.ErrMsg = "StockPlantEdbDetail GetItemByCode err: " + e.Error()
- return
- }
- // 获取指标数据
- //dataOb := new(data_manage.EdbData)
- //dataList, e := dataOb.GetItemsBySourceAndCode(edb.Source, edb.EdbCode, []string{}, "")
- //if e != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "StockPlantEdbDetail GetItemsBySourceAndCode err: " + e.Error()
- // return
- //}
- //edbData := make([]*data_manage.EdbDataItem, 0)
- //for _, v := range dataList {
- // edbData = append(edbData, data_manage.FormatEdbData2Item(v))
- //}
- resp := data_manage.FormatEdbInfo2Item(edb)
- br.Data = resp
- br.Ret = 200
- br.Msg = "获取成功"
- }
|