Authored by zhaoyue

Merge branch 'zhaoyue-dev' into 'master'

Zhaoyue dev



See merge request !9
1 git add --all src/* 1 git add --all src/*
2 git add push.sh 2 git add push.sh
3 git add pom.xml 3 git add pom.xml
4 -git commit -m "ADD code for uspih"  
5 -git push origin zhaoyue-dev4 4 +git commit -m "ADD code for uspih "
  5 +git push origin zhaoyue-dev
6 git status 6 git status
@@ -3,6 +3,7 @@ package com.xkl.authorization.resolvers; @@ -3,6 +3,7 @@ package com.xkl.authorization.resolvers;
3 import com.xkl.authorization.annotation.CurrentAdmin; 3 import com.xkl.authorization.annotation.CurrentAdmin;
4 import com.xkl.config.Constants; 4 import com.xkl.config.Constants;
5 import com.xkl.controller.uploadsoft.UpSoftAccountController; 5 import com.xkl.controller.uploadsoft.UpSoftAccountController;
  6 +import com.xkl.controller.uspih.AdminAccountController;
6 import com.xkl.domain.XklAdminEntity; 7 import com.xkl.domain.XklAdminEntity;
7 import com.xkl.repository.AdminRepository; 8 import com.xkl.repository.AdminRepository;
8 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +40,8 @@ public class CurrentAdminMethodArgumentResolver implements HandlerMethodArgument @@ -39,7 +40,8 @@ public class CurrentAdminMethodArgumentResolver implements HandlerMethodArgument
39 @Override 40 @Override
40 public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { 41 public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
41 //取出鉴权时存入的登录用户Id 42 //取出鉴权时存入的登录用户Id
42 - String currentAdminId = ((String) webRequest.getAttribute(Constants.CURRENT_USER_ID, RequestAttributes.SCOPE_REQUEST)).replace(UpSoftAccountController.UPSOFT_TOKEN_PREFIX, ""); 43 + String currentAdminId = ((String) webRequest.getAttribute(Constants.CURRENT_USER_ID, RequestAttributes.SCOPE_REQUEST)).
  44 + replace(UpSoftAccountController.UPSOFT_TOKEN_PREFIX, "").replace(AdminAccountController.USPIH_TOKEN_PREFIX, "");
43 if (currentAdminId != null) { 45 if (currentAdminId != null) {
44 //从数据库中查询并返回 46 //从数据库中查询并返回
45 XklAdminEntity admin = adminRepository.findByIdAndStatus(Long.parseLong(currentAdminId), Constants.STATUS_OK); 47 XklAdminEntity admin = adminRepository.findByIdAndStatus(Long.parseLong(currentAdminId), Constants.STATUS_OK);
@@ -23,12 +23,12 @@ public enum ResultStatus { @@ -23,12 +23,12 @@ public enum ResultStatus {
23 23
24 // 111开头的都是与amp报告上传软件相关的 24 // 111开头的都是与amp报告上传软件相关的
25 AMP_KEY_ERROR(-11100, "AMP密钥不匹配"), 25 AMP_KEY_ERROR(-11100, "AMP密钥不匹配"),
26 - REPORT_FORMAT_ERROR(-11140,"报告格式错误"), 26 + REPORT_FORMAT_ERROR(-11140,"报告格式错误/Report json format error"),
27 REPORT_EXISTED_ERROR(-11141,"报告重复上传"), 27 REPORT_EXISTED_ERROR(-11141,"报告重复上传"),
28 - REPORT_INVALID__ERROR(-11142,"报告在数据库中不存在"), 28 + REPORT_INVALID__ERROR(-11142,"报告在数据库中不存在/Report is not exist in the DB"),
29 29
30 - INVALID_USER_ERROR(-11150,"报告所属用户未注册"),  
31 - INVALID_ADMIN_RPDEL_ERROR(-11151,"报告非此操作员创建,无权删除!"), 30 + INVALID_USER_ERROR(-11150,"报告所属用户未注册/Report user's account is not exist"),
  31 + INVALID_ADMIN_RPDEL_ERROR(-11151,"报告非此操作员创建,无权删除!/Operator can not delete this report"),
32 32
33 DB_ERROR(-11160,"服务器错误,无法写入数据库"); 33 DB_ERROR(-11160,"服务器错误,无法写入数据库");
34 34
@@ -10,6 +10,8 @@ import com.xkl.config.ResultStatus; @@ -10,6 +10,8 @@ import com.xkl.config.ResultStatus;
10 public class ReportData { 10 public class ReportData {
11 private XklAmpReportEntity ampReport; 11 private XklAmpReportEntity ampReport;
12 private List<XklAmpReportDetailEntity> rpDetailList; 12 private List<XklAmpReportDetailEntity> rpDetailList;
  13 + private List<XklAmpReportResultEntity> basicResList;
  14 +
13 // ResultStatus resStatus; 15 // ResultStatus resStatus;
14 16
15 // public ReportData(ResultStatus resStatus) { 17 // public ReportData(ResultStatus resStatus) {
@@ -32,7 +34,15 @@ public class ReportData { @@ -32,7 +34,15 @@ public class ReportData {
32 this.rpDetailList = rpDetailList; 34 this.rpDetailList = rpDetailList;
33 } 35 }
34 36
35 -// public ResultStatus getResStatus() { 37 + public List<XklAmpReportResultEntity> getBasicResList() {
  38 + return basicResList;
  39 + }
  40 +
  41 + public void setBasicResList(List<XklAmpReportResultEntity> basicResList) {
  42 + this.basicResList = basicResList;
  43 + }
  44 +
  45 + // public ResultStatus getResStatus() {
36 // return resStatus; 46 // return resStatus;
37 // } 47 // }
38 // 48 //
  1 +package com.xkl.domain;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import javax.persistence.*;
  6 +
  7 +/**
  8 + * @author zhaoyue
  9 + * report诊断结果id列表
  10 + */
  11 +@Data
  12 +@Entity
  13 +@Table(name = "xkl_amp_report_result")
  14 +public class XklAmpReportResultEntity {
  15 + @Id
  16 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  17 + @Column(name = "id")
  18 + private long id;
  19 +
  20 + @Basic
  21 + @Column(name = "report_id")
  22 + private long reportId;
  23 + @Basic
  24 + @Column(name = "result_item_id")
  25 + private int resultItemId;
  26 +
  27 + public long getId() {
  28 + return id;
  29 + }
  30 +
  31 + public void setId(long id) {
  32 + this.id = id;
  33 + }
  34 +
  35 + public long getReportId() {
  36 + return reportId;
  37 + }
  38 +
  39 + public void setReportId(long reportId) {
  40 + this.reportId = reportId;
  41 + }
  42 +
  43 + public int getResultItemId() {
  44 + return resultItemId;
  45 + }
  46 +
  47 + public void setResultItemId(int resultItemId) {
  48 + this.resultItemId = resultItemId;
  49 + }
  50 +}
  1 +package com.xkl.repository;
  2 +
  3 +import org.springframework.data.repository.CrudRepository;
  4 +import com.xkl.domain.XklAmpReportResultEntity;
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * XklAmpReportResultEntity类的CRUD操作
  9 + *
  10 + * @see XklAmpReportResultEntity
  11 + */
  12 +public interface ReportResultRepository extends CrudRepository<XklAmpReportResultEntity, Long> {
  13 + public List<XklAmpReportResultEntity> findByReportId(long reportId);
  14 +}
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