Lssue.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /*
  3. * @Descripttion:
  4. * @version: 1.0.0
  5. * @Author: likang
  6. * @Date: 2022-07-26 16:16:11
  7. * @LastEditors: likang
  8. * @LastEditTime: 2022-07-29 16:00:37
  9. */
  10. namespace catchAdmin\system\controller;
  11. use catchAdmin\api\Directive;
  12. use catchAdmin\hydraulic\controller\HydEquipment;
  13. use catchAdmin\hydraulic\model\HydEquipment as ModelHydEquipment;
  14. use catcher\base\CatchRequest as Request;
  15. use catcher\CatchResponse;
  16. use catcher\base\CatchController;
  17. use catchAdmin\system\model\Lssue as lssueModel;
  18. use catcher\CatchAdmin;
  19. class Lssue extends CatchController
  20. {
  21. protected $lssueModel;
  22. public function __construct(LssueModel $lssueModel)
  23. {
  24. $this->lssueModel = $lssueModel;
  25. }
  26. /**
  27. * 列表
  28. * @time 2022年07月26日 16:16
  29. * @param Request $request
  30. */
  31. public function index(Request $request): \think\Response
  32. {
  33. return CatchResponse::paginate($this->lssueModel->getList());
  34. }
  35. /**
  36. * 保存信息
  37. * @time 2022年07月26日 16:16
  38. * @param Request $request
  39. */
  40. public function save(Request $request): \think\Response
  41. {
  42. $data = $request->post();
  43. $this->lssueModel->storeBy($request->post());
  44. $list = ModelHydEquipment::alias('e')->leftJoin('hydraulic h', 'e.id = h.eq_id')
  45. ->where('e.id', 'in', $data['equ_ids'])->column('h.imei');
  46. if ($data['directive'] == 'File') {
  47. $content = [
  48. 'file_name' => $data['file_name']
  49. ];
  50. } else if ($data['directive'] == 'Config') {
  51. $content = json_decode($data['file_name'], true);
  52. if (json_last_error() != 0) {
  53. return CatchResponse::fail(json_last_error_msg());
  54. }
  55. } else if ($data['directive'] = 'SysCMD') {
  56. $content = [
  57. 'cmd_content' => trim($data['file_name'])
  58. ];
  59. }
  60. Directive::Issued($data['type'], $content, $data['directive'], $list);
  61. // $this->lssueModel->IssueAll($content);
  62. return CatchResponse::success();
  63. }
  64. /**
  65. * 读取
  66. * @time 2022年07月26日 16:16
  67. * @param $id
  68. */
  69. public function read($id): \think\Response
  70. {
  71. return CatchResponse::success($this->lssueModel->findBy($id));
  72. }
  73. /**
  74. * 更新
  75. * @time 2022年07月26日 16:16
  76. * @param Request $request
  77. * @param $id
  78. */
  79. public function update(Request $request, $id): \think\Response
  80. {
  81. return CatchResponse::success($this->lssueModel->updateBy($id, $request->post()));
  82. }
  83. /**
  84. * 删除
  85. * @time 2022年07月26日 16:16
  86. * @param $id
  87. */
  88. public function delete($id): \think\Response
  89. {
  90. return CatchResponse::success($this->lssueModel->deleteBy($id, true));
  91. }
  92. }