Showing
27 changed files
with
329 additions
and
165 deletions
@@ -40,11 +40,7 @@ public class SignAspect { | @@ -40,11 +40,7 @@ public class SignAspect { | ||
40 | * @return | 40 | * @return |
41 | */ | 41 | */ |
42 | private String getKeyByType(int type){ | 42 | private String getKeyByType(int type){ |
43 | - long id = 0; | ||
44 | - if(type == 1) | ||
45 | - id = 1; | ||
46 | - else | ||
47 | - id = 2; | 43 | + long id = (long)type; |
48 | return (xklInterKeyRespository.findOne(id) == null)?"":xklInterKeyRespository.findOne(id).getKey(); | 44 | return (xklInterKeyRespository.findOne(id) == null)?"":xklInterKeyRespository.findOne(id).getKey(); |
49 | } | 45 | } |
50 | /** | 46 | /** |
@@ -80,13 +76,17 @@ public class SignAspect { | @@ -80,13 +76,17 @@ public class SignAspect { | ||
80 | } | 76 | } |
81 | 77 | ||
82 | String key = getKeyByType(type); | 78 | String key = getKeyByType(type); |
83 | - long t1= UtilTools.getNow10Second(); | ||
84 | - String sign1= SecurityTool.encode("MD5",str+t+key); | ||
85 | - /** | ||
86 | - * 比较sign和过期时间 | ||
87 | - */ | ||
88 | - if(sign1.equals(sign)&&Math.abs(t1-t)<300){ | ||
89 | - request.setAttribute("signAspect",true); | 79 | + if(key != null){ |
80 | + long t1= UtilTools.getNow10Second(); | ||
81 | + String sign1= SecurityTool.encode("MD5",str+t+key); | ||
82 | + /** | ||
83 | + * 比较sign和过期时间 | ||
84 | + */ | ||
85 | + if(sign1.equals(sign)&&Math.abs(t1-t)<300){ | ||
86 | + request.setAttribute("signAspect",true); | ||
87 | + }else{ | ||
88 | + request.setAttribute("signAspect",false); | ||
89 | + } | ||
90 | }else{ | 90 | }else{ |
91 | request.setAttribute("signAspect",false); | 91 | request.setAttribute("signAspect",false); |
92 | } | 92 | } |
1 | package com.xkl.config; | 1 | package com.xkl.config; |
2 | 2 | ||
3 | +import com.xkl.domain.XklAmpReportCategoryEntity; | ||
3 | import com.xkl.domain.XklAmpReportMetaItemsEntity; | 4 | import com.xkl.domain.XklAmpReportMetaItemsEntity; |
4 | import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | 5 | import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; |
5 | 6 | ||
@@ -32,32 +33,15 @@ public interface Constants { | @@ -32,32 +33,15 @@ public interface Constants { | ||
32 | Map<Integer,XklAmpReportMetaScoreStandardEntity> scoreMap=new HashMap<>(); | 33 | Map<Integer,XklAmpReportMetaScoreStandardEntity> scoreMap=new HashMap<>(); |
33 | 34 | ||
34 | /** | 35 | /** |
35 | - * 综合加权标准 | 36 | + * 大项综合加权标准 |
36 | */ | 37 | */ |
37 | - Map<Integer,Integer> weightedScoreMap=new HashMap<Integer,Integer>(){ | ||
38 | - { | ||
39 | - put(2,10); | ||
40 | - put(3,6); | ||
41 | - put(4,4); | ||
42 | - put(5,7); | ||
43 | - put(6,3); | ||
44 | - put(7,10); | ||
45 | - put(8,10); | ||
46 | - put(9,6); | ||
47 | - put(10,4); | ||
48 | - put(11,2); | ||
49 | - put(12,4); | ||
50 | - put(13,5); | ||
51 | - put(14,5); | ||
52 | - put(15,6); | ||
53 | - put(16,4); | ||
54 | - put(17,6); | ||
55 | - put(18,2); | ||
56 | - put(19,6); | ||
57 | - } | ||
58 | - }; | 38 | + Map<Integer,XklAmpReportCategoryEntity> weightedScoreMap=new HashMap<>(); |
59 | 39 | ||
60 | Map<Integer,XklAmpReportMetaItemsEntity> itemMetaMap = new HashMap<Integer, XklAmpReportMetaItemsEntity>(); | 40 | Map<Integer,XklAmpReportMetaItemsEntity> itemMetaMap = new HashMap<Integer, XklAmpReportMetaItemsEntity>(); |
41 | + /** | ||
42 | + * 分年龄段平均得分 | ||
43 | + */ | ||
44 | + Map<String,Double> aveScoreMap = new HashMap<>(); | ||
61 | 45 | ||
62 | public static final int MALE = 0; | 46 | public static final int MALE = 0; |
63 | public static final int FEMALE = 1; | 47 | public static final int FEMALE = 1; |
1 | package com.xkl.config; | 1 | package com.xkl.config; |
2 | 2 | ||
3 | +import com.xkl.domain.XklAmpReportAverageScoreEntity; | ||
4 | +import com.xkl.domain.XklAmpReportCategoryEntity; | ||
3 | import com.xkl.domain.XklAmpReportMetaItemsEntity; | 5 | import com.xkl.domain.XklAmpReportMetaItemsEntity; |
4 | import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | 6 | import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; |
7 | +import com.xkl.repository.XklAmpReportAveScoreRespository; | ||
8 | +import com.xkl.repository.XklAmpReportCategoryRespository; | ||
5 | import com.xkl.repository.XklAmpReportMetaItemsRespository; | 9 | import com.xkl.repository.XklAmpReportMetaItemsRespository; |
6 | import com.xkl.repository.XklAmpReportMetaScoreStandardRespository; | 10 | import com.xkl.repository.XklAmpReportMetaScoreStandardRespository; |
7 | import lombok.extern.apachecommons.CommonsLog; | 11 | import lombok.extern.apachecommons.CommonsLog; |
@@ -23,10 +27,14 @@ public class ScheduledTask implements Constants{ | @@ -23,10 +27,14 @@ public class ScheduledTask implements Constants{ | ||
23 | private XklAmpReportMetaScoreStandardRespository scoreStandardRespository; | 27 | private XklAmpReportMetaScoreStandardRespository scoreStandardRespository; |
24 | @Autowired | 28 | @Autowired |
25 | private XklAmpReportMetaItemsRespository metaItemsRespository; | 29 | private XklAmpReportMetaItemsRespository metaItemsRespository; |
30 | + @Autowired | ||
31 | + private XklAmpReportCategoryRespository reportCategoryRespository; | ||
32 | + @Autowired | ||
33 | + private XklAmpReportAveScoreRespository reportAveScoreRespository; | ||
26 | 34 | ||
27 | @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) | 35 | @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) |
28 | public void getTableMap(){ | 36 | public void getTableMap(){ |
29 | - log.info("Load ScoreStandard Table"); | 37 | + log.info("Load ScoreStandard and reportCategory Table"); |
30 | Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator(); | 38 | Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator(); |
31 | while(it.hasNext()){ | 39 | while(it.hasNext()){ |
32 | XklAmpReportMetaScoreStandardEntity scoreStandard=it.next(); | 40 | XklAmpReportMetaScoreStandardEntity scoreStandard=it.next(); |
@@ -35,6 +43,16 @@ public class ScheduledTask implements Constants{ | @@ -35,6 +43,16 @@ public class ScheduledTask implements Constants{ | ||
35 | } | 43 | } |
36 | 44 | ||
37 | @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) | 45 | @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) |
46 | + public void getWeightedScoreMap(){ | ||
47 | + log.info("Load WeightedScore Table"); | ||
48 | + Iterator<XklAmpReportCategoryEntity> iterator = reportCategoryRespository.findAll().iterator(); | ||
49 | + while (iterator.hasNext()){ | ||
50 | + XklAmpReportCategoryEntity reportCategory = iterator.next(); | ||
51 | + weightedScoreMap.put(reportCategory.getId(),reportCategory); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) | ||
38 | public void getItemMetaMap(){ | 56 | public void getItemMetaMap(){ |
39 | log.info("Load ItemMeta Table"); | 57 | log.info("Load ItemMeta Table"); |
40 | Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator(); | 58 | Iterator<XklAmpReportMetaItemsEntity> it = metaItemsRespository.findAll().iterator(); |
@@ -43,4 +61,15 @@ public class ScheduledTask implements Constants{ | @@ -43,4 +61,15 @@ public class ScheduledTask implements Constants{ | ||
43 | itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems); | 61 | itemMetaMap.put(reportMetaItems.getItemId(),reportMetaItems); |
44 | } | 62 | } |
45 | } | 63 | } |
64 | + | ||
65 | + @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) | ||
66 | + public void getAveScoreMap(){ | ||
67 | + log.info("Load AveScore Table"); | ||
68 | + Iterator<XklAmpReportAverageScoreEntity> iterator = reportAveScoreRespository.findAll().iterator(); | ||
69 | + while (iterator.hasNext()){ | ||
70 | + XklAmpReportAverageScoreEntity reportCategory = iterator.next(); | ||
71 | + String ageAndType = reportCategory.getAgeId()+"-"+reportCategory.getScoreType(); | ||
72 | + aveScoreMap.put(ageAndType,reportCategory.getAverageScore()); | ||
73 | + } | ||
74 | + } | ||
46 | } | 75 | } |
1 | package com.xkl.controller; | 1 | package com.xkl.controller; |
2 | 2 | ||
3 | import com.wordnik.swagger.annotations.ApiOperation; | 3 | import com.wordnik.swagger.annotations.ApiOperation; |
4 | +import com.xkl.authorization.annotation.Authorization; | ||
5 | +import com.xkl.authorization.annotation.CurrentUser; | ||
4 | import com.xkl.authorization.annotation.Sign; | 6 | import com.xkl.authorization.annotation.Sign; |
5 | import com.xkl.authorization.manager.ITokenManager; | 7 | import com.xkl.authorization.manager.ITokenManager; |
6 | import com.xkl.authorization.model.TokenModel; | 8 | import com.xkl.authorization.model.TokenModel; |
9 | +import com.xkl.config.Constants; | ||
7 | import com.xkl.config.ResultStatus; | 10 | import com.xkl.config.ResultStatus; |
8 | -import com.xkl.domain.User; | ||
9 | -import com.xkl.domain.XklMemberOpenidEntity; | 11 | +import com.xkl.domain.*; |
12 | +import com.xkl.model.ReportDetailModel; | ||
10 | import com.xkl.model.ResultModel; | 13 | import com.xkl.model.ResultModel; |
14 | +import com.xkl.repository.XklAmpReportDetailRespository; | ||
15 | +import com.xkl.repository.XklAmpReportHealthScoreRespository; | ||
16 | +import com.xkl.repository.XklAmpReportRespository; | ||
11 | import com.xkl.repository.XklMemberOpenidRespository; | 17 | import com.xkl.repository.XklMemberOpenidRespository; |
12 | import com.xkl.security.AntiXSS; | 18 | import com.xkl.security.AntiXSS; |
13 | import com.xkl.service.ILoginService; | 19 | import com.xkl.service.ILoginService; |
@@ -21,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -21,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestParam; | ||
21 | import org.springframework.web.bind.annotation.RestController; | 27 | import org.springframework.web.bind.annotation.RestController; |
22 | 28 | ||
23 | import javax.servlet.http.HttpServletRequest; | 29 | import javax.servlet.http.HttpServletRequest; |
30 | +import java.util.ArrayList; | ||
31 | +import java.util.List; | ||
24 | 32 | ||
25 | /** | 33 | /** |
26 | * Created by win7 on 2016/10/19. | 34 | * Created by win7 on 2016/10/19. |
@@ -109,13 +117,10 @@ public class OpenIdController { | @@ -109,13 +117,10 @@ public class OpenIdController { | ||
109 | if(xklMemberOpenid == null){ | 117 | if(xklMemberOpenid == null){ |
110 | return new ResponseEntity<>(ResultModel.error(ResultStatus.OPENID_ERROR), HttpStatus.OK); | 118 | return new ResponseEntity<>(ResultModel.error(ResultStatus.OPENID_ERROR), HttpStatus.OK); |
111 | } | 119 | } |
112 | - long accountId = xklMemberOpenid.getId(); | 120 | + long accountId = xklMemberOpenid.getAccountId(); |
113 | TokenModel model = tokenManager.createToken(String.valueOf(accountId)); | 121 | TokenModel model = tokenManager.createToken(String.valueOf(accountId)); |
114 | 122 | ||
115 | return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK); | 123 | return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK); |
116 | } | 124 | } |
117 | 125 | ||
118 | - | ||
119 | - | ||
120 | - | ||
121 | } | 126 | } |
@@ -9,14 +9,13 @@ import com.xkl.authorization.annotation.Sign; | @@ -9,14 +9,13 @@ import com.xkl.authorization.annotation.Sign; | ||
9 | import com.xkl.config.Constants; | 9 | import com.xkl.config.Constants; |
10 | import com.xkl.config.ResultStatus; | 10 | import com.xkl.config.ResultStatus; |
11 | import com.xkl.domain.*; | 11 | import com.xkl.domain.*; |
12 | -import com.xkl.model.ReportDetailModel; | ||
13 | -import com.xkl.model.ReportItemGraphModel; | ||
14 | -import com.xkl.model.ReportModel; | ||
15 | -import com.xkl.model.ResultModel; | 12 | +import com.xkl.model.*; |
16 | import com.xkl.repository.XklAmpReportDetailRespository; | 13 | import com.xkl.repository.XklAmpReportDetailRespository; |
17 | import com.xkl.repository.XklAmpReportHealthScoreRespository; | 14 | import com.xkl.repository.XklAmpReportHealthScoreRespository; |
18 | import com.xkl.repository.XklAmpReportRespository; | 15 | import com.xkl.repository.XklAmpReportRespository; |
16 | +import com.xkl.security.AntiXSS; | ||
19 | import com.xkl.service.IScoreService; | 17 | import com.xkl.service.IScoreService; |
18 | +import com.xkl.tools.HtmlTools; | ||
20 | import com.xkl.tools.UtilTools; | 19 | import com.xkl.tools.UtilTools; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
22 | import org.springframework.http.HttpStatus; | 21 | import org.springframework.http.HttpStatus; |
@@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController; | @@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController; | ||
28 | 27 | ||
29 | import javax.servlet.http.HttpServletRequest; | 28 | import javax.servlet.http.HttpServletRequest; |
30 | import java.util.*; | 29 | import java.util.*; |
31 | -import java.util.function.DoubleToIntFunction; | ||
32 | 30 | ||
33 | /** | 31 | /** |
34 | * Created by win7 on 2016/11/20. | 32 | * Created by win7 on 2016/11/20. |
@@ -46,9 +44,10 @@ public class ReportController { | @@ -46,9 +44,10 @@ public class ReportController { | ||
46 | @Autowired | 44 | @Autowired |
47 | private IScoreService scoreService; | 45 | private IScoreService scoreService; |
48 | 46 | ||
49 | - @RequestMapping(value="/list",method = RequestMethod.GET) | 47 | + @AntiXSS |
50 | @Authorization | 48 | @Authorization |
51 | @Sign | 49 | @Sign |
50 | + @RequestMapping(value="/list",method = RequestMethod.GET) | ||
52 | @ApiOperation(value = "体检报告列表查询接口") | 51 | @ApiOperation(value = "体检报告列表查询接口") |
53 | @ApiImplicitParams({ | 52 | @ApiImplicitParams({ |
54 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | 53 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), |
@@ -59,13 +58,14 @@ public class ReportController { | @@ -59,13 +58,14 @@ public class ReportController { | ||
59 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | 58 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); |
60 | 59 | ||
61 | long member_id=user.getMemberId(); | 60 | long member_id=user.getMemberId(); |
62 | - List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id); | 61 | + List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberIdAndStatus(member_id,1); |
63 | return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK); | 62 | return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK); |
64 | } | 63 | } |
65 | 64 | ||
66 | - @RequestMapping(value="/detail",method = RequestMethod.GET) | 65 | + @AntiXSS |
67 | @Authorization | 66 | @Authorization |
68 | @Sign | 67 | @Sign |
68 | + @RequestMapping(value="/detail",method = RequestMethod.GET) | ||
69 | @ApiOperation(value = "体检报告详情查询接口") | 69 | @ApiOperation(value = "体检报告详情查询接口") |
70 | @ApiImplicitParams({ | 70 | @ApiImplicitParams({ |
71 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | 71 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), |
@@ -93,8 +93,11 @@ public class ReportController { | @@ -93,8 +93,11 @@ public class ReportController { | ||
93 | XklAmpReportMetaItemsEntity metaItems=Constants.itemMetaMap.get(itemId); | 93 | XklAmpReportMetaItemsEntity metaItems=Constants.itemMetaMap.get(itemId); |
94 | if(metaItems!=null){ | 94 | if(metaItems!=null){ |
95 | reportDetail.setTitle(metaItems.getTitle()); | 95 | reportDetail.setTitle(metaItems.getTitle()); |
96 | - reportDetail.setNormal(metaItems.getStandardLowMale()+" - "+metaItems.getStandardHighMale()); | ||
97 | - reportDetail.setNormalNv(metaItems.getStandardLowFemale()+ " - "+metaItems.getStandardHighFemale()); | 96 | + if(report.getSex()==Constants.MALE){ |
97 | + reportDetail.setNormalRange(metaItems.getStandardLowMale()+" - "+metaItems.getStandardHighMale()); | ||
98 | + }else{ | ||
99 | + reportDetail.setNormalRange(metaItems.getStandardLowFemale()+ " - "+metaItems.getStandardHighFemale()); | ||
100 | + } | ||
98 | reportDetail.setType(metaItems.getType()); | 101 | reportDetail.setType(metaItems.getType()); |
99 | } | 102 | } |
100 | 103 | ||
@@ -108,31 +111,37 @@ public class ReportController { | @@ -108,31 +111,37 @@ public class ReportController { | ||
108 | return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); | 111 | return new ResponseEntity<>(ResultModel.ok(reportModel), HttpStatus.OK); |
109 | } | 112 | } |
110 | 113 | ||
111 | - /*@RequestMapping(value="/score",method = RequestMethod.GET) | ||
112 | - @Authorization | 114 | + @AntiXSS |
113 | @Sign | 115 | @Sign |
114 | - @ApiOperation(value = "健康评分接口(测试service用,后续可以注释掉)") | ||
115 | - @ApiImplicitParams({ | ||
116 | - @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | ||
117 | - }) | ||
118 | - public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request, @CurrentUser User user,@RequestParam long report_id, | 116 | + @RequestMapping(value="/score",method = RequestMethod.GET) |
117 | + @ApiOperation(value = "健康评分接口") | ||
118 | + public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request,@RequestParam long report_id, | ||
119 | @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | 119 | @RequestParam String sign, @RequestParam long t, @RequestParam int type) { |
120 | if(!(boolean)request.getAttribute("signAspect")) | 120 | if(!(boolean)request.getAttribute("signAspect")) |
121 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | 121 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); |
122 | + double score = 0; | ||
123 | + XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id); | ||
124 | + if(report != null ){ | ||
125 | + if(report.getScore()==0){//首次调用接口,score为0 | ||
126 | + //TODO:可以在上传时直接打分? | ||
127 | + //单独测试需要删除xkl_amp_report_health_scroe表中数据 | ||
128 | + score = scoreService.getScore(report_id); | ||
129 | + }else{ | ||
130 | + score = report.getScore(); | ||
131 | + } | ||
132 | + } | ||
133 | + return new ResponseEntity<>(ResultModel.ok(score), HttpStatus.OK); | ||
134 | + } | ||
122 | 135 | ||
123 | - //单独测试需要删除xkl_amp_report_health_scroe表中数据 | ||
124 | - scoreService.getScore(report_id); | ||
125 | - return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK); | ||
126 | - }*/ | ||
127 | - | ||
128 | - @RequestMapping(value="/itemInfo",method = RequestMethod.GET) | 136 | + @AntiXSS |
129 | @Authorization | 137 | @Authorization |
130 | @Sign | 138 | @Sign |
139 | + @RequestMapping(value="/itemInfo",method = RequestMethod.GET) | ||
131 | @ApiOperation(value = "指标解释查询接口") | 140 | @ApiOperation(value = "指标解释查询接口") |
132 | @ApiImplicitParams({ | 141 | @ApiImplicitParams({ |
133 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | 142 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), |
134 | }) | 143 | }) |
135 | - public ResponseEntity<ResultModel> getReportItemInfo(HttpServletRequest request, @CurrentUser User user,@RequestParam int itemId,@RequestParam int status, | 144 | + public ResponseEntity<ResultModel> getReportItemInfo(HttpServletRequest request, @CurrentUser User user,@RequestParam int itemId,@RequestParam int status,@RequestParam boolean isPureHtml, |
136 | @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | 145 | @RequestParam String sign, @RequestParam long t, @RequestParam int type) { |
137 | if(!(boolean)request.getAttribute("signAspect")) | 146 | if(!(boolean)request.getAttribute("signAspect")) |
138 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | 147 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); |
@@ -141,11 +150,11 @@ public class ReportController { | @@ -141,11 +150,11 @@ public class ReportController { | ||
141 | String result=""; | 150 | String result=""; |
142 | if(metaItems!= null){ | 151 | if(metaItems!= null){ |
143 | //0, normal,1, lower,2, higher | 152 | //0, normal,1, lower,2, higher |
144 | - if(status == 0){ | 153 | + if(status == Constants.NORMAL){ |
145 | result = metaItems.getExplainNormal(); | 154 | result = metaItems.getExplainNormal(); |
146 | - }else if(status == 1){ | 155 | + }else if(status == Constants.LOWER){ |
147 | result = metaItems.getExplainLow(); | 156 | result = metaItems.getExplainLow(); |
148 | - }else if(status == 2){ | 157 | + }else if(status == Constants.HIGHER){ |
149 | result = metaItems.getExplainHigh(); | 158 | result = metaItems.getExplainHigh(); |
150 | }else{ | 159 | }else{ |
151 | result = "没有此status相关信息"; | 160 | result = "没有此status相关信息"; |
@@ -153,13 +162,16 @@ public class ReportController { | @@ -153,13 +162,16 @@ public class ReportController { | ||
153 | }else{ | 162 | }else{ |
154 | result = "没有此itemId相关信息"; | 163 | result = "没有此itemId相关信息"; |
155 | } | 164 | } |
156 | - | 165 | + if(isPureHtml){ |
166 | + result = HtmlTools.stripHtml(result); | ||
167 | + } | ||
157 | return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK); | 168 | return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK); |
158 | } | 169 | } |
159 | 170 | ||
160 | - @RequestMapping(value="/itemGraph",method = RequestMethod.GET) | 171 | + @AntiXSS |
161 | @Authorization | 172 | @Authorization |
162 | @Sign | 173 | @Sign |
174 | + @RequestMapping(value="/itemGraph",method = RequestMethod.GET) | ||
163 | @ApiOperation(value = "指标曲线查询接口") | 175 | @ApiOperation(value = "指标曲线查询接口") |
164 | @ApiImplicitParams({ | 176 | @ApiImplicitParams({ |
165 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | 177 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), |
@@ -170,7 +182,7 @@ public class ReportController { | @@ -170,7 +182,7 @@ public class ReportController { | ||
170 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | 182 | return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); |
171 | 183 | ||
172 | long member_id=user.getMemberId(); | 184 | long member_id=user.getMemberId(); |
173 | - List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id); | 185 | + List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberIdAndStatus(member_id,1); |
174 | List<ReportItemGraphModel> reportItemGraphModelList =new ArrayList<>(); | 186 | List<ReportItemGraphModel> reportItemGraphModelList =new ArrayList<>(); |
175 | 187 | ||
176 | if(xklAmpReportEntity!=null && xklAmpReportEntity.size()>0){ | 188 | if(xklAmpReportEntity!=null && xklAmpReportEntity.size()>0){ |
@@ -192,4 +204,47 @@ public class ReportController { | @@ -192,4 +204,47 @@ public class ReportController { | ||
192 | } | 204 | } |
193 | 205 | ||
194 | 206 | ||
207 | + @AntiXSS | ||
208 | + @Authorization | ||
209 | + @Sign | ||
210 | + @RequestMapping(value="/compare",method = RequestMethod.POST) | ||
211 | + @ApiOperation(value = "微信端体检报告分年龄比较接口") | ||
212 | + public ResponseEntity<ResultModel> openIdCompare(HttpServletRequest request, @CurrentUser User user,@RequestParam Long report_id, | ||
213 | + @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | ||
214 | + if(!(boolean)request.getAttribute("signAspect")) | ||
215 | + return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | ||
216 | + List<CompareModel> result = new ArrayList<>(); | ||
217 | + | ||
218 | + XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id); | ||
219 | + double score = 0; | ||
220 | + if(report != null ) { | ||
221 | + if (report.getScore() == 0) {//首次调用接口,score为0 | ||
222 | + score = scoreService.getScore(report_id); | ||
223 | + } else { | ||
224 | + score = report.getScore(); | ||
225 | + } | ||
226 | + int age = report.getAge(); | ||
227 | + String ageId = String.valueOf((age - age % 5) / 5); | ||
228 | + for (Map.Entry<Integer, XklAmpReportCategoryEntity> entry : Constants.weightedScoreMap.entrySet()) { | ||
229 | + //List<XklAmpReportHealthScoreEntity> scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id); | ||
230 | + int typeId = entry.getKey(); | ||
231 | + XklAmpReportCategoryEntity value = entry.getValue(); | ||
232 | + String key = ageId +"-"+ typeId; | ||
233 | + double aveScore = Constants.aveScoreMap.get(key); | ||
234 | + double typeScore = 0; | ||
235 | + XklAmpReportHealthScoreEntity scoreEntity = xklAmpReportHealthScoreRespository.findByReportIdAndType(report_id, typeId); | ||
236 | + if (scoreEntity != null) { | ||
237 | + typeScore = scoreEntity.getTypeHealthScore(); | ||
238 | + }else{ | ||
239 | + if(typeId==1){//第一项为测试项目 | ||
240 | + typeScore = score; | ||
241 | + } | ||
242 | + } | ||
243 | + CompareModel cm = new CompareModel(typeId, value.getName(), typeScore, aveScore); | ||
244 | + result.add(cm); | ||
245 | + } | ||
246 | + } | ||
247 | + return new ResponseEntity<>(ResultModel.ok(result), HttpStatus.OK); | ||
248 | + } | ||
249 | + | ||
195 | } | 250 | } |
@@ -11,6 +11,7 @@ import com.xkl.authorization.model.TokenModel; | @@ -11,6 +11,7 @@ import com.xkl.authorization.model.TokenModel; | ||
11 | import com.xkl.config.ResultStatus; | 11 | import com.xkl.config.ResultStatus; |
12 | import com.xkl.domain.User; | 12 | import com.xkl.domain.User; |
13 | import com.xkl.model.ResultModel; | 13 | import com.xkl.model.ResultModel; |
14 | +import com.xkl.security.AntiXSS; | ||
14 | import com.xkl.service.ILoginService; | 15 | import com.xkl.service.ILoginService; |
15 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
16 | import org.springframework.http.HttpStatus; | 17 | import org.springframework.http.HttpStatus; |
@@ -34,6 +35,7 @@ public class TokenController { | @@ -34,6 +35,7 @@ public class TokenController { | ||
34 | @Autowired | 35 | @Autowired |
35 | private ITokenManager tokenManager; | 36 | private ITokenManager tokenManager; |
36 | 37 | ||
38 | + @AntiXSS | ||
37 | @Sign | 39 | @Sign |
38 | @RequestMapping(method = RequestMethod.POST) | 40 | @RequestMapping(method = RequestMethod.POST) |
39 | @ApiOperation(value = "用户登录接口") | 41 | @ApiOperation(value = "用户登录接口") |
@@ -54,7 +56,7 @@ public class TokenController { | @@ -54,7 +56,7 @@ public class TokenController { | ||
54 | return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK); | 56 | return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK); |
55 | } | 57 | } |
56 | 58 | ||
57 | - | 59 | + @AntiXSS |
58 | @Authorization | 60 | @Authorization |
59 | @Sign | 61 | @Sign |
60 | @RequestMapping(method = RequestMethod.DELETE) | 62 | @RequestMapping(method = RequestMethod.DELETE) |
@@ -77,9 +77,8 @@ public class UserInfoController { | @@ -77,9 +77,8 @@ public class UserInfoController { | ||
77 | return new ResponseEntity<>(ResultModel.ok(ResultStatus.USER_REGISTER), HttpStatus.OK); | 77 | return new ResponseEntity<>(ResultModel.ok(ResultStatus.USER_REGISTER), HttpStatus.OK); |
78 | } | 78 | } |
79 | 79 | ||
80 | - | ||
81 | - @Authorization | ||
82 | @AntiXSS | 80 | @AntiXSS |
81 | + @Authorization | ||
83 | @Sign | 82 | @Sign |
84 | @RequestMapping(method = RequestMethod.PUT) | 83 | @RequestMapping(method = RequestMethod.PUT) |
85 | @ApiOperation(value = "用户密码修改接口") | 84 | @ApiOperation(value = "用户密码修改接口") |
@@ -101,7 +100,7 @@ public class UserInfoController { | @@ -101,7 +100,7 @@ public class UserInfoController { | ||
101 | return new ResponseEntity<>(new ResultModel(ResultStatus.USER_MODPASS_LOGOUT), HttpStatus.OK); | 100 | return new ResponseEntity<>(new ResultModel(ResultStatus.USER_MODPASS_LOGOUT), HttpStatus.OK); |
102 | } | 101 | } |
103 | 102 | ||
104 | - | 103 | + @AntiXSS |
105 | @Authorization | 104 | @Authorization |
106 | @Sign | 105 | @Sign |
107 | @RequestMapping(method = RequestMethod.GET) | 106 | @RequestMapping(method = RequestMethod.GET) |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2017/1/15. | ||
9 | + */ | ||
10 | +@Data | ||
11 | +@Entity | ||
12 | +@Table(name = "xkl_amp_report_average_score") | ||
13 | +public class XklAmpReportAverageScoreEntity { | ||
14 | + @Id | ||
15 | + @Column(name = "id") | ||
16 | + private int id; | ||
17 | + @Basic | ||
18 | + @Column(name = "age_id") | ||
19 | + private int ageId; | ||
20 | + @Basic | ||
21 | + @Column(name = "score_type") | ||
22 | + private int scoreType; | ||
23 | + @Basic | ||
24 | + @Column(name = "average_score") | ||
25 | + private double averageScore; | ||
26 | +} |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2017/1/15. | ||
9 | + */ | ||
10 | +@Data | ||
11 | +@Entity | ||
12 | +@Table(name = "xkl_amp_report_category") | ||
13 | +public class XklAmpReportCategoryEntity { | ||
14 | + @Id | ||
15 | + @Column(name = "id") | ||
16 | + private int id; | ||
17 | + @Basic | ||
18 | + @Column(name = "name") | ||
19 | + private String name; | ||
20 | + @Basic | ||
21 | + @Column(name = "picture") | ||
22 | + private String picture; | ||
23 | + @Basic | ||
24 | + @Column(name = "score_weight") | ||
25 | + private Double scoreWeight; | ||
26 | +} |
@@ -10,7 +10,7 @@ import javax.persistence.*; | @@ -10,7 +10,7 @@ import javax.persistence.*; | ||
10 | */ | 10 | */ |
11 | @Data | 11 | @Data |
12 | @Entity | 12 | @Entity |
13 | -@Table(name = "xkl_amp_report_detail", schema = "hanhe_test", catalog = "") | 13 | +@Table(name = "xkl_amp_report_detail") |
14 | public class XklAmpReportDetailEntity { | 14 | public class XklAmpReportDetailEntity { |
15 | @Id | 15 | @Id |
16 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
@@ -11,7 +11,7 @@ import java.sql.Timestamp; | @@ -11,7 +11,7 @@ import java.sql.Timestamp; | ||
11 | */ | 11 | */ |
12 | @Data | 12 | @Data |
13 | @Entity | 13 | @Entity |
14 | -@Table(name = "xkl_amp_report", schema = "hanhe_test", catalog = "") | 14 | +@Table(name = "xkl_amp_report") |
15 | public class XklAmpReportEntity { | 15 | public class XklAmpReportEntity { |
16 | @Id | 16 | @Id |
17 | @Column(name = "id") | 17 | @Column(name = "id") |
@@ -109,7 +109,7 @@ public class XklAmpReportEntity { | @@ -109,7 +109,7 @@ public class XklAmpReportEntity { | ||
109 | private long companyId; | 109 | private long companyId; |
110 | @Basic | 110 | @Basic |
111 | @Column(name = "status") | 111 | @Column(name = "status") |
112 | - private Byte status; | 112 | + private int status; |
113 | 113 | ||
114 | public long getId() { | 114 | public long getId() { |
115 | return id; | 115 | return id; |
@@ -388,12 +388,4 @@ public class XklAmpReportEntity { | @@ -388,12 +388,4 @@ public class XklAmpReportEntity { | ||
388 | public void setCompanyId(long companyId) { | 388 | public void setCompanyId(long companyId) { |
389 | this.companyId = companyId; | 389 | this.companyId = companyId; |
390 | } | 390 | } |
391 | - | ||
392 | - public Byte getStatus() { | ||
393 | - return status; | ||
394 | - } | ||
395 | - | ||
396 | - public void setStatus(Byte status) { | ||
397 | - this.status = status; | ||
398 | - } | ||
399 | } | 391 | } |
@@ -10,7 +10,7 @@ import javax.persistence.*; | @@ -10,7 +10,7 @@ import javax.persistence.*; | ||
10 | */ | 10 | */ |
11 | @Data | 11 | @Data |
12 | @Entity | 12 | @Entity |
13 | -@Table(name = "xkl_amp_report_health_scroe", schema = "hanhe_test", catalog = "") | 13 | +@Table(name = "xkl_amp_report_health_scroe") |
14 | public class XklAmpReportHealthScoreEntity { | 14 | public class XklAmpReportHealthScoreEntity { |
15 | @Id | 15 | @Id |
16 | @GeneratedValue | 16 | @GeneratedValue |
@@ -10,7 +10,7 @@ import javax.persistence.*; | @@ -10,7 +10,7 @@ import javax.persistence.*; | ||
10 | */ | 10 | */ |
11 | @Data | 11 | @Data |
12 | @Entity | 12 | @Entity |
13 | -@Table(name = "xkl_amp_report_meta_items", schema = "hanhe_test", catalog = "") | 13 | +@Table(name = "xkl_amp_report_meta_items") |
14 | public class XklAmpReportMetaItemsEntity { | 14 | public class XklAmpReportMetaItemsEntity { |
15 | @Id | 15 | @Id |
16 | @Column(name = "id") | 16 | @Column(name = "id") |
@@ -10,7 +10,7 @@ import javax.persistence.*; | @@ -10,7 +10,7 @@ import javax.persistence.*; | ||
10 | */ | 10 | */ |
11 | @Data | 11 | @Data |
12 | @Entity | 12 | @Entity |
13 | -@Table(name = "xkl_amp_report_meta_score_standard", schema = "hanhe_test", catalog = "") | 13 | +@Table(name = "xkl_amp_report_meta_score_standard") |
14 | public class XklAmpReportMetaScoreStandardEntity { | 14 | public class XklAmpReportMetaScoreStandardEntity { |
15 | @Id | 15 | @Id |
16 | @GeneratedValue | 16 | @GeneratedValue |
@@ -10,7 +10,7 @@ import javax.persistence.*; | @@ -10,7 +10,7 @@ import javax.persistence.*; | ||
10 | */ | 10 | */ |
11 | @Data | 11 | @Data |
12 | @Entity | 12 | @Entity |
13 | -@Table(name = "xkl_inter_key", schema = "hanhe_test", catalog = "") | 13 | +@Table(name = "xkl_inter_key") |
14 | public class XklInterKeyEntity { | 14 | public class XklInterKeyEntity { |
15 | @Id | 15 | @Id |
16 | @Column(name = "id") | 16 | @Column(name = "id") |
@@ -12,7 +12,7 @@ import java.sql.Date; | @@ -12,7 +12,7 @@ import java.sql.Date; | ||
12 | */ | 12 | */ |
13 | @Data | 13 | @Data |
14 | @Entity | 14 | @Entity |
15 | -@Table(name = "xkl_member", schema = "hanhe_test", catalog = "") | 15 | +@Table(name = "xkl_member") |
16 | public class XklMemberEntity { | 16 | public class XklMemberEntity { |
17 | @Id | 17 | @Id |
18 | @GeneratedValue | 18 | @GeneratedValue |
@@ -9,7 +9,7 @@ import javax.persistence.*; | @@ -9,7 +9,7 @@ import javax.persistence.*; | ||
9 | */ | 9 | */ |
10 | @Data | 10 | @Data |
11 | @Entity | 11 | @Entity |
12 | -@Table(name = "xkl_member_openid", schema = "hanhe_test", catalog = "") | 12 | +@Table(name = "xkl_member_openid") |
13 | public class XklMemberOpenidEntity { | 13 | public class XklMemberOpenidEntity { |
14 | @Id | 14 | @Id |
15 | @GeneratedValue | 15 | @GeneratedValue |
1 | +package com.xkl.model; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Data; | ||
5 | +import lombok.NoArgsConstructor; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2017/1/15. | ||
9 | + */ | ||
10 | +@Data | ||
11 | +@NoArgsConstructor | ||
12 | +@AllArgsConstructor | ||
13 | +public class CompareModel { | ||
14 | + long typeId; | ||
15 | + String typeName; | ||
16 | + double typeScore; | ||
17 | + double typeScoreAVG; | ||
18 | +} |
@@ -17,75 +17,10 @@ public class ReportDetailModel { | @@ -17,75 +17,10 @@ public class ReportDetailModel { | ||
17 | * XklAmpReportMetaItemsEntity | 17 | * XklAmpReportMetaItemsEntity |
18 | */ | 18 | */ |
19 | private String title; | 19 | private String title; |
20 | - private String normalNv; | ||
21 | - private String normal; | 20 | + private String normalRange; |
22 | /** | 21 | /** |
23 | * XklAmpReportHealthScoreEntity | 22 | * XklAmpReportHealthScoreEntity |
24 | */ | 23 | */ |
25 | private int type; | 24 | private int type; |
26 | private double typeHealthScore; | 25 | private double typeHealthScore; |
27 | - | ||
28 | - public int getItemId() { | ||
29 | - return itemId; | ||
30 | - } | ||
31 | - | ||
32 | - public void setItemId(int itemId) { | ||
33 | - this.itemId = itemId; | ||
34 | - } | ||
35 | - | ||
36 | - public double getItemValue() { | ||
37 | - return itemValue; | ||
38 | - } | ||
39 | - | ||
40 | - public void setItemValue(double itemValue) { | ||
41 | - this.itemValue = itemValue; | ||
42 | - } | ||
43 | - | ||
44 | - public int getStatus() { | ||
45 | - return status; | ||
46 | - } | ||
47 | - | ||
48 | - public void setStatus(int status) { | ||
49 | - this.status = status; | ||
50 | - } | ||
51 | - | ||
52 | - public String getTitle() { | ||
53 | - return title; | ||
54 | - } | ||
55 | - | ||
56 | - public void setTitle(String title) { | ||
57 | - this.title = title; | ||
58 | - } | ||
59 | - | ||
60 | - public String getNormalNv() { | ||
61 | - return normalNv; | ||
62 | - } | ||
63 | - | ||
64 | - public void setNormalNv(String normalNv) { | ||
65 | - this.normalNv = normalNv; | ||
66 | - } | ||
67 | - | ||
68 | - public String getNormal() { | ||
69 | - return normal; | ||
70 | - } | ||
71 | - | ||
72 | - public void setNormal(String normal) { | ||
73 | - this.normal = normal; | ||
74 | - } | ||
75 | - | ||
76 | - public int getType() { | ||
77 | - return type; | ||
78 | - } | ||
79 | - | ||
80 | - public void setType(int type) { | ||
81 | - this.type = type; | ||
82 | - } | ||
83 | - | ||
84 | - public double getTypeHealthScore() { | ||
85 | - return typeHealthScore; | ||
86 | - } | ||
87 | - | ||
88 | - public void setTypeHealthScore(double typeHealthScore) { | ||
89 | - this.typeHealthScore = typeHealthScore; | ||
90 | - } | ||
91 | } | 26 | } |
1 | +package com.xkl.repository; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAmpReportAverageScoreEntity; | ||
4 | +import com.xkl.domain.XklAmpReportCategoryEntity; | ||
5 | +import org.springframework.data.repository.CrudRepository; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2016/11/20. | ||
9 | + */ | ||
10 | +public interface XklAmpReportAveScoreRespository extends CrudRepository<XklAmpReportAverageScoreEntity, Integer> { | ||
11 | + | ||
12 | +} |
1 | +package com.xkl.repository; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAmpReportCategoryEntity; | ||
4 | +import com.xkl.domain.XklMemberEntity; | ||
5 | +import org.springframework.data.repository.CrudRepository; | ||
6 | + | ||
7 | +import javax.persistence.criteria.CriteriaBuilder; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by win7 on 2016/11/20. | ||
11 | + */ | ||
12 | +public interface XklAmpReportCategoryRespository extends CrudRepository<XklAmpReportCategoryEntity, Integer> { | ||
13 | + | ||
14 | +} |
@@ -13,6 +13,7 @@ public interface XklAmpReportHealthScoreRespository extends CrudRepository<XklAm | @@ -13,6 +13,7 @@ public interface XklAmpReportHealthScoreRespository extends CrudRepository<XklAm | ||
13 | //item_id | 13 | //item_id |
14 | public XklAmpReportHealthScoreEntity findByReportIdAndType(long report_id,int type); | 14 | public XklAmpReportHealthScoreEntity findByReportIdAndType(long report_id,int type); |
15 | 15 | ||
16 | + public List<XklAmpReportHealthScoreEntity> findByReportId(long report_id); | ||
16 | //public boolean existsByReportId(long report_id); | 17 | //public boolean existsByReportId(long report_id); |
17 | 18 | ||
18 | //public void saveByReportId(List<XklAmpReportHealthScoreEntity> list,long report_id); | 19 | //public void saveByReportId(List<XklAmpReportHealthScoreEntity> list,long report_id); |
@@ -12,5 +12,5 @@ import java.util.List; | @@ -12,5 +12,5 @@ import java.util.List; | ||
12 | */ | 12 | */ |
13 | public interface XklAmpReportRespository extends CrudRepository<XklAmpReportEntity, Long> { | 13 | public interface XklAmpReportRespository extends CrudRepository<XklAmpReportEntity, Long> { |
14 | //member_id | 14 | //member_id |
15 | - public List<XklAmpReportEntity> findByMemberId(long member_id); | 15 | + public List<XklAmpReportEntity> findByMemberIdAndStatus(long member_id,int status); |
16 | } | 16 | } |
@@ -4,5 +4,5 @@ package com.xkl.service; | @@ -4,5 +4,5 @@ package com.xkl.service; | ||
4 | * Created by win7 on 2016/11/21. | 4 | * Created by win7 on 2016/11/21. |
5 | */ | 5 | */ |
6 | public interface IScoreService { | 6 | public interface IScoreService { |
7 | - public void getScore(long report_id); | 7 | + public double getScore(long report_id); |
8 | } | 8 | } |
@@ -28,7 +28,7 @@ public class ScoreServiceImpl implements IScoreService,Constants{ | @@ -28,7 +28,7 @@ public class ScoreServiceImpl implements IScoreService,Constants{ | ||
28 | private XklAmpReportHealthScoreRespository xklAmpReportHealthScoreRespository; | 28 | private XklAmpReportHealthScoreRespository xklAmpReportHealthScoreRespository; |
29 | 29 | ||
30 | @Override | 30 | @Override |
31 | - public void getScore(long report_id) { | 31 | + public double getScore(long report_id) { |
32 | Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map | 32 | Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map |
33 | 33 | ||
34 | /** | 34 | /** |
@@ -72,8 +72,8 @@ public class ScoreServiceImpl implements IScoreService,Constants{ | @@ -72,8 +72,8 @@ public class ScoreServiceImpl implements IScoreService,Constants{ | ||
72 | scoreEntity.setTypeHealthScore(score); | 72 | scoreEntity.setTypeHealthScore(score); |
73 | saveScoreList.add(scoreEntity); | 73 | saveScoreList.add(scoreEntity); |
74 | 74 | ||
75 | - double weightedScore=weightedScoreMap.get(item_type); | ||
76 | - finalScore += weightedScore*(score/100); | 75 | + double weightedScore=weightedScoreMap.get(item_type).getScoreWeight(); |
76 | + finalScore += weightedScore*score; | ||
77 | } | 77 | } |
78 | /** | 78 | /** |
79 | * 每类得分存入xkl_amp_report_health_scroe | 79 | * 每类得分存入xkl_amp_report_health_scroe |
@@ -87,5 +87,6 @@ public class ScoreServiceImpl implements IScoreService,Constants{ | @@ -87,5 +87,6 @@ public class ScoreServiceImpl implements IScoreService,Constants{ | ||
87 | report.setScore(finalScore); | 87 | report.setScore(finalScore); |
88 | xklAmpReportRespository.save(report); | 88 | xklAmpReportRespository.save(report); |
89 | } | 89 | } |
90 | + return finalScore; | ||
90 | } | 91 | } |
91 | } | 92 | } |
src/main/java/com/xkl/tools/HtmlTools.java
0 → 100644
1 | +package com.xkl.tools; | ||
2 | + | ||
3 | +import java.util.regex.Matcher; | ||
4 | +import java.util.regex.Pattern; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by win7 on 2017/1/15. | ||
8 | + */ | ||
9 | +public class HtmlTools { | ||
10 | + private static final String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式 | ||
11 | + private static final String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式 | ||
12 | + private static final String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式 | ||
13 | + private static final String regEx_space = "\\s*|\t|\r|\n";//定义空格回车换行符 | ||
14 | + | ||
15 | + /** | ||
16 | + * @param htmlStr | ||
17 | + * @return 删除html, style, javascript标签 ,剩余纯文本 | ||
18 | + */ | ||
19 | + public static String getTextFromHtml(String htmlStr) { | ||
20 | + Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE); | ||
21 | + Matcher m_script = p_script.matcher(htmlStr); | ||
22 | + htmlStr = m_script.replaceAll(""); // 过滤script标签 | ||
23 | + | ||
24 | + Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE); | ||
25 | + Matcher m_style = p_style.matcher(htmlStr); | ||
26 | + htmlStr = m_style.replaceAll(""); // 过滤style标签 | ||
27 | + | ||
28 | + Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); | ||
29 | + Matcher m_html = p_html.matcher(htmlStr); | ||
30 | + htmlStr = m_html.replaceAll(""); // 过滤html标签 | ||
31 | + | ||
32 | + Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE); | ||
33 | + Matcher m_space = p_space.matcher(htmlStr); | ||
34 | + htmlStr = m_space.replaceAll(""); // 过滤空格回车标签 | ||
35 | + | ||
36 | + htmlStr = htmlStr.replaceAll(" ", ""); //过滤 | ||
37 | + | ||
38 | + return htmlStr.trim(); // 返回文本字符串 | ||
39 | + } | ||
40 | + | ||
41 | + | ||
42 | + /** | ||
43 | + * @param content | ||
44 | + * @return 删除纯html标签,保留换行与空格 | ||
45 | + */ | ||
46 | + public static String stripHtml(String content) { | ||
47 | + // <p>段落替换为换行 | ||
48 | + content = content.replaceAll("<p .*?>", "\r\n"); | ||
49 | + // <br><br/>替换为换行 | ||
50 | + content = content.replaceAll("<br\\s*/?>", "\r\n"); | ||
51 | + // 去掉其它的<>之间的东西 | ||
52 | + content = content.replaceAll("\\<.*?>", ""); | ||
53 | + // 替换空格转义符 | ||
54 | + content = content.replaceAll(" ", " "); | ||
55 | + | ||
56 | + return content; | ||
57 | + } | ||
58 | + | ||
59 | + public static void main(String[] args) { | ||
60 | + String test1= "<p> <span style=\"font-size:16px;\"><strong><b style=\"line-height:20px;text-indent:-29.266666412353516px;white-space:normal;background-color:#FFFFFF;\"><b><span style=\"font-size:18px;font-family:宋体;\">血红蛋白:</span></b></b><span style=\"line-height:20px;text-indent:-29.266666412353516px;white-space:normal;background-color:#FFFFFF;font-size:18px;font-family:宋体;\"></span></strong><span style=\"font-size:18px;font-family:宋体;\"></span><span style=\"line-height:20px;text-indent:-29.266666412353516px;white-space:normal;background-color:#FFFFFF;font-size:18px;font-family:宋体;\"></span><span style=\"line-height:20px;text-indent:-29.266666412353516px;white-space:normal;background-color:#FFFFFF;font-size:18px;font-family:宋体;color:#000000;\">是一种含铁的蛋白质,其功能是运输氧和二氧化碳,维持血液酸碱平衡。</span></span> </p> <p> <span style=\"font-size:16px;\"></span><span style=\"font-size:16px;\"></span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <b style=\"text-indent:45pt;\"><span style=\"font-size:18px;font-family:宋体;\">成年男性:</span></b><span style=\"font-size:18px;font-family:宋体;\"></span><span style=\"font-size:18px;\">120g</span><span style=\"font-size:18px;font-family:宋体;\">~</span><span style=\"font-size:18px;\">160 g/L</span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <b style=\"text-indent:45pt;\"><span style=\"font-size:18px;font-family:宋体;\">成年女性:</span></b><span style=\"font-size:18px;font-family:宋体;\"></span><span style=\"font-size:18px;\">110g</span><span style=\"font-size:18px;font-family:宋体;\">~</span><span style=\"font-size:18px;\">150 g/L</span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <b style=\"text-indent:45pt;\"><span style=\"font-size:18px;font-family:宋体;\">儿 童:</span></b><span style=\"font-size:18px;font-family:宋体;\"></span><span style=\"font-size:18px;\">110g</span><span style=\"font-size:18px;font-family:宋体;\">~</span><span style=\"font-size:18px;\">160 g/L</span><span style=\"font-size:18px;\"> </span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <b style=\"text-indent:45pt;\"><span style=\"font-size:18px;font-family:宋体;\">新 生 儿:</span></b><span style=\"font-size:18px;font-family:宋体;\"></span><span style=\"font-size:18px;\">170g</span><span style=\"font-size:18px;font-family:宋体;\">~</span><span style=\"font-size:18px;\">200 g/L</span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <span style=\"font-size:18px;color:#E53333;\"><span style=\"white-space:nowrap;color:#E53333;\"><strong><br /> </strong></span></span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <span style=\"font-size:18px;color:#E53333;\"><span style=\"white-space:nowrap;color:#E53333;\"><strong>升高:缺氧、吸烟、剧烈运动后,慢性肺源性心脏病或先天性心脏病及高原病。</strong></span></span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <span style=\"font-size:18px;\"><span style=\"white-space:nowrap;color:#009900;\"><strong><br /> </strong></span></span> </p> <p style=\"margin-left:21.95pt;line-height:20px;white-space:normal;text-indent:-21.95pt;\"> <span style=\"font-size:18px;\"><span style=\"white-space:nowrap;color:#009900;\"><strong>建议:戒烟,到负氧离子浓度高的环境中调养,如公园、森林等。</strong></span><span style=\"color:#009900;\"><strong></strong></span><br /> </span> </p> <p> <span style=\"font-size:16px;\"><strong><span style=\"color:#e53333;\"> </span></strong></span> </p> <p style=\"text-indent:18.05pt;\"> <strong><b><span style=\"font-size:16px;font-family:宋体;color:red;\"><br /> </span></b> </strong> </p> <p style=\"text-indent:18.05pt;\"> <strong><br /> </strong> </p> <span style=\"font-size:16px;\"><strong></strong></span> <p> <br /> </p> <p> </p>"; | ||
61 | + String test2= "<span style=\"font-size:16px;\"><strong>总胆固醇:</strong>指血液中所有脂蛋白所含胆固醇之总和,人群总胆固醇水平主要取决于遗传因素和生活方式。</span><br />"; | ||
62 | + System.out.println(stripHtml(test1)); | ||
63 | + System.out.println(stripHtml(test2)); | ||
64 | + } | ||
65 | +} |
@@ -15,7 +15,7 @@ spring.datasource.password=HANhetest2016 | @@ -15,7 +15,7 @@ spring.datasource.password=HANhetest2016 | ||
15 | 15 | ||
16 | #Redis | 16 | #Redis |
17 | spring.redis.host=127.0.0.1 | 17 | spring.redis.host=127.0.0.1 |
18 | -#spring.redis.password=foobared | 18 | +spring.redis.password=foobared |
19 | #spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com | 19 | #spring.redis.host=r-m5e7cedd3124afd4.redis.rds.aliyuncs.com |
20 | #spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016 | 20 | #spring.redis.password=r-m5e7cedd3124afd4:XIkaiLURedis2016 |
21 | 21 |
-
Please register or login to post a comment