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);
|
|
@@ -144,6 +144,7 @@ public class ReportService implements IReportService { |
|
@@ -144,6 +144,7 @@ public class ReportService implements IReportService { |
144
|
ReportData reportData = new ReportData();
|
144
|
ReportData reportData = new ReportData();
|
145
|
XklAmpReportEntity ampReport = new XklAmpReportEntity();
|
145
|
XklAmpReportEntity ampReport = new XklAmpReportEntity();
|
146
|
List<XklAmpReportDetailEntity> detailList = new ArrayList<>();
|
146
|
List<XklAmpReportDetailEntity> detailList = new ArrayList<>();
|
|
|
147
|
+ List<XklAmpReportResultEntity> basicResList = new ArrayList<>();
|
147
|
int sex;
|
148
|
int sex;
|
148
|
|
149
|
|
149
|
/*
|
150
|
/*
|
|
@@ -182,12 +183,24 @@ public class ReportService implements IReportService { |
|
@@ -182,12 +183,24 @@ public class ReportService implements IReportService { |
182
|
detail.setItemId(item_id);
|
183
|
detail.setItemId(item_id);
|
183
|
detailList.add(detail);
|
184
|
detailList.add(detail);
|
184
|
}
|
185
|
}
|
|
|
186
|
+ /*
|
|
|
187
|
+ * 4. 获取诊断结论编号
|
|
|
188
|
+ */
|
|
|
189
|
+ JSONArray basicResIdsArr = rpJson.getJSONArray("basic_result_ids");
|
|
|
190
|
+ if (basicResIdsArr != null && basicResIdsArr.size() > 0) {
|
|
|
191
|
+ for (int resId = 0; resId < basicResIdsArr.size(); resId++) {
|
|
|
192
|
+ XklAmpReportResultEntity rpRes = new XklAmpReportResultEntity();
|
|
|
193
|
+ rpRes.setResultItemId(basicResIdsArr.getInteger(resId));
|
|
|
194
|
+ basicResList.add(rpRes);
|
|
|
195
|
+ }
|
|
|
196
|
+ }
|
185
|
} catch (Exception e) {
|
197
|
} catch (Exception e) {
|
186
|
return null;
|
198
|
return null;
|
187
|
}
|
199
|
}
|
188
|
markItemStatus(sex, detailList);
|
200
|
markItemStatus(sex, detailList);
|
189
|
reportData.setAmpReport(ampReport);
|
201
|
reportData.setAmpReport(ampReport);
|
190
|
reportData.setRpDetailList(detailList);
|
202
|
reportData.setRpDetailList(detailList);
|
|
|
203
|
+ reportData.setBasicResList(basicResList);
|
191
|
return reportData;
|
204
|
return reportData;
|
192
|
}
|
205
|
}
|
193
|
|
206
|
|
|
@@ -196,13 +209,17 @@ public class ReportService implements IReportService { |
|
@@ -196,13 +209,17 @@ public class ReportService implements IReportService { |
196
|
*/
|
209
|
*/
|
197
|
private long save2DB(ReportData report, XklAdminEntity admin, User user) {
|
210
|
private long save2DB(ReportData report, XklAdminEntity admin, User user) {
|
198
|
report.getAmpReport().setCreateBy(admin.getId());
|
211
|
report.getAmpReport().setCreateBy(admin.getId());
|
199
|
- report.getAmpReport().setCompanyId((long)admin.getCoid());
|
|
|
200
|
- report.getAmpReport().setMemberId((long)user.getMemberId());
|
212
|
+ report.getAmpReport().setCompanyId((long) admin.getCoid());
|
|
|
213
|
+ report.getAmpReport().setMemberId((long) user.getMemberId());
|
201
|
XklAmpReportEntity ampReport = reportRepository.save(report.getAmpReport());
|
214
|
XklAmpReportEntity ampReport = reportRepository.save(report.getAmpReport());
|
202
|
for (XklAmpReportDetailEntity detail : report.getRpDetailList()) {
|
215
|
for (XklAmpReportDetailEntity detail : report.getRpDetailList()) {
|
203
|
detail.setReportId(ampReport.getId());
|
216
|
detail.setReportId(ampReport.getId());
|
204
|
}
|
217
|
}
|
|
|
218
|
+ for (XklAmpReportResultEntity rpRes : report.getBasicResList()){
|
|
|
219
|
+ rpRes.setReportId(ampReport.getId());
|
|
|
220
|
+ }
|
205
|
reportDetailRepository.save(report.getRpDetailList());
|
221
|
reportDetailRepository.save(report.getRpDetailList());
|
|
|
222
|
+ reportResultRepository.save(report.getBasicResList());
|
206
|
return ampReport.getId();
|
223
|
return ampReport.getId();
|
207
|
}
|
224
|
}
|
208
|
|
225
|
|