12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace catchAdmin\alarm\model\get;
- use catchAdmin\system\model\SysDictData;
- use Exception;
- use think\facade\Db;
- trait AlarmRecordsGet
- {
-
- /**
- * 获取原因名称(文本)
- */
- public function getResultTextAttr($value)
- {
- $type = $this->result;
- if($type){
- return $this->getDictValue('AlarmHandleResult',$type);
- }else{
- return '未处理';
- }
- }
- /**
- * 获取开始时间(文本)
- */
- public function getStartTimeTextAttr($value)
- {
-
- if($this->start_time){
- return date('Y-m-d H:i:s',$this->start_time);
- }else{
- return '';
- }
- }
- /**
- * 获取结束时间(文本)
- */
- public function getEndTimeTextAttr($value)
- {
-
- if($this->end_time){
- return date('Y-m-d H:i:s',$this->end_time);
- }else{
- return '';
- }
- }
- /**
- * 获取处理人
- */
- public function getHandlerNameAttr($value)
- {
- return Db::table('users')->where('id',$this->handler_id)->value('realname');
- }
- /**
- * 获取原因
- */
- public function getReasonTextAttr($value)
- {
- return $this->getDictValue('AlarmType',$this->alarm_reason);
- }
- /**
- * 获取告警状态
- */
- public function getStateAttr($value)
- {
- return $this->getDictValue('AlarmState',$value);
- }
-
- /*
- * 获取字典值(文本)
- */
- public function getDictValue($typeCode,$value)
- {
-
- return (new SysDictData())->getValueByCode($typeCode,$value);
- }
- }
|