| 
					
				 | 
			
			
				@ -1,25 +1,32 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.hospital.doctor.dao.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.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.message.dao.BaseBannerDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.rm.base.BaseRequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.PageRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Pageable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Sort; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.transaction.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO, BaseDoctorBackgroundDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorBackgroundDao baseDoctorBackgroundDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorDao baseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorMessageDao doctorMessageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //查询背景 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<BaseDoctorBackgroundDO> getBackground(Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return baseDoctorBackgroundDao.getBackroundAll(page,pageSize); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -69,4 +76,64 @@ public class BaseDoctorBGService extends BaseJpaService<BaseDoctorBackgroundDO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return  baseDoctorBackgroundDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询某个医生快捷回复列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<BaseDoctorMessageDO> selectByDoctor(String doctor,Integer page,Integer size){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Sort sort = new Sort(Sort.Direction.DESC, "isSort"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Pageable pageRequest = new PageRequest(page-1,size,sort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return doctorMessageDao.findByDoctorAndDel(doctor,pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 增加和更新快捷回复信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctorMessageDO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public BaseDoctorMessageDO saveDoctorMessage(BaseDoctorMessageDO doctorMessageDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!StringUtils.isNotBlank(doctorMessageDO.getId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "select max(dm.is_sort) as total from base_doctor_message dm "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 设置置顶 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public BaseDoctorMessageDO setMessageHead(String id){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseDoctorMessageDO doctorMessageDO = doctorMessageDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select max(dm.is_sort) as total from base_doctor_message dm "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |