ctr_contract_event.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. contractdao "dashoo.cn/opms_parent/app/dao/contract"
  6. opsdevdao "dashoo.cn/opms_parent/app/dao/opsdev"
  7. contractmodel "dashoo.cn/opms_parent/app/model/contract"
  8. opsdevmodel "dashoo.cn/opms_parent/app/model/opsdev"
  9. "dashoo.cn/opms_parent/app/service"
  10. "dashoo.cn/opms_libary/myerrors"
  11. "github.com/gogf/gf/database/gdb"
  12. "github.com/gogf/gf/frame/g"
  13. "github.com/gogf/gf/os/gtime"
  14. )
  15. type ctrContractEventService struct {
  16. *service.ContextService
  17. Dao *contractdao.CtrContractEventDao
  18. ContractDao *contractdao.CtrContractDao
  19. DeliveryEventDao *opsdevdao.OpsDeliveryProjectEventDao
  20. DeliveryProjectDao *opsdevdao.OpsDeliveryProjectDao
  21. DeliveryRecordDao *opsdevdao.OpsDeliveryProjectEventRecordDao
  22. OperationDao *opsdevdao.OpsOperationEventDao
  23. OperationRecordDao *opsdevdao.OpsOperationEventRecordDao
  24. DeliveryAttachmentDao *opsdevdao.OpsDeliveryProjectEventAttachmentDao
  25. OperationAttachmentDao *opsdevdao.OpsOperationEventAttachmentDao
  26. }
  27. func NewCtrContractEventService(ctx context.Context) (*ctrContractEventService, error) {
  28. svc := &ctrContractEventService{}
  29. var err error
  30. if svc.ContextService, err = svc.Init(ctx); err != nil {
  31. return nil, err
  32. }
  33. svc.Dao = contractdao.NewCtrContractEventDao(svc.Tenant)
  34. svc.ContractDao = contractdao.NewCtrContractDao(svc.Tenant)
  35. svc.DeliveryEventDao = opsdevdao.NewOpsDeliveryProjectEventDao(svc.Tenant)
  36. svc.DeliveryProjectDao = opsdevdao.NewOpsDeliveryProjectDao(svc.Tenant)
  37. svc.DeliveryRecordDao = opsdevdao.NewOpsDeliveryProjectEventRecordDao(svc.Tenant)
  38. svc.OperationDao = opsdevdao.NewOpsOperationEventDao(svc.Tenant)
  39. svc.OperationRecordDao = opsdevdao.NewOpsOperationEventRecordDao(svc.Tenant)
  40. svc.DeliveryAttachmentDao = opsdevdao.NewOpsDeliveryProjectEventAttachmentDao(svc.Tenant)
  41. svc.OperationAttachmentDao = opsdevdao.NewOpsOperationEventAttachmentDao(svc.Tenant)
  42. return svc, nil
  43. }
  44. // buildContractEventPermissionWhere 构建合同事件查询权限条件
  45. // 仅能查看自己有权限的合同的事件信息
  46. func (s *ctrContractEventService) buildContractEventPermissionWhere() string {
  47. if s.CxtUser == nil {
  48. return ""
  49. }
  50. allVisibleRoles := []string{
  51. "SalesDirector",
  52. "GeneralManager",
  53. "ResearchAndDevelopmentDirector",
  54. "ResearchAndDevelopmentSupervisor",
  55. "PersonnelDirector",
  56. "SysAdmin",
  57. }
  58. for _, role := range allVisibleRoles {
  59. if service.StringsContains(s.CxtUser.Roles, role) {
  60. return ""
  61. }
  62. }
  63. where := "(1=0"
  64. if service.StringsContains(s.CxtUser.Roles, "RegionalManager") {
  65. where += fmt.Sprintf(" OR EXISTS (SELECT 1 FROM base_region_auth WHERE user_id = %d AND deleted_time IS NULL AND city_id = cc.cust_city_id)", s.CxtUser.Id)
  66. }
  67. if service.StringsContains(s.CxtUser.Roles, "SalesEngineer") {
  68. where += fmt.Sprintf(" OR a.incharge_id = %d", s.CxtUser.Id)
  69. }
  70. where += ")"
  71. return where
  72. }
  73. func (s *ctrContractEventService) GetProjectByContractId(req *contractmodel.CtrContractEventGetProjectReq) (*contractmodel.CtrContractEventProjectRsp, error) {
  74. rsp := &contractmodel.CtrContractEventProjectRsp{}
  75. type projectRow struct {
  76. Id int `orm:"id"`
  77. ProjectStatus string `orm:"project_status"`
  78. }
  79. var project projectRow
  80. count, err := s.DeliveryProjectDao.
  81. Unscoped().
  82. Where("contract_id = ? AND deleted_time IS NULL", req.ContractId).
  83. Count(1)
  84. if err != nil {
  85. g.Log().Error(err)
  86. return nil, myerrors.DbError("查询交付项目失败")
  87. }
  88. if count == 0 {
  89. rsp.Found = false
  90. return rsp, nil
  91. }
  92. err = s.DeliveryProjectDao.
  93. Unscoped().
  94. Fields(s.DeliveryProjectDao.Columns.Id, s.DeliveryProjectDao.Columns.ProjectStatus).
  95. Where("contract_id = ? AND deleted_time IS NULL", req.ContractId).
  96. Limit(1).
  97. Scan(&project)
  98. if err != nil {
  99. g.Log().Error(err)
  100. return nil, myerrors.DbError("查询交付项目详情失败")
  101. }
  102. rsp.Found = true
  103. rsp.ProjectId = project.Id
  104. rsp.ProjectStatus = project.ProjectStatus
  105. if rsp.ProjectStatus == "50" {
  106. rsp.EventType = contractmodel.ContractEventTypeOperation
  107. } else {
  108. rsp.EventType = contractmodel.ContractEventTypeDelivery
  109. }
  110. return rsp, nil
  111. }
  112. func (s *ctrContractEventService) CreateProjectForContract(req *contractmodel.CtrContractEventCreateProjectReq) error {
  113. var contractInfo contractmodel.CtrContract
  114. err := s.ContractDao.WherePri(req.ContractId).Scan(&contractInfo)
  115. if err != nil {
  116. g.Log().Error(err)
  117. return myerrors.DbError("查询合同信息失败")
  118. }
  119. if contractInfo.Id <= 0 {
  120. return myerrors.TipsError("合同不存在")
  121. }
  122. count, err := s.DeliveryProjectDao.
  123. Unscoped().
  124. Where("contract_id = ? AND deleted_time IS NULL", req.ContractId).
  125. Count(1)
  126. if err != nil {
  127. g.Log().Error(err)
  128. return myerrors.DbError("查询交付项目失败")
  129. }
  130. if count > 0 {
  131. return nil
  132. }
  133. data := g.Map{
  134. "project_name": contractInfo.ContractName,
  135. "project_status": "50",
  136. "contract_id": contractInfo.Id,
  137. "contract_no": contractInfo.ContractCode,
  138. "cust_id": contractInfo.CustId,
  139. "cust_name": contractInfo.CustName,
  140. "product_line": contractInfo.ProductLine,
  141. "sales_user_id": contractInfo.InchargeId,
  142. "sales_user_name": contractInfo.InchargeName,
  143. "sales_region_id": contractInfo.CustCityId,
  144. "delivery_node": "05",
  145. }
  146. service.SetCreatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
  147. _, err = s.DeliveryProjectDao.Data(data).Insert()
  148. if err != nil {
  149. g.Log().Error(err)
  150. return myerrors.DbError("创建交付项目失败")
  151. }
  152. return nil
  153. }
  154. func (s *ctrContractEventService) GetList(req *contractmodel.CtrContractEventSearchReq) (total int, list []*contractmodel.CtrContractEventRsp, err error) {
  155. baseQuery := s.Dao.DB.Model("ctr_contract_event a").
  156. LeftJoin("ctr_contract cc", "a.contract_id = cc.id AND cc.deleted_time IS NULL").
  157. LeftJoin("ops_delivery_project_event b", "a.event_type='10' AND a.event_id = b.id AND b.deleted_time IS NULL").
  158. LeftJoin("ops_operation_event c", "a.event_type='20' AND a.event_id = c.id AND c.deleted_time IS NULL").
  159. Unscoped().
  160. Where("a.deleted_time IS NULL")
  161. permissionWhere := s.buildContractEventPermissionWhere()
  162. if permissionWhere != "" {
  163. baseQuery = baseQuery.Where(permissionWhere)
  164. }
  165. if req.ContractId != 0 {
  166. baseQuery = baseQuery.Where("a.contract_id = ?", req.ContractId)
  167. }
  168. if req.EventType != "" {
  169. baseQuery = baseQuery.Where("a.event_type = ?", req.EventType)
  170. }
  171. if req.EventTitle != "" {
  172. likestr := fmt.Sprintf("%%%s%%", req.EventTitle)
  173. baseQuery = baseQuery.Where("(b.delivery_event_title LIKE ? OR c.event_title LIKE ?)", likestr, likestr)
  174. }
  175. if len(req.EventStatus) > 0 {
  176. baseQuery = baseQuery.Where("COALESCE(b.delivery_event_status, c.event_status) IN (?)", req.EventStatus)
  177. }
  178. if req.FeedbackReporter != "" {
  179. likestr := fmt.Sprintf("%%%s%%", req.FeedbackReporter)
  180. baseQuery = baseQuery.Where("(b.feedback_reporter LIKE ? OR c.feedback_reporter LIKE ?)", likestr, likestr)
  181. }
  182. if req.FeedbackDateStart != "" {
  183. baseQuery = baseQuery.Where("(b.feedback_date >= ? OR c.feedback_date >= ?)", req.FeedbackDateStart, req.FeedbackDateStart)
  184. }
  185. if req.FeedbackDateEnd != "" {
  186. baseQuery = baseQuery.Where("(b.feedback_date <= ? OR c.feedback_date <= ?)", req.FeedbackDateEnd, req.FeedbackDateEnd)
  187. }
  188. if req.OpsUserName != "" {
  189. likestr := fmt.Sprintf("%%%s%%", req.OpsUserName)
  190. baseQuery = baseQuery.Where("(b.ops_user_name LIKE ? OR c.ops_user_name LIKE ?)", likestr, likestr)
  191. }
  192. total, err = baseQuery.Fields("a.id").Count()
  193. if err != nil {
  194. g.Log().Error(err)
  195. return 0, nil, myerrors.DbError("获取合同事件总行数失败")
  196. }
  197. pageSize := req.PageSize
  198. if pageSize <= 0 {
  199. pageSize = 10
  200. }
  201. page := req.GetPage()
  202. err = baseQuery.Fields(
  203. "a.id as ctr_event_id",
  204. "a.event_id",
  205. "a.event_type",
  206. "a.contract_id",
  207. "a.contract_code",
  208. "a.contract_name",
  209. "a.cust_name",
  210. "COALESCE(b.delivery_event_title, c.event_title) as event_title",
  211. "COALESCE(b.delivery_event_no, c.event_no) as event_no",
  212. "COALESCE(b.delivery_event_type, c.event_type) as sub_event_type",
  213. "COALESCE(b.delivery_event_status, c.event_status) as event_status",
  214. "COALESCE(b.ops_user_name, c.ops_user_name) as ops_user_name",
  215. "COALESCE(b.feedback_reporter, c.feedback_reporter) as feedback_reporter",
  216. "COALESCE(b.feedback_date, c.feedback_date) as feedback_date",
  217. "COALESCE(b.complete_time, c.complete_time) as complete_time",
  218. "COALESCE(b.complete_desc, c.complete_desc) as complete_desc",
  219. ).OrderDesc("a.id").Page(page, pageSize).Scan(&list)
  220. if err != nil {
  221. g.Log().Error(err)
  222. return 0, nil, myerrors.DbError("查询合同事件列表失败")
  223. }
  224. return total, list, nil
  225. }
  226. func (s *ctrContractEventService) Create(req *contractmodel.CtrContractEventAddReq) error {
  227. return s.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
  228. var eventId int64
  229. var eventCode string
  230. var err error
  231. switch req.EventType {
  232. case contractmodel.ContractEventTypeOperation:
  233. eventId, eventCode, err = s.createOperationEvent(tx, req)
  234. case contractmodel.ContractEventTypeDelivery:
  235. eventId, eventCode, err = s.createDeliveryEvent(tx, req)
  236. default:
  237. return myerrors.TipsError("未知的事件类型")
  238. }
  239. if err != nil {
  240. return err
  241. }
  242. linkData := g.Map{
  243. "event_id": eventId,
  244. "event_code": eventCode,
  245. "event_type": req.EventType,
  246. "contract_id": req.ContractId,
  247. "contract_code": req.ContractCode,
  248. "contract_name": req.ContractName,
  249. "cust_id": req.CustId,
  250. "cust_name": req.CustName,
  251. "product_line": req.ProductLine,
  252. "is_big": req.IsBig,
  253. "incharge_id": s.GetCxtUserId(),
  254. "incharge_name": s.GetCxtUserName(),
  255. "remark": req.Remark,
  256. }
  257. service.SetCreatedInfo(linkData, s.GetCxtUserId(), s.GetCxtUserName())
  258. _, err = s.Dao.TX(tx).Data(linkData).Insert()
  259. if err != nil {
  260. g.Log().Error(err)
  261. return myerrors.DbError("新增合同事件关联记录失败")
  262. }
  263. return nil
  264. })
  265. }
  266. func (s *ctrContractEventService) createOperationEvent(tx *gdb.TX, req *contractmodel.CtrContractEventAddReq) (int64, string, error) {
  267. var project opsdevmodel.OpsDeliveryProject
  268. err := s.DeliveryProjectDao.
  269. TX(tx).
  270. Fields(s.DeliveryProjectDao.Columns.Attribute4, s.DeliveryProjectDao.Columns.Attribute3).
  271. Where("contract_id = ? AND deleted_time IS NULL", req.ContractId).
  272. OrderDesc(s.DeliveryProjectDao.Columns.Id).
  273. Limit(1).
  274. Scan(&project)
  275. if err != nil {
  276. g.Log().Error(err)
  277. return 0, "", myerrors.DbError("查询交付项目失败")
  278. }
  279. data := g.Map{
  280. "event_title": req.EventTitle,
  281. "event_desc": req.EventDesc,
  282. "event_type": req.SubEventType,
  283. "priority_level": req.PriorityLevel,
  284. "contract_id": req.ContractId,
  285. "contract_name": req.ContractName,
  286. "cust_id": req.CustId,
  287. "cust_name": req.CustName,
  288. "product_line": req.ProductLine,
  289. "is_big": req.IsBig,
  290. "is_ops": "10",
  291. "feedback_reporter": req.FeedbackReporter,
  292. "feedback_source": req.FeedbackSource,
  293. "event_no": generateOperationEventNo(),
  294. }
  295. if project.Attribute4 > 0 {
  296. data["event_status"] = opsdevmodel.EventStatusProcessing
  297. data["ops_user_id"] = int(project.Attribute4)
  298. data["ops_user_name"] = project.Attribute3
  299. } else {
  300. data["event_status"] = opsdevmodel.EventStatusPending
  301. }
  302. if req.FeedbackDate == "" {
  303. data["feedback_date"] = gtime.Now()
  304. } else {
  305. data["feedback_date"] = req.FeedbackDate
  306. }
  307. service.SetCreatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
  308. result, err := s.OperationDao.TX(tx).Data(data).Insert()
  309. if err != nil {
  310. g.Log().Error(err)
  311. return 0, "", myerrors.DbError("创建运维事件失败")
  312. }
  313. id, _ := result.LastInsertId()
  314. if len(req.Attachments) > 0 {
  315. for _, att := range req.Attachments {
  316. attData := g.Map{
  317. "event_id": id,
  318. "file_name": att.FileName,
  319. "file_url": att.FileUrl,
  320. "file_type": att.FileType,
  321. }
  322. service.SetCreatedInfo(attData, s.GetCxtUserId(), s.GetCxtUserName())
  323. _, _ = s.OperationAttachmentDao.TX(tx).Data(attData).Insert()
  324. }
  325. }
  326. return id, fmt.Sprintf("OPS-%d", id), nil
  327. }
  328. func (s *ctrContractEventService) createDeliveryEvent(tx *gdb.TX, req *contractmodel.CtrContractEventAddReq) (int64, string, error) {
  329. var project opsdevmodel.OpsDeliveryProject
  330. err := s.DeliveryProjectDao.
  331. TX(tx).
  332. Fields(
  333. s.DeliveryProjectDao.Columns.Id,
  334. s.DeliveryProjectDao.Columns.DeliveryUserId,
  335. s.DeliveryProjectDao.Columns.DeliveryUserName,
  336. ).
  337. Where("contract_id = ? AND deleted_time IS NULL", req.ContractId).
  338. OrderDesc(s.DeliveryProjectDao.Columns.Id).
  339. Limit(1).
  340. Scan(&project)
  341. if err != nil {
  342. g.Log().Error(err)
  343. return 0, "", myerrors.DbError("查询交付项目失败")
  344. }
  345. if project.Id <= 0 {
  346. return 0, "", myerrors.TipsError("未找到对应交付项目,请先创建项目")
  347. }
  348. data := g.Map{
  349. "project_id": project.Id,
  350. "delivery_event_title": req.EventTitle,
  351. "delivery_event_desc": req.EventDesc,
  352. "delivery_event_type": req.SubEventType,
  353. "feedback_reporter": req.FeedbackReporter,
  354. "feedback_source": req.FeedbackSource,
  355. "delivery_event_status": opsdevmodel.DeliveryEventStatusProcessing,
  356. "delivery_event_no": generateDeliveryEventNo(),
  357. }
  358. if project.DeliveryUserId > 0 {
  359. data["ops_user_id"] = project.DeliveryUserId
  360. data["ops_user_name"] = project.DeliveryUserName
  361. } else {
  362. data["ops_user_id"] = s.GetCxtUserId()
  363. data["ops_user_name"] = s.GetCxtUserName()
  364. }
  365. if req.FeedbackDate == "" {
  366. data["feedback_date"] = gtime.Now()
  367. } else {
  368. data["feedback_date"] = req.FeedbackDate
  369. }
  370. service.SetCreatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
  371. result, err := s.DeliveryEventDao.TX(tx).Data(data).Insert()
  372. if err != nil {
  373. g.Log().Error(err)
  374. return 0, "", myerrors.DbError("创建交付事件失败")
  375. }
  376. id, _ := result.LastInsertId()
  377. if len(req.Attachments) > 0 {
  378. for _, att := range req.Attachments {
  379. attData := g.Map{
  380. "event_id": id,
  381. "file_name": att.FileName,
  382. "file_url": att.FileUrl,
  383. "file_type": att.FileType,
  384. }
  385. service.SetCreatedInfo(attData, s.GetCxtUserId(), s.GetCxtUserName())
  386. _, _ = s.DeliveryAttachmentDao.TX(tx).Data(attData).Insert()
  387. }
  388. }
  389. return id, fmt.Sprintf("DEL-%d", id), nil
  390. }
  391. func generateOperationEventNo() string {
  392. return fmt.Sprintf("OPS%s", gtime.Now().Format("YmdHis"))
  393. }
  394. func generateDeliveryEventNo() string {
  395. return fmt.Sprintf("DEL%s", gtime.Now().Format("YmdHis"))
  396. }
  397. func (s *ctrContractEventService) Cancel(req *contractmodel.CtrContractEventCancelReq) error {
  398. entity, err := s.Dao.WherePri(req.Id).One()
  399. if err != nil {
  400. g.Log().Error(err)
  401. return myerrors.DbError("查询合同事件登记数据失败")
  402. }
  403. if entity == nil {
  404. return myerrors.TipsError("合同事件登记数据不存在")
  405. }
  406. switch req.EventType {
  407. case contractmodel.ContractEventTypeDelivery:
  408. return s.cancelDeliveryEvent(req)
  409. case contractmodel.ContractEventTypeOperation:
  410. return s.cancelOperationEvent(req)
  411. default:
  412. return myerrors.TipsError("未知的事件类型")
  413. }
  414. }
  415. func (s *ctrContractEventService) cancelDeliveryEvent(req *contractmodel.CtrContractEventCancelReq) error {
  416. var event opsdevmodel.OpsDeliveryProjectEvent
  417. err := s.DeliveryEventDao.FieldsEx(s.DeliveryEventDao.Columns.DeletedTime).WherePri(req.EventId).Scan(&event)
  418. if err != nil {
  419. g.Log().Error(err)
  420. return myerrors.DbError("查询交付事件数据失败")
  421. }
  422. if event.Id <= 0 {
  423. return myerrors.TipsError("交付事件不存在")
  424. }
  425. if event.DeliveryEventStatus == opsdevmodel.DeliveryEventStatusClosed {
  426. return myerrors.TipsError("已关闭的事件不能作废")
  427. }
  428. if event.DeliveryEventStatus == opsdevmodel.DeliveryEventStatusCancelled {
  429. return myerrors.TipsError("该事件已作废")
  430. }
  431. return s.DeliveryEventDao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
  432. data := g.Map{
  433. s.DeliveryEventDao.Columns.DeliveryEventStatus: opsdevmodel.DeliveryEventStatusCancelled,
  434. s.DeliveryEventDao.Columns.Remark: req.CancelReason,
  435. }
  436. service.SetUpdatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
  437. _, err := s.DeliveryEventDao.TX(tx).FieldsEx(service.UpdateFieldEx...).Data(data).WherePri(req.EventId).Update()
  438. if err != nil {
  439. g.Log().Error(err)
  440. return myerrors.DbError("作废交付事件失败")
  441. }
  442. recordData := g.Map{
  443. "delivery_event_id": req.EventId,
  444. "handle_user_id": s.GetCxtUserId(),
  445. "handle_user_name": s.GetCxtUserName(),
  446. "handle_content": "作废事件:" + req.CancelReason,
  447. }
  448. service.SetCreatedInfo(recordData, s.GetCxtUserId(), s.GetCxtUserName())
  449. _, err = s.DeliveryRecordDao.TX(tx).Data(recordData).Insert()
  450. if err != nil {
  451. g.Log().Error(err)
  452. return myerrors.DbError("记录交付事件作废过程失败")
  453. }
  454. return nil
  455. })
  456. }
  457. func (s *ctrContractEventService) cancelOperationEvent(req *contractmodel.CtrContractEventCancelReq) error {
  458. var event opsdevmodel.OpsOperationEvent
  459. err := s.OperationDao.FieldsEx(s.OperationDao.Columns.DeletedTime).WherePri(req.EventId).Scan(&event)
  460. if err != nil {
  461. g.Log().Error(err)
  462. return myerrors.DbError("查询运维事件数据失败")
  463. }
  464. if event.Id <= 0 {
  465. return myerrors.TipsError("运维事件不存在")
  466. }
  467. if event.EventStatus == opsdevmodel.EventStatusClosed {
  468. return myerrors.TipsError("已关闭的事件不能作废")
  469. }
  470. return s.OperationDao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
  471. data := g.Map{
  472. s.OperationDao.Columns.EventStatus: opsdevmodel.EventStatusClosed,
  473. s.OperationDao.Columns.Remark: req.CancelReason,
  474. }
  475. service.SetUpdatedInfo(data, s.GetCxtUserId(), s.GetCxtUserName())
  476. _, err := s.OperationDao.TX(tx).FieldsEx(service.UpdateFieldEx...).Data(data).WherePri(req.EventId).Update()
  477. if err != nil {
  478. g.Log().Error(err)
  479. return myerrors.DbError("作废运维事件失败")
  480. }
  481. recordData := g.Map{
  482. "event_id": req.EventId,
  483. "handle_user_id": s.GetCxtUserId(),
  484. "handle_user_name": s.GetCxtUserName(),
  485. "handle_content": "作废事件:" + req.CancelReason,
  486. "operate_type": "90",
  487. "handle_date": gtime.Now(),
  488. }
  489. service.SetCreatedInfo(recordData, s.GetCxtUserId(), s.GetCxtUserName())
  490. _, err = s.OperationRecordDao.TX(tx).Data(recordData).Insert()
  491. if err != nil {
  492. g.Log().Error(err)
  493. return myerrors.DbError("记录运维事件作废过程失败")
  494. }
  495. return nil
  496. })
  497. }