浏览代码

Merge branch 'dev' of lyr/patient-co-management into dev

sand 8 年之前
父节点
当前提交
c9a35c29d2

+ 8 - 0
src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java

@ -61,6 +61,7 @@ public class SignFamily extends IdEntity {
	private String agentDoctorName;//代理簽約人銘
	private String agentDoctorLevel;//代理簽約人等级
	private Long adminTeamId;//行政团队ID
	private Date expensesTime;//缴费时间
	public String getCode() {
		return code;
@ -457,4 +458,11 @@ public class SignFamily extends IdEntity {
				", familyCode='" + familyCode + '\'' +
				'}';
	}
	public Date getExpensesTime() {
		return expensesTime;
	}
	public void setExpensesTime(Date expensesTime) {
		this.expensesTime = expensesTime;
	}
}

+ 49 - 49
src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -24,55 +24,55 @@ public class DoctorInterceptor extends BaseInterceptor {
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		try {
			response.setCharacterEncoding("UTF-8");
			JSONObject json = getAgent(request);
			if (json == null) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			String tokenStr = json.has("token") ? json.getString("token") : "";
			String uid = json.has("uid") ? json.getString("uid") : "";
			String imei = json.has("imei") ? json.getString("imei") : "";
			if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			Token token = SystemData.doctorTokens.get(uid);
			if (token == null) {
				token = tokenDao.findByPatient(uid, 2);
				if (token != null) {
					// 加入缓存
					SystemData.doctorTokens.put(uid, token);
				}
			}
			if (token == null || token.getPlatform() != 2) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				flag = false;
			} else {
				if (token.getTimeout().getTime() < new Date().getTime()) {
					// 登录超时
					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
					flag = false;
				} else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
					// 别处登录
					response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
					flag = false;
				} else {
					// 一天只更新一次
					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
						// 今天未更新,则更新缓存
						token.setCzrq(new Date());
						// 更新内存
						SystemData.doctorTokens.put(uid, token);
						// 更新数据库
						tokenDao.save(token);
					}
				}
			}
//			response.setCharacterEncoding("UTF-8");
//			JSONObject json = getAgent(request);
//			if (json == null) {
//				// 未登录
//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
//				return false;
//			}
//			String tokenStr = json.has("token") ? json.getString("token") : "";
//			String uid = json.has("uid") ? json.getString("uid") : "";
//			String imei = json.has("imei") ? json.getString("imei") : "";
//
//			if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
//				return false;
//			}
//
//			Token token = SystemData.doctorTokens.get(uid);
//			if (token == null) {
//				token = tokenDao.findByPatient(uid, 2);
//				if (token != null) {
//					// 加入缓存
//					SystemData.doctorTokens.put(uid, token);
//				}
//			}
//			if (token == null || token.getPlatform() != 2) {
//				// 未登录
//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
//				flag = false;
//			} else {
//				if (token.getTimeout().getTime() < new Date().getTime()) {
//					// 登录超时
//					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
//					flag = false;
//				} else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
//					// 别处登录
//					response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
//					flag = false;
//				} else {
//					// 一天只更新一次
//					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
//						// 今天未更新,则更新缓存
//						token.setCzrq(new Date());
//						// 更新内存
//						SystemData.doctorTokens.put(uid, token);
//						// 更新数据库
//						tokenDao.save(token);
//					}
//				}
//			}
		} catch (Exception e) {
			e.printStackTrace();
		}

+ 104 - 0
src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java

@ -361,6 +361,110 @@ public class DoctorWorkTimeService extends BaseService {
        return json;
    }
    public JSONObject isFamousDoctorWorking(String doctor) throws Exception{
        JSONObject json = new JSONObject();
        Calendar calendar = Calendar.getInstance();
        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        if (week == 0) {
            week = 7;
        }
        // 医生工作时间设置
        Map<String, Object> result = findDoctorWeekWork(doctor, String.valueOf(week));
        if (result.get("workTime") == null) {
            // 医生未设置时,默认7*24小时工作
            json.put("status", "1");
            json.put("msg", "医生当前接受咨询");
        } else {
            WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime) result.get("workTime");
            if (doctorWorkTime.getReceiveConsult().equals("0")) {
                // 医生设置不接受咨询
                json.put("status", "0");
                json.put("msg", "医生不接受咨询");
            } else {
                if (StringUtils.isEmpty(doctorWorkTime.getMorningBegin()) && StringUtils.isEmpty(doctorWorkTime.getMorningEnd())
                        && StringUtils.isEmpty(doctorWorkTime.getAfternoonBegin()) && StringUtils.isEmpty(doctorWorkTime.getAfternoonEnd())
                        && StringUtils.isEmpty(doctorWorkTime.getNightBegin()) && StringUtils.isEmpty(doctorWorkTime.getNightEnd())) {
                    // 医生未设置工作时间,默认7*24小时工作
                    json.put("status", "1");
                    json.put("msg", "医生当前接受咨询");
                } else {
                    if (result.get("workWeek") != null) {
                        // 当前工作日已设置工作时间
                        int flag = 0;
                        WlyyDoctorWorkTime workTime = (WlyyDoctorWorkTime) result.get("workTime");
                        WlyyDoctorWorkWeek workWeek = (WlyyDoctorWorkWeek) result.get("workWeek");
                        int hour = calendar.get(Calendar.HOUR_OF_DAY);
                        int minute = calendar.get(Calendar.MINUTE);
                        String current = (hour < 10 ? ("0" + hour) : hour) + ":" + (hour < 10 ? ("0" + minute) : minute);
                        // 早上
                        if (workWeek.getMorning().equals("1")) {
                            String currentStart = workTime.getMorningBegin();
                            String currentEnd = workTime.getMorningEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                flag = 1;
                            }
                        }
                        // 下午
                        if (workWeek.getAfternoon().equals("1")) {
                            String currentStart = workTime.getAfternoonBegin();
                            String currentEnd = workTime.getAfternoonEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                flag = 1;
                            }
                        }
                        // 晚上
                        if (workWeek.getNight().equals("1")) {
                            String currentStart = workTime.getNightBegin();
                            String currentEnd = workTime.getNightEnd();
                            if (currentStart.length() == 4) {
                                currentStart = "0" + currentStart;
                            }
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if (current.compareTo(currentStart) >= 0 &&
                                    current.compareTo(currentEnd) < 0) {
                                flag = 1;
                            }
                        }
                        if (flag == 1) {
                            json.put("status", "1");
                            json.put("msg", "医生当前接受咨询");
                        } else {
                            json.put("status", "2");
                            json.put("msg", "医生当前不在工作时间");
                        }
                    } else {
                        json.put("status", "2");
                        json.put("msg", "医生当前不在工作时间");
                    }
                }
            }
        }
        return json;
    }
    /**
     * 查询名医当天是否接受咨询
     *

+ 2 - 2
src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1312,8 +1312,8 @@ public class FamilyContractService extends BaseService {
        }
        // 只查询未处理的消息
        filters.put("type", new SearchFilter("type", Operator.EQ, 1));
        filters.put("over", new SearchFilter("over", Operator.EQ, 1));
        filters.put("read", new SearchFilter("read", Operator.EQ, 1));
//        filters.put("over", new SearchFilter("over", Operator.EQ, 1));
//        filters.put("read", new SearchFilter("read", Operator.EQ, 1));
        Specification<Message> spec = DynamicSpecifications.bySearchFilter(filters.values(), Message.class);
        return messageDao.findAll(spec, pageRequest);
    }

+ 70 - 16
src/main/java/com/yihu/wlyy/service/app/talk/TalkGroupService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.talk;
import java.io.UnsupportedEncodingException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
@ -7,6 +8,10 @@ import java.util.*;
import javax.transaction.Transactional;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +24,7 @@ import com.yihu.wlyy.entity.discussion.WlyyTalkGroupMember;
import com.yihu.wlyy.repository.discussion.DiscussionGroupDao;
import com.yihu.wlyy.repository.discussion.DiscussionGroupMemberDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.util.StringUtils;
@Service
@Transactional
@ -32,6 +38,8 @@ public class TalkGroupService extends BaseService {
            DiscussionGroupMemberDao discussionGroupMemberDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    DoctorDao doctorDao;
    /**
     * 讨论组保存
@ -49,7 +57,7 @@ public class TalkGroupService extends BaseService {
     *
     * @param members
     */
    public void saveMembers(List<WlyyTalkGroupMember> members){
    public void saveMembers(List<WlyyTalkGroupMember> members) {
        discussionGroupMemberDao.save(members);
    }
@ -191,22 +199,22 @@ public class TalkGroupService extends BaseService {
     * @param groups
     * @return
     */
    public List<Map<String,Object>> getTalkGroupsSing(String[] groups){
        String params =  "";
    public List<Map<String, Object>> getTalkGroupsSing(String[] groups) {
        String params = "";
        List<String> paramList = new ArrayList<>();
        for(int i = 0; i < groups.length ; i++){
            params += (i == 0?"?":",?");
        for (int i = 0; i < groups.length; i++) {
            params += (i == 0 ? "?" : ",?");
        }
        paramList.addAll(Arrays.asList(groups));
        paramList.addAll(Arrays.asList(groups));
        String sqlgp = "select group_code,member_code from wlyy_talk_group_member where group_code in (" + params + ") and type = 2";
        String sqlgpm = "select member_code from wlyy_talk_group_member where group_code in (" + params + ") and type = 2";
        String sqlQu = "select * from wlyy_quota_result where qkdoctor_code in (" + sqlgpm+ ") and quato_code = '1' and level1_type = '1'";
        String sqlQuSum = "select a.group_code,sum(ifnull(b.result,0)) sign from ("+ sqlgp +") a left join (" + sqlQu+ ") b on a.member_code = b.qkdoctor_code group by a.group_code ";
        String sqlQu = "select * from wlyy_quota_result where qkdoctor_code in (" + sqlgpm + ") and quato_code = '1' and level1_type = '1'";
        String sqlQuSum = "select a.group_code,sum(ifnull(b.result,0)) sign from (" + sqlgp + ") a left join (" + sqlQu + ") b on a.member_code = b.qkdoctor_code group by a.group_code ";
        return jdbcTemplate.queryForList(sqlQuSum,paramList.toArray());
        return jdbcTemplate.queryForList(sqlQuSum, paramList.toArray());
    }
    /**
@ -225,7 +233,7 @@ public class TalkGroupService extends BaseService {
     * @param groupCode
     * @return
     */
    public WlyyTalkGroup findTalkGroup(String groupCode){
    public WlyyTalkGroup findTalkGroup(String groupCode) {
        return discussionGroupDao.findByCode(groupCode);
    }
@ -279,12 +287,12 @@ public class TalkGroupService extends BaseService {
        List<WlyyTalkGroup> result = new ArrayList<>();
        //查询语句
        String sqlIn = " select tg.* from wlyy_talk_group tg where tg.code in ("
                     + " select tgm.group_code "
                     + " from "
                     + "     (select * from wlyy_talk_group_member where member_code = ?) tgm "
                     + "  inner join "
                     + "     (select * from wlyy_talk_group_member where member_code = ?) tgmm "
                     + "  on tgm.group_code = tgmm.group_code )";
                + " select tgm.group_code "
                + " from "
                + "     (select * from wlyy_talk_group_member where member_code = ?) tgm "
                + "  inner join "
                + "     (select * from wlyy_talk_group_member where member_code = ?) tgmm "
                + "  on tgm.group_code = tgmm.group_code )";
        //查询
        result = jdbcTemplate.query(sqlIn, new Object[]{memberFirst, memberSencond}, new RowMapper<WlyyTalkGroup>() {
            @Override
@ -316,8 +324,54 @@ public class TalkGroupService extends BaseService {
     * @param doctor
     * @return
     */
    public long getDoctorTalkGroupCount(String doctor){
    public long getDoctorTalkGroupCount(String doctor) {
        return discussionGroupMemberDao.countByMemberCode(doctor);
    }
    /**
     * 获取以上一对一聊天
     *
     * @param doctor
     * @return
     */
    public JSONArray getOneToOneIm(String doctor) throws UnsupportedEncodingException {
        JSONArray result = null;
        JSONArray resultArray = new JSONArray();
        String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
                + "statistic/getchatlist.im";
        String json = HttpUtil.sendGet(url, "uid=" + doctor);
        if(!StringUtils.isEmpty(json)) {
            result = new JSONArray(json);
        }
        if (result != null && result.length() > 0) {
            for (int i = 0; i < result.length(); i++) {
                JSONObject obj = result.getJSONObject(i);
                if (obj.getInt("msg_type") == 1) {
                    JSONObject objRe = new JSONObject();
                    Doctor fromDoctor = doctorDao.findByCode(obj.getString("peer_uid"));
                    if(fromDoctor == null){
                        continue;
                    }
                    objRe.put("uid",obj.getString("uid"));
                    objRe.put("fromUid",obj.getString("peer_uid"));
                    objRe.put("fromName",fromDoctor.getName());
                    objRe.put("fromLevel",fromDoctor.getLevel());
                    objRe.put("lastContentType",obj.getInt("last_content_type"));
                    objRe.put("lastContent",new String(obj.getString("last_content").getBytes(),"utf-8"));
                    objRe.put("newMsgCount",obj.getInt("new_msg_count"));
                    objRe.put("lastMsgTime",obj.getLong("timestamp"));
                    resultArray.put(objRe);
                }
            }
        }
        return resultArray;
    }
}

+ 22 - 0
src/main/java/com/yihu/wlyy/web/doctor/discussion/DoctorDiscussionGroupController.java

@ -662,4 +662,26 @@ public class DoctorDiscussionGroupController extends BaseController {
		}
	}
	/**
	 * 获取医生一对一聊天
	 *
	 * @param doctor
	 * @return
	 */
	@RequestMapping(value = "/one_to_one_im")
	@ResponseBody
	public String getOneToOneIm(String doctor){
		try{
			if(org.springframework.util.StringUtils.isEmpty(doctor)){
				doctor = getUID();
			}
			JSONArray result = talkGroupService.getOneToOneIm(doctor);
			return write(200,"查询成功","data",result);
		}catch (Exception e){
			e.printStackTrace();
			return error(-1,"查询失败");
		}
	}
}

+ 3 - 0
src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.patient;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -654,6 +655,8 @@ public class DoctorPatientGroupController extends BaseController {
                    jtJson.put("beginDate",DateUtil.dateToStr(jtSign.getBegin(), DateUtil.YYYY_MM_DD));
                    jtJson.put("endDate",DateUtil.dateToStr(jtSign.getEnd(), DateUtil.YYYY_MM_DD));
                    jtJson.put("expensesType",jtSign.getExpensesType());
                    jtJson.put("expensesStatus",jtSign.getExpensesStatus());
                    jtJson.put("expensesTime",jtSign.getExpensesTime() == null?"":new SimpleDateFormat("yyyy-MM-dd HH:mm").format(jtSign.getExpensesTime()));
                    jtJson.put("jyDate", DateUtil.dateToStr(jtSign.getApplyUnsignDate(), DateUtil.YYYY_MM_DD));
                    jtJson.put("status",jtSign.getStatus());
                    json.put("jtSign",jtJson);

+ 3 - 1
src/main/resources/system.properties

@ -62,7 +62,9 @@ appSecret=2935b54b53a957d9516c920a544f2537
wechat_base_url=http%3a%2f%2fweixin.xmtyw.cn%2fwlyy
wechat_token=27eb3bb24f149a7760cf1bb154b08040
#是否签约检查和签约数据上传
sign_check_upload=http://172.19.103.87:8011
sign_check_upload=http://192.168.131.10:8011
#im一对一列表获取
im_list_get=http://172.19.103.76:3000/
#-------------测试------------#
#server_ip=ehr.yihu.com