Browse Source

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

 Conflicts:
	common/common-entity/sql记录
wushilong 3 years ago
parent
commit
b6088797d1

+ 41 - 3
business/push-service/src/main/java/com/yihu/jw/push/util/GetuiUtil.java

@ -18,9 +18,12 @@ import com.getui.push.v2.sdk.dto.req.message.android.Ups;
import com.getui.push.v2.sdk.dto.req.message.ios.Alert;
import com.getui.push.v2.sdk.dto.req.message.ios.Aps;
import com.getui.push.v2.sdk.dto.req.message.ios.IosDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
@ -58,6 +61,40 @@ public class GetuiUtil {
    }
    public static void main(String[] args) {
/*        String url = "http://sdk.open.api.igexin.com/apiex.htm";
        IGtPush push = new IGtPush(url, AppKey, MasterSecret);
        TransmissionTemplate t = new TransmissionTemplate();
        t.setAppId(AppID);
        t.setAppkey(AppKey);
        t.setTransmissionContent("{title:\"标题\",content:\"内容\",payload:\"自定义数据\"}");
        t.setTransmissionType(1);
        // 定义"点击链接打开通知模板",并设置标题、内容、链接
//        LinkTemplate template = new LinkTemplate();
//        template.setAppId(appId);
//        template.setAppkey(appKey);
//        template.setTitle("你好你好");
//        template.setText("哦,好吧");
//        template.setLogoUrl("");
//        template.setUrl("http://getui.com");
        List<String> appIds = new ArrayList<String>();
        appIds.add(AppID);
        // 定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
        SingleMessage message = new SingleMessage();
        message.setData(t);
        message.setOffline(true);
        message.setOfflineExpireTime(1000 * 600);
        // 指定向哪儿推
        Target target = new Target();
        target.setAppId(AppID);
        target.setClientId("d2fee750dcdf7a2567444b1d4f629305");
        IPushResult ret = push.pushMessageToSingle(message, target);
        System.out.println(ret.getResponse().toString());*/
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("title","title");
//        jsonObject.put("body","body");
@ -73,8 +110,8 @@ public class GetuiUtil {
        String cid = "d2fee750dcdf7a2567444b1d4f629305";
        String title = "ios11:49标题";
        String body = "安卓离线展示的内容";
//        String url = "https://www.baidu.com/";
        String url = "/archives/index";
        String url = "https://www.baidu.com/";
//        String url = "/archives/index";
        JSONObject payload = new JSONObject();
        payload.put("title",title);
        payload.put("body",body);
@ -88,7 +125,7 @@ public class GetuiUtil {
        json.put("platform",cloudCareDoctor);
        json.put("payload",payload.toString());
        push2(cid,1,json);
        push2(cid,2,json);
    }
    /**
@ -152,6 +189,7 @@ public class GetuiUtil {
            IosDTO iosDTO = new IosDTO();
            iosDTO.setAps(aps);
            iosDTO.setType("notify");
            iosDTO.setPayload(json.getString("payload"));
            pushChannel.setIos(iosDTO);
        }

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

@ -1602,6 +1602,19 @@ CREATE TABLE wlyy_patient_safe_area_confirm (
  PRIMARY KEY (`id`)
) 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='患者手表步数';
-- 2021-12-27
CREATE TABLE `base_activity_click` (
  `id` varchar(50) NOT NULL,

+ 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);
    }
}