|
@@ -46,8 +46,9 @@ func (problemInfoApi *ProblemInfoApi) CreateProblemInfo(c *gin.Context) {
|
|
|
problemInfo.Region = place.Region
|
|
|
}
|
|
|
|
|
|
- if problemInfo.UnitId != nil && *problemInfo.UnitId != 0 {
|
|
|
+ if problemInfo.Department != "" {
|
|
|
probleTypeIds := strings.Split(problemInfo.Matter, "|")
|
|
|
+ //计算分值
|
|
|
if len(probleTypeIds) > 0 {
|
|
|
_, proTypes := problemTypeService.GetProblemTypeIds(probleTypeIds)
|
|
|
var integral int
|
|
@@ -58,12 +59,40 @@ func (problemInfoApi *ProblemInfoApi) CreateProblemInfo(c *gin.Context) {
|
|
|
problemInfo.Integral = &integral
|
|
|
}
|
|
|
// 发送问题到负责人
|
|
|
- if err, unituser := unitUserService.GetUnitUsers(problemInfo.UnitId); err != nil {
|
|
|
- source := make([]string, 0)
|
|
|
- for _, item := range unituser {
|
|
|
- source = append(source, item.UUID)
|
|
|
+ departmentIds := strings.Split(problemInfo.Department, "|")
|
|
|
+ for _, unitId := range departmentIds {
|
|
|
+ id, _ := strconv.Atoi(unitId)
|
|
|
+ if err, unitPlaces := unitPlaceService.GetUnitPlaces(&id); err != nil {
|
|
|
+ unitPlaceService.CreateUnitPlace(autocode.UnitPlace{UnitId: &id, PlaceId: strconv.Itoa(int(problemInfo.SiteId))})
|
|
|
+ ids := []string{unitId}
|
|
|
+ sum := placeService.FindPlaceSum(ids)
|
|
|
+ unitService.UpdateUnitMaxIntegral(&id, sum)
|
|
|
+ } else {
|
|
|
+ isA := true
|
|
|
+ for _, unitPlace := range unitPlaces {
|
|
|
+ if unitPlace.PlaceId == strconv.Itoa(int(problemInfo.SiteId)) {
|
|
|
+ isA = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if isA {
|
|
|
+ placeIds := make([]string, 0)
|
|
|
+ for _, places := range unitPlaces {
|
|
|
+ placeIds = append(placeIds, places.PlaceId)
|
|
|
+ }
|
|
|
+ placeIds = append(placeIds, strconv.Itoa(int(problemInfo.SiteId)))
|
|
|
+ sum := placeService.FindPlaceSum(placeIds)
|
|
|
+ unitService.UpdateUnitMaxIntegral(&id, sum)
|
|
|
+ unitPlaceService.CreateUnitPlace(autocode.UnitPlace{UnitId: &id, PlaceId: strconv.Itoa(int(problemInfo.SiteId))})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if err, unituser := unitUserService.GetUnitUsers(&id); err != nil {
|
|
|
+ source := make([]string, 0)
|
|
|
+ for _, item := range unituser {
|
|
|
+ source = append(source, item.UUID)
|
|
|
+ }
|
|
|
+ SendMsg(autocodeReq.SendUser{ProblemID: problemInfo.ID, ID: source}, true)
|
|
|
}
|
|
|
- SendMsg(autocodeReq.SendUser{ProblemID: problemInfo.ID, ID: source}, true)
|
|
|
}
|
|
|
|
|
|
}
|