|
@@ -226,7 +226,7 @@ func GetReportIdListByOrgIds(orgIds map[string][]int) (ids []int, err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64, err error) {
|
|
|
+func GetMaxIdByPermissionIds(orgIds map[string][]int, disCardIds []int) (total int64, maxId int64, err error) {
|
|
|
db := models.Main()
|
|
|
if len(orgIds["ETA"]) == 0 && len(orgIds["HT"]) == 0 {
|
|
|
//err := db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Scan(&maxId).Error
|
|
@@ -239,12 +239,12 @@ func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64,
|
|
|
return
|
|
|
}
|
|
|
if len(orgIds["ETA"]) == 0 {
|
|
|
- err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&total).Error
|
|
|
+ err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ? and id not in ?", orgIds["HT"], disCardIds).Scan(&total).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取记录条数失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
+ err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ? and id not in ?", orgIds["HT"], disCardIds).Scan(&maxId).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
return
|
|
@@ -252,24 +252,24 @@ func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64,
|
|
|
return
|
|
|
}
|
|
|
if len(orgIds["HT"]) == 0 {
|
|
|
- err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&total).Error
|
|
|
+ err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"], disCardIds).Scan(&total).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&maxId).Error
|
|
|
+ err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"], disCardIds).Scan(&maxId).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&total).Error
|
|
|
+ err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"], disCardIds).Scan(&total).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
|
|
|
+ err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"], disCardIds).Scan(&maxId).Error
|
|
|
if err != nil {
|
|
|
logger.Error("获取报告最大ID失败:%v", err)
|
|
|
return
|
|
@@ -407,3 +407,16 @@ select cpm.permission_id from reports r LEFT JOIN (SELECT classify_id,permissio
|
|
|
err = db.Raw(sql, ids, ids).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func GetHiddenReportIds(classifyIds []int, plateName string) (reportIds []int, err error) {
|
|
|
+ db := models.Main()
|
|
|
+ exc := db.Model(&Report{}).Select("id")
|
|
|
+ if len(classifyIds) == 0 {
|
|
|
+ exc.Where("(source='ETA' and classify_id in ?)", classifyIds)
|
|
|
+ }
|
|
|
+ if plateName != "" {
|
|
|
+ exc.Or("(source='HT' and plate_name = ?)", plateName)
|
|
|
+ }
|
|
|
+ err = exc.Scan(&reportIds).Error
|
|
|
+ return
|
|
|
+}
|