chore: 提交本地修改后更新子模块
This commit is contained in:
parent
011b505a80
commit
0984924431
@ -15,6 +15,8 @@ import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -108,4 +110,31 @@ public class PrisonConsumptionController {
|
||||
ExcelUtils.write(response, "消费订单.xls", "数据", ConsumptionRespVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获取消费记录导入模板")
|
||||
public void getImportTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<ConsumptionImportExcelVO> list = Arrays.asList(
|
||||
ConsumptionImportExcelVO.builder()
|
||||
.prisonerNo("ZF20230001")
|
||||
.type(1)
|
||||
.totalAmount(new java.math.BigDecimal("50.00"))
|
||||
.tradeTime("2024-01-15 10:30:00")
|
||||
.status(1)
|
||||
.remark("示例数据")
|
||||
.build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "消费记录导入模板.xls", "消费记录", ConsumptionImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入消费记录")
|
||||
@PreAuthorize("@ss.hasPermission('prison:consumption:import')")
|
||||
public CommonResult<ImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<ConsumptionImportExcelVO> list = ExcelUtils.read(file, ConsumptionImportExcelVO.class);
|
||||
ImportRespVO respVO = consumptionService.importConsumption(list);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.consumption.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 消费记录导入 Excel VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "消费记录导入 Excel VO")
|
||||
public class ConsumptionImportExcelVO {
|
||||
|
||||
@ExcelProperty("罪犯编号")
|
||||
private String prisonerNo;
|
||||
|
||||
@ExcelProperty("类型(1-购物 2-餐饮 3-医疗 4-通讯 5-其他)")
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty("订单总金额")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
@ExcelProperty("交易时间(yyyy-MM-dd HH:mm:ss)")
|
||||
private String tradeTime;
|
||||
|
||||
@ExcelProperty("状态(1-成功 2-失败)")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -1,15 +1,21 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.dashboard;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.dashboard.vo.DashboardStatisticsVO;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.dashboard.vo.PrisonerDashboardStatsRespVO;
|
||||
import cn.iocoder.yudao.module.prison.service.dashboard.PrisonDashboardService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 管理后台 - 监管看板
|
||||
*
|
||||
@ -30,4 +36,12 @@ public class PrisonDashboardController {
|
||||
return dashboardService.getDashboardStatistics();
|
||||
}
|
||||
|
||||
@GetMapping("/prisoner-stats")
|
||||
@Operation(summary = "获取罪犯工作台统计数据")
|
||||
@Parameter(name = "prisonerId", description = "罪犯ID", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('prison:dashboard:query')")
|
||||
public CommonResult<PrisonerDashboardStatsRespVO> getPrisonerStats(@RequestParam("prisonerId") Long prisonerId) {
|
||||
return success(dashboardService.getPrisonerStats(prisonerId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,222 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.dashboard.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 罪犯工作台统计响应 VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "管理后台 - 罪犯工作台统计 Response VO")
|
||||
public class PrisonerDashboardStatsRespVO {
|
||||
|
||||
@Schema(description = "罪犯姓名", example = "张三")
|
||||
private String prisonerName;
|
||||
|
||||
@Schema(description = "监区信息", example = "一监区一分监区")
|
||||
private String prisonArea;
|
||||
|
||||
@Schema(description = "罪犯编号", example = "ZF20230001")
|
||||
private String prisonerNo;
|
||||
|
||||
@Schema(description = "入狱时间", example = "2023-01-15")
|
||||
private String imprisonmentDate;
|
||||
|
||||
@Schema(description = "出狱时间", example = "2028-01-14")
|
||||
private String releaseDate;
|
||||
|
||||
@Schema(description = "已服刑天数", example = "365")
|
||||
private Integer servedDays;
|
||||
|
||||
@Schema(description = "年龄", example = "35")
|
||||
private Integer age;
|
||||
|
||||
@Schema(description = "籍贯", example = "浙江省杭州市")
|
||||
private String nativePlace;
|
||||
|
||||
@Schema(description = "文化程度", example = "大专")
|
||||
private String education;
|
||||
|
||||
@Schema(description = "婚姻状况", example = "已婚")
|
||||
private String maritalStatus;
|
||||
|
||||
@Schema(description = "子女情况", example = "一子一女")
|
||||
private String children;
|
||||
|
||||
@Schema(description = "出生日期", example = "1990-05-20")
|
||||
private String birthDate;
|
||||
|
||||
@Schema(description = "犯罪类型", example = "盗窃罪")
|
||||
private String crimeType;
|
||||
|
||||
@Schema(description = "前科次数", example = "0")
|
||||
private String previousConvictions;
|
||||
|
||||
@Schema(description = "刑期", example = "5年")
|
||||
private String sentence;
|
||||
|
||||
@Schema(description = "风险评估分", example = "35")
|
||||
private Integer riskScore;
|
||||
|
||||
@Schema(description = "风险等级:1-低风险 2-中风险 3-高风险 4-极高风险", example = "1")
|
||||
private Integer riskLevel;
|
||||
|
||||
@Schema(description = "中心左侧数据")
|
||||
private CenterLeftData centerLeftData;
|
||||
|
||||
@Schema(description = "中心右侧数据")
|
||||
private CenterRightData centerRightData;
|
||||
|
||||
@Schema(description = "月度消费数据")
|
||||
private List<MonthlyConsumptionData> consumptionMonthlyData;
|
||||
|
||||
@Schema(description = "消费汇总")
|
||||
private ConsumptionSummary consumptionSummary;
|
||||
|
||||
@Schema(description = "心理访谈记录")
|
||||
private List<InterviewRecord> interviewRecords;
|
||||
|
||||
@Schema(description = "近期奖惩记录")
|
||||
private List<RewardsPunishment> rewardsPunishments;
|
||||
|
||||
@Schema(description = "计分考核记录")
|
||||
private List<ScoreRecord> scoreRecords;
|
||||
|
||||
@Schema(description = "消费记录")
|
||||
private List<ConsumptionRecord> consumptionRecords;
|
||||
|
||||
@Schema(description = "汇款记录")
|
||||
private List<RemittanceRecord> remittanceRecords;
|
||||
|
||||
@Schema(description = "关系人信息")
|
||||
private List<RelationshipInfo> relationships;
|
||||
|
||||
// ==================== 内部类定义 ====================
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CenterLeftData {
|
||||
private String topValue;
|
||||
private String topLabel;
|
||||
private String middleLeftValue;
|
||||
private String middleLeftLabel;
|
||||
private String middleRightValue;
|
||||
private String middleRightLabel;
|
||||
private String bottomValue;
|
||||
private String bottomLabel;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CenterRightData {
|
||||
private String topValue;
|
||||
private String topLabel;
|
||||
private String middleLeftValue;
|
||||
private String middleLeftLabel;
|
||||
private String middleRightValue;
|
||||
private String middleRightLabel;
|
||||
private String bottomLeftValue;
|
||||
private String bottomLeftLabel;
|
||||
private String bottomRightValue;
|
||||
private String bottomRightLabel;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MonthlyConsumptionData {
|
||||
private String category;
|
||||
private Integer monthlyStandard;
|
||||
private Integer perCapita;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ConsumptionSummary {
|
||||
private Integer inProgress;
|
||||
private Integer toWarehouse;
|
||||
private Integer outWarehouse;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class InterviewRecord {
|
||||
private String date;
|
||||
private String content;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RewardsPunishment {
|
||||
private String date;
|
||||
private String type;
|
||||
private String typeText;
|
||||
private String content;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ScoreRecord {
|
||||
private String date;
|
||||
private String score;
|
||||
private String scoreType;
|
||||
private Integer finalScore;
|
||||
private String level;
|
||||
private String levelText;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ConsumptionRecord {
|
||||
private String date;
|
||||
private String name;
|
||||
private String nameColor;
|
||||
private String category;
|
||||
private Integer amount;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RemittanceRecord {
|
||||
private String date;
|
||||
private String name;
|
||||
private String nameColor;
|
||||
private String category;
|
||||
private Integer amount;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class RelationshipInfo {
|
||||
private String name;
|
||||
private String relate;
|
||||
private String color;
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.risk;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.risk.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.risk.RiskDO;
|
||||
import cn.iocoder.yudao.module.prison.service.risk.RiskService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
@ -11,6 +13,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.convert.risk.RiskConvert;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -100,4 +103,34 @@ public class RiskController {
|
||||
RiskConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获取风险评估导入模板")
|
||||
public void getImportTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<RiskImportExcelVO> list = Arrays.asList(
|
||||
RiskImportExcelVO.builder()
|
||||
.prisonerNo("ZF20230001")
|
||||
.assessmentDate("2024-01-15")
|
||||
.riskScore(new java.math.BigDecimal("45"))
|
||||
.riskLevel(2)
|
||||
.riskDescription("中等风险人员")
|
||||
.riskFactors("有脱逃倾向,近期情绪异常")
|
||||
.suggestions("加强监管,定期心理疏导")
|
||||
.assessorName("王警官")
|
||||
.remark("示例数据")
|
||||
.build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "风险评估导入模板.xls", "风险评估", RiskImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入风险评估")
|
||||
@PreAuthorize("@ss.hasPermission('prison:risk:import')")
|
||||
public CommonResult<ImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<RiskImportExcelVO> list = ExcelUtils.read(file, RiskImportExcelVO.class);
|
||||
ImportRespVO respVO = riskService.importRisk(list);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.risk.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 风险评估导入 Excel VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "风险评估导入 Excel VO")
|
||||
public class RiskImportExcelVO {
|
||||
|
||||
@ExcelProperty("罪犯编号")
|
||||
private String prisonerNo;
|
||||
|
||||
@ExcelProperty("评估日期(yyyy-MM-dd)")
|
||||
private String assessmentDate;
|
||||
|
||||
@ExcelProperty("风险分数")
|
||||
private BigDecimal riskScore;
|
||||
|
||||
@ExcelProperty("风险等级(1-低风险 2-中风险 3-高风险 4-极高风险)")
|
||||
private Integer riskLevel;
|
||||
|
||||
@ExcelProperty("风险描述")
|
||||
private String riskDescription;
|
||||
|
||||
@ExcelProperty("风险因素")
|
||||
private String riskFactors;
|
||||
|
||||
@ExcelProperty("管控建议")
|
||||
private String suggestions;
|
||||
|
||||
@ExcelProperty("评估人姓名")
|
||||
private String assessorName;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -1,15 +1,18 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.riskassessment;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.riskassessment.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.service.riskassessment.RiskAssessmentService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@ -99,4 +102,36 @@ public class RiskAssessmentController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获取危险评估导入模板")
|
||||
public void getImportTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<RiskAssessmentImportExcelVO> list = Arrays.asList(
|
||||
RiskAssessmentImportExcelVO.builder()
|
||||
.prisonerNo("ZF20230001")
|
||||
.assessmentType(1)
|
||||
.assessmentDate("2024-01-15")
|
||||
.violenceScore(new java.math.BigDecimal("20"))
|
||||
.escapeScore(new java.math.BigDecimal("15"))
|
||||
.suicideScore(new java.math.BigDecimal("10"))
|
||||
.totalScore(new java.math.BigDecimal("45"))
|
||||
.riskLevel(2)
|
||||
.riskFactors("有暴力倾向")
|
||||
.suggestions("加强监管")
|
||||
.assessorName("李警官")
|
||||
.build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "危险评估导入模板.xls", "危险评估", RiskAssessmentImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入危险评估")
|
||||
@PreAuthorize("@ss.hasPermission('prison:risk-assessment:import')")
|
||||
public CommonResult<ImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<RiskAssessmentImportExcelVO> list = ExcelUtils.read(file, RiskAssessmentImportExcelVO.class);
|
||||
ImportRespVO respVO = riskAssessmentService.importRiskAssessment(list);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.riskassessment.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 危险评估导入 Excel VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "危险评估导入 Excel VO")
|
||||
public class RiskAssessmentImportExcelVO {
|
||||
|
||||
@ExcelProperty("罪犯编号")
|
||||
private String prisonerNo;
|
||||
|
||||
@ExcelProperty("评估类型(1-入狱评估 2-定期评估 3-专项评估)")
|
||||
private Integer assessmentType;
|
||||
|
||||
@ExcelProperty("评估日期(yyyy-MM-dd)")
|
||||
private String assessmentDate;
|
||||
|
||||
@ExcelProperty("暴力倾向得分")
|
||||
private BigDecimal violenceScore;
|
||||
|
||||
@ExcelProperty("脱逃倾向得分")
|
||||
private BigDecimal escapeScore;
|
||||
|
||||
@ExcelProperty("自杀倾向得分")
|
||||
private BigDecimal suicideScore;
|
||||
|
||||
@ExcelProperty("综合得分")
|
||||
private BigDecimal totalScore;
|
||||
|
||||
@ExcelProperty("风险等级(1-低风险 2-中风险 3-高风险 4-极高风险)")
|
||||
private Integer riskLevel;
|
||||
|
||||
@ExcelProperty("风险因素")
|
||||
private String riskFactors;
|
||||
|
||||
@ExcelProperty("管控建议")
|
||||
private String suggestions;
|
||||
|
||||
@ExcelProperty("评估人姓名")
|
||||
private String assessorName;
|
||||
|
||||
}
|
||||
@ -15,6 +15,8 @@ import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -96,4 +98,34 @@ public class PrisonScoreController {
|
||||
ExcelUtils.write(response, "计分考核.xls", "数据", ScoreRespVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获取计分考核导入模板")
|
||||
public void getImportTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<ScoreImportExcelVO> list = Arrays.asList(
|
||||
ScoreImportExcelVO.builder()
|
||||
.prisonerNo("ZF20230001")
|
||||
.year(2024)
|
||||
.month(1)
|
||||
.baseScore(new java.math.BigDecimal("80"))
|
||||
.rewardScore(new java.math.BigDecimal("5"))
|
||||
.penaltyScore(new java.math.BigDecimal("2"))
|
||||
.level(2)
|
||||
.assessorName("张警官")
|
||||
.remark("示例数据")
|
||||
.build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "计分考核导入模板.xls", "计分考核", ScoreImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入计分考核")
|
||||
@PreAuthorize("@ss.hasPermission('prison:score:import')")
|
||||
public CommonResult<ImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<ScoreImportExcelVO> list = ExcelUtils.read(file, ScoreImportExcelVO.class);
|
||||
ImportRespVO respVO = scoreService.importScore(list);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.score.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 计分考核导入 Excel VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "计分考核导入 Excel VO")
|
||||
public class ScoreImportExcelVO {
|
||||
|
||||
@ExcelProperty("罪犯编号")
|
||||
private String prisonerNo;
|
||||
|
||||
@ExcelProperty("考核年份")
|
||||
private Integer year;
|
||||
|
||||
@ExcelProperty("考核月份")
|
||||
private Integer month;
|
||||
|
||||
@ExcelProperty("基础分")
|
||||
private BigDecimal baseScore;
|
||||
|
||||
@ExcelProperty("加分")
|
||||
private BigDecimal rewardScore;
|
||||
|
||||
@ExcelProperty("扣分")
|
||||
private BigDecimal penaltyScore;
|
||||
|
||||
@ExcelProperty("考核等级(1-优秀 2-良好 3-合格 4-不合格)")
|
||||
private Integer level;
|
||||
|
||||
@ExcelProperty("考核人姓名")
|
||||
private String assessorName;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.situation;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.situation.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.situation.SituationDO;
|
||||
import cn.iocoder.yudao.module.prison.service.situation.SituationService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
@ -11,6 +13,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.convert.situation.SituationConvert;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -109,4 +112,34 @@ public class SituationController {
|
||||
SituationConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获取狱情收集导入模板")
|
||||
public void getImportTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<SituationImportExcelVO> list = Arrays.asList(
|
||||
SituationImportExcelVO.builder()
|
||||
.title("监室内发生争吵")
|
||||
.type(2)
|
||||
.level(1)
|
||||
.content("某日上午,一监区101室发生罪犯争吵")
|
||||
.occurTime("2024-01-15 10:30:00")
|
||||
.location("一监区101室")
|
||||
.involvedPrisonerNos("ZF20230001,ZF20230002")
|
||||
.reporter("张警官")
|
||||
.remark("示例数据")
|
||||
.build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "狱情收集导入模板.xls", "狱情收集", SituationImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入狱情收集")
|
||||
@PreAuthorize("@ss.hasPermission('prison:situation:import')")
|
||||
public CommonResult<ImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<SituationImportExcelVO> list = ExcelUtils.read(file, SituationImportExcelVO.class);
|
||||
ImportRespVO respVO = situationService.importSituation(list);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.situation.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 狱情收集导入 Excel VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "狱情收集导入 Excel VO")
|
||||
public class SituationImportExcelVO {
|
||||
|
||||
@ExcelProperty("标题")
|
||||
private String title;
|
||||
|
||||
@ExcelProperty("狱情类型(1-安全类 2-监管类 3-改造类 4-生产类 5-生活卫生类 6-其他)")
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty("狱情等级(1-一般 2-重要 3-紧急 4-严重)")
|
||||
private Integer level;
|
||||
|
||||
@ExcelProperty("内容")
|
||||
private String content;
|
||||
|
||||
@ExcelProperty("发生时间(yyyy-MM-dd HH:mm:ss)")
|
||||
private String occurTime;
|
||||
|
||||
@ExcelProperty("发生地点")
|
||||
private String location;
|
||||
|
||||
@ExcelProperty("涉及罪犯编号(多个用逗号分隔)")
|
||||
private String involvedPrisonerNos;
|
||||
|
||||
@ExcelProperty("报告人")
|
||||
private String reporter;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用导入结果 VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Schema(description = "管理后台 - 通用导入结果 Response VO")
|
||||
public class ImportRespVO {
|
||||
|
||||
@Schema(description = "成功导入条数", example = "10")
|
||||
private Integer successCount;
|
||||
|
||||
@Schema(description = "失败导入条数", example = "2")
|
||||
private Integer failureCount;
|
||||
|
||||
@Schema(description = "失败记录详情,key为行号,value为失败原因")
|
||||
private Map<Integer, String> failureRecords;
|
||||
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.warning;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.warning.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.warning.WarningDO;
|
||||
import cn.iocoder.yudao.module.prison.service.warning.WarningService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
@ -11,6 +13,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.convert.warning.WarningConvert;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -100,4 +103,33 @@ public class WarningController {
|
||||
WarningConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获取预警信息导入模板")
|
||||
public void getImportTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<WarningImportExcelVO> list = Arrays.asList(
|
||||
WarningImportExcelVO.builder()
|
||||
.title("发现可疑行为")
|
||||
.content("某罪犯在放风期间有异常行为")
|
||||
.type(1)
|
||||
.level(2)
|
||||
.source(1)
|
||||
.alertTime("2024-01-15 10:30:00")
|
||||
.occurTime("2024-01-15 10:00:00")
|
||||
.remark("示例数据")
|
||||
.build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "预警信息导入模板.xls", "预警信息", WarningImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入预警信息")
|
||||
@PreAuthorize("@ss.hasPermission('prison:warning:import')")
|
||||
public CommonResult<ImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
List<WarningImportExcelVO> list = ExcelUtils.read(file, WarningImportExcelVO.class);
|
||||
ImportRespVO respVO = warningService.importWarning(list);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.prison.controller.admin.warning.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 预警管理导入 Excel VO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "预警管理导入 Excel VO")
|
||||
public class WarningImportExcelVO {
|
||||
|
||||
@ExcelProperty("预警标题")
|
||||
private String title;
|
||||
|
||||
@ExcelProperty("预警内容")
|
||||
private String content;
|
||||
|
||||
@ExcelProperty("预警类型(1-安全预警 2-监管预警 3-改造预警 4-生产预警 5-生活卫生预警 6-其他)")
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty("预警等级(1-一般 2-重要 3-紧急 4-严重)")
|
||||
private Integer level;
|
||||
|
||||
@ExcelProperty("预警来源(1-民警报告 2-监控系统 3-举报 4-罪犯自首 5-智能分析 6-其他)")
|
||||
private Integer source;
|
||||
|
||||
@ExcelProperty("预警时间(yyyy-MM-dd HH:mm:ss)")
|
||||
private String alertTime;
|
||||
|
||||
@ExcelProperty("发生时间(yyyy-MM-dd HH:mm:ss)")
|
||||
private String occurTime;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -28,9 +28,12 @@ public class ErrorCodeConstants {
|
||||
|
||||
// ========== 计分考核 4xxxx ==========
|
||||
public static final ErrorCode PRISON_SCORE_NOT_EXISTS = new ErrorCode(4_000_001, "计分记录不存在");
|
||||
public static final ErrorCode SCORE_IMPORT_LIST_IS_EMPTY = new ErrorCode(4_000_002, "计分考核导入数据不能为空");
|
||||
|
||||
// ========== 危险评估 5xxxx ==========
|
||||
public static final ErrorCode PRISON_RISK_NOT_EXISTS = new ErrorCode(5_000_001, "评估记录不存在");
|
||||
public static final ErrorCode RISK_ASSESSMENT_IMPORT_LIST_IS_EMPTY = new ErrorCode(5_000_002, "危险评估导入数据不能为空");
|
||||
public static final ErrorCode RISK_IMPORT_LIST_IS_EMPTY = new ErrorCode(5_000_003, "风险评估导入数据不能为空");
|
||||
|
||||
// ========== 问卷管理 6xxxx ==========
|
||||
public static final ErrorCode PRISON_QUESTIONNAIRE_NOT_EXISTS = new ErrorCode(6_000_001, "问卷不存在");
|
||||
@ -42,6 +45,7 @@ public class ErrorCodeConstants {
|
||||
public static final ErrorCode PRISON_CONSUMPTION_AMOUNT_MISMATCH = new ErrorCode(7_000_002, "消费明细金额与订单总金额不一致");
|
||||
public static final ErrorCode PRISON_CONSUMPTION_DETAIL_EMPTY = new ErrorCode(7_000_003, "消费明细不能为空");
|
||||
public static final ErrorCode PRISON_CONSUMPTION_DETAIL_INVALID = new ErrorCode(7_000_004, "消费明细数据不合法,请检查商品名称、单价和数量");
|
||||
public static final ErrorCode CONSUMPTION_IMPORT_LIST_IS_EMPTY = new ErrorCode(7_000_005, "消费记录导入数据不能为空");
|
||||
|
||||
// ========== 罪犯监区变动记录 8xxxx ==========
|
||||
public static final ErrorCode PRISONER_AREA_LOG_NOT_EXISTS = new ErrorCode(8_000_001, "罪犯监区变动记录不存在");
|
||||
@ -56,9 +60,11 @@ public class ErrorCodeConstants {
|
||||
|
||||
// ========== 狱情收集 11xxxx ==========
|
||||
public static final ErrorCode PRISON_SITUATION_NOT_EXISTS = new ErrorCode(11_000_001, "狱情记录不存在");
|
||||
public static final ErrorCode SITUATION_IMPORT_LIST_IS_EMPTY = new ErrorCode(11_000_002, "狱情收集导入数据不能为空");
|
||||
|
||||
// ========== 预警管理 12xxxx ==========
|
||||
public static final ErrorCode PRISON_WARNING_NOT_EXISTS = new ErrorCode(12_000_001, "预警记录不存在");
|
||||
public static final ErrorCode WARNING_IMPORT_LIST_IS_EMPTY = new ErrorCode(12_000_002, "预警信息导入数据不能为空");
|
||||
|
||||
// ========== 别名 (兼容codegen生成的代码) ==========
|
||||
public static final ErrorCode AREA_NOT_EXISTS = PRISON_AREA_NOT_EXISTS;
|
||||
|
||||
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.prison.service.consumption;
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.consumption.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.consumption.ConsumptionDetailDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -67,4 +68,12 @@ public interface ConsumptionService {
|
||||
*/
|
||||
List<ConsumptionDetailDO> getConsumptionDetailList(Long consumptionId);
|
||||
|
||||
/**
|
||||
* 导入消费记录
|
||||
*
|
||||
* @param list 导入数据列表
|
||||
* @return 导入结果
|
||||
*/
|
||||
ImportRespVO importConsumption(List<ConsumptionImportExcelVO> list);
|
||||
|
||||
}
|
||||
|
||||
@ -11,8 +11,11 @@ import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.consumption.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.PrisonerDO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.consumption.ConsumptionDO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.consumption.ConsumptionDetailDO;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.PrisonerMapper;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.consumption.ConsumptionMapper;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.consumption.ConsumptionDetailMapper;
|
||||
import cn.iocoder.yudao.module.prison.convert.consumption.ConsumptionConvert;
|
||||
@ -40,6 +43,9 @@ public class ConsumptionServiceImpl implements ConsumptionService {
|
||||
@Resource
|
||||
private ConsumptionDetailMapper consumptionDetailMapper;
|
||||
|
||||
@Resource
|
||||
private PrisonerMapper prisonerMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createConsumption(ConsumptionSaveReqVO createReqVO) {
|
||||
@ -150,4 +156,66 @@ public class ConsumptionServiceImpl implements ConsumptionService {
|
||||
return "CS" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ImportRespVO importConsumption(List<ConsumptionImportExcelVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(CONSUMPTION_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
Map<Integer, String> failureRecords = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ConsumptionImportExcelVO importVO = list.get(i);
|
||||
int rowNum = i + 2; // Excel行号从2开始(1是表头)
|
||||
try {
|
||||
// 1. 校验罪犯编号
|
||||
if (StrUtil.isBlank(importVO.getPrisonerNo())) {
|
||||
failureRecords.put(rowNum, "罪犯编号不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. 根据罪犯编号查询罪犯
|
||||
PrisonerDO prisoner = prisonerMapper.selectByPrisonerNo(importVO.getPrisonerNo());
|
||||
if (prisoner == null) {
|
||||
failureRecords.put(rowNum, "罪犯编号不存在:" + importVO.getPrisonerNo());
|
||||
continue;
|
||||
}
|
||||
|
||||
// 3. 创建消费记录
|
||||
ConsumptionDO consumption = new ConsumptionDO();
|
||||
consumption.setPrisonerId(prisoner.getId());
|
||||
consumption.setOrderNo(generateOrderNo());
|
||||
consumption.setType(importVO.getType());
|
||||
consumption.setTotalAmount(importVO.getTotalAmount());
|
||||
consumption.setStatus(importVO.getStatus() != null ? importVO.getStatus() : 1);
|
||||
consumption.setRemark(importVO.getRemark());
|
||||
|
||||
// 处理交易时间
|
||||
if (StrUtil.isNotBlank(importVO.getTradeTime())) {
|
||||
try {
|
||||
consumption.setTradeTime(java.time.LocalDateTime.parse(importVO.getTradeTime(),
|
||||
java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
} catch (Exception e) {
|
||||
consumption.setTradeTime(java.time.LocalDateTime.now());
|
||||
}
|
||||
} else {
|
||||
consumption.setTradeTime(java.time.LocalDateTime.now());
|
||||
}
|
||||
|
||||
consumptionMapper.insert(consumption);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
failureRecords.put(rowNum, "导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return ImportRespVO.builder()
|
||||
.successCount(successCount)
|
||||
.failureCount(failureRecords.size())
|
||||
.failureRecords(failureRecords)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.prison.service.dashboard;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.dashboard.vo.DashboardStatisticsVO;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.dashboard.vo.PrisonerDashboardStatsRespVO;
|
||||
|
||||
/**
|
||||
* 监管看板 Service 接口
|
||||
@ -16,4 +17,12 @@ public interface PrisonDashboardService {
|
||||
*/
|
||||
DashboardStatisticsVO getDashboardStatistics();
|
||||
|
||||
/**
|
||||
* 获取罪犯工作台统计数据
|
||||
*
|
||||
* @param prisonerId 罪犯ID
|
||||
* @return 罪犯工作台统计数据
|
||||
*/
|
||||
PrisonerDashboardStatsRespVO getPrisonerStats(Long prisonerId);
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.prison.service.dashboard.impl;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.dashboard.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.PrisonerDO;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.dashboard.PrisonDashboardMapper;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.PrisonerMapper;
|
||||
import cn.iocoder.yudao.module.prison.service.dashboard.PrisonDashboardService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -10,6 +12,10 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -24,6 +30,7 @@ import java.util.Map;
|
||||
public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
|
||||
private final PrisonDashboardMapper dashboardMapper;
|
||||
private final PrisonerMapper prisonerMapper;
|
||||
|
||||
private static final String CACHE_KEY = "prison:dashboard:statistics";
|
||||
|
||||
@ -142,4 +149,87 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
return provinceMap.getOrDefault(provinceCode, provinceCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrisonerDashboardStatsRespVO getPrisonerStats(Long prisonerId) {
|
||||
// 获取罪犯基本信息
|
||||
PrisonerDO prisoner = prisonerMapper.selectById(prisonerId);
|
||||
if (prisoner == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PrisonerDashboardStatsRespVO vo = new PrisonerDashboardStatsRespVO();
|
||||
|
||||
// 基本信息
|
||||
vo.setPrisonerName(prisoner.getName());
|
||||
vo.setPrisonerNo(prisoner.getPrisonerNo());
|
||||
vo.setNativePlace(prisoner.getNativePlace());
|
||||
vo.setEducation(prisoner.getEducation());
|
||||
vo.setMaritalStatus(prisoner.getMaritalStatus());
|
||||
vo.setCrimeType(prisoner.getCrimeType());
|
||||
vo.setSentence(prisoner.getSentence());
|
||||
|
||||
// 计算年龄
|
||||
if (prisoner.getBirthDate() != null) {
|
||||
vo.setBirthDate(prisoner.getBirthDate().toString());
|
||||
vo.setAge(Period.between(prisoner.getBirthDate(), LocalDate.now()).getYears());
|
||||
}
|
||||
|
||||
// 入狱和出狱时间
|
||||
if (prisoner.getImprisonmentDate() != null) {
|
||||
vo.setImprisonmentDate(prisoner.getImprisonmentDate().toString());
|
||||
vo.setServedDays((int) ChronoUnit.DAYS.between(prisoner.getImprisonmentDate(), LocalDate.now()));
|
||||
}
|
||||
if (prisoner.getReleaseDate() != null) {
|
||||
vo.setReleaseDate(prisoner.getReleaseDate().toString());
|
||||
}
|
||||
|
||||
// 监区信息(简单拼接)
|
||||
vo.setPrisonArea(prisoner.getAreaId() != null ? "监区" + prisoner.getAreaId() : "未分配");
|
||||
|
||||
// 默认风险等级
|
||||
vo.setRiskScore(0);
|
||||
vo.setRiskLevel(1);
|
||||
|
||||
// 构建中心数据(使用默认值)
|
||||
vo.setCenterLeftData(PrisonerDashboardStatsRespVO.CenterLeftData.builder()
|
||||
.topValue("0")
|
||||
.topLabel("本月消费")
|
||||
.middleLeftValue("0")
|
||||
.middleLeftLabel("本月奖励")
|
||||
.middleRightValue("0")
|
||||
.middleRightLabel("本月惩罚")
|
||||
.bottomValue("0")
|
||||
.bottomLabel("账户余额")
|
||||
.build());
|
||||
|
||||
vo.setCenterRightData(PrisonerDashboardStatsRespVO.CenterRightData.builder()
|
||||
.topValue("0")
|
||||
.topLabel("本月得分")
|
||||
.middleLeftValue("0")
|
||||
.middleLeftLabel("基础分")
|
||||
.middleRightValue("0")
|
||||
.middleRightLabel("加分项")
|
||||
.bottomLeftValue("0")
|
||||
.bottomLeftLabel("扣分项")
|
||||
.bottomRightValue("良好")
|
||||
.bottomRightLabel("考核等级")
|
||||
.build());
|
||||
|
||||
// 初始化空列表
|
||||
vo.setConsumptionMonthlyData(new ArrayList<>());
|
||||
vo.setConsumptionSummary(PrisonerDashboardStatsRespVO.ConsumptionSummary.builder()
|
||||
.inProgress(0)
|
||||
.toWarehouse(0)
|
||||
.outWarehouse(0)
|
||||
.build());
|
||||
vo.setInterviewRecords(new ArrayList<>());
|
||||
vo.setRewardsPunishments(new ArrayList<>());
|
||||
vo.setScoreRecords(new ArrayList<>());
|
||||
vo.setConsumptionRecords(new ArrayList<>());
|
||||
vo.setRemittanceRecords(new ArrayList<>());
|
||||
vo.setRelationships(new ArrayList<>());
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.prison.service.risk;
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.risk.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.risk.RiskDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -59,4 +60,12 @@ public interface RiskService {
|
||||
*/
|
||||
PageResult<RiskDO> getRiskPage(RiskPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导入风险评估
|
||||
*
|
||||
* @param list 导入数据列表
|
||||
* @return 导入结果
|
||||
*/
|
||||
ImportRespVO importRisk(List<RiskImportExcelVO> list);
|
||||
|
||||
}
|
||||
|
||||
@ -1,19 +1,26 @@
|
||||
package cn.iocoder.yudao.module.prison.service.risk.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.risk.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.PrisonerDO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.risk.RiskDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.risk.RiskMapper;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.PrisonerMapper;
|
||||
import cn.iocoder.yudao.module.prison.service.risk.RiskService;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -31,6 +38,9 @@ public class RiskServiceImpl implements RiskService {
|
||||
@Resource
|
||||
private RiskMapper riskMapper;
|
||||
|
||||
@Resource
|
||||
private PrisonerMapper prisonerMapper;
|
||||
|
||||
@Override
|
||||
public Long createRisk(RiskSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -79,4 +89,66 @@ public class RiskServiceImpl implements RiskService {
|
||||
return riskMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ImportRespVO importRisk(List<RiskImportExcelVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(RISK_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
Map<Integer, String> failureRecords = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
RiskImportExcelVO importVO = list.get(i);
|
||||
int rowNum = i + 2;
|
||||
try {
|
||||
if (StrUtil.isBlank(importVO.getPrisonerNo())) {
|
||||
failureRecords.put(rowNum, "罪犯编号不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
PrisonerDO prisoner = prisonerMapper.selectByPrisonerNo(importVO.getPrisonerNo());
|
||||
if (prisoner == null) {
|
||||
failureRecords.put(rowNum, "罪犯编号不存在:" + importVO.getPrisonerNo());
|
||||
continue;
|
||||
}
|
||||
|
||||
RiskDO risk = new RiskDO();
|
||||
risk.setPrisonerId(prisoner.getId());
|
||||
risk.setPrisonerNo(prisoner.getPrisonerNo());
|
||||
risk.setRiskScore(importVO.getRiskScore() != null ? importVO.getRiskScore() : BigDecimal.ZERO);
|
||||
risk.setRiskLevel(importVO.getRiskLevel());
|
||||
risk.setRiskDescription(importVO.getRiskDescription());
|
||||
risk.setRiskFactors(importVO.getRiskFactors());
|
||||
risk.setSuggestions(importVO.getSuggestions());
|
||||
risk.setAssessorName(importVO.getAssessorName());
|
||||
risk.setRemark(importVO.getRemark());
|
||||
risk.setStatus(1);
|
||||
|
||||
if (StrUtil.isNotBlank(importVO.getAssessmentDate())) {
|
||||
try {
|
||||
risk.setAssessmentDate(LocalDate.parse(importVO.getAssessmentDate(),
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
} catch (Exception e) {
|
||||
risk.setAssessmentDate(LocalDate.now());
|
||||
}
|
||||
} else {
|
||||
risk.setAssessmentDate(LocalDate.now());
|
||||
}
|
||||
|
||||
riskMapper.insert(risk);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
failureRecords.put(rowNum, "导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return ImportRespVO.builder()
|
||||
.successCount(successCount)
|
||||
.failureCount(failureRecords.size())
|
||||
.failureRecords(failureRecords)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.prison.service.riskassessment;
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.riskassessment.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.riskassessment.RiskAssessmentDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -59,4 +60,12 @@ public interface RiskAssessmentService {
|
||||
*/
|
||||
PageResult<RiskAssessmentRespVO> getRiskAssessmentPage(RiskAssessmentPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导入危险评估
|
||||
*
|
||||
* @param list 导入数据列表
|
||||
* @return 导入结果
|
||||
*/
|
||||
ImportRespVO importRiskAssessment(List<RiskAssessmentImportExcelVO> list);
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.prison.service.riskassessment;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -8,14 +9,19 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.riskassessment.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.PrisonerDO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.riskassessment.RiskAssessmentDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.riskassessment.RiskAssessmentMapper;
|
||||
import cn.iocoder.yudao.module.prison.dal.mysql.PrisonerMapper;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -36,6 +42,9 @@ public class RiskAssessmentServiceImpl implements RiskAssessmentService {
|
||||
@Resource
|
||||
private RiskAssessmentMapper riskAssessmentMapper;
|
||||
|
||||
@Resource
|
||||
private PrisonerMapper prisonerMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createRiskAssessment(RiskAssessmentSaveReqVO createReqVO) {
|
||||
@ -173,4 +182,69 @@ public class RiskAssessmentServiceImpl implements RiskAssessmentService {
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ImportRespVO importRiskAssessment(List<RiskAssessmentImportExcelVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(RISK_ASSESSMENT_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
Map<Integer, String> failureRecords = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
RiskAssessmentImportExcelVO importVO = list.get(i);
|
||||
int rowNum = i + 2;
|
||||
try {
|
||||
if (StrUtil.isBlank(importVO.getPrisonerNo())) {
|
||||
failureRecords.put(rowNum, "罪犯编号不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
PrisonerDO prisoner = prisonerMapper.selectByPrisonerNo(importVO.getPrisonerNo());
|
||||
if (prisoner == null) {
|
||||
failureRecords.put(rowNum, "罪犯编号不存在:" + importVO.getPrisonerNo());
|
||||
continue;
|
||||
}
|
||||
|
||||
RiskAssessmentDO assessment = new RiskAssessmentDO();
|
||||
assessment.setPrisonerId(prisoner.getId());
|
||||
assessment.setPrisonerNo(prisoner.getPrisonerNo());
|
||||
assessment.setAssessmentType(importVO.getAssessmentType());
|
||||
|
||||
if (StrUtil.isNotBlank(importVO.getAssessmentDate())) {
|
||||
try {
|
||||
assessment.setAssessmentDate(LocalDate.parse(importVO.getAssessmentDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
} catch (Exception e) {
|
||||
assessment.setAssessmentDate(LocalDate.now());
|
||||
}
|
||||
} else {
|
||||
assessment.setAssessmentDate(LocalDate.now());
|
||||
}
|
||||
|
||||
assessment.setViolenceScore(importVO.getViolenceScore());
|
||||
assessment.setEscapeScore(importVO.getEscapeScore());
|
||||
assessment.setSuicideScore(importVO.getSuicideScore());
|
||||
assessment.setTotalScore(importVO.getTotalScore() != null ? importVO.getTotalScore() :
|
||||
calculateTotalScore(importVO.getViolenceScore(), importVO.getEscapeScore(), importVO.getSuicideScore()));
|
||||
assessment.setRiskLevel(importVO.getRiskLevel());
|
||||
assessment.setRiskFactors(importVO.getRiskFactors());
|
||||
assessment.setSuggestions(importVO.getSuggestions());
|
||||
assessment.setAssessorName(importVO.getAssessorName());
|
||||
assessment.setStatus(1);
|
||||
|
||||
riskAssessmentMapper.insert(assessment);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
failureRecords.put(rowNum, "导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return ImportRespVO.builder()
|
||||
.successCount(successCount)
|
||||
.failureCount(failureRecords.size())
|
||||
.failureRecords(failureRecords)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.prison.service.score;
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.score.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.score.ScoreDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -59,4 +60,12 @@ public interface ScoreService {
|
||||
*/
|
||||
PageResult<ScoreRespVO> getScorePage(ScorePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导入计分考核
|
||||
*
|
||||
* @param list 导入数据列表
|
||||
* @return 导入结果
|
||||
*/
|
||||
ImportRespVO importScore(List<ScoreImportExcelVO> list);
|
||||
|
||||
}
|
||||
@ -6,7 +6,11 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.score.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.score.ScoreDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -115,4 +119,57 @@ public class ScoreServiceImpl implements ScoreService {
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ImportRespVO importScore(List<ScoreImportExcelVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(SCORE_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
Map<Integer, String> failureRecords = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ScoreImportExcelVO importVO = list.get(i);
|
||||
int rowNum = i + 2;
|
||||
try {
|
||||
if (StrUtil.isBlank(importVO.getPrisonerNo())) {
|
||||
failureRecords.put(rowNum, "罪犯编号不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
PrisonerDO prisoner = prisonerMapper.selectByPrisonerNo(importVO.getPrisonerNo());
|
||||
if (prisoner == null) {
|
||||
failureRecords.put(rowNum, "罪犯编号不存在:" + importVO.getPrisonerNo());
|
||||
continue;
|
||||
}
|
||||
|
||||
ScoreDO score = new ScoreDO();
|
||||
score.setPrisonerId(prisoner.getId());
|
||||
score.setPrisonAreaId(prisoner.getPrisonAreaId());
|
||||
score.setPrisonCellId(prisoner.getPrisonCellId());
|
||||
score.setYear(importVO.getYear());
|
||||
score.setMonth(importVO.getMonth());
|
||||
score.setBaseScore(importVO.getBaseScore() != null ? importVO.getBaseScore() : BigDecimal.valueOf(80));
|
||||
score.setRewardScore(importVO.getRewardScore() != null ? importVO.getRewardScore() : BigDecimal.ZERO);
|
||||
score.setPenaltyScore(importVO.getPenaltyScore() != null ? importVO.getPenaltyScore() : BigDecimal.ZERO);
|
||||
score.setTotalScore(score.getBaseScore().add(score.getRewardScore()).subtract(score.getPenaltyScore()));
|
||||
score.setLevel(importVO.getLevel());
|
||||
score.setStatus(1); // 待审核
|
||||
score.setRemark(importVO.getRemark());
|
||||
|
||||
scoreMapper.insert(score);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
failureRecords.put(rowNum, "导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return ImportRespVO.builder()
|
||||
.successCount(successCount)
|
||||
.failureCount(failureRecords.size())
|
||||
.failureRecords(failureRecords)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.prison.service.situation;
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.situation.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.situation.SituationDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -59,4 +60,12 @@ public interface SituationService {
|
||||
*/
|
||||
PageResult<SituationDO> getSituationPage(SituationPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导入狱情收集
|
||||
*
|
||||
* @param list 导入数据列表
|
||||
* @return 导入结果
|
||||
*/
|
||||
ImportRespVO importSituation(List<SituationImportExcelVO> list);
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package cn.iocoder.yudao.module.prison.service.situation.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.situation.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.situation.SituationDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -94,4 +98,56 @@ public class SituationServiceImpl implements SituationService {
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ImportRespVO importSituation(List<SituationImportExcelVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(SITUATION_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
Map<Integer, String> failureRecords = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SituationImportExcelVO importVO = list.get(i);
|
||||
int rowNum = i + 2;
|
||||
try {
|
||||
if (StrUtil.isBlank(importVO.getTitle())) {
|
||||
failureRecords.put(rowNum, "标题不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
SituationDO situation = new SituationDO();
|
||||
situation.setTitle(importVO.getTitle());
|
||||
situation.setType(importVO.getType());
|
||||
situation.setLevel(importVO.getLevel());
|
||||
situation.setContent(importVO.getContent());
|
||||
situation.setLocation(importVO.getLocation());
|
||||
situation.setReporter(importVO.getReporter());
|
||||
situation.setRemark(importVO.getRemark());
|
||||
situation.setStatus(1);
|
||||
|
||||
if (StrUtil.isNotBlank(importVO.getOccurTime())) {
|
||||
try {
|
||||
situation.setOccurTime(LocalDateTime.parse(importVO.getOccurTime(),
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
} catch (Exception e) {
|
||||
situation.setOccurTime(LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
situationMapper.insert(situation);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
failureRecords.put(rowNum, "导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return ImportRespVO.builder()
|
||||
.successCount(successCount)
|
||||
.failureCount(failureRecords.size())
|
||||
.failureRecords(failureRecords)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.prison.service.warning;
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.warning.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.warning.WarningDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -59,4 +60,12 @@ public interface WarningService {
|
||||
*/
|
||||
PageResult<WarningDO> getWarningPage(WarningPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 导入预警信息
|
||||
*
|
||||
* @param list 导入数据列表
|
||||
* @return 导入结果
|
||||
*/
|
||||
ImportRespVO importWarning(List<WarningImportExcelVO> list);
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package cn.iocoder.yudao.module.prison.service.warning.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.warning.vo.*;
|
||||
import cn.iocoder.yudao.module.prison.controller.admin.vo.ImportRespVO;
|
||||
import cn.iocoder.yudao.module.prison.dal.dataobject.warning.WarningDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -79,4 +83,64 @@ public class WarningServiceImpl implements WarningService {
|
||||
return warningMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ImportRespVO importWarning(List<WarningImportExcelVO> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception(WARNING_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
Map<Integer, String> failureRecords = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
WarningImportExcelVO importVO = list.get(i);
|
||||
int rowNum = i + 2;
|
||||
try {
|
||||
if (StrUtil.isBlank(importVO.getTitle())) {
|
||||
failureRecords.put(rowNum, "预警标题不能为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
WarningDO warning = new WarningDO();
|
||||
warning.setTitle(importVO.getTitle());
|
||||
warning.setContent(importVO.getContent());
|
||||
warning.setType(importVO.getType());
|
||||
warning.setLevel(importVO.getLevel());
|
||||
warning.setSource(importVO.getSource());
|
||||
warning.setRemark(importVO.getRemark());
|
||||
warning.setStatus(1);
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if (StrUtil.isNotBlank(importVO.getAlertTime())) {
|
||||
try {
|
||||
warning.setAlertTime(LocalDateTime.parse(importVO.getAlertTime(), formatter));
|
||||
} catch (Exception e) {
|
||||
warning.setAlertTime(LocalDateTime.now());
|
||||
}
|
||||
} else {
|
||||
warning.setAlertTime(LocalDateTime.now());
|
||||
}
|
||||
if (StrUtil.isNotBlank(importVO.getOccurTime())) {
|
||||
try {
|
||||
warning.setOccurTime(LocalDateTime.parse(importVO.getOccurTime(), formatter));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
warningMapper.insert(warning);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
failureRecords.put(rowNum, "导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return ImportRespVO.builder()
|
||||
.successCount(successCount)
|
||||
.failureCount(failureRecords.size())
|
||||
.failureRecords(failureRecords)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user