Переглянути джерело

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

trick9191 7 роки тому
батько
коміт
4170b5f8f2
13 змінених файлів з 514 додано та 10 видалено
  1. 21 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/WlyyPatientDeviceController.java
  2. 77 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/WlyyPatientDevice.java
  3. 160 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/WlyyPatientDeviceLog.java
  4. 5 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/WlyyPatientDeviceDao.java
  5. 14 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/WlyyPatientDeviceLogDao.java
  6. 26 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyDeviceService.java
  7. 67 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyPatientDeviceLogService.java
  8. 21 1
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  9. 41 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  10. 6 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceDetailService.java
  11. 26 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  12. 25 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  13. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

+ 21 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/WlyyPatientDeviceController.java

@ -5,12 +5,16 @@ import com.yihu.wlyy.device.entity.PatientDeviceExportVO;
import com.yihu.wlyy.device.entity.WlyyPatientDeviceVO;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.WlyyPatientDevice;
import com.yihu.wlyy.repository.WlyyPatientDeviceDao;
import com.yihu.wlyy.service.doctor.DoctorService;
import com.yihu.wlyy.service.manager.device.WlyyDeviceService;
import com.yihu.wlyy.service.manager.device.WlyyPatientDeviceLogService;
import com.yihu.wlyy.service.manager.device.WlyyPatientDeviceService;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -22,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by yww on 2016/12/7.
@ -33,6 +38,14 @@ public class WlyyPatientDeviceController extends BaseController {
    private WlyyPatientDeviceService patientDeviceService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private WlyyDeviceService wlyyDeviceService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyPatientDeviceLogService wlyyPatientDeviceLogService;
    @Autowired
    private WlyyPatientDeviceDao wlyyPatientDeviceDao;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String listPageInit(){
@ -106,7 +119,15 @@ public class WlyyPatientDeviceController extends BaseController {
            if(id == null){
                return write(-1,"id不能为空!");
            }
            WlyyPatientDevice wlyyPatientDevice = wlyyPatientDeviceDao.findOne(id);
            patientDeviceService.delete(id);
            String deviceSn = "";
            if (wlyyPatientDevice!=null){
                deviceSn = wlyyPatientDevice.getDeviceSn();
            }
            //全部解绑后去判断就更新设备表中是否绑定字段.
            wlyyDeviceService.unBindUpdateIsBinding(deviceSn);
            wlyyPatientDeviceLogService.savePatientDeviceLog(wlyyPatientDevice,deviceSn,3,2);
            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);

+ 77 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/WlyyPatientDevice.java

@ -23,6 +23,20 @@ public class WlyyPatientDevice {
    private String userIdcard;
    private Date czrq;
    private String doctor;
    //操作医生姓名
    private String doctorName;
    //代绑人代码(家人)
    private String agent;
    //代绑人姓名
    private String agentName;
    //解绑人
    private String delUser;
    //1-解绑,0-绑定
    private Integer del;
    //设备活动类型
    private String deviceActivityType;
    //上传的协议图片地址
    private String agreementPhoto;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
@ -134,4 +148,67 @@ public class WlyyPatientDevice {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "agent")
    public String getAgent() {
        return agent;
    }
    public void setAgent(String agent) {
        this.agent = agent;
    }
    @Column(name = "agent_name")
    public String getAgentName() {
        return agentName;
    }
    public void setAgentName(String agentName) {
        this.agentName = agentName;
    }
    @Column(name = "del_user")
    public String getDelUser() {
        return delUser;
    }
    public void setDelUser(String delUser) {
        this.delUser = delUser;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "device_activity_type")
    public String getDeviceActivityType() {
        return deviceActivityType;
    }
    public void setDeviceActivityType(String deviceActivityType) {
        this.deviceActivityType = deviceActivityType;
    }
    @Column(name = "agreement_photo")
    public String getAgreementPhoto() {
        return agreementPhoto;
    }
    public void setAgreementPhoto(String agreementPhoto) {
        this.agreementPhoto = agreementPhoto;
    }
}

+ 160 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/WlyyPatientDeviceLog.java

@ -0,0 +1,160 @@
package com.yihu.wlyy.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "wlyy_patient_device_log", schema = "", catalog = "wlyy")
public class WlyyPatientDeviceLog {
    private long id;
    //dm_device表主键
    private long deviceId;
    //患者id
    private String patient;
    //设备sn码
    private String deviceSn;
    //设备名称
    private String deviceName;
    // 设备类型标识
    private String categoryCode;
    //操作人code
    private String operator;
    //操作人姓名
    private String operatorName;
    // 医生或者患者(1医生 2患者)
    private Integer role;
    //操作动作(1绑定 2解绑)
    private Integer operateCode;
    // 创建时间
    private Date createTime;
    //是否有效(0无效1有效)
    private int isDel;
    //上传的协议图片地址
    private String agreementPhoto;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    @Column(name = "device_id")
    public long getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(long deviceId) {
        this.deviceId = deviceId;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name = "device_name")
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    @Column(name = "category_code")
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    @Column(name = "operator")
    public String getOperator() {
        return operator;
    }
    public void setOperator(String operator) {
        this.operator = operator;
    }
    @Column(name = "operator_name")
    public String getOperatorName() {
        return operatorName;
    }
    public void setOperatorName(String operatorName) {
        this.operatorName = operatorName;
    }
    @Column(name = "role")
    public Integer getRole() {
        return role;
    }
    public void setRole(Integer role) {
        this.role = role;
    }
    @Column(name = "operate_code")
    public Integer getOperateCode() {
        return operateCode;
    }
    public void setOperateCode(Integer operateCode) {
        this.operateCode = operateCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "is_del")
    public int getIsDel() {
        return isDel;
    }
    public void setIsDel(int isDel) {
        this.isDel = isDel;
    }
    @Column(name = "agreement_photo")
    public String getAgreementPhoto() {
        return agreementPhoto;
    }
    public void setAgreementPhoto(String agreementPhoto) {
        this.agreementPhoto = agreementPhoto;
    }
    public WlyyPatientDeviceLog() {
    }
}

+ 5 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/WlyyPatientDeviceDao.java

@ -5,10 +5,15 @@ import com.yihu.wlyy.entity.device.PatientHealthStandard;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yww on 2016/12/7.
 */
public interface WlyyPatientDeviceDao extends PagingAndSortingRepository<WlyyPatientDevice,Integer> {
    @Query("select a from PatientHealthStandard a where a.patient = ?1 and a.type = ?2")
    PatientHealthStandard findByPatientType(String patient, int type);
    @Query("select pd from WlyyPatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<WlyyPatientDevice> findByDeviceSn(String deviceSn);
}

+ 14 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/WlyyPatientDeviceLogDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository;
import com.yihu.wlyy.entity.WlyyPatientDeviceLog;
import com.yihu.wlyy.entity.device.PatientHealthStandard;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by zd on 2018/06/21.
 */
public interface WlyyPatientDeviceLogDao extends PagingAndSortingRepository<WlyyPatientDeviceLog,Long> {
    @Query("select a from PatientHealthStandard a where a.patient = ?1 and a.type = ?2")
    PatientHealthStandard findByPatientType(String patient, int type);
}

+ 26 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyDeviceService.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.device.entity.WlyyDevice;
import com.yihu.wlyy.device.repository.DeviceManufacturerDao;
import com.yihu.wlyy.device.repository.WlyyDeviceDao;
import com.yihu.wlyy.entity.DmDevice;
import com.yihu.wlyy.entity.WlyyPatientDevice;
import com.yihu.wlyy.repository.DmDeviceDao;
import com.yihu.wlyy.service.common.excel.ExcelData;
import com.yihu.wlyy.util.ReadExcelUtil;
@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
@ -36,6 +38,8 @@ public class WlyyDeviceService {
    private DeviceManufacturerDao deviceManufacturerDao;
    @Autowired
    private DmDeviceDao dmDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public WlyyDevice findById(Long id){
        return deviceDao.findOne(id);
@ -366,4 +370,26 @@ public class WlyyDeviceService {
        return dataMap;
    }
    /**
     * 全部解绑后设备表更新为未绑定
     * @param deviceSn
     */
    public void unBindUpdateIsBinding(String deviceSn)throws Exception{
        String patientDeviceSql = "select count(*) num from wlyy.wlyy_patient_device pd where pd.device_sn ='"+deviceSn+"' and pd.del=0";
        Map<String,Object> map = jdbcTemplate.queryForMap(patientDeviceSql);
        int num = Integer.valueOf(String.valueOf(map.get("num")));
        String sql = "update device.wlyy_devices dd set dd.is_binding=? where dd.device_code=?";
        if (num==0){
            jdbcTemplate.update(sql,new Object[]{0,deviceSn});
            //deviceDetailDao.updateUnbindAll(0,deviceSn);
        }
        if (num==1){
            jdbcTemplate.update(sql,new Object[]{1,deviceSn});
            //deviceDetailDao.updateUnbindAll(1,deviceSn);
        }
        if (num>1){
            jdbcTemplate.update(sql,new Object[]{2,deviceSn});
            //deviceDetailDao.updateUnbindAll(2,deviceSn);
        }
    }
}

+ 67 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyPatientDeviceLogService.java

@ -0,0 +1,67 @@
package com.yihu.wlyy.service.manager.device;
import com.yihu.wlyy.device.entity.PatientDeviceExportVO;
import com.yihu.wlyy.device.entity.WlyyPatientDeviceVO;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.WlyyPatientDevice;
import com.yihu.wlyy.entity.WlyyPatientDeviceLog;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.WlyyPatientDeviceDao;
import com.yihu.wlyy.repository.WlyyPatientDeviceLogDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by zd on 2018/6/21.
 * 居民设备日志表,wlyy数据库
 */
@Service
public class WlyyPatientDeviceLogService extends BaseJpaService<WlyyPatientDeviceLog,WlyyPatientDeviceLogDao>  {
   @Autowired
   private WlyyPatientDeviceDao wlyyPatientDeviceDao;
   @Autowired
   private WlyyPatientDeviceLogDao wlyyPatientDeviceLogDao;
    /**
     * 绑定和解绑的时候会保存一条数据
     * @param patientDevice
     * @param role
     * @param operateCode
     * @throws Exception
     */
    @Transactional
    public void savePatientDeviceLog(WlyyPatientDevice patientDevice,String deviceSn,int role,int operateCode)throws Exception{
        if (patientDevice==null){
            patientDevice = wlyyPatientDeviceDao.findByDeviceSn(deviceSn).get(0);
        }
        WlyyPatientDeviceLog patientDeviceLog = new WlyyPatientDeviceLog();
        patientDeviceLog.setDeviceId(patientDevice.getDeviceId());
        patientDeviceLog.setPatient(patientDevice.getUser());
        patientDeviceLog.setCategoryCode(patientDevice.getCategoryCode());
        patientDeviceLog.setDeviceName(patientDevice.getDeviceName());
        patientDeviceLog.setDeviceSn(patientDevice.getDeviceSn());
        patientDeviceLog.setRole(role);
        patientDeviceLog.setOperateCode(operateCode);
        //patientDeviceLog.setAgreementPhoto(patientDevice.getAgreementPhoto());
        patientDeviceLog.setOperatorName("admin");
        patientDeviceLog.setOperator("admin");
        patientDeviceLog.setCreateTime(new Date());
        patientDeviceLog.setIsDel(1);
        wlyyPatientDeviceLogDao.save(patientDeviceLog);
    }
}

+ 21 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -1,5 +1,6 @@
package com.yihu.hos.device.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.device.common.configuration.HealthStandardConfig;
import com.yihu.hos.device.common.configuration.SystemConfig;
@ -85,6 +86,8 @@ public class DeviceService extends BaseService{
    private PatientAimBloodPressureDao patientAimBloodPressureDao;
    @Autowired
    private IotDeviceService iotDeviceService;
    @Autowired
    private SystemDictDao systemDictDao;
    private static Logger logger = LoggerFactory.getLogger(DeviceService.class);
    private ObjectMapper objectMapper = new ObjectMapper();
@ -499,7 +502,7 @@ public class DeviceService extends BaseService{
                Patient patient = patientDao.findByCode(patientCode);
                //增加积分
                if (dataUoloadCount>0 && "350205".equals(patient.getTown())){
                if (dataUoloadCount == 0 && "350205".equals(patient.getTown())){
                    String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                    Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
                    if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
@ -531,6 +534,23 @@ public class DeviceService extends BaseService{
                    }
                }
                //增加活跃度
                if (dataUoloadCount == 0){
                    String url1 = systemDictDao.findByDictNameAndCode("HEALTH_BANK_URL","HEALTH_BANK_URL");
                    String url = url1 + "/createActiveRecord";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("originalStatus", "0"));
                    params.add(new BasicNameValuePair("currentStatus","1"));
                    params.add(new BasicNameValuePair("patientId",patient.getCode()));
                    String response = HttpClientUtil.post(url,params,"UTF-8");
                    if (StringUtils.isNotEmpty(response)){
                        com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
                        if (!"200".equals(jsonObject.getString("status"))){
                            logger.info("添加活跃度失败!");
                        }
                    }
                }
                //血糖、血压数据需校验,如果超标,需要发送消息给医生
	            if (1 == deviceType || 2 == deviceType) {
		            verifyHealthIndex(result);

+ 41 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -1743,14 +1743,14 @@ public class PatientInfoService extends BaseService {
        }
    }
    public List<Map<String,Object>> getPatientSignByNameOrIdCard(String keyWord,String deviceSn,String doctorId,int pageNo,int pageSize)throws Exception{
    /*public List<Map<String,Object>> getPatientSignByNameOrIdCard(String keyWord,String deviceSn,String doctorId,int pageNo,int pageSize)throws Exception{
        Doctor doctor = doctorDao.findByCode(doctorId);
        String hospital = doctor.getHospital();
        int start = (pageNo-1)*pageSize;
        List<Map<String,Object>> patientList = new ArrayList<>();
       /* String sql = "SELECT p.code,p.name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex,p.idcard,f.doctor_name" +
       *//* String sql = "SELECT p.code,p.name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex,p.idcard,f.doctor_name" +
                " FROM wlyy_patient p  LEFT JOIN wlyy_sign_family f ON p.code = f.patient" +
                " WHERE f.status = 1 AND p.name LIKE '%"+keyWord+"%' OR p.idcard LIKE '%"+keyWord+"%' and f.hospital = '"+hospital+"'"+" limit ?,?";*/
                " WHERE f.status = 1 AND p.name LIKE '%"+keyWord+"%' OR p.idcard LIKE '%"+keyWord+"%' and f.hospital = '"+hospital+"'"+" limit ?,?";*//*
        String sql ="SELECT f.patient as code,f.name,f.idcard,f.doctor_name FROM wlyy_sign_family f where f.status > 0 AND f.hospital = '"+hospital+"' " ;
        if (StringUtils.isNotEmpty(keyWord)){
            sql +=  "AND f.name LIKE '%"+keyWord+"%' OR f.idcard LIKE '%"+keyWord+"%'";
@ -1758,6 +1758,44 @@ public class PatientInfoService extends BaseService {
        sql += " limit ?,?";
        patientList = jdbcTemplate.queryForList(sql ,new Object[]{start,pageSize});
        String patientDeviceSql = "SELECT user as patientCode FROM wlyy_patient_device WHERE device_sn='"+deviceSn+"'";
        List<Map<String,Object>> patientDeviceList = jdbcTemplate.queryForList(patientDeviceSql);
        for (Map<String,Object> map : patientList){
            map.put("age",IdCardUtil.getAgeForIdcard(String.valueOf(map.get("idcard"))));
            map.put("sex",Constant.getLevelSexName(IdCardUtil.getSexForIdcard_new(String.valueOf(map.get("idcard")))));
            for (Map<String,Object> patientDeviceMap : patientDeviceList){
                if (String.valueOf(map.get("code")).equals(String.valueOf(patientDeviceMap.get("patientCode")))){
                    map.put("del",1);
                }else {
                    map.put("del",0);
                }
            }
        }
        return patientList;
    }*/
    public List<Map<String,Object>> getPatientSignByNameOrIdCard(String keyWord,String deviceSn,int isManage,int level,String area,int pageNo,int pageSize)throws Exception{
        /* String sql = "SELECT p.code,p.name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex,p.idcard,f.doctor_name" +
                " FROM wlyy_patient p  LEFT JOIN wlyy_sign_family f ON p.code = f.patient" +
                " WHERE f.status = 1 AND p.name LIKE '%"+keyWord+"%' OR p.idcard LIKE '%"+keyWord+"%' and f.hospital = '"+hospital+"'"+" limit ?,?";*/
        String sql = "";
        List<Map<String,Object>> patientList = new ArrayList<>();
        if (isManage == 1 && level ==3){
            sql = "SELECT f.patient as code,f.name,f.idcard,f.doctor_name FROM wlyy_sign_family f where f.status >0 and LEFT(f.hospital, 6) = '"+area+"'";
        }
        if (isManage==0 || (isManage==1 && level == 2)) {
            sql = "SELECT f.patient as code,f.name,f.idcard,f.doctor_name FROM wlyy_sign_family f where f.status >0 and f.hospital = '" + area + "' and f.status > 0 ";
        }
        if (!StringUtils.isEmpty(keyWord)){
            sql += " AND f.name LIKE '%"+keyWord+"%' OR f.idcard LIKE '%"+keyWord+"%'";
        }
        sql += " limit ?,?";
        int start = (pageNo-1)*pageSize;
        patientList = jdbcTemplate.queryForList(sql ,new Object[]{start,pageSize});
        //判断是否有绑定过该设备的人
        String patientDeviceSql = "SELECT user as patientCode FROM wlyy_patient_device WHERE device_sn='"+deviceSn+"'";
        List<Map<String,Object>> patientDeviceList = jdbcTemplate.queryForList(patientDeviceSql);
        for (Map<String,Object> map : patientList){

+ 6 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/DeviceDetailService.java

@ -59,7 +59,8 @@ public class DeviceDetailService extends BaseService {
	@Transactional
	public void updateAfterBinding(PatientDevice patientDevice, Date grantTime,boolean isFirst)throws Exception{
		DeviceDetail deviceDetail = deviceDetailDao.findBySn(patientDevice.getDeviceSn());
		List<SignFamily> signFamilyList = signFamilyDao.findSSandJTByIdcard(patientDevice.getUserIdcard());
		SignFamily signFamily = signFamilyDao.findByIdcard(patientDevice.getUserIdcard());
		/*List<SignFamily> signFamilyList = signFamilyDao.findSSandJTByIdcard(patientDevice.getUserIdcard());*/
		long adminTeam=0L;
		String hospital = "";
		String isFirstBind = "";
@ -68,10 +69,10 @@ public class DeviceDetailService extends BaseService {
		if ("2".equals(patientDevice.getUserType())){
			keyType="2";
		}
		if (signFamilyList!=null && signFamilyList.size()>0){
			adminTeam = signFamilyList.get(0).getAdminTeamId();
			hospital = signFamilyList.get(0).getHospital();
			hospitalName = signFamilyList.get(0).getHospitalName();
		if (signFamily!=null){
			adminTeam = signFamily.getAdminTeamId();
			hospital = signFamily.getHospital();
			hospitalName = signFamily.getHospitalName();
		}
		//设备表没有数据则插入一条数据
		if (deviceDetail==null){

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
@ -10,6 +11,7 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -24,12 +26,15 @@ import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -48,6 +53,7 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -91,6 +97,10 @@ public class DoctorDeviceController extends BaseController {
	private PatientDeviceDao patientDeviceDao;
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private SystemDictDao systemDictDao;
	@Autowired
	private HttpClientUtil httpClientUtil;
	@Autowired
	private JmsTemplate jmsTemplate;
@ -165,6 +175,22 @@ public class DoctorDeviceController extends BaseController {
					logger.info("添加积分失败!");
				}
			}
			//活动的活跃度
			if (flag){
				String url1 = systemDictDao.findByDictNameAndCode("HEALTH_BANK_URL","HEALTH_BANK_URL");
				String url = url1 + "/createActiveRecord";
				List<NameValuePair> params = new ArrayList<>();
				params.add(new BasicNameValuePair("originalStatus", "0"));
				params.add(new BasicNameValuePair("currentStatus","1"));
				params.add(new BasicNameValuePair("patientId",patient.getCode()));
				String response = httpClientUtil.post(url,params,"UTF-8");
				if (StringUtils.isNotEmpty(response)){
					JSONObject jsonObject = JSON.parseObject(response);
					if (!"200".equals(jsonObject.getString("status"))){
						logger.info("添加活跃度失败!");
					}
				}
			}
			try {
				String openId = patient.getOpenid();
				String name = patient.getName();

+ 25 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -525,7 +525,7 @@ public class PatientInfoController extends BaseController {
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/getPatientSignByNameOrIdCard",method = RequestMethod.GET)
    /*@RequestMapping(value = "/getPatientSignByNameOrIdCard",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("在绑定设备的时候查找患者(带签约信息)")
    public String getPatientSignByNameOrIdCard(@ApiParam(value = "关键搜索词", name = "keyWord") @RequestParam(value = "keyWord",required = false)String keyWord,
@ -544,5 +544,29 @@ public class PatientInfoController extends BaseController {
            error(e);
            return error( -1, "查询失败!");
        }
    }*/
    @RequestMapping(value = "/getPatientSignByNameOrIdCard",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("在绑定设备的时候查找患者(带签约信息)")
    public String getPatientSignByNameOrIdCard(@ApiParam(value = "关键搜索词", name = "keyWord") @RequestParam(value = "keyWord",required = true,defaultValue = "")String keyWord,
                                               @ApiParam(value = "设备sn码", name = "deviceSn") @RequestParam(value = "deviceSn",required = true)String deviceSn,
                                               @ApiParam(value = "是否为管理员登录(0不是1是)", name = "isManage") @RequestParam(value = "isManage",required = true)String isManage,
                                               @ApiParam(value = "管理员地区权限level(3区  2社区)", name = "level") @RequestParam(value = "level",required = false,defaultValue = "0")String level,
                                               @ApiParam(value = "管理员地区code", name = "area") @RequestParam(value = "area",required = true)String area,
                                               @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page,
                                               @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize){
        if (StringUtils.isBlank(pageSize)) {
            pageSize = "10";
        }
        if (page.equals("0")){
            page = "1";
        }
        try {
            return  write(200,"查找成功!","data",patientInfoService.getPatientSignByNameOrIdCard(keyWord,deviceSn,Integer.valueOf(isManage),Integer.valueOf(level),area,Integer.valueOf(page),Integer.valueOf(pageSize)));
        } catch (Exception e) {
            error(e);
            return error( -1, "查询失败!");
        }
    }
}

+ 25 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.patient.device;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientHealthTime;
@ -8,6 +9,7 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -20,12 +22,15 @@ import com.yihu.wlyy.service.app.health.bank.CreditLogService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -77,6 +82,10 @@ public class PatientDeviceController extends BaseController {
    private MessageDao messageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${yihu.yihu_OpenPlatform_url}")
    private String url;
@ -262,6 +271,22 @@ public class PatientDeviceController extends BaseController {
                    logger.info("添加积分失败!");
                }
            }
            //活动的活跃度
            if (flag){
                String url1 = systemDictDao.findByDictNameAndCode("HEALTH_BANK_URL","HEALTH_BANK_URL");
                String url = url1 + "/createActiveRecord";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("originalStatus", "0"));
                params.add(new BasicNameValuePair("currentStatus","1"));
                params.add(new BasicNameValuePair("patientId",patient.getCode()));
                String response = httpClientUtil.post(url,params,"UTF-8");
                if (StringUtils.isNotEmpty(response)){
                    com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(response);
                    if (!"200".equals(jsonObject.getString("status"))){
                        logger.info("添加活跃度失败!");
                    }
                }
            }
            try {
                String openId = patient.getOpenid();
                String name = patient.getName();