1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381 |
- 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 IsHideResearch 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")
- isHideResearch, _ := this.GetBool("IsHideResearch")
- 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 || v.ChartPermissionId == utils.YAN_XUAN_KOU_DIAN_BAO_ID {
- continue
- }
- 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 {
- for _, v := range list {
- if (v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN || v.PermissionName == utils.YAN_XUAN_KOU_DIAN_BAO_NAME) && isHideResearch {
- continue
- }
- resp.List = append(resp.List, v)
- }
- // 查研观向7.4-新增一个宏观
- if !hideMacro {
- macro := &cygx.ChartPermission{
- ChartPermissionId: 1,
- PermissionName: "宏观",
- }
- resp.List = append(resp.List, macro)
- }
- }
- 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) OR ( chart_permission_name = '周期' AND product_id = 2 ) `
- }
- 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 || v.PermissionName == utils.GU_SHOU_NAME || v.PermissionName == utils.ZHOU_QI_NAME {
- resp.List = append(resp.List, v)
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 专项产业调研活动一级行业分类
- // @Description 专项产业调研活动一级行业分类接口
- // @Success 200 {object} cygx.ChartPermissionResp
- // @router /chartPermission/activitySpecial [get]
- func (this *IndustrialManagementController) ChartPermissionListActivitySpecial() {
- 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 || v.PermissionName == utils.GU_SHOU_NAME || v.PermissionName == utils.ZHOU_QI_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 = "操作成功"
- }
|