zk 2 anni fa
parent
commit
0e073a4fda

+ 34 - 0
server/api/v1/autocode/problem_info.go

@@ -40,6 +40,7 @@ func (problemInfoApi *ProblemInfoApi) CreateProblemInfo(c *gin.Context) {
 		response.FailWithMessage("创建失败,选择站点错误", c)
 	} else {
 		problemInfo.Oper = userId
+		problemInfo.OperName = utils.GetUserInfo(c).Username
 		problemInfo.SiteType = place.Type
 		problemInfo.Position = place.Position
 		problemInfo.SiteName = place.Name
@@ -330,6 +331,39 @@ func (problemInfoApi *ProblemInfoApi) FindProblemPInfo(c *gin.Context) {
 	}
 }
 
+func (problemInfoApi *ProblemInfoApi) GetProblemInfoCount(c *gin.Context) {
+	if err, list := problemInfoService.GetProblemInfoCount(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List: list,
+		}, "获取成功", c)
+	}
+}
+
+func (problemInfoApi *ProblemInfoApi) GetProblemInfoSum(c *gin.Context) {
+	if err, list := problemInfoService.GetProblemInfoSum(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List: list,
+		}, "获取成功", c)
+	}
+}
+
+func (problemInfoApi *ProblemInfoApi) GetPLaceRate(c *gin.Context) {
+	if err, list := problemInfoService.GetPLaceRate(); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List: list,
+		}, "获取成功", c)
+	}
+}
+
 // GetProblemInfoList 分页获取ProblemInfo列表
 // @Tags ProblemInfo
 // @Summary 分页获取ProblemInfo列表

+ 23 - 0
server/api/v1/autocode/unit.go

@@ -113,6 +113,29 @@ func (unitApi *UnitApi) UpdateUnitIntergral(c *gin.Context) {
 	response.OkWithMessage("更新成功", c)
 }
 
+func (unitApi *UnitApi) GetUnitIntergralRate(c *gin.Context) {
+	remark, _ := c.GetQuery("remark")
+	if err, list := unitService.GetUnitIntergralRate(remark); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List: list,
+		}, "获取成功", c)
+	}
+}
+func (unitApi *UnitApi) GetUnitDesc(c *gin.Context) {
+	remark, _ := c.GetQuery("remark")
+	if err, list := unitService.GetUnitDesc(remark); err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List: list,
+		}, "获取成功", c)
+	}
+}
+
 // FindUnit 用id查询Unit
 // @Tags Unit
 // @Summary 用id查询Unit

+ 1 - 0
server/initialize/router.go

@@ -45,6 +45,7 @@ func Routers() *gin.Engine {
 		systemRouter.InitBaseRouter(PublicGroup)            // 注册基础功能路由 不做鉴权
 		systemRouter.InitInitRouter(PublicGroup)            // 自动初始化相关
 		autocodeRouter.InitProblemInfoPRouter(PublicGroup)  // 问题详情
+		autocodeRouter.InitUnitPRouter(PublicGroup)         // 问题详情
 		autocodeRouter.InitContentPRouter(PublicGroup)      // 内容详情
 		systemRouter.InitWechatRouter(PublicGroup)          // 微信公众号
 		autocodeRouter.InitReadCountRouter(PublicGroup)     // 查阅次数查看

+ 8 - 0
server/model/autocode/place.go

@@ -19,6 +19,14 @@ type Place struct {
 	ProList         []PlacePro `json:"proList" gorm:"-"`
 }
 
+type PlaceRate struct {
+	Name        string `json:"siteType" form:"site_type" gorm:"column:site_type;comment:站点类型id;type:varchar(255);"`
+	Label       string `json:"label" form:"label" gorm:"column:label;comment:类型名称;type:varchar(255);"`
+	Mattercount string `json:"mattercount" form:"mattercount" gorm:"column:mattercount;comment:问题数量;type:varchar(255);"`
+	Num         string `json:"num" form:"num" gorm:"column:num;comment:总数量;type:varchar(255);"`
+	Proportion  string `json:"proportion" form:"proportion" gorm:"column:proportion;comment:比例;type:varchar(255);"`
+}
+
 // TableName Place 表名
 func (Place) TableName() string {
 	return "place"

+ 20 - 1
server/model/autocode/problem_info.go

@@ -12,6 +12,7 @@ type ProblemInfo struct {
 	global.GVA_MODEL
 	HandAt     time.Time   // 处理时间
 	Oper       uint        `json:"oper" form:"oper" gorm:"column:oper;comment:发布人;type:bigint"`
+	OperName   string      `json:"operName" form:"operName" gorm:"column:oper_name;comment:发布人;type:varchar(255);"`
 	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);"`
@@ -38,6 +39,7 @@ type ProblemInfo1 struct {
 	global.GVA_MODEL
 	HandAt     time.Time // 处理时间
 	Oper       uint      `json:"oper" form:"oper" gorm:"column:oper;comment:发布人;type:bigint"`
+	OperName   string    `json:"operName" form:"operName" gorm:"column:oper_name;comment:发布人;type:varchar(255);"`
 	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);"`
@@ -55,10 +57,27 @@ type ProblemInfo1 struct {
 	Audit      string    `json:"remark1" form:"remark1" gorm:"column:remark1;comment:审核备注;type:varchar(600);"`
 	Count      *int      `json:"count" form:"count" gorm:"default:0;column:count;comment:阅读次数;type:int);"`
 	Integral   *int      `json:"integral" form:"integral" gorm:"default:0;column:integral;comment:积分;type:int);"`
-	UnitName   string    `json:"unitName" form:"unitName" gorm:"column:unit_name;comment:单位名称;type:varchar(255));"`
+	UnitName   string    `json:"unitName" form:"unitName" gorm:"column:unit_name;comment:单位名称;type:varchar(255);"`
 	UnitId     *int      `json:"unitId" form:"unitId" gorm:"default:0;column:unit_id;comment:单位id;type:int);"`
 }
 
+type ProblemCount struct {
+	Matterid    string `json:"matterid" form:"matterid" gorm:"column:matterid;comment:问题ID;type:varchar(255);"`
+	Problem     string `json:"problem" form:"problem" gorm:"column:problem;comment:问题;type:varchar(255);"`
+	Mattercount string `json:"mattercount" form:"mattercount" gorm:"column:mattercount;comment:问题次数;type:varchar(255);"`
+	Num         string `json:"num" form:"num" gorm:"column:num;comment:次数;type:varchar(255);"`
+	Proportion  string `json:"proportion" form:"proportion" gorm:"column:proportion;comment:比例;type:varchar(255);"`
+}
+
+type ProblemSum struct {
+	UnitId         string `json:"unitId" form:"unitId" gorm:"column:unit_id;comment:单位ID;type:varchar(255);"`
+	UnitName       string `json:"unitName" form:"unitName" gorm:"column:unit_name;comment:单位名称;type:varchar(255);"`
+	Totalnum       string `json:"totalnum" form:"totalnum" gorm:"column:totalnum;comment:问题总数;type:varchar(255);"`
+	Handnum        string `json:"handnum" form:"handnum" gorm:"column:handnum;comment:已处理;type:varchar(255);"`
+	Num            string `json:"num" form:"num" gorm:"column:num;comment:总数;type:varchar(255);"`
+	Handproportion string `json:"handproportion" form:"handproportion" gorm:"column:handproportion;comment:处理率;type:varchar(255);"`
+}
+
 // TableName ProblemInfo 表名
 func (ProblemInfo) TableName() string {
 	return "problem_info"

+ 1 - 0
server/model/autocode/request/countInfo.go

@@ -0,0 +1 @@
+package request

+ 13 - 0
server/model/autocode/unit.go

@@ -18,6 +18,19 @@ type Unit struct {
 	//Places          []Place `json:"places" gorm:"many2many:place;"`
 }
 
+type UnitInitIntegral struct {
+	UnitName  string `json:"unitName" form:"unitName" gorm:"column:unit_name;comment:单位名称;type:varchar(200);"`
+	Score     string `json:"score" form:"score" gorm:"column:score;comment:得分;type:varchar(40);"`
+	Scorerate string `json:"scorerate" form:"scorerate" gorm:"column:scorerate;comment:得分率;type:varchar(40);"`
+	Remark    string `json:"remark" form:"remark" gorm:"column:remark;comment:单位类型;type:varchar(600);"`
+}
+
+type UnitDesc struct {
+	UnitName string `json:"unitName" form:"unitName" gorm:"column:unit_name;comment:单位名称;type:varchar(200);"`
+	Score    string `json:"score" form:"score" gorm:"column:score;comment:得分;type:varchar(40);"`
+	Remark   string `json:"remark" form:"remark" gorm:"column:remark;comment:单位类型;type:varchar(600);"`
+}
+
 // TableName Unit 表名
 func (Unit) TableName() string {
 	return "unit"

+ 4 - 1
server/router/autocode/problem_info.go

@@ -30,6 +30,9 @@ func (s *ProblemInfoRouter) InitProblemInfoPRouter(Router *gin.RouterGroup) {
 	problemInfoRouter := Router.Group("problemInfo").Use(middleware.OperationRecord())
 	var problemInfoApi = v1.ApiGroupApp.AutoCodeApiGroup.ProblemInfoApi
 	{
-		problemInfoRouter.GET("findProblemInfo", problemInfoApi.FindProblemInfo) // 根据ID获取ProblemInfo
+		problemInfoRouter.GET("findProblemInfo", problemInfoApi.FindProblemInfo)         // 根据ID获取ProblemInfo
+		problemInfoRouter.GET("getProblemInfoCount", problemInfoApi.GetProblemInfoCount) // 获取ProblemInfo  统计
+		problemInfoRouter.GET("getProblemInfoSum", problemInfoApi.GetProblemInfoSum)     // 获取ProblemInfo  统计
+		problemInfoRouter.GET("getPLaceRate", problemInfoApi.GetPLaceRate)               // 获取ProblemInfo  统计
 	}
 }

+ 9 - 0
server/router/autocode/unit.go

@@ -23,3 +23,12 @@ func (s *UnitRouter) InitUnitRouter(Router *gin.RouterGroup) {
 		unitRouter.GET("getUnitList", unitApi.GetUnitList)                 // 获取Unit列表
 	}
 }
+
+func (s *ProblemInfoRouter) InitUnitPRouter(Router *gin.RouterGroup) {
+	problemInfoRouter := Router.Group("unit").Use(middleware.OperationRecord())
+	var unitApi = v1.ApiGroupApp.AutoCodeApiGroup.UnitApi
+	{
+		problemInfoRouter.GET("getUnitIntergralRate", unitApi.GetUnitIntergralRate) // 根据ID获取ProblemInfo
+		problemInfoRouter.GET("getUnitDesc", unitApi.GetUnitDesc)                   // 根据ID获取ProblemInfo
+	}
+}

+ 27 - 0
server/service/autocode/problem_info.go

@@ -51,6 +51,33 @@ func (problemInfoService *ProblemInfoService) GetProblemInfo(id uint) (err error
 	return
 }
 
+func (problemInfoService *ProblemInfoService) GetProblemInfoCount() (err error, countInfo []autocode.ProblemCount) {
+	global.GVA_DB.Raw("SELECT statistics.matterid as matterid,pt.problem as problem,statistics.mattercount as mattercount,statistics.num as num,statistics.mattercount / num as proportion FROM ( SELECT  substring_index( substring_index( a.matter, '|', b.help_topic_id + 1 ), '|',- 1 ) AS matterid,  count( 1 ) AS mattercount," +
+		"  (  SELECT   count( 1 )   FROM   problem_info a   JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.matter ) - length( REPLACE ( a.matter, '|', '' ) ) + 1 ) WHERE ( a.matter != '' AND a.matter IS NOT NULL )) num  FROM  problem_info a  JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.matter ) - length( REPLACE ( a.matter, '|', '' ) ) + 1 ) " +
+		" WHERE  ( a.matter != '' AND a.matter IS NOT NULL )  GROUP BY  matterid  ) statistics INNER JOIN problem_type pt ON pt.id = statistics.matterid").Scan(&countInfo)
+	return err, countInfo
+}
+
+func (problemInfoService *ProblemInfoService) GetProblemInfoSum() (err error, countInfo []autocode.ProblemSum) {
+	global.GVA_DB.Raw("SELECT statistics1.unit_id unit_id,statistics1.unit_name unit_name,statistics1.mattercount totalnum,statistics2.mattercount handnum,statistics1.num,statistics2.mattercount/statistics1.mattercount handproportion FROM (" +
+		"SELECT a.unit_id,a.unit_name,count(substring_index(substring_index(a.matter,'|',b.help_topic_id+1),'|',-1)) AS mattercount,(" +
+		"SELECT count(1) FROM problem_info a JOIN mysql.help_topic b ON b.help_topic_id< (length(a.matter)-length(" +
+		"REPLACE (a.matter,'|',''))+1) WHERE (a.matter !='' AND a.matter IS NOT NULL)) num FROM problem_info a JOIN mysql.help_topic b ON b.help_topic_id< (length(a.matter)-length(" +
+		"REPLACE (a.matter,'|',''))+1) WHERE (a.matter !='' AND a.matter IS NOT NULL) GROUP BY unit_id) statistics1 INNER JOIN (" +
+		"SELECT a.unit_id,count(substring_index(substring_index(a.matter,'|',b.help_topic_id+1),'|',-1)) AS mattercount FROM problem_info a JOIN mysql.help_topic b ON b.help_topic_id< (length(a.matter)-length(" +
+		"REPLACE (a.matter,'|',''))+1) WHERE (a.matter !='' AND a.matter IS NOT NULL) AND a.`status` !='Untreated' GROUP BY unit_id) statistics2 ON statistics1.unit_id=statistics2.unit_id").Scan(&countInfo)
+	return err, countInfo
+}
+
+func (problemInfoService *ProblemInfoService) GetPLaceRate() (err error, countInfo []autocode.PlaceRate) {
+	global.GVA_DB.Raw("SELECT statistics.site_type site_type,dict.label label,statistics.mattercount mattercount,statistics.num num,statistics.mattercount/num proportion FROM (" +
+		"SELECT a.site_type,count(substring_index(substring_index(a.matter,'|',b.help_topic_id+1),'|',-1)) AS mattercount,(" +
+		"SELECT count(1) FROM problem_info a JOIN mysql.help_topic b ON b.help_topic_id< (length(a.matter)-length(" +
+		"REPLACE (a.matter,'|',''))+1) WHERE (a.matter !='' AND a.matter IS NOT NULL)) num FROM problem_info a JOIN mysql.help_topic b ON b.help_topic_id< (length(a.matter)-length(" +
+		"	REPLACE (a.matter,'|',''))+1) WHERE (a.matter !='' AND a.matter IS NOT NULL) GROUP BY site_type) statistics INNER JOIN sys_dictionary_details dict ON dict.`value`=statistics.site_type AND dict.sys_dictionary_id=8 AND dict.deleted_at IS NULL;").Scan(&countInfo)
+	return err, countInfo
+}
+
 // GetProblemInfoInfoList 分页获取ProblemInfo记录
 // Author [piexlmax](https://github.com/piexlmax)
 func (problemInfoService *ProblemInfoService) GetProblemInfoInfoList(info autoCodeReq.ProblemInfoSearch) (err error, infoList []autocode.ProblemInfo, total int64) {

+ 11 - 0
server/service/autocode/unit.go

@@ -62,6 +62,17 @@ func (unitService *UnitService) UpdateUnitIntergral() {
 
 }
 
+func (unitService *UnitService) GetUnitIntergralRate(remark string) (err error, countInfo []autocode.UnitInitIntegral) {
+	global.GVA_DB.Raw("SELECT remark,unit_name,unit_max_integral - unit_integral score,1- ( unit_integral / unit_max_integral ) scorerate FROM unit "+
+		"WHERE ( remark IS NOT NULL && remark != '' ) and remark =? ", remark).Scan(&countInfo)
+	return err, countInfo
+}
+
+func (unitService *UnitService) GetUnitDesc(remark string) (err error, countInfo []autocode.UnitDesc) {
+	global.GVA_DB.Raw("SELECT remark,unit_name,unit_max_integral-unit_integral score FROM unit WHERE (remark IS NOT NULL && remark !='') AND remark=? ORDER BY score DESC ", remark).Scan(&countInfo)
+	return err, countInfo
+}
+
 // UpdateUnit 开始下期
 // Author [piexlmax](https://github.com/piexlmax)
 func (unitService *UnitService) UpdateUnitNext(unit autocode.Unit) (err error) {