zk 2 年之前
父節點
當前提交
7f2b2d0392

+ 142 - 0
server/api/v1/autocode/unit_history.go

@@ -0,0 +1,142 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
+	autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
+	"github.com/flipped-aurora/gin-vue-admin/server/service"
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
+)
+
+type UnitHistoryApi struct {
+}
+
+var unitHistoryService = service.ServiceGroupApp.AutoCodeServiceGroup.UnitHistoryService
+
+// CreateUnitHistory 创建UnitHistory
+// @Tags UnitHistory
+// @Summary 创建UnitHistory
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.UnitHistory true "创建UnitHistory"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /unitHistory/createUnitHistory [post]
+func (unitHistoryApi *UnitHistoryApi) CreateUnitHistory(c *gin.Context) {
+	var unitHistory autocode.UnitHistory
+	_ = c.ShouldBindJSON(&unitHistory)
+	if err := unitHistoryService.CreateUnitHistory(unitHistory); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
+		response.FailWithMessage("创建失败", c)
+	} else {
+		response.OkWithMessage("创建成功", c)
+	}
+}
+
+// DeleteUnitHistory 删除UnitHistory
+// @Tags UnitHistory
+// @Summary 删除UnitHistory
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.UnitHistory true "删除UnitHistory"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
+// @Router /unitHistory/deleteUnitHistory [delete]
+func (unitHistoryApi *UnitHistoryApi) DeleteUnitHistory(c *gin.Context) {
+	var unitHistory autocode.UnitHistory
+	_ = c.ShouldBindJSON(&unitHistory)
+	if err := unitHistoryService.DeleteUnitHistory(unitHistory); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+
+// DeleteUnitHistoryByIds 批量删除UnitHistory
+// @Tags UnitHistory
+// @Summary 批量删除UnitHistory
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body request.IdsReq true "批量删除UnitHistory"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
+// @Router /unitHistory/deleteUnitHistoryByIds [delete]
+func (unitHistoryApi *UnitHistoryApi) DeleteUnitHistoryByIds(c *gin.Context) {
+	var IDS request.IdsReq
+	_ = c.ShouldBindJSON(&IDS)
+	if err := unitHistoryService.DeleteUnitHistoryByIds(IDS); err != nil {
+		global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
+		response.FailWithMessage("批量删除失败", c)
+	} else {
+		response.OkWithMessage("批量删除成功", c)
+	}
+}
+
+// UpdateUnitHistory 更新UnitHistory
+// @Tags UnitHistory
+// @Summary 更新UnitHistory
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data body autocode.UnitHistory true "更新UnitHistory"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
+// @Router /unitHistory/updateUnitHistory [put]
+func (unitHistoryApi *UnitHistoryApi) UpdateUnitHistory(c *gin.Context) {
+	var unitHistory autocode.UnitHistory
+	_ = c.ShouldBindJSON(&unitHistory)
+	if err := unitHistoryService.UpdateUnitHistory(unitHistory); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
+		response.FailWithMessage("更新失败", c)
+	} else {
+		response.OkWithMessage("更新成功", c)
+	}
+}
+
+// FindUnitHistory 用id查询UnitHistory
+// @Tags UnitHistory
+// @Summary 用id查询UnitHistory
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query autocode.UnitHistory true "用id查询UnitHistory"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
+// @Router /unitHistory/findUnitHistory [get]
+func (unitHistoryApi *UnitHistoryApi) FindUnitHistory(c *gin.Context) {
+	var unitHistory autocode.UnitHistory
+	_ = c.ShouldBindQuery(&unitHistory)
+	if err, reunitHistory := unitHistoryService.GetUnitHistory(unitHistory.ID); err != nil {
+		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
+		response.FailWithMessage("查询失败", c)
+	} else {
+		response.OkWithData(gin.H{"reunitHistory": reunitHistory}, c)
+	}
+}
+
+// GetUnitHistoryList 分页获取UnitHistory列表
+// @Tags UnitHistory
+// @Summary 分页获取UnitHistory列表
+// @Security ApiKeyAuth
+// @accept application/json
+// @Produce application/json
+// @Param data query autocodeReq.UnitHistorySearch true "分页获取UnitHistory列表"
+// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
+// @Router /unitHistory/getUnitHistoryList [get]
+func (unitHistoryApi *UnitHistoryApi) GetUnitHistoryList(c *gin.Context) {
+	var pageInfo autocodeReq.UnitHistorySearch
+	_ = c.ShouldBindQuery(&pageInfo)
+	if err, list, total := unitHistoryService.GetUnitHistoryInfoList(pageInfo); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     pageInfo.Page,
+			PageSize: pageInfo.PageSize,
+		}, "获取成功", c)
+	}
+}

+ 1 - 1
server/model/autocode/place.go

@@ -11,7 +11,7 @@ type Place struct {
 	global.GVA_MODEL
 	Name     string `json:"name" form:"name" gorm:"column:name;comment:点位名称;type:varchar(255);"`
 	Position string `json:"position" form:"position" gorm:"column:position;comment:点位定位;type:varchar(255);"`
-	Type     string `json:"type" form:"type" gorm:"column:type;comment:点位类型;type:varchar(255);"`
+	Type     *int   `json:"type" form:"type" gorm:"column:type;comment:点位类型;type:int;"`
 	Region   string `json:"region" form:"region" gorm:"column:region;comment:区域;type:varchar(255);"`
 }
 

+ 3 - 0
server/model/autocode/request/problem_info.go

@@ -3,9 +3,12 @@ package request
 import (
 	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
 	"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
+	"time"
 )
 
 type ProblemInfoSearch struct {
 	autocode.ProblemInfo1
 	request.PageInfo
+	CreatedAtStart time.Time
+	CreatedAtEnd   time.Time
 }

+ 11 - 0
server/model/autocode/request/unit_history.go

@@ -0,0 +1,11 @@
+package request
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
+)
+
+type UnitHistorySearch struct {
+	autocode.UnitHistory
+	request.PageInfo
+}

+ 23 - 0
server/model/autocode/unit_history.go

@@ -0,0 +1,23 @@
+// 自动生成模板UnitHistory
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+)
+
+// UnitHistory 结构体
+// 如果含有time.Time 请自行import time包
+type UnitHistory struct {
+	global.GVA_MODEL
+	UnitName        string `json:"unitName" form:"unitName" gorm:"column:unit_name;comment:单位名称;type:varchar(200);"`
+	UnitIntegral    *int   `json:"unitIntegral" form:"unitIntegral" gorm:"column:unit_integral;comment:现有积分;type:int"`
+	UnitMaxIntegral *int   `json:"unitMaxIntegral" form:"unitMaxIntegral" gorm:"column:unit_max_integral;comment:满分;type:int"`
+	Period          string `json:"period" form:"period" gorm:"column:period;comment:期编号;type:varchar(40);"`
+	UnitId          *uint  `json:"unitId" form:"unitId" gorm:"column:unit_id;comment:单位id;type:bigint"`
+	ProblemIds      string `json:"problemIds" form:"problemIds" gorm:"column:problem_ids;comment:关联问题id;type:varchar(10000);"`
+}
+
+// TableName UnitHistory 表名
+func (UnitHistory) TableName() string {
+	return "unit_history"
+}

+ 3 - 3
server/resource/template/web/table.vue.tpl

@@ -52,16 +52,16 @@
       </el-table-column>
       {{- range .Fields}}
       {{- if .DictType}}
-      <el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
+      <el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}">
         <template #default="scope">
           {{"{{"}} filterDict(scope.row.{{.FieldJson}},"{{.DictType}}") {{"}}"}}
         </template>
       </el-table-column>
       {{- else if eq .FieldType "bool" }}
-      <el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
+      <el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" >
         <template #default="scope">{{"{{"}} formatBoolean(scope.row.{{.FieldJson}}) {{"}}"}}</template>
       </el-table-column> {{- else }}
-      <el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
+      <el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" />
       {{- end }}
       {{- end }}
       <el-table-column label="按钮组">

+ 24 - 0
server/router/autocode/unit_history.go

@@ -0,0 +1,24 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/api/v1"
+	"github.com/flipped-aurora/gin-vue-admin/server/middleware"
+	"github.com/gin-gonic/gin"
+)
+
+type UnitHistoryRouter struct {
+}
+
+// InitUnitHistoryRouter 初始化 UnitHistory 路由信息
+func (s *UnitHistoryRouter) InitUnitHistoryRouter(Router *gin.RouterGroup) {
+	unitHistoryRouter := Router.Group("unitHistory").Use(middleware.OperationRecord())
+	var unitHistoryApi = v1.ApiGroupApp.AutoCodeApiGroup.UnitHistoryApi
+	{
+		unitHistoryRouter.POST("createUnitHistory", unitHistoryApi.CreateUnitHistory)             // 新建UnitHistory
+		unitHistoryRouter.DELETE("deleteUnitHistory", unitHistoryApi.DeleteUnitHistory)           // 删除UnitHistory
+		unitHistoryRouter.DELETE("deleteUnitHistoryByIds", unitHistoryApi.DeleteUnitHistoryByIds) // 批量删除UnitHistory
+		unitHistoryRouter.PUT("updateUnitHistory", unitHistoryApi.UpdateUnitHistory)              // 更新UnitHistory
+		unitHistoryRouter.GET("findUnitHistory", unitHistoryApi.FindUnitHistory)                  // 根据ID获取UnitHistory
+		unitHistoryRouter.GET("getUnitHistoryList", unitHistoryApi.GetUnitHistoryList)            // 获取UnitHistory列表
+	}
+}

+ 1 - 1
server/service/autocode/place.go

@@ -52,7 +52,7 @@ func (placeService *PlaceService) GetPlaceInfoList(info autoCodeReq.PlaceSearch)
 	offset := info.PageSize * (info.Page - 1)
 	// 创建db
 	db := global.GVA_DB.Model(&autocode.Place{})
-	if info.Type != "" {
+	if info.Type != nil {
 		db.Where("type=?", info.Type)
 	}
 	if info.Name != "" {

+ 66 - 0
server/service/autocode/unit_history.go

@@ -0,0 +1,66 @@
+package autocode
+
+import (
+	"github.com/flipped-aurora/gin-vue-admin/server/global"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
+	autoCodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
+	"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
+)
+
+type UnitHistoryService struct {
+}
+
+// CreateUnitHistory 创建UnitHistory记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (unitHistoryService *UnitHistoryService) CreateUnitHistory(unitHistory autocode.UnitHistory) (err error) {
+	err = global.GVA_DB.Create(&unitHistory).Error
+	return err
+}
+
+// DeleteUnitHistory 删除UnitHistory记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (unitHistoryService *UnitHistoryService) DeleteUnitHistory(unitHistory autocode.UnitHistory) (err error) {
+	err = global.GVA_DB.Delete(&unitHistory).Error
+	return err
+}
+
+// DeleteUnitHistoryByIds 批量删除UnitHistory记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (unitHistoryService *UnitHistoryService) DeleteUnitHistoryByIds(ids request.IdsReq) (err error) {
+	err = global.GVA_DB.Delete(&[]autocode.UnitHistory{}, "id in ?", ids.Ids).Error
+	return err
+}
+
+// UpdateUnitHistory 更新UnitHistory记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (unitHistoryService *UnitHistoryService) UpdateUnitHistory(unitHistory autocode.UnitHistory) (err error) {
+	err = global.GVA_DB.Save(&unitHistory).Error
+	return err
+}
+
+// GetUnitHistory 根据id获取UnitHistory记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (unitHistoryService *UnitHistoryService) GetUnitHistory(id uint) (err error, unitHistory autocode.UnitHistory) {
+	err = global.GVA_DB.Where("id = ?", id).First(&unitHistory).Error
+	return
+}
+
+// GetUnitHistoryInfoList 分页获取UnitHistory记录
+// Author [piexlmax](https://github.com/piexlmax)
+func (unitHistoryService *UnitHistoryService) GetUnitHistoryInfoList(info autoCodeReq.UnitHistorySearch) (err error, list interface{}, total int64) {
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	// 创建db
+	db := global.GVA_DB.Model(&autocode.UnitHistory{})
+	if info.UnitName != "" {
+		db.Where("unit_name = ?", info.UnitName)
+	}
+	if info.Period != "" {
+		db.Where("period = ?", info.Period)
+	}
+	var unitHistorys []autocode.UnitHistory
+	// 如果有条件搜索 下方会自动创建搜索语句
+	err = db.Count(&total).Error
+	err = db.Limit(limit).Offset(offset).Find(&unitHistorys).Error
+	return err, unitHistorys, total
+}

+ 40 - 14
server/service/example/exa_excel_parse.go

@@ -34,22 +34,45 @@ func (exa *ExcelService) ParseInfoList2Excel(infoList []system.SysBaseMenu, file
 	return err
 }
 
-func (exa *ExcelService) ProblemInfoList2Excel(infoList []autocode.ProblemInfo, filePath string, dictList []system.SysDictionary) error {
+func (exa *ExcelService) ProblemInfoList2Excel(infoList []autocode.ProblemInfo, filePath string, siteType system.SysDictionary, list []autocode.ProblemType) error {
 	excel := excelize.NewFile()
-	excel.SetSheetRow("Sheet1", "A1", &[]string{"ID", "问题发布时间", "问题处理时间", "问题视频地址", "问题图片", "站点名称", "站点位置", "问题", "站点类型", "责任部门", "处理状态", "处理图片", "处理内容", "处理人"})
+	excel.SetSheetRow("Sheet1", "A1", &[]string{"ID", "问题发布时间", "问题处理时间", "问题视频地址", "问题图片", "站点名称", "站点位置", "问题", "站点类型", "一类单位", "评分", "责任部门", "已查阅次数", "处理状态", "处理图片", "处理内容", "处理人"})
+	//站点类型
+	siteMap := make(map[int]string)
+	for _, siteT := range siteType.SysDictionaryDetails {
+		siteMap[siteT.Value] = siteT.Label
+	}
+	//问题类型
+	siteProMap := make(map[int]map[int]string)
+	siteId := list[0].SiteType
+	proMap := make(map[int]string)
+	for _, pro := range list {
+		if *siteId != *pro.SiteType {
+			siteProMap[*siteId] = proMap
+			siteId = pro.SiteType
+			proMap = make(map[int]string)
+		}
+		proMap[int(pro.ID)] = pro.Problem
+	}
+
 	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")
-					}
-				}
+		var status string
+		if problemInfo.Status != "Untreated" {
+			status = "未处理"
+		} else {
+			status = "已处理"
+		}
+		if problemInfo.Matter != "" {
+			for index, id := range strings.Split(problemInfo.Matter, "|") {
+				id, _ := strconv.Atoi(id)
+				matterStr.WriteString(strconv.Itoa(index+1) + "." + siteProMap[*problemInfo.SiteType][id] + " \n")
 			}
+		} else {
+			matterStr.WriteString(problemInfo.Remark)
 		}
+
 		excel.SetSheetRow("Sheet1", axis, &[]interface{}{
 			problemInfo.ID,
 			problemInfo.CreatedAt,
@@ -57,14 +80,17 @@ func (exa *ExcelService) ProblemInfoList2Excel(infoList []autocode.ProblemInfo,
 			problemInfo.Video,
 			problemInfo.Imgs,
 			problemInfo.SiteName,
-			"https://apis.map.qq.com/uri/v1/marker?marker=coord:" + problemInfo.Position + ";title:" + problemInfo.SiteName + ";addr:" + problemInfo.SiteType,
+			"https://apis.map.qq.com/uri/v1/marker?marker=coord:" + problemInfo.Position + ";title:" + problemInfo.SiteName + ";addr:" + siteMap[*problemInfo.SiteType],
 			matterStr.String(),
-			problemInfo.SiteType,
+			siteMap[*problemInfo.SiteType],
+			problemInfo.UnitName,
+			float64(*problemInfo.Integral) / 10,
 			problemInfo.Department,
-			problemInfo.Status,
+			*problemInfo.Count,
+			status,
 			problemInfo.HandImgs,
 			problemInfo.HandText,
-			problemInfo.Handler,
+			&problemInfo.Handler,
 		})
 	}
 	err := excel.SaveAs(filePath)