| | |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.swing.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class LockAlarmService { |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private LockInfMapper linfMapper; |
| | | |
| | | @Autowired |
| | | private AreaInfService areaInfService; |
| | | //查询锁实时告警信息 |
| | | public Response getLockAlm(Integer lockId, String almIds,int pageNum, int pageSize) { |
| | | public Response getLockAlm(Integer areaId, String almIds,Integer confirmFlag,int pageNum, int pageSize) { |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | if(lockId!=null){ |
| | | wrapper.eq("lock_id",lockId); |
| | | if(areaId!=null){ |
| | | List<Integer> areaList=new ArrayList(); |
| | | areaList.add(areaId); |
| | | areaInfService.getAllAreaId(areaId,areaList); |
| | | if(areaList!=null){ |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.in("area_id",areaList); |
| | | List<LockInf> lockInfList=linfMapper.selectList(wrapper1); |
| | | List<Integer> lockIdList = lockInfList.stream() |
| | | .map(LockInf::getLockId) // 提取id值 |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | wrapper.in("lock_id",lockIdList); |
| | | } |
| | | } |
| | | if(almIds!=null){ |
| | | String[] almId=almIds.split(","); |
| | | wrapper.in("alm_id",almId); |
| | | } |
| | | if(confirmFlag!=null){ |
| | | wrapper.eq("alm_is_confirmed",confirmFlag); |
| | | } |
| | | List<LockAlarm> list=mapper.selectList(wrapper); |
| | | for (LockAlarm alm:list) { |
| | |
| | | return new Response().setII(1,list!=null,pageInfo,"查询锁实时告警信息"); |
| | | } |
| | | //确认告警 |
| | | public Response confirmAlm(Integer lockId) { |
| | | public Response confirmAlm(Integer num) { |
| | | UpdateWrapper wrapper= new UpdateWrapper<LockAlarm>(); |
| | | wrapper.eq("lock_id",lockId); |
| | | wrapper.eq("num",num); |
| | | wrapper.set("alm_is_confirmed",1); |
| | | wrapper.set("alm_confirmed_time",new Date()); |
| | | mapper.update((LockAlarm) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(1,true,"确认告警成功!"); |
| | | } |
| | | //取消告警 |
| | | public Response cancleAlm(Integer lockId) { |
| | | public Response cancleAlm(Integer num) { |
| | | UpdateWrapper wrapper= new UpdateWrapper<LockAlarm>(); |
| | | wrapper.eq("lock_id",lockId); |
| | | wrapper.eq("num",num); |
| | | wrapper.set("alm_is_confirmed",0); |
| | | wrapper.set("alm_confirmed_time", ThreadLocalUtil.parse("2000-01-01 00:00:00",1)); |
| | | mapper.update((LockAlarm) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(1,true,"取消告警成功!"); |
| | | } |
| | | |
| | | //删除告警 |
| | | public Response delAlm(Integer num) { |
| | | UpdateWrapper wrapper= new UpdateWrapper<LockAlarm>(); |
| | | wrapper.eq("num",num); |
| | | mapper.delete(wrapper); |
| | | return new Response().set(1,true,"删除告警成功!"); |
| | | } |
| | | } |