Prechádzať zdrojové kódy

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

叶仕杰 3 rokov pred
rodič
commit
54edd270dc

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

@ -1388,4 +1388,8 @@ CREATE TABLE `base_yxdevice_index` (
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='云芯拐杖设备上传记录';
-- 20210828
ALTER table base_patient_sos_contacts add column update_info VARCHAR(1000) default null comment '同步信息 1成功,-1失败'
ALTER table base_patient_sos_contacts add column update_info VARCHAR(1000) default null comment '同步信息 1成功,-1失败'
-- 20210828
alter table base_patient add `sign_status` tinyint(1) DEFAULT NULL COMMENT '签约状态 1已签约 0未签约';

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -282,6 +282,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String latLon;//定位经纬度
    private String padImei;//绑定平板标志
    private String residentialArea;//居住小区
    private Integer signStatus;// 签约状态【0未签约,1已签约】
    private Integer deviceFlag;//绑定设备标识 大于0为绑定了设备
@ -872,6 +873,15 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
        this.residentialArea = residentialArea;
    }
    @Column(name = "sign_status")
    public Integer getSignStatus() {
        return signStatus;
    }
    public void setSignStatus(Integer signStatus) {
        this.signStatus = signStatus;
    }
    @Transient
    public Integer getDeviceFlag() {
        return deviceFlag;

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

@ -469,13 +469,15 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @return
     */
    public List<Map<String,Object>> findChild(String name,String residentialArea,String limit,JSONObject json){
        String sql = "SELECT id,name,photo,idcard,CAST(IFNULL(birthday,'') AS char ) birthday,residential_area residentialArea,sex  from base_patient WHERE archive_type = 2 and del = '1' ";
        String sql = "SELECT id,name,photo,idcard,CAST(IFNULL(birthday,'') AS char ) birthday,residential_area residentialArea" +
                ",sex,IFNULL(on_line,0) online  from base_patient WHERE archive_type = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        sql += " order by online desc";
        sql+=limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlCount = "SELECT COUNT(*) from base_door_coach_order where `status` = 6";
@ -483,7 +485,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            String paientId = map.get("id").toString();
            String filter = " and patient = '"+paientId+"'";
            Integer count = jdbcTemplate.queryForObject(sqlCount+filter,Integer.class);
            map.put("online",json.containsKey(paientId));
//            map.put("online",json.containsKey(paientId));
            map.put("doorCoach",count);
            String idcardNo = map.get("idcard") + "";
            Date birthday = DateUtil.strToDate(map.get("birthday").toString());
@ -514,7 +516,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     */
    public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,JSONObject json){
        String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ", GROUP_CONCAT(DISTINCT d.category_code) deviceFlag from base_patient a " +
                ", GROUP_CONCAT(DISTINCT d.category_code) deviceFlag,IFNULL(on_line,0) online,IFNULL(sign_status,0) signStatus from base_patient a " +
                " LEFT JOIN wlyy_patient_device d on d.`user`=a.id  WHERE a.archive_type = 1 and a.del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
@ -522,7 +524,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex ";
        sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,online,signStatus ";
        sql += " ORDER BY online,signStatus desc";
        sql += limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
@ -566,10 +569,11 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @return
     */
    public List<Map<String,Object>> findHelper(String name,String limit,JSONObject json){
        String sql = "SELECT id,name,photo,sex from base_doctor WHERE doctor_level = 2 and del = '1' ";
        String sql = "SELECT id,name,photo,sex,IFNULL(on_line,0) online from base_doctor WHERE doctor_level = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        sql += " ORDER BY online desc";
        sql+=limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
@ -590,7 +594,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
            Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
            map.put("online",json.containsKey(doctorId));
//            map.put("online",json.containsKey(doctorId));
            map.put("lifeCare",lifeCare);
            map.put("emergency",emergency);
            map.put("security",security);

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

@ -36,7 +36,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -149,6 +148,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                    patientLabelDO.setLabelName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICE_TYPE,lableCode));
                    patientLabelDao.save(patientLabelDO);
                    //居民签约状态
                    BasePatientDO patientDO = patientDao.findById(patientId);
                    patientDO.setSignStatus(1);
                    patientDao.save(patientDO);
                    //修改base_patient_add里面的del,状态修改成0
                }else {
                    logger.info("居民已签约,patient:"+patientId);
@ -425,37 +429,16 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        patientLabelDO.setLabelName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICE_TYPE,lableCode));
        patientLabelDao.save(patientLabelDO);
        //服务项目 emergencyAssistance 只能签约一个
        String sqlItem = "select item.`code`,item.name from base_service_package_item item INNER JOIN base_service_package_record pr on item.service_package_id = pr.service_package_id\n" +
                "where pr.sign_id='"+signId+"' GROUP BY item.`code`";
        List<Map<String,Object>> itemList = jdbcTemplate.queryForList(sqlItem);
        Map<String,List<Map<String,Object>>> signItem = itemList.stream().collect(Collectors.groupingBy(e->e.get("code").toString()));
        //居民签约状态
        patientDO.setSignStatus(1);
        patientDao.save(patientDO);
        Iterator<ServicePackageRecordDO> iterator = recordDOList.iterator();
        while (iterator.hasNext()) {
            ServicePackageRecordDO recordDO = iterator.next();
            recordDO.setPatient(patientId);
            recordDO.setSignId(signId);
//            if (idList.contains(recordDO.getServicePackageId())) {
//                iterator.remove();//使用迭代器的删除方法删除
//            }
        }
/*        if(recordDOList.size()>0){
            List<String> packages = recordDOList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
            String packagesId = packages.stream().map(String::valueOf).collect(Collectors.joining("','"));
            sqlItem = "select item.`code`,item.name from base_service_package_item item " +
                    "where item.service_package_id in ('"+packagesId+"') GROUP BY item.`code`";
            itemList = jdbcTemplate.queryForList(sqlItem);
           Map<String,List<Map<String,Object>>> newItem = itemList.stream().collect(Collectors.groupingBy(e->e.get("code").toString()));
           if (newItem.containsKey("emergencyAssistance")&&signItem.containsKey("emergencyAssistance")){
               String message = "重复签约服务项目:"+newItem.get("emergencyAssistance").get(0).get("name").toString();
               throw new Exception(message);
           }
        }*/
//        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
//        capacityAssessmentRecordDO.setServicePackageStatus(1);
//        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
        servicePackageRecordDao.save(recordDOList);
        //修改床位生请状态为已完成

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

@ -55,6 +55,8 @@ public class DeviceUploadService {
    private BaseYxDeviceIndexDao yxDeviceIndexDao;
    @Autowired
    private HvDeviceService hvDeviceService;
    @Autowired
    private YsDeviceService ysDeviceService;
    public Result uploadDevicesData(String dataJson)throws Exception {
        try {
@ -438,6 +440,7 @@ public class DeviceUploadService {
        }
        String res = "";
        //位置[434036bb95761faaf8771d10029ae8eaIC*860314001160427*0113*UD,210826,093829,V,0.000000,N,0.000000,E,0.00,0.0,100.0,0,62,31,0,0,00000000,1,1,460,0,22831,259001902,62,6,wifi0,20:6b:e7:67:bf:1f,-63,wifi1,d4:9e:05:a7:60:a6,-65,wifi2,e0:d4:62:2d:67:9c,-71,wifi3,54:75:95:b9:4f:8e,-73,wifi4,e4:72:e2:aa:73:0c,-73,wifi5,e0:d4:62:2d:67:a1,-73]
        //报警[XT*334588000000156*00CD*AL,180916,064153,A,22.570512,N,113.8623267,E,0.00,154.8,0.0,11,10 0,100,0,0,00100018,7,0,460,1,9529,21809,155,9529,21242,132,9529,21405,131,9529,63554,131,9 529,63555,130,9529,63556,118,9529,21869,116,0,12.4]
        String instruct[] = instructions.split("]");
        for (int i=0;i<instruct.length;i++){
            String inst = instruct[i];
@ -446,7 +449,7 @@ public class DeviceUploadService {
            String order = tmp[3];
            if(order.contains(",")){
                String tmp1[] = order.split(",");
                if("UD".equals(tmp1[0])||"CRUD".equals(tmp1[0])){
                if("UD".equals(tmp1[0])||"CRUD".equals(tmp1[0])||"AL".equals(tmp1[0])){
                    //处理位置信息
                    String lat,lon;
                    if("A".equals(tmp1[4])){
@ -456,6 +459,8 @@ public class DeviceUploadService {
                        lat = tmp1[4];
                        lon = tmp1[6];
                    }
                    //判断是否触发防走失工单
                    BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
                    deviceIndex.setSn(sn);
                    deviceIndex.setLat(lat);
@ -467,4 +472,23 @@ public class DeviceUploadService {
        }
    }
    /**
     * 判断是否触发防走失工单
     */
    public void yxLossPrevention(String sn,String lat,String lon){
        if("0.000000".equals(lat)&&"0.000000".equals(lon)){
            return;
        }
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(sn,"16");
        String safeAreaGz = null;
        if (devices.size()>0){
            safeAreaGz = devices.get(0).getSafeAreaGz();
        }
        if(StringUtil.isBlank(safeAreaGz)){
            return;
        }
    }
}

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

@ -0,0 +1,84 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
@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;
        return s;
    }
    /**
     * 判断坐标是否在多边形区域内
     * @param pointLon
     * @param pointLat
     * @param rangePositions 多边形坐标 [{"lon":118.19302036660137,"lat":24.494515439791996},{"lon":118.19401849369201,"lat":24.49606682685256}]
     * @return
     */
    public boolean isInPolygon(double pointLon, double pointLat, JSONArray rangePositions) {
        // 将要判断的横纵坐标组成一个点
        double[] lon =  rangePositions.stream().mapToDouble(item->((JSONObject)item).getDouble("lon")).toArray();
        double[] lat =  rangePositions.stream().mapToDouble(item->((JSONObject)item).getDouble("lat")).toArray();;
        Point2D.Double point = new Point2D.Double(pointLon, pointLat);
        // 将区域各顶点的横纵坐标放到一个点集合里面
        List<Point2D.Double> pointList = new ArrayList<Point2D.Double>();
        double polygonPoint_x = 0.0, polygonPoint_y = 0.0;
        for (int i = 0; i < lon.length; i++) {
            polygonPoint_x = lon[i];
            polygonPoint_y = lat[i];
            Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x, polygonPoint_y);
            pointList.add(polygonPoint);
        }
        return check(point, pointList);
    }
    private static boolean check(Point2D.Double point, List<Point2D.Double> polygon) {
        java.awt.geom.GeneralPath peneralPath = new java.awt.geom.GeneralPath();
        Point2D.Double first = polygon.get(0);
        // 通过移动到指定坐标(以双精度指定),将一个点添加到路径中
        peneralPath.moveTo(first.x, first.y);
        polygon.remove(0);
        for (Point2D.Double d : polygon) {
            // 通过绘制一条从当前坐标到新指定坐标(以双精度指定)的直线,将一个点添加到路径中。
            peneralPath.lineTo(d.x, d.y);
        }
        // 将几何多边形封闭
        peneralPath.lineTo(first.x, first.y);
        peneralPath.closePath();
        // 测试指定的 Point2D 是否在 Shape 的边界内。
        return peneralPath.contains(point);
    }
}