report_article.go 137 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "github.com/tealeg/xlsx"
  7. "hongze/hz_crm_api/controllers"
  8. "hongze/hz_crm_api/models"
  9. "hongze/hz_crm_api/models/company"
  10. "hongze/hz_crm_api/models/cygx"
  11. "hongze/hz_crm_api/models/roadshow"
  12. "hongze/hz_crm_api/models/system"
  13. "hongze/hz_crm_api/services"
  14. cygxService "hongze/hz_crm_api/services/cygx"
  15. "hongze/hz_crm_api/utils"
  16. "html"
  17. "os"
  18. "path/filepath"
  19. "strconv"
  20. "strings"
  21. "time"
  22. )
  23. // 报告管理
  24. type ReportArticleController struct {
  25. controllers.BaseAuthController
  26. }
  27. // @Title 主题列表
  28. // @Description 获取主题列表接口
  29. // @Param ChartPermissionId query int true "分类ID"
  30. // @Success 200 {object} cygx.CygxReportMappingListRep
  31. // @router /reportMappingist/list [get]
  32. func (this *ReportArticleController) CygxReportMappingist() {
  33. br := new(models.BaseResponse).Init()
  34. defer func() {
  35. this.Data["json"] = br
  36. this.ServeJSON()
  37. }()
  38. sysUser := this.SysUser
  39. if sysUser == nil {
  40. br.Msg = "请登录"
  41. br.ErrMsg = "请登录,SysUser Is Empty"
  42. return
  43. }
  44. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  45. if chartPermissionId < 1 {
  46. br.Msg = "请输入分类ID"
  47. return
  48. }
  49. list, err := cygx.CygxReportMappingist(chartPermissionId)
  50. if err != nil {
  51. br.Msg = "获取失败"
  52. br.ErrMsg = "获取失败,Err:" + err.Error()
  53. return
  54. }
  55. resp := new(cygx.CygxReportMappingListRep)
  56. resp.List = list
  57. br.Ret = 200
  58. br.Success = true
  59. br.Msg = "获取成功"
  60. br.Data = resp
  61. }
  62. // @Title 报告匹配类型列表
  63. // @Description 获取报告匹配类型列表接口
  64. // @Success 200 {object} cygx.CygxReportMappingMatchTypeRep
  65. // @Param ChartPermissionId query int true "分类ID"
  66. // @router /reportMappingMatchTypeRep/list [get]
  67. func (this *ReportArticleController) CygxReportMappingMatchTypeList() {
  68. br := new(models.BaseResponse).Init()
  69. defer func() {
  70. this.Data["json"] = br
  71. this.ServeJSON()
  72. }()
  73. sysUser := this.SysUser
  74. if sysUser == nil {
  75. br.Msg = "请登录"
  76. br.ErrMsg = "请登录,SysUser Is Empty"
  77. return
  78. }
  79. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  80. var condition string
  81. var pars []interface{}
  82. if chartPermissionId > 0 {
  83. condition += ` AND chart_permission_id = ? `
  84. pars = append(pars, chartPermissionId)
  85. }
  86. list, err := cygx.GetCygxReportMappingCygxList(condition, pars, 0, 0)
  87. if err != nil {
  88. br.Msg = "获取失败"
  89. br.ErrMsg = "获取失败,Err:" + err.Error()
  90. return
  91. }
  92. resp := new(cygx.CygxCygxReportMappingCygxResp)
  93. resp.List = list
  94. br.Ret = 200
  95. br.Success = true
  96. br.Msg = "获取成功"
  97. br.Data = resp
  98. }
  99. // @Title 报告列表
  100. // @Description 报告列表接口
  101. // @Param PageSize query int true "每页数据条数"
  102. // @Param CurrentIndex query int true "当前页页码,从1开始"
  103. // @Param IsFilter query int true "是否过滤 ,1是,0否,不传默认为0"
  104. // @Param IsClass query int true "是否归类 ,1是,0否 ,不传默认为0"
  105. // @Param ChartPermissionId query int true "行业ID --> 一级分类列表中 ChartPermissionId"
  106. // @Param SubCategoryName query string true "主题"
  107. // @Param MatchTypeName query string true "报告匹配类型"
  108. // @Param IndustrialManagementId int string true "产业ID"
  109. // @Param StartDate query string true "开始时间用0 补齐,列如2021-03-06 08:09:01"
  110. // @Param EndDate query string true "结束时间用0 补齐,列如2021-03-06 08:09:01"
  111. // @Param KeyWord query string true "搜索关键词"
  112. // @Param KeyWordStock query string true "搜索关键词.个股标签,关联标的部分"
  113. // @Success 200 {object} cygx.GetReportArticleListRep
  114. // @router /reportArticle/list [get]
  115. func (this *ReportArticleController) ReportArticleList() {
  116. br := new(models.BaseResponse).Init()
  117. defer func() {
  118. this.Data["json"] = br
  119. this.ServeJSON()
  120. }()
  121. sysUser := this.SysUser
  122. if sysUser == nil {
  123. br.Msg = "请登录"
  124. br.ErrMsg = "请登录,SysUser Is Empty"
  125. return
  126. }
  127. pageSize, _ := this.GetInt("PageSize")
  128. currentIndex, _ := this.GetInt("CurrentIndex")
  129. isFilter, _ := this.GetInt("IsFilter")
  130. isClass, _ := this.GetInt("IsClass")
  131. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  132. subCategoryName := this.GetString("SubCategoryName")
  133. matchTypeName := this.GetString("MatchTypeName")
  134. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  135. startDate := this.GetString("StartDate")
  136. endDate := this.GetString("EndDate")
  137. keyWord := this.GetString("KeyWord")
  138. keyWordStock := this.GetString("KeyWordStock")
  139. reportLabel := this.GetString("ReportLabel") // 查研观向7.4-报告标签
  140. var startSize int
  141. if pageSize <= 0 {
  142. pageSize = utils.PageSize20
  143. }
  144. if currentIndex <= 0 {
  145. currentIndex = 1
  146. }
  147. startSize = utils.StartIndex(currentIndex, pageSize)
  148. var condition string
  149. var pars []interface{}
  150. listPermission, errper := cygx.GetPermissionMappingCategoryID()
  151. if errper != nil {
  152. br.Msg = "获取失败"
  153. br.ErrMsg = "获取失败,Err:" + errper.Error()
  154. return
  155. }
  156. condition += ` AND art.is_report = 1 AND re.id !=28 `
  157. if isClass == 0 {
  158. condition += ` AND art.is_class = 0 `
  159. } else {
  160. condition += ` AND art.is_class = 1 `
  161. if industrialManagementId > 0 {
  162. condition += ` AND man.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  163. }
  164. }
  165. if keyWord != "" {
  166. condition += ` AND (art.title LIKE '%` + keyWord + `%' ) `
  167. }
  168. //个股标签跟标的的搜索
  169. if keyWordStock != "" {
  170. 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 + `%')) ) `
  171. }
  172. if isFilter == 0 {
  173. condition += ` AND art.is_filter = 0 `
  174. } else {
  175. condition += ` AND art.is_filter = 1 `
  176. }
  177. //行业
  178. if chartPermissionId > 0 {
  179. condition += ` AND re.chart_permission_id = ` + strconv.Itoa(chartPermissionId)
  180. }
  181. //主题
  182. if subCategoryName != "" {
  183. condition += ` AND art.sub_category_name = ` + "'" + subCategoryName + "' "
  184. }
  185. //发布时间
  186. if startDate != "" {
  187. condition += ` AND art.publish_date >= ` + "'" + startDate + " 00:00:00'"
  188. }
  189. if endDate != "" {
  190. condition += ` AND art.publish_date <= ` + "'" + endDate + " 23:59:59'"
  191. }
  192. //报告匹配类型
  193. if matchTypeName != "" && chartPermissionId > 0 {
  194. //condition += ` AND re.match_type_name = ` + "'" + matchTypeName + "' "
  195. //mappingCygxDetai, err := cygx.GetCygxReportMappingCygxDetailByNameAndChartPermissionId(matchTypeName, chartPermissionId)
  196. //if err != nil && err.Error() != utils.ErrNoRow() {
  197. // br.Msg = "获取失败"
  198. // br.ErrMsg = "获取失败,Err:" + err.Error()
  199. // return
  200. //}
  201. //if mappingCygxDetai == nil {
  202. // resp := new(cygx.GetReportArticleListRep)
  203. // resp.List = make([]*cygx.CygxReportArticle, 0)
  204. // page := paging.GetPaging(currentIndex, pageSize, 0)
  205. // resp.Paging = page
  206. // br.Ret = 200
  207. // br.Success = true
  208. // br.Msg = "获取成功"
  209. // br.Data = resp
  210. // return
  211. //}
  212. //这里量不大,走一下子查询
  213. //condition += ` AND art.category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(mappingCygxDetai.Id) + ` ) `
  214. condition += ` AND art.category_id IN ( SELECT category_id FROM cygx_report_mapping WHERE match_type_name = ` + "'" + matchTypeName + "'" + ` ) `
  215. }
  216. // 报告标签
  217. if reportLabel != "" {
  218. keywords := "%" + reportLabel + "%"
  219. // 查询包含关键词的产业/标的所关联的报告IDs
  220. artIds, e := cygx.GetArticleIdsFromIndustryAndSubjectGroupByKeyword(keywords)
  221. if e != nil {
  222. br.Msg = "获取失败"
  223. br.ErrMsg = "产业/标的关键词获取文章IDs失败, Err:" + e.Error()
  224. return
  225. }
  226. if len(artIds) > 0 {
  227. condition += ` AND art.article_id IN (` + utils.GetOrmInReplace(len(artIds)) + `)`
  228. pars = append(pars, artIds)
  229. }
  230. }
  231. total, err := cygx.GetReportArticleCount(condition, pars)
  232. if err != nil {
  233. br.Msg = "获取失败"
  234. br.ErrMsg = "获取失败,Err:" + err.Error()
  235. return
  236. }
  237. //return
  238. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
  239. //fmt.Println(condition)
  240. list, err := cygx.GetReportArticleList(condition, pars, startSize, pageSize, isClass)
  241. if err != nil {
  242. br.Msg = "获取失败"
  243. br.ErrMsg = "获取失败,Err:" + err.Error()
  244. return
  245. }
  246. reportMap := make(map[int]string)
  247. listMap, err := cygx.GetReportMapping()
  248. if err != nil {
  249. br.Msg = "获取失败"
  250. br.ErrMsg = "获取映射分类失败,Err:" + err.Error()
  251. return
  252. }
  253. for _, v := range listMap {
  254. reportMap[v.CategoryId] = v.MatchTypeName
  255. }
  256. var articleIds string
  257. for k, v := range list {
  258. var isShowButton bool
  259. if sysUser.RoleTypeCode == "rai_admin" || sysUser.RoleTypeCode == "rai_researcher" || sysUser.RoleTypeCode == "admin" {
  260. isShowButton = true
  261. } else {
  262. isShowButton = false
  263. }
  264. list[k].MatchTypeName = reportMap[v.CategoryId]
  265. list[k].ShowButton = true
  266. for _, vper := range listPermission {
  267. if v.CategoryId == vper.CategoryId {
  268. isShowButton = false
  269. }
  270. list[k].ShowButton = isShowButton
  271. }
  272. articleIds += strconv.Itoa(v.ArticleId) + ","
  273. }
  274. mapCommment := make(map[int]int)
  275. if articleIds != "" {
  276. articleIds = strings.TrimRight(articleIds, ",")
  277. condition = ` AND art.article_id IN (` + articleIds + `)`
  278. listPv, err := cygx.GetReportArticleListPvUv(condition)
  279. if err != nil {
  280. br.Msg = "获取失败"
  281. br.ErrMsg = "获取PV,Uv 失败,Err:" + err.Error()
  282. return
  283. }
  284. var condition string
  285. var pars []interface{}
  286. condition = ` AND k.article_id IN (` + articleIds + `)`
  287. listComment, err := cygx.GetArticleCommentListSearch(condition, pars)
  288. if err != nil {
  289. br.Msg = "获取失败"
  290. br.ErrMsg = "获取失败,Err:" + err.Error()
  291. return
  292. }
  293. for _, v := range listComment {
  294. mapCommment[v.ArticleId]++
  295. }
  296. if len(listPv) > 0 {
  297. for _, pv := range listPv {
  298. for k, v := range list {
  299. if v.ArticleId == pv.ArticleId {
  300. list[k].Pv = pv.Pv
  301. list[k].Uv = pv.Uv
  302. list[k].ClPv = pv.ClPv
  303. list[k].ClUv = pv.ClUv
  304. list[k].CollectionNum = pv.CollectionNum
  305. }
  306. }
  307. }
  308. }
  309. }
  310. //ListIndustrial []*IndustrialActivityGroupManagementRep
  311. //ListSubject []*SubjectActivityGroupManagementRep
  312. mapIndustrial := make(map[int]string)
  313. mapSubject := make(map[string]string)
  314. mapIndustrialList := make(map[int][]*cygx.IndustrialActivityGroupManagementRep)
  315. mapSubjectList := make(map[int][]*cygx.SubjectActivityGroupManagementRep)
  316. if articleIds != "" {
  317. industrialList, err := cygx.GetIndustrialArticleGroupListByarticleIds(articleIds)
  318. if err != nil {
  319. br.Msg = "获取失败"
  320. br.ErrMsg = "获取失败,GetIndustrialArticleGroupListByarticleIds Err:" + err.Error()
  321. return
  322. }
  323. subjectList, err := cygx.GetSubjectArticleGroupListByarticleIds(articleIds)
  324. if err != nil {
  325. br.Msg = "获取失败"
  326. br.ErrMsg = "获取失败,GetSubjectArticleGroupListByarticleIds Err:" + err.Error()
  327. return
  328. }
  329. //合并活动对应的多个标的
  330. for _, v := range subjectList {
  331. mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
  332. itemSubject := new(cygx.SubjectActivityGroupManagementRep)
  333. itemSubject.SubjectName = v.SubjectName
  334. itemSubject.IndustrialSubjectId = v.IndustrialSubjectId
  335. mapSubjectList[v.ArticleId] = append(mapSubjectList[v.ArticleId], itemSubject)
  336. }
  337. //活动对应的产业
  338. for _, v := range industrialList {
  339. var labelSubject string
  340. labelSubject = mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)]
  341. if labelSubject != "" {
  342. mapIndustrial[v.ArticleId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
  343. } else {
  344. mapIndustrial[v.ArticleId] += v.IndustryName + ","
  345. }
  346. itemindustrial := new(cygx.IndustrialActivityGroupManagementRep)
  347. itemindustrial.IndustryName = v.IndustryName
  348. itemindustrial.IndustrialManagementId = v.IndustrialManagementId
  349. mapIndustrialList[v.ArticleId] = append(mapIndustrialList[v.ArticleId], itemindustrial)
  350. }
  351. }
  352. for k, v := range list {
  353. if mapIndustrial[v.ArticleId] != "" {
  354. list[k].Label = strings.TrimRight(mapIndustrial[v.ArticleId], ",")
  355. }
  356. if v.SubCategoryName == "专项调研" {
  357. v.PublishDate = cygxService.ArticlePublishDate(v.PublishDate)
  358. }
  359. list[k].CommentNum = mapCommment[v.ArticleId]
  360. list[k].ListIndustrial = mapIndustrialList[v.ArticleId]
  361. list[k].ListSubject = mapSubjectList[v.ArticleId]
  362. if v.ReportId > 0 {
  363. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/ricc/yb/report/" + strconv.Itoa(v.ReportId)
  364. } else {
  365. list[k].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.ArticleId)
  366. list[k].ReportId = v.Id
  367. }
  368. }
  369. page := paging.GetPaging(currentIndex, pageSize, total)
  370. resp := new(cygx.GetReportArticleListRep)
  371. resp.List = list
  372. resp.Paging = page
  373. br.Ret = 200
  374. br.Success = true
  375. br.Msg = "获取成功"
  376. br.Data = resp
  377. }
  378. // @Title 过滤报告
  379. // @Description 过滤报告接口
  380. // @Param ReportId query int true "报告ID"
  381. // @Success Ret=200
  382. // @router /reportArticle/filter [post]
  383. func (this *IndustrialSubjectController) ReportArticleFilter() {
  384. br := new(models.BaseResponse).Init()
  385. defer func() {
  386. this.Data["json"] = br
  387. this.ServeJSON()
  388. }()
  389. sysUser := this.SysUser
  390. if sysUser == nil {
  391. br.Msg = "请登录"
  392. br.ErrMsg = "请登录,SysUser Is Empty"
  393. br.Ret = 408
  394. return
  395. }
  396. //if sysUser.RoleTypeCode != "rai_admin" && sysUser.RoleTypeCode != "rai_researcher" && sysUser.RoleTypeCode != "admin" {
  397. // br.Msg = "你没有操作权限请联系管理员"
  398. // return
  399. //}
  400. var req cygx.CygxReportArticleID
  401. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  402. if err != nil {
  403. br.Msg = "参数解析异常!"
  404. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  405. return
  406. }
  407. reportId := req.ReportId
  408. reportInfo, err := cygx.GetReportArticleId(reportId)
  409. if reportInfo == nil {
  410. br.Msg = "报告ID不存在!"
  411. return
  412. }
  413. if err != nil {
  414. br.Msg = "过滤失败!"
  415. br.ErrMsg = "过滤失败,Err:" + err.Error()
  416. return
  417. }
  418. if reportInfo.IsFilter == 1 {
  419. br.Msg = "您已过滤请勿重复操作!"
  420. return
  421. }
  422. if reportInfo.ReportType != 2 {
  423. br.Msg = "操作失败!"
  424. br.ErrMsg = "报告类型不属于产业报告!"
  425. return
  426. }
  427. err = cygx.FilterReportArticle(reportId)
  428. if err != nil {
  429. br.Msg = "过滤失败"
  430. br.ErrMsg = "过滤失败,Err:" + err.Error()
  431. return
  432. }
  433. br.Ret = 200
  434. br.Success = true
  435. br.Msg = "过滤成功"
  436. br.IsAddLog = true
  437. }
  438. // @Title 报告归类
  439. // @Description 报告归类接口
  440. // @Param request body cygx.ReportArticleClassificationResp true "type json string"
  441. // @Success Ret=200
  442. // @router /reportArticle/classification [post]
  443. func (this *IndustrialSubjectController) ReportArticleClassification() {
  444. br := new(models.BaseResponse).Init()
  445. defer func() {
  446. this.Data["json"] = br
  447. this.ServeJSON()
  448. }()
  449. sysUser := this.SysUser
  450. if sysUser == nil {
  451. br.Msg = "请登录"
  452. br.ErrMsg = "请登录,SysUser Is Empty"
  453. br.Ret = 408
  454. return
  455. }
  456. //if sysUser.RoleTypeCode != "rai_admin" && sysUser.RoleTypeCode != "rai_researcher" && sysUser.RoleTypeCode != "admin" {
  457. // br.Msg = "你没有操作权限请联系管理员"
  458. // return
  459. //}
  460. var req cygx.ReportArticleClassificationResp
  461. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  462. if err != nil {
  463. br.Msg = "参数解析异常!"
  464. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  465. return
  466. }
  467. var pars []interface{}
  468. var condition string
  469. reportId := req.ReportId
  470. industrialManagementIdStr := req.IndustrialManagementId
  471. reportInfo, _ := cygx.GetReportArticleId(reportId)
  472. if reportInfo == nil {
  473. br.Msg = "报告ID不存在!"
  474. return
  475. }
  476. if reportInfo.ReportType != 2 {
  477. br.Msg = "操作失败!"
  478. br.ErrMsg = "报告类型不属于产业报告!"
  479. return
  480. }
  481. industrialStrList := strings.Split(industrialManagementIdStr, ",")
  482. for _, v := range industrialStrList {
  483. condition = `AND industrial_management_id = ` + v
  484. totalIndustrialManagement, _ := cygx.GetIndustrialManagementCount(condition, pars)
  485. if totalIndustrialManagement < 1 {
  486. br.Msg = "操作失败"
  487. br.ErrMsg = "操作失败,产业不存在IndustrialManagementId:" + v
  488. return
  489. }
  490. }
  491. if req.IndustrialSubjectIdStr != "0" && req.IndustrialSubjectIdStr != "" {
  492. strList := strings.Split(req.IndustrialSubjectIdStr, ",")
  493. for _, v := range strList {
  494. condition = `AND industrial_subject_id = ` + v + ` AND industrial_management_id IN ( ` + industrialManagementIdStr + `)`
  495. totalIndustrialSubject, _ := cygx.GetIndustrialSubjectCount(condition, pars)
  496. if totalIndustrialSubject < 1 {
  497. br.Msg = "操作失败"
  498. br.ErrMsg = "操作失败,标的不存在IndustrialSubjectId:" + v
  499. return
  500. }
  501. }
  502. }
  503. err = cygx.ReportArticleClassificationEditNew(req.ReportId, industrialManagementIdStr, reportInfo.ArticleId, req.IndustrialSubjectIdStr)
  504. if err != nil {
  505. br.Msg = "分类失败"
  506. br.ErrMsg = "分类失败,Err:" + err.Error()
  507. return
  508. }
  509. go cygxService.DoArticleOnenIdWxTemplateMsg(reportInfo.ArticleId, 2)
  510. br.Ret = 200
  511. br.Success = true
  512. br.Msg = "分类成功"
  513. br.IsAddLog = true
  514. }
  515. // @Title 是否展示操作按钮
  516. // @Description 获取是否展示操作按钮接口
  517. // @Success Ret=200 {object} cygx.ShowButton
  518. // @router /reportArticle/showButton [get]
  519. func (this *IndustrialSubjectController) ShowButton() {
  520. br := new(models.BaseResponse).Init()
  521. defer func() {
  522. this.Data["json"] = br
  523. this.ServeJSON()
  524. }()
  525. sysUser := this.SysUser
  526. if sysUser == nil {
  527. br.Msg = "请登录"
  528. br.ErrMsg = "请登录,SysUser Is Empty"
  529. return
  530. }
  531. resp := new(cygx.ShowButton)
  532. if sysUser.RoleTypeCode == "rai_admin" || sysUser.RoleTypeCode == "rai_researcher" || sysUser.RoleTypeCode == "admin" {
  533. resp.IsShowButton = true
  534. }
  535. br.Ret = 200
  536. br.Success = true
  537. br.Msg = "获取成功"
  538. br.Data = resp
  539. }
  540. // @Title 下载阅读明细
  541. // @Description 获取下载阅读明细接口
  542. // @Param ReportId query int true "报告ID"
  543. // @Success Ret=200
  544. // @router /reportArticle/export [get]
  545. func (this *IndustrialSubjectController) Export() {
  546. br := new(models.BaseResponse).Init()
  547. defer func() {
  548. this.Data["json"] = br
  549. this.ServeJSON()
  550. }()
  551. sysUser := this.SysUser
  552. if sysUser == nil {
  553. br.Msg = "请登录"
  554. br.ErrMsg = "请登录,SysUser Is Empty"
  555. return
  556. }
  557. reportId, _ := this.GetInt("ReportId")
  558. //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
  559. resp := new(cygx.CanDownload)
  560. adminInfo, errAdmin := system.GetSysUserById(sysUser.AdminId)
  561. if errAdmin != nil {
  562. br.Msg = "获取失败"
  563. br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
  564. return
  565. }
  566. if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
  567. resp.IsCanDownload = true
  568. }
  569. var list []*cygx.ReportExportRep
  570. var err error
  571. if resp.IsCanDownload == false {
  572. //权益申请销售只能看到自己名下的客户的申请
  573. companyIds, err := cygxService.GetAdminLookUserCompanyIds(sysUser)
  574. if err != nil {
  575. br.Msg = "获取失败"
  576. br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
  577. return
  578. }
  579. var companyIdstr []string
  580. for _, v := range companyIds {
  581. companyIdstr = append(companyIdstr, strconv.Itoa(v))
  582. }
  583. sqlStr := ` AND h.company_id IN (` + strings.Join(companyIdstr, ",") + `) `
  584. listSeller, errSeller := cygx.GetReportExportRep(reportId, sqlStr)
  585. list = listSeller
  586. err = errSeller
  587. } else {
  588. sqlStr := ""
  589. listAdmin, errAdmin := cygx.GetReportExportRep(reportId, sqlStr)
  590. list = listAdmin
  591. err = errAdmin
  592. }
  593. if err != nil {
  594. br.Msg = "获取失败"
  595. br.ErrMsg = "获取失败,Err:" + err.Error()
  596. return
  597. }
  598. var listNew []*cygx.ReportExportRep
  599. for k, v := range list {
  600. if k > 0 && list[k].Id == list[k-1].Id {
  601. list[k-1].SellerName = list[k-1].SellerName + "/" + v.SellerName
  602. }
  603. }
  604. for k, v := range list {
  605. if k > 0 && list[k].Id != list[k-1].Id {
  606. listNew = append(listNew, v)
  607. }
  608. }
  609. //创建excel
  610. dir, err := os.Executable()
  611. exPath := filepath.Dir(dir)
  612. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  613. xlsxFile := xlsx.NewFile()
  614. if err != nil {
  615. br.Msg = "生成文件失败"
  616. br.ErrMsg = "生成文件失败"
  617. return
  618. }
  619. style := xlsx.NewStyle()
  620. alignment := xlsx.Alignment{
  621. Horizontal: "center",
  622. Vertical: "center",
  623. WrapText: true,
  624. }
  625. style.Alignment = alignment
  626. style.ApplyAlignment = true
  627. sheet, err := xlsxFile.AddSheet("关键词搜索统计")
  628. if err != nil {
  629. br.Msg = "新增Sheet失败"
  630. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  631. return
  632. }
  633. //标头
  634. rowTitle := sheet.AddRow()
  635. cellA := rowTitle.AddCell()
  636. cellA.Value = "姓名"
  637. cellB := rowTitle.AddCell()
  638. cellB.Value = "公司名"
  639. cellC := rowTitle.AddCell()
  640. cellC.Value = "销售名称"
  641. cellD := rowTitle.AddCell()
  642. cellD.Value = "阅读时间"
  643. cellE := rowTitle.AddCell()
  644. cellE.Value = "停留时间(s)"
  645. for _, item := range listNew {
  646. row := sheet.AddRow()
  647. cellA := row.AddCell()
  648. cellA.Value = item.RealName
  649. cellB := row.AddCell()
  650. cellB.Value = item.CompanyName
  651. cellC := row.AddCell()
  652. cellC.Value = item.SellerName
  653. cellD := row.AddCell()
  654. cellD.Value = item.CreateTime
  655. cellE := row.AddCell()
  656. cellE.Value = item.StopTime
  657. }
  658. err = xlsxFile.Save(downLoadnFilePath)
  659. if err != nil {
  660. br.Msg = "保存文件失败"
  661. br.ErrMsg = "保存文件失败"
  662. return
  663. }
  664. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  665. downloadFileName := "阅读明细统计列表" + randStr + ".xlsx"
  666. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  667. defer func() {
  668. os.Remove(downLoadnFilePath)
  669. }()
  670. br.Ret = 200
  671. br.Success = true
  672. br.Msg = "导出成功"
  673. }
  674. // @Title 通过报告ID获取对应的匹配类型
  675. // @Description 通过报告ID获取对应的匹配类型接口
  676. // @Param ReportId query int true "报告ID"
  677. // @Success 200 {object} cygx.ReportMatchTypeNameList
  678. // @router /reportArticle/getMatchTypeName [get]
  679. func (this *IndustrialSubjectController) GetMatchTypeNameByReportId() {
  680. br := new(models.BaseResponse).Init()
  681. defer func() {
  682. this.Data["json"] = br
  683. this.ServeJSON()
  684. }()
  685. sysUser := this.SysUser
  686. if sysUser == nil {
  687. br.Msg = "请登录"
  688. br.ErrMsg = "请登录,SysUser Is Empty"
  689. return
  690. }
  691. reportId, _ := this.GetInt("ReportId")
  692. detail, err := cygx.GetArticleDetailById(reportId)
  693. if err != nil {
  694. br.Msg = "获取信息失败"
  695. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  696. return
  697. }
  698. list, err := cygx.GetMatchTypeName(detail.CategoryId)
  699. if err != nil {
  700. br.Msg = "获取信息失败"
  701. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  702. return
  703. }
  704. resp := new(cygx.ReportMatchTypeNameList)
  705. resp.List = list
  706. br.Ret = 200
  707. br.Success = true
  708. br.Msg = "获取成功"
  709. br.Data = resp
  710. }
  711. // @Title 修改报告的匹配类型
  712. // @Description 修改报告的匹配类型接口
  713. // @Param request body cygx.UpdateReportMatchTypeNameRep true "type json string"
  714. // @Success Ret=200
  715. // @router /reportArticle/updateMatchTypeName [post]
  716. func (this *IndustrialSubjectController) UpdateMatchTypeName() {
  717. br := new(models.BaseResponse).Init()
  718. defer func() {
  719. this.Data["json"] = br
  720. this.ServeJSON()
  721. }()
  722. sysUser := this.SysUser
  723. if sysUser == nil {
  724. br.Msg = "请登录"
  725. br.ErrMsg = "请登录,SysUser Is Empty"
  726. return
  727. }
  728. var req cygx.UpdateReportMatchTypeNameRep
  729. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  730. reportId := req.ReportId
  731. if err != nil {
  732. br.Msg = "参数解析异常!"
  733. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  734. return
  735. }
  736. detail, err := cygx.GetMatchTypeNameById(req.MatchID)
  737. if err != nil {
  738. br.Msg = "获取信息失败"
  739. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  740. return
  741. }
  742. detailArt, err := cygx.GetArticleDetailById(reportId)
  743. if err != nil {
  744. br.Msg = "获取信息失败"
  745. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  746. return
  747. }
  748. err = cygx.UpdateReportMatchTypeName(detail.MatchTypeName, detail.ReportType, detail.CategoryId, req.ReportId, detailArt.IsSummary, detailArt.IsClass)
  749. if err != nil {
  750. br.Msg = "修改失败"
  751. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  752. return
  753. }
  754. go cygxService.DoArticleOnenIdWxTemplateMsg(detailArt.ArticleId, 2)
  755. go cygxService.AddCygxReportMappingCategoryGroupByArticleId(detailArt.ArticleId) // 手动修改报告归类
  756. go cygxService.UpdateArticleResourceData(detailArt.ArticleId) //写入首页最新 cygx_resource_data 表
  757. br.Ret = 200
  758. br.Success = true
  759. br.Msg = "修改成功"
  760. br.IsAddLog = true
  761. }
  762. // @Title 报告内容的保存与发布
  763. // @Description 报告内容的保存与发布接口
  764. // @Param request body cygx.ReportAddRep true "type json string"
  765. // @Success 200 操作成功
  766. // @router /reportArticle/PreserveAndPublish [post]
  767. func (this *ReportArticleController) PreserveAndPublish() {
  768. br := new(models.BaseResponse).Init()
  769. defer func() {
  770. this.Data["json"] = br
  771. this.ServeJSON()
  772. }()
  773. AdminUser := this.SysUser
  774. if AdminUser == nil {
  775. br.Msg = "请登录"
  776. br.ErrMsg = "请登录,用户信息为空"
  777. br.Ret = 408
  778. return
  779. }
  780. var req cygx.ReportAddRep
  781. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  782. if err != nil {
  783. br.Msg = "参数解析异常!"
  784. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  785. return
  786. }
  787. if req.Title == "" {
  788. br.Msg = "标题不可为空"
  789. br.ErrMsg = "标题不可为空"
  790. return
  791. }
  792. if req.Abstract == "" {
  793. br.Msg = "摘要不可为空"
  794. br.ErrMsg = "摘要不可为空"
  795. return
  796. }
  797. var articleId int
  798. industrialManagementIds := req.IndustrialManagementIds
  799. industrialSubjectIds := req.IndustrialSubjectIds
  800. chartPermissionId := req.ChartPermissionId
  801. publishDate := req.PublishDate
  802. if industrialManagementIds == "" {
  803. br.Msg = "请选择产业"
  804. return
  805. }
  806. if publishDate == "" {
  807. br.Msg = "请选择发布时间"
  808. return
  809. }
  810. industryIds := make([]int, 0)
  811. industrialManagementIdList := strings.Split(industrialManagementIds, ",")
  812. for _, v := range industrialManagementIdList {
  813. i, err := strconv.Atoi(v)
  814. if err != nil {
  815. br.Msg = "参数解析异常!"
  816. br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIds
  817. return
  818. }
  819. industryIds = append(industryIds, i)
  820. }
  821. if industrialSubjectIds != "" {
  822. industrialSubjectIdList := strings.Split(industrialSubjectIds, ",")
  823. for _, v := range industrialSubjectIdList {
  824. _, err := strconv.Atoi(v)
  825. if err != nil {
  826. br.Msg = "参数解析异常!"
  827. br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIds
  828. return
  829. }
  830. }
  831. }
  832. var pars []interface{}
  833. var condition string
  834. condition += ` AND chart_permission_id = ? AND sub_category_name = '专项调研' `
  835. pars = append(pars, chartPermissionId)
  836. charInfo, err := cygx.GetReportMappingDetail(condition, pars)
  837. if err != nil {
  838. br.Msg = "请选择所属行业"
  839. br.ErrMsg = "获取所属行业信息失败,Err:" + err.Error()
  840. return
  841. }
  842. var articleIdNew int
  843. if articleId == 0 {
  844. maxArticleIdArticleInfo, errMax := cygx.GetMaxArticleIdInfo()
  845. if errMax != nil {
  846. br.Msg = "发布失败"
  847. br.ErrMsg = "发布失败,Err:" + errMax.Error()
  848. return
  849. }
  850. if maxArticleIdArticleInfo.ArticleId < utils.SummaryArticleId {
  851. articleIdNew = utils.SummaryArticleId
  852. } else {
  853. articleIdNew = maxArticleIdArticleInfo.ArticleId + 1
  854. }
  855. }
  856. expertNumStr, expertContentStr, interviewDateStr, fileLink := cygx.BodyAnalysis(req.Body)
  857. item := new(cygx.CygxArticle)
  858. item.AdminId = AdminUser.AdminId
  859. item.AdminName = AdminUser.AdminName
  860. item.Title = req.Title
  861. item.Body = cygxService.GetRichtext(req.Body)
  862. item.BodyText, _ = cygx.GetReportContentTextSub(item.Body)
  863. item.Abstract = req.Abstract
  864. item.CategoryName = charInfo.MatchTypeName
  865. item.SubCategoryName = charInfo.SubCategoryName
  866. item.ArticleId = articleId
  867. item.CreateDate = time.Now()
  868. item.LastUpdatedTime = time.Now()
  869. item.IsReport = 1
  870. item.IsSummary = 1
  871. item.Source = 1
  872. item.IsClass = 1
  873. item.IsReport = 1
  874. item.ReportType = 2
  875. item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdNew))
  876. item.UpdateFrequency = "unknow"
  877. item.SellerAndMobile = req.SellerAndMobile
  878. item.ExpertBackground = expertContentStr
  879. item.ExpertNumber = expertNumStr
  880. item.InterviewDate = interviewDateStr
  881. item.FileLink = fileLink
  882. item.CategoryId = charInfo.CategoryId
  883. item.CategoryIdTwo = charInfo.CategoryId
  884. item.ChartPermissionIds = strconv.Itoa(chartPermissionId)
  885. item.PublishDate = utils.StrTimeToTime(publishDate + " 00:00:00") //时间字符串格式转时间格式
  886. //处理作者内容的格式信息
  887. if req.DoType == 1 {
  888. item.PublishStatus = 1
  889. }
  890. itemDepartment := new(cygx.CygxArticleDepartment)
  891. if req.ArticleId == 0 {
  892. item.ArticleId = articleIdNew
  893. //需求修改纪要的新增与修改与报告一致
  894. _, err := cygx.AddAReportrticle(item, 0, "", "", itemDepartment, industrialManagementIds, industrialSubjectIds)
  895. if err != nil {
  896. br.Msg = "发布失败"
  897. br.ErrMsg = "发布失败,Err:" + err.Error()
  898. return
  899. }
  900. } else {
  901. articleInfo, err := cygx.GetArticleIdInfoByArticleId(req.ArticleId)
  902. if err != nil {
  903. br.Msg = "文章不存在"
  904. return
  905. }
  906. if item.PublishStatus == 0 {
  907. item.PublishStatus = articleInfo.PublishStatus
  908. }
  909. item.ArticleId = req.ArticleId
  910. err = cygx.EditReportrticle(item, 0, "", "", articleInfo.PublishStatus, itemDepartment, industrialManagementIds, industrialSubjectIds)
  911. if err != nil {
  912. br.Msg = "发布失败"
  913. br.ErrMsg = "发布失败,Err:" + err.Error()
  914. return
  915. }
  916. }
  917. //if req.DoType == 1 {
  918. // go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  919. //}
  920. //{|1|}表示报告类型,{|2|}表示纪要类型
  921. //cygx.UpdateSubjecIds(subjectIds+"—"+strconv.Itoa(industrialDetail.IndustrialManagementId)+"{|2|}", industrialDetail.IndustrialManagementId, articleId)
  922. if item.PublishStatus == 1 {
  923. services.EsAddOrEditData(item)
  924. //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  925. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  926. }
  927. // 查研观向7.4-更新产业布局时间
  928. if len(industryIds) > 0 {
  929. go cygxService.UpdateIndustryLayoutTime(industryIds, false)
  930. }
  931. if len(industryIds) > 0 && req.DoType == 1 {
  932. //查研观向8.2.1专项调研报告模板消息推送
  933. cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
  934. }
  935. go cygxService.AddCygxReportMappingCategoryGroupByArticleId(item.ArticleId) // 手动修改报告归类
  936. br.Ret = 200
  937. br.Success = true
  938. br.Msg = "操作成功"
  939. br.IsAddLog = true
  940. }
  941. // @Title 报告详情
  942. // @Description 获取报告详情接口
  943. // @Param ReportId query int true "报告ID"
  944. // @Success Ret=200 {object} cygx.CygxArticleReport
  945. // @router /reportArticle/detail [get]
  946. func (this *ReportArticleController) Detail() {
  947. br := new(models.BaseResponse).Init()
  948. defer func() {
  949. this.Data["json"] = br
  950. this.ServeJSON()
  951. }()
  952. AdminUser := this.SysUser
  953. if AdminUser == nil {
  954. br.Msg = "请登录"
  955. br.ErrMsg = "请登录,用户信息为空"
  956. br.Ret = 408
  957. return
  958. }
  959. //reportId, _ := this.GetInt("ReportId")
  960. //if reportId < 1 {
  961. // br.Msg = "请输入报告ID"
  962. // return
  963. //}
  964. //articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(reportId)
  965. //if err != nil {
  966. // br.Msg = "报告不存在"
  967. // br.ErrMsg = "报告ID错误,Err:" + err.Error()
  968. // return
  969. //}
  970. articleId, _ := this.GetInt("ArticleId")
  971. if articleId < 1 {
  972. br.Msg = "请输入文章ID"
  973. return
  974. }
  975. articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(articleId)
  976. if err != nil {
  977. br.Msg = "文章内容不存在"
  978. br.ErrMsg = "纪要ID错误,Err:" + err.Error()
  979. return
  980. }
  981. industrialList, err := cygx.GetIndustrialArticleGroupManagementList(articleInfo.ArticleId)
  982. if err != nil && err.Error() != utils.ErrNoRow() {
  983. br.Msg = "获取信息失败"
  984. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
  985. return
  986. }
  987. subjectList, err := cygx.GetSubjectArticleGroupManagementList(articleInfo.ArticleId)
  988. if err != nil && err.Error() != utils.ErrNoRow() {
  989. br.Msg = "获取信息失败"
  990. br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
  991. return
  992. }
  993. articleInfo.PublishDate = cygxService.ArticlePublishDate(articleInfo.PublishDate)
  994. articleInfo.ListIndustrial = industrialList
  995. articleInfo.ListSubject = subjectList
  996. if articleInfo.ChartPermissionIds != "" {
  997. chartPermissionIdArr := strings.Split(articleInfo.ChartPermissionIds, ",")
  998. if len(chartPermissionIdArr) > 0 {
  999. articleInfo.ChartPermissionId, _ = strconv.Atoi(chartPermissionIdArr[0])
  1000. }
  1001. }
  1002. if articleId < utils.SummaryArticleId {
  1003. articleInfo.Abstract, _ = cygx.GetReportContentTextSub(articleInfo.Abstract)
  1004. articleInfo.Body = html.UnescapeString(articleInfo.Body)
  1005. }
  1006. br.Ret = 200
  1007. br.Success = true
  1008. br.Msg = "获取成功"
  1009. br.Data = articleInfo
  1010. }
  1011. // @Title 获取作者列表
  1012. // @Description 获取作者列表接口
  1013. // @Param KeyWord query string true "搜索关键词"
  1014. // @Success Ret=200 {object} cygx.CygxArticleDepartmentList
  1015. // @router /reportArticle/departmentList [get]
  1016. func (this *ReportArticleController) DepartmentList() {
  1017. br := new(models.BaseResponse).Init()
  1018. defer func() {
  1019. this.Data["json"] = br
  1020. this.ServeJSON()
  1021. }()
  1022. sysUser := this.SysUser
  1023. if sysUser == nil {
  1024. br.Msg = "请登录"
  1025. br.ErrMsg = "请登录,SysUser Is Empty"
  1026. br.Ret = 408
  1027. return
  1028. }
  1029. var condition string
  1030. keyWord := this.GetString("KeyWord")
  1031. if keyWord != "" {
  1032. condition = `WHERE nick_name LIKE'%` + keyWord + `%' ORDER BY create_time DESC `
  1033. } else {
  1034. condition += ` ORDER BY create_time DESC`
  1035. }
  1036. list, err := cygx.GetCygxArticleDepartmentList(condition)
  1037. if err != nil {
  1038. br.Msg = "获取失败"
  1039. br.ErrMsg = "获取失败,Err:" + err.Error()
  1040. return
  1041. }
  1042. resp := new(cygx.CygxArticleDepartmentList)
  1043. resp.List = list
  1044. br.Ret = 200
  1045. br.Success = true
  1046. br.Msg = "获取成功"
  1047. br.Data = resp
  1048. }
  1049. // @Title 下载客户阅读记录
  1050. // @Description 下载客户阅读记录接口
  1051. // @Param CompanyId query int true "公司ID"
  1052. // @Success Ret=200
  1053. // @router /reportArticle/companyHistory [get]
  1054. func (this *IndustrialSubjectController) CompanyHistory() {
  1055. br := new(models.BaseResponse).Init()
  1056. defer func() {
  1057. this.Data["json"] = br
  1058. this.ServeJSON()
  1059. }()
  1060. sysUser := this.SysUser
  1061. if sysUser == nil {
  1062. br.Msg = "请登录"
  1063. br.ErrMsg = "请登录,SysUser Is Empty"
  1064. return
  1065. }
  1066. companyId, _ := this.GetInt("CompanyId")
  1067. if companyId < 1 {
  1068. br.Msg = "请输入公司ID"
  1069. return
  1070. }
  1071. //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
  1072. var isCanDownload bool
  1073. adminInfo, err := system.GetSysUserById(sysUser.AdminId)
  1074. if err != nil {
  1075. br.Msg = "获取失败"
  1076. br.ErrMsg = "获取失败,Err:" + err.Error()
  1077. return
  1078. }
  1079. if adminInfo.Role == "admin" || strings.Index(adminInfo.RoleTypeCode, "rai") > -1 {
  1080. isCanDownload = true
  1081. }
  1082. if !isCanDownload {
  1083. br.Msg = "暂无下载权限"
  1084. return
  1085. }
  1086. //获取企业客户信息
  1087. companyInfo, err := company.GetCompanyById(companyId)
  1088. if err != nil {
  1089. br.Msg = "获取失败"
  1090. br.ErrMsg = "获取企业客户信息失败,Err:" + err.Error()
  1091. return
  1092. }
  1093. mapChartPermissionName := make(map[int]string)
  1094. listMap, err := cygx.GetPermissionMappingCategoryAll()
  1095. if err != nil {
  1096. br.Msg = "获取失败"
  1097. br.ErrMsg = "获取失败,Err:" + err.Error()
  1098. return
  1099. }
  1100. for _, v := range listMap {
  1101. mapChartPermissionName[v.CategoryId] = v.ChartPermissionName
  1102. }
  1103. mobiles, err := models.GetCompanyUserMobilesByCompanyId(companyId)
  1104. if err != nil && err.Error() != utils.ErrNoRow() {
  1105. br.Msg = "获取信息失败"
  1106. br.ErrMsg = "获取客户手机号信息失败,Err:" + err.Error()
  1107. return
  1108. }
  1109. if mobiles != "" {
  1110. mobiles = strings.Replace(mobiles, ",", "','", -1)
  1111. mobiles = "'" + mobiles + "'"
  1112. } else {
  1113. mobiles = "'1'"
  1114. }
  1115. emails, err := models.GetCompanyUserEmailsByCompanyId(companyId)
  1116. if err != nil && err.Error() != utils.ErrNoRow() {
  1117. br.Msg = "获取信息失败"
  1118. br.ErrMsg = "获取客户邮箱信息失败,Err:" + err.Error()
  1119. return
  1120. }
  1121. if emails != "" {
  1122. emails = strings.Replace(emails, ",", "','", -1)
  1123. emails = "'" + emails + "'"
  1124. } else {
  1125. emails = "'1'"
  1126. }
  1127. list, err := cygx.GetCompanyHistoryRecordNewPv(mobiles, emails)
  1128. if err != nil {
  1129. br.Msg = "获取失败"
  1130. br.ErrMsg = "获取失败,Err:" + err.Error()
  1131. return
  1132. }
  1133. for k, v := range list {
  1134. list[k].PermissionName = mapChartPermissionName[v.CategoryId]
  1135. }
  1136. //创建excel
  1137. dir, err := os.Executable()
  1138. exPath := filepath.Dir(dir)
  1139. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1140. xlsxFile := xlsx.NewFile()
  1141. if err != nil {
  1142. br.Msg = "生成文件失败"
  1143. br.ErrMsg = "生成文件失败"
  1144. return
  1145. }
  1146. style := xlsx.NewStyle()
  1147. alignment := xlsx.Alignment{
  1148. Horizontal: "center",
  1149. Vertical: "center",
  1150. WrapText: true,
  1151. }
  1152. style.Alignment = alignment
  1153. style.ApplyAlignment = true
  1154. sheet, err := xlsxFile.AddSheet("客户阅读记录")
  1155. if err != nil {
  1156. br.Msg = "新增Sheet失败"
  1157. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1158. return
  1159. }
  1160. //标头
  1161. rowTitle := sheet.AddRow()
  1162. cellA := rowTitle.AddCell()
  1163. cellA.Value = "姓名"
  1164. cellB := rowTitle.AddCell()
  1165. cellB.Value = "手机号/邮箱"
  1166. cellC := rowTitle.AddCell()
  1167. cellC.Value = "报告标题"
  1168. cellD := rowTitle.AddCell()
  1169. cellD.Value = "所属行业"
  1170. cellE := rowTitle.AddCell()
  1171. cellE.Value = "所属产业"
  1172. cellF := rowTitle.AddCell()
  1173. cellF.Value = "关联标的"
  1174. cellG := rowTitle.AddCell()
  1175. cellG.Value = "发布时间"
  1176. cellH := rowTitle.AddCell()
  1177. cellH.Value = "阅读时间"
  1178. cellI := rowTitle.AddCell()
  1179. cellI.Value = "阅读时长"
  1180. for _, item := range list {
  1181. row := sheet.AddRow()
  1182. cellA := row.AddCell()
  1183. cellA.Value = item.RealName
  1184. cellB := row.AddCell()
  1185. cellB.Value = item.Mobile
  1186. if item.Mobile == "" {
  1187. cellB.Value = item.Email
  1188. }
  1189. cellC := row.AddCell()
  1190. cellC.Value = item.Title
  1191. cellD := row.AddCell()
  1192. if item.CategoryId == 0 {
  1193. cellD.Value = "研选"
  1194. } else {
  1195. cellD.Value = item.PermissionName
  1196. }
  1197. cellE := row.AddCell()
  1198. cellE.Value = item.IndustryName
  1199. cellF := row.AddCell()
  1200. cellF.Value = item.SubjectNameStr
  1201. cellG := row.AddCell()
  1202. cellG.Value = item.PublishDate
  1203. cellH := row.AddCell()
  1204. cellH.Value = item.CreateTime
  1205. cellI := row.AddCell()
  1206. cellI.Value = item.StopTime
  1207. }
  1208. err = xlsxFile.Save(downLoadnFilePath)
  1209. if err != nil {
  1210. br.Msg = "保存文件失败"
  1211. br.ErrMsg = "保存文件失败"
  1212. return
  1213. }
  1214. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1215. downloadFileName := companyInfo.CompanyName + "阅读记录" + randStr + ".xlsx"
  1216. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1217. defer func() {
  1218. os.Remove(downLoadnFilePath)
  1219. }()
  1220. br.Ret = 200
  1221. br.Success = true
  1222. br.Msg = "导出成功"
  1223. }
  1224. // @Title 客户其他行为数据
  1225. // @Description 下载客户其他行为数据接口
  1226. // @Param CompanyId query int true "公司ID"
  1227. // @Success Ret=200
  1228. // @router /reportArticle/companyOtherHistory [get]
  1229. func (this *IndustrialSubjectController) CompanyOtherHistory() {
  1230. br := new(models.BaseResponse).Init()
  1231. defer func() {
  1232. this.Data["json"] = br
  1233. this.ServeJSON()
  1234. }()
  1235. sysUser := this.SysUser
  1236. if sysUser == nil {
  1237. br.Msg = "请登录"
  1238. br.ErrMsg = "请登录,SysUser Is Empty"
  1239. return
  1240. }
  1241. companyId, _ := this.GetInt("CompanyId")
  1242. if companyId <= 0 {
  1243. br.Msg = "请选择客户"
  1244. br.ErrMsg = "客户参数错误"
  1245. return
  1246. }
  1247. //获取企业客户信息
  1248. companyInfo, err := company.GetCompanyById(companyId)
  1249. if err != nil {
  1250. br.Msg = "获取失败"
  1251. br.ErrMsg = "获取企业客户信息失败,Err:" + err.Error()
  1252. return
  1253. }
  1254. var condition string
  1255. var pars []interface{}
  1256. //非管理员,那么只能看到该产品下的联系人
  1257. if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
  1258. productId := services.GetProductId(sysUser.RoleTypeCode)
  1259. condition += ` AND b.product_id = ? `
  1260. pars = append(pars, productId)
  1261. //流失客户(除非是超级管理员或者是部门管理员,要不然不允许看对应的联系人)
  1262. var companyProduct *company.CompanyProduct
  1263. if productId == 2 && sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_RAI_ADMIN {
  1264. // 当前是权益权限,且非 权益管理员
  1265. tmpCompanyProduct, _ := company.GetCompanyProductByCompanyIdAndProductId(companyId, 2)
  1266. companyProduct = tmpCompanyProduct
  1267. if companyProduct != nil && companyProduct.Status == utils.COMPANY_STATUS_LOSE {
  1268. condition += ` AND seller_id=? `
  1269. pars = append(pars, sysUser.AdminId)
  1270. }
  1271. }
  1272. }
  1273. list, err := company.GetCompanyUserListV2(condition, pars, companyId, 0, 1000)
  1274. if err != nil {
  1275. br.Msg = "获取失败"
  1276. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1277. return
  1278. }
  1279. var userIdstr string
  1280. for _, v := range list {
  1281. userIdstr += strconv.Itoa(int(v.UserId)) + ","
  1282. }
  1283. userIdstr = strings.TrimRight(userIdstr, ",")
  1284. resp := new(cygx.CompanyOtherHistoryListResp)
  1285. condition = ` AND user_id IN (` + userIdstr + `)`
  1286. listArticle, err := cygx.GetArticleCollectList(condition)
  1287. if err != nil {
  1288. br.Msg = "获取失败"
  1289. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1290. return
  1291. }
  1292. listIndustry, err := cygx.GetCygxIndustryList(companyId)
  1293. if err != nil {
  1294. br.Msg = "获取失败"
  1295. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1296. return
  1297. }
  1298. listDepartment, err := cygx.GetArticleDepartmentList(companyId)
  1299. if err != nil {
  1300. br.Msg = "获取失败"
  1301. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1302. return
  1303. }
  1304. //listkeyWord, err := cygx.GetCygxUserSearchKeyWordList(userIdstr)
  1305. //if err != nil {
  1306. // br.Msg = "获取失败"
  1307. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1308. // return
  1309. //}
  1310. //listkeyWord, err := cygx.GetCygxUserSearchKeyWordList(userIdstr)
  1311. //if err != nil {
  1312. // br.Msg = "获取失败"
  1313. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1314. // return
  1315. //}
  1316. for _, v := range list {
  1317. userItem := new(cygx.CompanyOtherHistoryList)
  1318. var artItems []*cygx.CygxArticleCollect
  1319. var industryItems []*cygx.CygxArticleIndustry
  1320. var departmentItems []*cygx.ArticleDepartment
  1321. //var keyWordItems []*cygx.KeyWord
  1322. for _, vArt := range listArticle {
  1323. if vArt.UserId == int(v.UserId) {
  1324. artItems = append(artItems, vArt)
  1325. }
  1326. }
  1327. for _, vIn := range listIndustry {
  1328. if vIn.UserId == int(v.UserId) {
  1329. industryItems = append(industryItems, vIn)
  1330. }
  1331. }
  1332. for _, vDe := range listDepartment {
  1333. if vDe.UserId == int(v.UserId) {
  1334. departmentItems = append(departmentItems, vDe)
  1335. }
  1336. }
  1337. //for _, vKw := range listkeyWord {
  1338. // if vKw.UserId == int(v.UserId) {
  1339. // keyWordItems = append(keyWordItems, vKw)
  1340. // }
  1341. //}
  1342. if len(artItems) > 0 || len(industryItems) > 0 || len(departmentItems) > 0 {
  1343. userItem.RealName = v.RealName
  1344. userItem.Email = v.Email
  1345. userItem.Mobile = v.Mobile
  1346. userItem.ListArticle = artItems
  1347. userItem.ListIndustrial = industryItems
  1348. userItem.ListDepartment = departmentItems
  1349. //userItem.ListKeyWord = keyWordItems
  1350. resp.List = append(resp.List, userItem)
  1351. }
  1352. }
  1353. //创建excel
  1354. dir, err := os.Executable()
  1355. exPath := filepath.Dir(dir)
  1356. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1357. xlsxFile := xlsx.NewFile()
  1358. if err != nil {
  1359. br.Msg = "生成文件失败"
  1360. br.ErrMsg = "生成文件失败"
  1361. return
  1362. }
  1363. style := xlsx.NewStyle()
  1364. alignment := xlsx.Alignment{
  1365. Horizontal: "center",
  1366. Vertical: "center",
  1367. WrapText: true,
  1368. }
  1369. style.Alignment = alignment
  1370. style.ApplyAlignment = true
  1371. sheet, err := xlsxFile.AddSheet("客户其他行为数据(收藏,关注)")
  1372. if err != nil {
  1373. br.Msg = "新增Sheet失败"
  1374. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1375. return
  1376. }
  1377. //标题样式
  1378. titleStyle := xlsx.NewStyle()
  1379. titleFont := xlsx.NewFont(16, "宋体")
  1380. titleFont.Bold = true
  1381. titleStyle.Font = *titleFont
  1382. titleStyle.Alignment = alignment
  1383. sheet.SetColWidth(0, 0, 20)
  1384. sheet.SetColWidth(1, 1, 20)
  1385. sheet.SetColWidth(2, 2, 20)
  1386. sheet.SetColWidth(3, 3, 20)
  1387. sheet.SetColWidth(4, 4, 20)
  1388. titleSonStyle := xlsx.NewStyle()
  1389. titleSonFont := xlsx.NewFont(16, "宋体")
  1390. titleSonFont.Bold = true
  1391. titleSonStyle.Font = *titleSonFont
  1392. for _, item := range resp.List {
  1393. rowTitle := sheet.AddRow()
  1394. //标题列
  1395. titleCell := rowTitle.AddCell()
  1396. titleCell.HMerge = 6 //向右合并列数,不包括自身列
  1397. titleCell.SetValue("客户姓名:" + item.RealName + " 手机号/邮箱:" + item.Mobile)
  1398. titleCell.SetStyle(titleStyle)
  1399. //文章
  1400. if len(item.ListArticle) > 0 {
  1401. rowArticle := sheet.AddRow()
  1402. cellA := rowArticle.AddCell()
  1403. cellA.Value = "收藏报告"
  1404. cellB := rowArticle.AddCell()
  1405. cellB.Value = "收藏时间"
  1406. cellC := rowArticle.AddCell()
  1407. cellC.Value = "发布时间"
  1408. cellD := rowArticle.AddCell()
  1409. cellD.Value = "报告类型"
  1410. cellE := rowArticle.AddCell()
  1411. cellE.Value = "所属产业"
  1412. cellF := rowArticle.AddCell()
  1413. cellF.Value = "关联标的"
  1414. cellA.SetStyle(titleSonStyle)
  1415. cellB.SetStyle(titleSonStyle)
  1416. cellC.SetStyle(titleSonStyle)
  1417. cellD.SetStyle(titleSonStyle)
  1418. cellE.SetStyle(titleSonStyle)
  1419. cellF.SetStyle(titleSonStyle)
  1420. for _, vArt := range item.ListArticle {
  1421. rowArticleVal := sheet.AddRow()
  1422. cellA := rowArticleVal.AddCell()
  1423. cellA.Value = vArt.Title
  1424. cellB := rowArticleVal.AddCell()
  1425. cellB.Value = vArt.CreateTime
  1426. cellC := rowArticleVal.AddCell()
  1427. cellC.Value = vArt.PublishDate
  1428. cellD := rowArticleVal.AddCell()
  1429. cellD.Value = vArt.MatchTypeName
  1430. cellE := rowArticleVal.AddCell()
  1431. cellE.Value = vArt.IndustryName
  1432. cellF := rowArticleVal.AddCell()
  1433. cellF.Value = vArt.SubjectName
  1434. }
  1435. }
  1436. //产业
  1437. if len(item.ListIndustrial) > 0 {
  1438. rowIndustrial := sheet.AddRow()
  1439. cellA := rowIndustrial.AddCell()
  1440. cellA.Value = "关注产业"
  1441. cellB := rowIndustrial.AddCell()
  1442. cellB.Value = "关注时间"
  1443. cellA.SetStyle(titleSonStyle)
  1444. cellB.SetStyle(titleSonStyle)
  1445. for _, vArt := range item.ListIndustrial {
  1446. rowIndustrialVal := sheet.AddRow()
  1447. cellA := rowIndustrialVal.AddCell()
  1448. cellA.Value = vArt.IndustryName
  1449. cellB := rowIndustrialVal.AddCell()
  1450. cellB.Value = vArt.CreateTime
  1451. }
  1452. }
  1453. //作者
  1454. if len(item.ListDepartment) > 0 {
  1455. rowDepartment := sheet.AddRow()
  1456. cellA := rowDepartment.AddCell()
  1457. cellA.Value = "关注作者"
  1458. cellB := rowDepartment.AddCell()
  1459. cellB.Value = "关注时间"
  1460. cellC := rowDepartment.AddCell()
  1461. cellC.Value = "作者相关产业"
  1462. cellA.SetStyle(titleSonStyle)
  1463. cellB.SetStyle(titleSonStyle)
  1464. cellC.SetStyle(titleSonStyle)
  1465. for _, vArt := range item.ListDepartment {
  1466. rowDepartmentVal := sheet.AddRow()
  1467. cellA := rowDepartmentVal.AddCell()
  1468. cellA.Value = vArt.NickName
  1469. cellB := rowDepartmentVal.AddCell()
  1470. cellB.Value = vArt.CreateTime
  1471. cellC := rowDepartmentVal.AddCell()
  1472. cellC.Value = vArt.IndustryName
  1473. }
  1474. }
  1475. }
  1476. err = xlsxFile.Save(downLoadnFilePath)
  1477. if err != nil {
  1478. br.Msg = "保存文件失败"
  1479. br.ErrMsg = "保存文件失败"
  1480. return
  1481. }
  1482. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1483. downloadFileName := companyInfo.CompanyName + "其他行为数据(收藏,关注)" + randStr + ".xlsx"
  1484. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1485. defer func() {
  1486. os.Remove(downLoadnFilePath)
  1487. }()
  1488. br.Ret = 200
  1489. br.Data = resp
  1490. br.Success = true
  1491. br.Msg = "导出成功"
  1492. }
  1493. // @Title 客户阅读量月度统计
  1494. // @Description 客户阅读量月度统计
  1495. // @Param CompanyId query int true "公司ID"
  1496. // @Success Ret=200
  1497. // @router /reportArticle/companyCount [get]
  1498. func (this *IndustrialSubjectController) CompanyCount() {
  1499. br := new(models.BaseResponse).Init()
  1500. defer func() {
  1501. this.Data["json"] = br
  1502. this.ServeJSON()
  1503. }()
  1504. sysUser := this.SysUser
  1505. if sysUser == nil {
  1506. br.Msg = "请登录"
  1507. br.ErrMsg = "请登录,SysUser Is Empty"
  1508. return
  1509. }
  1510. companyId, _ := this.GetInt("CompanyId")
  1511. if companyId < 1 {
  1512. br.Msg = "请输入公司ID"
  1513. return
  1514. }
  1515. //超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
  1516. var isCanDownload bool
  1517. adminInfo, err := system.GetSysUserById(sysUser.AdminId)
  1518. if err != nil {
  1519. br.Msg = "获取失败"
  1520. br.ErrMsg = "获取失败,Err:" + err.Error()
  1521. return
  1522. }
  1523. if adminInfo.Role == "admin" || strings.Index(adminInfo.RoleTypeCode, "rai") > -1 {
  1524. isCanDownload = true
  1525. }
  1526. if !isCanDownload {
  1527. br.Msg = "暂无下载权限"
  1528. return
  1529. }
  1530. //获取企业客户信息
  1531. companyInfo, err := company.GetCompanyById(companyId)
  1532. if err != nil {
  1533. br.Msg = "获取失败"
  1534. br.ErrMsg = "获取企业客户信息失败,Err:" + err.Error()
  1535. return
  1536. }
  1537. mobiles, err := models.GetCompanyUserMobilesByCompanyId(companyId)
  1538. if err != nil && err.Error() != utils.ErrNoRow() {
  1539. br.Msg = "获取信息失败"
  1540. br.ErrMsg = "获取客户手机号信息失败,Err:" + err.Error()
  1541. return
  1542. }
  1543. if mobiles != "" {
  1544. mobiles = strings.Replace(mobiles, ",", "','", -1)
  1545. mobiles = "'" + mobiles + "'"
  1546. } else {
  1547. mobiles = "'1'"
  1548. }
  1549. emails, err := models.GetCompanyUserEmailsByCompanyId(companyId)
  1550. if err != nil && err.Error() != utils.ErrNoRow() {
  1551. br.Msg = "获取信息失败"
  1552. br.ErrMsg = "获取客户邮箱信息失败,Err:" + err.Error()
  1553. return
  1554. }
  1555. if emails != "" {
  1556. emails = strings.Replace(emails, ",", "','", -1)
  1557. emails = "'" + emails + "'"
  1558. } else {
  1559. emails = "'1'"
  1560. }
  1561. listDate, err := cygx.GetCompanyHistoryRecordPvGroupDate(mobiles, emails)
  1562. if err != nil {
  1563. br.Msg = "获取失败"
  1564. br.ErrMsg = "获取失败,Err:" + err.Error()
  1565. return
  1566. }
  1567. dateMap := make(map[string]int)
  1568. permissionNameMap := make(map[string]int)
  1569. list, err := cygx.GetCompanyHistoryRecordPv(mobiles, emails)
  1570. if err != nil {
  1571. br.Msg = "获取失败"
  1572. br.ErrMsg = "获取失败,Err:" + err.Error()
  1573. return
  1574. }
  1575. for _, v := range list {
  1576. if dateMap[v.CreateTime] == 0 {
  1577. dateMap[v.CreateTime] = 1
  1578. } else {
  1579. dateMap[v.CreateTime] += 1
  1580. }
  1581. if v.CategoryId == 0 {
  1582. v.PermissionName = "研选"
  1583. }
  1584. if permissionNameMap[v.CreateTime+v.PermissionName] == 0 {
  1585. permissionNameMap[v.CreateTime+v.PermissionName] = 1
  1586. } else {
  1587. permissionNameMap[v.CreateTime+v.PermissionName] += 1
  1588. }
  1589. }
  1590. //创建excel
  1591. dir, err := os.Executable()
  1592. exPath := filepath.Dir(dir)
  1593. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1594. xlsxFile := xlsx.NewFile()
  1595. if err != nil {
  1596. br.Msg = "生成文件失败"
  1597. br.ErrMsg = "生成文件失败"
  1598. return
  1599. }
  1600. style := xlsx.NewStyle()
  1601. alignment := xlsx.Alignment{
  1602. Horizontal: "center",
  1603. Vertical: "center",
  1604. WrapText: true,
  1605. }
  1606. style.Alignment = alignment
  1607. style.ApplyAlignment = true
  1608. sheet, err := xlsxFile.AddSheet("客户阅读量月度统计")
  1609. if err != nil {
  1610. br.Msg = "新增Sheet失败"
  1611. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1612. return
  1613. }
  1614. //标头
  1615. rowTitle := sheet.AddRow()
  1616. cellA := rowTitle.AddCell()
  1617. cellA.Value = "月份"
  1618. cellB := rowTitle.AddCell()
  1619. cellB.Value = "总阅读数"
  1620. cellC := rowTitle.AddCell()
  1621. cellC.Value = "医药"
  1622. cellD := rowTitle.AddCell()
  1623. cellD.Value = "消费"
  1624. cellE := rowTitle.AddCell()
  1625. cellE.Value = "科技"
  1626. cellF := rowTitle.AddCell()
  1627. cellF.Value = "智造"
  1628. cellG := rowTitle.AddCell()
  1629. cellG.Value = "策略"
  1630. cellH := rowTitle.AddCell()
  1631. cellH.Value = "研选"
  1632. for _, item := range listDate {
  1633. row := sheet.AddRow()
  1634. cellA := row.AddCell()
  1635. cellA.Value = item.CreateTimes
  1636. cellB := row.AddCell()
  1637. cellB.Value = strconv.Itoa(dateMap[item.CreateTimes])
  1638. cellC := row.AddCell()
  1639. cellC.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"医药"])
  1640. cellD := row.AddCell()
  1641. cellD.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"消费"])
  1642. cellE := row.AddCell()
  1643. cellE.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"科技"])
  1644. cellF := row.AddCell()
  1645. cellF.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"智造"])
  1646. cellG := row.AddCell()
  1647. cellG.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"策略"])
  1648. cellH := row.AddCell()
  1649. cellH.Value = strconv.Itoa(permissionNameMap[item.CreateTimes+"研选"])
  1650. }
  1651. err = xlsxFile.Save(downLoadnFilePath)
  1652. if err != nil {
  1653. br.Msg = "保存文件失败"
  1654. br.ErrMsg = "保存文件失败"
  1655. return
  1656. }
  1657. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1658. downloadFileName := companyInfo.CompanyName + "客户阅读量月度统计" + randStr + ".xlsx"
  1659. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1660. defer func() {
  1661. os.Remove(downLoadnFilePath)
  1662. }()
  1663. br.Ret = 200
  1664. br.Success = true
  1665. br.Msg = "导出成功"
  1666. }
  1667. // @Title 客户导出文件种类
  1668. // @Description 客户导出文件种类接口
  1669. // @Success Ret=200 {object} cygx.NameAndUrlList
  1670. // @router /company/exportList [get]
  1671. func (this *ReportArticleController) ExportList() {
  1672. br := new(models.BaseResponse).Init()
  1673. defer func() {
  1674. this.Data["json"] = br
  1675. this.ServeJSON()
  1676. }()
  1677. sysUser := this.SysUser
  1678. if sysUser == nil {
  1679. br.Msg = "请登录"
  1680. br.ErrMsg = "请登录,SysUser Is Empty"
  1681. br.Ret = 408
  1682. return
  1683. }
  1684. detail, err := cygx.GetCygxConfigDetailByCode("export_list")
  1685. if err != nil {
  1686. br.Msg = "获取失败"
  1687. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1688. return
  1689. }
  1690. resp := new(cygx.NameAndUrlList)
  1691. exportList := strings.Split(detail.ConfigValue, "{|}")
  1692. for _, v := range exportList {
  1693. item := new(cygx.NameAndUrl)
  1694. vslice := strings.Split(v, "_")
  1695. item.Name = vslice[0]
  1696. item.Url = vslice[len(vslice)-1]
  1697. resp.List = append(resp.List, item)
  1698. }
  1699. br.Ret = 200
  1700. br.Success = true
  1701. br.Msg = "获取成功"
  1702. br.Data = resp
  1703. }
  1704. // @Title 留言列表详情
  1705. // @Description 获取留言列表详情接口
  1706. // @Param ArticleId query int true "文章ID"
  1707. // @Success 200 {object} cygx.ArticleCommentListResp
  1708. // @router /reportArticle/commentList [get]
  1709. func (this *ReportArticleController) CommentList() {
  1710. br := new(models.BaseResponse).Init()
  1711. defer func() {
  1712. this.Data["json"] = br
  1713. this.ServeJSON()
  1714. }()
  1715. sysUser := this.SysUser
  1716. if sysUser == nil {
  1717. br.Msg = "请登录"
  1718. br.ErrMsg = "请登录,SysUser Is Empty"
  1719. return
  1720. }
  1721. articleId, _ := this.GetInt("ArticleId")
  1722. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  1723. if articleInfo == nil {
  1724. br.Msg = "操作失败"
  1725. br.ErrMsg = "报告ID错误"
  1726. return
  1727. }
  1728. list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
  1729. resp := new(cygx.ArticleCommentListResp)
  1730. if err != nil {
  1731. br.Msg = "获取留言失败"
  1732. br.ErrMsg = "获取留言失败,Err:" + err.Error()
  1733. return
  1734. }
  1735. resp.List = list
  1736. br.Ret = 200
  1737. br.Success = true
  1738. br.Msg = "获取成功"
  1739. br.Data = resp
  1740. }
  1741. // @Title 提问详情excel表格下载
  1742. // @Description 提问详情excel表格下载接口
  1743. // @Param SummaryManageId query int true "纪要ID"
  1744. // @Success 200 导出成功
  1745. // @router /reportArticle/commnetListExport [get]
  1746. func (this *ReportArticleController) CommentListExport() {
  1747. br := new(models.BaseResponse).Init()
  1748. defer func() {
  1749. this.Data["json"] = br
  1750. this.ServeJSON()
  1751. }()
  1752. sysUser := this.SysUser
  1753. if sysUser == nil {
  1754. br.Msg = "请登录"
  1755. br.ErrMsg = "请登录,SysUser Is Empty"
  1756. return
  1757. }
  1758. articleId, _ := this.GetInt("ArticleId")
  1759. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  1760. if articleInfo == nil {
  1761. br.Msg = "操作失败"
  1762. br.ErrMsg = "报告ID错误"
  1763. return
  1764. }
  1765. list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
  1766. if err != nil {
  1767. br.Msg = "获取失败"
  1768. br.ErrMsg = "获取失败,Err:" + err.Error()
  1769. return
  1770. }
  1771. //创建excel
  1772. dir, err := os.Executable()
  1773. exPath := filepath.Dir(dir)
  1774. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1775. xlsxFile := xlsx.NewFile()
  1776. if err != nil {
  1777. br.Msg = "生成文件失败"
  1778. br.ErrMsg = "生成文件失败"
  1779. return
  1780. }
  1781. style := xlsx.NewStyle()
  1782. alignment := xlsx.Alignment{
  1783. Horizontal: "center",
  1784. Vertical: "center",
  1785. WrapText: true,
  1786. }
  1787. style.Alignment = alignment
  1788. style.ApplyAlignment = true
  1789. sheet, err := xlsxFile.AddSheet("名单")
  1790. if err != nil {
  1791. br.Msg = "新增Sheet失败"
  1792. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1793. return
  1794. }
  1795. //标头
  1796. rowTitle := sheet.AddRow()
  1797. cellA := rowTitle.AddCell()
  1798. cellA.Value = "姓名"
  1799. cellB := rowTitle.AddCell()
  1800. cellB.Value = "公司名称"
  1801. cellC := rowTitle.AddCell()
  1802. cellC.Value = "留言"
  1803. cellD := rowTitle.AddCell()
  1804. cellD.Value = "提交时间"
  1805. for _, item := range list {
  1806. row := sheet.AddRow()
  1807. cellA := row.AddCell()
  1808. cellA.Value = item.RealName
  1809. cellB := row.AddCell()
  1810. cellB.Value = item.CompanyName
  1811. cellC := row.AddCell()
  1812. cellC.Value = item.Content
  1813. cellD := row.AddCell()
  1814. cellD.Value = item.CreateTime
  1815. }
  1816. err = xlsxFile.Save(downLoadnFilePath)
  1817. if err != nil {
  1818. br.Msg = "保存文件失败"
  1819. br.ErrMsg = "保存文件失败"
  1820. return
  1821. }
  1822. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1823. downloadFileName := "留言列表" + randStr + ".xlsx"
  1824. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1825. defer func() {
  1826. os.Remove(downLoadnFilePath)
  1827. }()
  1828. br.Success = true
  1829. br.Ret = 200
  1830. br.Msg = "导出成功"
  1831. }
  1832. // @Title 新建报告类型
  1833. // @Description 新建报告类型接口
  1834. // @Param request body cygx.CygxReportMappingCygxAdd true "type json string"
  1835. // @Success Ret=200 {object} cygx.CygxReportMappingCygx
  1836. // @router /reportMapping/add [post]
  1837. func (this *IndustrialSubjectController) ReportMappingAdd() {
  1838. br := new(models.BaseResponse).Init()
  1839. defer func() {
  1840. this.Data["json"] = br
  1841. this.ServeJSON()
  1842. }()
  1843. sysUser := this.SysUser
  1844. if sysUser == nil {
  1845. br.Msg = "请登录"
  1846. br.ErrMsg = "请登录,SysUser Is Empty"
  1847. br.Ret = 408
  1848. return
  1849. }
  1850. var req cygx.CygxReportMappingCygxAdd
  1851. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1852. if err != nil {
  1853. br.Msg = "参数解析异常!"
  1854. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1855. return
  1856. }
  1857. var condition string
  1858. var pars []interface{}
  1859. reportType := req.ReportType
  1860. chartPermissionId := req.ChartPermissionId
  1861. chartPermissionName := req.ChartPermissionName
  1862. matchTypeName := req.MatchTypeName
  1863. condition = ` AND match_type_name = ? AND chart_permission_id = ? `
  1864. pars = append(pars, matchTypeName, chartPermissionId)
  1865. total, err := cygx.GetCygxReportMappingCygxCount(condition, pars)
  1866. if err != nil {
  1867. br.Msg = "新建报告类型失败"
  1868. br.ErrMsg = "新建报告类型失败,Err:" + err.Error()
  1869. return
  1870. }
  1871. if total > 0 {
  1872. br.Msg = "名称已存在"
  1873. br.ErrMsg = "名称已存在,Err:" + matchTypeName
  1874. return
  1875. }
  1876. maxDeatil, err := cygx.GetCygxReportMappingCelueMaxDetail()
  1877. if err != nil {
  1878. br.Msg = "新建报告类型失败"
  1879. br.ErrMsg = "GetCygxReportMappingCelueMaxDetail,Err:" + err.Error()
  1880. return
  1881. }
  1882. itemCygx := new(cygx.CygxReportMappingCygx)
  1883. itemCygx.ChartPermissionId = chartPermissionId
  1884. itemCygx.ChartPermissionName = chartPermissionName
  1885. itemCygx.MatchTypeName = matchTypeName
  1886. itemCygx.ReportType = reportType
  1887. itemCygx.IsReport = 1
  1888. itemCygx.CreateTime = time.Now()
  1889. itemCygx.ModifyTime = time.Now()
  1890. itemCelue := new(cygx.CygxReportMappingCelue)
  1891. itemCelue.ChartPermissionId = chartPermissionId
  1892. itemCelue.ChartPermissionName = chartPermissionName
  1893. itemCelue.SubCategoryName = matchTypeName
  1894. itemCelue.ReportType = reportType
  1895. itemCelue.IsReport = 1
  1896. itemCelue.CategoryId = maxDeatil.CategoryId + 1
  1897. itemCelue.CreateTime = time.Now()
  1898. itemCelue.ModifyTime = time.Now()
  1899. itemCygxId, err := cygx.AddCygxReportMappingCygx(itemCygx, itemCelue)
  1900. if err != nil {
  1901. br.Msg = "新建报告类型失败"
  1902. br.ErrMsg = "AddCygxReportMappingCygx,Err:" + err.Error()
  1903. return
  1904. }
  1905. resp := new(cygx.CygxReportMappingCygx)
  1906. resp.Id = int(itemCygxId)
  1907. resp.MatchTypeName = matchTypeName
  1908. br.Ret = 200
  1909. br.Success = true
  1910. br.Data = resp
  1911. br.Msg = "分类成功"
  1912. br.IsAddLog = true
  1913. }
  1914. //func init() {
  1915. // initart()
  1916. //}
  1917. func initart() {
  1918. //行业
  1919. var condition string
  1920. var pars []interface{}
  1921. condition += ` AND re.chart_permission_id = 62 `
  1922. //报告匹配类型
  1923. //9.5 13:52
  1924. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
  1925. listart, err := cygx.GetReportArticleList(condition, pars, 0, 2000, 1)
  1926. if err != nil {
  1927. fmt.Println(err)
  1928. return
  1929. }
  1930. //创建excel
  1931. dir, err := os.Executable()
  1932. exPath := filepath.Dir(dir)
  1933. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1934. xlsxFile := xlsx.NewFile()
  1935. if err != nil {
  1936. fmt.Println(err)
  1937. return
  1938. }
  1939. style := xlsx.NewStyle()
  1940. alignment := xlsx.Alignment{
  1941. Horizontal: "center",
  1942. Vertical: "center",
  1943. WrapText: true,
  1944. }
  1945. style.Alignment = alignment
  1946. style.ApplyAlignment = true
  1947. redStyle := xlsx.NewStyle()
  1948. redStyle.Alignment = alignment
  1949. redStyle.ApplyAlignment = true
  1950. redStyle.Font.Color = "ff0000"
  1951. //定义底色需要标黄的 单元格颜色
  1952. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  1953. redStyle.Fill = redFill
  1954. //redStyle.Border = *border
  1955. var sheetName string
  1956. sheetName = "PV"
  1957. sheet, err := xlsxFile.AddSheet(sheetName)
  1958. if err != nil {
  1959. fmt.Println(err)
  1960. return
  1961. }
  1962. //标头
  1963. rowTitle := sheet.AddRow()
  1964. cellAt := rowTitle.AddCell()
  1965. cellAt.Value = "标题"
  1966. cellPd := rowTitle.AddCell()
  1967. cellPd.Value = "发布时间"
  1968. cellA := rowTitle.AddCell()
  1969. cellA.Value = "姓名"
  1970. cellB := rowTitle.AddCell()
  1971. cellB.Value = "手机号"
  1972. cellC := rowTitle.AddCell()
  1973. cellC.Value = "公司名称"
  1974. cellD := rowTitle.AddCell()
  1975. cellD.Value = "所属销售"
  1976. cellDfw := rowTitle.AddCell()
  1977. cellDfw.Value = "服务销售"
  1978. cellDCreatedTime := rowTitle.AddCell()
  1979. cellDCreatedTime.Value = "阅读时间(最后一次)"
  1980. cellE := rowTitle.AddCell()
  1981. cellE.Value = "停留时长(多次合计))"
  1982. cellF := rowTitle.AddCell()
  1983. cellF.Value = "阅读来源"
  1984. cellStatus := rowTitle.AddCell()
  1985. cellStatus.Value = "客户状态"
  1986. cellTc := rowTitle.AddCell()
  1987. cellTc.Value = "签约套餐"
  1988. hasmobile := make(map[string]bool)
  1989. for _, v := range listart {
  1990. articleId := v.ArticleId
  1991. condition = ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
  1992. list, err := cygx.GetArticleHistoryList(articleId, condition)
  1993. if err != nil {
  1994. fmt.Println(err)
  1995. return
  1996. }
  1997. //上一次的阅读记录
  1998. list_H, err := cygx.GetArticleHistoryList_H(articleId, condition)
  1999. if err != nil {
  2000. fmt.Println(err)
  2001. return
  2002. }
  2003. mapArticle_H := make(map[string]bool)
  2004. for _, vPv := range list_H {
  2005. if !utils.ValidateMobileFormatat(vPv.Mobile) {
  2006. continue
  2007. }
  2008. mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] = true
  2009. }
  2010. listClPv, err := cygx.GetCygxCelueArticleHistoryRecordPvAll(strconv.Itoa(articleId))
  2011. if err != nil && err.Error() != utils.ErrNoRow() {
  2012. fmt.Println(err)
  2013. return
  2014. }
  2015. listClPv_H, err := cygx.GetCygxCelueArticleHistoryRecordPvAll_H(strconv.Itoa(articleId))
  2016. if err != nil && err.Error() != utils.ErrNoRow() {
  2017. fmt.Println(err)
  2018. return
  2019. }
  2020. for _, vPv := range listClPv_H {
  2021. if !utils.ValidateMobileFormatat(vPv.Mobile) {
  2022. continue
  2023. }
  2024. mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] = true
  2025. }
  2026. var listDate []*cygx.ArticleHistoryRep
  2027. var mobiles []string
  2028. var mapMobileCy = make(map[string]bool)
  2029. var mapMobileCl = make(map[string]bool)
  2030. mapstopTime := make(map[string]int)
  2031. if len(list) > 0 {
  2032. for _, vPv := range list {
  2033. if !utils.ValidateMobileFormatat(vPv.Mobile) {
  2034. continue
  2035. }
  2036. if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
  2037. continue
  2038. }
  2039. mobiles = append(mobiles, vPv.Mobile)
  2040. stopTime, _ := strconv.Atoi(vPv.StopTime)
  2041. mapstopTime[vPv.Mobile] += stopTime
  2042. }
  2043. }
  2044. if len(listClPv) > 0 {
  2045. for _, vPv := range listClPv {
  2046. if !utils.ValidateMobileFormatat(vPv.Mobile) {
  2047. continue
  2048. }
  2049. vPv.Ly = "1"
  2050. //if vPv.Mobile != "" {
  2051. mobiles = append(mobiles, vPv.Mobile)
  2052. //}
  2053. if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
  2054. continue
  2055. }
  2056. }
  2057. }
  2058. listUser, err := models.GetWxUserRaiSllerListByUserMobile(mobiles)
  2059. if err != nil {
  2060. fmt.Println(err)
  2061. return
  2062. }
  2063. listUserFicc, err := models.GetWxUserRaiSllerListByUserMobileFiic(mobiles)
  2064. if err != nil {
  2065. fmt.Println(err)
  2066. return
  2067. }
  2068. mapuserMapbil := make(map[string]*models.WxUserSller)
  2069. var companyIds []int
  2070. for _, vuser := range listUser {
  2071. //mapuserMapbil[vuser.Mobile] = vuser
  2072. companyIds = append(companyIds, vuser.CompanyId)
  2073. }
  2074. //合并合同所对应的权限
  2075. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
  2076. if err != nil {
  2077. fmt.Println(err)
  2078. return
  2079. }
  2080. //fmt.Println(companyIds)
  2081. //for k, vuser := range mappermissionName {
  2082. // fmt.Println(k, vuser)
  2083. //}
  2084. //fmt.Println(mappermissionName)
  2085. for _, vuser := range listUser {
  2086. vuser.ChartPermissionName = mappermissionName[vuser.CompanyId]
  2087. mapuserMapbil[vuser.Mobile] = vuser
  2088. }
  2089. for _, vuser := range listUserFicc {
  2090. vuser.Status = ""
  2091. vuser.SellerName = ""
  2092. if mapuserMapbil[vuser.Mobile] == nil {
  2093. mapuserMapbil[vuser.Mobile] = vuser
  2094. }
  2095. }
  2096. if len(list) > 0 {
  2097. for _, vPv := range list {
  2098. if !utils.ValidateMobileFormatat(vPv.Mobile) || mapMobileCy[vPv.Mobile] {
  2099. continue
  2100. }
  2101. if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
  2102. continue
  2103. }
  2104. if hasmobile[vPv.Mobile] {
  2105. continue
  2106. }
  2107. hasmobile[vPv.Mobile] = true
  2108. mapMobileCy[vPv.Mobile] = true
  2109. listDate = append(listDate, vPv)
  2110. }
  2111. }
  2112. if len(listClPv) > 0 {
  2113. for _, vPv := range listClPv {
  2114. if !utils.ValidateMobileFormatat(vPv.Mobile) || mapMobileCl[vPv.Mobile] {
  2115. continue
  2116. }
  2117. if mapArticle_H[fmt.Sprint("m_", vPv.Mobile)] {
  2118. continue
  2119. }
  2120. if hasmobile[vPv.Mobile] {
  2121. continue
  2122. }
  2123. hasmobile[vPv.Mobile] = true
  2124. mapMobileCl[vPv.Mobile] = true
  2125. listDate = append(listDate, vPv)
  2126. }
  2127. }
  2128. //rowtitle := sheet.AddRow()
  2129. //cellADatatitle := rowtitle.AddCell()
  2130. //cellADatatitle.Value = v.Title
  2131. for _, item := range listDate {
  2132. row := sheet.AddRow()
  2133. cellADatatitle := row.AddCell()
  2134. cellADatatitle.Value = v.Title
  2135. cellADataPd := row.AddCell()
  2136. cellADataPd.Value = v.PublishDate
  2137. cellAData := row.AddCell()
  2138. cellAData.Value = item.RealName
  2139. //if item.Ly == "1" {
  2140. // cellAData.SetStyle(redStyle)
  2141. //}
  2142. cellBData := row.AddCell()
  2143. cellBData.Value = item.Mobile
  2144. cellCData := row.AddCell()
  2145. //cellCData.Value = item.CompanyName
  2146. cellDData := row.AddCell()
  2147. cellDDataFw := row.AddCell()
  2148. //cellDData.Value = item.SellerName
  2149. cellEData := row.AddCell()
  2150. cellEData.Value = item.CreateTime
  2151. cellFData := row.AddCell()
  2152. if item.Ly == "" {
  2153. cellFData.Value = strconv.Itoa(mapstopTime[item.Mobile])
  2154. }
  2155. //fmt.Println(item.Source)
  2156. cellLyData := row.AddCell()
  2157. switch item.Source {
  2158. case "MOBILE":
  2159. cellLyData.Value = "小程序"
  2160. case "WEB":
  2161. cellLyData.Value = "网页版"
  2162. case "CELUE":
  2163. cellLyData.Value = "vmp"
  2164. }
  2165. cellStatusData := row.AddCell()
  2166. cellermissionNameData := row.AddCell()
  2167. if mapuserMapbil[item.Mobile] != nil {
  2168. cellCData.Value = mapuserMapbil[item.Mobile].CompanyName
  2169. cellDData.Value = mapuserMapbil[item.Mobile].SellerName
  2170. cellDDataFw.Value = mapuserMapbil[item.Mobile].ShareSeller
  2171. cellStatusData.Value = mapuserMapbil[item.Mobile].Status
  2172. cellermissionNameData.Value = mapuserMapbil[item.Mobile].ChartPermissionName
  2173. if mapuserMapbil[item.Mobile].RealName != "" {
  2174. cellAData.Value = mapuserMapbil[item.Mobile].RealName
  2175. }
  2176. }
  2177. }
  2178. err = xlsxFile.Save(downLoadnFilePath)
  2179. if err != nil {
  2180. fmt.Println(err)
  2181. return
  2182. }
  2183. }
  2184. }
  2185. func initAct() {
  2186. var condition string
  2187. mapMobile := make(map[string]bool)
  2188. mapuserMapbil := make(map[int]*models.WxUserSller)
  2189. //var activityIds []int
  2190. //activityIds = []int{5590, 5658, 5734, 5747, 5805, 5833, 5832, 5865, 5887, 5872, 5889, 5870, 5892, 5890, 5935, 5976, 5946, 6005,6062} // 2024-12-26 15:55
  2191. //activityIds = []int{6005} // 2024-10-31 17:15
  2192. //activityIds = []int{6052} // 2024-11-07 16:45
  2193. activity_ids := " 5590, 5658, 5734, 5747, 5805, 5833, 5832, 5865, 5887, 5872, 5889, 5870, 5892, 5890, 5935, 5976, 5946, 6005,6062,6174,6224,6254,6278 "
  2194. condition = " AND s.activity_id IN (" + activity_ids + ") AND ( is_meeting = 1 OR duration != '' ) AND s.create_time < '2024-12-19 15:55' "
  2195. listH, err := cygx.GetActivityMeetByUser(condition, 0, 9999)
  2196. if err != nil {
  2197. fmt.Println(err)
  2198. return
  2199. }
  2200. mobileMap := make(map[string]bool)
  2201. for _, v := range listH {
  2202. mobileMap[v.Mobile] = true
  2203. }
  2204. fmt.Println(mobileMap)
  2205. condition = " AND s.activity_id IN (" + activity_ids + ") AND ( is_meeting = 1 OR duration != '' ) AND s.create_time > '2024-12-19 15:55' "
  2206. list, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
  2207. fmt.Println(list)
  2208. fmt.Println()
  2209. if err != nil && err.Error() != utils.ErrNoRow() {
  2210. fmt.Println(err)
  2211. return
  2212. }
  2213. var listData []*cygx.UserInteraction
  2214. //for _, vid := range activityIds {
  2215. // activityId := strconv.Itoa(vid)
  2216. //
  2217. // //activityId := "5865"
  2218. // //condition = " AND s.activity_id = " + activityId + " AND duration != '' AND s.create_time < '2024-09-06 09:20' "
  2219. // //condition = " AND s.activity_id = " + activityId + " AND (is_meeting = 1 OR AND duration != '' ) AND s.create_time < '2024-09-13 10:30' "
  2220. // //list_H, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
  2221. // //if err != nil && err.Error() != utils.ErrNoRow() {
  2222. // // fmt.Println(err)
  2223. // // return
  2224. // //}
  2225. // //
  2226. // //for _, v := range list_H {
  2227. // // mapMobile[v.Mobile+"_"+activityId] = true
  2228. // //}
  2229. //
  2230. // //condition = " AND s.activity_id = 5833 AND duration != '' "
  2231. // //condition = " AND s.activity_id = " + activityId + " AND duration != '' " // 2024-09-06 09:20
  2232. // condition = " AND s.activity_id = " + activityId + " AND ( is_meeting = 1 OR duration != '' ) AND s.create_time > '2024-10-31 17:15' "
  2233. // list, err := cygx.GetActivityMeetByUser(condition, 0, 1000)
  2234. // if err != nil && err.Error() != utils.ErrNoRow() {
  2235. // fmt.Println(err)
  2236. // return
  2237. // }
  2238. //
  2239. // var companyIds []int
  2240. // for _, vuser := range list {
  2241. // //mapuserMapbil[vuser.Mobile] = vuser
  2242. // companyIds = append(companyIds, vuser.CompanyId)
  2243. // listData = append(listData, vuser)
  2244. // }
  2245. //
  2246. // listCompany, err := models.GetWxUserRaiSllerListByUserComapnyId(companyIds)
  2247. // if err != nil {
  2248. // fmt.Println(err)
  2249. // return
  2250. // }
  2251. //
  2252. // //合并合同所对应的权限
  2253. // mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
  2254. // if err != nil {
  2255. // fmt.Println(err)
  2256. // return
  2257. // }
  2258. // for _, v := range listCompany {
  2259. // v.ChartPermissionName = mappermissionName[v.CompanyId]
  2260. // mapuserMapbil[v.CompanyId] = v
  2261. // }
  2262. //
  2263. // listCompanyFicc, err := models.GetWxUserRaiSllerListByUserComapnyIdFicc(companyIds)
  2264. // if err != nil {
  2265. // fmt.Println(err)
  2266. // return
  2267. // }
  2268. //
  2269. // for _, v := range listCompanyFicc {
  2270. // if mapuserMapbil[v.CompanyId] != nil {
  2271. // continue
  2272. // }
  2273. // v.Status = ""
  2274. // v.SellerName = ""
  2275. // mapuserMapbil[v.CompanyId] = v
  2276. // }
  2277. //}
  2278. var companyIds []int
  2279. for _, vuser := range list {
  2280. fmt.Println(vuser.Mobile)
  2281. if mobileMap[vuser.Mobile] {
  2282. continue
  2283. }
  2284. companyIds = append(companyIds, vuser.CompanyId)
  2285. listData = append(listData, vuser)
  2286. }
  2287. listCompany, err := models.GetWxUserRaiSllerListByUserComapnyId(companyIds)
  2288. if err != nil {
  2289. fmt.Println(err)
  2290. return
  2291. }
  2292. //合并合同所对应的权限
  2293. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapByIds(companyIds)
  2294. if err != nil {
  2295. fmt.Println(err)
  2296. return
  2297. }
  2298. for _, v := range listCompany {
  2299. v.ChartPermissionName = mappermissionName[v.CompanyId]
  2300. mapuserMapbil[v.CompanyId] = v
  2301. }
  2302. listCompanyFicc, err := models.GetWxUserRaiSllerListByUserComapnyIdFicc(companyIds)
  2303. if err != nil {
  2304. fmt.Println(err)
  2305. return
  2306. }
  2307. for _, v := range listCompanyFicc {
  2308. if mapuserMapbil[v.CompanyId] != nil {
  2309. continue
  2310. }
  2311. v.Status = ""
  2312. v.SellerName = ""
  2313. mapuserMapbil[v.CompanyId] = v
  2314. }
  2315. //创建excel
  2316. dir, err := os.Executable()
  2317. exPath := filepath.Dir(dir)
  2318. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2319. xlsxFile := xlsx.NewFile()
  2320. if err != nil {
  2321. fmt.Println(err)
  2322. return
  2323. }
  2324. style := xlsx.NewStyle()
  2325. alignment := xlsx.Alignment{
  2326. Horizontal: "center",
  2327. Vertical: "center",
  2328. WrapText: true,
  2329. }
  2330. style.Alignment = alignment
  2331. style.ApplyAlignment = true
  2332. redStyle := xlsx.NewStyle()
  2333. redStyle.Alignment = alignment
  2334. redStyle.ApplyAlignment = true
  2335. redStyle.Font.Color = "ff0000"
  2336. //定义底色需要标黄的 单元格颜色
  2337. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  2338. redStyle.Fill = redFill
  2339. //redStyle.Border = *border
  2340. var sheetName string
  2341. sheetName = "到会信息"
  2342. sheet, err := xlsxFile.AddSheet(sheetName)
  2343. if err != nil {
  2344. fmt.Println(err)
  2345. return
  2346. }
  2347. //标头
  2348. rowTitle := sheet.AddRow()
  2349. cellAct := rowTitle.AddCell()
  2350. cellAct.Value = "活动名称/报告标题"
  2351. cellActime := rowTitle.AddCell()
  2352. cellActime.Value = " 活动时间/发布时间"
  2353. cellA := rowTitle.AddCell()
  2354. cellA.Value = "姓名"
  2355. cellB := rowTitle.AddCell()
  2356. cellB.Value = "手机号"
  2357. cellC := rowTitle.AddCell()
  2358. cellC.Value = "公司名称"
  2359. cellD := rowTitle.AddCell()
  2360. cellD.Value = "所属销售"
  2361. cellDfw := rowTitle.AddCell()
  2362. cellDfw.Value = "服务销售"
  2363. cellYd := rowTitle.AddCell()
  2364. cellYd.Value = "阅读时间"
  2365. cellstopTime := rowTitle.AddCell()
  2366. cellstopTime.Value = "停留时长"
  2367. cellLy := rowTitle.AddCell()
  2368. cellLy.Value = "阅读来源"
  2369. cellStatus := rowTitle.AddCell()
  2370. cellStatus.Value = "客户状态"
  2371. cellTc := rowTitle.AddCell()
  2372. cellTc.Value = "签约套餐"
  2373. for _, item := range listData {
  2374. if mapMobile[item.Mobile] {
  2375. continue
  2376. }
  2377. row := sheet.AddRow()
  2378. cellActData := row.AddCell()
  2379. cellActData.Value = item.ActivityName
  2380. cellActimeData := row.AddCell()
  2381. cellActimeData.Value = item.ActivityTime
  2382. cellAData := row.AddCell()
  2383. cellAData.Value = item.RealName
  2384. //if item.Ly == "1" {
  2385. // cellAData.SetStyle(redStyle)
  2386. //}
  2387. cellBData := row.AddCell()
  2388. cellBData.Value = item.Mobile
  2389. cellCData := row.AddCell()
  2390. //cellCData.Value = item.CompanyName
  2391. cellDData := row.AddCell()
  2392. cellDDatafw := row.AddCell()
  2393. //cellDData.Value = item.SellerName
  2394. cellYdData := row.AddCell()
  2395. cellYdData.Value = ""
  2396. cellstopTimeData := row.AddCell()
  2397. cellstopTimeData.Value = ""
  2398. cellLyData := row.AddCell()
  2399. cellLyData.Value = ""
  2400. cellStatusData := row.AddCell()
  2401. cellermissionNameData := row.AddCell()
  2402. if mapuserMapbil[item.CompanyId] != nil {
  2403. cellCData.Value = mapuserMapbil[item.CompanyId].CompanyName
  2404. cellDData.Value = mapuserMapbil[item.CompanyId].SellerName
  2405. cellDDatafw.Value = mapuserMapbil[item.CompanyId].ShareSeller
  2406. cellStatusData.Value = mapuserMapbil[item.CompanyId].Status
  2407. cellermissionNameData.Value = mapuserMapbil[item.CompanyId].ChartPermissionName
  2408. }
  2409. }
  2410. err = xlsxFile.Save(downLoadnFilePath)
  2411. if err != nil {
  2412. fmt.Println(err)
  2413. return
  2414. }
  2415. }
  2416. func initarta() {
  2417. //行业
  2418. var condition string
  2419. var pars []interface{}
  2420. condition += ` AND share_seller_id In (702,703,704,707) `
  2421. listProduct, err := company.GetCompanyProductList(condition, pars)
  2422. if err != nil {
  2423. fmt.Println(err)
  2424. return
  2425. }
  2426. var companyIds []int
  2427. mapSeller := make(map[int]string)
  2428. for _, v := range listProduct {
  2429. companyIds = append(companyIds, v.CompanyId)
  2430. mapSeller[v.CompanyId] = v.ShareSeller
  2431. }
  2432. //报告匹配类型
  2433. pars = make([]interface{}, 0)
  2434. condition = ` AND re.chart_permission_id IN (23,53) `
  2435. listart, err := cygx.GetReportArticleList(condition, pars, 0, 4000, 1)
  2436. if err != nil {
  2437. fmt.Println(err)
  2438. return
  2439. }
  2440. mapArticleTitle := make(map[int]string)
  2441. mapchart_permission_name := make(map[int]string)
  2442. var articleIds []int
  2443. for _, v := range listart {
  2444. mapArticleTitle[v.ArticleId] = v.Title
  2445. mapchart_permission_name[v.ArticleId] = v.ChartPermissionName
  2446. articleIds = append(articleIds, v.ArticleId)
  2447. }
  2448. //创建excel
  2449. dir, err := os.Executable()
  2450. exPath := filepath.Dir(dir)
  2451. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2452. xlsxFile := xlsx.NewFile()
  2453. if err != nil {
  2454. fmt.Println(err)
  2455. return
  2456. }
  2457. style := xlsx.NewStyle()
  2458. alignment := xlsx.Alignment{
  2459. Horizontal: "center",
  2460. Vertical: "center",
  2461. WrapText: true,
  2462. }
  2463. style.Alignment = alignment
  2464. style.ApplyAlignment = true
  2465. redStyle := xlsx.NewStyle()
  2466. redStyle.Alignment = alignment
  2467. redStyle.ApplyAlignment = true
  2468. redStyle.Font.Color = "ff0000"
  2469. //定义底色需要标黄的 单元格颜色
  2470. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  2471. redStyle.Fill = redFill
  2472. //redStyle.Border = *border
  2473. var sheetName string
  2474. sheetName = "PV"
  2475. sheet, err := xlsxFile.AddSheet(sheetName)
  2476. if err != nil {
  2477. fmt.Println(err)
  2478. return
  2479. }
  2480. //标头
  2481. rowTitle := sheet.AddRow()
  2482. cellA := rowTitle.AddCell()
  2483. cellA.Value = "姓名"
  2484. cellB := rowTitle.AddCell()
  2485. cellB.Value = "手机号"
  2486. cellC := rowTitle.AddCell()
  2487. cellC.Value = "公司名称"
  2488. cellD := rowTitle.AddCell()
  2489. cellD.Value = "服务销售"
  2490. cellDCreatedTime := rowTitle.AddCell()
  2491. cellDCreatedTime.Value = "最近阅读时间"
  2492. cellE := rowTitle.AddCell()
  2493. cellE.Value = "行业"
  2494. cellF := rowTitle.AddCell()
  2495. cellF.Value = "报告标题"
  2496. //articleId := v.ArticleId
  2497. //condition = ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
  2498. list, err := cygx.GetArticleHistoryListInit(articleIds, companyIds)
  2499. if err != nil {
  2500. fmt.Println(err)
  2501. return
  2502. }
  2503. mapMobile := make(map[string]bool)
  2504. for _, item := range list {
  2505. if mapMobile[item.Mobile] {
  2506. continue
  2507. }
  2508. row := sheet.AddRow()
  2509. cellAData := row.AddCell()
  2510. cellAData.Value = item.RealName
  2511. cellBData := row.AddCell()
  2512. cellBData.Value = item.Mobile
  2513. cellCData := row.AddCell()
  2514. cellCData.Value = item.CompanyName
  2515. cellDData := row.AddCell()
  2516. cellDData.Value = mapSeller[item.CompanyId]
  2517. cellEData := row.AddCell()
  2518. cellEData.Value = item.CreateTime
  2519. cellEcData := row.AddCell()
  2520. cellEcData.Value = mapchart_permission_name[item.ArticleId]
  2521. cellFData := row.AddCell()
  2522. cellFData.Value = mapArticleTitle[item.ArticleId]
  2523. mapMobile[item.Mobile] = true
  2524. }
  2525. err = xlsxFile.Save(downLoadnFilePath)
  2526. if err != nil {
  2527. fmt.Println(err)
  2528. return
  2529. }
  2530. }
  2531. func initActList() {
  2532. var condition string
  2533. var pars []interface{}
  2534. 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 "
  2535. list, errList := cygx.GetActivityListAll(condition, pars, 0, 999)
  2536. if errList != nil {
  2537. fmt.Println(errList)
  2538. return
  2539. }
  2540. //创建excel
  2541. dir, err := os.Executable()
  2542. exPath := filepath.Dir(dir)
  2543. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2544. xlsxFile := xlsx.NewFile()
  2545. if err != nil {
  2546. fmt.Println(err)
  2547. return
  2548. }
  2549. style := xlsx.NewStyle()
  2550. alignment := xlsx.Alignment{
  2551. Horizontal: "center",
  2552. Vertical: "center",
  2553. WrapText: true,
  2554. }
  2555. style.Alignment = alignment
  2556. style.ApplyAlignment = true
  2557. redStyle := xlsx.NewStyle()
  2558. redStyle.Alignment = alignment
  2559. redStyle.ApplyAlignment = true
  2560. redStyle.Font.Color = "ff0000"
  2561. //定义底色需要标黄的 单元格颜色
  2562. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  2563. redStyle.Fill = redFill
  2564. //redStyle.Border = *border
  2565. var sheetName string
  2566. sheetName = "到会信息"
  2567. sheet, err := xlsxFile.AddSheet(sheetName)
  2568. if err != nil {
  2569. fmt.Println(err)
  2570. return
  2571. }
  2572. //标头
  2573. rowTitle := sheet.AddRow()
  2574. cellA := rowTitle.AddCell()
  2575. cellA.Value = "活动名称"
  2576. cellB := rowTitle.AddCell()
  2577. cellB.Value = "活动时间"
  2578. cellC := rowTitle.AddCell()
  2579. cellC.Value = "活动标签"
  2580. for _, item := range list {
  2581. row := sheet.AddRow()
  2582. cellAData := row.AddCell()
  2583. cellAData.Value = item.ActivityName
  2584. cellBData := row.AddCell()
  2585. cellBData.Value = item.ActivityTime
  2586. cellCData := row.AddCell()
  2587. cellCData.Value = item.Label
  2588. }
  2589. err = xlsxFile.Save(downLoadnFilePath)
  2590. if err != nil {
  2591. fmt.Println(err)
  2592. return
  2593. }
  2594. }
  2595. func initOrder() {
  2596. var condition string
  2597. var pars []interface{}
  2598. //condition = " WHERE 1 = 1 AND source In ('article','yanxuanspecial') AND order_status = 2 GROUP BY order_id ASC "
  2599. condition = " AND source In ('activity') AND order_status = 2 GROUP BY order_id DESC "
  2600. list, errList := cygx.GetCygxOrderList(condition, pars, 0, 9999)
  2601. if errList != nil {
  2602. fmt.Println(errList)
  2603. return
  2604. }
  2605. //创建excel
  2606. dir, err := os.Executable()
  2607. exPath := filepath.Dir(dir)
  2608. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2609. xlsxFile := xlsx.NewFile()
  2610. if err != nil {
  2611. fmt.Println(err)
  2612. return
  2613. }
  2614. style := xlsx.NewStyle()
  2615. alignment := xlsx.Alignment{
  2616. Horizontal: "center",
  2617. Vertical: "center",
  2618. WrapText: true,
  2619. }
  2620. style.Alignment = alignment
  2621. style.ApplyAlignment = true
  2622. redStyle := xlsx.NewStyle()
  2623. redStyle.Alignment = alignment
  2624. redStyle.ApplyAlignment = true
  2625. redStyle.Font.Color = "ff0000"
  2626. //定义底色需要标黄的 单元格颜色
  2627. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  2628. redStyle.Fill = redFill
  2629. //redStyle.Border = *border
  2630. var sheetName string
  2631. sheetName = "活动"
  2632. sheet, err := xlsxFile.AddSheet(sheetName)
  2633. if err != nil {
  2634. fmt.Println(err)
  2635. return
  2636. }
  2637. //标头
  2638. //rowTitle := sheet.AddRow()
  2639. //cellA := rowTitle.AddCell()
  2640. //cellA.Value = "姓名"
  2641. //cellB := rowTitle.AddCell()
  2642. //cellB.Value = "手机号"
  2643. //cellC := rowTitle.AddCell()
  2644. //cellC.Value = "公司名称"
  2645. //
  2646. //cellMoney := rowTitle.AddCell()
  2647. //cellMoney.Value = "金额"
  2648. //
  2649. //cellname := rowTitle.AddCell()
  2650. //cellname.Value = "活动名称"
  2651. //
  2652. //cellTime := rowTitle.AddCell()
  2653. //cellTime.Value = "支付时间"
  2654. //
  2655. //for _, item := range list {
  2656. //
  2657. // row := sheet.AddRow()
  2658. // cellAData := row.AddCell()
  2659. // cellAData.Value = item.RealName
  2660. //
  2661. // cellBData := row.AddCell()
  2662. // cellBData.Value = item.Mobile
  2663. // cellCData := row.AddCell()
  2664. // cellCData.Value = item.CompanyName
  2665. //
  2666. // cellCMoneyData := row.AddCell()
  2667. // cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
  2668. //
  2669. // cellCnameData := row.AddCell()
  2670. // cellCnameData.Value = item.SourceTitle
  2671. //
  2672. // cellTimeata := row.AddCell()
  2673. // cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
  2674. //}
  2675. var mobiles []string
  2676. var activityIds []int
  2677. for _, v := range list {
  2678. mobiles = append(mobiles, v.Mobile)
  2679. activityIds = append(activityIds, v.SourceId)
  2680. }
  2681. pars = make([]interface{}, 0)
  2682. inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
  2683. condition = ` AND activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) `
  2684. pars = append(pars, activityIds)
  2685. listActivity, errList := cygx.GetActivityListAllInit(condition, pars)
  2686. if errList != nil {
  2687. fmt.Println(errList)
  2688. return
  2689. }
  2690. mapHost := make(map[int]string)
  2691. for _, v := range listActivity {
  2692. mapHost[v.ActivityId] = v.Host
  2693. }
  2694. rowTitle := sheet.AddRow()
  2695. cellA := rowTitle.AddCell()
  2696. cellA.Value = "姓名"
  2697. cellB := rowTitle.AddCell()
  2698. cellB.Value = "手机号"
  2699. cellC := rowTitle.AddCell()
  2700. cellC.Value = "公司名称"
  2701. cellSeller := rowTitle.AddCell()
  2702. cellSeller.Value = "所属销售"
  2703. cellInviteName := rowTitle.AddCell()
  2704. cellInviteName.Value = "推荐人"
  2705. cellMoney := rowTitle.AddCell()
  2706. cellMoney.Value = "金额"
  2707. cellname := rowTitle.AddCell()
  2708. cellname.Value = "报告标题"
  2709. cellNickename := rowTitle.AddCell()
  2710. cellNickename.Value = "作者"
  2711. cellTime := rowTitle.AddCell()
  2712. cellTime.Value = "支付时间"
  2713. for _, item := range list {
  2714. row := sheet.AddRow()
  2715. cellAData := row.AddCell()
  2716. cellAData.Value = item.RealName
  2717. cellBData := row.AddCell()
  2718. cellBData.Value = item.Mobile
  2719. cellCData := row.AddCell()
  2720. cellCData.Value = item.CompanyName
  2721. cellSellerData := row.AddCell()
  2722. cellSellerData.Value = item.SellerName
  2723. cellInviteNameData := row.AddCell()
  2724. if item.ShareName != "" {
  2725. cellInviteNameData.Value = item.ShareName
  2726. } else {
  2727. cellInviteNameData.Value = inviteNameMap[item.Mobile]
  2728. }
  2729. cellCMoneyData := row.AddCell()
  2730. cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
  2731. cellCnameData := row.AddCell()
  2732. cellCnameData.Value = item.SourceTitle
  2733. cellNickenameData := row.AddCell()
  2734. cellNickenameData.Value = mapHost[item.SourceId]
  2735. cellTimeata := row.AddCell()
  2736. cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
  2737. }
  2738. err = xlsxFile.Save(downLoadnFilePath)
  2739. if err != nil {
  2740. fmt.Println(err)
  2741. return
  2742. }
  2743. }
  2744. func initOrderArticle() {
  2745. var condition string
  2746. var pars []interface{}
  2747. condition = " AND source In ('article','yanxuanspecial') AND order_status = 2 GROUP BY order_id DESC "
  2748. list, errList := cygx.GetCygxOrderList(condition, pars, 0, 9999)
  2749. if errList != nil {
  2750. fmt.Println(errList)
  2751. return
  2752. }
  2753. var articleIds []int
  2754. var yanxuanArticleids []int
  2755. for _, v := range list {
  2756. if v.Source == "article" {
  2757. articleIds = append(articleIds, v.SourceId)
  2758. }
  2759. if v.Source == "yanxuanspecial" {
  2760. yanxuanArticleids = append(yanxuanArticleids, v.SourceId)
  2761. }
  2762. }
  2763. pars = make([]interface{}, 0)
  2764. condition = " AND art.article_id IN (" + utils.GetOrmInReplace(len(articleIds)) + ") GROUP BY art.article_id "
  2765. pars = append(pars, articleIds)
  2766. mapArtcileNickName := make(map[int]string)
  2767. listartcile, errList := cygx.GetSummaryManageListInit(condition, pars, 0, 999)
  2768. if errList != nil {
  2769. fmt.Println(errList)
  2770. return
  2771. }
  2772. for _, v := range listartcile {
  2773. mapArtcileNickName[v.ArticleId] = v.NickName
  2774. }
  2775. //fmt.Println(mapArtcileNickName)
  2776. //return
  2777. pars = make([]interface{}, 0)
  2778. condition = " AND a.id IN (" + utils.GetOrmInReplace(len(yanxuanArticleids)) + ") "
  2779. pars = append(pars, yanxuanArticleids)
  2780. mapArtcileNickNameYx := make(map[int]string)
  2781. listartcileYx, errList := cygx.GetYanxuanSpecialList(condition, pars, 0, 999)
  2782. if errList != nil {
  2783. fmt.Println(errList)
  2784. return
  2785. }
  2786. for _, v := range listartcileYx {
  2787. mapArtcileNickNameYx[v.Id] = v.NickName
  2788. }
  2789. var mobiles []string
  2790. for _, v := range list {
  2791. mobiles = append(mobiles, v.Mobile)
  2792. }
  2793. inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
  2794. //创建excel
  2795. dir, err := os.Executable()
  2796. exPath := filepath.Dir(dir)
  2797. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2798. xlsxFile := xlsx.NewFile()
  2799. if err != nil {
  2800. fmt.Println(err)
  2801. return
  2802. }
  2803. style := xlsx.NewStyle()
  2804. alignment := xlsx.Alignment{
  2805. Horizontal: "center",
  2806. Vertical: "center",
  2807. WrapText: true,
  2808. }
  2809. style.Alignment = alignment
  2810. style.ApplyAlignment = true
  2811. redStyle := xlsx.NewStyle()
  2812. redStyle.Alignment = alignment
  2813. redStyle.ApplyAlignment = true
  2814. redStyle.Font.Color = "ff0000"
  2815. //定义底色需要标黄的 单元格颜色
  2816. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  2817. redStyle.Fill = redFill
  2818. //redStyle.Border = *border
  2819. var sheetName string
  2820. sheetName = "活动"
  2821. sheet, err := xlsxFile.AddSheet(sheetName)
  2822. if err != nil {
  2823. fmt.Println(err)
  2824. return
  2825. }
  2826. //标头
  2827. rowTitle := sheet.AddRow()
  2828. cellA := rowTitle.AddCell()
  2829. cellA.Value = "姓名"
  2830. cellB := rowTitle.AddCell()
  2831. cellB.Value = "手机号"
  2832. cellC := rowTitle.AddCell()
  2833. cellC.Value = "公司名称"
  2834. cellSeller := rowTitle.AddCell()
  2835. cellSeller.Value = "所属销售"
  2836. cellInviteName := rowTitle.AddCell()
  2837. cellInviteName.Value = "推荐人"
  2838. cellMoney := rowTitle.AddCell()
  2839. cellMoney.Value = "金额"
  2840. cellname := rowTitle.AddCell()
  2841. cellname.Value = "报告标题"
  2842. cellNickename := rowTitle.AddCell()
  2843. cellNickename.Value = "作者"
  2844. cellTime := rowTitle.AddCell()
  2845. cellTime.Value = "支付时间"
  2846. for _, item := range list {
  2847. row := sheet.AddRow()
  2848. cellAData := row.AddCell()
  2849. cellAData.Value = item.RealName
  2850. cellBData := row.AddCell()
  2851. cellBData.Value = item.Mobile
  2852. cellCData := row.AddCell()
  2853. cellCData.Value = item.CompanyName
  2854. cellSellerData := row.AddCell()
  2855. cellSellerData.Value = item.SellerName
  2856. cellInviteNameData := row.AddCell()
  2857. if item.ShareName != "" {
  2858. cellInviteNameData.Value = item.ShareName
  2859. } else {
  2860. cellInviteNameData.Value = inviteNameMap[item.Mobile]
  2861. }
  2862. cellCMoneyData := row.AddCell()
  2863. cellCMoneyData.Value = fmt.Sprint(item.PayMoney)
  2864. cellCnameData := row.AddCell()
  2865. cellCnameData.Value = item.SourceTitle
  2866. cellNickenameData := row.AddCell()
  2867. if item.Source == "article" {
  2868. fmt.Println(mapArtcileNickName[item.SourceId])
  2869. cellNickenameData.Value = mapArtcileNickName[item.SourceId]
  2870. }
  2871. if item.Source == "yanxuanspecial" {
  2872. cellNickenameData.Value = mapArtcileNickNameYx[item.SourceId]
  2873. }
  2874. cellTimeata := row.AddCell()
  2875. cellTimeata.Value = item.PayTime.Format(utils.FormatDateTime)
  2876. }
  2877. err = xlsxFile.Save(downLoadnFilePath)
  2878. if err != nil {
  2879. fmt.Println(err)
  2880. return
  2881. }
  2882. }
  2883. func initRsList() {
  2884. list, errList := roadshow.GetCalendarDetailListinit()
  2885. if errList != nil {
  2886. fmt.Println(errList)
  2887. return
  2888. }
  2889. //创建excel
  2890. dir, err := os.Executable()
  2891. exPath := filepath.Dir(dir)
  2892. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2893. xlsxFile := xlsx.NewFile()
  2894. if err != nil {
  2895. fmt.Println(err)
  2896. return
  2897. }
  2898. style := xlsx.NewStyle()
  2899. alignment := xlsx.Alignment{
  2900. Horizontal: "center",
  2901. Vertical: "center",
  2902. WrapText: true,
  2903. }
  2904. style.Alignment = alignment
  2905. style.ApplyAlignment = true
  2906. redStyle := xlsx.NewStyle()
  2907. redStyle.Alignment = alignment
  2908. redStyle.ApplyAlignment = true
  2909. redStyle.Font.Color = "ff0000"
  2910. //定义底色需要标黄的 单元格颜色
  2911. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  2912. redStyle.Fill = redFill
  2913. //redStyle.Border = *border
  2914. var sheetName string
  2915. sheetName = "活动"
  2916. sheet, err := xlsxFile.AddSheet(sheetName)
  2917. if err != nil {
  2918. fmt.Println(err)
  2919. return
  2920. }
  2921. //标头
  2922. rowTitle := sheet.AddRow()
  2923. cellA := rowTitle.AddCell()
  2924. cellA.Value = "研究员"
  2925. cellB := rowTitle.AddCell()
  2926. cellB.Value = "路演时间"
  2927. cellC := rowTitle.AddCell()
  2928. cellC.Value = "公司名"
  2929. cellMoney := rowTitle.AddCell()
  2930. cellMoney.Value = "销售"
  2931. for _, item := range list {
  2932. row := sheet.AddRow()
  2933. cellAData := row.AddCell()
  2934. cellAData.Value = item.ResearcherName
  2935. cellBData := row.AddCell()
  2936. cellBData.Value = item.StartDate + " " + item.StartTime
  2937. cellCData := row.AddCell()
  2938. cellCData.Value = item.CompanyName
  2939. cellCnameData := row.AddCell()
  2940. cellCnameData.Value = item.SysUserRealName
  2941. }
  2942. err = xlsxFile.Save(downLoadnFilePath)
  2943. if err != nil {
  2944. fmt.Println(err)
  2945. return
  2946. }
  2947. }
  2948. func initHistoryRemarList() {
  2949. remarkList, err := company.GetCompanyHistoryRemarkListInitExport()
  2950. if err != nil {
  2951. fmt.Println(err)
  2952. return
  2953. }
  2954. var companyids []int
  2955. //var companyidsMap +
  2956. resp := new(company.CompanyHistoryRemarkListResp)
  2957. for _, v := range remarkList {
  2958. item := new(company.CompanyHistoryRemarkResp)
  2959. item.CompanyId = v.CompanyId
  2960. if !utils.InArrayByInt(companyids, v.CompanyId) {
  2961. companyids = append(companyids, v.CompanyId)
  2962. }
  2963. item.Content = v.Content
  2964. item.SysAdminName = v.SysAdminName
  2965. //item.SysAdminName = v.C
  2966. item.CreateTime = v.ShowTime.Format(utils.FormatDateTime)
  2967. switch v.TableName {
  2968. case "company_service_record":
  2969. item.RemarkType = "沟通记录"
  2970. case "company_product_remark":
  2971. item.RemarkType = "备注"
  2972. case "company_no_renewed_note":
  2973. item.RemarkType = "未续约备注"
  2974. case "company_renewal_reason":
  2975. item.RemarkType = "未续约说明"
  2976. case "cygx_user_feedback":
  2977. item.RemarkType = "交流反馈(" + v.RealName + ")"
  2978. default:
  2979. item.RemarkType = "备注"
  2980. }
  2981. resp.List = append(resp.List, item)
  2982. }
  2983. listCompany, err := company.GetOverseasCompanysByCompanyIds(companyids)
  2984. if err != nil {
  2985. fmt.Println(err)
  2986. return
  2987. }
  2988. mapCompamyName := make(map[int]string)
  2989. for _, v := range listCompany {
  2990. mapCompamyName[v.CompanyId] = v.CompanyName
  2991. }
  2992. //创建excel
  2993. dir, err := os.Executable()
  2994. exPath := filepath.Dir(dir)
  2995. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  2996. xlsxFile := xlsx.NewFile()
  2997. if err != nil {
  2998. fmt.Println(err)
  2999. return
  3000. }
  3001. style := xlsx.NewStyle()
  3002. alignment := xlsx.Alignment{
  3003. Horizontal: "center",
  3004. Vertical: "center",
  3005. WrapText: true,
  3006. }
  3007. style.Alignment = alignment
  3008. style.ApplyAlignment = true
  3009. redStyle := xlsx.NewStyle()
  3010. redStyle.Alignment = alignment
  3011. redStyle.ApplyAlignment = true
  3012. redStyle.Font.Color = "ff0000"
  3013. //定义底色需要标黄的 单元格颜色
  3014. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3015. redStyle.Fill = redFill
  3016. //redStyle.Border = *border
  3017. var sheetName string
  3018. sheetName = "备注"
  3019. sheet, err := xlsxFile.AddSheet(sheetName)
  3020. if err != nil {
  3021. fmt.Println(err)
  3022. return
  3023. }
  3024. //标头
  3025. rowTitle := sheet.AddRow()
  3026. cellA := rowTitle.AddCell()
  3027. cellA.Value = "录入人"
  3028. cellB := rowTitle.AddCell()
  3029. cellB.Value = " 录入时间"
  3030. cellC := rowTitle.AddCell()
  3031. cellC.Value = " 客户名称"
  3032. cellMoney := rowTitle.AddCell()
  3033. cellMoney.Value = "录入类型"
  3034. cellConct := rowTitle.AddCell()
  3035. cellConct.Value = "录入内容"
  3036. for _, item := range resp.List {
  3037. row := sheet.AddRow()
  3038. cellAData := row.AddCell()
  3039. cellAData.Value = item.SysAdminName
  3040. cellBData := row.AddCell()
  3041. cellBData.Value = item.CreateTime
  3042. cellCData := row.AddCell()
  3043. cellCData.Value = mapCompamyName[item.CompanyId]
  3044. cellCnameData := row.AddCell()
  3045. cellCnameData.Value = item.RemarkType
  3046. cellContentData := row.AddCell()
  3047. cellContentData.Value = item.Content
  3048. }
  3049. err = xlsxFile.Save(downLoadnFilePath)
  3050. if err != nil {
  3051. fmt.Println(err)
  3052. return
  3053. }
  3054. }
  3055. func initcygx_user_feedback() {
  3056. remarkList, err := cygx.GetCygxUserFeedbackListIni2t()
  3057. if err != nil {
  3058. fmt.Println(err)
  3059. return
  3060. }
  3061. var companyids []int
  3062. var sellerIds []int
  3063. var adminIds []int
  3064. //var companyidsMap
  3065. for _, v := range remarkList {
  3066. item := new(company.CompanyHistoryRemarkResp)
  3067. item.CompanyId = v.CompanyId
  3068. if !utils.InArrayByInt(companyids, v.CompanyId) {
  3069. companyids = append(companyids, v.CompanyId)
  3070. }
  3071. if !utils.InArrayByInt(sellerIds, v.SellerId) {
  3072. sellerIds = append(sellerIds, v.SellerId)
  3073. }
  3074. if !utils.InArrayByInt(adminIds, v.AdminId) {
  3075. adminIds = append(adminIds, v.AdminId)
  3076. }
  3077. }
  3078. sysUserList, err := system.GetAdminList()
  3079. if err != nil {
  3080. fmt.Println(err)
  3081. return
  3082. }
  3083. adminMap := make(map[int]*system.Admin, 0)
  3084. for _, v := range sysUserList {
  3085. adminMap[v.AdminId] = v
  3086. }
  3087. listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyids)
  3088. if err != nil {
  3089. fmt.Println(err)
  3090. return
  3091. }
  3092. mapCompamyName := make(map[int]*company.CompanyProduct)
  3093. for _, v := range listCompany {
  3094. mapCompamyName[v.CompanyId] = v
  3095. }
  3096. //创建excel
  3097. dir, err := os.Executable()
  3098. exPath := filepath.Dir(dir)
  3099. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3100. xlsxFile := xlsx.NewFile()
  3101. if err != nil {
  3102. fmt.Println(err)
  3103. return
  3104. }
  3105. style := xlsx.NewStyle()
  3106. alignment := xlsx.Alignment{
  3107. Horizontal: "center",
  3108. Vertical: "center",
  3109. WrapText: true,
  3110. }
  3111. style.Alignment = alignment
  3112. style.ApplyAlignment = true
  3113. redStyle := xlsx.NewStyle()
  3114. redStyle.Alignment = alignment
  3115. redStyle.ApplyAlignment = true
  3116. redStyle.Font.Color = "ff0000"
  3117. //定义底色需要标黄的 单元格颜色
  3118. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3119. redStyle.Fill = redFill
  3120. //redStyle.Border = *border
  3121. var sheetName string
  3122. sheetName = "针对kp的交流反馈"
  3123. sheet, err := xlsxFile.AddSheet(sheetName)
  3124. if err != nil {
  3125. fmt.Println(err)
  3126. return
  3127. }
  3128. //标头
  3129. rowTitle := sheet.AddRow()
  3130. cellA := rowTitle.AddCell()
  3131. cellA.Value = "服务销售姓名"
  3132. cellB := rowTitle.AddCell()
  3133. cellB.Value = " kp姓名"
  3134. cellC := rowTitle.AddCell()
  3135. cellC.Value = " 公司名称"
  3136. cellMoney := rowTitle.AddCell()
  3137. cellMoney.Value = "原销售"
  3138. cellConct := rowTitle.AddCell()
  3139. cellConct.Value = "交流反馈内容"
  3140. cellTime := rowTitle.AddCell()
  3141. cellTime.Value = "录入时间"
  3142. var SellerNameArr []string
  3143. for _, item := range sysUserList {
  3144. if !utils.InArrayByStr(SellerNameArr, item.RealName) {
  3145. SellerNameArr = append(SellerNameArr, item.RealName)
  3146. }
  3147. }
  3148. fmt.Println(SellerNameArr)
  3149. for _, v := range SellerNameArr {
  3150. fmt.Println(v)
  3151. }
  3152. //return
  3153. for _, v := range adminIds {
  3154. for _, item := range remarkList {
  3155. if item.AdminId != v {
  3156. //fmt.Println(v)
  3157. continue
  3158. }
  3159. fmt.Println(v)
  3160. row := sheet.AddRow()
  3161. cellAData := row.AddCell()
  3162. cellAData.Value = adminMap[item.AdminId].RealName
  3163. cellBData := row.AddCell()
  3164. cellBData.Value = item.RealName
  3165. cellCData := row.AddCell()
  3166. cellCData.Value = item.CompanyName
  3167. cellCnameData := row.AddCell()
  3168. cellCnameData.Value = mapCompamyName[item.CompanyId].SellerName
  3169. cellContentData := row.AddCell()
  3170. cellContentData.Value = item.Content
  3171. cellTimeData := row.AddCell()
  3172. cellTimeData.Value = item.CreateTime.Format(utils.FormatDateTime)
  3173. }
  3174. }
  3175. err = xlsxFile.Save(downLoadnFilePath)
  3176. if err != nil {
  3177. fmt.Println(err)
  3178. return
  3179. }
  3180. }
  3181. func initcompany_history_remark() {
  3182. remarkList, err := company.GetCompanyHistoryRemarkListInitExportinit()
  3183. if err != nil {
  3184. fmt.Println(err)
  3185. return
  3186. }
  3187. var companyids []int
  3188. var adminIds []int
  3189. //var companyidsMap
  3190. for _, v := range remarkList {
  3191. item := new(company.CompanyHistoryRemarkResp)
  3192. item.CompanyId = v.CompanyId
  3193. if !utils.InArrayByInt(companyids, v.CompanyId) {
  3194. companyids = append(companyids, v.CompanyId)
  3195. }
  3196. if !utils.InArrayByInt(adminIds, v.SysAdminId) {
  3197. adminIds = append(adminIds, v.SysAdminId)
  3198. }
  3199. switch v.TableName {
  3200. case "company_service_record":
  3201. item.RemarkType = "沟通记录"
  3202. case "company_product_remark":
  3203. item.RemarkType = "历史备注"
  3204. case "company_no_renewed_note":
  3205. item.RemarkType = "未续约备注"
  3206. case "company_renewal_reason":
  3207. item.RemarkType = "未续约说明"
  3208. case "cygx_user_feedback":
  3209. item.RemarkType = "交流反馈(" + v.RealName + ")"
  3210. default:
  3211. item.RemarkType = "备注"
  3212. }
  3213. }
  3214. listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyids)
  3215. if err != nil {
  3216. fmt.Println(err)
  3217. return
  3218. }
  3219. sysUserList, err := system.GetAdminList()
  3220. if err != nil {
  3221. fmt.Println(err)
  3222. return
  3223. }
  3224. adminMap := make(map[int]*system.Admin, 0)
  3225. for _, v := range sysUserList {
  3226. adminMap[v.AdminId] = v
  3227. }
  3228. mapCompamyName := make(map[int]*company.CompanyProduct)
  3229. for _, v := range listCompany {
  3230. mapCompamyName[v.CompanyId] = v
  3231. }
  3232. //创建excel
  3233. dir, err := os.Executable()
  3234. exPath := filepath.Dir(dir)
  3235. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3236. xlsxFile := xlsx.NewFile()
  3237. if err != nil {
  3238. fmt.Println(err)
  3239. return
  3240. }
  3241. style := xlsx.NewStyle()
  3242. alignment := xlsx.Alignment{
  3243. Horizontal: "center",
  3244. Vertical: "center",
  3245. WrapText: true,
  3246. }
  3247. style.Alignment = alignment
  3248. style.ApplyAlignment = true
  3249. redStyle := xlsx.NewStyle()
  3250. redStyle.Alignment = alignment
  3251. redStyle.ApplyAlignment = true
  3252. redStyle.Font.Color = "ff0000"
  3253. //定义底色需要标黄的 单元格颜色
  3254. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3255. redStyle.Fill = redFill
  3256. //redStyle.Border = *border
  3257. var sheetName string
  3258. sheetName = "针对kp的交流反馈"
  3259. sheet, err := xlsxFile.AddSheet(sheetName)
  3260. if err != nil {
  3261. fmt.Println(err)
  3262. return
  3263. }
  3264. //标头
  3265. rowTitle := sheet.AddRow()
  3266. cellA := rowTitle.AddCell()
  3267. cellA.Value = "服务销售姓名"
  3268. cellC := rowTitle.AddCell()
  3269. cellC.Value = " 公司名称"
  3270. cellMoney := rowTitle.AddCell()
  3271. cellMoney.Value = "原销售"
  3272. cellConct := rowTitle.AddCell()
  3273. cellConct.Value = "交流反馈内容"
  3274. cellType := rowTitle.AddCell()
  3275. cellType.Value = "记录类型"
  3276. cellTime := rowTitle.AddCell()
  3277. cellTime.Value = "录入时间"
  3278. var SellerNameArr []string
  3279. for _, item := range remarkList {
  3280. if !utils.InArrayByStr(SellerNameArr, mapCompamyName[item.CompanyId].ShareSeller) {
  3281. SellerNameArr = append(SellerNameArr, mapCompamyName[item.CompanyId].ShareSeller)
  3282. }
  3283. }
  3284. fmt.Println(SellerNameArr)
  3285. for _, v := range SellerNameArr {
  3286. fmt.Println(v)
  3287. }
  3288. //return
  3289. for _, v := range adminIds {
  3290. for _, item := range remarkList {
  3291. if item.SysAdminId != v {
  3292. //fmt.Println(v)
  3293. continue
  3294. }
  3295. fmt.Println(v)
  3296. row := sheet.AddRow()
  3297. cellAData := row.AddCell()
  3298. cellAData.Value = item.SysAdminName
  3299. cellCData := row.AddCell()
  3300. cellCData.Value = mapCompamyName[item.CompanyId].CompanyName
  3301. cellCnameData := row.AddCell()
  3302. cellCnameData.Value = mapCompamyName[item.CompanyId].SellerName
  3303. cellContentData := row.AddCell()
  3304. cellContentData.Value = item.Content
  3305. celltypeData := row.AddCell()
  3306. switch item.TableName {
  3307. case "company_service_record":
  3308. celltypeData.Value = "沟通记录"
  3309. case "company_product_remark":
  3310. celltypeData.Value = "历史备注"
  3311. default:
  3312. celltypeData.Value = "历史备注"
  3313. }
  3314. cellTimeData := row.AddCell()
  3315. cellTimeData.Value = item.CreateTime.Format(utils.FormatDateTime)
  3316. }
  3317. }
  3318. err = xlsxFile.Save(downLoadnFilePath)
  3319. if err != nil {
  3320. fmt.Println(err)
  3321. return
  3322. }
  3323. }
  3324. func initRsListinit() {
  3325. list, errList := roadshow.GetRsCalendarMeetingUserByRaiinit()
  3326. if errList != nil {
  3327. fmt.Println(errList)
  3328. return
  3329. }
  3330. var companyids []int
  3331. //var companyidsMap
  3332. var rsCalendarIds []int
  3333. for _, v := range list {
  3334. if !utils.InArrayByInt(companyids, v.CompanyId) {
  3335. companyids = append(companyids, v.CompanyId)
  3336. }
  3337. rsCalendarIds = append(rsCalendarIds, v.RsCalendarId)
  3338. }
  3339. listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyids)
  3340. if err != nil {
  3341. fmt.Println(err)
  3342. return
  3343. }
  3344. mapCompamyName := make(map[int]*company.CompanyProduct)
  3345. for _, v := range listCompany {
  3346. mapCompamyName[v.CompanyId] = v
  3347. }
  3348. mapRsCalendarLabel := make(map[int][]string) //1v1 路演标签
  3349. mapRsCalendarLabel = cygxService.GetRsCalendarLabelByRsCalendarIds(rsCalendarIds)
  3350. //创建excel
  3351. dir, err := os.Executable()
  3352. exPath := filepath.Dir(dir)
  3353. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3354. xlsxFile := xlsx.NewFile()
  3355. if err != nil {
  3356. fmt.Println(err)
  3357. return
  3358. }
  3359. style := xlsx.NewStyle()
  3360. alignment := xlsx.Alignment{
  3361. Horizontal: "center",
  3362. Vertical: "center",
  3363. WrapText: true,
  3364. }
  3365. style.Alignment = alignment
  3366. style.ApplyAlignment = true
  3367. redStyle := xlsx.NewStyle()
  3368. redStyle.Alignment = alignment
  3369. redStyle.ApplyAlignment = true
  3370. redStyle.Font.Color = "ff0000"
  3371. //定义底色需要标黄的 单元格颜色
  3372. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3373. redStyle.Fill = redFill
  3374. //redStyle.Border = *border
  3375. var sheetName string
  3376. sheetName = "活动"
  3377. sheet, err := xlsxFile.AddSheet(sheetName)
  3378. if err != nil {
  3379. fmt.Println(err)
  3380. return
  3381. }
  3382. //标头
  3383. rowTitle := sheet.AddRow()
  3384. cellA := rowTitle.AddCell()
  3385. cellA.Value = "公司名称"
  3386. cellB := rowTitle.AddCell()
  3387. cellB.Value = "所属服务销售"
  3388. cellC := rowTitle.AddCell()
  3389. cellC.Value = "原销售"
  3390. cellD := rowTitle.AddCell()
  3391. cellD.Value = "姓名"
  3392. cellE := rowTitle.AddCell()
  3393. cellE.Value = "手机号"
  3394. cellF := rowTitle.AddCell()
  3395. cellF.Value = "路演时间"
  3396. cellG := rowTitle.AddCell()
  3397. cellG.Value = "研究员"
  3398. cellH := rowTitle.AddCell()
  3399. cellH.Value = "路演形式"
  3400. cellI := rowTitle.AddCell()
  3401. cellI.Value = "路演主题"
  3402. cellJ := rowTitle.AddCell()
  3403. cellJ.Value = "主题标签"
  3404. for _, v := range companyids {
  3405. for _, item := range list {
  3406. if item.CompanyId != v {
  3407. //fmt.Println(v)
  3408. continue
  3409. }
  3410. row := sheet.AddRow()
  3411. cellAData := row.AddCell()
  3412. cellAData.Value = item.CompanyName
  3413. cellBData := row.AddCell()
  3414. cellCData := row.AddCell()
  3415. if mapCompamyName[item.CompanyId] != nil {
  3416. cellBData.Value = mapCompamyName[item.CompanyId].ShareSeller
  3417. cellCData.Value = mapCompamyName[item.CompanyId].SellerName
  3418. }
  3419. cellDData := row.AddCell()
  3420. cellDData.Value = item.RealName
  3421. cellEData := row.AddCell()
  3422. cellEData.Value = item.Mobile
  3423. cellFData := row.AddCell()
  3424. cellFData.Value = item.StartDate + " " + item.StartTime
  3425. cellGData := row.AddCell()
  3426. cellGData.Value = item.ResearcherName
  3427. cellHData := row.AddCell()
  3428. cellHData.Value = item.RoadshowType
  3429. cellIData := row.AddCell()
  3430. cellIData.Value = item.RoadShowTheme
  3431. cellJData := row.AddCell()
  3432. cellJData.Value = strings.Join(mapRsCalendarLabel[item.RsCalendarId], ",")
  3433. }
  3434. }
  3435. err = xlsxFile.Save(downLoadnFilePath)
  3436. if err != nil {
  3437. fmt.Println(err)
  3438. return
  3439. }
  3440. }
  3441. //func init() {
  3442. // initAct22()
  3443. //}
  3444. func initYaxuan() {
  3445. udi := 121323
  3446. var nickname = "鱼与塘"
  3447. listYax, errList := cygx.GetYanxuanSpecialListByconditioninit(udi)
  3448. if errList != nil {
  3449. fmt.Println(errList)
  3450. return
  3451. }
  3452. //创建excel
  3453. dir, err := os.Executable()
  3454. exPath := filepath.Dir(dir)
  3455. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3456. xlsxFile := xlsx.NewFile()
  3457. if err != nil {
  3458. fmt.Println(err)
  3459. return
  3460. }
  3461. style := xlsx.NewStyle()
  3462. alignment := xlsx.Alignment{
  3463. Horizontal: "center",
  3464. Vertical: "center",
  3465. WrapText: true,
  3466. }
  3467. style.Alignment = alignment
  3468. style.ApplyAlignment = true
  3469. redStyle := xlsx.NewStyle()
  3470. redStyle.Alignment = alignment
  3471. redStyle.ApplyAlignment = true
  3472. redStyle.Font.Color = "ff0000"
  3473. //定义底色需要标黄的 单元格颜色
  3474. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3475. redStyle.Fill = redFill
  3476. //redStyle.Border = *border
  3477. var sheetName string
  3478. sheetName = "活动"
  3479. sheet, err := xlsxFile.AddSheet(sheetName)
  3480. if err != nil {
  3481. fmt.Println(err)
  3482. return
  3483. }
  3484. //标头
  3485. rowTitle := sheet.AddRow()
  3486. cellA := rowTitle.AddCell()
  3487. cellA.Value = "文章标题"
  3488. cellB := rowTitle.AddCell()
  3489. cellB.Value = "发布时间"
  3490. cellC := rowTitle.AddCell()
  3491. cellC.Value = "作者昵称"
  3492. cellD := rowTitle.AddCell()
  3493. cellD.Value = "读者手机号"
  3494. cellE := rowTitle.AddCell()
  3495. cellE.Value = "姓名"
  3496. cellF := rowTitle.AddCell()
  3497. cellF.Value = "公司名"
  3498. for _, v := range listYax {
  3499. var condition string
  3500. var pars []interface{}
  3501. condition = ` AND yanxuan_special_id = ? AND company_id != 16 GROUP BY mobile ORDER BY create_time DESC `
  3502. pars = append(pars, v.Id)
  3503. list, err := cygx.GetCygxYanxuanSpecialRecordList(condition, pars)
  3504. if err != nil {
  3505. fmt.Println(err)
  3506. return
  3507. }
  3508. for _, item := range list {
  3509. row := sheet.AddRow()
  3510. cellAData := row.AddCell()
  3511. cellAData.Value = v.Title
  3512. cellBData := row.AddCell()
  3513. cellBData.Value = v.PublishTime.Format(utils.FormatDateTime)
  3514. cellCData := row.AddCell()
  3515. cellCData.Value = nickname
  3516. cellDData := row.AddCell()
  3517. cellDData.Value = item.RealName
  3518. cellEData := row.AddCell()
  3519. cellEData.Value = item.Mobile
  3520. cellFData := row.AddCell()
  3521. cellFData.Value = item.CompanyName
  3522. }
  3523. }
  3524. err = xlsxFile.Save(downLoadnFilePath)
  3525. if err != nil {
  3526. fmt.Println(err)
  3527. return
  3528. }
  3529. }
  3530. func initart22() {
  3531. //行业
  3532. var condition string
  3533. var pars []interface{}
  3534. condition += ` AND art.publish_date >= '2024-10-01'
  3535. AND art.publish_status = 1
  3536. AND art.article_type_id = 0 `
  3537. //return
  3538. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
  3539. //fmt.Println(condition)
  3540. list, err := cygx.GetReportArticleList(condition, pars, 0, 9999, 1)
  3541. if err != nil {
  3542. fmt.Println(err)
  3543. return
  3544. }
  3545. fmt.Println("list", len(list))
  3546. //return
  3547. reportMap := make(map[int]string)
  3548. listMap, err := cygx.GetReportMapping()
  3549. if err != nil {
  3550. fmt.Println(err)
  3551. return
  3552. }
  3553. for _, v := range listMap {
  3554. reportMap[v.CategoryId] = v.MatchTypeName
  3555. }
  3556. //创建excel
  3557. dir, err := os.Executable()
  3558. exPath := filepath.Dir(dir)
  3559. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3560. xlsxFile := xlsx.NewFile()
  3561. if err != nil {
  3562. fmt.Println(err)
  3563. return
  3564. }
  3565. style := xlsx.NewStyle()
  3566. alignment := xlsx.Alignment{
  3567. Horizontal: "center",
  3568. Vertical: "center",
  3569. WrapText: true,
  3570. }
  3571. style.Alignment = alignment
  3572. style.ApplyAlignment = true
  3573. redStyle := xlsx.NewStyle()
  3574. redStyle.Alignment = alignment
  3575. redStyle.ApplyAlignment = true
  3576. redStyle.Font.Color = "ff0000"
  3577. //定义底色需要标黄的 单元格颜色
  3578. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3579. redStyle.Fill = redFill
  3580. //redStyle.Border = *border
  3581. var sheetName string
  3582. sheetName = "数据"
  3583. sheet, err := xlsxFile.AddSheet(sheetName)
  3584. if err != nil {
  3585. fmt.Println(err)
  3586. return
  3587. }
  3588. //标头
  3589. rowTitle := sheet.AddRow()
  3590. cellAt := rowTitle.AddCell()
  3591. cellAt.Value = " 发布时间 "
  3592. cellPd := rowTitle.AddCell()
  3593. cellPd.Value = "行业"
  3594. //cellA := rowTitle.AddCell()
  3595. //cellA.Value = "系列"
  3596. cellB := rowTitle.AddCell()
  3597. cellB.Value = "报告名称"
  3598. for _, v := range list {
  3599. //if v.SubCategoryName != "行业深度" {
  3600. // continue
  3601. //}
  3602. row := sheet.AddRow()
  3603. cellADatatitle := row.AddCell()
  3604. cellADatatitle.Value = v.PublishDate
  3605. cellADataPd := row.AddCell()
  3606. if v.ChartPermissionName == "" {
  3607. cellADataPd.Value = v.CategoryName
  3608. } else {
  3609. cellADataPd.Value = v.ChartPermissionName
  3610. }
  3611. //cellAData := row.AddCell()
  3612. //cellAData.Value = v.SubCategoryName
  3613. cellBData := row.AddCell()
  3614. cellBData.Value = v.Title
  3615. }
  3616. err = xlsxFile.Save(downLoadnFilePath)
  3617. if err != nil {
  3618. fmt.Println(err)
  3619. return
  3620. }
  3621. }
  3622. func initAct22() {
  3623. //行业
  3624. var condition string
  3625. var pars []interface{}
  3626. condition += ` AND chart_permission_id != 31 AND activity_time > '2024-10-01' AND activity_time < '2024-12-24' AND publish_status = 1 ORDER BY activity_time DESC `
  3627. //fmt.Println(condition)
  3628. list, err := cygx.GetActivityListAll(condition, pars, 0, 9999)
  3629. if err != nil {
  3630. fmt.Println(err)
  3631. return
  3632. }
  3633. fmt.Println("list", len(list))
  3634. //创建excel
  3635. dir, err := os.Executable()
  3636. exPath := filepath.Dir(dir)
  3637. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3638. xlsxFile := xlsx.NewFile()
  3639. if err != nil {
  3640. fmt.Println(err)
  3641. return
  3642. }
  3643. style := xlsx.NewStyle()
  3644. alignment := xlsx.Alignment{
  3645. Horizontal: "center",
  3646. Vertical: "center",
  3647. WrapText: true,
  3648. }
  3649. style.Alignment = alignment
  3650. style.ApplyAlignment = true
  3651. redStyle := xlsx.NewStyle()
  3652. redStyle.Alignment = alignment
  3653. redStyle.ApplyAlignment = true
  3654. redStyle.Font.Color = "ff0000"
  3655. //定义底色需要标黄的 单元格颜色
  3656. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  3657. redStyle.Fill = redFill
  3658. //redStyle.Border = *border
  3659. var sheetName string
  3660. sheetName = "数据"
  3661. sheet, err := xlsxFile.AddSheet(sheetName)
  3662. if err != nil {
  3663. fmt.Println(err)
  3664. return
  3665. }
  3666. //标头
  3667. rowTitle := sheet.AddRow()
  3668. cellAt := rowTitle.AddCell()
  3669. cellAt.Value = " 活动时间 "
  3670. cellPd := rowTitle.AddCell()
  3671. cellPd.Value = "行业"
  3672. //cellA := rowTitle.AddCell()
  3673. //cellA.Value = "系列"
  3674. cellB := rowTitle.AddCell()
  3675. cellB.Value = " 活动名称"
  3676. for _, v := range list {
  3677. //if v.SubCategoryName != "行业深度" {
  3678. // continue
  3679. //}
  3680. row := sheet.AddRow()
  3681. cellADatatitle := row.AddCell()
  3682. cellADatatitle.Value = v.ActivityTime
  3683. cellADataPd := row.AddCell()
  3684. cellADataPd.Value = v.ChartPermissionName
  3685. //cellAData := row.AddCell()
  3686. //cellAData.Value = v.SubCategoryName
  3687. cellBData := row.AddCell()
  3688. cellBData.Value = v.ActivityName
  3689. }
  3690. err = xlsxFile.Save(downLoadnFilePath)
  3691. if err != nil {
  3692. fmt.Println(err)
  3693. return
  3694. }
  3695. }
  3696. //func init() {
  3697. // initQuanyi()
  3698. //}
  3699. func initLuyan() {
  3700. listEmail, err := cygx.GetAskEmail()
  3701. if err != nil {
  3702. fmt.Println(err)
  3703. return
  3704. }
  3705. var adminIds []int
  3706. mapchart_permission_name := make(map[string]bool)
  3707. var arrchart_permission_name []string
  3708. for _, v := range listEmail {
  3709. if v.AdminId > 0 {
  3710. adminIds = append(adminIds, v.AdminId)
  3711. }
  3712. if mapchart_permission_name[v.ChartPermissionName] || v.ChartPermissionName == "" {
  3713. continue
  3714. }
  3715. mapchart_permission_name[v.ChartPermissionName] = true
  3716. arrchart_permission_name = append(arrchart_permission_name, v.ChartPermissionName)
  3717. }
  3718. var condition string
  3719. var pars []interface{}
  3720. condition = " AND r.researcher_id IN (" + utils.GetOrmInReplace(len(adminIds)) + ") "
  3721. pars = append(pars, adminIds)
  3722. listRoadShow, err := roadshow.GetCalendarListInit(condition, pars)
  3723. if err != nil {
  3724. fmt.Println(err)
  3725. return
  3726. }
  3727. var companyIds []int
  3728. mapCompanyId := make(map[int]bool)
  3729. for _, v := range listRoadShow {
  3730. if mapCompanyId[v.CompanyId] || v.CompanyId == 0 {
  3731. continue
  3732. }
  3733. companyIds = append(companyIds, v.CompanyId)
  3734. mapCompanyId[v.CompanyId] = true
  3735. }
  3736. companyProductItems, err := company.GetCompanyProductByCompanyIdSAndProductId(companyIds, 2)
  3737. if err != nil {
  3738. fmt.Println(err)
  3739. return
  3740. }
  3741. fmt.Println(111)
  3742. mapCompanyStatus := make(map[int]string)
  3743. for _, v := range companyProductItems {
  3744. mapCompanyStatus[v.CompanyId] = v.Status
  3745. }
  3746. permissionList, err := company.GetCompanyProductReportPermissionLists(companyIds, 2)
  3747. if err != nil {
  3748. fmt.Println(err)
  3749. return
  3750. }
  3751. permissionArr := make(map[int][]string)
  3752. mappermissionArr := make(map[string]bool)
  3753. for _, v := range permissionList {
  3754. if mappermissionArr[fmt.Sprint(v.CompanyId, v.PermissionName)] {
  3755. continue
  3756. }
  3757. if mapCompanyStatus[v.CompanyId] == "正式" && v.Status != "正式" {
  3758. continue
  3759. }
  3760. permissionArr[v.CompanyId] = append(permissionArr[v.CompanyId], v.PermissionName)
  3761. mappermissionArr[fmt.Sprint(v.CompanyId, v.PermissionName)] = true
  3762. }
  3763. fmt.Println(len(listRoadShow))
  3764. fmt.Println(arrchart_permission_name)
  3765. //return
  3766. //创建excel
  3767. dir, err := os.Executable()
  3768. exPath := filepath.Dir(dir)
  3769. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3770. xlsxFile := xlsx.NewFile()
  3771. if err != nil {
  3772. fmt.Println(err)
  3773. return
  3774. }
  3775. style := xlsx.NewStyle()
  3776. alignment := xlsx.Alignment{
  3777. Horizontal: "center",
  3778. Vertical: "center",
  3779. WrapText: true,
  3780. }
  3781. style.Alignment = alignment
  3782. style.ApplyAlignment = true
  3783. for _, v := range arrchart_permission_name {
  3784. var sheetName string
  3785. sheetName = v
  3786. sheet, err := xlsxFile.AddSheet(sheetName)
  3787. if err != nil {
  3788. fmt.Println(err)
  3789. return
  3790. }
  3791. //标头
  3792. rowTitle := sheet.AddRow()
  3793. cellA := rowTitle.AddCell()
  3794. cellA.Value = "研究员"
  3795. cellB := rowTitle.AddCell()
  3796. cellB.Value = "行业"
  3797. cellC := rowTitle.AddCell()
  3798. cellC.Value = "路演时间"
  3799. cellCSeller := rowTitle.AddCell()
  3800. cellCSeller.Value = "客户名称"
  3801. cellD := rowTitle.AddCell()
  3802. cellD.Value = "申请销售"
  3803. cellE := rowTitle.AddCell()
  3804. cellE.Value = "当前客户状态"
  3805. cellF := rowTitle.AddCell()
  3806. cellF.Value = "当前行业权限"
  3807. for _, vE := range listEmail {
  3808. if vE.ChartPermissionName != v {
  3809. continue
  3810. }
  3811. for _, vS := range listRoadShow {
  3812. if vS.ResearcherId != strconv.Itoa(vE.AdminId) {
  3813. continue
  3814. }
  3815. row := sheet.AddRow()
  3816. cellAData := row.AddCell()
  3817. cellAData.Value = vE.Name
  3818. cellBData := row.AddCell()
  3819. cellBData.Value = v
  3820. cellCData := row.AddCell()
  3821. cellCData.Value = vS.StartDate + " " + vS.StartTime
  3822. cellDData := row.AddCell()
  3823. cellDData.Value = vS.CompanyName
  3824. cellEData := row.AddCell()
  3825. cellEData.Value = vS.SysUserRealName
  3826. cellFData := row.AddCell()
  3827. cellFData.Value = mapCompanyStatus[vS.CompanyId]
  3828. cellGData := row.AddCell()
  3829. cellGData.Value = strings.Join(permissionArr[vS.CompanyId], "/")
  3830. }
  3831. }
  3832. }
  3833. err = xlsxFile.Save(downLoadnFilePath)
  3834. if err != nil {
  3835. fmt.Println(err)
  3836. return
  3837. }
  3838. }
  3839. func initQuanyi() {
  3840. var condition string
  3841. var pars []interface{}
  3842. condition = ` AND product_id = 2 AND industry_id > 0 GROUP BY industry_id `
  3843. productList, err := company.GetCompanyProductList(condition, pars)
  3844. if err != nil {
  3845. fmt.Println(err)
  3846. return
  3847. }
  3848. condition = ` AND product_id = 2 AND industry_id > 0 `
  3849. productListData, err := company.GetCompanyProductList(condition, pars)
  3850. if err != nil {
  3851. fmt.Println(err)
  3852. return
  3853. }
  3854. //return
  3855. //创建excel
  3856. dir, err := os.Executable()
  3857. exPath := filepath.Dir(dir)
  3858. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3859. xlsxFile := xlsx.NewFile()
  3860. if err != nil {
  3861. fmt.Println(err)
  3862. return
  3863. }
  3864. style := xlsx.NewStyle()
  3865. alignment := xlsx.Alignment{
  3866. Horizontal: "center",
  3867. Vertical: "center",
  3868. WrapText: true,
  3869. }
  3870. style.Alignment = alignment
  3871. style.ApplyAlignment = true
  3872. for _, v := range productList {
  3873. var sheetName string
  3874. sheetName = v.IndustryName
  3875. sheet, err := xlsxFile.AddSheet(sheetName)
  3876. if err != nil {
  3877. fmt.Println(err)
  3878. return
  3879. }
  3880. //标头
  3881. rowTitle := sheet.AddRow()
  3882. cellA := rowTitle.AddCell()
  3883. cellA.Value = "客户名称"
  3884. cellB := rowTitle.AddCell()
  3885. cellB.Value = "行业"
  3886. cellC := rowTitle.AddCell()
  3887. cellC.Value = "状态"
  3888. cellCSeller := rowTitle.AddCell()
  3889. cellCSeller.Value = "销售"
  3890. for _, vE := range productListData {
  3891. if vE.IndustryId != v.IndustryId {
  3892. continue
  3893. }
  3894. row := sheet.AddRow()
  3895. cellAData := row.AddCell()
  3896. cellAData.Value = vE.CompanyName
  3897. cellBData := row.AddCell()
  3898. cellBData.Value = vE.IndustryName
  3899. cellCData := row.AddCell()
  3900. cellCData.Value = vE.Status
  3901. cellDData := row.AddCell()
  3902. cellDData.Value = vE.SellerName
  3903. }
  3904. }
  3905. err = xlsxFile.Save(downLoadnFilePath)
  3906. if err != nil {
  3907. fmt.Println(err)
  3908. return
  3909. }
  3910. fmt.Println("end")
  3911. }
  3912. func init() {
  3913. initart121_1()
  3914. }
  3915. func initBeizhu() {
  3916. productList, err := company.GetCompanyHistoryRemarkListInit()
  3917. if err != nil {
  3918. fmt.Println(err)
  3919. return
  3920. }
  3921. var companyids []int
  3922. for _, v := range productList {
  3923. companyids = append(companyids, v.CompanyId)
  3924. }
  3925. listCompany, err := company.GetOverseasCompanysByCompanyIds(companyids)
  3926. if err != nil {
  3927. fmt.Println(err)
  3928. return
  3929. }
  3930. mapCompamyName := make(map[int]string)
  3931. for _, v := range listCompany {
  3932. mapCompamyName[v.CompanyId] = v.CompanyName
  3933. }
  3934. //创建excel
  3935. dir, err := os.Executable()
  3936. exPath := filepath.Dir(dir)
  3937. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  3938. xlsxFile := xlsx.NewFile()
  3939. if err != nil {
  3940. fmt.Println(err)
  3941. return
  3942. }
  3943. style := xlsx.NewStyle()
  3944. alignment := xlsx.Alignment{
  3945. Horizontal: "center",
  3946. Vertical: "center",
  3947. WrapText: true,
  3948. }
  3949. style.Alignment = alignment
  3950. style.ApplyAlignment = true
  3951. var sheetName string
  3952. sheetName = "备注"
  3953. sheet, err := xlsxFile.AddSheet(sheetName)
  3954. if err != nil {
  3955. fmt.Println(err)
  3956. return
  3957. }
  3958. //标头
  3959. rowTitle := sheet.AddRow()
  3960. cellA := rowTitle.AddCell()
  3961. cellA.Value = "客户名称"
  3962. cellB := rowTitle.AddCell()
  3963. cellB.Value = "内容"
  3964. cellC := rowTitle.AddCell()
  3965. cellC.Value = "类型"
  3966. cellCSeller := rowTitle.AddCell()
  3967. cellCSeller.Value = "创建人"
  3968. cellTime := rowTitle.AddCell()
  3969. cellTime.Value = "创建时间"
  3970. for _, vE := range productList {
  3971. row := sheet.AddRow()
  3972. cellAData := row.AddCell()
  3973. cellAData.Value = mapCompamyName[vE.CompanyId]
  3974. cellBData := row.AddCell()
  3975. cellBData.Value = vE.Content
  3976. cellCData := row.AddCell()
  3977. switch vE.TableName {
  3978. case "company_service_record":
  3979. cellCData.Value = "沟通记录"
  3980. case "company_product_remark":
  3981. cellCData.Value = "备注"
  3982. case "company_no_renewed_note":
  3983. cellCData.Value = "未续约备注"
  3984. case "company_renewal_reason":
  3985. cellCData.Value = "未续约说明"
  3986. case "cygx_user_feedback":
  3987. cellCData.Value = "交流反馈(" + vE.RealName + ")"
  3988. default:
  3989. cellCData.Value = "备注"
  3990. }
  3991. cellNameData := row.AddCell()
  3992. cellNameData.Value = vE.SysAdminName
  3993. cellDData := row.AddCell()
  3994. cellDData.Value = vE.ShowTime.Format(utils.FormatDateTime)
  3995. }
  3996. err = xlsxFile.Save(downLoadnFilePath)
  3997. if err != nil {
  3998. fmt.Println(err)
  3999. return
  4000. }
  4001. fmt.Println("end")
  4002. }
  4003. func initUserbill() {
  4004. //研选阅读明细
  4005. var conditionBill string
  4006. var parsBill []interface{}
  4007. monthArr := []string{"08", "09", "10", "11", "12"}
  4008. conditionBill = " AND view_time > '2024-07-01' AND view_time < '2025-01-01' "
  4009. listBill, e := cygx.GetCygxRaiCompanyUserBillListAll(conditionBill, parsBill)
  4010. if e != nil {
  4011. fmt.Println(e)
  4012. return
  4013. }
  4014. mapCompanyIds := make(map[int]bool)
  4015. mapSellerServerCountTotal := make(map[int]float64)
  4016. mapSellerServerCount := make(map[string]float64)
  4017. var companyids []int
  4018. for _, v := range listBill {
  4019. if mapCompanyIds[v.CompanyId] {
  4020. continue
  4021. }
  4022. companyids = append(companyids, v.CompanyId)
  4023. mapCompanyIds[v.CompanyId] = true
  4024. }
  4025. //listCompany, err := company.GetOverseasCompanysByCompanyIds(companyids)
  4026. //if err != nil {
  4027. // fmt.Println(err)
  4028. // return
  4029. //}
  4030. //mapCompamyName := make(map[int]string)
  4031. //
  4032. //for _, v := range listCompany {
  4033. // mapCompamyName[v.CompanyId] = v.CompanyName
  4034. //}
  4035. companyProductItems, err := company.GetCompanyProductByCompanyIdSAndProductId(companyids, 2)
  4036. if err != nil {
  4037. fmt.Println(err)
  4038. return
  4039. }
  4040. mapCompamySeller := make(map[int]int)
  4041. for _, v := range companyProductItems {
  4042. mapCompamySeller[v.CompanyId] = v.ShareSellerId
  4043. }
  4044. for _, v := range listBill {
  4045. for _, m := range monthArr {
  4046. vM := v.ViewTime[5:7]
  4047. if m != vM {
  4048. continue
  4049. }
  4050. //fmt.Println(vM)
  4051. mapSellerServerCount[fmt.Sprint(mapCompamySeller[v.CompanyId], "_", m)] += v.ServeCount
  4052. }
  4053. mapSellerServerCountTotal[(mapCompamySeller[v.CompanyId])] += v.ServeCount
  4054. }
  4055. adminUserList, err := system.GetRaiAdminInit()
  4056. if err != nil {
  4057. fmt.Println(err)
  4058. return
  4059. }
  4060. //创建excel
  4061. dir, err := os.Executable()
  4062. exPath := filepath.Dir(dir)
  4063. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  4064. xlsxFile := xlsx.NewFile()
  4065. if err != nil {
  4066. fmt.Println(err)
  4067. return
  4068. }
  4069. style := xlsx.NewStyle()
  4070. alignment := xlsx.Alignment{
  4071. Horizontal: "center",
  4072. Vertical: "center",
  4073. WrapText: true,
  4074. }
  4075. style.Alignment = alignment
  4076. style.ApplyAlignment = true
  4077. var sheetName string
  4078. sheetName = "备注"
  4079. sheet, err := xlsxFile.AddSheet(sheetName)
  4080. if err != nil {
  4081. fmt.Println(err)
  4082. return
  4083. }
  4084. //标头
  4085. rowTitle := sheet.AddRow()
  4086. cellA := rowTitle.AddCell()
  4087. cellA.Value = "服务销售名称"
  4088. cellB8 := rowTitle.AddCell()
  4089. cellB8.Value = "8月份服务量"
  4090. cellB9 := rowTitle.AddCell()
  4091. cellB9.Value = "9月份服务量"
  4092. cellB10 := rowTitle.AddCell()
  4093. cellB10.Value = "10月份服务量"
  4094. cellB11 := rowTitle.AddCell()
  4095. cellB11.Value = "11月份服务量"
  4096. cellB12 := rowTitle.AddCell()
  4097. cellB12.Value = "12月份服务量"
  4098. cellB := rowTitle.AddCell()
  4099. cellB.Value = "总服务量"
  4100. for _, vE := range adminUserList {
  4101. row := sheet.AddRow()
  4102. cellAData := row.AddCell()
  4103. cellAData.Value = vE.RealName
  4104. cellBData8 := row.AddCell()
  4105. cellBData8.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_08")])
  4106. cellBData9 := row.AddCell()
  4107. cellBData9.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_09")])
  4108. cellBData10 := row.AddCell()
  4109. cellBData10.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_10")])
  4110. cellBData11 := row.AddCell()
  4111. cellBData11.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_11")])
  4112. cellBData12 := row.AddCell()
  4113. cellBData12.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.AdminId, "_12")])
  4114. cellBData := row.AddCell()
  4115. cellBData.Value = fmt.Sprint(mapSellerServerCountTotal[vE.AdminId])
  4116. }
  4117. err = xlsxFile.Save(downLoadnFilePath)
  4118. if err != nil {
  4119. fmt.Println(err)
  4120. return
  4121. }
  4122. fmt.Println("end")
  4123. }
  4124. func initUserCompanybill() {
  4125. //研选阅读明细
  4126. var conditionBill string
  4127. var parsBill []interface{}
  4128. conditionBill = " AND view_time > '2024-07-01' AND view_time < '2025-01-01' AND company_id IN (98, 1444, 1585, 5332, 6351, 8354, 8683, 9310, 13500) "
  4129. companyIdsArr := []int{98, 1444, 1585, 5332, 6351, 8354, 8683, 9310, 13500}
  4130. listBill, e := cygx.GetCygxRaiCompanyUserBillListAll(conditionBill, parsBill)
  4131. if e != nil {
  4132. fmt.Println(e)
  4133. return
  4134. }
  4135. mapCompanyIds := make(map[int]bool)
  4136. mapSellerServerCountTotal := make(map[int]float64)
  4137. mapSellerServerCount := make(map[string]float64)
  4138. var companyids []int
  4139. for _, v := range listBill {
  4140. if mapCompanyIds[v.CompanyId] {
  4141. continue
  4142. }
  4143. companyids = append(companyids, v.CompanyId)
  4144. mapCompanyIds[v.CompanyId] = true
  4145. }
  4146. listCompany, err := company.GetOverseasCompanysByCompanyIds(companyIdsArr)
  4147. if err != nil {
  4148. fmt.Println(err)
  4149. return
  4150. }
  4151. mapCompamyName := make(map[int]string)
  4152. for _, v := range listCompany {
  4153. mapCompamyName[v.CompanyId] = v.CompanyName
  4154. }
  4155. monthArr := []string{"08", "09", "10", "11", "12"}
  4156. companyProductItems, err := company.GetCompanyProductByCompanyIdSAndProductId(companyids, 2)
  4157. if err != nil {
  4158. fmt.Println(err)
  4159. return
  4160. }
  4161. mapCompamySeller := make(map[int]int)
  4162. for _, v := range companyProductItems {
  4163. mapCompamySeller[v.CompanyId] = v.ShareSellerId
  4164. }
  4165. //for _, v := range listBill {
  4166. // mapSellerServerCount[v.CompanyId] += v.ServeCount
  4167. //}
  4168. for _, v := range listBill {
  4169. for _, m := range monthArr {
  4170. vM := v.ViewTime[5:7]
  4171. if m != vM {
  4172. continue
  4173. }
  4174. //fmt.Println(vM)
  4175. mapSellerServerCount[fmt.Sprint(v.CompanyId, "_", m)] += v.ServeCount
  4176. }
  4177. mapSellerServerCountTotal[v.CompanyId] += v.ServeCount
  4178. }
  4179. fmt.Println(mapSellerServerCount)
  4180. //
  4181. ////ficc 研究员
  4182. //adminUserList, err := system.GetRaiAdminInit()
  4183. //if err != nil {
  4184. // fmt.Println(err)
  4185. // return
  4186. //}
  4187. //创建excel
  4188. dir, err := os.Executable()
  4189. exPath := filepath.Dir(dir)
  4190. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  4191. xlsxFile := xlsx.NewFile()
  4192. if err != nil {
  4193. fmt.Println(err)
  4194. return
  4195. }
  4196. style := xlsx.NewStyle()
  4197. alignment := xlsx.Alignment{
  4198. Horizontal: "center",
  4199. Vertical: "center",
  4200. WrapText: true,
  4201. }
  4202. style.Alignment = alignment
  4203. style.ApplyAlignment = true
  4204. var sheetName string
  4205. sheetName = "公司互动统计"
  4206. sheet, err := xlsxFile.AddSheet(sheetName)
  4207. if err != nil {
  4208. fmt.Println(err)
  4209. return
  4210. }
  4211. //标头
  4212. rowTitle := sheet.AddRow()
  4213. cellA := rowTitle.AddCell()
  4214. cellA.Value = "服务销售名称"
  4215. cellB8 := rowTitle.AddCell()
  4216. cellB8.Value = "8月份服务量"
  4217. cellB9 := rowTitle.AddCell()
  4218. cellB9.Value = "9月份服务量"
  4219. cellB10 := rowTitle.AddCell()
  4220. cellB10.Value = "10月份服务量"
  4221. cellB11 := rowTitle.AddCell()
  4222. cellB11.Value = "11月份服务量"
  4223. cellB12 := rowTitle.AddCell()
  4224. cellB12.Value = "12月份服务量"
  4225. cellB := rowTitle.AddCell()
  4226. cellB.Value = "总服务量"
  4227. for _, vE := range listCompany {
  4228. row := sheet.AddRow()
  4229. cellAData := row.AddCell()
  4230. cellAData.Value = vE.CompanyName
  4231. cellBData8 := row.AddCell()
  4232. cellBData8.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_08")])
  4233. cellBData9 := row.AddCell()
  4234. cellBData9.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_09")])
  4235. cellBData10 := row.AddCell()
  4236. cellBData10.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_10")])
  4237. cellBData11 := row.AddCell()
  4238. cellBData11.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_11")])
  4239. cellBData12 := row.AddCell()
  4240. cellBData12.Value = fmt.Sprint(mapSellerServerCount[fmt.Sprint(vE.CompanyId, "_12")])
  4241. cellBData := row.AddCell()
  4242. cellBData.Value = fmt.Sprint(mapSellerServerCountTotal[vE.CompanyId])
  4243. }
  4244. err = xlsxFile.Save(downLoadnFilePath)
  4245. if err != nil {
  4246. fmt.Println(err)
  4247. return
  4248. }
  4249. fmt.Println("end")
  4250. }
  4251. func initQuanyiXiaoShou() {
  4252. adminUserList, err := system.GetRaiAdminInitRai()
  4253. if err != nil {
  4254. fmt.Println(err)
  4255. return
  4256. }
  4257. adminMap := make(map[int]bool)
  4258. for _, vE := range adminUserList {
  4259. adminMap[vE.AdminId] = true
  4260. }
  4261. //研选阅读明细
  4262. var conditionBill string
  4263. var parsBill []interface{}
  4264. //列表页数据
  4265. tmpList, err := models.GetIncrementalCompanyListByOperationRecordIniut(conditionBill, parsBill, 0, 9999)
  4266. if err != nil {
  4267. fmt.Println(err)
  4268. return
  4269. }
  4270. ////列表页数据
  4271. //tmpList3, err := models.GetIncrementalCompanyListByOperationRecordIniut3(conditionBill, parsBill, 0, 9999)
  4272. //if err != nil {
  4273. // fmt.Println(err)
  4274. // return
  4275. //}
  4276. //
  4277. ////列表页数据
  4278. //tmpList4, err := models.GetIncrementalCompanyListByOperationRecordIniut4(conditionBill, parsBill, 0, 9999)
  4279. //if err != nil {
  4280. // fmt.Println(err)
  4281. // return
  4282. //}
  4283. //mapId := make(map[int]bool)
  4284. //for _, v := range tmpList3 {
  4285. // mapId[v.Id] = true
  4286. //}
  4287. //
  4288. //for _, v := range tmpList4 {
  4289. // mapId[v.Id] = true
  4290. //}
  4291. //for _, v := range tmpList {
  4292. // if !mapId[v.Id] {
  4293. // fmt.Println(v.Id)
  4294. // }
  4295. //}
  4296. //
  4297. //return
  4298. mapOperationadd := make(map[int]int)
  4299. mapOperationreceive := make(map[int]int)
  4300. for _, v := range tmpList {
  4301. if !adminMap[v.SellerId] {
  4302. fmt.Println("v.CompanyId", v.CompanyId)
  4303. return
  4304. }
  4305. if v.Operation == "add" {
  4306. mapOperationadd[v.SysUserId]++
  4307. } else {
  4308. mapOperationreceive[v.SysUserId]++
  4309. }
  4310. }
  4311. //创建excel
  4312. dir, err := os.Executable()
  4313. exPath := filepath.Dir(dir)
  4314. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  4315. xlsxFile := xlsx.NewFile()
  4316. if err != nil {
  4317. fmt.Println(err)
  4318. return
  4319. }
  4320. style := xlsx.NewStyle()
  4321. alignment := xlsx.Alignment{
  4322. Horizontal: "center",
  4323. Vertical: "center",
  4324. WrapText: true,
  4325. }
  4326. style.Alignment = alignment
  4327. style.ApplyAlignment = true
  4328. var sheetName string
  4329. sheetName = "2023年2季度"
  4330. sheet, err := xlsxFile.AddSheet(sheetName)
  4331. if err != nil {
  4332. fmt.Println(err)
  4333. return
  4334. }
  4335. //标头
  4336. rowTitle := sheet.AddRow()
  4337. cellA := rowTitle.AddCell()
  4338. cellA.Value = "销售"
  4339. cellB8 := rowTitle.AddCell()
  4340. cellB8.Value = "新增"
  4341. cellB9 := rowTitle.AddCell()
  4342. cellB9.Value = "新建"
  4343. cellB10 := rowTitle.AddCell()
  4344. cellB10.Value = "领取"
  4345. for _, vE := range adminUserList {
  4346. //if mapOperationadd[vE.AdminId]+mapOperationreceive[vE.AdminId] == 0 {
  4347. // continue
  4348. //}
  4349. row := sheet.AddRow()
  4350. cellAData := row.AddCell()
  4351. cellAData.Value = vE.RealName
  4352. cellBData8 := row.AddCell()
  4353. cellBData8.Value = fmt.Sprint(mapOperationadd[vE.AdminId] + mapOperationreceive[vE.AdminId])
  4354. cellBData9 := row.AddCell()
  4355. cellBData9.Value = fmt.Sprint(mapOperationadd[vE.AdminId])
  4356. cellBData10 := row.AddCell()
  4357. cellBData10.Value = fmt.Sprint(mapOperationreceive[vE.AdminId])
  4358. }
  4359. err = xlsxFile.Save(downLoadnFilePath)
  4360. if err != nil {
  4361. fmt.Println(err)
  4362. return
  4363. }
  4364. fmt.Println("end")
  4365. }
  4366. func initart121() {
  4367. //行业
  4368. var condition string
  4369. var pars []interface{}
  4370. condition += ` AND re.chart_permission_id = 22 AND art.publish_date > '2024-12-20' AND art.publish_date < '2025-01-21' `
  4371. //报告匹配类型
  4372. //9.5 13:52
  4373. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
  4374. listart, err := cygx.GetReportArticleList(condition, pars, 0, 2000, 1)
  4375. if err != nil {
  4376. fmt.Println(err)
  4377. return
  4378. }
  4379. fmt.Println("listart", len(listart))
  4380. //创建excel
  4381. dir, err := os.Executable()
  4382. exPath := filepath.Dir(dir)
  4383. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  4384. xlsxFile := xlsx.NewFile()
  4385. if err != nil {
  4386. fmt.Println(err)
  4387. return
  4388. }
  4389. style := xlsx.NewStyle()
  4390. alignment := xlsx.Alignment{
  4391. Horizontal: "center",
  4392. Vertical: "center",
  4393. WrapText: true,
  4394. }
  4395. style.Alignment = alignment
  4396. style.ApplyAlignment = true
  4397. redStyle := xlsx.NewStyle()
  4398. redStyle.Alignment = alignment
  4399. redStyle.ApplyAlignment = true
  4400. redStyle.Font.Color = "ff0000"
  4401. //定义底色需要标黄的 单元格颜色
  4402. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  4403. redStyle.Fill = redFill
  4404. //redStyle.Border = *border
  4405. var sheetName string
  4406. sheetName = "PV"
  4407. sheet, err := xlsxFile.AddSheet(sheetName)
  4408. if err != nil {
  4409. fmt.Println(err)
  4410. return
  4411. }
  4412. //标头
  4413. rowTitle := sheet.AddRow()
  4414. cellAt := rowTitle.AddCell()
  4415. cellAt.Value = "标题"
  4416. cellXl := rowTitle.AddCell()
  4417. cellXl.Value = "系列"
  4418. cellPd := rowTitle.AddCell()
  4419. cellPd.Value = "发布时间"
  4420. cellA := rowTitle.AddCell()
  4421. cellA.Value = "姓名"
  4422. cellB := rowTitle.AddCell()
  4423. cellB.Value = "手机号"
  4424. cellC := rowTitle.AddCell()
  4425. cellC.Value = "公司名称"
  4426. cellD := rowTitle.AddCell()
  4427. cellD.Value = "分类"
  4428. cellDCreatedTime := rowTitle.AddCell()
  4429. cellDCreatedTime.Value = "阅读时间"
  4430. cellE := rowTitle.AddCell()
  4431. cellE.Value = "停留时长"
  4432. cellF := rowTitle.AddCell()
  4433. cellF.Value = "阅读来源"
  4434. for k, v := range listart {
  4435. fmt.Println("kkkk", k)
  4436. articleId := v.ArticleId
  4437. condition = ` AND h.mobile!= '' AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
  4438. listPv, err := cygx.GetArticleHistoryList121(articleId, condition)
  4439. if err != nil {
  4440. fmt.Println(err)
  4441. return
  4442. }
  4443. //var listDate []*cygx.ArticleHistoryRep
  4444. var mobileArr []string
  4445. var companyIds []int
  4446. companyIdsMap := make(map[int]bool)
  4447. mapMobileUser := make(map[string]string)
  4448. for _, vuser := range listPv {
  4449. mobileArr = append(mobileArr, vuser.Mobile)
  4450. if companyIdsMap[vuser.CompanyId] {
  4451. continue
  4452. }
  4453. companyIds = append(companyIds, vuser.CompanyId)
  4454. companyIdsMap[vuser.CompanyId] = true
  4455. }
  4456. listUser, err := models.GetWxUserListByUserMobileHaveCompany(mobileArr)
  4457. if err != nil {
  4458. fmt.Println(err)
  4459. return
  4460. }
  4461. for _, vu := range listUser {
  4462. mapMobileUser[vu.Mobile] = vu.RealName
  4463. }
  4464. //合并合同所对应的权限
  4465. listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyIds)
  4466. if err != nil {
  4467. fmt.Println(err)
  4468. return
  4469. }
  4470. mapIndustryName := make(map[int]string)
  4471. for _, vC := range listCompany {
  4472. mapIndustryName[vC.CompanyId] = vC.IndustryName
  4473. }
  4474. //rowtitle := sheet.AddRow()
  4475. //cellADatatitle := rowtitle.AddCell()
  4476. //cellADatatitle.Value = v.Title
  4477. for _, item := range listPv {
  4478. //if mapIndustryName[item.CompanyId] ==""{
  4479. // continue
  4480. //}
  4481. row := sheet.AddRow()
  4482. cellADatatitle := row.AddCell()
  4483. cellADatatitle.Value = v.Title
  4484. cellXlData := row.AddCell()
  4485. cellXlData.Value = v.SubCategoryName
  4486. cellADataPd := row.AddCell()
  4487. cellADataPd.Value = v.PublishDate
  4488. cellAData := row.AddCell()
  4489. if item.RealName == "" {
  4490. cellAData.Value = mapMobileUser[item.Mobile]
  4491. } else {
  4492. cellAData.Value = item.RealName
  4493. }
  4494. cellBData := row.AddCell()
  4495. cellBData.Value = item.Mobile
  4496. cellCData := row.AddCell()
  4497. cellCData.Value = item.CompanyName
  4498. cellDData := row.AddCell()
  4499. cellDData.Value = mapIndustryName[item.CompanyId]
  4500. cellEData := row.AddCell()
  4501. cellEData.Value = item.CreateTime
  4502. cellFData := row.AddCell()
  4503. cellFData.Value = item.StopTime
  4504. //fmt.Println(item.Source)
  4505. cellLyData := row.AddCell()
  4506. switch item.Source {
  4507. case "MOBILE":
  4508. cellLyData.Value = "小程序"
  4509. case "WEB":
  4510. cellLyData.Value = "网页版"
  4511. case "CELUE":
  4512. cellLyData.Value = "vmp"
  4513. case "PC":
  4514. cellLyData.Value = "小程序"
  4515. }
  4516. }
  4517. err = xlsxFile.Save(downLoadnFilePath)
  4518. if err != nil {
  4519. fmt.Println(err)
  4520. return
  4521. }
  4522. }
  4523. }
  4524. func initart121_1() {
  4525. //行业
  4526. var condition string
  4527. var pars []interface{}
  4528. condition += ` AND re.chart_permission_id = 22 AND art.publish_date > '2023-01-01' AND art.publish_date < '2025-01-01' `
  4529. //报告匹配类型
  4530. //9.5 13:52
  4531. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC `
  4532. listart, err := cygx.GetReportArticleList(condition, pars, 0, 2000, 1)
  4533. if err != nil {
  4534. fmt.Println(err)
  4535. return
  4536. }
  4537. fmt.Println("listart", len(listart))
  4538. //创建excel
  4539. dir, err := os.Executable()
  4540. exPath := filepath.Dir(dir)
  4541. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  4542. xlsxFile := xlsx.NewFile()
  4543. if err != nil {
  4544. fmt.Println(err)
  4545. return
  4546. }
  4547. style := xlsx.NewStyle()
  4548. alignment := xlsx.Alignment{
  4549. Horizontal: "center",
  4550. Vertical: "center",
  4551. WrapText: true,
  4552. }
  4553. style.Alignment = alignment
  4554. style.ApplyAlignment = true
  4555. redStyle := xlsx.NewStyle()
  4556. redStyle.Alignment = alignment
  4557. redStyle.ApplyAlignment = true
  4558. redStyle.Font.Color = "ff0000"
  4559. //定义底色需要标黄的 单元格颜色
  4560. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  4561. redStyle.Fill = redFill
  4562. //redStyle.Border = *border
  4563. var sheetName string
  4564. sheetName = "PV"
  4565. sheet, err := xlsxFile.AddSheet(sheetName)
  4566. if err != nil {
  4567. fmt.Println(err)
  4568. return
  4569. }
  4570. //标头
  4571. rowTitle := sheet.AddRow()
  4572. cellAt := rowTitle.AddCell()
  4573. cellAt.Value = "标题"
  4574. cellXl := rowTitle.AddCell()
  4575. cellXl.Value = "系列"
  4576. cellPd := rowTitle.AddCell()
  4577. cellPd.Value = "发布时间"
  4578. cellA := rowTitle.AddCell()
  4579. cellA.Value = "姓名"
  4580. cellB := rowTitle.AddCell()
  4581. cellB.Value = "手机号"
  4582. cellC := rowTitle.AddCell()
  4583. cellC.Value = "公司名称"
  4584. cellD := rowTitle.AddCell()
  4585. cellD.Value = "分类"
  4586. cellDCreatedTime := rowTitle.AddCell()
  4587. cellDCreatedTime.Value = "阅读时间"
  4588. cellE := rowTitle.AddCell()
  4589. cellE.Value = "停留时长"
  4590. cellF := rowTitle.AddCell()
  4591. cellF.Value = "阅读来源"
  4592. for k, v := range listart {
  4593. fmt.Println("kkkk", k)
  4594. articleId := v.ArticleId
  4595. condition = ` AND h.mobile!= '' AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
  4596. listPv, err := cygx.GetArticleHistoryList121(articleId, condition)
  4597. if err != nil {
  4598. fmt.Println(err)
  4599. return
  4600. }
  4601. mapStopTime := make(map[string]int)
  4602. for _, vP := range listPv {
  4603. StopTime, _ := strconv.Atoi(vP.StopTime)
  4604. mapStopTime[vP.Mobile] += StopTime
  4605. }
  4606. haveMobile := make(map[string]bool)
  4607. //var listDate []*cygx.ArticleHistoryRep
  4608. var mobileArr []string
  4609. var companyIds []int
  4610. companyIdsMap := make(map[int]bool)
  4611. mapMobileUser := make(map[string]string)
  4612. for _, vuser := range listPv {
  4613. mobileArr = append(mobileArr, vuser.Mobile)
  4614. if companyIdsMap[vuser.CompanyId] {
  4615. continue
  4616. }
  4617. companyIds = append(companyIds, vuser.CompanyId)
  4618. companyIdsMap[vuser.CompanyId] = true
  4619. }
  4620. listUser, err := models.GetWxUserListByUserMobileHaveCompany(mobileArr)
  4621. if err != nil {
  4622. fmt.Println(err)
  4623. return
  4624. }
  4625. for _, vu := range listUser {
  4626. mapMobileUser[vu.Mobile] = vu.RealName
  4627. }
  4628. //合并合同所对应的权限
  4629. listCompany, err := company.GetCompanyProductsByCompanyIdsAndProductIdinit(companyIds)
  4630. if err != nil {
  4631. fmt.Println(err)
  4632. return
  4633. }
  4634. mapIndustryName := make(map[int]string)
  4635. for _, vC := range listCompany {
  4636. mapIndustryName[vC.CompanyId] = vC.IndustryName
  4637. }
  4638. //rowtitle := sheet.AddRow()
  4639. //cellADatatitle := rowtitle.AddCell()
  4640. //cellADatatitle.Value = v.Title
  4641. for _, item := range listPv {
  4642. //if mapIndustryName[item.CompanyId] ==""{
  4643. // continue
  4644. //}
  4645. if haveMobile[item.Mobile] {
  4646. continue
  4647. }
  4648. haveMobile[item.Mobile] = true
  4649. row := sheet.AddRow()
  4650. cellADatatitle := row.AddCell()
  4651. cellADatatitle.Value = v.Title
  4652. cellXlData := row.AddCell()
  4653. cellXlData.Value = v.SubCategoryName
  4654. cellADataPd := row.AddCell()
  4655. cellADataPd.Value = v.PublishDate
  4656. cellAData := row.AddCell()
  4657. if item.RealName == "" {
  4658. cellAData.Value = mapMobileUser[item.Mobile]
  4659. } else {
  4660. cellAData.Value = item.RealName
  4661. }
  4662. cellBData := row.AddCell()
  4663. cellBData.Value = item.Mobile
  4664. cellCData := row.AddCell()
  4665. cellCData.Value = item.CompanyName
  4666. cellDData := row.AddCell()
  4667. cellDData.Value = mapIndustryName[item.CompanyId]
  4668. cellEData := row.AddCell()
  4669. cellEData.Value = item.CreateTime
  4670. cellFData := row.AddCell()
  4671. cellFData.Value = strconv.Itoa(mapStopTime[item.Mobile])
  4672. //fmt.Println(item.Source)
  4673. cellLyData := row.AddCell()
  4674. switch item.Source {
  4675. case "MOBILE":
  4676. cellLyData.Value = "小程序"
  4677. case "WEB":
  4678. cellLyData.Value = "网页版"
  4679. case "CELUE":
  4680. cellLyData.Value = "vmp"
  4681. case "PC":
  4682. cellLyData.Value = "小程序"
  4683. }
  4684. }
  4685. err = xlsxFile.Save(downLoadnFilePath)
  4686. if err != nil {
  4687. fmt.Println(err)
  4688. return
  4689. }
  4690. }
  4691. }