|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.bizmatics.common.core.bean.CommonPage;
|
|
|
+import com.bizmatics.common.core.util.BeanMapperUtils;
|
|
|
import com.bizmatics.common.core.util.DateUtils;
|
|
|
import com.bizmatics.common.core.util.StringUtils;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
@@ -12,6 +13,7 @@ import com.bizmatics.mhfire.model.Alert;
|
|
|
import com.bizmatics.mhfire.persistence.mapper.AlertMapper;
|
|
|
import com.bizmatics.mhfire.service.AlertService;
|
|
|
import com.bizmatics.mhfire.service.util.Arith;
|
|
|
+import com.bizmatics.mhfire.service.vo.AlertMapVO;
|
|
|
import com.bizmatics.mhfire.service.vo.AlertStatisticsVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -101,18 +103,57 @@ public class AlertServiceImpl extends AbstractCrudService<AlertMapper, Alert> im
|
|
|
return this.ToCommonPage(page);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonPage<AlertMapVO> pageMap(Integer current, Integer size, Date startTime, Date endTime) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<Alert> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(Alert::getId,Alert::getGisX,Alert::getGisY);
|
|
|
+ if (null != startTime && null != endTime){
|
|
|
+ queryWrapper.between(Alert::getDcsj,startTime,endTime);
|
|
|
+ }
|
|
|
+ CommonPage<AlertMapVO> commonPage;
|
|
|
+ if (null != current && size != null){
|
|
|
+ IPage<Alert> page = new Page<>(current,size);
|
|
|
+ page = this.page(page,queryWrapper);
|
|
|
+ commonPage = new CommonPage<AlertMapVO>(BeanMapperUtils.mapList(page.getRecords(),Alert.class,AlertMapVO.class),page.getTotal(),page.getSize(),page.getCurrent());
|
|
|
+ }else {
|
|
|
+ List<Alert> list = this.list(queryWrapper);
|
|
|
+ commonPage = new CommonPage<AlertMapVO>(BeanMapperUtils.mapList(list,Alert.class,AlertMapVO.class),list.size(),list.size(),1);
|
|
|
+ }
|
|
|
+ return commonPage;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Alert getOne(String id) {
|
|
|
+ return this.getById(id);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<AlertStatisticsVO> getAlertStatistics(Date startTime, Date endTime) {
|
|
|
+
|
|
|
+ //获取同比
|
|
|
+ Date upStartTime = DateUtils.addYears(startTime, -1);
|
|
|
+ Date upEndTime = DateUtils.addYears(endTime, -1);
|
|
|
List<AlertStatisticsVO> list = new ArrayList<>();
|
|
|
list.add(getAsV(startTime, endTime, ALERT_TYPE[0]));
|
|
|
list.add(getAsV(startTime, endTime, ALERT_TYPE[1]));
|
|
|
list.add(getAsV(startTime, endTime, ALERT_TYPE[2]));
|
|
|
- int sum = list.stream().mapToInt(AlertStatisticsVO::getNumber).sum();
|
|
|
list.forEach(alertStatisticsVO -> {
|
|
|
- if (0 == sum){
|
|
|
+ AlertStatisticsVO upAsv = getAsV(upStartTime, upEndTime, alertStatisticsVO.getType());
|
|
|
+ Integer number = alertStatisticsVO.getNumber();
|
|
|
+ Integer upNumber = upAsv.getNumber();
|
|
|
+ if (number.equals(upNumber)) {
|
|
|
+ alertStatisticsVO.setSameStatus(0);
|
|
|
+ } else if (number > upNumber) {
|
|
|
+ alertStatisticsVO.setSameStatus(1);
|
|
|
+ } else {
|
|
|
+ alertStatisticsVO.setSameStatus(2);
|
|
|
+ }
|
|
|
+ if (0 != upNumber) {
|
|
|
+ alertStatisticsVO.setRadio(Arith.div(number, upNumber));
|
|
|
+ } else {
|
|
|
alertStatisticsVO.setRadio(0.00);
|
|
|
- }else {
|
|
|
- alertStatisticsVO.setRadio(Arith.div(alertStatisticsVO.getNumber(), sum));
|
|
|
}
|
|
|
});
|
|
|
return list;
|