| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.DeviceConstant; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.Fbs9100StateMapper; |
| | | import com.whyc.pojo.Fbs9100State; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class Fbs9100StateService { |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public Response<Map> getBTSEquipStatus(int userId) throws ParseException { |
| | | |
| | | Response<Map> response = new Response(); |
| | | Map<String, Integer> resultMap = new HashMap<>(); |
| | | resultMap.put("在线浮充数量",0); |
| | | resultMap.put("预充电数量",0); |
| | | resultMap.put("核容测试数量",0); |
| | | resultMap.put("内阻测试数量",0); |
| | | resultMap.put("通讯故障数量",0); |
| | | /*try { |
| | | List<FBS9100State> statusList = fbs9100StateMapper.getStatus(userId); |
| | | for (int i = 0; i < statusList.size(); i++) { |
| | | switch (statusList.get(i).getWorkState()){ |
| | | case DeviceConstant.DEV_ONLINE_CHARGE: |
| | | resultMap.put("在线浮充",statusList.get(i).getNum()); |
| | | break; |
| | | case DeviceConstant.DEV_PRE_CHARGE: |
| | | resultMap.put("预充电",statusList.get(i).getNum()); |
| | | break; |
| | | case DeviceConstant.DEV_NUCLEAR_CAP: |
| | | resultMap.put("核容测试",statusList.get(i).getNum()); |
| | | break; |
| | | case DeviceConstant.DEV_RES_TEST: |
| | | resultMap.put("内阻测试",statusList.get(i).getNum()); |
| | | break; |
| | | } |
| | | } |
| | | response.setCode(1); |
| | | response.setData(resultMap); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | response.setCode(0); |
| | | return response; |
| | | }*/ |
| | | QueryWrapper<Fbs9100State> wrapper = Wrappers.query(); |
| | | wrapper.select("record_datetime","dev_workstate"); |
| | | List<Fbs9100State> fbs9100StateList = mapper.selectList(wrapper); |
| | | //首先查看是否通讯故障,时间大于1分钟为通讯故障 |
| | | for (int i = 0; i < fbs9100StateList.size(); i++) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.MINUTE,-1); |
| | | Date time = instance.getTime(); |
| | | if(time.compareTo(DateUtil.YYYY_MM_DD_HH_MM_SS.parse(fbs9100StateList.get(i).getRecordDatetime()))>0){ |
| | | resultMap.put("通讯故障数量",resultMap.get("通讯故障数量")+1); |
| | | }else{ |
| | | switch (fbs9100StateList.get(i).getDevWorkstate()){ |
| | | case DeviceConstant.DEV_ONLINE_CHARGE: |
| | | resultMap.put("在线浮充数量",resultMap.get("在线浮充数量")+1); |
| | | break; |
| | | case DeviceConstant.DEV_PRE_CHARGE: |
| | | resultMap.put("预充电数量",resultMap.get("预充电数量")+1); |
| | | break; |
| | | case DeviceConstant.DEV_NUCLEAR_CAP: |
| | | resultMap.put("核容数量",resultMap.get("核容测试数量")+1); |
| | | break; |
| | | case DeviceConstant.DEV_RES_TEST: |
| | | resultMap.put("内阻测试数量",resultMap.get("内阻测试数量")+1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return new Response<Map>().set(1,resultMap); |
| | | } |
| | | } |