123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975 |
- package cygx
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "github.com/tealeg/xlsx"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/models/roadshow"
- "hongze/hz_crm_api/models/system"
- "hongze/hz_crm_api/services"
- cygxService "hongze/hz_crm_api/services/cygx"
- "hongze/hz_crm_api/utils"
- "html"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
- )
- // 报告管理
- type ReportArticleController struct {
- controllers.BaseAuthController
- }
- // @Title 主题列表
- // @Description 获取主题列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Success 200 {object} cygx.CygxReportMappingListRep
- // @router /reportMappingist/list [get]
- func (this *ReportArticleController) CygxReportMappingist() {
- 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
- }
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- if chartPermissionId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- list, err := cygx.CygxReportMappingist(chartPermissionId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxReportMappingListRep)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 报告匹配类型列表
- // @Description 获取报告匹配类型列表接口
- // @Success 200 {object} cygx.CygxReportMappingMatchTypeRep
- // @Param ChartPermissionId query int true "分类ID"
- // @router /reportMappingMatchTypeRep/list [get]
- func (this *ReportArticleController) CygxReportMappingMatchTypeList() {
- 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
- }
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- var condition string
- var pars []interface{}
- if chartPermissionId > 0 {
- condition += ` AND chart_permission_id = ? `
- pars = append(pars, chartPermissionId)
- }
- list, err := cygx.GetCygxReportMappingCygxList(condition, pars, 0, 0)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxCygxReportMappingCygxResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 报告列表
- // @Description 报告列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param IsFilter query int true "是否过滤 ,1是,0否,不传默认为0"
- // @Param IsClass query int true "是否归类 ,1是,0否 ,不传默认为0"
- // @Param ChartPermissionId query int true "行业ID --> 一级分类列表中 ChartPermissionId"
- // @Param SubCategoryName query string true "主题"
- // @Param MatchTypeName query string true "报告匹配类型"
- // @Param IndustrialManagementId int string true "产业ID"
- // @Param StartDate query string true "开始时间用0 补齐,列如2021-03-06 08:09:01"
- // @Param EndDate query string true "结束时间用0 补齐,列如2021-03-06 08:09:01"
- // @Param KeyWord query string true "搜索关键词"
- // @Param KeyWordStock query string true "搜索关键词.个股标签,关联标的部分"
- // @Success 200 {object} cygx.GetReportArticleListRep
- // @router /reportArticle/list [get]
- func (this *ReportArticleController) ReportArticleList() {
- 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
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- isFilter, _ := this.GetInt("IsFilter")
- isClass, _ := this.GetInt("IsClass")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- subCategoryName := this.GetString("SubCategoryName")
- matchTypeName := this.GetString("MatchTypeName")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- keyWord := this.GetString("KeyWord")
- keyWordStock := this.GetString("KeyWordStock")
- reportLabel := this.GetString("ReportLabel") // 查研观向7.4-报告标签
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- listPermission, errper := cygx.GetPermissionMappingCategoryID()
- if errper != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errper.Error()
- return
- }
- condition += ` AND art.is_report = 1 AND re.id !=28 `
- if isClass == 0 {
- condition += ` AND art.is_class = 0 `
- } else {
- condition += ` AND art.is_class = 1 `
- if industrialManagementId > 0 {
- condition += ` AND man.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
- }
- }
- if keyWord != "" {
- condition += ` AND (art.title LIKE '%` + keyWord + `%' ) `
- }
- //个股标签跟标的的搜索
- if keyWordStock != "" {
- condition += ` AND (art.stock LIKE '%` + keyWordStock + `%' OR art.article_id IN (SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN (SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWordStock + `%')) ) `
- }
- if isFilter == 0 {
- condition += ` AND art.is_filter = 0 `
- } else {
- condition += ` AND art.is_filter = 1 `
- }
- //行业
- if chartPermissionId > 0 {
- condition += ` AND re.chart_permission_id = ` + strconv.Itoa(chartPermissionId)
- }
- //主题
- if subCategoryName != "" {
- condition += ` AND art.sub_category_name = ` + "'" + subCategoryName + "' "
- }
- //发布时间
- if startDate != "" {
- condition += ` AND art.publish_date >= ` + "'" + startDate + " 00:00:00'"
- }
- if endDate != "" {
- condition += ` AND art.publish_date <= ` + "'" + endDate + " 23:59:59'"
- }
- //报告匹配类型
- if matchTypeName != "" && chartPermissionId > 0 {
- //condition += ` AND re.match_type_name = ` + "'" + matchTypeName + "' "
- //mappingCygxDetai, err := cygx.GetCygxReportMappingCygxDetailByNameAndChartPermissionId(matchTypeName, chartPermissionId)
- //if err != nil && err.Error() != utils.ErrNoRow() {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //if mappingCygxDetai == nil {
- // resp := new(cygx.GetReportArticleListRep)
- // resp.List = make([]*cygx.CygxReportArticle, 0)
- // page := paging.GetPaging(currentIndex, pageSize, 0)
- // resp.Paging = page
- // br.Ret = 200
- // br.Success = true
- // br.Msg = "获取成功"
- // br.Data = resp
- // return
- //}
- //这里量不大,走一下子查询
- //condition += ` AND art.category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(mappingCygxDetai.Id) + ` ) `
- condition += ` AND art.category_id IN ( SELECT category_id FROM cygx_report_mapping WHERE match_type_name = ` + "'" + matchTypeName + "'" + ` ) `
- }
- // 报告标签
- if reportLabel != "" {
- keywords := "%" + reportLabel + "%"
- // 查询包含关键词的产业/标的所关联的报告IDs
- artIds, e := cygx.GetArticleIdsFromIndustryAndSubjectGroupByKeyword(keywords)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "产业/标的关键词获取文章IDs失败, Err:" + e.Error()
- return
- }
- if len(artIds) > 0 {
- condition += ` AND art.article_id IN (` + utils.GetOrmInReplace(len(artIds)) + `)`
- pars = append(pars, artIds)
- }
- }
- total, err := cygx.GetReportArticleCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //return
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
- //fmt.Println(condition)
- list, err := cygx.GetReportArticleList(condition, pars, startSize, pageSize, isClass)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- reportMap := make(map[int]string)
- listMap, err := cygx.GetReportMapping()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取映射分类失败,Err:" + err.Error()
- return
- }
- for _, v := range listMap {
- reportMap[v.CategoryId] = v.MatchTypeName
- }
- var articleIds string
- for k, v := range list {
- var isShowButton bool
- if sysUser.RoleTypeCode == "rai_admin" || sysUser.RoleTypeCode == "rai_researcher" || sysUser.RoleTypeCode == "admin" {
- isShowButton = true
- } else {
- isShowButton = false
- }
- list[k].MatchTypeName = reportMap[v.CategoryId]
- list[k].ShowButton = true
- for _, vper := range listPermission {
- if v.CategoryId == vper.CategoryId {
- isShowButton = false
- }
- list[k].ShowButton = isShowButton
- }
- articleIds += strconv.Itoa(v.ArticleId) + ","
- }
- mapCommment := make(map[int]int)
- if articleIds != "" {
- articleIds = strings.TrimRight(articleIds, ",")
- condition = ` AND art.article_id IN (` + articleIds + `)`
- listPv, err := cygx.GetReportArticleListPvUv(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取PV,Uv 失败,Err:" + err.Error()
- return
- }
- var condition string
- var pars []interface{}
- condition = ` AND k.article_id IN (` + articleIds + `)`
- listComment, err := cygx.GetArticleCommentListSearch(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range listComment {
- mapCommment[v.ArticleId]++
- }
- if len(listPv) > 0 {
- for _, pv := range listPv {
- for k, v := range list {
- if v.ArticleId == pv.ArticleId {
- list[k].Pv = pv.Pv
- list[k].Uv = pv.Uv
- list[k].ClPv = pv.ClPv
- list[k].ClUv = pv.ClUv
- list[k].CollectionNum = pv.CollectionNum
- }
- }
- }
- }
- }
- //ListIndustrial []*IndustrialActivityGroupManagementRep
- //ListSubject []*SubjectActivityGroupManagementRep
- mapIndustrial := make(map[int]string)
- mapSubject := make(map[string]string)
- mapIndustrialList := make(map[int][]*cygx.IndustrialActivityGroupManagementRep)
- mapSubjectList := make(map[int][]*cygx.SubjectActivityGroupManagementRep)
- if articleIds != "" {
- industrialList, err := cygx.GetIndustrialArticleGroupListByarticleIds(articleIds)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetIndustrialArticleGroupListByarticleIds Err:" + err.Error()
- return
- }
- subjectList, err := cygx.GetSubjectArticleGroupListByarticleIds(articleIds)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetSubjectArticleGroupListByarticleIds Err:" + err.Error()
- return
- }
- //合并活动对应的多个标的
- for _, v := range subjectList {
- mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
- itemSubject := new(cygx.SubjectActivityGroupManagementRep)
- itemSubject.SubjectName = v.SubjectName
- itemSubject.IndustrialSubjectId = v.IndustrialSubjectId
- mapSubjectList[v.ArticleId] = append(mapSubjectList[v.ArticleId], itemSubject)
- }
- //活动对应的产业
- for _, v := range industrialList {
- var labelSubject string
- labelSubject = mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)]
- if labelSubject != "" {
- mapIndustrial[v.ArticleId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
- } else {
- mapIndustrial[v.ArticleId] += v.IndustryName + ","
- }
- itemindustrial := new(cygx.IndustrialActivityGroupManagementRep)
- itemindustrial.IndustryName = v.IndustryName
- itemindustrial.IndustrialManagementId = v.IndustrialManagementId
- mapIndustrialList[v.ArticleId] = append(mapIndustrialList[v.ArticleId], itemindustrial)
- }
- }
- for k, v := range list {
- if mapIndustrial[v.ArticleId] != "" {
- list[k].Label = strings.TrimRight(mapIndustrial[v.ArticleId], ",")
- }
- if v.SubCategoryName == "专项调研" {
- v.PublishDate = cygxService.ArticlePublishDate(v.PublishDate)
- }
- list[k].CommentNum = mapCommment[v.ArticleId]
- list[k].ListIndustrial = mapIndustrialList[v.ArticleId]
- list[k].ListSubject = mapSubjectList[v.ArticleId]
- if v.ReportId > 0 {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
- } else {
- list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(cygx.GetReportArticleListRep)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 过滤报告
- // @Description 过滤报告接口
- // @Param ReportId query int true "报告ID"
- // @Success Ret=200
- // @router /reportArticle/filter [post]
- func (this *IndustrialSubjectController) ReportArticleFilter() {
- 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
- }
- //if sysUser.RoleTypeCode != "rai_admin" && sysUser.RoleTypeCode != "rai_researcher" && sysUser.RoleTypeCode != "admin" {
- // br.Msg = "你没有操作权限请联系管理员"
- // return
- //}
- var req cygx.CygxReportArticleID
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- reportId := req.ReportId
- reportInfo, err := cygx.GetReportArticleId(reportId)
- if reportInfo == nil {
- br.Msg = "报告ID不存在!"
- return
- }
- if err != nil {
- br.Msg = "过滤失败!"
- br.ErrMsg = "过滤失败,Err:" + err.Error()
- return
- }
- if reportInfo.IsFilter == 1 {
- br.Msg = "您已过滤请勿重复操作!"
- return
- }
- if reportInfo.ReportType != 2 {
- br.Msg = "操作失败!"
- br.ErrMsg = "报告类型不属于产业报告!"
- return
- }
- err = cygx.FilterReportArticle(reportId)
- 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 request body cygx.ReportArticleClassificationResp true "type json string"
- // @Success Ret=200
- // @router /reportArticle/classification [post]
- func (this *IndustrialSubjectController) ReportArticleClassification() {
- 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
- }
- //if sysUser.RoleTypeCode != "rai_admin" && sysUser.RoleTypeCode != "rai_researcher" && sysUser.RoleTypeCode != "admin" {
- // br.Msg = "你没有操作权限请联系管理员"
- // return
- //}
- var req cygx.ReportArticleClassificationResp
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- var pars []interface{}
- var condition string
- reportId := req.ReportId
- industrialManagementIdStr := req.IndustrialManagementId
- reportInfo, _ := cygx.GetReportArticleId(reportId)
- if reportInfo == nil {
- br.Msg = "报告ID不存在!"
- return
- }
- if reportInfo.ReportType != 2 {
- br.Msg = "操作失败!"
- br.ErrMsg = "报告类型不属于产业报告!"
- return
- }
- industrialStrList := strings.Split(industrialManagementIdStr, ",")
- for _, v := range industrialStrList {
- condition = `AND industrial_management_id = ` + v
- totalIndustrialManagement, _ := cygx.GetIndustrialManagementCount(condition, pars)
- if totalIndustrialManagement < 1 {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,产业不存在IndustrialManagementId:" + v
- return
- }
- }
- if req.IndustrialSubjectIdStr != "0" && req.IndustrialSubjectIdStr != "" {
- strList := strings.Split(req.IndustrialSubjectIdStr, ",")
- for _, v := range strList {
- condition = `AND industrial_subject_id = ` + v + ` AND industrial_management_id IN ( ` + industrialManagementIdStr + `)`
- totalIndustrialSubject, _ := cygx.GetIndustrialSubjectCount(condition, pars)
- if totalIndustrialSubject < 1 {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,标的不存在IndustrialSubjectId:" + v
- return
- }
- }
- }
- err = cygx.ReportArticleClassificationEditNew(req.ReportId, industrialManagementIdStr, reportInfo.ArticleId, req.IndustrialSubjectIdStr)
- if err != nil {
- br.Msg = "分类失败"
- br.ErrMsg = "分类失败,Err:" + err.Error()
- return
- }
- go cygxService.DoArticleOnenIdWxTemplateMsg(reportInfo.ArticleId, 2)
- br.Ret = 200
- br.Success = true
- br.Msg = "分类成功"
- br.IsAddLog = true
- }
- // @Title 是否展示操作按钮
- // @Description 获取是否展示操作按钮接口
- // @Success Ret=200 {object} cygx.ShowButton
- // @router /reportArticle/showButton [get]
- func (this *IndustrialSubjectController) ShowButton() {
- 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.ShowButton)
- if sysUser.RoleTypeCode == "rai_admin" || sysUser.RoleTypeCode == "rai_researcher" || sysUser.RoleTypeCode == "admin" {
- resp.IsShowButton = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 下载阅读明细
- // @Description 获取下载阅读明细接口
- // @Param ReportId query int true "报告ID"
- // @Success Ret=200
- // @router /reportArticle/export [get]
- func (this *IndustrialSubjectController) Export() {
- 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
- }
- reportId, _ := this.GetInt("ReportId")
- //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
- resp := new(cygx.CanDownload)
- adminInfo, errAdmin := system.GetSysUserById(sysUser.AdminId)
- if errAdmin != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
- return
- }
- if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
- resp.IsCanDownload = true
- }
- var list []*cygx.ReportExportRep
- var err error
- if resp.IsCanDownload == false {
- //权益申请销售只能看到自己名下的客户的申请
- companyIds, err := cygxService.GetAdminLookUserCompanyIds(sysUser)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
- return
- }
- var companyIdstr []string
- for _, v := range companyIds {
- companyIdstr = append(companyIdstr, strconv.Itoa(v))
- }
- sqlStr := ` AND h.company_id IN (` + strings.Join(companyIdstr, ",") + `) `
- listSeller, errSeller := cygx.GetReportExportRep(reportId, sqlStr)
- list = listSeller
- err = errSeller
- } else {
- sqlStr := ""
- listAdmin, errAdmin := cygx.GetReportExportRep(reportId, sqlStr)
- list = listAdmin
- err = errAdmin
- }
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var listNew []*cygx.ReportExportRep
- for k, v := range list {
- if k > 0 && list[k].Id == list[k-1].Id {
- list[k-1].SellerName = list[k-1].SellerName + "/" + v.SellerName
- }
- }
- for k, v := range list {
- if k > 0 && list[k].Id != list[k-1].Id {
- listNew = append(listNew, v)
- }
- }
- //创建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,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("关键词搜索统计")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "公司名"
- cellC := rowTitle.AddCell()
- cellC.Value = "销售名称"
- cellD := rowTitle.AddCell()
- cellD.Value = "阅读时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "停留时间(s)"
- for _, item := range listNew {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.CompanyName
- cellC := row.AddCell()
- cellC.Value = item.SellerName
- cellD := row.AddCell()
- cellD.Value = item.CreateTime
- cellE := row.AddCell()
- cellE.Value = item.StopTime
- }
- 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 通过报告ID获取对应的匹配类型
- // @Description 通过报告ID获取对应的匹配类型接口
- // @Param ReportId query int true "报告ID"
- // @Success 200 {object} cygx.ReportMatchTypeNameList
- // @router /reportArticle/getMatchTypeName [get]
- func (this *IndustrialSubjectController) GetMatchTypeNameByReportId() {
- 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
- }
- reportId, _ := this.GetInt("ReportId")
- detail, err := cygx.GetArticleDetailById(reportId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- list, err := cygx.GetMatchTypeName(detail.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.ReportMatchTypeNameList)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 修改报告的匹配类型
- // @Description 修改报告的匹配类型接口
- // @Param request body cygx.UpdateReportMatchTypeNameRep true "type json string"
- // @Success Ret=200
- // @router /reportArticle/updateMatchTypeName [post]
- func (this *IndustrialSubjectController) UpdateMatchTypeName() {
- 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
- }
- var req cygx.UpdateReportMatchTypeNameRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- reportId := req.ReportId
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- detail, err := cygx.GetMatchTypeNameById(req.MatchID)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- detailArt, err := cygx.GetArticleDetailById(reportId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- err = cygx.UpdateReportMatchTypeName(detail.MatchTypeName, detail.ReportType, detail.CategoryId, req.ReportId, detailArt.IsSummary, detailArt.IsClass)
- if err != nil {
- br.Msg = "修改失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- go cygxService.DoArticleOnenIdWxTemplateMsg(detailArt.ArticleId, 2)
- go cygxService.AddCygxReportMappingCategoryGroupByArticleId(detailArt.ArticleId) // 手动修改报告归类
- go cygxService.UpdateArticleResourceData(detailArt.ArticleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "修改成功"
- br.IsAddLog = true
- }
- // @Title 报告内容的保存与发布
- // @Description 报告内容的保存与发布接口
- // @Param request body cygx.ReportAddRep true "type json string"
- // @Success 200 操作成功
- // @router /reportArticle/PreserveAndPublish [post]
- func (this *ReportArticleController) PreserveAndPublish() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req cygx.ReportAddRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Title == "" {
- br.Msg = "标题不可为空"
- br.ErrMsg = "标题不可为空"
- return
- }
- if req.Abstract == "" {
- br.Msg = "摘要不可为空"
- br.ErrMsg = "摘要不可为空"
- return
- }
- var articleId int
- industrialManagementIds := req.IndustrialManagementIds
- industrialSubjectIds := req.IndustrialSubjectIds
- chartPermissionId := req.ChartPermissionId
- publishDate := req.PublishDate
- if industrialManagementIds == "" {
- br.Msg = "请选择产业"
- return
- }
- if publishDate == "" {
- br.Msg = "请选择发布时间"
- return
- }
- industryIds := make([]int, 0)
- industrialManagementIdList := strings.Split(industrialManagementIds, ",")
- for _, v := range industrialManagementIdList {
- i, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIds
- return
- }
- industryIds = append(industryIds, i)
- }
- if industrialSubjectIds != "" {
- industrialSubjectIdList := strings.Split(industrialSubjectIds, ",")
- for _, v := range industrialSubjectIdList {
- _, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIds
- return
- }
- }
- }
- var pars []interface{}
- var condition string
- condition += ` AND chart_permission_id = ? AND sub_category_name = '专项调研' `
- pars = append(pars, chartPermissionId)
- charInfo, err := cygx.GetReportMappingDetail(condition, pars)
- if err != nil {
- br.Msg = "请选择所属行业"
- br.ErrMsg = "获取所属行业信息失败,Err:" + err.Error()
- return
- }
- var articleIdNew int
- if articleId == 0 {
- maxArticleIdArticleInfo, errMax := cygx.GetMaxArticleIdInfo()
- if errMax != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + errMax.Error()
- return
- }
- if maxArticleIdArticleInfo.ArticleId < utils.SummaryArticleId {
- articleIdNew = utils.SummaryArticleId
- } else {
- articleIdNew = maxArticleIdArticleInfo.ArticleId + 1
- }
- }
- expertNumStr, expertContentStr, interviewDateStr, fileLink := cygx.BodyAnalysis(req.Body)
- item := new(cygx.CygxArticle)
- item.AdminId = AdminUser.AdminId
- item.AdminName = AdminUser.AdminName
- item.Title = req.Title
- item.Body = cygxService.GetRichtext(req.Body)
- item.BodyText, _ = cygx.GetReportContentTextSub(item.Body)
- item.Abstract = req.Abstract
- item.CategoryName = charInfo.MatchTypeName
- item.SubCategoryName = charInfo.SubCategoryName
- item.ArticleId = articleId
- item.CreateDate = time.Now()
- item.LastUpdatedTime = time.Now()
- item.IsReport = 1
- item.IsSummary = 1
- item.Source = 1
- item.IsClass = 1
- item.IsReport = 1
- item.ReportType = 2
- item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdNew))
- item.UpdateFrequency = "unknow"
- item.SellerAndMobile = req.SellerAndMobile
- item.ExpertBackground = expertContentStr
- item.ExpertNumber = expertNumStr
- item.InterviewDate = interviewDateStr
- item.FileLink = fileLink
- item.CategoryId = charInfo.CategoryId
- item.CategoryIdTwo = charInfo.CategoryId
- item.ChartPermissionIds = strconv.Itoa(chartPermissionId)
- item.PublishDate = utils.StrTimeToTime(publishDate + " 00:00:00") //时间字符串格式转时间格式
- //处理作者内容的格式信息
- if req.DoType == 1 {
- item.PublishStatus = 1
- }
- itemDepartment := new(cygx.CygxArticleDepartment)
- if req.ArticleId == 0 {
- item.ArticleId = articleIdNew
- //需求修改纪要的新增与修改与报告一致
- _, err := cygx.AddAReportrticle(item, 0, "", "", itemDepartment, industrialManagementIds, industrialSubjectIds)
- if err != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + err.Error()
- return
- }
- } else {
- articleInfo, err := cygx.GetArticleIdInfoByArticleId(req.ArticleId)
- if err != nil {
- br.Msg = "文章不存在"
- return
- }
- if item.PublishStatus == 0 {
- item.PublishStatus = articleInfo.PublishStatus
- }
- item.ArticleId = req.ArticleId
- err = cygx.EditReportrticle(item, 0, "", "", articleInfo.PublishStatus, itemDepartment, industrialManagementIds, industrialSubjectIds)
- if err != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + err.Error()
- return
- }
- }
- //if req.DoType == 1 {
- // go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
- //}
- //{|1|}表示报告类型,{|2|}表示纪要类型
- //cygx.UpdateSubjecIds(subjectIds+"—"+strconv.Itoa(industrialDetail.IndustrialManagementId)+"{|2|}", industrialDetail.IndustrialManagementId, articleId)
- if item.PublishStatus == 1 {
- services.EsAddOrEditData(item)
- //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
- go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
- }
- // 查研观向7.4-更新产业布局时间
- if len(industryIds) > 0 {
- go cygxService.UpdateIndustryLayoutTime(industryIds, false)
- }
- if len(industryIds) > 0 && req.DoType == 1 {
- //查研观向8.2.1专项调研报告模板消息推送
- cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
- }
- go cygxService.AddCygxReportMappingCategoryGroupByArticleId(item.ArticleId) // 手动修改报告归类
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 报告详情
- // @Description 获取报告详情接口
- // @Param ReportId query int true "报告ID"
- // @Success Ret=200 {object} cygx.CygxArticleReport
- // @router /reportArticle/detail [get]
- func (this *ReportArticleController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- //reportId, _ := this.GetInt("ReportId")
- //if reportId < 1 {
- // br.Msg = "请输入报告ID"
- // return
- //}
- //articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(reportId)
- //if err != nil {
- // br.Msg = "报告不存在"
- // br.ErrMsg = "报告ID错误,Err:" + err.Error()
- // return
- //}
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 1 {
- br.Msg = "请输入文章ID"
- return
- }
- articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(articleId)
- if err != nil {
- br.Msg = "文章内容不存在"
- br.ErrMsg = "纪要ID错误,Err:" + err.Error()
- return
- }
- industrialList, err := cygx.GetIndustrialArticleGroupManagementList(articleInfo.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
- return
- }
- subjectList, err := cygx.GetSubjectArticleGroupManagementList(articleInfo.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
- return
- }
- articleInfo.PublishDate = cygxService.ArticlePublishDate(articleInfo.PublishDate)
- articleInfo.ListIndustrial = industrialList
- articleInfo.ListSubject = subjectList
- if articleInfo.ChartPermissionIds != "" {
- chartPermissionIdArr := strings.Split(articleInfo.ChartPermissionIds, ",")
- if len(chartPermissionIdArr) > 0 {
- articleInfo.ChartPermissionId, _ = strconv.Atoi(chartPermissionIdArr[0])
- }
- }
- if articleId < utils.SummaryArticleId {
- articleInfo.Abstract, _ = cygx.GetReportContentTextSub(articleInfo.Abstract)
- articleInfo.Body = html.UnescapeString(articleInfo.Body)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = articleInfo
- }
- // @Title 获取作者列表
- // @Description 获取作者列表接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success Ret=200 {object} cygx.CygxArticleDepartmentList
- // @router /reportArticle/departmentList [get]
- func (this *ReportArticleController) DepartmentList() {
- 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
- keyWord := this.GetString("KeyWord")
- if keyWord != "" {
- condition = `WHERE nick_name LIKE'%` + keyWord + `%' ORDER BY create_time DESC `
- } else {
- condition += ` ORDER BY create_time DESC`
- }
- list, err := cygx.GetCygxArticleDepartmentList(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxArticleDepartmentList)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 下载客户阅读记录
- // @Description 下载客户阅读记录接口
- // @Param CompanyId query int true "公司ID"
- // @Success Ret=200
- // @router /reportArticle/companyHistory [get]
- func (this *IndustrialSubjectController) CompanyHistory() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId < 1 {
- br.Msg = "请输入公司ID"
- return
- }
- //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
- var isCanDownload bool
- adminInfo, err := system.GetSysUserById(sysUser.AdminId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if adminInfo.Role == "admin" || strings.Index(adminInfo.RoleTypeCode, "rai") > -1 {
- isCanDownload = true
- }
- if !isCanDownload {
- br.Msg = "暂无下载权限"
- return
- }
- //获取企业客户信息
- companyInfo, err := company.GetCompanyById(companyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取企业客户信息失败,Err:" + err.Error()
- return
- }
- mapChartPermissionName := make(map[int]string)
- listMap, err := cygx.GetPermissionMappingCategoryAll()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range listMap {
- mapChartPermissionName[v.CategoryId] = v.ChartPermissionName
- }
- mobiles, err := models.GetCompanyUserMobilesByCompanyId(companyId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户手机号信息失败,Err:" + err.Error()
- return
- }
- if mobiles != "" {
- mobiles = strings.Replace(mobiles, ",", "','", -1)
- mobiles = "'" + mobiles + "'"
- } else {
- mobiles = "'1'"
- }
- emails, err := models.GetCompanyUserEmailsByCompanyId(companyId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户邮箱信息失败,Err:" + err.Error()
- return
- }
- if emails != "" {
- emails = strings.Replace(emails, ",", "','", -1)
- emails = "'" + emails + "'"
- } else {
- emails = "'1'"
- }
- list, err := cygx.GetCompanyHistoryRecordNewPv(mobiles, emails)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- list[k].PermissionName = mapChartPermissionName[v.CategoryId]
- }
- //创建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,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("客户阅读记录")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号/邮箱"
- cellC := rowTitle.AddCell()
- cellC.Value = "报告标题"
- cellD := rowTitle.AddCell()
- cellD.Value = "所属行业"
- cellE := rowTitle.AddCell()
- cellE.Value = "所属产业"
- cellF := rowTitle.AddCell()
- cellF.Value = "关联标的"
- cellG := rowTitle.AddCell()
- cellG.Value = "发布时间"
- cellH := rowTitle.AddCell()
- cellH.Value = "阅读时间"
- cellI := rowTitle.AddCell()
- cellI.Value = "阅读时长"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.Mobile
- if item.Mobile == "" {
- cellB.Value = item.Email
- }
- cellC := row.AddCell()
- cellC.Value = item.Title
- cellD := row.AddCell()
- if item.CategoryId == 0 {
- cellD.Value = "研选"
- } else {
- cellD.Value = item.PermissionName
- }
- cellE := row.AddCell()
- cellE.Value = item.IndustryName
- cellF := row.AddCell()
- cellF.Value = item.SubjectNameStr
- cellG := row.AddCell()
- cellG.Value = item.PublishDate
- cellH := row.AddCell()
- cellH.Value = item.CreateTime
- cellI := row.AddCell()
- cellI.Value = item.StopTime
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := companyInfo.CompanyName + "阅读记录" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // @Title 客户其他行为数据
- // @Description 下载客户其他行为数据接口
- // @Param CompanyId query int true "公司ID"
- // @Success Ret=200
- // @router /reportArticle/companyOtherHistory [get]
- func (this *IndustrialSubjectController) CompanyOtherHistory() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "请选择客户"
- br.ErrMsg = "客户参数错误"
- return
- }
- //获取企业客户信息
- companyInfo, err := company.GetCompanyById(companyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取企业客户信息失败,Err:" + err.Error()
- return
- }
- var condition string
- var pars []interface{}
- //非管理员,那么只能看到该产品下的联系人
- if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
- productId := services.GetProductId(sysUser.RoleTypeCode)
- condition += ` AND b.product_id = ? `
- pars = append(pars, productId)
- //流失客户(除非是超级管理员或者是部门管理员,要不然不允许看对应的联系人)
- var companyProduct *company.CompanyProduct
- if productId == 2 && sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_RAI_ADMIN {
- // 当前是权益权限,且非 权益管理员
- tmpCompanyProduct, _ := company.GetCompanyProductByCompanyIdAndProductId(companyId, 2)
- companyProduct = tmpCompanyProduct
- if companyProduct != nil && companyProduct.Status == utils.COMPANY_STATUS_LOSE {
- condition += ` AND seller_id=? `
- pars = append(pars, sysUser.AdminId)
- }
- }
- }
- list, err := company.GetCompanyUserListV2(condition, pars, companyId, 0, 1000)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var userIdstr string
- for _, v := range list {
- userIdstr += strconv.Itoa(int(v.UserId)) + ","
- }
- userIdstr = strings.TrimRight(userIdstr, ",")
- resp := new(cygx.CompanyOtherHistoryListResp)
- condition = ` AND user_id IN (` + userIdstr + `)`
- listArticle, err := cygx.GetArticleCollectList(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- listIndustry, err := cygx.GetCygxIndustryList(companyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- listDepartment, err := cygx.GetArticleDepartmentList(companyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- //listkeyWord, err := cygx.GetCygxUserSearchKeyWordList(userIdstr)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取数据失败,Err:" + err.Error()
- // return
- //}
- //listkeyWord, err := cygx.GetCygxUserSearchKeyWordList(userIdstr)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取数据失败,Err:" + err.Error()
- // return
- //}
- for _, v := range list {
- userItem := new(cygx.CompanyOtherHistoryList)
- var artItems []*cygx.CygxArticleCollect
- var industryItems []*cygx.CygxArticleIndustry
- var departmentItems []*cygx.ArticleDepartment
- //var keyWordItems []*cygx.KeyWord
- for _, vArt := range listArticle {
- if vArt.UserId == int(v.UserId) {
- artItems = append(artItems, vArt)
- }
- }
- for _, vIn := range listIndustry {
- if vIn.UserId == int(v.UserId) {
- industryItems = append(industryItems, vIn)
- }
- }
- for _, vDe := range listDepartment {
- if vDe.UserId == int(v.UserId) {
- departmentItems = append(departmentItems, vDe)
- }
- }
- //for _, vKw := range listkeyWord {
- // if vKw.UserId == int(v.UserId) {
- // keyWordItems = append(keyWordItems, vKw)
- // }
- //}
- if len(artItems) > 0 || len(industryItems) > 0 || len(departmentItems) > 0 {
- userItem.RealName = v.RealName
- userItem.Email = v.Email
- userItem.Mobile = v.Mobile
- userItem.ListArticle = artItems
- userItem.ListIndustrial = industryItems
- userItem.ListDepartment = departmentItems
- //userItem.ListKeyWord = keyWordItems
- resp.List = append(resp.List, userItem)
- }
- }
- //创建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,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("客户其他行为数据(收藏,关注)")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标题样式
- titleStyle := xlsx.NewStyle()
- titleFont := xlsx.NewFont(16, "宋体")
- titleFont.Bold = true
- titleStyle.Font = *titleFont
- titleStyle.Alignment = alignment
- sheet.SetColWidth(0, 0, 20)
- sheet.SetColWidth(1, 1, 20)
- sheet.SetColWidth(2, 2, 20)
- sheet.SetColWidth(3, 3, 20)
- sheet.SetColWidth(4, 4, 20)
- titleSonStyle := xlsx.NewStyle()
- titleSonFont := xlsx.NewFont(16, "宋体")
- titleSonFont.Bold = true
- titleSonStyle.Font = *titleSonFont
- for _, item := range resp.List {
- rowTitle := sheet.AddRow()
- //标题列
- titleCell := rowTitle.AddCell()
- titleCell.HMerge = 6 //向右合并列数,不包括自身列
- titleCell.SetValue("客户姓名:" + item.RealName + " 手机号/邮箱:" + item.Mobile)
- titleCell.SetStyle(titleStyle)
- //文章
- if len(item.ListArticle) > 0 {
- rowArticle := sheet.AddRow()
- cellA := rowArticle.AddCell()
- cellA.Value = "收藏报告"
- cellB := rowArticle.AddCell()
- cellB.Value = "收藏时间"
- cellC := rowArticle.AddCell()
- cellC.Value = "发布时间"
- cellD := rowArticle.AddCell()
- cellD.Value = "报告类型"
- cellE := rowArticle.AddCell()
- cellE.Value = "所属产业"
- cellF := rowArticle.AddCell()
- cellF.Value = "关联标的"
- cellA.SetStyle(titleSonStyle)
- cellB.SetStyle(titleSonStyle)
- cellC.SetStyle(titleSonStyle)
- cellD.SetStyle(titleSonStyle)
- cellE.SetStyle(titleSonStyle)
- cellF.SetStyle(titleSonStyle)
- for _, vArt := range item.ListArticle {
- rowArticleVal := sheet.AddRow()
- cellA := rowArticleVal.AddCell()
- cellA.Value = vArt.Title
- cellB := rowArticleVal.AddCell()
- cellB.Value = vArt.CreateTime
- cellC := rowArticleVal.AddCell()
- cellC.Value = vArt.PublishDate
- cellD := rowArticleVal.AddCell()
- cellD.Value = vArt.MatchTypeName
- cellE := rowArticleVal.AddCell()
- cellE.Value = vArt.IndustryName
- cellF := rowArticleVal.AddCell()
- cellF.Value = vArt.SubjectName
- }
- }
- //产业
- if len(item.ListIndustrial) > 0 {
- rowIndustrial := sheet.AddRow()
- cellA := rowIndustrial.AddCell()
- cellA.Value = "关注产业"
- cellB := rowIndustrial.AddCell()
- cellB.Value = "关注时间"
- cellA.SetStyle(titleSonStyle)
- cellB.SetStyle(titleSonStyle)
- for _, vArt := range item.ListIndustrial {
- rowIndustrialVal := sheet.AddRow()
- cellA := rowIndustrialVal.AddCell()
- cellA.Value = vArt.IndustryName
- cellB := rowIndustrialVal.AddCell()
- cellB.Value = vArt.CreateTime
- }
- }
- //作者
- if len(item.ListDepartment) > 0 {
- rowDepartment := sheet.AddRow()
- cellA := rowDepartment.AddCell()
- cellA.Value = "关注作者"
- cellB := rowDepartment.AddCell()
- cellB.Value = "关注时间"
- cellC := rowDepartment.AddCell()
- cellC.Value = "作者相关产业"
- cellA.SetStyle(titleSonStyle)
- cellB.SetStyle(titleSonStyle)
- cellC.SetStyle(titleSonStyle)
- for _, vArt := range item.ListDepartment {
- rowDepartmentVal := sheet.AddRow()
- cellA := rowDepartmentVal.AddCell()
- cellA.Value = vArt.NickName
- cellB := rowDepartmentVal.AddCell()
- cellB.Value = vArt.CreateTime
- cellC := rowDepartmentVal.AddCell()
- cellC.Value = vArt.IndustryName
- }
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := companyInfo.CompanyName + "其他行为数据(收藏,关注)" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Data = resp
- br.Success = true
- br.Msg = "导出成功"
- }
- // @Title 客户阅读量月度统计
- // @Description 客户阅读量月度统计
- // @Param CompanyId query int true "公司ID"
- // @Success Ret=200
- // @router /reportArticle/companyCount [get]
- func (this *IndustrialSubjectController) CompanyCount() {
- 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
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId < 1 {
- br.Msg = "请输入公司ID"
- return
- }
- //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
- var isCanDownload bool
- adminInfo, err := system.GetSysUserById(sysUser.AdminId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if adminInfo.Role == "admin" || strings.Index(adminInfo.RoleTypeCode, "rai") > -1 {
- isCanDownload = true
- }
- if !isCanDownload {
- br.Msg = "暂无下载权限"
- return
- }
- //获取企业客户信息
- companyInfo, err := company.GetCompanyById(companyId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取企业客户信息失败,Err:" + err.Error()
- return
- }
- mobiles, err := models.GetCompanyUserMobilesByCompanyId(companyId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户手机号信息失败,Err:" + err.Error()
- return
- }
- if mobiles != "" {
- mobiles = strings.Replace(mobiles, ",", "','", -1)
- mobiles = "'" + mobiles + "'"
- } else {
- mobiles = "'1'"
- }
- emails, err := models.GetCompanyUserEmailsByCompanyId(companyId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户邮箱信息失败,Err:" + err.Error()
- return
- }
- if emails != "" {
- emails = strings.Replace(emails, ",", "','", -1)
- emails = "'" + emails + "'"
- } else {
- emails = "'1'"
- }
- listDate, err := cygx.GetCompanyHistoryRecordPvGroupDate(mobiles, emails)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- dateMap := make(map[string]int)
- permissionNameMap := make(map[string]int)
- list, err := cygx.GetCompanyHistoryRecordPv(mobiles, emails)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range list {
- if dateMap[v.CreateTime] == 0 {
- dateMap[v.CreateTime] = 1
- } else {
- dateMap[v.CreateTime] += 1
- }
- if v.CategoryId == 0 {
- v.PermissionName = "研选"
- }
- if permissionNameMap[v.CreateTime+v.PermissionName] == 0 {
- permissionNameMap[v.CreateTime+v.PermissionName] = 1
- } else {
- permissionNameMap[v.CreateTime+v.PermissionName] += 1
- }
- }
- //创建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,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("客户阅读量月度统计")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "月份"
- cellB := rowTitle.AddCell()
- cellB.Value = "总阅读数"
- cellC := rowTitle.AddCell()
- cellC.Value = "医药"
- cellD := rowTitle.AddCell()
- cellD.Value = "消费"
- cellE := rowTitle.AddCell()
- cellE.Value = "科技"
- cellF := rowTitle.AddCell()
- cellF.Value = "智造"
- cellG := rowTitle.AddCell()
- cellG.Value = "策略"
- cellH := rowTitle.AddCell()
- cellH.Value = "研选"
- for _, item := range listDate {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.CreateTimes
- cellB := row.AddCell()
- cellB.Value = strconv.Itoa(dateMap[item.CreateTimes])
- cellC := row.AddCell()
- cellC.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"医药"])
- cellD := row.AddCell()
- cellD.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"消费"])
- cellE := row.AddCell()
- cellE.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"科技"])
- cellF := row.AddCell()
- cellF.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"智造"])
- cellG := row.AddCell()
- cellG.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"策略"])
- cellH := row.AddCell()
- cellH.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"研选"])
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := companyInfo.CompanyName + "客户阅读量月度统计" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Ret = 200
- br.Success = true
- br.Msg = "导出成功"
- }
- // @Title 客户导出文件种类
- // @Description 客户导出文件种类接口
- // @Success Ret=200 {object} cygx.NameAndUrlList
- // @router /company/exportList [get]
- func (this *ReportArticleController) ExportList() {
- 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
- }
- detail, err := cygx.GetCygxConfigDetailByCode("export_list")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.NameAndUrlList)
- exportList := strings.Split(detail.ConfigValue, "{|}")
- for _, v := range exportList {
- item := new(cygx.NameAndUrl)
- vslice := strings.Split(v, "_")
- item.Name = vslice[0]
- item.Url = vslice[len(vslice)-1]
- resp.List = append(resp.List, item)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 留言列表详情
- // @Description 获取留言列表详情接口
- // @Param ArticleId query int true "文章ID"
- // @Success 200 {object} cygx.ArticleCommentListResp
- // @router /reportArticle/commentList [get]
- func (this *ReportArticleController) CommentList() {
- 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
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "报告ID错误"
- return
- }
- list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
- resp := new(cygx.ArticleCommentListResp)
- if err != nil {
- br.Msg = "获取留言失败"
- br.ErrMsg = "获取留言失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 提问详情excel表格下载
- // @Description 提问详情excel表格下载接口
- // @Param SummaryManageId query int true "纪要ID"
- // @Success 200 导出成功
- // @router /reportArticle/commnetListExport [get]
- func (this *ReportArticleController) CommentListExport() {
- 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
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "报告ID错误"
- return
- }
- list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
- 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,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("名单")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "公司名称"
- cellC := rowTitle.AddCell()
- cellC.Value = "留言"
- cellD := rowTitle.AddCell()
- cellD.Value = "提交时间"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.CompanyName
- cellC := row.AddCell()
- cellC.Value = item.Content
- cellD := row.AddCell()
- cellD.Value = item.CreateTime
- }
- 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.Success = true
- br.Ret = 200
- br.Msg = "导出成功"
- }
- // @Title 新建报告类型
- // @Description 新建报告类型接口
- // @Param request body cygx.CygxReportMappingCygxAdd true "type json string"
- // @Success Ret=200 {object} cygx.CygxReportMappingCygx
- // @router /reportMapping/add [post]
- func (this *IndustrialSubjectController) ReportMappingAdd() {
- 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.CygxReportMappingCygxAdd
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- var condition string
- var pars []interface{}
- reportType := req.ReportType
- chartPermissionId := req.ChartPermissionId
- chartPermissionName := req.ChartPermissionName
- matchTypeName := req.MatchTypeName
- condition = ` AND match_type_name = ? AND chart_permission_id = ? `
- pars = append(pars, matchTypeName, chartPermissionId)
- total, err := cygx.GetCygxReportMappingCygxCount(condition, pars)
- if err != nil {
- br.Msg = "新建报告类型失败"
- br.ErrMsg = "新建报告类型失败,Err:" + err.Error()
- return
- }
- if total > 0 {
- br.Msg = "名称已存在"
- br.ErrMsg = "名称已存在,Err:" + matchTypeName
- return
- }
- maxDeatil, err := cygx.GetCygxReportMappingCelueMaxDetail()
- if err != nil {
- br.Msg = "新建报告类型失败"
- br.ErrMsg = "GetCygxReportMappingCelueMaxDetail,Err:" + err.Error()
- return
- }
- itemCygx := new(cygx.CygxReportMappingCygx)
- itemCygx.ChartPermissionId = chartPermissionId
- itemCygx.ChartPermissionName = chartPermissionName
- itemCygx.MatchTypeName = matchTypeName
- itemCygx.ReportType = reportType
- itemCygx.IsReport = 1
- itemCygx.CreateTime = time.Now()
- itemCygx.ModifyTime = time.Now()
- itemCelue := new(cygx.CygxReportMappingCelue)
- itemCelue.ChartPermissionId = chartPermissionId
- itemCelue.ChartPermissionName = chartPermissionName
- itemCelue.SubCategoryName = matchTypeName
- itemCelue.ReportType = reportType
- itemCelue.IsReport = 1
- itemCelue.CategoryId = maxDeatil.CategoryId + 1
- itemCelue.CreateTime = time.Now()
- itemCelue.ModifyTime = time.Now()
- itemCygxId, err := cygx.AddCygxReportMappingCygx(itemCygx, itemCelue)
- if err != nil {
- br.Msg = "新建报告类型失败"
- br.ErrMsg = "AddCygxReportMappingCygx,Err:" + err.Error()
- return
- }
- resp := new(cygx.CygxReportMappingCygx)
- resp.Id = int(itemCygxId)
- resp.MatchTypeName = matchTypeName
- br.Ret = 200
- br.Success = true
- br.Data = resp
- br.Msg = "分类成功"
- br.IsAddLog = true
- }
- func init() {
- initart()
- }
- func initart() {
- //行业
- var condition string
- var pars []interface{}
- condition += ` AND re.chart_permission_id = 62 `
- //报告匹配类型
- //9.5 13:52
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
- listart, err := cygx.GetReportArticleList(condition, pars, 0, 2000, 1)
- if err != nil {
- fmt.Println(err)
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "PV"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellAt := rowTitle.AddCell()
- cellAt.Value = "标题"
- cellPd := rowTitle.AddCell()
- cellPd.Value = "发布时间"
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名称"
- cellD := rowTitle.AddCell()
- cellD.Value = "所属销售"
- cellDfw := rowTitle.AddCell()
- cellDfw.Value = "服务销售"
- cellDCreatedTime := rowTitle.AddCell()
- cellDCreatedTime.Value = "阅读时间(最后一次)"
- cellE := rowTitle.AddCell()
- cellE.Value = "停留时长(多次合计))"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读来源"
- cellStatus := rowTitle.AddCell()
- cellStatus.Value = "客户状态"
- cellTc := rowTitle.AddCell()
- cellTc.Value = "签约套餐"
- hasmobile := make(map[string]bool)
- for _, v := range listart {
- articleId := v.ArticleId
- condition = ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
- list, err := cygx.GetArticleHistoryList(articleId, condition)
- if err != nil {
- fmt.Println(err)
- return
- }
- //上一次的阅读记录
- list_H, err := cygx.GetArticleHistoryList_H(articleId, condition)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapArticle_H := make(map[string]bool)
- for _, vPv := range list_H {
- if !utils.ValidateMobileFormatat(vPv.Mobile) {
- continue
- }
- mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] = true
- }
- listClPv, err := cygx.GetCygxCelueArticleHistoryRecordPvAll(strconv.Itoa(articleId))
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println(err)
- return
- }
- listClPv_H, err := cygx.GetCygxCelueArticleHistoryRecordPvAll_H(strconv.Itoa(articleId))
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println(err)
- return
- }
- for _, vPv := range listClPv_H {
- if !utils.ValidateMobileFormatat(vPv.Mobile) {
- continue
- }
- mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] = true
- }
- var listDate []*cygx.ArticleHistoryRep
- var mobiles []string
- var mapMobileCy = make(map[string]bool)
- var mapMobileCl = make(map[string]bool)
- mapstopTime := make(map[string]int)
- if len(list) > 0 {
- for _, vPv := range list {
- if !utils.ValidateMobileFormatat(vPv.Mobile) {
- continue
- }
- if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
- continue
- }
- mobiles = append(mobiles, vPv.Mobile)
- stopTime, _ := strconv.Atoi(vPv.StopTime)
- mapstopTime[vPv.Mobile] += stopTime
- }
- }
- if len(listClPv) > 0 {
- for _, vPv := range listClPv {
- if !utils.ValidateMobileFormatat(vPv.Mobile) {
- continue
- }
- vPv.Ly = "1"
- //if vPv.Mobile != "" {
- mobiles = append(mobiles, vPv.Mobile)
- //}
- if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
- continue
- }
- }
- }
- listUser, err := models.GetWxUserRaiSllerListByUserMobile(mobiles)
- if err != nil {
- fmt.Println(err)
- return
- }
- listUserFicc, err := models.GetWxUserRaiSllerListByUserMobileFiic(mobiles)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapuserMapbil := make(map[string]*models.WxUserSller)
- var companyIds []int
- for _, vuser := range listUser {
- //mapuserMapbil[vuser.Mobile] = vuser
- companyIds = append(companyIds, vuser.CompanyId)
- }
- //合并合同所对应的权限
- mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
- if err != nil {
- fmt.Println(err)
- return
- }
- //fmt.Println(companyIds)
- //for k, vuser := range mappermissionName {
- // fmt.Println(k, vuser)
- //}
- //fmt.Println(mappermissionName)
- for _, vuser := range listUser {
- vuser.ChartPermissionName = mappermissionName[vuser.CompanyId]
- mapuserMapbil[vuser.Mobile] = vuser
- }
- for _, vuser := range listUserFicc {
- vuser.Status = ""
- vuser.SellerName = ""
- if mapuserMapbil[vuser.Mobile] == nil {
- mapuserMapbil[vuser.Mobile] = vuser
- }
- }
- if len(list) > 0 {
- for _, vPv := range list {
- if !utils.ValidateMobileFormatat(vPv.Mobile) || mapMobileCy[vPv.Mobile] {
- continue
- }
- if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
- continue
- }
- if hasmobile[vPv.Mobile] {
- continue
- }
- hasmobile[vPv.Mobile] = true
- mapMobileCy[vPv.Mobile] = true
- listDate = append(listDate, vPv)
- }
- }
- if len(listClPv) > 0 {
- for _, vPv := range listClPv {
- if !utils.ValidateMobileFormatat(vPv.Mobile) || mapMobileCl[vPv.Mobile] {
- continue
- }
- if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
- continue
- }
- if hasmobile[vPv.Mobile] {
- continue
- }
- hasmobile[vPv.Mobile] = true
- mapMobileCl[vPv.Mobile] = true
- listDate = append(listDate, vPv)
- }
- }
- //rowtitle := sheet.AddRow()
- //cellADatatitle := rowtitle.AddCell()
- //cellADatatitle.Value = v.Title
- for _, item := range listDate {
- row := sheet.AddRow()
- cellADatatitle := row.AddCell()
- cellADatatitle.Value = v.Title
- cellADataPd := row.AddCell()
- cellADataPd.Value = v.PublishDate
- cellAData := row.AddCell()
- cellAData.Value = item.RealName
- //if item.Ly == "1" {
- // cellAData.SetStyle(redStyle)
- //}
- cellBData := row.AddCell()
- cellBData.Value = item.Mobile
- cellCData := row.AddCell()
- //cellCData.Value = item.CompanyName
- cellDData := row.AddCell()
- cellDDataFw := row.AddCell()
- //cellDData.Value = item.SellerName
- cellEData := row.AddCell()
- cellEData.Value = item.CreateTime
- cellFData := row.AddCell()
- if item.Ly == "" {
- cellFData.Value = strconv.Itoa(mapstopTime[item.Mobile])
- }
- //fmt.Println(item.Source)
- cellLyData := row.AddCell()
- switch item.Source {
- case "MOBILE":
- cellLyData.Value = "小程序"
- case "WEB":
- cellLyData.Value = "网页版"
- case "CELUE":
- cellLyData.Value = "vmp"
- }
- cellStatusData := row.AddCell()
- cellermissionNameData := row.AddCell()
- if mapuserMapbil[item.Mobile] != nil {
- cellCData.Value = mapuserMapbil[item.Mobile].CompanyName
- cellDData.Value = mapuserMapbil[item.Mobile].SellerName
- cellDDataFw.Value = mapuserMapbil[item.Mobile].ShareSeller
- cellStatusData.Value = mapuserMapbil[item.Mobile].Status
- cellermissionNameData.Value = mapuserMapbil[item.Mobile].ChartPermissionName
- if mapuserMapbil[item.Mobile].RealName != "" {
- cellAData.Value = mapuserMapbil[item.Mobile].RealName
- }
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- }
- func initAct() {
- var condition string
- mapMobile := make(map[string]bool)
- mapuserMapbil := make(map[int]*models.WxUserSller)
- //var activityIds []int
- //activityIds = []int{5590, 5658, 5734, 5747, 5805, 5833, 5832, 5865, 5887, 5872, 5889, 5870, 5892, 5890, 5935, 5976, 5946, 6005,6062} // 2024-12-19 15:55
- //activityIds = []int{6005} // 2024-10-31 17:15
- //activityIds = []int{6052} // 2024-11-07 16:45
- activity_ids := " 5590, 5658, 5734, 5747, 5805, 5833, 5832, 5865, 5887, 5872, 5889, 5870, 5892, 5890, 5935, 5976, 5946, 6005,6062,6174,6224,6254 "
- condition = " AND s.activity_id IN (" + activity_ids + ") AND ( is_meeting = 1 OR duration != '' ) AND s.create_time < '2024-12-12 15:30' "
- listH, err := cygx.GetActivityMeetByUser(condition, 0, 9999)
- if err != nil {
- fmt.Println(err)
- return
- }
- mobileMap := make(map[string]bool)
- for _, v := range listH {
- mobileMap[v.Mobile] = true
- }
- fmt.Println(mobileMap)
- condition = " AND s.activity_id IN (" + activity_ids + ") AND ( is_meeting = 1 OR duration != '' ) AND s.create_time > '2024-12-12 15:30' "
- list, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
- fmt.Println(list)
- fmt.Println()
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println(err)
- return
- }
- var listData []*cygx.UserInteraction
- //for _, vid := range activityIds {
- // activityId := strconv.Itoa(vid)
- //
- // //activityId := "5865"
- // //condition = " AND s.activity_id = " + activityId + " AND duration != '' AND s.create_time < '2024-09-06 09:20' "
- // //condition = " AND s.activity_id = " + activityId + " AND (is_meeting = 1 OR AND duration != '' ) AND s.create_time < '2024-09-13 10:30' "
- // //list_H, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
- // //if err != nil && err.Error() != utils.ErrNoRow() {
- // // fmt.Println(err)
- // // return
- // //}
- // //
- // //for _, v := range list_H {
- // // mapMobile[v.Mobile+"_"+activityId] = true
- // //}
- //
- // //condition = " AND s.activity_id = 5833 AND duration != '' "
- // //condition = " AND s.activity_id = " + activityId + " AND duration != '' " // 2024-09-06 09:20
- // condition = " AND s.activity_id = " + activityId + " AND ( is_meeting = 1 OR duration != '' ) AND s.create_time > '2024-10-31 17:15' "
- // list, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
- // if err != nil && err.Error() != utils.ErrNoRow() {
- // fmt.Println(err)
- // return
- // }
- //
- // var companyIds []int
- // for _, vuser := range list {
- // //mapuserMapbil[vuser.Mobile] = vuser
- // companyIds = append(companyIds, vuser.CompanyId)
- // listData = append(listData, vuser)
- // }
- //
- // listCompany, err := models.GetWxUserRaiSllerListByUserComapnyId(companyIds)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- //
- // //合并合同所对应的权限
- // mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- // for _, v := range listCompany {
- // v.ChartPermissionName = mappermissionName[v.CompanyId]
- // mapuserMapbil[v.CompanyId] = v
- // }
- //
- // listCompanyFicc, err := models.GetWxUserRaiSllerListByUserComapnyIdFicc(companyIds)
- // if err != nil {
- // fmt.Println(err)
- // return
- // }
- //
- // for _, v := range listCompanyFicc {
- // if mapuserMapbil[v.CompanyId] != nil {
- // continue
- // }
- // v.Status = ""
- // v.SellerName = ""
- // mapuserMapbil[v.CompanyId] = v
- // }
- //}
- var companyIds []int
- for _, vuser := range list {
- fmt.Println(vuser.Mobile)
- if mobileMap[vuser.Mobile] {
- continue
- }
- companyIds = append(companyIds, vuser.CompanyId)
- listData = append(listData, vuser)
- }
- listCompany, err := models.GetWxUserRaiSllerListByUserComapnyId(companyIds)
- if err != nil {
- fmt.Println(err)
- return
- }
- //合并合同所对应的权限
- mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, v := range listCompany {
- v.ChartPermissionName = mappermissionName[v.CompanyId]
- mapuserMapbil[v.CompanyId] = v
- }
- listCompanyFicc, err := models.GetWxUserRaiSllerListByUserComapnyIdFicc(companyIds)
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, v := range listCompanyFicc {
- if mapuserMapbil[v.CompanyId] != nil {
- continue
- }
- v.Status = ""
- v.SellerName = ""
- mapuserMapbil[v.CompanyId] = v
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "到会信息"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellAct := rowTitle.AddCell()
- cellAct.Value = "活动名称/报告标题"
- cellActime := rowTitle.AddCell()
- cellActime.Value = " 活动时间/发布时间"
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名称"
- cellD := rowTitle.AddCell()
- cellD.Value = "所属销售"
- cellDfw := rowTitle.AddCell()
- cellDfw.Value = "服务销售"
- cellYd := rowTitle.AddCell()
- cellYd.Value = "阅读时间"
- cellstopTime := rowTitle.AddCell()
- cellstopTime.Value = "停留时长"
- cellLy := rowTitle.AddCell()
- cellLy.Value = "阅读来源"
- cellStatus := rowTitle.AddCell()
- cellStatus.Value = "客户状态"
- cellTc := rowTitle.AddCell()
- cellTc.Value = "签约套餐"
- for _, item := range listData {
- if mapMobile[item.Mobile] {
- continue
- }
- row := sheet.AddRow()
- cellActData := row.AddCell()
- cellActData.Value = item.ActivityName
- cellActimeData := row.AddCell()
- cellActimeData.Value = item.ActivityTime
- cellAData := row.AddCell()
- cellAData.Value = item.RealName
- //if item.Ly == "1" {
- // cellAData.SetStyle(redStyle)
- //}
- cellBData := row.AddCell()
- cellBData.Value = item.Mobile
- cellCData := row.AddCell()
- //cellCData.Value = item.CompanyName
- cellDData := row.AddCell()
- cellDDatafw := row.AddCell()
- //cellDData.Value = item.SellerName
- cellYdData := row.AddCell()
- cellYdData.Value = ""
- cellstopTimeData := row.AddCell()
- cellstopTimeData.Value = ""
- cellLyData := row.AddCell()
- cellLyData.Value = ""
- cellStatusData := row.AddCell()
- cellermissionNameData := row.AddCell()
- if mapuserMapbil[item.CompanyId] != nil {
- cellCData.Value = mapuserMapbil[item.CompanyId].CompanyName
- cellDData.Value = mapuserMapbil[item.CompanyId].SellerName
- cellDDatafw.Value = mapuserMapbil[item.CompanyId].ShareSeller
- cellStatusData.Value = mapuserMapbil[item.CompanyId].Status
- cellermissionNameData.Value = mapuserMapbil[item.CompanyId].ChartPermissionName
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initarta() {
- //行业
- var condition string
- var pars []interface{}
- condition += ` AND share_seller_id In (702,703,704,707) `
- listProduct, err := company.GetCompanyProductList(condition, pars)
- if err != nil {
- fmt.Println(err)
- return
- }
- var companyIds []int
- mapSeller := make(map[int]string)
- for _, v := range listProduct {
- companyIds = append(companyIds, v.CompanyId)
- mapSeller[v.CompanyId] = v.ShareSeller
- }
- //报告匹配类型
- pars = make([]interface{}, 0)
- condition = ` AND re.chart_permission_id IN (23,53) `
- listart, err := cygx.GetReportArticleList(condition, pars, 0, 4000, 1)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapArticleTitle := make(map[int]string)
- mapchart_permission_name := make(map[int]string)
- var articleIds []int
- for _, v := range listart {
- mapArticleTitle[v.ArticleId] = v.Title
- mapchart_permission_name[v.ArticleId] = v.ChartPermissionName
- articleIds = append(articleIds, v.ArticleId)
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "PV"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名称"
- cellD := rowTitle.AddCell()
- cellD.Value = "服务销售"
- cellDCreatedTime := rowTitle.AddCell()
- cellDCreatedTime.Value = "最近阅读时间"
- cellE := rowTitle.AddCell()
- cellE.Value = "行业"
- cellF := rowTitle.AddCell()
- cellF.Value = "报告标题"
- //articleId := v.ArticleId
- //condition = ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
- list, err := cygx.GetArticleHistoryListInit(articleIds, companyIds)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapMobile := make(map[string]bool)
- for _, item := range list {
- if mapMobile[item.Mobile] {
- continue
- }
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.RealName
- cellBData := row.AddCell()
- cellBData.Value = item.Mobile
- cellCData := row.AddCell()
- cellCData.Value = item.CompanyName
- cellDData := row.AddCell()
- cellDData.Value = mapSeller[item.CompanyId]
- cellEData := row.AddCell()
- cellEData.Value = item.CreateTime
- cellEcData := row.AddCell()
- cellEcData.Value = mapchart_permission_name[item.ArticleId]
- cellFData := row.AddCell()
- cellFData.Value = mapArticleTitle[item.ArticleId]
- mapMobile[item.Mobile] = true
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initActList() {
- var condition string
- var pars []interface{}
- condition = " AND chart_permission_id = 31 AND activity_time >= '2024-03-01' AND activity_time <= '2024-09-21' AND activity_type_id = 3 AND publish_status = 1 AND yidong_activity_id = '' ORDER BY activity_time ASC "
- list, errList := cygx.GetActivityListAll(condition, pars, 0, 999)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "到会信息"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "活动名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "活动时间"
- cellC := rowTitle.AddCell()
- cellC.Value = "活动标签"
- for _, item := range list {
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.ActivityName
- cellBData := row.AddCell()
- cellBData.Value = item.ActivityTime
- cellCData := row.AddCell()
- cellCData.Value = item.Label
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initOrder() {
- var condition string
- var pars []interface{}
- //condition = " WHERE 1 = 1 AND source In ('article','yanxuanspecial') AND order_status = 2 GROUP BY order_id ASC "
- condition = " AND source In ('activity') AND order_status = 2 GROUP BY order_id DESC "
- list, errList := cygx.GetCygxOrderList(condition, pars, 0, 9999)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "活动"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- //rowTitle := sheet.AddRow()
- //cellA := rowTitle.AddCell()
- //cellA.Value = "姓名"
- //cellB := rowTitle.AddCell()
- //cellB.Value = "手机号"
- //cellC := rowTitle.AddCell()
- //cellC.Value = "公司名称"
- //
- //cellMoney := rowTitle.AddCell()
- //cellMoney.Value = "金额"
- //
- //cellname := rowTitle.AddCell()
- //cellname.Value = "活动名称"
- //
- //cellTime := rowTitle.AddCell()
- //cellTime.Value = "支付时间"
- //
- //for _, item := range list {
- //
- // row := sheet.AddRow()
- // cellAData := row.AddCell()
- // cellAData.Value = item.RealName
- //
- // cellBData := row.AddCell()
- // cellBData.Value = item.Mobile
- // cellCData := row.AddCell()
- // cellCData.Value = item.CompanyName
- //
- // cellCMoneyData := row.AddCell()
- // cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
- //
- // cellCnameData := row.AddCell()
- // cellCnameData.Value = item.SourceTitle
- //
- // cellTimeata := row.AddCell()
- // cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
- //}
- var mobiles []string
- var activityIds []int
- for _, v := range list {
- mobiles = append(mobiles, v.Mobile)
- activityIds = append(activityIds, v.SourceId)
- }
- pars = make([]interface{}, 0)
- inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
- condition = ` AND activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) `
- pars = append(pars, activityIds)
- listActivity, errList := cygx.GetActivityListAllInit(condition, pars)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- mapHost := make(map[int]string)
- for _, v := range listActivity {
- mapHost[v.ActivityId] = v.Host
- }
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名称"
- cellSeller := rowTitle.AddCell()
- cellSeller.Value = "所属销售"
- cellInviteName := rowTitle.AddCell()
- cellInviteName.Value = "推荐人"
- cellMoney := rowTitle.AddCell()
- cellMoney.Value = "金额"
- cellname := rowTitle.AddCell()
- cellname.Value = "报告标题"
- cellNickename := rowTitle.AddCell()
- cellNickename.Value = "作者"
- cellTime := rowTitle.AddCell()
- cellTime.Value = "支付时间"
- for _, item := range list {
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.RealName
- cellBData := row.AddCell()
- cellBData.Value = item.Mobile
- cellCData := row.AddCell()
- cellCData.Value = item.CompanyName
- cellSellerData := row.AddCell()
- cellSellerData.Value = item.SellerName
- cellInviteNameData := row.AddCell()
- if item.ShareName != "" {
- cellInviteNameData.Value = item.ShareName
- } else {
- cellInviteNameData.Value = inviteNameMap[item.Mobile]
- }
- cellCMoneyData := row.AddCell()
- cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
- cellCnameData := row.AddCell()
- cellCnameData.Value = item.SourceTitle
- cellNickenameData := row.AddCell()
- cellNickenameData.Value = mapHost[item.SourceId]
- cellTimeata := row.AddCell()
- cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initOrderArticle() {
- var condition string
- var pars []interface{}
- condition = " AND source In ('article','yanxuanspecial') AND order_status = 2 GROUP BY order_id DESC "
- list, errList := cygx.GetCygxOrderList(condition, pars, 0, 9999)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- var articleIds []int
- var yanxuanArticleids []int
- for _, v := range list {
- if v.Source == "article" {
- articleIds = append(articleIds, v.SourceId)
- }
- if v.Source == "yanxuanspecial" {
- yanxuanArticleids = append(yanxuanArticleids, v.SourceId)
- }
- }
- pars = make([]interface{}, 0)
- condition = " AND art.article_id IN (" + utils.GetOrmInReplace(len(articleIds)) + ") GROUP BY art.article_id "
- pars = append(pars, articleIds)
- mapArtcileNickName := make(map[int]string)
- listartcile, errList := cygx.GetSummaryManageListInit(condition, pars, 0, 999)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- for _, v := range listartcile {
- mapArtcileNickName[v.ArticleId] = v.NickName
- }
- //fmt.Println(mapArtcileNickName)
- //return
- pars = make([]interface{}, 0)
- condition = " AND a.id IN (" + utils.GetOrmInReplace(len(yanxuanArticleids)) + ") "
- pars = append(pars, yanxuanArticleids)
- mapArtcileNickNameYx := make(map[int]string)
- listartcileYx, errList := cygx.GetYanxuanSpecialList(condition, pars, 0, 999)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- for _, v := range listartcileYx {
- mapArtcileNickNameYx[v.Id] = v.NickName
- }
- var mobiles []string
- for _, v := range list {
- mobiles = append(mobiles, v.Mobile)
- }
- inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "活动"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名称"
- cellSeller := rowTitle.AddCell()
- cellSeller.Value = "所属销售"
- cellInviteName := rowTitle.AddCell()
- cellInviteName.Value = "推荐人"
- cellMoney := rowTitle.AddCell()
- cellMoney.Value = "金额"
- cellname := rowTitle.AddCell()
- cellname.Value = "报告标题"
- cellNickename := rowTitle.AddCell()
- cellNickename.Value = "作者"
- cellTime := rowTitle.AddCell()
- cellTime.Value = "支付时间"
- for _, item := range list {
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.RealName
- cellBData := row.AddCell()
- cellBData.Value = item.Mobile
- cellCData := row.AddCell()
- cellCData.Value = item.CompanyName
- cellSellerData := row.AddCell()
- cellSellerData.Value = item.SellerName
- cellInviteNameData := row.AddCell()
- if item.ShareName != "" {
- cellInviteNameData.Value = item.ShareName
- } else {
- cellInviteNameData.Value = inviteNameMap[item.Mobile]
- }
- cellCMoneyData := row.AddCell()
- cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
- cellCnameData := row.AddCell()
- cellCnameData.Value = item.SourceTitle
- cellNickenameData := row.AddCell()
- if item.Source == "article" {
- fmt.Println(mapArtcileNickName[item.SourceId])
- cellNickenameData.Value = mapArtcileNickName[item.SourceId]
- }
- if item.Source == "yanxuanspecial" {
- cellNickenameData.Value = mapArtcileNickNameYx[item.SourceId]
- }
- cellTimeata := row.AddCell()
- cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initRsList() {
- list, errList := roadshow.GetCalendarDetailListinit()
- if errList != nil {
- fmt.Println(errList)
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "活动"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "研究员"
- cellB := rowTitle.AddCell()
- cellB.Value = "路演时间"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名"
- cellMoney := rowTitle.AddCell()
- cellMoney.Value = "销售"
- for _, item := range list {
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.ResearcherName
- cellBData := row.AddCell()
- cellBData.Value = item.StartDate + " " + item.StartTime
- cellCData := row.AddCell()
- cellCData.Value = item.CompanyName
- cellCnameData := row.AddCell()
- cellCnameData.Value = item.SysUserRealName
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initHistoryRemarList() {
- remarkList, err := company.GetCompanyHistoryRemarkListInitExport()
- if err != nil {
- fmt.Println(err)
- return
- }
- var companyids []int
- //var companyidsMap +
- resp := new(company.CompanyHistoryRemarkListResp)
- for _, v := range remarkList {
- item := new(company.CompanyHistoryRemarkResp)
- item.CompanyId = v.CompanyId
- if !utils.InArrayByInt(companyids, v.CompanyId) {
- companyids = append(companyids, v.CompanyId)
- }
- item.Content = v.Content
- item.SysAdminName = v.SysAdminName
- //item.SysAdminName = v.C
- item.CreateTime = v.ShowTime.Format(utils.FormatDateTime)
- switch v.TableName {
- case "company_service_record":
- item.RemarkType = "沟通记录"
- case "company_product_remark":
- item.RemarkType = "备注"
- case "company_no_renewed_note":
- item.RemarkType = "未续约备注"
- case "company_renewal_reason":
- item.RemarkType = "未续约说明"
- case "cygx_user_feedback":
- item.RemarkType = "交流反馈(" + v.RealName + ")"
- default:
- item.RemarkType = "备注"
- }
- resp.List = append(resp.List, item)
- }
- listCompany, err := company.GetOverseasCompanysByCompanyIds(companyids)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapCompamyName := make(map[int]string)
- for _, v := range listCompany {
- mapCompamyName[v.CompanyId] = v.CompanyName
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "备注"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "录入人"
- cellB := rowTitle.AddCell()
- cellB.Value = " 录入时间"
- cellC := rowTitle.AddCell()
- cellC.Value = " 客户名称"
- cellMoney := rowTitle.AddCell()
- cellMoney.Value = "录入类型"
- cellConct := rowTitle.AddCell()
- cellConct.Value = "录入内容"
- for _, item := range resp.List {
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.SysAdminName
- cellBData := row.AddCell()
- cellBData.Value = item.CreateTime
- cellCData := row.AddCell()
- cellCData.Value = mapCompamyName[item.CompanyId]
- cellCnameData := row.AddCell()
- cellCnameData.Value = item.RemarkType
- cellContentData := row.AddCell()
- cellContentData.Value = item.Content
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initcygx_user_feedback() {
- remarkList, err := cygx.GetCygxUserFeedbackListIni2t()
- if err != nil {
- fmt.Println(err)
- return
- }
- var companyids []int
- var sellerIds []int
- var adminIds []int
- //var companyidsMap
- for _, v := range remarkList {
- item := new(company.CompanyHistoryRemarkResp)
- item.CompanyId = v.CompanyId
- if !utils.InArrayByInt(companyids, v.CompanyId) {
- companyids = append(companyids, v.CompanyId)
- }
- if !utils.InArrayByInt(sellerIds, v.SellerId) {
- sellerIds = append(sellerIds, v.SellerId)
- }
- if !utils.InArrayByInt(adminIds, v.AdminId) {
- adminIds = append(adminIds, v.AdminId)
- }
- }
- sysUserList, err := system.GetAdminList()
- if err != nil {
- fmt.Println(err)
- return
- }
- adminMap := make(map[int]*system.Admin, 0)
- for _, v := range sysUserList {
- adminMap[v.AdminId] = v
- }
- listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyids)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapCompamyName := make(map[int]*company.CompanyProduct)
- for _, v := range listCompany {
- mapCompamyName[v.CompanyId] = v
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "针对kp的交流反馈"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "服务销售姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = " kp姓名"
- cellC := rowTitle.AddCell()
- cellC.Value = " 公司名称"
- cellMoney := rowTitle.AddCell()
- cellMoney.Value = "原销售"
- cellConct := rowTitle.AddCell()
- cellConct.Value = "交流反馈内容"
- cellTime := rowTitle.AddCell()
- cellTime.Value = "录入时间"
- var SellerNameArr []string
- for _, item := range sysUserList {
- if !utils.InArrayByStr(SellerNameArr, item.RealName) {
- SellerNameArr = append(SellerNameArr, item.RealName)
- }
- }
- fmt.Println(SellerNameArr)
- for _, v := range SellerNameArr {
- fmt.Println(v)
- }
- //return
- for _, v := range adminIds {
- for _, item := range remarkList {
- if item.AdminId != v {
- //fmt.Println(v)
- continue
- }
- fmt.Println(v)
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = adminMap[item.AdminId].RealName
- cellBData := row.AddCell()
- cellBData.Value = item.RealName
- cellCData := row.AddCell()
- cellCData.Value = item.CompanyName
- cellCnameData := row.AddCell()
- cellCnameData.Value = mapCompamyName[item.CompanyId].SellerName
- cellContentData := row.AddCell()
- cellContentData.Value = item.Content
- cellTimeData := row.AddCell()
- cellTimeData.Value = item.CreateTime.Format(utils.FormatDateTime)
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initcompany_history_remark() {
- remarkList, err := company.GetCompanyHistoryRemarkListInitExportinit()
- if err != nil {
- fmt.Println(err)
- return
- }
- var companyids []int
- var adminIds []int
- //var companyidsMap
- for _, v := range remarkList {
- item := new(company.CompanyHistoryRemarkResp)
- item.CompanyId = v.CompanyId
- if !utils.InArrayByInt(companyids, v.CompanyId) {
- companyids = append(companyids, v.CompanyId)
- }
- if !utils.InArrayByInt(adminIds, v.SysAdminId) {
- adminIds = append(adminIds, v.SysAdminId)
- }
- switch v.TableName {
- case "company_service_record":
- item.RemarkType = "沟通记录"
- case "company_product_remark":
- item.RemarkType = "历史备注"
- case "company_no_renewed_note":
- item.RemarkType = "未续约备注"
- case "company_renewal_reason":
- item.RemarkType = "未续约说明"
- case "cygx_user_feedback":
- item.RemarkType = "交流反馈(" + v.RealName + ")"
- default:
- item.RemarkType = "备注"
- }
- }
- listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyids)
- if err != nil {
- fmt.Println(err)
- return
- }
- sysUserList, err := system.GetAdminList()
- if err != nil {
- fmt.Println(err)
- return
- }
- adminMap := make(map[int]*system.Admin, 0)
- for _, v := range sysUserList {
- adminMap[v.AdminId] = v
- }
- mapCompamyName := make(map[int]*company.CompanyProduct)
- for _, v := range listCompany {
- mapCompamyName[v.CompanyId] = v
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "针对kp的交流反馈"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "服务销售姓名"
- cellC := rowTitle.AddCell()
- cellC.Value = " 公司名称"
- cellMoney := rowTitle.AddCell()
- cellMoney.Value = "原销售"
- cellConct := rowTitle.AddCell()
- cellConct.Value = "交流反馈内容"
- cellType := rowTitle.AddCell()
- cellType.Value = "记录类型"
- cellTime := rowTitle.AddCell()
- cellTime.Value = "录入时间"
- var SellerNameArr []string
- for _, item := range remarkList {
- if !utils.InArrayByStr(SellerNameArr, mapCompamyName[item.CompanyId].ShareSeller) {
- SellerNameArr = append(SellerNameArr, mapCompamyName[item.CompanyId].ShareSeller)
- }
- }
- fmt.Println(SellerNameArr)
- for _, v := range SellerNameArr {
- fmt.Println(v)
- }
- //return
- for _, v := range adminIds {
- for _, item := range remarkList {
- if item.SysAdminId != v {
- //fmt.Println(v)
- continue
- }
- fmt.Println(v)
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.SysAdminName
- cellCData := row.AddCell()
- cellCData.Value = mapCompamyName[item.CompanyId].CompanyName
- cellCnameData := row.AddCell()
- cellCnameData.Value = mapCompamyName[item.CompanyId].SellerName
- cellContentData := row.AddCell()
- cellContentData.Value = item.Content
- celltypeData := row.AddCell()
- switch item.TableName {
- case "company_service_record":
- celltypeData.Value = "沟通记录"
- case "company_product_remark":
- celltypeData.Value = "历史备注"
- default:
- celltypeData.Value = "历史备注"
- }
- cellTimeData := row.AddCell()
- cellTimeData.Value = item.CreateTime.Format(utils.FormatDateTime)
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initRsListinit() {
- list, errList := roadshow.GetRsCalendarMeetingUserByRaiinit()
- if errList != nil {
- fmt.Println(errList)
- return
- }
- var companyids []int
- //var companyidsMap
- var rsCalendarIds []int
- for _, v := range list {
- if !utils.InArrayByInt(companyids, v.CompanyId) {
- companyids = append(companyids, v.CompanyId)
- }
- rsCalendarIds = append(rsCalendarIds, v.RsCalendarId)
- }
- listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyids)
- if err != nil {
- fmt.Println(err)
- return
- }
- mapCompamyName := make(map[int]*company.CompanyProduct)
- for _, v := range listCompany {
- mapCompamyName[v.CompanyId] = v
- }
- mapRsCalendarLabel := make(map[int][]string) //1v1 路演标签
- mapRsCalendarLabel = cygxService.GetRsCalendarLabelByRsCalendarIds(rsCalendarIds)
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "活动"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "公司名称"
- cellB := rowTitle.AddCell()
- cellB.Value = "所属服务销售"
- cellC := rowTitle.AddCell()
- cellC.Value = "原销售"
- cellD := rowTitle.AddCell()
- cellD.Value = "姓名"
- cellE := rowTitle.AddCell()
- cellE.Value = "手机号"
- cellF := rowTitle.AddCell()
- cellF.Value = "路演时间"
- cellG := rowTitle.AddCell()
- cellG.Value = "研究员"
- cellH := rowTitle.AddCell()
- cellH.Value = "路演形式"
- cellI := rowTitle.AddCell()
- cellI.Value = "路演主题"
- cellJ := rowTitle.AddCell()
- cellJ.Value = "主题标签"
- for _, v := range companyids {
- for _, item := range list {
- if item.CompanyId != v {
- //fmt.Println(v)
- continue
- }
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = item.CompanyName
- cellBData := row.AddCell()
- cellCData := row.AddCell()
- if mapCompamyName[item.CompanyId] != nil {
- cellBData.Value = mapCompamyName[item.CompanyId].ShareSeller
- cellCData.Value = mapCompamyName[item.CompanyId].SellerName
- }
- cellDData := row.AddCell()
- cellDData.Value = item.RealName
- cellEData := row.AddCell()
- cellEData.Value = item.Mobile
- cellFData := row.AddCell()
- cellFData.Value = item.StartDate + " " + item.StartTime
- cellGData := row.AddCell()
- cellGData.Value = item.ResearcherName
- cellHData := row.AddCell()
- cellHData.Value = item.RoadshowType
- cellIData := row.AddCell()
- cellIData.Value = item.RoadShowTheme
- cellJData := row.AddCell()
- cellJData.Value = strings.Join(mapRsCalendarLabel[item.RsCalendarId], ",")
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- //func init() {
- // initart22()
- //}
- func initYaxuan() {
- udi := 121323
- var nickname = "鱼与塘"
- listYax, errList := cygx.GetYanxuanSpecialListByconditioninit(udi)
- if errList != nil {
- fmt.Println(errList)
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "活动"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "文章标题"
- cellB := rowTitle.AddCell()
- cellB.Value = "发布时间"
- cellC := rowTitle.AddCell()
- cellC.Value = "作者昵称"
- cellD := rowTitle.AddCell()
- cellD.Value = "读者手机号"
- cellE := rowTitle.AddCell()
- cellE.Value = "姓名"
- cellF := rowTitle.AddCell()
- cellF.Value = "公司名"
- for _, v := range listYax {
- var condition string
- var pars []interface{}
- condition = ` AND yanxuan_special_id = ? AND company_id != 16 GROUP BY mobile ORDER BY create_time DESC `
- pars = append(pars, v.Id)
- list, err := cygx.GetCygxYanxuanSpecialRecordList(condition, pars)
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, item := range list {
- row := sheet.AddRow()
- cellAData := row.AddCell()
- cellAData.Value = v.Title
- cellBData := row.AddCell()
- cellBData.Value = v.PublishTime.Format(utils.FormatDateTime)
- cellCData := row.AddCell()
- cellCData.Value = nickname
- cellDData := row.AddCell()
- cellDData.Value = item.RealName
- cellEData := row.AddCell()
- cellEData.Value = item.Mobile
- cellFData := row.AddCell()
- cellFData.Value = item.CompanyName
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
- func initart22() {
- //行业
- var condition string
- var pars []interface{}
- condition += ` AND art.publish_date >= '2024-10-01'
- AND art.publish_status = 1
- AND art.article_type_id = 0 `
- //return
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
- //fmt.Println(condition)
- list, err := cygx.GetReportArticleList(condition, pars, 0, 9999, 1)
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println("list", len(list))
- //return
- reportMap := make(map[int]string)
- listMap, err := cygx.GetReportMapping()
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, v := range listMap {
- reportMap[v.CategoryId] = v.MatchTypeName
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- fmt.Println(err)
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- redStyle := xlsx.NewStyle()
- redStyle.Alignment = alignment
- redStyle.ApplyAlignment = true
- redStyle.Font.Color = "ff0000"
- //定义底色需要标黄的 单元格颜色
- redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
- redStyle.Fill = redFill
- //redStyle.Border = *border
- var sheetName string
- sheetName = "数据"
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- fmt.Println(err)
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellAt := rowTitle.AddCell()
- cellAt.Value = " 报告名称 "
- cellPd := rowTitle.AddCell()
- cellPd.Value = "行业"
- //cellA := rowTitle.AddCell()
- //cellA.Value = "系列"
- cellB := rowTitle.AddCell()
- cellB.Value = "发布时间"
- for _, v := range list {
- //if v.SubCategoryName != "行业深度" {
- // continue
- //}
- row := sheet.AddRow()
- cellADatatitle := row.AddCell()
- cellADatatitle.Value = v.Title
- cellADataPd := row.AddCell()
- if v.ChartPermissionName == "" {
- cellADataPd.Value = v.CategoryName
- } else {
- cellADataPd.Value = v.ChartPermissionName
- }
- //cellAData := row.AddCell()
- //cellAData.Value = v.SubCategoryName
- cellBData := row.AddCell()
- cellBData.Value = v.PublishDate
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- fmt.Println(err)
- return
- }
- }
|