|
@@ -38,8 +38,6 @@ type ExcelInfo struct {
|
|
|
|
|
|
// Update 更新 excel表格基础信息
|
|
|
func (excelInfo *ExcelInfo) Update(cols []string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //_, err = o.Update(excelInfo, cols...)
|
|
|
err = global.DmSQL["data"].Select(cols).Updates(excelInfo).Error
|
|
|
return
|
|
|
}
|
|
@@ -69,18 +67,6 @@ type MyExcelInfoList struct {
|
|
|
|
|
|
// AddExcelInfo 新增表格
|
|
|
func AddExcelInfo(excelInfo *ExcelInfo, excelEdbMappingList []*ExcelEdbMapping, childExcel *ExcelInfo) (err error) {
|
|
|
- //o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // if err != nil {
|
|
|
- // _ = o.Rollback()
|
|
|
- // } else {
|
|
|
- // _ = o.Commit()
|
|
|
- // }
|
|
|
- //}()
|
|
|
-
|
|
|
to := global.DmSQL["data"].Begin()
|
|
|
|
|
|
defer func() {
|
|
@@ -101,12 +87,6 @@ func AddExcelInfo(excelInfo *ExcelInfo, excelEdbMappingList []*ExcelEdbMapping,
|
|
|
if childExcel != nil {
|
|
|
// 表格信息入库
|
|
|
childExcel.ParentId = excelInfo.ExcelInfoId
|
|
|
- //_, err = o.Insert(childExcel)
|
|
|
- //if err != nil {
|
|
|
- // err = fmt.Errorf("新增子表失败:%v", err)
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
err = to.Create(childExcel).Error
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("新增子表失败:%v", err)
|
|
@@ -120,8 +100,6 @@ func AddExcelInfo(excelInfo *ExcelInfo, excelEdbMappingList []*ExcelEdbMapping,
|
|
|
v.ExcelInfoId = excelInfo.ExcelInfoId
|
|
|
excelEdbMappingList[k] = v
|
|
|
}
|
|
|
- //_, err = o.InsertMulti(dataNum, excelEdbMappingList)
|
|
|
-
|
|
|
err = to.CreateInBatches(excelEdbMappingList, utils.MultiAddNum).Error
|
|
|
}
|
|
|
|
|
@@ -130,17 +108,6 @@ func AddExcelInfo(excelInfo *ExcelInfo, excelEdbMappingList []*ExcelEdbMapping,
|
|
|
|
|
|
// EditExcelInfo 编辑表格
|
|
|
func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string, excelEdbMappingList []*ExcelEdbMapping) (err error) {
|
|
|
- //o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // if err != nil {
|
|
|
- // _ = o.Rollback()
|
|
|
- // } else {
|
|
|
- // _ = o.Commit()
|
|
|
- // }
|
|
|
- //}()
|
|
|
to := global.DmSQL["data"].Begin()
|
|
|
|
|
|
defer func() {
|
|
@@ -158,15 +125,10 @@ func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string, excelEd
|
|
|
//更新父级分类时,同时更新子集分类
|
|
|
if excelInfo.Source == utils.BALANCE_TABLE && excelInfo.ParentId == 0 {
|
|
|
// 同步更新子表分类
|
|
|
- //sql := `UPDATE FROM excel_info set excel_classify_id = ? WHERE parent_id=? `
|
|
|
- //_, err = o.Raw(sql, excelInfo.ExcelClassifyId, excelInfo.ExcelInfoId).Exec()
|
|
|
-
|
|
|
sql := `UPDATE FROM excel_info set excel_classify_id = ? WHERE parent_id=? `
|
|
|
err = to.Exec(sql, excelInfo.ExcelClassifyId, excelInfo.ExcelInfoId).Error
|
|
|
}
|
|
|
// 删除关系表
|
|
|
- //sql := `DELETE FROM excel_edb_mapping WHERE excel_info_id=? `
|
|
|
- //_, err = o.Raw(sql, excelInfo.ExcelInfoId).Exec()
|
|
|
|
|
|
sql := `DELETE FROM excel_edb_mapping WHERE excel_info_id=? `
|
|
|
err = to.Exec(sql, excelInfo.ExcelInfoId).Error
|
|
@@ -178,44 +140,14 @@ func EditExcelInfo(excelInfo *ExcelInfo, updateExcelInfoParams []string, excelEd
|
|
|
v.ExcelInfoId = excelInfo.ExcelInfoId
|
|
|
excelEdbMappingList[k] = v
|
|
|
}
|
|
|
- //_, err = o.InsertMulti(dataNum, excelEdbMappingList)
|
|
|
err = to.CreateInBatches(excelEdbMappingList, utils.MultiAddNum).Error
|
|
|
}
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetExcelInfoAll 获取所有表格列表,用于分类展示
|
|
|
-func GetExcelInfoAll() (items []*ExcelClassifyItems, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
- // unique_code,sys_user_id,sys_user_real_name,is_join_permission
|
|
|
- // FROM excel_info where is_delete=0 ORDER BY sort asc,create_time ASC `
|
|
|
- //_, err = o.Raw(sql).QueryRows(&items)
|
|
|
-
|
|
|
- sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
- unique_code,sys_user_id,sys_user_real_name,is_join_permission
|
|
|
- FROM excel_info where is_delete=0 ORDER BY sort asc,create_time ASC `
|
|
|
- err = global.DmSQL["data"].Raw(sql).Find(&items).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetNoContentExcelInfoAll 获取不含content的表格列表 用于分类展示
|
|
|
func GetNoContentExcelInfoAll(source, userId int) (items []*ExcelClassifyItems, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
- // unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission
|
|
|
- // FROM excel_info where is_delete=0 AND source = ? `
|
|
|
- //
|
|
|
- //pars := []interface{}{source}
|
|
|
- //
|
|
|
- //if userId > 0 {
|
|
|
- // sql += ` AND sys_user_id = ? `
|
|
|
- // pars = append(pars, userId)
|
|
|
- //}
|
|
|
- //sql += ` ORDER BY sort asc,excel_info_id desc `
|
|
|
- //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission
|
|
|
FROM excel_info where is_delete=0 AND source = ? `
|
|
@@ -233,26 +165,6 @@ func GetNoContentExcelInfoAll(source, userId int) (items []*ExcelClassifyItems,
|
|
|
|
|
|
// GetBalanceNoContentExcelInfoAll 获取不含content的平衡表表格列表 用于分类展示
|
|
|
func GetBalanceNoContentExcelInfoAll(source int, excelInfoIds []int, userId int) (items []*ExcelClassifyItems, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
- // unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission
|
|
|
- // FROM excel_info where is_delete=0 AND source = ? AND parent_id = 0 AND balance_type=0 `
|
|
|
- //
|
|
|
- //pars := []interface{}{source}
|
|
|
- //
|
|
|
- //if userId > 0 {
|
|
|
- // if len(excelInfoIds) > 0 {
|
|
|
- // sql += ` AND (excel_info_id in (` + utils.GetOrmInReplace(len(excelInfoIds)) + `) or sys_user_id = ?)`
|
|
|
- // pars = append(pars, excelInfoIds, userId)
|
|
|
- // } else {
|
|
|
- // sql += ` AND sys_user_id = ? `
|
|
|
- // pars = append(pars, userId)
|
|
|
- // }
|
|
|
- //}
|
|
|
- //
|
|
|
- //sql += ` ORDER BY sort asc,excel_info_id desc `
|
|
|
- //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission
|
|
|
FROM excel_info where is_delete=0 AND source = ? AND parent_id = 0 AND balance_type=0 `
|
|
@@ -274,23 +186,8 @@ func GetBalanceNoContentExcelInfoAll(source int, excelInfoIds []int, userId int)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetAllExcelInfoBySource 根据来源获取包含content的表格列表
|
|
|
-func GetAllExcelInfoBySource(source int) (items []*ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info where is_delete=0 AND source = ? ORDER BY sort asc,create_time desc `
|
|
|
- //_, err = o.Raw(sql, source).QueryRows(&items)
|
|
|
-
|
|
|
- sql := ` SELECT * FROM excel_info where is_delete=0 AND source = ? ORDER BY sort asc,create_time desc `
|
|
|
- err = global.DmSQL["data"].Raw(sql, source).Find(&items).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetExcelInfoById 根据id 获取eta表格详情
|
|
|
func GetExcelInfoById(excelInfoId int) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
|
err = global.DmSQL["data"].Raw(sql, excelInfoId).First(&item).Error
|
|
|
return
|
|
@@ -298,33 +195,12 @@ func GetExcelInfoById(excelInfoId int) (item *ExcelInfo, err error) {
|
|
|
|
|
|
// GetExcelInfoByUnicode 编码获取表格
|
|
|
func GetExcelInfoByUnicode(unicode string) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE unique_code = ? AND is_delete = 0 `
|
|
|
- //err = o.Raw(sql, unicode).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE unique_code = ? AND is_delete = 0 `
|
|
|
err = global.DmSQL["data"].Raw(sql, unicode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetExcelInfoViewById(excelInfoId int) (item *ExcelInfoView, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
-
|
|
|
- sql := ` SELECT * FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
|
- err = global.DmSQL["data"].Raw(sql, excelInfoId).First(&item).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
func GetExcelInfoCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
- //if condition != "" {
|
|
|
- // sql += condition
|
|
|
- //}
|
|
|
- //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
-
|
|
|
sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
@@ -334,16 +210,6 @@ func GetExcelInfoCountByCondition(condition string, pars []interface{}) (count i
|
|
|
}
|
|
|
|
|
|
func GetNoContentExcelInfoListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*ExcelClassifyItems, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := `SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
- // unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission FROM excel_info WHERE 1=1 `
|
|
|
- //if condition != "" {
|
|
|
- // sql += condition
|
|
|
- //}
|
|
|
- //
|
|
|
- //sql += ` AND is_delete=0 ORDER BY excel_info_id DESC LIMIT ?,? `
|
|
|
- //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
-
|
|
|
sql := `SELECT excel_info_id,excel_classify_id,excel_name AS excel_classify_name,
|
|
|
unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission FROM excel_info WHERE 1=1 `
|
|
|
if condition != "" {
|
|
@@ -359,16 +225,6 @@ func GetNoContentExcelInfoListByCondition(condition string, pars []interface{},
|
|
|
}
|
|
|
|
|
|
func GetNoContentExcelInfoListByConditionNoPage(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := `SELECT excel_info_id,excel_classify_id,excel_name,
|
|
|
- // unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission, parent_id, balance_type, update_user_id,update_user_real_name,rel_excel_info_id,version_name FROM excel_info WHERE is_delete=0 `
|
|
|
- //if condition != "" {
|
|
|
- // sql += condition
|
|
|
- //}
|
|
|
- //
|
|
|
- //sql += ` ORDER BY excel_info_id DESC `
|
|
|
- //_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
-
|
|
|
sql := `SELECT excel_info_id,excel_classify_id,excel_name,
|
|
|
unique_code,sys_user_id,sys_user_real_name,sort,is_join_permission, parent_id, balance_type, update_user_id,update_user_real_name,rel_excel_info_id,version_name FROM excel_info WHERE is_delete=0 `
|
|
|
if condition != "" {
|
|
@@ -382,14 +238,6 @@ func GetNoContentExcelInfoListByConditionNoPage(condition string, pars []interfa
|
|
|
}
|
|
|
|
|
|
func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []*ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
- //if condition != "" {
|
|
|
- // sql += condition
|
|
|
- //}
|
|
|
- //sql += ` ORDER BY sort asc, excel_info_id asc`
|
|
|
- //_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
@@ -401,14 +249,6 @@ func GetExcelInfoListByCondition(condition string, pars []interface{}) (items []
|
|
|
|
|
|
// GetNextExcelInfoByCondition 根据条件获取下一个表格
|
|
|
func GetNextExcelInfoByCondition(condition string, pars []interface{}) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
- //if condition != "" {
|
|
|
- // sql += condition
|
|
|
- //}
|
|
|
- //sql += " ORDER BY sort asc , create_time desc LIMIT 1 "
|
|
|
- //err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
@@ -420,15 +260,6 @@ func GetNextExcelInfoByCondition(condition string, pars []interface{}) (item *Ex
|
|
|
|
|
|
// GetNextExcelInfo 根据分类id获取下一个excel表格
|
|
|
func GetNextExcelInfo(classifyId, classifySort, source int) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT b.* FROM excel_classify AS a
|
|
|
- // INNER JOIN excel_info AS b ON a.excel_classify_id=b.excel_classify_id
|
|
|
- // WHERE (a.sort>? OR (a.sort=? and a.excel_classify_id>?) ) AND a.is_delete=0 AND b.is_delete=0
|
|
|
- // AND a.source = ? AND b.source = ?
|
|
|
- // ORDER BY a.sort ASC,b.sort asc,b.create_time desc
|
|
|
- // LIMIT 1 `
|
|
|
- //err = o.Raw(sql, classifySort, classifySort, classifyId, source, source).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT b.* FROM excel_classify AS a
|
|
|
INNER JOIN excel_info AS b ON a.excel_classify_id=b.excel_classify_id
|
|
|
WHERE (a.sort>? OR (a.sort=? and a.excel_classify_id>?) ) AND a.is_delete=0 AND b.is_delete=0
|
|
@@ -439,33 +270,8 @@ func GetNextExcelInfo(classifyId, classifySort, source int) (item *ExcelInfo, er
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// EditExcelInfoImage 修改excel表格的图片
|
|
|
-func EditExcelInfoImage(excelInfoId int, imageUrl string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //
|
|
|
- //sql := ` UPDATE excel_info SET excel_image=?, modify_time = NOW() WHERE excel_info_id = ? AND is_delete=0 `
|
|
|
- //_, err = o.Raw(sql, imageUrl, excelInfoId).Exec()
|
|
|
- //if err != nil {
|
|
|
- // fmt.Println("EditExcelInfoImage Err:", err.Error())
|
|
|
- // return err
|
|
|
- //}
|
|
|
-
|
|
|
- sql := ` UPDATE excel_info SET excel_image=?, modify_time = NOW() WHERE excel_info_id = ? AND is_delete=0 `
|
|
|
- err = global.DmSQL["data"].Exec(sql, imageUrl, excelInfoId).Error
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EditExcelInfoImage Err:", err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetExcelInfoByUniqueCode 根据unique_code来获取excel表格详情
|
|
|
func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE unique_code=? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE unique_code=? AND is_delete=0 `
|
|
|
err = global.DmSQL["data"].Raw(sql, uniqueCode).First(&item).Error
|
|
|
return
|
|
@@ -473,10 +279,6 @@ func GetExcelInfoByUniqueCode(uniqueCode string) (item *ExcelInfo, err error) {
|
|
|
|
|
|
// GetFirstExcelInfoByClassifyId 获取当前分类下,且排序数相同 的排序第一条的数据
|
|
|
func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE excel_classify_id=? AND is_delete=0 order by sort asc,excel_info_id desc limit 1`
|
|
|
- //err = o.Raw(sql, classifyId).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE excel_classify_id=? AND is_delete=0 order by sort asc,excel_info_id desc limit 1`
|
|
|
err = global.DmSQL["data"].Raw(sql, classifyId).First(&item).Error
|
|
|
return
|
|
@@ -484,15 +286,6 @@ func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error)
|
|
|
|
|
|
// UpdateExcelInfoSortByClassifyId 根据表格id更新排序
|
|
|
func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, updateSort string, source int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? AND source=? AND is_delete=0 AND ( sort > ? `
|
|
|
- //// todo 前一个兄弟节点后移
|
|
|
- //if prevExcelInfoId > 0 {
|
|
|
- // sql += ` or (excel_info_id < ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
|
|
|
- //}
|
|
|
- //sql += `)`
|
|
|
- //_, err = o.Raw(sql, classifyId, source, nowSort).Exec()
|
|
|
-
|
|
|
sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? AND source=? AND is_delete=0 AND ( sort > ? `
|
|
|
// todo 前一个兄弟节点后移
|
|
|
if prevExcelInfoId > 0 {
|
|
@@ -535,29 +328,8 @@ type ExcelInfoView struct {
|
|
|
RightMax string `description:"表格右侧最大值"`
|
|
|
}
|
|
|
|
|
|
-// GetExcelInfoByClassifyIdAndName 根据分类id和表格名获取表格信息
|
|
|
-func GetExcelInfoByClassifyIdAndName(classifyId int, excelName string) (item *ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE excel_classify_id = ? and excel_name=? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, classifyId, excelName).QueryRow(&item)
|
|
|
-
|
|
|
- sql := ` SELECT * FROM excel_info WHERE excel_classify_id = ? and excel_name=? AND is_delete=0 `
|
|
|
- err = global.DmSQL["data"].Raw(sql, classifyId, excelName).First(&item).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetNoContentExcelListByCondition 获取没有content的excel表格列表数据
|
|
|
func GetNoContentExcelListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyExcelInfoList, err error) {
|
|
|
- // o := orm.NewOrmUsingDB("data")
|
|
|
- // sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
- //FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
- // if condition != "" {
|
|
|
- // sql += condition
|
|
|
- // }
|
|
|
- // //sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
|
- // sql += " ORDER BY create_time DESC LIMIT ?,? "
|
|
|
- // _, err = o.Raw(sql, pars...).QueryRows(&item)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
@@ -574,16 +346,6 @@ func GetNoContentExcelListByCondition(condition string, pars []interface{}, star
|
|
|
|
|
|
// GetNoContentExcelListByConditionNoPage 获取没有content的excel表格列表数据
|
|
|
func GetNoContentExcelListByConditionNoPage(condition string, pars []interface{}) (item []*MyExcelInfoList, err error) {
|
|
|
- // o := orm.NewOrmUsingDB("data")
|
|
|
- // sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
- //FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
- // if condition != "" {
|
|
|
- // sql += condition
|
|
|
- // }
|
|
|
- // //sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
|
|
|
- // sql += " ORDER BY create_time DESC"
|
|
|
- // _, err = o.Raw(sql, pars).QueryRows(&item)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
@@ -596,13 +358,6 @@ func GetNoContentExcelListByConditionNoPage(condition string, pars []interface{}
|
|
|
}
|
|
|
|
|
|
func GetExcelListCountByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
- //if condition != "" {
|
|
|
- // sql += condition
|
|
|
- //}
|
|
|
- //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
-
|
|
|
sql := ` SELECT COUNT(1) AS count FROM excel_info WHERE 1=1 AND is_delete=0 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
@@ -611,46 +366,15 @@ func GetExcelListCountByCondition(condition string, pars []interface{}) (count i
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetExcelViewInfoByExcelInfoId 根据excelInfoId 获取ETA表格详情
|
|
|
-func GetExcelViewInfoByExcelInfoId(excelInfoId int) (item *MyExcelInfoList, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission FROM excel_info WHERE excel_info_id = ? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
-
|
|
|
- sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission FROM excel_info WHERE excel_info_id = ? AND is_delete=0 `
|
|
|
- err = global.DmSQL["data"].Raw(sql, excelInfoId).First(&item).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetExcelInfoCountByClassifyId 根据分类id获取名下表格数量
|
|
|
func GetExcelInfoCountByClassifyId(classifyId int) (total int64, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, classifyId).QueryRow(&total)
|
|
|
-
|
|
|
sql := ` SELECT count(1) total FROM excel_info WHERE excel_classify_id = ? AND is_delete=0 `
|
|
|
err = global.DmSQL["data"].Raw(sql, classifyId).First(&total).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// UpdateExcelInfoClassifyId 更改表格分类
|
|
|
-func UpdateExcelInfoClassifyId(classifyId, excelInfoId int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` update excel_info set excel_classify_id = ? WHERE excel_info_id=? `
|
|
|
- //_, err = o.Raw(sql, classifyId, excelInfoId).Exec()
|
|
|
-
|
|
|
- sql := ` update excel_info set excel_classify_id = ? WHERE excel_info_id=? `
|
|
|
- err = global.DmSQL["data"].Exec(sql, classifyId, excelInfoId).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetNoContentExcelInfoByName 根据名称 获取eta表格详情
|
|
|
func GetNoContentExcelInfoByName(excelName string, source, adminId int) (item *MyExcelInfoList, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
- //FROM excel_info WHERE excel_name = ? AND source = ? AND is_delete=0 AND sys_user_id = ? `
|
|
|
- //err = o.Raw(sql, excelName, source, adminId).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
FROM excel_info WHERE excel_name = ? AND source = ? AND is_delete=0 AND sys_user_id = ? `
|
|
|
err = global.DmSQL["data"].Raw(sql, excelName, source, adminId).First(&item).Error
|
|
@@ -659,11 +383,6 @@ func GetNoContentExcelInfoByName(excelName string, source, adminId int) (item *M
|
|
|
|
|
|
// GetNoContentExcelInfoByUniqueCode 根据unique_code来获取excel表格详情
|
|
|
func GetNoContentExcelInfoByUniqueCode(uniqueCode string) (item *MyExcelInfoList, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
- //FROM excel_info WHERE unique_code=? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
FROM excel_info WHERE unique_code=? AND is_delete=0 `
|
|
|
err = global.DmSQL["data"].Raw(sql, uniqueCode).First(&item).Error
|
|
@@ -672,11 +391,6 @@ func GetNoContentExcelInfoByUniqueCode(uniqueCode string) (item *MyExcelInfoList
|
|
|
|
|
|
// GetNoContentExcelInfoByExcelId 根据表格id来获取excel表格详情
|
|
|
func GetNoContentExcelInfoByExcelId(excelInfoId int) (item *MyExcelInfoList, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
- //FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
|
- //err = o.Raw(sql, excelInfoId).QueryRow(&item)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission,update_user_id,update_user_real_name
|
|
|
FROM excel_info WHERE excel_info_id=? AND is_delete=0 `
|
|
|
err = global.DmSQL["data"].Raw(sql, excelInfoId).First(&item).Error
|
|
@@ -685,18 +399,6 @@ func GetNoContentExcelInfoByExcelId(excelInfoId int) (item *MyExcelInfoList, err
|
|
|
|
|
|
// AddExcelInfoAndSheet 新增excel
|
|
|
func AddExcelInfoAndSheet(excelInfo *ExcelInfo, sheetParamsList []AddExcelSheetParams) (err error) {
|
|
|
- //o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // if err != nil {
|
|
|
- // _ = o.Rollback()
|
|
|
- // } else {
|
|
|
- // _ = o.Commit()
|
|
|
- // }
|
|
|
- //}()
|
|
|
-
|
|
|
to := global.DmSQL["data"].Begin()
|
|
|
|
|
|
defer func() {
|
|
@@ -712,8 +414,6 @@ func AddExcelInfoAndSheet(excelInfo *ExcelInfo, sheetParamsList []AddExcelSheetP
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- //excelInfo.ExcelInfoId = int(lastId)
|
|
|
-
|
|
|
// sheet信息入库
|
|
|
for _, sheetInfo := range sheetParamsList {
|
|
|
dataNum := len(sheetInfo.DataList)
|
|
@@ -731,11 +431,6 @@ func AddExcelInfoAndSheet(excelInfo *ExcelInfo, sheetParamsList []AddExcelSheetP
|
|
|
ModifyTime: time.Now(),
|
|
|
CreateTime: time.Now(),
|
|
|
}
|
|
|
- //sheetId, tmpErr := o.Insert(excelSheetInfo)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
|
|
|
tmpErr := to.Create(excelSheetInfo).Error
|
|
|
if tmpErr != nil {
|
|
@@ -743,19 +438,12 @@ func AddExcelInfoAndSheet(excelInfo *ExcelInfo, sheetParamsList []AddExcelSheetP
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- //excelSheetInfo.ExcelSheetId = int(sheetId)
|
|
|
-
|
|
|
// data信息入库
|
|
|
if dataNum > 0 {
|
|
|
for k, _ := range sheetInfo.DataList {
|
|
|
sheetInfo.DataList[k].ExcelSheetId = excelSheetInfo.ExcelSheetId
|
|
|
sheetInfo.DataList[k].ExcelInfoId = excelSheetInfo.ExcelInfoId
|
|
|
}
|
|
|
- //_, tmpErr = o.InsertMulti(dataNum, sheetInfo.DataList)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
|
|
|
tmpErr = to.CreateInBatches(sheetInfo.DataList, utils.MultiAddNum).Error
|
|
|
if tmpErr != nil {
|
|
@@ -770,18 +458,6 @@ func AddExcelInfoAndSheet(excelInfo *ExcelInfo, sheetParamsList []AddExcelSheetP
|
|
|
|
|
|
// SaveExcelInfoAndSheet 编辑保存
|
|
|
func SaveExcelInfoAndSheet(excelInfo *ExcelInfo, updateExcelInfoParam []string, sheetParamsList []AddExcelSheetParams) (err error) {
|
|
|
- //o, err := orm.NewOrmUsingDB("data").Begin()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // if err != nil {
|
|
|
- // _ = o.Rollback()
|
|
|
- // } else {
|
|
|
- // _ = o.Commit()
|
|
|
- // }
|
|
|
- //}()
|
|
|
-
|
|
|
to := global.DmSQL["data"].Begin()
|
|
|
|
|
|
defer func() {
|
|
@@ -806,11 +482,6 @@ func SaveExcelInfoAndSheet(excelInfo *ExcelInfo, updateExcelInfoParam []string,
|
|
|
}
|
|
|
|
|
|
// 再删除历史sheet中的cell data信息
|
|
|
- //sql = `DELETE FROM excel_sheet_data WHERE excel_info_id = ?`
|
|
|
- //_, err = o.Raw(sql, excelInfo.ExcelInfoId).Exec()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
|
|
|
sql = `DELETE FROM excel_sheet_data WHERE excel_info_id = ?`
|
|
|
err = to.Exec(sql, excelInfo.ExcelInfoId).Error
|
|
@@ -835,12 +506,6 @@ func SaveExcelInfoAndSheet(excelInfo *ExcelInfo, updateExcelInfoParam []string,
|
|
|
ModifyTime: time.Now(),
|
|
|
CreateTime: time.Now(),
|
|
|
}
|
|
|
- //sheetId, tmpErr := o.Insert(excelSheetInfo)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
- //excelSheetInfo.ExcelSheetId = int(sheetId)
|
|
|
|
|
|
tmpErr := to.Create(excelSheetInfo).Error
|
|
|
if tmpErr != nil {
|
|
@@ -853,12 +518,6 @@ func SaveExcelInfoAndSheet(excelInfo *ExcelInfo, updateExcelInfoParam []string,
|
|
|
sheetInfo.DataList[k].ExcelSheetId = excelSheetInfo.ExcelSheetId
|
|
|
sheetInfo.DataList[k].ExcelInfoId = excelSheetInfo.ExcelInfoId
|
|
|
}
|
|
|
- //_, tmpErr = o.InsertMulti(dataNum, sheetInfo.DataList)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
tmpErr = to.CreateInBatches(sheetInfo.DataList, utils.MultiAddNum).Error
|
|
|
}
|
|
|
}
|
|
@@ -876,10 +535,6 @@ type BatchRefreshExcelReq struct {
|
|
|
|
|
|
// GetExcelMaxSortByClassifyId 获取当前分类下,且排序数最大的excel
|
|
|
func GetExcelMaxSortByClassifyId(classifyId int, source int) (sort int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT Max(sort) AS sort FROM excel_info WHERE excel_classify_id=? AND source = ? AND is_delete=0 order by sort desc,excel_info_id desc limit 1`
|
|
|
- //err = o.Raw(sql, classifyId, source).QueryRow(&sort)
|
|
|
-
|
|
|
sql := ` SELECT COALESCE(MAX(sort),0) AS sort FROM excel_info WHERE excel_classify_id=? AND source = ? AND is_delete=0 order by sort desc,excel_info_id desc limit 1`
|
|
|
err = global.DmSQL["data"].Raw(sql, classifyId, source).Scan(&sort).Error
|
|
|
return
|
|
@@ -895,10 +550,6 @@ func GetNoContentExcelListByExcelInfoIdList(excelInfoIdList []string) (items []*
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
- //_, err = o.Raw(sql, excelInfoIdList).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
err = global.DmSQL["data"].Raw(sql, excelInfoIdList).Find(&items).Error
|
|
|
return
|
|
@@ -909,10 +560,6 @@ func GetNoContentExcelListByExcelInfoIdAndParentId(excelInfoIdList []string) (it
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) OR parent_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
- //_, err = o.Raw(sql, excelInfoIdList, excelInfoIdList).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) OR parent_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
err = global.DmSQL["data"].Raw(sql, excelInfoIdList, excelInfoIdList).Find(&items).Error
|
|
|
return
|
|
@@ -928,10 +575,6 @@ func GetNoContentExcelListByUserId(userIdList []int) (items []*MyExcelInfoList,
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT * FROM excel_info WHERE sys_user_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
- //_, err = o.Raw(sql, userIdList).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT * FROM excel_info WHERE sys_user_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
err = global.DmSQL["data"].Raw(sql, userIdList).Find(&items).Error
|
|
|
|
|
@@ -951,10 +594,6 @@ func ModifyExcelInfoUserIdByCodeList(excelIdList []string, userId int, userName
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := `UPDATE excel_info SET sys_user_id=?,sys_user_real_name=? WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
- //_, err = o.Raw(sql, userId, userName, excelIdList).Exec()
|
|
|
-
|
|
|
sql := `UPDATE excel_info SET sys_user_id=?,sys_user_real_name=? WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
err = global.DmSQL["data"].Exec(sql, userId, userName, excelIdList).Error
|
|
|
return
|
|
@@ -973,9 +612,6 @@ func ModifyExcelInfoUserIdByOldUserId(oldUserIdList []int, userId int, userName
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := `UPDATE excel_info SET sys_user_id=?,sys_user_real_name=? WHERE is_delete=0 AND sys_user_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
- //_, err = o.Raw(sql, userId, userName, oldUserIdList).Exec()
|
|
|
|
|
|
sql := `UPDATE excel_info SET sys_user_id=?,sys_user_real_name=? WHERE is_delete=0 AND sys_user_id in (` + utils.GetOrmInReplace(num) + `) `
|
|
|
err = global.DmSQL["data"].Exec(sql, userId, userName, oldUserIdList).Error
|
|
@@ -987,9 +623,6 @@ func GetExcelBaseInfoByExcelInfoIdList(excelInfoIdList []int) (items []*data_man
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name FROM excel_info WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
- //_, err = o.Raw(sql, excelInfoIdList).QueryRows(&items)
|
|
|
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name FROM excel_info WHERE excel_info_id in (` + utils.GetOrmInReplace(num) + `) order by excel_info_id DESC `
|
|
|
err = global.DmSQL["data"].Raw(sql, excelInfoIdList).Find(&items).Error
|
|
@@ -1001,28 +634,6 @@ func ReplaceEdbInExcel(oldEdbInfoId, newEdbInfoId int, updateExcelList []*ExcelI
|
|
|
var errmsg string
|
|
|
logMsg := `` // 记录替换的日志
|
|
|
replaceTotal := 0
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //to, err := o.Begin()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // if err != nil {
|
|
|
- // _ = to.Rollback()
|
|
|
- // } else {
|
|
|
- // _ = to.Commit()
|
|
|
- // if logMsg != `` {
|
|
|
- // utils.FileLog.Info(fmt.Sprintf("替换表格中的指标记录,替换总表格数:%d,旧的指标id:%d,新的指标id:%d;%s", replaceTotal, oldEdbInfoId, newEdbInfoId, logMsg))
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if errmsg != "" {
|
|
|
- // fmt.Println("errmsg:" + errmsg)
|
|
|
- // }
|
|
|
- // if err != nil && errmsg != "" {
|
|
|
- // //go alarm_msg.SendAlarmMsg("替换替换配置中的指标记录失败提醒,errmsg:"+errmsg, 3)
|
|
|
- // }
|
|
|
- //}()
|
|
|
-
|
|
|
to := global.DmSQL["data"].Begin()
|
|
|
|
|
|
defer func() {
|
|
@@ -1039,18 +650,11 @@ func ReplaceEdbInExcel(oldEdbInfoId, newEdbInfoId int, updateExcelList []*ExcelI
|
|
|
fmt.Println("errmsg:" + errmsg)
|
|
|
}
|
|
|
if err != nil && errmsg != "" {
|
|
|
- //go alarm_msg.SendAlarmMsg("替换替换配置中的指标记录失败提醒,errmsg:"+errmsg, 3)
|
|
|
}
|
|
|
}()
|
|
|
// 替换表格中的内容
|
|
|
for _, excelInfo := range updateExcelList {
|
|
|
//更新配置中的指标A
|
|
|
- //sql := `UPDATE excel_info SET content=?, modify_time=? WHERE excel_info_id=?`
|
|
|
- //_, err = to.Raw(sql, excelInfo.Content, time.Now(), excelInfo.ExcelInfoId).Exec()
|
|
|
- //if err != nil {
|
|
|
- // errmsg = "更新表格内容失败:Err:" + err.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
|
|
|
sql := `UPDATE excel_info SET content=?, modify_time=? WHERE excel_info_id=?`
|
|
|
err = to.Exec(sql, excelInfo.Content, time.Now(), excelInfo.ExcelInfoId).Error
|
|
@@ -1068,13 +672,6 @@ func ReplaceEdbInExcel(oldEdbInfoId, newEdbInfoId int, updateExcelList []*ExcelI
|
|
|
return
|
|
|
}
|
|
|
// 插入新的绑定
|
|
|
- //sql = `UPDATE excel_edb_mapping SET edb_info_id=?, modify_time=? WHERE excel_info_id=? and edb_info_id=?`
|
|
|
- //_, err = to.Raw(sql, newEdbInfoId, time.Now(), excelInfo.ExcelInfoId, oldEdbInfoId).Exec()
|
|
|
- //if err != nil {
|
|
|
- // errmsg = "更新指标B关联图表配置信息失败:Err:" + err.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
sql = `UPDATE excel_edb_mapping SET edb_info_id=?, modify_time=? WHERE excel_info_id=? and edb_info_id=?`
|
|
|
err = to.Exec(sql, newEdbInfoId, time.Now(), excelInfo.ExcelInfoId, oldEdbInfoId).Error
|
|
|
if err != nil {
|
|
@@ -1090,10 +687,6 @@ func ReplaceEdbInExcel(oldEdbInfoId, newEdbInfoId int, updateExcelList []*ExcelI
|
|
|
|
|
|
// GetChildExcelInfoByParentId 根据id 获取eta表格详情
|
|
|
func GetChildExcelInfoByParentId(parentId int) (items []*ExcelInfo, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission, parent_id, balance_type, update_user_id,update_user_real_name FROM excel_info WHERE parent_id=? AND is_delete=0 order by sort asc, excel_info_id asc`
|
|
|
- //_, err = o.Raw(sql, parentId).QueryRows(&items)
|
|
|
-
|
|
|
sql := ` SELECT excel_info_id,source,excel_type,excel_name,unique_code,excel_classify_id,sys_user_id,sys_user_real_name,excel_image,file_url,sort,create_time,modify_time,is_join_permission, parent_id, balance_type, update_user_id,update_user_real_name FROM excel_info WHERE parent_id=? AND is_delete=0 order by sort asc, excel_info_id asc`
|
|
|
err = global.DmSQL["data"].Raw(sql, parentId).Find(&items).Error
|
|
|
return
|
|
@@ -1115,10 +708,6 @@ func UpdateExcelInfoClassifyIdByIds(classifyId int, excelIds []int) (err error)
|
|
|
if len(excelIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("data")
|
|
|
- //sql := fmt.Sprintf(`UPDATE excel_info SET excel_classify_id = ? WHERE excel_info_id IN (%s)`, utils.GetOrmInReplace(len(excelIds)))
|
|
|
- //_, err = o.Raw(sql, classifyId, excelIds).Exec()
|
|
|
-
|
|
|
sql := fmt.Sprintf(`UPDATE excel_info SET excel_classify_id = ? WHERE excel_info_id IN (%s)`, utils.GetOrmInReplace(len(excelIds)))
|
|
|
err = global.DmSQL["data"].Exec(sql, classifyId, excelIds).Error
|
|
|
return
|