Commit 7f025aaac348645000d247fbdd9d4eb1bf3e5a51

Authored by landong2015
1 parent aad7ee259e
Exists in master

New changelist

Showing 7 changed files with 269 additions and 173 deletions

mainData/src/main/java/com/lymsh/yimiao/main/data/model/MedInoculateOrderQuery.java View file @ 7f025aa
... ... @@ -2,6 +2,8 @@
2 2  
3 3 import com.lymsh.mommybaby.basecommon.base.BaseQuery;
4 4  
  5 +import java.util.List;
  6 +
5 7 public class MedInoculateOrderQuery extends BaseQuery{
6 8 private String ioId;
7 9 private String ioKidId;
... ... @@ -11,6 +13,16 @@
11 13 private String ioInoculateTime;
12 14 private String ioOrderOPer;
13 15 private String ioOrderTime;
  16 +
  17 + private List<String> ids;//多个id情况
  18 +
  19 + public List<String> getIds() {
  20 + return ids;
  21 + }
  22 +
  23 + public void setIds(List<String> ids) {
  24 + this.ids = ids;
  25 + }
14 26  
15 27 public String getIoId() {
16 28 return ioId;
mainData/src/main/java/com/lymsh/yimiao/main/data/model/MedInoculateRecordQuery.java View file @ 7f025aa
... ... @@ -2,6 +2,7 @@
2 2  
3 3  
4 4 import java.util.Date;
  5 +import java.util.List;
5 6  
6 7 import com.lymsh.mommybaby.basecommon.base.BaseQuery;
7 8  
... ... @@ -18,6 +19,16 @@
18 19 private String icIsInoculate;
19 20 private String icJiCi;
20 21 private String isDelete;
  22 +
  23 + private List<String> ids;//多个id情况
  24 +
  25 + public List<String> getIds() {
  26 + return ids;
  27 + }
  28 +
  29 + public void setIds(List<String> ids) {
  30 + this.ids = ids;
  31 + }
21 32  
22 33 public String getIsDelete() {
23 34 return isDelete;
mainData/src/main/java/com/lymsh/yimiao/main/data/model/MedKidsQuery.java View file @ 7f025aa
... ... @@ -3,7 +3,9 @@
3 3  
4 4 import com.lymsh.mommybaby.basecommon.base.BaseQuery;
5 5  
  6 +import java.util.List;
6 7  
  8 +
7 9 public class MedKidsQuery extends BaseQuery {
8 10 private String id;
9 11 private String name;
... ... @@ -16,6 +18,16 @@
16 18 private String buildOPer;//建档人
17 19 private String buildTime;//建档时间
18 20 private String isDelete;//宝宝是否有效
  21 +
  22 + private List<String> ids;//多个id情况
  23 +
  24 + public List<String> getIds() {
  25 + return ids;
  26 + }
  27 +
  28 + public void setIds(List<String> ids) {
  29 + this.ids = ids;
  30 + }
19 31  
20 32 public String getIsDelete() {
21 33 return isDelete;
mainData/src/main/resources/mainOrm/MedInoculaterecord.xml View file @ 7f025aa
... ... @@ -70,6 +70,12 @@
70 70 <if test="isDelete != null and isDelete != ''">
71 71 and ic_delete = #{isDelete,jdbcType=VARCHAR}
72 72 </if>
  73 + <if test="ids != null ">
  74 + and ic_kidId in
  75 + <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
  76 + #{item,jdbcType=VARCHAR}
  77 + </foreach>
  78 + </if>
73 79 </where>
74 80 </sql>
75 81  
mainData/src/main/resources/mainOrm/MedKids.xml View file @ 7f025aa
... ... @@ -70,6 +70,12 @@
70 70 <if test="isDelete != null and isDelete != ''">
71 71 and isdelete = #{isDelete,jdbcType=VARCHAR}
72 72 </if>
  73 + <if test="ids != null ">
  74 + and ki_id in
  75 + <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
  76 + #{item,jdbcType=VARCHAR}
  77 + </foreach>
  78 + </if>
73 79 </where>
74 80 </sql>
75 81  
... ... @@ -88,6 +94,48 @@
88 94 select count(1) from med_kids
89 95 <include refid="MedKidsCondition" />
90 96 </select>
  97 +
  98 +
  99 + <resultMap id="KidInoculationRecordMap" type="com.lymsh.yimiao.main.data.model.KidInoculationRecords">
  100 + <result column="KI_BIRTHDAY" property="birthday" jdbcType="VARCHAR" />
  101 + <result column="IC_KIDID" property="recordKidId" jdbcType="VARCHAR" />
  102 + <result column="IC_ID" property="recordId" jdbcType="VARCHAR" />
  103 + <result column="IC_VACCINEID" property="vaccineInfoId" jdbcType="VARCHAR" />
  104 + <result column="IC_INOCULATETIME" property="inoculateTime" jdbcType="VARCHAR" />
  105 + <result column="MONTH_AGE" property="monthAge" jdbcType="VARCHAR" />
  106 + <result column="IC_JICI" property="jiCi" jdbcType="VARCHAR" />
  107 + <result column="VI_NAME" property="vaccineInfoName" jdbcType="VARCHAR" />
  108 + <result column="VN_NAME" property="vaccineNameTitle" jdbcType="VARCHAR" />
  109 + <result column="VN_VACCINETYPE" property="vaccineType" jdbcType="VARCHAR" />
  110 + <result column="CNT" property="cnt" jdbcType="INTEGER" />
  111 + </resultMap>
  112 +
  113 + <select id="queryInoculationRecord" resultMap="KidInoculationRecordMap" parameterType="java.lang.String">
  114 + SELECT D.KI_NAME,
  115 + TO_DATE(D.KI_BIRTHDAY,'YYYY/MM/DD') AS KI_BIRTHDAY,
  116 + B.IC_KIDID,
  117 + B.IC_ID,
  118 + B.IC_VACCINEID,
  119 + TO_DATE(B.IC_INOCULATETIME,'YYYY/MM/DD') AS IC_INOCULATETIME,
  120 + TRUNC(MONTHS_BETWEEN(TO_DATE(B.IC_INOCULATETIME,'YYYY/MM/DD'),TO_DATE(D.KI_BIRTHDAY,'YYYY/MM/DD'))) AS MONTH_AGE,
  121 + B.IC_JICI,
  122 + C.VI_NAME,
  123 + A.VN_NAME,
  124 + A.VN_VACCINETYPE,
  125 + CCC.CNT
  126 + FROM med_InoculateRecord B
  127 + INNER JOIN med_Vaccineinfo C ON B.IC_VACCINEID=C.VI_ID AND C.ISDELETE=1
  128 + INNER JOIN med_VaccineName A ON C.VI_VACCINENAMEID=A.VN_ID AND A.ISDELETE=1
  129 + INNER JOIN MED_KIDS D ON B.IC_KIDID=D.KI_ID
  130 + INNER JOIN (SELECT AA.VN_NAME,COUNT(DISTINCT b.column_value) AS CNT
  131 + FROM med_VaccineName AA, table(splitstr(AA.VN_MONTHAGE, ',')) b
  132 + WHERE AA.VN_MONTHAGE IS NOT NULL
  133 + AND AA.ISDELETE = 1
  134 + GROUP BY AA.VN_NAME) CCC ON A.VN_NAME=CCC.VN_NAME
  135 + WHERE B.IC_DELETE = 1
  136 + AND B.IC_KIDID= #{recordKidId,jdbcType=VARCHAR}
  137 + </select>
  138 +
91 139  
92 140  
93 141  
mainData/src/main/resources/mainOrm/MedOrganization.xml View file @ 7f025aa
... ... @@ -14,7 +14,7 @@
14 14 <result column="o_villageNo" property="oVillageNo" jdbcType="VARCHAR" />
15 15 <result column="o_address" property="oAddress" jdbcType="VARCHAR" />
16 16 <result column="o_isValid" property="oIsValid" jdbcType="VARCHAR" />
17   -<result column="isDelete" property="isDelete;" jdbcType="VARCHAR" />
  17 +<result column="isDelete" property="isDelete" jdbcType="VARCHAR" />
18 18 </resultMap>
19 19  
20 20 <select id="getMedOrganization" resultMap="MedOrganizationResultMap" parameterType="java.lang.String">
webApi/src/main/java/com/lyms/yimiao/web/controller/v1/KidsController.java View file @ 7f025aa
... ... @@ -12,6 +12,7 @@
12 12 import com.lymsh.yimiao.main.data.service.*;
13 13 import com.lymsh.yimiao.main.data.util.JsonUtil;
14 14 import com.lymsh.yimiao.main.data.util.LoginContext;
  15 +import com.lymsh.yimiao.main.data.util.VaccineNameSington;
15 16 import org.apache.commons.collections.CollectionUtils;
16 17 import org.apache.commons.lang.StringUtils;
17 18 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -21,7 +22,6 @@
21 22 import org.springframework.web.bind.annotation.RequestMapping;
22 23 import org.springframework.web.bind.annotation.RequestMethod;
23 24 import org.springframework.web.bind.annotation.RequestParam;
24   -import sun.security.util.Length;
25 25  
26 26  
27 27 import javax.servlet.http.HttpServletRequest;
28 28  
... ... @@ -29,13 +29,13 @@
29 29 import java.util.*;
30 30  
31 31 /**
32   - * 宝宝接口
33   - *
  32 + * 宝宝接口
  33 + * <p/>
34 34 * Created by Administrator on 2016/4/28 0028.
35 35 */
36 36 @Controller
37 37 @RequestMapping("/v1")
38   -public class KidsController extends BaseController{
  38 +public class KidsController extends BaseController {
39 39  
40 40 @Value("#{configProperties['yimiao.token']}")
41 41 private String token;
... ... @@ -63,6 +63,9 @@
63 63  
64 64 private final static String isDelete = "1";
65 65  
  66 + @Autowired
  67 + private VaccineNameSington vaccineNameSington;
  68 +
66 69 // /**
67 70 // * 发送验证码
68 71 // * @param response
69 72  
70 73  
71 74  
... ... @@ -93,21 +96,22 @@
93 96  
94 97 /**
95 98 * 校验验证码
  99 + *
96 100 * @param response
97   - * @param code 发送给用户的验证码
  101 + * @param code 发送给用户的验证码
98 102 */
99 103 @RequestMapping(value = "/checkCode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
100 104 @TokenRequired
101 105 public void checkCode(HttpServletResponse response,
102 106 @RequestParam("phone") String phone,
103   - @RequestParam("code") String code){
  107 + @RequestParam("code") String code) {
104 108  
105 109 Map<String, Object> resultMsgMap = new HashMap<>();
106 110  
107 111 //通过手机拿到redis中的验证码,然后和用户输入的验证码做校验
108 112 //从redis里面获取验证码
109 113 Object verCodeObj = (Object) RedisUtils.getObj("c_" + phone);
110   - if (verCodeObj==null){
  114 + if (verCodeObj == null) {
111 115 //参数错误
112 116 resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.VER_CODE_EXPIRE);
113 117 resultMsgMap.put(ResultUtils.ERROR_MSG, "验证码已过期,请重新获取.");
114 118  
... ... @@ -116,12 +120,12 @@
116 120 }
117 121  
118 122 if (code.equals(verCodeObj)) {
119   - resultMsgMap.put("idRight",true);
  123 + resultMsgMap.put("idRight", true);
120 124 resultMsgMap.put(ResultUtils.ERROR_CODE, 0);
121 125 resultMsgMap.put(ResultUtils.ERROR_MSG, "成功");
122 126 writeJson(response, JsonUtil.obj2JsonString(resultMsgMap));
123 127 } else {
124   - resultMsgMap.put("idRight",false);
  128 + resultMsgMap.put("idRight", false);
125 129 resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.USER_PASSWORD_ERROR);
126 130 resultMsgMap.put(ResultUtils.ERROR_MSG, "验证码错误,请重新输入");
127 131 writeJson(response, JsonUtil.obj2JsonString(resultMsgMap));
... ... @@ -130,6 +134,7 @@
130 134  
131 135 /**
132 136 * 查询当前登陆账号所关联的宝宝,返回ID
  137 + *
133 138 * @param response
134 139 * @param birthday
135 140 * @param barCode
... ... @@ -138,9 +143,9 @@
138 143 @RequestMapping(value = "/queryKidsId", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
139 144 @TokenRequired
140 145 public void getKidsId(HttpServletResponse response,
141   - @RequestParam("birthday") String birthday,
142   - @RequestParam(value = "barCode",required = false) String barCode,
143   - @RequestParam(value = "phone",required = false) String phone) {
  146 + @RequestParam("birthday") String birthday,
  147 + @RequestParam(value = "barCode", required = false) String barCode,
  148 + @RequestParam(value = "phone", required = false) String phone) {
144 149  
145 150 MedKidsQuery medKidsQuery = new MedKidsQuery();
146 151 medKidsQuery.setBirthday(birthday);
147 152  
148 153  
149 154  
150 155  
151 156  
152 157  
153 158  
154 159  
155 160  
156 161  
157 162  
158 163  
159 164  
160 165  
... ... @@ -152,104 +157,116 @@
152 157  
153 158 List<Map> list = new ArrayList<>();
154 159  
155   - if (CollectionUtils.isNotEmpty(medKidsList)){
  160 + if (CollectionUtils.isNotEmpty(medKidsList)) {
156 161  
157   - List<String> ids = null;
158   -
159   - List<String> names = new ArrayList<>();
160   - for (int i=0;i<medKidsList.size();i++){
161   - Map<String,String> map = new HashMap<>();
162   -
163   - ids = new ArrayList<>();
164   - if(names.contains(medKidsList.get(i).getName())) continue;
165   -
166   - names.add(medKidsList.get(i).getName());
167   -
168   - for (int j=0;j<medKidsList.size();j++){
169   - String id = medKidsList.get(j).getId();
170   - if(!ids.contains(medKidsList.get(j).getId()) && i == j) {
171   - ids.add(id);
172   - }
173   -
174   - if(medKidsList.get(i).getName().equals(medKidsList.get(j).getName()) && i != j && !ids.contains(j)){
175   - ids.add(id);
176   - }
  162 + for (MedKids medKids : medKidsList) {
  163 + Map<String, String> map = new HashMap<>();
  164 + if (StringUtils.isNotEmpty(medKids.getName())){
  165 + map.put("id",medKids.getId());
  166 + map.put("name",medKids.getName());
177 167 }
178   - String tmp = "";
179   - for(String k : ids) {
180   - tmp += k + ",";
181   - }
182   - map.put("name",medKidsList.get(i).getName());
183   - map.put("idStr",tmp.substring(0,tmp.length()-1));
184   -
185 168 list.add(map);
186 169 }
187 170 }
188 171 ResultUtils.buildSuccessResultAndWrite(response, list);
  172 +
  173 +// List<String> ids = null;
  174 +//
  175 +// List<String> names = new ArrayList<>();
  176 +// for (int i = 0; i < medKidsList.size(); i++) {
  177 +// Map<String, String> map = new HashMap<>();
  178 +//
  179 +// ids = new ArrayList<>();
  180 +// if (names.contains(medKidsList.get(i).getName())) continue;
  181 +//
  182 +// names.add(medKidsList.get(i).getName());
  183 +//
  184 +// for (int j = 0; j < medKidsList.size(); j++) {
  185 +// String id = medKidsList.get(j).getId();
  186 +// if (!ids.contains(medKidsList.get(j).getId()) && i == j) {
  187 +// ids.add(id);
  188 +// }
  189 +//
  190 +// if (medKidsList.get(i).getName().equals(medKidsList.get(j).getName()) && i != j && !ids.contains(j)) {
  191 +// ids.add(id);
  192 +// }
  193 +// }
  194 +// String tmp = "";
  195 +// for (String k : ids) {
  196 +// tmp += k + ",";
  197 +// }
  198 +// map.put("name", medKidsList.get(i).getName());
  199 +// map.put("id", tmp.substring(0, tmp.length() - 1));
  200 +//
  201 +// list.add(map);
  202 +// }
  203 +// }
  204 +// ResultUtils.buildSuccessResultAndWrite(response, list);
189 205 }
190 206  
191 207 /**
192   - * 添加宝宝接口(当前登陆用户与小孩子进行关联
  208 + * 添加宝宝接口(当前登陆用户与小孩子进行关联)
  209 + *
193 210 * @param response
194   - * @param idStr 宝宝id
  211 + * @param id 宝宝id
195 212 */
196 213 @RequestMapping(value = "/babys", method = RequestMethod.POST)
197 214 @TokenRequired
198 215 public void UserRelateKids(HttpServletResponse response,
199 216 HttpServletRequest request,
200   - @RequestParam("idStr")String idStr){
201   - String[] ids = idStr.split("id");
202   - for (String id : ids){
203   - MedKids kids = medKidsService.getMedKids(id);
204   - if (kids == null) {
205   - ResultUtils.buildParameterErrorResultAndWrite(response, "宝宝id不存在");
206   - return;
207   - }
208   - //取到当前登陆用户的id
209   - LoginContext loginContext = (LoginContext) request.getAttribute("loginContext");
210   - YmUsers users = usersService.getYmUsers(loginContext.getId());
211   - //把查询到的宝宝id与登陆用户关联
212   - YmUserKidMapsQuery query = new YmUserKidMapsQuery();
213   - query.setUserId(users.getId());
214   - query.setKidId(id);
215   - query.setYn(YnEnum.yes.getId());
216   - int count = ymUserKidMapsService.queryYmUserKidMapsCount(query);
217   - if (count!=0){
218   - continue;
219   - }
220   - YmUserKidMaps userKidMaps = new YmUserKidMaps();
221   - userKidMaps.setUserId(users.getId());
222   - userKidMaps.setKidId(id);
223   - userKidMaps.setCreated(new Date());
224   - userKidMaps.setYn(YnEnum.yes.getId());
225   - ymUserKidMapsService.addYmUserKidMaps(userKidMaps);
  217 + @RequestParam("id") String id) {
  218 + MedKids kids = medKidsService.getMedKids(id);
  219 + if (kids == null) {
  220 + ResultUtils.buildParameterErrorResultAndWrite(response, "宝宝id不存在");
  221 + return;
226 222 }
  223 + //取到当前登陆用户的id
  224 + LoginContext loginContext = (LoginContext) request.getAttribute("loginContext");
  225 + YmUsers users = usersService.getYmUsers(loginContext.getId());
  226 + //把查询到的宝宝id与登陆用户关联
  227 + YmUserKidMapsQuery query = new YmUserKidMapsQuery();
  228 + query.setUserId(users.getId());
  229 + query.setKidId(id);
  230 + query.setYn(YnEnum.yes.getId());
  231 + int count = ymUserKidMapsService.queryYmUserKidMapsCount(query);
  232 + if (count != 0) {
  233 + //已经关联了的版本就不需要在关联,直接返回成功
  234 + ResultUtils.buildSuccessResultAndWrite(response);
  235 + }
  236 + YmUserKidMaps userKidMaps = new YmUserKidMaps();
  237 + userKidMaps.setUserId(users.getId());
  238 + userKidMaps.setKidId(id);
  239 + userKidMaps.setCreated(new Date());
  240 + userKidMaps.setYn(YnEnum.yes.getId());
  241 + ymUserKidMapsService.addYmUserKidMaps(userKidMaps);
227 242 ResultUtils.buildSuccessResultAndWrite(response);
228 243 }
229 244  
230 245 /**
231   - * 获取宝宝信息
  246 + * 获取宝宝信息
232 247 *
233 248 * @param response
234   - * @param id 宝宝id
  249 + * @param id 宝宝id
235 250 */
236   - @RequestMapping(value = "/babys", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
  251 + @RequestMapping(value = "/babys", method = RequestMethod.GET)
237 252 @TokenRequired
238 253 public void getKids(HttpServletResponse response,
239   - @RequestParam("id")String id) {
  254 + @RequestParam("id") String id) {
240 255 if (StringUtils.isBlank(id)) {
241 256 ResultUtils.buildIdIsNull(response);
242 257 return;
243 258 }
244   -
  259 + //取出建档最早的那个
245 260 MedKidsQuery query = new MedKidsQuery();
246 261 query.setIsDelete(isDelete);
247 262 query.setId(id);
  263 + query.setSort("KI_BUILDTIME DESC");
248 264 List<MedKids> medKidList = medKidsService.queryMedKids(query);
249 265  
250 266 Map<String, Object> map = new HashMap<>();
251 267  
252   - if (CollectionUtils.isNotEmpty(medKidList)){
  268 + if (CollectionUtils.isNotEmpty(medKidList)) {
  269 + //取出第一个宝宝
253 270 MedKids kids = medKidList.get(0);
254 271  
255 272 map.put("id", kids.getId());
... ... @@ -257,7 +274,7 @@
257 274 map.put("birthday", DateUtil.getSecond(DateUtil.parseYMD(kids.getBirthday())));
258 275  
259 276 MedInoculateOrderQuery inoculateorderQuery = new MedInoculateOrderQuery();
260   - inoculateorderQuery.setIoKidId(id);
  277 + inoculateorderQuery.setIoKidId(kids.getId());
261 278 //时间倒序
262 279 inoculateorderQuery.setSort("io_inoculateDate desc");
263 280 List<MedInoculateOrder> inoculateorderList = medInoculateorderService.queryMedInoculateOrder(inoculateorderQuery);
264 281  
265 282  
266 283  
267 284  
268 285  
269 286  
270 287  
271 288  
272 289  
273 290  
274 291  
275 292  
276 293  
277 294  
278 295  
279 296  
280 297  
281 298  
... ... @@ -274,143 +291,133 @@
274 291 map.put("organizationId", medInoculateorder.getIoOrganizationId());
275 292 MedOrganization medOrganization = medOrganizationService.getMedOrganization(medInoculateorder.getIoOrganizationId());
276 293 map.put("organizationName", medOrganization == null ? "" : medOrganization.getoName());
277   - }else {
  294 + } else {
278 295 map.put("ioInoculateTime", null);
279 296 map.put("vaccineId", null);
280 297 map.put("vaccineName", null);
281 298 map.put("organizationId", null);
282 299 map.put("organizationName", null);
283 300 }
284   - }else {
285   - ResultUtils.buildParameterErrorResultAndWrite(response,"宝宝信息不存在");
  301 + } else {
  302 + ResultUtils.buildParameterErrorResultAndWrite(response, "宝宝信息不存在");
286 303 }
287 304 writeJson(response, JsonUtil.obj2JsonString(map));
288 305 }
289 306  
290 307 /**
291   - * 根据月龄获取宝宝该月龄预约接种的疫苗(分为免费疫苗和收费疫苗两个模块)
  308 + * 根据月龄获取宝宝该月龄预约接种的疫苗(分为免费疫苗和收费疫苗两个模块)
292 309 *
293 310 * @param response
294   - * @param kidId 宝宝ID
  311 + * @param kidId 宝宝ID
295 312 */
296 313 @RequestMapping(value = "/inoculatePlan", method = RequestMethod.GET)
297   - @TokenRequired
  314 + //@TokenRequired
298 315 public void getKidVaccines(HttpServletResponse response,
299   - @RequestParam("birthday")String birthday,//2016-01-02
300   - @RequestParam("id")String kidId) {
301   - //使用生日来和当前时间做比较,算出月龄
  316 + @RequestParam("id") String kidId) {
  317 + List<MedVaccineName> nameList = vaccineNameSington.getListVaccineName();
302 318  
303   - //0,1.2.3.4.5.6.7.8.10.11.1岁,1岁半,2岁,3岁,4岁,6岁
  319 + List<KidInoculationRecords> recordsList = medKidsService.queryInoculationRecord(kidId);
  320 +
304 321 List<Map> list = new ArrayList<>();//最外层的list
305 322  
306   - for (MouthAgeEnum mouth : MouthAgeEnum.values()){
307   - List<Map> mouthAgeList = new ArrayList<>();
308   - Map<String,Object> mouthMap = new HashMap<>();
  323 + int monthYear = 0;
309 324  
310   - Map<String,Object> inoculationMap = new HashMap<>();
  325 + for (MouthAgeEnum ageEnum : MouthAgeEnum.values()){
311 326  
  327 + Map<String, Object> map = new HashMap<>();
  328 +
  329 + Map<String, Object> mouthMap = new HashMap<>();//装免费和收费的map
  330 + List<Map> mouthList = new ArrayList<>();//月龄的list
312 331 List<Map> freeList = new ArrayList<>();
313 332 List<Map> chargeList = new ArrayList<>();
314 333  
315   - String mouthAge = String.valueOf(mouth.getId());
316   -
317   - //先根据月龄去找这个月龄下要接种的所有疫苗
318   - MedVaccineNameQuery vaccineNameQuery = new MedVaccineNameQuery();
319   - vaccineNameQuery.setVnMonthAge(mouthAge);
320   - vaccineNameQuery.setIsDelete(isDelete);
321   - List<MedVaccineName> vaccineNameList = medVaccineNameService.queryMedVaccineName(vaccineNameQuery);
322   - if (CollectionUtils.isNotEmpty(vaccineNameList)){
323   - for (MedVaccineName data : vaccineNameList){
  334 + for (MedVaccineName data : nameList){
  335 + if (ageEnum.getId()==data.getMouthAge()){
324 336 if (data.getVnVaccineType()==1){
325   - //免费
326   - freeList.add(getInoculate(data,mouthAge,kidId));
327   - }else if (data.getVnVaccineType()==2){
328   - //收费
329   - chargeList.add(getInoculate(data,mouthAge,kidId));
  337 + Map<String,Object> freeMap = new HashMap<>();
  338 + freeMap.put("id",data.getVnId());
  339 + freeMap.put("name",data.getVnName());
  340 + String[]a = data.getVnMonthAge().split(",");
  341 + int sum = a.length;
  342 + int current = 0 ;
  343 + for (int i = 0;i<a.length;i++){
  344 + if (data.getMouthAge()==Integer.valueOf(a[i])){
  345 + current = i + 1;
  346 + }
330 347 }
  348 + freeMap.put("current",current);
  349 + freeMap.put("sum",sum);
  350 + //接种ID
  351 + if (CollectionUtils.isNotEmpty(recordsList)){
  352 + for (KidInoculationRecords temp : recordsList){
  353 + if (temp.getJiCi()==current && temp.getVaccineNameTitle() == data.getVnName()
  354 + && temp.getCnt() == sum && temp.getVaccineType().equals("1")){
  355 + freeMap.put("inoculateId", temp.getRecordId());
  356 + break;
  357 + }else {
  358 + freeMap.put("inoculateId",null);
  359 + }
  360 + }
  361 + }else {
  362 + freeMap.put("inoculateId",null);
  363 + }
  364 + freeList.add(freeMap);
  365 + }else if (data.getVnVaccineType()==2) {
  366 + Map<String, Object> chargeMap = new HashMap<>();
  367 + chargeMap.put("id", data.getVnId());
  368 + chargeMap.put("name", data.getVnName());
  369 + String[] a = data.getVnMonthAge().split(",");
  370 + int sum = a.length;
  371 + int current = 0;
  372 + for (int i = 0; i < a.length; i++) {
  373 + if (data.getMouthAge() == Integer.valueOf(a[i])) {
  374 + current = i + 1;
  375 + }
  376 + }
  377 + chargeMap.put("current", current);
  378 + chargeMap.put("sum", sum);
  379 + //接种ID
  380 + if (CollectionUtils.isNotEmpty(recordsList)){
  381 + for (KidInoculationRecords temp : recordsList){
  382 + if (temp.getJiCi()==current && temp.getVaccineNameTitle()==data.getVnName()
  383 + && temp.getCnt() == sum&& temp.getVaccineType().equals("2")){
  384 + chargeMap.put("inoculateId", temp.getRecordId());
  385 + break;
  386 + }else {
  387 + chargeMap.put("inoculateId",null);
  388 + }
  389 + }
  390 + }else {
  391 + chargeMap.put("inoculateId",null);
  392 + }
  393 + chargeList.add(chargeMap);
  394 + }
331 395 }
332   - inoculationMap.put("freeList",freeList);
333   - inoculationMap.put("chargeList",chargeList);
334 396 }
335   - mouthAgeList.add(inoculationMap);
336   -
337   - mouthMap.put("mouthAgeList",mouthAgeList);
338   -
339   - list.add(mouthMap);
  397 + monthYear = monthYear + 1 ;
  398 + mouthMap.put("freeList",freeList);
  399 + mouthMap.put("chargeList",chargeList);
  400 + mouthList.add(mouthMap);
  401 + map.put(monthYear + "monthsOfAge", mouthList);
  402 + list.add(map);
340 403 }
341 404  
342 405 ResultUtils.buildSuccessResultAndWrite(response,list);
343 406 }
344 407  
345   - public Map<String,Object> getInoculate(MedVaccineName data,String mouthAge,String kidId){
346   - Map<String,Object> map = new HashMap<>();
347   -
348   - map.put("id",data.getVnId());//疫苗名称ID
349   - map.put("name",data.getVnName());//疫苗名称title
350   - String mouth = null;
351   -
352   - int length = 0;
353   -
354   - if (data.getVnMonthAge()!=null){
355   -
356   - String[] ages = data.getVnMonthAge().split(",");
357   - for (int a = 0 ; a < ages.length ; a++){
358   - if (mouthAge.equals(ages[a])){
359   - length = a + 1;
360   - }
361   - }
362   - mouth = "(第" + length + "/" + ages.length + "剂)";
363   - }
364   - map.put("mouthAge",mouth);
365   -
366   - //去接种预约表里面查某个疫苗是否接种,如果在指定时间内没有接种
367   -
368   - boolean isInoculate = false;
369   - String vaccineInfoId = null;
370   -
371   - //查出这个宝宝的所有接种信息
372   - MedInoculateRecordQuery inoculateRecordQuery = new MedInoculateRecordQuery();
373   - inoculateRecordQuery.setIcKidId(kidId);
374   - inoculateRecordQuery.setIsDelete(isDelete);
375   - List<MedInoculateRecord> inoculateRecordList = medInoculateRecordService.queryMedInoculateRecord(inoculateRecordQuery);
376   - if (CollectionUtils.isNotEmpty(inoculateRecordList)){
377   - for (MedInoculateRecord temp : inoculateRecordList){
378   -
379   - MedVaccineInfoQuery infoQuery = new MedVaccineInfoQuery();
380   - infoQuery.setIsDelete(isDelete);
381   - infoQuery.setViId(temp.getIcVaccineId());
382   - List<MedVaccineInfo> infoList = medVaccineinfoService.queryMedVaccineInfo(infoQuery);
383   -
384   - String VaccineNameId = "";
385   -
386   - if (CollectionUtils.isNotEmpty(infoList)){
387   - VaccineNameId = infoList.get(0).getViVaccineNameId();
388   - }
389   -
390   - //最后使用剂次和疫苗名称ID来判断接种表里面宝宝的接种是否成立
391   - if (length==Integer.valueOf(temp.getIcJiCi()) && data.getVnId().equals(VaccineNameId)){
392   - isInoculate = true;
393   - vaccineInfoId = temp.getIcVaccineId();
394   - }
395   - }
396   - }
397   - map.put("isInoculate",isInoculate);
398   - map.put("vaccineInfoId",vaccineInfoId);
399   - return map;
400   - }
401   -
402 408 /**
403 409 * 获取接种记录
  410 + *
404 411 * @param response
405 412 * @param kidId 宝宝ID
406   - * @param vaccineInfoId 疫苗基本信息ID
  413 + * @param vaccineInfoId 疫苗基本信息ID
407 414 */
408 415 @RequestMapping(value = "/inoculateRecord", method = RequestMethod.GET)
409 416 @TokenRequired
410 417 public void getKidVaccines(HttpServletResponse response,
411   - @RequestParam("kidId")String kidId,
412   - @RequestParam("jiCi")String jiCi,
413   - @RequestParam("vaccineInfoId")String vaccineInfoId){
  418 + @RequestParam("kidId") String kidId,
  419 + @RequestParam("jiCi") String jiCi,
  420 + @RequestParam("vaccineInfoId") String vaccineInfoId) {
414 421  
415 422 List<Map> list = new ArrayList<>();
416 423  
... ... @@ -455,7 +462,7 @@
455 462 map.put("batchNumber", data.getIcBatchNumber());
456 463 list.add(map);
457 464 }
458   - ResultUtils.buildSuccessResultAndWrite(response,list);
  465 + ResultUtils.buildSuccessResultAndWrite(response, list);
459 466 }
460 467  
461 468