فهرست منبع

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 سال پیش
والد
کامیت
db18961f15
24فایلهای تغییر یافته به همراه2143 افزوده شده و 329 حذف شده
  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. 100 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  9. 1013 38
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  10. 73 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  11. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java
  12. 24 50
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  13. 66 62
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  14. 21 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelController.java
  15. 15 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  16. 8 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  17. 20 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  18. 6 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  19. 13 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  20. 24 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  21. 13 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  22. 8 49
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  23. 8 11
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java
  24. 317 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.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();
        }
    }
}

+ 100 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -3416,30 +3416,130 @@ public class FamilyContractService extends BaseService {
        return signFamilyDao.findOutTimeSigningByPatient(patient);
    }
    public JSONObject getServerPatientList(Long teamCode){
        String serverSql="SELECT " +
                " d.`code` As labelCode, " +
                " d.`name` AS label " +
                " FROM " +
                " wlyy_sign_dict d " +
                " WHERE " +
                " d.type IN ('1', '2') " +
                " AND d. YEAR = '"+DateUtil.getSignYear()+"' " +
                " AND d.`code` NOT IN ( " +
                " SELECT " +
                "  LEFT ( " +
                "   d. CODE, " +
                "   (INSTR(d. CODE, '-') - 1) " +
                "  ) AS CODE " +
                " FROM " +
                "  wlyy_sign_dict d " +
                " WHERE " +
                "  d. CODE LIKE '%-%' " +
                " GROUP BY " +
                "  CODE " +
                ")";
        String patientSql =" SELECT " +
                " s.patient, " +
                " s.server_type AS serverType, " +
                " s.special_population AS specialPopulation, " +
                " s.sign_year " +
                " FROM " +
                " wlyy_sign_family s " +
                " WHERE " +
                " s.`status` >= 0 " +
                " AND s.server_type IS NOT NULL "+
                " AND s.admin_team_code =" +teamCode+
                " AND s.doctor_health IS NULL";
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(patientSql);
        JSONObject rs = new JSONObject();
        rs.put("count",(patientList!=null&&patientList.size()>0)?patientList.size():0);
        List<Map<String,Object>> serlist = jdbcTemplate.queryForList(serverSql);
        if(serlist!=null&&serlist.size()>0){
            if(patientList!=null){
                for(Map<String,Object> map :serlist){
                    String labelCode = (String)map.get("labelCode");
                    List<Map<String,String>> codes = new ArrayList<>();
                    Iterator iterator = patientList.iterator();
                    while(iterator.hasNext()){
                        Map<String,Object> p =  ( Map<String,Object>)iterator.next();
                        String serverType = ((String)p.get("serverType"))==null?"":((String)p.get("serverType"));
                        if(labelCode.indexOf("-")==-1){
                            if(labelCode.equals(serverType)){
                                Map<String,String> code = new HashMap<>();
                                code.put("code",serverType);
                                codes.add(code);
                                iterator.remove();
                            }
                        }else{
                            String[] key = labelCode.split("-");
                            if(key[0].equals(serverType)){
                                Map<String,String> code = new HashMap<>();
                                code.put("code",serverType);
                                codes.add(code);
                                iterator.remove();
                            }
                        }
                    }
                    map.put("codes",codes);
                    map.put("number",(codes!=null&&codes.size()>0)?codes.size():0);
                }
            }
        }
        rs.put("patients",serlist);
        return rs;
    }
    public List<Map<String,Object>> patientGroupByServerType(String doctor) {
        // 先根据server_type分组查找wlyy_sign_family表中该医生的签约的患者,然后wlyy_sign_dict left join 得到全部的类型
        String sql=" select sd.code labelCode,sd.name labelName,IFNULL(t.count,0) amount from wlyy_sign_dict sd  " +
                " left join " +
                " ( " +
                " SELECT " +
                "  sf.server_type type, " +
                "  sf.server_type_name name, " +
                "  count(id) count " +
                " FROM " +
                "  wlyy_sign_family sf " +
                " WHERE " +
                "  sf. STATUS > 0 " +
                " AND ( " +
                "  sf.doctor =? " +
                "  or sf.doctor_health =? " +
                " ) " +
                " group by sf.server_type " +
                " ) t " +
                " on sd.`code`=t.type " +
                " where  sd.id in (4,5,6,7,8,9,10,11,12)";
        List<Map<String,Object>> queryData=jdbcTemplate.queryForList(sql,doctor,doctor);
        return queryData;
    }
}

+ 1013 - 38
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -1816,7 +1816,7 @@ public class StatisticsService extends BaseService {
                   " GROUP BY left(f.apply_date,10)";
        //按月
        }else{
            sql ="SELECT (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('2017-06-01','%v')+1) as weekOfMonth,count(1) as signCount " +
            sql ="SELECT (DATE_FORMAT(f.apply_date,'%v')-DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"','%v')+1) as weekOfMonth,count(1) as signCount " +
                    " FROM wlyy_sign_family f " +
                    " where f.apply_date >='"+startDate+" 00:00:00' " +
                    " AND f.apply_date<='"+endDate+" 00:00:00' " +
@ -1894,14 +1894,21 @@ public class StatisticsService extends BaseService {
                " AND q.quota_date ='"+startDate+"' " +
                " AND q.qkdoctor_code ='"+id+"'";
        Map<String,Object> noRelyMap = jdbcTemplate.queryForMap(noRelysql);
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(noRelysql);
        Long noRelystartCount = Long.parseLong((String)noRelyMap.get("result"));
        Long totalstartCount = Long.parseLong((String)totalMap.get("result"));
        List<Map<String,Object>> noRelyList = jdbcTemplate.queryForList(noRelysql);
        Long noRelystartCount =0L;
        Long totalstartCount = 0L;
        if(noRelyList!=null&&noRelyList.size()>0){
            Map<String,Object> noRelyMap =noRelyList.get(0);
            noRelystartCount = Long.parseLong((String)noRelyMap.get("result"));
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalsql);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> totalMap =totalList.get(0);
            totalstartCount = Long.parseLong((String)totalMap.get("result"));
        }
        Long noRelyEndCount ;
        Long totalEndCount ;
        Long noRelyEndCount =0L;
        Long totalEndCount =0L;
        if("1".equals(isNow)){
            String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
            //当前时间获取未回复咨询总数
@ -1931,11 +1938,16 @@ public class StatisticsService extends BaseService {
                    " AND q.level1_type ='1' " +
                    " AND q.quota_date ='"+startDate+"' " +
                    " AND q.qkdoctor_code ='"+id+"'";
            Map<String,Object> noRelyEndMap = jdbcTemplate.queryForMap(noRelyEndsql);
            Map<String,Object> totalEndMap = jdbcTemplate.queryForMap(totalEndsql);
            noRelyEndCount = Long.parseLong((String)noRelyEndMap.get("result"));
            totalEndCount = Long.parseLong((String)totalEndMap.get("result"));
            List<Map<String,Object>> noRelyEndList = jdbcTemplate.queryForList(noRelyEndsql);
            if(noRelyEndList!=null&&noRelyEndList.size()>0){
                Map<String,Object> noRelyEndMap = noRelyEndList.get(0);
                noRelyEndCount = Long.parseLong((String)noRelyEndMap.get("result"));
            }
            List<Map<String,Object>> totalEndList = jdbcTemplate.queryForList(totalEndsql);
            if(totalEndList!=null&&totalEndList.size()>0){
                Map<String,Object> totalEndMap = totalEndList.get(0);
                totalEndCount = Long.parseLong((String)totalEndMap.get("result"));
            }
        }
        JSONObject rs = new JSONObject();
@ -2200,12 +2212,12 @@ public class StatisticsService extends BaseService {
        return js;
    }
    public int checkDoctorIsTeamleader(String doctor){
    public JSONObject checkDoctorIsTeamleader(String doctor){
        AdminTeam team = adminTeamDao.findByLeaderCode(doctor);
        if(team!=null){
            return 1;
            return new JSONObject(team);
        }
        return 0;
        return null;
    }
    /**
@ -2503,7 +2515,7 @@ public class StatisticsService extends BaseService {
     * @param sort 0降序 1升续
     * @return
     */
    public JSONArray getMemberConsultList(String teamCode,String startDate,String endDate,String sort){
    public JSONArray getMemberConsultList(String teamCode,String startDate,String endDate,String sort,String sortType){
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
@ -2597,6 +2609,11 @@ public class StatisticsService extends BaseService {
                " t.doctor_code = d.`code` " +
                "AND t.available = 1 " +
                "AND t.team_id =  "+teamCode ;
        if("0".equals(sort)){
            totalSql = totalSql+ " ORDER BY total DESC";
        }else{
            totalSql = totalSql+ " ORDER BY total ASC";
        }
        //结束咨询
        String endConsultSql ="SELECT " +
@ -2640,9 +2657,21 @@ public class StatisticsService extends BaseService {
                " t.doctor_code = d.`code` " +
                " AND t.available = 1 " +
                " AND t.team_id = "+teamCode;
        if("0".equals(sort)){
            endConsultSql = endConsultSql+ " ORDER BY endRey DESC";
        }else{
            endConsultSql = endConsultSql+ " ORDER BY endRey ASC";
        }
        List<Map<String,Object>> onReyList = jdbcTemplate.queryForList(onReySQL);
        Map<String,Object> onReyMap = new HashMap<>();
        //将List转换为Map降低循环层级
        if(onReyList!=null&&onReyList.size()>0){
            for(Map<String,Object> list :onReyList){
                String code = (String)list.get("doctorCode");
                onReyMap.put(code,list);
            }
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
@ -2664,23 +2693,58 @@ public class StatisticsService extends BaseService {
                endConsultMap.put(code,list);
            }
        }
        if("0".equals(sortType)){
            //未回复数
            //合并结果集
            if(onReyList!=null&&onReyList.size()>0){
                for(Map<String,Object> map :onReyList){
                    String code = (String)map.get("doctorCode");
        //合并结果集
        if(onReyList!=null&&onReyList.size()>0){
            for(Map<String,Object> map :onReyList){
                String code = (String)map.get("doctorCode");
                    Map<String,Object> t = ( Map<String,Object>)totalMap.get(code);
                    Long totalCout = (Long)t.get("total");
                    map.put("total",totalCout);
                    Map<String,Object> e =( Map<String,Object>)endConsultMap.get(code);
                    Long endCout = (Long)e.get("endRey");
                    map.put("endRey",endCout);
                }
            }
            return new JSONArray(onReyList);
        }else if("1".equals(sortType)){
            //总数
            //合并结果集
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map :totalList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> t = ( Map<String,Object>)onReyMap.get(code);
                    Long noRely = (Long)t.get("noRely");
                    map.put("noRely",noRely);
                Map<String,Object> t = ( Map<String,Object>)totalMap.get(code);
                Long totalCout = (Long)t.get("total");
                map.put("total",totalCout);
                    Map<String,Object> e =( Map<String,Object>)endConsultMap.get(code);
                    Long endCout = (Long)e.get("endRey");
                    map.put("endRey",endCout);
                }
            }
            return new JSONArray(totalList);
        }else{
            //结束咨询数
            //合并结果集
            if(endConsultList!=null&&endConsultList.size()>0){
                for(Map<String,Object> map :endConsultList){
                    String code = (String)map.get("doctorCode");
                Map<String,Object> e =( Map<String,Object>)endConsultMap.get(code);
                Long endCout = (Long)e.get("endRey");
                map.put("endRey",endCout);
                    Map<String,Object> t = ( Map<String,Object>)totalMap.get(code);
                    Long totalCout = (Long)t.get("total");
                    map.put("total",totalCout);
                    Map<String,Object> r = ( Map<String,Object>)onReyMap.get(code);
                    Long noRely = (Long)r.get("noRely");
                    map.put("noRely",noRely);
                }
            }
            return new JSONArray(endConsultList);
        }
        return new JSONArray(onReyList);
    }
    public JSONObject getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){
@ -2870,7 +2934,7 @@ public class StatisticsService extends BaseService {
            planSQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    "FROM " +
                    " wlyy_followup w " +
@ -2886,7 +2950,7 @@ public class StatisticsService extends BaseService {
            //按月
            totalSQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " wlyy_followup w " +
@ -2899,7 +2963,7 @@ public class StatisticsService extends BaseService {
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " wlyy_followup w " +
@ -2940,7 +3004,7 @@ public class StatisticsService extends BaseService {
            planSQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS planCount " +
                    "FROM " +
                    " wlyy_followup w " +
@ -2955,7 +3019,7 @@ public class StatisticsService extends BaseService {
            //按月
            totalSQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " wlyy_followup w " +
@ -2967,7 +3031,7 @@ public class StatisticsService extends BaseService {
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('2017-06-01', '%v') + 1 " +
                    "  DATE_FORMAT(w.create_time, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS followupCount " +
                    " FROM " +
                    " wlyy_followup w " +
@ -3005,7 +3069,6 @@ public class StatisticsService extends BaseService {
                "  wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
@ -3021,6 +3084,918 @@ public class StatisticsService extends BaseService {
        }else{
            totalSQL =totalSQL+" ORDER BY followupCount ASC";
        }
        return null;
        String addSQL = "SELECT " +
                " IFNULL(c.followupCount,0) AS addCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  w.doctor_code, " +
                "  w.doctor_name, " +
                "  COUNT(1) AS followupCount " +
                " FROM " +
                "  wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =" +teamCode ;
        if("0".equals(sort)){
            addSQL =addSQL+" ORDER BY addCount DESC";
        }else{
            addSQL =addSQL+" ORDER BY addCount ASC";
        }
        String planSQL = "SELECT " +
                " IFNULL(c.followupCount,0) AS planCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  w.doctor_code, " +
                "  w.doctor_name, " +
                "  COUNT(1) AS followupCount " +
                " FROM " +
                "  wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.status ='2'"+
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =" +teamCode ;
        if("0".equals(sort)){
            planSQL =planSQL+" ORDER BY planCount DESC";
        }else{
            planSQL =planSQL+" ORDER BY planCount ASC";
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSQL);
        //降低循环层级
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map:totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList= jdbcTemplate.queryForList(addSQL);
        //降低循环层级
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map:addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        List<Map<String,Object>> planList = jdbcTemplate.queryForList(planSQL);
        //降低循环层级
        Map<String,Object> planMap = new HashMap<>();
        if(planList!=null&&planList.size()>0){
            for(Map<String,Object> map:planList){
                String code = (String)map.get("doctorCode");
                planMap.put(code,map);
            }
        }
        if("0".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                //以总数为基准,合并结果集
                for(Map<String ,Object> map : totalList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> m =(Map<String,Object>)addMap.get(code);
                    if(m!=null){
                        Long addCount = (Long)m.get("addCount");
                        map.put("addCount",addCount==null?0L:addCount);
                    }else{
                        map.put("addCount",0L);
                    }
                    Map<String,Object> m2 =(Map<String,Object>)planMap.get(code);
                    if(m2!=null){
                        Long planCount = (Long)m2.get("planCount");
                        map.put("planCount",planCount);
                    }else{
                        map.put("planCount",0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else if("1".equals(sortType)){
            //按增量排序
            if(addList!=null&&addList.size()>0){
                //以增量为基准,合并结果集
                for(Map<String ,Object> map : totalList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> m =(Map<String,Object>)planMap.get(code);
                    if(m!=null){
                        Long planCount = (Long)m.get("planCount");
                        map.put("planCount",planCount);
                    }else{
                        map.put("planCount",0L);
                    }
                    Map<String,Object> m2 =(Map<String,Object>)planMap.get(code);
                    if(m2!=null){
                        Long followupCount = (Long)m2.get("followupCount");
                        map.put("followupCount",followupCount);
                    }else{
                        map.put("followupCount",0L);
                    }
                }
            }
            return new JSONArray(addList);
        }else{
            //按计划量排序
            if(planList!=null&&planList.size()>0){
                //以增量为基准,合并结果集
                for(Map<String ,Object> map : planList){
                    String code = (String)map.get("doctorCode");
                    Map<String,Object> m =(Map<String,Object>)planMap.get(code);
                    if(m!=null){
                        Long followupCount = (Long)m.get("followupCount");
                        map.put("followupCount",followupCount);
                    }else{
                        map.put("followupCount",0L);
                    }
                    Map<String,Object> m2 =(Map<String,Object>)addMap.get(code);
                    if(m2!=null){
                        Long addCount = (Long)m2.get("addCount");
                        map.put("addCount",addCount==null?0L:addCount);
                    }else{
                        map.put("addCount",0L);
                    }
                }
            }
            return new JSONArray(planList);
        }
    }
    public JSONObject getTeamDoctorFolTitle(String teamCode,String doctor,String startDate,String endDate){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql = "SELECT " +
                " COUNT(1) AS followupCount " +
                " FROM " +
                " wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL";
        String addSql = "SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
                " wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.followup_class IS NOT NULL";
        String planSql = "SELECT " +
                " COUNT(1) AS planCount " +
                " FROM " +
                " wlyy_followup w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.create_time >= '"+startDate+"' " +
                " AND w.create_time <= '"+endDate+"' " +
                " AND w.status ='2'"+
                " AND w.followup_class IS NOT NULL";
        JSONObject rs = new JSONObject();
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> map = totalList.get(0);
            Long followupCount = (Long)map.get("followupCount");
            rs.put("followupCount",followupCount!=null?followupCount:0L);
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        if(addList!=null&&addList.size()>0){
            Map<String,Object> map = addList.get(0);
            Long addCount = (Long)map.get("addCount");
            rs.put("addCount",addCount!=null?addCount:0L);
        }
        List<Map<String,Object>> planList = jdbcTemplate.queryForList(planSql);
        if(planList!=null&&planList.size()>0){
            Map<String,Object> map = planList.get(0);
            Long planCount = (Long)map.get("planCount");
            rs.put("planCount",planCount!=null?planCount:0L);
        }
        return rs;
    }
    public JSONArray getTeamResLine(String teamCode,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ;
        if("0".equals(type)){
            //查周
            totalSql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //查月
            //查周
            totalSql = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(totalSql);
        return new JSONArray(list);
    }
    public JSONArray getTeamDoctorResLine(String teamCode,String startDate,String endDate,String type,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ;
        if("0".equals(type)){
            //查周
            totalSql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.doctor_code = '"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //查月
            totalSql = "SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS reservationCount " +
                    " FROM " +
                    " wlyy_patient_reservation w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode +
                    " AND w.doctor_code = '"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(totalSql);
        return new JSONArray(list);
    }
    public JSONArray getTeamDoctorResList(String teamCode,String startDate,String endDate,String sort,String sortType){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql = "SELECT " +
                " IFNULL(c.reservationCount,0) AS reservationCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS reservationCount, " +
                " w.doctor_code AS doctorCode, " +
                " w.doctor AS name " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code = " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " GROUP BY doctorCode  " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            totalSql = totalSql+  " ORDER BY reservationCount DESC";
        }else{
            totalSql = totalSql+  " ORDER BY reservationCount ASC";
        }
        String addSql = "SELECT " +
                " IFNULL(c.reservationCount,0) AS addCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS reservationCount, " +
                " w.doctor_code AS doctorCode, " +
                " w.doctor AS name " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code = " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY doctorCode  " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            addSql = addSql+  " ORDER BY addCount DESC";
        }else{
            addSql = addSql+  " ORDER BY addCount ASC";
        }
        List<Map<String,Object>> totalList =jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map :totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map :addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        if("0".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map:totalList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) addMap.get(code);
                    if (m != null) {
                        Long addCount = (Long) m.get("addCount");
                        map.put("addCount", addCount != null ? addCount : 0L);
                    } else {
                        map.put("addCount", 0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else{
            //按增量排序
            if(addList!=null&&addList.size()>0){
                for(Map<String,Object> map:addList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) totalMap.get(code);
                    if (m != null) {
                        Long reservationCount = (Long) m.get("reservationCount");
                        map.put("reservationCount", reservationCount != null ? reservationCount : 0L);
                    } else {
                        map.put("reservationCount", 0L);
                    }
                }
            }
            return new JSONArray(addList);
        }
    }
    public JSONObject getTeamDoctorResTitle(String teamCode,String doctor,String startDate,String endDate){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSQL ="SELECT " +
                " COUNT(1) AS reservationCount " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.czrq <= '"+endDate+"' ";
        String addSQL ="SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
                " wlyy_patient_reservation w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor_code ='"+doctor+"' " +
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"'";
        JSONObject rs = new JSONObject();
        Long reservationCount =0L;
        Long addCount = 0L;
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSQL);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> map =totalList.get(0);
            reservationCount = (Long)map.get("reservationCount");
        }
        rs.put("reservationCount",reservationCount);
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSQL);
        if(addList!=null&&addList.size()>0){
            Map<String,Object> map =addList.get(0);
            addCount = (Long)map.get("addCount");
        }
        rs.put("addCount",addCount);
        return rs;
    }
    public JSONArray getTeamGuidLine(String teamCode,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String SQL ;
        if("0".equals(type)){
            //按周统计
            SQL ="SELECT " +
                    " left(w.create_time,10) AS dateNo, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode+
                    " AND w.czrq <= '"+startDate+"' " +
                    " AND w.czrq >= '"+endDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //按月统计
            SQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(SQL);
        return new JSONArray(totalList);
    }
    public JSONArray getTeamDoctorGuidLine(String teamCode,String startDate,String endDate,String type,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String SQL ;
        if("0".equals(type)){
            //按周统计
            SQL ="SELECT " +
                    " left(w.create_time,10) AS dateNo, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code = " +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+startDate+"' " +
                    " AND w.czrq >= '"+endDate+"' " +
                    " GROUP BY dateNo";
        }else{
            //按月统计
            SQL ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth, " +
                    " COUNT(1) AS guidanceCount " +
                    " FROM " +
                    " wlyy_patient_health_guidance w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(SQL);
        return new JSONArray(totalList);
    }
    public JSONArray getTeamGuidList(String teamCode,String startDate,String endDate,String sort,String sortType){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ="SELECT " +
                " IFNULL(c.guidanceCount,0) AS guidanceCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " w.doctor, " +
                " COUNT(1) AS guidanceCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY w.doctor " +
                " ) c ON c.doctor = m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            totalSql = totalSql+   " ORDER BY guidanceCount DESC";
        }else{
            totalSql = totalSql+   " ORDER BY guidanceCount ASC";
        }
        String addSql ="SELECT " +
                " IFNULL(c.guidanceCount,0) AS addCount, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " w.doctor, " +
                " COUNT(1) AS guidanceCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY w.doctor " +
                " ) c ON c.doctor = m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode ;
        if("0".equals(sort)){
            addSql = addSql+   " ORDER BY addCount DESC";
        }else{
            addSql = addSql+   " ORDER BY addCount ASC";
        }
        List<Map<String,Object>> totalList =jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map :totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map :addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        if("0".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map:totalList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) addMap.get(code);
                    if (m != null) {
                        Long addCount = (Long) m.get("addCount");
                        map.put("addCount", addCount != null ? addCount : 0L);
                    } else {
                        map.put("addCount", 0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else{
            //按增量排序
            if(addList!=null&&addList.size()>0){
                for(Map<String,Object> map:addList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) totalMap.get(code);
                    if (m != null) {
                        Long guidanceCount = (Long) m.get("guidanceCount");
                        map.put("guidanceCount", guidanceCount != null ? guidanceCount : 0L);
                    } else {
                        map.put("guidanceCount", 0L);
                    }
                }
            }
            return new JSONArray(addList);
        }
    }
    public JSONObject getTeamDoctorGuiTitle(String teamCode,String doctor,String startDate,String endDate){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSQL ="SELECT " +
                " COUNT(1) AS guidanceCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq >= '"+endDate+"'";
        String addSQL ="SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
                " wlyy_patient_health_guidance w " +
                " WHERE " +
                " w.admin_team_code =  " +teamCode+
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq <= '"+startDate+"' " +
                " AND w.czrq >= '"+endDate+"'";
        JSONObject rs = new JSONObject();
        Long guidanceCount =0L;
        Long addCount = 0L;
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSQL);
        if(totalList!=null&&totalList.size()>0){
            Map<String,Object> map =totalList.get(0);
            guidanceCount = (Long)map.get("guidanceCount");
        }
        rs.put("guidanceCount",guidanceCount);
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSQL);
        if(addList!=null&&addList.size()>0){
            Map<String,Object> map =addList.get(0);
            addCount = (Long)map.get("addCount");
        }
        rs.put("addCount",addCount);
        return rs;
    }
    public JSONArray getTeamEduLine(String teamCode,String startDate,String endDate,String type){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String sql;
        if("0".equals(type)){
            //按周统计
            sql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchCount " +
                    " FROM " +
                    " wlyy_health_edu_article_patient w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            sql ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchno " +
                    "FROM " +
                    " wlyy_health_edu_article_patient w " +
                    "WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    "GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return new JSONArray(list);
    }
    public JSONArray getTeamDoctorEduLine(String teamCode,String startDate,String endDate,String type,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String sql;
        if("0".equals(type)){
            //按周统计
            sql = "SELECT " +
                    " left(w.czrq,10) AS dateNo,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchCount " +
                    " FROM " +
                    " wlyy_health_edu_article_patient w " +
                    " WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    " GROUP BY dateNo";
        }else{
            sql ="SELECT " +
                    " ( " +
                    "  DATE_FORMAT(w.czrq, '%v') - DATE_FORMAT('"+startDate+"', '%v') + 1 " +
                    " ) AS weekOfMonth,COUNT(1) AS articleCount,count(DISTINCT w.batch_no) batchno " +
                    "FROM " +
                    " wlyy_health_edu_article_patient w " +
                    "WHERE " +
                    " w.admin_team_code =" +teamCode+
                    " AND w.doctor ='"+doctor+"'"+
                    " AND w.czrq <= '"+endDate+"' " +
                    " AND w.czrq >= '"+startDate+"' " +
                    "GROUP BY weekOfMonth";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return new JSONArray(list);
    }
    public JSONArray getTeamEduList(String teamCode,String startDate,String endDate,String sort,String sortType){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ="SELECT " +
                " IFNULL(c.articleCount,0) AS articleCount, " +
                " IFNULL(c.batchno,0) AS batchno, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS articleCount, " +
                " COUNT(DISTINCT w.batch_no) batchno, " +
                " w.doctor AS doctorCode " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " GROUP BY doctorCode " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode;
        if("0".equals(sort)){
            //降序
            if("0".equals(sortType)){
                //总人次
                totalSql = totalSql+ " ORDER BY articleCount DESC";
            }else if("2".equals(sortType)){
                //总批次
                totalSql = totalSql+ " ORDER BY batchno DESC";
            }
        }else{
            if("0".equals(sortType)){
                totalSql = totalSql+ " ORDER BY articleCount ASC";
            }else if("2".equals(sortType)){
                totalSql = totalSql+ " ORDER BY batchno ASC";
            }
        }
        String addSql ="SELECT " +
                " IFNULL(c.articleCount,0) AS addCount, " +
                " IFNULL(c.batchno,0) AS addBatchno, " +
                " d.`code` AS doctorCode, " +
                " d.`name` AS name " +
                " FROM " +
                " wlyy_admin_team_member m " +
                " LEFT JOIN ( " +
                " SELECT " +
                " COUNT(1) AS articleCount, " +
                " COUNT(DISTINCT w.batch_no) batchno, " +
                " w.doctor AS doctorCode " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode+
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"' " +
                " GROUP BY doctorCode " +
                " ) c ON c.doctorCode =m.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE  " +
                "  d.`code` = m.doctor_code " +
                " AND m.available = 1 " +
                " AND m.team_id =  " +teamCode;
        if("0".equals(sort)){
            if("1".equals(sortType)){
                addSql = addSql+ " ORDER BY addCount DESC";
            }else if("3".equals(sortType)){
                addSql = addSql+ " ORDER BY addBatchno DESC";
            }
        }else{
            if("1".equals(sortType)){
                addSql = addSql+ " ORDER BY addCount ASC";
            }else if("3".equals(sortType)){
                addSql = addSql+ " ORDER BY addBatchno ASC";
            }
        }
        List<Map<String,Object>> totalList =jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> map :totalList){
                String code = (String)map.get("doctorCode");
                totalMap.put(code,map);
            }
        }
        List<Map<String,Object>> addList = jdbcTemplate.queryForList(addSql);
        Map<String,Object> addMap = new HashMap<>();
        if(addList!=null&&addList.size()>0){
            for(Map<String,Object> map :addList){
                String code = (String)map.get("doctorCode");
                addMap.put(code,map);
            }
        }
        if("0".equals(sortType)||"2".equals(sortType)){
            //按总数排序
            if(totalList!=null&&totalList.size()>0){
                for(Map<String,Object> map:totalList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) addMap.get(code);
                    if (m != null) {
                        Long addCount = (Long) m.get("addCount");
                        Long addBatchno = (Long) m.get("addBatchno");
                        map.put("addCount", addCount != null ? addCount : 0L);
                        map.put("addBatchno", addBatchno != null ? addBatchno : 0L);
                    } else {
                        map.put("addCount", 0L);
                        map.put("addBatchno", 0L);
                    }
                }
            }
            return new JSONArray(totalList);
        }else{
            //按增量排序
            if(addList!=null&&addList.size()>0){
                for(Map<String,Object> map:addList) {
                    String code = (String) map.get("doctorCode");
                    Map<String, Object> m = (Map<String, Object>) totalMap.get(code);
                    if (m != null) {
                        Long articleCount = (Long) m.get("articleCount");
                        map.put("articleCount", articleCount != null ? articleCount : 0L);
                        Long batchno = (Long) m.get("batchno");
                        map.put("batchno", batchno != null ? batchno : 0L);
                    } else {
                        map.put("articleCount", 0L);
                        map.put("batchno", 0L);
                    }
                }
            }
            return new JSONArray(addList);
        }
    }
    public JSONObject getTeamDoctorEduTitle(String teamCode,String startDate,String endDate,String doctor){
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        String totalSql ="SELECT " +
                " COUNT(1) AS articleCount, " +
                " COUNT(DISTINCT w.batch_no) batchno " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq <= '"+endDate+"' ";
        String addSql ="SELECT " +
                " COUNT(1) AS addCount, " +
                " COUNT(DISTINCT w.batch_no) addBatchno " +
                " FROM " +
                " wlyy_health_edu_article_patient w " +
                " WHERE " +
                " w.admin_team_code =" +teamCode +
                " AND w.doctor ='"+doctor+"'" +
                " AND w.czrq <= '"+endDate+"' " +
                " AND w.czrq >= '"+startDate+"'";
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        List<Map<String,Object>> addList =jdbcTemplate.queryForList(addSql);
        JSONObject rs = new JSONObject();
        rs.put("totalList",totalList);
        rs.put("addList",addList);
        return rs;
    }
}

+ 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);

+ 66 - 62
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -371,71 +371,75 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
            String batchNo = UUID.randomUUID().toString();
            Date createTime = new Date();
            for (String p : patientSet) {
                Patient patientTemp = patientService.findByCode(p);
                SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
                if (signFamily == null) {
                    throw new Exception("can not find patient's family sign info");
                }
                for (String a : articles) {
                    // 查询文章信息
                    HealthEduArticle temp = maps.get(a);
                    if (temp == null) {
                        temp = healthEduArticleService.findArticleByCode(a);
                        // 添加到缓存
                        maps.put(a, temp);
                try{
                    Patient patientTemp = patientService.findByCode(p);
                    SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
                    if (signFamily == null) {
                        throw new Exception("can not find patient's family sign info");
                    }
                    for (String a : articles) {
                        // 查询文章信息
                        HealthEduArticle temp = maps.get(a);
                        if (temp == null) {
                            temp = healthEduArticleService.findArticleByCode(a);
                            // 添加到缓存
                            maps.put(a, temp);
                        }
                    HealthEduArticlePatient heap = new HealthEduArticlePatient();
                    // 设置文章标识
                    heap.setArticle(a);
                    // 设置文章简介
                    //heap.setContent(temp.getContent());
                    // 设置文章标题
                    //heap.setTitle(temp.getTitle());
                    // 设置文章查看URL
                    //heap.setUrl(temp.getUrl());
                    // 设置发送时间
                    heap.setCzrq(new Date());
                    // 设置医生标识
                    heap.setDoctor(doctor.getCode());
                    // 设置医生姓名
                    heap.setDoctorName(doctor.getName());
                    // 设置患者标识
                    heap.setPatient(p);
                    // 设置为示读
                    heap.setRead(1);
                    // 签约类型
                    heap.setSignType(2);
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    //附加内容
                    heap.setAttachedContent(attachedContent);
                    //批次号记录发送批次
                    heap.setBatchNo(batchNo);
                    //创建时间
                    heap.setCzrq(createTime);
                    heap.setSignCode(patientService.getSignCodeByPatient(p));
                    list.add(heap);
                    consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
                    if(StringUtils.isNotBlank(attachedContent)){
                        //发送备注
                        consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, attachedContent, ImUtill.CONTENT_TYPE_TEXT, patientTemp.getName());
                        HealthEduArticlePatient heap = new HealthEduArticlePatient();
                        // 设置文章标识
                        heap.setArticle(a);
                        // 设置文章简介
                        //heap.setContent(temp.getContent());
                        // 设置文章标题
                        //heap.setTitle(temp.getTitle());
                        // 设置文章查看URL
                        //heap.setUrl(temp.getUrl());
                        // 设置发送时间
                        heap.setCzrq(new Date());
                        // 设置医生标识
                        heap.setDoctor(doctor.getCode());
                        // 设置医生姓名
                        heap.setDoctorName(doctor.getName());
                        // 设置患者标识
                        heap.setPatient(p);
                        // 设置为示读
                        heap.setRead(1);
                        // 签约类型
                        heap.setSignType(2);
                        // 行政团队
                        heap.setAdminTeamCode(signFamily.getAdminTeamId());
                        //附加内容
                        heap.setAttachedContent(attachedContent);
                        //批次号记录发送批次
                        heap.setBatchNo(batchNo);
                        //创建时间
                        heap.setCzrq(createTime);
                        heap.setSignCode(patientService.getSignCodeByPatient(p));
                        list.add(heap);
                        consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
                        if(StringUtils.isNotBlank(attachedContent)){
                            //发送备注
                            consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, attachedContent, ImUtill.CONTENT_TYPE_TEXT, patientTemp.getName());
                        }
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
                        json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                        json.put("toUser", p);
                        json.put("article", temp.getCode() + "");
                        json.put("title", temp.getTitle());
                        json.put("doctorName", doctor.getName());
                        json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                        json.put("remark", endMsg);
                        Map<String, Object> content = new HashMap<>();
                        content.put("openid", patientTemp.getOpenid());
                        content.put("name", patientTemp.getName());
                        content.put("json", json);
                        content.put("code",patientTemp.getCode());
                        msgs.put(patientTemp.getCode(), content);
                    }
                    // 推送消息给微信端
                    JSONObject json = new JSONObject();
                    json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
                    json.put("toUser", p);
                    json.put("article", temp.getCode() + "");
                    json.put("title", temp.getTitle());
                    json.put("doctorName", doctor.getName());
                    json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                    json.put("remark", endMsg);
                    Map<String, Object> content = new HashMap<>();
                    content.put("openid", patientTemp.getOpenid());
                    content.put("name", patientTemp.getName());
                    content.put("json", json);
                    content.put("code",patientTemp.getCode());
                    msgs.put(patientTemp.getCode(), content);
                }catch (Exception e){
                    error(e);
                }
            }
            // 保存到数据库

+ 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, "查询失败");
        }
    }
    /**
     * 查询某个团队的某个标签类型下各标签患者数
     *

+ 8 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -1133,10 +1133,16 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    @RequestMapping(value = "/findNoHealthSignFamilyHealthNum")
    @ResponseBody
    public String findNoHealthSignFamilyHealthNum(
            String labelType,
            @RequestParam(required = false)String labelType,
            @RequestParam(required = false) String patientName,
            Long teamCode) {
            @RequestParam(required = false)Long teamCode) {
        try {
            //修改年度服务类型1.3.4需求
            if("1".equals(labelType)){
                JSONObject  rs =  familyContractService.getServerPatientList(teamCode);
                return write(200, "查询成功!", "data", rs);
            }
            List listNum = new ArrayList();
            Map patients = new HashMap();
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);

+ 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) {

+ 317 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -899,9 +899,10 @@ public class StatisticsController extends BaseController {
    public String getMemberConsultList(@RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String sort){
                                       @RequestParam(required = true)String sort,
                                       @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort));
            return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -967,4 +968,318 @@ public class StatisticsController extends BaseController {
        }
    }
    /**
     * 根据团队获取团队底下用户列表
     * @param sort 0为降序,1为升序
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sortType 0为总数排序,1为增量排序,2为计划中排序
     * @return
     */
    @RequestMapping("/getDoctorTeamFolList")
    @ResponseBody
    public String getDoctorTeamFolList(@RequestParam(required = true)String sort,
                                       @RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getDoctorTeamFolList(startDate,endDate,teamCode,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生随访头信息
     * @param teamCode
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamDoctorFolTitle")
    @ResponseBody
    public String getTeamDoctorFolTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String doctor,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorFolTitle(teamCode,doctor,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取待预约量团队统计则线图
     * @param teamCode
     * @param type
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamResLine")
    @ResponseBody
    public String getTeamResLine(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String type,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamResLine(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生预约量团队统计则线图
     * @param teamCode
     * @param type
     * @param startDate
     * @param endDate
     * @param doctor
     * @return
     */
    @RequestMapping("/getTeamDoctorResLine")
    @ResponseBody
    public String getTeamDoctorResLine(@RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String type,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorResLine(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队待预约量医生列表信息
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort 0为降序,1为升序
     * @param sortType 0为按总数,1为按增数
     * @return
     */
    @RequestMapping("/getTeamDoctorResList")
    @ResponseBody
    public String getTeamDoctorResList(@RequestParam(required = true)String teamCode,
                                       @RequestParam(required = true)String startDate,
                                       @RequestParam(required = true)String endDate,
                                       @RequestParam(required = true)String sort,
                                       @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorResList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生待预信息
     * @param teamCode
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamDoctorResTitle")
    @ResponseBody
    public String getTeamDoctorResTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String doctor,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorResTitle(teamCode,doctor,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康指导折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @return
     */
    @RequestMapping("/getTeamGuidLine")
    @ResponseBody
    public String getTeamGuidLine(@RequestParam(required = true)String teamCode,
                                  @RequestParam(required = true)String startDate,
                                  @RequestParam(required = true)String endDate,
                                  @RequestParam(required = true)String type){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamGuidLine(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     *  获取团队医生则线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @param doctor
     * @return
     */
    @RequestMapping("/getTeamDoctorGuidLine")
    @ResponseBody
    public String getTeamDoctorGuidLine(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate,
                                        @RequestParam(required = true)String type,
                                        @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuidLine(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队指导总数List
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort
     * @param sortType
     * @return
     */
    @RequestMapping("/getTeamGuidList")
    @ResponseBody
    public String getTeamGuidList(@RequestParam(required = true)String teamCode,
                                  @RequestParam(required = true)String startDate,
                                  @RequestParam(required = true)String endDate,
                                  @RequestParam(required = true)String sort,
                                  @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamGuidList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生健康指导头部信息
     * @param teamCode
     * @param doctor
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getTeamDoctorGuiTitle")
    @ResponseBody
    public String getTeamDoctorGuiTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String doctor,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorGuiTitle(teamCode,doctor,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康教育折线统计
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0按周 1按月
     * @return
     */
    @RequestMapping("/getTeamEduLine")
    @ResponseBody
    public String getTeamEduLine(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate,
                                 @RequestParam(required = true)String type){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamEduLine(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @return
     */
    @RequestMapping("/getTeamDoctorEduLine")
    @ResponseBody
    public String getTeamDoctorEduLine(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate,
                                 @RequestParam(required = true)String type,
                                 @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduLine(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队成员健康教育列表
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort
     * @param sortType
     * @return
     */
    @RequestMapping("/getTeamEduList")
    @ResponseBody
    public String getTeamEduList(@RequestParam(required = true)String teamCode,
                                 @RequestParam(required = true)String startDate,
                                 @RequestParam(required = true)String endDate,
                                 @RequestParam(required = true)String sort,
                                 @RequestParam(required = true)String sortType){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamEduList(teamCode,startDate,endDate,sort,sortType));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamDoctorEduTitle")
    @ResponseBody
    public String getTeamDoctorEduTitle(@RequestParam(required = true)String teamCode,
                                        @RequestParam(required = true)String startDate,
                                        @RequestParam(required = true)String endDate,
                                        @RequestParam(required = true)String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDoctorEduTitle(teamCode,startDate,endDate,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}