|
@@ -61,6 +61,8 @@ func AddReportAndChapter(reportInfo *models.Report, inheritReportId int, grantAd
|
|
|
|
|
|
errMsg = "生成报告失败"
|
|
|
|
|
|
+ reportFreeLayoutList := make([]*report.ReportFreeLayout, 0)
|
|
|
+
|
|
|
// 报告继承
|
|
|
if inheritReportId > 0 {
|
|
|
inheritReport, tmpErr := models.GetReportByReportId(inheritReportId)
|
|
@@ -97,6 +99,25 @@ func AddReportAndChapter(reportInfo *models.Report, inheritReportId int, grantAd
|
|
|
reportInfo.EndImg = inheritReport.EndImg
|
|
|
}
|
|
|
reportInfo.InheritReportId = inheritReport.Id
|
|
|
+ pages, tmpErr := report.GetReportFreeLayoutListByReportId(inheritReport.Id, 0)
|
|
|
+ if tmpErr != nil {
|
|
|
+ errMsg = "获取自由布局内容页失败"
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range pages {
|
|
|
+ reportFreeLayoutList = append(reportFreeLayoutList, &report.ReportFreeLayout{
|
|
|
+ Id: 0,
|
|
|
+ ReportId: 0,
|
|
|
+ ReportChapterId: 0,
|
|
|
+ Page: v.Page,
|
|
|
+ IsChapter: v.IsChapter,
|
|
|
+ Content: v.Content,
|
|
|
+ ContentStruct: v.ContentStruct,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ ModifyTime: time.Now(),
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -105,7 +126,7 @@ func AddReportAndChapter(reportInfo *models.Report, inheritReportId int, grantAd
|
|
|
|
|
|
// 新增报告及章节
|
|
|
var reportId int64
|
|
|
- reportId, err = models.AddReportAndChapter(reportInfo, allGrantUserList, addChapterList)
|
|
|
+ reportId, err = models.AddReportAndChapter(reportInfo, reportFreeLayoutList, allGrantUserList, addChapterList)
|
|
|
if err != nil {
|
|
|
err = errors.New("新增报告及章节失败, Err: " + err.Error())
|
|
|
return
|
|
@@ -343,6 +364,24 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 每篇章节对应的分页内容页
|
|
|
+ chapterFreeLayoutListMap := make(map[int][]*report.ReportFreeLayout)
|
|
|
+ {
|
|
|
+ allReportFreeLayoutList, tmpErr := report.GetAllReportFreeLayoutListByReportId(inheritReportId)
|
|
|
+ if tmpErr != nil {
|
|
|
+ errMsg = "获取自由布局内容页失败"
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, reportFreeLayout := range allReportFreeLayoutList {
|
|
|
+ chapterFreeLayoutList, ok := chapterFreeLayoutListMap[reportFreeLayout.ReportChapterId]
|
|
|
+ if !ok {
|
|
|
+ chapterFreeLayoutList = make([]*report.ReportFreeLayout, 0)
|
|
|
+ }
|
|
|
+ chapterFreeLayoutListMap[reportFreeLayout.ReportChapterId] = append(chapterFreeLayoutList, reportFreeLayout)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 待添加的章节
|
|
|
chapterTypeList := make([]*models.ReportChapterType, 0)
|
|
|
// 待添加的章节类型id列表
|
|
@@ -486,20 +525,22 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
// 继承的报告章节内容
|
|
|
for i := 0; i < len(inheritReportChapters); i++ {
|
|
|
customChapter := inheritReportChapters[i]
|
|
|
+ // 继承的报告章节ID
|
|
|
+ inheritReportChapterId := customChapter.ReportChapterId
|
|
|
|
|
|
// 授权用户列表
|
|
|
- tmpGrantList, ok := grantListMap[customChapter.ReportChapterId]
|
|
|
+ tmpGrantList, ok := grantListMap[inheritReportChapterId]
|
|
|
if !ok {
|
|
|
tmpGrantList = make([]*report.ReportChapterGrant, 0)
|
|
|
}
|
|
|
- oldChapterIdGrantListMap[customChapter.ReportChapterId] = tmpGrantList
|
|
|
+ oldChapterIdGrantListMap[inheritReportChapterId] = tmpGrantList
|
|
|
|
|
|
// 关联品种列表
|
|
|
- chapterPermissionList, ok := chapterPermissionListMap[customChapter.ReportChapterId]
|
|
|
+ chapterPermissionList, ok := chapterPermissionListMap[inheritReportChapterId]
|
|
|
if !ok {
|
|
|
chapterPermissionList = make([]*report.ReportChapterPermissionMapping, 0)
|
|
|
}
|
|
|
- oldChapterPermissionListMap[customChapter.ReportChapterId] = chapterPermissionList
|
|
|
+ oldChapterPermissionListMap[inheritReportChapterId] = chapterPermissionList
|
|
|
|
|
|
// 判断该章节是否是系统章节,如果是的话,那就是需要额外创建的
|
|
|
if customChapter.TypeId > 0 {
|
|
@@ -521,9 +562,10 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
customChapter.ContentModifyTime = time.Now()
|
|
|
|
|
|
customAddChapter := models.AddReportChapter{
|
|
|
- ReportChapter: customChapter,
|
|
|
- GrantList: tmpGrantList,
|
|
|
- GrantPermissionList: chapterPermissionList,
|
|
|
+ ReportChapter: customChapter,
|
|
|
+ GrantList: tmpGrantList,
|
|
|
+ GrantPermissionList: chapterPermissionList,
|
|
|
+ InheritReportChapterId: inheritReportChapterId,
|
|
|
}
|
|
|
customAddChapterList = append(customAddChapterList, customAddChapter)
|
|
|
}
|
|
@@ -532,6 +574,8 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
// 最大排序
|
|
|
var maxSort int
|
|
|
for _, typeItem := range chapterTypeList {
|
|
|
+ // 继承的章节ID
|
|
|
+ inheritReportChapterId := 0
|
|
|
v, ok := inheritChapterMap[typeItem.ReportChapterTypeId]
|
|
|
|
|
|
// 章节授权用户
|
|
@@ -542,6 +586,8 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
chapterItem := new(models.ReportChapter)
|
|
|
|
|
|
if ok && v != nil {
|
|
|
+ inheritReportChapterId = v.ReportChapterId
|
|
|
+
|
|
|
// 如果存在继承的章节,那么就从继承的章节内容中获取
|
|
|
chapterItem.AddType = 2
|
|
|
chapterItem.Title = v.Title
|
|
@@ -586,6 +632,8 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
return
|
|
|
}
|
|
|
if chapterNewest != nil {
|
|
|
+ inheritReportChapterId = chapterNewest.ReportChapterId
|
|
|
+
|
|
|
chapterItem.AddType = 2
|
|
|
chapterItem.Title = chapterNewest.Title
|
|
|
chapterItem.ReportType = chapterNewest.ReportType
|
|
@@ -681,9 +729,10 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
}
|
|
|
|
|
|
addChapter := models.AddReportChapter{
|
|
|
- ReportChapter: chapterItem,
|
|
|
- GrantList: tmpGrantList,
|
|
|
- GrantPermissionList: tmpChapterPermissionList,
|
|
|
+ ReportChapter: chapterItem,
|
|
|
+ GrantList: tmpGrantList,
|
|
|
+ GrantPermissionList: tmpChapterPermissionList,
|
|
|
+ InheritReportChapterId: inheritReportChapterId,
|
|
|
}
|
|
|
|
|
|
chapterList = append(chapterList, addChapter)
|
|
@@ -696,6 +745,27 @@ func getAddChapter(reportInfo *models.Report, minClassifyId, inheritReportId int
|
|
|
chapterList = append(chapterList, addChapterItem)
|
|
|
}
|
|
|
|
|
|
+ for k, chapterItem := range chapterList {
|
|
|
+ reportFreeLayoutList, ok := chapterFreeLayoutListMap[chapterItem.InheritReportChapterId]
|
|
|
+ if ok {
|
|
|
+ tmpReportFreeLayoutList := make([]*report.ReportFreeLayout, 0)
|
|
|
+ for _, v := range reportFreeLayoutList {
|
|
|
+ tmpReportFreeLayoutList = append(tmpReportFreeLayoutList, &report.ReportFreeLayout{
|
|
|
+ Id: 0,
|
|
|
+ ReportId: 0,
|
|
|
+ ReportChapterId: 0,
|
|
|
+ Page: v.Page,
|
|
|
+ IsChapter: v.IsChapter,
|
|
|
+ Content: v.Content,
|
|
|
+ ContentStruct: v.ContentStruct,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ ModifyTime: time.Now(),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ chapterList[k].ReportChapterFreeLayoutList = tmpReportFreeLayoutList
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//hasGrantUserMap := make(map[int]bool)
|
|
|
//for _, grantList := range typeGrantListMap {
|
|
|
// for _, grant := range grantList {
|