Browse Source

医养1.7.4

liubing 3 years ago
parent
commit
5a6e30d82f

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BasePatientMonitorDataDO.java

@ -23,7 +23,7 @@ public class BasePatientMonitorDataDO extends IdEntity {
    private String deviceSn;
    /**
     * 当前已用TYPE类型:
     *  1血糖测量 2血压测量,5心率,7呼吸,8步数,9定位上传,10温度(烟感),11床带状态更新(睡眠带),15烟雾浓度,15燃气浓度
     *  1血糖测量 2血压测量,5心率,7呼吸,8步数,9定位上传,10温度(烟感),11床带状态更新(睡眠带),14燃气浓度,15烟雾浓度,
     *  20紧急呼叫 22安防预警
     */
    private Integer type;

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

@ -76,6 +76,17 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findUnSignPatientLocations")
    @ApiOperation("查找未签约老人坐标")
    public PageEnvelop findUnSignPatientLocations(@ApiParam(name = "page")@RequestParam(value = "page")Integer page,
                                                  @ApiParam(name = "size")@RequestParam(value = "size")Integer size){
        try {
            return baseServiceNewsService.findUnSignPatientLocations(page,size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getLatLon")
    @ApiOperation("查询所有社工坐标")
    public ListEnvelop getLatLon(){

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

@ -83,6 +83,11 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     * @return
     */
    public Map<String,Object> doctorSimpleInfo(String doctorId){
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
        if (doctorDO==null){
            return null;
        }
        String sql = "SELECT d.id,d.name,d.photo,d.sex ";
        sql += " ,h.org_code orgCode,h.org_name orgName from base_doctor d left join base_doctor_hospital h on d.id = h.doctor_code  and h.del = 1" +
                "  WHERE d.id = '"+doctorId+"' limit 1 ";
@ -90,16 +95,33 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        Map<String,Object> map = list.get(0);
        //签约老人数、紧急救助完成数、生活照料完成数、安防监护完成数
        String sql1 = "SELECT COUNT(DISTINCT sr.patient) FROM " +
                " base_service_package_sign_record sr, base_service_package_record r, base_team_member m " +
                " WHERE  sr.id = r.sign_id and sr.status=1 " +
                "  and m.team_code = r.team_code " +
                "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
        String sql1 = "";
        String sqlLife = "";
        String sqlEmergency = "";
        String sqlSecurity = "";
        String filter = "";
        if (2==doctorDO.getLevel()){//社工
             sql1 = "SELECT COUNT(DISTINCT sr.patient) FROM " +
                    " base_service_package_sign_record sr, base_service_package_record r, base_team_member m " +
                    " WHERE  sr.id = r.sign_id and sr.status=1 " +
                    "  and m.team_code = r.team_code " +
                    "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
             sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
             sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
             sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
             filter = " and doctor = '"+doctorId+"'";
        }else if (4==doctorDO.getLevel()){
            sql1 = " SELECT count(DISTINCT p.id) from base_patient_helper ph INNER JOIN base_patient p " +
                    " on ph.patient = p.id and p.del=1 " +
                    "where ph.doctor='"+doctorId+"' and ph.del=1 ";
            sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
            sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
            sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
            filter = " and doctor = '"+doctorId+"'";
        }else {
            return null;
        }
        Integer signNum = jdbcTemplate.queryForObject(sql1,Integer.class);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
        String filter = " and doctor = '"+doctorId+"'";
        Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
        Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
        Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);

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

@ -11,6 +11,7 @@ import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -131,7 +132,7 @@ public class BaseServiceNewsService {
                "WHERE t.patient = p.id and t.del=1 and t.`status`=1 and p.del =1  " +filter+
                "UNION  " +
                "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid from base_service_package_sign_record t,base_patient p " +
                "WHERE t.patient = p.id and t.`status`=1 and p.del =1"+filter;
                "WHERE t.patient = p.id and t.`status`=1 and p.del =1 and p.sign_status=1 "+filter;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            String patient = map.get("id").toString();
@ -180,6 +181,80 @@ public class BaseServiceNewsService {
        return list;
    }
    /**
     * 查找所有未签约老人
     * 社区老人
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findUnSignPatientLocations(Integer page,Integer size){
        page = page>0?page-1:0;
        String filter =" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            if (StringUtils.isNotBlank(orgCodes)){
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and p.id not in ('"+orgCodes+"') ";
            }
        }
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid " +
                " from base_patient p " +
                "WHERE  p.del =1 and p.sign_status=0 "+filter+" limit "+page*size+","+size;
        String sqlCount = "SELECT count(p.id) " +
                " from base_patient p " +
                "WHERE  p.del =1 and p.sign_status=0 "+filter ;
        Long count = jdbcTemplate.queryForObject(sqlCount,Long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            String patient = map.get("id").toString();
            sql = "select label_code,label_name from wlyy_patient_label where label_type=1 and patient='"+patient+"' ";
            List<Map<String,Object>> labels = jdbcTemplate.queryForList(sql);
            if (labels.size()>0){
                map.put("label_code",labels.get(0).get("label_code"));
                map.put("label_name",labels.get(0).get("label_name"));
            }
            else {
                map.put("label_code",null);
                map.put("label_name",null);
            }
            String devices= deviceService.getPatientDeviceCategoryCode(map.get("id").toString());
            if ("0".equals(devices)){
                map.put("devices",new ArrayList<>());
            }else {
                String[] ss = devices.split(",");
                map.put("devices",ss);
            }
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            sql = " select CONCAT(o.serve_lat,',',o.serve_lon) latLon,'紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn from base_emergency_assistance_order o where o.patient='"+patient+"' and `status`=1 " +
                    " UNION All  " +
                    "select CONCAT(o.serve_lat,',',o.serve_lon) latLon,o.serve_desc serverDesc,o.hospital orgCode,o.device_sn from base_security_monitoring_order o where o.patient='"+patient+"' and `status`=1 ";
            List<Map<String,Object>> orderPoints = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> tmp:orderPoints){
                if (null!=tmp.get("device_sn")){
                    String device_sn = tmp.get("device_sn").toString();
                    if (StringUtils.isNotBlank(device_sn)){
                        DeviceDetail deviceDetail = deviceDetailDao.findBySn(device_sn);
                        if (null!=deviceDetail){
                            tmp.put("contactStatus",deviceDetail.getContactStatus());
                            tmp.put("categoryCode",deviceDetail.getCategoryCode());
                        }
                    }
                }
                String orgCode = tmp.get("orgCode").toString();
                BaseOrgDO orgDO = orgDao.findByCode(orgCode);
                if (null!=orgDO){
                    tmp.put("orgType",orgDO.getType());
                }
            }
            map.put("orderPoints",orderPoints);
        }
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    public List<Map<String , Object>> getLatLon(){
        String filter =" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_helper' or dict_name = 'jkzl_teacher' ";

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

@ -2029,6 +2029,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        tmp.put("city", response.getString("last_city"));
                        tmp.put("province", response.getString("last_province"));
                        tmp.put("address", response.getString("last_address"));
                        if (response.containsKey("location_updated_at") && response.get("location_updated_at") != null) {
                            JSONObject locationTimeObj = response.getJSONObject("location_updated_at");
                            Long locationTime =  locationTimeObj.getLongValue("$date");
                            tmp.put("locationTime", DateUtil.dateToStrLong( new Date(locationTime)));
                        }
                        result.put("location", tmp);
                        BasePatientDO patientDO = basePatientDao.findById(patient);
                        if (null != patientDO) {
@ -2089,13 +2094,15 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                DevicePatientDevice deviceDO = devicePatientDeviceDos2.get(0);
                double dulat = 0l;
                double dulon = 0l;
                String locationTime=null;
                //获取当前定位
                String sql = " SELECT * FROM base_yxdevice_index WHERE sn = '" + deviceDO.getDeviceSn() + "' " +
                String sql = " SELECT *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time FROM base_yxdevice_index WHERE sn = '" + deviceDO.getDeviceSn() + "' " +
                        "AND create_time LIKE '" + DateUtil.getStringDateShort() + "%' AND lon != 0 AND lat != 0 ORDER BY create_time DESC  ";
                List<Map<String, Object>> pointTmp = jdbcTemplate.queryForList(sql);
                if (pointTmp.size() > 0) {
                    dulat = Double.parseDouble(pointTmp.get(0).get("lat").toString());
                    dulon = Double.parseDouble(pointTmp.get(0).get("lon").toString());
                    locationTime = pointTmp.get(0).get("create_time").toString();
                }
                if ((dulat == 0.0 && dulon == 0.0)) {
                    BasePatientDO patientDO = basePatientDao.findById(deviceDO.getUser());
@ -2129,6 +2136,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                            Double areaLat = Double.parseDouble(areaPoint[1]);
                            positionTmp.put("lat", areaLat);
                            positionTmp.put("lon", areaLon);
                            positionTmp.put("locationTime", locationTime);
                            fenceLocation.add(positionTmp);
                        }
                        if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size() > 0) {
@ -2140,6 +2148,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                    obj.put("address", address);
                                    obj.put("lon", dulon);
                                    obj.put("lat", dulat);
                                    obj.put("locationTime", locationTime);
                                }
                            }
                        } else if (devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
@ -2151,6 +2160,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                location.put("city", "");
                                location.put("lon", dulon);
                                location.put("lat", dulat);
                                location.put("locationTime", locationTime);
                                result.put("location", location);
                                JSONArray fences = new JSONArray();
                                JSONObject fence = new JSONObject();

+ 25 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java

@ -9,6 +9,8 @@ import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
@ -67,6 +69,8 @@ public class DetectionPlatformService  {
    private ServicePackageService servicePackageService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
@ -549,27 +553,27 @@ public class DetectionPlatformService  {
    }
    public List<Map<String,Object >> findSignOlder(String doctorId){
        /*String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                " and m.del = '1' and  p.del = '1' " +
                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";*/
        String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and  p.del = '1' " +
                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";
//        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei,p.residential_area residentialArea  " +
//                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
//                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
//                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        if (doctorDO==null){
            return null;
        }
        String sql = "";
        if (2==doctorDO.getLevel()){//社工
            sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                    " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                    " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                    "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                    "and m.doctor_code = '"+doctorId+"' and m.del = '1' and  p.del = '1' " +
                    " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                    " ORDER BY online desc,p.ykt_id desc,signStatus desc ";
        }else if (4==doctorDO.getLevel()){//助老员
            sql = " SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea, " +
                  " p.sex,p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus " +
                  " from base_patient p,base_patient_helper ph " +
                  " where p.id = ph.patient and p.del=1 and ph.del=1 and ph.doctor='"+doctorId+"' ";
        }else {
            return null;
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order ";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order ";

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

@ -703,7 +703,7 @@ public class PatientInfoPlatFormService {
            sql += " and pd.device_sn = '"+deviceSn+"' ";
        }
        sql+=" order by device_type desc,pd.czrq asc ";
        sql+=" order by dd.device_type desc,pd.czrq asc ";
        list =  jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp :list){
            String category_code = tmp.get("category_code").toString();

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

@ -190,10 +190,10 @@ public class HvDeviceService {
            deviceHealthIndexDao.save(list);
            for (DeviceHealthIndex tmp :list){
                if ("1".equals(tmp.getDeviceType())){
                    dataPushLogUtil.savePatientMonitorData(tmp.getDeviceSn(),14,tmp.getValue()+tmp.getUnit(),null);
                    dataPushLogUtil.savePatientMonitorData(tmp.getDeviceSn(),14,tmp.getValue()+" "+tmp.getUnit(),null);
                }
                if ("2".equals(tmp.getDeviceType())){
                    dataPushLogUtil.savePatientMonitorData(tmp.getDeviceSn(),15,tmp.getValue()+tmp.getUnit(),null);
                    dataPushLogUtil.savePatientMonitorData(tmp.getDeviceSn(),15,tmp.getValue()+" "+tmp.getUnit(),null);
                }
            }
        }

+ 5 - 5
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java

@ -256,10 +256,10 @@ public class OnenetService {
        index.setRecordTime(time);
        index.setDeviceType(deviceType);
        if ("1".equals(deviceType)){
            dataPushLogUtil.savePatientMonitorData(resourceSerial,14,monitorValue+unit,null);
            dataPushLogUtil.savePatientMonitorData(resourceSerial,14,monitorValue+" "+unit,null);
        }
        if ("2".equals(deviceType)){
            dataPushLogUtil.savePatientMonitorData(resourceSerial,15,monitorValue+unit,null);
            dataPushLogUtil.savePatientMonitorData(resourceSerial,15,monitorValue+" "+unit,null);
        }
        deviceHealthIndexDao.save(index);
    }
@ -414,7 +414,7 @@ public class OnenetService {
            index.setDeviceType("2");
            index.setValue(value);
            deviceHealthIndexDao.save(index);
            dataPushLogUtil.savePatientMonitorData(deviceSn,15,value+"%",null);
            dataPushLogUtil.savePatientMonitorData(deviceSn,15,value+" "+"%",null);
            if (smokeValue>=70){
                if (StringUtils.isNotBlank(index.getTemperaturValue())){
                    if (50<=Integer.valueOf(index.getTemperaturValue())){ //查询温度是否>=50
@ -514,10 +514,10 @@ public class OnenetService {
            index.setRecordTime(DateUtil.getStringDate());
            deviceHealthIndexDao.save(index);
            if ("1".equals(index.getDeviceType())){
                dataPushLogUtil.savePatientMonitorData(deviceSn,14,index.getValue()+index.getUnit(),null);
                dataPushLogUtil.savePatientMonitorData(deviceSn,14,index.getValue()+" "+index.getUnit(),null);
            }
            if ("2".equals(index.getDeviceType())){
                dataPushLogUtil.savePatientMonitorData(deviceSn,15,index.getValue()+index.getUnit(),null);
                dataPushLogUtil.savePatientMonitorData(deviceSn,15,index.getValue()+" "+index.getUnit(),null);
            }
        }