| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.AlarmParamMapper; |
| | | import com.whyc.pojo.AlarmParam; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class AlarmParamService { |
| | | @Resource |
| | | @Autowired(required = false) |
| | | private AlarmParamMapper mapper; |
| | | |
| | | //电池告警参数设置--列表查询 |
| | | public Response serchByCondition(List AlarmIds) { |
| | | List list = mapper.serchByCondition(AlarmIds); |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1, pageInfo); |
| | | //获取设备告警参数 |
| | | public Response getAlmParam(Integer devId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("dev_id",devId); |
| | | wrapper.orderByAsc("num"); |
| | | List list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list!=null,list,"获取设备告警参数"); |
| | | } |
| | | |
| | | //查询电池优劣好坏的标准 |
| | | public Response serchQuality() { |
| | | //0.查询劣化(告警)和损坏(更换)的阈值 |
| | | QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper(); |
| | | alarmWrapper.and(wrapper -> { |
| | | return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange"); |
| | | }); |
| | | alarmWrapper.orderByAsc("alm_id"); |
| | | List<AlarmParam> paramList = mapper.selectList(alarmWrapper); |
| | | float capAlarm = 0f; |
| | | float capChange = 0f; |
| | | if (paramList != null && paramList.size() > 0) { |
| | | capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8 |
| | | capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6 |
| | | } else { |
| | | capAlarm = 0.8f; |
| | | capChange = 0.6f; |
| | | } |
| | | Map<String, Float> map = new HashMap<>(); |
| | | map.put("capAlarm", capAlarm); |
| | | map.put("capChange", capChange); |
| | | return new Response<>().setII(1, true, map, "查询电池优劣好坏的标准"); |
| | | } |
| | | |
| | | //告警参数设置 |
| | | @Transactional |
| | | public Response setParam(List<AlarmParam> list) { |
| | | if (list != null && list.size() > 0) { |
| | | for (AlarmParam p : list) { |
| | | UpdateWrapper wrapper = new UpdateWrapper(); |
| | | wrapper.set("alm_low_coe", p.getAlmLowCoe()); |
| | | wrapper.eq("alm_id", p.getAlmId()); |
| | | mapper.update((AlarmParam) ActionUtil.objeNull, wrapper); |
| | | } |
| | | } |
| | | return new Response().set(1, true); |
| | | } |
| | | } |
| | | } |