1、修改bug
This commit is contained in:
parent
db923ac9ae
commit
e5c0984c00
|
@ -28,11 +28,46 @@ func (s HandlerService) DiseaseList(c *gin.Context) (data interface{}, err error
|
|||
if req.Page < 1 {
|
||||
req.Page = 1
|
||||
}
|
||||
data, err = repo.DiseaseList(c, req)
|
||||
if req.Pid < 0 {
|
||||
req.Pid = 0
|
||||
}
|
||||
data, err = repo.DiseaseListNew(c, req)
|
||||
go s.SaveLog("获取病害库列表", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) DiseaseStatistics(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewDiseaseService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
var (
|
||||
userInfo *model.SystemUser
|
||||
ok bool
|
||||
)
|
||||
if userInfo, ok = us.(*model.SystemUser); !ok {
|
||||
go s.SaveLog("DiseaseList", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.DiseaseStatistics(c)
|
||||
go s.SaveLog("获取标注库统计信息", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) CreateTrainDatasetByDisease(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewDiseaseService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.TrainDatasetRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("CreateTrainDatasetByDisease", "Manage", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
req.UserId = userInfo.UserId
|
||||
data, err = repo.CreateTrainDatasetByDisease(c, req)
|
||||
go s.SaveLog("创建训练数据集", "Training", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) DiseaseTypeList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewDiseaseService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
|
|
|
@ -15,6 +15,15 @@ func (s HandlerService) GetEdgeList(c *gin.Context) (data interface{}, err error
|
|||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.EdgeDatasetRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if req.Size < 1 {
|
||||
req.Size = 20
|
||||
}
|
||||
if req.Size > 1000 {
|
||||
req.Size = 1000
|
||||
}
|
||||
if req.Page < 1 {
|
||||
req.Page = 1
|
||||
}
|
||||
if err != nil {
|
||||
go s.SaveLog("GetEdgeList", "Dataset", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
|
|
|
@ -14,7 +14,11 @@ func (s HandlerService) UploadFile(c *gin.Context) (data interface{}, err error)
|
|||
repo := service.NewFileService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.UploadFileRequest
|
||||
var (
|
||||
req proto.UploadFileRequest
|
||||
scene string
|
||||
datasetId int64
|
||||
)
|
||||
form, err := c.MultipartForm()
|
||||
if err != nil {
|
||||
go s.SaveLog("UploadFile", "Manage", "", "", userInfo.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
|
@ -22,11 +26,20 @@ func (s HandlerService) UploadFile(c *gin.Context) (data interface{}, err error)
|
|||
}
|
||||
files := form.File["file"]
|
||||
val := form.Value["scene"]
|
||||
scene := val[0]
|
||||
if len(val) > 0 {
|
||||
scene = val[0]
|
||||
} else {
|
||||
scene = "other"
|
||||
}
|
||||
if len(scene) < 1 {
|
||||
scene = "other"
|
||||
}
|
||||
datasetId, _ := strconv.ParseInt(form.Value["datasetId"][0], 10, 64)
|
||||
if len(form.Value["datasetId"]) > 0 {
|
||||
datasetId, _ = strconv.ParseInt(form.Value["datasetId"][0], 10, 64)
|
||||
} else {
|
||||
datasetId = 0
|
||||
}
|
||||
|
||||
req = proto.UploadFileRequest{
|
||||
Creator: userInfo.UserId,
|
||||
Scene: scene,
|
||||
|
|
|
@ -183,6 +183,30 @@ func (s HandlerService) DelProject(c *gin.Context) (data interface{}, err error)
|
|||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) GetProjectResult(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ProjectRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("GetProjectResult", "Manage", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
if req.Size < 1 {
|
||||
req.Size = 20
|
||||
}
|
||||
if req.Size > 100 {
|
||||
req.Size = 100
|
||||
}
|
||||
if req.Page < 1 {
|
||||
req.Page = 1
|
||||
}
|
||||
data, err = repo.GetProjectResult(c, req)
|
||||
go s.SaveLog("获取项目检测结果", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) ProductList(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewManageService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
|
|
|
@ -89,6 +89,31 @@ func (s HandlerService) ModelIssue(c *gin.Context) (data interface{}, err error)
|
|||
go s.SaveLog("模型下发", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
func (s HandlerService) ModelIssueLog(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewModelService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.ModelIssueLogRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("ModelIssueLog", "Manage", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
|
||||
if req.Size < 1 {
|
||||
req.Size = 20
|
||||
}
|
||||
if req.Size > 100 {
|
||||
req.Size = 100
|
||||
}
|
||||
if req.Page < 1 {
|
||||
req.Page = 1
|
||||
}
|
||||
data, err = repo.ModelIssueLog(c, req)
|
||||
go s.SaveLog("查看模型下发日志", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) GetModelWorkflow(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewModelService(s.AppConfig, s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
|
|
|
@ -176,3 +176,11 @@ func (s HandlerService) NodeLastState(c *gin.Context) (data interface{}, err err
|
|||
go s.SaveLog("获取节点最后运行信息", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
func (s HandlerService) GetAnalysisInfo(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewSystemService(s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
data, err = repo.GetAnalysisInfo(c)
|
||||
go s.SaveLog("获取统计数据", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -167,3 +167,61 @@ func (s HandlerService) TrainingTaskLog(c *gin.Context) (data interface{}, err e
|
|||
go s.SaveLog("获取训练任务日志详情", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) TrainingTaskResult(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewTaskService(s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.TaskItemRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("TrainingTaskResult", "Manage", "", "", req.ToString(), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.TrainingTaskResult(c, req)
|
||||
go s.SaveLog("获取训练任务结果", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
||||
func (s HandlerService) CreateTrainingTask(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewTaskService(s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.TrainingTaskItemRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("CreateTrainingTask", "Manage", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.CreateTrainingTask(c, req)
|
||||
go s.SaveLog("创建训练任务", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
func (s HandlerService) EditTrainingTask(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewTaskService(s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.TrainingTaskItemRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("EditTrainingTask", "Manage", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.EditTrainingTask(c, req)
|
||||
go s.SaveLog("修改训练任务", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
func (s HandlerService) ReRunTrainingTask(c *gin.Context) (data interface{}, err error) {
|
||||
repo := service.NewTaskService(s.Engine, s.Logger)
|
||||
us, _ := c.Get("operatorUser")
|
||||
userInfo := us.(*model.SystemUser)
|
||||
var req proto.TrainingTaskItemRequest
|
||||
err = c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
go s.SaveLog("ReRunTrainingTask", "Manage", "", "", ToString(req), fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return nil, e.NewValidErr(err)
|
||||
}
|
||||
data, err = repo.ReRunTrainingTask(c, req)
|
||||
go s.SaveLog("重新执行训练任务", "Manage", "", "", "", fmt.Sprintf("%d", userInfo.UserId), c.Request.RemoteAddr, "")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
type BasePageList struct {
|
||||
Page int64 `json:"pageNum,omitempty" form:"page"`
|
||||
Page int64 `json:"page,omitempty" form:"page"`
|
||||
Size int64 `json:"pageSize,omitempty" form:"pageSize"`
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,8 @@ type ProjectRequest struct {
|
|||
LineName string `json:"lineName"`
|
||||
ProjectName string `json:"projectName"`
|
||||
OwnerId int64 `json:"ownerId,omitempty"`
|
||||
ProjectId int64 `json:"projectId,omitempty"`
|
||||
SideType int `json:"sideType,omitempty"`
|
||||
BasePageList
|
||||
}
|
||||
|
||||
|
@ -139,6 +141,8 @@ type ProjectItemRequest struct {
|
|||
FixedDeviceNum int `json:"fixedDeviceNum"`
|
||||
Direction string `json:"direction"`
|
||||
LaneNum int `json:"laneNum"`
|
||||
BizType int `json:"bizType"`
|
||||
SideType int `json:"sideType"`
|
||||
Creator int64 `json:"creator"`
|
||||
}
|
||||
|
||||
|
@ -416,6 +420,11 @@ func (p ModelIssueRequest) ToString() string {
|
|||
return string(data)
|
||||
}
|
||||
|
||||
type ModelIssueLogRequest struct {
|
||||
ModelId int64 `json:"modelId"`
|
||||
BasePageList
|
||||
}
|
||||
|
||||
type DeviceRequest struct {
|
||||
Key string `json:"key"`
|
||||
ProductId int64 `json:"productId"`
|
||||
|
@ -496,8 +505,11 @@ func (p BrandItemRequest) ToString() string {
|
|||
}
|
||||
|
||||
type DiseaseRequest struct {
|
||||
BizType int `json:"bizType"`
|
||||
Key string `json:"key"`
|
||||
DiseaseType int `json:"diseaseType"`
|
||||
FileType int `json:"fileType"`
|
||||
LabelType int `json:"labelType"`
|
||||
Pid int `json:"pid,omitempty"`
|
||||
Key string `json:"key"`
|
||||
BasePageList
|
||||
}
|
||||
|
||||
|
@ -725,6 +737,19 @@ func (p TaskLogItem) ToString() string {
|
|||
return string(data)
|
||||
}
|
||||
|
||||
type TrainingTaskItemRequest struct {
|
||||
TaskId int64 `json:"taskId,omitempty"`
|
||||
ModelName string `json:"taskName"` //模型名称
|
||||
BizType int `json:"categoryId"` //业务类型
|
||||
ModelDesc string `json:"taskDesc"` //模型描述
|
||||
DatasetId int64 `json:"trainDatasetId"` //训练数据集编号
|
||||
Arithmetic string `json:"arithmetic"` //算法
|
||||
ImageSize int `json:"imageSize"` //图像大小
|
||||
BatchSize int `json:"batchSize"` //批次大小
|
||||
EpochsSize int `json:"epochsSize"` //迭代次数
|
||||
OutputType string `json:"outputType"` //输出格式
|
||||
}
|
||||
|
||||
type ReportRequest struct {
|
||||
ReportId int64 `json:"reportId,omitempty"`
|
||||
TaskId int64 `json:"taskId,omitempty"`
|
||||
|
@ -748,6 +773,7 @@ type TrainDatasetRequest struct {
|
|||
ValidationNumber int64 `json:"validationNumber"`
|
||||
TestNumber int64 `json:"testNumber"`
|
||||
SplitMethod int `json:"splitMethod"`
|
||||
BizType int `json:"bizType"`
|
||||
UserId int64 `json:"userId"`
|
||||
}
|
||||
|
||||
|
@ -761,4 +787,5 @@ type TrainDatasetItemRequest struct {
|
|||
type EdgeDatasetRequest struct {
|
||||
NodeId int64 `json:"nodeId"`
|
||||
Path string `json:"path"`
|
||||
BasePageList
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ type DatasetItem struct {
|
|||
CreateAt int64 `json:"createAt"`
|
||||
DatasetCount int64 `json:"datasetCount"`
|
||||
DatasetSize int64 `json:"datasetSize"`
|
||||
LabelCount int64 `json:"labelCount"`
|
||||
LabelSize int64 `json:"labelSize"`
|
||||
}
|
||||
|
||||
type NodeState struct {
|
||||
|
@ -192,3 +194,82 @@ type TrainingDatasetFileItem struct {
|
|||
IsDisease int `json:"isDisease"`
|
||||
CategoryId int `json:"categoryId"`
|
||||
}
|
||||
|
||||
type DiseaseStatisticsItem struct {
|
||||
DiseaseType int `json:"diseaseType"`
|
||||
DiseaseName string `json:"diseaseName"`
|
||||
TotalNum int64 `json:"totalNum"`
|
||||
TotalSize int64 `json:"totalSize"`
|
||||
}
|
||||
|
||||
type DiseaseFileInfoItem struct {
|
||||
FileId int64 `json:"fileId"`
|
||||
FileName string `json:"fileName"` //文件名
|
||||
FilePath string `json:"filePath"` //文件路径
|
||||
CategoryId int `json:"categoryId"` //病害分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
CategoryName string `json:"categoryName"` //分类名称
|
||||
FileType int `json:"fileType"` //文件类型, 1:图片 2:视频 3:雷达图谱
|
||||
FileTypeName string `json:"fileTypeName"` //文件类型名称
|
||||
FileSize int64 `json:"fileSize"` //文件大小
|
||||
LabelType int `json:"labelType"` //标注类型
|
||||
LabelTypeName string `json:"labelTypeName"` //标注类型名称
|
||||
FileContent string `json:"fileContent"` //base64文件
|
||||
CreateAt int64 `json:"createAt"` //上传时间
|
||||
UpdateAt int64 `json:"updateAt"` //更新时间
|
||||
Pid int64 `json:"pid"`
|
||||
}
|
||||
|
||||
type AnalysisInfo struct {
|
||||
ModelTotal int64 `json:"modelTotal"`
|
||||
RoadModel int64 `json:"roadModel"`
|
||||
BridgeModel int64 `json:"bridgeModel"`
|
||||
TunnelModel int64 `json:"tunnelModel"`
|
||||
SideSlopeModel int64 `json:"sideSlopeModel"`
|
||||
ProjectTotal int64 `json:"projectTotal"`
|
||||
RoadProject int64 `json:"roadProject"`
|
||||
BridgeProject int64 `json:"bridgeProject"`
|
||||
TunnelProject int64 `json:"tunnelProject"`
|
||||
SideSlopeProject int64 `json:"sideSlopeProject"`
|
||||
DeviceTotal int64 `json:"deviceTotal"`
|
||||
CloudDevice int64 `json:"cloudDevice"`
|
||||
EdgeDevice int64 `json:"edgeDevice"`
|
||||
TotalLabelData int64 `json:"totalLabelData"`
|
||||
RoadLabelData int64 `json:"roadLabelData"`
|
||||
BridgeLabelData int64 `json:"bridgeLabelData"`
|
||||
TunnelLabelData int64 `json:"tunnelLabelData"`
|
||||
SideSlopeLabelData int64 `json:"sideSlopeLabelData"`
|
||||
}
|
||||
|
||||
type ModelIssueLogItem struct {
|
||||
Id int64 `json:"id"`
|
||||
ModelId int64 `json:"modelId"`
|
||||
NodeId int64 `json:"nodeId"`
|
||||
NodeName string `json:"nodeName"`
|
||||
Status int `json:"status"`
|
||||
IssueResult string `json:"issueResult"`
|
||||
CreateAt int64 `json:"createAt"`
|
||||
UpdateAt int64 `json:"updateAt"`
|
||||
}
|
||||
type TrainTaskInfoItem struct {
|
||||
TaskId int64 `json:"taskId"`
|
||||
TrainDatasetId int64 `json:"trainDatasetId"`
|
||||
TrainDatasetName string `json:"trainDatasetName"`
|
||||
CategoryId int `json:"categoryId"`
|
||||
CategoryName string `json:"categoryName"`
|
||||
TaskName string `json:"taskName"`
|
||||
TaskDesc string `json:"taskDesc"`
|
||||
Arithmetic string `json:"arithmetic"`
|
||||
ImageSize int `json:"imageSize"`
|
||||
BatchSize int `json:"batchSize"`
|
||||
EpochsSize int `json:"epochsSize"`
|
||||
OutputType string `json:"outputType"`
|
||||
StartTime int64 `json:"startTime"`
|
||||
FinishTime int64 `json:"finishTime"`
|
||||
Loss float64 `json:"loss"`
|
||||
Accuracy float64 `json:"accuracy"`
|
||||
ModelFilePath string `json:"modelFilePath"`
|
||||
ModelFileMetricsPath string `json:"modelFileMetricsPath"`
|
||||
Status int `json:"status"`
|
||||
CreateAt int64 `json:"createAt"`
|
||||
UpdateAt int64 `json:"updateAt"`
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
project.POST("/add", e.ErrorWrapper(hs.AddProject))
|
||||
project.POST("/edit", e.ErrorWrapper(hs.EditProject))
|
||||
project.POST("/delete", e.ErrorWrapper(hs.DelProject))
|
||||
project.POST("/result", e.ErrorWrapper(hs.GetProjectResult))
|
||||
|
||||
}
|
||||
product := manage.Group("/product")
|
||||
|
@ -141,6 +142,7 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
model.POST("/edit", e.ErrorWrapper(hs.EditModel))
|
||||
model.POST("/delete", e.ErrorWrapper(hs.DelModel))
|
||||
model.POST("/issue", e.ErrorWrapper(hs.ModelIssue))
|
||||
model.POST("/issueLog", e.ErrorWrapper(hs.ModelIssueLog))
|
||||
model.POST("/workflow", e.ErrorWrapper(hs.GetModelWorkflow))
|
||||
}
|
||||
file := r.Group("/file")
|
||||
|
@ -224,8 +226,12 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
})
|
||||
train := task.Group("/train")
|
||||
{
|
||||
train.POST("/create", e.ErrorWrapper(hs.CreateTrainingTask))
|
||||
train.POST("/edit", e.ErrorWrapper(hs.EditTrainingTask))
|
||||
train.POST("/reRun", e.ErrorWrapper(hs.ReRunTrainingTask))
|
||||
train.POST("/list", e.ErrorWrapper(hs.TrainingTaskList))
|
||||
train.POST("/info", e.ErrorWrapper(hs.TrainingTaskInfo))
|
||||
train.POST("/result", e.ErrorWrapper(hs.TrainingTaskResult))
|
||||
train.POST("/log", e.ErrorWrapper(hs.TrainingTaskLog))
|
||||
}
|
||||
}
|
||||
|
@ -233,6 +239,8 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
{
|
||||
disease.Use(middleware.JwtAuthMiddleware(logger.Logger))
|
||||
disease.POST("/list", e.ErrorWrapper(hs.DiseaseList))
|
||||
disease.POST("/statistics", e.ErrorWrapper(hs.DiseaseStatistics))
|
||||
disease.POST("/create", e.ErrorWrapper(hs.CreateTrainDatasetByDisease))
|
||||
diseaseType := disease.Group("/type")
|
||||
{
|
||||
diseaseType.POST("/list", e.ErrorWrapper(hs.DiseaseTypeList))
|
||||
|
@ -283,6 +291,11 @@ func InitRouter(cfg *config.WebConfig, logger *logging.Logger, engine *xorm.Engi
|
|||
}
|
||||
|
||||
}
|
||||
analysis := r.Group("/analysis")
|
||||
{
|
||||
analysis.Use(middleware.JwtAuthMiddleware(logger.Logger))
|
||||
analysis.POST("/info", e.ErrorWrapper(hs.GetAnalysisInfo))
|
||||
}
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
|
|
@ -108,15 +108,25 @@ func (rp *repo) DatasetList(ctx context.Context, req proto.DatasetRequest) (rsp
|
|||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
||||
type QuantityStatistics struct {
|
||||
TotalNumber int64
|
||||
TotalSize int64
|
||||
}
|
||||
data := make([]proto.DatasetItem, len(list))
|
||||
for k, v := range list {
|
||||
detailList := make([]model.FileManager, 0)
|
||||
datasetCount, err := rp.engine.Where("dataset_id = ?", v.DatasetId).And("data_type=1").FindAndCount(&detailList)
|
||||
datasetCount, err := rp.engine.Where("dataset_id = ?", v.DatasetId).FindAndCount(&detailList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
fm := new(model.FileManager)
|
||||
datasetSize, err := rp.engine.Where("dataset_id = ?", v.DatasetId).And("data_type=1").SumInt(fm, "file_size")
|
||||
datasetSize, err := rp.engine.Where("dataset_id = ?", v.DatasetId).SumInt(fm, "file_size")
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
qs := new(QuantityStatistics)
|
||||
_, err = rp.engine.SQL(`select sum(file_size) total_size, count(file_id) total_number from file_manager where is_disease > 0`).Get(qs)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
@ -132,6 +142,8 @@ func (rp *repo) DatasetList(ctx context.Context, req proto.DatasetRequest) (rsp
|
|||
CreateAt: v.CreateAt,
|
||||
DatasetCount: datasetCount,
|
||||
DatasetSize: datasetSize,
|
||||
LabelCount: qs.TotalNumber,
|
||||
LabelSize: qs.TotalSize,
|
||||
}
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
|
|
|
@ -4,9 +4,13 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"git.hpds.cc/Component/logging"
|
||||
"go.uber.org/zap"
|
||||
"hpds-iot-web/config"
|
||||
"hpds-iot-web/internal/proto"
|
||||
"hpds-iot-web/model"
|
||||
"hpds-iot-web/pkg/utils"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"time"
|
||||
"xorm.io/xorm"
|
||||
|
@ -14,10 +18,14 @@ import (
|
|||
|
||||
type DiseaseService interface {
|
||||
DiseaseList(ctx context.Context, req proto.DiseaseRequest) (rsp *proto.BaseResponse, err error)
|
||||
DiseaseListNew(ctx context.Context, req proto.DiseaseRequest) (rsp *proto.BaseResponse, err error)
|
||||
DiseaseStatistics(ctx context.Context) (rsp *proto.BaseResponse, err error)
|
||||
DiseaseTypeList(ctx context.Context, req proto.DiseaseTypeRequest) (rsp *proto.BaseResponse, err error)
|
||||
AddDiseaseType(ctx context.Context, req proto.DiseaseTypeItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
EditDiseaseType(ctx context.Context, req proto.DiseaseTypeItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
DeleteDiseaseType(ctx context.Context, req proto.DiseaseTypeItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
||||
CreateTrainDatasetByDisease(ctx context.Context, req proto.TrainDatasetRequest) (rsp *proto.BaseResponse, err error)
|
||||
}
|
||||
|
||||
func NewDiseaseService(cfg *config.WebConfig, engine *xorm.Engine, logger *logging.Logger) DiseaseService {
|
||||
|
@ -41,7 +49,7 @@ func (rp *repo) DiseaseList(ctx context.Context, req proto.DiseaseRequest) (rsp
|
|||
default:
|
||||
data := make([]model.Disease, 0)
|
||||
count, err := rp.engine.Where("(? = '' or disease_name like ?)", req.Key, "%"+req.Key+"%").
|
||||
And("(? = 0 or category_id = ?)", req.BizType, req.BizType).
|
||||
And("(? = 0 or category_id = ?)", req.DiseaseType, req.DiseaseType).
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&data)
|
||||
if err != nil {
|
||||
|
@ -64,6 +72,127 @@ ReturnPoint:
|
|||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) DiseaseListNew(ctx context.Context, req proto.DiseaseRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var count int64
|
||||
list := make([]model.LabelFile, 0)
|
||||
count, err = rp.engine.Where("(? = 0 or category_id = ?)", req.DiseaseType, req.DiseaseType).
|
||||
And("(?=0 or file_type = ?)", req.FileType, req.FileType).
|
||||
And("(?=0 or label_type = ?)", req.LabelType, req.LabelType).
|
||||
And("(?=-1 or pid = ?)", req.Pid, req.Pid).
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
data := make([]proto.DiseaseFileInfoItem, len(list))
|
||||
for k, v := range list {
|
||||
item := proto.DiseaseFileInfoItem{
|
||||
FileId: v.FileId,
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
CategoryId: v.CategoryId,
|
||||
CategoryName: model.GetBizType(v.CategoryId),
|
||||
FileSize: v.FileSize,
|
||||
LabelType: v.LabelType,
|
||||
FileType: v.FileType,
|
||||
FileTypeName: model.GetFileType(v.FileType),
|
||||
LabelTypeName: model.GetLabelType(v.LabelType),
|
||||
CreateAt: v.CreateAt,
|
||||
UpdateAt: v.UpdateAt,
|
||||
Pid: v.Pid,
|
||||
}
|
||||
if item.FileType == 1 || (item.FileType == 3 && item.Pid > 0) {
|
||||
item.FileContent = utils.ImgFileToBase64(v.FilePath)
|
||||
}
|
||||
if item.FileType == 2 {
|
||||
item.FileContent = utils.FileToBase64(v.FilePath)
|
||||
}
|
||||
|
||||
data[k] = item
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp = FillPaging(count, req.Page, req.Size, data, rsp)
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) DiseaseStatistics(ctx context.Context) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
list := make([]*proto.DiseaseStatisticsItem, 5)
|
||||
type Statistics struct {
|
||||
CategoryId int
|
||||
TotalCount int64
|
||||
TotalSize int64
|
||||
}
|
||||
//所有的数据
|
||||
statList := make([]Statistics, 0)
|
||||
err = rp.engine.SQL(`select category_id, sum(file_size) total_size, count(file_id) total_count from label_file group by category_id;`).Find(&statList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
totalItem := &proto.DiseaseStatisticsItem{
|
||||
DiseaseType: 0,
|
||||
DiseaseName: "数据量总计",
|
||||
}
|
||||
for _, v := range statList {
|
||||
item := &proto.DiseaseStatisticsItem{
|
||||
DiseaseType: v.CategoryId,
|
||||
DiseaseName: model.GetBizType(v.CategoryId) + "数据",
|
||||
TotalNum: v.TotalCount,
|
||||
TotalSize: v.TotalSize,
|
||||
}
|
||||
totalItem.TotalNum += v.TotalCount
|
||||
totalItem.TotalSize += v.TotalSize
|
||||
list[v.CategoryId] = item
|
||||
}
|
||||
list[0] = totalItem
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Data = list
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) DiseaseTypeList(ctx context.Context, req proto.DiseaseTypeRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
|
@ -229,3 +358,260 @@ ReturnPoint:
|
|||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) CreateTrainDatasetByDisease(ctx context.Context, req proto.TrainDatasetRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
//trainFileList []model.LabelFile
|
||||
trainDiseaseFileList []model.LabelFile
|
||||
trainNoDiseaseFileList []model.LabelFile
|
||||
//valFileList []model.LabelFile
|
||||
valDiseaseFileList []model.LabelFile
|
||||
valNoDiseaseFileList []model.LabelFile
|
||||
//testFileList []model.LabelFile
|
||||
testDiseaseFileList []model.LabelFile
|
||||
testNoDiseaseFileList []model.LabelFile
|
||||
trainDiseaseCount int64
|
||||
trainNoDiseaseCount int64
|
||||
//wg sync.WaitGroup
|
||||
)
|
||||
log := new(model.DatasetOperationLog)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
fileList := make([]model.LabelFile, 0)
|
||||
err = rp.engine.Where("category_id = ? and file_type = 1", req.BizType).Find(&fileList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
trainDiseaseFileList = make([]model.LabelFile, 0)
|
||||
err = rp.engine.Where("category_id = ? and label_type = 1 and file_type = 1", req.BizType).Find(&trainDiseaseFileList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
trainNoDiseaseFileList = make([]model.LabelFile, 0)
|
||||
err = rp.engine.Where("category_id = ? and label_type = 2 and file_type = 1", req.BizType).Find(&trainNoDiseaseFileList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
||||
if req.TargetData == 0 {
|
||||
req.TargetData = len(fileList)
|
||||
}
|
||||
if req.TargetData > len(fileList) {
|
||||
err = fmt.Errorf("超出现有标注数据集数量")
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
||||
trainNumber := int(math.Floor(float64(int64(req.TargetData)*req.TrainNumber) / 100))
|
||||
valNumber := int(math.Floor(float64(int64(req.TargetData)*req.ValidationNumber) / 100))
|
||||
testNumber := req.TargetData - trainNumber - valNumber
|
||||
trainDiseaseCount = int64(float64(int64(len(trainDiseaseFileList))*req.TrainNumber) / 100)
|
||||
trainNoDiseaseCount = int64(float64(int64(len(trainNoDiseaseFileList))*req.TrainNumber) / 100)
|
||||
if trainDiseaseCount+trainNoDiseaseCount > int64(trainNumber) {
|
||||
if trainDiseaseCount > int64(trainNumber/2) {
|
||||
trainDiseaseCount = int64(trainNumber / 2)
|
||||
}
|
||||
if trainNoDiseaseCount > int64(trainNumber)-trainDiseaseCount {
|
||||
trainNoDiseaseCount = int64(trainNumber) - trainDiseaseCount
|
||||
}
|
||||
}
|
||||
|
||||
valDiseaseCount := int64(float64(int64(len(trainDiseaseFileList))*req.ValidationNumber) / 100)
|
||||
valNoDiseaseCount := int64(float64(int64(len(trainNoDiseaseFileList))*req.ValidationNumber) / 100)
|
||||
if valDiseaseCount+valNoDiseaseCount > int64(valNumber) {
|
||||
if valDiseaseCount > int64(valNumber/2) {
|
||||
valDiseaseCount = int64(valNumber / 2)
|
||||
}
|
||||
if valNoDiseaseCount > int64(valNumber)-valDiseaseCount {
|
||||
valNoDiseaseCount = int64(valNumber) - valDiseaseCount
|
||||
}
|
||||
}
|
||||
|
||||
testDiseaseCount := int64(float64(int64(len(trainDiseaseFileList))*req.TestNumber) / 100)
|
||||
testNoDiseaseCount := int64(float64(int64(len(trainNoDiseaseFileList))*req.TestNumber) / 100)
|
||||
if testDiseaseCount+testNoDiseaseCount > int64(testNumber) {
|
||||
if testDiseaseCount > int64(testNumber/2) {
|
||||
testDiseaseCount = int64(testNumber / 2)
|
||||
}
|
||||
if testNoDiseaseCount > int64(testNumber)-testDiseaseCount {
|
||||
testNoDiseaseCount = int64(testNumber) - testDiseaseCount
|
||||
}
|
||||
}
|
||||
|
||||
if req.SplitMethod == 1 {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.Shuffle(len(trainDiseaseFileList), func(i, j int) {
|
||||
trainDiseaseFileList[i], trainDiseaseFileList[j] = trainDiseaseFileList[j], trainDiseaseFileList[i]
|
||||
})
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.Shuffle(len(trainNoDiseaseFileList), func(i, j int) {
|
||||
trainNoDiseaseFileList[i], trainNoDiseaseFileList[j] = trainNoDiseaseFileList[j], trainNoDiseaseFileList[i]
|
||||
})
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rand.Shuffle(len(fileList), func(i, j int) {
|
||||
fileList[i], fileList[j] = fileList[j], fileList[i]
|
||||
})
|
||||
}
|
||||
testDiseaseFileList = trainDiseaseFileList[:testDiseaseCount]
|
||||
testNoDiseaseFileList = trainNoDiseaseFileList[:testNoDiseaseCount]
|
||||
valDiseaseFileList = trainDiseaseFileList[testDiseaseCount : testDiseaseCount+valDiseaseCount]
|
||||
valNoDiseaseFileList = trainNoDiseaseFileList[testNoDiseaseCount : testNoDiseaseCount+valNoDiseaseCount]
|
||||
trainDiseaseFileList = trainDiseaseFileList[testDiseaseCount+valDiseaseCount : testDiseaseCount+valDiseaseCount+trainDiseaseCount]
|
||||
trainNoDiseaseFileList = trainNoDiseaseFileList[testNoDiseaseCount+valNoDiseaseCount : testNoDiseaseCount+valNoDiseaseCount+trainNoDiseaseCount]
|
||||
rp.logger.With(zap.String("创建训练集", "数据集大小"),
|
||||
zap.Int("有病害训练数据集", len(trainDiseaseFileList)),
|
||||
zap.Int("无病害训练数据集", len(trainNoDiseaseFileList)),
|
||||
zap.Int("有病害验证数据集", len(valDiseaseFileList)),
|
||||
zap.Int("无病害验证数据集", len(valNoDiseaseFileList)),
|
||||
).Info("总数据集", zap.Int("len(fileList)", len(fileList)))
|
||||
train := new(model.TrainingDataset)
|
||||
h, err = rp.engine.Where("name = ?", req.TrainName).Get(train)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
train.Name = req.TrainName
|
||||
train.DatasetDesc = req.TrainDesc
|
||||
//train.DatasetId = req.DatasetId
|
||||
train.CategoryId = req.BizType
|
||||
train.ValidationNumber = float64(req.ValidationNumber)
|
||||
train.TestNumber = float64(req.TestNumber)
|
||||
_, err = rp.engine.Insert(train)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
}
|
||||
log.TargetData = int64(req.TargetData)
|
||||
log.DatasetId = req.DatasetId
|
||||
log.TrainingDatasetId = train.DatasetId
|
||||
log.SplitMethod = req.SplitMethod
|
||||
log.TrainNumber = int64(trainNumber)
|
||||
log.ValidationNumber = int64(valNumber)
|
||||
log.TestNumber = int64(testNumber)
|
||||
log.Creator = req.UserId
|
||||
_, err = rp.engine.Insert(log)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
list := make([]model.TrainingDatasetDetail, 0)
|
||||
for _, v := range trainDiseaseFileList {
|
||||
item := model.TrainingDatasetDetail{
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
DatasetId: train.DatasetId,
|
||||
CategoryId: 1,
|
||||
FileSize: v.FileSize,
|
||||
IsDisease: 1,
|
||||
OperationLogId: log.LogId,
|
||||
Creator: req.UserId,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
for _, v := range trainNoDiseaseFileList {
|
||||
item := model.TrainingDatasetDetail{
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
DatasetId: train.DatasetId,
|
||||
CategoryId: 1,
|
||||
FileSize: v.FileSize,
|
||||
IsDisease: 2,
|
||||
OperationLogId: log.LogId,
|
||||
Creator: req.UserId,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
for _, v := range valDiseaseFileList {
|
||||
item := model.TrainingDatasetDetail{
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
DatasetId: train.DatasetId,
|
||||
CategoryId: 3,
|
||||
FileSize: v.FileSize,
|
||||
IsDisease: 1,
|
||||
OperationLogId: log.LogId,
|
||||
Creator: req.UserId,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
for _, v := range valNoDiseaseFileList {
|
||||
item := model.TrainingDatasetDetail{
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
DatasetId: train.DatasetId,
|
||||
CategoryId: 3,
|
||||
FileSize: v.FileSize,
|
||||
IsDisease: 2,
|
||||
OperationLogId: log.LogId,
|
||||
Creator: req.UserId,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
for _, v := range testDiseaseFileList {
|
||||
item := model.TrainingDatasetDetail{
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
DatasetId: train.DatasetId,
|
||||
CategoryId: 2,
|
||||
FileSize: v.FileSize,
|
||||
IsDisease: 1,
|
||||
OperationLogId: log.LogId,
|
||||
Creator: req.UserId,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
for _, v := range testNoDiseaseFileList {
|
||||
item := model.TrainingDatasetDetail{
|
||||
FileName: v.FileName,
|
||||
FilePath: v.FilePath,
|
||||
DatasetId: train.DatasetId,
|
||||
CategoryId: 2,
|
||||
FileSize: v.FileSize,
|
||||
IsDisease: 2,
|
||||
OperationLogId: log.LogId,
|
||||
Creator: req.UserId,
|
||||
CreateAt: time.Now().Unix(),
|
||||
UpdateAt: time.Now().Unix(),
|
||||
}
|
||||
list = append(list, item)
|
||||
}
|
||||
_, err = rp.engine.Insert(list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Err = err
|
||||
rsp.Data = log
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"git.hpds.cc/Component/logging"
|
||||
"hpds-iot-web/config"
|
||||
"hpds-iot-web/internal/proto"
|
||||
"hpds-iot-web/model"
|
||||
"hpds-iot-web/pkg/utils"
|
||||
"net/http"
|
||||
"xorm.io/xorm"
|
||||
|
@ -36,11 +37,26 @@ func (rp *repo) GetEdgeList(ctx context.Context, req proto.EdgeDatasetRequest) (
|
|||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
param := make(map[string]string)
|
||||
var (
|
||||
h bool
|
||||
)
|
||||
node := new(model.Node)
|
||||
h, err = rp.engine.ID(req.NodeId).Get(node)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("设备未在线")
|
||||
goto ReturnPoint
|
||||
}
|
||||
param := make(map[string]interface{})
|
||||
param["path"] = req.Path
|
||||
param["page"] = int(req.Page)
|
||||
param["pageSize"] = int(req.Size)
|
||||
|
||||
header := make(map[string]string)
|
||||
header["Content-Type"] = "application/json"
|
||||
res, err := utils.HttpDo("http://192.168.22.151:8099/api/directory/list", "POST", param, header)
|
||||
res, err := utils.HttpDo(fmt.Sprintf("http://%s:8099/api/directory/list", node.LocalIP), "POST", param, header)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
@ -71,11 +87,23 @@ func (rp *repo) GetEdgeInfo(ctx context.Context, req proto.EdgeDatasetRequest) (
|
|||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
param := make(map[string]string)
|
||||
var (
|
||||
h bool
|
||||
)
|
||||
node := new(model.Node)
|
||||
h, err = rp.engine.ID(req.NodeId).Get(node)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("设备未在线")
|
||||
goto ReturnPoint
|
||||
}
|
||||
param := make(map[string]interface{})
|
||||
param["path"] = req.Path
|
||||
header := make(map[string]string)
|
||||
header["Content-Type"] = "application/json"
|
||||
res, err := utils.HttpDo("http://192.168.22.151:8099/api/directory/info", "POST", param, header)
|
||||
res, err := utils.HttpDo(fmt.Sprintf("http://%s:8099/api/directory/info", node.LocalIP), "POST", param, header)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ type ManageService interface {
|
|||
AddProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
EditProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
DelProject(ctx context.Context, req proto.ProjectItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetProjectResult(ctx context.Context, req proto.ProjectRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
||||
ProductList(ctx context.Context, req proto.ProductRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetProductInfo(ctx context.Context, req proto.ProductItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
@ -381,6 +382,7 @@ func (rp *repo) AddProject(ctx context.Context, req proto.ProjectItemRequest) (r
|
|||
Direction: req.Direction,
|
||||
LaneNum: req.LaneNum,
|
||||
Status: 1,
|
||||
SideType: req.SideType,
|
||||
Creator: req.Creator,
|
||||
}
|
||||
var (
|
||||
|
@ -470,6 +472,9 @@ func (rp *repo) EditProject(ctx context.Context, req proto.ProjectItemRequest) (
|
|||
if req.OwnerId > 0 {
|
||||
item.OwnerId = req.OwnerId
|
||||
}
|
||||
if req.BizType > 0 {
|
||||
item.BizType = req.BizType
|
||||
}
|
||||
if len(req.LineName) > 0 {
|
||||
item.LineName = req.LineName
|
||||
}
|
||||
|
@ -500,6 +505,9 @@ func (rp *repo) EditProject(ctx context.Context, req proto.ProjectItemRequest) (
|
|||
if req.LaneNum > 0 {
|
||||
item.LaneNum = req.LaneNum
|
||||
}
|
||||
if req.SideType > 0 && item.SideType != req.SideType {
|
||||
item.SideType = req.SideType
|
||||
}
|
||||
_, err = rp.engine.ID(req.ProjectId).AllCols().Update(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
|
@ -563,6 +571,81 @@ ReturnPoint:
|
|||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) GetProjectResult(ctx context.Context, req proto.ProjectRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
count int64
|
||||
)
|
||||
project := new(model.Project)
|
||||
h, err = rp.engine.ID(req.ProjectId).Get(project)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("未找到对应的项目")
|
||||
goto ReturnPoint
|
||||
}
|
||||
if project.BizType == 4 {
|
||||
if project.SideType == 1 {
|
||||
list := make([]model.MultiLevelPlatform, 0)
|
||||
count, err = rp.engine.Where("project_id=?", req.ProjectId).
|
||||
And("(? = 0 or multi_level_platform_type=?)", req.SideType, req.SideType).
|
||||
Asc("created_at").
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
rsp = FillPaging(count, req.Page, req.Size, list, rsp)
|
||||
} else {
|
||||
list := make([]model.Gnss, 0)
|
||||
count, err = rp.engine.Where("project_id=?", req.ProjectId).
|
||||
And("(? = 0 or gnss_type=?)", req.SideType, req.SideType).
|
||||
Asc("created_at").
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
rsp = FillPaging(count, req.Page, req.Size, list, rsp)
|
||||
}
|
||||
} else {
|
||||
list := make([]model.ProjectResult, 0)
|
||||
count, err = rp.engine.Where("project_id=?", req.ProjectId).Asc("source_result_id").
|
||||
Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
rsp = FillPaging(count, req.Page, req.Size, list, rsp)
|
||||
}
|
||||
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) ProductList(ctx context.Context, req proto.ProductRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
|
|
|
@ -22,6 +22,7 @@ type ModelService interface {
|
|||
EditModel(ctx context.Context, req proto.ModelItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
DelModel(ctx context.Context, req proto.ModelItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
ModelIssue(ctx context.Context, req proto.ModelIssueRequest) (rsp *proto.BaseResponse, err error)
|
||||
ModelIssueLog(ctx context.Context, req proto.ModelIssueLogRequest) (rsp *proto.BaseResponse, err error)
|
||||
GetModelWorkflow(ctx context.Context, req proto.ModelItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
}
|
||||
|
||||
|
@ -46,6 +47,7 @@ func (rp *repo) ModelList(ctx context.Context, req proto.ModelRequest) (rsp *pro
|
|||
default:
|
||||
data := make([]model.Model, 0)
|
||||
count, err := rp.engine.Where("(? = '' or model_name like ?)", req.ModelName, "%"+req.ModelName+"%").
|
||||
And("(?=0 or biz_type=?)", req.BizType, req.BizType).
|
||||
And("status = 1").Limit(int(req.Size), int(((req.Page)-1)*req.Size)).
|
||||
FindAndCount(&data)
|
||||
if err != nil {
|
||||
|
@ -290,6 +292,7 @@ func (rp *repo) ModelIssue(ctx context.Context, req proto.ModelIssueRequest) (rs
|
|||
}
|
||||
item.ModelId = req.ModelId
|
||||
item.NodeId = req.NodeId
|
||||
item.Status = 1
|
||||
item.CreateAt = time.Now().Unix()
|
||||
item.UpdateAt = time.Now().Unix()
|
||||
_, err = rp.engine.Insert(item)
|
||||
|
@ -331,6 +334,66 @@ ReturnPoint:
|
|||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) ModelIssueLog(ctx context.Context, req proto.ModelIssueLogRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
count int64
|
||||
)
|
||||
m := new(model.Model)
|
||||
h, err = rp.engine.ID(req.ModelId).Get(m)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("未能找到对应的模型")
|
||||
goto ReturnPoint
|
||||
}
|
||||
logList := make([]model.IssueModel, 0)
|
||||
count, err = rp.engine.Where("model_id=?", req.ModelId).FindAndCount(&logList)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
list := make([]proto.ModelIssueLogItem, len(logList))
|
||||
for k, v := range logList {
|
||||
list[k] = proto.ModelIssueLogItem{
|
||||
Id: v.Id,
|
||||
ModelId: v.ModelId,
|
||||
NodeId: v.NodeId,
|
||||
NodeName: model.GetNodeName(v.NodeId),
|
||||
Status: v.Status,
|
||||
IssueResult: v.IssueResult,
|
||||
CreateAt: v.CreateAt,
|
||||
UpdateAt: v.UpdateAt,
|
||||
}
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "获取模型下发日志成功"
|
||||
rsp.Err = ctx.Err()
|
||||
rsp = FillPaging(count, req.Page, req.Size, list, rsp)
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
|
||||
}
|
||||
|
||||
func (rp *repo) GetModelWorkflow(ctx context.Context, req proto.ModelItemRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
|
|
|
@ -23,6 +23,8 @@ type SystemService interface {
|
|||
EditNode(ctx context.Context, req proto.NodeItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
NodeState(ctx context.Context, req proto.NodeInfoRequest) (rsp *proto.BaseResponse, err error)
|
||||
NodeLastState(ctx context.Context, req proto.NodeInfoRequest) (rsp *proto.BaseResponse, err error)
|
||||
|
||||
GetAnalysisInfo(ctx context.Context) (rsp *proto.BaseResponse, err error)
|
||||
}
|
||||
|
||||
func NewSystemService(engine *xorm.Engine, logger *logging.Logger) SystemService {
|
||||
|
@ -456,7 +458,7 @@ c.disk_total,c.swap_total,a.c_p_u cpu_used,c.node_status, a.mem_used,a.swap_used
|
|||
a.net_out_speed, a.net_out_transfer, a.load1, a.load5, a.load15, a.tcp_conn_count, a.udp_conn_count, a.process_count,
|
||||
d.task_name exec_task from node_state a , (select node_name, max(uptime) uptime from node_state group by node_name) b, node c
|
||||
left join (select t2.node_id, t2.task_name from task t2, (select node_id, max(start_time) start from task group by node_id) t1 where t2.node_id = t1.node_id and t2.start_time = t1.start and t2.status = 1) d on c.node_id = d.node_id
|
||||
where a.node_name = b.node_name and a.uptime = b.uptime and a.node_name = c.node_guid and c.node_status > 0 and (? = '' or a.node_name = ?) `, req.NodeGuid, req.NodeGuid).Find(&list)
|
||||
where a.node_name = b.node_name and a.uptime = b.uptime and a.node_name = c.node_name and c.node_status > 0 and (? = '' or a.node_name = ?) `, req.NodeGuid, req.NodeGuid).Find(&list)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
@ -478,3 +480,105 @@ ReturnPoint:
|
|||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) GetAnalysisInfo(ctx context.Context) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
data := new(proto.AnalysisInfo)
|
||||
type AnalysisItem struct {
|
||||
BizType int
|
||||
Total int64
|
||||
}
|
||||
modelTotal := make([]AnalysisItem, 0)
|
||||
err = rp.engine.SQL(`select biz_type, count(model_id) total from model where status = 1 group by biz_type`).Find(&modelTotal)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
for _, v := range modelTotal {
|
||||
switch v.BizType {
|
||||
case 1:
|
||||
data.RoadModel = v.Total
|
||||
case 2:
|
||||
data.BridgeModel = v.Total
|
||||
case 3:
|
||||
data.TunnelModel = v.Total
|
||||
case 4:
|
||||
data.SideSlopeModel = v.Total
|
||||
}
|
||||
data.ModelTotal += v.Total
|
||||
}
|
||||
projectTotal := make([]AnalysisItem, 0)
|
||||
err = rp.engine.SQL(`select biz_type, count(project_id) total from project where status = 1 group by biz_type`).Find(&projectTotal)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
for _, v := range projectTotal {
|
||||
switch v.BizType {
|
||||
case 1:
|
||||
data.RoadProject = v.Total
|
||||
case 2:
|
||||
data.BridgeProject = v.Total
|
||||
case 3:
|
||||
data.TunnelProject = v.Total
|
||||
case 4:
|
||||
data.SideSlopeProject = v.Total
|
||||
}
|
||||
data.ProjectTotal += v.Total
|
||||
}
|
||||
deviceTotal := make([]AnalysisItem, 0)
|
||||
err = rp.engine.SQL(`select node_type biz_type, count(node_id) total from node group by node_type`).Find(&deviceTotal)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
for _, v := range deviceTotal {
|
||||
switch v.BizType {
|
||||
case 1:
|
||||
data.CloudDevice = v.Total
|
||||
case 2:
|
||||
data.EdgeDevice = v.Total
|
||||
}
|
||||
data.DeviceTotal += v.Total
|
||||
}
|
||||
labelTotal := make([]AnalysisItem, 0)
|
||||
err = rp.engine.SQL(`select category_id biz_type, sum(file_size) total from label_file group by category_id`).Find(&labelTotal)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
for _, v := range labelTotal {
|
||||
switch v.BizType {
|
||||
case 1:
|
||||
data.RoadLabelData = v.Total
|
||||
case 2:
|
||||
data.BridgeLabelData = v.Total
|
||||
case 3:
|
||||
data.TunnelLabelData = v.Total
|
||||
case 4:
|
||||
data.SideSlopeLabelData = v.Total
|
||||
}
|
||||
data.TotalLabelData += v.Total
|
||||
}
|
||||
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "获取统计数据"
|
||||
rsp.Err = ctx.Err()
|
||||
rsp.Data = data
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ type TaskService interface {
|
|||
TrainingTaskList(ctx context.Context, req proto.TaskRequest) (rsp *proto.BaseResponse, err error)
|
||||
TrainingTaskInfo(ctx context.Context, req proto.TaskItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
TrainingTaskLog(ctx context.Context, req proto.TaskItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
TrainingTaskResult(ctx context.Context, req proto.TaskItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
CreateTrainingTask(ctx context.Context, req proto.TrainingTaskItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
EditTrainingTask(ctx context.Context, req proto.TrainingTaskItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
ReRunTrainingTask(ctx context.Context, req proto.TrainingTaskItemRequest) (rsp *proto.BaseResponse, err error)
|
||||
}
|
||||
|
||||
func NewTaskService(engine *xorm.Engine, logger *logging.Logger) TaskService {
|
||||
|
@ -504,7 +508,7 @@ func (rp *repo) TaskResult(ctx context.Context, req proto.ReportRequest) (rsp *p
|
|||
continue
|
||||
}
|
||||
fileDiscern = ir.Image
|
||||
for _, value := range ir.Diseases {
|
||||
for key, value := range ir.Diseases {
|
||||
diseaseType = model.GetDiseaseType(value.Type, md.BizType)
|
||||
if len(value.Param.MaxWidth) > 0 && width == 0 {
|
||||
width, _ = strconv.ParseFloat(value.Param.MaxWidth, 64)
|
||||
|
@ -521,7 +525,7 @@ func (rp *repo) TaskResult(ctx context.Context, req proto.ReportRequest) (rsp *p
|
|||
case "轻度":
|
||||
diseaseLevel = 1
|
||||
}
|
||||
memo += fmt.Sprintf("发现[%s],等级[%s],长度[%f],最大宽度[%s],面积[%f];\n", value.Type, value.Level, value.Param.Length, value.Param.MaxWidth, value.Param.Area)
|
||||
memo += fmt.Sprintf("%d. 发现[%s],等级[%s],长度[%f],最大宽度[%s],面积[%f];\n", key+1, value.Type, value.Level, value.Param.Length, value.Param.MaxWidth, value.Param.Area)
|
||||
}
|
||||
fn, _ := base64.StdEncoding.DecodeString(fileDiscern)
|
||||
buff := bytes.NewBuffer(fn)
|
||||
|
@ -747,8 +751,8 @@ func (rp *repo) TrainingTaskInfo(ctx context.Context, req proto.TaskItemRequest)
|
|||
var (
|
||||
h bool
|
||||
)
|
||||
item := new(model.TrainTask)
|
||||
h, err = rp.engine.ID(req.TaskId).Get(item)
|
||||
task := new(model.TrainTask)
|
||||
h, err = rp.engine.ID(req.TaskId).Get(task)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
@ -756,6 +760,28 @@ func (rp *repo) TrainingTaskInfo(ctx context.Context, req proto.TaskItemRequest)
|
|||
err = fmt.Errorf("未能找到对应的任务信息")
|
||||
goto ReturnPoint
|
||||
}
|
||||
item := new(proto.TrainTaskInfoItem)
|
||||
item.TaskId = task.TaskId
|
||||
item.TrainDatasetId = task.TrainDatasetId
|
||||
item.TrainDatasetName = model.GetTrainDatasetName(task.TrainDatasetId)
|
||||
item.CategoryId = task.CategoryId
|
||||
item.CategoryName = model.GetBizType(task.CategoryId)
|
||||
item.TaskName = task.TaskName
|
||||
item.TaskDesc = task.TaskDesc
|
||||
item.Arithmetic = task.Arithmetic
|
||||
item.ImageSize = task.ImageSize
|
||||
item.BatchSize = task.BatchSize
|
||||
item.EpochsSize = task.EpochsSize
|
||||
item.OutputType = task.OutputType
|
||||
item.StartTime = task.StartTime
|
||||
item.FinishTime = task.FinishTime
|
||||
item.Loss = task.Loss
|
||||
item.Accuracy = task.Accuracy
|
||||
item.ModelFilePath = task.ModelFilePath
|
||||
item.ModelFileMetricsPath = task.ModelFileMetricsPath
|
||||
item.Status = task.Status
|
||||
item.CreateAt = task.CreateAt
|
||||
item.UpdateAt = task.UpdateAt
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
|
@ -806,3 +832,247 @@ ReturnPoint:
|
|||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
||||
func (rp *repo) TrainingTaskResult(ctx context.Context, req proto.TaskItemRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
)
|
||||
item := new(model.TrainTaskResult)
|
||||
h, err = rp.engine.Where("task_id = ?", req.TaskId).Desc("create_at").Get(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("任务还未训练完成")
|
||||
goto ReturnPoint
|
||||
}
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Err = err
|
||||
rsp.Data = item
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
|
||||
}
|
||||
|
||||
func (rp *repo) CreateTrainingTask(ctx context.Context, req proto.TrainingTaskItemRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
)
|
||||
item := new(model.TrainTask)
|
||||
h, err = rp.engine.Where("task_name=?", req.ModelName).Get(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if h {
|
||||
err = fmt.Errorf("已存在同名任务,请修改后继续")
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.TaskName = req.ModelName
|
||||
item.TrainDatasetId = req.DatasetId
|
||||
item.CategoryId = req.BizType
|
||||
item.TaskDesc = req.ModelDesc
|
||||
item.Arithmetic = req.Arithmetic
|
||||
item.ImageSize = req.ImageSize
|
||||
item.BatchSize = req.BatchSize
|
||||
item.EpochsSize = req.EpochsSize
|
||||
item.OutputType = req.OutputType
|
||||
item.StartTime = time.Now().Unix()
|
||||
item.Status = 2
|
||||
_, err = rp.engine.Insert(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
payload := make(map[string]interface{})
|
||||
payload["taskId"] = item.TaskId
|
||||
payload["taskName"] = item.TaskName
|
||||
payload["trainDatasetId"] = item.TrainDatasetId
|
||||
payload["arithmetic"] = item.Arithmetic
|
||||
payload["imageSize"] = item.ImageSize
|
||||
payload["batchSize"] = item.BatchSize
|
||||
payload["epochsSize"] = item.EpochsSize
|
||||
payload["outputType"] = item.OutputType
|
||||
payload["testSize"] = item.OutputType
|
||||
mqClient := mq.GetMqClient("task-request", 1)
|
||||
mqPayload := &mq.InstructionReq{
|
||||
Command: mq.TrainTaskAdd,
|
||||
Payload: payload,
|
||||
}
|
||||
pData, _ := json.Marshal(mqPayload)
|
||||
err = mq.GenerateAndSendData(mqClient.EndPoint.(hpds_node.AccessPoint), pData, rp.logger)
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
func (rp *repo) EditTrainingTask(ctx context.Context, req proto.TrainingTaskItemRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
)
|
||||
item := new(model.TrainTask)
|
||||
h, err = rp.engine.ID(req.TaskId).Get(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("为找到对应任务")
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.TaskName = req.ModelName
|
||||
item.TrainDatasetId = req.DatasetId
|
||||
item.CategoryId = req.BizType
|
||||
item.TaskDesc = req.ModelDesc
|
||||
item.Arithmetic = req.Arithmetic
|
||||
item.ImageSize = req.ImageSize
|
||||
item.BatchSize = req.BatchSize
|
||||
item.EpochsSize = req.EpochsSize
|
||||
item.OutputType = req.OutputType
|
||||
item.StartTime = time.Now().Unix()
|
||||
item.Status = 2
|
||||
_, err = rp.engine.ID(item.TaskId).AllCols().Update(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
|
||||
payload := make(map[string]interface{})
|
||||
payload["taskId"] = item.TaskId
|
||||
payload["taskName"] = item.TaskName
|
||||
payload["trainDatasetId"] = item.TrainDatasetId
|
||||
payload["arithmetic"] = item.Arithmetic
|
||||
payload["imageSize"] = item.ImageSize
|
||||
payload["batchSize"] = item.BatchSize
|
||||
payload["epochsSize"] = item.EpochsSize
|
||||
payload["outputType"] = item.OutputType
|
||||
payload["testSize"] = item.OutputType
|
||||
mqClient := mq.GetMqClient("task-request", 1)
|
||||
mqPayload := &mq.InstructionReq{
|
||||
Command: mq.TrainTaskAdd,
|
||||
Payload: payload,
|
||||
}
|
||||
pData, _ := json.Marshal(mqPayload)
|
||||
err = mq.GenerateAndSendData(mqClient.EndPoint.(hpds_node.AccessPoint), pData, rp.logger)
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
func (rp *repo) ReRunTrainingTask(ctx context.Context, req proto.TrainingTaskItemRequest) (rsp *proto.BaseResponse, err error) {
|
||||
rsp = new(proto.BaseResponse)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = fmt.Errorf("超时/取消")
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Message = "超时/取消"
|
||||
rsp.Err = ctx.Err()
|
||||
return rsp, ctx.Err()
|
||||
default:
|
||||
var (
|
||||
h bool
|
||||
)
|
||||
item := new(model.TrainTask)
|
||||
h, err = rp.engine.ID(req.TaskId).Get(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
if !h {
|
||||
err = fmt.Errorf("为找到对应任务")
|
||||
goto ReturnPoint
|
||||
}
|
||||
item.StartTime = time.Now().Unix()
|
||||
item.Status = 2
|
||||
_, err = rp.engine.ID(item.TaskId).AllCols().Update(item)
|
||||
if err != nil {
|
||||
goto ReturnPoint
|
||||
}
|
||||
payload := make(map[string]interface{})
|
||||
payload["taskId"] = item.TaskId
|
||||
payload["taskName"] = item.TaskName
|
||||
payload["trainDatasetId"] = item.TrainDatasetId
|
||||
payload["arithmetic"] = item.Arithmetic
|
||||
payload["imageSize"] = item.ImageSize
|
||||
payload["batchSize"] = item.BatchSize
|
||||
payload["epochsSize"] = item.EpochsSize
|
||||
payload["outputType"] = item.OutputType
|
||||
payload["testSize"] = item.OutputType
|
||||
mqClient := mq.GetMqClient("task-request", 1)
|
||||
mqPayload := &mq.InstructionReq{
|
||||
Command: mq.TrainTaskAdd,
|
||||
Payload: payload,
|
||||
}
|
||||
pData, _ := json.Marshal(mqPayload)
|
||||
err = mq.GenerateAndSendData(mqClient.EndPoint.(hpds_node.AccessPoint), pData, rp.logger)
|
||||
rsp.Code = http.StatusOK
|
||||
rsp.Status = http.StatusText(http.StatusOK)
|
||||
rsp.Message = "成功"
|
||||
rsp.Err = err
|
||||
return rsp, err
|
||||
}
|
||||
ReturnPoint:
|
||||
if err != nil {
|
||||
rsp.Code = http.StatusInternalServerError
|
||||
rsp.Status = http.StatusText(http.StatusInternalServerError)
|
||||
rsp.Err = err
|
||||
rsp.Message = "失败"
|
||||
}
|
||||
return rsp, err
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ type TaskLog struct {
|
|||
TaskLogId int64 `xorm:"not null pk autoincr BIGINT(11)" json:"taskLogId"`
|
||||
TaskId int64 `xorm:"INT(11) index" json:"taskId"`
|
||||
NodeId int64 `xorm:"INT(11) index" json:"nodeId"`
|
||||
Content string `xorm:"LANGTEXT" json:"content"`
|
||||
Content string `xorm:"LONGTEXT" json:"content"`
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
||||
|
|
|
@ -2,14 +2,15 @@ package model
|
|||
|
||||
type DatasetOperationLog struct {
|
||||
LogId int64 `xorm:"not null pk autoincr INT(11)" json:"logId"`
|
||||
DatasetId int64 `xorm:"INT(11) index" json:"datasetId"`
|
||||
TrainingDatasetId int64 `xorm:"INT(11) index" json:"trainingDatasetId"`
|
||||
TargetData int64 `xorm:"INT(11) default 0" json:"targetData"` //目标数据, 0:全量数据; n:指定数据量
|
||||
TrainNumber int64 `xorm:"INT(11)" json:"trainNumber"` //训练集数量
|
||||
ValidationNumber int64 `xorm:"INT(11)" json:"validationNumber"` //检验集数量
|
||||
TestNumber int64 `xorm:"INT(11)" json:"testNumber"` //测试集数量
|
||||
SplitMethod int `xorm:"SMALLINT default 1" json:"splitMethod"` //分割方式,1:随机分割;2:顺序分割
|
||||
Creator int64 `xorm:"INT(11) index" json:"creator"` //创建人
|
||||
CreateAt int64 `xorm:"created" json:"createAt"` //创建时间
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"` //更新时间
|
||||
DatasetId int64 `xorm:"INT(11) index" json:"datasetId"` //数据集为0时,代表该次操作来源为标注数据集
|
||||
TrainingDatasetId int64 `xorm:"INT(11) index" json:"trainingDatasetId"` //创建的训练数据集编号
|
||||
BizType int `xorm:"SMALLINT default 1 index" json:"bizType"` //数据集的业务分类
|
||||
TargetData int64 `xorm:"INT(11) default 0" json:"targetData"` //目标数据, 0:全量数据; n:指定数据量
|
||||
TrainNumber int64 `xorm:"INT(11)" json:"trainNumber"` //训练集数量
|
||||
ValidationNumber int64 `xorm:"INT(11)" json:"validationNumber"` //检验集数量
|
||||
TestNumber int64 `xorm:"INT(11)" json:"testNumber"` //测试集数量
|
||||
SplitMethod int `xorm:"SMALLINT default 1" json:"splitMethod"` //分割方式,1:随机分割;2:顺序分割
|
||||
Creator int64 `xorm:"INT(11) index" json:"creator"` //创建人
|
||||
CreateAt int64 `xorm:"created" json:"createAt"` //创建时间
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"` //更新时间
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package model
|
||||
|
||||
type Gnss struct {
|
||||
GnssId int64 `xorm:"not null pk autoincr INT(11)" json:"gnssId"` //
|
||||
ProjectId int64 `xorm:"INT(11) index" json:"projectId"` //项目编号
|
||||
GnssType int `xorm:"int default 0" json:"gnssType"` //GNSS类型
|
||||
AccumulativeDisplacementX float64 `xorm:"decimal(18,6)" json:"accumulativeDisplacementX"` //累计位移X(mm)
|
||||
AccumulativeDisplacementY float64 `xorm:"decimal(18,6)" json:"accumulativeDisplacementY"` //累计位移Y(mm)
|
||||
AccumulativeDisplacementH float64 `xorm:"decimal(18,6)" json:"accumulativeDisplacementH"` //累计位移H(mm)
|
||||
TwoDimensional float64 `xorm:"decimal(18,6)" json:"twoDimensional"` //2D
|
||||
ThreeDimensional float64 `xorm:"decimal(18,6)" json:"threeDimensional"` //3D
|
||||
CurrentDisplacementX float64 `xorm:"decimal(18,6)" json:"currentDisplacementX"` //当次位移X(mm)
|
||||
CurrentDisplacementY float64 `xorm:"decimal(18,6)" json:"currentDisplacementY"` //当次位移Y(mm)
|
||||
CurrentDisplacementH float64 `xorm:"decimal(18,6)" json:"currentDisplacementH"` //当次位移H(mm)
|
||||
Azimuth float64 `xorm:"decimal(18,6)" json:"azimuth"` //方位角(°)
|
||||
AccelerationX float64 `xorm:"decimal(18,6)" json:"accelerationX"` //X轴加速度(mm)
|
||||
AccelerationY float64 `xorm:"decimal(18,6)" json:"accelerationY"` //Y轴加速度(mm)
|
||||
AccelerationZ float64 `xorm:"decimal(18,6)" json:"accelerationZ"` //Z轴加速度(mm)
|
||||
CreatedAt int64 `xorm:"created" json:"createdAt"` //
|
||||
}
|
|
@ -37,6 +37,8 @@ func New(driveName, dsn string, showSql bool, logger *logging.Logger) {
|
|||
&Disease{},
|
||||
&DiseaseType{},
|
||||
&FileManager{},
|
||||
&Gnss{},
|
||||
&LabelFile{},
|
||||
&MatterAttribute{},
|
||||
&MatterCategory{},
|
||||
&MatterEvent{},
|
||||
|
@ -47,12 +49,14 @@ func New(driveName, dsn string, showSql bool, logger *logging.Logger) {
|
|||
&MatterVersion{},
|
||||
&Model{},
|
||||
&ModelVersion{},
|
||||
&MultiLevelPlatform{},
|
||||
&Node{},
|
||||
&NodeState{},
|
||||
&IssueModel{},
|
||||
&OriginalData{},
|
||||
&Owner{},
|
||||
&Project{},
|
||||
&ProjectResult{},
|
||||
&SystemMenu{},
|
||||
&OperationLog{},
|
||||
&SystemRoleMenu{},
|
||||
|
@ -67,6 +71,7 @@ func New(driveName, dsn string, showSql bool, logger *logging.Logger) {
|
|||
&TrainingDatasetDetail{},
|
||||
&TrainTask{},
|
||||
&TrainTaskLog{},
|
||||
&TrainTaskResult{},
|
||||
)
|
||||
if err != nil {
|
||||
logger.Error("同步数据库表结构", zap.Error(err))
|
||||
|
@ -114,3 +119,39 @@ func GetTrainCategory(categoryId int) string {
|
|||
}
|
||||
return "other"
|
||||
}
|
||||
|
||||
func GetBizType(categoryId int) string {
|
||||
switch categoryId {
|
||||
case 1:
|
||||
return "道路"
|
||||
case 2:
|
||||
return "桥梁"
|
||||
case 3:
|
||||
return "隧道"
|
||||
case 4:
|
||||
return "边坡"
|
||||
}
|
||||
return "其他"
|
||||
}
|
||||
|
||||
func GetFileType(categoryId int) string {
|
||||
switch categoryId {
|
||||
case 1:
|
||||
return "图片"
|
||||
case 2:
|
||||
return "视频"
|
||||
case 3:
|
||||
return "雷达图谱"
|
||||
}
|
||||
return "其他"
|
||||
}
|
||||
|
||||
func GetLabelType(typeId int) string {
|
||||
switch typeId {
|
||||
case 1:
|
||||
return "有病害"
|
||||
case 2:
|
||||
return "无病害"
|
||||
}
|
||||
return "其他分类"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package model
|
||||
|
||||
type LabelFile struct {
|
||||
FileId int64 `xorm:"not null pk autoincr INT(11)" json:"fileId"`
|
||||
FileName string `xorm:"VARCHAR(200)" json:"fileName"` //文件名
|
||||
FilePath string `xorm:"VARCHAR(400)" json:"filePath"` //文件路径
|
||||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //病害分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
FileSize int64 `xorm:"BIGINT" json:"fileSize"` //文件大小
|
||||
FileType int `xorm:"not null SMALLINT default 1" json:"fileType"` //文件类型, 1:图片 2: 视频 3:雷达图谱
|
||||
LabelType int `xorm:"SMALLINT default 1" json:"labelType"` //标注类型 1: 有病害 2: 无病害
|
||||
Pid int64 `xorm:"INT(11) index default 0" json:"pid"` //上级文件,当文件是雷达图谱时,需要增加子文件
|
||||
CreateAt int64 `xorm:"created" json:"createAt"` //上传时间
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"` //更新时间
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package model
|
||||
|
||||
type MultiLevelPlatform struct {
|
||||
MultiLevelPlatformId int64 `xorm:"not null pk autoincr INT(11)" json:"multiLevelPlatformId"` //
|
||||
ProjectId int64 `xorm:"INT(11) index" json:"projectId"` //项目编号
|
||||
MultiLevelPlatformType int `xorm:"int default 3" json:"multiLevelPlatformType"` //多级平台类型 3 三级 5 五级
|
||||
X float64 `xorm:"decimal(18,6)" json:"x"` //X(m)
|
||||
Y float64 `xorm:"decimal(18,6)" json:"y"` //Y(m)
|
||||
H float64 `xorm:"decimal(18,6)" json:"h"` //H(m)
|
||||
AccumulativeDisplacementX float64 `xorm:"decimal(18,6)" json:"accumulativeDisplacementX"` //累计位移X(mm)
|
||||
AccumulativeDisplacementY float64 `xorm:"decimal(18,6)" json:"accumulativeDisplacementY"` //累计位移Y(mm)
|
||||
AccumulativeDisplacementH float64 `xorm:"decimal(18,6)" json:"accumulativeDisplacementH"` //累计位移H(mm)
|
||||
IntervalDisplacementX float64 `xorm:"decimal(18,6)" json:"intervalDisplacementX"` //间隔位移X(mm)
|
||||
IntervalDisplacementY float64 `xorm:"decimal(18,6)" json:"intervalDisplacementY"` //间隔位移Y(mm)
|
||||
IntervalDisplacementH float64 `xorm:"decimal(18,6)" json:"intervalDisplacementH"` //间隔位移H(mm)
|
||||
HorizontalResultantDisplacement float64 `xorm:"decimal(18,6)" json:"horizontalResultantDisplacement"` //水平合位移(mm)
|
||||
ResultantDisplacement float64 `xorm:"decimal(18,6)" json:"resultantDisplacement"` //合位移(mm)
|
||||
CreatedAt int64 `xorm:"" json:"createdAt"` //
|
||||
}
|
|
@ -17,6 +17,7 @@ type Node struct {
|
|||
Virtualization string `xorm:"varchar(1000)" json:"virtualization,omitempty"`
|
||||
BootTime uint64 `xorm:"BIGINT" json:"bootTime,omitempty"`
|
||||
IP string `xorm:"varchar(100)" json:"ip"`
|
||||
LocalIP string `xorm:"VARCHAR(100)" json:"localIP"` //本地局域网IP地址
|
||||
IsGpu bool `xorm:"TINYINT(1) default 0" json:"isGpu"`
|
||||
IsTaskExecute bool `xorm:"TINYINT(1) default 0" json:"isTaskExecute"`
|
||||
CountryCode string `xorm:"varchar(100)" json:"countryCode,omitempty"`
|
||||
|
@ -24,3 +25,12 @@ type Node struct {
|
|||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
||||
|
||||
func GetNodeName(nodeId int64) string {
|
||||
item := new(Node)
|
||||
h, err := DB.ID(nodeId).Get(item)
|
||||
if err != nil || !h {
|
||||
return ""
|
||||
}
|
||||
return item.NodeName
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ type Project struct {
|
|||
ProjectId int64 `xorm:"not null pk autoincr INT(11)" json:"projectId"`
|
||||
ProjectName string `xorm:"varchar(200) not null " json:"projectName"`
|
||||
OwnerId int64 `xorm:"not null INT(11) default 0" json:"ownerId"`
|
||||
BizType int `xorm:"SMALLINT" json:"bizType"`
|
||||
LineName string `xorm:"varchar(200) not null " json:"lineName"`
|
||||
StartName string `xorm:"varchar(200) not null " json:"startName"`
|
||||
EndName string `xorm:"varchar(200) not null " json:"endName"`
|
||||
|
@ -14,6 +15,7 @@ type Project struct {
|
|||
StartPointLat float64 `xorm:"decimal(18,6)" json:"startPointLat"`
|
||||
EndPointLng float64 `xorm:"decimal(18,6)" json:"endPointLng"`
|
||||
EndPointLat float64 `xorm:"decimal(18,6)" json:"endPointLat"`
|
||||
SideType int `xorm:"smallint default 0" json:"sideType"` //边坡平台类型,1:三、五级平台;2: gnss
|
||||
Status int `xorm:"SMALLINT default 1" json:"status"`
|
||||
Creator int64 `xorm:"INT(11) default 0" json:"creator"`
|
||||
Modifier int64 `xorm:"INT(11) default 0" json:"modifier"`
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package model
|
||||
|
||||
type ProjectResult struct {
|
||||
Id int64 `xorm:"not null pk autoincr BIGINT" json:"id"`
|
||||
ProjectId int64 `xorm:"INT(11) index" json:"projectId"` //项目编号
|
||||
SourceResultId int64 `xorm:"INT(11) index" json:"sourceResultId"` //识别结果来源编号
|
||||
MilepostNumber string `xorm:"VARCHAR(50)" json:"milepostNumber"` //里程桩号
|
||||
UpDown string `xorm:"VARCHAR(20)" json:"upDown"` //上下行
|
||||
LineNum int `xorm:"SMALLINT default 1" json:"lineNum"` //车道号
|
||||
DiseaseType string `xorm:"VARCHAR(50)" json:"diseaseType"` //病害类型
|
||||
DiseaseLevel string `xorm:"VARCHAR(20)" json:"diseaseLevel"` //病害等级
|
||||
Length float64 `xorm:"decimal(18,6)" json:"length"` //长度
|
||||
Width float64 `xorm:"decimal(18,6)" json:"width"` //宽度
|
||||
Acreage float64 `xorm:"decimal(18,6)" json:"acreage"` //面积
|
||||
Memo string `xorm:"VARCHAR(1000)" json:"memo"` //备注说明
|
||||
Result string `xorm:"LONGTEXT" json:"result"` //识别结果
|
||||
Creator int64 `xorm:"INT(11) default 0" json:"creator"`
|
||||
Modifier int64 `xorm:"INT(11) default 0" json:"modifier"`
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
|
@ -1,18 +1,23 @@
|
|||
package model
|
||||
|
||||
type TrainTask struct {
|
||||
TaskId int64 `xorm:"not null pk autoincr BIGINT(11)" json:"taskId"`
|
||||
TrainDatasetId int64 `xorm:"INT(11) index" json:"trainDatasetId"`
|
||||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //业务分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
TaskName string `xorm:"VARCHAR(200)" json:"taskName"`
|
||||
TaskDesc string `xorm:"VARCHAR(500)" json:"taskDesc"`
|
||||
StartTime int64 `xorm:"BIGINT" json:"startTime"`
|
||||
FinishTime int64 `xorm:"BIGINT" json:"finishTime"`
|
||||
Loss float64 `xorm:"DECIMAL(18,6)" json:"loss"`
|
||||
Accuracy float64 `xorm:"DECIMAL(18,6)" json:"accuracy"`
|
||||
ModelFilePath string `xorm:"VARCHAR(2000)" json:"modelFilePath"`
|
||||
PbModelFilePath string `xorm:"VARCHAR(2000)" json:"pbModelFilePath"`
|
||||
Status int `xorm:"not null SMALLINT default 0" json:"status"` // 1:等待执行; 2:执行中; 3:执行完成; 4:任务分配失败; 5:任务执行失败
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
TaskId int64 `xorm:"not null pk autoincr BIGINT(11)" json:"taskId"`
|
||||
TrainDatasetId int64 `xorm:"INT(11) index" json:"trainDatasetId"`
|
||||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //业务分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
TaskName string `xorm:"VARCHAR(200)" json:"taskName"`
|
||||
TaskDesc string `xorm:"VARCHAR(500)" json:"taskDesc"`
|
||||
Arithmetic string `xorm:"VARCHAR(50)" json:"arithmetic"`
|
||||
ImageSize int `xorm:"INT" json:"imageSize"`
|
||||
BatchSize int `xorm:"INT" json:"batchSize"`
|
||||
EpochsSize int `xorm:"INT" json:"epochsSize"`
|
||||
OutputType string `xorm:"VARCHAR(20)" json:"outputType"`
|
||||
StartTime int64 `xorm:"BIGINT" json:"startTime"`
|
||||
FinishTime int64 `xorm:"BIGINT" json:"finishTime"`
|
||||
Loss float64 `xorm:"DECIMAL(18,6)" json:"loss"`
|
||||
Accuracy float64 `xorm:"DECIMAL(18,6)" json:"accuracy"`
|
||||
ModelFilePath string `xorm:"VARCHAR(2000)" json:"modelFilePath"`
|
||||
ModelFileMetricsPath string `xorm:"VARCHAR(2000)" json:"modelFileMetricsPath"`
|
||||
Status int `xorm:"not null SMALLINT default 0" json:"status"` // 1:等待执行; 2:执行中; 3:执行完成; 4:任务分配失败; 5:任务执行失败
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package model
|
||||
|
||||
type TrainTaskResult struct {
|
||||
ResultId int64 `xorm:"not null pk autoincr BIGINT(11)" json:"resultId"`
|
||||
TaskId int64 `xorm:"INT(11) index" json:"taskId"`
|
||||
Content string `xorm:"LONGTEXT" json:"content"`
|
||||
Result string `xorm:"VARCHAR(200)" json:"result"`
|
||||
Loss float64 `xorm:"DECIMAL(18,6)" json:"loss"`
|
||||
Accuracy float64 `xorm:"DECIMAL(18,6)" json:"accuracy"`
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
}
|
|
@ -1,11 +1,22 @@
|
|||
package model
|
||||
|
||||
type TrainingDataset struct {
|
||||
DatasetId int64 `xorm:"not null pk autoincr INT(11)" json:"datasetId"`
|
||||
Name string `xorm:"VARCHAR(200)" json:"name"`
|
||||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //业务分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
DatasetDesc string `xorm:"varchar(200)" json:"datasetDesc"`
|
||||
StoreName string `xorm:"varchar(200)" json:"storeName"` //存储路径
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
DatasetId int64 `xorm:"not null pk autoincr INT(11)" json:"datasetId"`
|
||||
Name string `xorm:"VARCHAR(200)" json:"name"`
|
||||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //业务分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
||||
DatasetDesc string `xorm:"varchar(200)" json:"datasetDesc"`
|
||||
StoreName string `xorm:"varchar(200)" json:"storeName"` //存储路径
|
||||
ValidationNumber float64 `xorm:"DECIMAL(18,4)" json:"validationNumber"` //验证占比
|
||||
TestNumber float64 `xorm:"DECIMAL(18,4)" json:"testNumber"` //测试占比
|
||||
CreateAt int64 `xorm:"created" json:"createAt"`
|
||||
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
||||
}
|
||||
|
||||
func GetTrainDatasetName(id int64) string {
|
||||
item := new(TrainingDataset)
|
||||
h, err := DB.ID(id).Get(item)
|
||||
if err != nil || !h {
|
||||
return ""
|
||||
}
|
||||
return item.Name
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ type TrainingDatasetDetail struct {
|
|||
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //训练集分类,1:训练集;2:测试集;3:验证集
|
||||
FileSize int64 `xorm:"BIGINT" json:"fileSize"` //文件大小
|
||||
FileMd5 string `xorm:"VARCHAR(64)" json:"fileMd5"` //文件MD5
|
||||
IsDisease int `xorm:"TINYINT(1)" json:"isDisease"` //是否有病害
|
||||
IsDisease int `xorm:"TINYINT(1)" json:"isDisease"` //是否有病害, 1:有病害;2:无病害;
|
||||
OperationLogId int64 `xorm:"INT(11) index" json:"operationLogId"` //操作日志编号
|
||||
Creator int64 `xorm:"INT(11) index" json:"creator"` //上传人
|
||||
CreateAt int64 `xorm:"created" json:"createAt"` //上传时间
|
||||
|
|
|
@ -3,6 +3,13 @@ package mq
|
|||
const (
|
||||
TaskAdd = iota + 1
|
||||
ModelIssue
|
||||
TaskExecute
|
||||
TaskResponse
|
||||
ModelIssueRepeater
|
||||
ModelIssueResponse
|
||||
TaskExecuteLog
|
||||
TaskLog
|
||||
TrainTaskAdd
|
||||
)
|
||||
|
||||
type InstructionReq struct {
|
||||
|
|
|
@ -2,6 +2,7 @@ package utils
|
|||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"git.hpds.cc/Component/logging"
|
||||
|
@ -117,3 +118,8 @@ func DownloadMinioFileToLocalPath(accessUrl, dstPath, fileName, protocol, endpoi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func FileToBase64(fn string) string {
|
||||
buff := ReadFile(fn)
|
||||
return base64.StdEncoding.EncodeToString(buff) // 加密成base64字符串
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func HttpDo(reqUrl, method string, params map[string]string, header map[string]string) (data []byte, err error) {
|
||||
func HttpDo(reqUrl, method string, params map[string]interface{}, header map[string]string) (data []byte, err error) {
|
||||
var paramStr string = ""
|
||||
if contentType, ok := header["Content-Type"]; ok && strings.Contains(contentType, "json") {
|
||||
bytesData, _ := json.Marshal(params)
|
||||
|
@ -20,9 +20,9 @@ func HttpDo(reqUrl, method string, params map[string]string, header map[string]s
|
|||
} else {
|
||||
for k, v := range params {
|
||||
if len(paramStr) == 0 {
|
||||
paramStr = fmt.Sprintf("%s=%s", k, url.QueryEscape(v))
|
||||
paramStr = fmt.Sprintf("%s=%s", k, url.QueryEscape(v.(string)))
|
||||
} else {
|
||||
paramStr = fmt.Sprintf("%s&%s=%s", paramStr, k, url.QueryEscape(v))
|
||||
paramStr = fmt.Sprintf("%s&%s=%s", paramStr, k, url.QueryEscape(v.(string)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,3 +129,11 @@ func ImageToBuff(img image.Image, imgType string) *bytes.Buffer {
|
|||
}
|
||||
return buff
|
||||
}
|
||||
|
||||
func ImgFileToBase64(fn string) string {
|
||||
fileByte := ReadFile(fn)
|
||||
buff := bytes.NewBuffer(fileByte)
|
||||
m, _, _ := image.Decode(buff)
|
||||
return "data:image/jpeg;base64," + ImageToBase64(m, "jpeg")
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue