|
@ -8,6 +8,8 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.util.ConstantUtils;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -18,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.sound.sampled.Mixer;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@ -50,6 +53,8 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -81,7 +86,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
|
|
|
* @param sorts
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> queryPatientBaseInfo(String nameOrIdcard,int page,int size,String sorts)throws Exception{
|
|
|
public MixEnvelop queryPatientBaseInfo(String nameOrIdcard, int page, int size, String sorts)throws Exception{
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
String param = null == nameOrIdcard ? "": nameOrIdcard;
|
|
|
String sql = "SELECT\n" +
|
|
@ -96,23 +101,34 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
|
|
|
"ELSE\n" +
|
|
|
"\t'未知'\n" +
|
|
|
"END AS \"sex\",\n" +
|
|
|
" phone AS \"phone\",\n" +
|
|
|
" mobile AS \"phone\",\n" +
|
|
|
" committee_name AS \"committeeName\",\n" +
|
|
|
" province_name || city_name || town_name || street_name AS \"address\"\n" +
|
|
|
" province_name AS \"provinceName\"," +
|
|
|
" city_name AS \"cityName\", " +
|
|
|
"town_name AS \"townName\"," +
|
|
|
" street_name \"streetName\"," +
|
|
|
" address AS \"address\"\n" +
|
|
|
"FROM\n" +
|
|
|
"\tbase_patient\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tNAME LIKE '%%'\n" +
|
|
|
"OR idcard LIKE '%%'\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"\tbase_patient\n";
|
|
|
if (StringUtils.isNotEmpty(nameOrIdcard)){
|
|
|
sql+="WHERE\n" +
|
|
|
"\tNAME LIKE '%"+nameOrIdcard+"%'\n" +
|
|
|
"OR idcard LIKE '%"+nameOrIdcard+"%'\n";
|
|
|
}
|
|
|
sql+="ORDER BY\n" +
|
|
|
"\tcreate_time DESC";
|
|
|
String countSql = "select count(id) from base_patient where name like '%" + param + "%' or idcard like '%" + param + "%'";
|
|
|
Long count = jdbcTemplate.queryForObject(countSql,Long.class);
|
|
|
if(count <= 0){
|
|
|
return result;
|
|
|
return null;
|
|
|
}
|
|
|
result = jdbcTemplate.queryForList(sql);
|
|
|
return result;
|
|
|
MixEnvelop envelop = new MixEnvelop();
|
|
|
result = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
envelop.setDetailModelList(result);
|
|
|
envelop.setTotalCount(count.intValue());
|
|
|
envelop.setCurrPage(page);
|
|
|
envelop.setPageSize(size);
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
/**
|