Browse Source

Merge branch 'feature/eta1.8.5_excel_balance' into debug

xyxie 10 months ago
parent
commit
abcd2d0eef

+ 4 - 4
controllers/data_manage/excel/balance_table.go

@@ -1136,7 +1136,7 @@ func (c *ExcelInfoController) AddStaticExcel() {
 		childExcelList[k].Content = content
 	}
 
-	excelInfo, err, errMsg, isSendEmail := data.AddBalanceStaticExcel(oldExcelInfo, req.VersionName, sysUser, 0, req.ExcelInfoId, 1, childExcelList, true, excelDataMap)
+	excelInfo, err, errMsg, isSendEmail := data.AddBalanceStaticExcel(oldExcelInfo, oldExcelInfo.ExcelClassifyId, req.VersionName, sysUser, 0, req.ExcelInfoId, 1, childExcelList, true, excelDataMap)
 	if err != nil {
 		br.Msg = "复制失败"
 		if errMsg != `` {
@@ -1330,7 +1330,7 @@ func (c *ExcelInfoController) ModifyBalanceExcelVersion() {
 	{
 		var condition string
 		var pars []interface{}
-		condition += " AND rel_excel_info_id=? "
+		condition += " AND rel_excel_info_id=? AND parent_id=0"
 		pars = append(pars, req.ExcelInfoId)
 
 		condition += " AND version_name=? "
@@ -1338,12 +1338,12 @@ func (c *ExcelInfoController) ModifyBalanceExcelVersion() {
 
 		count, tmpErr := excel.GetExcelInfoCountByCondition(condition, pars)
 		if tmpErr != nil {
-			br.Msg = "查询版本失败"
+			br.Msg = "查询版本名称失败"
 			br.ErrMsg = tmpErr.Error()
 			return
 		}
 		if count > 0 {
-			br.Msg = "表格版本号已存在,请重新填写表格名称"
+			br.Msg = "表格版本名称已存在,请重新填写版本名称"
 			br.IsSendEmail = false
 			return
 		}

+ 24 - 2
controllers/data_manage/excel/excel_info.go

@@ -431,8 +431,30 @@ func (c *ExcelInfoController) List() {
 	//只看我的
 	isShowMe, _ := c.GetBool("IsShowMe")
 	if isShowMe {
-		condition += " AND sys_user_id = ? "
-		pars = append(pars, sysUser.AdminId)
+		if source == utils.BALANCE_TABLE { //平衡表的,显示同时需要显示协作人相关的图表
+			//找到当前协作人相关的表格ID
+			obj := new(excel3.ExcelWorker)
+			existList, err := obj.GetBySysUserId(sysUser.AdminId)
+			if err != nil {
+				br.Msg = "获取表格协作人失败!"
+				br.ErrMsg = "获取表格协作人失败,Err:" + err.Error()
+				return
+			}
+			if len(existList) > 0 {
+				var excelIds []int
+				for _, v := range existList {
+					excelIds = append(excelIds, v.ExcelInfoId)
+				}
+				condition += fmt.Sprintf(` AND  ( excel_info_id IN (%s)  or sys_user_id = ?)`, utils.GetOrmInReplace(len(excelIds)))
+				pars = append(pars, excelIds, sysUser.AdminId)
+			} else {
+				condition += " AND sys_user_id = ? "
+				pars = append(pars, sysUser.AdminId)
+			}
+		} else {
+			condition += " AND sys_user_id = ? "
+			pars = append(pars, sysUser.AdminId)
+		}
 	}
 	//获取表格信息
 	list, err := excel3.GetNoContentExcelListByCondition(condition, pars, startSize, pageSize)

+ 8 - 0
models/data_manage/excel/excel_worker.go

@@ -72,3 +72,11 @@ func (e *ExcelWorker) GetByExcelInfoId(excelInfoId int) (items []*ExcelWorker, e
 	_, err = o.Raw(sql, excelInfoId).QueryRows(&items)
 	return
 }
+
+// 查询
+func (e *ExcelWorker) GetBySysUserId(sysUserId int) (items []*ExcelWorker, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := `select * from excel_worker where sys_user_id = ? `
+	_, err = o.Raw(sql, sysUserId).QueryRows(&items)
+	return
+}

+ 8 - 8
services/data/chart_info_excel_balance.go

@@ -1266,7 +1266,7 @@ func getBalanceDataListStartDateAndValue(dataList []*data_manage.EdbDataList) (s
 }
 
 // AddBalanceStaticExcel 另存为和存为静态表以及子表的复制都调用该接口
-func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, versionName string, sysUser *system.Admin, parentId, relExcelInfoId, balanceType int, childExcelList []*excelModel.ExcelInfo, pingNameFlag bool, excelDataMap map[int]map[int][]*data_manage.EdbDataList) (excelInfo *excelModel.ExcelInfo, err error, errMsg string, isSendEmail bool) {
+func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, excelClassifyId int, versionName string, sysUser *system.Admin, parentId, relExcelInfoId, balanceType int, childExcelList []*excelModel.ExcelInfo, pingNameFlag bool, excelDataMap map[int]map[int][]*data_manage.EdbDataList) (excelInfo *excelModel.ExcelInfo, err error, errMsg string, isSendEmail bool) {
 	isSendEmail = true
 
 	versionName = utils.TrimLRStr(versionName)
@@ -1275,7 +1275,7 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, versionName strin
 	if balanceType == 1 && versionName != "" {
 		var condition string
 		var pars []interface{}
-		condition += " AND rel_excel_info_id=? AND balance_type=1"
+		condition += " AND rel_excel_info_id=? AND balance_type=1 AND parent_id=0"
 		pars = append(pars, oldExcelInfo.ExcelInfoId)
 
 		condition += " AND version_name=? "
@@ -1283,12 +1283,12 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, versionName strin
 
 		count, tmpErr := excelModel.GetExcelInfoCountByCondition(condition, pars)
 		if tmpErr != nil {
-			errMsg = "查询版本失败"
+			errMsg = "查询版本名称失败"
 			err = tmpErr
 			return
 		}
 		if count > 0 {
-			errMsg = "表格版本号已存在,请重新填写版本号"
+			errMsg = "表格版本名称已存在,请重新填写版本名称"
 			err = errors.New(errMsg)
 			isSendEmail = false
 			return
@@ -1310,7 +1310,7 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, versionName strin
 		Source:             oldExcelInfo.Source,
 		ExcelType:          oldExcelInfo.ExcelType,
 		UniqueCode:         utils.MD5(utils.EXCEL_DATA_PREFIX + "_" + timestamp),
-		ExcelClassifyId:    oldExcelInfo.ExcelClassifyId,
+		ExcelClassifyId:    excelClassifyId,
 		SysUserId:          sysUser.AdminId,
 		SysUserRealName:    sysUser.RealName,
 		Content:            content,
@@ -1351,7 +1351,7 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, versionName strin
 	}
 	if parentId == 0 && len(childExcelList) > 0 {
 		for _, childExcelInfo := range childExcelList {
-			_, err, errMsg, isSendEmail = AddBalanceStaticExcel(childExcelInfo, versionName, sysUser, excelInfo.ExcelInfoId, relExcelInfoId, balanceType, []*excelModel.ExcelInfo{}, false, excelDataMap)
+			_, err, errMsg, isSendEmail = AddBalanceStaticExcel(childExcelInfo, excelClassifyId, versionName, sysUser, excelInfo.ExcelInfoId, relExcelInfoId, balanceType, []*excelModel.ExcelInfo{}, false, excelDataMap)
 			if err != nil {
 				return
 			}
@@ -1604,7 +1604,7 @@ func CopyBalanceExcel(oldExcelInfo *excelModel.ExcelInfo, excelClassifyId int, e
 	}
 	// 查询出每个子表的内容,并将内容转为静态版本
 	excelDataMap := make(map[int]map[int][]*data_manage.EdbDataList)
-	excelInfo, err, errMsg, isSendEmail = AddBalanceStaticExcel(oldExcelInfo, "", sysUser, 0, 0, 0, childExcelList, false, excelDataMap)
+	excelInfo, err, errMsg, isSendEmail = AddBalanceStaticExcel(oldExcelInfo, excelClassifyId, "", sysUser, 0, 0, 0, childExcelList, false, excelDataMap)
 	if err != nil {
 		errMsg = "复制动态表失败"
 		err = fmt.Errorf("复制动态表失败 %s", err.Error())
@@ -1655,7 +1655,7 @@ func CopyBalanceExcel(oldExcelInfo *excelModel.ExcelInfo, excelClassifyId int, e
 				}
 			}
 		}
-		_, err, errMsg, isSendEmail = AddBalanceStaticExcel(staticExcelInfo, staticExcelInfo.VersionName, sysUser, 0, excelInfo.ExcelInfoId, 1, childList, false, excelDataMap)
+		_, err, errMsg, isSendEmail = AddBalanceStaticExcel(staticExcelInfo, excelClassifyId, staticExcelInfo.VersionName, sysUser, 0, excelInfo.ExcelInfoId, 1, childList, false, excelDataMap)
 		if err != nil {
 			errMsg = "复制动态表失败"
 			err = fmt.Errorf("复制动态表失败 %s", err.Error())