Procházet zdrojové kódy

Merge branch 'dev' of liuwenbin/wlyy2.0 into dev

huangwenjie před 6 roky
rodič
revize
bbef84e046

+ 2 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -74,7 +74,8 @@ public class SpecialistMapping {
        public static final String patientRehabilitationDetail = "/patientRehabilitationDetail";
        public static final String recentPlanDetailRecord = "/recentPlanDetailRecord";
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String dailyJob = "/dailyJob";
    }
    public static class serviceItem{

+ 76 - 19
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java

@ -82,8 +82,8 @@ public class RehabilitationManageController {
                                          @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                          @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                          @RequestParam(value = "status", required = false)Integer status,
                                          @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = true)
                                          @RequestParam(value = "doctorCode", required = true)String doctorCode){
                                          @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                          @RequestParam(value = "doctorCode", required = false)String doctorCode){
        try {
            return rehabilitationManageService.calendarPlanDetail(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode);
        }catch (Exception e){
@ -105,7 +105,7 @@ public class RehabilitationManageController {
                                         @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                         @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                         @RequestParam(value = "status", required = false)Integer status,
                                         @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = true)
                                         @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                         @RequestParam(value = "doctorCode", required = true)String doctorCode){
        try {
            return rehabilitationManageService.calendarPlanDetailList(planId,searchTask,status,doctorCode,executeStartTime,executeEndTime);
@ -117,7 +117,7 @@ public class RehabilitationManageController {
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.serviceItemList)
    @ApiOperation(value = "康复管理-服务项目内容列表")
    @ApiOperation(value = "康复管理-多个康复计划服务项目内容信息列表")
    public ObjEnvelop serviceItemList(@ApiParam(name = "planDetailIds", value = "多个服务项目id用‘,’分隔", required = true)
                                             @RequestParam(value = "planDetailIds", required = true)String planDetailIds){
        try {
@ -130,7 +130,7 @@ public class RehabilitationManageController {
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.serviceItem)
    @ApiOperation(value = "康复管理-服务项目-完成项目内容信息")
    @ApiOperation(value = "康复管理-康复计划服务项目确认详情页")
    public ObjEnvelop serviceItem(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                   @RequestParam(value = "planDetailId", required = true)String planDetailId){
        try {
@ -165,17 +165,14 @@ public class RehabilitationManageController {
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.updateStatusRehabilitationOperate)
    @ApiOperation(value = "康复管理-服务项目-完成项目内容信息")
    @PostMapping(value = SpecialistMapping.rehabilitation.updateStatusRehabilitationOperate)
    @ApiOperation(value = "康复管理-更新康复计划操作完成日志状态")
    public Envelop updateStatusRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                                        @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                        @ApiParam(name = "status", value = "服务项目id", required = true)
                                                        @ApiParam(name = "status", value = "状态", required = true)
                                                        @RequestParam(value = "status", required = true)Integer status){
        try {
            if(rehabilitationOperateRecordsDao.updateStatus(status,planDetailId)>0){
                return Envelop.getSuccess(SpecialistMapping.api_success);
            }
            return Envelop.getError("update error!");
            return rehabilitationManageService.updateStatusRehabilitationOperate(status,planDetailId);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
@ -185,8 +182,7 @@ public class RehabilitationManageController {
    @GetMapping(value = SpecialistMapping.rehabilitation.patientRehabilitationDetail)
    @ApiOperation(value = "康复管理-居民详情页")
    public Envelop patientRehabilitationDetail(
                                       @ApiParam(name = "patientCode", value = "居民code", required = true)
    public Envelop patientRehabilitationDetail(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                       @RequestParam(value = "patientCode", required = true)String patientCode,
                                       @ApiParam(name = "healthDoctor", value = "健管师医生code", required = true)
                                       @RequestParam(value = "healthDoctor", required = true)String healthDoctor,
@ -210,16 +206,77 @@ public class RehabilitationManageController {
    public Envelop recentPlanDetailRecord(
            @ApiParam(name = "patientCode", value = "居民code", required = true)
            @RequestParam(value = "patientCode", required = true)String patientCode,
            @ApiParam(name = "startTime", value = "开始时间", required = true)
            @RequestParam(value = "startTime", required = true)String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime", required = true)String endTime){
            @ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
            @RequestParam(value = "startTime", required = false)String startTime,
            @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
            @RequestParam(value = "endTime", required = false)String endTime,
            @ApiParam(name = "page", value = "第几页,从1开始", required = true)
            @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
            @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
            @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize){
        try {
            return rehabilitationManageService.recentPlanDetailRecord(patientCode,startTime,endTime);
            return rehabilitationManageService.recentPlanDetailRecord(patientCode,startTime,endTime,page,pageSize);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.serviceDoctorList)
    @ApiOperation(value = "康复管理-医生端居民详情服务医生列表")
    public Envelop serviceDoctorList(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                               @RequestParam(value = "patientCode", required = true)String patientCode,
                                               @ApiParam(name = "healthDoctor", value = "健管师医生code", required = true)
                                               @RequestParam(value = "healthDoctor", required = true)String healthDoctor,
                                               @ApiParam(name = "healthDoctorName", value = "健管师医生名称", required = true)
                                               @RequestParam(value = "healthDoctorName", required = true)String healthDoctorName,
                                               @ApiParam(name = "generalDoctor", value = "全科医生code", required = true)
                                               @RequestParam(value = "generalDoctor", required = true)String generalDoctor,
                                               @ApiParam(name = "generalDoctorName", value = "全科医生名称", required = true)
                                               @RequestParam(value = "generalDoctorName", required = true)String generalDoctorName){
        try {
            return rehabilitationManageService.serviceDoctorList(patientCode,healthDoctor, healthDoctorName,generalDoctor,generalDoctorName);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.appCalendarPlanDetailList)
    @ApiOperation(value = "康复管理-app端、微信端计划的服务项目列表")
    public ObjEnvelop appCalendarPlanDetailList(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                             @RequestParam(value = "executeStartTime", required = true)String executeStartTime,
                                             @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                             @RequestParam(value = "executeEndTime", required = true)String executeEndTime,
                                             @ApiParam(name = "planId", value = "计划id", required = true)
                                             @RequestParam(value = "planId", required = true)String planId,
                                             @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)", required = false)
                                             @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                             @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                             @RequestParam(value = "status", required = false)Integer status){
        try {
            return rehabilitationManageService.appCalendarPlanDetailList(planId,searchTask,status,executeStartTime,executeEndTime);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.dailyJob)
    @ApiOperation(value = "每日康复服务通知")
    public ObjEnvelop dailyJob(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                @RequestParam(value = "startTime", required = true)String startTime,
                                @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                @RequestParam(value = "endTime", required = true)String endTime){
        try {
            return rehabilitationManageService.dailyJob(startTime,endTime);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java

@ -18,5 +18,5 @@ public interface PatientRehabilitationPlanDao extends PagingAndSortingRepository
    List<PatientRehabilitationPlanDO> findByPatientAndCreateUser(String patient, String doctor);
    @Query(" select p from PatientRehabilitationPlanDO p where p.patient=?1 order by p.createTime desc ")
    List<PatientRehabilitationPlanDO> findbyPatient(String patientCode);
    List<PatientRehabilitationPlanDO> findbyPatients(String patientCode);
}

+ 4 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java

@ -7,6 +7,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by 刘文彬 on 2018/8/20.
@ -53,4 +54,7 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    Integer completeServiceByDoctor(String generalDoctor,String healthDoctor,String patient,Integer status);
    RehabilitationDetailDO findById(String planDetailId);
    @Query(value ="select d.doctor,p.patient,count(1) from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and d.execute_time>=?1 and d.execute_time<=?2 GROUP BY d.doctor,p.patient",nativeQuery = true)
    List<Map<String,Object>> dailyJob(String startTime,String endTime);
}

+ 207 - 69
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -111,46 +111,51 @@ public class RehabilitationManageService {
        finalSql += " ORDER BY b.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
        List<Map<String,Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(finalSql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one:patientRehabilitationPlanDOList){
            Map<String,Object> resultMap = new HashMap<>();
            Integer age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
            String sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
            resultMap.put("age",age);
            resultMap.put("hospitalName",one.get("hospital_name"));
            resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
            resultMap.put("patientName",one.get("name"));
            resultMap.put("id",one.get("id"));
            //健康情况
            resultMap.put("healthyCondition","康复期");
            //安排类型
            String planTypeName = null;
            Integer planTypeTemp = (Integer)one.get("plan_type");
            switch (planTypeTemp){
                case 1:planTypeName="康复计划" ;break;
                case 2:planTypeName="(转)社区医院" ;break;
                case 3:planTypeName="(转)转家庭病床" ;break;
            }
            resultMap.put("planTypeName",planTypeName);
            //今日待办(即今日全部的项目)
            Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"00:00:00");
            Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"23:59:59");
            Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.get("id").toString(),beginTime,endTime);
            resultMap.put("todayBacklogCount",todayBacklogCount);//今日待办总数
            //已完成
            Integer finishedCount = rehabilitationDetailDao.completenessCount(1,one.get("id").toString(),beginTime,endTime);
            resultMap.put("finishedCount",finishedCount);//已完成
            //未完成
            Integer notstartedCount = rehabilitationDetailDao.completenessCount(0,one.get("id").toString(),beginTime,endTime);//未开始
            Integer underwayCount = rehabilitationDetailDao.completenessCount(2,one.get("id").toString(),beginTime,endTime);//已预约
            Integer unfinishedCount = notstartedCount+underwayCount;
            resultMap.put("unfinishedCount",unfinishedCount);//未完成
            //完成度(已完成/(已完成+未完成))
            Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.get("id").toString());
            Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.get("id").toString());
            resultMap.put("allCount",allCount);//总数
            resultMap.put("allFinishCount",allFinishCount);//全部已完成数
            resultList.add(resultMap);
        if(patientRehabilitationPlanDOList.size()>0&&patientRehabilitationPlanDOList.get(0).get("id")!=null){
            for(Map<String,Object> one:patientRehabilitationPlanDOList){
                Map<String,Object> resultMap = new HashMap<>();
                Integer age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
                String sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
                resultMap.put("age",age);
                resultMap.put("hospitalName",one.get("hospital_name"));
                resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
                resultMap.put("patientName",one.get("name"));
                resultMap.put("patientCode",one.get("patient"));
                resultMap.put("id",one.get("id"));
                resultMap.put("patientCode",one.get("patient"));
                //健康情况
                resultMap.put("healthyCondition","康复期");
                //安排类型
                String planTypeName = null;
                Integer planTypeTemp = (Integer)one.get("plan_type");
                switch (planTypeTemp){
                    case 1:planTypeName="康复计划" ;break;
                    case 2:planTypeName="(转)社区医院" ;break;
                    case 3:planTypeName="(转)转家庭病床" ;break;
                }
                resultMap.put("planTypeName",planTypeName);
                //今日待办(即今日全部的项目)
                Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"00:00:00");
                Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+ " "+"23:59:59");
                Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.get("id").toString(),beginTime,endTime);
                resultMap.put("todayBacklogCount",todayBacklogCount);//今日待办总数
                //已完成
                Integer finishedCount = rehabilitationDetailDao.completenessCount(1,one.get("id").toString(),beginTime,endTime);
                resultMap.put("finishedCount",finishedCount);//已完成
                //未完成
                Integer notstartedCount = rehabilitationDetailDao.completenessCount(0,one.get("id").toString(),beginTime,endTime);//未开始
                Integer underwayCount = rehabilitationDetailDao.completenessCount(2,one.get("id").toString(),beginTime,endTime);//已预约
                Integer unfinishedCount = notstartedCount+underwayCount;
                resultMap.put("unfinishedCount",unfinishedCount);//未完成
                //完成度(已完成/(已完成+未完成))
                Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.get("id").toString());
                Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.get("id").toString());
                resultMap.put("allCount",allCount);//总数
                resultMap.put("allFinishCount",allFinishCount);//全部已完成数
                resultList.add(resultMap);
            }
        }
        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,Long.valueOf(count));
    }
@ -386,7 +391,7 @@ public class RehabilitationManageService {
                        family.put("all",0);
                        family.put("finish",0);
                    }
                    if((Integer)one.get("status")!=1){
                    if((Integer)one.get("status")==1){
                        family.put("finish",family.get("finish")+1);
                    }
                    family.put("all",family.get("all")+1);
@ -401,7 +406,7 @@ public class RehabilitationManageService {
                        specialist.put("all",0);
                        specialist.put("finish",0);
                    }
                    if((Integer)one.get("status")!=1){
                    if((Integer)one.get("status")==1){
                        specialist.put("finish",(specialist.get("finish"))+1);
                    }
                    specialist.put("all",(specialist.get("all"))+1);
@ -414,7 +419,7 @@ public class RehabilitationManageService {
                    Map<String,Integer> family = new HashMap<>();
                    family.put("all",0);
                    family.put("finish",0);
                    if((Integer)one.get("status")!=1){
                    if((Integer)one.get("status")==1){
                        family.put("finish",family.get("finish")+1);
                    }
                    family.put("all",family.get("all")+1);
@ -423,7 +428,7 @@ public class RehabilitationManageService {
                    Map<String,Integer> specialist = new HashMap<>();
                    specialist.put("all",0);
                    specialist.put("finish",0);
                    if((Integer)one.get("status")!=1){
                    if((Integer)one.get("status")==1){
                        specialist.put("finish",specialist.get("finish")+1);
                    }
                    specialist.put("all",specialist.get("all")+1);
@ -461,7 +466,7 @@ public class RehabilitationManageService {
     */
    public ObjEnvelop calendarPlanDetailList(String planId,Integer searchTask,Integer status,String doctorCode,String executeStartTime,String executeEndTime){
        String sql = " select d.*,i.content,i.title from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
        String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.content,i.title from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_service_item i on i.id = h.service_item_id " +
                " where d.execute_time>='"+executeStartTime+"' and d.execute_time<='"+executeEndTime+"' and d.plan_id='"+planId+"' " ;
@ -480,7 +485,7 @@ public class RehabilitationManageService {
    }
    /**
     * 服务项目内容列表
     * 多个康复计划服务项目内容列表
     * @param planDetailIds
     * @return
     * @throws Exception
@ -492,7 +497,8 @@ public class RehabilitationManageService {
            planDetailList +=",'"+one+"'";
        }
        String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
        String sql = "select i.title,i.content,i.type,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,p.doctor,p.patient " +
        String sql = "select i.title,i.content,i.type,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as specialistDoctor," +
                " d.doctor_name as specialistDoctorName,p.patient ,p.create_user ,p.create_user_name " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_service_item i on i.id = h.service_item_id " +
@ -504,6 +510,12 @@ public class RehabilitationManageService {
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one:serviceItemList){
            Map<String,Object> resultMap = new HashMap<>();
            List<String> executeDoctorList = new ArrayList<>();
            if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
                executeDoctorList.add(one.get("create_user_name")+"");
            }
            executeDoctorList.add(one.get("specialistDoctorName")+"");
            resultMap.put("executeDoctorList",executeDoctorList);
            resultMap.put("title",one.get("title"));//项目标题
            resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
            resultMap.put("content",one.get("content"));//项目内容
@ -548,13 +560,14 @@ public class RehabilitationManageService {
    }
    /**
     * 单个服务项目内容
     * 康复计划服务项目确认页
     * @param planDetailId
     * @return
     * @throws Exception
     */
    public ObjEnvelop serviceItem(String planDetailId) throws Exception{
        String sql = "select i.title,i.content,i.type,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,p.doctor,p.patient " +
        String sql = "select i.title,i.content,i.type as itemType,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as specialistDoctor, " +
                " d.doctor_name as specialistDoctorName,p.patient ,p.create_user ,p.create_user_name " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_service_item i on i.id = h.service_item_id " +
@ -563,6 +576,12 @@ public class RehabilitationManageService {
        List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
        Map<String,Object> one = serviceItemList.get(0);
        Map<String,Object> resultMap = new HashMap<>();
        List<String> executeDoctorList = new ArrayList<>();
        if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
            executeDoctorList.add(one.get("create_user_name")+"");
        }
        executeDoctorList.add(one.get("specialistDoctorName")+"");
        resultMap.put("executeDoctorList",executeDoctorList);
        resultMap.put("title",one.get("title"));//项目标题
        resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
        resultMap.put("content",one.get("content"));//项目内容
@ -588,10 +607,10 @@ public class RehabilitationManageService {
            map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
            messageMapList.add(map);
        }
        Integer type = (Integer) one.get("type");
        Integer itemType = (Integer) one.get("itemType");
        resultMap.put("messageList",messageMapList);//指导与汇报记录
        resultMap.put("patient",one.get("patient"));
        resultMap.put("type",type);//1扫码、0上传附件、2、健康教育,3、健康指导,4、随访
        resultMap.put("type",itemType);//1扫码、0上传附件、2、健康教育,3、健康指导,4、随访
        //是否完成任务
        List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
@ -603,13 +622,12 @@ public class RehabilitationManageService {
            String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
            resultMap.put("completeTime",completeTimeStr);//完成时间
            resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
            if(type!=1||type!=0){
            if(itemType!=1&&itemType!=0){
                resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD));
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
            }
        }
        resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
        //完成信息
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
    }
@ -644,6 +662,7 @@ public class RehabilitationManageService {
        Map<String,Object> generalDoctorMap =  new HashMap<>();
        generalDoctorMap.put("type","全科医生");
        generalDoctorMap.put("doctorName",generalDoctorName);
        generalDoctorMap.put("doctorCode",generalDoctor);
        Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor,patientCode,1);
        Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor,patientCode);
        Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor,patientCode,1);
@ -654,6 +673,7 @@ public class RehabilitationManageService {
        Map<String,Object> healthDoctorMap =  new HashMap<>();
        healthDoctorMap.put("type","健管师");
        healthDoctorMap.put("doctorName",healthDoctorName);
        healthDoctorMap.put("doctorCode",healthDoctor);
        Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor,patientCode,1);
        Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor,patientCode);
        Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor,patientCode,1);
@ -661,11 +681,11 @@ public class RehabilitationManageService {
        healthDoctorMap.put("serviceCount",healthServiceCount);
        serviceDoctorList.add(healthDoctorMap);
        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='' and sign_status='1' and status='1'";
        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status='1'";
        List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
        for(Map<String,Object> one:specialistRelationList){
            String doctor = one.get("doctor").toString();
            String doctorName = one.get("doctorName").toString();
            String doctor = one.get("doctor")+"";
            String doctorName = one.get("doctor_name")+"";
            Integer unfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(doctor,patientCode,1);
            Integer finishCount = rehabilitationDetailDao.findItemByDoctor(doctor,patientCode);
            Integer serviceCount = rehabilitationDetailDao.completeServiceByDoctor(doctor,patientCode,1);
@ -673,14 +693,15 @@ public class RehabilitationManageService {
            map.put("finishedItem",finishCount-unfinishCount);
            map.put("serviceCount",serviceCount);
            map.put("doctorName",doctorName);
            healthDoctorMap.put("type","专科医生");
            map.put("doctorCode",doctor);
            map.put("type","专科医生");
            serviceDoctorList.add(map);
        }
        resultMap.put("serviceDoctorList",serviceDoctorList);
        //康复计划
        List<Map<String,Object>> planList = new ArrayList<>();
        List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findbyPatient(patientCode);
        List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findbyPatients(patientCode);
        Integer planUnderway = 0;//进行中
        Integer planFinish = 0;//已完成
        for(PatientRehabilitationPlanDO one:list){
@ -720,11 +741,16 @@ public class RehabilitationManageService {
            Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.getId());
            map.put("allCount",allCount);//总数
            List<RehabilitationDetailDO> detailList = rehabilitationDetailDao.getAllRehabilitationDetail(one.getId());
            Date executeTimeStart = detailList.get(0).getExecuteTime();
            Date executeTimeEnd = detailList.get(detailList.size()-1).getExecuteTime();
            String executeStart = DateUtil.dateToStr(executeTimeStart,"yyyy/MM/dd");
            String executeEnd = DateUtil.dateToStr(executeTimeEnd,"yyyy/MM/dd");
            map.put("time",executeStart+"-"+executeEnd);
            if(detailList.size()>0){
                Date executeTimeStart = detailList.get(0).getExecuteTime();
                Date executeTimeEnd = detailList.get(detailList.size()-1).getExecuteTime();
                String executeStart = DateUtil.dateToStr(executeTimeStart,"yyyy/MM/dd");
                String executeEnd = DateUtil.dateToStr(executeTimeEnd,"yyyy/MM/dd");
                map.put("time",executeStart+"-"+executeEnd);
            }else{
                map.put("time","");
            }
            planList.add(map);
        }
        resultMap.put("planList",planList);
@ -785,19 +811,31 @@ public class RehabilitationManageService {
     * @param startTime
     * @param endTime
     */
    public ObjEnvelop recentPlanDetailRecord(String patientCode,String startTime,String endTime){
    public ObjEnvelop recentPlanDetailRecord(String patientCode,String startTime,String endTime,Integer page, Integer pageSize) throws Exception{
        Map<String,Object> resultMap = new HashMap<>();
        //近期康复相关记录
//        String currentTime = DateUtil.getStringDate();
        String planDetailSql = " select d.*,i.content,i.title from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
                " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"' and d.executeTime>='"+startTime+"' and d.executeTime<='"+endTime+"' order by executeTime desc";
                " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status=1 and p.patient='"+patientCode+"' ";
        if(StringUtils.isNotEmpty(startTime)){
            planDetailSql += "  and d.execute_Time>='"+startTime+"' ";
        }
        if(StringUtils.isNotEmpty(endTime)){
            planDetailSql += "  and d.execute_time<='"+endTime+"' ";
        }
        //        List<Map<String,Object>> planDetailsCount = jdbcTemplate.queryForList(planDetailSql);
//        int count = 0;
//        if(planDetailsCount!=null&&planDetailsCount.size()>0){
//            count = planDetailsCount.size();
//        }
        planDetailSql += " ORDER BY d.execute_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
        List<Map<String,Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
        List<Map<String,Object>> planDetailList = new ArrayList<>();
        for(Map<String,Object> one:planDetails){
            Date executeTimeDate = (Date)one.get("execute_time");
            String executeTime = DateUtil.dateToStr(executeTimeDate,"yyyy/MM/dd HH:mm");
            String content = one.get("content").toString();
            String title = one.get("title").toString();
            String content = one.get("content")+"";
            String title = one.get("title")+"";
            Integer status = (Integer)one.get("status");
            String statusName = "";
            switch (status){
@ -822,7 +860,7 @@ public class RehabilitationManageService {
        Integer planDetailUnfinish = 0;
        for(Map<String,Object> one:planDetailList2){
            Integer status = (Integer)one.get("status");
            Integer status = (Integer)one.get("num");
            if(status==1){
                planDetailFinish+=1;
            }else{
@ -842,7 +880,7 @@ public class RehabilitationManageService {
     * @param doctorType 1、专科医生,2、家庭医生
     */
    @Transactional
    public Envelop saveGuidanceMessage(String messageId,String patient,String doctor,Integer doctorType,String content,String planDetailId){
    public Envelop saveGuidanceMessage(String messageId,String patient,String doctor,Integer doctorType,String content,String planDetailId) throws Exception{
        GuidanceMessageLogDO guidanceMessageLogDO = new GuidanceMessageLogDO();
        guidanceMessageLogDO.setMessageId(messageId);
        guidanceMessageLogDO.setPlanDetailId(planDetailId);
@ -869,7 +907,107 @@ public class RehabilitationManageService {
        guidanceMessageLogDO.setAdminTeamCode(adminTeamCode);
        guidanceMessageLogDO.setAdminTeamName(adminTeamName);
        guidanceMessageLogDO.setDoctorName(doctorName);
        guidanceMessageLogDO.setCreateTime(new Date());
        guidanceMessageLogDao.save(guidanceMessageLogDO);
        return Envelop.getSuccess(SpecialistMapping.api_success);
    }
    /**
     * 康复管理-更新康复计划操作完成日志状态
     * @param planDetailId
     * @param status
     * @throws Exception
     */
    @Transactional
    public Envelop updateStatusRehabilitationOperate(Integer status,String planDetailId){
        if(rehabilitationOperateRecordsDao.updateStatus(status,planDetailId)>0){
           return Envelop.getSuccess(SpecialistMapping.api_success);
        }
        return Envelop.getError("更新失败!");
    }
    /**
     * app端居民详情服务医生列表
     * @param patientCode
     * @param healthDoctor
     * @param healthDoctorName
     * @param generalDoctor
     * @param generalDoctorName
     * @return
     */
    public ObjEnvelop serviceDoctorList(String patientCode,String healthDoctor,String healthDoctorName,String generalDoctor,String generalDoctorName){
        //服务医生
        //完成项目=全部的服务项目-未完成的服务项目
        List<Map<String,Object>> serviceDoctorList = new ArrayList<>();
        Map<String,Object> generalDoctorMap =  new HashMap<>();
        generalDoctorMap.put("type","全科医生");
        generalDoctorMap.put("doctorName",generalDoctorName);
        Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor,patientCode,1);
        Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor,patientCode);
        Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor,patientCode,1);
        generalDoctorMap.put("finishedItem",generalFinishCount-generalUnfinishCount);
        generalDoctorMap.put("serviceCount",generalServiceCount);
        serviceDoctorList.add(generalDoctorMap);
        Map<String,Object> healthDoctorMap =  new HashMap<>();
        healthDoctorMap.put("type","健管师");
        healthDoctorMap.put("doctorName",healthDoctorName);
        Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor,patientCode,1);
        Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor,patientCode);
        Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor,patientCode,1);
        healthDoctorMap.put("finishedItem",healthFinishCount-healthUnfinishCount);
        healthDoctorMap.put("serviceCount",healthServiceCount);
        serviceDoctorList.add(healthDoctorMap);
        String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status='1'";
        List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
        for(Map<String,Object> one:specialistRelationList){
            String doctor = one.get("doctor")+"";
            String doctorName = one.get("doctor_name")+"";
            Integer unfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(doctor,patientCode,1);
            Integer finishCount = rehabilitationDetailDao.findItemByDoctor(doctor,patientCode);
            Integer serviceCount = rehabilitationDetailDao.completeServiceByDoctor(doctor,patientCode,1);
            Map<String,Object> map =  new HashMap<>();
            map.put("finishedItem",finishCount-unfinishCount);
            map.put("serviceCount",serviceCount);
            map.put("doctorName",doctorName);
            map.put("type","专科医生");
            serviceDoctorList.add(map);
        }
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,serviceDoctorList);
    }
    /**
     * app端、微信端计划的服务项目列表
     * @param planId
     * @param searchTask
     * @param status
     * @param executeStartTime
     * @param executeEndTime
     * @return
     */
    public ObjEnvelop appCalendarPlanDetailList(String planId,Integer searchTask,Integer status,String executeStartTime,String executeEndTime){
        Map<String,Object> resultMap = new HashMap<>();
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId,searchTask,status,null,executeStartTime,executeEndTime);
        Integer finishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);
        resultMap.put("planDetailList",objEnvelop.getObj());
        resultMap.put("finishCount",finishCount);
        resultMap.put("allCount",allCount);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
    }
    /**
     * 每日康复服务通知
     * @param startTime
     * @param endTime
     * @return
     */
    public ObjEnvelop dailyJob(String startTime,String endTime){
        List<Map<String,Object>> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
    }
}