Explorar el Código

紧急救助,无im

liubing hace 4 años
padre
commit
87e65fd8a3

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

@ -387,4 +387,38 @@ CREATE TABLE `base_semoni_doctor_status` (
alter TABLE base.base_security_monitoring_order add COLUMN doctor_confirm_finish_img VARCHAR(3000) DEFAULT NULL COMMENT '医生确认完成照片';
alter TABLE base.base_security_monitoring_order add COLUMN doctor_confirm_finish_time timestamp NULL DEFAULT NULL COMMENT '医生确认完成时间';
-- 2021-04-10 lb
ALTER table base.base_patient_bed_apply  MODIFY `patient` varchar(50) DEFAULT NULL;
ALTER table base.base_patient_bed_apply  MODIFY `patient` varchar(50) DEFAULT NULL;
-- 2021-04-12 lb
CREATE TABLE `base_emergency_assistance_order` (
  `id` varchar(50) NOT NULL DEFAULT '',
  `patient` varchar(50) DEFAULT NULL COMMENT '发起救助的居民id',
  `patient_name` varchar(10) DEFAULT NULL COMMENT '发起救助的居民姓名',
  `patient_phone` varchar(15) DEFAULT NULL COMMENT '救助居民电话',
  `patient_idcard` varchar(200) DEFAULT NULL COMMENT '救助居民身份证',
  `org_code` varchar(100) DEFAULT NULL COMMENT '救助居民所在机构code',
  `org_name` varchar(100) DEFAULT NULL COMMENT '救助居民所在机构名称',
  `serve_address` varchar(100) DEFAULT NULL COMMENT '居民当前定位地址',
  `serve_lat` varchar(100) DEFAULT NULL COMMENT '居民当前定位地址纬度',
  `serve_lon` varchar(100) DEFAULT NULL COMMENT '居民当前定位地址经度',
  `session_id` varchar(150) DEFAULT NULL COMMENT '会话id',
  `doctor` varchar(50) DEFAULT NULL COMMENT '医生code',
  `doctor_name` varchar(50) DEFAULT NULL COMMENT '医生name',
  `doctor_address` varchar(100) DEFAULT NULL COMMENT '医生当前定位地址',
  `doctor_lat` varchar(100) DEFAULT NULL COMMENT '医生当定位地址纬度',
  `doctor_lon` varchar(100) DEFAULT NULL COMMENT '医生当前定位地址经度',
  `conclusion` varchar(100) DEFAULT NULL COMMENT '服务完成笔记',
  `conclusion_img` varchar(100) DEFAULT NULL COMMENT '服务相关附件',
  `status` tinyint(4) DEFAULT '1' COMMENT '工单状态 -1已取消 0已完成 1申请中',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `create_user` varchar(50) DEFAULT NULL COMMENT '创建者id',
  `create_user_name` varchar(50) DEFAULT NULL COMMENT '创建者名称',
  `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `update_user` varchar(50) DEFAULT NULL,
  `update_user_name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='居民紧急救助服务工单';
-- 2021-04-13 lb
ALTER table base_doctor ADD COLUMN `doctor_lat` varchar(100) DEFAULT NULL COMMENT '医生当前定位地址纬度';
ALTER table base_doctor ADD COLUMN `doctor_lon` varchar(100) DEFAULT NULL COMMENT '医生当前定位地址经度';

+ 18 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -287,6 +287,8 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
     * 类型 1社区医生,2助老员
     */
    private Integer level;
    private String doctorLat;//医生当前定位地址纬度
    private String doctorLon;//医生当前定位地址经度
    @Column(name = "visit_time")
@ -763,4 +765,20 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    public void setLevel(Integer level) {
        this.level = level;
    }
    public String getDoctorLat() {
        return doctorLat;
    }
    public void setDoctorLat(String doctorLat) {
        this.doctorLat = doctorLat;
    }
    public String getDoctorLon() {
        return doctorLon;
    }
    public void setDoctorLon(String doctorLon) {
        this.doctorLon = doctorLon;
    }
}

+ 228 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -0,0 +1,228 @@
package com.yihu.jw.entity.care.assistance;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * Created by Bing on 2021/4/12.
 */
@Entity
@Table(name="base_emergency_assistance_order")
public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private String patient; //发起救助的居民id
    private String patientName; //发起救助的居民姓名
    private String patientPhone; //救助居民电话
    private String patientIdcard; //救助居民身份证
    private String orgCode; //救助居民所在机构code
    private String orgName; //救助居民所在机构名称
    private String patientAddress;
    private String serveLat; //居民当前定位地址纬度
    private String serveLon; //居民当前定位地址经度
    private String sessionId; //会话id
    private String doctor; //医生code
    private String doctorName; //医生name
    private String doctorAddress;
    private String doctorLat; //医生当定位地址纬度
    private String doctorLon; //医生当前定位地址经度
    private String conclusion; //服务完成笔记
    private String conclusionImg; //服务相关附件
    private Integer status; //工单状态 -1已取消 0已完成 1申请中
    private String sendMessage;//
    private Integer patientAge;
    private String patientPhoto;
    private Integer patientSex;
    private double distance;//医生与患者距离 单位km
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getPatientPhone() {
        return patientPhone;
    }
    public void setPatientPhone(String patientPhone) {
        this.patientPhone = patientPhone;
    }
    public String getPatientIdcard() {
        return patientIdcard;
    }
    public void setPatientIdcard(String patientIdcard) {
        this.patientIdcard = patientIdcard;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getServeLat() {
        return serveLat;
    }
    public void setServeLat(String serveLat) {
        this.serveLat = serveLat;
    }
    public String getServeLon() {
        return serveLon;
    }
    public void setServeLon(String serveLon) {
        this.serveLon = serveLon;
    }
    public String getSessionId() {
        return sessionId;
    }
    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getDoctorLat() {
        return doctorLat;
    }
    public void setDoctorLat(String doctorLat) {
        this.doctorLat = doctorLat;
    }
    public String getDoctorLon() {
        return doctorLon;
    }
    public void setDoctorLon(String doctorLon) {
        this.doctorLon = doctorLon;
    }
    public String getConclusion() {
        return conclusion;
    }
    public void setConclusion(String conclusion) {
        this.conclusion = conclusion;
    }
    public String getConclusionImg() {
        return conclusionImg;
    }
    public void setConclusionImg(String conclusionImg) {
        this.conclusionImg = conclusionImg;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getPatientAddress() {
        return patientAddress;
    }
    public void setPatientAddress(String patientAddress) {
        this.patientAddress = patientAddress;
    }
    public String getDoctorAddress() {
        return doctorAddress;
    }
    public void setDoctorAddress(String doctorAddress) {
        this.doctorAddress = doctorAddress;
    }
    @Transient
    public String getSendMessage() {
        return sendMessage;
    }
    public void setSendMessage(String sendMessage) {
        this.sendMessage = sendMessage;
    }
    @Transient
    public Integer getPatientAge() {
        return patientAge;
    }
    public void setPatientAge(Integer patientAge) {
        this.patientAge = patientAge;
    }
    @Transient
    public String getPatientPhoto() {
        return patientPhoto;
    }
    public void setPatientPhoto(String patientPhoto) {
        this.patientPhoto = patientPhoto;
    }
    @Transient
    public Integer getPatientSex() {
        return patientSex;
    }
    public void setPatientSex(Integer patientSex) {
        this.patientSex = patientSex;
    }
    @Transient
    public double getDistance() {
        return distance;
    }
    public void setDistance(double distance) {
        this.distance = distance;
    }
}

+ 19 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/assistance/EmergencyAssistanceDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.care.dao.assistance;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/4/12.
 */
public interface EmergencyAssistanceDao extends PagingAndSortingRepository<EmergencyAssistanceDO,String>,
        JpaSpecificationExecutor<EmergencyAssistanceDO> {
    List<EmergencyAssistanceDO> queryByPatientAndStatusIn(String patient, Integer[] status, Sort sort);
    EmergencyAssistanceDO findByPatientAndStatus(String patient,Integer status);
}

+ 214 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java

@ -0,0 +1,214 @@
package com.yihu.jw.care.endpoint.assistance;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
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.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Bing on 2021/4/12.
 */
@RestController
@RequestMapping(value = "/emergency_assistance")
@Api(description = "紧急救助相关")
public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private EmergencyAssistanceService assistanceService;
    @PostMapping(value = "newOrder")
    @ApiOperation(value = "居民发起新的紧急救助")
    @ServicesAuth(item = "emergencyAssistance")
    public ObjEnvelop newOrder(@ApiParam(name="patientId",value = "居民id")
                               @RequestParam(value = "patientId") String patientId,
                               @ApiParam(name="jsonData",value = "创建工单json")
                               @RequestParam(value = "jsonData") String jsonData
                               ){
        try {
            JSONObject result = assistanceService.newOrder(patientId,jsonData);
            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());
        }
    }
    @GetMapping(value = "getOrderDetail")
    @ApiOperation(value = "查看救助详情")
    public ObjEnvelop getOrderDetail(@ApiParam(name="orderId",value = "工单id")
                               @RequestParam(value = "orderId") String orderId
    ){
        try {
            JSONObject result = assistanceService.getOrderDetail(orderId);
            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());
        }
    }
    @GetMapping(value = "getTabStatusCounts")
    @ApiOperation(value = "查看居民救助历史tab数量")
    public ObjEnvelop getTabStatusCounts(
                                    @ApiParam(name="patient",value = "患者")
                                    @RequestParam(value = "patient") String patient
    ){
        try {
            JSONObject result = assistanceService.getTabStatusCounts(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());
        }
    }
    @GetMapping(value = "existApplyStatus")
    @ApiOperation(value = "查看居民救助状态是否在申请中")
    public ObjEnvelop existApplyStatus(@ApiParam(name="patient",value = "患者")
                                    @RequestParam(value = "patient") String patient){
        try {
            JSONObject result = assistanceService.existApplyStatus(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());
        }
    }
    @GetMapping(value = "getOrderList")
    @ApiOperation(value = "查看居民救助历史记录(所有状态)")
    public ListEnvelop getOrderList(@ApiParam(name="patientId",value = "居民id")
                               @RequestParam(value = "patientId",required = false) String patientId,
                                    @ApiParam(name="doctor",value = "查看医生")
                               @RequestParam(value = "doctor",required = false) String doctor,
                                    @ApiParam(name="status",value = "状态")
                               @RequestParam(value = "status",required = true) String status,
                                    @ApiParam(name="page",value = "page")
                               @RequestParam(value = "page",required = true) Integer page,
                                    @ApiParam(name="pageSize",value = "pageSize")
                               @RequestParam(value = "pageSize",required = true) Integer pageSize
    ){
        try {
            page = page>0?page-1:0;
            if (StringUtils.isBlank(patientId)&&StringUtils.isBlank(doctor)){
                return ListEnvelop.getError("请求参数错误");
            }
            return ListEnvelop.getSuccess( "查询成功",assistanceService.getOrderList(patientId,doctor,status,page,pageSize,"desc"));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @GetMapping(value = "getUnCompleteOrderList")
    @ApiOperation(value = "医生查看居民救助列表(不包括已取消与已完成)")
    public ListEnvelop getUnCompleteOrderList(@ApiParam(name="patientId",value = "居民id")
                                    @RequestParam(value = "patientId",required = false) String patientId,
                                    @ApiParam(name="doctor",value = "查看医生")
                                    @RequestParam(value = "doctor",required = false) String doctor,
                                    @ApiParam(name="page",value = "page")
                                    @RequestParam(value = "page") Integer page,
                                    @ApiParam(name="pageSize",value = "pageSize")
                                    @RequestParam(value = "pageSize") Integer pageSize
    ){
        try {
            page = page>0?page-1:0;
            if (StringUtils.isBlank(patientId)&&StringUtils.isBlank(doctor)){
                return ListEnvelop.getError("请求参数错误");
            }
            return ListEnvelop.getSuccess( "查询成功",assistanceService.getOrderList(patientId,doctor,"1",page,pageSize,"asc"));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @PostMapping(value = "cancelOrder")
    @ApiOperation(value = "居民取消救助工单")
    public ObjEnvelop cancelOrder(@ApiParam(name="patient",value = "患者")
                                       @RequestParam(value = "patient") String patient,
                                       @ApiParam(name="orderId",value = "工单id")
                                       @RequestParam(value = "orderId") String orderId){
        try {
            JSONObject result = assistanceService.cancelOrder(patient,orderId);
            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());
        }
    }
    @PostMapping(value = "updateConclusion")
    @ApiOperation(value = "医生编辑救助服务小结")
    @ObserverRequired
    public ObjEnvelop updateConclusion(@ApiParam(name="doctor",value = "doctor")
                                  @RequestParam(value = "doctor") String doctor,
                                  @ApiParam(name="orderId",value = "工单id")
                                  @RequestParam(value = "orderId") String orderId,
                                  @ApiParam(name="conclusion",value = "服务小结")
                                  @RequestParam(value = "conclusion") String conclusion,
                                  @ApiParam(name="conclusionImg",value = "附件多张图片用逗号隔开,非必传")
                                  @RequestParam(value = "conclusionImg",required = false) String conclusionImg){
        try {
            JSONObject result = assistanceService.updateConclusion(doctor,orderId,conclusion,conclusionImg);
            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());
        }
    }
    @PostMapping(value = "updateDoctorLocation")
    @ApiOperation(value = "更新医生定位信息")
    @ObserverRequired
    public ObjEnvelop updateDoctorLocation(@ApiParam(name="doctor",value = "doctor")
                                       @RequestParam(value = "doctor") String doctor,
                                       @ApiParam(name="orderId",value = "工单id",required =false )
                                       @RequestParam(value = "orderId",required = false) String orderId,
                                       @ApiParam(name="doctorAddress",value = "医生地址描述")
                                       @RequestParam(value = "doctorAddress") String doctorAddress,
                                       @ApiParam(name="doctorLat",value = "医生当前定位纬度")
                                       @RequestParam(value = "doctorLat") String doctorLat,
                                       @ApiParam(name="doctorLon",value = "医生当前定位经度")
                                       @RequestParam(value = "doctorLon") String doctorLon){
        try {
            JSONObject result = assistanceService.updateDoctorLocation(doctor,orderId,doctorAddress,doctorLat,doctorLon);
            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());
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -26,7 +26,7 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "messages")
    @ApiOperation("应用消息")
    public ObjEnvelop messages(@ApiParam(name = "type", value = "消息类型 10床位申请,11安全监护")
    public ObjEnvelop messages(@ApiParam(name = "type", value = "消息类型 10床位申请,11安全监护,12紧急救助")
                               @RequestParam(value = "type", required = false) String type,
                               @ApiParam(name = "doctor", value = "doctor")
                               @RequestParam(value = "doctor", required = false) String doctor){

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

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.org;
import com.yihu.jw.care.service.org.BaseOrgService;
import com.yihu.jw.restmodel.web.ListEnvelop;
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;
@ -35,6 +36,18 @@ public class OrgEndpoint extends EnvelopRestEndpoint {
    }
    @RequestMapping(value = "/findOrgByCode", method = RequestMethod.GET)
    @ApiOperation(value = "获取机构信息")
    public ObjEnvelop findOrgByCode(
                                   @ApiParam(name = "orgCode", value = "orgCode")
                                   @RequestParam(value = "orgCode", required = false) String orgCode) {
        try {
            return ObjEnvelop.getSuccess("获取成功",orgService.findOrgByCode(orgCode));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
}

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

@ -71,7 +71,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "getSecurityOrderUnCompleteList")
    @ApiOperation(value = "获取医生机构下未结束的安防工单")
    @ApiOperation(value = "获取服务医生下未结束的安防工单")
    public ListEnvelop getSecurityOrderUnCompleteList(@ApiParam(name="doctor",value = "医生ID,当前查看列表医生",required = true)
                                            @RequestParam(value = "doctor")String doctor){

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

@ -0,0 +1,320 @@
package com.yihu.jw.care.service.assistance;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.print.DocFlavor;
import java.util.*;
/**
 * Created by Bing on 2021/4/12.
 */
@Service
public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistanceDO, EmergencyAssistanceDao> {
    @Autowired
    private EmergencyAssistanceDao emergencyAssistanceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private ServicePackageSignRecordDao servicePackageSignRecordDao;
    @Autowired
    private BaseTeamMemberDao baseTeamMemberDao;
    @Autowired
    private CountDistance countDistance;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
     * 新建居民紧急救助
     * @param patient
     * @param jsonData
     * @return
     */
    public JSONObject newOrder(String patient,String jsonData){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = JSON.parseObject(jsonData,EmergencyAssistanceDO.class);
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO==null){
            String failMsg = "当前居民未存在,请先进行建档";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        assistanceDO.setPatient(patient);
        assistanceDO.setPatientIdcard(patientDO.getIdcard());
        assistanceDO.setPatientName(patientDO.getName());
        assistanceDO.setPatientPhone(patientDO.getMobile());
        if (emergencyAssistanceDao.findByPatientAndStatus(patient,1)!=null){
            String failMsg = "当前居民存在申请中的救助,请完成后再申请";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        //签约防走失服务包
        String sql ="SELECT i.code,team_code,org_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+assistanceDO.getPatient()+"' and i.code='emergencyAssistance' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
        if (items.size()==0){
            String failMsg = "当前居民未签约紧急救助服务项,请先进行签约";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        Map<String,Object> mapTmp = items.get(0);
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
        if (doctorDOS.size()==0){
            String failMsg = "紧急救助服务项服务医生为空,不可发起救助";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        //获取距离患者最近的一个医生
        double distance = 0.0;
        for (BaseDoctorDO doctorDO:doctorDOS){
            double distanceTmp = countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(doctorDO.getDoctorLat()),Double.parseDouble(doctorDO.getDoctorLon()));
            if (distanceTmp>distance){
                distance = distanceTmp;
                assistanceDO.setDoctor(doctorDO.getId());
                assistanceDO.setDoctorName(doctorDO.getName());
                assistanceDO.setDoctorAddress("");
                assistanceDO.setDoctorLon(118.0388772928781+"");
                assistanceDO.setDoctorLat(24.472242502394266+"");
            }
        }
        //创建im会话
//        assistanceDO.setSessionId();
        //向会话中发送一条 陈XX发起紧急救助
        if (StringUtils.isNotBlank(assistanceDO.getSendMessage())){
            //新建工单message不为空时 ,发送对应的消息
        }
        emergencyAssistanceDao.save(assistanceDO);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,assistanceDO);
        return result;
    }
    /**
     * 救助工单详情
     * @param orderID
     * @return
     */
    public JSONObject getOrderDetail(String orderID){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
        if (assistanceDO==null){
            String failMsg = "当前救助工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
        assistanceDO.setPatientPhoto(patientDO.getPhoto());
        assistanceDO.setPatientSex(patientDO.getSex());
        assistanceDO.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
        double distance=countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(assistanceDO.getDoctorLat()),Double.parseDouble(assistanceDO.getDoctorLon()));
        assistanceDO.setDistance(distance);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,assistanceDO);
        return result;
    }
    /**
     * 居民救助历史tab数量
     * @param patient
     * @return
     */
    public JSONObject getTabStatusCounts(String patient){
        JSONObject result = new JSONObject();
        JSONObject tmpObj = new JSONObject();
        tmpObj.put("status_-1",0);//已取消
        tmpObj.put("status_0",0);//已完成
        tmpObj.put("status_1",0);//申请中
        StringBuilder sql = new StringBuilder(" select ord.status,count(ord.id) count from base_emergency_assistance_order ord where 1=1" +
                " and ord.patient='"+patient+"' group by ord.status  ");
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
        for (Map<String,Object> map:sqlResult){
            tmpObj.put("status_"+map.get("status"),map.get("count"));
        }
        Integer All = 0;
        Set<String> keySet = tmpObj.keySet();
        for (String key : keySet){
            All+=tmpObj.getInteger(key);
        }
        tmpObj.put("all",All);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,tmpObj);
        return result;
    }
    public JSONObject existApplyStatus(String patient){
        JSONObject result = new JSONObject();
        JSONObject tmpObj = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findByPatientAndStatus(patient,1);
        if (assistanceDO==null){
            tmpObj.put("exist","false");
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg,tmpObj);
        }
        else {
            BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
            assistanceDO.setPatientPhoto(patientDO.getPhoto());
            assistanceDO.setPatientSex(patientDO.getSex());
            assistanceDO.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
            double distance=countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(assistanceDO.getDoctorLat()),Double.parseDouble(assistanceDO.getDoctorLon()));
            assistanceDO.setDistance(distance);
            tmpObj.put("exist","true");
            tmpObj.put("assistanceDO",assistanceDO);
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg,tmpObj);
        }
        return result;
    }
    /**
     * 查看居民救助历史记录
     * @param patient
     * @param doctor
     * @return
     */
    public List<EmergencyAssistanceDO> getOrderList(String patient,String doctor,String status,Integer page,Integer pageSize,String sort){
        StringBuilder sql = new StringBuilder(" select ord.* from base_emergency_assistance_order ord where 1=1 ");
        if (StringUtils.isNotBlank(doctor)){
            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 " +
                    " 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)){
            sql.append(" and  ord.patient  = '"+patient+"' ");
        }
        sql.append(" and ord.status in ( '").append(status.replace(",","','")).append("' ");
        sql.append(" order by ord.create_time "+sort+" limit "+page*pageSize+","+pageSize);
        List<EmergencyAssistanceDO> resultList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(EmergencyAssistanceDO.class));
        for (EmergencyAssistanceDO obj:resultList){
            BasePatientDO patientDO = patientDao.findById(obj.getPatient());
            obj.setPatientPhoto(patientDO.getPhoto());
            obj.setPatientSex(patientDO.getSex());
            obj.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
        }
        return resultList;
    }
    public JSONObject cancelOrder(String patient,String orderId){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderId);
        if (assistanceDO==null){
            String failMsg = "当前救助工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (!assistanceDO.getPatient().equals(patient)){
            String failMsg = "当前救助工单不是您的工单,无法取消";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (assistanceDO.getStatus()==-1){
            String failMsg = "当前救助工单已取消";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        assistanceDO.setStatus(-1);
        assistanceDO.setUpdateUser(patient);
        assistanceDO.setUpdateUserName(assistanceDO.getPatientName());
        assistanceDO.setUpdateTime(new Date());
        //im是否结束会话?
        emergencyAssistanceDao.save(assistanceDO);
        String failMsg = "当前救助工单已取消";
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,assistanceDO);
        return result;
    }
    /**
     *
     * @param doctor
     * @param orderId
     * @param conclusion 必传
     * @param conclusionImg 非必传
     * @return
     */
    public JSONObject updateConclusion(String doctor,String orderId,String conclusion,String conclusionImg){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderId);
        if (assistanceDO==null){
            String failMsg = "当前救助工单不存在,无法取消";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        assistanceDO.setConclusion(conclusion);
        if (StringUtils.isNotBlank(conclusionImg)){
            assistanceDO.setConclusionImg(conclusionImg);
        }
        assistanceDO.setStatus(0);
        assistanceDO.setUpdateUser(doctor);
        assistanceDO.setUpdateUserName(assistanceDO.getDoctorName());
        assistanceDO.setUpdateTime(new Date());
        //im会话是否结束?
        return getOrderDetail(orderId);
    }
    public JSONObject updateDoctorLocation(String doctor,String orderId,String doctorAddress,String doctorLat,String doctorLon){
        JSONObject result = new JSONObject();
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        if (doctorDO==null){
            String failMsg = "当前医生不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        else {
            doctorDO.setDoctorLat(doctorLat);
            doctorDO.setDoctorLon(doctorLon);
            doctorDao.save(doctorDO);
            result.put(ResponseContant.resultFlag, ResponseContant.success);
        }
        if (StringUtils.isNotBlank(orderId)){
            EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderId);
            if (assistanceDO!=null){
                assistanceDO.setDoctorAddress(doctorAddress);
                assistanceDO.setDoctorLat(doctorLat);
                assistanceDO.setDoctorLon(doctorLon);
                emergencyAssistanceDao.save(assistanceDO);
                return getOrderDetail(orderId);
            }
        }
        else {
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg,null);
        }
        return result;
    }
}

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

@ -39,7 +39,7 @@ public class DoctorMessageService {
    /**
     *
     * @param doctor
     * @param type  床位申请,11安全监护
     * @param type  11床位申请,11安全监护 ,12紧急救助
     * @return
     */
    public JSONObject findDoctorAllMessage(String doctor,String type){
@ -61,14 +61,18 @@ public class DoctorMessageService {
                String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time from base_patient_bed_apply where org_code='"+obj.getOrgCode()+"' " +
                        "and status <> -1 and status<>0 order by create_time asc";
                Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ;
                count +=sqlCount;
                if (sqlResult.containsKey("count")){
                    Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ;
                    count +=sqlCount;
                }
                listTmp.add(sqlResult);
            }
            listTmp.sort(Comparator.comparing(obj ->  obj.get("create_time").toString()));
            tmpJson.put("count",count);
            tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民申请床位");
            tmpJson.put("time",listTmp.get(0).get("create_time").toString());
            if (listTmp.size()>0){
                tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民申请床位");
                tmpJson.put("time",listTmp.get(0).get("create_time").toString());
            }
            result.put("bedApply",tmpJson);
        }
@ -76,21 +80,49 @@ public class DoctorMessageService {
            JSONObject tmpJson = new JSONObject();
            count=0;
            List<Map<String,Object>> listTmp = new ArrayList<>();
            for (BaseDoctorHospitalDO obj:hospitalDO){
                String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,serve_desc from base_security_monitoring_order where hospital='"+obj.getOrgCode()+"' " +
                        "and status <>-1 and status<> 7 order by create_time asc";
                Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
            String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,serve_desc from base_security_monitoring_order ord where 1=1 " +
                    "and status <>-1 and status<> 7  ";
            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='8' 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")){
                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ;
                count +=sqlCount;
                listTmp.add(sqlResult);
            }
            listTmp.sort(Comparator.comparing(obj ->  obj.get("create_time").toString()));
            listTmp.add(sqlResult);
            tmpJson.put("count",count);
            tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民"+listTmp.get(0).get("serve_desc").toString());
            tmpJson.put("time",listTmp.get(0).get("create_time"));
            if (listTmp.size()>0){
                tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民"+listTmp.get(0).get("serve_desc").toString());
                tmpJson.put("time",listTmp.get(0).get("create_time"));
            }
            result.put("security",tmpJson);
        }
        if (typeNull||type.equals("12")){//紧急救助
            JSONObject tmpJson = new JSONObject();
            count=0;
            List<Map<String,Object>> listTmp = new ArrayList<>();
            String sql="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time from base_emergency_assistance_order ord where 1=1 " +
                    "and status =1  ";
            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') ";
            sql+=" order by create_time asc ";
            Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
            if (sqlResult.containsKey("count")){
                Integer sqlCount =Integer.parseInt(sqlResult.get("count").toString()) ;
                count +=sqlCount;
            }
            listTmp.add(sqlResult);
            tmpJson.put("count",count);
            if (listTmp.size()>0&&listTmp.get(0).get("patient_name")!=null){
                tmpJson.put("message",listTmp.get(0).get("patient_name").toString()+"居民发起了紧急呼叫");
                tmpJson.put("time",listTmp.get(0).get("create_time"));
            }
            result.put("assistance",tmpJson);
        }
        return result;
    }

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/org/BaseOrgService.java

@ -31,4 +31,8 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseOrgDO.class));
    }
    public BaseOrgDO findOrgByCode(String orgCode){
        BaseOrgDO orgDO = orgDao.findByCode(orgCode);
        return orgDO;
    }
}

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

@ -216,10 +216,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        String sql = " select p.id patientCode,p.name,p.sex,p.photo,p.idcard,ord.id orderId,ord.number,ord.serve_desc,ord.create_time,ord.`status`,ord.doctor," +
                "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                "where 1=1 ";
        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctor);
        if (hospitalDOs.size()>0){
            sql += "and ord.hospital = '"+hospitalDOs.get(0).getOrgCode()+"' ";
        }else  {
        if (StringUtils.isNotBlank(doctor)){
            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='8' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        } else  {
            return new JSONArray();
        }
        if (StringUtils.isNotBlank(serverDoctor)){
@ -290,29 +292,25 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    public List<Map<String,Object>> getSecurityOrderUnCompleteList(String doctor){
        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctor);
        List<Map<String,Object>> result = new ArrayList<>();
        if (hospitalDOs.size()>0){
            for (BaseDoctorHospitalDO obj:hospitalDOs){
                String sql = " select p.id patientCode,p.name,p.sex,p.idcard,p.photo,ord.id orderId,ord.number,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor," +
                        "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                        "where ord.status <>-1 and ord.status<> 7  ";
                sql += "and ord.hospital = '"+obj.getOrgCode()+"' ";
                sql +=" order by ord.create_time asc ";
                List<Map<String,Object>> tmp= jdbcTemplate.queryForList(sql);
                for (Map<String,Object> map:tmp){
                    if (map.get("idcard")==null){
                        map.put("age",null);
                    }
                    else{
                        Integer age  = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
                        map.put("age",age);
                    }
                }
                result.addAll(tmp);
        String sql = " select p.id patientCode,p.name,p.sex,p.idcard,p.photo,ord.id orderId,ord.number,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor," +
                "ord.doctor_name,ord.patient_phone,ord.conclusion_status from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                "where ord.status <>-1 and ord.status<> 7  ";
        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='8' 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){
            if (map.get("idcard")==null){
                map.put("age",null);
            }
            result.sort(Comparator.comparing(obj -> ((Map<String,Object>) obj).get("create_time").toString()));
            else{
                Integer age  = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
                map.put("age",age);
            }
        }
        return result;
    }

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

@ -147,7 +147,7 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
    public PageEnvelop<List<Map<String,Object>>> assessmentPage(String doctorId,String name, int page, int size,
                    Integer status,Integer levelConclusion,Integer servicePackageStatus){
        String sql = "SELECT c.id,c.patient,c.assessment_time,c.service_package_status servicePackageStatus, " +
                "c.`status`,c.level_conclusion levelConclusion,p.name,p.mobile,p.sex,p.idcard  ";
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.mobile,p.sex,p.idcard  ";
        String countSql = "SELECT count(*) ";
        String filters = "from base_capacity_assessment_record c,base_patient p " +

+ 35 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/CountDistance.java

@ -0,0 +1,35 @@
package com.yihu.jw.care.util;
import org.springframework.stereotype.Component;
@Component
public class CountDistance {
    private static double EARTH_RADIUS = 6378.137;// 6378.137赤道半径6378137
    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }
    /**
     * 通过经纬度计算两点之间的距离(单位:米)
     * @param latone
     * @param lngone
     * @param lattwo
     * @param lngtwo
     * @return
     */
    public  double getDistance(double latone, double lngone, double lattwo, double lngtwo) {
        double radlatone = rad(latone);
        double radlattwo = rad(lattwo);
        double a = radlatone - radlattwo;
        double b = rad(lngone) - rad(lngtwo);
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
                + Math.cos(radlatone) * Math.cos(radlattwo)
                * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000d) / 10000d;
        s = s*1000;
        return s;
    }
}