Bladeren bron

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

wangzhinan 3 jaren geleden
bovenliggende
commit
426ce9d792

+ 27 - 0
business/base-service/src/main/java/com/yihu/jw/internet/service/YKYKCommonService.java

@ -0,0 +1,27 @@
package com.yihu.jw.internet.service;
import com.yihu.jw.internet.dao.InternetUpLogDao;
import com.yihu.jw.internet.entity.InternetUpErrorLogDO;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
/**
 * Created by wsy on 2021/9/7.
 */
public class YKYKCommonService extends BaseJpaService<InternetUpErrorLogDO, InternetUpLogDao> {
    private org.slf4j.Logger logger = LoggerFactory.getLogger(YKYKCommonService.class);
    @Autowired
    private InternetUpErrorLogService internetUpErrorLogService;
    @Autowired
    private InternetUpLogDao internetUpLogDao;
    @Value("{fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
}

+ 37 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/aop/ClientSearchRequestAspect.java

@ -0,0 +1,37 @@
package com.yihu.jw.base.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.lang.reflect.Method;
/**
 * Created by wsy on 2021/9/7.
 */
@Order(5)
@Aspect
@Component
public class ClientSearchRequestAspect {
    private static final String REQ_LIMIT = "req_limit";
    public static int RESPONSE_STATUS_CODE = 1000;
    @Around("execution(* com.yihu.jw.base.endpoint.searchClient.ClientSearchEndpoint.saveBaseSearchNoveltyRepeat(..))"
            +"&& @annotation(com.yihu.jw.base.aop.ClientSearchRequestLimit)")
    public Object method(ProceedingJoinPoint pjp) throws Throwable{
        MethodSignature signature = (MethodSignature) pjp.getSignature();
        Method method = signature.getMethod();//获取被拦截的方法
        ClientSearchRequestLimit limit = method.getAnnotation(ClientSearchRequestLimit.class);
        if ( limit == null ){
            return pjp.proceed();
        }
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return requestAttributes;
    }
}

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/aop/ClientSearchRequestLimit.java

@ -0,0 +1,18 @@
package com.yihu.jw.base.aop;
import java.lang.annotation.*;
/**
 * Created by wsy on 2021/9/7.
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ClientSearchRequestLimit {
    int time() default 60;
    int count() default 2;
    int waits() default 300;
}

+ 17 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/searchClient/BaseSearchNoveltyRepeatDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.base.dao.searchClient;
import com.yihu.jw.entity.base.searchClient.BaseSearchNoveltyRepeatDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by wsy on 2021/9/4.
 */
public interface BaseSearchNoveltyRepeatDao extends PagingAndSortingRepository<BaseSearchNoveltyRepeatDO,String>{
    @Query(value = "select b from BaseSearchNoveltyRepeatDO b where name = ?1 or subject = ?1 or content = ?1")
    List<BaseSearchNoveltyRepeatDO> findBySearchData(String searchData);
}

+ 6 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/searchClient/ClientSearchEndpoint.java

@ -4,9 +4,9 @@ package com.yihu.jw.base.endpoint.searchClient;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.base.aop.ClientSearchRequestLimit;
import com.yihu.jw.base.service.clientSearch.ClientSearchService;
import com.yihu.jw.entity.base.searchClient.BaseSearchNoveltyRepeatDO;
import com.yihu.jw.entity.base.searchClient.FileResourceVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -42,6 +42,7 @@ public class ClientSearchEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.ClientSearch.CREATE)
    @ApiOperation(value = "保存查新查重服务")
    @ClientSearchRequestLimit(time = 60,count = 2,waits = 10)
    public Envelop saveBaseSearchNoveltyRepeat(@ApiParam(name = "jsonData",value = "")
                                               @RequestParam(name = "jsonData", required = true) String jsonData) throws Exception{
        try{
@ -71,6 +72,9 @@ public class ClientSearchEndpoint extends EnvelopRestEndpoint {
    public Envelop findSearchNoveltyRepeatById(@ApiParam(name = "SearchData", value = "查询字段")
                                               @RequestParam(name = "SearchData", required = true) String SearchData) throws Exception{
        try{
            if(SearchData == null || SearchData.trim().length() == 0){
                return failed("输入参数为空,请重新输入");
            }
            List list;
            list = clientSearchService.findBySearchData(SearchData);
            return success("success",list);
@ -92,7 +96,7 @@ public class ClientSearchEndpoint extends EnvelopRestEndpoint {
                                               @ApiParam(name = "pageSize", value = "每页分页大小", required = true, defaultValue = "10")
                                               @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize) throws Exception{
        try{
            List<BaseSearchNoveltyRepeatDO> list = clientSearchService.search(fields,filters,sorts,page,pageSize);
            List<BaseSearchNoveltyRepeatDO> list = clientSearchService.search(fields,filters,"-createTime",page,pageSize);
            int count = (int) clientSearchService.getCount(filters);
            return success("success",200,list,count,page,pageSize);
        }catch (Exception e){

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/menu/BaseMenuManageService.java

@ -185,7 +185,11 @@ public class BaseMenuManageService {
                baseMenuDictDO.setFunctionName(menuFunction.getDictValue());
            }else {
                WlyyHospitalSysDictDO menuLocation = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("menuLocation",baseMenuDictDO.getMenuLocation());
                baseMenuDictDO.setLocaTionName(menuLocation.getDictValue());
                if (menuLocation.getDictValue() == null){
                    baseMenuDictDO.setLocaTionName("无");
                }else {
                    baseMenuDictDO.setLocaTionName(menuLocation.getDictValue());
                }
            }
        }
        return baseMenuDictDO;

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

@ -35,12 +35,13 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private PatientDeviceService patientDeviceService;
    /**************************v1.1.0新增 设备异常动态************************************/
    @GetMapping(value = "getHealthMonitoringListNew")
    @ApiOperation(value = "体征监测/安防监护")
    public PageEnvelop getHealthMonitoringListNew(
            @ApiParam(name="page",value = "page") @RequestParam(required = true) int page,
            @ApiParam(name="size",value = "size") @RequestParam(required = true) int size,
            @ApiParam(name="type",value = "type=1(健康监测)   type=2(安防检测)") @RequestParam(required = true) int type) {
            @ApiParam(name="type",value = "type=1(健康监测)   type=2(安防检测)   type=3(设备异常)") @RequestParam(required = true) int type) {
        try {
            return platformService.getHealthMonitoringListNew(page,size,type);
        } catch (Exception e) {
@ -157,4 +158,26 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
    }
    /********************v1.1.0**************************/
    @GetMapping(value = "getGiveEarlyWarning")
    @ApiOperation(value = "物联网检测大屏,预警部分")
    public ObjEnvelop getGiveEarlyWarning(){
        try {
            return success("查询成功",200, platformService.getDistributionOfWarningTypes());
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "getServiceSituation")
    @ApiOperation(value = "物联网检测大屏,服务情况")
    public ObjEnvelop getServiceSituation(){
        try {
            return success("查询成功",200, platformService.getServiceSituation());
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
}

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

@ -11,6 +11,7 @@ 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.utils.StringUtil;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,6 +22,7 @@ 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.stream.Collectors;
@ -60,7 +62,7 @@ public class DetectionPlatformService  {
            sql +=" limit "+page*pageSize+","+pageSize;
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        }else {
        }else if (type == 2){
            String sql = " select  '22' as 'OrderType',ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`,ord.doctor,ord.doctor_name \n" +
                    "from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id order by create_time desc ";
            String countSql = "select count(id) from ("+sql+")A ";
@ -68,6 +70,16 @@ public class DetectionPlatformService  {
            sql +=" limit "+page*pageSize+","+pageSize;
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        } else {
            String sql = " SELECT pd.id,pd.device_sn deviceSn,pd.`user`,p.`name`,d.contact_status_time contactStatusTime,CASE pd.category_code WHEN '1' THEN '血糖仪离线' WHEN '2' THEN '血压计离线' WHEN '13' THEN '睡眠带离线'\n" +
                    "WHEN '17' THEN '随身WiFi离线' WHEN '7' THEN '居家安全报警器离线' WHEN '12' THEN '监控器离线' WHEN '14' THEN '气感报警器离线' WHEN '15' THEN '烟感报警器离线' WHEN '16' THEN '智能拐杖离线' WHEN '4' THEN '智能手表离线' \n" +
                    "ELSE '未知' END categoryCode FROM wlyy_devices d,wlyy_patient_device pd,base_patient p\n" +
                    "WHERE d.contact_status = 0 AND pd.del = 0 AND pd.device_sn = d.device_code AND pd.`user` = p.id ORDER BY d.contact_status_time DESC ";
            String countSql = "select count(id) from ("+sql+")A ";
            long count = jdbcTemplate.queryForObject(countSql,long.class);
            sql +=" limit "+page*pageSize+","+pageSize;
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        }
    }
@ -323,4 +335,71 @@ public class DetectionPlatformService  {
        return nightRecordList;  //起夜记录
    }
    public JSONObject getDistributionOfWarningTypes(){
        JSONObject object = new JSONObject();
        /****预警类型分布****/
        String sql = "SELECT hsd.dict_value,aa.count FROM wlyy_hospital_sys_dict hsd LEFT JOIN (SELECT serve_desc,COUNT(1) count FROM base_security_monitoring_order GROUP BY serve_desc)aa ON hsd.dict_value = aa.serve_desc WHERE hsd.dict_name = 'security_server_dict'";
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        /****工单总量****/
        String sqlAll = "SELECT COUNT(1) count FROM base_security_monitoring_order";
        Integer countAll = jdbcTemplate.queryForObject(sqlAll,Integer.class);
        /****误报警数量****/
        String sql1 = "SELECT COUNT(1) count FROM base_security_monitoring_order WHERE emergency_cancel IS NOT NULL OR emergency_cancel != ''";
        Integer falseAlarmCount = jdbcTemplate.queryForObject(sql1,Integer.class);
        /****响应数量****/
        String responseCountSql = "SELECT COUNT(1) count FROM base_security_monitoring_order WHERE (emergency_cancel IS NOT NULL OR emergency_cancel != '') OR `status` = 0 GROUP BY id";
        List<Map<String,Object>> responseList = jdbcTemplate.queryForList(responseCountSql);
        Integer responseCount = responseList.size();
        object.put("distributionOfWarning",list);
        object.put("countAll",countAll);
        object.put("falseAlarmCount",falseAlarmCount);
        object.put("responseCount",responseCount);
        /****误报警率****/
        object.put("falseAlarmLaw",getRange(falseAlarmCount,countAll));
        /****响应率****/
        object.put("responseLaw",getRange(responseCount,countAll));
        return object;
    }
    public JSONObject getServiceSituation(){
        JSONObject object = new JSONObject();
        /*****设备分类****/
        // SELECT hsd.`value` dict_value,aa.count FROM base_system_dict_entry hsd LEFT JOIN (SELECT serve_desc,COUNT(1) count FROM base_security_monitoring_order GROUP BY serve_desc)aa ON hsd.`value` = aa.serve_desc WHERE hsd.remark = 'security'
        String passportTypeSql = "SELECT sde.`value`,COUNT(d.id) count,GROUP_CONCAT(DISTINCT d.category_code SEPARATOR ',') AS category_code,GROUP_CONCAT(DISTINCT d.model SEPARATOR ',') AS model FROM base_system_dict_entry sde LEFT JOIN dm_device d ON FIND_IN_SET(sde.`code`,d.service_topic) WHERE sde.remark = 'security' GROUP BY sde.`value` ";
        List<Map<String , Object>> passportType = jdbcTemplate.queryForList(passportTypeSql);
        String useSql = "";
        String allSql = "";
        String model = "";
        Integer use = 0;
        Integer putOnFile = 0;
        if (passportType.size() > 0) {
            for (int i=0;i<passportType.size();i++) {
                System.out.println(passportType.get(i).get("value") +"      " + passportType.get(i).get("count") +"      " + passportType.get(i).get("category_code"));
                Long count = (Long) passportType.get(i).get("count");
                model = (String) passportType.get(i).get("model");
                model = model.replace(",","','");
                if ( count.intValue() > 0) {
                    useSql = "SELECT COUNT(1) FROM wlyy_patient_device WHERE category_code IN ("+ passportType.get(i).get("category_code") +") AND del = 0";
                    use = jdbcTemplate.queryForObject(useSql,Integer.class);
                    passportType.get(i).put("use",use);//使用
                    allSql = "SELECT COUNT(1) FROM wlyy_devices WHERE device_model IN ('"+ model +"')";
                    putOnFile = jdbcTemplate.queryForObject(allSql,Integer.class);
                    passportType.get(i).put("putOnFile",putOnFile); //备案
                    passportType.get(i).put("stock",putOnFile - use); //库存
                } else {
                    passportType.get(i).put("putOnFile",0); //备案
                    passportType.get(i).put("stock",0); //库存
                    passportType.get(i).put("use",0); //使用
                }
            }
        }
        object.put("passportType",passportType);
        return object;
    }
}

+ 28 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/WlyyDeviceDao.java

@ -0,0 +1,28 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
/***
 * @ClassName: WlyyDeviceDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/9/6 11:12
 */
public interface WlyyDeviceDao extends PagingAndSortingRepository<DeviceDetail, Long> {
    @Modifying
    @Query("update DeviceDetail o set o.contactStatus = 0 , o.contactStatusTime = ?1 where o.deviceCode = ?2")
    void updateContactStatus(Date contactStatusTime, String orderId);
    @Modifying
    @Query("update DeviceDetail o set o.contactStatus = 1 , o.contactStatusTime = ?1 where o.deviceCode = ?2")
    void updateContactStatus1(Date contactStatusTime, String orderId);
}

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

@ -3,6 +3,7 @@ package com.yihu.jw.care.event;
import com.yihu.jw.care.job.BirthdayReminderJob;
import com.yihu.jw.care.job.QuartzHelper;
import com.yihu.jw.care.job.consult.FinishConsultJob;
import com.yihu.jw.care.job.device.DeviceLostAssociationJob;
import com.yihu.jw.care.job.device.PatientSosContactsJob;
import com.yihu.jw.care.job.message.DoctorSendUnreadJob;
import com.yihu.jw.care.job.message.PatientSendUnreadJob;
@ -84,6 +85,14 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("PATIENT_SOS_CONTACTS_JOB exist");
            }
            if (!quartzHelper.isExistJob("DEVICE_LOST_ASSOCIATION_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("DEVICE_LOST_ASSOCIATION_JOB");
                quartzHelper.addJob(DeviceLostAssociationJob.class, trigger, "DEVICE_LOST_ASSOCIATION_JOB", new HashMap<String, Object>());
                logger.info("DEVICE_LOST_ASSOCIATION_JOB success");
            } else {
                logger.info("DEVICE_LOST_ASSOCIATION_JOB exist");
            }
        } catch (Exception e) {
            logger.info(" job start failed");
        }

+ 37 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/device/DeviceLostAssociationJob.java

@ -0,0 +1,37 @@
package com.yihu.jw.care.job.device;
import com.yihu.jw.care.service.device.PatientDeviceService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/***
 * @ClassName: DeviceLostAssociationJob
 * @Description: 医养物联网检测大屏失联率
 * @Auther: shi kejing
 * @Date: 2021/9/6 13:37
 */
@DisallowConcurrentExecution
public class DeviceLostAssociationJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(DeviceLostAssociationJob.class);
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("DeviceLostAssociationJob start");
        try {
            patientDeviceService.selectAndUpdate();
            logger.info("DeviceLostAssociationJob end");
        } catch (Exception e) {
            logger.info(e.getMessage());
            e.printStackTrace();
        }
    }
}

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

@ -4,8 +4,11 @@ package com.yihu.jw.care.service.device;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.WlyyDeviceDao;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
@ -16,12 +19,14 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.annotation.PostConstruct;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -41,6 +46,10 @@ public class PatientDeviceService {
    private GpsUtil gpsUtil;
    @Autowired
    private DeviceDao deviceDao;
    @Autowired
    private WlyyDeviceDao wlyyDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    Map<Integer, String> relations = new HashMap<>();
@ -218,4 +227,94 @@ public class PatientDeviceService {
    /******************************************* 爱牵挂设备end *****************************************************/
    /**************************************物联网检测大屏失联率start************************************************/
    public void selectAndUpdate(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String endTime = sdf.format(new Date());
        Calendar device1 = Calendar.getInstance();
        device1.setTime(new Date());
        device1.add(device1.DATE, -30);
        Date nowDate = device1.getTime();
        String startTimeDevice1 = sdf.format(nowDate);
        Calendar device2 = Calendar.getInstance();
        device2.setTime(new Date());
        device2.add(device2.DATE, -2);
        Date nowDate2 = device2.getTime();
        String startTimeDevice2 = sdf.format(nowDate2);
        try {
            /**血糖仪,血压计。30天内有数据上传,则改为未失联**/
            String sql = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code IN (1,2) GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code IN (1,2)) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NOT NULL OR aa.device_sn != ''";
            List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
            if (list.size() > 0) {
                for (int i=0;i<list.size();i++) {
                    wlyyDeviceDao.updateContactStatus1(new Date(), (String) list.get(i).get("device_sn"));
                }
            }
            /**智能拐杖、智能手表。2天内有数据上传,则改为未失联**/
            sql = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code IN (16) GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code IN (16)) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NOT NULL OR aa.device_sn != ''";
            list = jdbcTemplate.queryForList(sql);
            if (list.size() > 0) {
                for (int i=0;i<list.size();i++) {
                    wlyyDeviceDao.updateContactStatus1(new Date(), (String) list.get(i).get("device_sn"));
                }
            }
            /**血糖仪**/
            String sql1 = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code = 1 GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code = 1) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NULL OR aa.device_sn = ''";
            List<Map<String , Object>> list1 = jdbcTemplate.queryForList(sql1);
            if (list1.size() > 0) {
                for (int i=0;i<list1.size();i++) {
                    wlyyDeviceDao.updateContactStatus(new Date(), (String) list1.get(i).get("device_sn"));
                }
            }
            /**血压计**/
            String sql2 = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code = 2 GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code = 2) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NULL OR aa.device_sn = ''";
            List<Map<String , Object>> list2 = jdbcTemplate.queryForList(sql2);
            if (list2.size() > 0) {
                for (int i=0;i<list2.size();i++) {
                    wlyyDeviceDao.updateContactStatus(new Date(), (String) list2.get(i).get("device_sn"));
                }
            }
            /**智能手表**/
            //startTimeDevice2   2天
            /**智能拐杖**/
            String sql3 = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code = 16 GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code = 16) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NULL OR aa.device_sn = ''";
            List<Map<String , Object>> list3 = jdbcTemplate.queryForList(sql3);
            if (list3.size() > 0) {
                for (int i=0;i<list3.size();i++) {
                    wlyyDeviceDao.updateContactStatus(new Date(), (String) list3.get(i).get("device_sn"));
                }
            }
        } catch (Exception e) {
            logger.info(e.getMessage());
        }
    }
}

+ 15 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.web;
import com.yihu.jw.care.job.BirthdayReminderJob;
import com.yihu.jw.care.job.QuartzHelper;
import com.yihu.jw.care.job.consult.FinishConsultJob;
import com.yihu.jw.care.job.device.DeviceLostAssociationJob;
import com.yihu.jw.care.job.message.DoctorSendUnreadJob;
import com.yihu.jw.care.job.message.PatientSendUnreadJob;
import com.yihu.jw.care.service.BirthdayReminderService;
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.UUID;
/**
 * 任务启动
@ -37,6 +39,19 @@ public class JobController extends BaseController {
    @Autowired
    private BirthdayReminderService birthdayReminderService;
    @RequestMapping(value = "/deviceLostAssociationJob", method = RequestMethod.POST)
    @ApiOperation("医养物联网检测大屏失联率")
    public String deviceLostAssociationJob() {
        try {
            quartzHelper.startNow(DeviceLostAssociationJob.class, null, null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
        this.jobService = jobService;

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

@ -1,18 +1,21 @@
#居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
#\u5C45\u6C1124\u5C0F\u65F6\u672A\u56DE\u590D\u7684\u54A8\u8BE2\u81EA\u52A8\u5173\u95ED \u6BCF\u5C0F\u65F659\u5206\u5F00\u59CB\u6267\u884C\u4E00\u6B21
finish_consult_job=0 59 * * * ?
#每天的早上9:00,给所有医生/助老员/教师发送一条短信
#\u6BCF\u5929\u7684\u65E9\u4E0A9:00\uFF0C\u7ED9\u6240\u6709\u533B\u751F/\u52A9\u8001\u5458/\u6559\u5E08\u53D1\u9001\u4E00\u6761\u77ED\u4FE1
DOCTOR_SEND_UNREAD_MES_JOB=0 0 9 * * ?
#每天的早上9:00,给所有居民发送未读消息微信模板
#\u6BCF\u5929\u7684\u65E9\u4E0A9:00\uFF0C\u7ED9\u6240\u6709\u5C45\u6C11\u53D1\u9001\u672A\u8BFB\u6D88\u606F\u5FAE\u4FE1\u6A21\u677F
PATIENT_SEND_UNREAD_MES_JOB=0 0 9 * * ?
#每天的早上9:00,生日祝福提醒短信
#\u6BCF\u5929\u7684\u65E9\u4E0A9:00\uFF0C\u751F\u65E5\u795D\u798F\u63D0\u9192\u77ED\u4FE1
BIRTHDAY_REMINDER_JOB=0 0 9 * * ?
#取消订单支付超时的订单,每3分钟执行一次
#\u53D6\u6D88\u8BA2\u5355\u652F\u4ED8\u8D85\u65F6\u7684\u8BA2\u5355\uFF0C\u6BCF3\u5206\u949F\u6267\u884C\u4E00\u6B21
CANCEL_PAY_ORDER_OVERTIME_JOB=0 0/3 * * * ?
#居民紧急联系人数据同步更新每2分钟执行一次
PATIENT_SOS_CONTACTS_JOB=0 0/2 * * * ?
#\u5C45\u6C11\u7D27\u6025\u8054\u7CFB\u4EBA\u6570\u636E\u540C\u6B65\u66F4\u65B0\u6BCF2\u5206\u949F\u6267\u884C\u4E00\u6B21
PATIENT_SOS_CONTACTS_JOB=0 0/2 * * * ?
#\u533B\u517B\u7269\u8054\u7F51\u68C0\u6D4B\u5927\u5C4F\u5931\u8054\u7387
DEVICE_LOST_ASSOCIATION_JOB=0 30 23 * * ?