浏览代码

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

lyr 8 年之前
父节点
当前提交
c13d6095d5

+ 4 - 3
patient-co-figure/src/main/java/com/yihu/figure/web/HealthIndexController.java

@ -1,6 +1,7 @@
package com.yihu.figure.web;
package com.yihu.figure.controller.health;
import com.yihu.figure.service.HealthIndexService;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.service.health.HealthIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -18,7 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@Controller
@RequestMapping(value = "/health/")
@RequestMapping(value = "/health/")
@Api(description = "自动生成体征数据接口")
@Api(description = "自动生成体征数据接口")
public class HealthIndexController extends BaseController{
public class HealthIndexController extends BaseController {
    @Autowired
    @Autowired
    private HealthIndexService healthIndexService;
    private HealthIndexService healthIndexService;

+ 2 - 2
patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexDao.java

@ -3,9 +3,9 @@
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
 *******************************************************************************/
package com.yihu.figure.dao;
package com.yihu.figure.dao.health;
import com.yihu.figure.model.HealthIndex;
import com.yihu.figure.model.health.HealthIndex;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 2 - 2
patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexStatisticsDao.java

@ -1,6 +1,6 @@
package com.yihu.figure.dao;
package com.yihu.figure.dao.health;
import com.yihu.figure.model.HealthIndexStatistics;
import com.yihu.figure.model.health.HealthIndexStatistics;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
/**

+ 2 - 1
patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndex.java

@ -1,6 +1,7 @@
package com.yihu.figure.model;
package com.yihu.figure.model.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;

+ 2 - 1
patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndexStatistics.java

@ -1,6 +1,7 @@
package com.yihu.figure.model;
package com.yihu.figure.model.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.figure.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;

+ 6 - 5
patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexService.java

@ -1,9 +1,10 @@
package com.yihu.figure.service;
package com.yihu.figure.service.health;
import com.yihu.figure.dao.HealthIndexDao;
import com.yihu.figure.dao.HealthIndexStatisticsDao;
import com.yihu.figure.model.HealthIndex;
import com.yihu.figure.model.HealthIndexStatistics;
import com.yihu.figure.dao.health.HealthIndexDao;
import com.yihu.figure.dao.health.HealthIndexStatisticsDao;
import com.yihu.figure.model.health.HealthIndex;
import com.yihu.figure.model.health.HealthIndexStatistics;
import com.yihu.figure.service.BaseService;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.ETLConstantData;
import com.yihu.figure.util.ETLConstantData;
import com.yihu.figure.util.IdCardUtil;
import com.yihu.figure.util.IdCardUtil;

+ 2 - 1
patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexStatisticsService.java

@ -1,5 +1,6 @@
package com.yihu.figure.service;
package com.yihu.figure.service.health;
import com.yihu.figure.service.BaseService;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import javax.transaction.Transactional;

+ 0 - 511
patient-co-figure/src/main/java/com/yihu/figure/web/BaseController.java

@ -1,511 +0,0 @@
package com.yihu.figure.web;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.figure.model.IdEntity;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ReflectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.*;
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger(BaseController.class);
    @Autowired
    protected HttpServletRequest request;
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 獲取髮送請求用戶的uid
     *
     * @return
     */
    public String getLastUid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("lastUid");
        } catch (Exception e) {
            return null;
        }
    }
    public String getOpenid() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("openid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取用户ID
     *
     * @return
     */
    public long getId() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getLong("id");
        } catch (Exception e) {
            return 0;
        }
    }
    public String getIMEI() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("imei");
        } catch (Exception e) {
            return null;
        }
    }
    public String getToken() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("token");
        } catch (Exception e) {
            return null;
        }
    }
    public void error(Exception e) {
        logger.error(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void warn(Exception e) {
        logger.warn(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void infoMessage(String message) {
        logger.info(message);
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 接口处理成功
     *
     * @param msg
     * @return
     */
    public String success(String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONObject value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param total 总数
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, int total, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put("total", total);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Page<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            // 是否为第一页
            map.put("isFirst", list.isFirst());
            // 是否为最后一页
            map.put("isLast", list.isLast());
            // 总条数
            map.put("total", list.getTotalElements());
            // 总页数
            map.put("totalPages", list.getTotalPages());
            map.put(key, list.getContent());
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", page == null ? false : page.isFirst());
            // 是否为最后一页
            json.put("isLast", page == null ? true : page.isLast());
            // 总条数
            json.put("total", page == null ? 0 : page.getTotalElements());
            // 总页数
            json.put("totalPages", page == null ? 0 : page.getTotalPages());
            json.put(key, array);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Map<?, ?> value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, String value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, String key, IdEntity entity) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, entity);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param key 结果数据
     * @return
     */
    public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", isFirst);
            // 是否为最后一页
            json.put("isLast", isLast);
            // 总条数
            json.put("total", total);
            // 总页数
            json.put("totalPages", totalPages);
            json.put(key, values);
            return json.toString();
        } catch (Exception e) {
            logger.error("BaseController:", e.getMessage());
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public String trimEnd(String param, String trimChars) {
        if (param.endsWith(trimChars)) {
            param = param.substring(0, param.length() - trimChars.length());
        }
        return param;
    }
    /**
     * 无效用户消息返回
     *
     * @param e
     * @param defaultCode
     * @param defaultMsg
     * @return
     */
    public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
        try {
            // if (e instanceof UndeclaredThrowableException) {
            // UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
            // InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
            // if (iue != null) {
            // return error(iue.getCode(), iue.getMsg());
            // }
            // }
            return error(defaultCode, defaultMsg);
        } catch (Exception e2) {
            return null;
        }
    }
    public List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String... propertyNames) {
        List<Map<String, Object>> result = new ArrayList<>();
        for (Object bean : beans) {
            result.add(copyBeanProperties(bean, propertyNames));
        }
        return result;
    }
    /**
     * 复制特定属性。
     *
     * @param bean
     * @param propertyNames
     * @return
     */
    public Map<String, Object> copyBeanProperties(Object bean, String... propertyNames) {
        Map<String, Object> simplifiedBean = new HashMap<>();
        for (String propertyName : propertyNames) {
            Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
            if (field != null) {
                field.setAccessible(true);
                Object value = ReflectionUtils.getField(field, bean);
                simplifiedBean.put(propertyName, value == null ? "" : value);
            } else {
                simplifiedBean.put(propertyName, "");
            }
        }
        return simplifiedBean;
    }
}

+ 8 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -42,9 +42,9 @@ public class PatientReservation extends IdEntity {
	// 预约时间段:AM (上午)或者PM (下午)
	// 预约时间段:AM (上午)或者PM (下午)
	private String sectionType;
	private String sectionType;
	// 一次预约段的开始时间
	// 一次预约段的开始时间
	private String startTime;
	private Date startTime;
	// 一次预约段的结束时间
	// 一次预约段的结束时间
	private String endTime;
	private Date endTime;
	// 医生所在医疗机构编码
	// 医生所在医疗机构编码
	private String orgCode;
	private String orgCode;
	// 医疗机构名称
	// 医疗机构名称
@ -154,20 +154,22 @@ public class PatientReservation extends IdEntity {
	}
	}
	@Column(name = "start_time")
	@Column(name = "start_time")
	public String getStartTime() {
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getStartTime() {
		return startTime;
		return startTime;
	}
	}
	public void setStartTime(String startTime) {
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
		this.startTime = startTime;
	}
	}
	@Column(name = "end_time")
	@Column(name = "end_time")
	public String getEndTime() {
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEndTime() {
		return endTime;
		return endTime;
	}
	}
	public void setEndTime(String endTime) {
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
		this.endTime = endTime;
	}
	}

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java

@ -35,6 +35,6 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	PatientReservation findByPatientAndCancelerAndCancelTime(String patient,String canceler,String cancelerTime);
	PatientReservation findByPatientAndCancelerAndCancelTime(String patient,String canceler,String cancelerTime);
	//根据患者医获取近三个月的已取消的预约记录
	//根据患者医获取近三个月的已取消的预约记录
	@Query("select a from PatientReservation a where a.patient = ?1 and (a.startTime between ?2 and ?3 or a.startTime between ?4 and ?5 ) and a.status = 0 order by a.startTime desc")
	List<PatientReservation> findByPatientAndStartTime(String patientCode, String strStart, String strEnd,String startTime,String endTime);
	@Query("select a from PatientReservation a where a.patient = ?1 and a.startTime between ?2 and ?3 and a.status = 0 order by a.startTime desc")
	List<PatientReservation> findByPatientAndStartTime(String patientCode,Date startTime,Date endTime);
}
}

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

@ -4,7 +4,6 @@ import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
@ -68,65 +67,67 @@ public class PatientDeviceService extends BaseService {
	 * 保存患者设备
	 * 保存患者设备
	 */
	 */
	public boolean saveDevice(PatientDevice patientDevice) throws Exception {
	public boolean saveDevice(PatientDevice patientDevice) throws Exception {
		//判断sn码是否被使用
		String sn = patientDevice.getDeviceSn();
		String type =  patientDevice.getCategoryCode();
		Long deviceId =  patientDevice.getDeviceId();
		String userType = patientDevice.getUserType();
		if(userType == null)
		{
			userType = "-1";
			patientDevice.setUserType("-1");
		}
		synchronized (patientDevice.getDeviceSn()){
			//判断sn码是否被使用
			String sn = patientDevice.getDeviceSn();
			String type =  patientDevice.getCategoryCode();
			Long deviceId =  patientDevice.getDeviceId();
			String userType = patientDevice.getUserType();
			if(userType == null)
			{
				userType = "-1";
				patientDevice.setUserType("-1");
			}
		boolean needVerify = true;
		//修改操作
		if(patientDevice.getId()!=null)
		{
			PatientDevice deviceOld =  patientDeviceDao.findOne(patientDevice.getId());
			if(deviceOld!=null)
			boolean needVerify = true;
			//修改操作
			if(patientDevice.getId()!=null)
			{
			{
				if(deviceOld.getDeviceSn().equals(sn))
				PatientDevice deviceOld =  patientDeviceDao.findOne(patientDevice.getId());
				if(deviceOld!=null)
				{
				{
					needVerify = false;
					if(deviceOld.getDeviceSn().equals(sn))
					{
						needVerify = false;
					}
				}
				else{
					throw new Exception("不存在该条记录!");
				}
				}
			}
			}
			else{
				throw new Exception("不存在该条记录!");
			}
		}
		//校验sn码是否被使用
		if(needVerify) {
			PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserTypeAndDel(deviceId, sn, userType,0);
			if (device != null && !device.getId().equals(patientDevice.getId())) {
				throw new Exception("sn码" + sn + "已被使用!");
			//校验sn码是否被使用
			if(needVerify) {
				PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserTypeAndDel(deviceId, sn, userType,0);
				if (device != null && !device.getId().equals(patientDevice.getId())) {
					throw new Exception("sn码" + sn + "已被使用!");
				}
			}
			patientDevice.setCzrq(clock.getCurrentDate());
			//当前用户的身份证
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			patientDevice.setUserIdcard(patient.getIdcard());
			//注册设备
			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);
			}
			}
		}
		patientDevice.setCzrq(clock.getCurrentDate());
		//当前用户的身份证
		Patient patient = patientDao.findByCode(patientDevice.getUser());
		patientDevice.setUserIdcard(patient.getIdcard());
		//注册设备
		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 true;
	}
	}
	/**
	/**

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -179,7 +179,7 @@ public class PatientReservationService extends BaseService {
            reservation.setPhone(phone);
            reservation.setPhone(phone);
            reservation.setSectionType(section_type);
            reservation.setSectionType(section_type);
            reservation.setSsc(ssc);
            reservation.setSsc(ssc);
            reservation.setStartTime(start_time);
            reservation.setStartTime(DateUtil.strToDate(start_time,DateUtil.YYYY_M_D_HH_MM_SS));
            reservation.setStatus(1);
            reservation.setStatus(1);
            // 保存记录
            // 保存记录
            PatientReservation temp = patientReservationDao.save(reservation);
            PatientReservation temp = patientReservationDao.save(reservation);

+ 16 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -100,8 +100,8 @@ public class GuahaoXMService implements IGuahaoService {
        reservation.setPhone(patientPhone);
        reservation.setPhone(patientPhone);
        reservation.setSectionType(sectionType);
        reservation.setSectionType(sectionType);
        reservation.setSsc(clinicCard);
        reservation.setSsc(clinicCard);
        reservation.setStartTime(startTime);
        reservation.setEndTime(endTime);
        reservation.setStartTime(DateUtil.strToDate(startTime,DateUtil.YYYY_M_D_HH_MM_SS));
        reservation.setEndTime(DateUtil.strToDate(endTime,DateUtil.YYYY_M_D_HH_MM_SS));
        reservation.setStatus(1);
        reservation.setStatus(1);
        if (StringUtils.isNotEmpty(dcode)) {
        if (StringUtils.isNotEmpty(dcode)) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
@ -868,7 +868,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
    /**
     * 根据患者医保卡获取近三个月的预约记录
     * 根据患者医保卡获取近三个月的预约记录
     */
     */
    public List<PatientReservation> GetRegList(String patientCode, String strStart, String strEnd,String strStartTime,String strEndTime) throws Exception {
    public List<PatientReservation> GetRegList(String patientCode, String strStart, String strEnd,Date strStartTime,Date strEndTime) throws Exception {
        Patient patient = patientService.findByCode(patientCode);
        Patient patient = patientService.findByCode(patientCode);
        if (patient == null) {
        if (patient == null) {
            throw new Exception("不存在该用户!");
            throw new Exception("不存在该用户!");
@ -947,8 +947,8 @@ public class GuahaoXMService implements IGuahaoService {
                patientReservation.setDeptName(dept);
                patientReservation.setDeptName(dept);
                patientReservation.setDoctorCode(DoctorCode);
                patientReservation.setDoctorCode(DoctorCode);
                patientReservation.setDoctorName(doctor);
                patientReservation.setDoctorName(doctor);
                patientReservation.setStartTime(regBegin);
                patientReservation.setEndTime(regEnd);
                patientReservation.setStartTime(DateUtil.strToDate(regBegin,DateUtil.YYYY_M_D_HH_MM_SS));
                patientReservation.setEndTime(DateUtil.strToDate(regEnd,DateUtil.YYYY_M_D_HH_MM_SS));
                patientReservation.setOrgCode(OrgCode);
                patientReservation.setOrgCode(OrgCode);
                patientReservation.setOrgName(org);
                patientReservation.setOrgName(org);
                patientReservation.setType("1");
                patientReservation.setType("1");
@ -982,9 +982,17 @@ public class GuahaoXMService implements IGuahaoService {
        }
        }
        //根据患者医保卡获取近三个月的已取消的预约记录
        //根据患者医保卡获取近三个月的已取消的预约记录
        List<PatientReservation> list = patientReservationDao.findByPatientAndStartTime(patientCode,strStart,strEnd,strStartTime,strEndTime);
        List<PatientReservation> list = patientReservationDao.findByPatientAndStartTime(patientCode,strStartTime,strEndTime);
        if(list.size()>0){
        if(list.size()>0){
            patientRegList.addAll(list);
            patientRegList.addAll(list);
            patientRegList.sort(new Comparator<PatientReservation>() {
                public int compare(PatientReservation o1, PatientReservation o2) {
                    Date startTime1 = o1.getStartTime();
                    Date startTime2 = o2.getStartTime();
                    return startTime2.compareTo(startTime1);
                }
            });
        }
        }
        //保存http日志
        //保存http日志
@ -1072,8 +1080,8 @@ public class GuahaoXMService implements IGuahaoService {
            patientReservation.setDeptName(dept);
            patientReservation.setDeptName(dept);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorName(doctor);
            patientReservation.setDoctorName(doctor);
            patientReservation.setStartTime(regBegin);
            patientReservation.setEndTime(regEnd);
            patientReservation.setStartTime(DateUtil.strToDate(regBegin,DateUtil.YYYY_M_D_HH_MM_SS));
            patientReservation.setEndTime(DateUtil.strToDate(regEnd,DateUtil.YYYY_M_D_HH_MM_SS));
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgName(org);
            patientReservation.setOrgName(org);
            patientReservation.setType("1");
            patientReservation.setType("1");

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -23,6 +23,8 @@ public class DateUtil {
	public static final String YYYY_MM_DD_HH = "yyyy-MM-dd HH";
	public static final String YYYY_MM_DD_HH = "yyyy-MM-dd HH";
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_M_D_HH_MM_SS = "yyyy/M/d HH:mm:ss";
	/**
	/**
	 * 字符串转时间格式
	 * 字符串转时间格式

+ 1 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -574,11 +574,10 @@ public class BookingController extends WeixinBaseController {
                             @RequestParam(value = "patient", required = false) String patient) {
                             @RequestParam(value = "patient", required = false) String patient) {
        try {
        try {
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sm2 = new SimpleDateFormat("yyyy/M/d");
            Date nowDate = new Date();
            Date nowDate = new Date();
            Date oneMonthAfter = getMonthBefore(nowDate, -1);
            Date oneMonthAfter = getMonthBefore(nowDate, -1);
            Date threeMonthBefore = getMonthBefore(nowDate, 3);        //三个月历史记录
            Date threeMonthBefore = getMonthBefore(nowDate, 3);        //三个月历史记录
            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), sm2.format(threeMonthBefore), sm2.format(oneMonthAfter));
            List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), threeMonthBefore, oneMonthAfter);
            return write(200, "获取患者预约信息列表成功!", "data", list);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
        } catch (Exception e) {
            return error(-1, e.getMessage());
            return error(-1, e.getMessage());