Explorar o código

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

lyr %!s(int64=8) %!d(string=hai) anos
pai
achega
19dbc65275

+ 53 - 53
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -23,59 +23,59 @@ public class DoctorInterceptor extends BaseInterceptor {
	@Override
	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);
//					}
//				}
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
		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);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}

+ 30 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/record/HospitalizationService.java

@ -1,7 +1,36 @@
package com.yihu.wlyy.service.app.record;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by zhenglingfeng on 2016/10/17.
 */
public class HospitalizationService {
@Service
public class HospitalizationService extends BaseService {
    /**
     * 获取健康档案信息
     */
    public String getHospitalizationRecord(String strSSID, String startDate, String endDate, String startNum, String endNum) throws Exception {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
        url = url + "/third/smjk/InpatientRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("startDate", startDate));
        params.add(new BasicNameValuePair("endDate", endDate));
        params.add(new BasicNameValuePair("startNum", startNum));
        params.add(new BasicNameValuePair("endNum", endNum));
        String result = HttpClientUtil.post(url, params, "UTF-8");
        return result;
    }
}

+ 28 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/record/OutpatientService.java

@ -1,7 +1,34 @@
package com.yihu.wlyy.service.app.record;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by zhenglingfeng on 2016/10/17.
 */
public class OutpatientService {
@Service
public class OutpatientService extends BaseService {
    public String getOutpatientRecord(String strSSID, String startDate, String endDate, String startNum, String endNum) {
        String url = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
        url = url + "/third/smjk/OutpatientRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        params.add(new BasicNameValuePair("startDate", startDate));
        params.add(new BasicNameValuePair("endDate", endDate));
        params.add(new BasicNameValuePair("startNum", startNum));
        params.add(new BasicNameValuePair("endNum", endNum));
        String result = HttpClientUtil.post(url, params, "UTF-8");
        return result;
    }
}

+ 48 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/record/HospitalizationController.java

@ -1,7 +1,54 @@
package com.yihu.wlyy.web.doctor.record;
import com.yihu.wlyy.service.app.record.HospitalizationService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by zhenglingfeng on 2016/10/17.
 */
public class HospitalizationController {
@Controller
@RequestMapping(value = "/doctor/record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-健康档案住院记录")
public class HospitalizationController extends BaseController {
    @Autowired
    private HospitalizationService hospitalizationService;
    /**
     * 获取门/急诊数据
     *
     * @return
     */
    @RequestMapping(value = "/hospitalization", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取住院记录")
    public String getHospitalizationRecord(@ApiParam(name="strSSID",value="健康卡号",defaultValue = "D56668987")
                                     @RequestParam(value="strSSID",required = true) String strSSID,
                                     @ApiParam(name="startDate",value="查询的开始日期",defaultValue = "2015-01-01")
                                     @RequestParam(value="startDate",required = true) String startDate,
                                     @ApiParam(name="endDate",value="查询的结束日期",defaultValue = "2016-10-01")
                                     @RequestParam(value="endDate",required = true) String endDate,
                                     @ApiParam(name="startNum",value="需要获取的起始行数",defaultValue = "0")
                                     @RequestParam(value="startNum",required = true) String startNum,
                                     @ApiParam(name="endNum",value="需要获取的结束的行数",defaultValue = "10")
                                     @RequestParam(value="endNum",required = true) String endNum) {
        try {
            String data = hospitalizationService.getHospitalizationRecord(strSSID, startDate, endDate, startNum, endNum);
            return write(200, "获取住院记录成功!", "data", data);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取住院记录成功!");
        }
    }
}

+ 48 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/record/OutpatientController.java

@ -1,7 +1,54 @@
package com.yihu.wlyy.web.doctor.record;
import com.yihu.wlyy.service.app.record.OutpatientService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * Created by zhenglingfeng on 2016/10/17.
 */
public class OutpatientController {
@Controller
@RequestMapping(value = "/doctor/record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-健康档案门/急诊记录")
public class OutpatientController extends BaseController {
    @Autowired
    private OutpatientService outpatientService;
    /**
     * 获取门/急诊数据
     *
     * @return
     */
    @ApiOperation("获取门/急诊数据")
    @RequestMapping(value = "/outpatient", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getOutpatientRecord(
                    @ApiParam(name="strSSID", value="健康卡号")
                    @RequestParam(value = "strSSID") String strSSID,
                    @ApiParam(name="startDate", value="查询的开始日期")
                    @RequestParam(value = "startDate") String startDate,
                    @ApiParam(name="endDate", value="查询的结束日期")
                    @RequestParam(value = "endDate") String endDate,
                    @ApiParam(name="startNum", value="需要获取的起始行数")
                    @RequestParam(value = "startNum") String startNum,
                    @ApiParam(name="endNum", value="需要获取的结束的行数")
                    @RequestParam(value = "endNum") String endNum) {
        try {
            String result = outpatientService.getOutpatientRecord(strSSID,
                    startDate, endDate, startNum, endNum);
            return write(200, "获取门/急诊数据成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取门/急诊数据失败!");
        }
    }
}