Explorar o código

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

wangzhinan %!s(int64=2) %!d(string=hai) anos
pai
achega
e4f366ea33

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorDao.java

@ -24,7 +24,7 @@ import java.util.List;
public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO, String>, JpaSpecificationExecutor<BaseDoctorDO>  {
    @Modifying
    @Query("UPDATE BaseDoctorDO SET idcard = CONCAT(idcard,'-'),password = CONCAT(password,'-'), mobile = CONCAT(mobile,'-')   WHERE id = ?1")
    @Query("UPDATE BaseDoctorDO SET idcard = CONCAT(idcard,'-'),password = CONCAT(password,'-'), mobile = CONCAT(mobile,'-'),id = concat(id,'-')   WHERE id = ?1")
    void logOff(String id);
    BaseDoctorDO findById(String id);

+ 34 - 4
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -55,6 +55,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
@ -178,6 +180,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private HcyyService hcyyService;
    @Autowired
    private BaseSmsDao baseSmsDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @PostConstruct
    private void init() {
@ -255,13 +259,17 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    @PostMapping(value = "/doctor/logOff")
    @PostMapping(value = "/oauth/doctor/logOff")
    public JSONObject doctorLogOff(HttpServletRequest request){
        JSONObject jsonObject = new JSONObject();
        try {
            String userAgent = request.getHeader("userAgent");
            org.json.JSONObject json = new org.json.JSONObject(userAgent);
            userDetailsService.logOff(json.getString("uid"));
            BaseLoginLogDO loginLogDO = getLoginLog();
            if(loginLogDO == null){
                jsonObject.put("msg","该操作没有权限");
                jsonObject.put("status",200);
                return jsonObject;
            }
            userDetailsService.logOff(loginLogDO.getUserId());
            jsonObject.put("msg","注销成功");
            jsonObject.put("status",200);
            return jsonObject;
@ -273,6 +281,28 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
    }
    public HttpServletRequest getRequest(){
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }
    private BaseLoginLogDO getLoginLog(){
        String accessToken = this.extractToken(getRequest());
        String sql  = "SELECT a.* from base_login_log a WHERE a.token='"+accessToken+"' ORDER BY a.create_time desc LIMIT 1";
        List<BaseLoginLogDO> baseLoginLogDOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseLoginLogDO.class));
        //BaseLoginLogDO loginLogDO = baseLoginLogDao.findByToken(accessToken);
        return baseLoginLogDOList.size()>0?baseLoginLogDOList.get(0):null;
    }
    private String extractToken(HttpServletRequest request) {
        String accessToken = request.getHeader("token");
        if (null == accessToken) {
            accessToken = request.getParameter("token");
        }
        return accessToken;
    }
    /**
     * 登陆
     *

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java

@ -7,6 +7,7 @@ import com.yihu.jw.care.service.device.DevicePatientFaceService;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.care.util.DingdingUtil;
import com.yihu.jw.care.util.HongLingJinUtil;
import com.yihu.jw.care.util.PatientPushOnOffUtil;
import com.yihu.jw.care.util.SpeechTtsUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
@ -61,6 +62,8 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
    private SpeechTtsUtil speechTtsUtil;
    @Autowired
    private HongLingJinUtil hongLingJinUtil;
    @Autowired
    private PatientPushOnOffUtil patientPushOnOffUtil;
    @GetMapping(value = "open/getToken")
@ -86,6 +89,20 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "open/patienPushOnOff")
    @ApiOperation(value = "初始化居民消息订阅开关")
    public Envelop patienPushOnOff(){
        try {
            patientPushOnOffUtil.patientPushOnOff();
            return success("初始化成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException2(e);
        }
    }
    @GetMapping(value = "open/findFaceRecord")
    @ApiOperation(value = "获取人脸数据")

+ 3 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java

@ -336,7 +336,8 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
                        messageDO.setData(one.getContent());
                        messageDO.setDel("1");
                        messageDO.setCreateTime(new Date());
                        messageDO.setAudioUrl(speechTtsUtil.wordToVoice(title));
                        String url = speechTtsUtil.wordToVoice(one.getContent());
                        messageDO.setAudioUrl(url);
                        systemMessageDao.save(messageDO);
                        //推送socket
                        com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
@ -346,6 +347,7 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
                        message.put("relation_code",messageDO.getRelationCode());
                        message.put("content_type",41);
                        message.put("content_notice","");
                        message.put("audioUrl",url);
                        String content_notice = null;
                        imUtil.sendPatientSystemMessage(messageDO.getReceiver(), JSON.toJSONString(message, SerializerFeature.WriteMapNullValue));
                    }

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java

@ -121,8 +121,8 @@ public class PatientMessageEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "/getSystemMessageListPadTwo")
    public ListEnvelop getSystemMessageListPad(@ApiParam(name = "patient", required = true)
                                               @RequestParam(value = "patient", required = true) String patient,
                                               @ApiParam(name = "type", value = "类型", required = true)
                                               @RequestParam(value = "type", required = true) String type) {
                                               @ApiParam(name = "type", value = "类型", required = false)
                                               @RequestParam(value = "type", required = false) String type) {
        try {
            return ListEnvelop.getSuccess("查询成功",patientMessageService.getSystemMessageListPad(patient, type));
        } catch (Exception e) {

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

@ -152,7 +152,10 @@ public class PatientMessageService {
    public List<Map<String,Object>> getSystemMessageListPad(String patient,String type){
        String sql = "SELECT id,type,title,sender_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,is_read,data,content,audio_url " +
        if (!StringUtils.isNotBlank(type)) {
            type = "41,42,991,992,993,994,995,996,999";
        }
        String sql = "SELECT id,type,title,sender_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,is_read,data,content,audio_url as audioUrl " +
                " FROM base_system_message WHERE type IN ("+type+") and receiver = '"+patient+"'" +
                " AND del = 1  ORDER BY create_time DESC ";
        return  jdbcTemplate.queryForList(sql);

+ 79 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/PatientPushOnOffUtil.java

@ -0,0 +1,79 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.log.BasePatientPadPushOnOffDao;
import com.yihu.jw.entity.log.BasePatientPadPushOnOffEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by wsl on 2022/8/2
 */
@Component
public class PatientPushOnOffUtil {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientPadPushOnOffDao basePatientPadPushOnOffDao;
    //初始化居民推送开关
    @Transactional(rollbackFor = Exception.class)
    public String patientPushOnOff(){
        JSONObject jsonObject = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        jsonObject.put("1","时间整点报时");
        jsonArray.add(jsonObject);
        jsonObject.put("2","智能安居设备状态播报(必选)");
        jsonArray.add(jsonObject);
        jsonObject.put("3","体征测量消息");
        jsonArray.add(jsonObject);
        jsonObject.put("4","用药提醒");
        jsonArray.add(jsonObject);
        jsonObject.put("5","天气预报");
        jsonArray.add(jsonObject);
        jsonObject.put("6","服务预约提醒");
        jsonArray.add(jsonObject);
        jsonObject.put("7","生日祝福提醒");
        jsonArray.add(jsonObject);
        jsonObject.put("8","热点新闻播报");
        jsonArray.add(jsonObject);
        String sql = "SELECT p.id FROM  base_patient p WHERE  p.sign_status = 1 AND p.del = 1  ";
        List<String> patientList = jdbcTemplate.queryForList(sql, String.class);
        List<BasePatientPadPushOnOffEntity> onOffEntityList = new ArrayList<>();
        patientList.forEach(patientId -> {
            for (int i = 1; i <= jsonArray.size(); i++) {
                BasePatientPadPushOnOffEntity onOffEntity = new BasePatientPadPushOnOffEntity();
                onOffEntity.setPatient(patientId);
                onOffEntity.setType(i);
                onOffEntity.setTypeName(jsonArray.getJSONObject(0).getString(i+""));
                if (jsonArray.getJSONObject(0).getString(i+"").equals("智能安居设备状态播报(必选)")){
                    onOffEntity.setOnOff(1);
                }else {
                    onOffEntity.setOnOff(0);
                }
                onOffEntity.setCreateTime(new Date());
                onOffEntityList.add(onOffEntity);
            }
        });
        basePatientPadPushOnOffDao.save(onOffEntityList);
        return null;
    }
}

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

@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@ -172,7 +171,7 @@ public class DeviceUploadService {
                    String onOff= jdbcTemplate.queryForObject(adminSql,String.class);
                    Boolean kg = Boolean.parseBoolean(onOff);
                    String patientOnOffSql = "select on_off from base_patient_pad_pushonoff where patient = '" + patientDO.getId() + "' and type = 3";
                    Integer integer = jdbcTemplate.queryForObject(patientOnOffSql, new BeanPropertyRowMapper<>(Integer.class));
                    Integer integer = jdbcTemplate.queryForObject(patientOnOffSql,Integer.class);
                    if (kg&&integer==0?false:true) {
                        messageDO.setTitle(typeName);
                        messageDO.setType("42");//42体征设备测量
@ -199,7 +198,7 @@ public class DeviceUploadService {
                        messageDO.setCreateTime(new Date());
                        //推送socket
                        com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                        message.put("title", typeName2);
                        message.put("title", typeName);
                        message.put("code", messageDO.getCode());
                        message.put("content", messageDO.getData());
                        message.put("relation_code", messageDO.getRelationCode());

+ 1 - 1
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java

@ -131,7 +131,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("OVERTIME_VISIT_JOB exist");
            }
            //归集数据定时推送 每天晚上十一点
            //归集数据定时推送 每天凌晨两点
            if (!quartzHelper.isExistJob("SAVE_DATA_PUSH_JOB")){
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("SAVE_DATA_PUSH_JOB");
                quartzHelper.addJob(SaveDataPushJob.class, trigger, "SAVE_DATA_PUSH_JOB", new HashMap<String, Object>());

+ 1 - 27
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -325,6 +325,7 @@ public class PatientDeviceService {
                    patients.put("patient",map.get("id"));
                    patients.put("name",map.get("name"));
                    patients.put("sex",map.get("sex"));
                    patients.put("device_sn",map.get("device_sn").toString());
                    rslist.add(patients);
                }
                Thread.sleep(1000);
@ -362,7 +363,6 @@ public class PatientDeviceService {
                }
                Thread.sleep(1000);
            }
            System.out.println("离线居民人数:"+rslist.size());
            if (rslist.size()>0) {
                deviceLostMessageUtil.watchRemainingPower(rslist);
            }
@ -372,32 +372,6 @@ public class PatientDeviceService {
        }
    }
   /* //爱牵挂报警器电量获取判断
    public void deviceSoSAlarmRemainIngPower() {
        try {
            List<JSONObject> rslist = new ArrayList();
            String deviceWatchSql = "SELECT p.id,p.`name`,p.sex,d.device_sn,p.photo FROM base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user` WHERE category_code = 7 AND p.del = 1 ";
            List<Map<String, Object>> patientList = jdbcTemplate.queryForList(deviceWatchSql);
            for (Map<String, Object> map : patientList) {
                JSONObject response = getAqgDeviceInfo2(map.get("device_sn").toString());
                if (response.containsKey("remaining_power") && response.get("remaining_power") != null && response.getInteger("remaining_power") <= 20) {
                    JSONObject patients = new JSONObject();
                    patients.put("patient", map.get("id"));
                    patients.put("name", map.get("name"));
                    patients.put("sex", map.get("sex"));
                    rslist.add(patients);
                }
                Thread.sleep(1000);
            }
            if (rslist.size() > 0) {
                deviceLostMessageUtil.sosAlarmRemainIngPower(rslist);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/
    public static final String baseUrl = "http://api.aiqiangua.com:8888";// 正式环境
    public static final String deviceInfo = baseUrl +"/api/device/{0}";

+ 4 - 4
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/message/PushTimeIntegerPointService.java

@ -27,7 +27,7 @@ public class PushTimeIntegerPointService {
    @Autowired
    private SystemMessageDao systemMessageDao;
    private static String message = "现在是北京时间{Time}点整";
    private static String message = "现在是北京时间{Time}点整!";
    public void pushTimeIntegerPoint() {
        int i = DateUtil.integerTime();
@ -35,13 +35,13 @@ public class PushTimeIntegerPointService {
        List<SystemMessageDO> systemMessageDOList = new ArrayList<>();
        List<Map<String, Object>> signOldPatientList = systemPushMessageUtil.signOldPatient();
        String url = deviceLostMessageUtil.audioUrl(content);
        int num = 0;
        //int num = 0;
        for (Map<String, Object> map : signOldPatientList) {
            String patient = map.get("id").toString();
            if (!systemPushMessageUtil.findPatientPushOnOff(patient,1)){
                continue;
            }
            num+=1;
          //num+=1;
            SystemMessageDO messageDO = systemPushMessageUtil.systemMessageDOSave("整点报时", content,"996","0","system","整点报时通知助手",patient,map.get("name").toString(),"1",map.get("photo").toString(),url);
            /*socket 推送*/
            deviceLostMessageUtil.patientMessageSocket(messageDO,null);
@ -49,7 +49,7 @@ public class PushTimeIntegerPointService {
        }
        systemMessageDao.save(systemMessageDOList);
        systemPushMessageUtil.basePushRecordLogEntitySave(content,"2",new Date(),num,1,"签约老人",1,8);
        systemPushMessageUtil.basePushRecordLogEntitySave(content,"2",new Date(),systemMessageDOList.size(),1,"签约老人",1,8);
    }

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

@ -64,7 +64,7 @@ public class PushWeatherForecastService {
        }
        systemMessageDao.save(messageDOList);
        systemPushMessageUtil.basePushRecordLogEntitySave(content,"2",new Date(),list.size(),1,"签约老人",1,7);
        systemPushMessageUtil.basePushRecordLogEntitySave(content,"2",new Date(),messageDOList.size(),1,"签约老人",1,7);
    }

+ 2 - 4
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java

@ -174,12 +174,10 @@ public class DeviceLostMessageUtil {
        List<Map<String,Object>> patientList = jdbcTemplate.queryForList(sql);
        System.out.println(devices);
        //所有居民的设备
        for (Map<String, Object> patient : patientList) {
            String deviceSns = patient.get("deviceSn").toString();
            String[] deviceSplit = deviceSns.split(",");
            System.out.println(patient.get("id"));
            String deivceName = "";
            String deviceSnS = "";
            for (String deviceSn : deviceSplit) {
@ -191,7 +189,6 @@ public class DeviceLostMessageUtil {
                            systemMessageDao.delete(sendMessageBefore);
                        }
                        String deviceInfoSql = "SELECT device_sn,device_name,category_code FROM wlyy_patient_device WHERE device_sn = '"+offLineDeviceSn+"'";
                        System.out.println("SN吗 "+offLineDeviceSn);
                        List<DevicePatientDevice> query = jdbcTemplate.query(deviceInfoSql, new BeanPropertyRowMapper<>(DevicePatientDevice.class));
                        if (StringUtils.isNotBlank(deivceName)){
                            deivceName+=","+query.get(0).getDeviceName();
@ -286,7 +283,8 @@ public class DeviceLostMessageUtil {
            message.put("type","991");
            message.put("content",contentTwo);
            message.put("audioUrl",s);
            message.put("content_type",999);
            message.put("deviceSn",jsonObject.getString("device_sn"));
            message.put("content_type",991);
            imUtil.sendPatientSystemMessage(jsonObject.getString("patient"), JSON.toJSONString(message, SerializerFeature.WriteMapNullValue));
        }
        if (messageDOS.size() > 0) {

+ 2 - 2
svr/svr-cloud-job/src/main/resources/system.properties

@ -44,8 +44,8 @@ PUSHRECORD_LOG_INFO_JOB= 0 0/5 * * * ? *
PUSH_DEVICE_OFF_LONE_JOB= 0 30 9 * * ?
#\u6BCF\u5929\u65E9\u4E0A\u5341\u4E00\u70B9 \u624B\u8868\u4F69\u6234\u63D0\u9192
DEVICE_WATCH_OFF_WEAR_JOB= 0 0 11 * * ?
#\u624B\u8868\u7535\u91CF\u4F4E \u6BCF\u4E00\u4E2A\u5C0F\u65F6\u83B7\u53D6\u4E00\u6B21 \u7535\u91CF
DEVICE_WATCH_REMAINING_POWER_JOB= 0 0 8,9,10,14,15,16,17,18,19,20 * * ?
#\u624B\u8868\u7535\u91CF\u4F4E 8,14,21\u70B9\u63A8\u9001 \u7535\u91CF
DEVICE_WATCH_REMAINING_POWER_JOB= 0 0 8,14,21 * * ?
#\u65F6\u95F4\u6574\u70B9\u62A5\u65F6\uFF1A\u65E9\u4E0A10\u70B9\u5230\u4E0B\u534818\u70B9\u8FDB\u884C\u51C6\u70B9\u64AD\u62A5
PUSH_MASSAGE_TIME_INTEGER_POINT_JOB= 0 0 10,11,12,13,14,15,16,17,18 * * ?
#\u5929\u6C14\u9884\u62A5\uFF1A\u6BCF\u5929\u65E9\u4E0A11\u70B9\u64AD\u62A5