Browse Source

Merge remote-tracking branch 'origin/master' into sandbox

Roc 1 year ago
parent
commit
2f7ee84325

+ 3 - 0
controllers/data_manage/chart_classify.go

@@ -1037,6 +1037,9 @@ func (this *ChartClassifyController) ChartClassifyChartListV2() {
 
 	for k, item := range allNodes {
 		item.Button = data.GetChartOpButton(this.SysUser, item.SysUserId)
+		item.Button.AddButton = false
+		item.Button.OpButton = false
+		item.Button.DeleteButton = false
 		allNodes[k] = item
 	}
 

+ 10 - 10
controllers/data_manage/correlation/correlation_chart_info.go

@@ -696,7 +696,6 @@ func (this *CorrelationChartInfoController) Detail() {
 
 	var dataResp interface{} // 绘图数据返回(目前是滚动相关性的图)
 	var xEdbIdValue []int
-	var xDateTimeValue []string
 	var yDataList []data_manage.YData
 	switch chartInfo.Source {
 	case utils.CHART_SOURCE_CORRELATION: // 相关性图
@@ -717,10 +716,11 @@ func (this *CorrelationChartInfoController) Detail() {
 		}
 	case utils.CHART_SOURCE_ROLLING_CORRELATION: // 滚动相关性图
 		startDate, endDate := utils.GetDateByDateType(correlationChart.DateType, correlationChart.StartDate.Format(utils.FormatDate), correlationChart.EndDate.Format(utils.FormatDate))
-		xDateTimeValue, yDataList, e = correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, correlationChart.LeadValue, correlationChart.LeadUnit, correlationChart.CalculateValue, correlationChart.CalculateUnit, startDate, endDate)
-		dataResp = data_manage.RollingCorrelationChartDataResp{
-			XDateTimeValue: xDateTimeValue,
-			YDataList:      yDataList,
+		dataResp, e = correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, correlationChart.LeadValue, correlationChart.LeadUnit, correlationChart.CalculateValue, correlationChart.CalculateUnit, startDate, endDate, chartInfo.ChartName, chartInfo.ChartNameEn)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取滚动相关性图表, 图表计算值失败, Err:" + e.Error()
+			return
 		}
 	}
 
@@ -1175,7 +1175,6 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 
 	var dataResp interface{} // 绘图数据返回(目前是滚动相关性的图)
 	var xEdbIdValue []int
-	var xDateTimeValue []string
 	var yDataList []data_manage.YData
 	switch chartInfo.Source {
 	case utils.CHART_SOURCE_CORRELATION: // 相关性图
@@ -1197,10 +1196,11 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 	case utils.CHART_SOURCE_ROLLING_CORRELATION: // 滚动相关性图
 		startDate, endDate := utils.GetDateByDateType(correlationChart.DateType, correlationChart.StartDate.Format(utils.FormatDate), correlationChart.EndDate.Format(utils.FormatDate))
 
-		xDateTimeValue, yDataList, e = correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, correlationChart.LeadValue, correlationChart.LeadUnit, correlationChart.CalculateValue, correlationChart.CalculateUnit, startDate, endDate)
-		dataResp = data_manage.RollingCorrelationChartDataResp{
-			XDateTimeValue: xDateTimeValue,
-			YDataList:      yDataList,
+		dataResp, e = correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, correlationChart.LeadValue, correlationChart.LeadUnit, correlationChart.CalculateValue, correlationChart.CalculateUnit, startDate, endDate, chartInfo.ChartName, chartInfo.ChartNameEn)
+		if e != nil {
+			msg = "获取失败"
+			errMsg = "获取滚动相关性图表, 图表计算值失败, Err:" + e.Error()
+			return
 		}
 	}
 

+ 117 - 0
controllers/data_manage/edb_info.go

@@ -6,7 +6,9 @@ import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hz_eta_api/controllers"
 	"hongze/hz_eta_api/models"
+	"hongze/hz_eta_api/models/company"
 	"hongze/hz_eta_api/models/data_manage"
+	"hongze/hz_eta_api/models/system"
 	"hongze/hz_eta_api/services/alarm_msg"
 	"hongze/hz_eta_api/services/data"
 	"hongze/hz_eta_api/services/elastic"
@@ -4180,3 +4182,118 @@ func (this *EdbInfoController) GetEdbBeforeAndAfterDateData() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+
+// EdbChartAdminList
+// @Title 获取创建人员分组
+// @Description 获取创建人员分组
+// @Param   Source   query   int  false       "来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库"
+// @Success 200 {object} company.DepartmentGroupSellersResp
+// @router /edb_chart/adminList [get]
+func (this *EdbInfoController) EdbChartAdminList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	source, _ := this.GetInt("Source", 0)
+	if source <= 0 || source > 5 {
+		br.Msg = "错误的来源"
+		br.IsSendEmail = false
+		return
+	}
+
+	idList, err := data.GetEdbChartAdminList(source)
+	if err != nil {
+		//br.Success = true
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	fmt.Println("idlist:",idList)
+	systemAdminMap := make(map[int]*system.Admin)
+	departmentMap := make(map[string]string)
+	departmentAdminMap := make(map[int]string)
+	groupMap := make(map[string]string)
+	systemAdminList, err := system.GetAdminListByIdListWithoutEnable(idList)
+	if err != nil {
+		br.Msg = "获取用户列表失败"
+		br.ErrMsg = "获取用户列表失败,Err:" + err.Error()
+		return
+	}
+
+	for _, v := range systemAdminList {
+		systemAdminMap[v.AdminId] = v
+		departmentMap[v.DepartmentName] = v.DepartmentName
+		departmentAdminMap[v.AdminId] = v.DepartmentName
+		groupMap[v.GroupName] = v.DepartmentName
+	}
+
+	depList := make([]company.DepartmentGroupAdmins, 0)
+
+	i := 1
+	for _, v := range departmentMap {
+		item := company.DepartmentGroupAdmins{
+			AdminId:      "dep_" + strconv.Itoa(i),
+			RealName:     v,
+		}
+		i++
+		depList = append(depList, item)
+	}
+
+	for k:=0;k<len(depList);k++{
+		for k1, v1 := range groupMap {
+			if v1 == depList[k].RealName && v1 != "" {
+				item := &company.DepartmentGroupAdmins{
+					AdminId:      "group_" + strconv.Itoa(k),
+					RealName:     k1,
+				}
+				depList[k].ChildrenList = append(depList[k].ChildrenList, item)
+			}
+		}
+	}
+
+
+
+	for _, admin := range systemAdminList {
+		for i, v := range depList {
+			for _, group := range v.ChildrenList {
+				if admin.GroupName == group.RealName {
+					item := &company.DepartmentGroupAdmins{
+						AdminId:      strconv.Itoa(admin.AdminId),
+						RealName:     admin.RealName,
+						RoleTypeCode: admin.RoleTypeCode,
+						Authority:    admin.Authority,
+					}
+					if group.RealName != "" {
+						group.ChildrenList = append(group.ChildrenList, item)
+					} else {
+						depList[i].ChildrenList = append(depList[i].ChildrenList, item)
+					}
+				}
+			}
+		}
+	}
+
+	for _, groupList := range depList {
+		for k, v := range groupList.ChildrenList {
+			if v.RealName == "" {
+				groupList.ChildrenList = append(groupList.ChildrenList[:k], groupList.ChildrenList[k+1:]...)
+			}
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = depList
+}

+ 12 - 11
controllers/data_manage/multiple_graph_config.go

@@ -295,6 +295,8 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 		correlationConf := req.Correlation
 		// 配置了数据才有返回
 		if correlationConf.LeadValue > 0 {
+			tmpChartInfo := *chartInfo
+
 			moveUnitDays, ok := utils.FrequencyDaysMap[correlationConf.CalculateUnit]
 			if !ok {
 				br.Msg = "错误的分析周期"
@@ -310,7 +312,7 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 				return
 			}
 
-			tmpChartInfo := *chartInfo
+			tmpChartInfo.ChartName += fmt.Sprint(`(`, correlationConf.CalculateValue, correlationConf.CalculateUnit, `)`)
 			tmpChartInfo.Source = utils.CHART_SOURCE_CORRELATION
 			resp.CorrelationData = response.CorrelationResp{
 				ChartInfo:   tmpChartInfo,
@@ -352,12 +354,6 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 			rollingCorrelationData := make([]interface{}, 0)
 			for _, rollingCorrelationConf := range rollingCorrelationConfList {
 				if rollingCorrelationConf.CalculateValue > 0 && rollingCorrelationConf.CalculateUnit != `` {
-					xDateTimeValue, yDataList, e := correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, rollingCorrelationConf.LeadValue, rollingCorrelationConf.LeadUnit, rollingCorrelationConf.CalculateValue, rollingCorrelationConf.CalculateUnit, startDate, endDate)
-					if e != nil {
-						br.Msg = "获取失败"
-						br.ErrMsg = "获取滚动相关性图表, 图表计算值失败, Err:" + e.Error()
-						return
-					}
 					tmpChartInfo := *chartInfo
 					tmpChartInfo.Source = utils.CHART_SOURCE_ROLLING_CORRELATION
 					// ”指标A名称“+”指标B名称“+"滚动相关性"+”滚动相关性计算窗口值“+”滚动相关性计算窗口单位“
@@ -372,11 +368,16 @@ func (this *ChartInfoController) MultipleGraphPreview() {
 					} else {
 						tmpChartInfo.ChartName = fmt.Sprintf(`%s与%s(领先%d%s)%d%s滚动相关性`, edbInfoMappingA.EdbName, edbInfoMappingB.EdbName, int(math.Abs(float64(rollingCorrelationConf.LeadValue))), rollingCorrelationConf.LeadUnit, rollingCorrelationConf.CalculateValue, rollingCorrelationConf.CalculateUnit)
 					}
+					dataResp, e := correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, rollingCorrelationConf.LeadValue, rollingCorrelationConf.LeadUnit, rollingCorrelationConf.CalculateValue, rollingCorrelationConf.CalculateUnit, startDate, endDate, tmpChartInfo.ChartName, tmpChartInfo.ChartNameEn)
+					if e != nil {
+						br.Msg = "获取失败"
+						br.ErrMsg = "获取滚动相关性图表, 图表计算值失败, Err:" + e.Error()
+						return
+					}
 					rollingCorrelationData = append(rollingCorrelationData, response.RollingCorrelationResp{
-						ChartInfo:      tmpChartInfo,
-						EdbInfoList:    mappingList,
-						XDateTimeValue: xDateTimeValue,
-						YDataList:      yDataList,
+						ChartInfo:   tmpChartInfo,
+						EdbInfoList: mappingList,
+						DataResp:    dataResp,
 						CorrelationChartInfo: data_manage.CorrelationInfo{
 							LeadValue:       rollingCorrelationConf.LeadValue,
 							LeadUnit:        rollingCorrelationConf.LeadUnit,

+ 125 - 59
controllers/english_report/report.go

@@ -7,12 +7,14 @@ import (
 	"hongze/hz_eta_api/controllers"
 	"hongze/hz_eta_api/models"
 	"hongze/hz_eta_api/models/company"
+	"hongze/hz_eta_api/models/system"
 	"hongze/hz_eta_api/services"
 	"hongze/hz_eta_api/services/alarm_msg"
 	"hongze/hz_eta_api/utils"
 	"html"
 	"strconv"
 	"strings"
+	"sync"
 	"time"
 )
 
@@ -389,55 +391,114 @@ func (this *EnglishReportController) ListReport() {
 		}
 	}
 
-	total, err := models.GetEnglishReportListCount(condition, pars, companyType)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	list, err := models.GetEnglishReportList(condition, pars, companyType, startSize, pageSize)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
+	var total int
+	var errCount, errList, errOther error
+	var authOk bool
+	list := make([]*models.EnglishReportList, 0)
+	failMap := make(map[int]bool, 0)    // 有群发失败记录的研报
+	adminMap := make(map[int]string, 0) // 编辑中的研究员姓名
 
-	// 获取邮件配置-是否有权限群发
-	conf := new(models.EnglishReportEmailConf)
-	authKey := "english_report_email_conf"
-	confAuth, e := company.GetConfigDetailByCode(authKey)
-	if e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取群发邮件权限失败, Err: " + e.Error()
-		return
-	}
-	if confAuth.ConfigValue == "" {
+	wg := sync.WaitGroup{}
+	wg.Add(3)
+
+	// 列表总数
+	go func() {
+		defer func() {
+			wg.Done()
+		}()
+
+		t, e := models.GetEnglishReportListCount(condition, pars, companyType)
+		if e != nil {
+			errCount = fmt.Errorf("获取英文研报Count失败, Err: %s", e.Error())
+			return
+		}
+		total = t
+	}()
+
+	// 列表数据
+	go func() {
+		defer func() {
+			wg.Done()
+		}()
+
+		// 限制一下富文本字段, 列表用不到
+		fieldArr := []string{
+			"id", "add_type", "classify_id_first", "classify_name_first", "classify_id_second", "classify_name_second", "title", "abstract", "author",
+			"frequency", "create_time", "modify_time", "state", "publish_time", "stage", "msg_is_send", "report_code", "pv", "share_url",
+			"pv_email", "email_state", "from_report_id", "key_takeaways", "admin_id", "admin_real_name",
+		}
+		items, e := models.GetEnglishReportList(condition, pars, companyType, startSize, pageSize, fieldArr)
+		if e != nil {
+			errList = fmt.Errorf("获取英文研报列表失败, Err: %s", e.Error())
+			return
+		}
+		list = items
+	}()
+
+	// 群发权限/失败记录
+	go func() {
+		defer func() {
+			wg.Done()
+		}()
+
+		// 获取邮件配置-是否有权限群发
+		conf := new(models.EnglishReportEmailConf)
+		authKey := "english_report_email_conf"
+		confAuth, e := company.GetConfigDetailByCode(authKey)
+		if e != nil {
+			errOther = fmt.Errorf("获取群发邮件权限失败, Err: %s", e.Error())
+			return
+		}
+		if confAuth.ConfigValue == "" {
+			errOther = fmt.Errorf("群发邮件配置为空")
+			return
+		}
+		if e := json.Unmarshal([]byte(confAuth.ConfigValue), &conf); e != nil {
+			errOther = fmt.Errorf("群发邮件配置有误")
+			return
+		}
+		authArr := strings.Split(conf.SendAuthGroup, ",")
+		if utils.InArrayByStr(authArr, sysUser.RoleTypeCode) {
+			authOk = true
+		}
+
+		// 是否有群发邮件失败的记录,标记红点
+		failList, e := models.GetEnglishReportEmailLogFailList(0)
+		if e != nil {
+			errOther = fmt.Errorf("获取群发邮件记录失败, Err: %s", e.Error())
+			return
+		}
+		for i := range failList {
+			failMap[failList[i].ReportId] = true
+		}
+
+		// 获取admin, 用于匹配编辑中的研究员姓名
+		admins, e := system.GetSysAdminList("", make([]interface{}, 0), []string{"admin_id", "real_name"}, "")
+		if e != nil {
+			errOther = fmt.Errorf("获取系统用户列表失败, Err: %s", e.Error())
+			return
+		}
+		for _, a := range admins {
+			adminMap[a.AdminId] = a.RealName
+		}
+	}()
+	wg.Wait()
+
+	if errCount != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "群发邮件配置为空"
+		br.ErrMsg = errCount.Error()
 		return
 	}
-	if e := json.Unmarshal([]byte(confAuth.ConfigValue), &conf); e != nil {
+	if errList != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "群发邮件配置有误"
+		br.ErrMsg = errList.Error()
 		return
 	}
-	authOk := false
-	authArr := strings.Split(conf.SendAuthGroup, ",")
-	if utils.InArrayByStr(authArr, sysUser.RoleTypeCode) {
-		authOk = true
-	}
-
-	// 是否有群发邮件失败的记录,标记红点
-	failList, e := models.GetEnglishReportEmailLogFailList(0)
-	if e != nil {
+	if errOther != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取群发邮件记录失败, Err: " + e.Error()
+		br.ErrMsg = errOther.Error()
 		return
 	}
-	failMap := make(map[int]bool, 0)
-	for i := range failList {
-		failMap[failList[i].ReportId] = true
-	}
 
 	for _, item := range list {
 		if item.State == 2 {
@@ -445,37 +506,42 @@ func (this *EnglishReportController) ListReport() {
 		}
 		item.EmailAuth = authOk
 		item.EmailHasFail = failMap[item.Id]
+
 		// 邮箱PV大于0的时候, 不展示最初版本的PV
 		if item.PvEmail > 0 {
 			item.Pv = 0
 		}
 
-		/*key := fmt.Sprint(`crm:enReport:edit:`, item.Id)
-		opUserId, _ := utils.Rc.RedisInt(key)
-		//如果当前没有人操作,获取当前操作人是本人,那么编辑按钮可用
-		if opUserId <= 0 || (opUserId == this.SysUser.AdminId) {
-			item.CanEdit = true
-		} else {
-			adminInfo, errAdmin := system.GetSysUserById(opUserId)
-			if errAdmin != nil {
-				br.Msg = "获取失败"
-				br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
-				return
+		// 报告是否正在编辑中
+		var opUser models.MarkReportItem
+		key := fmt.Sprint(`crm:enReport:edit:`, item.Id)
+		opUserId, e := utils.Rc.RedisInt(key)
+		if e != nil {
+			str, te := utils.Rc.RedisString(key)
+			if te == nil {
+				te = json.Unmarshal([]byte(str), &opUser)
+				if te == nil {
+					opUserId = opUser.AdminId
+				}
 			}
-			item.Editor = adminInfo.RealName
-		}*/
-		markStatus, err := services.UpdateEnReportEditMark(item.Id, this.SysUser.AdminId, 2, this.SysUser.RealName)
-		if err != nil {
-			br.Msg = "查询标记状态失败"
-			br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
-			return
 		}
-		if markStatus.Status == 0 {
+		var ret models.MarkReportResp
+		if opUserId > 0 && opUserId != sysUser.AdminId {
+			editor := opUser.Editor
+			if editor == "" {
+				editor = adminMap[opUserId]
+			}
+			ret.Status = 1
+			ret.Msg = fmt.Sprintf("当前%s正在编辑报告", editor)
+			ret.Editor = editor
+		}
+		if ret.Status == 0 {
 			item.CanEdit = true
 		} else {
-			item.Editor = markStatus.Editor
+			item.Editor = ret.Editor
 		}
 	}
+
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(models.EnglishReportListResp)
 	resp.Paging = page

+ 5 - 4
controllers/sandbox/sandbox.go

@@ -325,11 +325,11 @@ func (this *SandboxController) Save() {
 		return
 	}
 
-	var sandboxInfo *sandbox.Sandbox
+	var sandboxResp *sandbox.SandboxSaveResp
 	var errMsg string
 	if req.SandboxVersionCode == `` {
 		//新增沙盘
-		sandboxInfo, err = sandboxService.AddSandbox(req, sysUser.AdminId, sysUser.RealName)
+		sandboxResp, err = sandboxService.AddSandbox(req, sysUser.AdminId, sysUser.RealName)
 	} else {
 		////更新当前编辑中的状态缓存
 		//err = sandboxService.UpdateSandboxEditMark(req.SandboxId, sysUser.AdminId, 1)
@@ -339,7 +339,7 @@ func (this *SandboxController) Save() {
 		//}
 
 		//编辑沙盘
-		sandboxInfo, err, errMsg = sandboxService.UpdateSandbox(req, sysUser.AdminId, sysUser.RealName)
+		sandboxResp, err, errMsg = sandboxService.UpdateSandbox(req, sysUser.AdminId, sysUser.RealName)
 	}
 	if err != nil {
 		br.Msg = "保存失败!"
@@ -349,11 +349,12 @@ func (this *SandboxController) Save() {
 		br.ErrMsg = "保存失败,Err:" + err.Error()
 		return
 	}
+
 	msg := "保存成功"
 	br.Ret = 200
 	br.Success = true
 	br.Msg = msg
-	br.Data = sandboxInfo
+	br.Data = sandboxResp
 }
 
 // AddSandboxDraft

+ 10 - 0
models/company/company_seller.go

@@ -23,3 +23,13 @@ type DepartmentGroupSellers struct {
 	RoleTypeCode string                   `description:"角色编码"`
 	Authority    int                      `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
 }
+
+
+type DepartmentGroupAdmins struct {
+	AdminId string `description:"系统用户id"`
+	//AdminName string `description:"系统用户名称"`
+	RealName     string                   `description:"用户真实名称"`
+	ChildrenList []*DepartmentGroupAdmins `description:"角色列表"`
+	RoleTypeCode string                   `description:"角色编码"`
+	Authority    int                      `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
+}

+ 9 - 0
models/data_manage/chart_info.go

@@ -1766,3 +1766,12 @@ func GetChartInfoByAdminIdAndClassify(sourceList []int, adminId, classifyId int)
 	_, err = o.Raw(sql, sourceList, adminId, classifyId).QueryRows(&items)
 	return
 }
+
+// GetChartInfoAdminList 根据条件获取图表数据了列表
+func GetChartInfoAdminList() (items []int, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT sys_user_id FROM chart_info GROUP BY sys_user_id `
+
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 9 - 0
models/data_manage/edb_info.go

@@ -1762,3 +1762,12 @@ type BeforeAndAfterDateDataResp struct {
 	List []*EdbDataList `description:"list"`
 	Date string         `description:"实际日期"`
 }
+
+// GetEdbInfoAdminList
+func GetEdbInfoAdminList(edbType int) (list []int, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT sys_user_id FROM edb_info WHERE edb_info_type = ? GROUP BY sys_user_id  `
+
+	_,err = o.Raw(sql, edbType).QueryRows(&list)
+	return
+}

+ 9 - 0
models/data_manage/mysteel_chemical_index.go

@@ -308,3 +308,12 @@ func ModifyMysteelChemicalIndexUserIdByCodeList(edbIdList []string, userId int,
 	_, err = o.Raw(sql, userId, userName, edbIdList).Exec()
 	return
 }
+
+// GetMysteelChemicalIndexAdminList 获取所有指标创建人
+func GetMysteelChemicalIndexAdminList() (list []int, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT sys_user_id FROM base_from_mysteel_chemical_index GROUP BY sys_user_id `
+
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 1 - 2
models/data_manage/response/multiple_graph_config.go

@@ -26,8 +26,7 @@ type CorrelationResp struct {
 type RollingCorrelationResp struct {
 	ChartInfo            data_manage.ChartInfoView
 	EdbInfoList          []*data_manage.ChartEdbInfoMapping
-	XDateTimeValue       []string                    `description:"柱方图的x轴数据,指标id"`
-	YDataList            []data_manage.YData         `description:"柱方图的y轴数据"`
+	DataResp             interface{}
 	CorrelationChartInfo data_manage.CorrelationInfo `description:"相关性图表信息"`
 }
 

+ 8 - 3
models/english_report.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"errors"
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hz_eta_api/utils"
@@ -280,7 +281,7 @@ func GetEnglishReportListCount(condition string, pars []interface{}, companyType
 	return
 }
 
-func GetEnglishReportList(condition string, pars []interface{}, companyType string, startSize, pageSize int) (items []*EnglishReportList, err error) {
+func GetEnglishReportList(condition string, pars []interface{}, companyType string, startSize, pageSize int, fieldArr []string) (items []*EnglishReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	//产品权限
 	companyTypeSqlStr := ``
@@ -290,8 +291,12 @@ func GetEnglishReportList(condition string, pars []interface{}, companyType stri
 		companyTypeSqlStr = " AND classify_id_first = 40 "
 	}
 
-	sql := `SELECT * 
-        FROM english_report WHERE 1=1  ` + companyTypeSqlStr
+	fields := "*"
+	if len(fieldArr) > 0 {
+		fields = strings.Join(fieldArr, ",")
+	}
+
+	sql := fmt.Sprintf(`SELECT %s FROM english_report WHERE 1=1 %s `, fields, companyTypeSqlStr)
 	if condition != "" {
 		sql += condition
 	}

+ 6 - 0
models/sandbox/sandbox.go

@@ -187,3 +187,9 @@ func GetList(condition string, pars []interface{}, startSize, pageSize int) (tot
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
 	return
 }
+
+// SandboxSaveResp 保存沙盘响应体
+type SandboxSaveResp struct {
+	*Sandbox
+	VersionCode string `description:"版本号"`
+}

+ 16 - 0
models/system/sys_admin.go

@@ -353,3 +353,19 @@ type SyncGroupData struct {
 	Source  int `description:"来源: 1-CRM; 2-ETA"`
 	GroupId int `description:"分组ID"`
 }
+
+// GetSysAdminList 获取admin列表
+func GetSysAdminList(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*Admin, err error) {
+	fields := "*"
+	if len(fieldArr) > 0 {
+		fields = strings.Join(fieldArr, ",")
+	}
+	order := `enabled DESC, last_updated_time DESC`
+	if orderRule != "" {
+		order = orderRule
+	}
+	sql := fmt.Sprintf(`SELECT %s FROM admin WHERE 1=1 %s ORDER BY %s`, fields, condition, order)
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 7 - 0
models/target.go

@@ -1436,3 +1436,10 @@ func ModifyEdbinfoUserIdByCodeList(edbCodeList []string, userId int) (err error)
 	_, err = o.Raw(sql, userId, edbCodeList).Exec()
 	return
 }
+
+func GetEdbInfoAdminList() (list []int, err error) {
+	sql := `SELECT user_id FROM edbinfo GROUP BY user_id `
+	o := orm.NewOrmUsingDB("edb")
+	_,err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -1879,6 +1879,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"],
+        beego.ControllerComments{
+            Method: "EdbChartAdminList",
+            Router: `/edb_chart/adminList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["hongze/hz_eta_api/controllers/data_manage:EdbInfoController"],
         beego.ControllerComments{
             Method: "MoveEdbChartUser",

+ 74 - 13
services/data/correlation/chart_info.go

@@ -379,10 +379,41 @@ func GetChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *data_manage.ChartEd
 	return
 }
 
+// RollingCorrelationChartDataResp 滚动相关性图表数据
+type RollingCorrelationChartDataResp struct {
+	MaxData             float64
+	MinData             float64
+	LatestDate          string `description:"真实数据的最后日期"`
+	EdbInfoCategoryType int
+	ChartColor          string
+	ChartStyle          string
+	PredictChartColor   string
+	ChartType           int
+	ChartWidth          int
+	EdbName             string
+	EdbNameEn           string
+	Unit                string
+	UnitEn              string
+	IsAxis              int
+	DataList            []data_manage.EdbDataList
+}
+
 // GetRollingCorrelationChartDataByEdbInfo 滚动相关性计算
-func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *data_manage.ChartEdbInfoMapping, leadValue int, leadUnit string, calculateValue int, calculateUnit string, startDate, endDate string) (xDateTimeValue []string, yDataList []data_manage.YData, err error) {
-	xDateTimeValue = make([]string, 0)
-	yData := make([]float64, 0)
+func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *data_manage.ChartEdbInfoMapping, leadValue int, leadUnit string, calculateValue int, calculateUnit string, startDate, endDate, chartName, chartNameEn string) (dataResp RollingCorrelationChartDataResp, err error) {
+	dataResp = RollingCorrelationChartDataResp{
+		DataList:          make([]data_manage.EdbDataList, 0),
+		MaxData:           0,
+		MinData:           0,
+		ChartColor:        "#00f",
+		ChartStyle:        `spline`,
+		PredictChartColor: `#00f`,
+		ChartType:         0,
+		ChartWidth:        3,
+		EdbName:           chartName,
+		EdbNameEn:         chartNameEn,
+		IsAxis:            1,
+	}
+	dataList := make([]data_manage.EdbDataList, 0)
 
 	// 计算窗口,不包含第一天
 	startDateTime, _ := time.ParseInLocation(utils.FormatDate, startDate, time.Local)
@@ -457,6 +488,8 @@ func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *d
 		endDateTime, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
 		endDateTime = endDateTime.AddDate(0, 0, -(calculateDay - 1))
 
+		// 是否开始第一条数据
+		var isStart, isNotFirst bool
 		for currDay := startDateTime; !currDay.After(endDateTime); currDay = currDay.AddDate(0, 0, 1) {
 			yCalculateData := make([]float64, 0)
 			baseCalculateData := make([]float64, 0)
@@ -479,18 +512,46 @@ func GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB *d
 			var ratio float64
 			if len(baseCalculateData) > 0 {
 				ratio = utils.CalculateCorrelationByIntArr(baseCalculateData, yCalculateData)
+			} else {
+				// 没有数据的话,那就不返回
+				continue
+			}
+
+			// 过滤前面都是0的数据
+			{
+				if ratio != 0 {
+					isStart = true
+				}
+
+				if !isStart {
+					continue
+				}
+			}
+
+			dataTime := currDay.AddDate(0, 0, calculateDay-1)
+			dataList = append(dataList, data_manage.EdbDataList{
+				//EdbDataId:     0,
+				EdbInfoId:     0,
+				DataTime:      dataTime.Format(utils.FormatDate),
+				DataTimestamp: dataTime.UnixNano() / 1e6,
+				Value:         ratio,
+			})
+
+			if !isNotFirst {
+				dataResp.MinData = ratio
+				dataResp.MaxData = ratio
+				isNotFirst = true
+			}
+			if dataResp.MinData > ratio {
+				dataResp.MinData = ratio
+			}
+			if dataResp.MaxData < ratio {
+				dataResp.MaxData = ratio
 			}
-			yData = append(yData, ratio)
-			xDateTimeValue = append(xDateTimeValue, currDay.AddDate(0, 0, calculateDay-1).Format(utils.FormatDate))
 		}
+		dataResp.DataList = dataList
 	}
 
-	yDataList = make([]data_manage.YData, 0)
-	yDate := "0000-00-00"
-	yDataList = append(yDataList, data_manage.YData{
-		Date:  yDate,
-		Value: yData,
-	})
 	return
 }
 
@@ -1031,8 +1092,8 @@ func EditChartInfo(req data_manage.EditChartInfoReq, sysUser *system.Admin) (cha
 	correlationChart.CalculateUnit = req.CorrelationChartInfo.CalculateUnit
 	correlationChart.StartDate = startDate
 	correlationChart.EndDate = endDate
-	correlationChart.EdbInfoIdFirst = edbInfoIdArr[0]
-	correlationChart.EdbInfoIdSecond = edbInfoIdArr[1]
+	correlationChart.EdbInfoIdFirst = req.CorrelationChartInfo.EdbInfoIdList[0].EdbInfoId
+	correlationChart.EdbInfoIdSecond = req.CorrelationChartInfo.EdbInfoIdList[1].EdbInfoId
 
 	// 滚动相关性会有日期等信息
 	if chartItem.Source == utils.CHART_SOURCE_ROLLING_CORRELATION {

+ 46 - 6
services/data/edb_info.go

@@ -2031,8 +2031,8 @@ func GetMoveEdbChartList(source, userId int, keyword, classify string, startSize
 
 	case 2: //钢联化工数据库
 		if keyword != `` {
-			condition += " AND (index_name like ? OR index_code like ?) "
-			pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
+			condition += " AND (index_name like ? OR index_code like ? OR sys_user_real_name like ? ) "
+			pars = append(pars, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
 		}
 		if userId > 0 {
 			condition += ` AND sys_user_id = ? `
@@ -2065,8 +2065,8 @@ func GetMoveEdbChartList(source, userId int, keyword, classify string, startSize
 		}
 	case 3, 4: //ETA指标库、ETA预测指标
 		if keyword != `` {
-			condition += " AND (edb_code like ? OR edb_name like ?) "
-			pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
+			condition += " AND (edb_code like ? OR edb_name like ? OR sys_user_real_name like ? ) "
+			pars = append(pars, "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
 		}
 		if userId > 0 {
 			condition += ` AND sys_user_id = ? `
@@ -2105,8 +2105,8 @@ func GetMoveEdbChartList(source, userId int, keyword, classify string, startSize
 		}
 	case 5: //图库
 		if keyword != `` {
-			condition += " AND chart_name like ?  "
-			pars = append(pars, "%"+keyword+"%")
+			condition += " AND (chart_name like ?  OR sys_user_real_name like ? ) "
+			pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
 		}
 		if userId > 0 {
 			condition += ` AND sys_user_id = ? `
@@ -2962,3 +2962,43 @@ func getEdbRuleTitle(edbInfo, parentEdbInfo *data_manage.EdbInfo, childList []da
 
 	return
 }
+
+
+// GetEdbChartAdminList
+// @param source 来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库
+func GetEdbChartAdminList(source int) (list []int, err error) {
+	switch source {
+	case 1: //手工数据指标
+		list, err = models.GetEdbInfoAdminList()
+		if err != nil {
+			return
+		}
+
+	case 2: //钢联化工数据库
+		list, err = data_manage.GetMysteelChemicalIndexAdminList()
+		if err != nil {
+			return
+		}
+
+	case 3: //ETA指标库
+		list, err = data_manage.GetEdbInfoAdminList(0)
+		if err != nil {
+			return
+		}
+
+	case 4: //ETA预测指标
+		list, err = data_manage.GetEdbInfoAdminList(1)
+		if err != nil {
+			return
+		}
+	case 5: //图库
+		list, err = data_manage.GetChartInfoAdminList()
+		if err != nil {
+			return
+		}
+	default:
+		return
+	}
+
+	return
+}

+ 1 - 5
services/data/future_good/profit_chart_info.go

@@ -309,14 +309,10 @@ func ProfitChartChartData(baseDataList []*data_manage.EdbDataList, futureGoodEdb
 
 			calculateMap := make(map[int]float64)
 			for _, childFutureGoodEdbInfoId := range childFutureGoodEdbInfoIdList {
-				tmpRealDateTime := findDateTime
-				tmpFindDataValue, tmpIsFind := edbDataMap[childFutureGoodEdbInfoId][findDateTime.Format(utils.FormatDate)]
+				tmpFindDataValue, tmpIsFind := edbDataMap[childFutureGoodEdbInfoId][realDateTime.Format(utils.FormatDate)]
 
 				if tmpIsFind && tmpFindDataValue != 0 {
 					calculateMap[childFutureGoodEdbInfoId] = tmpFindDataValue
-					if maxDate.IsZero() || maxDate.Before(tmpRealDateTime) {
-						maxDate = tmpRealDateTime
-					}
 				}
 			}
 			// 合约的数据不全,不参与计算

+ 21 - 4
services/sandbox/sandbox.go

@@ -15,14 +15,15 @@ import (
 )
 
 // AddSandbox 新增沙盘
-func AddSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string) (sandboxInfo *sandbox.Sandbox, err error) {
+func AddSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string) (resp *sandbox.SandboxSaveResp, err error) {
+	resp = new(sandbox.SandboxSaveResp)
 	// 获取产品权限详情
 	chartPermissionInfo, err := company.GetChartPermissionListById(req.ChartPermissionId)
 	if err != nil {
 		return
 	}
 	//沙盘主表信息
-	sandboxInfo = &sandbox.Sandbox{
+	sandboxInfo := &sandbox.Sandbox{
 		Name:                utils.TrimStr(req.Name),
 		ChartPermissionId:   req.ChartPermissionId,
 		ChartPermissionName: chartPermissionInfo.PermissionName,
@@ -64,11 +65,17 @@ func AddSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string)
 
 	//新增沙盘
 	err = sandbox.AddNewSandbox(sandboxInfo, sandboxVersionInfo, sandboxDraftInfo)
+	if err != nil {
+		return
+	}
+	resp.Sandbox = sandboxInfo
+	resp.VersionCode = sandboxVersionInfo.VersionCode
 	return
 }
 
 // UpdateSandbox 更新沙盘
-func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string) (sandboxInfo *sandbox.Sandbox, err error, errMsg string) {
+func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName string) (resp *sandbox.SandboxSaveResp, err error, errMsg string) {
+	resp = new(sandbox.SandboxSaveResp)
 	// 获取沙盘版本信息
 	sandboxVersion, err := sandbox.GetSandboxVersionBySandboxVersionCode(req.SandboxVersionCode)
 	if err != nil {
@@ -79,7 +86,7 @@ func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName strin
 		return
 	}
 	// 获取沙盘主表信息
-	sandboxInfo, err = sandbox.GetSandboxById(sandboxVersion.SandboxId)
+	sandboxInfo, err := sandbox.GetSandboxById(sandboxVersion.SandboxId)
 	if err != nil {
 		if err.Error() == utils.ErrNoRow() {
 			errMsg = "找不到该沙盘"
@@ -152,6 +159,11 @@ func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName strin
 
 		//修改沙盘
 		err = sandbox.UpdateSandboxName(sandboxInfo, sandboxVersionInfo, sandboxDraftInfo, updateSandboxColumn, updateSandboxVersionColumn)
+		if err != nil {
+			return
+		}
+		resp.Sandbox = sandboxInfo
+		resp.VersionCode = sandboxVersionInfo.VersionCode
 	} else {
 		sandboxInfo.Name = utils.TrimStr(req.Name)
 		sandboxInfo.ChartPermissionId = req.ChartPermissionId
@@ -194,6 +206,11 @@ func UpdateSandbox(req request.AddAndEditSandbox, opUserId int, opUserName strin
 
 		//修改沙盘
 		err = sandbox.UpdateSandbox(sandboxInfo, updateSandbox, sandboxVersionInfo, sandboxDraftInfo)
+		if err != nil {
+			return
+		}
+		resp.Sandbox = sandboxInfo
+		resp.VersionCode = sandboxVersionInfo.VersionCode
 	}
 	return
 }