|
@ -9,9 +9,11 @@ import com.yihu.es.entity.RoleVo;
|
|
|
import com.yihu.wlyy.config.es.ElastricSearchSave;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
|
|
|
import com.yihu.wlyy.entity.education.HealthEduArticle;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
|
|
|
import com.yihu.wlyy.service.app.team.AdminTeamService;
|
|
|
import com.yihu.wlyy.service.common.account.RoleService;
|
|
|
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
|
|
@ -60,6 +62,8 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
private AdminTeamService teamService;
|
|
|
@Autowired
|
|
|
private CommonUtil commonUtil;
|
|
|
@Autowired
|
|
|
private SignPatientLabelInfoService signPatientLabelInfoService;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@ -466,6 +470,7 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
if (!StringUtils.isEmpty(labelUnit)) {
|
|
|
whereSql += " and w.hospital in (" + labelUnit + ") ";
|
|
|
}
|
|
|
whereSql += " and p.openid is not null ";
|
|
|
List<String> groupPatient = jdbcTemplate.queryForList(tableSql + whereSql, String.class);
|
|
|
patientSet.addAll(groupPatient);
|
|
|
}
|
|
@ -597,10 +602,38 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
public JSONObject pushArticleConfirm(String articleId,String labelType, String condition, String groupType,Long teamId,String doctorCode) throws Exception{
|
|
|
public void initPatients(String userCode,String[] groups,String group,String labelType,long teamCode,String[] patients,Set<String> patientSet) throws Exception{
|
|
|
Map<String, HealthEduArticle> maps = new HashMap<String, HealthEduArticle>();
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(group) && groups.length > 0) {
|
|
|
//递归患者数据
|
|
|
for (String g : groups) {
|
|
|
getPatientByGroup(userCode,g, labelType, teamCode, patientSet, 0, 100);
|
|
|
}
|
|
|
}
|
|
|
//去重操作
|
|
|
for (String p : patients) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(p)) {
|
|
|
patientSet.add(p);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void getPatientByGroup(String userCode,String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
|
|
|
org.json.JSONArray result = signPatientLabelInfoService.getPatientByLabel(userCode, labelCode, labelType, teamCode, page, pagesize, false, "",false);
|
|
|
for (Object o : result) {
|
|
|
org.json.JSONObject json = (org.json.JSONObject) o;
|
|
|
String patient = (String) json.get("code");
|
|
|
patientSet.add(patient);
|
|
|
}
|
|
|
if (result.length() == 100) {
|
|
|
getPatientByGroup(userCode,labelCode, labelType, teamCode, patientSet, page + 1, pagesize);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public JSONObject pushArticleConfirm(String userCode,String[] groups,String group,String labelType,long teamCode,String[] patients,String articleId) throws Exception{
|
|
|
JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"");
|
|
|
Set<String> patientSet = new HashSet<>();
|
|
|
initPatients(patientSet,labelType,condition,groupType,teamId,doctorCode);
|
|
|
initPatients(userCode,groups,group,labelType,teamCode,patients,patientSet);
|
|
|
long num = patientSet.size();
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("num", num);
|
|
@ -608,108 +641,108 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生推送文章初始化被推患者信息
|
|
|
* @param patientSet
|
|
|
* @param labelType
|
|
|
* @param condition
|
|
|
* @param groupType
|
|
|
* @param teamId
|
|
|
* @param doctorCode
|
|
|
*/
|
|
|
public void initPatients(Set<String> patientSet, String labelType, String condition, String groupType,Long teamId,String doctorCode) {
|
|
|
|
|
|
String adminTeamCodetemp = "";
|
|
|
if(teamId!=null){
|
|
|
adminTeamCodetemp+=teamId.longValue();
|
|
|
}else{
|
|
|
List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
|
|
|
for(AdminTeam one:teamList){
|
|
|
adminTeamCodetemp+=","+one.getId();
|
|
|
}
|
|
|
adminTeamCodetemp=adminTeamCodetemp.length()>0?adminTeamCodetemp.substring(1):"";
|
|
|
}
|
|
|
|
|
|
String[] cond = {};
|
|
|
String[] group = {};
|
|
|
if (!StringUtils.isEmpty(condition)) {
|
|
|
cond = condition.split(",");
|
|
|
}
|
|
|
StringBuilder whereSql = new StringBuilder();
|
|
|
String tableSql = "";
|
|
|
for (String one : cond) {
|
|
|
if ("1".equals(one)) {//有绑定设备
|
|
|
tableSql = " LEFT JOIN wlyy_patient_device d on d.user=aa.patient and d.device_id is not null ";
|
|
|
} else if ("2".equals(one)) {//孕产妇
|
|
|
whereSql.append(" and tt LIKE '%41%' ");
|
|
|
} else if ("3".equals(one)) {//65岁以上老年人
|
|
|
whereSql.append(" and tt LIKE '%13%' ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isEmpty(groupType)) {
|
|
|
group = groupType.split(",");
|
|
|
}
|
|
|
String sql = "";
|
|
|
List<String> groupPatient = null;
|
|
|
List<String> resultList = new ArrayList<>();
|
|
|
switch (labelType) {
|
|
|
case "1": {
|
|
|
for (String one : group) {
|
|
|
sql = " SELECT DISTINCT(aa.patient) FROM " +
|
|
|
" ( SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l, " +
|
|
|
" wlyy_sign_family_server q WHERE w. STATUS > 0 AND l. STATUS = 1 AND w.admin_team_code in (" +adminTeamCodetemp+")"+
|
|
|
" AND w.patient = l.patient " +//AND LEFT (w.hospital, 6) = '350211' " +
|
|
|
" AND w. CODE = q.sign_code AND q.server_type = 1 ) a " +
|
|
|
" GROUP BY a.patient HAVING 1 = 1 " + whereSql + " and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "2": {
|
|
|
for (String one : group) {
|
|
|
sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
// /**
|
|
|
// * 医生推送文章初始化被推患者信息
|
|
|
// * @param patientSet
|
|
|
// * @param labelType
|
|
|
// * @param condition
|
|
|
// * @param groupType
|
|
|
// * @param teamId
|
|
|
// * @param doctorCode
|
|
|
// */
|
|
|
// public void initPatients(Set<String> patientSet, String labelType, String condition, String groupType,Long teamId,String doctorCode) {
|
|
|
//
|
|
|
// String adminTeamCodetemp = "";
|
|
|
// if(teamId!=null){
|
|
|
// adminTeamCodetemp+=teamId.longValue();
|
|
|
// }else{
|
|
|
// List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
|
|
|
// for(AdminTeam one:teamList){
|
|
|
// adminTeamCodetemp+=","+one.getId();
|
|
|
// }
|
|
|
// adminTeamCodetemp=adminTeamCodetemp.length()>0?adminTeamCodetemp.substring(1):"";
|
|
|
// }
|
|
|
//
|
|
|
// String[] cond = {};
|
|
|
// String[] group = {};
|
|
|
// if (!StringUtils.isEmpty(condition)) {
|
|
|
// cond = condition.split(",");
|
|
|
// }
|
|
|
// StringBuilder whereSql = new StringBuilder();
|
|
|
// String tableSql = "";
|
|
|
// for (String one : cond) {
|
|
|
// if ("1".equals(one)) {//有绑定设备
|
|
|
// tableSql = " LEFT JOIN wlyy_patient_device d on d.user=aa.patient and d.device_id is not null ";
|
|
|
// } else if ("2".equals(one)) {//孕产妇
|
|
|
// whereSql.append(" and tt LIKE '%41%' ");
|
|
|
// } else if ("3".equals(one)) {//65岁以上老年人
|
|
|
// whereSql.append(" and tt LIKE '%13%' ");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// if (!StringUtils.isEmpty(groupType)) {
|
|
|
// group = groupType.split(",");
|
|
|
// }
|
|
|
// String sql = "";
|
|
|
// List<String> groupPatient = null;
|
|
|
// List<String> resultList = new ArrayList<>();
|
|
|
// switch (labelType) {
|
|
|
// case "1": {
|
|
|
// for (String one : group) {
|
|
|
// sql = " SELECT DISTINCT(aa.patient) FROM " +
|
|
|
// " ( SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
// " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l, " +
|
|
|
// " wlyy_sign_family_server q WHERE w. STATUS > 0 AND l. STATUS = 1 AND w.admin_team_code in (" +adminTeamCodetemp+")"+
|
|
|
// " AND w.patient = l.patient " +//AND LEFT (w.hospital, 6) = '350211' " +
|
|
|
// " AND w. CODE = q.sign_code AND q.server_type = 1 ) a " +
|
|
|
// " GROUP BY a.patient HAVING 1 = 1 " + whereSql + " and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
|
|
|
// groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
// resultList.addAll(groupPatient);
|
|
|
// }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "3": {
|
|
|
for (String one : group) {
|
|
|
sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
// break;
|
|
|
// }
|
|
|
// case "2": {
|
|
|
// for (String one : group) {
|
|
|
// sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
// " SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
// " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
// " WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
// " GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%' ) aa " + tableSql;
|
|
|
// groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
// resultList.addAll(groupPatient);
|
|
|
//// }
|
|
|
// }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
case "4": {
|
|
|
for (String one : group) {
|
|
|
sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
" SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
" FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
" WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
" GROUP BY a.patient HAVING 1=1 " + whereSql.toString() + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
|
|
|
groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
resultList.addAll(groupPatient);
|
|
|
// break;
|
|
|
// }
|
|
|
// case "3": {
|
|
|
// for (String one : group) {
|
|
|
// sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
// " SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
// " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
// " WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
// " GROUP BY a.patient HAVING 1=1 " + whereSql + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
|
|
|
// groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
// resultList.addAll(groupPatient);
|
|
|
//// }
|
|
|
// }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
patientSet.addAll(resultList);
|
|
|
}
|
|
|
// break;
|
|
|
// }
|
|
|
// case "4": {
|
|
|
// for (String one : group) {
|
|
|
// sql = " select DISTINCT(aa.patient) from ( " +
|
|
|
// " SELECT a.patient, GROUP_CONCAT( concat(a.label_type, a.label) ) tt " +
|
|
|
// " FROM ( SELECT l.* FROM wlyy_sign_family w, wlyy_sign_patient_label_info l " +
|
|
|
// " WHERE w. STATUS > 0 and l.status=1 AND w.admin_team_code in ("+adminTeamCodetemp+") AND w.patient = l.patient ) a " +// AND LEFT (w.hospital, 6) = '350211' ) a " +
|
|
|
// " GROUP BY a.patient HAVING 1=1 " + whereSql.toString() + " and tt LIKE '%" + labelType + one + "%') aa " + tableSql;
|
|
|
// groupPatient = jdbcTemplate.queryForList(sql, String.class);
|
|
|
// resultList.addAll(groupPatient);
|
|
|
//// }
|
|
|
// }
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// patientSet.addAll(resultList);
|
|
|
// }
|
|
|
|
|
|
public JSONArray pushArticleLogs(int page, int pagesize, String patientCode,String level1Type) throws Exception {
|
|
|
|
|
@ -781,7 +814,10 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
String secondLevelCategoryName,String firstLevelCategoryId,String firstLevelCategoryName,String content,String operatorRoleCode,
|
|
|
String opertorRoleLevel,Integer userScope,String articleId) throws Exception {
|
|
|
|
|
|
image = commonUtil.copyTempImage(image);
|
|
|
if(!StringUtils.isEmpty(image)){
|
|
|
|
|
|
image = commonUtil.copyTempImage(image);
|
|
|
}
|
|
|
Integer isAuthentication = 0;
|
|
|
//当管理员具有审核权限时,添加文章不需认证,添加后自动认证,
|
|
|
Doctor doctor = doctorDao.findByCode(userCode);
|
|
@ -810,7 +846,7 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject queryArticlePcList(String firstLevelCategoryId, String secondLevelCategoryId, String insertTimeStart, String insertTimeEnd, String articlelevel, String articleTitle,
|
|
|
String userCode, String currentUserRole, String currentUserRoleLevel, String isAuthentication, Boolean isMyArticle, Integer page, Integer pageSize) throws Exception{
|
|
|
String userCode, String currentUserRole, String currentUserRoleLevel, String isAuthentication, Boolean isMyArticle, Integer page, Integer pageSize,Integer sEcho) throws Exception{
|
|
|
// Doctor doctor = doctorDao.findByCode(userCode);
|
|
|
// boolean isManage = false;
|
|
|
// if(doctor.getLevel()==10){
|
|
@ -820,7 +856,7 @@ public class JMJkEduArticleService extends BaseService {
|
|
|
userCode = null;
|
|
|
}
|
|
|
return thirdJkEduArticleService.queryArticlePcList(firstLevelCategoryId,secondLevelCategoryId,insertTimeStart,insertTimeEnd,articlelevel,
|
|
|
articleTitle,userCode,isAuthentication,currentUserRole,currentUserRoleLevel,page,pageSize);
|
|
|
articleTitle,userCode,isAuthentication,currentUserRole,currentUserRoleLevel,page,pageSize,sEcho);
|
|
|
}
|
|
|
|
|
|
/**
|