| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.DevAlmEnum; |
| | | import com.whyc.dto.DalmDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.DevalarmDataMapper; |
| | |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.SubTablePageInfoUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class DevalarmDataService { |
| | |
| | | @Autowired(required = false) |
| | | private SubTablePageInfoUtil service; |
| | | |
| | | @Autowired(required = false) |
| | | private UserInfService uinfService; |
| | | |
| | | //获取设备告警信息 |
| | | public Response getDAlmInf(int uid, DalmDto dto) { |
| | | PageHelper.startPage(dto.getPageNum(),dto.getPageSize()); |
| | | dto.setUid(uid); |
| | | List<DevalarmData> list=mapper.getDAlmInf(dto); |
| | | for (DevalarmData data:list) { |
| | | UserInf uinf=uinfService.getUinfByUId(data.getConfirmedUid()); |
| | | data.setConfirmedUname(uinf!=null?uinf.getUname():""); |
| | | int almId=data.getAlmId(); |
| | | data.setAlmName(DevAlmEnum.getValue(almId)); |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"获取设备告警信息"); |
| | | } |
| | |
| | | public Response getDAlmHis(DalmDto dto) throws ParseException { |
| | | UserInf uinf= ActionUtil.getUser(); |
| | | dto.setUid(uinf.getUid()); |
| | | if(dto.getStartTime()==null){ |
| | | dto.setStartTime(ThreadLocalUtil.parse("2024-01-01 00:00:00",1)); |
| | | } |
| | | if(dto.getEndTime()==null){ |
| | | dto.setEndTime(new Date()); |
| | | } |
| | | PageInfo pageInfo=service.getPageInfo(dto.getPageNum(),dto.getPageSize(),dto.getStartTime(),dto.getEndTime() |
| | | ,"db_alarm", "tb_devalarm_data", dto); |
| | | return new Response().setII(1,pageInfo!=null,pageInfo,"获取设备告警信息"); |
| | | } |
| | | //确认实时告警 |
| | | public Response confiirmAlm(int devId) { |
| | | public Response confiirmAlm(int num) { |
| | | UserInf uinf= ActionUtil.getUser(); |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.set("alm_is_confirmed",1); |
| | | wrapper.set("confirmed_uid",uinf.getUid()); |
| | | wrapper.set("confirmed_time",new Date()); |
| | | wrapper.eq("dev_id",devId); |
| | | wrapper.eq("num",num); |
| | | int flag=mapper.update((DevalarmData) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(1,flag>0,"确认实时告警"); |
| | | } |
| | | //获取所有的告警类型 |
| | | public Response getAllAlmName() { |
| | | Map<Integer,String> map=DevAlmEnum.getOpInfo(); |
| | | return new Response().setII(1,true,map,"获取所有的告警类型"); |
| | | } |
| | | //弹窗告警 |
| | | public Response getDAlmPopUp(Integer uid) { |
| | | List<DevalarmData> list=mapper.getDAlmPopUp(uid); |
| | | for (DevalarmData data:list) { |
| | | int almId=data.getAlmId(); |
| | | data.setAlmName(DevAlmEnum.getValue(almId)); |
| | | } |
| | | return new Response().setII(1,list!=null,list,"弹窗告警"); |
| | | } |
| | | } |