|
@@ -427,31 +427,56 @@ func (this *PredictEdbInfoController) Add() {
|
|
|
ruleList := make([]request.RuleConfig, 0)
|
|
|
{
|
|
|
ruleMap := make(map[string]request.RuleConfig)
|
|
|
+ ruleEndNumSortMap := make(map[int]request.RuleConfig)
|
|
|
dateIntList := make([]int64, 0)
|
|
|
+ endNumList := make([]int, 0)
|
|
|
for _, v := range req.RuleList {
|
|
|
- confEndDate, err := time.Parse(utils.FormatDate, v.EndDate)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "配置项中时间异常,请重新选择"
|
|
|
- br.ErrMsg = "配置项中时间异常,请重新选择,err:" + err.Error()
|
|
|
- br.IsSendEmail = false
|
|
|
- return
|
|
|
+ if req.EndDateType == 0 {
|
|
|
+ confEndDate, err := time.Parse(utils.FormatDate, v.EndDate)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "配置项中时间异常,请重新选择"
|
|
|
+ br.ErrMsg = "配置项中时间异常,请重新选择,err:" + err.Error()
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ dateIntList = append(dateIntList, confEndDate.Unix())
|
|
|
+ ruleMap[v.EndDate] = v
|
|
|
+ } else {
|
|
|
+ if _, ok := ruleEndNumSortMap[v.EndNum]; ok {
|
|
|
+ br.Msg = "所选期数不能和其他时间段相同"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ endNumList = append(endNumList, v.EndNum)
|
|
|
+ ruleEndNumSortMap[v.EndNum] = v
|
|
|
}
|
|
|
- dateIntList = append(dateIntList, confEndDate.Unix())
|
|
|
- ruleMap[v.EndDate] = v
|
|
|
}
|
|
|
- sort.Slice(dateIntList, func(i, j int) bool {
|
|
|
- return dateIntList[i] < dateIntList[j]
|
|
|
- })
|
|
|
- for _, dateInt := range dateIntList {
|
|
|
- currDateTime := time.Unix(dateInt, 0)
|
|
|
- item, ok := ruleMap[currDateTime.Format(utils.FormatDate)]
|
|
|
- if !ok {
|
|
|
- br.Msg = "配置项中时间异常,请重新选择"
|
|
|
- br.ErrMsg = "配置项中时间异常,请重新选择"
|
|
|
- br.IsSendEmail = false
|
|
|
- return
|
|
|
+ if req.EndDateType == 0 {
|
|
|
+ sort.Slice(dateIntList, func(i, j int) bool {
|
|
|
+ return dateIntList[i] < dateIntList[j]
|
|
|
+ })
|
|
|
+ for _, dateInt := range dateIntList {
|
|
|
+ currDateTime := time.Unix(dateInt, 0)
|
|
|
+ item, ok := ruleMap[currDateTime.Format(utils.FormatDate)]
|
|
|
+ if !ok {
|
|
|
+ br.Msg = "配置项中时间异常,请重新选择"
|
|
|
+ br.ErrMsg = "配置项中时间异常,请重新选择"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ruleList = append(ruleList, item)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sort.Ints(endNumList)
|
|
|
+ for _, endNum := range endNumList {
|
|
|
+ item, ok := ruleEndNumSortMap[endNum]
|
|
|
+ if !ok {
|
|
|
+ br.Msg = "配置项中时间异常,请重新选择"
|
|
|
+ br.ErrMsg = "配置项中时间异常,请重新选择"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ruleList = append(ruleList, item)
|
|
|
}
|
|
|
- ruleList = append(ruleList, item)
|
|
|
}
|
|
|
}
|
|
|
req.RuleList = ruleList
|