|
|
package com.xkl.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.xkl.config.Constants;
|
|
|
import com.xkl.config.ResultStatus;
|
|
|
import com.xkl.domain.*;
|
|
|
import com.xkl.model.ReportIdModel;
|
|
|
import com.xkl.model.ResultModel;
|
|
|
import com.xkl.repository.ReportDetailRepository;
|
|
|
import com.xkl.repository.ReportMetaItemsRepository;
|
|
|
import com.xkl.repository.ReportRepository;
|
|
|
import com.xkl.repository.UserRepository;
|
|
|
import com.xkl.repository.*;
|
|
|
import com.xkl.security.SecurityTool;
|
|
|
import com.xkl.tools.UtilTools;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.http.HttpStatus;
|
...
|
...
|
@@ -36,6 +33,9 @@ public class ReportService implements IReportService { |
|
|
private ReportDetailRepository reportDetailRepository;
|
|
|
|
|
|
@Autowired
|
|
|
private ReportResultRepository reportResultRepository;
|
|
|
|
|
|
@Autowired
|
|
|
private UserRepository userRepository;
|
|
|
|
|
|
// 存储报告相关md5,防止重复上传已存在报告,防止重复上传错误报告。
|
...
|
...
|
@@ -112,7 +112,7 @@ public class ReportService implements IReportService { |
|
|
*/
|
|
|
public ResponseEntity<ResultModel> delete(XklAdminEntity admin, long report_id) {
|
|
|
// 1. 得到report,验证报告存在性
|
|
|
XklAmpReportEntity report = reportRepository.findById( report_id);
|
|
|
XklAmpReportEntity report = reportRepository.findById(report_id);
|
|
|
if (report == null || report.getStatus() == 0) {
|
|
|
// 报告不存在,返回
|
|
|
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
|
...
|
...
|
@@ -144,6 +144,7 @@ public class ReportService implements IReportService { |
|
|
ReportData reportData = new ReportData();
|
|
|
XklAmpReportEntity ampReport = new XklAmpReportEntity();
|
|
|
List<XklAmpReportDetailEntity> detailList = new ArrayList<>();
|
|
|
List<XklAmpReportResultEntity> basicResList = new ArrayList<>();
|
|
|
int sex;
|
|
|
|
|
|
/*
|
...
|
...
|
@@ -182,12 +183,24 @@ public class ReportService implements IReportService { |
|
|
detail.setItemId(item_id);
|
|
|
detailList.add(detail);
|
|
|
}
|
|
|
/*
|
|
|
* 4. 获取诊断结论编号
|
|
|
*/
|
|
|
JSONArray basicResIdsArr = rpJson.getJSONArray("basic_result_ids");
|
|
|
if (basicResIdsArr != null && basicResIdsArr.size() > 0) {
|
|
|
for (int resId = 0; resId < basicResIdsArr.size(); resId++) {
|
|
|
XklAmpReportResultEntity rpRes = new XklAmpReportResultEntity();
|
|
|
rpRes.setResultItemId(basicResIdsArr.getInteger(resId));
|
|
|
basicResList.add(rpRes);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return null;
|
|
|
}
|
|
|
markItemStatus(sex, detailList);
|
|
|
reportData.setAmpReport(ampReport);
|
|
|
reportData.setRpDetailList(detailList);
|
|
|
reportData.setBasicResList(basicResList);
|
|
|
return reportData;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -196,13 +209,17 @@ public class ReportService implements IReportService { |
|
|
*/
|
|
|
private long save2DB(ReportData report, XklAdminEntity admin, User user) {
|
|
|
report.getAmpReport().setCreateBy(admin.getId());
|
|
|
report.getAmpReport().setCompanyId((long)admin.getCoid());
|
|
|
report.getAmpReport().setMemberId((long)user.getMemberId());
|
|
|
report.getAmpReport().setCompanyId((long) admin.getCoid());
|
|
|
report.getAmpReport().setMemberId((long) user.getMemberId());
|
|
|
XklAmpReportEntity ampReport = reportRepository.save(report.getAmpReport());
|
|
|
for (XklAmpReportDetailEntity detail : report.getRpDetailList()) {
|
|
|
detail.setReportId(ampReport.getId());
|
|
|
}
|
|
|
for (XklAmpReportResultEntity rpRes : report.getBasicResList()){
|
|
|
rpRes.setReportId(ampReport.getId());
|
|
|
}
|
|
|
reportDetailRepository.save(report.getRpDetailList());
|
|
|
reportResultRepository.save(report.getBasicResList());
|
|
|
return ampReport.getId();
|
|
|
}
|
|
|
|
...
|
...
|
|