|
@@ -18,6 +18,7 @@ import (
|
|
|
"os"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "sync"
|
|
|
"time"
|
|
|
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
@@ -664,7 +665,6 @@ func (this *ReportController) Edit() {
|
|
|
br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
reportCode := utils.MD5(strconv.Itoa(int(req.ReportId)))
|
|
|
resp := new(models.EditResp)
|
|
|
resp.ReportId = req.ReportId
|
|
@@ -719,6 +719,7 @@ func (this *ReportController) Detail() {
|
|
|
return
|
|
|
}
|
|
|
chapterList := make([]*models.ReportChapter, 0)
|
|
|
+ pageList := make([]*report.ContentPage, 0)
|
|
|
if item.HasChapter == 1 {
|
|
|
// 获取章节内容
|
|
|
tmpChapterList, err := models.GetPublishedChapterListByReportId(item.Id)
|
|
@@ -737,7 +738,34 @@ func (this *ReportController) Detail() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if item.ReportLayout == 3 {
|
|
|
+ pages, err := report.GetFreeLayoutChapterPagesByReportId(item.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取自由布局内容页失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, page := range pages {
|
|
|
+ page.Content = html.UnescapeString(page.Content)
|
|
|
+ page.ContentStruct = html.UnescapeString(page.ContentStruct)
|
|
|
+ pageList = append(pageList, page)
|
|
|
+ }
|
|
|
+ }
|
|
|
//item.Abstract = item.Title
|
|
|
+ } else {
|
|
|
+ if item.ReportLayout == 3 {
|
|
|
+ pages, err := report.GetFreeLayoutPagesByReportId(item.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取自由布局内容页失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, page := range pages {
|
|
|
+ page.Content = html.UnescapeString(page.Content)
|
|
|
+ page.ContentStruct = html.UnescapeString(page.ContentStruct)
|
|
|
+ pageList = append(pageList, page)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
item.Content = html.UnescapeString(item.Content)
|
|
|
item.ContentSub = html.UnescapeString(item.ContentSub)
|
|
@@ -846,8 +874,9 @@ func (this *ReportController) Detail() {
|
|
|
}
|
|
|
|
|
|
resp := &models.ReportDetailView{
|
|
|
- ReportDetail: item,
|
|
|
- ChapterList: chapterList,
|
|
|
+ ReportDetail: item,
|
|
|
+ ChapterList: chapterList,
|
|
|
+ FreeLayoutContentPages: pageList,
|
|
|
}
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -904,7 +933,12 @@ func (this *ReportController) SaveReportContent() {
|
|
|
br.IsSendEmail = false
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ if reportInfo.ReportLayout == 3 && req.FreeLayoutConfig == "" {
|
|
|
+ br.Msg = "自由布局配置为空"
|
|
|
+ br.ErrMsg = "自由布局配置为空"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
// 标记更新中
|
|
|
{
|
|
|
markStatus, err := services.UpdateReportEditMark(req.ReportId, 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
|
|
@@ -933,11 +967,12 @@ func (this *ReportController) SaveReportContent() {
|
|
|
|
|
|
content = services.HandleReportContent(content, "del", nil)
|
|
|
|
|
|
+
|
|
|
fmt.Println("line 839")
|
|
|
fmt.Println(content)
|
|
|
fmt.Println("line 841")
|
|
|
|
|
|
- if content != "" {
|
|
|
+ if content != "" || reportInfo.ReportLayout == 3 {
|
|
|
e := utils.ContentXssCheck(content)
|
|
|
if e != nil {
|
|
|
br.Msg = "存在非法标签"
|
|
@@ -959,7 +994,11 @@ func (this *ReportController) SaveReportContent() {
|
|
|
go alarm_msg.SendAlarmMsg("解析 ContentSub 失败,Err:"+err.Error(), 3)
|
|
|
//utils.SendEmail(utils.APPNAME+"失败提醒", "解析 ContentSub 失败,Err:"+err.Error(), utils.EmailSendToUsers)
|
|
|
}
|
|
|
+
|
|
|
//reportInfo.Content = html.EscapeString(req.Content) //html.EscapeString(content)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
reportInfo.Content = html.EscapeString(content)
|
|
|
reportInfo.ContentSub = html.EscapeString(contentSub)
|
|
|
reportInfo.ContentStruct = html.EscapeString(req.ContentStruct)
|
|
@@ -970,17 +1009,65 @@ func (this *ReportController) SaveReportContent() {
|
|
|
reportInfo.EndResourceId = req.EndResourceId
|
|
|
reportInfo.ModifyTime = time.Now()
|
|
|
reportInfo.ContentModifyTime = time.Now()
|
|
|
- updateCols := []string{"Content", "ContentSub", "ContentStruct", "HeadImg", "EndImg", "CanvasColor", "HeadResourceId", "EndResourceId", "ModifyTime", "ContentModifyTime"}
|
|
|
+ // updateCols := []string{"Content", "ContentSub", "ContentStruct", "HeadImg", "EndImg", "CanvasColor", "HeadResourceId", "EndResourceId", "ModifyTime", "ContentModifyTime"}
|
|
|
|
|
|
- fmt.Println(reportInfo.ContentStruct)
|
|
|
- err = reportInfo.UpdateReport(updateCols)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "保存失败"
|
|
|
- br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ //fmt.Println(reportInfo.ContentStruct)
|
|
|
+ //err = reportInfo.UpdateReport(updateCols)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "保存失败"
|
|
|
+ // br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ if reportInfo.ReportLayout == 3 {
|
|
|
+ reportInfo.FreeLayoutConfig = req.FreeLayoutConfig
|
|
|
+ //自由布局更新每页的数据
|
|
|
+ ormList := report.ToOrmViewList(req.FreeLayoutContentPages, false, reportInfo.Id, 0)
|
|
|
+ var wg sync.WaitGroup
|
|
|
+ wg.Add(len(ormList))
|
|
|
+ for _, v := range ormList {
|
|
|
+ go func(v *report.ReportFreeLayout) {
|
|
|
+ defer wg.Done()
|
|
|
+ content = v.Content
|
|
|
+ content = services.HandleReportContent(content, "del", nil)
|
|
|
+ if content != "" {
|
|
|
+ e = utils.ContentXssCheck(content)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "存在非法标签"
|
|
|
+ br.ErrMsg = "存在非法标签, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ contentClean, e := services.FilterReportContentBr(content)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "内容去除前后空格失败"
|
|
|
+ br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ content = contentClean
|
|
|
+ v.ContentStruct = services.HandleReportContentStruct(v.ContentStruct, "del", nil)
|
|
|
+ v.Content = html.EscapeString(content)
|
|
|
+ v.ContentStruct = html.EscapeString(v.ContentStruct)
|
|
|
+ }
|
|
|
+ }(v)
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ err = models.InsertOrUpdateReportFreeLayoutContentPage(reportInfo, ormList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ updateCols := []string{"Content", "ContentSub", "ContentStruct", "HeadImg", "EndImg", "CanvasColor", "HeadResourceId", "EndResourceId", "ModifyTime", "ContentModifyTime"}
|
|
|
+ err = reportInfo.UpdateReport(updateCols)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
go models.AddReportSaveLog(reportId, this.SysUser.AdminId, reportInfo.Content, reportInfo.ContentSub, reportInfo.ContentStruct, reportInfo.CanvasColor, this.SysUser.AdminName, reportInfo.HeadResourceId, reportInfo.EndResourceId)
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
resp := new(models.SaveReportContentResp)
|
|
@@ -1002,7 +1089,7 @@ func (this *ReportController) SaveReportContent() {
|
|
|
// @Param ClassifyIdThird query int true "三级分类id"
|
|
|
// @Param State query string true "报告状态,多状态用英文,隔开"
|
|
|
// @Success 200 {object} models.ReportListResp
|
|
|
-// @router /list/authorized [get]
|
|
|
+// @router /list/authorized [get]
|
|
|
func (this *ReportController) AuthorizedListReport() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
@@ -1172,17 +1259,21 @@ func (this *ReportController) BaseDetail() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
- /*var req models.ReportDetailReq
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if req.ReportId <= 0 {
|
|
|
- br.Msg = "参数错误"
|
|
|
- return
|
|
|
- }*/
|
|
|
+ /*
|
|
|
+ var req models.ReportDetailReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.ReportId <= 0 {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ */
|
|
|
reportId, err := this.GetInt("ReportId")
|
|
|
if err != nil {
|
|
|
br.Msg = "获取参数失败!"
|
|
@@ -1209,7 +1300,28 @@ func (this *ReportController) BaseDetail() {
|
|
|
|
|
|
reportInfo.Content = html.UnescapeString(reportInfo.Content)
|
|
|
reportInfo.ContentSub = html.UnescapeString(reportInfo.ContentSub)
|
|
|
-
|
|
|
+ if reportInfo.ReportLayout == 3 {
|
|
|
+ if reportInfo.HeadResourceId > 0 {
|
|
|
+ headResource, err := smart_report.GetResourceItemById(reportInfo.HeadResourceId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取资源库版头失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportInfo.HeadImg = headResource.ImgUrl
|
|
|
+ reportInfo.HeadStyle = headResource.Style
|
|
|
+ }
|
|
|
+ if reportInfo.EndResourceId > 0 {
|
|
|
+ headResource, err := smart_report.GetResourceItemById(reportInfo.EndResourceId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "获取资源库版尾失败, Err: " + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reportInfo.EndImg = headResource.ImgUrl
|
|
|
+ reportInfo.EndStyle = headResource.Style
|
|
|
+ }
|
|
|
+ }
|
|
|
grandAdminList := make([]models.ReportDetailViewAdmin, 0)
|
|
|
permissionList := make([]models.ReportDetailViewPermission, 0)
|
|
|
|
|
@@ -1327,11 +1439,12 @@ func (this *ReportController) EditLayoutImg() {
|
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- //if req.Content == "" {
|
|
|
- // br.Msg = "报告内容不能为空"
|
|
|
- // return
|
|
|
- //}
|
|
|
- //更新标记key
|
|
|
+ // if req.Content == "" {
|
|
|
+ // br.Msg = "报告内容不能为空"
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // 更新标记key
|
|
|
markStatus, err := services.UpdateReportEditMark(int(req.ReportId), 0, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
|
|
|
if err != nil {
|
|
|
br.Msg = err.Error()
|
|
@@ -1339,7 +1452,7 @@ func (this *ReportController) EditLayoutImg() {
|
|
|
}
|
|
|
if markStatus.Status == 1 {
|
|
|
br.Msg = markStatus.Msg
|
|
|
- //br.Ret = 202 //202 服务器已接受请求,但尚未处理。
|
|
|
+ // br.Ret = 202 //202 服务器已接受请求,但尚未处理。
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1611,10 +1724,28 @@ func (this *ReportController) PrePublishReport() {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- if reportDetail.Content == "" {
|
|
|
- br.Msg = "报告内容为空,不可设置定时发布"
|
|
|
- br.ErrMsg = "报告内容为空,不可设置定时发布,report_id:" + strconv.Itoa(reportDetail.Id)
|
|
|
- return
|
|
|
+ if reportDetail.ReportLayout != 3 {
|
|
|
+ if reportDetail.Content == "" {
|
|
|
+ br.Msg = "报告内容为空,不可设置定时发布"
|
|
|
+ br.ErrMsg = "报告内容为空,不可设置定时发布,report_id:" + strconv.Itoa(reportDetail.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pages, err := report.GetFreeLayoutChapterPagesByReportId(reportDetail.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取自由布局报告失败,不可设置定时发布"
|
|
|
+ br.ErrMsg = "获取自由布局报告失败,不可设置定时发布,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var content string
|
|
|
+ for _, page := range pages {
|
|
|
+ content += page.Content
|
|
|
+ }
|
|
|
+ if content == "" {
|
|
|
+ br.Msg = "自由布局报告内容为空,不可设置定时发布"
|
|
|
+ br.ErrMsg = "自由布局报告内容为空,不可设置定时发布,report_id:" + strconv.Itoa(reportDetail.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1713,10 +1844,26 @@ func (this *ReportController) SubmitApprove() {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- if reportItem.Content == "" {
|
|
|
+ if reportItem.Content == "" && reportItem.ReportLayout != 3 {
|
|
|
br.Msg = "报告内容为空,不可提交"
|
|
|
br.ErrMsg = "报告内容为空,不可提交,report_id:" + strconv.Itoa(reportItem.Id)
|
|
|
return
|
|
|
+ } else {
|
|
|
+ pages, err := report.GetFreeLayoutChapterPagesByReportId(reportItem.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取自由布局报告失败,不可提交"
|
|
|
+ br.ErrMsg = "获取自由布局报告失败,不可提交,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var content string
|
|
|
+ for _, page := range pages {
|
|
|
+ content += page.Content
|
|
|
+ }
|
|
|
+ if content == "" {
|
|
|
+ br.Msg = "自由布局报告内容为空,不可提交"
|
|
|
+ br.ErrMsg = "自由布局报告内容为空,不可提交,report_id:" + strconv.Itoa(reportItem.Id)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1972,10 +2119,10 @@ func (this *ReportCommonController) ShareTransform() {
|
|
|
// @author: Roc
|
|
|
// @datetime 2024-06-21 09:19:05
|
|
|
func init() {
|
|
|
- //fixApproveRecord()
|
|
|
- //fixChapterPermission()
|
|
|
- //fixReportEs()
|
|
|
- //fixSmartReport()
|
|
|
+ // fixApproveRecord()
|
|
|
+ // fixChapterPermission()
|
|
|
+ // fixReportEs()
|
|
|
+ // fixSmartReport()
|
|
|
}
|
|
|
|
|
|
// 修复研报审批数据
|
|
@@ -1991,7 +2138,7 @@ func fixApproveRecord() {
|
|
|
return
|
|
|
}
|
|
|
for _, recordItem := range list {
|
|
|
- //fmt.Println(recordItem)
|
|
|
+ // fmt.Println(recordItem)
|
|
|
recordItem.NodeState = recordItem.State
|
|
|
recordItem.NodeApproveUserId = recordItem.ApproveUserId
|
|
|
recordItem.NodeApproveUserName = recordItem.ApproveUserName
|
|
@@ -2041,7 +2188,7 @@ func fixChapterPermission() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //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}
|
|
|
+ // 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}
|
|
|
notIdList := []int{}
|
|
|
allReportChapterList, err := models.GetAllReportChapter()
|
|
|
if err != nil {
|
|
@@ -2164,7 +2311,7 @@ func fixSmartReport() {
|
|
|
for _, v := range list {
|
|
|
fmt.Println(v)
|
|
|
addList = append(addList, &models.Report{
|
|
|
- //Id: 0,
|
|
|
+ // Id: 0,
|
|
|
AddType: 1,
|
|
|
ClassifyIdFirst: v.ClassifyIdFirst,
|
|
|
ClassifyNameFirst: v.ClassifyNameFirst,
|
|
@@ -2180,7 +2327,7 @@ func fixSmartReport() {
|
|
|
PublishTime: v.PublishTime,
|
|
|
Stage: v.Stage,
|
|
|
MsgIsSend: v.MsgIsSend,
|
|
|
- //ThsMsgIsSend: v.Tha,
|
|
|
+ // ThsMsgIsSend: v.Tha,
|
|
|
Content: v.Content,
|
|
|
VideoUrl: v.VideoUrl,
|
|
|
VideoName: v.VideoName,
|
|
@@ -2276,7 +2423,7 @@ func fixSmartReport() {
|
|
|
func initPdf() {
|
|
|
inFile := "anNNgk3Bbi4LRULwcJgNOPrREYh5.pdf"
|
|
|
f2, err := services.GeneralWaterMarkPdf(inFile, "颜鹏 - 18170239278")
|
|
|
- //f2, err := services.GeneralWaterMarkPdf(inFile, "上周美国馏分油库存累库95万桶,馏分油表需环比下降(-25.6万桶/日)。本期馏分油产量继续抬升,在供增需减的环比变动下库存持续累库。馏分油供应的增加我们认为可能和进口的油种有关,今年以来美国进口的中重质原油占比不断走高,尤其是5")
|
|
|
+ // f2, err := services.GeneralWaterMarkPdf(inFile, "上周美国馏分油库存累库95万桶,馏分油表需环比下降(-25.6万桶/日)。本期馏分油产量继续抬升,在供增需减的环比变动下库存持续累库。馏分油供应的增加我们认为可能和进口的油种有关,今年以来美国进口的中重质原油占比不断走高,尤其是5")
|
|
|
if err != nil {
|
|
|
fmt.Println("生成失败,ERR:", err)
|
|
|
return
|