busAdminController.go 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. /*
  2. * @Author: lilig
  3. * @Date: 2023-10-10 15:22:58
  4. * @LastEditors: lilifor
  5. * @LastEditTime: 2023-10-10 15:22:58
  6. * @FilePath: \SCD\controllers\TaskController.go
  7. * @Description:
  8. *
  9. * Copyright (c) 2023 by lilig/jujutong, All Rights Reserved.
  10. */
  11. package controllers
  12. import (
  13. "encoding/json"
  14. "fmt"
  15. "scd_check_tools/models/bo"
  16. "scd_check_tools/tools"
  17. "strconv"
  18. "strings"
  19. "github.com/astaxie/beego/orm"
  20. )
  21. //业务管理服务
  22. type BusAdminController struct {
  23. BaseController
  24. }
  25. func init() {
  26. }
  27. // @Summary 创建新的接线方式
  28. // @Description 创建新的接线方式
  29. // @Tags 业务管理服务
  30. // @Accept x-www-form-urlencoded
  31. // @Produce json
  32. // @Param id formData int false "数据ID。指定id值大于0时为编辑操作;否则为新增操作"
  33. // @Param name formData string true "任务名称"
  34. // @Param vol_id formData int true "电压等级ID"
  35. // @Param pic formData string false "接线图地址"
  36. // @Success 200 {object} ResultOK 成功
  37. // @Failure 500 {object} ResultError 失败
  38. // @router /admin/linkstyle/save [post]
  39. func (c *BusAdminController) SaveLinkStyleInfo() {
  40. id, _ := c.GetInt("id")
  41. obj := new(bo.LinkStyleMgr)
  42. obj.SetUserInfo(c.GetCurrentUserInfo())
  43. obj.Model = bo.T_data_link_style{Id: id}
  44. obj.Model.Name = c.GetString("name")
  45. obj.Model.VolLevelId, _ = c.GetInt("vol_id")
  46. obj.Model.Pic = c.GetString("pic")
  47. if obj.Model.Name == "" {
  48. c.Data["json"] = c.ResultError("名称不能为空")
  49. c.ServeJSON()
  50. return
  51. }
  52. if obj.Model.VolLevelId == 0 {
  53. c.Data["json"] = c.ResultError("电压等级不能为空")
  54. c.ServeJSON()
  55. return
  56. }
  57. err := obj.Save()
  58. if err != nil {
  59. c.Data["json"] = c.ResultError(err.Error())
  60. c.ServeJSON()
  61. return
  62. }
  63. c.Data["json"] = c.ResultOK("", 0)
  64. c.ServeJSON()
  65. }
  66. // @Summary 删除指定的接线方式
  67. // @Description 删除指定的接线方式
  68. // @Tags 业务管理服务
  69. // @Accept x-www-form-urlencoded
  70. // @Produce json
  71. // @Param id formData int true "接线方式ID"
  72. // @Success 200 {object} ResultOK 成功
  73. // @Failure 500 {object} ResultError 失败
  74. // @router /admin/linkstyle/delete [post]
  75. func (c *BusAdminController) DeleteLinkStyleByID() {
  76. id, _ := c.GetInt("id")
  77. if id == 0 {
  78. c.Data["json"] = c.ResultError("id不能为空!")
  79. c.ServeJSON()
  80. return
  81. }
  82. obj := new(bo.LinkStyleMgr)
  83. obj.SetUserInfo(c.GetCurrentUserInfo())
  84. obj.Model = bo.T_data_link_style{}
  85. obj.Model.Id = id
  86. err := obj.Delete()
  87. if err != nil {
  88. c.Data["json"] = c.ResultError(err.Error())
  89. c.ServeJSON()
  90. return
  91. }
  92. c.Data["json"] = c.ResultOK("", 0)
  93. c.ServeJSON()
  94. }
  95. // @Summary 查询接线方式
  96. // @Description 查询接线方式。支持名称、电压等级等过滤条件
  97. // @Tags 检测任务服务接口
  98. // @Accept x-www-form-urlencoded
  99. // @Produce json
  100. // @Param pageno query int true "当前页码。默认为1"
  101. // @Param pagesize query int true "每页显示数据数。默认为20"
  102. // @Param id query int false "ID"
  103. // @Param vol_id query int false "电压ID"
  104. // @Param name query string false "名称"
  105. // @Success 200 {object} ResultOK 成功
  106. // @Failure 500 {object} ResultError 失败
  107. // @router /admin/linkstyle/list [get]
  108. func (c *BusAdminController) GetLinkStyleList() {
  109. obj := new(bo.LinkStyleMgr)
  110. obj.SetUserInfo(c.GetCurrentUserInfo())
  111. obj.Model = bo.T_data_link_style{}
  112. obj.Model.Id, _ = c.GetInt("id")
  113. obj.Model.VolLevelId, _ = c.GetInt("vol_id")
  114. obj.Model.Name = c.GetString("name")
  115. pi, _ := c.GetInt("pagesize", 20)
  116. po, _ := c.GetInt("pageno", 0)
  117. if po == 0 {
  118. po, _ = c.GetInt("pageindex", 0)
  119. }
  120. if po == 0 {
  121. po = 1
  122. }
  123. lst, cnt, err := obj.List(po, pi)
  124. if err != nil {
  125. c.Data["json"] = c.ResultError(err.Error())
  126. c.ServeJSON()
  127. return
  128. }
  129. c.Data["json"] = c.ResultOK(lst, cnt)
  130. c.ServeJSON()
  131. }
  132. // @Summary 添加接线方式的模型
  133. // @Description 添加接线方式的模型
  134. // @Tags 业务管理服务
  135. // @Accept x-www-form-urlencoded
  136. // @Produce json
  137. // @Param id formData int false "数据ID。指定id值大于0时为编辑操作;否则为新增操作"
  138. // @Param linkstyle_id formData int true "接线方式ID"
  139. // @Param model_id formData int true "内置模型id"
  140. // @Success 200 {object} ResultOK 成功
  141. // @Failure 500 {object} ResultError 失败
  142. // @router /admin/linkstyle-model/save [post]
  143. func (c *BusAdminController) SaveLinkStyleModelInfo() {
  144. id, _ := c.GetInt("id")
  145. obj := new(bo.LinkStyleModelMgr)
  146. obj.SetUserInfo(c.GetCurrentUserInfo())
  147. obj.Model = bo.T_data_link_style_model{Id: id}
  148. obj.Model.LinkstyleId, _ = c.GetInt("linkstyle_id")
  149. obj.Model.ModelId, _ = c.GetInt("model_id")
  150. if obj.Model.LinkstyleId == 0 {
  151. c.Data["json"] = c.ResultError("接线方式不能为空")
  152. c.ServeJSON()
  153. return
  154. }
  155. if obj.Model.ModelId == 0 {
  156. c.Data["json"] = c.ResultError("模型ID不能为空")
  157. c.ServeJSON()
  158. return
  159. }
  160. err := obj.Save()
  161. if err != nil {
  162. c.Data["json"] = c.ResultError(err.Error())
  163. c.ServeJSON()
  164. return
  165. }
  166. c.Data["json"] = c.ResultOK("", 0)
  167. c.ServeJSON()
  168. }
  169. // @Summary 删除指定接线方式下属的模型
  170. // @Description 删除指定接线方式下属的模型
  171. // @Tags 业务管理服务
  172. // @Accept x-www-form-urlencoded
  173. // @Produce json
  174. // @Param id formData int true "接线方式ID"
  175. // @Param model_id formData int true "模型ID"
  176. // @Success 200 {object} ResultOK 成功
  177. // @Failure 500 {object} ResultError 失败
  178. // @router /admin/linkstyle-model/delete [post]
  179. func (c *BusAdminController) DeleteLinkStyleModelByID() {
  180. id, _ := c.GetInt("id")
  181. if id == 0 {
  182. c.Data["json"] = c.ResultError("id不能为空!")
  183. c.ServeJSON()
  184. return
  185. }
  186. model_id, _ := c.GetInt("model_id")
  187. if model_id == 0 {
  188. c.Data["json"] = c.ResultError("模型id不能为空!")
  189. c.ServeJSON()
  190. return
  191. }
  192. obj := new(bo.LinkStyleModelMgr)
  193. obj.SetUserInfo(c.GetCurrentUserInfo())
  194. obj.Model = bo.T_data_link_style_model{}
  195. obj.Model.LinkstyleId = id
  196. obj.Model.Id = model_id
  197. err := obj.Delete()
  198. if err != nil {
  199. c.Data["json"] = c.ResultError(err.Error())
  200. c.ServeJSON()
  201. return
  202. }
  203. c.Data["json"] = c.ResultOK("", 0)
  204. c.ServeJSON()
  205. }
  206. // @Summary 查询接线方式下模型列表
  207. // @Description 查询接线方式下模型列表
  208. // @Tags 检测任务服务接口
  209. // @Accept x-www-form-urlencoded
  210. // @Produce json
  211. // @Param pageno query int true "当前页码。默认为1"
  212. // @Param pagesize query int true "每页显示数据数。默认为20"
  213. // @Param id query int false "ID"
  214. // @Param linkstyle_id query int false "接线方式ID"
  215. // @Success 200 {object} ResultOK 成功
  216. // @Failure 500 {object} ResultError 失败
  217. // @router /admin/linkstyle-model/list [get]
  218. func (c *BusAdminController) GetLinkStyleModelList() {
  219. obj := new(bo.LinkStyleModelMgr)
  220. obj.SetUserInfo(c.GetCurrentUserInfo())
  221. obj.Model = bo.T_data_link_style_model{}
  222. obj.Model.Id, _ = c.GetInt("id")
  223. obj.Model.LinkstyleId, _ = c.GetInt("linkstyle_id")
  224. pi, _ := c.GetInt("pagesize", 20)
  225. po, _ := c.GetInt("pageno", 0)
  226. if po == 0 {
  227. po, _ = c.GetInt("pageindex", 0)
  228. }
  229. if po == 0 {
  230. po = 1
  231. }
  232. lst, cnt, err := obj.List(po, pi)
  233. if err != nil {
  234. c.Data["json"] = c.ResultError(err.Error())
  235. c.ServeJSON()
  236. return
  237. }
  238. c.Data["json"] = c.ResultOK(lst, cnt)
  239. c.ServeJSON()
  240. }
  241. // @Summary 创建或编辑新的内置模型
  242. // @Description 创建新的内置模型
  243. // @Tags 业务管理服务
  244. // @Accept x-www-form-urlencoded
  245. // @Produce json
  246. // @Param id formData int false "数据ID。指定id值大于0时为编辑操作;否则为新增操作"
  247. // @Param model_name formData string true "模型名称"
  248. // @Param vol_id formData int true "电压等级ID"
  249. // @Param line_link_style formData int true "接线方式ID"
  250. // @Param ied_types formData string false "包含的装置类型,关联代码:ied_type。多个类型之间使用逗号分隔。"
  251. // @Param relation_json formData string false "模型定义内容。svg源代码(xml格式)。"
  252. // @Param area_type formData string false "间隔类型。关联代码:area_type"
  253. // @Success 200 {object} ResultOK 成功
  254. // @Failure 500 {object} ResultError 失败
  255. // @router /admin/sysmodel/save [post]
  256. func (c *BusAdminController) SaveSysModelInfo() {
  257. id, _ := c.GetInt("id")
  258. obj := new(bo.SysCheckModelMgr)
  259. obj.SetUserInfo(c.GetCurrentUserInfo())
  260. obj.Model = bo.T_data_model_defualt{Id: id, IsSys: 1}
  261. obj.Model.ModelName = c.GetString("model_name")
  262. obj.Model.AreaType, _ = c.GetInt("area_type")
  263. obj.Model.IedTypes = c.GetString("ied_types")
  264. obj.Model.VolId, _ = c.GetInt("vol_id")
  265. obj.Model.LineLinkStyle, _ = c.GetInt("line_link_style")
  266. obj.Model.RelationJson = c.GetString("relation_json")
  267. if id == 0 && obj.Model.ModelName == "" {
  268. c.Data["json"] = c.ResultError("模型名称不能为空")
  269. c.ServeJSON()
  270. return
  271. }
  272. if id == 0 && obj.Model.VolId == 0 {
  273. c.Data["json"] = c.ResultError("电压等级不能为空")
  274. c.ServeJSON()
  275. return
  276. }
  277. if id == 0 && obj.Model.LineLinkStyle == 0 {
  278. c.Data["json"] = c.ResultError("接线方式不能为空")
  279. c.ServeJSON()
  280. return
  281. }
  282. if id == 0 && obj.Model.AreaType == 0 {
  283. c.Data["json"] = c.ResultError("间隔类型不能为空")
  284. c.ServeJSON()
  285. return
  286. }
  287. err := obj.Save()
  288. if err != nil {
  289. c.Data["json"] = c.ResultError(err.Error())
  290. c.ServeJSON()
  291. return
  292. }
  293. c.Data["json"] = c.ResultOK("", 0)
  294. c.ServeJSON()
  295. }
  296. // @Summary 复制并保存指定的内置检测模型为自定义模型
  297. // @Description 复制并保存指定的内置检测模型为自定义模型
  298. // @Tags 业务管理服务
  299. // @Accept x-www-form-urlencoded
  300. // @Produce json
  301. // @Param id formData int true "模型ID"
  302. // @Param newname formData string true "新模型名称"
  303. // @Success 200 {object} ResultOK 成功
  304. // @Failure 500 {object} ResultError 失败
  305. // @router /admin/sysmodel/saveas [post]
  306. func (c *BusAdminController) CopySysModelByID() {
  307. id, _ := c.GetInt("id")
  308. if id == 0 {
  309. c.Data["json"] = c.ResultError("id不能为空!")
  310. c.ServeJSON()
  311. return
  312. }
  313. new_name := c.GetString("newname")
  314. obj := new(bo.SysCheckModelMgr)
  315. obj.SetUserInfo(c.GetCurrentUserInfo())
  316. obj.Model = bo.T_data_model_defualt{Id: id}
  317. obj.Model.Id = id
  318. obj.Model.ModelName = new_name
  319. err, newid := obj.Copy(id)
  320. if err != nil {
  321. c.Data["json"] = c.ResultError(err.Error())
  322. c.ServeJSON()
  323. return
  324. }
  325. c.Data["json"] = c.ResultOK(newid, 0)
  326. c.ServeJSON()
  327. }
  328. // @Summary 删除指定的检测模型
  329. // @Description 删除指定的检测模型
  330. // @Tags 业务管理服务
  331. // @Accept x-www-form-urlencoded
  332. // @Produce json
  333. // @Param id formData int true "模型ID"
  334. // @Success 200 {object} ResultOK 成功
  335. // @Failure 500 {object} ResultError 失败
  336. // @router /admin/sysmodel/delete [post]
  337. func (c *BusAdminController) DeleteSysModelByID() {
  338. id, _ := c.GetInt("id")
  339. if id == 0 {
  340. c.Data["json"] = c.ResultError("id不能为空!")
  341. c.ServeJSON()
  342. return
  343. }
  344. obj := new(bo.SysCheckModelMgr)
  345. obj.SetUserInfo(c.GetCurrentUserInfo())
  346. obj.Model = bo.T_data_model_defualt{Id: id}
  347. obj.Model.Id = id
  348. err := obj.Delete()
  349. if err != nil {
  350. c.Data["json"] = c.ResultError(err.Error())
  351. c.ServeJSON()
  352. return
  353. }
  354. c.Data["json"] = c.ResultOK("", 0)
  355. c.ServeJSON()
  356. }
  357. // @Summary 更新检测模型指定装置的类型编码
  358. // @Description 更新检测模型指定装置的类型编码
  359. // @Tags 业务管理服务
  360. // @Accept x-www-form-urlencoded
  361. // @Produce json
  362. // @Param id formData int true "模型ID"
  363. // @Param old_iedtype formData string true "装置原编码"
  364. // @Param new_iedtype formData string true "装置新编码"
  365. // @Success 200 {object} ResultOK 成功
  366. // @Failure 500 {object} ResultError 失败
  367. // @router /admin/sysmodel/update/iedtype [post]
  368. func (c *BusAdminController) UPdateSysModelIedType() {
  369. id, _ := c.GetInt("id")
  370. if id == 0 {
  371. c.Data["json"] = c.ResultError("模型编号不能为空!")
  372. c.ServeJSON()
  373. return
  374. }
  375. oldtype := c.GetString("old_iedtype")
  376. newtype := c.GetString("new_iedtype")
  377. if oldtype == "" || newtype == "" {
  378. c.Data["json"] = c.ResultError("装置类型编码不能为空!")
  379. c.ServeJSON()
  380. return
  381. }
  382. obj := new(bo.SysCheckModelMgr)
  383. obj.SetUserInfo(c.GetCurrentUserInfo())
  384. obj.Model = bo.T_data_model_defualt{Id: id}
  385. err := obj.UpdateIedType(oldtype, newtype)
  386. if err != nil {
  387. c.Data["json"] = c.ResultError(err.Error())
  388. c.ServeJSON()
  389. return
  390. }
  391. c.Data["json"] = c.ResultOK("", 0)
  392. c.ServeJSON()
  393. }
  394. // @Summary 获取检测模型指定装置的自定义类型编码
  395. // @Description 获取检测模型指定装置的自定义类型编码
  396. // @Tags 业务管理服务
  397. // @Accept x-www-form-urlencoded
  398. // @Produce json
  399. // @Param id formData int true "模型ID"
  400. // @Param ied_type formData string true "装置原编码"
  401. // @Success 200 {object} ResultOK 成功
  402. // @Failure 500 {object} ResultError 失败
  403. // @router /admin/sysmodel/get/iedtype [get]
  404. func (c *BusAdminController) GetSysModelIedTypeMapping() {
  405. id, _ := c.GetInt("id")
  406. if id == 0 {
  407. c.Data["json"] = c.ResultError("模型编号不能为空!")
  408. c.ServeJSON()
  409. return
  410. }
  411. oldtype := c.GetString("ied_type")
  412. if oldtype == "" {
  413. c.Data["json"] = c.ResultError("装置类型编码不能为空!")
  414. c.ServeJSON()
  415. return
  416. }
  417. obj := new(bo.SysCheckModelMgr)
  418. obj.SetUserInfo(c.GetCurrentUserInfo())
  419. obj.Model = bo.T_data_model_defualt{Id: id}
  420. r := obj.GetIedtypeMapping(oldtype)
  421. c.Data["json"] = c.ResultOK(r, 0)
  422. c.ServeJSON()
  423. }
  424. // @Summary 查询检测模型列表
  425. // @Description 查询检测模型列表。支持名称、电压等级等过滤条件
  426. // @Tags 检测任务服务接口
  427. // @Accept x-www-form-urlencoded
  428. // @Produce json
  429. // @Param pageno query int true "当前页码。默认为1"
  430. // @Param pagesize query int true "每页显示数据数。默认为20"
  431. // @Param id query int false "ID"
  432. // @Param vol_id query int false "电压等级ID"
  433. // @Param model_name query string false "名称"
  434. // @Param line_link_style query int false "接线方式"
  435. // @Param area_type query int false "间隔类型"
  436. // @Param is_sys query int false "模型类型。1 内置模型 2 自定义模型"
  437. // @Success 200 {object} ResultOK 成功
  438. // @Failure 500 {object} ResultError 失败
  439. // @router /admin/sysmodel/list [get]
  440. func (c *BusAdminController) GetSysModelList() {
  441. obj := new(bo.SysCheckModelMgr)
  442. obj.SetUserInfo(c.GetCurrentUserInfo())
  443. obj.Model = bo.T_data_model_defualt{}
  444. obj.Model.Id, _ = c.GetInt("id")
  445. obj.Model.IsSys, _ = c.GetInt("is_sys", 1) //默认查询系统内置模型
  446. obj.Model.VolId, _ = c.GetInt("vol_id")
  447. obj.Model.ModelName = c.GetString("model_name")
  448. obj.Model.LineLinkStyle, _ = c.GetInt("line_link_style")
  449. obj.Model.AreaType, _ = c.GetInt("area_type")
  450. pi, _ := c.GetInt("pagesize", 20)
  451. po, _ := c.GetInt("pageno", 0)
  452. if po == 0 {
  453. po, _ = c.GetInt("pageindex", 0)
  454. }
  455. if po == 0 {
  456. po = 1
  457. }
  458. lst, cnt, err := obj.List(po, pi)
  459. if err != nil {
  460. c.Data["json"] = c.ResultError(err.Error())
  461. c.ServeJSON()
  462. return
  463. }
  464. //如果是获取指定模型信息时,附加模型的标准装置类型信息
  465. if obj.Model.Id > 0 {
  466. //间隔类型id
  467. syscode := new(bo.Global)
  468. codeinfo := syscode.GetCodeInfoByID(tools.IsEmpty(lst[0]["area_type"]))
  469. if codeinfo != nil {
  470. code := "area_type_" + tools.IsEmpty(codeinfo["code"])
  471. codeinfo = syscode.GetCodeInfoByCode("area_ied_type", code)
  472. codes := strings.Split(tools.IsEmpty(codeinfo["name"]), ",")
  473. ccrows := []orm.Params{}
  474. for _, item := range codes {
  475. tmp := syscode.GetCodeInfoByCode("ied_type", item)
  476. if tmp == nil {
  477. ccrows = append(ccrows, orm.Params{"code": item, "name": item})
  478. } else {
  479. ccrows = append(ccrows, tmp)
  480. }
  481. }
  482. lst[0]["ied_type"] = ccrows
  483. }
  484. }
  485. c.Data["json"] = c.ResultOK(lst, cnt)
  486. c.ServeJSON()
  487. }
  488. // @Summary 重新分析指定的SCD检测模型间隔
  489. // @Description 重新分析指定的SCD检测模型间隔
  490. // @Tags 业务管理服务
  491. // @Accept x-www-form-urlencoded
  492. // @Produce json
  493. // @Param scd_id formData int true "SCD文件ID"
  494. // @Success 200 {object} ResultOK 成功
  495. // @Failure 500 {object} ResultError 失败
  496. // @router /admin/parse/check_area [post]
  497. func (c *BusAdminController) ResetCheckAreaByID() {
  498. id, _ := c.GetInt64("scd_id")
  499. if id == 0 {
  500. c.Data["json"] = c.ResultError("SCD文件ID不能为空!")
  501. c.ServeJSON()
  502. return
  503. }
  504. obj := new(bo.CheckAreaMgr)
  505. obj.SetUserInfo(c.GetCurrentUserInfo())
  506. obj.ScdId = id
  507. err := obj.Reset()
  508. if err != nil {
  509. c.Data["json"] = c.ResultError(err.Error())
  510. c.ServeJSON()
  511. return
  512. }
  513. c.Data["json"] = c.ResultOK("", 0)
  514. c.ServeJSON()
  515. }
  516. // @Summary 查询指定电压等级及接线方式下的检测间隔分析结果
  517. // @Description 查询指定电压等级及接线方式下的检测间隔分析结果
  518. // @Tags 业务管理服务
  519. // @Accept x-www-form-urlencoded
  520. // @Produce json
  521. // @Param scd_id formData int true "SCD文件ID"
  522. // @Param vol_id formData int false "电压等级ID"
  523. // @Param link_style_id formData int false "接线方式ID"
  524. // @Success 200 {object} ResultOK 成功
  525. // @Failure 500 {object} ResultError 失败
  526. // @router /admin/get/check_area [get]
  527. func (c *BusAdminController) GetCheckAreaByVolID() {
  528. id, _ := c.GetInt64("scd_id")
  529. if id == 0 {
  530. c.Data["json"] = c.ResultError("SCD文件ID不能为空!")
  531. c.ServeJSON()
  532. return
  533. }
  534. volid, _ := c.GetInt("vol_id")
  535. lsid, _ := c.GetInt("link_style_id")
  536. obj := new(bo.CheckAreaMgr)
  537. obj.SetUserInfo(c.GetCurrentUserInfo())
  538. obj.ScdId = id
  539. lst, err := obj.GetAreaListByVol(id, volid, lsid)
  540. if err != nil {
  541. c.Data["json"] = c.ResultError(err.Error())
  542. c.ServeJSON()
  543. return
  544. }
  545. if lst == nil || len(lst) == 0 {
  546. //新分析
  547. err = obj.Reset()
  548. if err != nil {
  549. c.Data["json"] = c.ResultError(err.Error())
  550. c.ServeJSON()
  551. return
  552. }
  553. lst, _ = obj.GetAreaListByVol(id, volid, lsid)
  554. }
  555. c.Data["json"] = c.ResultOK(lst, 0)
  556. c.ServeJSON()
  557. }
  558. // @Summary 查询指定检测间隔下的IED装置列表
  559. // @Description 查询指定检测间隔下的IED装置列表
  560. // @Tags 业务管理服务
  561. // @Accept x-www-form-urlencoded
  562. // @Produce json
  563. // @Param scd_id formData int true "SCD文件ID"
  564. // @Param area_id formData int true "检测间隔ID"
  565. // @Success 200 {object} ResultOK 成功
  566. // @Failure 500 {object} ResultError 失败
  567. // @router /admin/get/check_area/ied [get]
  568. func (c *BusAdminController) GetCheckAreaIedByAreaID() {
  569. id, _ := c.GetInt64("scd_id")
  570. if id == 0 {
  571. c.Data["json"] = c.ResultError("SCD文件ID不能为空!")
  572. c.ServeJSON()
  573. return
  574. }
  575. area_id, _ := c.GetInt("area_id")
  576. obj := new(bo.CheckAreaMgr)
  577. obj.SetUserInfo(c.GetCurrentUserInfo())
  578. obj.ScdId = id
  579. lst, err := obj.GetIedList(id, area_id)
  580. if err != nil {
  581. c.Data["json"] = c.ResultError(err.Error())
  582. c.ServeJSON()
  583. return
  584. }
  585. c.Data["json"] = c.ResultOK(lst, 0)
  586. c.ServeJSON()
  587. }
  588. // @Summary 修改并保存指定检测间隔下的IED装置列表
  589. // @Description 修改并保存指定检测间隔下的IED装置列表
  590. // @Tags 业务管理服务
  591. // @Accept x-www-form-urlencoded
  592. // @Produce json
  593. // @Param scd_id formData int true "SCD文件ID"
  594. // @Param area_id formData int true "检测间隔ID"
  595. // @Param ied_ids formData string true "IED装置name列表,多个ied采用逗号分隔。如:PT1001,PL1001,..."
  596. // @Success 200 {object} ResultOK 成功
  597. // @Failure 500 {object} ResultError 失败
  598. // @router /admin/update/check_area/ied [post]
  599. func (c *BusAdminController) SaveCheckAreaIedByAreaID() {
  600. id, _ := c.GetInt64("scd_id")
  601. if id == 0 {
  602. c.Data["json"] = c.ResultError("SCD文件ID不能为空!")
  603. c.ServeJSON()
  604. return
  605. }
  606. area_id, _ := c.GetInt("area_id")
  607. ieds := c.GetString("ied_ids")
  608. if area_id == 0 {
  609. c.Data["json"] = c.ResultError("检测间隔ID不能为空!")
  610. c.ServeJSON()
  611. return
  612. }
  613. if ieds == "" {
  614. c.Data["json"] = c.ResultError("检测间隔装置列表不能为空!")
  615. c.ServeJSON()
  616. return
  617. }
  618. obj := new(bo.CheckAreaMgr)
  619. obj.SetUserInfo(c.GetCurrentUserInfo())
  620. obj.ScdId = id
  621. err := obj.UpdateIeds(id, area_id, ieds)
  622. if err != nil {
  623. c.Data["json"] = c.ResultError(err.Error())
  624. c.ServeJSON()
  625. return
  626. }
  627. c.Data["json"] = c.ResultOK("", 0)
  628. c.ServeJSON()
  629. }
  630. // @Summary 获取指定模型和装置类型的功能列表
  631. // @Description 获取指定模型和装置类型的功能列表
  632. // @Tags 业务管理服务
  633. // @Accept x-www-form-urlencoded
  634. // @Produce json
  635. // @Param model_id formData int true "模型ID"
  636. // @Param ied_type formData string true "装置类型"
  637. // @Success 200 {object} ResultOK 成功
  638. // @Failure 500 {object} ResultError 失败
  639. // @router /admin/model/function/list [get]
  640. func (c *BusAdminController) GetFuncListByIedType() {
  641. modelid, _ := c.GetInt("model_id")
  642. if modelid == 0 {
  643. c.Data["json"] = c.ResultError("模型ID不能为空!")
  644. c.ServeJSON()
  645. return
  646. }
  647. ied_type := c.GetString("ied_type")
  648. if ied_type == "" {
  649. c.Data["json"] = c.ResultError("装置类型不能为空!")
  650. c.ServeJSON()
  651. return
  652. }
  653. obj := new(bo.SysCheckModelIedFuncMgr)
  654. obj.SetUserInfo(c.GetCurrentUserInfo())
  655. lst, err := obj.GetList(modelid, ied_type)
  656. if err != nil {
  657. c.Data["json"] = c.ResultError(err.Error())
  658. c.ServeJSON()
  659. return
  660. }
  661. c.Data["json"] = c.ResultOK(lst, 0)
  662. c.ServeJSON()
  663. }
  664. // @Summary 获取指定模型和装置类型的端子列表
  665. // @Description 获取指定模型和装置类型的端子列表
  666. // @Tags 业务管理服务
  667. // @Accept x-www-form-urlencoded
  668. // @Produce json
  669. // @Param model_id formData int true "模型ID"
  670. // @Param ied_type formData string true "查询的装置类型"
  671. // @Param ref_ied_type formData string true "对侧关联装置类型"
  672. // @Param sv_or_goose formData string true "信号类型。仅支持:SV或GOOSE"
  673. // @Param in_or_out formData string true "信号方向。仅支持:'输出'或'接收'"
  674. // @Success 200 {object} ResultOK 成功
  675. // @Failure 500 {object} ResultError 失败
  676. // @router /admin/model/function/fcda/list [get]
  677. func (c *BusAdminController) GetFuncFcdaList() {
  678. modelid, _ := c.GetInt("model_id")
  679. if modelid == 0 {
  680. c.Data["json"] = c.ResultError("模型ID不能为空!")
  681. c.ServeJSON()
  682. return
  683. }
  684. ied_type := c.GetString("ied_type")
  685. if ied_type == "" {
  686. c.Data["json"] = c.ResultError("查询的装置类型不能为空!")
  687. c.ServeJSON()
  688. return
  689. }
  690. ref_ied_type := c.GetString("ref_ied_type")
  691. if ied_type == "" {
  692. c.Data["json"] = c.ResultError("对侧关联装置类型不能为空!")
  693. c.ServeJSON()
  694. return
  695. }
  696. obj := new(bo.SysCheckModelIedFuncMgr)
  697. obj.SetUserInfo(c.GetCurrentUserInfo())
  698. lst, err := obj.GetList(modelid, ied_type)
  699. if err != nil {
  700. c.Data["json"] = c.ResultError(err.Error())
  701. c.ServeJSON()
  702. return
  703. }
  704. if len(lst) == 0 {
  705. c.Data["json"] = c.ResultOK("", 0)
  706. c.ServeJSON()
  707. return
  708. }
  709. funcids := []string{}
  710. for _, row := range lst {
  711. funcids = append(funcids, tools.IsEmpty(row["id"]))
  712. }
  713. fcdaMgr := new(bo.SysCheckModelIedFuncFcdaMgr)
  714. fcdaMgr.Model = bo.T_data_model_func_fcda{}
  715. fcdaMgr.Model.ModelId = modelid
  716. fcdaMgr.Model.Svorgoose = strings.ToUpper(c.GetString("sv_or_goose"))
  717. fcdaMgr.Model.Inorout = c.GetString("in_or_out")
  718. fcdaList, err := fcdaMgr.GetList(ref_ied_type, funcids)
  719. if err != nil {
  720. c.Data["json"] = c.ResultError(err.Error())
  721. c.ServeJSON()
  722. return
  723. }
  724. c.Data["json"] = c.ResultOK(fcdaList, len(fcdaList))
  725. c.ServeJSON()
  726. }
  727. // @Summary 保存模型装置功能及端子信息
  728. // @Description 保存装置功能及端子信息
  729. // @Tags 业务管理服务
  730. // @Accept x-www-form-urlencoded
  731. // @Produce json
  732. // @Param model_id formData int true "模型ID"
  733. // @Param ied_type formData string true "装置类型代码"
  734. // @Param func_id formData int false "功能ID。编辑时必传。"
  735. // @Param func_name formData string true "功能名称。必传。"
  736. // @Param fcda_id formData int false "端子ID。编辑时必传。"
  737. // @Param fcda_name formData string true "端子名称。必传。"
  738. // @Param fcda_match_exp formData string true "端子匹配表达式。必传。"
  739. // @Param sv_or_goose formData string true "端子信号类型。必传。仅支持SV或GOOSE"
  740. // @Param in_or_out formData string true "端子信号输入输出方向。必传。仅支持中文的'接收'或'输出'"
  741. // @Success 200 {object} ResultOK 成功
  742. // @Failure 500 {object} ResultError 失败
  743. // @router /admin/model/function/fcda/save [post]
  744. func (c *BusAdminController) SaveFuncFcda() {
  745. modelid, _ := c.GetInt("model_id")
  746. if modelid == 0 {
  747. c.Data["json"] = c.ResultError("模型ID不能为空!")
  748. c.ServeJSON()
  749. return
  750. }
  751. ied_type := c.GetString("ied_type")
  752. func_name := c.GetString("func_name")
  753. fcda_name := c.GetString("fcda_name")
  754. fcda_match_exp := c.GetString("fcda_match_exp")
  755. func_id, _ := c.GetInt("func_id")
  756. fcda_id, _ := c.GetInt("fcda_id")
  757. svorgoose := c.GetString("sv_or_goose")
  758. inorout := c.GetString("in_or_out")
  759. if func_name == "" {
  760. c.Data["json"] = c.ResultError("功能名称不能为空!")
  761. c.ServeJSON()
  762. return
  763. }
  764. if fcda_name == "" {
  765. c.Data["json"] = c.ResultError("端子设计名称不能为空!")
  766. c.ServeJSON()
  767. return
  768. }
  769. if fcda_match_exp == "" {
  770. c.Data["json"] = c.ResultError("端子匹配关键词不能为空!")
  771. c.ServeJSON()
  772. return
  773. }
  774. if svorgoose == "" {
  775. c.Data["json"] = c.ResultError("端子信号类型不能为空!")
  776. c.ServeJSON()
  777. return
  778. }
  779. if inorout == "" {
  780. c.Data["json"] = c.ResultError("端子信号方向不能为空!")
  781. c.ServeJSON()
  782. return
  783. }
  784. mod := bo.T_data_model_func_def{}
  785. mod.Id = func_id
  786. mod.ModelId = modelid
  787. mod.IedType = ied_type
  788. mod.FuncFcdaId = fcda_id
  789. mod.FuncName = func_name
  790. mod.FcdaName = fcda_name
  791. mod.FcdaMatchExp = fcda_match_exp
  792. mod.Svorgoose = svorgoose
  793. mod.Inorout = inorout
  794. mgr := new(bo.SysCheckModelIedFuncMgr)
  795. mgr.SetUserInfo(c.GetCurrentUserInfo())
  796. mgr.Model = mod
  797. _, _, err := mgr.Save()
  798. if err != nil {
  799. c.Data["json"] = c.ResultError(err.Error())
  800. c.ServeJSON()
  801. return
  802. }
  803. c.Data["json"] = c.ResultOK("", 0)
  804. c.ServeJSON()
  805. }
  806. // @Summary 删除指定模型所有的装置端子
  807. // @Description 删除指定模型所有的装置端子
  808. // @Tags 业务管理服务
  809. // @Accept x-www-form-urlencoded
  810. // @Produce json
  811. // @Param model_id formData int true "模型ID"
  812. // @Success 200 {object} ResultOK 成功
  813. // @Failure 500 {object} ResultError 失败
  814. // @router /admin/model/fcda/delall [post]
  815. func (c *BusAdminController) DelAllFuncFcda() {
  816. modelid, _ := c.GetInt("model_id")
  817. if modelid == 0 {
  818. c.Data["json"] = c.ResultError("模型ID不能为空!")
  819. c.ServeJSON()
  820. return
  821. }
  822. fcdaMgr := new(bo.SysCheckModelIedFuncMgr)
  823. fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
  824. fcdaMgr.Model = bo.T_data_model_func_def{}
  825. fcdaMgr.Model.ModelId = modelid
  826. err := fcdaMgr.Delete()
  827. if err != nil {
  828. c.Data["json"] = c.ResultError(err.Error())
  829. c.ServeJSON()
  830. return
  831. }
  832. c.Data["json"] = c.ResultOK("", 0)
  833. c.ServeJSON()
  834. }
  835. // @Summary 删除装置端子
  836. // @Description 删除装置端子
  837. // @Tags 业务管理服务
  838. // @Accept x-www-form-urlencoded
  839. // @Produce json
  840. // @Param model_id formData int true "模型ID"
  841. // @Param fcda_id formData int true "端子ID"
  842. // @Success 200 {object} ResultOK 成功
  843. // @Failure 500 {object} ResultError 失败
  844. // @router /admin/model/function/fcda/del [post]
  845. func (c *BusAdminController) DelFuncFcda() {
  846. modelid, _ := c.GetInt("model_id")
  847. if modelid == 0 {
  848. c.Data["json"] = c.ResultError("模型ID不能为空!")
  849. c.ServeJSON()
  850. return
  851. }
  852. fcda_id, _ := c.GetInt("fcda_id")
  853. if fcda_id == 0 {
  854. c.Data["json"] = c.ResultError("端子ID不能为空!")
  855. c.ServeJSON()
  856. return
  857. }
  858. fcdaMgr := new(bo.SysCheckModelIedFuncFcdaMgr)
  859. fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
  860. fcdaMgr.Model = bo.T_data_model_func_fcda{}
  861. fcdaMgr.Model.ModelId = modelid
  862. fcdaMgr.Model.Id = fcda_id
  863. err := fcdaMgr.Delete()
  864. if err != nil {
  865. c.Data["json"] = c.ResultError(err.Error())
  866. c.ServeJSON()
  867. return
  868. }
  869. c.Data["json"] = c.ResultOK("", 0)
  870. c.ServeJSON()
  871. }
  872. // @Summary 获取模型装置端子已关联的接收端子
  873. // @Description 获取模型装置端子已关联的接收端子
  874. // @Tags 业务管理服务
  875. // @Accept x-www-form-urlencoded
  876. // @Produce json
  877. // @Param model_id formData int true "模型ID"
  878. // @Param from_fcda_id formData int true "输出装置端子ID"
  879. // @Param to_ied_type formData string false "输入装置类型"
  880. // @Param goosesv formData string false "信号类型。GOOSE|SV"
  881. // @Success 200 {object} ResultOK 成功
  882. // @Failure 500 {object} ResultError 失败
  883. // @router /admin/model/function/fcda-ref/list [get]
  884. func (c *BusAdminController) GetFuncFcdaRef() {
  885. modelid, _ := c.GetInt("model_id")
  886. if modelid == 0 {
  887. c.Data["json"] = c.ResultError("模型ID不能为空!")
  888. c.ServeJSON()
  889. return
  890. }
  891. fcda_id, _ := c.GetInt("from_fcda_id")
  892. if fcda_id == 0 {
  893. c.Data["json"] = c.ResultError("输出装置端子ID不能为空!")
  894. c.ServeJSON()
  895. return
  896. }
  897. fcdaMgr := new(bo.SysCheckModelFcdaRalationMgr)
  898. fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
  899. fcdaMgr.Model = bo.T_data_model_fcda_ref{}
  900. fcdaMgr.Model.ModelId = modelid
  901. fcdaMgr.Model.FromFcdaId = fcda_id
  902. fcdaMgr.Model.ToIedCode = c.GetString("to_ied_type")
  903. fcdaMgr.Model.Goosesv = c.GetString("goosesv")
  904. lst, err := fcdaMgr.GetList()
  905. if err != nil {
  906. c.Data["json"] = c.ResultError(err.Error())
  907. c.ServeJSON()
  908. return
  909. }
  910. c.Data["json"] = c.ResultOK(lst, len(lst))
  911. c.ServeJSON()
  912. }
  913. // @Summary 保存模型装置端子间关联关系
  914. // @Description 保存模型装置端子间关联关系
  915. // @Tags 业务管理服务
  916. // @Accept x-www-form-urlencoded
  917. // @Produce json
  918. // @Param model_id formData int true "模型ID"
  919. // @Param from_ied_type formData string true "输出装置类型"
  920. // @Param to_ied_type formData string true "输入装置类型"
  921. // @Param from_fcda_id formData int false "输出装置端子ID"
  922. // @Param to_fcda_ids formData string false "输入装置端子ID"
  923. // @Param batch_fcda_ids formData json-string true "批量保存端子关系。类型为序列化的二维数组字符串。数组元素为:[[fromfcdaid,tofcdaid],...]"
  924. // @Param goosesv formData string true "信号类型。值范围:GOOSE|SV"
  925. // @Success 200 {object} ResultOK 成功
  926. // @Failure 500 {object} ResultError 失败
  927. // @router /admin/model/function/fcda-ref/save [post]
  928. func (c *BusAdminController) SaveFuncFcdaRef() {
  929. modelid, _ := c.GetInt("model_id")
  930. if modelid == 0 {
  931. c.Data["json"] = c.ResultError("模型ID不能为空!")
  932. c.ServeJSON()
  933. return
  934. }
  935. fcda_id, _ := c.GetInt("from_fcda_id")
  936. if fcda_id == 0 {
  937. c.Data["json"] = c.ResultError("输出装置端子ID不能为空!")
  938. c.ServeJSON()
  939. return
  940. }
  941. fcda_in_ids := c.GetString("to_fcda_ids")
  942. fcdaMgr := new(bo.SysCheckModelFcdaRalationMgr)
  943. fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
  944. fcdaMgr.Model = bo.T_data_model_fcda_ref{}
  945. fcdaMgr.Model.ModelId = modelid
  946. fcdaMgr.Model.FromFcdaId = fcda_id
  947. fcdaMgr.Model.FromIedCode = c.GetString("from_ied_type")
  948. fcdaMgr.Model.ToIedCode = c.GetString("to_ied_type")
  949. fcdaMgr.Model.Goosesv = strings.ToUpper(c.GetString("goosesv"))
  950. if fcdaMgr.Model.FromIedCode == "" || fcdaMgr.Model.ToIedCode == "" {
  951. c.Data["json"] = c.ResultError("输入和输出装置类型不能为空!")
  952. c.ServeJSON()
  953. return
  954. }
  955. if fcdaMgr.Model.Goosesv == "" {
  956. c.Data["json"] = c.ResultError("信号类型不能为空!")
  957. c.ServeJSON()
  958. return
  959. }
  960. if fcdaMgr.Model.Goosesv != "GOOSE" && fcdaMgr.Model.Goosesv != "SV" {
  961. c.Data["json"] = c.ResultError("信号类型不正确。只能为GOOSE或SV")
  962. c.ServeJSON()
  963. return
  964. }
  965. batch_fcda_ids := c.GetString("batch_fcda_ids")
  966. if batch_fcda_ids != "" {
  967. //批量保存
  968. fcdalist := [][]int{}
  969. err := json.Unmarshal([]byte(batch_fcda_ids), &fcdalist)
  970. if err != nil {
  971. c.Data["json"] = c.ResultError("无效的批量端子关系数据")
  972. c.ServeJSON()
  973. return
  974. }
  975. obj := new(bo.SysCheckModelIedFuncFcdaMgr)
  976. for _, item := range fcdalist {
  977. fcdainf, err := obj.One(item[0])
  978. if err != nil {
  979. c.Data["json"] = c.ResultError(fmt.Sprintf("无效的端子ID:%d", item[0]))
  980. c.ServeJSON()
  981. return
  982. }
  983. fcdaMgr.Model.FromFuncId = fcdainf.FuncId
  984. fcdaMgr.Model.FromFcdaId = item[0]
  985. fcdainf, err = obj.One(item[1])
  986. if err != nil {
  987. c.Data["json"] = c.ResultError(fmt.Sprintf("无效的端子ID:%d", item[1]))
  988. c.ServeJSON()
  989. return
  990. }
  991. fcdaMgr.Model.ToFcdaId = item[1]
  992. fcdaMgr.Model.ToFuncId = fcdainf.FuncId
  993. err = fcdaMgr.Save()
  994. if err != nil {
  995. c.Data["json"] = c.ResultError(err.Error())
  996. c.ServeJSON()
  997. return
  998. }
  999. }
  1000. c.Data["json"] = c.ResultOK("", 0)
  1001. c.ServeJSON()
  1002. return
  1003. }
  1004. obj := new(bo.SysCheckModelIedFuncFcdaMgr)
  1005. fcdainf, er := obj.One(fcdaMgr.Model.FromFcdaId)
  1006. if er != nil {
  1007. c.Data["json"] = c.ResultError("无效的输出端子ID")
  1008. c.ServeJSON()
  1009. return
  1010. }
  1011. fcdaMgr.Model.FromFuncId = fcdainf.FuncId
  1012. //清除输出端子的原关系
  1013. err := fcdaMgr.Delete()
  1014. if err != nil {
  1015. c.Data["json"] = c.ResultError(err.Error())
  1016. c.ServeJSON()
  1017. return
  1018. }
  1019. if fcda_in_ids != "" {
  1020. fcda_in_ids_1 := strings.Split(fcda_in_ids, ",")
  1021. for _, k := range fcda_in_ids_1 {
  1022. fcdaMgr.Model.ToFcdaId, _ = strconv.Atoi(k) //设置接收端子id
  1023. fcdainf, er = obj.One(fcdaMgr.Model.ToFcdaId)
  1024. if er != nil {
  1025. c.Data["json"] = c.ResultError("无效的接收端子ID")
  1026. c.ServeJSON()
  1027. return
  1028. }
  1029. //清除接收端子的原关系
  1030. fcdaMgr.Model.FromFcdaId = 0
  1031. fcdaMgr.Delete()
  1032. fcdaMgr.Model.ToFuncId = fcdainf.FuncId
  1033. //建立新的端子关系
  1034. fcdaMgr.Model.FromFcdaId = fcda_id //还原输出端子id
  1035. err := fcdaMgr.Save()
  1036. if err != nil {
  1037. c.Data["json"] = c.ResultError(err.Error())
  1038. c.ServeJSON()
  1039. return
  1040. }
  1041. }
  1042. }
  1043. c.Data["json"] = c.ResultOK("", 0)
  1044. c.ServeJSON()
  1045. }
  1046. // @Summary 删除端子之间的关联关系
  1047. // @Description 删除端子之间的关联关系
  1048. // @Tags 业务管理服务
  1049. // @Accept x-www-form-urlencoded
  1050. // @Produce json
  1051. // @Param model_id formData int true "模型ID"
  1052. // @Param from_fcda_id formData int true "输入端子ID"
  1053. // @Param to_fcda_id formData int true "输出端子ID"
  1054. // @Success 200 {object} ResultOK 成功
  1055. // @Failure 500 {object} ResultError 失败
  1056. // @router /admin/model/function/fcda-ref/del [post]
  1057. func (c *BusAdminController) DelFuncFcdaRef() {
  1058. fcdaMgr := new(bo.SysCheckModelFcdaRalationMgr)
  1059. fcdaMgr.SetUserInfo(c.GetCurrentUserInfo())
  1060. fcdaMgr.Model = bo.T_data_model_fcda_ref{}
  1061. fcdaMgr.Model.ModelId, _ = c.GetInt("model_id", 0)
  1062. fcdaMgr.Model.FromFcdaId, _ = c.GetInt("from_fcda_id", 0)
  1063. fcdaMgr.Model.ToFcdaId, _ = c.GetInt("to_fcda_id")
  1064. if fcdaMgr.Model.ModelId == 0 {
  1065. c.Data["json"] = c.ResultError("模型ID不能为空!")
  1066. c.ServeJSON()
  1067. return
  1068. }
  1069. if fcdaMgr.Model.FromFcdaId == 0 {
  1070. c.Data["json"] = c.ResultError("输入端子ID不能为空!")
  1071. c.ServeJSON()
  1072. return
  1073. }
  1074. if fcdaMgr.Model.ToFcdaId == 0 {
  1075. c.Data["json"] = c.ResultError("接收端子ID不能为空")
  1076. c.ServeJSON()
  1077. return
  1078. }
  1079. //清除原关系
  1080. err := fcdaMgr.Delete()
  1081. if err != nil {
  1082. c.Data["json"] = c.ResultError(err.Error())
  1083. c.ServeJSON()
  1084. return
  1085. }
  1086. c.Data["json"] = c.ResultOK("", 0)
  1087. c.ServeJSON()
  1088. }