فهرست منبع

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

trick9191 8 سال پیش
والد
کامیت
3973ea92af
19فایلهای تغییر یافته به همراه639 افزوده شده و 225 حذف شده
  1. 13 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientDevice.java
  2. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientFamilyTemp.java
  3. 8 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyMemberDao.java
  4. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyTempDao.java
  5. 85 31
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  6. 163 33
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  7. 140 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  8. 73 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  9. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java
  10. 24 50
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  11. 21 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java
  12. 15 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  13. 20 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  14. 6 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  15. 13 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  16. 24 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  17. 13 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  18. 8 49
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  19. 8 11
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

+ 13 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientDevice.java

@ -1,13 +1,12 @@
package com.yihu.wlyy.entity.device;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import java.util.Date;
@Entity
@Table(name = "wlyy_patient_device")
@ -29,6 +28,7 @@ public class PatientDevice extends IdEntity {
	private String userIdcard;
	// 操作医生代码
	private String doctor;
	private String agent;//代绑人代码(家人)
	// 操作时间
	private Date czrq;
	///**
@ -140,4 +140,13 @@ public class PatientDevice extends IdEntity {
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	@Column(name="agent")
	public String getAgent() {
		return agent;
	}
	public void setAgent(String agent) {
		this.agent = agent;
	}
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientFamilyTemp.java

@ -26,7 +26,7 @@ public class PatientFamilyTemp extends IdEntity {
    //添加时间
    private Date czrq;
    //状态标识
    // 0 :未处理;1:已同意;2:已拒绝
    // 0 :未处理;1:已同意;2:已拒绝;3:已撤销
    private String state;
    //更新时间
    private Date updateTime;

+ 8 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyMemberDao.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -40,4 +39,12 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<Patie
     * @return
     */
    List<PatientFamilyMember> findByPatient(String patient);
    /**
     *
     * @param familyMember
     * @param isAuthorize
     * @return
     */
    List<PatientFamilyMember> findByFamilyMemberAndIsAuthorize(String familyMember,Integer isAuthorize);
}

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

@ -1,6 +1,5 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.PatientFamilyTemp;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -13,4 +12,6 @@ import java.util.List;
public interface PatientFamilyTempDao extends PagingAndSortingRepository<PatientFamilyTemp, Long>,
        JpaSpecificationExecutor<PatientFamilyTemp> {
    public List<PatientFamilyTemp> findByDealerAndPatient(String dealer,String patient);
    public List<PatientFamilyTemp> findByPatientAndState(String patient,String state);
}

+ 85 - 31
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -91,7 +91,7 @@ public class FamilyMemberService extends BaseService {
            return -2;
        }
        if (relation < 5) {
        if (relation>0&&relation < 5) {//家庭关系为父亲、母亲、老公、老婆时只能有一个
            List<PatientFamilyMember> familyMembers = memberDao.findByPatientAndFamilyRelation(patient, relation);
            if (familyMembers != null && familyMembers.size() > 0) {
@ -355,6 +355,25 @@ public class FamilyMemberService extends BaseService {
        return obj;
    }
    /**
     * 撤销添加家人
     * @param id
     * @return
     */
    public int revokeAddMember(Long id){
        PatientFamilyTemp temp = patientFamilyTempDao.findOne(id);
        if("1".equals(temp.getState())){
            return 1;
        }else if("2".equals(temp.getState())){
            return 2;
        }else if("3".equals(temp.getState())){
            return 3;
        }else if("0".equals(temp.getState())){
            temp.setState("3");
            patientFamilyTempDao.save(temp);
        }
        return 200;
    }
    /**
     * 获取所有家庭成员,包括自己
@ -479,10 +498,12 @@ public class FamilyMemberService extends BaseService {
                    }
                }
                Integer isAuthorize = (Integer)map.get("is_authorize");
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
@ -497,6 +518,19 @@ public class FamilyMemberService extends BaseService {
                    obj.put("addressName", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                    obj.put("status", status);
                    obj.put("source", 1);
                    if (isAuthorize==1){
                        PatientFamilyMember familyMember = memberDao.findByPatientAndFamilyMember(String.valueOf(map.get("family_member")),patient);
                        if(familyMember.getIsAuthorize()==1){
                            obj.put("authorizeStatus", 1);//相互授权
                        }else {
                            obj.put("authorizeStatus", 2);//居民单方向向家人授权
                        }
                    }else {
                        obj.put("authorizeStatus", 3);//居民被家人授权
                    }
                }
                if (ssSign && jtSign) {
@ -508,11 +542,38 @@ public class FamilyMemberService extends BaseService {
                } else {
                    obj.put("signType", 0);
                }
                obj.put("state","1");//0 :未处理;1:已同意;2:已拒绝
                obj.put("id",map.get("id"));
                resultArray.put(obj);
            }
        }
        //待审核记录
        if(StringUtils.isBlank(doctorCode)){
            List<PatientFamilyTemp> tempList = patientFamilyTempDao.findByPatientAndState(patient,"0");
            if(tempList!=null&&tempList.size()>0){
                for (PatientFamilyTemp temp:tempList){
                    JSONObject obj = new JSONObject();
                    Patient p = patientDao.findByCode(temp.getFamilyMember());
                    obj.put("code", p.getCode());
                    obj.put("name", p.getName());
                    obj.put("sex", p.getSex());
                    obj.put("isAuthorize", 0);//0:未授权,1:已授权
                    obj.put("birthday", p.getBirthday());
                    obj.put("idcard", StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard());
                    obj.put("photo", p.getPhoto());
                    obj.put("mobile", p.getMobile());
                    obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
                    obj.put("familyRelation", temp.getFamilyRelation());
                    obj.put("familyRelationName", relations.get(temp.getFamilyRelation()));
                    obj.put("signType", 0);
                    obj.put("state","0");//0 :未处理;1:已同意;2:已拒绝
                    obj.put("id",temp.getId());
                    resultArray.put(obj);
                }
            }
        }
        return resultArray;
    }
@ -541,26 +602,18 @@ public class FamilyMemberService extends BaseService {
     * @param patient
     * @return
     */
    public JSONArray getAuthorizeMembers(String patient){
    public JSONArray getAuthorizeMembers(String patient) throws Exception{
        JSONArray resultArray = new JSONArray();
        resultArray.put(getPatient(patient));
        String sql = "select * " +
                " from " +
                "    wlyy_patient_family_member t1, " +
                "    wlyy_patient t2 " +
                " where " +
                "        t1.patient = ? " +
                "    and t1.is_authorize = 1 " +
                "    and t1.family_member = t2.code order by t1.family_relation ";
        List<PatientFamilyMember> list = memberDao.findByFamilyMemberAndIsAuthorize(patient,1);
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient});
        if (result != null && result.size() > 0) {
        if (list != null && list.size() > 0) {
            JSONArray tem = new JSONArray();
            for (Map<String, Object> map : result) {
            for (PatientFamilyMember member : list) {
                JSONObject obj = new JSONObject();
                List<SignFamily> signs = contractService.findAllSignByPatient(map.get("code").toString());
                Patient p = patientDao.findByCode(member.getPatient());
                List<SignFamily> signs = contractService.findAllSignByPatient(p.getCode());
                boolean ssSign = false;
                boolean jtSign = false;
@ -573,20 +626,20 @@ public class FamilyMemberService extends BaseService {
                    }
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                Integer relation = familyRelationTrans(p,member.getFamilyRelation());
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                String idCard = StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString();
                obj.put("code", p.getCode());
                obj.put("name", p.getName());
                obj.put("sex", p.getSex());
                obj.put("isAuthorize", member.getIsAuthorize());//0:未授权,1:已授权
                obj.put("birthday", p.getBirthday());
                String idCard = StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard();
                obj.put("idcard", CommonUtil.getIdcardEncode(idCard));
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("ssc", map.get("ssc"));
                obj.put("familyRelation", family_relation);
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                obj.put("photo", p.getPhoto());
                obj.put("mobile", p.getMobile());
                obj.put("ssc", p.getSex());
                obj.put("familyRelation", relation);
                obj.put("familyRelationName", relations.get(relation));
                if (ssSign && jtSign) {
                    obj.put("signType", 3);
@ -598,7 +651,7 @@ public class FamilyMemberService extends BaseService {
                    obj.put("signType", 0);
                }
                if(family_relation==0){
                if(member.getIsAuthorize()==0){
                    tem.put(obj);
                }else {
                    resultArray.put(obj);
@ -657,6 +710,7 @@ public class FamilyMemberService extends BaseService {
            obj.put("familyRelation", "-1");
            obj.put("familyRelationName", "自己");
            obj.put("isAuthorize", 1);//0:未授权,1:已授权
            obj.put("authorizeStatus", 3);//
            if (ssSign && jtSign) {
                obj.put("signType", 3);
@ -1002,7 +1056,7 @@ public class FamilyMemberService extends BaseService {
    @Transactional
    public int addMemberFamily(Patient p, Patient m, String patient, String member, int relation) throws Exception {
        if (relation < 5) {
        if (relation>0&&relation < 5) {
            List<PatientFamilyMember> familyMembers = memberDao.findByPatientAndFamilyRelation(patient, relation);
            if (familyMembers != null && familyMembers.size() > 0) {

+ 163 - 33
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -464,18 +464,42 @@ public class PatientHealthIndexService extends BaseService {
        Date date = DateUtil.strToDateShort(dateString);
        /***************** 按时间排序 ***************************/
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
        String sql = "SELECT " +
                "MIN(id) id" +
                ", user" +
                ",value1" +
                ",value2" +
                ",value3" +
                ",value4" +
                ",value5" +
                ",value6" +
                ",value7" +
                ",device_sn" +
                ",type" +
                ",record_date" +
                ",sort_date" +
                ",min(czrq) czrq " +
                " from device.wlyy_patient_health_index " +
                " WHERE `user` = '"+patient+"' " +
                " and type = 1" +
                " and DATE_FORMAT(record_date,'%Y-%m-%d') = '"+dateString+"'" +
                " and del = '1' " +
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by record_date,id desc ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
//        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString);
        if (list != null && list.size() > 0) {
            obj.put("type", 1);
            obj.put("czrq", date);
            obj.put("recordDate", date);
            obj.put("sortDate", date);
            for (DevicePatientHealthIndex item : list) {
                String data = item.getValue1();
                String dataType = item.getValue2();
                String deviceSn = item.getDeviceSn()==null?"":item.getDeviceSn();
                String recordDate = DateUtil.dateToStr(item.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS);
                Long id = item.getId();
            for (Map<String,Object> item : list) {
                String data = item.get("value1").toString();
                String dataType = item.get("value2").toString();
                String deviceSn = item.get("device_sn")==null?"":item.get("device_sn").toString();
                String recordDate = item.get("record_date").toString();
                Long id = Long.parseLong(item.get("id")+"");
                if (data != null && dataType != null) {
                    if (dataType.equals("1")) {
                        obj.put("value1", data);
@ -776,23 +800,78 @@ public class PatientHealthIndexService extends BaseService {
     * @param end     结束时间
     * @return
     */
    public List<DevicePatientHealthIndex> findChartByPatient(String patient, int type, int gi_type, String begin, String end) {
        List<DevicePatientHealthIndex> re = new ArrayList<>();
    public JSONArray findChartByPatient(String patient, int type, int gi_type, String begin, String end) {
        JSONArray re = new JSONArray();
        Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
        if (gi_type != 0) {
            Sort sort = new Sort(Direction.ASC, "recordDate");
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
        String sql = "SELECT " +
                "MIN(id) id" +
                ", user" +
                ",value1" +
                ",value2" +
                ",value3" +
                ",value4" +
                ",value5" +
                ",value6" +
                ",value7" +
                ",device_sn" +
                ",type" +
                ",record_date" +
                ",sort_date" +
                ",min(czrq) czrq " +
                " from device.wlyy_patient_health_index " +
                " WHERE `user` = '"+patient+"' " +
                " and type =" +type+
                " and record_date >= '"+begin+"'" +
                " and record_date <= '"+end+"' " +
                " and del = '1' " ;
        String conditionApp = "";
        if(gi_type != 0){
            conditionApp = " and value2 = '"+gi_type+"' ";
        }
        sql = sql +conditionApp +
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by sort_date desc ,record_date desc limit "+0+" ,"+1000+" ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            JSONObject json = new JSONObject();
            json.put("id",map.get("id"));
            json.put("patient",map.get("user"));
            json.put("value1",map.get("value1"));
            json.put("value2",map.get("value2"));
            json.put("value3",map.get("value3"));
            json.put("value4",map.get("value4"));
            json.put("value5",map.get("value5"));
            json.put("value6",map.get("value6"));
            json.put("value7",map.get("value7"));
            json.put("deviceSn",map.get("device_sn")==null?"":map.get("device_sn"));
            json.put("type",map.get("type"));
            Date date = (Date) map.get("record_date");
            if (type == 2) {
                json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
            } else {
                json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
            }
            json.put("sortDate",map.get("sort_date"));
            json.put("czrq",map.get("czrq"));
        } else {
            // 排序
            Sort sort = new Sort(Direction.ASC, "recordDate");
            PageRequest pageRequest = new PageRequest(0, 1000, sort);
            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
            re.put(json);
        }
//        if (gi_type != 0) {
//            Sort sort = new Sort(Direction.ASC, "recordDate");
//            PageRequest pageRequest = new PageRequest(0, 1000, sort);
//            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//
//        } else {
//            // 排序
//            Sort sort = new Sort(Direction.ASC, "recordDate");
//            PageRequest pageRequest = new PageRequest(0, 1000, sort);
//            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//        }
        return re;
    }
@ -807,8 +886,8 @@ public class PatientHealthIndexService extends BaseService {
     * @param pageSize
     * @return
     */
    public List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, String start, String end, int page, int pageSize) {
        List<DevicePatientHealthIndex> re = new ArrayList<>();
    public JSONArray findIndexByPatient(String patient, int type, String start, String end, int page, int pageSize) {
        JSONArray re = new JSONArray();
        if (page > 0) {
            page = page - 1;
        }
@ -817,23 +896,74 @@ public class PatientHealthIndexService extends BaseService {
        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
        if (type == 1)   //血糖特殊处理
        {
            PageRequest pageRequest = new PageRequest(page, pageSize);
            //根据时间过滤排序
            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
            if (dateList != null && dateList.size() > 0) {
                for (String dateString : dateList) {
                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
                    if (obj != null) {
                        re.add(obj);
                    }
                }
            }
//            PageRequest pageRequest = new PageRequest(page, pageSize);
//            //根据时间过滤排序
//            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//            if (dateList != null && dateList.size() > 0) {
//                for (String dateString : dateList) {
//                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
//                    if (obj != null) {
//                        re.add(obj);
//                    }
//                }
//            }
        } else {
            // 排序
            Sort sort = new Sort(Direction.DESC, "recordDate");
            PageRequest pageRequest = new PageRequest(page, pageSize, sort);
            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
            re = list;
            String sql = "SELECT " +
                    "MIN(id) id" +
                    ", user" +
                    ",value1" +
                    ",value2" +
                    ",value3" +
                    ",value4" +
                    ",value5" +
                    ",value6" +
                    ",value7" +
                    ",device_sn" +
                    ",type" +
                    ",record_date" +
                    ",sort_date" +
                    ",min(czrq) czrq " +
                    " from device.wlyy_patient_health_index " +
                    " WHERE `user` = '"+patient+"' " +
                    " and type =" +type+
                    " and record_date >= '"+start+"'" +
                    " and record_date <= '"+end+"' " +
                    " and del = '1' " +
                    " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                    " order by sort_date desc ,record_date desc limit "+pageRequest.getOffset()+" ,"+pageRequest.getPageSize()+" ";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> map:list){
                JSONObject json = new JSONObject();
                json.put("id",map.get("id"));
                json.put("patient",map.get("user"));
                json.put("value1",map.get("value1"));
                json.put("value2",map.get("value2"));
                json.put("value3",map.get("value3"));
                json.put("value4",map.get("value4"));
                json.put("value5",map.get("value5"));
                json.put("value6",map.get("value6"));
                json.put("value7",map.get("value7"));
                json.put("deviceSn",map.get("device_sn")==null?"":map.get("device_sn"));
                json.put("type",map.get("type"));
                Date date = (Date) map.get("record_date");
                if (type == 2) {
                    json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
                } else {
                    json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
                }
                json.put("sortDate",map.get("sort_date"));
                json.put("czrq",map.get("czrq"));
                re.put(json);
            }
//            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize());
//            re = list;
        }
        return re;
    }

+ 140 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -3,13 +3,11 @@ package com.yihu.wlyy.service.app.label;
import com.google.common.collect.Lists;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
@ -23,15 +21,11 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.web.BaseController;
import org.apache.commons.beanutils.converters.CalendarConverter;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.type.descriptor.sql.JdbcTypeFamilyInformation;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
@ -43,8 +37,6 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static javafx.scene.input.KeyCode.X;
/**
 * 患者标签信息服务
 * <p>
@ -3072,4 +3064,144 @@ public class SignPatientLabelInfoService extends BaseService {
        }
    }
    /**
     * 获取医生所有团队的所有居民
     *
     * @param doctor
     * @return
     * @throws Exception
     */
    public JSONArray getSignPatientsByDoctorCode(String doctor) throws Exception {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Object[] args = null;
        String sql = "SELECT " +
                "   t2.label" +
                "   ,t2.label_type labelType" +
                "   ,t3.id teamCode" +
                "   ,t1.* " +
                " FROM " +
                "   wlyy_sign_family t1, " +
                "   wlyy_sign_patient_label_info t2 ," +
                "   (SELECT t.id FROM wlyy_admin_team_member m, wlyy_admin_team t WHERE m.doctor_code = ? AND t.id = m.team_id AND t.available = true AND m.available = true) t3" +
                " WHERE " +
                "   t2.status = 1 " +
                "   AND t1.patient = t2.patient " +
                "   AND t1.status > 0 " +
                "   AND t1.admin_team_code = t3.id ";
        args = new Object[]{doctor};
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    JSONObject signLabel = new JSONObject();
                    signLabel.put("label", sign.get("label"));
                    signLabel.put("labelType", sign.get("labelType"));
                    signLabel.put("teamCode", sign.get("teamCode"));
                    JSONArray ja = jsonP.getJSONArray("signLabel");
                    ja.put(signLabel);
                    continue;
                }
                JSONObject json = new JSONObject();
                JSONObject signLabel = new JSONObject();
                signLabel.put("label", sign.get("label"));
                signLabel.put("labelType", sign.get("labelType"));
                signLabel.put("teamCode", sign.get("teamCode"));
                JSONArray ja = new JSONArray();
                ja.put(signLabel);
                json.put("signLabel",ja);
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 开始时间
                json.put("begin", sign.get("begin") != null ? DateUtil.dateToStr((Date) sign.get("begin"), DateUtil.YYYY_MM_DD) : "");
                // 结束时间
                json.put("end", sign.get("end") != null ? DateUtil.dateToStr((Date) sign.get("end"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                //签约类型
                json.put("type", String.valueOf(sign.get("type")));
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                result.put(p.getCode(), json);
            }
        }
        if (result.size() > 0) {
            List<JSONObject> list = Lists.newArrayList(result.values());
            return new JSONArray(list);
        } else {
            return new JSONArray();
        }
    }
}

+ 73 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.team;
import com.google.common.collect.Lists;
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.AdminTeamMember;
@ -15,7 +16,6 @@ import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.hospital.HospitalService;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@ -56,6 +57,77 @@ public class AdminTeamService extends BaseService {
    SignFamilyRenewDao signFamliyRenewDao;
    @Autowired
    HospitalDao hospitalDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    /**
     * 根据医生code返回所有团队的医生
     * (pc端im使用)
     * @param doctor
     * @return
     */
    public JSONArray getTeamMembersByDoctorCode(String doctor){
        String sql = "SELECT " +
                "   d.code" +
                "   ,d.name" +
                "   ,d.hospital" +
                "   ,d.hospital_name hospitalName" +
                "   ,d.dept_name deptName" +
                "   ,d.job_name jobName" +
                "   ,d.level" +
                "   ,d.sex" +
                "   ,d.photo" +
                "   ,d.expertise" +
                "   ,d.introduce" +
                "   ,t.id teamCode" +
                " FROM " +
                "   wlyy_admin_team_member m" +
                "   , wlyy_admin_team t" +
                "   , wlyy_doctor d" +
                "   ,(SELECT t1.id FROM wlyy_admin_team_member m1, wlyy_admin_team t1 WHERE m1.doctor_code = '"+doctor+"' AND t1.id = m1.team_id AND t1.available = true AND m1.available = true) te" +
                " WHERE " +
                "   t.id = m.team_id AND " +
                "   m.doctor_code = d.code AND " +
                "   t.id = te.id AND " +
                "   t.available = true AND " +
                "   m.available = true ";
        List<Map<String, Object>> doctors = jdbcTemplate.queryForList(sql);
        Map<String, JSONObject> result = new HashMap<>();
        if(doctors!=null&&doctors.size()>0){
            for (Map<String, Object> map:doctors){
                String code = map.get("code").toString();
                if(result.containsKey(code)){
                    JSONObject json = result.get(code);
                    JSONArray ja = json.getJSONArray("teams");
                    ja.put(map.get("teamCode"));
                }else {
                    JSONObject json = new JSONObject();
                    json.put("code",map.get("code"));
                    json.put("name",map.get("name"));
                    json.put("hospital",map.get("hospital"));
                    json.put("jobName",map.get("jobName"));
                    json.put("level",map.get("level"));
                    json.put("sex",map.get("sex"));
                    json.put("photo",map.get("photo"));
                    json.put("hospitalName",map.get("hospitalName"));
                    json.put("deptName",map.get("deptName"));
                    json.put("expertise",map.get("expertise"));
                    json.put("introduce",map.get("introduce"));
                    JSONArray ja = new JSONArray();
                    ja.put(map.get("teamCode"));
                    json.put("teams",ja);
                    result.put(code,json);
                }
            }
        }
        if (result.size() > 0) {
            List<JSONObject> list = Lists.newArrayList(result.values());
            return new JSONArray(list);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 获取团队数量。

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java

@ -72,7 +72,8 @@ public class SMSController extends BaseController {
			if (StringUtils.isEmpty(ip)) {
				return error(-1, "无效的ip请求!");
			}
			String res = smsService.send(mobile, ip, type, getUID());
//			String res = smsService.send(mobile, ip, type, getUID());
			String res = smsService.send(mobile, ip, type, getRepUID());
			if (StringUtils.equals(res, "ok")) {
				return write(200, "验证码短信已发送!");
			} else {

+ 24 - 50
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -1,9 +1,10 @@
package com.yihu.wlyy.web.doctor.health;
import java.util.*;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -12,7 +13,6 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.json.JSONArray;
import org.json.JSONObject;
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;
@ -20,10 +20,7 @@ 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.patient.PatientHealthStandard;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.util.*;
@Controller
@RequestMapping(value = "/doctor/health_index", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ -71,27 +68,27 @@ public class DoctorHealthController extends BaseController {
											   @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
												   @RequestParam(value="end",required = true) String end) {
		try {
			Iterable<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);
			if (list == null) {
			JSONArray jsonArray = healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);
			if (jsonArray.length()==0) {
				return success("查询成功!");
			}
			JSONArray jsonArray = new JSONArray();
			for (DevicePatientHealthIndex model : list) {
				JSONObject modelJson = new JSONObject();
				modelJson.put("patient", model.getUser());
				modelJson.put("value1", model.getValue1());
				modelJson.put("value2", model.getValue2());
				modelJson.put("value3", model.getValue3());
				modelJson.put("value4", model.getValue4());
				modelJson.put("value5", model.getValue5());
				modelJson.put("value6", model.getValue6());
				modelJson.put("value7", model.getValue7());
				modelJson.put("type", model.getType());
				modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
				modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
				modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				jsonArray.put(modelJson);
			}
//			JSONArray jsonArray = new JSONArray();
//			for (DevicePatientHealthIndex model : list) {
//				JSONObject modelJson = new JSONObject();
//				modelJson.put("patient", model.getUser());
//				modelJson.put("value1", model.getValue1());
//				modelJson.put("value2", model.getValue2());
//				modelJson.put("value3", model.getValue3());
//				modelJson.put("value4", model.getValue4());
//				modelJson.put("value5", model.getValue5());
//				modelJson.put("value6", model.getValue6());
//				modelJson.put("value7", model.getValue7());
//				modelJson.put("type", model.getType());
//				modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
//				modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
//				modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
//				jsonArray.put(modelJson);
//			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
@ -126,30 +123,7 @@ public class DoctorHealthController extends BaseController {
				List<Object> list = healthIndexService.findIndexByPatient2(patient, type, begin, end, page, pagesize);
				jsonArray = new JSONArray(list);
			}else{
				List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(patient, type, begin, end, page, pagesize);
				if (list != null) {
					for (DevicePatientHealthIndex model : list) {
						JSONObject modelJson = new JSONObject();
						modelJson.put("id", model.getId());
						modelJson.put("patient", model.getUser());
						modelJson.put("value1", model.getValue1());
						modelJson.put("value2", model.getValue2());
						modelJson.put("value3", model.getValue3());
						modelJson.put("value4", model.getValue4());
						modelJson.put("value5", model.getValue5());
						modelJson.put("value6", model.getValue6());
						modelJson.put("value7", model.getValue7());
						modelJson.put("type", model.getType());
						if (type == 2) {
							modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
						} else {
							modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
						}
						modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
						modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
						jsonArray.put(modelJson);
					}
				}
				jsonArray = healthIndexService.findIndexByPatient(patient, type, begin, end, page, pagesize);
			}
			return write(200, "查询成功", "list", jsonArray);

+ 21 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java

@ -1,20 +1,21 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.repository.doctor.SignLabelDao;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
@ -30,6 +31,23 @@ public class SignPatientLabelController extends BaseController {
    SignPatientLabelService labelService;
    @Autowired
    AdminTeamService teamService;
    @Autowired
    SignLabelDao signLabelDao;
    /**
     * 获取大类(pc端im使用)
     * @return
     */
    @RequestMapping(value = "/signLabels", method = RequestMethod.GET)
    @ApiOperation(value = "获取标签大类")
    public String getSignLabels(){
        try {
            List<SignLabel> labels = signLabelDao.findLabels();
            return write(200, "获取成功", "data", labels);
        }catch (Exception e){
            return error(-1, "获取失败");
        }
    }
    /**
     * 添加标签

+ 15 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -1,6 +1,5 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -236,6 +235,21 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    /**
     * pc端im使用
     * @return
     */
    @RequestMapping(value = "/doctor_team_patient", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生所有团队的所有居民")
    public String getDoctorTeamsPatient(){
        try {
            JSONArray result = labelInfoService.getSignPatientsByDoctorCode(getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 查询某个团队的某个标签类型下各标签患者数
     *

+ 20 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -1,13 +1,10 @@
package com.yihu.wlyy.web.doctor.team;
import com.yihu.wlyy.entity.dict.Disease;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
@ -22,11 +19,12 @@ import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@ -60,6 +58,22 @@ public class AdminTeamController extends BaseController {
        }
    }
    /**
     * pc端im使用
     * @return
     */
    @RequestMapping(value = "/doctorTeamMembers", method = RequestMethod.GET)
    @ApiOperation(value = "根据医生code返回所有团队的医生")
    public String getTeamMembersByDoctorCode(){
        try {
            JSONArray jsonArray = teamService.getTeamMembersByDoctorCode(getUID());
            return write(200, "OK", "data", jsonArray);
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(method = RequestMethod.POST)
    @ApiOperation(value = "创建团队")
    public String createTeam(@RequestParam("team_name") String teamName,

+ 6 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -184,7 +184,8 @@ public class PatientController extends WeixinBaseController {
                       @RequestParam(required = false) String address,
                       @RequestParam(required = false) String street) {
        try {
            Patient patient = patientInfoService.findByCode(getUID());
            Patient patient = patientInfoService.findByCode(getRepUID());
//            Patient patient = patientInfoService.findByCode(getUID());
            if (StringUtils.isEmpty(photo)) {
                photo = fetchWxImages();
            }
@ -766,7 +767,8 @@ public class PatientController extends WeixinBaseController {
            if (smsCheck != 1) {
                return error(-1, "验证码错误");
            }
            int result = patientInfoService.changeMobile(getUID(), mobile, captcha, type);
//            int result = patientInfoService.changeMobile(getUID(), mobile, captcha, type);
            int result = patientInfoService.changeMobile(getRepUID(), mobile, captcha, type);
            if (result == -1) {
                return error(-1, "居民信息查找失败");
            } else if (result == 1) {
@ -822,7 +824,8 @@ public class PatientController extends WeixinBaseController {
            newPassword1 = StringUtils.reverse(newPassword1);
            newPassword2 = StringUtils.reverse(newPassword2);
            oldPassword = StringUtils.reverse(oldPassword);
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword, getUID());
            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword, getRepUID());
//            patientInfoService.updatePassword(newPassword1, newPassword2, oldPassword, getUID());
            return write(200, "更新成功");
        } catch (Exception e) {
            return error(-1, e.getMessage());

+ 13 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -85,7 +85,8 @@ public class PatientDeviceController extends BaseController {
                               @RequestParam(required = false) String newDeviceSN) {
        try {
            String user = getUID();
//            String user = getUID();
            String user = getRepUID();
            if (StringUtils.isNotEmpty(newDeviceSN)) {
//                校验新的sn码 1.是否被占用 2.是否是真的设备码
@ -148,7 +149,11 @@ public class PatientDeviceController extends BaseController {
        try {
            PatientDevice device = objectMapper.readValue(json, PatientDevice.class);
            // 设置患者标识
            device.setUser(getUID());
            device.setUser(getRepUID());
//            device.setUser(getUID());
            if(!getUID().equals(getRepUID())&&device.getId()==null){
                device.setAgent(getRepUID());
            }
            patientDeviceService.saveDevice(device);
@ -211,7 +216,8 @@ public class PatientDeviceController extends BaseController {
                                @ApiParam(name = "device_sn", value = "设备SN码", defaultValue = "15L000002")
                                @RequestParam(value = "device_sn", required = true) String deviceSn) {
        try {
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getUID(), deviceSn, type);
//            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getUID(), deviceSn, type);
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getRepUID(), deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
@ -229,11 +235,13 @@ public class PatientDeviceController extends BaseController {
        try {
            PatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
                if (!StringUtils.equals(pd.getUser(), getUID())) {
//                if (!StringUtils.equals(pd.getUser(), getUID())) {
                if (!StringUtils.equals(pd.getUser(), getRepUID())) {
                    return error(-1, "只允许删除自己的设备!");
                }
                // 删除设备
                patientDeviceService.deleteDevice(id, getUID());
                patientDeviceService.deleteDevice(id, getRepUID());
//                patientDeviceService.deleteDevice(id, getUID());
                return success("设备已删除!");
            } else {
                return error(-1, "不存在该设备!");

+ 24 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -11,10 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * 家庭关系成员控制器
@ -115,6 +112,29 @@ public class FamilyMemberController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/member_revoke", method = RequestMethod.POST)
    @ApiOperation(value = "撤销添加家庭成员")
    @ResponseBody
    public String revokeAddFamily(@ApiParam(name = "id", value = "关系", defaultValue = "1")
                                  @RequestParam(value = "id", required = true) Long id){
        try {
            int result = familyMemberService.revokeAddMember(id);
            if(result==1){
                return error(-1, "已同意,撤销失败");
            }else if(result == 2){
                return error(-1, "已拒绝,撤销失败");
            }else if(result == 3){
                return error(-1, "已撤销,请不要重复操作");
            }
            return write(200, "撤销成功");
        }catch (Exception e){
            e.printStackTrace();
            return error(-1, "撤销失败");
        }
    }
    /**
     * 删除成员
     *

+ 13 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -3,9 +3,13 @@ package com.yihu.wlyy.web.patient.health;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.education.HealthEduArticleOpHistory;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.app.health.HealthEduArticlePatientService;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.htmlparser.Parser;
@ -14,7 +18,6 @@ import org.htmlparser.visitors.TextExtractingVisitor;
import org.json.JSONArray;
import org.json.JSONObject;
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;
@ -22,11 +25,6 @@ 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.education.HealthEduArticlePatient;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -118,17 +116,18 @@ public class HealthEduArticleController extends BaseController {
    public String article(@RequestParam(value = "article", required = true) String article) {
        try {
            //获取单条文章记录
            List<HealthEduArticlePatient> healthEduArticlePatients = healthEduArticlePatientService.findByArticleAndPatient(article, getUID());
            String patient = getRepUID();
            List<HealthEduArticlePatient> healthEduArticlePatients = healthEduArticlePatientService.findByArticleAndPatient(article, patient);
            if (healthEduArticlePatients == null || healthEduArticlePatients.size() == 0) {
                return error(-2, "对不起,该消息不是您的消息,您无法查看哦~");
            }
            int isRead = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
            int isRead = healthEduArticleOpHistoryService.countByUserStatus(patient, HealthEduArticleOpHistory.READ_STATUS);
            //插入文章读取状态第一次阅读记录浏览数量//暂时更新每次都算一次浏览量
            HealthEduArticlePatient healthEduArticlePatient = healthEduArticlePatients.get(0);
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS, healthEduArticlePatient.getArticle(), healthEduArticlePatient.getTitle(), getUID());
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS, healthEduArticlePatient.getArticle(), healthEduArticlePatient.getTitle(), patient);
            if (isRead == 0) {
                //将文章更新为已读
                healthEduArticlePatientService.updateRead(getUID(), healthEduArticlePatient.getArticle());
                healthEduArticlePatientService.updateRead(patient, healthEduArticlePatient.getArticle());
            }
            HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(healthEduArticlePatient.getArticle());
@ -165,7 +164,8 @@ public class HealthEduArticleController extends BaseController {
    @ResponseBody
    public String read(@RequestParam("article") String article) {
        try {
            healthEduArticlePatientService.updateRead(getUID(), article);
//            healthEduArticlePatientService.updateRead(getUID(), article);
            healthEduArticlePatientService.updateRead(getRepUID(), article);
            return success("操作成功!");
        } catch (Exception ex) {
            error(ex);
@ -195,7 +195,8 @@ public class HealthEduArticleController extends BaseController {
    @ResponseBody
    public String readAllArticle() {
        try {
            String patient = getUID();
//            String patient = getUID();
            String patient = getRepUID();
            healthEduArticleService.readAllArticle(patient);
            return write(200, "更改状态成功!");
        } catch (Exception e) {

+ 8 - 49
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

@ -3,11 +3,11 @@ package com.yihu.wlyy.web.patient.health;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -386,9 +386,12 @@ public class PatientHealthController extends BaseController {
                                        @ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                        @RequestParam(value = "type", required = true) String type,
                                        @ApiParam(name = "patient", value = "居民code", defaultValue = "1")
                                        @RequestParam(value = "patient", required = true) String patient) {
                                        @RequestParam(value = "patient", required = false) String patient) {
        try {
//            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
            if(StringUtils.isBlank(patient)){
                patient = getUID();
            }
            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, patient, null);
            //血糖和血压需要校验
            if (type.equals("1") || type.equals("2")) {
@ -429,32 +432,12 @@ public class PatientHealthController extends BaseController {
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
//            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
            if (list == null) {
            if (jsonArray.length()==0) {
                return success("查询成功!");
            }
            JSONArray jsonArray = new JSONArray();
            for (DevicePatientHealthIndex model : list) {
                JSONObject modelJson = new JSONObject();
                modelJson.put("patient", model.getUser());
                modelJson.put("value1", model.getValue1());
                modelJson.put("value2", model.getValue2());
                modelJson.put("value3", model.getValue3());
                modelJson.put("value4", model.getValue4());
                modelJson.put("value5", model.getValue5());
                modelJson.put("value6", model.getValue6());
                modelJson.put("value7", model.getValue7());
                modelJson.put("type", model.getType());
                if (type == 2) {
                    modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                } else {
                    modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
                }
                modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                jsonArray.put(modelJson);
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
@ -483,32 +466,8 @@ public class PatientHealthController extends BaseController {
//                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
//                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
                if (list != null) {
                    for (DevicePatientHealthIndex model : list) {
                        JSONObject modelJson = new JSONObject();
                        modelJson.put("id", model.getId());
                        modelJson.put("patient", model.getUser());
                        modelJson.put("value1", model.getValue1());
                        modelJson.put("value2", model.getValue2());
                        modelJson.put("value3", model.getValue3());
                        modelJson.put("value4", model.getValue4());
                        modelJson.put("value5", model.getValue5());
                        modelJson.put("value6", model.getValue6());
                        modelJson.put("value7", model.getValue7());
                        modelJson.put("deviceSn", model.getDeviceSn()==null?"":model.getDeviceSn());
                        modelJson.put("type", model.getType());
                        if (type == 2) {
                            modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        } else {
                            modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
                        }
                        modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
                        modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                        jsonArray.put(modelJson);
                    }
                }
            }

+ 8 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -1,11 +1,8 @@
package com.yihu.wlyy.web.patient.sign;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignWeb;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -14,13 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
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.RestController;
import com.yihu.wlyy.entity.patient.SignWeb;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.web.BaseController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping(value = "/patient/sign", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ -277,7 +273,8 @@ public class PatientSignController extends BaseController {
	@RequestMapping("/signs")
	public String getSigns() {
		try {
			List<JSONObject> jsonArray  = signWebService.getSigns(getUID());
			List<JSONObject> jsonArray  = signWebService.getSigns(getRepUID());
//			List<JSONObject> jsonArray  = signWebService.getSigns(getUID());
			//JSONArray jsonArray  = signWebService.getSigns("915cc456-5b1d-11e6-8344-fa163e8aee56");
			return write(200, "查询成功!", "data",new JSONArray(jsonArray));
		} catch (Exception ex) {