|  | @ -1,17 +1,22 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.hospital.message.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.message.BaseBannerDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.message.dao.BaseBannerDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.apache.xmlbeans.impl.xb.xsdschema.Public;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 | 
	
		
			
				|  |  | import org.springframework.data.repository.PagingAndSortingRepository;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.swing.plaf.PanelUI;
 | 
	
		
			
				|  |  | import javax.transaction.Transactional;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | public class BaseBannerDoctorService extends BaseJpaService<BaseBannerDoctorDO, BaseBannerDoctorDao> {
 | 
	
	
		
			
				|  | @ -20,7 +25,38 @@ public class BaseBannerDoctorService extends BaseJpaService<BaseBannerDoctorDO,
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  |     //批量新增锦旗
 | 
	
		
			
				|  |  |     public void bannerGive(String patientId, String doctorId, List<String> list,Integer relationType){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public void bannerGive(String patientId,String patientName, List<String> list,String content,
 | 
	
		
			
				|  |  |                            String doctor,String doctorName){
 | 
	
		
			
				|  |  |         if (list.size()>0){
 | 
	
		
			
				|  |  |             for (int i=0;i<list.size();i++){
 | 
	
		
			
				|  |  |                 BaseBannerDoctorDO baseBannerDoctorDO = new BaseBannerDoctorDO();
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setBannerId(list.get(i));
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setContent(content);
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setDoctor(doctor);
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setDoctorName(doctorName);
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setPatientId(patientId);
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setPatientName(patientName);
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setRelationType(1);
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setRerelationName("送锦旗留言");
 | 
	
		
			
				|  |  |                 baseBannerDoctorDO.setRelationCode("system");
 | 
	
		
			
				|  |  |                 baseBannerDoctorDao.save(baseBannerDoctorDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     //获取医生锦旗数量接口
 | 
	
		
			
				|  |  |     public JSONObject getDoctorBanners(String doctorID){
 | 
	
		
			
				|  |  |         StringBuffer sql = new StringBuffer();
 | 
	
		
			
				|  |  |         sql.append("SELECT COUNT(1) AS \"total\",b.name  FROM base_banner_doctor a LEFT JOIN base_banner b on a.banner_id= b.id\n" +
 | 
	
		
			
				|  |  |                 "where 1=1 ");
 | 
	
		
			
				|  |  |         sql.append("and a.doctor = "+doctorID);
 | 
	
		
			
				|  |  |         sql.append( " GROUP BY a.banner_id");
 | 
	
		
			
				|  |  |         //获取每个锦旗数量
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString());
 | 
	
		
			
				|  |  |         int count = baseBannerDoctorDao.getTotalBannerCount(doctorID);
 | 
	
		
			
				|  |  |         JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |         jsonObject.put("count",count);
 | 
	
		
			
				|  |  |         jsonObject.put("resultlist",list);
 | 
	
		
			
				|  |  |         return jsonObject;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |