Selaa lähdekoodia

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

wangjun 3 vuotta sitten
vanhempi
commit
72d13503e5
27 muutettua tiedostoa jossa 649 lisäystä ja 74 poistoa
  1. 1 0
      common/common-entity/sql记录
  2. 46 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/booking/BaseBookingServiceDo.java
  3. 3 3
      common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java
  4. 12 4
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  5. 31 23
      common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java
  6. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  7. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/booking/BaseBookingServiceDao.java
  8. 49 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/booking/BaseBookingServiceEndpoint.java
  9. 40 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  10. 10 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  11. 39 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/OnlineContactEndpoint.java
  12. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  13. 7 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  14. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java
  15. 37 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/booking/BaseBookingServiceService.java
  16. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  17. 142 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  18. 60 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  19. 6 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java
  20. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java
  21. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  22. 115 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java
  23. 10 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  24. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  25. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  26. 9 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  27. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

+ 1 - 0
common/common-entity/sql记录

@ -1243,3 +1243,4 @@ CREATE TABLE `base_patient_sos_contacts` (
ALTER table base.base_patient_sos_contacts add column phone_seqid int(2) default null COMMENT '联系人序号';
ALTER table base_emergency_assistance_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_security_monitoring_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_service_package_record add column team_code varchar(50) DEFAULT NULL COMMENT '团队id';

+ 46 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/booking/BaseBookingServiceDo.java

@ -0,0 +1,46 @@
package com.yihu.jw.entity.care.booking;
import javax.persistence.*;
/***
 * @ClassName: BaseBookingServiceDo
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:19
 */
@Entity
@Table(name="base_booking_service")
public class BaseBookingServiceDo {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    private String patient;
    private Integer status;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java

@ -19,7 +19,7 @@ public class PatientSosContactsDO extends IdEntity {
    private String patient;
    private String sosName; //紧急联系人
    private String sosPhone; //联系电话
    private String relation; //与联系人关系 同base_patient_family_member
    private Integer relation; //与联系人关系 同base_patient_family_member
    private Date updateTime; //修改日期
    private Integer successFlag;//联系人是否同步成功 -2删除失败 -1添加失败 0待同步 1添加成功 2删除成功
    private Integer del;
@ -51,11 +51,11 @@ public class PatientSosContactsDO extends IdEntity {
        this.sosPhone = sosPhone;
    }
    public String getRelation() {
    public Integer getRelation() {
        return relation;
    }
    public void setRelation(String relation) {
    public void setRelation(Integer relation) {
        this.relation = relation;
    }

+ 12 - 4
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1359,9 +1359,10 @@ public class DateUtil {
     *  返回 xx天XX小时XX分钟XX秒前
     * @param date1 当前时间
     * @param date2 过去时间
     * @param fliter 0不携带秒 1携带秒
     * @return
     */
    public static String getDifferentTimeInfo(Date date1, Date date2){
    public static String getDifferentTimeInfo(Date date1, Date date2,Integer fliter){
        if (date1 == null || date2 == null){
            return null;
        }
@ -1390,11 +1391,18 @@ public class DateUtil {
                return result.toString();
            }
        }
        if (secondFieldDiff > 0L) {
            result.append(String.format("%d秒", secondFieldDiff));
        if (1==fliter){
            if (secondFieldDiff > 0L) {
                result.append(String.format("%d秒", secondFieldDiff));
            }
        }else {
            if (result.indexOf("分钟")==-1){
                result.append("1分钟前");
                return result.toString();
            }
        }
        result.append("前");
        return result.toString();
    }
}

+ 31 - 23
common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java

@ -54,17 +54,19 @@ public class HealthIndexUtil {
            int index = Integer.valueOf(values[1]);
            String value1 = values[0];
            // 餐后
            if (index % 2 == 0) {
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter));
            if (StringUtils.isNotBlank(value1)){
                if (index % 2 == 0) {
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter));
            } else { //餐前
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore));
                } else { //餐前
                    tmp.put("value1",value1);
                    tmp.put("indexName","血糖");
                    tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore));
                }
                result.add(tmp);
            }
            result.add(tmp);
        }
        //血压校验
        else if (type == 2) {
@ -78,17 +80,21 @@ public class HealthIndexUtil {
            Double maxValueSZY = HEALTH_STANDARD_SZY_MAX;
            Double minValueSZY = HEALTH_STANDARD_SZY_MIN;
            // 收缩压/舒张压校验
            tmp.put("value1",value1);
            tmp.put("indexName","收缩压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY));
            result.add(tmp);
            if (StringUtils.isNotBlank(value1)){
                tmp.put("value1",value1);
                tmp.put("indexName","收缩压");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY));
                result.add(tmp);
            }
            //舒张压校验
            tmp = new JSONObject();
            tmp.put("value1",value2);
            tmp.put("indexName","舒张压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY));
            result.add(tmp);
            tmp = new JSONObject();
            if (StringUtils.isNotBlank(value2)){
                tmp = new JSONObject();
                tmp.put("value1",value2);
                tmp.put("indexName","舒张压");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY));
                result.add(tmp);
                tmp = new JSONObject();
            }
            //脉搏检验
            if (StringUtils.isNotBlank(value3)){
                tmp.put("value1",value3);
@ -99,10 +105,12 @@ public class HealthIndexUtil {
        }
        else if (type == 5) {//心率
            String value1 = values[0];//心率
            tmp.put("value1",value1);
            tmp.put("indexName","心率");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
            result.add(tmp);
            if (StringUtils.isNotBlank(value1)){
                tmp.put("value1",value1);
                tmp.put("indexName","心率");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
                result.add(tmp);
            }
        }
        return result;
    }

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -589,7 +589,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        } else if ("2".equals(loginType)) {//2.为医生账号
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ?", username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?", username, username);
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ? limit 1", username, username);
        } else if ("4".equals(loginType)) { //4.第三方患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?", username, getIdcard());
        }

+ 21 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/booking/BaseBookingServiceDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.care.dao.booking;
import com.yihu.jw.entity.care.booking.BaseBookingServiceDo;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/***
 * @ClassName: BaseBookingServiceDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:23
 */
public interface BaseBookingServiceDao extends PagingAndSortingRepository<BaseBookingServiceDo,String>,
        JpaSpecificationExecutor<BaseBookingServiceDo> {
    @Query("select a from BaseBookingServiceDo a where a.patient = ?1 and a.status = '1'")
    BaseBookingServiceDo findByPatient(String patient);
}

+ 49 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/booking/BaseBookingServiceEndpoint.java

@ -0,0 +1,49 @@
package com.yihu.jw.care.endpoint.booking;
import com.yihu.jw.care.service.booking.BaseBookingServiceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
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.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;
/***
 * @ClassName: BaseBookingServiceEndpoint
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:31
 */
@RestController
@RequestMapping("bookingService" )
@Api(tags = "预订服务弹框", description = "预订服务弹框")
public class BaseBookingServiceEndpoint  extends EnvelopRestEndpoint {
    @Autowired
    private BaseBookingServiceService serviceService;
    @ApiOperation("是否需要弹框")
    @GetMapping(value= "findByPatient")
    public Envelop findByPatient(@ApiParam(name = "patient", value = "patient", required = true) @RequestParam(value = "patient", required = true)String patient){
        return success("获取成功!",serviceService.findByPatient(patient));
    }
    @ApiOperation("保存,不在弹框")
    @GetMapping(value= "saveByPatient")
    public Envelop saveByPatient(@ApiParam(name = "patient", value = "patient", required = true) @RequestParam(value = "patient", required = true)String patient){
        try {
            serviceService.saveByPatient(patient);
            return success("保存成功!");
        }catch (Exception e){
            e.printStackTrace();
            return success("保存失败!");
        }
    }
}

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

@ -9,6 +9,7 @@ import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -303,4 +304,43 @@ public class PatientDeviceController extends BaseController {
            return errorResult(e);
        }
    }
    @ApiOperation("获取设备详情信息")
    @RequestMapping(value = "getPatientDeviceDetail",method = RequestMethod.GET)
    public String getPatientDeviceDetail(@ApiParam(name="patient")
                                         @RequestParam(value = "patient")String patient,
                                         @ApiParam(name="deviceSN")
                                         @RequestParam(value = "deviceSN")String deviceSn){
        try {
            JSONObject result = patientDeviceService.getPatientDeviceDetail(patient,deviceSn);
            if (result.getInt(ResponseContant.resultFlag)==ResponseContant.success){
                return write(200,"获取成功","data",result.getJSONObject(ResponseContant.resultMsg));
            }else {
                return error(-1,result.getString(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("获取设备详情信息")
    @RequestMapping(value = "getPatientDeviceData",method = RequestMethod.GET)
    public String getPatientDeviceData(@ApiParam(name="patient")
                                       @RequestParam(value = "patient")String patient,
                                       @ApiParam(name="deviceSN")
                                       @RequestParam(value = "deviceSN")String deviceSn,
                                       @ApiParam(name="page")
                                       @RequestParam(value = "page")Integer page,
                                       @ApiParam(name="pageSize")
                                       @RequestParam(value = "pageSize")Integer pageSize){
        try {
            return write(200,"获取成功","data",patientDeviceService.getPatientDeviceData(patient,deviceSn,page,pageSize));
        }catch (Exception e){
            return errorResult(e);
        }
    }
}

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

@ -232,6 +232,16 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "/baseInfoCount")
    @ApiOperation(value = "医生首页服务数量获取")
    public ObjEnvelop baseInfoCount(@ApiParam(name="doctor")@RequestParam(value = "doctor")String doctor){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorService.baseInfoCount(doctor)) ;
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "/initEntranceData")
    @ApiOperation(value = "初始化新生儿未入学埋点数据")
    public Envelop initEntranceData(){

+ 39 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/OnlineContactEndpoint.java

@ -0,0 +1,39 @@
package com.yihu.jw.care.endpoint.patient;
import com.yihu.jw.care.service.patient.OnlineContactService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/***
 * @ClassName: OnlineContactEndpoint
 * @Description: 在线联系
 * @Auther: shi kejing
 * @Date: 2021/8/11 16:43
 */
@RestController
@RequestMapping("online" )
@Api(tags = "在线联系", description = "在线联系")
public class OnlineContactEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private OnlineContactService service;
    @GetMapping(value = "getOnLineObj")
    @ApiOperation(value = "获取在线联系")
    public Envelop getOnLineObj(
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient) {
        try{
            return success("获取成功",service.getOnLineObj(patient));
        }catch (Exception e){
            return failedException2(e);
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -324,7 +324,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop patientMonitoringInfo(@ApiParam(name = "patient", value = "patient")
                                @RequestParam(value = "patient") String patient,
                                @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                @RequestParam(value = "topicItem",required = false,defaultValue = "preventLost") String topicItem) {
                                @RequestParam(value = "topicItem",required = false) String topicItem) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo(patient,topicItem));
        } catch (Exception e) {

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

@ -289,7 +289,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(assistanceDO.getId());
        for (BaseEmergencyWarnLogDO tmp:logDOS){
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime()));
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime(),0));
        }
        emergencyOrderVO.setOrderLogInfo(logDOS);
        List<PatientSosContactsDO> contactsDOS = contactsService.getPatientSosContacts(assistanceDO.getPatient());
@ -554,7 +554,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql.append(" AND EXISTS (" +
                    "SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = i.team_code " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                    " and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') group by ord.status");
        }
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
@ -604,7 +604,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql.append(" AND EXISTS (" +
                    "SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = i.team_code " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                    " and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
        }
        if (StringUtils.isNotBlank(patient)){
@ -632,7 +632,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql.append(" AND EXISTS (" +
                    "SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = i.team_code " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                    " and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
        }
        if (StringUtils.isNotBlank(patient)){
@ -859,7 +859,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                logDO.setOrderId(orderId);
                logDO.setUserType(2);
                logDO.setCreateTime(new Date());
                logDO.setContent("助老员"+doctorDO.getName()+"前往定位");
                logDO.setContent("前往定位");
                logDao.save(logDO);
            }
        }
@ -969,7 +969,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        String sql = " select '20' as OrderType,ord.id,ord.doctor,ord.status,p.name,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time" +
                " from base_emergency_assistance_order ord INNER JOIN base_doctor p on ord.doctor = p.id where ord.doctor='"+doctor+"'" ;
        sql +="UNION " +
                "select  '22' as 'OrderType',ord.id,ord.doctor,p.name,ord.status,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "select  '22' as 'OrderType',ord.id,ord.doctor,ord.status,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_security_monitoring_order ord INNER JOIN base_doctor p on ord.doctor = p.id  where ord.doctor='"+doctor+"'" ;
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);
@ -998,7 +998,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                logDO.setUserCode(doctor);
                logDO.setUserName(doctorDO.getName());
                logDO.setUserType(2);
                logDO.setContent("助老员"+doctorDO.getName()+"发送消\""+message+"\"");
                logDO.setContent("发送消息\""+message+"\"");
                logDO.setCreateTime(new Date());
                logDao.save(logDO);
            }

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java

@ -180,7 +180,7 @@ public class BirthdayWishesService {
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                "and i.del = 1 and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "' " ;
        List<Map<String, Object>> patientInfos =  jdbcTemplate.queryForList(sql);
@ -226,7 +226,7 @@ public class BirthdayWishesService {
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                "and i.del = 1 and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "'  " ;
        List<String> patientInfos =  jdbcTemplate.queryForList(sql,String.class);
@ -261,7 +261,7 @@ public class BirthdayWishesService {
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code ";
                "and i.del = 1 and m.team_code = r.team_code ";
        //根据权限获取生日居民列表
        if (roleType == 1) {

+ 37 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/booking/BaseBookingServiceService.java

@ -0,0 +1,37 @@
package com.yihu.jw.care.service.booking;
import com.yihu.jw.care.dao.booking.BaseBookingServiceDao;
import com.yihu.jw.entity.care.booking.BaseBookingServiceDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/***
 * @ClassName: BaseBookingServiceService
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/12 10:24
 */
@Service
public class BaseBookingServiceService {
    @Autowired
    private BaseBookingServiceDao serviceDao;
    public void saveByPatient(String patient) throws Exception {
            BaseBookingServiceDo serviceDo = new BaseBookingServiceDo();
            serviceDo.setPatient(patient);
            serviceDo.setStatus(1);
            serviceDao.save(serviceDo);
    }
    public int findByPatient(String patient){
        BaseBookingServiceDo serviceDo = serviceDao.findByPatient(patient);
        if (serviceDo != null){
            return serviceDo.getStatus();
        }else {
            return 0;
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -282,7 +282,7 @@ public class ContactsService {
                contactsDO.setPatient(patient);
                contactsDO.setSosName(name);
                contactsDO.setSosPhone(num);
                contactsDO.setRelation(relation);
                contactsDO.setRelation(Integer.parseInt(relation));
                contactsDO.setSuccessFlag(0);
                sosContactsDao.save(contactsDO);
            }

+ 142 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -1,10 +1,13 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.care.util.ConcealUtil;
import com.yihu.jw.care.util.MyJdbcTemplate;
@ -15,9 +18,12 @@ import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
@ -79,6 +85,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
@ -91,6 +99,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private String esIndex;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private ContactsService contactsService;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @PostConstruct
    public void init() {
@ -761,13 +773,141 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return resultMap;
    }
    /**
     * 根据设备sn及居民code获取居民有效的设备绑定信息
     * @param deviceSn 设备sn码
     * @return
     */
    public JSONObject getPatientDeviceDetail(String patient,String deviceSn){
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (null==patientDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"当前居民不存在");
        }
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        if (devices.size()==0){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"未查询到该设备");
        }else {
            DevicePatientDevice device = devices.get(0);
            if (!patient.equals(device.getUser())){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"居民未绑定该设备");
            }else {
                String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
                        "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' ";
                Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
                devInfo.put("patient",patient);
                devInfo.put("patientName",patientDO.getName());
                devInfo.put("sosContactsDOS",new ArrayList<>());
                if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
                    devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
                }
                result.put(ResponseContant.resultFlag,ResponseContant.success);
                result.put(ResponseContant.resultMsg,JSON.parseObject(JSON.toJSONString(devInfo, SerializerFeature.WriteMapNullValue)));
            }
        }
        return result;
    }
    /**
     * 根据设备sn及居民code获取居民有效的设备绑定数据
     * @param deviceSn 设备sn码
     * @return
     */
    public List<DevicePatientDevice> findByDeviceSn(String deviceSn){
       return  patientDeviceDao.findByDeviceSn(deviceSn);
    public JSONObject getPatientDeviceData(String patient,String deviceSn,Integer page,Integer pageSize)throws Exception{
        page = page>0?page-1:0;
        JSONObject result = new JSONObject();
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        if (devices.size()>0){
            DevicePatientDevice device = devices.get(0);
            if (!patient.equals(device.getUser())){
                throw new Exception("居民未绑定该设备");
            }else{
                switch (device.getCategoryCode()){
                    case "1"://血压设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        break;
                    case "2"://血糖设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        break;
                    case "4"://手表 紧急工单与安防工单
                        result = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                    case "7"://报警器 紧急工单
                        result = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                    case "12"://监控
                        com.alibaba.fastjson.JSONObject tmp =ysDeviceService.getDeviceLiveAddress(patient,deviceSn,1,null);
                        result.put("monitorInfoStatus",tmp.getIntValue(ResponseContant.resultFlag));
                        if (tmp.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                            result.put("monitorInfo",tmp.getString(ResponseContant.resultMsg));
                        }
                        else {
                            result.put("monitorInfo",tmp.getJSONObject(ResponseContant.resultMsg));
                        }
                        break;
                    default://安防设备
                        result = null;
                        break;
                }
            }
        }else {
            throw new Exception("设备未被绑定");
        }
        return result;
    }
    public JSONObject getHealthIndex(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){
        String sqlCount = "select count(id) from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 ";
        String sql = "select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) sign_status from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 order by record_date desc limit "+page*pageSize+","+pageSize;
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:list){
            Integer type =Integer.parseInt(tmp.get("type").toString());
            String value1 = tmp.get("value1")==null?null:tmp.get("value1").toString();
            String value2 = tmp.get("value2")==null?null:tmp.get("value2").toString();
            String value3 = tmp.get("value3")==null?null:tmp.get("value3").toString();
            String value4 = tmp.get("value4")==null?null:tmp.get("value4").toString();
            String value5 = tmp.get("value5")==null?null:tmp.get("value5").toString();
            String value6 = tmp.get("value6")==null?null:tmp.get("value6").toString();
            String value7 = tmp.get("value7")==null?null:tmp.get("value7").toString();
            com.alibaba.fastjson.JSONArray errorInfo = healthIndexUtil.verifyHealthIndex(type,value1,value2,value3,value4,value5,value6,value7);
            tmp.put("errorInfo",errorInfo);
        }
        result.put("total",count);
        result.put("page",page+1);
        result.put("pageSize",pageSize);
        result.put("dataList",list);
        return result;
    }
    public JSONObject getEmeWarn(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){
        String sqlCount = "select SUM(total) from( \n" +
                "select count(ord.id) as total from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' " +
                " and ord.patient='"+patient+"' " +
                "UNION All " +
                "select count(ord.id)  as total from base_security_monitoring_order ord  where ord.device_sn='"+deviceSn+"' " +
                " and ord.patient='"+patient+"' )A ";
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        String sql = "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"' " +
                "UNION " +
                "select  '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
                "ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order ord " +
                " where ord.device_sn='"+deviceSn+"' and ord.patient='"+patient+"'  order by create_time desc limit "+page*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        result.put("total",count);
        result.put("page",page+1);
        result.put("pageSize",pageSize);
        result.put("dataList",list);
        return result;
    }
     /******************************************* 爱牵挂设备start *****************************************************/

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

@ -2,18 +2,21 @@ package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.service.birthday.BirthdayWishesService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
@ -24,10 +27,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by yeshijie on 2021/3/3.
@ -60,6 +60,8 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private ImService imService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private BirthdayWishesService birthdayWishesService;
    /**
     * 获取医生简单详情
@ -76,7 +78,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        String sql1 = "SELECT COUNT(DISTINCT sr.patient) FROM " +
                " base_service_package_sign_record sr, base_service_package_record r, base_service_package_item i, base_team_member m " +
                " WHERE  sr.id = r.sign_id and sr.status=1  AND r.service_package_id = i.service_package_id " +
                " AND i.del = 1 and m.team_code = i.team_code " +
                " AND i.del = 1 and m.team_code = r.team_code " +
                "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
        Integer signNum = jdbcTemplate.queryForObject(sql1,Integer.class);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
@ -547,4 +549,57 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    }
    public JSONObject baseInfoCount(String doctor){
        JSONObject result = new JSONObject();
        result.put("lifeCare",0);
        result.put("emergencyAssistance",0);
        result.put("patientCare",0);//人文关怀
        result.put("security",0);
        List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(doctor);
        String hospital = doctorHospitalDOs.get(0).getOrgCode();
        //生活照料
        String countSql = "SELECT  " +
                "   count(o.id)  " +
                " FROM  " +
                "   base_life_care_order o  " +
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " WHERE  " +
                "  o.hospital = 'hospital' "+
                " AND o.status = 1 and o.pay_status>0  ";
        Long count = jdbcTemplate.queryForObject(countSql,Long.class);
        if (count>0){
            result.put("lifeCare",count);
        }
        //紧急救助
        countSql = " select count(ord.id) count from base_emergency_assistance_order ord where ord.status=1 " +
                "AND EXISTS (SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_service_package_item i ,base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and " +
                " sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                "  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        count = jdbcTemplate.queryForObject(countSql,Long.class);
        if (count>0){
            result.put("emergencyAssistance",count);
        }
        //安防工单
        countSql = " select count(ord.id) count from base_security_monitoring_order ord where ord.status=1 " +
                "AND EXISTS (SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_service_package_item i ,base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and " +
                " sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and  m.team_code = r.team_code " +
                "  and i.del = 1 and sr.`status`=1  and i.topic_item='security' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        count = jdbcTemplate.queryForObject(countSql,Long.class);
        if (count>0){
            result.put("security",count);
        }
        //人文关怀
        try {
            Integer counts = birthdayWishesService.getPatientByDoctorCount(doctor);
            if (count>0){
                result.put("patientCare",count);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
}

+ 6 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java

@ -95,7 +95,7 @@ public class DoctorMessageService {
            sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                    " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
            sql+=" order by create_time asc ";
            Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
            if (sqlResult.containsKey("count")){
@ -119,7 +119,7 @@ public class DoctorMessageService {
            sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                    " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
            sql+=" order by create_time asc ";
            Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
            if (sqlResult.containsKey("count")){
@ -148,7 +148,7 @@ public class DoctorMessageService {
                    "and  EXISTS ( \n" +
                    "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                    "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                    "r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                    "r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                    "and m.doctor_code = '"+doctor+"' and m.del = '1') \n" +
                    "order by create_time DESC ";
@ -159,7 +159,7 @@ public class DoctorMessageService {
                        "and  EXISTS ( \n" +
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                        "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                        "and m.doctor_code = '"+doctor+"' and m.del = '1') ";
            }
@ -173,7 +173,7 @@ public class DoctorMessageService {
                    "and EXISTS ( \n" +
                    "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                    "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                    "r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' \n" +
                    "r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' \n" +
                    "and m.doctor_code = '"+doctor+"' and m.del = '1')\n" +
                    "order by create_time DESC ";
@ -186,7 +186,7 @@ public class DoctorMessageService {
                        "and EXISTS ( \n" +
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                        "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' \n" +
                        "and m.doctor_code = '"+doctor+"' and m.del = '1')";
            }

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -134,7 +134,7 @@ public class PatientMessageService {
                logDO.setOrderId(messageDO.getRelationCode());
                logDO.setUserType(1);
                logDO.setCreateTime(new Date());
                logDO.setContent("家属"+patientDO.getName()+"已知悉预警消息");
                logDO.setContent("已知悉");
                logDao.save(logDO);
            }
        }

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -79,7 +79,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        String filters = " from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_patient p " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and p.id = sr.patient " +
                "and i.del = 1 and m.team_code = r.team_code and p.id = sr.patient " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        if(!StringUtil.isEmpty(name)){

+ 115 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java

@ -0,0 +1,115 @@
package com.yihu.jw.care.service.patient;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.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;
/***
 * @ClassName: OnlineContactService
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/11 16:47
 */
@Service
public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePatientDao> {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ImUtil imUtil;
    public JSONObject getOnLineObj(String patient){
        JSONObject obj = new JSONObject();
        String zlySql = "SELECT  doc.* from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc \n" +
                "WHERE sr.status=1 and m.team_code = r.team_code and m.doctor_code = doc.id and sr.id=r.sign_id and sr.patient='"+patient+"' and m.del = '1' ";
        String jsSql = "SELECT p.*,pfm.family_relation familyRelation,p.archive_type\n" +
                "FROM base_patient_family_member pfm,base_patient p\n" +
                "WHERE pfm.del = 1 AND pfm.family_member = p.id AND p.patient_status = 1 AND pfm.patient = '"+patient+"'";
        String fwzSql = "SELECT org.* from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_org org \n" +
                "WHERE sr.status=1 and m.team_code = r.team_code and m.org_code = org.code and sr.id=r.sign_id \n" +
                "and sr.patient='"+patient+"' and m.del = '1' ";
        List<Map<String,Object>> zlyList = jdbcTemplate.queryForList(zlySql);
        List<Map<String,Object>> jsList = jdbcTemplate.queryForList(jsSql);
        List<Map<String,Object>> fwzList = jdbcTemplate.queryForList(fwzSql);
        if (zlyList.size() > 0){
            for (int i=0;i<zlyList.size();i++){
                List list = new ArrayList();
                JSONObject helperObj = new JSONObject();
                helperObj.put("id",zlyList.get(i).get("id"));
                helperObj.put("name",zlyList.get(i).get("name"));
                helperObj.put("photo",zlyList.get(i).get("photo"));
                Integer onLineFlag =0;
                String onLineStr = imUtil.findByUserIdAndType(zlyList.get(i).get("id").toString(),"helper");
                JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
                if (200 == oneLineObj.getInteger("status")){
                    if (oneLineObj.getInteger("data")>0){
                        onLineFlag=1;
                    }
                }
                helperObj.put("onLineFlag", onLineFlag);
                list.add(helperObj);
                obj.put("helperObj",list);///助老员
            }
        }
        if (jsList.size() > 0){
            for (int i=0;i<jsList.size();i++){
                JSONObject familyObj = new JSONObject();
                List list = new ArrayList();
                familyObj.put("id",jsList.get(i).get("id"));
                familyObj.put("name",jsList.get(i).get("name"));
                familyObj.put("photo",jsList.get(i).get("photo"));
                familyObj.put("familyRelation",jsList.get(i).get("familyRelation"));
                String archive_type = null;
                Integer onLineFlag =0;
                switch (jsList.get(i).get("archive_type").toString()){
                    case "1":
                        archive_type = "older";//老人
                        break;
                    case "2":
                        archive_type = "child";//新生儿
                        break;
                }
                if (StringUtils.isNotBlank(archive_type)){
                    String onLineStr = imUtil.findByUserIdAndType(jsList.get(i).get("id").toString(),archive_type);
                    JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
                    if (200 == oneLineObj.getInteger("status")){
                        if (oneLineObj.getInteger("data")>0){
                            onLineFlag=1;
                        }
                    }
                }
                familyObj.put("onLineFlag", onLineFlag);
                list.add(familyObj);
                obj.put("familyObj",list);
            }
        }
        if (fwzList.size() > 0){
            for (int i=0;i<fwzList.size();i++){
                JSONObject serStationObj = new JSONObject();
                List list = new ArrayList();
                serStationObj.put("code",fwzList.get(i).get("code"));
                serStationObj.put("name",fwzList.get(i).get("name"));
                serStationObj.put("photo",fwzList.get(i).get("photo"));
                serStationObj.put("mobile",fwzList.get(i).get("mobile"));
                serStationObj.put("address",fwzList.get(i).get("address"));
                list.add(serStationObj);
                obj.put("serStationObj",list);
            }
        }
        return obj;
    }
}

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

@ -276,7 +276,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(orderDO.getId());
        for (BaseEmergencyWarnLogDO tmp:logDOS){
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime()));
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime(),0));
        }
        emergencyOrderVO.setOrderLogInfo(logDOS);
        List<PatientSosContactsDO> contactsDOS = contactsService.getPatientSosContacts(orderDO.getPatient());
@ -505,7 +505,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                    " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        }
        if (StringUtils.isNotBlank(serverDoctor)){
            fliter +=" and ord.doctor = '"+serverDoctor+"' ";
@ -607,7 +607,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            fliter+=" and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                    " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        }
        if (StringUtils.isNotBlank(patient)){
            fliter+=" and ord.patient='"+patient+"' ";
@ -626,10 +626,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        String pyCode = "";
        for (Map<String,Object> map:sqlResult){
            result.put("status_"+map.get("status"),result.getInteger("status_"+map.get("status"))+Integer.parseInt(map.get("count").toString()));
            pyCode =  serverTmp.get(map.get("serve_desc")).toString();
            result.put("svr_"+pyCode,result.getInteger("svr_"+pyCode)+Integer.parseInt(map.get("count").toString()));
            result.put("status_all",result.getInteger("status_all")+Integer.parseInt(map.get("count").toString()));
            result.put("svr_all",result.getInteger("svr_all")+Integer.parseInt(map.get("count").toString()));
            pyCode =  serverTmp.get(map.get("serve_desc"))==null?null:serverTmp.get(map.get("serve_desc")).toString();
            if (StringUtils.isNotBlank(pyCode)){
                result.put("svr_"+pyCode,result.getInteger("svr_"+pyCode)+Integer.parseInt(map.get("count").toString()));
                result.put("status_all",result.getInteger("status_all")+Integer.parseInt(map.get("count").toString()));
                result.put("svr_all",result.getInteger("svr_all")+Integer.parseInt(map.get("count").toString()));
            }
        }
        return result;
    }
@ -642,7 +644,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
                "base_team_member m " +
                "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
                " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        sql +=" order by ord.create_time asc ";
        result= jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:result){

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java

@ -102,7 +102,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
                    "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                    "base_service_package_item i,base_team_member m " +
                    "WHERE  sr.id = r.sign_id and sr.patient = a.patient and sr.status=1 and r.service_package_id = i.service_package_id " +
                    "and i.del = 1 and m.team_code = i.team_code " ;
                    "and i.del = 1 and m.team_code = r.team_code " ;
            if(StringUtils.isNotBlank(doctorId)){
                filters += " and m.doctor_code = '"+doctorId+"' ";
            }

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java

@ -131,7 +131,7 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
                "base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_team_member m  " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "                and i.del = 1 and m.team_code = i.team_code and ar.patient = sr.patient " +
                "                and i.del = 1 and m.team_code = r.team_code and ar.patient = sr.patient " +
                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1 " +
                "GROUP BY ar.level_conclusion" ;
        List<Map<String,Object>> countMapList = jdbcTemplate.queryForList(sql);

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

@ -256,7 +256,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     */
    public int getSignTotal(String doctorId){
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id" +
                "WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        return jdbcTemplate.queryForObject(sql,Integer.class);
@ -483,10 +483,14 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag " +
                "from base_service_package_sign_record spsr,base_service_package_record r,base_team_member mem,base_doctor doc " +
                "WHERE spsr.patient = '"+patient+"' AND spsr.status = 1  " +
                "and r.team_code = mem.team_code and spsr.id=r.sign_id and mem.doctor_code = doc.id and mem.del=1 ";
        String sql="SELECT  DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 " +
                " THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,doc.job_title_name as jobName,doc.job_title_code as job, " +
                " 0 as onLineFlag,org.code,org.name as orgName " +
                "from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc, " +
                "base_service_package pack,base_org org " +
                "WHERE sr.patient='"+patient+"' and sr.status=1  and m.team_code = r.team_code and " +
                " m.doctor_code = doc.id and sr.id=r.sign_id and pack.id = r.service_package_id and pack.org_code = org.code " +
                " and m.del = '1'";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        if ("1".equals(onlineFlag)){//展示是否在线
            String listStr = imUtil.getOnlineListByType("helper");

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -277,7 +277,7 @@ public class StatisticsService {
        Integer helperTotal = 0;
        Integer teacherTotal = 0;
        //老人 儿童注册人数
        String sql1 = "SELECT COUNT(*) c,archive_type from base_patient WHERE archive_type is  not null and del='1' GROUP BY archive_type";
        String sql1 = "SELECT COUNT(*) c,archive_type*1 as archive_type from base_patient WHERE archive_type is  not null and del='1' GROUP BY archive_type";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
        for(Map<String,Object> map:list1){
            String archive_type = map.get("archive_type").toString();