浏览代码

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

yeshijie 3 年之前
父节点
当前提交
c4bf753d98
共有 20 个文件被更改,包括 637 次插入21 次删除
  1. 4 1
      common/common-entity/sql记录
  2. 157 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/searchClient/BaseSearchNoveltyRepeatDO.java
  3. 2 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  4. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  5. 134 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/searchClient/ClientSearchEndpoint.java
  6. 24 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/clientSearch/ClientSearchService.java
  7. 24 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  8. 4 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  9. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java
  10. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YunXunDeviceService.java
  11. 3 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  12. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  13. 80 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  14. 28 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/WlyyDeviceDao.java
  15. 9 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  16. 37 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/device/DeviceLostAssociationJob.java
  17. 1 1
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/device/YunXunDeviceService.java
  18. 99 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  19. 15 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java
  20. 10 7
      svr/svr-cloud-job/src/main/resources/system.properties

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

@ -1430,4 +1430,7 @@ CREATE TABLE `device_data_push_log` (
  `data` varchar(1000) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=449 DEFAULT CHARSET=utf8mb4 COMMENT='设备项目推送数据日志';
) ENGINE=InnoDB AUTO_INCREMENT=449 DEFAULT CHARSET=utf8mb4 COMMENT='设备项目推送数据日志';
--2021-09-07
alter table base_patient modify column archive_type  tinyint(2) DEFAULT NULL COMMENT '档案类型 1老人 2新生儿';

+ 157 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/searchClient/BaseSearchNoveltyRepeatDO.java

@ -0,0 +1,157 @@
package com.yihu.jw.entity.base.searchClient;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wsy on 2021/9/4.
 */
@Entity
@Table(name = "base_search_novelty_repeat")
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class BaseSearchNoveltyRepeatDO extends UuidIdentityEntityWithOperator {
    private String Name;         //委托人
    private String Phone;        //联系电话
    private String Email;        //联系邮箱
    private String Address;      //联系地址
    private String subject;             //申请主题
    private String mechanism;           //机构
    private String content;             //申请内容
    private String file;            //文件
    private Integer status;              //状态码
    private String number;              //委托单号
    //private String createTime;            //生成时间
    private String reversion;                 //答复
   /* private String update_time;           //更新时间
    private String update_user_name;      //更新用户*/
    private String statusName;            //状态名称
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
/*  public String getUpdate_time() {
        return update_time;
    }
    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }
    public String getUpdate_user_name() {
        return update_user_name;
    }
    public void setUpdate_user_name(String update_user_name) {
        this.update_user_name = update_user_name;
    }
*/
    public String getReversion() {
        return reversion;
    }
    public void setReversion(String reversion) {
        this.reversion = reversion;
    }
    /*public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }*/
    public String getName() {
        return Name;
    }
    public void setName(String Name) {
        this.Name = Name;
    }
    public String getPhone() {
        return Phone;
    }
    public void setPhone(String Phone) {
        this.Phone = Phone;
    }
    public String getEmail() {
        return Email;
    }
    public void setEmail(String Email) {
        this.Email = Email;
    }
    public String getAddress() {
        return Address;
    }
    public void setAddress(String Address) {
        this.Address = Address;
    }
    public String getSubject() {
        return subject;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }
    public String getMechanism() {
        return mechanism;
    }
    public void setMechanism(String mechanism) {
        this.mechanism = mechanism;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getFile() {
        return file;
    }
    public void setFile(String file) {
        this.file = file;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getNumber() {
        return number;
    }
    public void setNumber(String number) {
        this.number = number;
    }
}

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -867,6 +867,8 @@ public class BaseRequestMapping {
        public static final String FINDALL = "/findAll";
        public static final String CHANGESTATUS = "/changestatus";
        public static final String REPLY = "/reply";
        public static final String FILEDOWNLOAD = "/fileDownLoad";
        public static final String FILEUPLOAD = "/fileUpLoad";
    }
}

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

@ -339,7 +339,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
        if ("pad".equals(parameters.get("clientType"))&&("2".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
            throw new InvalidGrantException("不允许登录该平台");
        }
        wlyyUserSimple.setAccessToken(token.getValue());

+ 134 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/searchClient/ClientSearchEndpoint.java

@ -0,0 +1,134 @@
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.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;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;
/**
 * Created by wsy on 2021/9/4.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.ClientSearch.PREFIX)
@Api(value = "查新查重服务",description = "查新查重服务",tags = {"查新查重服务"})
public class ClientSearchEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ClientSearchService clientSearchService;
    @PostMapping(value = BaseRequestMapping.ClientSearch.CREATE)
    @ApiOperation(value = "保存查新查重服务")
    public Envelop saveBaseSearchNoveltyRepeat(@ApiParam(name = "jsonData",value = "")
                                               @RequestParam(name = "jsonData", required = true) String jsonData) throws Exception{
        try{
            BaseSearchNoveltyRepeatDO baseSearchNoveltyRepeatDO = objectMapper.readValue(jsonData, BaseSearchNoveltyRepeatDO.class);
            clientSearchService.saveBaseSearchNoveltyRepeat(baseSearchNoveltyRepeatDO);
            return success("success");
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(BaseRequestMapping.ClientSearch.DELETEBYID)
    @ApiOperation(value = "删除查新查重")
    public Envelop deleteSearchNoveltyRepeatById(@ApiParam(name = "id",value = "")
                                                 @RequestParam(name = "id", required = true) String id) throws Exception{
        try{
            clientSearchService.deleteByid(id);
            return success("success");
        }catch(Exception e){
            return failedException(e);
        }
    }
    @GetMapping(BaseRequestMapping.ClientSearch.FINDBYSEARCHDATA)
    @ApiOperation(value = "根据搜索查询")
    public Envelop findSearchNoveltyRepeatById(@ApiParam(name = "SearchData", value = "查询字段")
                                               @RequestParam(name = "SearchData", required = true) String SearchData) throws Exception{
        try{
            List list;
            list = clientSearchService.findBySearchData(SearchData);
            return success("success",list);
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(BaseRequestMapping.ClientSearch.FINDALL)
    @ApiOperation("查询所有")
    public Envelop findSearchNoveltyRepeatAll( @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
                                               @RequestParam(value = "fields", required = false) String fields,
                                               @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
                                               @RequestParam(value = "filters", required = false) String filters,
                                               @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
                                               @RequestParam(value = "sorts", required = false) String sorts,
                                               @ApiParam(name = "page", value = "第几页,从1开始", required = true, defaultValue = "1")
                                               @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                                               @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);
            int count = (int) clientSearchService.getCount(filters);
            return success("success",200,list,count,page,pageSize);
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(BaseRequestMapping.ClientSearch.CHANGESTATUS)
    @ApiOperation("变更状态")
    public Envelop changeStatus(@ApiParam(name = "id", value = "")
                                @RequestParam(value = "id",required = true) String id,
                                @ApiParam(name = "status",value = "1 待接收、2 办理中、3 已退回、4 已办结")
                                @RequestParam(name = "status",required = true) Integer status){
        try{
            clientSearchService.updateById(id,status);
            return success("success");
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(BaseRequestMapping.ClientSearch.REPLY)
    @ApiOperation("答复")
    public Envelop reply(@ApiParam(name = "id", value = "")
                         @RequestParam(value = "id",required = true) String id,
                         @ApiParam(name = "reply",value = "")
                         @RequestParam(name = "reply",required = true) String reply,
                         @ApiParam(name = "updateUser",value = "答复操作人")
                         @RequestParam(name = "updataUser",required = true) String updataUser){
        try{
            clientSearchService.updateReply(id,reply,updataUser);
            return success("success");
        }catch (Exception e){
            return failedException(e);
        }
    }
}

+ 24 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/clientSearch/ClientSearchService.java

@ -38,6 +38,8 @@ public class ClientSearchService extends BaseJpaService<BaseSearchNoveltyRepeatD
        //获取随机数
        int number = r.nextInt();
        baseSearchNoveltyRepeatDO.setNumber(Integer.toString(number).replace("-",""));
        baseSearchNoveltyRepeatDO.setStatus(1);
        baseSearchNoveltyRepeatDO.setStatusName("待接收");
        baseSearchNoveltyRepeatDO.setCreateTime(new Date());
        return baseSearchNoveltyRepeatDao.save(baseSearchNoveltyRepeatDO);
    }
@ -60,7 +62,22 @@ public class ClientSearchService extends BaseJpaService<BaseSearchNoveltyRepeatD
    public void updateById(String id, Integer status) {
        BaseSearchNoveltyRepeatDO baseSearchNoveltyRepeatDO = baseSearchNoveltyRepeatDao.findOne(id);
        if (baseSearchNoveltyRepeatDO != null){
            if(status == 1){
                baseSearchNoveltyRepeatDO.setStatusName("待接收");
            }
            if(status == 2){
                baseSearchNoveltyRepeatDO.setStatusName("办理中");
            }
            if(status == 3){
                baseSearchNoveltyRepeatDO.setStatusName("已退回");
            }
            if(status == 4){
                baseSearchNoveltyRepeatDO.setStatusName("已办结");
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
            Date date = new Date();
           /* baseSearchNoveltyRepeatDO.setUpdate_time(sdf.format(date));*/
@ -82,4 +99,11 @@ public class ClientSearchService extends BaseJpaService<BaseSearchNoveltyRepeatD
            baseSearchNoveltyRepeatDao.save(baseSearchNoveltyRepeatDO);
        }
    }
    public BaseSearchNoveltyRepeatDO findFileById(String id){
        BaseSearchNoveltyRepeatDO baseSearchNoveltyRepeatDO = new BaseSearchNoveltyRepeatDO();
        baseSearchNoveltyRepeatDO = baseSearchNoveltyRepeatDao.findOne(id);
        return baseSearchNoveltyRepeatDO;
    }
}

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

+ 4 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -256,9 +256,10 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        //pc管理端端推送消息
        imUtill.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
        emergencyAssistanceDao.save(assistanceDO);
        return getOrderDetail(assistanceDO.getId(),null);
        result.put("resultFlag", ResponseContant.success);
        result.put("resultMsg",assistanceDO);
        return result;
    }
    public JSONObject getOrderDetail(String orderID,String doctor){
@ -372,7 +373,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        //附加信息 紧急救助无
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
        JSONArray familyArr =  familyMemberService.getPatientMembers(assistanceDO.getPatient(),null,null,null,null);
        JSONArray familyArr =  familyMemberService.getPatientMembers(assistanceDO.getPatient(),null,null,null,"3");
        String emeCallPhone = "";
        if (assistanceDO.getOrderSource()!=1){//设备发起工单
//            String category = assistanceDO.getOrderSource()==2?"4":"7";

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java

@ -207,7 +207,7 @@ public class ConsultTeamService {
            participants.put(patientId, 0);//家庭成员拉入会话
        }
        for (int i=0;i<agentFamilyArr.size();i++){//创建家属系统消息
            JSONObject tmp = familyArr.getJSONObject(i);
            JSONObject tmp = agentFamilyArr.getJSONObject(i);
            String patientId = tmp.getString("id");
            if (patient.equals(patientId)){
                continue;
@ -419,8 +419,8 @@ public class ConsultTeamService {
            }
            participants.put(patientId, 0);
        }
        for (int i=0;i<familyArr.size();i++){
            JSONObject tmp = familyArr.getJSONObject(i);
        for (int i=0;i<agentFamilyArr.size();i++){
            JSONObject tmp = agentFamilyArr.getJSONObject(i);
            String patientId = tmp.getString("id");
            if (patient.equals(patientId)){
                continue;

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

@ -51,7 +51,7 @@ public class YunXunDeviceService {
     */
    public void sendInstruction(String sn,String instruction){
        try {
            String url = "http://117.24.13.79:43210/yunxin/sendMessage?deviceSN="+sn+"&message="+instruction;
            String url = "http://www.cityihealth.com:43210/yunxin/sendMessage?deviceSN="+sn+"&message="+instruction;
            String response = httpClientUtil.get(url,"UTF-8");
            logger.info("sendInstruction="+response);
        }catch (Exception e){

+ 3 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -355,6 +355,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
            obj.put("familyRelationName", "自己");
            obj.put("isAuthorize", 1);//0:未授权,1:已授权
            obj.put("authorizeStatus", 3);//
            obj.put("archiveType", p.getArchiveType());//
            if (jtSign) {
                obj.put("signType", 1);
@ -385,7 +386,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if (StringUtils.isNotBlank(archive_type)){
            sql += " and t2.archive_type='"+archive_type+"' ";
            sql += " and t2.archive_type in ('"+archive_type.replace(",","','")+"') ";
        }
/*        if(isContacts != null){
            sql += " and t1.is_contacts = "+ isContacts;
@ -417,6 +418,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", map.get("family_relation"));
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                obj.put("archiveType",StringUtils.isEmpty(String.valueOf(map.get("archive_type"))) ?"":map.get("archive_type"));
                if (!StringUtils.isEmpty(doctorCode)) {
                    obj.put("relaholder", relations.get(map.get("family_relation")));

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

@ -424,7 +424,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
        JSONArray familyArr =  familyMemberService.getPatientMembers(orderDO.getPatient(),null,null,null,null);
        JSONArray familyArr =  familyMemberService.getPatientMembers(orderDO.getPatient(),null,null,null,"3");
        for (int i=0;i<familyArr.size();i++){
            String patientId = familyArr.getJSONObject(i).getString("id");
            BasePatientDO patientDO1 = basePatientDao.findById(patientId);

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

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

@ -51,7 +51,7 @@ public class YunXunDeviceService {
     */
    public void sendInstruction(String sn,String instruction){
        try {
            String url = "http://117.24.13.79:43210/yunxin/sendMessage?deviceSN="+sn+"&message="+instruction;
            String url = "http://www.www.cityihealth.com:43210/yunxin/sendMessage?deviceSN="+sn+"&message="+instruction;
            String response = httpClientUtil.get(url,"UTF-8");
            logger.info("sendInstruction="+response);
        }catch (Exception e){

+ 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 * * ?