Quellcode durchsuchen

导出使用字典,单查询

ice vor 3 Jahren
Ursprung
Commit
ea47bb549e

+ 4 - 1
server/api/v1/autocode/problem_info.go

@@ -59,7 +59,8 @@ func (problemInfoApi *ProblemInfoApi) ExportExcel(c *gin.Context) {
 		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
 		response.FailWithMessage("获取失败", c)
 	} else {
-		err := service.ServiceGroupApp.ExampleServiceGroup.ExcelService.ProblemInfoList2Excel(list, filePath)
+		_, dictList := service.ServiceGroupApp.SystemServiceGroup.DictionaryService.GetSysDictionaryDetailList()
+		err := service.ServiceGroupApp.ExampleServiceGroup.ExcelService.ProblemInfoList2Excel(list, filePath, dictList)
 		if err != nil {
 			global.GVA_LOG.Error("转换Excel失败!", zap.Any("err", err))
 			response.FailWithMessage("转换Excel失败", c)
@@ -151,6 +152,8 @@ func (problemInfoApi *ProblemInfoApi) FindProblemInfo(c *gin.Context) {
 		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
 		response.FailWithMessage("查询失败", c)
 	} else {
+		//param := reqMode.SysDictionarySearch{, request.PageInfo{PageSize: 9999, Page: 0}}
+		_, reproblemInfo.MatterList = service.ServiceGroupApp.SystemServiceGroup.DictionaryService.GetSysDictionaryDetail(reproblemInfo.SiteType)
 		response.OkWithData(gin.H{"reproblemInfo": reproblemInfo}, c)
 	}
 }

+ 1 - 3
server/core/server.go

@@ -33,8 +33,6 @@ func RunWindowsServer() {
 	欢迎使用 cc
 	当前版本:V2.4.5 alpha
     微信号:zk1006
-	默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
-	默认前端文件运行地址:http://127.0.0.1:8080
-`, address)
+`)
 	global.GVA_LOG.Error(s.ListenAndServe().Error())
 }

+ 17 - 15
server/model/autocode/problem_info.go

@@ -3,27 +3,29 @@ package autocode
 
 import (
 	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/system"
 )
 
 // ProblemInfo 结构体
 // 如果含有time.Time 请自行import time包
 type ProblemInfo struct {
 	global.GVA_MODEL
-	Oper       uint   `json:"oper" form:"oper" gorm:"column:oper;comment:发布人;type:bigint"`
-	Handler    *int   `json:"handler" form:"handler" gorm:"column:handler;comment:处理人;type:bigint"`
-	Imgs       string `json:"imgs" form:"imgs" gorm:"column:imgs;comment:关联图片;type:varchar(2000);"`
-	Video      string `json:"video" form:"video" gorm:"column:video;comment:关联视频;type:varchar(255);"`
-	SiteId     uint   `json:"siteId" form:"siteId" gorm:"column:site_id;comment:站点id;type:bigint"`
-	SiteName   string `json:"siteName" form:"siteName" gorm:"column:site_name;comment:站点id;type:bigint"`
-	Position   string `json:"position" form:"position" gorm:"column:position;comment:经纬度;type:varchar(255);"`
-	Matter     string `json:"matter" form:"matter" gorm:"column:matter;comment:问题列表;type:varchar(255);"`
-	SiteType   string `json:"siteType" form:"siteType" gorm:"column:site_type;comment:站点类型;type:varchar(255);"`
-	Status     string `json:"status" form:"status" gorm:"column:status;comment:处理状态;type:varchar(255);"`
-	Region     string `json:"region" form:"region" gorm:"column:region;comment:区域;type:varchar(255);"`
-	HandImgs   string `json:"handImgs" form:"handImgs" gorm:"column:hand_imgs;comment:处理图片;type:varchar(255);"`
-	HandText   string `json:"handText" form:"handText" gorm:"column:hand_text;comment:处理内容;type:varchar(255);"`
-	Department string `json:"department" form:"department" gorm:"column:department;comment:责任部门;type:varchar(255);"`
-	Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:问题备注;type:varchar(600);"`
+	Oper       uint                 `json:"oper" form:"oper" gorm:"column:oper;comment:发布人;type:bigint"`
+	Handler    *int                 `json:"handler" form:"handler" gorm:"column:handler;comment:处理人;type:bigint"`
+	Imgs       string               `json:"imgs" form:"imgs" gorm:"column:imgs;comment:关联图片;type:varchar(2000);"`
+	Video      string               `json:"video" form:"video" gorm:"column:video;comment:关联视频;type:varchar(255);"`
+	SiteId     uint                 `json:"siteId" form:"siteId" gorm:"column:site_id;comment:站点id;type:bigint"`
+	SiteName   string               `json:"siteName" form:"siteName" gorm:"column:site_name;comment:站点id;type:bigint"`
+	Position   string               `json:"position" form:"position" gorm:"column:position;comment:经纬度;type:varchar(255);"`
+	Matter     string               `json:"matter" form:"matter" gorm:"column:matter;comment:问题列表;type:varchar(255);"`
+	SiteType   string               `json:"siteType" form:"siteType" gorm:"column:site_type;comment:站点类型;type:varchar(255);"`
+	Status     string               `json:"status" form:"status" gorm:"column:status;comment:处理状态;type:varchar(255);"`
+	Region     string               `json:"region" form:"region" gorm:"column:region;comment:区域;type:varchar(255);"`
+	HandImgs   string               `json:"handImgs" form:"handImgs" gorm:"column:hand_imgs;comment:处理图片;type:varchar(255);"`
+	HandText   string               `json:"handText" form:"handText" gorm:"column:hand_text;comment:处理内容;type:varchar(255);"`
+	Department string               `json:"department" form:"department" gorm:"column:department;comment:责任部门;type:varchar(255);"`
+	Remark     string               `json:"remark" form:"remark" gorm:"column:remark;comment:问题备注;type:varchar(600);"`
+	MatterList system.SysDictionary `json:"matterList" gorm:"-"`
 }
 
 // TableName ProblemInfo 表名

+ 18 - 6
server/service/example/exa_excel_parse.go

@@ -1,14 +1,15 @@
 package example
 
 import (
+	"bytes"
 	"errors"
 	"fmt"
-	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
-	"strconv"
-
 	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
 	"github.com/flipped-aurora/gin-vue-admin/server/model/system"
 	"github.com/xuri/excelize/v2"
+	"strconv"
+	"strings"
 )
 
 type ExcelService struct {
@@ -33,11 +34,22 @@ func (exa *ExcelService) ParseInfoList2Excel(infoList []system.SysBaseMenu, file
 	return err
 }
 
-func (exa *ExcelService) ProblemInfoList2Excel(infoList []autocode.ProblemInfo, filePath string) error {
+func (exa *ExcelService) ProblemInfoList2Excel(infoList []autocode.ProblemInfo, filePath string, dictList []system.SysDictionary) error {
 	excel := excelize.NewFile()
-	excel.SetSheetRow("Sheet1", "A1", &[]string{"ID", "问题发布时间", "问题处理时间", "问题视频地址", "问题图片", "站点名称", "站点位置", "问题ID", "站点类型", "责任部门", "处理状态", "处理图片", "处理内容", "处理人"})
+	excel.SetSheetRow("Sheet1", "A1", &[]string{"ID", "问题发布时间", "问题处理时间", "问题视频地址", "问题图片", "站点名称", "站点位置", "问题", "站点类型", "责任部门", "处理状态", "处理图片", "处理内容", "处理人"})
 	for i, problemInfo := range infoList {
 		axis := fmt.Sprintf("A%d", i+2)
+		var matterStr bytes.Buffer
+		for _, dictionary := range dictList {
+			if dictionary.Name == problemInfo.SiteType {
+				for index, id := range strings.Split(problemInfo.Matter, "|") {
+					tempid, _ := strconv.Atoi(id)
+					if len(dictionary.SysDictionaryDetails) >= tempid+1 {
+						matterStr.WriteString(strconv.Itoa(index+1) + "." + dictionary.SysDictionaryDetails[tempid].Label + " \n")
+					}
+				}
+			}
+		}
 		excel.SetSheetRow("Sheet1", axis, &[]interface{}{
 			problemInfo.ID,
 			problemInfo.CreatedAt,
@@ -46,7 +58,7 @@ func (exa *ExcelService) ProblemInfoList2Excel(infoList []autocode.ProblemInfo,
 			problemInfo.Imgs,
 			problemInfo.SiteName,
 			"https://apis.map.qq.com/uri/v1/marker?marker=coord:" + problemInfo.Position + ";title:" + problemInfo.SiteName + ";addr:" + problemInfo.SiteType,
-			problemInfo.Matter,
+			matterStr.String(),
 			problemInfo.SiteType,
 			problemInfo.Department,
 			problemInfo.Status,

+ 10 - 0
server/service/system/sys_dictionary.go

@@ -75,6 +75,16 @@ func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uin
 	return
 }
 
+func (dictionaryService *DictionaryService) GetSysDictionaryDetail(Type string) (err error, sysDictionary system.SysDictionary) {
+	err = global.GVA_DB.Where("name = ? ", Type).Preload("SysDictionaryDetails").First(&sysDictionary).Error
+	return
+}
+
+func (dictionaryService *DictionaryService) GetSysDictionaryDetailList() (err error, sysDictionary []system.SysDictionary) {
+	err = global.GVA_DB.Where("`type` LIKE ?", "site_%").Preload("SysDictionaryDetails").Find(&sysDictionary).Error
+	return
+}
+
 //@author: [piexlmax](https://github.com/piexlmax)
 //@author: [SliverHorn](https://github.com/SliverHorn)
 //@function: GetSysDictionaryInfoList

+ 1 - 1
server/service/system/sys_dictionary_detail.go

@@ -59,7 +59,7 @@ func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetail(i
 //@param: info request.SysDictionaryDetailSearch
 //@return: err error, list interface{}, total int64
 
-func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (err error, list interface{}, total int64) {
+func (dictionaryDetailService *DictionaryDetailService) GetSysDictionaryDetailInfoList(info request.SysDictionaryDetailSearch) (err error, list []system.SysDictionaryDetail, total int64) {
 	limit := info.PageSize
 	offset := info.PageSize * (info.Page - 1)
 	// 创建db