|
@ -23,9 +23,12 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
|
import com.yihu.jw.exception.business.ManageException;
|
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
|
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
|
|
|
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -34,6 +37,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@ -123,48 +127,133 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
|
|
|
* @param docStatus
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject queryDoctorListFullInfo(String nameOrIdcard, String orgCode, String docStatus, int page, int size) throws Exception {
|
|
|
public JSONObject queryDoctorListFullInfo(String nameOrIdcard, String orgCode, String docStatus, int page, int size,String wechatId) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String orgCodeVale = null == orgCode ? "" : orgCode;
|
|
|
String del = null == docStatus ? "" : docStatus;
|
|
|
String nameOrIdcardValue = null == nameOrIdcard ? "" : "%" + nameOrIdcard + "%";
|
|
|
int start = 0 == page ? page++ : (page - 1) * size;
|
|
|
int end = 0 == size ? 15 : page * size;
|
|
|
String sql = "select" +
|
|
|
" tb.id as id," +
|
|
|
" tb.name as name," +
|
|
|
" tb.idcard as idcard, " +
|
|
|
" tb.sex as sex, " +
|
|
|
" tb.mobile as mobile, " +
|
|
|
" GROUP_CONCAT(tb.org SEPARATOR ',') as orgInfo, " +
|
|
|
" tb.job_title_name as jobTitleName, " +
|
|
|
" tb.status as status " +
|
|
|
"from " +
|
|
|
" ( " +
|
|
|
" select " +
|
|
|
" doc.id, " +
|
|
|
" doc.name, " +
|
|
|
" doc.idcard, " +
|
|
|
" case doc.sex when 1 then '男' when 2 then '女' else '未知' end as sex, " +
|
|
|
" doc.mobile, " +
|
|
|
" concat(hos.org_name,'/',dept.name,'/',hos.doctor_duty_name) as org, " +
|
|
|
" doc.job_title_name, " +
|
|
|
" case doc.del when 0 then '已失效' when 1 then '生效中' end as status, " +
|
|
|
" doc.create_time " +
|
|
|
" from " +
|
|
|
" base_doctor doc, " +
|
|
|
" base_doctor_hospital hos, " +
|
|
|
" dict_hospital_dept dept " +
|
|
|
" where " +
|
|
|
" doc.id = hos.doctor_code " +
|
|
|
" and " +
|
|
|
" hos.org_code = dept.org_code " +
|
|
|
" and " +
|
|
|
" hos.dept_code = dept.code " +
|
|
|
" and " +
|
|
|
" ((doc.idcard like '{idcard}' or ''= '{idcard}' ) or (doc.name like '{name}' or ''= '{name}' ) and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) " +
|
|
|
" ) tb " +
|
|
|
"GROUP BY tb.id order by tb.create_time desc limit {start},{end} ";
|
|
|
// String sql = "select" +
|
|
|
// " tb.id as id," +
|
|
|
// " tb.name as name," +
|
|
|
// " tb.idcard as idcard, " +
|
|
|
// " tb.sex as sex, " +
|
|
|
// " tb.mobile as mobile, " +
|
|
|
// " GROUP_CONCAT(tb.org SEPARATOR ',') as orgInfo, " +
|
|
|
// " tb.job_title_name as jobTitleName, " +
|
|
|
// " tb.status as status " +
|
|
|
// "from " +
|
|
|
// " ( " +
|
|
|
// " select " +
|
|
|
// " doc.id, " +
|
|
|
// " doc.name, " +
|
|
|
// " doc.idcard, " +
|
|
|
// " case doc.sex when 1 then '男' when 2 then '女' else '未知' end as sex, " +
|
|
|
// " doc.mobile, " +
|
|
|
// " concat(hos.org_name,'/',dept.name,'/',hos.doctor_duty_name) as org, " +
|
|
|
// " doc.job_title_name, " +
|
|
|
// " case doc.del when 0 then '已失效' when 1 then '生效中' end as status, " +
|
|
|
// " doc.create_time " +
|
|
|
// " from " +
|
|
|
// " base_doctor doc, " +
|
|
|
// " base_doctor_hospital hos, " +
|
|
|
// " dict_hospital_dept dept " +
|
|
|
// " where " +
|
|
|
// " doc.id = hos.doctor_code " +
|
|
|
// " and " +
|
|
|
// " hos.org_code = dept.org_code " +
|
|
|
// " and " +
|
|
|
// " hos.dept_code = dept.code " +
|
|
|
// " and " +
|
|
|
// " ((doc.idcard like '{idcard}' or ''= '{idcard}' ) or (doc.name like '{name}' or ''= '{name}' ) and (hos.org_code = '{orgCode}' or ''= '{orgCode}') and (doc.del = '{docStatus}' or ''= '{docStatus}')) " +
|
|
|
// " ) tb " +
|
|
|
// "GROUP BY tb.id order by tb.create_time desc limit {start},{end} ";
|
|
|
// String finalSql = sql
|
|
|
// .replace("{idcard}",nameOrIdcardValue)
|
|
|
// .replace("{name}",nameOrIdcardValue)
|
|
|
// .replace("{orgCode}",orgCodeVale)
|
|
|
// .replace("{docStatus}",del)
|
|
|
// .replace("{start}",String.valueOf(start))
|
|
|
// .replace("{end}",String.valueOf(end));
|
|
|
|
|
|
String sql="SELECT\n" +
|
|
|
"\ttb. ID AS \"ID\",\n" +
|
|
|
"\ttb.idcard AS \"idcard\",\n" +
|
|
|
"\ttb. NAME AS \"NAME\",\n" +
|
|
|
"\ttb.sex AS \"sex\",\n" +
|
|
|
"\ttb.mobile AS \"mobile\",";
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
sql+=" wm_concat (tb.org || ',') AS \"orgInfo\",";
|
|
|
}else {
|
|
|
sql+=" GROUP_CONCAT(tb.org SEPARATOR ',') AS orgInfo,";
|
|
|
}
|
|
|
sql+="tb.job_title_name AS \"jobTitleName\",\n" +
|
|
|
"\ttb.status AS \"status\",\n" +
|
|
|
" tb.create_time AS \"createtime\"\n" +
|
|
|
"FROM\n" +
|
|
|
"\t(\n" +
|
|
|
"\t\tSELECT\n" +
|
|
|
"\t\t\tdoc. ID,\n" +
|
|
|
"\t\t\tdoc. NAME,\n" +
|
|
|
"\t\t\tdoc.idcard,\n" +
|
|
|
"\t\t\tCASE\n" +
|
|
|
"\t\tWHEN doc.sex = 1 THEN\n" +
|
|
|
"\t\t\t'男'\n" +
|
|
|
"\t\tWHEN doc.sex = 2 THEN\n" +
|
|
|
"\t\t\t'女'\n" +
|
|
|
"\t\tELSE\n" +
|
|
|
"\t\t\t'未知'\n" +
|
|
|
"\t\tEND AS sex,\n" +
|
|
|
"\t\tdoc.mobile,\n" +
|
|
|
"\t\thos.org_name || '/' || dept. NAME || '/' || hos.doctor_duty_name AS org,\n" +
|
|
|
"\t\tdoc.job_title_name,\n" +
|
|
|
"\t\tCASE\n" +
|
|
|
"\tWHEN doc.del = 0 THEN\n" +
|
|
|
"\t\t'已失效'\n" +
|
|
|
"\tWHEN doc.del = 1 THEN\n" +
|
|
|
"\t\t'生效中'\n" +
|
|
|
"\tEND AS status,\n" +
|
|
|
"\tdoc.create_time\n" +
|
|
|
"FROM\n" +
|
|
|
"\tbase_doctor doc,\n" +
|
|
|
"\tbase_doctor_hospital hos,\n" +
|
|
|
"\tdict_hospital_dept dept\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tdoc. ID = hos.doctor_code\n" +
|
|
|
"AND hos.org_code = dept.org_code\n" +
|
|
|
"AND hos.dept_code = dept.code\n" +
|
|
|
"AND (\n" +
|
|
|
"\t(\n" +
|
|
|
"\t\tdoc.idcard LIKE '%%'\n" +
|
|
|
"\t\tOR '' = '%%'\n" +
|
|
|
"\t)\n" +
|
|
|
"\tOR (doc. NAME LIKE '%%' OR '' = '%%')\n" +
|
|
|
"\tAND (hos.org_code = '' OR '' = '')\n" +
|
|
|
"\tAND (doc.del = '' OR '' = '')\n" +
|
|
|
")\n" +
|
|
|
"\t) tb";
|
|
|
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
sql+=" GROUP BY\n" +
|
|
|
"\ttb. ID,\n" +
|
|
|
"\ttb.idcard,\n" +
|
|
|
"\ttb. NAME,\n" +
|
|
|
"\ttb.sex,\n" +
|
|
|
"\ttb.mobile,\n" +
|
|
|
"\ttb.job_title_name,\n" +
|
|
|
"\ttb.status,\n" +
|
|
|
" tb.create_time\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"\ttb.create_time DESC";
|
|
|
}else {
|
|
|
sql+=" GROUP BY\n" +
|
|
|
"\ttb. ID\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"\ttb.create_time DESC";
|
|
|
}
|
|
|
|
|
|
|
|
|
String finalSql = sql
|
|
|
.replace("{idcard}",nameOrIdcardValue)
|
|
|
.replace("{name}",nameOrIdcardValue)
|
|
@ -173,8 +262,36 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
|
|
|
.replace("{start}",String.valueOf(start))
|
|
|
.replace("{end}",String.valueOf(end));
|
|
|
|
|
|
List<Map<String,Object>> list=null;
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
String oracleSql="SELECT\n" +
|
|
|
"\t*\n" +
|
|
|
"FROM\n" +
|
|
|
"\t(\n" +
|
|
|
"\t\tSELECT\n" +
|
|
|
"\t\t\tA .*\n" +
|
|
|
"\t\tFROM\n" +
|
|
|
"\t\t\t(";
|
|
|
|
|
|
oracleSql+=finalSql;
|
|
|
|
|
|
oracleSql+="\t\t\t) A\n" +
|
|
|
"\t\tWHERE\n" +
|
|
|
" ROWNUM <="+page*size +
|
|
|
"\t) \n" +
|
|
|
"WHERE\n" +
|
|
|
"\tROWNUM >= "+(page-1)*size;
|
|
|
Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
|
|
|
list = jdbcTemplate.queryForList(oracleSql);
|
|
|
}else {
|
|
|
finalSql+=" LIMIT " + (page - 1) * size + "," + size + "";
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+finalSql);
|
|
|
list = jdbcTemplate.queryForList(finalSql);
|
|
|
}
|
|
|
|
|
|
|
|
|
String countSql = " select " +
|
|
|
" count(DISTINCT (doc.id)) as count " +
|
|
|
" COUNT(DISTINCT (doc.id)) as count " +
|
|
|
" from " +
|
|
|
" base_doctor doc, " +
|
|
|
" base_doctor_hospital hos, " +
|
|
@ -192,7 +309,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
|
|
|
.replace("{name}",nameOrIdcardValue)
|
|
|
.replace("{orgCode}",orgCodeVale)
|
|
|
.replace("{docStatus}",del);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(finalSql);
|
|
|
// List<Map<String,Object>> list = jdbcTemplate.queryForList(finalSql);
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
|
|
|
int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
|
|
|
result.put("count", count);
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|