Showing
16 changed files
with
549 additions
and
115 deletions
... | ... | @@ -7,11 +7,13 @@ import com.ash.base.JsonResult; |
7 | 7 | import com.ash.base.OptionStatus; |
8 | 8 | import com.ash.base.excelOpt.ExcelErrorMessage; |
9 | 9 | import com.ash.entity.Case; |
10 | +import com.ash.entity.CaseAnalysis; | |
10 | 11 | import com.ash.entity.FileData; |
11 | 12 | import com.ash.enums.AnalysisStatusEnum; |
12 | 13 | import com.ash.enums.FileDataTypeEnum; |
13 | 14 | import com.ash.enums.ReviewStatusEnum; |
14 | 15 | import com.ash.excelData.CaseExcelData; |
16 | +import com.ash.service.CaseAnalysisService; | |
15 | 17 | import com.ash.service.CaseService; |
16 | 18 | import com.ash.service.FileDataService; |
17 | 19 | import com.ash.util.UUIDGenerator; |
... | ... | @@ -30,6 +32,7 @@ import java.net.URLEncoder; |
30 | 32 | import java.nio.charset.StandardCharsets; |
31 | 33 | import java.util.ArrayList; |
32 | 34 | import java.util.List; |
35 | +import java.util.Map; | |
33 | 36 | import java.util.Optional; |
34 | 37 | import java.util.stream.Collectors; |
35 | 38 | |
... | ... | @@ -44,6 +47,10 @@ public class CaseController extends BaseController { |
44 | 47 | @Resource |
45 | 48 | private FileDataService fileDataService; |
46 | 49 | |
50 | + @Resource | |
51 | + private CaseAnalysisService caseAnalysisService; | |
52 | + | |
53 | + | |
47 | 54 | @PostMapping("/save") |
48 | 55 | public JsonResult save(@RequestBody Case data) { |
49 | 56 | try { |
... | ... | @@ -129,6 +136,12 @@ public class CaseController extends BaseController { |
129 | 136 | page.setCurrent(pageNo); |
130 | 137 | page.setSize(pageSize); |
131 | 138 | Page<Case> dataPage = caseService.pageByCondition(params, page); |
139 | + if (CollectionUtils.isNotEmpty(dataPage.getRecords())) { | |
140 | + List<String> caseIds = dataPage.getRecords() | |
141 | + .stream().map(Case::getId).collect(Collectors.toList()); | |
142 | + Map<String, CaseAnalysis> caseAnalysisMap = caseAnalysisService.listByCaseId(caseIds); | |
143 | + dataPage.getRecords().forEach(e -> e.setAnalysis(caseAnalysisMap.get(e.getId()))); | |
144 | + } | |
132 | 145 | |
133 | 146 | return JsonResult.ok(OptionStatus.OPT_SUCCESS.getName(), dataPage); |
134 | 147 | |
... | ... | @@ -174,4 +187,40 @@ public class CaseController extends BaseController { |
174 | 187 | public JsonResult reAnalysis() throws IOException { |
175 | 188 | return JsonResult.ok(); |
176 | 189 | } |
190 | + | |
191 | + @PostMapping("/saveAnalysis") | |
192 | + public JsonResult save(@RequestBody CaseAnalysis analysis) { | |
193 | + try { | |
194 | + Boolean success = caseAnalysisService.save(analysis); | |
195 | + return new JsonResult(success, OptionStatus.OPT_SUCCESS.getName(), null); | |
196 | + } catch (Exception ex) { | |
197 | + ex.printStackTrace(); | |
198 | + log.error(ex.getMessage()); | |
199 | + return JsonResult.error(OptionStatus.OPT_ERROR.getName()); | |
200 | + } | |
201 | + } | |
202 | + | |
203 | + @PostMapping("/conformAnalysis") | |
204 | + public JsonResult conformAnalysis(@RequestBody CaseAnalysis analysis) { | |
205 | + try { | |
206 | + Boolean success = caseAnalysisService.conform(analysis); | |
207 | + return new JsonResult(success, OptionStatus.OPT_SUCCESS.getName(), null); | |
208 | + } catch (Exception ex) { | |
209 | + ex.printStackTrace(); | |
210 | + log.error(ex.getMessage()); | |
211 | + return JsonResult.error(OptionStatus.OPT_ERROR.getName()); | |
212 | + } | |
213 | + } | |
214 | + | |
215 | + @PostMapping("/cancelConform") | |
216 | + public JsonResult cancelConform(@RequestBody CaseAnalysis analysis) { | |
217 | + try { | |
218 | + Boolean success = caseAnalysisService.cancelConform(analysis); | |
219 | + return new JsonResult(success, OptionStatus.OPT_SUCCESS.getName(), null); | |
220 | + } catch (Exception ex) { | |
221 | + ex.printStackTrace(); | |
222 | + log.error(ex.getMessage()); | |
223 | + return JsonResult.error(OptionStatus.OPT_ERROR.getName()); | |
224 | + } | |
225 | + } | |
177 | 226 | } | ... | ... |
... | ... | @@ -8,11 +8,13 @@ import com.ash.base.OptionStatus; |
8 | 8 | import com.ash.base.excelOpt.ExcelErrorMessage; |
9 | 9 | import com.ash.entity.FileData; |
10 | 10 | import com.ash.entity.WarningInstance; |
11 | +import com.ash.entity.WarningInstanceAnalysis; | |
11 | 12 | import com.ash.enums.AnalysisStatusEnum; |
12 | 13 | import com.ash.enums.FileDataTypeEnum; |
13 | 14 | import com.ash.enums.ReviewStatusEnum; |
14 | 15 | import com.ash.excelData.WarningInstanceExcelData; |
15 | 16 | import com.ash.service.FileDataService; |
17 | +import com.ash.service.WarningInstanceAnalysisService; | |
16 | 18 | import com.ash.service.WarningInstanceService; |
17 | 19 | import com.ash.util.UUIDGenerator; |
18 | 20 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
... | ... | @@ -30,6 +32,7 @@ import java.net.URLEncoder; |
30 | 32 | import java.nio.charset.StandardCharsets; |
31 | 33 | import java.util.ArrayList; |
32 | 34 | import java.util.List; |
35 | +import java.util.Map; | |
33 | 36 | import java.util.Optional; |
34 | 37 | import java.util.stream.Collectors; |
35 | 38 | |
... | ... | @@ -39,6 +42,10 @@ import java.util.stream.Collectors; |
39 | 42 | public class WarningInstanceController extends BaseController { |
40 | 43 | @Resource |
41 | 44 | private WarningInstanceService warningInstanceService; |
45 | + | |
46 | + @Resource | |
47 | + private WarningInstanceAnalysisService warningInstanceAnalysisService; | |
48 | + | |
42 | 49 | @Resource |
43 | 50 | private FileDataService fileDataService; |
44 | 51 | |
... | ... | @@ -139,6 +146,12 @@ public class WarningInstanceController extends BaseController { |
139 | 146 | page.setCurrent(pageNo); |
140 | 147 | page.setSize(pageSize); |
141 | 148 | Page<WarningInstance> dataPage = warningInstanceService.pageByCondition(params, page); |
149 | + if (CollectionUtils.isNotEmpty(dataPage.getRecords())) { | |
150 | + List<String> wiIds = dataPage.getRecords() | |
151 | + .stream().map(WarningInstance::getId).collect(Collectors.toList()); | |
152 | + Map<String, WarningInstanceAnalysis> analysisMap = warningInstanceAnalysisService.listByWiId(wiIds); | |
153 | + dataPage.getRecords().forEach(e -> e.setAnalysis(analysisMap.get(e.getId()))); | |
154 | + } | |
142 | 155 | |
143 | 156 | return JsonResult.ok(OptionStatus.OPT_SUCCESS.getName(), dataPage); |
144 | 157 | |
... | ... | @@ -186,4 +199,41 @@ public class WarningInstanceController extends BaseController { |
186 | 199 | return JsonResult.ok(); |
187 | 200 | } |
188 | 201 | |
202 | + @PostMapping("/saveAnalysis") | |
203 | + public JsonResult save(@RequestBody WarningInstanceAnalysis analysis) { | |
204 | + try { | |
205 | + Boolean success = warningInstanceAnalysisService.save(analysis); | |
206 | + return new JsonResult(success, OptionStatus.OPT_SUCCESS.getName(), null); | |
207 | + } catch (Exception ex) { | |
208 | + ex.printStackTrace(); | |
209 | + log.error(ex.getMessage()); | |
210 | + return JsonResult.error(OptionStatus.OPT_ERROR.getName()); | |
211 | + } | |
212 | + } | |
213 | + | |
214 | + @PostMapping("/conformAnalysis") | |
215 | + public JsonResult conformAnalysis(@RequestBody WarningInstanceAnalysis analysis) { | |
216 | + try { | |
217 | + Boolean success = warningInstanceAnalysisService.conform(analysis); | |
218 | + return new JsonResult(success, OptionStatus.OPT_SUCCESS.getName(), null); | |
219 | + } catch (Exception ex) { | |
220 | + ex.printStackTrace(); | |
221 | + log.error(ex.getMessage()); | |
222 | + return JsonResult.error(OptionStatus.OPT_ERROR.getName()); | |
223 | + } | |
224 | + } | |
225 | + | |
226 | + @PostMapping("/cancelConform") | |
227 | + public JsonResult cancelConform(@RequestBody WarningInstanceAnalysis analysis) { | |
228 | + try { | |
229 | + Boolean success = warningInstanceAnalysisService.cancelConform(analysis); | |
230 | + return new JsonResult(success, OptionStatus.OPT_SUCCESS.getName(), null); | |
231 | + } catch (Exception ex) { | |
232 | + ex.printStackTrace(); | |
233 | + log.error(ex.getMessage()); | |
234 | + return JsonResult.error(OptionStatus.OPT_ERROR.getName()); | |
235 | + } | |
236 | + } | |
237 | + | |
238 | + | |
189 | 239 | } | ... | ... |
... | ... | @@ -77,85 +77,12 @@ public class Case extends BaseModel { |
77 | 77 | private ReviewStatusEnum reviewStatus; |
78 | 78 | |
79 | 79 | |
80 | - | |
81 | -// 分析数据 | |
82 | - /** | |
83 | - * 地区 | |
84 | - */ | |
85 | - @TableField(value = "area") | |
86 | - private String area; | |
87 | - | |
88 | - /** | |
89 | - * 县区 | |
90 | - */ | |
91 | - @TableField(value = "county") | |
92 | - private String county; | |
93 | - | |
94 | - | |
95 | - /** | |
96 | - * 涉案总金额 | |
97 | - */ | |
98 | - @TableField(value = "total_amount") | |
99 | - private Double totalAmount; | |
100 | - | |
101 | - /** | |
102 | - * 案损金额 | |
103 | - */ | |
104 | - @TableField(value = "amount") | |
105 | - private Double amount; | |
106 | - | |
107 | - /** | |
108 | - * 受害人性别 | |
109 | - */ | |
110 | - @TableField(value = "sex") | |
111 | - private String sex; | |
112 | - | |
113 | - /** | |
114 | - * 受害人年龄 | |
115 | - */ | |
116 | - @TableField(value = "age") | |
117 | - private Integer age; | |
118 | - | |
119 | - /** | |
120 | - * 受害人职业 | |
121 | - */ | |
122 | - @TableField(value = "career") | |
123 | - private String career; | |
124 | - | |
125 | - /** | |
126 | - * 身份证号码 | |
127 | - */ | |
128 | - @TableField(value = "id_card") | |
129 | - private String idCard; | |
130 | - | |
131 | - /** | |
132 | - * 诈骗类型 | |
133 | - */ | |
134 | - @TableField(value = "fraud_type") | |
135 | - private String fraudType; | |
136 | - | |
137 | - /** | |
138 | - * 引流方式 | |
139 | - */ | |
140 | - @TableField(value = "rainage_method") | |
141 | - private String rainageMethod; | |
142 | - | |
143 | - /** | |
144 | - * 引流方式详情 | |
145 | - */ | |
146 | - @TableField(value = "rainage_detail") | |
147 | - private String rainageDetail; | |
148 | - | |
149 | - /** | |
150 | - * 支付方式 | |
151 | - */ | |
152 | - @TableField(value = "pay_method") | |
153 | - private String payMethod; | |
154 | - | |
155 | - | |
156 | 80 | @Transient |
157 | 81 | private transient String startTime; |
158 | 82 | |
159 | 83 | @Transient |
160 | 84 | private transient String endTime; |
85 | + | |
86 | + @Transient | |
87 | + private transient CaseAnalysis analysis; | |
161 | 88 | } | ... | ... |
1 | +package com.ash.entity; | |
2 | + | |
3 | +import com.ash.base.BaseModel; | |
4 | +import com.ash.enums.ConformStatusEnum; | |
5 | +import com.baomidou.mybatisplus.annotation.TableField; | |
6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
8 | +import com.fasterxml.jackson.annotation.JsonInclude; | |
9 | +import lombok.Data; | |
10 | + | |
11 | +@Data | |
12 | +@TableName(value = "t_ash_case_analysis") | |
13 | +@JsonInclude(JsonInclude.Include.NON_NULL) | |
14 | +public class CaseAnalysis extends BaseModel { | |
15 | + | |
16 | + @TableId(value = "id") | |
17 | + private String id; | |
18 | + | |
19 | + /** | |
20 | + * 案件id | |
21 | + */ | |
22 | + @TableField(value = "case_id") | |
23 | + private String caseId; | |
24 | + | |
25 | + /** | |
26 | + * 地区 | |
27 | + */ | |
28 | + @TableField(value = "area") | |
29 | + private String area; | |
30 | + | |
31 | + /** | |
32 | + * 县区 | |
33 | + */ | |
34 | + @TableField(value = "county") | |
35 | + private String county; | |
36 | + | |
37 | + | |
38 | + /** | |
39 | + * 涉案总金额 | |
40 | + */ | |
41 | + @TableField(value = "total_amount") | |
42 | + private Double totalAmount; | |
43 | + | |
44 | + /** | |
45 | + * 案损金额 | |
46 | + */ | |
47 | + @TableField(value = "amount") | |
48 | + private Double amount; | |
49 | + | |
50 | + /** | |
51 | + * 受害人性别 | |
52 | + */ | |
53 | + @TableField(value = "sex") | |
54 | + private String sex; | |
55 | + | |
56 | + /** | |
57 | + * 受害人年龄 | |
58 | + */ | |
59 | + @TableField(value = "age") | |
60 | + private Integer age; | |
61 | + | |
62 | + /** | |
63 | + * 受害人职业 | |
64 | + */ | |
65 | + @TableField(value = "career") | |
66 | + private String career; | |
67 | + | |
68 | + /** | |
69 | + * 身份证号码 | |
70 | + */ | |
71 | + @TableField(value = "id_card") | |
72 | + private String idCard; | |
73 | + | |
74 | + /** | |
75 | + * 诈骗类型 | |
76 | + */ | |
77 | + @TableField(value = "fraud_type") | |
78 | + private String fraudType; | |
79 | + | |
80 | + /** | |
81 | + * 引流方式 | |
82 | + */ | |
83 | + @TableField(value = "rainage_method") | |
84 | + private String rainageMethod; | |
85 | + | |
86 | + /** | |
87 | + * 引流方式详情 | |
88 | + */ | |
89 | + @TableField(value = "rainage_detail") | |
90 | + private String rainageDetail; | |
91 | + | |
92 | + /** | |
93 | + * 支付方式 | |
94 | + */ | |
95 | + @TableField(value = "pay_method") | |
96 | + private String payMethod; | |
97 | + | |
98 | + /** | |
99 | + * 确认状态 | |
100 | + */ | |
101 | + @TableField(value = "conform_status") | |
102 | + private ConformStatusEnum conformStatus; | |
103 | +} | ... | ... |
1 | 1 | package com.ash.entity; |
2 | 2 | |
3 | 3 | import com.ash.base.BaseModel; |
4 | +import com.ash.enums.ConformStatusEnum; | |
4 | 5 | import com.baomidou.mybatisplus.annotation.TableField; |
5 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
6 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
8 | +import com.fasterxml.jackson.annotation.JsonInclude; | |
9 | +import com.github.yulichang.common.support.func.S; | |
7 | 10 | import lombok.Data; |
8 | 11 | |
9 | 12 | @Data |
13 | +@JsonInclude(JsonInclude.Include.NON_NULL) | |
10 | 14 | @TableName(value = "t_ash_warning_instance_analysis") |
11 | 15 | public class WarningInstanceAnalysis extends BaseModel { |
12 | 16 | @TableId(value = "id") |
13 | 17 | private String id; |
14 | 18 | |
19 | + | |
20 | + /** | |
21 | + * 警情id | |
22 | + */ | |
23 | + @TableField(value = "wi_id") | |
24 | + private String wiId; | |
25 | + | |
15 | 26 | /** |
16 | 27 | * 地区 |
17 | 28 | */ |
... | ... | @@ -48,4 +59,10 @@ public class WarningInstanceAnalysis extends BaseModel { |
48 | 59 | @TableField(value = "pay_method") |
49 | 60 | private String payMethod; |
50 | 61 | |
62 | + /** | |
63 | + * 确认状态 | |
64 | + */ | |
65 | + @TableField(value = "conform_status") | |
66 | + private ConformStatusEnum conformStatus; | |
67 | + | |
51 | 68 | } | ... | ... |
1 | +package com.ash.entity.dao; | |
2 | + | |
3 | +import com.ash.entity.CaseAnalysis; | |
4 | +import com.github.yulichang.base.MPJBaseMapper; | |
5 | +import org.apache.ibatis.annotations.Mapper; | |
6 | +import org.springframework.stereotype.Repository; | |
7 | + | |
8 | +@Mapper | |
9 | +@Repository | |
10 | +public interface CaseAnalysisMapper extends CommonBaseMapper<CaseAnalysis>, MPJBaseMapper<CaseAnalysis> { | |
11 | +} | ... | ... |
1 | +package com.ash.enums; | |
2 | + | |
3 | +public enum ConformStatusEnum { | |
4 | + CONFIRMED("已确认"), | |
5 | + UNCONFIRMED("未确认"), | |
6 | + ; | |
7 | + | |
8 | + | |
9 | + private final String text; | |
10 | + | |
11 | + private ConformStatusEnum(String text) { | |
12 | + this.text = text; | |
13 | + } | |
14 | + | |
15 | + public String getText() { | |
16 | + return text; | |
17 | + } | |
18 | +} | ... | ... |
1 | +package com.ash.service; | |
2 | + | |
3 | +import com.ash.base.AshErrorCode; | |
4 | +import com.ash.base.AshException; | |
5 | +import com.ash.entity.Case; | |
6 | +import com.ash.entity.CaseAnalysis; | |
7 | +import com.ash.entity.dao.CaseAnalysisMapper; | |
8 | +import com.ash.enums.ConformStatusEnum; | |
9 | +import com.ash.enums.ReviewStatusEnum; | |
10 | +import com.ash.util.UUIDGenerator; | |
11 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
12 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
13 | +import lombok.extern.slf4j.Slf4j; | |
14 | +import org.apache.commons.collections.CollectionUtils; | |
15 | +import org.apache.commons.lang3.StringUtils; | |
16 | +import org.springframework.stereotype.Service; | |
17 | +import org.springframework.transaction.annotation.Transactional; | |
18 | + | |
19 | +import javax.annotation.Resource; | |
20 | +import java.util.HashMap; | |
21 | +import java.util.List; | |
22 | +import java.util.Map; | |
23 | +import java.util.function.Function; | |
24 | +import java.util.stream.Collectors; | |
25 | + | |
26 | +@Slf4j | |
27 | +@Service | |
28 | +public class CaseAnalysisService { | |
29 | + | |
30 | + @Resource | |
31 | + private CaseAnalysisMapper caseAnalysisMapper; | |
32 | + | |
33 | + @Resource | |
34 | + private CaseService caseService; | |
35 | + | |
36 | + public static Map<String, String> codeAreaMap = new HashMap<>(); | |
37 | + | |
38 | + static { | |
39 | + codeAreaMap.put("A3401", "合肥"); | |
40 | + codeAreaMap.put("A3402", "芜湖"); | |
41 | + codeAreaMap.put("A3403", "蚌埠"); | |
42 | + codeAreaMap.put("A3404", "淮南"); | |
43 | + codeAreaMap.put("A3405", "马鞍山"); | |
44 | + codeAreaMap.put("A3406", "淮北"); | |
45 | + codeAreaMap.put("A3407", "铜陵"); | |
46 | + codeAreaMap.put("A3408", "安庆"); | |
47 | + codeAreaMap.put("A3410", "黄山"); | |
48 | + codeAreaMap.put("A3411", "滁州"); | |
49 | + codeAreaMap.put("A3412", "阜阳"); | |
50 | + codeAreaMap.put("A3413", "宿州"); | |
51 | + codeAreaMap.put("A3415", "六安"); | |
52 | + codeAreaMap.put("A3416", "亳州"); | |
53 | + codeAreaMap.put("A3417", "池州"); | |
54 | + codeAreaMap.put("A3418", "宣城"); | |
55 | + } | |
56 | + | |
57 | + public Boolean save(CaseAnalysis data) { | |
58 | + String uuid = UUIDGenerator.uuid(); | |
59 | + data.setId(uuid); | |
60 | + if (data.getConformStatus() == null) { | |
61 | + data.setConformStatus(ConformStatusEnum.UNCONFIRMED); | |
62 | + } | |
63 | + | |
64 | + if (StringUtils.isBlank(data.getCaseId())) { | |
65 | + throw new AshException(AshErrorCode.ILLEGAL_PARAM, "caseId is empty!"); | |
66 | + } | |
67 | + | |
68 | + Case caseInfo = caseService.load(data.getCaseId()); | |
69 | + setArea(caseInfo.getCode(), data); | |
70 | + | |
71 | + int insert = caseAnalysisMapper.insert(data); | |
72 | + return insert > 0; | |
73 | + } | |
74 | + | |
75 | + public CaseAnalysis load(String id) { | |
76 | + return caseAnalysisMapper.selectById(id); | |
77 | + } | |
78 | + | |
79 | + public void update(CaseAnalysis data) { | |
80 | + String id = data.getId(); | |
81 | + if (StringUtils.isBlank(id)) { | |
82 | + throw new AshException(AshErrorCode.ILLEGAL_PARAM, "id is empty!"); | |
83 | + } | |
84 | + CaseAnalysis oldData = caseAnalysisMapper.selectById(id); | |
85 | + if (oldData == null) { | |
86 | + throw new AshException(AshErrorCode.DATA_NOT_EXIST); | |
87 | + } | |
88 | + | |
89 | + Case caseInfo = caseService.load(data.getCaseId()); | |
90 | + setArea(caseInfo.getCode(), data); | |
91 | + | |
92 | + caseAnalysisMapper.updateById(data); | |
93 | + } | |
94 | + | |
95 | + private void setArea(String caseCode, CaseAnalysis data) { | |
96 | + if (data != null && StringUtils.isNotBlank(caseCode) && caseCode.length() >= 4) { | |
97 | + String area = codeAreaMap.get(caseCode.substring(0, 5)); | |
98 | + if (StringUtils.isNotBlank(area)) { | |
99 | + data.setArea(area); | |
100 | + } else { | |
101 | + data.setArea("未知"); | |
102 | + } | |
103 | + } | |
104 | + } | |
105 | + | |
106 | + public Map<String, CaseAnalysis> listByCaseId(List<String> caseIds) { | |
107 | + QueryWrapper<CaseAnalysis> queryWrapper = new QueryWrapper<>(); | |
108 | + LambdaQueryWrapper<CaseAnalysis> lambda = queryWrapper.lambda(); | |
109 | + lambda.in(CaseAnalysis::getCaseId, caseIds); | |
110 | + List<CaseAnalysis> warningInstanceAnalyses = caseAnalysisMapper.selectList(queryWrapper); | |
111 | + if (CollectionUtils.isNotEmpty(warningInstanceAnalyses)) { | |
112 | + return warningInstanceAnalyses.stream() | |
113 | + .collect(Collectors.toMap(CaseAnalysis::getCaseId, Function.identity())); | |
114 | + } | |
115 | + return new HashMap<>(); | |
116 | + } | |
117 | + | |
118 | + @Transactional | |
119 | + public Boolean conform(CaseAnalysis data) { | |
120 | + Boolean result = true; | |
121 | + data.setConformStatus(ConformStatusEnum.CONFIRMED); | |
122 | + update(data); | |
123 | + Case caseInfo = caseService.load(data.getCaseId()); | |
124 | + caseInfo.setReviewStatus(ReviewStatusEnum.AUDITED); | |
125 | + caseService.update(caseInfo); | |
126 | + return result; | |
127 | + } | |
128 | + | |
129 | + | |
130 | + @Transactional | |
131 | + public Boolean cancelConform(CaseAnalysis data) { | |
132 | + Boolean result = true; | |
133 | + CaseAnalysis wa = load(data.getId()); | |
134 | + wa.setConformStatus(ConformStatusEnum.UNCONFIRMED); | |
135 | + update(wa); | |
136 | + Case caseInfo = caseService.load(wa.getCaseId()); | |
137 | + caseInfo.setReviewStatus(ReviewStatusEnum.UNAUDITED); | |
138 | + caseService.update(caseInfo); | |
139 | + return result; | |
140 | + } | |
141 | +} | ... | ... |
... | ... | @@ -8,6 +8,7 @@ import com.ash.base.AshException; |
8 | 8 | import com.ash.base.BaseModel; |
9 | 9 | import com.ash.base.excelOpt.ExcelErrorMessage; |
10 | 10 | import com.ash.entity.Case; |
11 | +import com.ash.entity.CaseAnalysis; | |
11 | 12 | import com.ash.entity.dao.CaseMapper; |
12 | 13 | import com.ash.excelData.CaseExcelData; |
13 | 14 | import com.ash.listener.CaseExcelListener; |
... | ... | @@ -37,46 +38,19 @@ public class CaseService { |
37 | 38 | @Resource |
38 | 39 | private CaseMapper caseMapper; |
39 | 40 | |
40 | - public static Map<String, String> codeAreaMap = new HashMap<>(); | |
41 | - | |
42 | - static { | |
43 | - codeAreaMap.put("A3401", "合肥"); | |
44 | - codeAreaMap.put("A3402", "芜湖"); | |
45 | - codeAreaMap.put("A3403", "蚌埠"); | |
46 | - codeAreaMap.put("A3404", "淮南"); | |
47 | - codeAreaMap.put("A3405", "马鞍山"); | |
48 | - codeAreaMap.put("A3406", "淮北"); | |
49 | - codeAreaMap.put("A3407", "铜陵"); | |
50 | - codeAreaMap.put("A3408", "安庆"); | |
51 | - codeAreaMap.put("A3410", "黄山"); | |
52 | - codeAreaMap.put("A3411", "滁州"); | |
53 | - codeAreaMap.put("A3412", "阜阳"); | |
54 | - codeAreaMap.put("A3413", "宿州"); | |
55 | - codeAreaMap.put("A3415", "六安"); | |
56 | - codeAreaMap.put("A3416", "亳州"); | |
57 | - codeAreaMap.put("A3417", "池州"); | |
58 | - codeAreaMap.put("A3418", "宣城"); | |
59 | - } | |
60 | - | |
61 | 41 | public Boolean save(Case data) { |
62 | 42 | String uuid = UUIDGenerator.uuid(); |
63 | 43 | data.setId(uuid); |
64 | - setArea(data); | |
65 | 44 | int insert = caseMapper.insert(data); |
66 | 45 | return insert > 0; |
67 | 46 | } |
68 | 47 | |
69 | - private void setArea(Case data) { | |
70 | - if (data != null && StringUtils.isNotBlank(data.getCode()) && data.getCode().length() >= 4) { | |
71 | - String area = codeAreaMap.get(data.getCode().substring(0, 5)); | |
72 | - if (StringUtils.isNotBlank(area)) { | |
73 | - data.setArea(area); | |
74 | - } else { | |
75 | - data.setArea("未知"); | |
76 | - } | |
77 | - } | |
48 | + public Case load(String id) { | |
49 | + return caseMapper.selectById(id); | |
78 | 50 | } |
79 | 51 | |
52 | + | |
53 | + | |
80 | 54 | public Boolean saveAll(List<Case> dataList) { |
81 | 55 | if (CollectionUtils.isEmpty(dataList)) { |
82 | 56 | throw new AshException(AshErrorCode.ILLEGAL_PARAM, "dataList is empty!"); |
... | ... | @@ -97,7 +71,6 @@ public class CaseService { |
97 | 71 | sub.forEach(t -> { |
98 | 72 | String uuid = UUIDGenerator.uuid(); |
99 | 73 | t.setId(uuid); |
100 | - setArea(t); | |
101 | 74 | }); |
102 | 75 | try { |
103 | 76 | Integer result = caseMapper.insertBatchSomeColumn(sub); |
... | ... | @@ -122,7 +95,6 @@ public class CaseService { |
122 | 95 | throw new AshException(AshErrorCode.DATA_NOT_EXIST); |
123 | 96 | } |
124 | 97 | |
125 | - setArea(data); | |
126 | 98 | int result = caseMapper.updateById(data); |
127 | 99 | return result > 0; |
128 | 100 | } | ... | ... |
... | ... | @@ -15,11 +15,10 @@ public class FileDataService { |
15 | 15 | @Resource |
16 | 16 | private FileDataMapper fileDataMapper; |
17 | 17 | |
18 | - public Boolean save(FileData data) { | |
18 | + public void save(FileData data) { | |
19 | 19 | String uuid = UUIDGenerator.uuid(); |
20 | 20 | data.setId(uuid); |
21 | 21 | int insert = fileDataMapper.insert(data); |
22 | - return insert > 0; | |
23 | 22 | } |
24 | 23 | |
25 | 24 | public FileData load(String id) { | ... | ... |
1 | +package com.ash.service; | |
2 | + | |
3 | +import com.ash.base.AshErrorCode; | |
4 | +import com.ash.base.AshException; | |
5 | +import com.ash.entity.WarningInstance; | |
6 | +import com.ash.entity.WarningInstanceAnalysis; | |
7 | +import com.ash.entity.dao.WarningInstanceAnalysisMapper; | |
8 | +import com.ash.enums.ConformStatusEnum; | |
9 | +import com.ash.enums.ReviewStatusEnum; | |
10 | +import com.ash.util.UUIDGenerator; | |
11 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
12 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
13 | +import lombok.extern.slf4j.Slf4j; | |
14 | +import org.apache.commons.collections.CollectionUtils; | |
15 | +import org.apache.commons.lang3.StringUtils; | |
16 | +import org.springframework.stereotype.Service; | |
17 | +import org.springframework.transaction.annotation.Transactional; | |
18 | + | |
19 | +import javax.annotation.Resource; | |
20 | +import java.util.HashMap; | |
21 | +import java.util.List; | |
22 | +import java.util.Map; | |
23 | +import java.util.function.Function; | |
24 | +import java.util.stream.Collectors; | |
25 | + | |
26 | +@Slf4j | |
27 | +@Service | |
28 | +public class WarningInstanceAnalysisService { | |
29 | + | |
30 | + @Resource | |
31 | + private WarningInstanceAnalysisMapper warningInstanceAnalysisMapper; | |
32 | + | |
33 | + @Resource | |
34 | + private WarningInstanceService warningInstanceService; | |
35 | + | |
36 | + public Boolean save(WarningInstanceAnalysis data) { | |
37 | + String uuid = UUIDGenerator.uuid(); | |
38 | + data.setId(uuid); | |
39 | + if (data.getConformStatus() == null) { | |
40 | + data.setConformStatus(ConformStatusEnum.UNCONFIRMED); | |
41 | + } | |
42 | + int insert = warningInstanceAnalysisMapper.insert(data); | |
43 | + return insert > 0; | |
44 | + } | |
45 | + | |
46 | + public WarningInstanceAnalysis load(String id) { | |
47 | + return warningInstanceAnalysisMapper.selectById(id); | |
48 | + } | |
49 | + | |
50 | + public void update(WarningInstanceAnalysis data) { | |
51 | + String id = data.getId(); | |
52 | + if (StringUtils.isBlank(id)) { | |
53 | + throw new AshException(AshErrorCode.ILLEGAL_PARAM, "id is empty!"); | |
54 | + } | |
55 | + WarningInstanceAnalysis oldData = warningInstanceAnalysisMapper.selectById(id); | |
56 | + if (oldData == null) { | |
57 | + throw new AshException(AshErrorCode.DATA_NOT_EXIST); | |
58 | + } | |
59 | + | |
60 | + int result = warningInstanceAnalysisMapper.updateById(data); | |
61 | + } | |
62 | + | |
63 | + public Map<String, WarningInstanceAnalysis> listByWiId(List<String> wiIds) { | |
64 | + QueryWrapper<WarningInstanceAnalysis> queryWrapper = new QueryWrapper<>(); | |
65 | + LambdaQueryWrapper<WarningInstanceAnalysis> lambda = queryWrapper.lambda(); | |
66 | + lambda.in(WarningInstanceAnalysis::getWiId, wiIds); | |
67 | + List<WarningInstanceAnalysis> warningInstanceAnalyses = warningInstanceAnalysisMapper.selectList(queryWrapper); | |
68 | + if (CollectionUtils.isNotEmpty(warningInstanceAnalyses)) { | |
69 | + return warningInstanceAnalyses.stream() | |
70 | + .collect(Collectors.toMap(WarningInstanceAnalysis::getWiId, Function.identity())); | |
71 | + } | |
72 | + return new HashMap<>(); | |
73 | + } | |
74 | + | |
75 | + @Transactional | |
76 | + public Boolean conform(WarningInstanceAnalysis data) { | |
77 | + Boolean result = true; | |
78 | + data.setConformStatus(ConformStatusEnum.CONFIRMED); | |
79 | + update(data); | |
80 | + WarningInstance wi = warningInstanceService.load(data.getWiId()); | |
81 | + wi.setReviewStatus(ReviewStatusEnum.AUDITED); | |
82 | + warningInstanceService.update(wi); | |
83 | + return result; | |
84 | + } | |
85 | + | |
86 | + | |
87 | + @Transactional | |
88 | + public Boolean cancelConform(WarningInstanceAnalysis data) { | |
89 | + Boolean result = true; | |
90 | + WarningInstanceAnalysis wa = load(data.getId()); | |
91 | + wa.setConformStatus(ConformStatusEnum.UNCONFIRMED); | |
92 | + update(wa); | |
93 | + WarningInstance wi = warningInstanceService.load(wa.getWiId()); | |
94 | + wi.setReviewStatus(ReviewStatusEnum.UNAUDITED); | |
95 | + warningInstanceService.update(wi); | |
96 | + return result; | |
97 | + } | |
98 | + | |
99 | +} | ... | ... |
... | ... | @@ -41,6 +41,10 @@ public class WarningInstanceService { |
41 | 41 | return insert > 0; |
42 | 42 | } |
43 | 43 | |
44 | + public WarningInstance load(String id) { | |
45 | + return warningInstanceMapper.selectById(id); | |
46 | + } | |
47 | + | |
44 | 48 | public Boolean saveAll(List<WarningInstance> dataList) { |
45 | 49 | if (CollectionUtils.isEmpty(dataList)) { |
46 | 50 | throw new AshException(AshErrorCode.ILLEGAL_PARAM, "dataList is empty!"); | ... | ... |
... | ... | @@ -29,6 +29,26 @@ create table `t_ash_warning_instance` |
29 | 29 | primary key (id) |
30 | 30 | ) comment = '警情列表' ENGINE = InnoDB; |
31 | 31 | |
32 | +create table `t_ash_warning_instance_analysis` | |
33 | +( | |
34 | + id varchar(32) not null, | |
35 | + wi_id varchar(32), | |
36 | + area varchar(50), | |
37 | + amount double, | |
38 | + sex varchar(50), | |
39 | + career varchar(50), | |
40 | + rainage_method varchar(50), | |
41 | + pay_method varchar(50), | |
42 | + conform_status varchar(50) DEFAULT 'UNCONFIRMED', | |
43 | + create_time timestamp null, | |
44 | + create_by varchar(32), | |
45 | + last_modify_time timestamp null, | |
46 | + last_modify_by varchar(32), | |
47 | + primary key (id) | |
48 | +) comment = '警情分析结果' ENGINE = InnoDB; | |
49 | + | |
50 | +create index i_wia_wi on t_ash_warning_instance_analysis(wi_id); | |
51 | + | |
32 | 52 | create table `t_ash_case` |
33 | 53 | ( |
34 | 54 | id varchar(32) not null, |
... | ... | @@ -60,6 +80,31 @@ create table `t_ash_case` |
60 | 80 | primary key (id) |
61 | 81 | ) comment = '案件列表' ENGINE = InnoDB; |
62 | 82 | |
83 | +create table `t_ash_case_analysis` | |
84 | +( | |
85 | + id varchar(32) not null, | |
86 | + case_id varchar(50), | |
87 | + area varchar(50), | |
88 | + county varchar(50), | |
89 | + total_amount double, | |
90 | + amount double, | |
91 | + sex varchar(50), | |
92 | + age int, | |
93 | + career varchar(50), | |
94 | + id_card varchar(50), | |
95 | + fraud_type varchar(50), | |
96 | + rainage_method varchar(50), | |
97 | + rainage_detail varchar(500), | |
98 | + pay_method varchar(50), | |
99 | + conform_status varchar(50) DEFAULT 'UNCONFIRMED', | |
100 | + create_time timestamp null, | |
101 | + create_by varchar(32), | |
102 | + last_modify_time timestamp null, | |
103 | + last_modify_by varchar(32), | |
104 | + primary key (id) | |
105 | +) comment = '案件分析结果' ENGINE = InnoDB; | |
106 | + | |
107 | +create index i_case_ci on t_ash_case_analysis(case_id); | |
63 | 108 | |
64 | 109 | create table `t_ash_file_data` |
65 | 110 | ( | ... | ... |