ADD:add weight score service
Showing
17 changed files
with
597 additions
and
16 deletions
@@ -2,11 +2,13 @@ package com.xkl; | @@ -2,11 +2,13 @@ package com.xkl; | ||
2 | 2 | ||
3 | import org.springframework.boot.SpringApplication; | 3 | import org.springframework.boot.SpringApplication; |
4 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
5 | +import org.springframework.scheduling.annotation.EnableScheduling; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * Spring-Boot启动类 | 8 | * Spring-Boot启动类 |
8 | */ | 9 | */ |
9 | @SpringBootApplication | 10 | @SpringBootApplication |
11 | +@EnableScheduling | ||
10 | public class Application { | 12 | public class Application { |
11 | 13 | ||
12 | public static void main(String[] args) { | 14 | public static void main(String[] args) { |
1 | package com.xkl.config; | 1 | package com.xkl.config; |
2 | 2 | ||
3 | +import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | ||
4 | + | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.Map; | ||
7 | + | ||
3 | /** | 8 | /** |
4 | * 常量 | 9 | * 常量 |
5 | */ | 10 | */ |
6 | -public class Constants { | 11 | +public interface Constants { |
7 | 12 | ||
8 | /** | 13 | /** |
9 | * 存储当前登录用户id的字段名 | 14 | * 存储当前登录用户id的字段名 |
10 | */ | 15 | */ |
11 | - public static final String CURRENT_USER_ID = "CURRENT_USER_ID"; | 16 | + String CURRENT_USER_ID = "CURRENT_USER_ID"; |
12 | 17 | ||
13 | /** | 18 | /** |
14 | * token有效期(小时) | 19 | * token有效期(小时) |
15 | */ | 20 | */ |
16 | - public static final int TOKEN_EXPIRES_HOUR = 72; | 21 | + int TOKEN_EXPIRES_HOUR = 72; |
17 | 22 | ||
18 | /** | 23 | /** |
19 | * 存放Authorization的header字段 | 24 | * 存放Authorization的header字段 |
20 | */ | 25 | */ |
21 | - public static final String AUTHORIZATION = "authorization"; | 26 | + String AUTHORIZATION = "authorization"; |
22 | 27 | ||
28 | + /** | ||
29 | + * 单项打分标准 | ||
30 | + */ | ||
31 | + Map<Integer,XklAmpReportMetaScoreStandardEntity> scoreMap=new HashMap<>(); | ||
32 | + | ||
33 | + /** | ||
34 | + * 综合加权标准 | ||
35 | + */ | ||
36 | + Map<Integer,Integer> weightedScoreMap=new HashMap<Integer,Integer>(){ | ||
37 | + { | ||
38 | + put(2,10); | ||
39 | + put(3,6); | ||
40 | + put(4,4); | ||
41 | + put(5,7); | ||
42 | + put(6,3); | ||
43 | + put(7,10); | ||
44 | + put(8,10); | ||
45 | + put(9,6); | ||
46 | + put(10,4); | ||
47 | + put(11,2); | ||
48 | + put(12,4); | ||
49 | + put(13,5); | ||
50 | + put(14,5); | ||
51 | + put(15,6); | ||
52 | + put(16,4); | ||
53 | + put(17,6); | ||
54 | + put(18,2); | ||
55 | + put(19,6); | ||
56 | + } | ||
57 | + }; | ||
23 | } | 58 | } |
1 | +package com.xkl.config; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | ||
4 | +import com.xkl.repository.XklAmpReportMetaScoreStandardRespository; | ||
5 | +import lombok.extern.apachecommons.CommonsLog; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.scheduling.annotation.Scheduled; | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import java.util.Iterator; | ||
11 | + | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by win7 on 2016/11/21. | ||
15 | + * 定时任务读取打分标准 | ||
16 | + */ | ||
17 | +@Component | ||
18 | +@CommonsLog | ||
19 | +public class ScheduledTask { | ||
20 | + @Autowired | ||
21 | + private XklAmpReportMetaScoreStandardRespository scoreStandardRespository; | ||
22 | + | ||
23 | + @Scheduled(initialDelay = 0,fixedRate = 24*60*60*1000) | ||
24 | + public void getTableMap(){ | ||
25 | + log.info("Load ScoreStandard Table"); | ||
26 | + Iterator<XklAmpReportMetaScoreStandardEntity> it=scoreStandardRespository.findAll().iterator(); | ||
27 | + while(it.hasNext()){ | ||
28 | + XklAmpReportMetaScoreStandardEntity scoreStandard=it.next(); | ||
29 | + Constants.scoreMap.put(scoreStandard.getItemId(),scoreStandard); | ||
30 | + } | ||
31 | + } | ||
32 | +} |
@@ -5,11 +5,13 @@ import com.wordnik.swagger.annotations.ApiImplicitParams; | @@ -5,11 +5,13 @@ import com.wordnik.swagger.annotations.ApiImplicitParams; | ||
5 | import com.wordnik.swagger.annotations.ApiOperation; | 5 | import com.wordnik.swagger.annotations.ApiOperation; |
6 | import com.xkl.authorization.annotation.Authorization; | 6 | import com.xkl.authorization.annotation.Authorization; |
7 | import com.xkl.authorization.annotation.CurrentUser; | 7 | import com.xkl.authorization.annotation.CurrentUser; |
8 | -import com.xkl.domain.User; | ||
9 | -import com.xkl.domain.XklAmpReportEntity; | ||
10 | -import com.xkl.domain.XklMemberEntity; | 8 | +import com.xkl.config.Constants; |
9 | +import com.xkl.domain.*; | ||
11 | import com.xkl.model.ResultModel; | 10 | import com.xkl.model.ResultModel; |
11 | +import com.xkl.repository.XklAmpReportDetailRespository; | ||
12 | +import com.xkl.repository.XklAmpReportHealthScoreRespository; | ||
12 | import com.xkl.repository.XklAmpReportRespository; | 13 | import com.xkl.repository.XklAmpReportRespository; |
14 | +import com.xkl.service.IScoreService; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.http.HttpStatus; | 16 | import org.springframework.http.HttpStatus; |
15 | import org.springframework.http.ResponseEntity; | 17 | import org.springframework.http.ResponseEntity; |
@@ -19,7 +21,8 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -19,7 +21,8 @@ import org.springframework.web.bind.annotation.RequestParam; | ||
19 | import org.springframework.web.bind.annotation.RestController; | 21 | import org.springframework.web.bind.annotation.RestController; |
20 | 22 | ||
21 | import javax.servlet.http.HttpServletRequest; | 23 | import javax.servlet.http.HttpServletRequest; |
22 | -import java.util.List; | 24 | +import java.util.*; |
25 | +import java.util.function.DoubleToIntFunction; | ||
23 | 26 | ||
24 | /** | 27 | /** |
25 | * Created by win7 on 2016/11/20. | 28 | * Created by win7 on 2016/11/20. |
@@ -29,18 +32,41 @@ import java.util.List; | @@ -29,18 +32,41 @@ import java.util.List; | ||
29 | public class ReportController { | 32 | public class ReportController { |
30 | @Autowired | 33 | @Autowired |
31 | private XklAmpReportRespository xklAmpReportRespository; | 34 | private XklAmpReportRespository xklAmpReportRespository; |
35 | + @Autowired | ||
36 | + private XklAmpReportDetailRespository xklAmpReportDetailRespository; | ||
32 | 37 | ||
33 | - @RequestMapping(method = RequestMethod.GET) | ||
34 | - @Authorization | 38 | + private XklAmpReportHealthScoreRespository xklAmpReportHealthScoreRespository; |
39 | + | ||
40 | + @Autowired | ||
41 | + private IScoreService scoreService; | ||
42 | + | ||
43 | + @RequestMapping(value="/list",method = RequestMethod.GET) | ||
44 | + //@Authorization | ||
35 | //@Sign | 45 | //@Sign |
36 | @ApiOperation(value = "体检报告列表查询接口") | 46 | @ApiOperation(value = "体检报告列表查询接口") |
37 | @ApiImplicitParams({ | 47 | @ApiImplicitParams({ |
38 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | 48 | @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), |
39 | }) | 49 | }) |
40 | - public ResponseEntity<ResultModel> getUserInfo(HttpServletRequest request, @CurrentUser User user, | 50 | + public ResponseEntity<ResultModel> getReportList(HttpServletRequest request, @CurrentUser User user, |
41 | @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | 51 | @RequestParam String sign, @RequestParam long t, @RequestParam int type) { |
42 | long member_id=user.getMember_id(); | 52 | long member_id=user.getMember_id(); |
43 | List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id); | 53 | List<XklAmpReportEntity> xklAmpReportEntity=xklAmpReportRespository.findByMemberId(member_id); |
44 | return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK); | 54 | return new ResponseEntity<>(ResultModel.ok(xklAmpReportEntity), HttpStatus.OK); |
45 | } | 55 | } |
56 | + | ||
57 | + @RequestMapping(value="/score",method = RequestMethod.GET) | ||
58 | + @Authorization | ||
59 | + //@Sign | ||
60 | + @ApiOperation(value = "健康评分接口") | ||
61 | + @ApiImplicitParams({ | ||
62 | + @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"), | ||
63 | + }) | ||
64 | + public ResponseEntity<ResultModel> getReportScore(HttpServletRequest request, @CurrentUser User user,@RequestParam long report_id, | ||
65 | + @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | ||
66 | + scoreService.getScore(report_id); | ||
67 | + return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK); | ||
68 | + } | ||
69 | + | ||
70 | + | ||
71 | + | ||
46 | } | 72 | } |
@@ -2,13 +2,10 @@ package com.xkl.domain; | @@ -2,13 +2,10 @@ package com.xkl.domain; | ||
2 | 2 | ||
3 | import lombok.Data; | 3 | import lombok.Data; |
4 | 4 | ||
5 | -import javax.persistence.Column; | ||
6 | -import javax.persistence.Entity; | ||
7 | -import javax.persistence.Id; | ||
8 | -import javax.persistence.Table; | 5 | +import javax.persistence.*; |
9 | 6 | ||
10 | /** | 7 | /** |
11 | - * 用户数据的domain类 | 8 | + * 用户登录表 |
12 | */ | 9 | */ |
13 | @Entity | 10 | @Entity |
14 | @Table(name = "xkl_local_account") | 11 | @Table(name = "xkl_local_account") |
@@ -24,6 +21,7 @@ public class User { | @@ -24,6 +21,7 @@ public class User { | ||
24 | 21 | ||
25 | //用户id | 22 | //用户id |
26 | @Id | 23 | @Id |
24 | + @GeneratedValue | ||
27 | @Column(name = "id") | 25 | @Column(name = "id") |
28 | private long id; | 26 | private long id; |
29 | 27 |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2016/11/21. | ||
9 | + * report详情 | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Entity | ||
13 | +@Table(name = "xkl_amp_report_detail", schema = "hanhe_test", catalog = "") | ||
14 | +public class XklAmpReportDetailEntity { | ||
15 | + @Id | ||
16 | + @GeneratedValue | ||
17 | + @Column(name = "id") | ||
18 | + private long id; | ||
19 | + @Basic | ||
20 | + @Column(name = "report_id") | ||
21 | + private long reportId; | ||
22 | + @Basic | ||
23 | + @Column(name = "item_id") | ||
24 | + private int itemId; | ||
25 | + @Basic | ||
26 | + @Column(name = "item_value") | ||
27 | + private double itemValue; | ||
28 | + @Basic | ||
29 | + @Column(name = "status") | ||
30 | + private int status; | ||
31 | +} |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2016/11/21. | ||
9 | + * 每个体检大类的打分 | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Entity | ||
13 | +@Table(name = "xkl_amp_report_health_scroe", schema = "hanhe_test", catalog = "") | ||
14 | +public class XklAmpReportHealthScoreEntity { | ||
15 | + @Id | ||
16 | + @GeneratedValue | ||
17 | + @Column(name = "id") | ||
18 | + private long id; | ||
19 | + @Basic | ||
20 | + @Column(name = "report_id") | ||
21 | + private long reportId; | ||
22 | + @Basic | ||
23 | + @Column(name = "type") | ||
24 | + private int type; | ||
25 | + @Basic | ||
26 | + @Column(name = "type_health_score") | ||
27 | + private double typeHealthScore; | ||
28 | + | ||
29 | +} |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2016/11/21. | ||
9 | + * 体检结果的解释 | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Entity | ||
13 | +@Table(name = "xkl_amp_report_meta_items", schema = "hanhe_test", catalog = "") | ||
14 | +public class XklAmpReportMetaItemsEntity { | ||
15 | + private int id; | ||
16 | + private int itmeId; | ||
17 | + private String type; | ||
18 | + private String title; | ||
19 | + private double standardLowMale; | ||
20 | + private double standardHighMale; | ||
21 | + private double standardLowFemale; | ||
22 | + private double standardHighFemale; | ||
23 | + private String explainLow; | ||
24 | + private String explainHigh; | ||
25 | + private String explainNormal; | ||
26 | + | ||
27 | + @Id | ||
28 | + @Column(name = "id") | ||
29 | + public int getId() { | ||
30 | + return id; | ||
31 | + } | ||
32 | + | ||
33 | + public void setId(int id) { | ||
34 | + this.id = id; | ||
35 | + } | ||
36 | + | ||
37 | + @Basic | ||
38 | + @Column(name = "itme_id") | ||
39 | + public int getItmeId() { | ||
40 | + return itmeId; | ||
41 | + } | ||
42 | + | ||
43 | + public void setItmeId(int itmeId) { | ||
44 | + this.itmeId = itmeId; | ||
45 | + } | ||
46 | + | ||
47 | + @Basic | ||
48 | + @Column(name = "type") | ||
49 | + public String getType() { | ||
50 | + return type; | ||
51 | + } | ||
52 | + | ||
53 | + public void setType(String type) { | ||
54 | + this.type = type; | ||
55 | + } | ||
56 | + | ||
57 | + @Basic | ||
58 | + @Column(name = "title") | ||
59 | + public String getTitle() { | ||
60 | + return title; | ||
61 | + } | ||
62 | + | ||
63 | + public void setTitle(String title) { | ||
64 | + this.title = title; | ||
65 | + } | ||
66 | + | ||
67 | + @Basic | ||
68 | + @Column(name = "standard_low_male") | ||
69 | + public double getStandardLowMale() { | ||
70 | + return standardLowMale; | ||
71 | + } | ||
72 | + | ||
73 | + public void setStandardLowMale(double standardLowMale) { | ||
74 | + this.standardLowMale = standardLowMale; | ||
75 | + } | ||
76 | + | ||
77 | + @Basic | ||
78 | + @Column(name = "standard_high_male") | ||
79 | + public double getStandardHighMale() { | ||
80 | + return standardHighMale; | ||
81 | + } | ||
82 | + | ||
83 | + public void setStandardHighMale(double standardHighMale) { | ||
84 | + this.standardHighMale = standardHighMale; | ||
85 | + } | ||
86 | + | ||
87 | + @Basic | ||
88 | + @Column(name = "standard_low_female") | ||
89 | + public double getStandardLowFemale() { | ||
90 | + return standardLowFemale; | ||
91 | + } | ||
92 | + | ||
93 | + public void setStandardLowFemale(double standardLowFemale) { | ||
94 | + this.standardLowFemale = standardLowFemale; | ||
95 | + } | ||
96 | + | ||
97 | + @Basic | ||
98 | + @Column(name = "standard_high_female") | ||
99 | + public double getStandardHighFemale() { | ||
100 | + return standardHighFemale; | ||
101 | + } | ||
102 | + | ||
103 | + public void setStandardHighFemale(double standardHighFemale) { | ||
104 | + this.standardHighFemale = standardHighFemale; | ||
105 | + } | ||
106 | + | ||
107 | + @Basic | ||
108 | + @Column(name = "explain_low") | ||
109 | + public String getExplainLow() { | ||
110 | + return explainLow; | ||
111 | + } | ||
112 | + | ||
113 | + public void setExplainLow(String explainLow) { | ||
114 | + this.explainLow = explainLow; | ||
115 | + } | ||
116 | + | ||
117 | + @Basic | ||
118 | + @Column(name = "explain_high") | ||
119 | + public String getExplainHigh() { | ||
120 | + return explainHigh; | ||
121 | + } | ||
122 | + | ||
123 | + public void setExplainHigh(String explainHigh) { | ||
124 | + this.explainHigh = explainHigh; | ||
125 | + } | ||
126 | + | ||
127 | + @Basic | ||
128 | + @Column(name = "explain_normal") | ||
129 | + public String getExplainNormal() { | ||
130 | + return explainNormal; | ||
131 | + } | ||
132 | + | ||
133 | + public void setExplainNormal(String explainNormal) { | ||
134 | + this.explainNormal = explainNormal; | ||
135 | + } | ||
136 | + | ||
137 | + @Override | ||
138 | + public boolean equals(Object o) { | ||
139 | + if (this == o) return true; | ||
140 | + if (o == null || getClass() != o.getClass()) return false; | ||
141 | + | ||
142 | + XklAmpReportMetaItemsEntity that = (XklAmpReportMetaItemsEntity) o; | ||
143 | + | ||
144 | + if (id != that.id) return false; | ||
145 | + if (itmeId != that.itmeId) return false; | ||
146 | + if (Double.compare(that.standardLowMale, standardLowMale) != 0) return false; | ||
147 | + if (Double.compare(that.standardHighMale, standardHighMale) != 0) return false; | ||
148 | + if (Double.compare(that.standardLowFemale, standardLowFemale) != 0) return false; | ||
149 | + if (Double.compare(that.standardHighFemale, standardHighFemale) != 0) return false; | ||
150 | + if (type != null ? !type.equals(that.type) : that.type != null) return false; | ||
151 | + if (title != null ? !title.equals(that.title) : that.title != null) return false; | ||
152 | + if (explainLow != null ? !explainLow.equals(that.explainLow) : that.explainLow != null) return false; | ||
153 | + if (explainHigh != null ? !explainHigh.equals(that.explainHigh) : that.explainHigh != null) return false; | ||
154 | + if (explainNormal != null ? !explainNormal.equals(that.explainNormal) : that.explainNormal != null) | ||
155 | + return false; | ||
156 | + | ||
157 | + return true; | ||
158 | + } | ||
159 | + | ||
160 | + @Override | ||
161 | + public int hashCode() { | ||
162 | + int result; | ||
163 | + long temp; | ||
164 | + result = id; | ||
165 | + result = 31 * result + itmeId; | ||
166 | + result = 31 * result + (type != null ? type.hashCode() : 0); | ||
167 | + result = 31 * result + (title != null ? title.hashCode() : 0); | ||
168 | + temp = Double.doubleToLongBits(standardLowMale); | ||
169 | + result = 31 * result + (int) (temp ^ (temp >>> 32)); | ||
170 | + temp = Double.doubleToLongBits(standardHighMale); | ||
171 | + result = 31 * result + (int) (temp ^ (temp >>> 32)); | ||
172 | + temp = Double.doubleToLongBits(standardLowFemale); | ||
173 | + result = 31 * result + (int) (temp ^ (temp >>> 32)); | ||
174 | + temp = Double.doubleToLongBits(standardHighFemale); | ||
175 | + result = 31 * result + (int) (temp ^ (temp >>> 32)); | ||
176 | + result = 31 * result + (explainLow != null ? explainLow.hashCode() : 0); | ||
177 | + result = 31 * result + (explainHigh != null ? explainHigh.hashCode() : 0); | ||
178 | + result = 31 * result + (explainNormal != null ? explainNormal.hashCode() : 0); | ||
179 | + return result; | ||
180 | + } | ||
181 | +} |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by win7 on 2016/11/21. | ||
9 | + * 打分标准 | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Entity | ||
13 | +@Table(name = "xkl_amp_report_meta_score_standard", schema = "hanhe_test", catalog = "") | ||
14 | +public class XklAmpReportMetaScoreStandardEntity { | ||
15 | + @Id | ||
16 | + @GeneratedValue | ||
17 | + @Column(name = "id") | ||
18 | + private long id; | ||
19 | + @Basic | ||
20 | + @Column(name = "item_id") | ||
21 | + private int itemId; | ||
22 | + @Basic | ||
23 | + @Column(name = "item_name") | ||
24 | + private String itemName; | ||
25 | + @Basic | ||
26 | + @Column(name = "item_type") | ||
27 | + private int itemType; | ||
28 | + @Basic | ||
29 | + @Column(name = "interval1_min") | ||
30 | + private double interval1Min; | ||
31 | + @Basic | ||
32 | + @Column(name = "interval1_max") | ||
33 | + private double interval1Max; | ||
34 | + @Basic | ||
35 | + @Column(name = "interval1_score") | ||
36 | + private double interval1Score; | ||
37 | + @Basic | ||
38 | + @Column(name = "interval2_min") | ||
39 | + private double interval2Min; | ||
40 | + @Basic | ||
41 | + @Column(name = "interval2_max") | ||
42 | + private double interval2Max; | ||
43 | + @Basic | ||
44 | + @Column(name = "interval2_score") | ||
45 | + private double interval2Score; | ||
46 | + @Basic | ||
47 | + @Column(name = "interval3_min") | ||
48 | + private double interval3Min; | ||
49 | + @Basic | ||
50 | + @Column(name = "interval3_max") | ||
51 | + private double interval3Max; | ||
52 | + @Basic | ||
53 | + @Column(name = "interval3_score") | ||
54 | + private double interval3Score; | ||
55 | + @Basic | ||
56 | + @Column(name = "interval4_min") | ||
57 | + private double interval4Min; | ||
58 | + @Basic | ||
59 | + @Column(name = "interval4_max") | ||
60 | + private double interval4Max; | ||
61 | + @Basic | ||
62 | + @Column(name = "interval4_score") | ||
63 | + private double interval4Score; | ||
64 | + @Basic | ||
65 | + @Column(name = "interval5_min") | ||
66 | + private double interval5Min; | ||
67 | + @Basic | ||
68 | + @Column(name = "interval5_max") | ||
69 | + private double interval5Max; | ||
70 | + @Basic | ||
71 | + @Column(name = "interval5_score") | ||
72 | + private double interval5Score; | ||
73 | + | ||
74 | + /** | ||
75 | + * 由单项体检的值判断得分 | ||
76 | + * @param score | ||
77 | + * @return | ||
78 | + */ | ||
79 | + public double getScore(double score){ | ||
80 | + double result = 0; | ||
81 | + if(score>interval1Min && score<interval1Max) | ||
82 | + result = interval1Score; | ||
83 | + else if(score>interval2Min && score<interval2Max) | ||
84 | + result = interval2Score; | ||
85 | + else if(score>interval3Min && score<interval3Max) | ||
86 | + result = interval3Score; | ||
87 | + else if(score>interval4Min && score<interval4Max) | ||
88 | + result = interval4Score; | ||
89 | + else if(score>interval5Min && score<interval5Max) | ||
90 | + result = interval5Score; | ||
91 | + return result; | ||
92 | + } | ||
93 | +} |
@@ -8,12 +8,14 @@ import java.sql.Date; | @@ -8,12 +8,14 @@ import java.sql.Date; | ||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Created by win7 on 2016/11/20. | 10 | * Created by win7 on 2016/11/20. |
11 | + * 用户信息表 | ||
11 | */ | 12 | */ |
12 | @Data | 13 | @Data |
13 | @Entity | 14 | @Entity |
14 | @Table(name = "xkl_member", schema = "hanhe_test", catalog = "") | 15 | @Table(name = "xkl_member", schema = "hanhe_test", catalog = "") |
15 | public class XklMemberEntity { | 16 | public class XklMemberEntity { |
16 | @Id | 17 | @Id |
18 | + @GeneratedValue | ||
17 | @Column(name = "id") | 19 | @Column(name = "id") |
18 | private long id; | 20 | private long id; |
19 | @Basic | 21 | @Basic |
1 | +package com.xkl.repository; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAmpReportDetailEntity; | ||
4 | +import com.xkl.domain.XklAmpReportHealthScoreEntity; | ||
5 | +import org.springframework.data.repository.CrudRepository; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by win7 on 2016/11/20. | ||
11 | + */ | ||
12 | +public interface XklAmpReportDetailRespository extends CrudRepository<XklAmpReportDetailEntity, Long> { | ||
13 | + //item_id | ||
14 | + public List<XklAmpReportDetailEntity> findByReportIdAndItemId(long report_id, long item_id); | ||
15 | + | ||
16 | + public List<XklAmpReportDetailEntity> findAllByReportId(long report_id); | ||
17 | +} |
1 | +package com.xkl.repository; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAmpReportHealthScoreEntity; | ||
4 | +import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | ||
5 | +import org.springframework.data.repository.CrudRepository; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by win7 on 2016/11/20. | ||
11 | + */ | ||
12 | +public interface XklAmpReportHealthScoreRespository extends CrudRepository<XklAmpReportHealthScoreEntity, Long> { | ||
13 | + //item_id | ||
14 | + public List<XklAmpReportHealthScoreEntity> findByReportIdAndType(long report_id,int type); | ||
15 | + | ||
16 | + //public boolean existsByReportId(long report_id); | ||
17 | + | ||
18 | + //public void saveByReportId(List<XklAmpReportHealthScoreEntity> list,long report_id); | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | +} |
1 | +package com.xkl.repository; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAmpReportEntity; | ||
4 | +import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | ||
5 | +import org.springframework.data.repository.CrudRepository; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by win7 on 2016/11/20. | ||
11 | + */ | ||
12 | +public interface XklAmpReportMetaScoreStandardRespository extends CrudRepository<XklAmpReportMetaScoreStandardEntity, Long> { | ||
13 | + //item_id | ||
14 | + public List<XklAmpReportMetaScoreStandardEntity> findByItemId(long member_id); | ||
15 | +} |
1 | +package com.xkl.service; | ||
2 | + | ||
3 | +import com.xkl.config.Constants; | ||
4 | +import com.xkl.domain.XklAmpReportDetailEntity; | ||
5 | +import com.xkl.domain.XklAmpReportEntity; | ||
6 | +import com.xkl.domain.XklAmpReportHealthScoreEntity; | ||
7 | +import com.xkl.domain.XklAmpReportMetaScoreStandardEntity; | ||
8 | +import com.xkl.repository.XklAmpReportDetailRespository; | ||
9 | +import com.xkl.repository.XklAmpReportHealthScoreRespository; | ||
10 | +import com.xkl.repository.XklAmpReportRespository; | ||
11 | +import lombok.extern.apachecommons.CommonsLog; | ||
12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
13 | +import org.springframework.stereotype.Service; | ||
14 | + | ||
15 | +import java.util.*; | ||
16 | + | ||
17 | +/** | ||
18 | + * Created by win7 on 2016/11/21. | ||
19 | + */ | ||
20 | +@Service | ||
21 | +@CommonsLog | ||
22 | +public class ScoreServiceImpl implements IScoreService,Constants{ | ||
23 | + @Autowired | ||
24 | + private XklAmpReportRespository xklAmpReportRespository; | ||
25 | + @Autowired | ||
26 | + private XklAmpReportDetailRespository xklAmpReportDetailRespository; | ||
27 | + @Autowired | ||
28 | + private XklAmpReportHealthScoreRespository xklAmpReportHealthScoreRespository; | ||
29 | + | ||
30 | + @Override | ||
31 | + public void getScore(long report_id) { | ||
32 | + Map<Integer,Double> typeScoreMap=new HashMap<>();//记录各大项打分的Map | ||
33 | + | ||
34 | + List<XklAmpReportDetailEntity> reportDetailList=xklAmpReportDetailRespository.findAllByReportId(report_id); | ||
35 | + | ||
36 | + for(XklAmpReportDetailEntity detail:reportDetailList){ | ||
37 | + | ||
38 | + int item_id=detail.getItemId(); | ||
39 | + XklAmpReportMetaScoreStandardEntity scoreStandard= scoreMap.get(item_id);//从定时加载的打分map中取出该体检小项 | ||
40 | + | ||
41 | + if(scoreStandard!=null) { | ||
42 | + double score = scoreStandard.getScore(detail.getItemValue()); | ||
43 | + int item_type = scoreStandard.getItemType(); | ||
44 | + | ||
45 | + if(typeScoreMap.containsKey(item_type)){//将分类中的每个大项中分数相加 | ||
46 | + double type_score=typeScoreMap.get(item_type)+score; | ||
47 | + typeScoreMap.put(item_type,type_score); | ||
48 | + }else{ | ||
49 | + typeScoreMap.put(item_type,score); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + } | ||
54 | + /** | ||
55 | + * 循环每类得分的typeScoreMap,计算总得分 | ||
56 | + */ | ||
57 | + double finalScore=0; | ||
58 | + List<XklAmpReportHealthScoreEntity> saveScoreList=new ArrayList<>(); | ||
59 | + | ||
60 | + Iterator<Map.Entry<Integer,Double>> it=typeScoreMap.entrySet().iterator(); | ||
61 | + while(it.hasNext()){ | ||
62 | + Map.Entry<Integer, Double> entry = it.next(); | ||
63 | + int item_type = entry.getKey(); | ||
64 | + double score = entry.getValue(); | ||
65 | + | ||
66 | + XklAmpReportHealthScoreEntity scoreEntity=new XklAmpReportHealthScoreEntity(); | ||
67 | + scoreEntity.setReportId(report_id); | ||
68 | + scoreEntity.setType(item_type); | ||
69 | + scoreEntity.setTypeHealthScore(score); | ||
70 | + saveScoreList.add(scoreEntity); | ||
71 | + | ||
72 | + double weightedScore=weightedScoreMap.get(item_type); | ||
73 | + finalScore += weightedScore*(score/100); | ||
74 | + } | ||
75 | + /** | ||
76 | + * 每类得分存入xkl_amp_report_health_scroe | ||
77 | + * 总得分存入xkl_amp_report | ||
78 | + */ | ||
79 | + if(saveScoreList!=null&&saveScoreList.size()>0) | ||
80 | + xklAmpReportHealthScoreRespository.save(saveScoreList); | ||
81 | + | ||
82 | + XklAmpReportEntity report=xklAmpReportRespository.findOne(report_id); | ||
83 | + if(report!=null){ | ||
84 | + report.setScore(finalScore); | ||
85 | + xklAmpReportRespository.save(report); | ||
86 | + } | ||
87 | + } | ||
88 | +} |
-
Please register or login to post a comment