1
|
package com.xkl.service;
|
1
|
package com.xkl.service;
|
2
|
|
2
|
|
|
|
3
|
+import com.alibaba.fastjson.JSONArray;
|
3
|
import com.alibaba.fastjson.JSONObject;
|
4
|
import com.alibaba.fastjson.JSONObject;
|
4
|
import com.xkl.config.Constants;
|
5
|
import com.xkl.config.Constants;
|
5
|
import com.xkl.config.ResultStatus;
|
6
|
import com.xkl.config.ResultStatus;
|
6
|
import com.xkl.domain.*;
|
7
|
import com.xkl.domain.*;
|
7
|
import com.xkl.model.ReportIdModel;
|
8
|
import com.xkl.model.ReportIdModel;
|
8
|
import com.xkl.model.ResultModel;
|
9
|
import com.xkl.model.ResultModel;
|
9
|
-import com.xkl.repository.ReportDetailRepository;
|
|
|
10
|
-import com.xkl.repository.ReportMetaItemsRepository;
|
|
|
11
|
-import com.xkl.repository.ReportRepository;
|
|
|
12
|
-import com.xkl.repository.UserRepository;
|
10
|
+import com.xkl.repository.*;
|
13
|
import com.xkl.security.SecurityTool;
|
11
|
import com.xkl.security.SecurityTool;
|
14
|
-import com.xkl.tools.UtilTools;
|
|
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
import org.springframework.data.redis.core.RedisTemplate;
|
13
|
import org.springframework.data.redis.core.RedisTemplate;
|
17
|
import org.springframework.http.HttpStatus;
|
14
|
import org.springframework.http.HttpStatus;
|
|
@@ -36,6 +33,9 @@ public class ReportService implements IReportService { |
|
@@ -36,6 +33,9 @@ public class ReportService implements IReportService { |
36
|
private ReportDetailRepository reportDetailRepository;
|
33
|
private ReportDetailRepository reportDetailRepository;
|
37
|
|
34
|
|
38
|
@Autowired
|
35
|
@Autowired
|
|
|
36
|
+ private ReportResultRepository reportResultRepository;
|
|
|
37
|
+
|
|
|
38
|
+ @Autowired
|
39
|
private UserRepository userRepository;
|
39
|
private UserRepository userRepository;
|
40
|
|
40
|
|
41
|
// 存储报告相关md5,防止重复上传已存在报告,防止重复上传错误报告。
|
41
|
// 存储报告相关md5,防止重复上传已存在报告,防止重复上传错误报告。
|
|
@@ -112,7 +112,7 @@ public class ReportService implements IReportService { |
|
@@ -112,7 +112,7 @@ public class ReportService implements IReportService { |
112
|
*/
|
112
|
*/
|
113
|
public ResponseEntity<ResultModel> delete(XklAdminEntity admin, long report_id) {
|
113
|
public ResponseEntity<ResultModel> delete(XklAdminEntity admin, long report_id) {
|
114
|
// 1. 得到report,验证报告存在性
|
114
|
// 1. 得到report,验证报告存在性
|
115
|
- XklAmpReportEntity report = reportRepository.findById( report_id);
|
115
|
+ XklAmpReportEntity report = reportRepository.findById(report_id);
|
116
|
if (report == null || report.getStatus() == 0) {
|
116
|
if (report == null || report.getStatus() == 0) {
|
117
|
// 报告不存在,返回
|
117
|
// 报告不存在,返回
|
118
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
118
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
|
@@ -127,6 +127,8 @@ public class ReportService implements IReportService { |
|
@@ -127,6 +127,8 @@ public class ReportService implements IReportService { |
127
|
reportRepository.delete(report);
|
127
|
reportRepository.delete(report);
|
128
|
List<XklAmpReportDetailEntity> detailList = reportDetailRepository.findByReportId(report.getId());
|
128
|
List<XklAmpReportDetailEntity> detailList = reportDetailRepository.findByReportId(report.getId());
|
129
|
reportDetailRepository.delete(detailList);
|
129
|
reportDetailRepository.delete(detailList);
|
|
|
130
|
+ List<XklAmpReportResultEntity> rpResList = reportResultRepository.findByReportId(report.getId());
|
|
|
131
|
+ reportResultRepository.delete(rpResList);
|
130
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
132
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
131
|
}
|
133
|
}
|
132
|
|
134
|
|
|
@@ -144,6 +146,7 @@ public class ReportService implements IReportService { |
|
@@ -144,6 +146,7 @@ public class ReportService implements IReportService { |
144
|
ReportData reportData = new ReportData();
|
146
|
ReportData reportData = new ReportData();
|
145
|
XklAmpReportEntity ampReport = new XklAmpReportEntity();
|
147
|
XklAmpReportEntity ampReport = new XklAmpReportEntity();
|
146
|
List<XklAmpReportDetailEntity> detailList = new ArrayList<>();
|
148
|
List<XklAmpReportDetailEntity> detailList = new ArrayList<>();
|
|
|
149
|
+ List<XklAmpReportResultEntity> basicResList = new ArrayList<>();
|
147
|
int sex;
|
150
|
int sex;
|
148
|
|
151
|
|
149
|
/*
|
152
|
/*
|
|
@@ -182,12 +185,24 @@ public class ReportService implements IReportService { |
|
@@ -182,12 +185,24 @@ public class ReportService implements IReportService { |
182
|
detail.setItemId(item_id);
|
185
|
detail.setItemId(item_id);
|
183
|
detailList.add(detail);
|
186
|
detailList.add(detail);
|
184
|
}
|
187
|
}
|
|
|
188
|
+ /*
|
|
|
189
|
+ * 4. 获取诊断结论编号
|
|
|
190
|
+ */
|
|
|
191
|
+ JSONArray basicResIdsArr = rpJson.getJSONArray("basic_result_ids");
|
|
|
192
|
+ if (basicResIdsArr != null && basicResIdsArr.size() > 0) {
|
|
|
193
|
+ for (int resId = 0; resId < basicResIdsArr.size(); resId++) {
|
|
|
194
|
+ XklAmpReportResultEntity rpRes = new XklAmpReportResultEntity();
|
|
|
195
|
+ rpRes.setResultItemId(basicResIdsArr.getInteger(resId));
|
|
|
196
|
+ basicResList.add(rpRes);
|
|
|
197
|
+ }
|
|
|
198
|
+ }
|
185
|
} catch (Exception e) {
|
199
|
} catch (Exception e) {
|
186
|
return null;
|
200
|
return null;
|
187
|
}
|
201
|
}
|
188
|
markItemStatus(sex, detailList);
|
202
|
markItemStatus(sex, detailList);
|
189
|
reportData.setAmpReport(ampReport);
|
203
|
reportData.setAmpReport(ampReport);
|
190
|
reportData.setRpDetailList(detailList);
|
204
|
reportData.setRpDetailList(detailList);
|
|
|
205
|
+ reportData.setBasicResList(basicResList);
|
191
|
return reportData;
|
206
|
return reportData;
|
192
|
}
|
207
|
}
|
193
|
|
208
|
|
|
@@ -196,13 +211,17 @@ public class ReportService implements IReportService { |
|
@@ -196,13 +211,17 @@ public class ReportService implements IReportService { |
196
|
*/
|
211
|
*/
|
197
|
private long save2DB(ReportData report, XklAdminEntity admin, User user) {
|
212
|
private long save2DB(ReportData report, XklAdminEntity admin, User user) {
|
198
|
report.getAmpReport().setCreateBy(admin.getId());
|
213
|
report.getAmpReport().setCreateBy(admin.getId());
|
199
|
- report.getAmpReport().setCompanyId((long)admin.getCoid());
|
|
|
200
|
- report.getAmpReport().setMemberId((long)user.getMemberId());
|
214
|
+ report.getAmpReport().setCompanyId((long) admin.getCoid());
|
|
|
215
|
+ report.getAmpReport().setMemberId((long) user.getMemberId());
|
201
|
XklAmpReportEntity ampReport = reportRepository.save(report.getAmpReport());
|
216
|
XklAmpReportEntity ampReport = reportRepository.save(report.getAmpReport());
|
202
|
for (XklAmpReportDetailEntity detail : report.getRpDetailList()) {
|
217
|
for (XklAmpReportDetailEntity detail : report.getRpDetailList()) {
|
203
|
detail.setReportId(ampReport.getId());
|
218
|
detail.setReportId(ampReport.getId());
|
204
|
}
|
219
|
}
|
|
|
220
|
+ for (XklAmpReportResultEntity rpRes : report.getBasicResList()){
|
|
|
221
|
+ rpRes.setReportId(ampReport.getId());
|
|
|
222
|
+ }
|
205
|
reportDetailRepository.save(report.getRpDetailList());
|
223
|
reportDetailRepository.save(report.getRpDetailList());
|
|
|
224
|
+ reportResultRepository.save(report.getBasicResList());
|
206
|
return ampReport.getId();
|
225
|
return ampReport.getId();
|
207
|
}
|
226
|
}
|
208
|
|
227
|
|