rcvr.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package impl
  4. import (
  5. "context"
  6. "smart-site-management/impl/v1/alarm"
  7. "smart-site-management/impl/v1/dust"
  8. "smart-site-management/impl/v1/staff"
  9. "smart-site-management/impl/v1/vehicle"
  10. "smart-site-management/impl/v1/tower"
  11. "smart-site-management/pb"
  12. "smart-site-management/pb/v1"
  13. "smart-site-management/impl/v1/camera"
  14. "smart-site-management/impl/v1/project"
  15. "smart-site-management/impl/v1/user"
  16. "github.com/jaryhe/gopkgs/tasker/rpctasker"
  17. "google.golang.org/grpc"
  18. )
  19. // 具体实现
  20. type Rcvr struct {
  21. }
  22. func Register(s *grpc.Server) {
  23. pb.RegisterSmartSiteProjectServer(s, &Rcvr{})
  24. }
  25. // 修改密码
  26. func (c *Rcvr) ChangePasswd(ctx context.Context, req *v1.ChangePasswdRequest) (reply *v1.ChangePasswdReply, err error) {
  27. t1 := func() error {
  28. reply, err = user.ChangePasswd(ctx, req)
  29. return err
  30. }
  31. return reply, rpctasker.Exec(ctx, t1)
  32. }
  33. func (c *Rcvr) EmailUpdate(ctx context.Context, req *v1.EmailUpdateRequest) (reply *v1.EmailUpdateReply, err error) {
  34. t1 := func() error {
  35. reply, err = user.EmailUpdate(ctx, req)
  36. return err
  37. }
  38. return reply, rpctasker.Exec(ctx, t1)
  39. }
  40. func (c *Rcvr) EmailPrepare(ctx context.Context, req *v1.EmailPrepareRequest) (reply *v1.EmailPrepareReply, err error) {
  41. t1 := func() error {
  42. reply, err = user.EmailPrepare(ctx, req)
  43. return err
  44. }
  45. return reply, rpctasker.Exec(ctx, t1)
  46. }
  47. func (c *Rcvr) PhoneUpdate(ctx context.Context, req *v1.PhoneUpdateRequest) (reply *v1.PhoneUpdateReply, err error) {
  48. t1 := func() error {
  49. reply, err = user.PhoneUpdate(ctx, req)
  50. return err
  51. }
  52. return reply, rpctasker.Exec(ctx, t1)
  53. }
  54. func (c *Rcvr) UserInfo(ctx context.Context, req *v1.UserInfoRequest) (reply *v1.UserInfoReply, err error) {
  55. t1 := func() error {
  56. reply, err = user.UserInfo(ctx, req)
  57. return err
  58. }
  59. return reply, rpctasker.Exec(ctx, t1)
  60. }
  61. func (c *Rcvr) Login(ctx context.Context, req *v1.LoginRequest) (reply *v1.LoginReply, err error) {
  62. t1 := func() error {
  63. reply, err = user.Login(ctx, req)
  64. return err
  65. }
  66. return reply, rpctasker.Exec(ctx, t1)
  67. }
  68. // 项目变更申请
  69. func (c *Rcvr) ProjectChange(ctx context.Context, req *v1.ProjectChangeRequest) (reply *v1.ProjectChangeReply, err error) {
  70. t1 := func() error {
  71. reply, err = project.ProjectChange(ctx, req)
  72. return err
  73. }
  74. return reply, rpctasker.Exec(ctx, t1)
  75. }
  76. // 设置工程平面图或效果图
  77. func (c *Rcvr) ProjectSetPic(ctx context.Context, req *v1.ProjectSetPicRequest) (reply *v1.ProjectSetPicReply, err error) {
  78. t1 := func() error {
  79. reply, err = project.ProjectSetPic(ctx, req)
  80. return err
  81. }
  82. return reply, rpctasker.Exec(ctx, t1)
  83. }
  84. // 修改工程名或地址,不需审批
  85. func (c *Rcvr) ProjectUpdate(ctx context.Context, req *v1.ProjectUpdateRequest) (reply *v1.ProjectUpdateReply, err error) {
  86. t1 := func() error {
  87. reply, err = project.ProjectUpdate(ctx, req)
  88. return err
  89. }
  90. return reply, rpctasker.Exec(ctx, t1)
  91. }
  92. // 获取项目变更所需的原始字段和value信息
  93. func (c *Rcvr) ProjectInfoForChange(ctx context.Context, req *v1.ProjectInfoForChangeRequest) (reply *v1.ProjectInfoForChangeReply, err error) {
  94. t1 := func() error {
  95. reply, err = project.ProjectInfoForChange(ctx, req)
  96. return err
  97. }
  98. return reply, rpctasker.Exec(ctx, t1)
  99. }
  100. // 项目变更工单列表
  101. func (c *Rcvr) ProjectChangeInfoList(ctx context.Context, req *v1.ProjectChangeInfoListRequest) (reply *v1.ProjectChangeInfoListReply, err error) {
  102. t1 := func() error {
  103. reply, err = project.ProjectChangeInfoList(ctx, req)
  104. return err
  105. }
  106. return reply, rpctasker.Exec(ctx, t1)
  107. }
  108. // 设备列表
  109. func (c *Rcvr) DeviceList(ctx context.Context, req *v1.DeviceListRequest) (reply *v1.DeviceListReply, err error) {
  110. t1 := func() error {
  111. reply, err = project.DeviceList(ctx, req)
  112. return err
  113. }
  114. return reply, rpctasker.Exec(ctx, t1)
  115. }
  116. // 获取设备绑定的摄像头
  117. func (c *Rcvr) DeviceVideoChannel(ctx context.Context, req *v1.DeviceVideoChannelRequest) (reply *v1.DeviceVideoChannelReply, err error) {
  118. t1 := func() error {
  119. reply, err = project.DeviceVideoChannel(ctx, req)
  120. return err
  121. }
  122. return reply, rpctasker.Exec(ctx, t1)
  123. }
  124. func (c *Rcvr) ChannelUpdate(ctx context.Context, req *v1.ChannelUpdateRequest) (reply *v1.ChannelUpdateReply, err error) {
  125. t1 := func() error {
  126. reply, err = camera.ChannelUpdate(ctx, req)
  127. return err
  128. }
  129. return reply, rpctasker.Exec(ctx, t1)
  130. }
  131. // 视频设备列表
  132. func (c *Rcvr) VedioList(ctx context.Context, req *v1.VedioListRequest) (reply *v1.VedioListReply, err error) {
  133. t1 := func() error {
  134. reply, err = camera.VedioList(ctx, req)
  135. return err
  136. }
  137. return reply, rpctasker.Exec(ctx, t1)
  138. }
  139. // 运渣车辆列表
  140. func (c *Rcvr) VehicleList(ctx context.Context, req *v1.VehicleListRequest) (reply *v1.VehicleListReply, err error) {
  141. t1 := func() error {
  142. reply, err = vehicle.VehicleList(ctx, req)
  143. return err
  144. }
  145. return reply, rpctasker.Exec(ctx, t1)
  146. }
  147. // 获取实时播放地址
  148. func (c *Rcvr) RealPlay(ctx context.Context, req *v1.RealPlayRequest) (reply *v1.RealPlayReply, err error) {
  149. t1 := func() error {
  150. reply, err = camera.RealPlay(ctx, req)
  151. return err
  152. }
  153. return reply, rpctasker.Exec(ctx, t1)
  154. }
  155. func (c *Rcvr) Ptz(ctx context.Context, req *v1.PtzRequest) (reply *v1.PtzReply, err error) {
  156. t1 := func() error {
  157. reply, err = camera.Ptz(ctx, req)
  158. return err
  159. }
  160. return reply, rpctasker.Exec(ctx, t1)
  161. }
  162. func (c *Rcvr) VedioPing(ctx context.Context, req *v1.VedioPingRequest) (reply *v1.VedioPingReply, err error) {
  163. t1 := func() error {
  164. reply, err = camera.VedioPing(ctx, req)
  165. return err
  166. }
  167. return reply, rpctasker.Exec(ctx, t1)
  168. }
  169. // 最近一次考勤数据
  170. func (c *Rcvr) LatestStaffData(ctx context.Context, req *v1.LatestStaffDataRequest) (reply *v1.LatestStaffDataReply, err error) {
  171. t1 := func() error {
  172. reply, err = staff.LatestStaffData(ctx, req)
  173. return err
  174. }
  175. return reply, rpctasker.Exec(ctx, t1)
  176. }
  177. func (c *Rcvr) StaffList(ctx context.Context, req *v1.StaffListRequest) (reply *v1.StaffListReply, err error) {
  178. t1 := func() error {
  179. reply, err = staff.StaffList(ctx, req)
  180. return err
  181. }
  182. return reply, rpctasker.Exec(ctx, t1)
  183. }
  184. func (c *Rcvr) StaffAttendance(ctx context.Context, req *v1.StaffAttendanceRequest) (reply *v1.StaffAttendanceReply, err error) {
  185. t1 := func() error {
  186. reply, err = staff.StaffAttendance(ctx, req)
  187. return err
  188. }
  189. return reply, rpctasker.Exec(ctx, t1)
  190. }
  191. // 按工种进行考勤统计
  192. func (c *Rcvr) StaffWorkTypeStatistics(ctx context.Context, req *v1.StaffWorkTypeStatisticsRequest) (reply *v1.StaffWorkTypeStatisticsReply, err error) {
  193. t1 := func() error {
  194. reply, err = staff.StaffWorkTypeStatistics(ctx, req)
  195. return err
  196. }
  197. return reply, rpctasker.Exec(ctx, t1)
  198. }
  199. // 按员工类型进行考勤统计
  200. func (c *Rcvr) StaffTypeStatistics(ctx context.Context, req *v1.StaffTypeStatisticsRequest) (reply *v1.StaffTypeStatisticsReply, err error) {
  201. t1 := func() error {
  202. reply, err = staff.StaffTypeStatistics(ctx, req)
  203. return err
  204. }
  205. return reply, rpctasker.Exec(ctx, t1)
  206. }
  207. // 按劳务公司进行考勤统计
  208. func (c *Rcvr) LaborCompanyStatistics(ctx context.Context, req *v1.LaborCompanyStatisticsRequest) (reply *v1.LaborCompanyStatisticsReply, err error) {
  209. t1 := func() error {
  210. reply, err = staff.LaborCompanyStatistics(ctx, req)
  211. return err
  212. }
  213. return reply, rpctasker.Exec(ctx, t1)
  214. }
  215. // 最近一次扬尘数据
  216. func (c *Rcvr) LatestDustMonitorData(ctx context.Context, req *v1.LatestDustMonitorDataRequest) (reply *v1.LatestDustMonitorDataReply, err error) {
  217. t1 := func() error {
  218. reply, err = dust.LatestDustMonitorData(ctx, req)
  219. return err
  220. }
  221. return reply, rpctasker.Exec(ctx, t1)
  222. }
  223. // 历史扬尘数据
  224. func (c *Rcvr) DustMonitorHistory(ctx context.Context, req *v1.DustMonitorHistoryRequest) (reply *v1.DustMonitorHistoryReply, err error) {
  225. t1 := func() error {
  226. reply, err = dust.DustMonitorHistory(ctx, req)
  227. return err
  228. }
  229. return reply, rpctasker.Exec(ctx, t1)
  230. }
  231. // 扬尘设备列表
  232. func (c *Rcvr) DustList(ctx context.Context, req *v1.DustListRequest) (reply *v1.DustListReply, err error) {
  233. t1 := func() error {
  234. reply, err = dust.DustList(ctx, req)
  235. return err
  236. }
  237. return reply, rpctasker.Exec(ctx, t1)
  238. }
  239. // 扬尘列表
  240. func (c *Rcvr) DustAqi(ctx context.Context, req *v1.DustAqiRequest) (reply *v1.DustAqiReply, err error) {
  241. t1 := func() error {
  242. reply, err = dust.DustAqi(ctx, req)
  243. return err
  244. }
  245. return reply, rpctasker.Exec(ctx, t1)
  246. }
  247. // 告警列表
  248. func (c *Rcvr) AlarmList(ctx context.Context, req *v1.AlarmListRequest) (reply *v1.AlarmListReply, err error) {
  249. t1 := func() error {
  250. reply, err = alarm.AlarmList(ctx, req)
  251. return err
  252. }
  253. return reply, rpctasker.Exec(ctx, t1)
  254. }
  255. // 摄像头(通道列表)
  256. func (c *Rcvr) CameraList(ctx context.Context, req *v1.CameraListRequest) (reply *v1.CameraListReply, err error) {
  257. t1 := func() error {
  258. reply, err = camera.CameraList(ctx, req)
  259. return err
  260. }
  261. return reply, rpctasker.Exec(ctx, t1)
  262. }
  263. // 设备绑定摄像头
  264. func (c *Rcvr) DeviceBindCamera(ctx context.Context, req *v1.DeviceBindCameraRequest) (reply *v1.DeviceBindCameraReply, err error) {
  265. t1 := func() error {
  266. reply, err = camera.DeviceBindCamera(ctx, req)
  267. return err
  268. }
  269. return reply, rpctasker.Exec(ctx, t1)
  270. }
  271. // 设备入库审批
  272. func (c *Rcvr) DeviceApprove(ctx context.Context, req *v1.DeviceApproveRequest) (reply *v1.DeviceApproveReply, err error) {
  273. t1 := func() error {
  274. reply, err = project.DeviceApprove(ctx, req)
  275. return err
  276. }
  277. return reply, rpctasker.Exec(ctx, t1)
  278. }
  279. // 设备解绑摄像头
  280. func (c *Rcvr) DeviceUnbindCamera(ctx context.Context, req *v1.DeviceUnbindCameraRequest) (reply *v1.DeviceUnbindCameraReply, err error) {
  281. t1 := func() error {
  282. reply, err = camera.DeviceUnbindCamera(ctx, req)
  283. return err
  284. }
  285. return reply, rpctasker.Exec(ctx, t1)
  286. }
  287. // 视屏设备下的通道列表
  288. func (c *Rcvr) ChannelList(ctx context.Context, req *v1.ChannelListRequest) (reply *v1.ChannelListReply, err error) {
  289. t1 := func() error {
  290. reply, err = camera.ChannelList(ctx, req)
  291. return err
  292. }
  293. return reply, rpctasker.Exec(ctx, t1)
  294. }
  295. // 项目(工程)信息
  296. func (c *Rcvr) ProjectInfo(ctx context.Context, req *v1.ProjectInfoRequest) (reply *v1.ProjectInfoReply, err error) {
  297. t1 := func() error {
  298. reply, err = project.ProjectInfo(ctx, req)
  299. return err
  300. }
  301. return reply, rpctasker.Exec(ctx, t1)
  302. }
  303. // 项目设备统计
  304. func (c *Rcvr) ProjectDeviceStatistics(ctx context.Context, req *v1.ProjectDeviceStatisticsRequest) (reply *v1.ProjectDeviceStatisticsReply, err error) {
  305. t1 := func() error {
  306. reply, err = project.ProjectDeviceStatistics(ctx, req)
  307. return err
  308. }
  309. return reply, rpctasker.Exec(ctx, t1)
  310. }
  311. // 获取项目进度
  312. func (c *Rcvr) ProjectProgress(ctx context.Context, req *v1.ProjectProgressRequest) (reply *v1.ProjectProgressReply, err error) {
  313. t1 := func() error {
  314. reply, err = project.ProjectProgress(ctx, req)
  315. return err
  316. }
  317. return reply, rpctasker.Exec(ctx, t1)
  318. }
  319. // 添加项目进度
  320. func (c *Rcvr) ProjectProgressAdd(ctx context.Context, req *v1.ProjectProgressAddRequest) (reply *v1.ProjectProgressAddReply, err error) {
  321. t1 := func() error {
  322. reply, err = project.ProjectProgressAdd(ctx, req)
  323. return err
  324. }
  325. return reply, rpctasker.Exec(ctx, t1)
  326. }
  327. // 进度完成设置
  328. func (c *Rcvr) ProjectProgressSet(ctx context.Context, req *v1.ProjectProgressSetRequest) (reply *v1.ProjectProgressSetReply, err error) {
  329. t1 := func() error {
  330. reply, err = project.ProjectProgressSet(ctx, req)
  331. return err
  332. }
  333. return reply, rpctasker.Exec(ctx, t1)
  334. }
  335. // 删除项目进度
  336. func (c *Rcvr) ProjectProgressDel(ctx context.Context, req *v1.ProjectProgressDelRequest) (reply *v1.ProjectProgressDelReply, err error) {
  337. t1 := func() error {
  338. reply, err = project.ProjectProgressDel(ctx, req)
  339. return err
  340. }
  341. return reply, rpctasker.Exec(ctx, t1)
  342. }
  343. // 添加告警规则
  344. func (c *Rcvr) AlarmRuleAdd(ctx context.Context, req *v1.AlarmRuleAddRequest) (reply *v1.AlarmRuleAddReply, err error) {
  345. t1 := func() error {
  346. reply, err = alarm.AlarmRuleAdd(ctx, req)
  347. return err
  348. }
  349. return reply, rpctasker.Exec(ctx, t1)
  350. }
  351. // 删除告警规则
  352. func (c *Rcvr) AlarmRuleDelete(ctx context.Context, req *v1.AlarmRuleDeleteRequest) (reply *v1.AlarmRuleDeleteReply, err error) {
  353. t1 := func() error {
  354. reply, err = alarm.AlarmRuleDelete(ctx, req)
  355. return err
  356. }
  357. return reply, rpctasker.Exec(ctx, t1)
  358. }
  359. // 告警规则列表
  360. func (c *Rcvr) AlarmRuleList(ctx context.Context, req *v1.AlarmRuleListRequest) (reply *v1.AlarmRuleListReply, err error) {
  361. t1 := func() error {
  362. reply, err = alarm.AlarmRuleList(ctx, req)
  363. return err
  364. }
  365. return reply, rpctasker.Exec(ctx, t1)
  366. }
  367. // 更新告警规则
  368. func (c *Rcvr) AlarmRuleUpdate(ctx context.Context, req *v1.AlarmRuleUpdateRequest) (reply *v1.AlarmRuleUpdateReply, err error) {
  369. t1 := func() error {
  370. reply, err = alarm.AlarmRuleUpdate(ctx, req)
  371. return err
  372. }
  373. return reply, rpctasker.Exec(ctx, t1)
  374. }
  375. // 告警规则启停用
  376. func (c *Rcvr) AlarmRuleOnOff(ctx context.Context, req *v1.AlarmRuleOnOffRequest) (reply *v1.AlarmRuleOnOffReply, err error) {
  377. t1 := func() error {
  378. reply, err = alarm.AlarmRuleOnOff(ctx, req)
  379. return err
  380. }
  381. return reply, rpctasker.Exec(ctx, t1)
  382. }
  383. // 添加告警联系人
  384. func (c *Rcvr) AlarmContactAdd(ctx context.Context, req *v1.AlarmContactAddRequest) (reply *v1.AlarmContactAddReply, err error) {
  385. t1 := func() error {
  386. reply, err = alarm.AlarmContactAdd(ctx, req)
  387. return err
  388. }
  389. return reply, rpctasker.Exec(ctx, t1)
  390. }
  391. // 删除告警联系人
  392. func (c *Rcvr) AlarmContactDelete(ctx context.Context, req *v1.AlarmContactDeleteRequest) (reply *v1.AlarmContactDeleteReply, err error) {
  393. t1 := func() error {
  394. reply, err = alarm.AlarmContactDelete(ctx, req)
  395. return err
  396. }
  397. return reply, rpctasker.Exec(ctx, t1)
  398. }
  399. // 编辑告警联系人
  400. func (c *Rcvr) AlarmContactUpdate(ctx context.Context, req *v1.AlarmContactUpdateRequest) (reply *v1.AlarmContactUpdateReply, err error) {
  401. t1 := func() error {
  402. reply, err = alarm.AlarmContactUpdate(ctx, req)
  403. return err
  404. }
  405. return reply, rpctasker.Exec(ctx, t1)
  406. }
  407. // 告警联系人列表
  408. func (c *Rcvr) AlarmContactList(ctx context.Context, req *v1.AlarmContactListRequest) (reply *v1.AlarmContactListReply, err error) {
  409. t1 := func() error {
  410. reply, err = alarm.AlarmContactList(ctx, req)
  411. return err
  412. }
  413. return reply, rpctasker.Exec(ctx, t1)
  414. }
  415. // 最近一次塔吊数据
  416. func (c *Rcvr) LatestTowerMonitorData(ctx context.Context, req *v1.LatestTowerMonitorDataRequest) (reply *v1.LatestTowerMonitorDataReply, err error) {
  417. t1 := func() error {
  418. reply, err = tower.LatestTowerMonitorData(ctx, req)
  419. return err
  420. }
  421. return reply, rpctasker.Exec(ctx, t1)
  422. }
  423. // 历史塔吊数据
  424. func (c *Rcvr) TowerMonitorHistory(ctx context.Context, req *v1.TowerMonitorHistoryRequest) (reply *v1.TowerMonitorHistoryReply, err error) {
  425. t1 := func() error {
  426. reply, err = tower.TowerMonitorHistory(ctx, req)
  427. return err
  428. }
  429. return reply, rpctasker.Exec(ctx, t1)
  430. }
  431. // iot设备列表
  432. func (c *Rcvr) IotList(ctx context.Context, req *v1.IotListRequest) (reply *v1.IotListReply, err error) {
  433. t1 := func() error {
  434. reply, err = tower.IotList(ctx, req)
  435. return err
  436. }
  437. return reply, rpctasker.Exec(ctx, t1)
  438. }
  439. func (c *Rcvr) IotLast(ctx context.Context, req *v1.IotLastRequest) (reply *v1.IotLastReply, err error) {
  440. t1 := func() error {
  441. reply, err = tower.IotLast(ctx, req)
  442. return err
  443. }
  444. return reply, rpctasker.Exec(ctx, t1)
  445. }
  446. // iot设备类型列表
  447. func (c *Rcvr) IotTypeList(ctx context.Context, req *v1.IotTypeListRequest) (reply *v1.IotTypeListReply, err error) {
  448. t1 := func() error {
  449. reply, err = tower.IotTypeList(ctx, req)
  450. return err
  451. }
  452. return reply, rpctasker.Exec(ctx, t1)
  453. }