|
@@ -1,6 +1,7 @@
|
|
package models
|
|
package models
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ sql2 "database/sql"
|
|
"eta/eta_hub/global"
|
|
"eta/eta_hub/global"
|
|
"eta/eta_hub/utils"
|
|
"eta/eta_hub/utils"
|
|
"github.com/beego/beego/v2/client/orm"
|
|
"github.com/beego/beego/v2/client/orm"
|
|
@@ -101,6 +102,7 @@ type ReportListResp struct {
|
|
}
|
|
}
|
|
|
|
|
|
func GetReportListCount(condition string, pars []interface{}, companyType string) (count int, err error) {
|
|
func GetReportListCount(condition string, pars []interface{}, companyType string) (count int, err error) {
|
|
|
|
+ var totalNull sql2.NullInt64
|
|
//产品权限
|
|
//产品权限
|
|
companyTypeSqlStr := ``
|
|
companyTypeSqlStr := ``
|
|
if companyType == "ficc" {
|
|
if companyType == "ficc" {
|
|
@@ -114,7 +116,12 @@ func GetReportListCount(condition string, pars []interface{}, companyType string
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
- err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, pars...).Scan(&count).Error
|
|
|
|
|
|
+ err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, pars...).Scan(&totalNull).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ count = int(totalNull.Int64)
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -195,33 +202,45 @@ type ReportDetail struct {
|
|
func GetReportById(reportId int) (item *Report, err error) {
|
|
func GetReportById(reportId int) (item *Report, err error) {
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
sql := `SELECT * FROM report WHERE id=?`
|
|
sql := `SELECT * FROM report WHERE id=?`
|
|
- err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, reportId).Scan(&item).Error
|
|
|
|
|
|
+ err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, reportId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetReportStage(classifyIdFirst, classifyIdSecond int) (count int, err error) {
|
|
func GetReportStage(classifyIdFirst, classifyIdSecond int) (count int, err error) {
|
|
|
|
+ var totalNull sql2.NullInt64
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
sql := ``
|
|
sql := ``
|
|
if classifyIdSecond > 0 {
|
|
if classifyIdSecond > 0 {
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? "
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? "
|
|
- global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdSecond).Scan(&count)
|
|
|
|
|
|
+ global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdSecond).Scan(&totalNull)
|
|
} else {
|
|
} else {
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? "
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? "
|
|
- global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdFirst).Scan(&count)
|
|
|
|
|
|
+ global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdFirst).Scan(&totalNull)
|
|
|
|
+ }
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
+ count = int(totalNull.Int64)
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetReportStageEdit(classifyIdFirst, classifyIdSecond, reportId int) (count int, err error) {
|
|
func GetReportStageEdit(classifyIdFirst, classifyIdSecond, reportId int) (count int, err error) {
|
|
|
|
+ var totalNull sql2.NullInt64
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
sql := ``
|
|
sql := ``
|
|
if classifyIdSecond > 0 {
|
|
if classifyIdSecond > 0 {
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? AND id<>? "
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? AND id<>? "
|
|
- global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdSecond, reportId).Scan(&count)
|
|
|
|
|
|
+ global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdSecond, reportId).Scan(&totalNull)
|
|
} else {
|
|
} else {
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? AND id<>? "
|
|
sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? AND id<>? "
|
|
- global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdFirst, reportId).Scan(&count)
|
|
|
|
|
|
+ global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdFirst, reportId).Scan(&totalNull)
|
|
}
|
|
}
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ count = int(totalNull.Int64)
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -371,9 +390,14 @@ func ModifyReportThsMsgIsSend(item *ReportDetail) (err error) {
|
|
|
|
|
|
// GetDayWeekReportStage 获取晨报周报期数
|
|
// GetDayWeekReportStage 获取晨报周报期数
|
|
func GetDayWeekReportStage(classifyIdFirst int, yearStart time.Time) (count int, err error) {
|
|
func GetDayWeekReportStage(classifyIdFirst int, yearStart time.Time) (count int, err error) {
|
|
|
|
+ var totalNull sql2.NullInt64
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
sql := " SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first = ? AND create_time > ? "
|
|
sql := " SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first = ? AND create_time > ? "
|
|
- global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdFirst, yearStart).Scan(&count)
|
|
|
|
|
|
+ global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, classifyIdFirst, yearStart).Scan(&totalNull)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ count = int(totalNull.Int64)
|
|
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -382,7 +406,7 @@ func GetDayWeekReportStage(classifyIdFirst int, yearStart time.Time) (count int,
|
|
func GetReportByReportId(reportId int) (item *Report, err error) {
|
|
func GetReportByReportId(reportId int) (item *Report, err error) {
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
sql := `SELECT * FROM report WHERE id = ?`
|
|
sql := `SELECT * FROM report WHERE id = ?`
|
|
- err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, reportId).Scan(&item).Error
|
|
|
|
|
|
+ err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sql, reportId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -636,7 +660,13 @@ func GetClassifyListCount(keyWord, companyType string) (count int, err error) {
|
|
sqlCount = `SELECT COUNT(1) AS count FROM classify WHERE parent_id=0 ` + companyTypeSqlStr
|
|
sqlCount = `SELECT COUNT(1) AS count FROM classify WHERE parent_id=0 ` + companyTypeSqlStr
|
|
}
|
|
}
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
//o := orm.NewOrmUsingDB("rddp")
|
|
- err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sqlCount, pars...).Scan(&count).Error
|
|
|
|
|
|
+ var totalNull sql2.NullInt64
|
|
|
|
+ err = global.DbMap[utils.MYSQL_URL_RDDP].Raw(sqlCount, pars...).Scan(&totalNull).Error
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ count = int(totalNull.Int64)
|
|
|
|
+
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|