|
@@ -1093,11 +1093,15 @@ func (this *ReportController) EditLayoutImg() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
-// TODO 修复历史章节报告的品种权限
|
|
|
// TODO 修复历史报告的ES数据
|
|
|
|
|
|
+// init
|
|
|
+// @Description: 修复历史报告数据
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-06-21 09:19:05
|
|
|
func init() {
|
|
|
//fixApproveRecord()
|
|
|
+ //fixChapterPermission()
|
|
|
}
|
|
|
|
|
|
// 修复研报审批数据
|
|
@@ -1136,3 +1140,67 @@ func fixApproveRecord() {
|
|
|
|
|
|
fmt.Println("审批数据修复完成")
|
|
|
}
|
|
|
+
|
|
|
+// fixChapterPermission
|
|
|
+// @Description: 修复章节关联的品种权限
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-06-20 18:08:34
|
|
|
+func fixChapterPermission() {
|
|
|
+ allChapterTypePermissionList, err := models.GetAllChapterTypePermission()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("获取所有章节类型ID获取章节类型权限列表失败,Err:", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ currChapterTypePermissionIdListMap := make(map[int][]int)
|
|
|
+
|
|
|
+ hasPermissionMap := make(map[string]bool)
|
|
|
+ for _, v := range allChapterTypePermissionList {
|
|
|
+ tmpChapterTypePermissionList, ok := currChapterTypePermissionIdListMap[v.ReportChapterTypeId]
|
|
|
+ if !ok {
|
|
|
+ tmpChapterTypePermissionList = make([]int, 0)
|
|
|
+ }
|
|
|
+ key := fmt.Sprint(v.ReportChapterTypeId, "-", v.ChartPermissionId)
|
|
|
+ if _, has := hasPermissionMap[key]; !has {
|
|
|
+ hasPermissionMap[key] = true
|
|
|
+ currChapterTypePermissionIdListMap[v.ReportChapterTypeId] = append(tmpChapterTypePermissionList, v.ChartPermissionId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ notIdList := []int{9675, 9675, 9740, 9749, 9768, 9773, 9791, 9792, 9793, 9850, 9851, 9852, 9852, 9852, 9853, 9854, 9856, 9857, 9857, 9858, 9859, 9860, 9861, 9862, 9862, 9863, 9866}
|
|
|
+ allReportChapterList, err := models.GetAllReportChapter()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("获取所有章节失败,Err:", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ addList := make([]*report.ReportChapterPermissionMapping, 0)
|
|
|
+ for _, v := range allReportChapterList {
|
|
|
+ // 如果是上面的章节id,那么就过滤掉,因为已经入库了
|
|
|
+ if utils.InArrayByInt(notIdList, v.ReportChapterId) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ permissionIdList, ok := currChapterTypePermissionIdListMap[v.TypeId]
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, permissionId := range permissionIdList {
|
|
|
+ addList = append(addList, &report.ReportChapterPermissionMapping{
|
|
|
+ ReportChapterPermissionMappingId: 0,
|
|
|
+ ReportChapterId: v.ReportChapterId,
|
|
|
+ ChartPermissionId: permissionId,
|
|
|
+ CreateTime: v.ModifyTime,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ obj := report.ReportChapterPermissionMapping{}
|
|
|
+ err = obj.MultiAdd(addList)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("批量添加报章节的品种权限失败,Err:", err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|