Browse Source

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

lyr 8 years ago
parent
commit
b902ea4596

+ 76 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -1,21 +1,20 @@
package com.yihu.wlyy.service.app.device;
import java.util.*;
import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -29,9 +28,7 @@ import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.service.BaseService;
import java.util.*;
@Component
@Transactional(rollbackFor = Exception.class)
@ -54,6 +51,12 @@ public class PatientDeviceService extends BaseService {
	@Autowired
	private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
	private String url = SystemConf.getInstance().getYihuOpenPlatformUrl();
	private String appid = SystemConf.getInstance().getYihuOpenPlatformAppId();
	private String secret = SystemConf.getInstance().getYihuOpenPlatformSecret();
	private String registerDevice = "DeviceGateway/DeviceApi/registerDevice";//注册设备
	/**
	 * 保存患者设备
@ -98,11 +101,73 @@ public class PatientDeviceService extends BaseService {
		//当前用户的身份证
		Patient patient = patientDao.findByCode(patientDevice.getUser());
		patientDevice.setUserIdcard(patient.getIdcard());
		patientDeviceDao.save(patientDevice);
		//注册设备
		Map<String, String> params = new HashMap<>();
		params.put("deviceSn", sn);
		//调用服务
		String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
		System.out.println("注册设备="+response);
		JSONObject json = new JSONObject(response);
		String code = json.get("Code").toString();
		//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
		if("10000".equals(code)||"10001".equals(code))
		{
			patientDeviceDao.save(patientDevice);
		}else{
			String message = json.get("Message").toString();
			throw new Exception(message);
		}
		return true;
	}
	/**
	 * 注册设备
	 * @return
	 * @throws Exception
     */
	public String registerSnInit() throws Exception{
		String re = "";
		Iterable<PatientDevice> iterable = patientDeviceDao.findAll();
		if(iterable!=null){
			for (PatientDevice patientDevice:iterable){
				String deviceSn = patientDevice.getDeviceSn();
				Map<String, String> params = new HashMap<>();
				params.put("deviceSn", deviceSn);
				String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
				System.out.println("注册设备="+response);
				JSONObject json = new JSONObject(response);
				String code = json.get("Code").toString();
				//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
				if("10000".equals(code)||"10001".equals(code))
				{
				}else{
					String message = json.get("Message").toString();
					re+= deviceSn + message +";";
				}
			}
		}
		return re;
	}
	/**
	 * 单个注册
	 * @param deviceSn
	 * @return
	 * @throws Exception
     */
	public String registerSn(String deviceSn) throws Exception{
		Map<String, String> params = new HashMap<>();
		params.put("deviceSn", deviceSn);
		String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
		return response;
	}
	/**
	 * 删除患者设备
	 */

+ 2 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -144,25 +144,18 @@ public class FollowUpService extends BaseService {
        List<Followup> list = followupDao.findByDoctor(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime));
        if (list != null && list.size() > 0) {
            for (Followup followup : list) {
                String status = followup.getStatus();
                String date = DateUtil.dateToStrShort(followup.getFollowupDate());
                Map<String, String> map = getFollowupDetail(followup);
                if(temp.containsKey(date)){
                    Map<String, Object> vo = temp.get(date);
                    if(!"1".equals(status)){
                        vo.put("num",Integer.parseInt(vo.get("num").toString())+1);
                    }
                    vo.put("num",Integer.parseInt(vo.get("num").toString())+1);
                    ((List<Map<String, String>>)vo.get("list")).add(map);
                    temp.put(date,vo);
                }else{
                    Map<String, Object> vo = new HashMap<>();
                    List<Map<String, String>> list1 = new ArrayList<>();
                    vo.put("date",date);
                    if(!"1".equals(status)){
                        vo.put("num",1);//未完成数量
                    }else{
                        vo.put("num",0);
                    }
                    vo.put("num",1);
                    list1.add(map);
                    vo.put("list",list1);
                    temp.put(date,vo);

+ 33 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -9,7 +9,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -113,6 +112,39 @@ public class DoctorDeviceController extends BaseController {
		}
	}
	/**
	 * 批量注册接口(2.17号正式发布初始化一次没问题后可以删除)
	 * @return
     */
	@ApiOperation("批量注册接口")
	@RequestMapping(value = "registerSnInit",method = RequestMethod.GET)
	@ResponseBody
	public String registerSnInit(){
		try{
			String re = patientDeviceService.registerSnInit();
			if("".equals(re)){
				return  write(200,"批量注册成功");
			}
			return error(-1, re);
		}catch (Exception e){
			return error(-1,e.getMessage());
		}
	}
	@ApiOperation("单个注册接口")
	@RequestMapping(value = "registerSn",method = RequestMethod.GET)
	@ResponseBody
	public String registerSn(@ApiParam(name="deviceSn",value="设备SN码",defaultValue = "15L000002")
							@RequestParam(value="deviceSn",required = true) String deviceSn){
		try{
			String re = patientDeviceService.registerSn(deviceSn);
			return write(200,re);
		}catch (Exception e){
			return error(-1,e.getMessage());
		}
	}
	@ApiOperation("通过sn码获取设备绑定情况")
	@RequestMapping(value = "PatientDeviceIdcard",method = RequestMethod.GET)

+ 6 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -1,9 +1,9 @@
package com.yihu.wlyy.web.patient.device;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -16,9 +16,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.web.BaseController;
import java.util.List;
import java.util.Map;
/**
 * 患者端:设备管理控制类
@ -41,7 +40,7 @@ public class PatientDeviceController extends BaseController {
	@ApiOperation("设备保存接口")
	@RequestMapping(value = "SavePatientDevice",method = RequestMethod.POST)
	@ResponseBody
	public String saveDevice(@ApiParam(name="json",value="设备数据json",defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"16C000337\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
	public String saveDevice(@ApiParam(name="json",value="设备数据json",defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
							  @RequestParam(value="json",required = true) String json) {
		try {
			PatientDevice device = objectMapper.readValue(json,PatientDevice.class);