Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

yeshijie 3 years ago
parent
commit
048f47f12c
24 changed files with 937 additions and 47 deletions
  1. 3 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java
  2. 11 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/course/DoctorPatientTmpDao.java
  3. 57 3
      svr/svr-base/src/main/java/com/yihu/jw/base/util/EntranceUtil.java
  4. 4 0
      svr/svr-cloud-care/pom.xml
  5. 13 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/WebSocketConfig.java
  6. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/CourseSalesOrderRecordDao.java
  7. 11 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/DoctorPatientTmpDao.java
  8. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/RecruitStudentsRecordDao.java
  9. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  10. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/doorCoach/BaseDoorCoachOrderDao.java
  11. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  12. 42 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  13. 13 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  14. 196 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  15. 73 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PcManageWebSocketServer.java
  16. 14 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  17. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java
  18. 65 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  19. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  20. 13 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  21. 12 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  22. 196 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  23. 168 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/EntranceUtil.java
  24. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

+ 3 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java

@ -1,6 +1,7 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import org.hibernate.validator.constraints.LuhnCheck;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -29,4 +30,6 @@ public interface ConsultTeamDao  extends PagingAndSortingRepository<ConsultTeamD
	Integer  countByTime(int type, String doctor, Date startTime, Date endTime);
	ConsultTeamDo queryByRelationCode(String relationCode);
	List<ConsultTeamDo> findByTypeAndDel(Integer type,String del);
}

+ 11 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/course/DoctorPatientTmpDao.java

@ -2,9 +2,12 @@ package com.yihu.jw.base.dao.course;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/6/7.
 */
@ -16,6 +19,12 @@ public interface DoctorPatientTmpDao extends PagingAndSortingRepository<DoctorPa
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3")
    Integer findByPatientAndDoctorCodeAndType(String patient,String doctorCode,Integer type);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.orgCode = ?2 and t.type=?3 and t.del=1")
    Integer findByPatientAndOrgCodeAndType(String patient,String orgCode,Integer type);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.orgCode = ?2 and t.type=?3 and t.status=?4 and t.del=1")
    Integer findByPatientAndOrgCodeAndTypeAndStatus(String patient,String orgCode,Integer type,Integer status);
    List<DoctorPatientTmpDO> queryByPatientAndTypeIn(String patient,Integer[] type);
    @Modifying
    @Query(value = "update DoctorPatientTmpDO t set t.del=0 where 1=1")
    void deleteAll();
}

+ 57 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/util/EntranceUtil.java

@ -1,12 +1,24 @@
package com.yihu.jw.base.util;
import com.yihu.jw.base.dao.course.CourseDao;
import com.yihu.jw.base.dao.course.CourseSalesOrderRecordDao;
import com.yihu.jw.base.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.base.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.care.course.CourseDO;
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 教师与新生儿 入学关系更新工具
@ -17,6 +29,8 @@ public class EntranceUtil {
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     *
@ -29,7 +43,7 @@ public class EntranceUtil {
     */
    public void newRecord(String patient,Integer type,Integer del,String doctorCode,String orgCode,String relationCode){
        if (1==type||2==type){//在线咨询与上门辅导不重复保存
            if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,orgCode,type)!=0){
            if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctorCode,type)!=0){
                return ;
            }
        }
@ -37,6 +51,16 @@ public class EntranceUtil {
        tmpDO.setPatient(patient);
        tmpDO.setType(type);
        tmpDO.setDel(del);
        tmpDO.setStatus(0);
        if (StringUtils.isBlank(orgCode)){
            List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(doctorCode);
            if (list.size()>0){
                orgCode = list.get(0).getOrgCode();
            }
        }
        if (doctorPatientTmpDao.findByPatientAndOrgCodeAndTypeAndStatus(patient,orgCode,3,1)!=0){
            tmpDO.setDel(0);
        }
        tmpDO.setOrgCode(orgCode);
        tmpDO.setDoctorCode(doctorCode);
        tmpDO.setRelationCode(relationCode);
@ -44,7 +68,7 @@ public class EntranceUtil {
    }
    /**
     * 更新状态
     * 更新状态 状态为1 已入学,将该幼儿咨询、上门、课程数据失效
     * @param relationCode
     */
    public void updateStatus(Integer status,String relationCode){
@ -52,7 +76,13 @@ public class EntranceUtil {
        if (tmpDO!=null){
            tmpDO.setStatus(status);
            doctorPatientTmpDao.save(tmpDO);
            if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                List<DoctorPatientTmpDO> list = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                List<String> relationCodes  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                deleteRecord2List(relationCodes);
            }
        }
    }
    /**
@ -61,18 +91,25 @@ public class EntranceUtil {
     */
    public void updateStatus2(Integer status,String[] relationCode) {
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        List<String>relationCodes = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO != null) {
                tmpDO.setStatus(status);
                list.add(tmpDO);
                if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                    List<DoctorPatientTmpDO> listTmp = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                    List<String> relationCodeTmp  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                    relationCodes.addAll(relationCodeTmp);
                }
            }
        }
        doctorPatientTmpDao.save(list);
        deleteRecord2List(relationCodes);
    }
    /**
     * 删除记录
     * 删除记录 单条
     * @param relationCode
     */
    public void deleteRecord(String relationCode){
@ -99,4 +136,21 @@ public class EntranceUtil {
        }
        doctorPatientTmpDao.save(list);
    }
    /**
     * 删除记录
     * @param relationCode
     */
    public void deleteRecord2List(List<String> relationCode){
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setDel(0);
            }
        }
        doctorPatientTmpDao.save(list);
    }
}

+ 4 - 0
svr/svr-cloud-care/pom.xml

@ -203,6 +203,10 @@
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <!--   poi xml导入导出工具 end -->
        <!--基础业务组件-->

+ 13 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/WebSocketConfig.java

@ -0,0 +1,13 @@
package com.yihu.jw.care.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
    @Bean
    public ServerEndpointExporter serverEndpointExporter(){
        return new ServerEndpointExporter();
    }
}

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/CourseSalesOrderRecordDao.java

@ -4,6 +4,8 @@ import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
@ -14,4 +16,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface CourseSalesOrderRecordDao extends PagingAndSortingRepository<CourseSalesOrderRecordDO, String>
        , JpaSpecificationExecutor<CourseSalesOrderRecordDO> {
    List<CourseSalesOrderRecordDO> findByStatus(String status);
}

+ 11 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/DoctorPatientTmpDao.java

@ -2,9 +2,12 @@ package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/6/7.
 */
@ -13,10 +16,15 @@ public interface DoctorPatientTmpDao extends PagingAndSortingRepository<DoctorPa
    DoctorPatientTmpDO findByRelationCode(String relationCode);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3 and t.del=1")
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3")
    Integer findByPatientAndDoctorCodeAndType(String patient,String doctorCode,Integer type);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.orgCode = ?2 and t.type=?3 and t.del=1")
    Integer findByPatientAndOrgCodeAndType(String patient,String orgCode,Integer type);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.orgCode = ?2 and t.type=?3 and t.status=?4 and t.del=1")
    Integer findByPatientAndOrgCodeAndTypeAndStatus(String patient,String orgCode,Integer type,Integer status);
    List<DoctorPatientTmpDO> queryByPatientAndTypeIn(String patient,Integer[] type);
    @Modifying
    @Query(value = "update DoctorPatientTmpDO t set t.del=0 where 1=1")
    void deleteAll();
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/RecruitStudentsRecordDao.java

@ -19,4 +19,6 @@ public interface RecruitStudentsRecordDao extends PagingAndSortingRepository<Rec
    List<RecruitStudentsRecordDO> findByRecruitStudentsIdAndStatus(String recruitStudentsId, String status);
    List<RecruitStudentsRecordDO> findByOrgCodeAndStatus(String orgCode, String status);
    List<RecruitStudentsRecordDO> findByDelAndStatus(Integer del,String status);
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java

@ -58,7 +58,7 @@ public interface DevicePatientHealthIndexDao
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = ?1 and a.type=?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?5 ,?6",nativeQuery = true)
	List<String> findDateList(String patient, int type, Date start, Date end, int currentSize, int pageSize);
	
	@Query(value= " select * from wlyy_patient_health_index where type in (1,2) and record_date BETWEEN ?1 AND ?2  AND user in (select p.code from wlyy.wlyy_patient p INNER JOIN wlyy.wlyy_sign_family s on s.patient = p.code RIGHT JOIN wlyy.wlyy_sign_patient_label_info sp on sp.patient = p.code where  s.status > 0 AND s.admin_team_code = ?3 and (s.doctor = ?4 or s.doctor_health =?4) and sp.status = 1 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2))",nativeQuery = true)
	@Query(value= " select * from wlyy_patient_health_index where type in (1,2) and record_date BETWEEN ?1 AND ?2  AND user in (select p.code from wlyy.wlyy_patient p INNER JOIN wlyy.wlyy_sign_family s on s.patient = p.code RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code where  s.status > 0 AND s.admin_team_code = ?3 and (s.doctor = ?4 or s.doctor_health =?4) and sp.status = 1 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2))",nativeQuery = true)
	List<DevicePatientHealthIndex> findByTeamcodeAndRecordDate(Date start, Date end, String teamcode, String doctorcode);
	@Query(value="select * from wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/doorCoach/BaseDoorCoachOrderDao.java

@ -50,4 +50,6 @@ public interface BaseDoorCoachOrderDao extends PagingAndSortingRepository<BaseDo
    @Query("select o from BaseDoorCoachOrderDO o where o.doctor = ?1 and o.status in (1,2,3,4,5)")
    List<BaseDoorCoachOrderDO> getUnFinishOrderByDoctor(String doctor);
    List<BaseDoorCoachOrderDO> queryByStatusIn(Integer[] status);
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -174,7 +174,7 @@ public class PatientDeviceController extends BaseController {
    public ListEnvelop patientDeviceListByTopic(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                                @RequestParam(value = "patient", required = true) String patient,
                                                @ApiParam(name = "topic", value = "专题CODE;preventLost防走失,preventFall防跌倒", defaultValue = "preventLost")
                                                @RequestParam(value = "topic", required = true) String topic) {
                                                @RequestParam(value = "topic", required = false) String topic) {
        try {
            return ListEnvelop.getSuccess("查询成功",  patientDeviceService.patientDeviceListByTopic(patient,topic));
        } catch (Exception ex) {

+ 42 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -6,6 +6,7 @@ import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.doctor.CareDoctorService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -39,6 +40,8 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    private CapacityAssessmentRecordService capacityAssessmentRecordService;
    @Autowired
    private ConsultTeamService consultTeamService;
    @Autowired
    private EntranceUtil entranceUtil;
    @GetMapping(value = "doctorPage")
    @ApiOperation(value = "获取医生记录分页")
@ -213,18 +216,54 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "管理员获取居民档案列表")
    public PageEnvelop getArchiveList(@ApiParam(name="type",value = "档案类型,1老人 2新生儿")
                                      @RequestParam(value = "type",required = false,defaultValue = "2")Integer type,
                                      @ApiParam(name = "signStatus",value = "签约状况 -1未签约,0全部,1已签约 ")
                                      @RequestParam(value = "signStatus",required = false,defaultValue = "0")Integer signStatus,
                                      @ApiParam(name = "signStatus",value = "签约状况 -1全部,0未签约,1已签约 ")
                                      @RequestParam(value = "signStatus",required = false,defaultValue = "-1")Integer signStatus,
                                      @ApiParam(name = "name", value = "居民姓名", required = false)
                                      @RequestParam(value = "name",required = false) String name,
                                      @ApiParam(name = "page")
                                      @RequestParam(value = "page",required = true)Integer page,
                                      @ApiParam(name = "size")
                                      @RequestParam(value = "size",required = true)Integer size){
        try {
            return doctorService.getArchiveList(type, signStatus, page, size);
            return doctorService.getArchiveList(type, signStatus,name,page, size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "/getArchiveNum")
    @ApiOperation(value = "管理员获取居民tab数量")
    public ObjEnvelop getArchiveNum(){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorService.getArchiveNum()) ;
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "/initEntranceData")
    @ApiOperation(value = "初始化新生儿未入学埋点数据")
    public Envelop initEntranceData(){
        try {
            entranceUtil.initData();
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败");
        }
    }
    @GetMapping(value = "/deleteEntranceData")
    @ApiOperation(value = "删除新生儿未入学埋点数据")
    public Envelop deleteEntranceData(){
        try {
            entranceUtil.deleteAll();
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败");
        }
    }
}

+ 13 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -187,6 +187,19 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "servicePackageByPatient")
    @ApiOperation(value = "获取患者所有服务包")
    public ObjEnvelop servicePackageByPatient (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.servicePackageByPatient(patient));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "servicePackageSign")
    @ApiOperation(value = "分配服务包-签约")
    @ObserverRequired

+ 196 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -0,0 +1,196 @@
package com.yihu.jw.care.endpoint.third.platForm;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.third.PatientInfoPlatFormService;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/6/16.
 * 管理端pc端 居民详情大屏
 */
@RestController
@RequestMapping(value = "/cloudCare/noLogin/patientInfoForm")
@Api(description = "管理端pc端 居民详情大屏")
public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private PatientInfoPlatFormService patientInfoPlatFormService;
    @Autowired
    private PatientDoorCoachOrderService patientDoorCoachOrderService;
    @Autowired
    private DoctorDoorCoachOrderService doctorDoorCoachOrderService;
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @Autowired
    private EmergencyAssistanceService assistanceService;
    @GetMapping(value = "getPatientInfo")
    @ApiParam("获取居民详情页")
    public ObjEnvelop getPatientInfo(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientInfo(patient,patientType));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping(value = "getPatientEvent")
    @ApiParam("获取就诊事件")
    public ObjEnvelop getPatientEvent(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType,
                                     @ApiParam(name="page",value="page")
                                     @RequestParam(name = "page")Integer page,
                                     @ApiParam(name="pageSize",value="pageSize")
                                     @RequestParam(name = "pageSize")Integer pageSize){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientEvent(patient,patientType,page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping(value = "getServiceOrder")
    @ApiParam("获取服务工单列表")
    public ObjEnvelop getServiceOrder(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType,
                                     @ApiParam(name="page",value="page")
                                     @RequestParam(name = "page")Integer page,
                                     @ApiParam(name="pageSize",value="pageSize")
                                     @RequestParam(name = "pageSize")Integer pageSize){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getServiceOrder(patient,patientType,page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping(value = "getHealthIndexInfo")
    @ApiParam("获取居民体征信息")
    public ObjEnvelop getHealthIndexInfo(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
                                             @RequestParam(value="patient",required = true) String patient,
                                         @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                             @RequestParam(value="type",required = true) int type,
                                         @ApiParam(name="gi_type",value="就餐类型",defaultValue = "1")
                                             @RequestParam(value = "gi_type",required = false) int gi_type,
                                         @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
                                             @RequestParam(value="begin",required = true) String begin,
                                         @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
                                             @RequestParam(value="end",required = true) String end){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getHealthIndexInfo(patient,type,gi_type,begin,end));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping("getDoorCoachByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单,如果为空,则获取该患者当前最新一条的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "patientCode", name = "patientCode")
            @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = false) String orderId) {
        try {
            // 没有提供工单id的情况下,则获取该医生当前最新一条的工单
            if (StringUtils.isEmpty(orderId)) {
                // 根据接单医生code获取最近一次服务orderId
                orderId = patientDoorCoachOrderService.getOrderIdByPatient(patientCode);
                if (StringUtils.isEmpty(orderId)) {
                    return ObjEnvelop.getSuccess( "获取失败, 该患者暂无工单",null);
                }
            }
            // 根据orderId获取工单信息
            BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.getDoorServiceOrderById(orderId);
            return ObjEnvelop.getSuccess( "获取成功",  baseDoorCoachOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败, 该医生暂无工单!" + e.getMessage());
        }
    }
    @GetMapping("getLifeCareByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId) {
        try {
            // 根据orderId获取工单信息
            LifeCareOrderDO doorServiceOrderDO = lifeCareOrderService.getServiceOrderById(orderId);
            return ObjEnvelop.getSuccess("获取成功", doorServiceOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败" ,-1);
        }
    }
    @GetMapping(value = "getSecurityOrderDetail")
    @ApiOperation(value = "获取安防工单详情")//
    public ObjEnvelop getSecurityOrderDetail(@ApiParam(name="orderId",value = "orderId",required = true)
                                             @RequestParam(value = "orderId")String orderId,
                                             @ApiParam(name="doctor",value = "doctor",required = false)
                                             @RequestParam(value = "doctor",required = false)String doctor){
        try {
            JSONObject result = securityMonitoringOrderService.getSecurityOrderDetail(orderId,doctor);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("创建成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "patientGetOrderDetail")
    @ApiOperation(value = "患者查看救助详情")//仅只能查看已完成
    public ObjEnvelop patientGetOrderDetail(@ApiParam(name="orderId",value = "工单id")
                                            @RequestParam(value = "orderId") String orderId,
                                            @ApiParam(name="patient",value = "patient")
                                            @RequestParam(value = "patient") String patient
    ){
        try {
            JSONObject result = assistanceService.patientGetOrderDetail(orderId,patient);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("查询成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 73 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PcManageWebSocketServer.java

@ -0,0 +1,73 @@
package com.yihu.jw.care.endpoint.third.platForm;
import org.springframework.web.bind.annotation.RestController;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
 * Created by Bing on 2021/6/17.
 *
 * @ServerEndpoint 注解是一个类层次的注解,它的功能主要是将目前的类定义成一个websocket服务器端,
 */
@RestController
@ServerEndpoint("/cloudCare/noLogin/pcManage/websocket")
public class PcManageWebSocketServer {
    private static Collection<PcManageWebSocketServer> servers = Collections.synchronizedCollection(new ArrayList<PcManageWebSocketServer>());
    //与某个客户端的连接会话,需要通过它来给客户端发送数据
    private Session session;
    @OnOpen
    public void onOpen(Session session){
        this.session = session;
        add(this);
    }
    public void sendMessage(String message) throws IOException {
        this.session.getBasicRemote().sendText(message);
    }
    @OnClose
    public void onClose(){
        remove(this);
    }
    @OnMessage
    public void onMessage(String message, Session session) {
        System.out.println("来自客户端的消息:" + message);
    }
    @OnError
    public void onError(Session session, Throwable error){
        System.out.println("发生错误");
        error.printStackTrace();
    }
    public static void broadCast(String msg){
        for (PcManageWebSocketServer bitCoinServer : servers) {
            try {
                bitCoinServer.sendMessage(msg);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public static int getTotal(){
        return servers.size();
    }
    public static void add(PcManageWebSocketServer server){
        System.out.println("有新连接加入! 当前总连接数是:"+ servers.size());
        servers.add(server);
    }
    public static void remove(PcManageWebSocketServer server){
        System.out.println("有连接退出! 当前总连接数是:"+ servers.size());
        servers.remove(server);
    }
}

+ 14 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -11,6 +11,7 @@ import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
import com.yihu.jw.care.dao.sign.ServicePackageItemDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.endpoint.third.platForm.PcManageWebSocketServer;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.device.PatientDeviceService;
@ -97,6 +98,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    private ConsultDao consultDao;
    @Autowired
    private DictService dictService;
    @Autowired
    private PcManageWebSocketServer pcManageWebSocketServer;
    /**
     * 新建居民紧急救助
@ -202,21 +205,24 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            }
        }
        //推送socket给医生
        JSONObject message = new JSONObject();
        message.put("session_id",assistanceDO.getSessionId());
        message.put("sender_name",assistanceDO.getPatientName());
        message.put("content_notice",assistanceDO.getPatientName()+" 发起紧急救助!");
        message.put("sender_code",assistanceDO.getPatient());
        message.put("OrderType",20);
        message.put("order_id",assistanceDO.getId());
        message.put("content_type",40);
        for (BaseDoctorDO doctorDO:doctorDOS){
            JSONObject message = new JSONObject();
            message.put("session_id",assistanceDO.getSessionId());
            message.put("sender_name",assistanceDO.getPatientName());
            message.put("content_notice",assistanceDO.getPatientName()+" 发起紧急救助!");
            message.put("sender_code",assistanceDO.getPatient());
            message.put("OrderType",20);
            message.put("order_id",assistanceDO.getId());
            message.put("content_type",40);
            try {
                imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //pc管理端端推送消息
        pcManageWebSocketServer.broadCast(message.toString());
        emergencyAssistanceDao.save(assistanceDO);
        return getOrderDetail(assistanceDO.getId(),null);
    }

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java

@ -859,4 +859,16 @@ public class CourseService {
        return recordDO;
    }
    /**
     * 获取新生儿被录取机构列表
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getEntranceOrgList(String patient){
        String sql = "select sr.id,sr.patient,sr.org_code,org.`name`,org.photo from base_recruit_students_record sr " +
                " inner JOIN base_org org on sr.org_code = org.`code` where sr.patient = '"+patient+"' and sr.`status`=2 \n" +
                "GROUP BY sr.org_code";
        return jdbcTemplate.queryForList(sql);
    }
}

+ 65 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -327,7 +327,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0 ";
        //已入学
        String sql1=" select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.org_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0   ";
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=1   ";
        String sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat(tmp.type) type,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp " +
                " Inner JOIN base_patient p on tmp.patient  = p.id " +
@ -393,7 +393,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0 ";
        //已入学
        String sql1=" select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.org_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0   ";
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=1   ";
        String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
@ -424,33 +424,87 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    }
    public PageEnvelop getArchiveList(Integer type,Integer signStatus,Integer page,Integer size){
    public PageEnvelop getArchiveList(Integer type,Integer signStatus,String name,Integer page,Integer size){
        page = page>0?page-1:0;
        String countSql  ="select count(DISTINCT p.id)";
        String sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard from base_patient p  ";
        String countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1 ";
        String sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,null as sign_status from base_patient p where 1=1 ";
        String sqlCondition = "";
        if (null!=type){
            sqlCondition +=" and p.del=1 and p.archive_type="+type+" ";
        }
        if (null!=signStatus){
            if (-1==signStatus){//未签约
        if (null!=signStatus&&1==type){
            countSql  ="select count(DISTINCT p.id) from base_patient p,wlyy_archive a where a.patient = p.id ";
            sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,a.sign_status as sign_status from base_patient p,wlyy_archive a where a.patient = p.id ";
            if (0==signStatus){//未签约
                sqlCondition +=" and NOT EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) ";
            }
            if (1==signStatus){//已签约
            else if (1==signStatus){//已签约
                sqlCondition +=" and EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) ";
            }
        }
        if (null!=type){//档案类型
            sqlCondition +=" and p.del=1 and p.archive_type="+type+" ";
        }
        if (StringUtils.isNotBlank(name)){
            sqlCondition +=" and p.name like '%"+name+"%' ";
        }
        if(1==type){
            sqlCondition += " order by a.sign_status desc ";
        }
        Long count = jdbcTemplate.queryForObject(countSql+sqlCondition,Long.class);
        sqlCondition +=" limit "+page*size+","+size;
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+sqlCondition);
        for (Map<String,Object>tmp:result){
            String idcard= tmp.get("idcard").toString();
            if (StringUtils.isNotBlank(idcard)){
                try {
                    Integer age = IdCardUtil.getAgeForIdcard(idcard);
                    tmp.put("age",age);
                }catch (Exception e){
                    tmp.put("age",null);
                }
            }else {
                tmp.put("age",null);
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",result,page,size,count);
    }
    public JSONObject getArchiveNum(){
        JSONObject result = new JSONObject();
        String countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1 ";
        String sqlCondition = "";
        //老人
       String sqlCondition_sign =" and NOT EXISTS(select sr.id from base_service_package_sign_record sr " +
                " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                " where sr.patient = p.id) and p.del=1 and p.archive_type=1 ";
        //已签约
       String sqlCondition_unSign =" and EXISTS(select sr.id from base_service_package_sign_record sr " +
                " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                " where sr.patient = p.id) and p.del=1 and p.archive_type=1 ";
       //新生儿
        sqlCondition +=" and p.del=1 and p.archive_type="+2+" ";//新生儿
        Long count_children = jdbcTemplate.queryForObject(countSql+sqlCondition,Long.class);
        Long count_sign = jdbcTemplate.queryForObject(countSql+sqlCondition_sign,Long.class);
        Long count_unSign = jdbcTemplate.queryForObject(countSql+sqlCondition_unSign,Long.class);
        result.put("count_children",count_children);
        result.put("count_sign",count_sign);
        result.put("count_unSign",count_unSign);
        result.put("count_agedAll",count_sign+count_unSign);
        return result;
    }
}

+ 24 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -608,6 +608,30 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    }
    public JSONObject getPatientOrderList2(String patient, Integer status, int page, int size) {
        page = page>0?page-1:0;
        String sqlCount = "select count(ord.id) from  base_life_care_order ord where ord.patient = '"+patient+"' ";
        String sql = "select ord.id,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') createTime,DATE_FORMAT(ord.patient_expected_serve_time,'%Y-%m-%d %H:%i:%S') serveTime,ord.status,ord.hospital,ord.hospital_name hospitalName" +
                ",ord.doctor,ord.doctor_name doctorName,ord.expected_doctor_name expectedDoctorName,group_concat(Distinct fee.name SEPARATOR '、') serveItems" +
                " from base_life_care_order ord LEFT JOIN base_life_care_fee_detail fee on ord.id = fee.order_id " +
                "and fee.`status`<>3 where ord.patient = '"+patient+"' ";
        String fliter = "";
        if (status != null){
            fliter += " and ord.status = "+status;
        }
        Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class);
        fliter += " group by ord.id order by ord.create_time desc limit "+page*size+","+size;
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+fliter);
        JSONObject object = new JSONObject();
        object.put("total",count);
        object.put("detailModelList",result);
        object.put("currPage",page);
        object.put("pageSize",size);
        return object;
    }
    /**
     * 签到保存
     * @param orderId

+ 13 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.endpoint.third.platForm.PcManageWebSocketServer;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.device.PatientDeviceService;
@ -102,6 +103,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private PcManageWebSocketServer pcManageWebSocketServer;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -205,21 +208,23 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            }
        }
        //推送socket给医生  推送紧急预警
        JSONObject message = new JSONObject();
        message.put("session_id",sessionId);
        message.put("sender_name",orderDO.getPatientName());
        message.put("content_notice",orderDO.getPatientName()+" "+warnStr+"!");
        message.put("sender_code",orderDO.getPatient());
        message.put("OrderType",22);
        message.put("order_id",orderDO.getId());
        message.put("content_type",40);
        for (BaseDoctorDO doctorDO:doctorDOS){
            JSONObject message = new JSONObject();
            message.put("session_id",sessionId);
            message.put("sender_name",orderDO.getPatientName());
            message.put("content_notice",orderDO.getPatientName()+" "+warnStr+"!");
            message.put("sender_code",orderDO.getPatient());
            message.put("OrderType",22);
            message.put("order_id",orderDO.getId());
            message.put("content_type",40);
            try {
                imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //pc管理端端推送消息
        pcManageWebSocketServer.broadCast(message.toString());
        result.put("resultFlag", 1);
        result.put("resultMsg",orderDO);

+ 12 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -480,11 +480,21 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    }
    /**
     * 根据服务专题获取服务项目
     * 获取患者签约服务包
     * @param patient
     * @param topicType
     * @return
     */
    public List<Map<String, Object>> servicePackageByPatient(String patient)
    {
       String sql="select  DISTINCT pack.*,CASE WHEN pack.type=1 THEN '养老服务' WHEN pack.type=2 THEN '医疗服务'\n" +
                "WHEN pack.type=3 THEN '安防监护' WHEN pack.type=4 THEN '慢病管理' ELSE pack.type\n" +
                "END as 'typeName' from base_service_package_record re, base_service_package_item item,base_service_package pack  \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and pack.del=1  and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) ";
        List<Map<String,Object>> resultSql = jdbcTemplate.queryForList(sql);
        return resultSql;
    }
    public List<Map<String, Object>> servicePackageByTopicType(String patient, String topicType)
    {
        String sql="\n" +

+ 196 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -0,0 +1,196 @@
package com.yihu.jw.care.service.third;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.course.CourseService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by Bing on 2021/6/16.
 */
@Service
public class PatientInfoPlatFormService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @Autowired
    private CourseService courseService;
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private PatientDoorCoachOrderService patientDoorCoachOrderService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    /**
     * 老人--基本信息
     * @param patient
     * @param patientType 1老人 2新生儿
     * @return
     */
    public JSONObject getPatientInfo(String patient,Integer patientType){
        JSONObject result = new JSONObject();
        JSONObject tmp = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO!=null){
            tmp.put("name",patientDO.getName());
            tmp.put("sex",patientDO.getSex());
            tmp.put("address",patientDO.getAddress());
            tmp.put("address",patientDO.getAddress());
            tmp.put("patient",patientDO.getId());
            String idcard = patientDO.getIdcard();
            if (StringUtils.isNotBlank(idcard)){
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                tmp.put("age",age);
            }else {
                tmp.put("age",null);
            }
            //标签类型
            List<String> labelList = new ArrayList<>();
            Integer sex = patientDO.getSex();
            String sexName = sex!=null?(1==sex?"男":"女"):"未知";
            labelList.add(sexName);
            List<WlyyPatientLabelDO> labelDOS = patientLabelDao.findByPatient(patient);
            List<String> labeltmp = labelDOS.stream().map(WlyyPatientLabelDO::getLabelName).collect(Collectors.toList());
            labelList.addAll(labeltmp);
            tmp.put("patientLabel",labelList);
            result.put("patientInfo",tmp);//基本信息
            result.put("patientDevices",getDevices(patient,patientType));//健康设备
            if (1==patientType){
                result.put("signService",getSignService(patient));//签约服务
                result.put("MonitoringInfo",getPatientMonitoringInfo(patient));//安防监护信息
            }
            if (2==patientType){
                result.put("signService",getSignService(patient));//入园机构列表(报名且录取机构)
                result.put("MonitoringInfo",getMonitoringInfo(patient)); //新生儿入院信息
            }
            return result;
        }
        return null;
    }
    /**
     * 老人--获取签约服务
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getSignService(String patient){
       List<Map<String,Object>> list =  servicePackageService.servicePackageByPatient(patient);
        return list;
    }
    /**
     * 新生儿--获取入园机构列表(报名且录取机构)
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getEntranceOrgList(String patient){
        List<Map<String,Object>> list =  courseService.getEntranceOrgList(patient);
        return list;
    }
    /**
     * 老人/新生儿--获取健康设备
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getDevices(String patient,Integer patientType){
        List<Map<String,Object>> list = patientDeviceService.patientDeviceListByTopic(patient,null);
        return list;
    }
    /**
     * 老人/新生儿--获取就诊事件  暂无
     * @param patient
     * @return
     */
    public JSONObject getPatientEvent(String patient,Integer patientType,Integer page,Integer pageSize){
        return null;
    }
    /**
     * 老人/新生儿--患病情况 暂无
     * @param patient
     * @param patientType
     * @return
     */
    public JSONObject getIllnessInfo(String patient,Integer patientType){
        return null;
    }
    /**
     * 老人/新生儿--服务工单列表
     * @param patient
     * @param patientType
     * @return
     */
    public JSONObject getServiceOrder(String patient, Integer patientType, Integer page, Integer pageSize) throws Exception {
        if (1==patientType){//老人 生活照料
            return lifeCareOrderService.getPatientOrderList2(patient,null,page,pageSize);
        }
        if (2==patientType){//新生儿 上门辅导
            return patientDoorCoachOrderService.getDoorOrderList(null,null,null,null,
                    null,null,null,null,patient,page,pageSize, null);
        }
        return null;
    }
    /**
     * 老人/新生儿-- 体征信息
     * 老人:血糖、血压、身高体重、心率
     * 新生儿:体温
     * @param patient
     * @return
     */
    public JSONArray getHealthIndexInfo(String patient, int type, int gi_type, String begin, String end){
       return healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);//图表
    }
    /**
     * 老人-- 安防监护信息
     * @param patient
     * @return
     */
    public JSONObject getPatientMonitoringInfo(String patient){
        return securityMonitoringOrderService.patientMonitoringInfo(patient);
    }
    /**
     * 新生儿-- 入园监护 暂无
     * @param patient
     * @return
     */
    public JSONObject getMonitoringInfo(String patient){
        return null;
    }
}

+ 168 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/EntranceUtil.java

@ -1,12 +1,30 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.CourseDao;
import com.yihu.jw.care.dao.course.CourseSalesOrderRecordDao;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.care.course.CourseDO;
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.im.dao.ConsultTeamDao;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.swing.table.TableModel;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 教师与新生儿 入学关系更新工具
@ -17,6 +35,18 @@ public class EntranceUtil {
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private RecruitStudentsRecordDao recruitStudentsRecordDao;
    @Autowired
    private BaseDoorCoachOrderDao doorCoachOrderDao;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private CourseDao courseDao;
    @Autowired
    private CourseSalesOrderRecordDao courseSalesOrderRecordDao;
    /**
     *
@ -29,7 +59,7 @@ public class EntranceUtil {
     */
    public void newRecord(String patient,Integer type,Integer del,String doctorCode,String orgCode,String relationCode){
        if (1==type||2==type){//在线咨询与上门辅导不重复保存
            if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,orgCode,type)!=0){
            if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctorCode,type)!=0){
                return ;
            }
        }
@ -37,14 +67,23 @@ public class EntranceUtil {
        tmpDO.setPatient(patient);
        tmpDO.setType(type);
        tmpDO.setDel(del);
        tmpDO.setStatus(0);
        if (StringUtils.isBlank(orgCode)){
            List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(doctorCode);
            if (list.size()>0){
                orgCode = list.get(0).getOrgCode();
            }
        }
        if (doctorPatientTmpDao.findByPatientAndOrgCodeAndTypeAndStatus(patient,orgCode,3,1)!=0){
            tmpDO.setDel(0);
        }
        tmpDO.setOrgCode(orgCode);
        tmpDO.setDoctorCode(doctorCode);
        tmpDO.setRelationCode(relationCode);
        doctorPatientTmpDao.save(tmpDO);
    }
    /**
     * 更新状态
     * 更新状态 状态为1 已入学,将该幼儿咨询、上门、课程数据失效
     * @param relationCode
     */
    public void updateStatus(Integer status,String relationCode){
@ -52,7 +91,13 @@ public class EntranceUtil {
        if (tmpDO!=null){
            tmpDO.setStatus(status);
            doctorPatientTmpDao.save(tmpDO);
            if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                List<DoctorPatientTmpDO> list = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                List<String> relationCodes  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                deleteRecord2List(relationCodes);
            }
        }
    }
    /**
@ -61,18 +106,25 @@ public class EntranceUtil {
     */
    public void updateStatus2(Integer status,String[] relationCode) {
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        List<String>relationCodes = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO != null) {
                tmpDO.setStatus(status);
                list.add(tmpDO);
                if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                    List<DoctorPatientTmpDO> listTmp = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                    List<String> relationCodeTmp  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                    relationCodes.addAll(relationCodeTmp);
                }
            }
        }
        doctorPatientTmpDao.save(list);
        deleteRecord2List(relationCodes);
    }
    /**
     * 删除记录
     * 删除记录 单条
     * @param relationCode
     */
    public void deleteRecord(String relationCode){
@ -100,4 +152,116 @@ public class EntranceUtil {
        doctorPatientTmpDao.save(list);
    }
    /**
     * 删除记录
     * @param relationCode
     */
    public void deleteRecord2List(List<String> relationCode){
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setDel(0);
            }
        }
        doctorPatientTmpDao.save(list);
    }
    /**
     * 初始化数据
     */
    public void initData(){
        List<DoctorPatientTmpDO> saveList = new ArrayList<>();
        //入学
        List<RecruitStudentsRecordDO> enList = recruitStudentsRecordDao.findByDelAndStatus(1,"2");
        List<String> patients = enList.stream().map(RecruitStudentsRecordDO::getPatient).collect(Collectors.toList());
        for (RecruitStudentsRecordDO tmp:enList){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(3);
            tmpDO.setDel(1);
            tmpDO.setStatus(1);
            tmpDO.setOrgCode(tmp.getOrgCode());
            tmpDO.setRelationCode(tmp.getId());
            saveList.add(tmpDO);
        }
        //上门
        List<BaseDoorCoachOrderDO> doorlist = doorCoachOrderDao.queryByStatusIn(new Integer[]{3,4,5,6,});
        for (BaseDoorCoachOrderDO tmp:doorlist){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(2);
            if (patients.contains(tmp.getPatient())){
                tmpDO.setDel(0);
            }
            else {
                tmpDO.setDel(1);
            }
            tmpDO.setStatus(0);
            tmpDO.setDoctorCode(tmp.getDoctor());
            tmpDO.setOrgCode(tmp.getHospital());
            tmpDO.setRelationCode(tmp.getId());
            saveList.add(tmpDO);
        }
        //咨询
        List<ConsultTeamDo> consultList = consultTeamDao.findByTypeAndDel(23,"1");
        for (ConsultTeamDo tmp:consultList){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(1);
            if (patients.contains(tmp.getPatient())){
                tmpDO.setDel(0);
            }
            else {
                tmpDO.setDel(1);
            }
            tmpDO.setStatus(0);
            tmpDO.setDoctorCode(tmp.getDoctor());
            if (StringUtils.isNotBlank(tmp.getDoctor())){
                List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(tmp.getDoctor());
                if (list.size()>0){
                    tmpDO.setOrgCode(list.get(0).getOrgCode());
                }
            }
            tmpDO.setRelationCode(tmp.getConsult());
            saveList.add(tmpDO);
        }
        //课程
        List<CourseSalesOrderRecordDO> courseList = courseSalesOrderRecordDao.findByStatus("2");
        for (CourseSalesOrderRecordDO tmp:courseList){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(4);
            if (patients.contains(tmp.getPatient())){
                tmpDO.setDel(0);
            }
            else {
                tmpDO.setDel(1);
            }
            tmpDO.setStatus(0);
            CourseDO courseDO = courseDao.findOne(tmp.getCourseId());
            if (courseDO!=null){
                tmpDO.setDoctorCode(courseDO.getDoctor());
            }
            tmpDO.setOrgCode(tmp.getOrgCode());
            tmpDO.setRelationCode(tmp.getId());
            saveList.add(tmpDO);
        }
        for (DoctorPatientTmpDO tmp:saveList){
            if (1==tmp.getType()||2==tmp.getType()){//在线咨询与上门辅导不重复保存
                if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(tmp.getPatient(),tmp.getDoctorCode(),tmp.getType())!=0){
                    continue;
                }
            }
            doctorPatientTmpDao.save(tmp);
        }
    }
    /**
     * 清除所有数据
     */
    public void deleteAll(){
        doctorPatientTmpDao.deleteAll();
    }
}

+ 1 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -139,7 +139,7 @@ public class YsDeviceService {
                    jsonObject.put("patientPhone",patientDO.getMobile());
                    jsonObject.put("serveDesc","疑似跌倒!");
                    jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                    jsonObject.put("serveAddress",deviceDO.getAddress());
                    jsonObject.put("serveAddress",deviceDO.getSosAddress());
                    jsonObject.put("serveLat",lat);
                    jsonObject.put("serveLon",lon);
                    jsonObject.put("topicItem","preventFall");