zk hace 2 años
padre
commit
e3938e7197
Se han modificado 1 ficheros con 27 adiciones y 9 borrados
  1. 27 9
      server/api/v1/autocode/problem_info.go

+ 27 - 9
server/api/v1/autocode/problem_info.go

@@ -241,16 +241,34 @@ func (problemInfoApi *ProblemInfoApi) UpdateProblemInfoStatus(c *gin.Context) {
 	problemInfoNow.Status = problemInfo.Status
 	problemInfoNow.Audit = problemInfo.Audit
 	if problemInfo.Status == "Success" {
-		if time.Now().Before(problemInfoNow.HandAt) {
+		if time.Now().Unix() > problemInfoNow.HandAt.Unix() {
 			//超时扣分
-			//todo 扣站点分数
-
-			//todo 扣单位分数
-			_, unit := unitService.GetUnit(uint(*problemInfo.UnitId))
-			oldIntegral := *unit.UnitIntegral
-			nowIntegral := oldIntegral - *problemInfoNow.Integral
-			unit.UnitIntegral = &nowIntegral
-			unitService.UpdateUnitA(unit)
+			probIds := strings.Split(problemInfoNow.Matter, "|")
+			//问题关联的部门
+			unitIds := strings.Split(problemInfoNow.Department, "|")
+			if err, probTypes := problemTypeService.GetProblemTypeIds(probIds); err == nil {
+				//扣部门分数
+				for _, unitId := range unitIds {
+					if unitId == "" {
+						continue
+					}
+					integral := 0
+					for _, probType := range probTypes {
+						if strings.Index(probType.UnitIds, unitId) != -1 {
+							integral = integral + *probType.Integral
+						}
+					}
+					if integral != 0 {
+						id, _ := strconv.Atoi(unitId)
+						global.GVA_LOG.Error("id!", zap.Any("unitId", unitId), zap.Any("id", id))
+						_, unit := unitService.GetUnit(uint(id))
+						oldIntegral := *unit.UnitIntegral
+						nowIntegral := oldIntegral + integral
+						unit.UnitIntegral = &nowIntegral
+						unitService.UpdateUnitA(unit)
+					}
+				}
+			}
 		} else {
 			temp := 0
 			problemInfo.Integral = &temp