Browse Source

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

LAPTOP-KB9HII50\70708 3 năm trước cách đây
mục cha
commit
94cbae6a3a
21 tập tin đã thay đổi với 284 bổ sung45 xóa
  1. 4 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelDO.java
  3. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/YsConfig.java
  4. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/label/WlyyPatientLabelDao.java
  5. 29 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/activity/ChildActivityEndpoint.java
  6. 15 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  7. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  8. 26 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java
  9. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  10. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  11. 48 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java
  12. 13 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java
  13. 7 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  14. 4 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  15. 63 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  16. 3 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  17. 26 11
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  18. 3 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java
  19. 6 3
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/EmeWarnOrderDayJob.java
  20. 6 3
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/EmeWarnOrderJob.java
  21. 11 5
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

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

+ 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";
    /**
     * 录像相关
     */

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

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

@ -61,10 +61,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 +75,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);
        }
    }
}

+ 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 新生儿")

+ 26 - 4
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);
@ -65,7 +67,8 @@ public class ChildActivityRegistrationService {
     * @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 " +
        String sql = "SELECT a.id,a.activity_type activityType,a.patient,p.name,p.sex,p.idcard,p.photo,org.code,org.name,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,7 +76,7 @@ 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+"' ";
@ -92,4 +95,23 @@ public class ChildActivityRegistrationService {
        return childActivityRegistrationDao.findByPatient(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();

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

@ -53,6 +53,8 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	private HttpClientUtilCare httpClientUtil;
	@Value("${cloudCare.deviceUrl}")
	private String cloudDeviceUrl;
	@Autowired
	private YsDeviceService ysDeviceService;
	/**
@ -65,6 +67,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 = "";

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

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

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

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