AtlasController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/3/9
  6. * Time: 上午11:56
  7. */
  8. namespace console\controllers;
  9. use backendApi\modules\v1\models\lists\atlas\EmpUserList;
  10. use backendApi\modules\v1\models\lists\atlas\NetworkLineList;
  11. use backendApi\modules\v1\models\lists\atlas\NetworkList;
  12. use backendApi\modules\v1\models\lists\atlas\RelationList;
  13. use common\libs\export\module\AtlasExport;
  14. use Yii;
  15. class AtlasController extends BaseController {
  16. /**
  17. * 开拓网络列表导出
  18. * @param $taskId
  19. * @return bool
  20. */
  21. public function actionRelationListExport($taskId) {
  22. $factory = AtlasExport::factory($taskId);
  23. $factory->listModelClass = RelationList::class;
  24. try {
  25. if ($factory->generate()) {
  26. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '开拓网络列表导出成功');
  27. }
  28. unset($factory);
  29. return true;
  30. } catch (\Exception $e) {
  31. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '开拓网络列表导出失败。详情:' . $e->getMessage(), false);
  32. }
  33. // 记录日志
  34. // $logApiSystem = new ApiSystem();
  35. // $logApiSystem->setRequestContent($params)->setResponseContent($exportForm->getErrors())->saveByConsole([
  36. // 'apiName' => '开拓网络列表导出',
  37. // 'optType' => ApiSystem::OPT_TYPE_CALL
  38. // ]);
  39. unset($factory);
  40. return false;
  41. }
  42. /**
  43. * 安置网络列表导出
  44. * @param $taskId
  45. * @return bool
  46. */
  47. public function actionNetworkListExport($taskId) {
  48. $factory = AtlasExport::factory($taskId);
  49. $factory->listModelClass = NetworkList::class;
  50. try {
  51. if ($factory->generate()) {
  52. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '安置网络列表导出成功');
  53. }
  54. unset($factory);
  55. return true;
  56. } catch (\Exception $e) {
  57. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '安置网络列表导出失败。详情:' . $e->getMessage(), false);
  58. }
  59. unset($factory);
  60. return false;
  61. }
  62. /**
  63. * 安置链路列表导出
  64. * @param $taskId
  65. * @return bool
  66. */
  67. public function actionNetworkLineListExport($taskId) {
  68. $factory = AtlasExport::factory($taskId);
  69. $factory->listModelClass = NetworkLineList::class;
  70. try {
  71. if ($factory->generate()) {
  72. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '安置链路列表导出成功');
  73. }
  74. unset($factory);
  75. return true;
  76. } catch (\Exception $e) {
  77. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '安置链路列表导出失败。详情:' . $e->getMessage(), false);
  78. }
  79. unset($factory);
  80. return false;
  81. }
  82. /**
  83. * 聘级网络列表导出
  84. * @param $taskId
  85. * @return bool
  86. */
  87. public function actionEmpUserListExport($taskId) {
  88. $factory = AtlasExport::factory($taskId);
  89. $factory->listModelClass = EmpUserList::class;
  90. try {
  91. if ($factory->generate()) {
  92. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '聘级网络列表导出成功');
  93. }
  94. unset($factory);
  95. return true;
  96. } catch (\Exception $e) {
  97. Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), '聘级网络列表导出失败。详情:' . $e->getMessage(), false);
  98. }
  99. unset($factory);
  100. return false;
  101. }
  102. }