新增预警配置;优化完成统计
This commit is contained in:
parent
80d2d0aa19
commit
ba3562027c
|
@ -31,7 +31,7 @@ public class StatisticController extends BaseController {
|
|||
* 获取完成情况统计
|
||||
*/
|
||||
@GetMapping("/complete/all")
|
||||
public R<StatisticNumVo> getComplete(BaseQueryBo query) {
|
||||
public R<List<StatisticNumVo>> getComplete(BaseQueryBo query) {
|
||||
return R.ok(statisticService.getComplete4All(query));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.dromara.scale.controller;
|
|||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
|
@ -32,7 +33,7 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/scale/warn")
|
||||
public class SysWarnRecordController extends BaseController {
|
||||
public class SysWarnController extends BaseController {
|
||||
|
||||
private final ISysWarnRecordService sysWarnRecordService;
|
||||
|
||||
|
@ -90,4 +91,17 @@ public class SysWarnRecordController extends BaseController {
|
|||
public R<List<SysEvaluationRecordVo>> getEvaluationRecordList(@NotNull(message = "主键不能为空") Long warnId) {
|
||||
return R.ok(sysWarnRecordService.queryConclusionListByWarnId(warnId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改预警记录
|
||||
*/
|
||||
@SaCheckPermission("scale:warn:edit")
|
||||
@Log(title = "预警记录", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/config/{ids}")
|
||||
public R<Void> config(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Integer[] ids) {
|
||||
return toAjax(sysWarnRecordService.updateWarnConfig(ids));
|
||||
}
|
||||
|
||||
}
|
|
@ -15,4 +15,5 @@ public class BaseQueryBo {
|
|||
Long batchNo;
|
||||
Long scaleId;
|
||||
Long deptId;
|
||||
|
||||
}
|
||||
|
|
|
@ -26,4 +26,7 @@ public interface SysWarnRecordMapper extends BaseMapperPlus<SysWarnRecord, SysWa
|
|||
List<SysEvaluationRecordVo> selectEvaluationRecordListByWarnId(Long warnId);
|
||||
|
||||
|
||||
int updateConfigByIds(String ids);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
public interface IStatisticService {
|
||||
|
||||
|
||||
StatisticNumVo getComplete4All(BaseQueryBo query);
|
||||
List<StatisticNumVo> getComplete4All(BaseQueryBo query);
|
||||
|
||||
List<StatisticNumVo> getComplete4Class(BaseQueryBo query);
|
||||
|
||||
|
|
|
@ -44,4 +44,6 @@ public interface ISysWarnRecordService {
|
|||
|
||||
List<SysEvaluationRecordVo> queryConclusionListByWarnId(Long warnId);
|
||||
|
||||
Boolean updateWarnConfig(Integer[] ids);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,11 @@ import org.dromara.scale.mapper.StatisticMapper;
|
|||
import org.dromara.scale.service.IStatisticService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>TODO<p>
|
||||
|
@ -25,25 +29,39 @@ public class StatisticServiceImpl implements IStatisticService {
|
|||
private final StatisticMapper statisticMapper;
|
||||
|
||||
@Override
|
||||
public StatisticNumVo getComplete4All(BaseQueryBo query) {
|
||||
public List<StatisticNumVo> getComplete4All(BaseQueryBo query) {
|
||||
Long batchNo = query.getBatchNo();
|
||||
Long scaleId = query.getScaleId();
|
||||
List<StatisticNumVo> list = statisticMapper.selectCompleteAvaluation(batchNo, scaleId);
|
||||
int complete = list.stream().mapToInt(StatisticNumVo::getValue).sum();
|
||||
int uncompleted = list.stream().mapToInt(StatisticNumVo::getSpareValue).sum();
|
||||
|
||||
StatisticNumVo data = new StatisticNumVo();
|
||||
//data.setName(deptName);
|
||||
data.setValue(complete);
|
||||
data.setSpareValue(uncompleted);
|
||||
return data;
|
||||
List<StatisticNumVo> statisticNumVos = statisticMapper.selectCompleteAvaluation(batchNo, scaleId);
|
||||
Map<String, List<StatisticNumVo>> collect = statisticNumVos.stream()
|
||||
.collect(Collectors.groupingBy(StatisticNumVo::getParentName));
|
||||
return processData(collect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatisticNumVo> getComplete4Class(BaseQueryBo query) {
|
||||
Long batchNo = query.getBatchNo();
|
||||
Long scaleId = query.getScaleId();
|
||||
return statisticMapper.selectCompleteAvaluation(batchNo, scaleId);
|
||||
List<StatisticNumVo> statisticNumVos = statisticMapper.selectCompleteAvaluation(batchNo, scaleId);
|
||||
Map<String, List<StatisticNumVo>> collect = statisticNumVos.stream()
|
||||
.collect(Collectors.groupingBy(StatisticNumVo::getDeptName));
|
||||
return processData(collect);
|
||||
}
|
||||
|
||||
private List<StatisticNumVo> processData(Map<String, List<StatisticNumVo>> collect) {
|
||||
Set<String> keys = collect.keySet();
|
||||
List<StatisticNumVo> data = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
List<StatisticNumVo> list = collect.get(key);
|
||||
int complete = list.stream().mapToInt(StatisticNumVo::getValue).sum();
|
||||
int uncompleted = list.stream().mapToInt(StatisticNumVo::getSpareValue).sum();
|
||||
StatisticNumVo one = new StatisticNumVo();
|
||||
one.setName(key);
|
||||
one.setValue(complete);
|
||||
one.setSpareValue(uncompleted);
|
||||
data.add(one);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dromara.scale.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -101,4 +102,10 @@ public class SysWarnRecordServiceImpl implements ISysWarnRecordService {
|
|||
public List<SysEvaluationRecordVo> queryConclusionListByWarnId(Long warnId) {
|
||||
return baseMapper.selectEvaluationRecordListByWarnId(warnId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateWarnConfig(Integer[] ids) {
|
||||
|
||||
return baseMapper.updateConfigByIds(StrUtil.join(StrUtil.COMMA, ids)) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,11 @@
|
|||
where wr.warn_id = #{warnId}
|
||||
</select>
|
||||
|
||||
|
||||
<update id="updateConfigByIds">
|
||||
update sys_warn_config
|
||||
set status = 0;
|
||||
update sys_warn_config
|
||||
set status=1
|
||||
where find_in_set(id, #{ids})
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue