report_approve.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. package report_approve
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. "strings"
  8. "time"
  9. )
  10. // ReportApprove 报告审批表
  11. //type ReportApprove struct {
  12. // ReportApproveId int `orm:"column(report_approve_id);pk" description:"审批ID"`
  13. // ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  14. // ReportId int `description:"报告ID"`
  15. // ReportTitle string `description:"报告标题"`
  16. // ClassifyFirstId int `description:"一级分类ID"`
  17. // ClassifySecondId int `description:"二级分类ID"`
  18. // ClassifyThirdId int `description:"三级分类ID"`
  19. // State int `description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
  20. // FlowId int `description:"审批流ID"`
  21. // FlowVersion int `description:"审批流版本"`
  22. // StartNodeId int `description:"开始节点ID"`
  23. // CurrNodeId int `description:"当前节点ID"`
  24. // ApplyUserId int `description:"申请人ID"`
  25. // ApplyUserName string `description:"申请人姓名"`
  26. // ApproveRemark string `description:"审批备注"`
  27. // ApproveTime time.Time `description:"审批时间"`
  28. // CreateTime time.Time `description:"创建时间"`
  29. // ModifyTime time.Time `description:"修改时间"`
  30. //}
  31. type ReportApprove struct {
  32. ReportApproveId int `gorm:"primaryKey;column:report_approve_id;type:int(10) unsigned;not null"` // 审批ID
  33. ReportType int `gorm:"column:report_type;type:tinyint(4) unsigned;not null;default:0"` // 报告类型:1-中文研报;2-英文研报;3-智能研报
  34. ReportId int `gorm:"index:idx_report_id;column:report_id;type:int(10) unsigned;not null;default:0"` // 报告Id
  35. ReportTitle string `gorm:"column:report_title;type:varchar(255);not null;default:''"` // 报告标题
  36. ClassifyFirstId int `gorm:"column:classify_first_id;type:int(10) unsigned;not null;default:0"` // 一级分类Id
  37. ClassifySecondId int `gorm:"column:classify_second_id;type:int(10) unsigned;not null;default:0"` // 二级分类Id
  38. State int `gorm:"column:state;type:tinyint(4) unsigned;not null;default:0"` // 审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回
  39. FlowId int `gorm:"column:flow_id;type:int(10) unsigned;not null;default:0"` // 审批流Id
  40. FlowVersion int `gorm:"column:flow_version;type:int(10) unsigned;not null;default:0"` // 审批流版本
  41. StartNodeId int `gorm:"column:start_node_id;type:int(10) unsigned;not null;default:0"` // 开始节点Id
  42. CurrNodeId int `gorm:"column:curr_node_id;type:int(10) unsigned;not null;default:0"` // 当前节点Id
  43. ApplyUserId int `gorm:"index:idx_approve_user_id;column:apply_user_id;type:int(10) unsigned;not null;default:0"` // 申请人Id
  44. ApplyUserName string `gorm:"column:apply_user_name;type:varchar(128);not null;default:''"` // 申请人姓名
  45. ApproveRemark string `gorm:"column:approve_remark;type:varchar(255);not null;default:''"` // 审批备注
  46. ApproveTime time.Time `gorm:"column:approve_time;type:datetime"` // 审批时间
  47. CreateTime time.Time `gorm:"column:create_time;type:datetime"` // 创建时间
  48. ModifyTime time.Time `gorm:"column:modify_time;type:datetime"` // 更新时间
  49. ClassifyThirdId int `gorm:"column:classify_third_id;type:int(10) unsigned;default:0"` // 三级分类Id
  50. }
  51. var ReportApproveCols = struct {
  52. ReportApproveId string
  53. ReportType string
  54. ReportId string
  55. ReportTitle string `description:"报告标题"`
  56. ClassifyFirstId string `description:"一级分类ID"`
  57. ClassifySecondId string `description:"二级分类ID"`
  58. ClassifyThirdId string `description:"三级分类ID"`
  59. State string
  60. FlowId string
  61. FlowVersion string
  62. StartNodeId string
  63. CurrNodeId string
  64. ApplyUserId string `description:"申请人ID"`
  65. ApplyUserName string `description:"申请人姓名"`
  66. ApproveRemark string `description:"审批备注"`
  67. ApproveTime string `description:"审批时间"`
  68. CreateTime string
  69. ModifyTime string
  70. }{
  71. ReportApproveId: "report_approve_id",
  72. ReportType: "report_type",
  73. ReportId: "report_id",
  74. ReportTitle: "report_title",
  75. ClassifyFirstId: "classify_first_id",
  76. ClassifySecondId: "classify_second_id",
  77. ClassifyThirdId: "classify_third_id",
  78. State: "state",
  79. FlowId: "flow_id",
  80. FlowVersion: "flow_version",
  81. StartNodeId: "start_node_id",
  82. CurrNodeId: "curr_node_id",
  83. ApplyUserId: "apply_user_id",
  84. ApplyUserName: "apply_user_name",
  85. ApproveRemark: "approve_remark",
  86. ApproveTime: "approve_time",
  87. CreateTime: "create_time",
  88. ModifyTime: "modify_time",
  89. }
  90. func (m *ReportApprove) TableName() string {
  91. return "report_approve"
  92. }
  93. func (m *ReportApprove) PrimaryId() string {
  94. return ReportApproveCols.ReportApproveId
  95. }
  96. func (m *ReportApprove) Create() (err error) {
  97. //o := orm.NewOrmUsingDB("rddp")
  98. //id, err := o.Insert(m)
  99. //if err != nil {
  100. // return
  101. //}
  102. //m.ReportApproveId = int(id)
  103. err = global.DmSQL["rddp"].Create(m).Error
  104. return
  105. }
  106. func (m *ReportApprove) CreateMulti(items []*ReportApprove) (err error) {
  107. if len(items) == 0 {
  108. return
  109. }
  110. //o := orm.NewOrmUsingDB("rddp")
  111. //_, err = o.InsertMulti(len(items), items)
  112. err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
  113. return
  114. }
  115. func (m *ReportApprove) Update(cols []string) (err error) {
  116. //o := orm.NewOrmUsingDB("rddp")
  117. //_, err = o.Update(m, cols...)
  118. err = global.DmSQL["rddp"].Select(cols).Updates(m).Error
  119. return
  120. }
  121. func (m *ReportApprove) Del() (err error) {
  122. //o := orm.NewOrmUsingDB("rddp")
  123. sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  124. //_, err = o.Raw(sql, m.ReportApproveId).Exec()
  125. err = global.DmSQL["rddp"].Exec(sql, m.ReportApproveId).Error
  126. return
  127. }
  128. func (m *ReportApprove) MultiDel(menuIds []int) (err error) {
  129. if len(menuIds) == 0 {
  130. return
  131. }
  132. //o := orm.NewOrmUsingDB("rddp")
  133. sql := fmt.Sprintf(`DELETE FROM %s WHERE %s IN (%s)`, m.TableName(), m.PrimaryId(), utils.GetOrmInReplace(len(menuIds)))
  134. //_, err = o.Raw(sql, menuIds).Exec()
  135. err = global.DmSQL["rddp"].Exec(sql, menuIds).Error
  136. return
  137. }
  138. func (m *ReportApprove) GetItemById(id int) (item *ReportApprove, err error) {
  139. //o := orm.NewOrmUsingDB("rddp")
  140. sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  141. //err = o.Raw(sql, id).QueryRow(&item)
  142. err = global.DmSQL["rddp"].Raw(sql, id).First(&item).Error
  143. return
  144. }
  145. func (m *ReportApprove) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *ReportApprove, err error) {
  146. //o := orm.NewOrmUsingDB("rddp")
  147. order := ``
  148. if orderRule != "" {
  149. order = ` ORDER BY ` + orderRule
  150. }
  151. sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
  152. //err = o.Raw(sql, pars).QueryRow(&item)
  153. err = global.DmSQL["rddp"].Raw(sql, pars).First(&item).Error
  154. return
  155. }
  156. func (m *ReportApprove) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
  157. //o := orm.NewOrmUsingDB("rddp")
  158. sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
  159. //err = o.Raw(sql, pars).QueryRow(&count)
  160. err = global.DmSQL["rddp"].Raw(sql, pars).Scan(&count).Error
  161. return
  162. }
  163. func (m *ReportApprove) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*ReportApprove, err error) {
  164. //o := orm.NewOrmUsingDB("rddp")
  165. fields := strings.Join(fieldArr, ",")
  166. if len(fieldArr) == 0 {
  167. fields = `*`
  168. }
  169. order := `ORDER BY create_time DESC`
  170. if orderRule != "" {
  171. order = ` ORDER BY ` + orderRule
  172. }
  173. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  174. //_, err = o.Raw(sql, pars).QueryRows(&items)
  175. err = global.DmSQL["rddp"].Raw(sql, pars).Find(&items).Error
  176. return
  177. }
  178. func (m *ReportApprove) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*ReportApprove, err error) {
  179. //o := orm.NewOrmUsingDB("rddp")
  180. fields := strings.Join(fieldArr, ",")
  181. if len(fieldArr) == 0 {
  182. fields = `*`
  183. }
  184. order := `ORDER BY create_time DESC`
  185. if orderRule != "" {
  186. order = ` ORDER BY ` + orderRule
  187. }
  188. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
  189. //_, err = o.Raw(sql, pars...).QueryRows(&items)
  190. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  191. return
  192. }
  193. // ReportApproveItem 报告审批信息
  194. type ReportApproveItem struct {
  195. ReportApproveId int `description:"审批ID"`
  196. ReportApproveRecordId int `description:"审批记录ID"`
  197. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  198. ReportId int `description:"报告ID"`
  199. ReportTitle string `description:"报告标题"`
  200. ReportClassify string `description:"报告分类"`
  201. ClassifyFirstId int `description:"一级分类ID"`
  202. ClassifySecondId int `description:"二级分类ID"`
  203. State int `description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
  204. RecordState int `description:"审批记录状态:1-待审批;2-已通过;3-已驳回"`
  205. FlowId int `description:"审批流ID"`
  206. FlowVersion int `description:"审批流版本"`
  207. StartNodeId int `description:"开始节点ID"`
  208. CurrNodeId int `description:"当前节点ID"`
  209. ApplyUserId int `description:"申请人ID"`
  210. ApplyUserName string `description:"申请人姓名"`
  211. ApproveRemark string `description:"审批备注"`
  212. ApproveTime string `description:"审批时间"`
  213. HandleTime string `description:"处理时间"`
  214. CreateTime string `description:"创建时间"`
  215. ModifyTime string `description:"修改时间"`
  216. DetailImgUrl string `description:"报告详情长图地址"`
  217. DetailPdfUrl string `description:"报告详情PDF地址"`
  218. }
  219. // FormatReportApproveOrm2Item 格式化报告审批
  220. func FormatReportApproveOrm2Item(origin *ReportApproveItemOrm) (item *ReportApproveItem) {
  221. item = new(ReportApproveItem)
  222. if origin == nil {
  223. return
  224. }
  225. item.ReportApproveId = origin.ReportApproveId
  226. item.ReportApproveRecordId = origin.ReportApproveRecordId
  227. item.ReportType = origin.ReportType
  228. item.ReportId = origin.ReportId
  229. item.ReportTitle = origin.ReportTitle
  230. item.ClassifyFirstId = origin.ClassifyFirstId
  231. item.ClassifySecondId = origin.ClassifySecondId
  232. item.State = origin.State
  233. item.RecordState = origin.RecordState
  234. item.FlowId = origin.FlowId
  235. item.FlowVersion = origin.FlowVersion
  236. item.StartNodeId = origin.StartNodeId
  237. item.CurrNodeId = origin.CurrNodeId
  238. item.ApplyUserId = origin.ApplyUserId
  239. item.ApplyUserName = origin.ApplyUserName
  240. item.ApproveRemark = origin.ApproveRemark
  241. item.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, origin.ApproveTime)
  242. item.HandleTime = utils.TimeTransferString(utils.FormatDateTime, origin.HandleTime)
  243. item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
  244. item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
  245. return
  246. }
  247. // ReportApproveListReq 审批列表请求体
  248. type ReportApproveListReq struct {
  249. PageSize int `form:"PageSize"`
  250. CurrentIndex int `form:"CurrentIndex"`
  251. ListType int `form:"ListType" description:"列表类型:1-待处理;2-已处理;3-我发起的"`
  252. ReportType int `form:"ReportType" description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  253. ClassifyFirstId int `form:"ClassifyFirstId" description:"一级分类ID"`
  254. ClassifySecondId int `form:"ClassifySecondId" description:"二级分类ID"`
  255. Keyword string `form:"Keyword" description:"关键词:报告标题"`
  256. ApproveState int `form:"ApproveState" description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
  257. TimeType int `form:"TimeType" description:"时间类型:1-提交时间;2-处理时间;3-审批时间"`
  258. StartTime string `form:"StartTime" description:"开始时间"`
  259. EndTime string `form:"EndTime" description:"结束时间"`
  260. SortField int `form:"SortField" description:"排序字段:1-提交时间;2-处理时间;3-审批时间"`
  261. SortRule int `form:"SortRule" description:"排序方式: 1-正序; 2-倒序(默认)"`
  262. }
  263. // ReportApproveListResp 审批列表响应体
  264. type ReportApproveListResp struct {
  265. List []*ReportApproveItem
  266. Paging *paging.PagingItem `description:"分页数据"`
  267. }
  268. type ReportApproveItemOrm struct {
  269. ReportApproveId int `description:"审批ID"`
  270. ReportApproveRecordId int `description:"审批记录ID"`
  271. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  272. ReportId int `description:"报告ID"`
  273. ReportTitle string `description:"报告标题"`
  274. ClassifyFirstId int `description:"一级分类ID"`
  275. ClassifySecondId int `description:"二级分类ID"`
  276. ClassifyThirdId int `description:"二级分类ID"`
  277. State int `description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
  278. RecordState int `description:"审批记录状态:1-待审批;2-已通过;3-已驳回"`
  279. FlowId int `description:"审批流ID"`
  280. FlowVersion int `description:"审批流版本"`
  281. StartNodeId int `description:"开始节点ID"`
  282. CurrNodeId int `description:"当前节点ID"`
  283. ApplyUserId int `description:"申请人ID"`
  284. ApplyUserName string `description:"申请人姓名"`
  285. ApproveRemark string `description:"审批备注"`
  286. ApproveTime time.Time `description:"审批时间"`
  287. HandleTime time.Time `description:"处理时间"`
  288. CreateTime time.Time `description:"创建时间"`
  289. ModifyTime time.Time `description:"修改时间"`
  290. NodeState int `description:"当前节点审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回" json:"-"`
  291. NodeApproveTime time.Time `description:"当前节点审批时间" json:"-"`
  292. }
  293. // GetApprovingReportApproveCount 获取待处理的审批分页列表总数
  294. func GetApprovingReportApproveCount(cond string, pars []interface{}) (count int, err error) {
  295. //o := orm.NewOrmUsingDB("rddp")
  296. base := fmt.Sprintf(`SELECT a.report_approve_record_id
  297. FROM report_approve_record AS a
  298. JOIN report_approve AS b ON a.report_approve_id = b.report_approve_id AND a.node_id = b.curr_node_id
  299. WHERE 1 = 1 %s`, cond)
  300. sql := fmt.Sprintf(`SELECT COUNT(1) FROM (%s) t`, base)
  301. //err = o.Raw(sql, pars).QueryRow(&count)
  302. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  303. return
  304. }
  305. // GetApprovingReportApprovePageList 获取待处理的审批列表-分页
  306. func GetApprovingReportApprovePageList(cond string, pars []interface{}, orderRule string, startSize, pageSize int) (items []*ReportApproveItemOrm, err error) {
  307. //o := orm.NewOrmUsingDB("rddp")
  308. order := `ORDER BY a.create_time DESC`
  309. if orderRule != "" {
  310. order = ` ORDER BY ` + orderRule
  311. }
  312. sql := fmt.Sprintf(`SELECT a.report_approve_record_id, a.state AS record_state, b.*
  313. FROM report_approve_record AS a
  314. JOIN report_approve AS b ON a.report_approve_id = b.report_approve_id AND a.node_id = b.curr_node_id
  315. WHERE 1 = 1 %s %s
  316. LIMIT ?,?`, cond, order)
  317. //_, err = o.Raw(sql, pars...).QueryRows(&items)
  318. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  319. return
  320. }
  321. // GetApprovedReportApproveCount 获取已处理的审批分页列表总数
  322. func GetApprovedReportApproveCount(cond string, pars []interface{}) (count int, err error) {
  323. //o := orm.NewOrmUsingDB("rddp")
  324. base := fmt.Sprintf(`SELECT a.report_approve_record_id
  325. FROM report_approve_record AS a
  326. JOIN report_approve AS b ON a.report_approve_id = b.report_approve_id
  327. WHERE 1 = 1 %s`, cond)
  328. sql := fmt.Sprintf(`SELECT COUNT(1) FROM (%s) t`, base)
  329. //err = o.Raw(sql, pars).QueryRow(&count)
  330. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  331. return
  332. }
  333. // GetApprovedReportApprovePageList 获取已处理的审批列表-分页
  334. func GetApprovedReportApprovePageList(cond string, pars []interface{}, orderRule string, startSize, pageSize int) (items []*ReportApproveItemOrm, err error) {
  335. //o := orm.NewOrmUsingDB("rddp")
  336. order := `ORDER BY a.create_time DESC`
  337. if orderRule != "" {
  338. order = ` ORDER BY ` + orderRule
  339. }
  340. sql := fmt.Sprintf(`SELECT a.report_approve_record_id, a.node_state AS record_state,a.node_state,a.node_approve_time, a.node_approve_time AS handle_time, b.*
  341. FROM report_approve_record AS a
  342. JOIN report_approve AS b ON a.report_approve_id = b.report_approve_id
  343. WHERE 1 = 1 %s %s
  344. LIMIT ?,?`, cond, order)
  345. //_, err = o.Raw(sql, pars...).QueryRows(&items)
  346. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  347. return
  348. }
  349. // GetApplyReportApproveCount 获取我发起的审批分页列表总数
  350. func GetApplyReportApproveCount(cond string, pars []interface{}) (count int, err error) {
  351. //o := orm.NewOrmUsingDB("rddp")
  352. base := fmt.Sprintf(`SELECT a.* FROM report_approve AS a WHERE 1 = 1 %s`, cond)
  353. sql := fmt.Sprintf(`SELECT COUNT(1) FROM (%s) t`, base)
  354. //err = o.Raw(sql, pars).QueryRow(&count)
  355. err = global.DmSQL["rddp"].Raw(sql, pars).Scan(&count).Error
  356. return
  357. }
  358. // GetApplyReportApprovePageList 获取我发起的审批列表-分页
  359. func GetApplyReportApprovePageList(cond string, pars []interface{}, orderRule string, startSize, pageSize int) (items []*ReportApproveItemOrm, err error) {
  360. //o := orm.NewOrmUsingDB("rddp")
  361. order := `ORDER BY a.create_time DESC`
  362. if orderRule != "" {
  363. order = ` ORDER BY ` + orderRule
  364. }
  365. sql := fmt.Sprintf(`SELECT a.* FROM report_approve AS a WHERE 1 = 1 %s %s LIMIT ?,?`, cond, order)
  366. //_, err = o.Raw(sql, pars...).QueryRows(&items)
  367. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  368. return
  369. }
  370. // ReportApproveDetail 审批详情信息
  371. type ReportApproveDetail struct {
  372. Report *ReportApproveDetailReport `description:"报告信息"`
  373. Approve *ReportApproveDetailItem `description:"审批信息"`
  374. ApproveFlowNodes []*ReportApproveDetailNodes `description:"审批节点信息"`
  375. //ApproveFlow *ReportApproveFlowItem `description:"审批流信息"`
  376. }
  377. // ReportApproveDetailItem 审批详情-审批信息
  378. type ReportApproveDetailItem struct {
  379. ReportApproveId int `description:"审批ID"`
  380. State int `description:"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"`
  381. FlowId int `description:"审批流ID"`
  382. FlowVersion int `description:"审批流版本"`
  383. StartNodeId int `description:"开始节点ID"`
  384. CurrNodeId int `description:"当前节点ID"`
  385. ApplyUserId int `description:"申请人ID"`
  386. ApplyUserName string `description:"申请人姓名"`
  387. ApproveTime string `description:"审批时间"`
  388. CreateTime string `description:"创建时间"`
  389. ModifyTime string `description:"修改时间"`
  390. }
  391. // ReportApproveDetailReport 审批详情-报告信息
  392. type ReportApproveDetailReport struct {
  393. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  394. ReportId int `description:"报告ID"`
  395. ReportTitle string `description:"报告标题"`
  396. ReportCode string `description:"报告code"`
  397. ReportClassify string `description:"报告分类"`
  398. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  399. //ClassifyFirstId int `description:"一级分类ID"`
  400. //ClassifySecondId int `description:"二级分类ID"`
  401. //Content string `description:"报告内容"`
  402. }
  403. // CreateApproveAndRecord 新增审批和记录
  404. func (m *ReportApprove) CreateApproveAndRecord(approveItem *ReportApprove, recordItems []*ReportApproveRecord) (err error) {
  405. if approveItem == nil {
  406. err = fmt.Errorf("approve is nil")
  407. return
  408. }
  409. //o := orm.NewOrmUsingDB("rddp")
  410. //tx, e := o.Begin()
  411. //if e != nil {
  412. // err = fmt.Errorf("orm begin err: %s", e.Error())
  413. // return
  414. //}
  415. //defer func() {
  416. // if err != nil {
  417. // _ = tx.Rollback()
  418. // return
  419. // }
  420. // _ = tx.Commit()
  421. //}()
  422. //
  423. //lastId, e := tx.Insert(approveItem)
  424. //if e != nil {
  425. // err = fmt.Errorf("insert approve err: %s", e.Error())
  426. // return
  427. //}
  428. //approveItem.ReportApproveId = int(lastId)
  429. //
  430. //if len(recordItems) > 0 {
  431. // for _, v := range recordItems {
  432. // v.ReportApproveId = approveItem.ReportApproveId
  433. // }
  434. // _, e = tx.InsertMulti(len(recordItems), recordItems)
  435. // if e != nil {
  436. // err = fmt.Errorf("insert records err: %s", e.Error())
  437. // return
  438. // }
  439. //}
  440. tx := global.DmSQL["data"].Begin()
  441. defer func() {
  442. if err != nil {
  443. _ = tx.Rollback()
  444. return
  445. }
  446. _ = tx.Commit()
  447. }()
  448. e := tx.Create(approveItem).Error
  449. if e != nil {
  450. err = fmt.Errorf("insert approve err: %v", e)
  451. return
  452. }
  453. if len(recordItems) > 0 {
  454. for _, v := range recordItems {
  455. v.ReportApproveId = approveItem.ReportApproveId
  456. }
  457. e = tx.CreateInBatches(recordItems, utils.MultiAddNum).Error
  458. if e != nil {
  459. err = fmt.Errorf("insert records err: %v", e)
  460. return
  461. }
  462. }
  463. return
  464. }
  465. // ReportApprovePassReq 审批通过请求体
  466. type ReportApprovePassReq struct {
  467. ReportApproveId int `description:"审批ID"`
  468. ReportUrl string `description:"报告URL"`
  469. }
  470. // ReportApproveRefuseReq 审批驳回请求体
  471. type ReportApproveRefuseReq struct {
  472. ReportApproveId int `description:"审批ID"`
  473. ApproveRemark string `description:"驳回理由"`
  474. }
  475. // ReportApproveCancelReq 撤销审批请求体
  476. type ReportApproveCancelReq struct {
  477. ReportApproveId int `description:"审批ID"`
  478. }
  479. // ReportApproveCheckApproveOpenReq 校验分类是否打开审批请求体
  480. type ReportApproveCheckApproveOpenReq struct {
  481. ReportType int `description:"报告类型:1-中文研报;2-英文研报;3-智能研报"`
  482. ClassifyFirstId int `description:"一级分类ID"`
  483. ClassifySecondId int `description:"二级分类ID"`
  484. ClassifyThirdId int `description:"三级分类ID"`
  485. }