123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace common\services;
- use common\components\AjaxException;
- use common\models\EventOverview;
- use yii\db\ActiveQuery;
- class EventOverviewService
- {
- /**
- * @param $id
- * @return EventOverview
- * @throws AjaxException
- */
- public static function getEventOverviewById($id): EventOverview
- {
- /** @var EventOverview $EventOverview */
- $EventOverview = EventOverview::find()->where(["delete_time" => 0, "id" => $id])->one();
- if (!$EventOverview) {
- throw new AjaxException("该事件概览不存在!");
- }
- return $EventOverview;
- }
- /**
- * @return ActiveQuery
- */
- public static function getEventOverviewQuery(): ActiveQuery
- {
- return EventOverview::find()->where(["delete_time" => 0]);
- }
- /**
- * 通过案例ID删除应急处置
- * @param $accident_id
- */
- public static function deleteByAccidentCasesId($accident_id): void
- {
- EventOverview::updateAll(["delete_time" => time()], ["accident_id" => $accident_id]);
- }
- public static function dealWithList($data, $accident_id)
- {
- $sourceDataList = array_column(EventSourceDataService::getSourceDataListByAccidentId($accident_id), null, "id");
- /** @var EventOverview[] $data */
- foreach ($data as $value) {
- //将数组从json转化出来
- OperationalAdjustmentsService::dealWithSourceData($value, $sourceDataList);
- if ($value->end_time == 0) {
- $value->end_time = "";
- }
- }
- return $data;
- }
- }
|