ソースを参照

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

liubing 3 年 前
コミット
e046c01437

+ 6 - 2
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -344,7 +344,9 @@ public class ElasticsearchUtil {
            String sqlArea = " select area_level from wlyy_job_config_new where id='"+index+"' ";
            List<String> areaLevels = jdbcTemplate.queryForList(sqlArea,String.class);
            if (areaLevels.size()>0){
                areaLevel = areaLevels.get(0);
                if (StringUtils.isNotBlank(areaLevels.get(0))){
                    areaLevel = areaLevels.get(0);
                }
            }
        }
@ -1144,7 +1146,9 @@ public class ElasticsearchUtil {
            String sqlArea = " select area_level from wlyy_job_config_new where id='"+index+"' ";
            List<String> areaLevels = jdbcTemplate.queryForList(sqlArea,String.class);
            if (areaLevels.size()>0){
                areaLevel = areaLevels.get(0);
                if (StringUtils.isNotBlank(areaLevels.get(0))){
                    areaLevel = areaLevels.get(0);
                }
            }
        }

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

@ -1600,4 +1600,17 @@ CREATE TABLE wlyy_patient_safe_area_confirm (
  `manage_status` tinyint(2) DEFAULT '0' COMMENT '电子围栏确认情况 0待确认 1已确认',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='患者电子围栏新增记录';
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='患者电子围栏新增记录';
-- 2021-12-22
CREATE TABLE `base_patient_step` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '手表sn',
   steps varchar(6) default null COMMENT '步数',
	 `day` varchar(10) DEFAULT null COMMENT '日期',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '产生日期',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT='患者手表步数';

+ 71 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BasePatientStepDo.java

@ -0,0 +1,71 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2021/12/22.
 */
@Entity
@Table(name="base_patient_step")
public class BasePatientStepDo extends IdEntity{
    private String patient;
    private String deviceSn;
    private String steps;
    private String day;
    private Date createTime;
    private Integer del;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getSteps() {
        return steps;
    }
    public void setSteps(String steps) {
        this.steps = steps;
    }
    public String getDay() {
        return day;
    }
    public void setDay(String day) {
        this.day = day;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 56 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.statistics.DetectionPlatformService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
@ -37,6 +38,8 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    private DetectionPlatformService platformService;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @ApiOperation("环境信息")
@ -206,6 +209,27 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("获取患者步数数据")
    @RequestMapping(value ="getPatientStep",method = RequestMethod.GET)
    public ObjEnvelop getPatientStep(@ApiParam(name="patient")@RequestParam(value = "patient",required = false)String patient,
                                     @ApiParam(name="deviceSn")@RequestParam(value = "deviceSn",required = false)String deviceSn,
                                     @ApiParam(name="day")@RequestParam(value = "day",required = false)String day){
        try {
            if (StringUtils.isBlank(patient)&&StringUtils.isBlank(deviceSn)){
                return ObjEnvelop.getError("请求参数");
            }
            org.json.JSONObject result = patientDeviceService.getPatientStep(patient,deviceSn,day);
            if (ResponseContant.success==result.getInt(ResponseContant.resultFlag)){
                return ObjEnvelop.getSuccess("获取成功",result.get(ResponseContant.resultMsg));
            }else {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("获取烟雾/燃气浓度列表")
    @RequestMapping(value ="getSmokeOrGasList",method = RequestMethod.GET)
    public ListEnvelop getSmokeOrGasList(@ApiParam(name="deviceSn")@RequestParam(value = "deviceSn",required = true)String deviceSn,
@ -248,4 +272,36 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("助老员端获取日常监护居民")
    @GetMapping(value = "findMonitorPatientsByDoctor")
    @ResponseBody
    public ObjEnvelop findMonitorPatientsByDoctor(@ApiParam(name = "doctor",  required = true)@RequestParam(value = "doctor")String doctor,
                                                  @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典,actionTrack行动轨迹", required = true)
                                                  @RequestParam(value = "topicItem",required = true,defaultValue = "preventLost") String topicItem,
                                                  @ApiParam(name = "day", value = "day", required = false)
                                                  @RequestParam(value = "day",required = false) String day,
                                                  @ApiParam(name = "page")
                                                  @RequestParam(value = "page",required = false) Integer page,
                                                  @ApiParam(name = "pageSize")
                                                  @RequestParam(value = "pageSize",required = false) Integer pageSize,
                                                  @ApiParam(name = "detail", value = "是否返回专题详情0否 1是")
                                                  @RequestParam(value = "detail",required = false,defaultValue = "0") Integer detail) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.findMonitorPatientsByDoctor(doctor,topicItem,day,page,pageSize,detail));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("助老员端获取日常监护居民")
    @GetMapping(value = "findSignOlder")
    @ResponseBody
    public ObjEnvelop findSignOlder(@ApiParam(name = "doctor",  required = true)@RequestParam(value = "doctor")String doctor) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", platformService.findSignOlder(doctor));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
}

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

@ -1189,6 +1189,32 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return result;
    }
    public JSONObject getPatientStep(String patient,String deviceSn,String day){
        JSONObject result = new JSONObject();
        String sql = " select * from base_patient_step where 1=1 ";
        if (StringUtils.isNotBlank(patient)){
            sql +=" and patient='"+patient+"'";
        }
        if (StringUtils.isNotBlank(deviceSn)){
            sql += " and device_sn='"+deviceSn+"' ";
        }
        if (StringUtils.isNotBlank(day)){
            sql +=" and create_time>='"+day+" 00:00:00' and create_time<'"+day+" 23:59:59' ";
        }else   {
            sql +=" order by create_time desc ";
        }
        sql +=" limit 1 ";
        List<BasePatientStepDo> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BasePatientStepDo.class));
        if (list.size()>0){
            result.put(ResponseContant.resultFlag,ResponseContant.success);
            result.put(ResponseContant.resultMsg,list.get(0));
        }else {
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"无步数数据!");
        }
        return result;
    }
    /**
     * 烟感、气感设备浓度列表获取
     */

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

@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.xerces.internal.xs.datatypes.ByteList;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
@ -16,6 +18,7 @@ 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.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import io.swagger.models.auth.In;
@ -29,10 +32,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/***
@ -60,6 +60,11 @@ public class DetectionPlatformService  {
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private ServicePackageService servicePackageService;
    /**
     * 体征监测 安防监护
@ -528,4 +533,55 @@ public class DetectionPlatformService  {
        return object;
    }
    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.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' ";
        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 ";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order  ";
        String sqlDevice = "SELECT pd.category_code deviceFlag, IFNULL(d.contact_status,0) status from wlyy_patient_device pd,wlyy_devices d";
        for (Map<String,Object> map : list){
            String paientId = map.get("id").toString();
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            //签约医生标识
            List<Map<String,Object>> doctorList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","1");
            List<Map<String,Object>> helperList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","2");
            map.put("helper", helperList.size()>0?1:0);
            map.put("doctor", doctorList.size()>0?1:0);
            String filterDevice = " WHERE pd.device_sn = d.device_code and pd.user = '"+paientId+"' ORDER BY deviceFlag,status desc";
            List<Map<String,Object>> deviceList = jdbcTemplate.queryForList(sqlDevice+filterDevice);
            Iterator it = deviceList.listIterator();
            Map<Object,Object> deviceMap = new HashedMap();
            while (it.hasNext()){
                Map<String,Object> tmp = (Map<String,Object>)it.next();
                if(deviceMap.containsKey(tmp.get("deviceFlag"))){
                    it.remove();
                }else{
                    deviceMap.put(tmp.get("deviceFlag"),tmp.get("deviceFlag"));
                }
            }
            String filter = " where patient = '"+paientId+"'";
            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("lifeCare",lifeCare);
            map.put("emergency",emergency);
            map.put("security",security);
            map.put("devices",deviceList);
        }
        return list;
    }
}

+ 14 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BasePatientStepDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BasePatientStepDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/12/22.
 */
public interface BasePatientStepDao extends PagingAndSortingRepository<BasePatientStepDo,Long>,
        JpaSpecificationExecutor<BasePatientStepDo> {
}

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

@ -393,6 +393,19 @@ public class DeviceController {
        }
    }
    @ApiOperation("设备步数接收")
    @RequestMapping(value = "stepsCreate",  method = {RequestMethod.POST,RequestMethod.GET})
    public String stepsCreate() {
        try {
            deviceService.stepsCreate();
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带end****************************************************************/
    /**
     * 返回接口处理结果

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

@ -99,6 +99,8 @@ public class DeviceService {
    private DeviceDataPushLogUtil dataPushLogUtil;
    @Autowired
    private PatientSafeAreaDao safeAreaDao;
    @Autowired
    private BasePatientStepDao stepDao;
    /**
     * 获取爱牵挂管理员cookie
@ -582,9 +584,19 @@ public class DeviceService {
    public void bySteps(String imei,String time_begin,int value) {
        try {
            if(StringUtils.isNotBlank(imei)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    BasePatientStepDo basePatientStepDo = new BasePatientStepDo();
                    basePatientStepDo.setPatient(devicePatientDeviceDos.get(0).getUser());
                    basePatientStepDo.setDeviceSn(imei);
                    basePatientStepDo.setDel(1);
                    basePatientStepDo.setSteps(value+"");
                    Date createTime = DateUtil.strToDate(time_begin,DateUtil.yyyy_MM_dd_HH_mm_ss);
                    basePatientStepDo.setCreateTime(createTime);
                    basePatientStepDo.setDay(DateUtil.dateToStr(createTime,DateUtil.YYYY_MM_DD));
                    stepDao.save(basePatientStepDo);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
@ -1006,4 +1018,34 @@ public class DeviceService {
        }
    }
    @Async
    public void stepsCreate(){
        String sql = " select data from device_data_push_log where api_name='爱牵挂设备步数数据接收' ORDER BY create_time asc ";
        List<String> steps = jdbcTemplate.queryForList(sql,String.class);
        List<BasePatientStepDo> list = new ArrayList<>();
        for(String step:steps)
        {
            try {
                JSONObject stepObj = JSONObject.parseObject(step);
                String imei = stepObj.getString("imei").replace("\"]","").replace("[\"","");
                String value = stepObj.getString("value").replace("\"]","").replace("[\"","");
                String time_begin = stepObj.getString("time_begin").replace("\"]","").replace("[\"","");
                if(StringUtils.isNotBlank(imei)){
                    List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                    if (devicePatientDeviceDos.size()>0){
                        BasePatientStepDo basePatientStepDo = new BasePatientStepDo();
                        basePatientStepDo.setPatient(devicePatientDeviceDos.get(0).getUser());
                        basePatientStepDo.setDeviceSn(imei);
                        basePatientStepDo.setDel(1);
                        basePatientStepDo.setSteps(value+"");
                        Date createTime = DateUtil.strToDate(time_begin,DateUtil.yyyy_MM_dd_HH_mm_ss);
                        basePatientStepDo.setCreateTime(createTime);
                        basePatientStepDo.setDay(DateUtil.dateToStr(createTime,DateUtil.YYYY_MM_DD));
                        list.add(basePatientStepDo);
                    }
                }
            }catch (Exception e){ }
        }
        stepDao.save(list);
    }
}