|
@@ -331,13 +331,12 @@ func GetCreatingNumber(ctx context.Context, enterpriseID string) (*int64, error)
|
|
|
func GetProjectData(ctx context.Context, projectid string) (http_model.ProjectDataResponse, error) {
|
|
|
db := GetReadDB(ctx)
|
|
|
var projectInfo gorm_model.ProjectInfo
|
|
|
-
|
|
|
// 查询项目基本信息
|
|
|
if err := db.Where("project_id = ?", projectid).First(&projectInfo).Error; err != nil {
|
|
|
logrus.WithContext(ctx).Errorf("[Project db] GetProjectData error, err: %+v", err)
|
|
|
return http_model.ProjectDataResponse{}, err
|
|
|
}
|
|
|
-
|
|
|
+ fmt.Println("projectInfo---", projectInfo.ProjectID)
|
|
|
var projectTasks []gorm_model.YoungeeTaskInfo
|
|
|
if err := db.Where("project_id = ? AND task_status = ?", projectid, 2).Find(&projectTasks).Error; err != nil {
|
|
|
return http_model.ProjectDataResponse{}, err
|
|
@@ -429,7 +428,6 @@ func GetProjectData(ctx context.Context, projectid string) (http_model.ProjectDa
|
|
|
} else {
|
|
|
manRatio = 0
|
|
|
}
|
|
|
-
|
|
|
// 构建响应
|
|
|
res := http_model.ProjectDataResponse{
|
|
|
Recruittime: *projectInfo.PassAt,
|
|
@@ -464,6 +462,18 @@ func GetProjectExecuteData(ctx context.Context, projectid string) (http_model.Ex
|
|
|
if err = query.Count(&total).Error; err != nil {
|
|
|
return http_model.ExecuteDataResponse{}, err
|
|
|
}
|
|
|
+
|
|
|
+ // 初始化统计数据
|
|
|
+ skedateStats := make(map[string]int)
|
|
|
+ linkdateStatics := make(map[string]int)
|
|
|
+ startDate := *projectData.CreatedAt
|
|
|
+ endDate := time.Now()
|
|
|
+ // 填充日期统计
|
|
|
+ for d := startDate; d.Before(endDate) || d.Equal(endDate); d = d.Add(24 * time.Hour) {
|
|
|
+ skedateStats[d.Format("2006-01-02")] = 0
|
|
|
+ linkdateStatics[d.Format("2006-01-02")] = 0
|
|
|
+ }
|
|
|
+
|
|
|
var presketchnum int64 //代传初稿数
|
|
|
var sketchnum int64 //待审
|
|
|
var sketchaccnum int64 //通过
|
|
@@ -479,7 +489,10 @@ func GetProjectExecuteData(ctx context.Context, projectid string) (http_model.Ex
|
|
|
var acclinkcnt, backcnt, submintcnt, firlinkacccnt int
|
|
|
var defaultnum int64
|
|
|
var defaultratio float64
|
|
|
+ var sktchinfo gorm_model.YounggeeSketchInfo
|
|
|
+ var draftee, settle_amount float64
|
|
|
for _, task := range projectTaskInfo {
|
|
|
+ draftee += task.DraftFee
|
|
|
switch task.TaskStage {
|
|
|
case 9:
|
|
|
presketchnum += 1
|
|
@@ -501,70 +514,89 @@ func GetProjectExecuteData(ctx context.Context, projectid string) (http_model.Ex
|
|
|
if task.CurDefaultType != 0 {
|
|
|
defaultnum += 1
|
|
|
}
|
|
|
- var sktchinfo gorm_model.YounggeeSketchInfo
|
|
|
- err = db.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ? ", task.TaskID).First(&sktchinfo).Error
|
|
|
- if err != nil {
|
|
|
- return http_model.ExecuteDataResponse{}, err
|
|
|
- } else {
|
|
|
-
|
|
|
- if projectData.ProjectForm == 1 {
|
|
|
- if task.SignedTime.IsZero() {
|
|
|
- createduraion += sktchinfo.CreateAt.Sub(task.SignedTime)
|
|
|
- crecnt += 1
|
|
|
+ if task.TaskStage == 15 {
|
|
|
+ settle_amount += task.SettleAmount
|
|
|
+ }
|
|
|
+ if task.TaskStage > 9 {
|
|
|
+ //初稿
|
|
|
+ //err = db.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ? ", task.TaskID).First(&sktchinfo).Error
|
|
|
+ err = db.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ?", task.TaskID).Order("create_at ASC").First(&sktchinfo).Error
|
|
|
|
|
|
- }
|
|
|
+ if err != nil {
|
|
|
+ return http_model.ExecuteDataResponse{}, err
|
|
|
} else {
|
|
|
- if sktchinfo.IsSubmit == 1 {
|
|
|
- createduraion += sktchinfo.CreateAt.Sub(task.SelectDate)
|
|
|
- crecnt += 1
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if sktchinfo.IsOk == 1 {
|
|
|
- duration += sktchinfo.AgreeAt.Sub(sktchinfo.CreateAt)
|
|
|
- accskecnt += 1
|
|
|
- }
|
|
|
+ if projectData.ProjectForm == 1 {
|
|
|
+ if !task.SignedTime.IsZero() {
|
|
|
+ createduraion += sktchinfo.CreateAt.Sub(task.SignedTime)
|
|
|
+ crecnt += 1
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if sktchinfo.IsSubmit == 1 {
|
|
|
+ createduraion += sktchinfo.CreateAt.Sub(task.SelectDate)
|
|
|
+ crecnt += 1
|
|
|
+ }
|
|
|
+ } //平均创作耗时
|
|
|
+ var sktchaccinfo gorm_model.YounggeeSketchInfo
|
|
|
+ err = db.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ?", task.TaskID).Order("create_at ASC").Last(&sktchaccinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ return http_model.ExecuteDataResponse{}, err
|
|
|
+ }
|
|
|
|
|
|
- if sktchinfo.IsSubmit == 1 {
|
|
|
- submint += 1
|
|
|
- if sktchinfo.RejectAt.IsZero() && sktchinfo.IsOk == 1 {
|
|
|
- firacccnt += 1
|
|
|
+ if sktchaccinfo.IsOk == 1 {
|
|
|
+ duration += sktchaccinfo.AgreeAt.Sub(sktchinfo.CreateAt)
|
|
|
+ accskecnt += 1 //审稿耗时
|
|
|
+ submint += 1
|
|
|
+ if sktchaccinfo.SketchID == sktchinfo.SketchID {
|
|
|
+ firacccnt += 1
|
|
|
+ } //首次通过
|
|
|
+ AgreeDate := sktchaccinfo.AgreeAt.Format("2006-01-02")
|
|
|
+ if _, exists := skedateStats[AgreeDate]; exists {
|
|
|
+ skedateStats[AgreeDate]++
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if task.TaskStage > 11 {
|
|
|
+ var linkinfo gorm_model.YounggeeLinkInfo //最后一次上传link
|
|
|
+ err = db.Model(gorm_model.YounggeeLinkInfo{}).Where("task_id = ? ", task.TaskID).Order("create_at ASC").Last(&linkinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ continue
|
|
|
+ } else {
|
|
|
|
|
|
- var linkinfo gorm_model.YounggeeLinkInfo
|
|
|
- err = db.Model(gorm_model.YounggeeLinkInfo{}).Where("task_id = ? ", task.TaskID).First(&linkinfo).Error
|
|
|
- if err != nil {
|
|
|
- return http_model.ExecuteDataResponse{}, err
|
|
|
- } else {
|
|
|
-
|
|
|
- if linkinfo.IsOk == 1 {
|
|
|
- linkaccduartion += linkinfo.AgreeAt.Sub(linkinfo.CreateAt)
|
|
|
- acclinkcnt += 1
|
|
|
- }
|
|
|
+ if linkinfo.IsOk == 1 {
|
|
|
+ linkaccduartion += linkinfo.AgreeAt.Sub(linkinfo.CreateAt)
|
|
|
+ acclinkcnt += 1
|
|
|
+ } //平均质检时间
|
|
|
+ var linkfirinfo gorm_model.YounggeeLinkInfo //最后一次上传link
|
|
|
+ err = db.Model(gorm_model.YounggeeLinkInfo{}).Where("task_id = ? ", task.TaskID).Order("create_at ASC").First(&linkfirinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ return http_model.ExecuteDataResponse{}, err
|
|
|
+ } else {
|
|
|
+ backduration += linkinfo.CreateAt.Sub(sktchinfo.AgreeAt)
|
|
|
+ backcnt += 1
|
|
|
+ var linklasinfo gorm_model.YounggeeLinkInfo //最后一次上传link
|
|
|
+ err = db.Model(gorm_model.YounggeeLinkInfo{}).Where("task_id = ? ", task.TaskID).Order("create_at ASC").Last(&linklasinfo).Error
|
|
|
+ if err != nil {
|
|
|
+ return http_model.ExecuteDataResponse{}, err
|
|
|
+ }
|
|
|
+ if linklasinfo.IsOk == 1 {
|
|
|
+ submintcnt += 1
|
|
|
+ if linklasinfo.LinkID == linkfirinfo.LinkID {
|
|
|
+ firlinkacccnt += 1
|
|
|
+ } //首次通过
|
|
|
+ AgreeDate := linklasinfo.AgreeAt.Format("2006-01-02")
|
|
|
+ if _, exists := linkdateStatics[AgreeDate]; exists {
|
|
|
+ linkdateStatics[AgreeDate]++
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if linkinfo.IsSubmit == 1 {
|
|
|
- backduration += linkinfo.SubmitAt.Sub(sktchinfo.AgreeAt)
|
|
|
- backcnt += 1
|
|
|
}
|
|
|
|
|
|
- if linkinfo.IsSubmit == 1 {
|
|
|
- submintcnt += 1
|
|
|
- if linkinfo.RejectAt.IsZero() && linkinfo.IsOk == 1 {
|
|
|
- firlinkacccnt += 1
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
- //var datainfo gorm_model.YounggeeDataInfo
|
|
|
- //err = db.Model(gorm_model.YounggeeDataInfo{}).Where("task_id = ? ", task.TaskID).First(&datainfo).Error
|
|
|
- //if err != nil {
|
|
|
- // return http_model.ExecuteDataResponse{}, err
|
|
|
- //} else {
|
|
|
- // if datainfo
|
|
|
- //
|
|
|
- //}
|
|
|
}
|
|
|
if submint > 0 && firacccnt > 0 {
|
|
|
firaccratio = float64(firacccnt) / float64(submint)
|
|
@@ -619,6 +651,22 @@ func GetProjectExecuteData(ctx context.Context, projectid string) (http_model.Ex
|
|
|
DataNum: datanum,
|
|
|
DefaultNum: defaultnum,
|
|
|
DefaultRatio: defaultratio,
|
|
|
+ DraftFee: draftee,
|
|
|
+ Settle_Amount: settle_amount,
|
|
|
}
|
|
|
return res, nil
|
|
|
}
|
|
|
+
|
|
|
+func GetProjecdata(ctx context.Context, projectid string) (http_model.ProjectdataResponse, error) {
|
|
|
+ db := GetReadDB(ctx)
|
|
|
+ var projectInfo gorm_model.ProjectInfo
|
|
|
+
|
|
|
+ // 查询项目基本信息
|
|
|
+ if err := db.Where("project_id = ?", projectid).First(&projectInfo).Error; err != nil {
|
|
|
+ logrus.WithContext(ctx).Errorf("[Project db] GetProjectData error, err: %+v", err)
|
|
|
+ return http_model.ProjectdataResponse{}, err
|
|
|
+ }
|
|
|
+
|
|
|
+ res := http_model.ProjectdataResponse{}
|
|
|
+ return res, nil
|
|
|
+}
|