|  | @ -2,6 +2,8 @@ package com.yihu.iot.service.dict;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | import com.yihu.iot.dao.dict.IotHospitalDao;
 |  | import com.yihu.iot.dao.dict.IotHospitalDao;
 | 
												
													
														
															|  | import com.yihu.jw.entity.iot.dict.IotHospitalDO;
 |  | import com.yihu.jw.entity.iot.dict.IotHospitalDO;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.rm.iot.IotRequestMapping;
 | 
												
													
														
															|  | import com.yihu.mysql.query.BaseJpaService;
 |  | import com.yihu.mysql.query.BaseJpaService;
 | 
												
													
														
															|  | import org.apache.commons.lang3.StringUtils;
 |  | import org.apache.commons.lang3.StringUtils;
 | 
												
													
														
															|  | import org.springframework.beans.factory.annotation.Autowired;
 |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
												
											
												
													
														
															|  | @ -21,14 +23,19 @@ public class IotHospitalService extends BaseJpaService<IotHospitalDO, IotHospita
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private JdbcTemplate jdbcTemplate;
 |  |     private JdbcTemplate jdbcTemplate;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public IotHospitalDO create(IotHospitalDO hospitalDO) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public MixEnvelop create(IotHospitalDO hospitalDO) {
 | 
												
													
														
															|  | 
 |  |         //判断该单位是否已添加
 | 
												
													
														
															|  | 
 |  |         IotHospitalDO oldHospital = hospitalDao.findByNameAndDel(hospitalDO.getName(), "1");
 | 
												
													
														
															|  | 
 |  |         if(oldHospital != null){
 | 
												
													
														
															|  | 
 |  |             return MixEnvelop.getError("该单位已存在,请重新输入!");
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  |         hospitalDO.setSaasId(getCode());
 |  |         hospitalDO.setSaasId(getCode());
 | 
												
													
														
															|  |         hospitalDO.setDel("1");
 |  |         hospitalDO.setDel("1");
 | 
												
													
														
															|  |         hospitalDao.save(hospitalDO);
 |  |         hospitalDao.save(hospitalDO);
 | 
												
													
														
															|  |         return hospitalDO;
 |  | 
 | 
												
													
														
															|  | 
 |  |         return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create, hospitalDO);
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public List<IotHospitalDO> getListByName(String name, String level, Integer page, Integer pageSize) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public MixEnvelop<IotHospitalDO, IotHospitalDO> getListByName(String name, String level, Integer page, Integer pageSize) {
 | 
												
													
														
															|  |         String sql = "SELECT * FROM `iot_hospital` h WHERE h.del = 1 ";
 |  |         String sql = "SELECT * FROM `iot_hospital` h WHERE h.del = 1 ";
 | 
												
													
														
															|  |         if(StringUtils.isNotBlank(name)){
 |  |         if(StringUtils.isNotBlank(name)){
 | 
												
													
														
															|  |             sql += "and h.name like '%" + name + "%' ";
 |  |             sql += "and h.name like '%" + name + "%' ";
 | 
												
											
												
													
														
															|  | @ -37,9 +44,13 @@ public class IotHospitalService extends BaseJpaService<IotHospitalDO, IotHospita
 | 
												
													
														
															|  |             sql += "and h.level = '" + level + "' ";
 |  |             sql += "and h.level = '" + level + "' ";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if(page != null && pageSize != null){
 |  |         if(page != null && pageSize != null){
 | 
												
													
														
															|  | 
 |  |             Long count = Long.valueOf(jdbcTemplate.queryForList(sql).size());
 | 
												
													
														
															|  |             sql += "limit " + (page-1)*pageSize + "," + pageSize;
 |  |             sql += "limit " + (page-1)*pageSize + "," + pageSize;
 | 
												
													
														
															|  | 
 |  |             List<IotHospitalDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(IotHospitalDO.class));
 | 
												
													
														
															|  | 
 |  |             return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, list, page, pageSize, count);
 | 
												
													
														
															|  | 
 |  |         }else {
 | 
												
													
														
															|  | 
 |  |             List<IotHospitalDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(IotHospitalDO.class));
 | 
												
													
														
															|  | 
 |  |             return MixEnvelop.getSuccessList(IotRequestMapping.Company.message_success_find, list);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         List<IotHospitalDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(IotHospitalDO.class));
 |  | 
 | 
												
													
														
															|  |         return list;
 |  | 
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | }
 |  | }
 |