contract_allocation.go 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  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/contract"
  11. "hongze/hz_crm_api/models/cygx"
  12. "hongze/hz_crm_api/models/system"
  13. cygxService "hongze/hz_crm_api/services/cygx"
  14. "hongze/hz_crm_api/utils"
  15. "os"
  16. "path/filepath"
  17. "strconv"
  18. "strings"
  19. "time"
  20. )
  21. // ContractAllocationController 权益合同派单
  22. type ContractAllocationController struct {
  23. controllers.BaseAuthController
  24. }
  25. // getQueryParams 获取基础查询信息
  26. func getQueryParams(condition string, pars []interface{}, sysUser *system.Admin, tableAlias string) (newCondition string, newPars []interface{}) {
  27. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  28. condition += " AND " + tableAlias + "product_id=?"
  29. pars = append(pars, 1)
  30. } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  31. condition += " AND " + tableAlias + "product_id=?"
  32. pars = append(pars, 2)
  33. } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FINANCE {
  34. //超级管理员账户,不做条件限制
  35. } else {
  36. //如果不是研究员,那么去找对应的 部门、小组、销售
  37. if sysUser.Authority == 0 {
  38. //普通用户
  39. condition += " AND " + tableAlias + "seller_id=?"
  40. pars = append(pars, sysUser.AdminId)
  41. } else if sysUser.Authority == 1 {
  42. //部门主管
  43. condition += " AND " + tableAlias + "department_id=?"
  44. pars = append(pars, sysUser.DepartmentId)
  45. } else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  46. //权益小组负责人
  47. condition += " AND " + tableAlias + "group_id=?"
  48. pars = append(pars, sysUser.GroupId)
  49. } else if sysUser.Authority == 2 && sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  50. //ficc销售主管
  51. pid, err := company.GetParentIdFromGroup(sysUser.GroupId)
  52. if err != nil {
  53. fmt.Println(err.Error())
  54. return
  55. }
  56. var ids []*string
  57. if pid != nil && *pid != 0 {
  58. ids, err = company.GetGroupIdsByParentId(*pid)
  59. if err != nil {
  60. fmt.Println(err.Error())
  61. }
  62. } else {
  63. ids, err = company.GetGroupIdsByParentId(sysUser.GroupId)
  64. if err != nil {
  65. fmt.Println(err.Error())
  66. }
  67. }
  68. var idSlice []string
  69. var sid string
  70. for _, id := range ids {
  71. idSlice = append(idSlice, *id)
  72. }
  73. //加入父级groupId
  74. if *pid > 0 {
  75. idSlice = append(idSlice, strconv.Itoa(*pid))
  76. } else {
  77. idSlice = append(idSlice, strconv.Itoa(sysUser.GroupId))
  78. }
  79. sid = strings.Join(idSlice, ",")
  80. condition += " AND " + tableAlias + `group_id IN (` + sid + `) `
  81. fmt.Println("condition:", condition)
  82. //pars = append(pars, sysUser.GroupId)
  83. } else if sysUser.Authority == 4 {
  84. //ficc小组负责人
  85. condition += " AND " + tableAlias + "group_id=?"
  86. pars = append(pars, sysUser.GroupId)
  87. } else {
  88. //不知道什么类型的用户(后面新增的位置类型客户)
  89. condition += " AND " + tableAlias + "seller_id=?"
  90. pars = append(pars, sysUser.AdminId)
  91. }
  92. }
  93. newCondition = condition
  94. newPars = pars
  95. return
  96. }
  97. // @Title 合同列表
  98. // @Description 合同列表接口
  99. // @Param PageSize query int true "每页数据条数"
  100. // @Param CurrentIndex query int true "当前页页码,从1开始"
  101. // @Param Keyword query string true "客户名称"
  102. // @Param AdminId query string true "销售id,多个用英文逗号隔开,空字符串为全部"
  103. // @Param StartDate query string false "开始日期"
  104. // @Param EndDate query string false "结束日期"
  105. // @Param ContractType query string false "合同类型,枚举值:“,`新签合同`,`续约合同`,`补充协议`"
  106. // @Param FormalType query string false "转正类型,枚举值:“,`标准`,`非标`"
  107. // @Param IsExport query bool false "是否导出excel,默认是false"
  108. // @Param ResearcherRealName query string false "研究员姓名"
  109. // @Param IsAllocation query int false "派点状态: -1-默认全部; 0-未派点; 1-已派点"
  110. // @Success 200 {object} cygx.CompanyContractListResp
  111. // @router /allocation/company_contract_list [get]
  112. func (this *ContractAllocationController) CompanyContractList() {
  113. br := new(models.BaseResponse).Init()
  114. defer func() {
  115. this.Data["json"] = br
  116. this.ServeJSON()
  117. }()
  118. sysUser := this.SysUser
  119. if sysUser == nil {
  120. br.Msg = "请登录"
  121. br.ErrMsg = "请登录,SysUser Is Empty"
  122. br.Ret = 408
  123. return
  124. }
  125. pageSize, _ := this.GetInt("PageSize")
  126. currentIndex, _ := this.GetInt("CurrentIndex")
  127. adminId := this.GetString("AdminId")
  128. formalType := this.GetString("FormalType")
  129. contractType := this.GetString("ContractType")
  130. keyword := this.GetString("Keyword")
  131. startDate := this.GetString("StartDate")
  132. endDate := this.GetString("EndDate")
  133. researcherRealName := this.GetString("ResearcherRealName")
  134. isAllocation, _ := this.GetInt("IsAllocation", -1) // CRM 13.9
  135. if startDate == "" {
  136. startDate = "2015-01-01"
  137. }
  138. if endDate == "" {
  139. endDate = time.Now().Format(utils.FormatDate)
  140. }
  141. var startSize int
  142. if pageSize <= 0 {
  143. pageSize = utils.PageSize20
  144. }
  145. if currentIndex <= 0 {
  146. currentIndex = 1
  147. }
  148. startSize = utils.StartIndex(currentIndex, pageSize)
  149. //是否导出报表
  150. isExport, _ := this.GetBool("IsExport")
  151. if isExport {
  152. pageSize = 10000
  153. currentIndex = 1
  154. }
  155. var condition string
  156. var pars []interface{}
  157. //条件
  158. if adminId != "" {
  159. condition += ` AND c.seller_id in (` + adminId + `) `
  160. //pars = append(pars, adminId)
  161. } else {
  162. //权益申请销售只能看到自己名下的客户的申请
  163. companyIds, err := cygxService.GetAdminLookUserCompanyIdsBySelf(sysUser)
  164. if err != nil {
  165. br.Msg = "获取失败"
  166. br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
  167. return
  168. }
  169. lencompanyIds := len(companyIds)
  170. if lencompanyIds > 0 {
  171. condition += ` AND c.company_id IN (` + utils.GetOrmInReplace(lencompanyIds) + `)`
  172. pars = append(pars, companyIds)
  173. }
  174. ////根据当前角色来获取查询条件
  175. //condition, pars = getQueryParams(condition, pars, sysUser, "c.")
  176. }
  177. //关键字搜索
  178. if keyword != "" {
  179. condition += ` and b.company_name like "%` + keyword + `%" `
  180. }
  181. //是否派点
  182. if isAllocation != -1 {
  183. condition += ` AND a.product_id = ? `
  184. pars = append(pars, isAllocation)
  185. }
  186. // 标准非标查询
  187. switch formalType {
  188. case "标准":
  189. condition += ` AND a.source = ? `
  190. pars = append(pars, "系统合同")
  191. case "非标":
  192. condition += ` AND a.source = ? `
  193. pars = append(pars, "上传附件")
  194. }
  195. if contractType != "" {
  196. condition += ` AND a.contract_type = ? `
  197. pars = append(pars, contractType)
  198. }
  199. //默认只查询权益 2023-06-01 之后的合同
  200. condition += ` AND c.product_id = ? AND a.start_date > ? `
  201. pars = append(pars, 2, "2023-06-01")
  202. mapMoneyPoint := make(map[int]float64)
  203. //研究员姓名查询
  204. if researcherRealName != "" {
  205. var conditionAllocation string
  206. var parsAllocation []interface{}
  207. conditionAllocation = " AND real_name = ? "
  208. parsAllocation = append(parsAllocation, researcherRealName)
  209. allocationCompanyContractList, err := cygx.GetCygxAllocationCompanyContractList(conditionAllocation, parsAllocation)
  210. if err != nil {
  211. br.Msg = "获取失败"
  212. br.ErrMsg = "获取失败,GetCygxAllocationCompanyContractListErr:" + err.Error()
  213. return
  214. }
  215. var companyContractIds []int
  216. for _, v := range allocationCompanyContractList {
  217. companyContractIds = append(companyContractIds, v.CompanyContractId)
  218. mapMoneyPoint[v.CompanyContractId] = v.Money
  219. }
  220. lenCon := len(companyContractIds)
  221. if lenCon == 0 {
  222. condition += ` AND a.company_contract_id = 0 `
  223. } else {
  224. condition += ` AND a.company_contract_id IN (` + utils.GetOrmInReplace(lenCon) + `)`
  225. pars = append(pars, companyContractIds)
  226. }
  227. }
  228. var list []*cygx.CompanyContractResp
  229. total, err := cygx.GetCompanyContractCountJoinCompany(condition, pars)
  230. if err != nil && err.Error() != utils.ErrNoRow() {
  231. br.Msg = "获取失败"
  232. br.ErrMsg = "获取失败,Err:" + err.Error()
  233. return
  234. }
  235. //列表页数据
  236. list, err = cygx.GetCompanyContractListJoinCompany(condition, pars, startSize, pageSize)
  237. if err != nil {
  238. br.Msg = "获取失败"
  239. br.ErrMsg = "获取失败,Err:" + err.Error()
  240. return
  241. }
  242. mapCompamy := make(map[int]string)
  243. listLen := len(list)
  244. if listLen == 0 {
  245. list = make([]*cygx.CompanyContractResp, 0)
  246. } else {
  247. var contractCodes []string
  248. var companyContractIds []int
  249. for _, v := range list {
  250. switch v.Source {
  251. case "系统合同":
  252. v.FormalType = "标准"
  253. case "上传附件":
  254. v.FormalType = "非标"
  255. }
  256. contractCodes = append(contractCodes, v.ContractCode)
  257. companyContractIds = append(companyContractIds, v.CompanyContractId)
  258. mapCompamy[v.CompanyId] = strconv.Itoa(v.CompanyContractId)
  259. }
  260. lencontractCodes := len(contractCodes)
  261. if lencontractCodes > 0 {
  262. //获取标准合同的ID,这里上面的查询已经关联了三张表,拆分吧。。。
  263. condition = ""
  264. joinStr := ""
  265. pars = make([]interface{}, 0)
  266. condition = " AND a.contract_code IN (" + utils.GetOrmInReplace(lencontractCodes) + ") "
  267. pars = append(pars, contractCodes)
  268. listContract, err := contract.GetContractList(condition, joinStr, pars, 0, lencontractCodes)
  269. if err != nil {
  270. br.Msg = "获取合同列表失败!"
  271. br.ErrMsg = "获取合同列表失败,Err:" + err.Error()
  272. return
  273. }
  274. mapContractCode := make(map[string]int)
  275. for _, v := range listContract {
  276. mapContractCode[v.ContractCode] = v.ContractId
  277. }
  278. mapIsGray, err := cygxService.GetMapIsGrayByCompanyContractIds(companyContractIds)
  279. if err != nil {
  280. br.Msg = "获取合同列表失败!"
  281. br.ErrMsg = "获取合同列表失败,GetMapIsGrayByCompanyContractIds Err:" + err.Error()
  282. return
  283. }
  284. //合并合同所对应的权限
  285. mappermissionName, err := cygxService.GetCompanyContractPermissionNameMapById(mapCompamy)
  286. if err != nil {
  287. br.Msg = "获取失败"
  288. br.ErrMsg = "获取失败,Err:" + err.Error()
  289. return
  290. }
  291. for _, v := range list {
  292. v.ContractId = mapContractCode[v.ContractCode]
  293. v.MoneyPoint = mapMoneyPoint[v.CompanyContractId]
  294. v.PermissionName = mappermissionName[v.CompanyId]
  295. v.IsGray = mapIsGray[v.CompanyContractId]
  296. }
  297. }
  298. }
  299. page := paging.GetPaging(currentIndex, pageSize, total)
  300. resp := cygx.CompanyContractListResp{
  301. Paging: page,
  302. List: list,
  303. }
  304. //导出excel
  305. if isExport {
  306. CompanyContractListExport(this, resp, br)
  307. return
  308. }
  309. br.Ret = 200
  310. br.Success = true
  311. br.Msg = "获取成功"
  312. br.Data = resp
  313. }
  314. // CompanyContractListExport 导出Excel
  315. func CompanyContractListExport(this *ContractAllocationController, resp cygx.CompanyContractListResp, br *models.BaseResponse) {
  316. dir, err := os.Executable()
  317. exPath := filepath.Dir(dir)
  318. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  319. xlsxFile := xlsx.NewFile()
  320. if err != nil {
  321. br.Msg = "生成文件失败"
  322. br.ErrMsg = "生成文件失败"
  323. return
  324. }
  325. style := xlsx.NewStyle()
  326. alignment := xlsx.Alignment{
  327. Horizontal: "center",
  328. Vertical: "center",
  329. WrapText: true,
  330. }
  331. style.Alignment = alignment
  332. style.ApplyAlignment = true
  333. sheel, err := xlsxFile.AddSheet("派点导出数据")
  334. if err != nil {
  335. br.Msg = "新增Sheet失败"
  336. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  337. return
  338. }
  339. sheel.SetColWidth(0, 0, 30)
  340. sheel.SetColWidth(1, 1, 15)
  341. sheel.SetColWidth(2, 2, 15)
  342. sheel.SetColWidth(3, 3, 18)
  343. titleRow := sheel.AddRow()
  344. cellA := titleRow.AddCell()
  345. cellA.SetStyle(style)
  346. cellA.SetValue("合同编号")
  347. cellB := titleRow.AddCell()
  348. cellB.SetStyle(style)
  349. cellB.SetValue("转正类型")
  350. cellC := titleRow.AddCell()
  351. cellC.SetStyle(style)
  352. cellC.SetValue("合同类型")
  353. cellD := titleRow.AddCell()
  354. cellD.SetStyle(style)
  355. cellD.SetValue("公司名称")
  356. cellE := titleRow.AddCell()
  357. cellE.SetStyle(style)
  358. cellE.SetValue("所属销售")
  359. cellF := titleRow.AddCell()
  360. cellF.SetStyle(style)
  361. cellF.SetValue("合同金额")
  362. cellG := titleRow.AddCell()
  363. cellG.SetStyle(style)
  364. cellG.SetValue("合同期限")
  365. cellH := titleRow.AddCell()
  366. cellH.SetStyle(style)
  367. cellH.SetValue("签约套餐")
  368. cellI := titleRow.AddCell()
  369. cellI.SetStyle(style)
  370. cellI.SetValue("状态")
  371. for _, v := range resp.List {
  372. dataRow := sheel.AddRow()
  373. dataRow.SetHeight(20)
  374. cellA := dataRow.AddCell()
  375. cellA.SetStyle(style)
  376. cellA.SetValue(v.ContractCode)
  377. cellB := dataRow.AddCell()
  378. cellB.SetStyle(style)
  379. cellB.SetValue(v.FormalType)
  380. cellC := dataRow.AddCell()
  381. cellC.SetStyle(style)
  382. cellC.SetValue(v.ContractType)
  383. cellD := dataRow.AddCell()
  384. cellD.SetStyle(style)
  385. cellD.SetValue(v.CompanyName)
  386. cellE := dataRow.AddCell()
  387. cellE.SetStyle(style)
  388. cellE.SetValue(v.SellerName)
  389. cellF := dataRow.AddCell()
  390. cellF.SetStyle(style)
  391. cellF.SetValue(v.Money)
  392. cellG := dataRow.AddCell()
  393. cellG.SetStyle(style)
  394. cellG.SetValue(fmt.Sprint(v.StartDate, " ~ ", v.EndDate))
  395. cellH := dataRow.AddCell()
  396. cellH.SetStyle(style)
  397. cellH.SetValue(v.PermissionName)
  398. cellI := dataRow.AddCell()
  399. cellI.SetStyle(style)
  400. if v.IsAllocation == 1 {
  401. cellI.SetValue("已派点")
  402. } else {
  403. cellI.SetValue("未派点")
  404. }
  405. }
  406. err = xlsxFile.Save(downLoadnFilePath)
  407. if err != nil {
  408. br.Msg = "保存文件失败"
  409. br.ErrMsg = "保存文件失败"
  410. return
  411. }
  412. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  413. downloadFileName := "派点导出数据_" + randStr + ".xlsx"
  414. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  415. defer func() {
  416. os.Remove(downLoadnFilePath)
  417. }()
  418. br.Ret = 200
  419. br.Success = true
  420. br.Msg = "导出成功"
  421. }
  422. // @Title 详情
  423. // @Description 获取详情接口
  424. // @Param CompanyContractId query int true "ID"
  425. // @Param ShowDetail query bool false "是否是派点详情展示"
  426. // @Success Ret=200 {object} cygx.CygxAllocationCompanyContractDetailResp
  427. // @router /allocation/detail [get]
  428. func (this *ContractAllocationController) CompanyContracDetail() {
  429. br := new(models.BaseResponse).Init()
  430. defer func() {
  431. this.Data["json"] = br
  432. this.ServeJSON()
  433. }()
  434. AdminUser := this.SysUser
  435. if AdminUser == nil {
  436. br.Msg = "请登录"
  437. br.ErrMsg = "请登录,用户信息为空"
  438. br.Ret = 408
  439. return
  440. }
  441. resp := new(cygx.CygxAllocationCompanyContractDetailResp)
  442. companyContractId, _ := this.GetInt("CompanyContractId")
  443. if companyContractId < 1 {
  444. br.Msg = "请输入详情ID"
  445. return
  446. }
  447. showDetail, _ := this.GetBool("ShowDetail", false)
  448. contractItem, err := company.GetCompanyContractById(companyContractId)
  449. if err != nil {
  450. br.Msg = "获取信息失败"
  451. br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
  452. return
  453. }
  454. total, err := cygx.GetCygxAllocationCompanyContractCountByCompanyContractId(companyContractId)
  455. if err != nil {
  456. br.Msg = "获取信息失败"
  457. br.ErrMsg = "获取合同信息失败,GetCygxAllocationCompanyContractCountByCompanyContractId Err:" + err.Error()
  458. return
  459. }
  460. //var contractPermissionList []*company.ContractPermissionList
  461. expMap := map[int]string{0: "(3w)", 1: "(5w)"} // 买方研选价格
  462. //classifyName := "权益"
  463. //plist := new(company.ContractPermissionList)
  464. hasPermissions, e := company.GetCompanyContractPermissionByCompanyContractId(companyContractId)
  465. if e != nil {
  466. br.Msg = "获取失败"
  467. br.ErrMsg = "获取合同权限信息失败,Err:" + e.Error()
  468. return
  469. }
  470. hasMap := make(map[int]*company.CompanyContractPermission)
  471. for _, p := range hasPermissions {
  472. hasMap[p.ChartPermissionId] = p
  473. }
  474. checkItems := make([]*company.PermissionLookItem, 0)
  475. raiPermissions, e := company.GetPermissionLookItemsExt("2", utils.COMPANY_PRODUCT_RAI_NAME)
  476. if e != nil {
  477. br.Msg = "获取失败"
  478. br.ErrMsg = "获取权益权限列表失败, Err: " + e.Error()
  479. return
  480. }
  481. mapPermissionNameHave := make(map[string]bool) // 判断合同是否存在某一行业权限种类
  482. var expensiveYx int
  483. for _, n := range raiPermissions {
  484. match := hasMap[n.ChartPermissionId]
  485. if match == nil {
  486. continue
  487. }
  488. // 升级
  489. if match.IsUpgrade == 1 {
  490. n.IsUpgrade = 1
  491. checkItems = append(checkItems, n)
  492. continue
  493. }
  494. mapPermissionNameHave[n.PermissionName] = true
  495. // 买方研选(3w/5w)
  496. if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  497. expensiveYx = match.ExpensiveYx
  498. n.PermissionName += expMap[match.ExpensiveYx]
  499. checkItems = append(checkItems, n)
  500. continue
  501. }
  502. checkItems = append(checkItems, n)
  503. }
  504. resp.Money = contractItem.Money / 10000
  505. //有研选时,对研选套餐类型做文案处理
  506. respItemYx := new(cygx.AllocationPermissionListResp)
  507. if mapPermissionNameHave[utils.CHART_PERMISSION_NAME_MF_YANXUAN] {
  508. var moneyYx float64
  509. if expensiveYx == 0 {
  510. moneyYx = 3
  511. }
  512. if expensiveYx == 1 {
  513. moneyYx = 5
  514. }
  515. resp.TotalPointsContent = fmt.Sprint(resp.Money, "W,", "其中", moneyYx, "w默认归属买方研选,请对剩余", resp.Money-moneyYx, "w按照100%进行比值分配")
  516. if showDetail {
  517. resp.TotalPointsContent = fmt.Sprint(resp.Money, "W")
  518. }
  519. resp.Money = resp.Money - moneyYx
  520. respItemYx.Proportion = moneyYx
  521. respItemYx.ChartPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
  522. respItemYx.List = append(respItemYx.List, &cygx.AllocationRealNameListResp{utils.CHART_PERMISSION_NAME_MF_YANXUAN, 0, moneyYx})
  523. } else {
  524. resp.TotalPointsContent = fmt.Sprint(resp.Money, "W")
  525. }
  526. sysUserList, err := cygx.GetAskEmailList()
  527. if err != nil {
  528. br.Msg = "获取失败"
  529. br.ErrMsg = "获取失败,GetAskEmailList Err: " + err.Error()
  530. return
  531. }
  532. mapPermissionUser := make(map[string][]*cygx.AllocationRealNameListResp)
  533. var respList []*cygx.AllocationPermissionListResp
  534. if total == 0 {
  535. for _, v := range sysUserList {
  536. if !mapPermissionNameHave[v.ChartPermissionName] {
  537. continue
  538. }
  539. item := new(cygx.AllocationRealNameListResp)
  540. item.RealName = v.Name
  541. mapPermissionUser[v.ChartPermissionName] = append(mapPermissionUser[v.ChartPermissionName], item)
  542. }
  543. for k, v := range mapPermissionUser {
  544. respItem := new(cygx.AllocationPermissionListResp)
  545. respItem.ChartPermissionName = k
  546. respItem.List = v
  547. respList = append(respList, respItem)
  548. }
  549. if respItemYx.ChartPermissionName != "" {
  550. respList = append(respList, respItemYx)
  551. }
  552. } else {
  553. listUser, err := cygx.GetCygxAllocationCompanyContractListById(companyContractId)
  554. if err != nil {
  555. br.Msg = "获取失败"
  556. br.ErrMsg = "获取失败,GetCygxAllocationCompanyContractListById Err: " + err.Error()
  557. return
  558. }
  559. for _, v := range listUser {
  560. if showDetail && v.Money == 0 {
  561. continue
  562. }
  563. item := new(cygx.AllocationRealNameListResp)
  564. item.RealName = v.RealName
  565. item.Money = v.Money
  566. item.Proportion = v.Proportion
  567. mapPermissionUser[v.ChartPermissionName] = append(mapPermissionUser[v.ChartPermissionName], item)
  568. }
  569. listPermission, err := cygx.GetCygxAllocationCompanyContractPermissionListById(companyContractId)
  570. if err != nil {
  571. br.Msg = "获取失败"
  572. br.ErrMsg = "获取失败,GetCygxAllocationCompanyContractPermissionListById Err: " + err.Error()
  573. return
  574. }
  575. for _, v := range listPermission {
  576. if showDetail && v.Money == 0 {
  577. continue
  578. }
  579. respItem := new(cygx.AllocationPermissionListResp)
  580. respItem.ChartPermissionName = v.ChartPermissionName
  581. respItem.Money = v.Money
  582. respItem.Proportion = v.Proportion
  583. respItem.List = mapPermissionUser[v.ChartPermissionName]
  584. respList = append(respList, respItem)
  585. }
  586. }
  587. //处理是否置灰
  588. mapIsGray, err := cygxService.GetMapIsGrayByCompanyContractIds([]int{companyContractId})
  589. if err != nil {
  590. br.Msg = "获取合同列表失败!"
  591. br.ErrMsg = "获取合同列表失败,GetMapIsGrayByCompanyContractIds Err:" + err.Error()
  592. return
  593. }
  594. resp.IsGray = mapIsGray[companyContractId]
  595. resp.List = respList
  596. resp.CompanyContractId = companyContractId
  597. br.Ret = 200
  598. br.Success = true
  599. br.Msg = "获取成功"
  600. br.Data = resp
  601. }
  602. // @Title 更新派点
  603. // @Description 更新派点接口
  604. // @Param request body cygx.AddProductInteriorReq true "type json string"
  605. // @Success 200 {object} "保存成功"
  606. // @router /allocation/update [post]
  607. func (this *ContractAllocationController) CompanyContracUpdate() {
  608. br := new(models.BaseResponse).Init()
  609. defer func() {
  610. this.Data["json"] = br
  611. this.ServeJSON()
  612. }()
  613. sysUser := this.SysUser
  614. if sysUser == nil {
  615. br.Msg = "请登录"
  616. br.ErrMsg = "请登录,SysUser Is Empty"
  617. br.Ret = 408
  618. return
  619. }
  620. var req cygx.UpdateAllocationCompanyContractReq
  621. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  622. if err != nil {
  623. br.Msg = "参数解析异常!"
  624. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  625. return
  626. }
  627. companyContractId := req.CompanyContractId
  628. if companyContractId == 0 {
  629. br.Msg = "参数错误"
  630. br.ErrMsg = "参数错误,id不可为空"
  631. return
  632. }
  633. mapIsGray, err := cygxService.GetMapIsGrayByCompanyContractIds([]int{companyContractId})
  634. if err != nil {
  635. br.Msg = "获取合同列表失败!"
  636. br.ErrMsg = "获取合同列表失败,GetMapIsGrayByCompanyContractIds Err:" + err.Error()
  637. return
  638. }
  639. if mapIsGray[companyContractId] {
  640. br.Msg = "超过90天,无法修改!"
  641. br.ErrMsg = "超过90天,无法修改,companyContractId :" + strconv.Itoa(companyContractId)
  642. return
  643. }
  644. contractItem, err := company.GetCompanyContractById(companyContractId)
  645. if err != nil {
  646. br.Msg = "获取信息失败"
  647. br.ErrMsg = "获取合同信息失败,Err:" + err.Error()
  648. return
  649. }
  650. money := contractItem.Money / 10000 // 合同金额,万为单位
  651. var moneyAvg float64 // 行业所占合同的平均金额
  652. hasPermissions, e := company.GetCompanyContractPermissionByCompanyContractId(companyContractId)
  653. if e != nil {
  654. br.Msg = "获取失败"
  655. br.ErrMsg = "获取合同权限信息失败,Err:" + e.Error()
  656. return
  657. }
  658. hasMap := make(map[int]*company.CompanyContractPermission)
  659. for _, p := range hasPermissions {
  660. hasMap[p.ChartPermissionId] = p
  661. }
  662. raiPermissions, e := company.GetPermissionLookItemsExt("2", utils.COMPANY_PRODUCT_RAI_NAME)
  663. if e != nil {
  664. br.Msg = "获取失败"
  665. br.ErrMsg = "获取权益权限列表失败, Err: " + e.Error()
  666. return
  667. }
  668. mapPermissionNameHave := make(map[string]bool) // 判断合同是否存在某一行业权限种类
  669. for _, n := range raiPermissions {
  670. //只计算,医药、消费、科技、智造、策略、买方研选的
  671. if n.PermissionName != utils.YI_YAO_NAME && n.PermissionName != utils.XIAO_FEI_NAME && n.PermissionName != utils.KE_JI_NAME && n.PermissionName != utils.ZHI_ZAO_NAME && n.PermissionName != utils.CE_LUE_NAME && n.PermissionName != utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  672. continue
  673. }
  674. match := hasMap[n.ChartPermissionId]
  675. if match == nil {
  676. continue
  677. }
  678. mapPermissionNameHave[n.PermissionName] = true
  679. // 买方研选(3w/5w)
  680. if n.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  681. if match.ExpensiveYx == 1 {
  682. money = money - 5
  683. } else {
  684. money = money - 3
  685. }
  686. }
  687. }
  688. if len(mapPermissionNameHave) > 0 {
  689. moneyAvg = money / float64(len(mapPermissionNameHave))
  690. }
  691. list := req.List
  692. var items []*cygx.CygxAllocationCompanyContract
  693. var itemsPermission []*cygx.CygxAllocationCompanyContractPermission
  694. var proportionSum float64 // 校验前端传过来的占比使用
  695. for _, v := range list {
  696. itemPermission := new(cygx.CygxAllocationCompanyContractPermission)
  697. itemPermission.CompanyContractId = companyContractId
  698. itemPermission.AdminId = sysUser.AdminId
  699. itemPermission.AdminName = sysUser.RealName
  700. itemPermission.Proportion = v.Proportion
  701. itemPermission.Money = v.Money
  702. itemPermission.MoneyAvg = moneyAvg
  703. itemPermission.ChartPermissionName = v.ChartPermissionName
  704. itemPermission.CreateTime = time.Now()
  705. itemPermission.ModifyTime = time.Now()
  706. itemsPermission = append(itemsPermission, itemPermission)
  707. for _, v2 := range v.List {
  708. item := new(cygx.CygxAllocationCompanyContract)
  709. item.CompanyContractId = companyContractId
  710. item.AdminId = sysUser.AdminId
  711. item.AdminName = sysUser.RealName
  712. item.Proportion = v2.Proportion
  713. item.Money = v2.Money
  714. item.RealName = v2.RealName
  715. item.ChartPermissionName = v.ChartPermissionName
  716. item.CreateTime = time.Now()
  717. item.ModifyTime = time.Now()
  718. items = append(items, item)
  719. }
  720. if v.ChartPermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  721. continue
  722. }
  723. proportionSum += v.Proportion
  724. }
  725. if proportionSum > 100.5 || proportionSum < 99.5 {
  726. br.Msg = "操作失败,派点填写信息错误"
  727. br.ErrMsg = "获取合同信息失败,Err:" + fmt.Sprint(proportionSum)
  728. return
  729. }
  730. err = cygx.AddAndUpdateCygxAllocationCompanyContract(items, itemsPermission, companyContractId)
  731. if err != nil {
  732. br.Msg = "操作失败"
  733. br.ErrMsg = "操作失败,AddAndUpdateCygxAllocationCompanyContract Err:" + err.Error()
  734. return
  735. }
  736. br.Ret = 200
  737. br.Success = true
  738. br.IsAddLog = true
  739. br.Msg = "操作成功"
  740. }
  741. // @Title 研究员派点统计
  742. // @Description 研究员派点统计接口
  743. // @Param PageSize query int true "每页数据条数"
  744. // @Param CurrentIndex query int true "当前页页码,从1开始"
  745. // @Param Keyword query string true "客户名称"
  746. // @Param StartDate query string false "开始日期"
  747. // @Param EndDate query string false "结束日期"
  748. // @Param IsExport query bool false "是否导出excel,默认是false"
  749. // @Success 200 {object} cygx.CompanyContractListResp
  750. // @router /allocation/statistics [get]
  751. func (this *ContractAllocationController) CompanyContractStatistics() {
  752. br := new(models.BaseResponse).Init()
  753. defer func() {
  754. this.Data["json"] = br
  755. this.ServeJSON()
  756. }()
  757. sysUser := this.SysUser
  758. if sysUser == nil {
  759. br.Msg = "请登录"
  760. br.ErrMsg = "请登录,SysUser Is Empty"
  761. br.Ret = 408
  762. return
  763. }
  764. keyword := this.GetString("Keyword")
  765. startDate := this.GetString("StartDate")
  766. endDate := this.GetString("EndDate")
  767. if startDate == "" {
  768. startDate = "2015-01-01"
  769. }
  770. if endDate == "" {
  771. endDate = time.Now().Format(utils.FormatDate)
  772. }
  773. //是否导出报表
  774. isExport, _ := this.GetBool("IsExport")
  775. var condition string
  776. var pars []interface{}
  777. //根据当前角色来获取查询条件
  778. condition, pars = getQueryParams(condition, pars, sysUser, "c.")
  779. companyIds, err := cygxService.GetAdminLookUserCompanyIdsBySelf(sysUser)
  780. if err != nil {
  781. br.Msg = "获取失败"
  782. br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
  783. return
  784. }
  785. lencompanyIds := len(companyIds)
  786. if lencompanyIds > 0 {
  787. condition += ` AND c.company_id IN (` + utils.GetOrmInReplace(lencompanyIds) + `)`
  788. pars = append(pars, companyIds)
  789. }
  790. //关键字搜索
  791. if keyword != "" {
  792. condition += ` and b.company_name like "%` + keyword + `%" `
  793. }
  794. //默认只查询权益 2023-06-01 之后的合同
  795. condition += ` AND c.product_id = ? AND a.start_date > ? `
  796. pars = append(pars, 2, "2023-01-01")
  797. //列表页数据
  798. listContract, err := cygx.GetCompanyContractListJoinCompany(condition, pars, 0, 1000)
  799. if err != nil {
  800. br.Msg = "获取失败"
  801. br.ErrMsg = "获取失败,Err:" + err.Error()
  802. return
  803. }
  804. var companyContractIds []int
  805. for _, v := range listContract {
  806. companyContractIds = append(companyContractIds, v.CompanyContractId)
  807. }
  808. lenArr := len(companyContractIds)
  809. mapUserAllocation := make(map[string]float64) // 关联合同
  810. mapUserMoney := make(map[string]float64) // 派点金额
  811. mapPermissionAllocation := make(map[string]float64)
  812. mapPermissionMoney := make(map[string]float64)
  813. mapPermissionMoneyAvg := make(map[string]float64)
  814. totalContract := lenArr //所有的关联合同
  815. var totalMoney float64 //所有的关联合同的金额 单位万
  816. if lenArr > 0 {
  817. var conditionAllocation string
  818. var parsAllocation []interface{}
  819. conditionAllocation = ` AND company_contract_id IN(` + utils.GetOrmInReplace(lenArr) + ` ) `
  820. parsAllocation = append(parsAllocation, companyContractIds)
  821. allocationCompanyContractList, err := cygx.GetCygxAllocationCompanyContractList(conditionAllocation, parsAllocation)
  822. if err != nil {
  823. br.Msg = "获取失败"
  824. br.ErrMsg = "获取失败,Err:" + err.Error()
  825. return
  826. }
  827. allocationCompanyContractPermissionList, err := cygx.GetCygxAllocationCompanyContractPermissionList(conditionAllocation, parsAllocation)
  828. if err != nil {
  829. br.Msg = "获取失败"
  830. br.ErrMsg = "获取失败,Err:" + err.Error()
  831. return
  832. }
  833. for _, v := range allocationCompanyContractList {
  834. if v.Proportion != 0 {
  835. mapUserAllocation[v.RealName] += 1
  836. mapUserMoney[v.RealName] += v.Money
  837. mapPermissionAllocation[v.ChartPermissionName] += 1
  838. mapPermissionMoney[v.ChartPermissionName] += v.Money
  839. totalMoney += v.Money
  840. }
  841. }
  842. for _, v := range allocationCompanyContractPermissionList {
  843. mapPermissionMoneyAvg[v.ChartPermissionName] += v.MoneyAvg
  844. }
  845. }
  846. sysUserList, err := cygx.GetAskEmailList()
  847. if err != nil {
  848. br.Msg = "获取失败"
  849. br.ErrMsg = "获取失败,GetAskEmailList Err: " + err.Error()
  850. return
  851. }
  852. mapPermissionUser := make(map[string][]*cygx.AllocationRealNameStatisticsListResp)
  853. for _, v := range sysUserList {
  854. item := new(cygx.AllocationRealNameStatisticsListResp)
  855. item.RealName = v.Name
  856. item.TotalRelatedContract = mapUserAllocation[v.Name]
  857. item.TotalDispatchPoint = fmt.Sprint(mapUserMoney[v.Name])
  858. if item.TotalDispatchPoint == "" {
  859. item.TotalDispatchPoint = "0"
  860. }
  861. //组内占比
  862. //utils.SubFloatToString(val, 4)
  863. //item.GroupProportion = fmt.Sprint(mapUserMoney[v.Name] / mapPermissionMoney[v.ChartPermissionName] * 100)
  864. if mapUserMoney[v.Name] == 0 {
  865. item.GroupProportion = ""
  866. } else {
  867. item.GroupProportion = utils.SubFloatToString(mapUserMoney[v.Name]/mapPermissionMoney[v.ChartPermissionName]*100, 2)
  868. }
  869. if item.GroupProportion == "" {
  870. item.GroupProportion = "0"
  871. }
  872. item.GroupProportion += "%"
  873. //部门占比
  874. item.DepartmentProportion = utils.SubFloatToString(mapUserMoney[v.Name]/totalMoney*100, 2)
  875. if item.DepartmentProportion == "" {
  876. item.DepartmentProportion = "0"
  877. }
  878. item.DepartmentProportion += "%"
  879. mapPermissionUser[v.ChartPermissionName] = append(mapPermissionUser[v.ChartPermissionName], item)
  880. }
  881. for k, v := range mapPermissionUser {
  882. lenUser := len(v)
  883. item := new(cygx.AllocationRealNameStatisticsListResp)
  884. item.RealName = "合计"
  885. item.TotalRelatedContract = mapPermissionAllocation[k]
  886. item.TotalDispatchPoint = fmt.Sprint(utils.SubFloatToString(mapPermissionMoney[k], 2), "/", mapPermissionMoneyAvg[k])
  887. item.GroupProportion = "100%"
  888. // 部门占比
  889. item.DepartmentProportion = utils.SubFloatToString(mapPermissionMoney[k]/totalMoney*100, 2)
  890. if item.DepartmentProportion == "" {
  891. item.DepartmentProportion = "0"
  892. }
  893. item.DepartmentProportion += "%"
  894. mapPermissionUser[k] = append(mapPermissionUser[k], item)
  895. item = new(cygx.AllocationRealNameStatisticsListResp)
  896. item.RealName = "平均"
  897. item.TotalRelatedContract = utils.SubFloatToFloat(mapPermissionAllocation[k]/float64(lenUser), 2)
  898. item.TotalDispatchPoint = utils.SubFloatToString(mapPermissionMoney[k]/float64(lenUser), 2)
  899. //组内占比
  900. if mapPermissionMoney[k] == 0 {
  901. item.GroupProportion = ""
  902. } else {
  903. item.GroupProportion = utils.SubFloatToString(float64(lenUser)/mapPermissionMoney[k]*100, 2)
  904. }
  905. if item.GroupProportion == "" {
  906. item.GroupProportion = "0"
  907. }
  908. item.GroupProportion += "%"
  909. // 部门占比
  910. item.DepartmentProportion = utils.SubFloatToString(mapPermissionMoney[k]/totalMoney*100/float64(len(mapPermissionUser[k])), 2)
  911. if item.DepartmentProportion == "" {
  912. item.DepartmentProportion = "0"
  913. }
  914. item.DepartmentProportion += "%"
  915. mapPermissionUser[k] = append(mapPermissionUser[k], item)
  916. }
  917. var list []*cygx.AllocationPermissionStatisticsListResp
  918. permissionNameArr := []string{"医药", "消费", "科技", "智造", "策略"}
  919. for _, v := range permissionNameArr {
  920. item := new(cygx.AllocationPermissionStatisticsListResp)
  921. item.ChartPermissionName = v
  922. item.List = mapPermissionUser[v]
  923. list = append(list, item)
  924. }
  925. resp := cygx.CygxAllocationCompanyContractDetailStatisticsResp{
  926. List: list,
  927. }
  928. resp.TotalContract = totalContract
  929. resp.TotalMoney = totalMoney
  930. //导出excel
  931. if isExport {
  932. CompanyContractStatisticsExport(this, resp, br)
  933. return
  934. }
  935. br.Ret = 200
  936. br.Success = true
  937. br.Msg = "获取成功"
  938. br.Data = resp
  939. }
  940. // CompanyContractStatisticsExport 导出Excel
  941. func CompanyContractStatisticsExport(this *ContractAllocationController, resp cygx.CygxAllocationCompanyContractDetailStatisticsResp, br *models.BaseResponse) {
  942. dir, err := os.Executable()
  943. exPath := filepath.Dir(dir)
  944. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  945. xlsxFile := xlsx.NewFile()
  946. if err != nil {
  947. br.Msg = "生成文件失败"
  948. br.ErrMsg = "生成文件失败"
  949. return
  950. }
  951. style := xlsx.NewStyle()
  952. alignment := xlsx.Alignment{
  953. Horizontal: "center",
  954. Vertical: "center",
  955. WrapText: true,
  956. }
  957. style.Alignment = alignment
  958. style.ApplyAlignment = true
  959. sheel, err := xlsxFile.AddSheet("研究员派点统计")
  960. if err != nil {
  961. br.Msg = "新增Sheet失败"
  962. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  963. return
  964. }
  965. sheel.SetColWidth(0, 0, 30)
  966. sheel.SetColWidth(1, 1, 15)
  967. sheel.SetColWidth(2, 2, 15)
  968. sheel.SetColWidth(3, 3, 18)
  969. titleRow := sheel.AddRow()
  970. cellA := titleRow.AddCell()
  971. cellA.SetStyle(style)
  972. cellA.SetValue("组别")
  973. cellB := titleRow.AddCell()
  974. cellB.SetStyle(style)
  975. cellB.SetValue("研究员")
  976. cellC := titleRow.AddCell()
  977. cellC.SetStyle(style)
  978. cellC.SetValue("关联合同")
  979. cellD := titleRow.AddCell()
  980. cellD.SetStyle(style)
  981. cellD.SetValue("总派点")
  982. cellE := titleRow.AddCell()
  983. cellE.SetStyle(style)
  984. cellE.SetValue("组内占比")
  985. cellF := titleRow.AddCell()
  986. cellF.SetStyle(style)
  987. cellF.SetValue("部门占比")
  988. for _, v := range resp.List {
  989. for k2, v2 := range v.List {
  990. dataRow := sheel.AddRow()
  991. dataRow.SetHeight(20)
  992. cellA := dataRow.AddCell()
  993. cellA.SetStyle(style)
  994. cellA.SetValue(v.ChartPermissionName)
  995. if k2 < len(v.List)-1 {
  996. cellA.VMerge = 1
  997. }
  998. cellB := dataRow.AddCell()
  999. cellB.SetStyle(style)
  1000. cellB.SetValue(v2.RealName)
  1001. cellC := dataRow.AddCell()
  1002. cellC.SetStyle(style)
  1003. cellC.SetValue(v2.TotalRelatedContract)
  1004. cellD := dataRow.AddCell()
  1005. cellD.SetStyle(style)
  1006. cellD.SetValue(v2.TotalDispatchPoint)
  1007. cellE := dataRow.AddCell()
  1008. cellE.SetStyle(style)
  1009. cellE.SetValue(v2.GroupProportion)
  1010. cellF := dataRow.AddCell()
  1011. cellF.SetStyle(style)
  1012. cellF.SetValue(v2.DepartmentProportion)
  1013. }
  1014. }
  1015. titleRow = sheel.AddRow()
  1016. cellA = titleRow.AddCell()
  1017. cellA.HMerge = 1
  1018. cellA.SetStyle(style)
  1019. cellA.SetValue("部门合计")
  1020. cellB = titleRow.AddCell()
  1021. cellB.SetStyle(style)
  1022. cellB.SetValue("")
  1023. cellC = titleRow.AddCell()
  1024. cellC.SetStyle(style)
  1025. cellC.SetValue(resp.TotalContract)
  1026. cellD = titleRow.AddCell()
  1027. cellD.SetStyle(style)
  1028. cellD.SetValue(resp.TotalMoney)
  1029. cellE = titleRow.AddCell()
  1030. cellE.SetStyle(style)
  1031. cellE.SetValue("-")
  1032. cellF = titleRow.AddCell()
  1033. cellF.SetStyle(style)
  1034. cellF.SetValue("100%")
  1035. err = xlsxFile.Save(downLoadnFilePath)
  1036. if err != nil {
  1037. br.Msg = "保存文件失败"
  1038. br.ErrMsg = "保存文件失败"
  1039. return
  1040. }
  1041. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1042. downloadFileName := "研究员派点统计_" + randStr + ".xlsx"
  1043. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1044. defer func() {
  1045. os.Remove(downLoadnFilePath)
  1046. }()
  1047. br.Ret = 200
  1048. br.Success = true
  1049. br.Msg = "导出成功"
  1050. }