| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void siteReservesNotice(String siteId) throws Exception { |
| | | public void siteReservesNotice() throws Exception{ |
| | | QueryWrapper<Sites> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select(" *, " + |
| | | " (select count(r.id) from locks r where r.site_id = sites.id) as all_lock_num ," + |
| | | "(select count(l.bike_code) from locks l where l.site_id = sites.id and l.bike_code IS NOT NULL and l.bike_code !='' ) as bikeCount"); |
| | | queryWrapper.lambda().eq(Sites::getStatus,Constants.ZERO); |
| | | queryWrapper.lambda().eq(Sites::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.lambda().orderByAsc(Sites::getCode); |
| | | List<Sites> sitesList = sitesMapper.selectList(queryWrapper); |
| | | if (!CollectionUtils.isEmpty(sitesList)){ |
| | | for (Sites s:sitesList) { |
| | | if(Constants.formatIntegerNum(s.getAllLockNum())<=Constants.ZERO){ |
| | | continue; |
| | | } |
| | | BigDecimal warnMin = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.WARN_MIN).getCode()); |
| | | BigDecimal warnMax = new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.WARN_MAX).getCode()); |
| | | BigDecimal rata = new BigDecimal(s.getBikeCount()).divide(new BigDecimal(s.getAllLockNum()),2,BigDecimal.ROUND_HALF_UP); |
| | | if(rata.compareTo(warnMax)>Constants.ZERO){ |
| | | //发送钉钉通知 |
| | | DingDingNotice.reservesNotice(s.getName(), |
| | | systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_URL).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_SECRET).getCode(),Constants.ZERO,warnMax); |
| | | }else if(rata.compareTo(warnMin)<Constants.ZERO){ |
| | | //发送钉钉通知 |
| | | DingDingNotice.reservesNotice(s.getName(), |
| | | systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_URL).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.DINGDING,Constants.DINGDING_SECRET).getCode(),Constants.ONE,warnMin); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |