|
@@ -157,3 +157,95 @@ func ChangeLogisticsStatus(ctx context.Context, taskIds []string) error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// GetSpecialTaskLogisticsList 查询专项包含物流信息的task list
|
|
|
+func GetSpecialTaskLogisticsList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TalentConditions) ([]*http_model.SpecialTaskLogisticsInfo, int64, error) {
|
|
|
+ db := GetReadDB(ctx)
|
|
|
+ // 查询Task表信息
|
|
|
+ db = db.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("task_status = 2 and project_id = ?", projectID)
|
|
|
+ // 根据Project条件过滤
|
|
|
+ conditionType := reflect.TypeOf(conditions).Elem()
|
|
|
+ conditionValue := reflect.ValueOf(conditions).Elem()
|
|
|
+ var platformNickname string = ""
|
|
|
+ for i := 0; i < conditionType.NumField(); i++ {
|
|
|
+ field := conditionType.Field(i)
|
|
|
+ tag := field.Tag.Get("condition")
|
|
|
+ value := conditionValue.FieldByName(field.Name)
|
|
|
+ if !util.IsBlank(value) {
|
|
|
+ if tag == "platform_nickname" {
|
|
|
+ platformNickname = fmt.Sprintf("%v", value.Interface())
|
|
|
+ continue
|
|
|
+ } else {
|
|
|
+ db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var taskInfos []gorm_model.YoungeeTaskInfo
|
|
|
+ db = db.Model(gorm_model.YoungeeTaskInfo{})
|
|
|
+ // 查询总数
|
|
|
+ var totalTask int64
|
|
|
+ if err := db.Count(&totalTask).Error; err != nil {
|
|
|
+ logrus.WithContext(ctx).Errorf("[GetSpecialTaskLogisticsList] error query mysql total, err:%+v", err)
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+ db.Order("task_id").Find(&taskInfos)
|
|
|
+
|
|
|
+ // 查询任务id
|
|
|
+ var taskIds []string
|
|
|
+ taskMap := make(map[string]gorm_model.YoungeeTaskInfo)
|
|
|
+ for _, taskInfo := range taskInfos {
|
|
|
+ taskIds = append(taskIds, taskInfo.TaskId)
|
|
|
+ taskMap[taskInfo.TaskId] = taskInfo
|
|
|
+ }
|
|
|
+ db1 := GetReadDB(ctx)
|
|
|
+ db1 = db1.Debug().Model(gorm_model.YoungeeTaskLogistics{})
|
|
|
+
|
|
|
+ var logisticsInfos []gorm_model.YoungeeTaskLogistics
|
|
|
+ db1 = db1.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id IN ?", taskIds).Find(&logisticsInfos)
|
|
|
+ logisticsMap := make(map[string]gorm_model.YoungeeTaskLogistics)
|
|
|
+ for _, logisticsInfo := range logisticsInfos {
|
|
|
+ logisticsMap[logisticsInfo.TaskID] = logisticsInfo
|
|
|
+ }
|
|
|
+ // 查询总数
|
|
|
+ var totalLogistics int64
|
|
|
+ if err := db1.Count(&totalLogistics).Error; err != nil {
|
|
|
+ logrus.WithContext(ctx).Errorf("[GetSpecialTaskLogisticsList] error query mysql total, err:%+v", err)
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询该页数据
|
|
|
+ limit := pageSize
|
|
|
+ offset := pageSize * pageNum // assert pageNum start with 0
|
|
|
+ err := db.Order("task_id").Limit(int(limit)).Offset(int(offset)).Error
|
|
|
+ if err != nil {
|
|
|
+ logrus.WithContext(ctx).Errorf("[GetSpecialTaskLogisticsList] error query mysql total, err:%+v", err)
|
|
|
+ return nil, 0, err
|
|
|
+ }
|
|
|
+
|
|
|
+ var TaskLogisticss []*http_model.SpecialTaskLogistics
|
|
|
+ var taskLogisticss []*http_model.SpecialTaskLogisticsInfo
|
|
|
+ var newTaskLogisticss []*http_model.SpecialTaskLogisticsInfo
|
|
|
+ for _, taskId := range taskIds {
|
|
|
+ TaskLogistics := new(http_model.SpecialTaskLogistics)
|
|
|
+ TaskLogistics.Talent = taskMap[taskId]
|
|
|
+ TaskLogistics.Logistics = logisticsMap[taskId]
|
|
|
+ TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
|
|
|
+ regionCode, _ := strconv.Atoi(conv.MustString(gjson.Get(TalentPostAddrSnap, "region_code"), ""))
|
|
|
+ TaskLogistics.Region = GetRegion(ctx, regionCode)
|
|
|
+ TaskLogisticss = append(TaskLogisticss, TaskLogistics)
|
|
|
+ }
|
|
|
+ taskLogisticss = pack.SpecialTaskLogisticsToTaskInfo(TaskLogisticss)
|
|
|
+
|
|
|
+ for _, v := range taskLogisticss {
|
|
|
+ if platformNickname == "" {
|
|
|
+ newTaskLogisticss = append(newTaskLogisticss, v)
|
|
|
+ } else if strings.Contains(v.PlatformNickname, platformNickname) {
|
|
|
+ newTaskLogisticss = append(newTaskLogisticss, v)
|
|
|
+ } else if strings.Contains(v.TaskID, platformNickname) {
|
|
|
+ newTaskLogisticss = append(newTaskLogisticss, v)
|
|
|
+ } else {
|
|
|
+ totalTask--
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newTaskLogisticss, totalTask, nil
|
|
|
+}
|