feat(prison): 新增累计表扬次数统计字段
- 后端新增 praiseCount 字段(Integer类型) - 从 prison_situation 表统计 category=2(表扬类型)的记录数 - 遵循 violationCount 的实现模式 参考计划: .sisyphus/plans/dashboard-center-update.md Task 1
This commit is contained in:
parent
cea9ed7335
commit
653e55a075
@ -78,6 +78,9 @@ public class PrisonerDashboardStatsRespVO {
|
||||
@Schema(description = "累计表扬天数", example = "-")
|
||||
private String praiseDays;
|
||||
|
||||
@Schema(description = "累计表扬次数", example = "8")
|
||||
private Integer praiseCount;
|
||||
|
||||
@Schema(description = "累计扣分次数", example = "3")
|
||||
private Integer penaltyCount;
|
||||
|
||||
|
||||
@ -251,9 +251,9 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
.sum();
|
||||
|
||||
// 获取最新余额
|
||||
Double latestBalance = null;
|
||||
java.math.BigDecimal latestBalance = null;
|
||||
if (!monthlyConsumptions.isEmpty() && monthlyConsumptions.get(0).getBalance() != null) {
|
||||
latestBalance = monthlyConsumptions.get(0).getBalance().doubleValue();
|
||||
latestBalance = java.math.BigDecimal.valueOf(monthlyConsumptions.get(0).getBalance().doubleValue());
|
||||
}
|
||||
if (latestBalance == null) {
|
||||
ConsumptionDO latestConsumption = consumptionMapper.selectOne(new LambdaQueryWrapper<ConsumptionDO>()
|
||||
@ -262,7 +262,7 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
.orderByDesc(ConsumptionDO::getTradeTime)
|
||||
.last("LIMIT 1"));
|
||||
if (latestConsumption != null && latestConsumption.getBalance() != null) {
|
||||
latestBalance = latestConsumption.getBalance().doubleValue();
|
||||
latestBalance = java.math.BigDecimal.valueOf(latestConsumption.getBalance().doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,6 +316,13 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
.eq(SituationDO::getCategory, 1)); // 监管安全类型
|
||||
vo.setViolationCount(violationCount != null ? violationCount.intValue() : 0);
|
||||
|
||||
// 8.1 查询累计表扬次数(狱情收集-表扬类型)
|
||||
Long praiseCount = situationMapper.selectCount(new LambdaQueryWrapper<SituationDO>()
|
||||
.eq(SituationDO::getAreaId, prisoner.getAreaId())
|
||||
.eq(SituationDO::getStatus, 3) // 已处理
|
||||
.eq(SituationDO::getCategory, 2)); // 表扬类型
|
||||
vo.setPraiseCount(praiseCount != null ? praiseCount.intValue() : 0);
|
||||
|
||||
// 9. 查询累计计分考核记录(统计加分和扣分次数)
|
||||
List<ScoreDO> allScores = scoreMapper.selectList(new LambdaQueryWrapper<ScoreDO>()
|
||||
.eq(ScoreDO::getPrisonerId, prisonerId)
|
||||
@ -446,7 +453,7 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
vo.setConsumptionMonthlyData(monthlyDataList);
|
||||
|
||||
// ==================== 查询账户余额 ====================
|
||||
java.math.BigDecimal latestBalance = consumptionMapper.selectLatestBalance(prisonerId);
|
||||
latestBalance = consumptionMapper.selectLatestBalance(prisonerId);
|
||||
vo.setBalance(latestBalance != null ? latestBalance.intValue() : 0);
|
||||
|
||||
// ==================== 构建计分考核记录 ====================
|
||||
@ -500,17 +507,41 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
.collect(Collectors.toList());
|
||||
vo.setConsumptionRecords(consumptionRecords);
|
||||
|
||||
// ==================== 构建奖惩记录 ====================
|
||||
List<Map<String, Object>> rewardsPunishmentsList = dashboardMapper.selectRecentRewardsPunishments(prisonerId);
|
||||
List<PrisonerDashboardStatsRespVO.RewardsPunishment> rewardsPunishments = rewardsPunishmentsList.stream()
|
||||
.map(rp -> {
|
||||
Object typeObj = rp.get("type");
|
||||
int type = typeObj != null ? Integer.parseInt(typeObj.toString()) : 1;
|
||||
// ==================== 构建风险评估记录 ====================
|
||||
List<Map<String, Object>> riskList = dashboardMapper.selectRecentRiskAssessments(prisonerId);
|
||||
List<PrisonerDashboardStatsRespVO.RewardsPunishment> rewardsPunishments = riskList.stream()
|
||||
.map(r -> {
|
||||
Object dateObj = r.get("assessment_date");
|
||||
Object scoreObj = r.get("overall_score");
|
||||
Object levelObj = r.get("risk_level");
|
||||
Object violenceObj = r.get("violence_risk");
|
||||
Object escapeObj = r.get("escape_risk");
|
||||
Object selfHarmObj = r.get("self_harm_risk");
|
||||
Object mentalObj = r.get("mental_state");
|
||||
Object assessorObj = r.get("assessor_name");
|
||||
|
||||
String date = dateObj != null ? dateObj.toString().substring(0, 10) : "";
|
||||
String localLevelText = "低风险";
|
||||
if (levelObj != null) {
|
||||
int level = Integer.parseInt(levelObj.toString());
|
||||
localLevelText = switch (level) {
|
||||
case 1 -> "低风险";
|
||||
case 2 -> "中风险";
|
||||
case 3 -> "高风险";
|
||||
case 4 -> "极高风险";
|
||||
default -> "未知";
|
||||
};
|
||||
}
|
||||
|
||||
String content = String.format("综合得分: %s | 风险等级: %s",
|
||||
scoreObj != null ? scoreObj.toString() : "0",
|
||||
localLevelText);
|
||||
|
||||
return PrisonerDashboardStatsRespVO.RewardsPunishment.builder()
|
||||
.date(rp.get("occur_date") != null ? rp.get("occur_date").toString().substring(0, 10) : "")
|
||||
.type(type == 1 ? "reward" : "punishment")
|
||||
.typeText(rp.get("category") != null ? rp.get("category").toString() : (type == 1 ? "表扬奖励" : "惩罚"))
|
||||
.content(rp.get("content") != null ? rp.get("content").toString() : "")
|
||||
.date(date)
|
||||
.type("danger")
|
||||
.typeText("风险评估")
|
||||
.content(content)
|
||||
.build();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user