| | |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.PoleBinding; |
| | | import com.sandu.ximon.dao.enums.DeviceRespStatusEnums; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.mapper.LightMapper; |
| | | import com.sandu.ximon.dao.mapper.LightTaskMapper; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | * |
| | | * @return 返回组合数据dto |
| | | */ |
| | | public List<LightBo> listLight(int pageNo, int pageSize, String keyword) { |
| | | public List<LightBo> listLight(int pageNo, int pageSize, String keyword, Integer order, Integer seq) { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | |
| | | PageHelper.startPage(pageNo, pageSize); |
| | | //排序字段 |
| | | String orderByResult = OrderByEnums.LIGHT_POLE_NAME.getCode(); |
| | | //正序、倒叙 |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.LIGHT_POLE_NAME.getCode(); |
| | | break; |
| | | case 2: |
| | | orderByResult = OrderByEnums.LIGHT_UPDATE_TIME.getCode(); |
| | | break; |
| | | case 3: |
| | | orderByResult = OrderByEnums.LIGHT_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = OrderByEnums.ASC.getCode(); |
| | | break; |
| | | case 2: |
| | | orderBySeq = OrderByEnums.DESC.getCode(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //排序方式 |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | PageHelper.startPage(pageNo, pageSize, orderBy); |
| | | |
| | | List<LightBo> listLight = baseMapper.listLight(clientId, keyword); |
| | | |
| | |
| | | |
| | | public BigDecimal getlistEnergy(Integer week) { |
| | | |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | // List<LightBo> listLight = baseMapper.listLight(clientId, null); |
| | | // List<String> deviceCodeList = listLight.stream().map(LightBo::getDeviceCode).collect(Collectors.toList()); |
| | | |
| | | //获取到正在执行的任务列表 |
| | | List<LightTaskDto> lightTaskDtos = SpringContextHolder.getBean(LightTaskService.class).listTask(); |
| | |
| | | /** |
| | | * 节能率计算开始 |
| | | */ |
| | | //TODO |
| | | //获取昨天的星期数 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime yesterday = now.minusDays(1); |
| | |
| | | //判断Task.getWeekList()是否包含昨天的星期数 不包含直接返回0 不进行计算 |
| | | if (Task.getWeekList() != null && !Task.getWeekList().isEmpty()) { |
| | | if (!Task.getWeekList().contains(week)) { |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal(1); |
| | | } |
| | | } else { |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal(1); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * 一天的能耗 |
| | | * |
| | | * @param list |
| | | * @param |
| | | * @return |
| | | */ |
| | | public BigDecimal jisuanEnergy(LightTaskDto Task) { |
| | |
| | | // BigDecimal hour = BigDecimal.valueOf((v2.getHour() - v1.getHour())); |
| | | // BigDecimal hour; |
| | | if (v1.getBrightness() == 0) { |
| | | return BigDecimal.ZERO; |
| | | return new BigDecimal(1); |
| | | } |
| | | double hour; |
| | | double min; |