|
@@ -1599,12 +1599,6 @@ func (this *ChartInfoController) BatchCalculateBatchSave() {
|
|
|
Fail: make([]data_manage.BatchEdbInfoCalculateBatchSaveFailResp, 0),
|
|
|
Success: make([]data_manage.BatchEdbInfoCalculateBatchSaveSuccessResp, 0),
|
|
|
}
|
|
|
- /* redisKeyList := make([]string, 0) //需要清理的缓存key列表
|
|
|
- defer func() {
|
|
|
- for _, redisKey := range redisKeyList {
|
|
|
- utils.Rc.Delete(redisKey)
|
|
|
- }
|
|
|
- }()*/
|
|
|
|
|
|
var formulaInt int
|
|
|
switch req.Source {
|
|
@@ -1729,6 +1723,16 @@ func (this *ChartInfoController) BatchCalculateBatchSave() {
|
|
|
}
|
|
|
reqEdbList = append(reqEdbList, v)
|
|
|
}
|
|
|
+
|
|
|
+ if len(reqEdbList) <= 0 {
|
|
|
+ br.Msg = "新增失败!"
|
|
|
+ if len(resp.Fail) > 0 {
|
|
|
+ br.ErrMsg = resp.Fail[0].Msg
|
|
|
+ } else {
|
|
|
+ br.Msg = "请选择指标"
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
req.EdbList = reqEdbList
|
|
|
// 调用指标库去更新
|
|
|
reqJson, err := json.Marshal(req)
|
|
@@ -1756,6 +1760,195 @@ func (this *ChartInfoController) BatchCalculateBatchSave() {
|
|
|
br.IsAddLog = true
|
|
|
}
|
|
|
|
|
|
+// BatchCalculateBatchEdit
|
|
|
+// @Title 多指标求和和多指标求平均编辑接口
|
|
|
+// @Description 多指标求和和多指标求平均编辑接口
|
|
|
+// @Param request body data_manage.EdbInfoCalculateBatchSaveReq true "type json string"
|
|
|
+// @Success Ret=200 返回指标id
|
|
|
+// @router /edb_info/calculate/batch/edit/batch [post]
|
|
|
+func (this *ChartInfoController) BatchCalculateBatchEdit() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ if br.ErrMsg == "" {
|
|
|
+ br.IsSendEmail = false
|
|
|
+ }
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var req data_manage.BatchEdbInfoCalculateBatchSaveReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := data_manage.BatchEdbInfoCalculateBatchSaveResp{
|
|
|
+ Fail: make([]data_manage.BatchEdbInfoCalculateBatchSaveFailResp, 0),
|
|
|
+ Success: make([]data_manage.BatchEdbInfoCalculateBatchSaveSuccessResp, 0),
|
|
|
+ }
|
|
|
+
|
|
|
+ var formulaInt int
|
|
|
+ switch req.Source {
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS, utils.DATA_SOURCE_CALCULATE_HBZ, utils.DATA_SOURCE_CALCULATE_HCZ, utils.DATA_SOURCE_CALCULATE_TIME_SHIFT, utils.DATA_SOURCE_CALCULATE_CJJX:
|
|
|
+ if req.Formula == "" {
|
|
|
+ br.Msg = "请输入N值"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ formulaInt, _ = strconv.Atoi(req.Formula)
|
|
|
+ if formulaInt <= 0 {
|
|
|
+ br.Msg = "N值输入错误,请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZJPJ:
|
|
|
+ //直接拼接指标
|
|
|
+ //校验时间格式
|
|
|
+ _, err = time.ParseInLocation(utils.FormatDate, req.Formula, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "拼接日期有误,请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NHCC: //拟合残差指标
|
|
|
+ //指标校验
|
|
|
+ if len(req.EdbInfoIdArr) != 2 {
|
|
|
+ br.Msg = "选择的指标异常,请重新选择"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fromEdbInfoId := req.EdbInfoIdArr[0].EdbInfoId
|
|
|
+ if fromEdbInfoId <= 0 {
|
|
|
+ br.Msg = "请选择指标"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //校验时间格式
|
|
|
+ //数据格式:2022-11-01,2022-11-10
|
|
|
+ timeList := strings.Split(req.Formula, ",")
|
|
|
+ if len(timeList) != 2 {
|
|
|
+ br.Msg = "选择的指标异常,请重新选择"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ startDate, err := time.ParseInLocation(utils.FormatDate, timeList[0], time.Local)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "开始日期有误,请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ endDate, err := time.ParseInLocation(utils.FormatDate, timeList[1], time.Local)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "结束日期有误,请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if utils.GetTimeSubDay(startDate, endDate) < 2 {
|
|
|
+ br.Msg = "日期间隔不得少于两天"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZSXY: // 指数修匀
|
|
|
+ if req.Formula == "" {
|
|
|
+ br.Msg = "请填写alpha值"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ alpha, e := strconv.ParseFloat(req.Formula, 64)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "alpha值输入错误, 请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if alpha <= 0 || alpha >= 1 {
|
|
|
+ br.Msg = "alpha值输入错误, 请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(req.EdbList) > 100 {
|
|
|
+ br.Msg = "最多只能选择100个指标"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reqEdbList := make([]*data_manage.CalculateEdbInfoItem, 0)
|
|
|
+ for _, v := range req.EdbList {
|
|
|
+ if v.EdbInfoId <= 0 {
|
|
|
+ resp.Fail = append(resp.Fail, data_manage.BatchEdbInfoCalculateBatchSaveFailResp{
|
|
|
+ CalculateId: v.CalculateId,
|
|
|
+ Msg: "请选择要编辑的指标",
|
|
|
+ })
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.EdbName = strings.Trim(v.EdbName, " ")
|
|
|
+ if v.EdbName == "" {
|
|
|
+ resp.Fail = append(resp.Fail, data_manage.BatchEdbInfoCalculateBatchSaveFailResp{
|
|
|
+ CalculateId: v.CalculateId,
|
|
|
+ Msg: "指标名称不能为空",
|
|
|
+ })
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if v.Frequency == "" {
|
|
|
+ resp.Fail = append(resp.Fail, data_manage.BatchEdbInfoCalculateBatchSaveFailResp{
|
|
|
+ CalculateId: v.CalculateId,
|
|
|
+ Msg: "频率不能为空",
|
|
|
+ })
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if v.Unit == "" {
|
|
|
+ resp.Fail = append(resp.Fail, data_manage.BatchEdbInfoCalculateBatchSaveFailResp{
|
|
|
+ CalculateId: v.CalculateId,
|
|
|
+ Msg: "单位不能为空",
|
|
|
+ })
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ if v.ClassifyId <= 0 {
|
|
|
+ resp.Fail = append(resp.Fail, data_manage.BatchEdbInfoCalculateBatchSaveFailResp{
|
|
|
+ CalculateId: v.CalculateId,
|
|
|
+ Msg: "请选择分类",
|
|
|
+ })
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ reqEdbList = append(reqEdbList, v)
|
|
|
+ }
|
|
|
+ if len(reqEdbList) <= 0 {
|
|
|
+ br.Msg = "编辑失败!"
|
|
|
+ if len(resp.Fail) > 0 {
|
|
|
+ br.ErrMsg = resp.Fail[0].Msg
|
|
|
+ } else {
|
|
|
+ br.Msg = "请选择指标"
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.EdbList = reqEdbList
|
|
|
+ // 调用指标库去更新
|
|
|
+ reqJson, err := json.Marshal(req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ respItem, err := data.BatchEditEdbCalculateMultiData(string(reqJson))
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "编辑失败!"
|
|
|
+ br.ErrMsg = "编辑失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if respItem.Ret != 200 {
|
|
|
+ br.Msg = respItem.Msg
|
|
|
+ br.ErrMsg = respItem.ErrMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "批量编辑成功"
|
|
|
+ br.Data = respItem.Data
|
|
|
+ br.IsAddLog = true
|
|
|
+}
|
|
|
+
|
|
|
// CalculateMapping
|
|
|
// @Title 获取计算指标与基础指标关联
|
|
|
// @Description 获取计算指标与基础指标关联
|