|
@@ -153,7 +153,7 @@ func (e *ExcelChartEdb) AddChartEdbAndData(list []*AddChartEdbAndDataItem, chart
|
|
|
}
|
|
|
|
|
|
//更新图表id
|
|
|
- sql := `update excel_chart_edb set chart_info_id = ? where excel_chart_edb_id in (` + utils.GetOrmInReplace(len(updateIds)) + `)`
|
|
|
+ sql := `update excel_chart_edb set chart_info_id = ? where excel_chart_edb_id in (` + utils.GetOrmInReplace(len(updateIds)) + `) and chart_info_id=0`
|
|
|
_, err = o.Raw(sql, chartInfoId, updateIds).Exec()
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("更新图表id失败,AddChartEdbAndData: %v", err)
|
|
@@ -324,3 +324,40 @@ func DeleteExcelChartEdbAndData(excelInfoIds []int, chartInfoIds []int) (err err
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 删除平衡表中的指标和数据
|
|
|
+func DeleteBalanceExcelChartInfoAndData(chartInfoId int) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ to, err := o.Begin()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ _ = to.Rollback()
|
|
|
+ } else {
|
|
|
+ _ = to.Commit()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ sql := ` DELETE FROM chart_info WHERE chart_info_id=? `
|
|
|
+ _, err = to.Raw(sql, chartInfoId).Exec()
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("删除平衡表图表失败 %s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sql = ` DELETE FROM excel_chart_edb WHERE chart_info_id=? `
|
|
|
+ _, err = to.Raw(sql, chartInfoId).Exec()
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("删除平衡表图表指标失败 %s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 删除表格里的数据
|
|
|
+ sql = ` DELETE FROM excel_chart_data WHERE chart_info_id=? `
|
|
|
+ _, err = to.Raw(sql, chartInfoId).Exec()
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("删除平衡表图表指标失败 %s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|