Browse Source

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

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java
#	common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
wangzhinan 3 years ago
parent
commit
accb9b8bc2
35 changed files with 558 additions and 149 deletions
  1. 1 1
      business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java
  2. 4 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java
  3. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelDO.java
  4. 3 0
      gateway/ag-basic/src/main/resources/application.yml
  5. 64 13
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAUtils.java
  6. 21 9
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java
  7. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  8. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/YsConfig.java
  9. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/activity/ChildActivityRegistrationDao.java
  10. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/label/WlyyPatientLabelDao.java
  11. 35 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/activity/ChildActivityEndpoint.java
  12. 33 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  13. 15 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  14. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  15. 32 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java
  16. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  17. 17 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  18. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  19. 48 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java
  20. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  21. 2 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
  22. 7 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  23. 66 56
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java
  24. 13 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java
  25. 7 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  26. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  27. 4 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  28. 63 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  29. 3 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  30. 18 15
      svr/svr-cloud-care/src/main/resources/application.yml
  31. 26 11
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  32. 3 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java
  33. 6 3
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/EmeWarnOrderDayJob.java
  34. 6 3
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/EmeWarnOrderJob.java
  35. 11 5
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -678,7 +678,7 @@ public class FileUploadService {
            type = type.substring(type.lastIndexOf("."),type.length()-1);
        }
        logger.info(type);
        List img = new ArrayList(Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp","xls","xlsx","text/plain","mp4","m4v","avi","ogm","wmv","mpg","webm","ogv","mov","asx","mpeg","image/png"));
        List img = new ArrayList(Arrays.asList("jpeg","bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp","xls","xlsx","text/plain","mp4","m4v","avi","ogm","wmv","mpg","webm","ogv","mov","asx","mpeg","image/png"));
        if (!img.contains(type)) {
            return false;
        }

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java

@ -65,4 +65,8 @@ public interface SystemMessageDao extends PagingAndSortingRepository<SystemMessa
    @Query("update SystemMessageDO a set a.del=0 where a.id in (?1)")
    Integer delMessage(String[] ids);
    @Modifying
    @Query("DELETE FROM SystemMessageDO where type='43' and relationCode in(?1) ")
    void delMessageByRelationCode(List<String> relationCode);
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelDO.java

@ -17,7 +17,7 @@ public class WlyyPatientLabelDO extends UuidIdentityEntity {
    private String labelCode;
    // 标签名称
    private String labelName;
    // 标签类型 1.服务类型 2居民标签
    // 标签类型 1.服务类型 2居民标签 3老人标签
    private String labelType;
    // 是否系统标签
    private Integer isSystem;

+ 3 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -89,6 +89,9 @@ zuul:
    svr-cloud-care:
      path: /cloudCare/**
      serviceId: svr-cloud-care
    svr-cloud-care-test:
      path: /cloudCareTest/**
      serviceId: svr-cloud-care-test
    svr-cloud-medicine:
      path: /cloudMedicine/**
      serviceId: svr-cloud-care

+ 64 - 13
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAUtils.java

@ -3,12 +3,11 @@ package com.yihu.jw.security.utils;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.security.Security;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
public class RSAUtils {
@ -45,6 +44,53 @@ public class RSAUtils {
        return new String(decrypt(Base64.decodeBase64(string),keyPair));
    }
    /**
     * RSA公钥加密
     *
     * @param str
     *            加密字符串
     * @param publicKey
     *            公钥
     * @return 密文
     * @throws Exception
     *             加密过程中的异常信息
     */
    public static String encrypt( String str, String publicKey ) throws Exception{
        //base64编码的公钥
        byte[] decoded = Base64.decodeBase64(publicKey);
        RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
        //RSA加密
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, pubKey);
        String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
        return outStr;
    }
    /**
     * RSA私钥解密
     *
     * @param str
     *            加密字符串
     * @param privateKey
     *            私钥
     * @return 铭文
     * @throws Exception
     *             解密过程中的异常信息
     */
    public static String decrypt(String str, String privateKey) throws Exception{
        //64位解码加密后的字符串
        byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8"));
        //base64编码的私钥
        byte[] decoded = Base64.decodeBase64(privateKey);
        RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
        //RSA解密
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, priKey);
        String outStr = new String(cipher.doFinal(inputByte));
        return outStr;
    }
    private static byte[] decrypt(byte[] string,KeyPair keyPair) {
        try {
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
@ -60,14 +106,19 @@ public class RSAUtils {
        }
    }
//    public static void main(String[] args) {
//
//        KeyPair keyPair =  initKey();
//        // 生成public key
//        System.out.println(generateBase64PublicKey(keyPair));
//
//        // 解密
//        System.out.println(decryptBase64("wAfY9JkoKay9SxcPIs1FcG+t6sR+wYwAs/mh9DpfcBraxzqoZdb9LyaAigzFQ0EKck9OyHL0dhv+Uxuw5hHw6CPT0B2Z0i1gwrjDUNaL1gWvqt1pDJVGrIYPLJSjs9xktFhY1jbxQgXGjyCt06Rwid5sJknw90AUO0CyQulfipg=",keyPair));
//    }
    public static void main(String[] args) throws Exception{
        KeyPair keyPair =  getKey();
        // 生成public key
        String privateKeyString = new String(Base64.encodeBase64((keyPair.getPrivate().getEncoded())));
        String publicKeyString = new String(Base64.encodeBase64(keyPair.getPublic().getEncoded()));
        System.out.println("publicKeyString="+publicKeyString);
        System.out.println("privateKeyString="+privateKeyString);
        String str = "123ysj*#%";
        String encryptStr = encrypt(str,publicKeyString);
        // 字符串解密
        System.out.println(decrypt(encryptStr,privateKeyString));
    }
}

+ 21 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java

@ -360,15 +360,27 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
                        packageRecordDO.setTeamCode(teamDO.getId());
                        servicePackageRecordDao.save(packageRecordDO);
                        //建档状态
                        ArchiveDO archiveDO = new ArchiveDO();
                        archiveDO.setCreateTime(new Date());
                        archiveDO.setArchiveOperatorName(doctorDO.getName());
                        archiveDO.setDoctorCode(doctorDO.getId());
                        archiveDO.setPatient(patient);
                        archiveDO.setSickName(name);
                        archiveDO.setIdcard(idcard);
                        archiveDO.setSignStatus(1);
                        archiveDao.save(archiveDO);
                        List<String> teams = new ArrayList<>();
                        teams.add(teamDO.getId());
                        List<BaseDoctorDO> doctorDOS = baseDoctorDao.findDoctorsByTeam(teams);
                        List<ArchiveDO> saveList = new ArrayList<>();
                        for (BaseDoctorDO tmp:doctorDOS){
                            ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patient,tmp.getId());
                            if(archiveDO!=null){
                                archiveDO.setSignStatus(1);
                            }else{
                                archiveDO = new ArchiveDO();
                                archiveDO.setCreateTime(new Date());
                                archiveDO.setArchiveOperatorName(tmp.getName());
                                archiveDO.setPatient(patient);
                                archiveDO.setSickName(name);
                                archiveDO.setIdcard(idcard);
                                archiveDO.setSignStatus(1);
                                archiveDO.setDoctorCode(tmp.getId());
                            }
                            saveList.add(archiveDO);
                        }
                        archiveDao.save(saveList);
                        //居民标签
                        WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
                        patientLabelDO.setCzrq(new Date());

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java

@ -44,6 +44,14 @@ public class AqgConfig {
     */
    public static final String X1_locations = baseUrl+"/api/locationdata/";
    /**
     * X1设备修改
     * 计步1小时 心率30分钟 定位15分钟
     * 计步数据开关、 睡眠开关、轨迹开关、 心率、血氧、血压定时测量开关
     */
    public static final String X1_deviceModify = baseUrl+"/api/device/{0}/4g/edit?frequency_location=15&frequency_step=60" +
            "&frequency_heartrate=30&pedometer_enable=1&sleep_enable=1&track_enable=1&heartrate_enable=1";
    /**
     * 睡眠带 修改心率呼吸率报警阈值
     */

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/YsConfig.java

@ -53,6 +53,8 @@ public class YsConfig {
    //云台停止
    public static final String ptzStop = iotBaseUrl +"/api/lapp/device/ptz/stop";
    public static final String openChannelNo = iotBaseUrl +"/api/lapp/live/video/open";
    /**
     * 录像相关
     */

+ 5 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/activity/ChildActivityRegistrationDao.java

@ -6,6 +6,8 @@ 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 yeshijie on 2021/10/16.
 */
@ -17,4 +19,7 @@ public interface ChildActivityRegistrationDao extends PagingAndSortingRepository
    @Query("select a from ChildActivityRegistrationDO a where a.patient = ?1 ")
    ChildActivityRegistrationDO findByPatient(String patient);
    @Query("select a from ChildActivityRegistrationDO a where a.patient = ?1 ")
    List<ChildActivityRegistrationDO> findListByPatient(String patient);
}

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/label/WlyyPatientLabelDao.java

@ -19,4 +19,7 @@ public interface WlyyPatientLabelDao extends PagingAndSortingRepository<WlyyPati
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 group by w.labelType,w.labelCode order by w.czrq desc")
    List<WlyyPatientLabelDO> findByPatient(String patient);
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 and w.labelType=?2 group by w.labelType,w.labelCode order by w.czrq desc")
    List<WlyyPatientLabelDO> findByPatientAndLabelType(String patient,String labelType);
}

+ 35 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/activity/ChildActivityEndpoint.java

@ -14,6 +14,8 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by yeshijie on 2021/10/16.
 */
@ -30,10 +32,11 @@ public class ChildActivityEndpoint  extends EnvelopRestEndpoint {
    public PageEnvelop childActivityRegistrationList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "activityType", value = "活动类型 1小鬼来当家 2秋游去 3我喜欢我自己 4乡村音乐") @RequestParam(value = "activityType", required = false) String status,
            @ApiParam(name = "orgCode", value = "orgCode", required = false, defaultValue = "orgCode") @RequestParam(value = "orgCode",required = false) String orgCode,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try{
            return activityRegistrationService.childActivityRegistrationList(patient, status, page, size);
            return activityRegistrationService.childActivityRegistrationList(patient, status,orgCode, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -44,8 +47,8 @@ public class ChildActivityEndpoint  extends EnvelopRestEndpoint {
    public ObjEnvelop isActivityRegist(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
        try{
            ChildActivityRegistrationDO registrationDO = activityRegistrationService.isActivityRegist(patient);
            if(registrationDO==null){
            List<ChildActivityRegistrationDO> registrationDO = activityRegistrationService.isActivityRegist(patient);
            if(registrationDO.size()==0){
                return ObjEnvelop.getSuccess("查询成功",0);
            }else {
                return ObjEnvelop.getSuccess("查询成功",1);
@ -61,10 +64,12 @@ public class ChildActivityEndpoint  extends EnvelopRestEndpoint {
            @ApiParam(name = "patient", value = "居民id")
            @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "activityType", value = "活动类型 1小鬼来当家 2秋游去 3我喜欢我自己 4乡村音乐")
            @RequestParam(value = "activityType", required = true) String activityType
            @RequestParam(value = "activityType", required = true) String activityType,
            @ApiParam(name = "orgCode", value = "")
            @RequestParam(value = "orgCode", required = false) String orgCode
    ) {
        try {
            JSONObject result = activityRegistrationService.applyActivity(patient,activityType);
            JSONObject result = activityRegistrationService.applyActivity(patient,activityType,orgCode);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
@ -73,4 +78,29 @@ public class ChildActivityEndpoint  extends EnvelopRestEndpoint {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "cancelActivityRegist")
    @ApiOperation("取消活动申请")
    public Envelop cancelActivityRegist(@ApiParam(name = "id", value = "居民code") @RequestParam(value = "id", required = true) String id){
        try {
            activityRegistrationService.cancelActivityRegist(id);
            return success();
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @PostMapping("activityClick")
    @ApiOperation(value = "幼儿活动点击")
    public Envelop applyActivity(
            @ApiParam(name = "type", value = "1活动浏览2公益课程播放")
            @RequestParam(value = "type", required = true) Integer type
        ) {
        try {
            activityRegistrationService.activityClick(type);
            return success("success");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
}

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

@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -42,6 +43,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import static java.lang.Thread.sleep;
/***
 * @ClassName: PadDeviceController
 * @Description:
@ -66,6 +69,8 @@ public class PadDeviceController extends BaseController {
    private ContactsService contactsService;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 设备列表获取
@ -253,4 +258,32 @@ public class PadDeviceController extends BaseController {
        }
    }
    @RequestMapping(value ="open/updateX1Device",method = RequestMethod.GET)
    @ApiOperation(value = "批量修改爱牵挂手表设备信息")
    public String updateX1Device() {
        try {
            String sql = " select device_code from wlyy_devices wd where wd.category_code=4 ";
            List<String> deviceSns = jdbcTemplate.queryForList(sql,String.class);
            for (String deviceSn:deviceSns) {
                patientDeviceService.updateX1Device(deviceSn);
                sleep(2000);
            }
            System.out.println("MODIFY FINISH");
            return write(200, "获取成功", "data", "success");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value ="open/updateX1DeviceBySn",method = RequestMethod.GET)
    @ApiOperation(value = "修改爱牵挂手表设备信息")
    public String updateX1DeviceBySn(@ApiParam(name = "deviceSn", value = "deviceSn", defaultValue = "deviceSn")
                                 @RequestParam(value = "deviceSn", required = true) String deviceSn) {
        try {
            patientDeviceService.updateX1Device(deviceSn);
            return write(200, "获取成功", "data", "success");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
}

+ 15 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -1,5 +1,6 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.doctor.CareDoctorService;
@ -16,14 +17,11 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created with IntelliJ IDEA.
@ -268,4 +266,15 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
            return failedListEnvelopException2(e);
        }
    }
    @RequestMapping(value="esDataModify",method = RequestMethod.GET)
    public ObjEnvelop esDataModify(@RequestParam(required = true) String sql,@RequestParam(required = true) String jsonStr){
        try {
            return ObjEnvelop.getSuccess("success",statisticsService.esDataModify(sql,jsonStr));
        }catch (Exception e){
           return failedObjEnvelopException2(e);
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -116,7 +116,7 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "getPatientInfo")
    @ApiOperation("获取居民详情页")
    @ApiOperation("获取居民详情页--弃用")
    public ObjEnvelop getPatientInfo(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")

+ 32 - 7
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java

@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@ -35,9 +36,9 @@ public class ChildActivityRegistrationService {
     * @param activityType
     * @return
     */
    public JSONObject applyActivity(String patient, String activityType){
    public JSONObject applyActivity(String patient, String activityType,String orgCode){
        JSONObject result = new JSONObject();
        ChildActivityRegistrationDO activityRegistrationDO = childActivityRegistrationDao.findByPatient(patient);
        ChildActivityRegistrationDO activityRegistrationDO = childActivityRegistrationDao.findByPatientAndActivityType(patient,activityType);
        if(activityRegistrationDO != null){
            String failMsg = "您已报名过改类型的活动,请勿重复报名!";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
@ -49,6 +50,7 @@ public class ChildActivityRegistrationService {
        activityRegistrationDO = new ChildActivityRegistrationDO();
        activityRegistrationDO.setActivityType(activityType);
        activityRegistrationDO.setPatient(patient);
        activityRegistrationDO.setOrgCode(orgCode);
        activityRegistrationDO.setPatientName(patientDO.getName());
        childActivityRegistrationDao.save(activityRegistrationDO);
@ -64,8 +66,9 @@ public class ChildActivityRegistrationService {
     * @param page
     * @param size
     */
    public PageEnvelop childActivityRegistrationList(String patient,String activityType, int page, int size){
        String sql = "SELECT a.activity_type activityType,a.patient,p.name,p.sex,p.idcard,p.photo from base_child_activity_registration a,base_patient p " +
    public PageEnvelop childActivityRegistrationList(String patient,String activityType,String orgCode, int page, int size){
        String sql = "SELECT a.id,a.activity_type activityType,a.patient,p.name,p.sex,p.idcard,p.photo,org.code,org.name orgName,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_child_activity_registration a " +
                "LEFT JOIN base_org org on a.org_code = org.code ,base_patient p " +
                "WHERE a.patient = p.id";
        String sqlCount = "select count(a.id) from base_child_activity_registration a,base_patient p WHERE a.patient = p.id  ";
@ -73,11 +76,14 @@ public class ChildActivityRegistrationService {
        String limit = " order by a.create_time desc limit "+page*size+","+size;
        String filter = "";
        if(StringUtils.isNotBlank(patient)){
            filter += " and a.pateint = '"+patient+"' ";
            filter += " and a.patient = '"+patient+"' ";
        }
        if(StringUtils.isNotBlank(activityType)){
            filter += " and a.activity_type = '"+activityType+"' ";
        }
        if (StringUtils.isNotBlank(orgCode)){
            filter += " and a.org_code = '"+orgCode+"' ";
        }
        Long count = jdbcTemplate.queryForObject(sqlCount+filter,Long.class);
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+filter);
        for (Map<String,Object> map:result){
@ -88,8 +94,27 @@ public class ChildActivityRegistrationService {
    }
    public ChildActivityRegistrationDO isActivityRegist(String patient){
        return childActivityRegistrationDao.findByPatient(patient);
    public List<ChildActivityRegistrationDO> isActivityRegist(String patient){
        return childActivityRegistrationDao.findListByPatient(patient);
    }
    /**
     * 取消活动申请
     * @param id
     */
    @Transactional
    public void cancelActivityRegist(String id){
        childActivityRegistrationDao.delete(id);
    }
    /**
     *
     * @param type 1活动浏览:居民端亲子活动banner点击数
     * @param type 2公益课程播放:视频点击数
     */
    @Transactional
    public void activityClick(Integer type){
        String sql = " UPDATE base_child_activity_click SET num = num+1 where type="+type;
        jdbcTemplate.execute(sql);
    }
}

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

@ -269,6 +269,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea",patientDO.getResidentialArea());
        if (null!=assistanceDO.getDeviceSn()){
            String device_sn = assistanceDO.getDeviceSn();
@ -820,6 +822,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea",patientDO.getResidentialArea());
        if (null!=assistanceDO.getDeviceSn()){
            String device_sn = assistanceDO.getDeviceSn();
@ -911,6 +914,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea","");
        if (null!=assistanceDO.getDeviceSn()){
            String device_sn = assistanceDO.getDeviceSn();
@ -1071,6 +1075,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea","");
        if (null!=assistanceDO.getDeviceSn()){
            String device_sn = assistanceDO.getDeviceSn();

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

@ -53,6 +53,10 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	private HttpClientUtilCare httpClientUtil;
	@Value("${cloudCare.deviceUrl}")
	private String cloudDeviceUrl;
	@Autowired
	private YsDeviceService ysDeviceService;
	@Autowired
	private	 PatientDeviceService patientDeviceService;
	/**
@ -65,6 +69,12 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	@Transactional(rollbackFor = Exception.class)
	public void updateAfterBinding(DevicePatientDevice devicePatientDevice, Date grantTime, boolean isFirst)throws Exception{
		DeviceDetail deviceDetail = deviceDetailDao.findBySn(devicePatientDevice.getDeviceSn());
		
		if ("CS-C6Wi-3E4WFR".equals(deviceDetail.getDeviceModel())){//监控器 直播地址开通->关闭视频加密 后续暂时先于APP操作
			ysDeviceService.videoOpen(devicePatientDevice.getDeviceSn(),null);
		}
		long adminTeam=0L;
		String hospital = "";
		String isFirstBind = "";
@ -217,7 +227,14 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
			params.add(new BasicNameValuePair("deviceSN", device.getDeviceSn()));
			params.add(new BasicNameValuePair("pushAddress", cloudDeviceUrl+deviceDO.getNeedRegister()));
			String response = httpClientUtil.post(url, params,"UTF-8");
			System.out.println("注册结果:"+response);
			//注册日志
		}
		/**
		 * 手表信息修改
		 */
		if ("4".equals(device.getCategoryCode())){
			patientDeviceService.updateX1Device(device.getDeviceSn());
		}
	}
}

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

@ -1954,6 +1954,27 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return response.getBody();
    }
    /**
     * X1设备修改
     * 计步1小时 心率30分钟 定位15分钟
     * 计步数据开关、 睡眠开关、轨迹开关、 心率、血氧、血压定时测量开关
     */
    public  String updateX1Device(String deviceSn){
        String url =MessageFormat.format(AqgConfig.X1_deviceModify, deviceSn) ;
        Map<String,Object> headers = new HashMap<>();
        headers.put("Accept", MediaType.APPLICATION_JSON.toString());
        headers.put("Cookie", getCookie());
        String  responseStr = httpClientUtil.get(url,"utf-8",headers);
        com.alibaba.fastjson.JSONObject resObj = JSON.parseObject(responseStr);
        if (resObj.getBooleanValue("success")){
            System.out.println(deviceSn+":success");
        }else {
            System.out.println(deviceSn+":false--response"+responseStr);
        }
        return "success";
    }
    /******************************************* 爱牵挂设备end *****************************************************/
}

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

@ -24,6 +24,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@ -781,6 +782,53 @@ public class YsDeviceService {
//        System.out.println("1");
//    }
    @Async
    public void videoOpen(String deviceSn,HttpServletRequest request) throws Exception {
        StringBuilder responseStr = new StringBuilder("--"+deviceSn+"-- ");
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("accessToken",getIotAccessToken(deviceSn));
        param.add("source",deviceSn+":"+1);
        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.openChannelNo,param, HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        responseStr.append("->开通通道:"+responseBody.getInteger("code"));
        JSONObject param2 = new JSONObject();
        param2.put("accessToken",getAccessToken(deviceSn));
        param2.put("deviceSerial",deviceSn);
        param2.put("channelNo","1");
        param2.put("isTrust",0);
        response = httpClientUtil.assesTokenPostHttp(YsConfig.surveillanceWay,param2,HttpMethod.POST);
        responseBody = response.getBody();
        responseStr.append("->获取通道详情:"+responseBody.getInteger("code"));
        if (responseBody.getInteger("code")==200){
            try {
                JSONObject tmp =  responseBody.getJSONObject("data");
                String validateCode = tmp.getString("ipcValidateCode");
                param2 = new JSONObject();
                param2.put("accessToken",getAccessToken(deviceSn));
                param2.put("deviceSerial",deviceSn);
                param2.put("isEncrypt","0");
                validateCode = messageDecrypt(validateCode,getSecretKey(deviceSn));
                param2.put("validateCode",validateCode);
                response = httpClientUtil.assesTokenPostHttp(YsConfig.deviceEncrypt,param2,HttpMethod.POST);
                responseBody = response.getBody();
                responseStr.append("->视频解密:"+responseBody.getInteger("code"));
            }catch (Exception e){
            }
        }
//        //设置编码格式
//
//
//        //设置活动检测
//        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
//        param.add("accessToken",getIotAccessToken());
//        param.add("deviceSerial",deviceSn);
//        param.add("enable","1");
//        param.add("channelNo","1");
//        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp("https://open.ys7.com/api/lapp/device/intelligence/detection/switch/set",param, HttpMethod.POST);
//        JSONObject responseBody = response.getBody();
//        responseStr.append("->活动检测:"+responseBody.getInteger("code"));
        logger.info(responseStr.toString());
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -113,7 +113,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     */
    public Map<String,Object> doctorInfo(String doctorId,String isRole){
        String sql = "SELECT d.id,d.name,d.doctor_level level,d.photo,d.introduce,d.expertise,d.mobile,d.idcard,d.sex,h.dept_code deptCode,h.dept_name deptName,d.job_title_code jobTitleCode,d.job_title_name jobTitleName ";
        sql += " ,h.org_code orgCode,org.address orgAddress,h.org_name orgName from base_doctor d left join base_doctor_hospital h on d.id = h.doctor_code  and h.del = 1" +
        sql += " ,h.org_code orgCode,org.address orgAddress,org.name orgName from base_doctor d left join base_doctor_hospital h on d.id = h.doctor_code  and h.del = 1" +
                " LEFT JOIN base_org org on h.org_code = org.`code`  WHERE d.id = '"+doctorId+"' limit 1 ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> map = list.get(0);

+ 2 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -897,7 +897,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                if (orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForPay.getType()&&1==orderDO.getPayWay()){
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
                    if (businessOrderDO!=null){
                        if (1 == businessOrderDO.getStatus()){
                        //1.4.2 上门辅导费用0时 无需走退款流程
                        if (1 == businessOrderDO.getStatus()&&businessOrderDO.getPayPrice()>0.0){
                            //退款流程
                            try {
                                payService.dispatcherOrderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");

+ 7 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -670,6 +670,13 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code='lifeCare' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
        if(items.size()==0){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "居民未签约生活照料服务,无法发起申请";
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        Map<String,Object> mapTmp = items.get(0);
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(mapTmp.get("team_code").toString(),2);
        for (BaseDoctorDO doctorDO:doctorDOS){

+ 66 - 56
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java

@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
@ -36,6 +38,11 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    public JSONObject getOnLineObj(String patient){
        JSONObject obj = new JSONObject();
@ -126,78 +133,81 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
        JSONObject result = new JSONObject();
        JSONArray doctorResult = new JSONArray();
        JSONArray patientResult = new JSONArray();
        String doctors = imUtil.getSessionListByType(patient,"0","1","2",null,null,"1");
        String patients = imUtil.getSessionListByType(patient,"0","100","2",null,null,"2");
        JSONArray doctorArr = JSON.parseArray(doctors);
        JSONArray patientArr = JSON.parseArray(patients);
        if (doctorArr.size()==0){//取签约医生其中一个
          List<Map<String,Object>> signDoctors =  servicePackageService.getServerDoctorAll(patient,null,null);
          if (signDoctors.size()>0){
              Map<String,Object> tmp = signDoctors.get(0);
              JSONObject tmpObj = new JSONObject();
              tmpObj.put("name",tmp.get("doctorName"));
              tmpObj.put("unread_count","0");
              tmpObj.put("avatar",tmp.get("photo"));
              tmpObj.put("userType","1");
              tmpObj.put("doctorId",tmp.get("doctor"));
              tmpObj.put("relationName","助老员");
              doctorResult.add(tmpObj);
          }
        }else {
            JSONObject tmp = doctorArr.getJSONObject(0);
            JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
            for (int i=0;i<participantsTimeArray.size();i++){
                JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
                String id =  tmpObj.getString("id");
                if (!id.equals(patient)){
                    tmp.put("avatar",tmp.getString("photo"));
                    tmp.put("doctorId",id);
                    tmp.put("relationName","助老员");
                    break;
                }
            }
            doctorResult.add(tmp);
        //医生默认取签约第一个
        List<Map<String,Object>> signDoctors =  servicePackageService.getServerDoctorAll(patient,null,null);
        if (signDoctors.size()>0){
            Map<String,Object> tmp = signDoctors.get(0);
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("name",tmp.get("doctorName"));
            tmpObj.put("unread_count","0");
            tmpObj.put("avatar",tmp.get("photo"));
            tmpObj.put("userType","1");
            tmpObj.put("doctorId",tmp.get("doctor"));
            tmpObj.put("doctorLevel",tmp.get("doctorLevel"));
            tmpObj.put("relationName",null==tmp.get("doctorLevel")?"":"1".equals(tmp.get("doctorLevel").toString())?"社区医生":"助老员");
            doctorResult.add(tmpObj);
        }
        JSONArray families = familyMemberService.membersWithOnLineFlag(patient);
        if (families.size()>0){
            List<String> familyIds = families.stream().map(item->((JSONObject)item).getString("id")).collect(Collectors.toList());
            if(patientArr.size()>0){
                JSONObject tmp = patientArr.getJSONObject(0);
                JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
                for (int i=0;i<participantsTimeArray.size();i++){
                    JSONObject tmpObj = participantsTimeArray.getJSONObject(i);
                    String id =  tmpObj.getString("id");
                    if (!id.equals(patient)&&familyIds.contains(id)){
                        tmp.put("avatar",tmp.getString("photo"));
                        tmp.put("patientId",id);
                        String sql = " select family_relation from base_patient_family_member where " +
                                " patient = '"+patient+"' and family_member='"+id+"' " +
                                " and (del=1 or del is null) ";
                        List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class);
                        if(relations.size()>0){
                            tmp.put("relationName",familyMemberService.relations.get(relations.get(0)));
                        }else {
                            tmp.put("relationName","其他");
                boolean findFlag = false;//有会话的展示会话中的一条 且不为家属
                for (int i=0;i<patientArr.size();i++){
                    JSONObject tmp = patientArr.getJSONObject(i);
                    JSONArray participantsTimeArray = tmp.getJSONArray("participantsTimeArray");
                    for (int j=0;j<participantsTimeArray.size();j++){
                        JSONObject tmpObj = participantsTimeArray.getJSONObject(j);
                        String id =  tmpObj.getString("id");
                        BasePatientDO patientDO = patientDao.findById(id);
                        if (patientDO.getArchiveType()==3){
                            continue;
                        }
                        if (!id.equals(patient)&&familyIds.contains(id)){
                            tmp.put("avatar",tmp.getString("photo"));
                            tmp.put("patientId",id);
                            String sql = " select family_relation from base_patient_family_member where " +
                                    " patient = '"+patient+"' and family_member='"+id+"' " +
                                    " and (del=1 or del is null) ";
                            List<Integer> relations = jdbcTemplate.queryForList(sql,Integer.class);
                            if(relations.size()>0){
                                tmp.put("relationName",familyMemberService.relations.get(relations.get(0)));
                            }else {
                                tmp.put("relationName","其他");
                            }
                            patientResult.add(tmp);
                            findFlag=true;
                            break;
                        }
                        patientResult.add(tmp);
                    }
                    if (findFlag){
                        break;
                    }
                }
            }
            if (patientResult.size()==0){
                if (families.size()>0){
                    JSONObject tmp = families.getJSONObject(0);
                    JSONObject tmpObj = new JSONObject();
                    tmpObj.put("name",tmp.getString("name"));
                    tmpObj.put("unread_count","0");
                    tmpObj.put("avatar",tmp.getString("photo"));
                    tmpObj.put("userType","2");
                    tmpObj.put("patientId",tmp.get("id"));
                    tmpObj.put("relationName",tmp.get("familyRelationName"));
                    patientResult.add(tmpObj);
                    for (int i=0;i<families.size();i++){
                        JSONObject tmp = families.getJSONObject(i);
                        JSONObject tmpObj = new JSONObject();
                        tmpObj.put("name",tmp.getString("name"));
                        tmpObj.put("unread_count","0");
                        tmpObj.put("avatar",tmp.getString("photo"));
                        tmpObj.put("userType","2");
                        BasePatientDO patientDO = patientDao.findById(tmp.get("id").toString());
                        if (patientDO.getArchiveType()==3){
                            continue;
                        }
                        tmpObj.put("patientId",tmp.get("id"));
                        tmpObj.put("relationName",tmp.get("familyRelationName"));
                        patientResult.add(tmpObj);
                        break;
                    }
                }
            }
        }
        result.put("doctors",doctorResult);

+ 13 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java

@ -244,6 +244,10 @@ public class PayService {
        if(businessOrderDO.getStatus()!=1){
            return "订单为已支付状态时,才可申请退款";
        }
        if (0.0==businessOrderDO.getPayPrice()){
            return "订单费用为0,无法申请退款";
        }
        if("3".equals(type)){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if(6!=orderDO.getStatus()){
@ -781,7 +785,15 @@ public class PayService {
        businessOrderDO.setPayType(1);
        businessOrderDO.setPayPrice(Double.valueOf(price));
        businessOrderDO.setLastPayTime(lastPayTime);
        businessOrderService.save(businessOrderDO);
        //1.4.2 上门辅导费用0时无需支付
        if ("3".equals(type)&&0.0==price){
            businessOrderDO.setStatus(1);
            businessOrderService.save(businessOrderDO);
            doorCoachOrderService.payOrderAfter(relationCode);
        }else {
            businessOrderService.save(businessOrderDO);
        }
        return businessOrderDO;
    }

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

@ -270,6 +270,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea",patientDO.getResidentialArea());
        if (null!=orderDO.getDeviceSn()){
            String device_sn = orderDO.getDeviceSn();
@ -440,6 +441,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patientDO.getId());
                if(null==monitorInfo){
                    monitorInfo = new JSONObject();
                }
                if (sleepPlans.size()>0){
                    BaseSleepPlan sleepPlan = sleepPlans.get(0);
                    String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
@ -635,6 +639,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea","");//结束时该字段无意义
        if (null!=orderDO.getDeviceSn()){
            String device_sn = orderDO.getDeviceSn();
@ -1060,6 +1065,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea","");
        if (null!=orderDO.getDeviceSn()){
            String device_sn = orderDO.getDeviceSn();
@ -1228,6 +1234,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        message.put("categoryCode","");
        message.put("orgType","");
        message.put("contactStatus","");
        message.put("residentialArea","");
        if (null!=one.getDeviceSn()){
            String device_sn = one.getDeviceSn();

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

@ -459,7 +459,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                List<BaseDoctorDO> doctorDOS = doctorDao.findDoctorsByTeam(teams);
                List<ArchiveDO> saveList = new ArrayList<>();
                for (BaseDoctorDO tmp:doctorDOS){
                    ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
                    ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,tmp.getId());
                    if(archiveDO!=null){
                        archiveDO.setSignStatus(1);
                    }else{
@ -470,6 +470,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                        archiveDO.setSickName(patientDO.getName());
                        archiveDO.setIdcard(patientDO.getIdcard());
                        archiveDO.setSignStatus(1);
                        archiveDO.setDoctorCode(tmp.getId());
                    }
                    saveList.add(archiveDO);
                }
@ -662,7 +663,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag,String doctorLevel){
        String sql="SELECT DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 " +
                " THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,doc.job_title_name as jobName,doc.job_title_code as job, " +
                " 0 as onLineFlag,org.code,org.name as orgName " +
                " 0 as onLineFlag,org.code,org.name as orgName ,doc.doctor_level doctorLevel " +
                "from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc, " +
                "base_service_package pack,base_org org " +
                "WHERE sr.patient='"+patient+"' and sr.status=1  and m.team_code = r.team_code and " +

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

@ -289,9 +289,11 @@ public class DetectionPlatformService  {
    }
    public List<Map<String,Object>> getOrderListWarning(){
       String sql = " select o.id as order_id,o.patient,o.patient_name patientName,CONCAT(o.serve_lat,',',o.serve_lon) latLon,'20' as orderType,'紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn from base_emergency_assistance_order o where  `status`=1 " +
       String sql = " select o.id as order_id,o.patient,o.patient_name patientName,CONCAT(o.serve_lat,',',o.serve_lon) latLon,'20' as orderType,'紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn,p.residential_area residentialArea from base_emergency_assistance_order o " +
               " INNER JOIN base_patient p on o.patient = p.id where  `status`=1 " +
                " UNION All  " +
                " select o.id as order_id,o.patient,o.patient_name patientName,CONCAT(o.serve_lat,',',o.serve_lon) latLon,'22' as orderType,o.serve_desc serverDesc,o.hospital orgCode,o.device_sn from base_security_monitoring_order o where  `status`=1 ";
                " select o.id as order_id,o.patient,o.patient_name patientName,CONCAT(o.serve_lat,',',o.serve_lon) latLon,'22' as orderType,o.serve_desc serverDesc,o.hospital orgCode,o.device_sn,p.residential_area residentialArea from base_security_monitoring_order o " +
               " INNER JOIN base_patient p on o.patient = p.id where  `status`=1 ";
        List<Map<String,Object>> orderPoints2 = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:orderPoints2){
            if (null!=tmp.get("device_sn")){

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

@ -15,6 +15,7 @@ import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.es.es.ElasticSearchHelperUtil;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
@ -27,9 +28,11 @@ import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -79,6 +82,12 @@ public class StatisticsService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private ElasticSearchHelperUtil elasticSearchHelper;
    @Value("${es.index.Statistics}")
    private String esIndex;
    @Value("${es.type.Statistics}")
    private String esType;
    private static final String defalutArea = "330100";
@ -95,7 +104,7 @@ public class StatisticsService {
     */
    public JSONObject statisticsTotalAmount(String endDate) throws Exception {
        JSONObject res = new JSONObject();
        String index = "28,31,35,37,39,44";
        String index = "28,31,35,37,39,44,54";
        String[] indexes = index.split(",");
        for(String ind:indexes){
            //总量
@ -124,6 +133,18 @@ public class StatisticsService {
        //评估类型
        res.put("capacityAssessment",capacityAssessment(endDate,defalutArea,defalutLevel));
        res.put("patientLabelStatistic",statisticsOrderServer("47",endDate,2,"2"));
        // 1.4.2 大屏新增活动浏览数、公益课程播放数、活动报名数
        String sql = " select type,num from base_child_activity_click where type in(1,2)";
        List<Map<String,Object>> lists = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:lists){
            Integer num = Integer.parseInt(tmp.get("num").toString());
            res.put("activity_"+tmp.get("type").toString(),num);
        }
        sql = " select count(id) as total from base_child_activity_registration ";
        Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
        res.put("activity_3",count);
        return res;
    }
@ -1404,4 +1425,45 @@ public class StatisticsService {
        }
        return null;
    }
    /**
     *
     * @param esSql
     * @param jsonStr 修改数据
     * @return
     */
    public boolean esDataModify(String esSql,String jsonStr) {
        try {
            if (StringUtils.containsIgnoreCase(esSql,"limit")){
                return false;
            }
            Boolean flag=false;
            List<SaveModel> objs = elasticsearchUtil.excute(esSql,SaveModel.class,"","");
            List<Map<String,Object>> sourceMap = new ArrayList<>();
            int i=0;
            for (SaveModel tmp:objs){
                String jsonStr1 = JSON.toJSONString(tmp);
                Map<String,Object> tmpInfo = com.alibaba.fastjson.JSONObject.parseObject(jsonStr1,Map.class);
                if (StringUtils.isNotBlank(jsonStr)){
                    Map<String,Object> modifyInfo = com.alibaba.fastjson.JSONObject.parseObject(jsonStr,Map.class);
                    for (String key:modifyInfo.keySet()){
                        tmpInfo.put(key, modifyInfo.get(key));
                    }
                    sourceMap.add(tmpInfo);
                }
                i++;
            }
            if (i>0){
                flag = elasticSearchHelper.updateByMap(esIndex,esIndex,sourceMap);//修改
            }
            return flag;
        }
        catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}

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

@ -167,10 +167,9 @@ public class PatientInfoPlatFormService {
            }
            //标签类型
            List<String> labelList = new ArrayList<>();
            Integer sex = patientDO.getSex();
            String sexName = sex!=null?(1==sex?"男性":"女性"):"未知";
            labelList.add(sexName);
            List<WlyyPatientLabelDO> labelDOS = patientLabelDao.findByPatient(patient);
            //1.4.2老人标签
            List<WlyyPatientLabelDO> labelDOS = patientLabelDao.findByPatientAndLabelType(patient,"3");
            List<String> labeltmp = labelDOS.stream().map(WlyyPatientLabelDO::getLabelName).collect(Collectors.toList());
            labelList.addAll(labeltmp);
            tmp.put("patientLabel",labelList);

+ 18 - 15
svr/svr-cloud-care/src/main/resources/application.yml

@ -6,21 +6,24 @@ spring:
  aop:
    proxy-target-class: true
  datasource:
    max-active: 200
    max-idle: 200 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 20000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 200 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
    hikari:
      minimum-idle: 100                  # 最小连接数
      maximum-pool-size: 300
      max-active: 200
      max-idle: 200 #最大空闲连接
      min-idle: 10 #最小空闲连接
      validation-query-timeout: 20
      log-validation-errors: true
      validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
      validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
      test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
      test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
      idle-timeout: 60000
      connection-test-query: SELECT 1
      num-tests-per-eviction-run: 200 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
      test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
      min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
      time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  http:
    multipart:

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

@ -277,6 +277,12 @@ public class DeviceService {
        try {
            if(StringUtils.isNotBlank(deviceid)){
                if (type==4){
                    String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+1+"' and dict_name = 'security_server_dict' and saas_id=1 ";
                    List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
                    if (listTmp!=null&&listTmp.size()>0){
                    }else{
                        return;
                    }
                    List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceid);
                    if (devicePatientDeviceDos.size()>0){
                        DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
@ -646,7 +652,7 @@ public class DeviceService {
                                        planDetail.setBreath(breath);
                                        planDetail.setHeartRate(heartrate);
                                        sleepPlanDetailDao.save(planDetail);
                                        outBedOrder(null, timeDate,devicePatientDeviceDos.get(0), patient, device, "超时未起床", JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
                                        outBedOrder(null, timeDate,devicePatientDeviceDos.get(0), patient, device, "3", JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
                                        orderCreate = true;
                                    }
                                }
@ -661,7 +667,7 @@ public class DeviceService {
                                        planDetail.setSiestaStatus(0);
                                        planDetail.setBedStatus(0);
                                        sleepPlanDetailDao.save(planDetail);
                                        outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"超时未午睡",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"7",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
@ -686,7 +692,7 @@ public class DeviceService {
                                            planDetail.setBreath(breath);
                                            planDetail.setHeartRate(heartrate);
                                            sleepPlanDetailDao.save(planDetail);
                                            outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"8",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            orderCreate=true;
                                        }
                                    }
@ -727,7 +733,7 @@ public class DeviceService {
                                        planDetail.setBedStatus(1);
                                        planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
                                        sleepPlanDetailDao.save(planDetail);
                                        outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"超时未上床晚休",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"6",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
@ -746,7 +752,7 @@ public class DeviceService {
                                            planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
                                            planDetail.setBedStatus(0);
                                            sleepPlanDetailDao.save(planDetail);
                                            outBedOrder(records.get(0),timeDate,devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            outBedOrder(records.get(0),timeDate,devicePatientDeviceDos.get(0),patient,device,"4",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            orderCreate=true;
                                        }
                                    }
@ -770,7 +776,7 @@ public class DeviceService {
//                                    planDetail.setHeartRate(heartrate);
//                                    planDetail.setBedStatus(1);
//                                    planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
//                                    outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
//                                    outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"5",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
//                                    return null;
//                                }
//                            }
@ -781,7 +787,7 @@ public class DeviceService {
//                                    planDetail.setHeartRate(heartrate);
//                                    planDetail.setBedStatus(1);
//                                    planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
//                                    outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
//                                    outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"5",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
//                                    return null;
//                                }
//                            }
@ -796,9 +802,18 @@ public class DeviceService {
        return null;
    }
    public void outBedOrder(BaseSleepNightRecord record,Date time_date,DevicePatientDevice patientDevice,String patient ,String device,String serverName,String warnInfo)throws Exception{
    public void outBedOrder(BaseSleepNightRecord record,Date time_date,DevicePatientDevice patientDevice,String patient ,String device,String dictCode,String warnInfo)throws Exception{
        // //夜间十二点 起床半小时后未回床 触发安防工单
            BasePatientDO patientDO = patientDao.findById(patient);
        String serveDesc = "";
        String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict' and saas_id=1 ";
        List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
        if (listTmp!=null&&listTmp.size()>0){
            serveDesc = listTmp.get(0).get("dict_value")+"";
        }else{
            return ;
        }
        BasePatientDO patientDO = patientDao.findById(patient);
            if(null!=patientDO){
                String sql ="select DISTINCT pack.org_code,pack.org_name\n" +
                        " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
@ -823,7 +838,7 @@ public class DeviceService {
                    jsonObject.put("patient",patientDO.getId());
                    jsonObject.put("patientName",patientDO.getName());
                    jsonObject.put("patientPhone",patientDO.getMobile());
                    jsonObject.put("serveDesc",serverName);
                    jsonObject.put("serveDesc",serveDesc);
                    jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                    jsonObject.put("serveAddress",address.replace(" ",""));
                    jsonObject.put("serveLat",lat);
@ -836,7 +851,7 @@ public class DeviceService {
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("jsonData", jsonObjectParam.toJSONString()));
                    params.add(new BasicNameValuePair("warnStr", serverName));
                    params.add(new BasicNameValuePair("warnStr", serveDesc));
                    params.add(new BasicNameValuePair("orderSource", "5"));
                    String response = httpClientUtil.post(url, params,"UTF-8");
                    System.out.println(response);

+ 3 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java

@ -90,10 +90,12 @@ public class SecurityOrderUtil {
                }
                String serveDesc = "";
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict'";
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict' and saas_id=1 ";
                List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
                if (listTmp!=null&&listTmp.size()>0){
                    serveDesc = listTmp.get(0).get("dict_value")+"";
                }else{
                    return new JSONObject();
                }
                JSONObject jsonObject = new JSONObject();

+ 6 - 3
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/EmeWarnOrderDayJob.java

@ -41,14 +41,15 @@ public class EmeWarnOrderDayJob implements Job {
        try {
            //救助工单>=1天未处理
            String sql = " select '紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.session_id sessionId,o.patient,o.patient_name patientName,o.create_time,20 as type from " +
                    "base_emergency_assistance_order o where status=1 and (TIMESTAMPDIFF(DAY,o.create_time,now()) >=1) and not EXISTS ( " +
            String sql = " select '紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.session_id sessionId,o.patient,o.patient_name patientName,o.create_time,20 as type,p.residential_area residentialArea from " +
                    "base_emergency_assistance_order o INNER JOIN base_patient p on o.patient = p.id where status=1 and (TIMESTAMPDIFF(DAY,o.create_time,now()) >=1) and not EXISTS ( " +
                    " select 1 from base_emergency_warn_log log where log.order_id = o.id) ";
            List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
            //安防>=1天未处理
            sql = " select o.serve_desc serverDesc,o.hospital orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.patient,o.patient_name patientName,o.serve_desc serverDesc,ct.id consult,22 as type from base_security_monitoring_order o " +
            sql = " select o.serve_desc serverDesc,o.hospital orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.patient,o.patient_name patientName,o.serve_desc serverDesc,ct.id consult,22 as type,p.residential_area residentialArea from " +
                    " base_security_monitoring_order o INNER JOIN base_patient p on o.patient = p.id " +
                    " INNER JOIN wlyy_consult ct on o.id = ct.relation_code where o.status=1 and (TIMESTAMPDIFF(DAY,o.create_time,now()) >=1 ) and not EXISTS ( " +
                    " select 1 from base_emergency_warn_log log where log.order_id = o.id); ";
            list.addAll(jdbcTemplate.queryForList(sql));
@ -74,6 +75,7 @@ public class EmeWarnOrderDayJob implements Job {
                        message.put("categoryCode","");
                        message.put("orgType","");
                        message.put("contactStatus","");
                        message.put("residentialArea",null==map.get("residentialArea")?"":map.get("residentialArea"));
                        if (null!=map.get("device_sn")){
                            String device_sn = map.get("device_sn").toString();
@ -109,6 +111,7 @@ public class EmeWarnOrderDayJob implements Job {
                        message.put("categoryCode","");
                        message.put("orgType","");
                        message.put("contactStatus","");
                        message.put("residentialArea",null==map.get("residentialArea")?"":map.get("residentialArea"));
                        if (null!=map.get("device_sn")){
                            String device_sn = map.get("device_sn").toString();

+ 6 - 3
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/EmeWarnOrderJob.java

@ -41,15 +41,16 @@ public class EmeWarnOrderJob implements Job {
        try {
            //救助工单<=1小时&&<1未处理
            String sql = " select '紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.session_id sessionId,o.patient,o.patient_name patientName,o.create_time,20 as type from " +
                "base_emergency_assistance_order o where status=1 and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=1 " +
            String sql = " select '紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.session_id sessionId,o.patient,o.patient_name patientName,o.create_time,20 as type,p.residential_area residentialArea from " +
                "base_emergency_assistance_order o INNER JOIN base_patient p on o.patient = p.id where status=1 and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=1 " +
                "and TIMESTAMPDIFF(HOUR,o.create_time,now()) <24) and not EXISTS ( " +
                    " select 1 from base_emergency_warn_log log where log.order_id = o.id) ";
            List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
            //安防<=1小时&&<1天未处理
             sql = " select o.serve_desc serverDesc,o.hospital orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.patient,o.patient_name patientName,o.serve_desc serverDesc,ct.id consult,22 as type from base_security_monitoring_order o " +
             sql = " select o.serve_desc serverDesc,o.hospital orgCode,o.device_sn,o.serve_lat,o.serve_lon,o.id,o.patient,o.patient_name patientName,o.serve_desc serverDesc,ct.id consult,22 as type,p.residential_area residentialArea from " +
                     " base_security_monitoring_order o INNER JOIN base_patient p on o.patient = p.id " +
                     " INNER JOIN wlyy_consult ct on o.id = ct.relation_code where o.status=1 and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=1 " +
                     " AND TIMESTAMPDIFF(HOUR,o.create_time,now()) <24) and not EXISTS ( " +
                    " select 1 from base_emergency_warn_log log where log.order_id = o.id); ";
@ -76,6 +77,7 @@ public class EmeWarnOrderJob implements Job {
                        message.put("categoryCode","");
                        message.put("orgType","");
                        message.put("contactStatus","");
                        message.put("residentialArea",null==map.get("residentialArea")?"":map.get("residentialArea"));
                        if (null!=map.get("device_sn")){
                            String device_sn = map.get("device_sn").toString();
@ -111,6 +113,7 @@ public class EmeWarnOrderJob implements Job {
                        message.put("categoryCode","");
                        message.put("orgType","");
                        message.put("contactStatus","");
                        message.put("residentialArea",null==map.get("residentialArea")?"":map.get("residentialArea"));
                        if (null!=map.get("device_sn")){
                            String device_sn = map.get("device_sn").toString();

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

@ -9,6 +9,7 @@ import com.yihu.jw.care.util.DateUtil;
import com.yihu.jw.care.util.DeviceLostMessageUtil;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
@ -52,6 +53,8 @@ public class PatientDeviceService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DeviceLostMessageUtil deviceLostMessageUtil;
    @Autowired
    private SystemMessageDao systemMessageDao;
    Map<Integer, String> relations = new HashMap<>();
    @PostConstruct
@ -246,7 +249,7 @@ public class PatientDeviceService {
            List<String> lostSN = new ArrayList<>();
            List<String> onContact = new ArrayList<>();
            /*******************未失联**/
/*            //血糖仪,血压计。30天内有数据上传,则改为未失联
           //血糖仪,血压计。30天内有数据上传,则改为未失联
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
@ -263,13 +266,13 @@ public class PatientDeviceService {
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
                onContact.addAll(devices);
            }*/
            }
            /***************失联**/
            //血糖仪、血压**/
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
                lostSN.addAll(devices);
            }
@ -282,7 +285,10 @@ public class PatientDeviceService {
                lostSN.addAll(devices);
            }
            if (onContact.size()>0){
                wlyyDeviceDao.updateByContactStatus(1,new Date(),onContact);
//                wlyyDeviceDao.updateByContactStatus(1,new Date(),onContact);
                //如果在线 将之前的离线消息全部清除
                systemMessageDao.delMessageByRelationCode(onContact);
            }
            if (lostSN.size()>0){
                wlyyDeviceDao.updateByContactStatus(0,new Date(),lostSN);