123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344 |
- package cygx
- import (
- "encoding/json"
- "fmt"
- "github.com/tealeg/xlsx"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/cygx"
- cygxService "hongze/hz_crm_api/services/cygx"
- "hongze/hz_crm_api/utils"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
- )
- // 产业管理
- type IndustrialManagementController struct {
- controllers.BaseAuthController
- }
- //func init() {
- // fmt.Println("init start")
- // go cygxService.UpdateOriginIndustryLayoutTime()
- // fmt.Println("init end")
- //}
- // @Title 获取一级分类
- // @Description 获取一级分类接口
- // @Param HideMacro query bool false "是否隐藏宏观(默认不隐藏)"
- // @Param IsCeLueReport query bool false "是否是策略平台的报告类型"
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/first [get]
- func (this *IndustrialManagementController) ChartPermissionList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- // 是否隐藏宏观
- hideMacro, _ := this.GetBool("HideMacro")
- isCeLueReport, _ := this.GetBool("IsCeLueReport")
- resp := new(cygx.ChartPermissionResp)
- list, err := cygx.GetChartPermissionAll()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- //判断是否是策略平台的报告类型
- if isCeLueReport {
- for _, v := range list {
- if v.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
- resp.List = append(resp.List, v)
- }
- }
- item := new(cygx.ChartPermission)
- item.PermissionName = utils.GU_SHOU_NAME
- item.ChartPermissionId = utils.GU_SHOU_ID
- resp.List = append(resp.List, item)
- } else {
- // 查研观向7.4-新增一个宏观
- if !hideMacro {
- macro := &cygx.ChartPermission{
- ChartPermissionId: 1,
- PermissionName: "宏观",
- }
- list = append(list, macro)
- }
- resp.List = list
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取带有图标的一级分类
- // @Description 获取带有图标的一级分类接口
- // @Param Havestrategy query int true "是否有策略,1有,0无 默认无"
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/firstHaveIco [get]
- func (this *IndustrialManagementController) ChartPermissionListIco() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- havestrategy, _ := this.GetInt("Havestrategy")
- var condition string
- if havestrategy > 0 {
- condition = ` AND chart_permission_id IN (19,20,21,22,23) `
- } else {
- condition = ` AND chart_permission_id IN (19,20,21,22) `
- }
- list, err := cygx.GetChartPermissionIco(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k := range list {
- list[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202109/20210909/aoa5IKOh4uTS1BPwvdGQ3ape4gwN.jpg"
- }
- resp := new(cygx.ChartPermissionResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取一级分类无策略
- // @Description 获取一级分类接口
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/noTacticsfirst [get]
- func (this *IndustrialManagementController) NoTacticsChartPermissionList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- list, err := cygx.GetChartPermissionAllNoTactics()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.ChartPermissionResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取一级分类(包含其它)
- // @Description 获取一级分类(包含其它)接口
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/noTacticsfirstOther [get]
- func (this *IndustrialManagementController) NoTacticsChartPermissionOtherList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- list, err := cygx.GetChartPermissionOtherAll()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.ChartPermissionResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产品内测一级分类接口,包含,医药消费科技制造策略
- // @Description 产品内测一级分类接口,包含,医药消费科技制造策略
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/firstProduct [get]
- func (this *IndustrialManagementController) ChartPermissionFirstProduct() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- resp := new(cygx.ChartPermissionResp)
- list, err := cygx.GetChartPermissionAll()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- //医药消费科技制造策略
- for _, v := range list {
- if v.PermissionName == utils.YI_YAO_NAME || v.PermissionName == utils.XIAO_FEI_NAME || v.PermissionName == utils.KE_JI_NAME || v.PermissionName == utils.ZHI_ZAO_NAME || v.PermissionName == utils.CE_LUE_NAME {
- resp.List = append(resp.List, v)
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 添加产业
- // @Description 添加产业接口
- // @Param request body cygx.IndustrialManagementAdd true "type json string"
- // @Success Ret=200 {object} cygx.NewId
- // @router /industrialManagement/add [post]
- func (this *IndustrialManagementController) IndustrialManagementAdd() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.IndustrialManagementAdd
- var pars []interface{}
- var condition string
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- source := req.Source
- permissionName := req.PermissionName
- if source != 2 && source != 3 {
- source = 1
- }
- if req.IndustryName == "" {
- br.Msg = "请输入产业名称"
- return
- }
- if permissionName == "" {
- if req.ChartPermissionId < 1 {
- br.Msg = "请选择所属行业"
- return
- }
- } else {
- req.ChartPermissionId = 31 //研选ID
- }
- // 查研观向7.4-不再手动填写布局时间, 而是第一次新增报告/活动的时候自动更新布局时间
- if source == 1 {
- //if req.LayoutTime == "" {
- // br.Msg = "请输入布局时间"
- // return
- //}
- if req.RecommendedIndex < 0 {
- br.Msg = "请输入推荐指数"
- return
- }
- if req.RecommendedIndex < 0 || req.RecommendedIndex > 100 {
- br.Msg = "推荐指数范围在0-100之间"
- return
- }
- } else {
- req.LayoutTime = time.Now().Format(utils.FormatDateTime)
- }
- item := new(cygx.CygxIndustrialManagement)
- item.ChartPermissionId = req.ChartPermissionId
- item.IndustryName = req.IndustryName
- item.RecommendedIndex = req.RecommendedIndex
- item.LayoutTime = req.LayoutTime
- item.IsNewLabel = req.IsNewLabel
- item.Source = source
- if req.IsNewLabel == 0 {
- item.IsHandNewLabel = 1
- }
- item.CreateTime = time.Now()
- condition = `AND product_id=2 AND show_type=1 AND is_other=0 AND chart_permission_id = ` + strconv.Itoa(req.ChartPermissionId)
- totalChartPermissionId, _ := cygx.GetChartPermissionCount(condition, pars)
- if totalChartPermissionId < 1 {
- br.Msg = "分类ID不存在,请重新填写"
- br.ErrMsg = "分类ID不存在,请重新填写:" + strconv.Itoa(req.ChartPermissionId)
- return
- }
- //如果是通过产业模块正常添加
- if source == 1 {
- condition = ` AND source != 1 AND industry_name = '` + req.IndustryName + `'`
- totalSource, err := cygx.GetIndustrialManagementCount(condition, pars)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败 Err:" + err.Error()
- return
- }
- if totalSource > 0 {
- // 修改来源为正常添加
- err = cygx.EditIndustrialManagementFromAct(item)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败 Err:" + err.Error()
- return
- }
- br.Msg = "该产业已存在"
- br.ErrMsg = "名称已经存在,请重新填写:" + req.IndustryName
- return
- }
- }
- // 查研观向7.4-全行业(包括研选)重名校验
- //if permissionName == "研选" {
- // condition = ` AND industry_name = '` + req.IndustryName + `'`
- //} else {
- // condition = ` AND source = 1 AND industry_name = '` + req.IndustryName + `'`
- //}
- condition = ` AND industry_name = '` + req.IndustryName + `'`
- total, err := cygx.GetIndustrialManagementCount(condition, pars)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败 Err:" + err.Error()
- return
- }
- if total > 0 {
- br.Msg = "该产业已存在"
- br.ErrMsg = "名称已经存在,请重新填写:" + req.IndustryName
- return
- }
- newId, err := cygx.AddIndustrialManagement(item)
- if err != nil {
- br.Msg = "添加失败"
- br.ErrMsg = "添加失败 Err:" + err.Error()
- return
- }
- go cygxService.AddUserIndustryFllowByNewId(int(newId)) //现了新的产业,给选择推送方式的用户自动添加关注
- resp := new(cygx.NewId)
- resp.NewId = strconv.Itoa(int(newId))
- resp.ChartPermissionId = req.ChartPermissionId
- br.Data = resp
- br.Ret = 200
- br.Success = true
- br.Msg = "添加成功"
- br.IsAddLog = true
- }
- // @Title 获取产业列表
- // @Description 获取产业列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Param OrderColumn query int false "排序字段 ,AddTime添加时间 ,Recommended推荐指数 ,ReportTime 报告更新时间 "
- // @Param KeyWord query string false "搜索关键词"
- // @Success Ret=200 {object} cygx.GetIndustrialManagementList
- // @router /industrialManagement/list [get]
- func (this *IndustrialManagementController) IndustrialManagementlist() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- orderColumn := this.GetString("OrderColumn")
- keyWord := this.GetString("KeyWord")
- if chartPermissionId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- if orderColumn != "Recommended" && orderColumn != "ReportTime" {
- orderColumn = "AddTime"
- }
- var condition string
- if keyWord != "" {
- condition += ` AND (man.industry_name LIKE '%` + keyWord + `%' ) `
- }
- condition += ` AND man.chart_permission_id = ` + strconv.Itoa(chartPermissionId)
- // @Param OrderColumn query int true "排序字段 ,AddTime 添加时间 ,Recommended 推荐指数 ,ReportTime 报告更新时间 "
- //var list []*cygx.CygxIndustrialManagementNum
- //var err error
- //var orderSrt string
- //if orderColumn == "Recommended" {
- // orderSrt = "man.recommended_index DESC,update_time DESC"
- //} else {
- // orderSrt = "update_time DESC"
- //}
- //
- //if orderColumn == "AddTime" {
- // listAddTime, errAddTime := cygx.GetIndustrialManagementAll(condition, "create_time")
- // list = listAddTime
- // err = errAddTime
- //} else if orderColumn == "Recommended" {
- // listAddTime, errAddTime := cygx.GetIndustrialManagementAllByReportTime(condition, orderSrt)
- // list = listAddTime
- // err = errAddTime
- //} else {
- // listAddTime, errAddTime := cygx.GetIndustrialManagementAllByReportTime(condition, orderSrt)
- // list = listAddTime
- // err = errAddTime
- //}
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- // return
- //}
- // 查研观向7.4-研选产业同时需要查询弘则覆盖的产业
- var isCover bool
- var conditionCover string
- var pars []interface{}
- if chartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
- // 获取弘则覆盖产业IDs
- coverIds, e := cygx.GetYxIndustryUseHzIndustryIds()
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取弘则覆盖产业IDs失败, Err: " + e.Error()
- return
- }
- if len(coverIds) > 0 {
- isCover = true
- conditionCover += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(len(coverIds)) + `)`
- pars = append(pars, coverIds)
- }
- }
- orderMap := map[string]string{
- "AddTime": ` create_time ASC`,
- "Recommended": ` recommended_index DESC, update_time DESC`,
- "ReportTime": ` update_time DESC`,
- }
- orderRule := orderMap[orderColumn]
- if orderRule == `` {
- orderRule = ` create_time ASC`
- }
- list, e := cygx.GetIndustryListWithHzCover(condition, conditionCover, orderRule, isCover, pars)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业信息失败, Err: " + e.Error()
- return
- }
- for k, v := range list {
- if v.ArtNum > 0 || v.ActNum > 0 {
- list[k].IsRelevance = true
- }
- }
- resp := new(cygx.GetIndustrialManagementList)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取产业详情
- // @Description 获取产业详情接口
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success Ret=200 {object} cygx.CygxIndustrialManagementDetailRep
- // @router /industrialManagement/industrialManagementDetail [get]
- func (this *IndustrialManagementController) IndustrialManagementDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- if industrialManagementId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- detail, err := cygx.GetIndustrialManagemenDetailById(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxIndustrialManagementDetailRep)
- resp.IndustrialManagementId = detail.IndustrialManagementId
- resp.IndustryName = detail.IndustryName
- resp.ChartPermissionId = detail.ChartPermissionId
- resp.RecommendedIndex = detail.RecommendedIndex
- resp.CreateTime = detail.CreateTime
- resp.LayoutTime = detail.LayoutTime
- resp.IsNewLabel = detail.IsNewLabel
- resp.IsDeepLabel = detail.IsDeepLabel
- resultTime := detail.CreateTime.AddDate(0, 2, 0).Format(utils.FormatDateTime)
- if utils.StrTimeToTime(resultTime).After(time.Now()) {
- resp.IsShowNewLabel = true
- }
- count, err := cygx.GetIndustrialManagementGroupArtCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- countDeep, err := cygx.GetIndustrialManagementGroupArtCountByDeep(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if count >= 10 && countDeep > 0 {
- resp.IsShowDeepLabel = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 修改产业
- // @Description 修改产业接口
- // @Param request body cygx.CygxIndustrialManagementEdit true "type json string"
- // @Success Ret=200 修改产业成功
- // @router /industrialManagement/edit [post]
- func (this *IndustrialManagementController) IndustrialManagementEdit() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.CygxIndustrialManagementEdit
- var pars []interface{}
- var condition string
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.IndustryName == "" {
- br.Msg = "请输入产业名称"
- return
- }
- industrialManagementId := req.IndustrialManagementId
- condition = ` AND industrial_management_id = ` + strconv.Itoa(req.IndustrialManagementId)
- totalIndustrialManagement, _ := cygx.GetIndustrialManagementCount(condition, pars)
- if totalIndustrialManagement < 1 {
- br.Msg = "修改失败"
- br.ErrMsg = "信息不存在!"
- return
- }
- //if req.LayoutTime == "" {
- // br.Msg = "请输入布局时间"
- // return
- //}
- if req.RecommendedIndex < 0 {
- br.Msg = "请输入推荐指数"
- return
- }
- if req.RecommendedIndex < 0 || req.RecommendedIndex > 100 {
- br.Msg = "推荐指数范围在0-100之间"
- return
- }
- condition = ` AND product_id=2 AND show_type=1 AND is_other=0 AND chart_permission_id = ` + strconv.Itoa(req.ChartPermissionId)
- totalChartPermissionId, _ := cygx.GetChartPermissionCount(condition, pars)
- if totalChartPermissionId < 1 {
- br.Msg = "分类ID不存在,请重新填写"
- br.ErrMsg = "分类ID不存在,请重新填写:" + strconv.Itoa(req.ChartPermissionId)
- return
- }
- // 查研观向7.4-全行业(包括研选)重名校验
- condition = ` AND industry_name = '` + req.IndustryName + `' AND industrial_management_id != ` + strconv.Itoa(req.IndustrialManagementId)
- //condition = ` AND industry_name = '` + req.IndustryName + `' AND industrial_management_id != ` + strconv.Itoa(req.IndustrialManagementId) + ` AND chart_permission_id = ` + strconv.Itoa(req.ChartPermissionId)
- total, _ := cygx.GetIndustrialManagementCount(condition, pars)
- if total > 0 {
- br.Msg = "产业已存在,请重新填写"
- br.ErrMsg = "名称已经存在,请重新填写:" + req.IndustryName
- return
- }
- //condition = ` AND recommended_index = ` + strconv.Itoa(req.RecommendedIndex) + ` AND chart_permission_id = ` + strconv.Itoa(req.ChartPermissionId) + ` AND industrial_management_id != ` + strconv.Itoa(req.IndustrialManagementId)
- //totalRecommendedIndex, _ := cygx.GetIndustrialManagementCount(condition, pars)
- //if totalRecommendedIndex > 0 {
- // br.Msg = "推荐指数已经存在,请重新填写"
- // br.ErrMsg = "推荐指数已经存在,请重新填写:" + strconv.Itoa(req.RecommendedIndex)
- // return
- //}
- item := new(cygx.CygxIndustrialManagement)
- item.ChartPermissionId = req.ChartPermissionId
- item.IndustryName = req.IndustryName
- item.RecommendedIndex = req.RecommendedIndex
- //item.LayoutTime = req.LayoutTime
- item.IndustrialManagementId = req.IndustrialManagementId
- item.IsNewLabel = req.IsNewLabel
- item.IsDeepLabel = req.IsDeepLabel
- detail, err := cygx.GetIndustrialManagemenDetailById(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resultTime := detail.CreateTime.AddDate(0, 2, 0).Format(utils.FormatDateTime)
- if utils.StrTimeToTime(resultTime).After(time.Now()) && req.IsNewLabel == 0 {
- item.IsHandNewLabel = 1
- }
- count, err := cygx.GetIndustrialManagementGroupArtCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- countDeep, err := cygx.GetIndustrialManagementGroupArtCountByDeep(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if count >= 10 && countDeep > 0 && req.IsDeepLabel == 0 {
- item.IsHandDeepLabel = 1
- }
- if (count < 10 || countDeep == 0) && req.IsDeepLabel == 1 {
- item.IsHandDeepLabel = 1
- }
- err = cygx.EditIndustrialManagement(item)
- if err != nil {
- br.Msg = "编辑失败"
- br.ErrMsg = "修改失败 Err:" + err.Error()
- return
- }
- go cygx.UpdateIndustrialManagementSubjectNames(industrialManagementId, req.IndustryName)
- // 查研观向7.4-更新产业布局时间
- industryIds := make([]int, 0)
- industryIds = append(industryIds, industrialManagementId)
- go cygxService.UpdateIndustryLayoutTime(industryIds, false)
- br.Ret = 200
- br.Success = true
- br.Msg = "编辑成功"
- br.IsAddLog = true
- }
- // @Title 删除产业
- // @Description 删除产业接口
- // @Param IndustrialManagementId query int true "产业ID"
- // @Param request body models.BannerDeleteReq true "type json string"
- // @Success Ret=200
- // @router /industrialManagement/delete [post]
- func (this *IndustrialManagementController) IndustrialManagementDelete() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.IndustrialManagementDelte
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- IndustrialManagementId := req.IndustrialManagementId
- if IndustrialManagementId < 1 {
- br.Msg = "请输入产业ID"
- return
- }
- count, _ := cygx.GetIndustrialManagementGroupArtCount(IndustrialManagementId)
- if count > 0 {
- br.Ret = 460
- br.Msg = "当前产业下有关联报告,请将相关报告重新归类后再删除"
- return
- }
- countAct, err := cygx.GetIndustrialManagementGroupActCount(IndustrialManagementId)
- if err != nil {
- br.Msg = "删除失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if countAct > 0 {
- br.Ret = 460
- br.Msg = "当前产业下有关联活动,请将相关活动重新归类后再删除"
- return
- }
- var pars []interface{}
- var condition string
- condition = ` AND industrial_management_id = ` + strconv.Itoa(IndustrialManagementId)
- totalIndustrialManagement, _ := cygx.GetIndustrialManagementCount(condition, pars)
- if totalIndustrialManagement < 1 {
- br.Msg = "删除失败"
- br.ErrMsg = "信息不存在!"
- return
- }
- err = cygx.DeleteIndustrialManagement(IndustrialManagementId)
- if err != nil {
- br.Msg = "删除信息失败"
- br.ErrMsg = "删除信息失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "已删除"
- br.IsAddLog = true
- }
- // @Title 获取产业报告数量详情
- // @Description 获取产业报告数量详情接口
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success Ret=200 {object} cygx.IndustrialManagementDetial
- // @router /industrialManagement/detail [get]
- func (this *IndustrialManagementController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- if industrialManagementId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- industrialManagementInfo, err := cygx.GetindustrialManagemenById(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- listArtType, errList := cygx.GetIndustrialManagementArtTypeList(industrialManagementId)
- if errList != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取列表信息失败,Err:" + errList.Error()
- return
- }
- var list []*cygx.IndustrialManagementArtTypeList
- mapArtType := make(map[string]*cygx.IndustrialManagementArtTypeList)
- for _, v := range listArtType {
- if mapArtType[v.MatchTypeName] == nil {
- mapArtType[v.MatchTypeName] = v
- } else {
- mapArtType[v.MatchTypeName].ArtNum += v.ArtNum
- }
- }
- for _, v := range mapArtType {
- list = append(list, v)
- }
- resp := new(cygx.IndustrialManagementDetial)
- if industrialManagementInfo.LayoutTime == utils.EmptyDateTimeStr {
- resp.LayoutTime = ""
- } else {
- //resultTime := utils.StrTimeToTime(industrialManagementInfo.LayoutTime) //时间字符串格式转时间格式
- //var oldTime string
- //if industrialManagementInfo.CreateTime.After(resultTime) {
- // oldTime = resultTime.Format(utils.FormatDateTime)
- //} else {
- // oldTime = industrialManagementInfo.CreateTime.Format(utils.FormatDateTime)
- //}
- //if industrialManagementInfo.ArtNum == 0 {
- // oldTime = resultTime.Format(utils.FormatDateTime)
- //}
- //resp.LayoutTime = utils.TimeRemoveHms(oldTime)
- resp.LayoutTime = utils.TimeRemoveHms(industrialManagementInfo.LayoutTime)
- }
- // 查研观向7.4-细分活动类型为"弘则活动"和"研选活动"
- //count, err := cygx.GetIndustrialManagementGroupActCount(industrialManagementId)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- // return
- //}
- //item := new(cygx.IndustrialManagementArtTypeList)
- //item.ArtNum = count
- //item.MatchTypeName = "相关活动"
- //list = append(list, item)
- countList, e := cygx.GetIndustryActCountGroupByType(industrialManagementId)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业关联的活动数失败, Err: " + e.Error()
- return
- }
- //针对研选的路演精华做单独处理 判断有没有路演精华这个类型,如果有就做相加,没有就做合并
- countYxLyjh, e := cygx.GetIndustrialManagementArtYxLYJH(industrialManagementId)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业关联的活动数失败, Err: " + e.Error()
- return
- }
- var haveYxLyjh bool
- for _, v := range list {
- if v.MatchTypeName == utils.CYGX_LYJH {
- v.ArtNum += countYxLyjh
- haveYxLyjh = true
- }
- }
- if !haveYxLyjh {
- lyjhCount := new(cygx.IndustrialManagementArtTypeList)
- lyjhCount.MatchTypeName = utils.CYGX_LYJH
- lyjhCount.ArtNum = countYxLyjh
- list = append(list, lyjhCount)
- }
- hzCount := new(cygx.IndustrialManagementArtTypeList)
- hzCount.MatchTypeName = utils.CYGX_ACTIVITY_TYPE_NAME_HZ
- yxCount := new(cygx.IndustrialManagementArtTypeList)
- yxCount.MatchTypeName = utils.CYGX_ACTIVITY_TYPE_NAME_YX
- for i := range countList {
- if countList[i].ActivityType == utils.CYGX_ACTIVITY_TYPE_NAME_HZ {
- hzCount.ArtNum = countList[i].ActivityCount
- }
- if countList[i].ActivityType == utils.CYGX_ACTIVITY_TYPE_NAME_YX {
- yxCount.ArtNum = countList[i].ActivityCount
- }
- }
- list = append(list, hzCount, yxCount)
- resp.ArtTotalNum = industrialManagementInfo.ArtNum
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业导出
- // @Description 产业导出接口
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /industrialManagement/export [get]
- func (this *IndustrialManagementController) ChartPermissionExport() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- resp := new(cygx.CanDownload)
- if sysUser.Authority == 1 || sysUser.Authority == 3 {
- resp.IsCanDownload = true
- }
- if sysUser.Role == "admin" {
- resp.IsCanDownload = true
- }
- if sysUser.RoleTypeCode == "rai_admin" || sysUser.RoleTypeCode == "ficc_admin" || sysUser.RoleTypeCode == "admin" {
- resp.IsCanDownload = true
- }
- if resp.IsCanDownload == false {
- br.Msg = "你没有预览权限"
- return
- }
- chartPermissionIdStrList, err := cygx.GetChartPermissionIdStr()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- //生成excel文件
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- //普通样式
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- //设置默认字体和文字大小
- xlsx.SetDefaultFont(12, "宋体")
- style.Alignment = alignment
- style.ApplyAlignment = true
- //标题样式
- titleStyle := xlsx.NewStyle()
- titleFont := xlsx.NewFont(20, "宋体")
- titleFont.Bold = true
- titleStyle.Font = *titleFont
- titleStyle.Alignment = alignment
- //titleStyle.ApplyAlignment = true
- //表头
- headerStyle := xlsx.NewStyle()
- headerFont := xlsx.NewFont(12, "宋体")
- headerFont.Bold = true
- headerStyle.Font = *headerFont
- headerStyle.Alignment = alignment
- headerStyle.ApplyAlignment = true
- //导入报表
- sheel, err := xlsxFile.AddSheet("预览报表")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //设置列宽
- sheel.SetColWidth(0, 0, 28)
- sheel.SetColWidth(1, 1, 18)
- sheel.SetColWidth(2, 2, 18)
- sheel.SetColWidth(3, 3, 18)
- sheel.SetColWidth(4, 4, 40)
- //标题行
- titleRow := sheel.AddRow()
- titleRow.SetHeight(40)
- //标题列
- titleCell := titleRow.AddCell()
- titleCell.HMerge = 6 //向右合并列数,不包括自身列
- titleCell.SetValue("预览")
- titleCell.SetStyle(titleStyle)
- //表头
- headerRow := sheel.AddRow()
- headerRow.SetHeight(18)
- cellA := headerRow.AddCell()
- cellA.SetValue("行业")
- cellA.SetStyle(headerStyle)
- cellB := headerRow.AddCell()
- cellB.SetValue("行业报告数量")
- cellB.SetStyle(headerStyle)
- cellC := headerRow.AddCell()
- cellC.SetValue("产业分类")
- cellC.SetStyle(headerStyle)
- cellD := headerRow.AddCell()
- cellD.SetValue("推荐指数")
- cellD.SetStyle(headerStyle)
- cellE := headerRow.AddCell()
- cellE.SetValue("研究员")
- cellE.SetStyle(headerStyle)
- cellF := headerRow.AddCell()
- cellF.SetValue("覆盖标的")
- cellF.SetStyle(headerStyle)
- cellG := headerRow.AddCell()
- cellG.SetValue("产业报告数量")
- cellG.SetStyle(headerStyle)
- listMatchType, err := cygx.CygxReportMappingMatchTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range chartPermissionIdStrList {
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- industrialManagementList, err := cygx.GetIndustrialManagementIdStr(v.ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- matchTypeList, err := cygx.GetMatchTypeList(v.ChartPermissionId)
- fmt.Println(matchTypeList)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- var matchTypeStr string
- for _, vmatchType := range listMatchType {
- matchTypeStr += vmatchType.MatchTypeName + "(0),"
- }
- matchTypeStr = strings.TrimRight(matchTypeStr, ",")
- countReport, _ := cygx.GetchartPermissionReportNameCount(v.ChartPermissionId)
- chartPermissionReportName := v.MatchTypeName + "(" + strconv.Itoa(countReport) + ")"
- if v.ChartPermissionName == "消费" {
- chartPermissionReportName = "/"
- }
- if len(industrialManagementList) < 1 {
- dataRow := sheel.AddRow()
- dataRow.SetHeight(18)
- cellA := dataRow.AddCell()
- cellA.SetString(v.ChartPermissionName)
- cellA.SetStyle(style)
- cellB := dataRow.AddCell()
- cellB.SetString(chartPermissionReportName)
- cellB.SetStyle(style)
- cellC := dataRow.AddCell()
- cellC.SetString("")
- cellC.SetStyle(style)
- cellD := dataRow.AddCell()
- cellD.SetString("")
- cellD.SetStyle(style)
- cellE := dataRow.AddCell()
- cellE.SetString("")
- cellE.SetStyle(style)
- cellF := dataRow.AddCell()
- cellF.SetString("")
- cellF.SetStyle(style)
- cellG := dataRow.AddCell()
- cellG.SetString(matchTypeStr)
- cellG.SetStyle(style)
- } else {
- for k2, v2 := range industrialManagementList {
- subList, err := cygx.GetIndustrialSubjectAll(v2.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- analystList, err := cygx.GetIndustrialAnalystAll(v2.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- var subjectNameStr string
- var analystNameStr string
- var reportNumStr string
- for _, v3 := range subList {
- if v2.IndustrialManagementId == v3.IndustrialManagementId {
- subjectNameStr += v3.SubjectName + ","
- }
- }
- for _, v3 := range analystList {
- if v2.IndustrialManagementId == v3.IndustrialManagementId {
- analystNameStr += v3.AnalystName + ","
- }
- }
- for _, vMt := range listMatchType {
- countRe, _ := cygx.GetReportCount(v.ChartPermissionId, v2.IndustrialManagementId, vMt.MatchTypeName)
- reportNumStr += vMt.MatchTypeName + "(" + strconv.Itoa(countRe) + ")" + ","
- }
- industrialManagementList[k2].SubjectName = strings.TrimRight(subjectNameStr, ",")
- industrialManagementList[k2].AnalystName = strings.TrimRight(analystNameStr, ",")
- industrialManagementList[k2].ReportNum = strings.TrimRight(reportNumStr, ",")
- }
- for k4, v4 := range industrialManagementList {
- dataRow := sheel.AddRow()
- dataRow.SetHeight(18)
- cellA := dataRow.AddCell()
- cellA.SetString(v.ChartPermissionName)
- if k4 < len(industrialManagementList)-1 {
- cellA.VMerge = 1 // span1 向下合并1格
- }
- cellA.SetStyle(style)
- cellB := dataRow.AddCell()
- if k4 < len(industrialManagementList)-1 {
- cellB.VMerge = 1 // span1 向下合并1格
- }
- fmt.Println(len(industrialManagementList))
- cellB.SetString(chartPermissionReportName)
- cellB.SetStyle(style)
- cellC := dataRow.AddCell()
- cellC.SetString(v4.IndustryName)
- cellC.SetStyle(style)
- cellD := dataRow.AddCell()
- cellD.SetString(strconv.Itoa(v4.RecommendedIndex))
- cellD.SetStyle(style)
- cellE := dataRow.AddCell()
- cellE.SetString(v4.AnalystName)
- cellE.SetStyle(style)
- cellF := dataRow.AddCell()
- cellF.SetString(v4.SubjectName)
- cellF.SetStyle(style)
- cellG := dataRow.AddCell()
- cellG.SetString(v4.ReportNum)
- cellG.SetStyle(style)
- }
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "产业管理预览" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // @Title 获取关联产业列表
- // @Description 获取关联产业列表接口
- // @Param KeyWord query string false "搜索关键词"
- // @Success Ret=200 {object} cygx.GetCygxIndustrialManagementList
- // @router /industrialManagement/listByName [get]
- func (this *IndustrialManagementController) IndustrialManagementlistByName() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var condition string
- var conditionKeyWord string
- keyWord := this.GetString("KeyWord")
- charInfo, err := cygx.GetCategoryInfoByName(utils.CHART_PERMISSION_NAME_MF_YANXUAN)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,找不到研选分类信息Err:" + err.Error()
- return
- }
- if keyWord != "" {
- condition = ` AND industry_name LIKE '%` + keyWord + `%' AND chart_permission_id = ` + strconv.Itoa(charInfo.ChartPermissionId)
- } else {
- condition = ` AND industrial_management_id = 0 `
- }
- listIndustrial, err := cygx.GetIndustrialManagement(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range listIndustrial {
- conditionKeyWord += "'" + v.IndustryName + "',"
- }
- if conditionKeyWord != "" {
- conditionKeyWord = strings.TrimRight(conditionKeyWord, ",")
- conditionKeyWord = ` AND industry_map_name NOT IN ( ` + conditionKeyWord + `)`
- }
- if keyWord != "" {
- condition = ` AND industry_map_name LIKE '%` + keyWord + `%' AND level = 4 ` + conditionKeyWord
- } else {
- condition = ` AND industry_map_id = 0 `
- }
- listMap, err := cygx.GetIndustrialMapListName(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.GetCygxIndustrialManagementList)
- for _, v := range listMap {
- item := new(cygx.ArtGroupIndustrialManagementRep)
- item.IndustryName = v.IndustryMapName
- listIndustrial = append(listIndustrial, item)
- }
- resp.List = listIndustrial
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 一级分类所关联的产业列表
- // @Description 获取一级分类所关联的产业列表接口
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/listIndustrial [get]
- func (this *IndustrialManagementController) ListIndustrial() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- list, err := cygx.GetChartPermissionAllNoTactics()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- listIndustrial, err := cygx.GetIndustrialManagementAllCheckName(v.ChartPermissionId, "create_time")
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].List = listIndustrial
- }
- resp := new(cygx.ChartPermissionResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业、标的模糊查询
- // @Description 产业、标的模糊查询接口
- // @Param KeyWord query string false "搜索关键词"
- // @Success Ret=200 {object} cygx.GetIndustrialManagementList
- // @router /industrialManagement/search [get]
- func (this *IndustrialManagementController) IndustrialSearch() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- keyWord := this.GetString("KeyWord")
- if keyWord == "" {
- br.Msg = "请输入关键词"
- return
- }
- var condition string
- if keyWord != "" {
- condition += ` AND (man.industry_name LIKE '%` + keyWord + `%' ) `
- }
- var list []*cygx.CygxIndustrialManagementNum
- var err error
- var orderSrt string
- orderSrt = " man.recommended_index DESC,update_time DESC"
- listAddTime, err := cygx.GetIndustrialManagementAllByReportTime(condition, orderSrt)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list = listAddTime
- if keyWord != "" {
- condition = ` AND (sub.subject_name LIKE '%` + keyWord + `%' ) GROUP BY sub.subject_name `
- }
- listSubject, err := cygx.GetIndustrialSubjectAllByIds(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for _, v := range listSubject {
- item := new(cygx.CygxIndustrialManagementNum)
- item.IndustryName = v.SubjectName
- list = append(list, item)
- }
- if len(list) == 0 {
- list = make([]*cygx.CygxIndustrialManagementNum, 0)
- }
- resp := new(cygx.GetIndustrialManagementList)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 移动产业
- // @Description 移动产业
- // @Param request body cygx.IndustryMove true "type json string"
- // @Success Ret=200 string "操作成功"
- // @router /industrialManagement/move [post]
- func (this *IndustrialManagementController) IndustryMove() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.IndustryMove
- if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
- return
- }
- if req.IndustrialManagementId <= 0 || req.ChartPermissionId <= 0 {
- br.Msg = "参数有误"
- return
- }
- item, e := cygx.GetIndustrialManagementInfo(req.IndustrialManagementId)
- if e != nil {
- br.Msg = "移动失败"
- br.ErrMsg = "获取产业信息失败, Err: " + e.Error()
- return
- }
- if item.ChartPermissionId == req.ChartPermissionId {
- br.Msg = "产业已在该行业下, 无需移动"
- return
- }
- updateCols := []string{"ChartPermissionId"}
- item.ChartPermissionId = req.ChartPermissionId
- if e = item.Update(updateCols); e != nil {
- br.Msg = "移动失败"
- br.ErrMsg = "更新产业信息失败, Err: " + e.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
|