|  | @ -1,5 +1,6 @@
 | 
												
													
														
															|  | package com.yihu.jw.hospital.message.service;
 |  | package com.yihu.jw.hospital.message.service;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.alibaba.fastjson.JSONObject;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.message.BaseUserMessageDO;
 |  | import com.yihu.jw.entity.hospital.message.BaseUserMessageDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.message.BaseUserMsgContentDO;
 |  | import com.yihu.jw.entity.hospital.message.BaseUserMsgContentDO;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.message.dao.BaseUserMessageDao;
 |  | import com.yihu.jw.hospital.message.dao.BaseUserMessageDao;
 | 
												
											
												
													
														
															|  | @ -29,6 +30,8 @@ public class UserMsgContentService extends BaseJpaService<BaseUserMsgContentDO,
 | 
												
													
														
															|  |     private MsgContentDao msgContentDao;
 |  |     private MsgContentDao msgContentDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private HibenateUtils hibenateUtils;
 |  |     private HibenateUtils hibenateUtils;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private BaseBannerDoctorService bannerDoctorService;
 | 
												
													
														
															|  |     //获取评论
 |  |     //获取评论
 | 
												
													
														
															|  |     public List getAllMessage(String relationCode){
 |  |     public List getAllMessage(String relationCode){
 | 
												
													
														
															|  |         List<BaseUserMessageDO> list = msgContentDao.findByRelationCode(relationCode);
 |  |         List<BaseUserMessageDO> list = msgContentDao.findByRelationCode(relationCode);
 | 
												
											
												
													
														
															|  | @ -121,5 +124,49 @@ public class UserMsgContentService extends BaseJpaService<BaseUserMsgContentDO,
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         return sqlForExpert.toString();
 |  |         return sqlForExpert.toString();
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  |     //医生主页展示的医生信息
 | 
												
													
														
															|  | 
 |  |     public JSONObject showContentByDoctor(String doctor){
 | 
												
													
														
															|  | 
 |  |         //锦旗总数和各个锦旗数量
 | 
												
													
														
															|  | 
 |  |         JSONObject jsonObject = bannerDoctorService.getDoctorBanners(doctor);
 | 
												
													
														
															|  | 
 |  |         //留言总数
 | 
												
													
														
															|  | 
 |  |         int messageTotal = userMessageDao.getAllMessageTotalCount(doctor);
 | 
												
													
														
															|  | 
 |  |         //查询医生各项评价平均分
 | 
												
													
														
															|  | 
 |  |         String sqlscore = "SELECT " +
 | 
												
													
														
															|  | 
 |  |                 "AVG(a.score) AS \"score\"," +
 | 
												
													
														
															|  | 
 |  |                 "a.score_type AS \"score_type\" " +
 | 
												
													
														
															|  | 
 |  |                 "FROM base_evaluate a,base_evaluate_score b " +
 | 
												
													
														
															|  | 
 |  |                 "WHERE " +
 | 
												
													
														
															|  | 
 |  |                 "a.relation_code=b.id " +
 | 
												
													
														
															|  | 
 |  |                 "AND b.doctor='" + doctor + "' " +
 | 
												
													
														
															|  | 
 |  |                 "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
 | 
												
													
														
															|  | 
 |  |         List<Map<String, Object>> listscore = jdbcTemplate.queryForList(sqlscore);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         Double doctorScore = new Double("0");
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (listscore != null && listscore.size() > 0) {
 | 
												
													
														
															|  | 
 |  |             for (Map<String, Object> _listscore : listscore) {
 | 
												
													
														
															|  | 
 |  |                 doctorScore += Double.parseDouble(_listscore.get("score").toString());
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         doctorScore = doctorScore / 3;
 | 
												
													
														
															|  | 
 |  |         //总评
 | 
												
													
														
															|  | 
 |  |         jsonObject.put("doctorScore", doctorScore);
 | 
												
													
														
															|  | 
 |  |         if (listscore != null && listscore.size() > 0) {
 | 
												
													
														
															|  | 
 |  |             //各项平均分
 | 
												
													
														
															|  | 
 |  |             jsonObject.put("scoreDoctor", listscore);
 | 
												
													
														
															|  | 
 |  |         } else {
 | 
												
													
														
															|  | 
 |  |             jsonObject.put("scoreDoctor", null);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         List<BaseUserMessageDO> messageList= userMessageDao.getAllMessageByDoctor(doctor);
 | 
												
													
														
															|  | 
 |  |         if (null!=messageList){
 | 
												
													
														
															|  | 
 |  |             for (BaseUserMessageDO baseUserMessageDO:messageList){
 | 
												
													
														
															|  | 
 |  |                 String id = baseUserMessageDO.getId();
 | 
												
													
														
															|  | 
 |  |                 List<BaseUserMsgContentDO> contentlist=baseUserMsgContentDao.getContentListByID(id);
 | 
												
													
														
															|  | 
 |  |                 baseUserMessageDO.setMsgList(contentlist);
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             jsonObject.put("messageList", messageList);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return jsonObject;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | }
 |  | }
 |