|
|
@@ -77,23 +77,23 @@ func (s *UrgentTaskService) DeleteUrgentTaskByIds(ids []int) (err error) {
|
|
|
func (s *UrgentTaskService) UpdateUrgentTask(task1 task.UrgentTaskConf) (err error) {
|
|
|
//查找此task_id是否存在,如果存在不更新,否则更新
|
|
|
var entity task.UrgentTaskConf
|
|
|
- err = global.GVA_DB.Model(&task.UrgentTaskConf{}).Where("task_id = ? and id != ? and create_date = ?", task1.TaskId, task1.Id, task1.CreateDate).First(&entity).Error
|
|
|
- if !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
- return errors.New("已存在此task_id的任务,更新失败")
|
|
|
+ err = global.GVA_DB.Model(&task.UrgentTaskConf{}).Where("task_id = ? and id = ? and create_date = ?", task1.TaskId, task1.Id, task1.CreateDate).First(&entity).Error
|
|
|
+ if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ return errors.New("没有找到数据")
|
|
|
+ }
|
|
|
+ upPcCode := ""
|
|
|
+ if task1.PcCode != "" {
|
|
|
+ upPcCode = task1.PcCode
|
|
|
+ task1.PcCode = entity.PcCode + "," + task1.PcCode
|
|
|
}
|
|
|
err = global.GVA_DB.Model(&task.UrgentTaskConf{}).Where("id", task1.Id).Updates(&task1).Error
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
date := entity.CreateDate[:10]
|
|
|
- if entity.PcCode != task1.PcCode {
|
|
|
- codeSplit := strings.Split(entity.PcCode, ",")
|
|
|
+ if upPcCode != "" {
|
|
|
ctx := context.Background()
|
|
|
- for _, code := range codeSplit {
|
|
|
- key := fmt.Sprintf(cache.TemporaryTaskPcCode, date, code)
|
|
|
- global.GVA_REDIS.Del(ctx, key)
|
|
|
- }
|
|
|
- upCodeSplit := strings.Split(task1.PcCode, ",")
|
|
|
+ upCodeSplit := strings.Split(upPcCode, ",")
|
|
|
for _, upCode := range upCodeSplit {
|
|
|
key := fmt.Sprintf(cache.TemporaryTaskPcCode, date, upCode)
|
|
|
global.GVA_REDIS.Set(ctx, key, task1.TaskId, time.Hour*6)
|