|  | @ -1,25 +1,32 @@
 | 
												
													
														
															|  | package com.yihu.jw.hospital.doctor.dao.service;
 |  | package com.yihu.jw.hospital.doctor.dao.service;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.doctor.dao.BaseDoctorMessageDao;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.doctor.BaseDoctorBackgroundDO;
 |  | import com.yihu.jw.entity.base.doctor.BaseDoctorBackgroundDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.base.doctor.BaseDoctorMessageDO;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.doctor.dao.BaseDoctorBackgroundDao;
 |  | import com.yihu.jw.hospital.doctor.dao.BaseDoctorBackgroundDao;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
 |  | 
 | 
												
													
														
															|  | import com.yihu.jw.rm.base.BaseRequestMapping;
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
												
													
														
															|  | import com.yihu.mysql.query.BaseJpaService;
 |  | import com.yihu.mysql.query.BaseJpaService;
 | 
												
													
														
															|  | import org.apache.commons.lang.StringUtils;
 |  | import org.apache.commons.lang.StringUtils;
 | 
												
													
														
															|  | import org.springframework.beans.factory.annotation.Autowired;
 |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | import org.springframework.stereotype.Service;
 |  | import org.springframework.stereotype.Service;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import javax.transaction.Transactional;
 |  | import javax.transaction.Transactional;
 | 
												
													
														
															|  | 
 |  | import java.util.Date;
 | 
												
													
														
															|  | import java.util.List;
 |  | import java.util.List;
 | 
												
													
														
															|  | 
 |  | import java.util.Map;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | @Service
 |  | @Service
 | 
												
													
														
															|  | public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO, BaseDoctorBackgroundDao> {
 |  | public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO, BaseDoctorBackgroundDao> {
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private BaseDoctorBackgroundDao baseDoctorBackgroundDao;
 |  |     private BaseDoctorBackgroundDao baseDoctorBackgroundDao;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private BaseDoctorDao baseDoctorDao;
 |  |     private BaseDoctorDao baseDoctorDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private BaseDoctorMessageDao doctorMessageDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     private HibenateUtils hibenateUtils;
 | 
												
													
														
															|  |     //查询背景
 |  |     //查询背景
 | 
												
													
														
															|  |     public List<BaseDoctorBackgroundDO> getBackground(Integer page,Integer pageSize){
 |  |     public List<BaseDoctorBackgroundDO> getBackground(Integer page,Integer pageSize){
 | 
												
													
														
															|  |         return baseDoctorBackgroundDao.getBackroundAll(page,pageSize);
 |  |         return baseDoctorBackgroundDao.getBackroundAll(page,pageSize);
 | 
												
											
												
													
														
															|  | @ -69,4 +76,88 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO,
 | 
												
													
														
															|  |         return  baseDoctorBackgroundDO;
 |  |         return  baseDoctorBackgroundDO;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 查询某个医生快捷回复列表
 | 
												
													
														
															|  | 
 |  |      * @param doctor
 | 
												
													
														
															|  | 
 |  |      * @param page
 | 
												
													
														
															|  | 
 |  |      * @param size
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public List<Map<String,Object>> selectByDoctor(String doctor, Integer contentType, String content, Integer page, Integer size){
 | 
												
													
														
															|  | 
 |  |         String sql = "select id as \"id\", doctor as \"doctor\",doctor_name as \"doctorName\",content_type as \"contentType\"," +
 | 
												
													
														
															|  | 
 |  |                 "content as \"content\" , content_desc as \"contentDesc\",is_sort as \"isSort\",del as \"del\" " +
 | 
												
													
														
															|  | 
 |  |                 " from base_doctor_message whre del=1 and doctor='"+doctor+"' ";
 | 
												
													
														
															|  | 
 |  |         if (contentType!=null){
 | 
												
													
														
															|  | 
 |  |             sql +=" and content_type= "+contentType;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNotBlank(content)){
 | 
												
													
														
															|  | 
 |  |             sql +=" and content like '%"+content+"%'v";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         sql +=" order by is_sort desc ";
 | 
												
													
														
															|  | 
 |  |         List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql,page,size);
 | 
												
													
														
															|  | 
 |  |         return mapList;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 增加和更新快捷回复信息
 | 
												
													
														
															|  | 
 |  |      * @param doctorMessageDO
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     @Transactional
 | 
												
													
														
															|  | 
 |  |     public BaseDoctorMessageDO saveDoctorMessage(BaseDoctorMessageDO doctorMessageDO){
 | 
												
													
														
															|  | 
 |  |         if (!StringUtils.isNotBlank(doctorMessageDO.getId())){
 | 
												
													
														
															|  | 
 |  |             String sql = "select max(dm.is_sort) as total from base_doctor_message dm where dm.del=1 ";
 | 
												
													
														
															|  | 
 |  |             List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  | 
 |  |             Integer isSort=0;
 | 
												
													
														
															|  | 
 |  |             if (maps!=null&&maps.size()!=0){
 | 
												
													
														
															|  | 
 |  |                 isSort = Integer.parseInt(maps.get(0).get("total").toString());
 | 
												
													
														
															|  | 
 |  |             }else {
 | 
												
													
														
															|  | 
 |  |                 isSort=isSort+1;
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             doctorMessageDO.setIsSort(isSort);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setDel(1);
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setUpdateTime(new Date());
 | 
												
													
														
															|  | 
 |  |         return  doctorMessageDao.save(doctorMessageDO);
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 设置置顶
 | 
												
													
														
															|  | 
 |  |      * @param id
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     @Transactional
 | 
												
													
														
															|  | 
 |  |     public BaseDoctorMessageDO setMessageHead(String id){
 | 
												
													
														
															|  | 
 |  |         BaseDoctorMessageDO doctorMessageDO = doctorMessageDao.findOne(id);
 | 
												
													
														
															|  | 
 |  |         String sql = "select max(dm.is_sort) as total from base_doctor_message dm where dm.del=1  ";
 | 
												
													
														
															|  | 
 |  |         List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  | 
 |  |         Integer isSort=0;
 | 
												
													
														
															|  | 
 |  |         if (maps!=null&&maps.size()!=0){
 | 
												
													
														
															|  | 
 |  |             isSort = Integer.parseInt(maps.get(0).get("total").toString());
 | 
												
													
														
															|  | 
 |  |         }else {
 | 
												
													
														
															|  | 
 |  |             isSort=isSort+1;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setIsSort(isSort);
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setUpdateTime(new Date());
 | 
												
													
														
															|  | 
 |  |         return doctorMessageDao.save(doctorMessageDO);
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     @Transactional
 | 
												
													
														
															|  | 
 |  |     public BaseDoctorMessageDO delDoctorMessage(String id){
 | 
												
													
														
															|  | 
 |  |         BaseDoctorMessageDO doctorMessageDO = doctorMessageDao.findOne(id);
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setDel(0);
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |         doctorMessageDO.setUpdateTime(new Date());
 | 
												
													
														
															|  | 
 |  |         return doctorMessageDao.save(doctorMessageDO);
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | }
 |  | }
 |