소스 검색

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

wangzhinan 3 년 전
부모
커밋
6ac0c6ed89
31개의 변경된 파일1353개의 추가작업 그리고 57개의 파일을 삭제
  1. 3 0
      business/base-service/src/main/java/com/yihu/jw/gateway/dao/GcTokenDao.java
  2. 4 0
      business/base-service/src/main/java/com/yihu/jw/gateway/service/GcTokenService.java
  3. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java
  4. 58 0
      common/common-util/src/main/java/com/yihu/jw/util/common/NetworkUtil.java
  5. 40 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/MvcConfig.java
  6. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/visit/BaseVisitDao.java
  7. 25 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/DoctorConsultEndpoint.java
  8. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java
  9. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  10. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  11. 20 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java
  12. 115 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/GcTokenController.java
  13. 132 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/WlyygcDataEndpoint.java
  14. 159 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/interceptors/GateWayInterceptor.java
  15. 41 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java
  16. 18 19
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  17. 15 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  18. 5 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  19. 24 13
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  20. 403 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/WlyygcStatisticsService.java
  21. 38 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java
  22. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  23. 98 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/BaseResultModel.java
  24. 33 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/GcClientDetailsModel.java
  25. 51 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/GcTokenModel.java
  26. 39 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/ResultOneModel.java
  27. 1 1
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/BirthdayReminderService.java
  28. 1 1
      svr/svr-iot-sn/readme.MD
  29. 1 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/gateway/GcTokenController.java
  30. 3 2
      svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcTokenDao.java
  31. 2 2
      svr/svr-iot/src/main/java/com/yihu/iot/service/gateway/GcTokenService.java

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/gateway/dao/GcTokenDao.java

@ -26,4 +26,7 @@ public interface GcTokenDao extends PagingAndSortingRepository<GcToken, Long>, J
    @Query("from GcToken where appid=?1 and outTime >= now () ")
    List<GcToken> findByAppId(String token);
    @Query("from GcToken where appid=?1 and outTime >= ?2 and del=1 ")
    List<GcToken> findByAppIdAndOutTime(String token, Date now);
}

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/gateway/service/GcTokenService.java

@ -116,4 +116,8 @@ public class GcTokenService {
        }
    }
    public List<GcToken> findByAppIdAndOutTime(String appid,Date now){
        return tokenDao.findByAppIdAndOutTime(appid,now);
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java

@ -16,7 +16,7 @@ public class BaseVisitDO extends UuidIdentityEntityWithCreateTime {
    private String patient;
    private String patientName;
    private String type;//类型 1老人日常走访
    private String type;//类型 1老人日常走访 2老人日常临时走访(管理端直接新增记录没有计划)
    private String status;//状态 0计划中 1 已完成 2计划超时
    private Date visitDate;//完成走访时间
    private Date visitPlanDate;//计划走访时间

+ 58 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/NetworkUtil.java

@ -0,0 +1,58 @@
package com.yihu.jw.util.common;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/** 
 * 常用获取客户端信息的工具 
 *  
 */
public final class NetworkUtil {
	/**
	 * 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址;
	 *
	 * @param request
	 * @return
	 * @throws IOException
	 */
	public final static String getIpAddress(HttpServletRequest request) throws IOException {
		// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
		String ip = request.getHeader("X-Forwarded-For");
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getHeader("Proxy-Client-IP");
			}
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getHeader("WL-Proxy-Client-IP");
			}
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getHeader("HTTP_CLIENT_IP");
			}
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getHeader("HTTP_X_FORWARDED_FOR");
			}
			if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
				ip = request.getRemoteAddr();
			}
		} else if (ip.length() > 15) {
			String[] ips = ip.split(",");
			for (int index = 0; index < ips.length; index++) {
				String strIp = (String) ips[index];
				if (!("unknown".equalsIgnoreCase(strIp))) {
					ip = strIp;
					break;
				}
			}
		}
		return ip;
	}
}

+ 40 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/MvcConfig.java

@ -0,0 +1,40 @@
package com.yihu.jw.care.config;
import com.tencentcloudapi.cdn.v20180606.models.UserAgentFilter;
import com.yihu.jw.care.interceptors.GateWayInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {
    private Logger logger = LoggerFactory.getLogger(MvcConfig.class);
    @Autowired
    private GateWayInterceptor gateWayInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
//         excludePathPatterns 用户排除拦截 ,/third/juye/kit/**
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/open/gc/**").excludePathPatterns(
                "/open/gc/accesstoken");
        super.addInterceptors(registry);
        logger.info("init gateWayInterceptor");
    }
}

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

@ -15,4 +15,7 @@ public interface BaseVisitDao  extends PagingAndSortingRepository<BaseVisitDO, S
    @Query("select a from BaseVisitDO a where a.doctor = ?1 and a.visitPlanDate between ?2 and ?3 ")
    List<BaseVisitDO> findByDoctor(String doctor, Date begin, Date end) throws Exception;
    @Query("select a from BaseVisitDO a where a.visitPlanDate between ?1 and ?2 ")
    List<BaseVisitDO> findByDoctor2(Date begin, Date end) throws Exception;
}

+ 25 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/DoctorConsultEndpoint.java

@ -8,6 +8,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -118,4 +119,28 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
            return failedException2(e);
        }
    }
    @PostMapping(value = "videoInviteMiniProgram")
    @ApiOperation(value = "医生端:发起/断开 会话小程序视频邀请", notes = "医生端:发起/断开 会话小程序视频邀请")
    public Envelop videoInviteMiniProgram(@ApiParam(name = "sender_id", value = "发起人")
                                          @RequestParam(value = "sender_id",required = true) String sender_id,
                                          @ApiParam(name = "reciver_id", value = "接收人")
                                          @RequestParam(value = "reciver_id",required = true) String reciver_id,
                                          @ApiParam(name = "reciver_type", value = "接收人类型1居民 2医生")
                                          @RequestParam(value = "reciver_type",required = false) String reciver_type,
                                          @ApiParam(name = "token", value = "token")
                                          @RequestParam(value = "token",required = false) String token,
                                          @ApiParam(name = "channelName", value = "房间号")
                                          @RequestParam(value = "channelName",required = false) String channelName,
                                          @ApiParam(name = "session_id", value = "会话ID",required = false)
                                          @RequestParam(value = "session_id",required = false) String session_id
    ){
        try{
            consultService.sendWeTempMesMiniProgram(sender_id,reciver_id,session_id,token,channelName);
            return success("操作成功");
        }catch (Exception e){
            return failedException2(e);
        }
    }
}

+ 1 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java

@ -119,6 +119,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@ApiOperation(value = "im推送个推消息")
	public Envelop sendGetuiMessage(String sessionId,String type,String senderName,String senderId,String targetId){
		try {
			logger.info("im推送1个推消息"+sessionId+","+senderName+","+targetId);
			String body = "收到来自"+senderName+"的一条消息,请关注并及时处理。";
			String peerName = null;
			String sql = "SELECT name from im_internet_hospital.sessions WHERE id = '"+sessionId+"'";

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

@ -370,6 +370,17 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("获取getAqgDeviceInfo2定位数据")
    @RequestMapping(value = "getAqgDeviceInfo2",method = RequestMethod.GET)
    public String getAqgDeviceInfo2(@ApiParam(name = "deviceSn",value = "设备sn码")
                                    @RequestParam(value = "deviceSn",required = true)String deviceSn){
        try {
            return write(200,"获取成功","data",patientDeviceService.getAqgDeviceInfo2(deviceSn));
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("获取睡眠带设备信息")
    @RequestMapping(value = "getSleepDeviceInfo",method = RequestMethod.GET)
    public String getSleepDeviceInfo(@ApiParam(name = "deviceSn",value = "睡眠带MAC 去除符号:")

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

@ -317,9 +317,10 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation("助老员端获取日常监护居民")
    @GetMapping(value = "findSignOlder")
    @ResponseBody
    public ObjEnvelop findSignOlder() {
    public ObjEnvelop findSignOlder(
            @RequestParam(value = "doctor", required = false, defaultValue = "0") String doctor) {
        try {
            return ObjEnvelop.getSuccess("查询成功", platformService.findSignOlder());
            return ObjEnvelop.getSuccess("查询成功", platformService.findSignOlder(doctor));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }

+ 20 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java

@ -38,8 +38,8 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
                                        @RequestParam(value = "startTime", required = true) String startTime,
                                       @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2021-11-30 00:00:00")
                                        @RequestParam(value = "endTime", required = true) String endTime,
                                       @ApiParam(name = "doctor", value = "医生id")
                                        @RequestParam(value = "doctor", required = true) String doctor) {
                                       @ApiParam(name = "doctor", value = "医生id", required = false)
                                        @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            List<Map<String, Object>> result = baseVisitService.getListByDoctor(doctor, startTime, endTime);
            return ListEnvelop.getSuccess("创建成功",result);
@ -131,4 +131,22 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("直接新增走访--管理员端")
    @RequestMapping(value = "/adminAddVisit",method = RequestMethod.POST)
    public Envelop adminAddVisit(@ApiParam(name = "doctor", value = "医生id")
                                 @RequestParam(value = "doctor", required = true) String doctor,
                                 @ApiParam(name = "patient", value = "患者代码")
                                 @RequestParam(value = "patient", required = true) String patient,
                                 @ApiParam(name = "visitContent", value = "走访记录")
                                 @RequestParam(value = "visitContent", required = true) String visitContent,
                                 @ApiParam(name = "visitImg", value = "走访图片")
                                 @RequestParam(value = "visitImg", required = true) String visitImg) {
        try {
            baseVisitService.adminAddVisit(doctor,patient,visitContent,visitImg);
            return Envelop.getSuccess("操作成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
}

+ 115 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/GcTokenController.java

@ -0,0 +1,115 @@
package com.yihu.jw.care.endpoint.wlyygc;
import com.yihu.jw.care.vo.BaseResultModel;
import com.yihu.jw.care.vo.GcClientDetailsModel;
import com.yihu.jw.care.vo.GcTokenModel;
import com.yihu.jw.care.vo.ResultOneModel;
import com.yihu.jw.entity.iot.gateway.GcClientDetails;
import com.yihu.jw.entity.iot.gateway.GcHttpLog;
import com.yihu.jw.entity.iot.gateway.GcToken;
import com.yihu.jw.gateway.dao.GcHttpLogDao;
import com.yihu.jw.gateway.service.GcClientDetailsService;
import com.yihu.jw.gateway.service.GcTokenService;
import com.yihu.jw.util.common.NetworkUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2022/01/18.
 * 对外的网关
 */
@Controller
@RequestMapping(value = "open/gc", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@Api(description = "gctoken相关服务")
public class GcTokenController {
    @Autowired
    private GcTokenService gcTokenService;
    @Autowired
    private GcClientDetailsService clientDetailsService;
    @Autowired
    private GcHttpLogDao httpLogDao;
    @ApiOperation("获取accesstoken")
    @RequestMapping(value = "accesstoken", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public ResultOneModel<GcTokenModel> getToken(
            @ApiParam(name = "appid", value = "appid", required = true) @RequestParam(required = true, value = "appid") String appid,
            @ApiParam(name = "appSecret", value = "appSecret", required = true) @RequestParam(required = true, value = "appSecret") String appSecret,
            @ApiParam(name = "过期时间 yyyy-MM-dd", value = "overTime", required = false) @RequestParam(required = false, value = "overTime") String overTime,
            HttpServletRequest request) {
        String ip = "";
        try {
            ip = NetworkUtil.getIpAddress(request);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            //查询appId 的token是否过期
            GcToken gcToken = new GcToken();
            List<GcToken> gcTokenList = gcTokenService.findByAppIdAndOutTime(appid, new Date());
            if(gcTokenList == null || gcTokenList.size() == 0){
                //得到用户
                GcClientDetails clientDetails = clientDetailsService.findByAppId(appid);
                if (clientDetails == null) {
                    ResultOneModel resultOneModel = new ResultOneModel(null);
                    resultOneModel.setStatus(BaseResultModel.statusEm.error_Appid.getCode());
                    resultOneModel.setMessage(BaseResultModel.statusEm.error_Appid.getMessage());
                    saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), "", "", request.getRequestURI(), 0, BaseResultModel.statusEm.error_Appid.getMessage());
                    return resultOneModel;
                }
                //判断appSecret
                if (!appSecret.equals(clientDetails.getAppSecret())) {
                    ResultOneModel resultOneModel = new ResultOneModel(null);
                    resultOneModel.setStatus(BaseResultModel.statusEm.error_AppSecret.getCode());
                    resultOneModel.setMessage(BaseResultModel.statusEm.error_AppSecret.getMessage());
                    saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), "", "", request.getRequestURI(), 0, BaseResultModel.statusEm.error_Appid.getMessage());
                    return resultOneModel;
                }
                //生成token
                gcToken = gcTokenService.createToken(appid, appSecret, ip,overTime,2);
                saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), new JSONObject(gcToken).toString(), gcToken.getAccesstoken(), request.getRequestURI(), 1, "成功");
            }else {
                gcToken = gcTokenList.get(0);
            }
            GcTokenModel gcTokenModel = new GcTokenModel();
            BeanUtils.copyProperties(gcToken, gcTokenModel);
            gcTokenModel.setOutTime(gcToken.getOutTime().getTime());
            return new ResultOneModel(gcTokenModel);
        } catch (Exception e) {
            saveHttpLog(ip, new JSONObject(request.getParameterMap()).toString(), "", "", request.getRequestURI(), 0, BaseResultModel.statusEm.login_system_error.getMessage());
            return new ResultOneModel(BaseResultModel.statusEm.login_system_error.getCode(), BaseResultModel.statusEm.login_system_error.getMessage());
        }
    }
    private void saveHttpLog(String ip, String input, String output, String token, String method, Integer flag, String message) {
        GcHttpLog gcHttpLog = new GcHttpLog();
        gcHttpLog.setCreateTime(new Date());
        gcHttpLog.setIp(ip);
        gcHttpLog.setInput(input);
        if(output.length() > 3000) {
            output = output.substring(0, 3000);
        }
        gcHttpLog.setOutput(output);
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
}

+ 132 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/WlyygcDataEndpoint.java

@ -0,0 +1,132 @@
package com.yihu.jw.care.endpoint.wlyygc;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.WlyygcStatisticsService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
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.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;
/**
 * Created by yeshijie on 2022/1/18.
 */
@RestController
@RequestMapping(value = "open/gc/data")
@Api(value = "对外开放统计数据", tags = {"对外开放统计数据"})
public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private WlyygcStatisticsService wlyygcStatisticsService;
    @GetMapping(value = "signOlderNum")
    @ApiOperation(value = "社区签约老人数量")
    public ObjEnvelop signOlderNum(@ApiParam(name = "code", value = "社区编码")
                                   @RequestParam(value = "code", required = true) String code) {
        try {
            Integer result = wlyygcStatisticsService.signOlderNum(code);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceInfo")
    @ApiOperation(value = "绑定设备在线数量,绑定设备总数")
    public ObjEnvelop deviceInfo(@ApiParam(name = "code", value = "社区编码")
                                  @RequestParam(value = "code", required = true) String code) {
        try {
            JSONObject result = wlyygcStatisticsService.deviceInfo(code);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "emeAndSec")
    @ApiOperation(value = "安防/紧急呼叫总数")
    public ObjEnvelop emeAndSec(@ApiParam(name = "code", value = "社区编码")
                                 @RequestParam(value = "code", required = true) String code) {
        try {
            JSONObject result = wlyygcStatisticsService.emeAndSec(code);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "emeAndSecInfo")
    @ApiOperation(value = "安防/紧急呼叫概要")
    public PageEnvelop emeAndSecInfo(@ApiParam(name = "code", value = "社区编码", required = true)
                                     @RequestParam(value = "code", required = true) String code,
                                     @ApiParam(name = "page", value = "分页大小", required = true)
                                     @RequestParam(value = "page") Integer page,
                                     @ApiParam(name = "size", value = "页码", required = true)
                                     @RequestParam(value = "size") Integer size,
                                     @ApiParam(name = "type", value = "类型", required = false)
                                     @RequestParam(value = "type", required = false) Integer type,
                                     @ApiParam(name = "status", value = "状态", required = false)
                                     @RequestParam(value = "status", required = false) Integer status) {
        try {
            return wlyygcStatisticsService.emeAndSecInfo(page,size,code,type,status);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "signOldList")
    @ApiOperation(value = "获取签约老人")
    public PageEnvelop signOldList(@ApiParam(name = "code", value = "社区编码")
                                   @RequestParam(value = "code", required = true) String code,
                                   @ApiParam(name = "page", value = "分页大小", required = true)
                                   @RequestParam(value = "page") Integer page,
                                   @ApiParam(name = "size", value = "页码", required = true)
                                   @RequestParam(value = "size") Integer size) {
        try {
            return wlyygcStatisticsService.signOldList(code, page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "securityEmergencyList")
    @ApiOperation(value = "获取安防/监护")
    public PageEnvelop securityEmergencyList(@ApiParam(name = "code", value = "社区编码")
                                            @RequestParam(value = "code", required = true) String code,
                                            @ApiParam(name = "page", value = "分页大小", required = true)
                                            @RequestParam(value = "page") Integer page,
                                            @ApiParam(name = "type", value = "类型", required = false)
                                            @RequestParam(value = "type") Integer type,
                                            @ApiParam(name = "size", value = "页码", required = true)
                                            @RequestParam(value = "size") Integer size) {
        try {
            return wlyygcStatisticsService.securityEmergencyList(code,type,page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceList")
    @ApiOperation(value = "获取设备列表")
    public PageEnvelop deviceList(@ApiParam(name = "code", value = "社区编码")
                                  @RequestParam(value = "code", required = true) String code,
                                  @ApiParam(name = "page", value = "分页大小", required = true)
                                  @RequestParam(value = "page") Integer page,
                                  @ApiParam(name = "size", value = "页码", required = true)
                                  @RequestParam(value = "size") Integer size) {
        try {
            return wlyygcStatisticsService.deviceList(code, page, size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
}

+ 159 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/interceptors/GateWayInterceptor.java

@ -0,0 +1,159 @@
package com.yihu.jw.care.interceptors;
/**
 * Created by chenweida on 2017/8/17.
 */
import com.yihu.jw.care.vo.BaseResultModel;
import com.yihu.jw.entity.iot.gateway.GcHttpLog;
import com.yihu.jw.entity.iot.gateway.GcToken;
import com.yihu.jw.gateway.dao.GcHttpLogDao;
import com.yihu.jw.gateway.dao.GcTokenDao;
import com.yihu.jw.util.common.NetworkUtil;
import net.sf.json.JSONObject;
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.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
 * 对外的请求拦截
 */
@Component
public class GateWayInterceptor implements HandlerInterceptor {
    private Logger logger = LoggerFactory.getLogger(GateWayInterceptor.class);
    @Autowired
    private GcHttpLogDao httpLogDao;
    @Autowired
    private GcTokenDao gcTokenDaoDao;
    public static String status = "1";
    /**
     * preHandle:预处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        String accesstoken = request.getHeader("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        //********************************判断accesstoken********************************
        try {
            if (org.springframework.util.StringUtils.isEmpty(accesstoken)) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_null.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                return false;
            }
            GcToken gcToken = gcTokenDaoDao.findByToken(accesstoken);
            if (gcToken == null) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_no_power.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                return false;
            }
            if (gcToken.getDel() == null || gcToken.getDel() == 0) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                //token无效
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_effect.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                return false;
            }
            if (System.currentTimeMillis() > gcToken.getOutTime().getTime()) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                //token过期
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_time.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
                return false;
            }
        } catch (Exception e) {
            saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), e.getMessage());
            return false;
        }
        //********************************判断accesstoken********************************
        return flag;
    }
    /**
     * 后处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        String output = "";
        if (modelAndView != null) {
            output = JSONObject.fromObject(modelAndView.getModelMap()).toString();
        } else {
            Object returnObj = request.getAttribute("returnObj");
            if (returnObj != null) {
                output = JSONObject.fromObject(returnObj).toString();
            }
        }
        HandlerMethod handlerMethod = (HandlerMethod) handler;
//        response.getOutputStream()
        String token = request.getHeader("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        saveHttpLog(ip,
                JSONObject.fromObject(request.getParameterMap()).toString(),
                output,
                token,
                request.getRequestURI(),
                GcHttpLog.flagEm.success.getCode(),
                null);
    }
    /**
     * 整个请求处理完毕回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param ex
     * @throws Exception
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
    public void saveHttpLog(String ip, String input, String output, String token, String method, Integer flag, String message) {
        GcHttpLog gcHttpLog = new GcHttpLog();
        gcHttpLog.setCreateTime(new Date());
        gcHttpLog.setIp(ip);
        gcHttpLog.setInput(input);
        if(output!=null&&output.length() > 3000) {
            output = output.substring(0, 3000);
        }
        gcHttpLog.setOutput(output);
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
}

+ 41 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java

@ -13,6 +13,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.care.consult.BaseYunxingChannelDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
@ -27,18 +28,20 @@ import com.yihu.jw.sms.dao.HospitalSysDictDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import org.apache.commons.collections.map.HashedMap;
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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static jxl.biff.FormatRecord.logger;
/**
 * Created with IntelliJ IDEA.
@ -50,6 +53,12 @@ import static jxl.biff.FormatRecord.logger;
@Service
public class ConsultService {
    private static Logger logger = LoggerFactory.getLogger(ConsultService.class);
    @Value("${wechat.id}")
    private String wechatId;
    @Value("${wechat.appId}")
    private String wechatAppId;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
@ -80,6 +89,36 @@ public class ConsultService {
    private BaseYunxingChannelDao yunxingChannelDao;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    /**
     * 发送微信模版消息-小程序视频
     * @param sender_id 发送者ID
     * @param reciver_id 接收者ID
     * @param session_id 会话ID
     */
    public String sendWeTempMesMiniProgram(String sender_id, String reciver_id, String session_id,String token,String channelName)throws Exception {
        BasePatientDO patient = basePatientDao.findById(reciver_id);
        if(patient!=null){
            BaseDoctorDO doctorDO = baseDoctorDao.findById(sender_id);
            JSONObject json = new JSONObject();
            json.put("nickName", patient.getName());
            json.put("token", token);
            json.put("channelName", channelName);
            String first = "【key1】您好!【key2】向您发起了视频请求";
            first = first.replace("key1",patient.getName());
            first = first.replace("key2", doctorDO.getName());
            List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patient.getId());
            if (basePatientWechatDos.size()>0){
                String openId = basePatientWechatDos.get(0).getOpenid();
                messageUtil.putTemplateWxMessage(wechatId,"template_consult_notice","spthtx",openId,first,null,null,28,json, DateUtil.dateToChineseDate(new Date()),"视频请求","点击接收");
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
    /**
     * 保存云信channelId

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

@ -1111,28 +1111,27 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                    String safeArea=null;
                    if (safeAreaDOS.size()>0){
                        safeArea = safeAreaDOS.get(0).getSafeAreaGz();
                    }
                    String[] safeAreas = safeArea.split(";");
                    com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
                    for (String area:safeAreas){
                        String[] areaPoint = area.split(",");
                        com.alibaba.fastjson.JSONObject positionTmp = new com.alibaba.fastjson.JSONObject();
                        Double areaLon = Double.parseDouble( areaPoint[0]);
                        Double areaLat = Double.parseDouble( areaPoint[1]);
                        String[] safeAreas = safeArea.split(";");
                        com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
                        for (String area:safeAreas){
                            String[] areaPoint = area.split(",");
                            com.alibaba.fastjson.JSONObject positionTmp = new com.alibaba.fastjson.JSONObject();
                            Double areaLon = Double.parseDouble( areaPoint[0]);
                            Double areaLat = Double.parseDouble( areaPoint[1]);
//                                com.alibaba.fastjson.JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                        positionTmp.put("lat",areaLat);
                        positionTmp.put("lon",areaLon);
                        fenceLocation.add(positionTmp);
                    }
                    if (!countDistance.isInPolygon(dulon,dulat,fenceLocation)){
                            positionTmp.put("lat",areaLat);
                            positionTmp.put("lon",areaLon);
                            fenceLocation.add(positionTmp);
                        }
                        if (!countDistance.isInPolygon(dulon,dulat,fenceLocation)){
//                        orderUtil.createSecurityOrder(sn,null,null,8,"1","yslkaqqy",null);
                        devInfoObj.put("isTrueFalse","已超出围栏范围");
                        devInfoObj.put("isNotAlarm","已报警");
                    } else {
                        devInfoObj.put("isTrueFalse","未超出围栏范围");
                        devInfoObj.put("isNotAlarm","未报警");
                            devInfoObj.put("isTrueFalse","已超出围栏范围");
                            devInfoObj.put("isNotAlarm","已报警");
                        } else {
                            devInfoObj.put("isTrueFalse","未超出围栏范围");
                            devInfoObj.put("isNotAlarm","未报警");
                        }
                    }
                    break;
            }
//        }

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

@ -1700,7 +1700,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                double homeLon = Double.parseDouble(homeLatLon.split(",")[1]);
                                double homeDistance = countDistance.getDistance(result.getJSONObject("location").getDouble("lat"), result.getJSONObject("location").getDouble("lon"),
                                        homeLat, homeLon);
                                if (homeDistance > 50 * 1000) {
                                if (homeDistance* 1000 > 50) {
                                    result.put("atHome", false);
                                } else {
                                    result.put("atHome", true);
@ -2296,6 +2296,17 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                " from base_patient p , base_service_package_sign_record sr,base_service_package_record r,base_team_member m  " +
                " WHERE p.id = sr.patient and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id  " +
                " and m.del = '1' ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            if (org.apache.commons.lang.StringUtils.isNotBlank(orgCodes)){
                orgCodes = orgCodes.replaceAll(",","','");
                sql += " and p.id not in ('"+orgCodes+"') ";
            }
        }
        String fliter = "";
        String categoryCode = "";
        String topicItemTmp = topicItem;
@ -2431,18 +2442,18 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                    double homeLon = Double.parseDouble(homeLatLon.split(",")[1]);
                                    double homeDistance = countDistance.getDistance(Double.parseDouble(latLon[0]), Double.parseDouble(latLon[1]),
                                            homeLat, homeLon);
                                    if (homeDistance > 50 * 1000) {
                                    if (homeDistance * 1000 > 50) {
                                        tmp.put("atHome", false);
                                    } else {
                                        tmp.put("atHome", true);
                                    }
                                } else {
                                    tmp.put("atHome", null);
                                    tmp.put("atHome", true);
                                }
                                String locationAddress = LatitudeUtils.getLocationAddress(latLon[0], latLon[1]);
                                tmp.put("address", locationAddress);
                            } else {
                                tmp.put("atHome", null);
                                tmp.put("atHome", true);
                                tmp.put("address", "");
                            }
                        }

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

@ -533,23 +533,23 @@ public class DetectionPlatformService  {
        return object;
    }
    public List<Map<String,Object >> findSignOlder(){
    public List<Map<String,Object >> findSignOlder(String doctorId){
        String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
        /*String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                " and m.del = '1' and  p.del = '1' " +
                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";*/
        /*String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
        String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and  p.del = '1' " +
                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";*/
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";
//        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei,p.residential_area residentialArea  " +
//                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +

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

@ -158,10 +158,12 @@ public class StatisticsService {
        // activity-1   活动浏览次数
        // activity-2   公艺课程播放
        String sql = " SELECT activity_type, COUNT(id) FROM base_activity_click WHERE activity_type IN (1, 2) GROUP BY activity_type";
        res.put("activity_1", 0);
        res.put("activity_2", 0);
        String sql = " SELECT activity_type, COUNT(id) total  FROM base_activity_click WHERE activity_type IN (1, 2) GROUP BY activity_type";
        List<Map<String, Object>> lists = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> tmp : lists) {
            Integer num = Integer.parseInt(tmp.get("id").toString());
            Integer num = Integer.parseInt(tmp.get("total").toString());
            res.put("activity_" + tmp.get("activity_type").toString(), num);
        }
@ -230,7 +232,7 @@ public class StatisticsService {
        // 32 新生儿-在线咨询总数
        // 35 新生儿-上门辅导-服务工单数
        // 54 新生儿-上门辅导-工单数发起数
        if ("".equals(interval)) {
        if (StringUtils.isBlank(interval)) {
            interval = "1";
        }
        if ("".equals(timeLevel)) {
@ -272,9 +274,20 @@ public class StatisticsService {
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_" + ind, saveModel.getResult2().longValue());
            }
            String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status >= 0 ";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
            List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
            String filter = "";
            String filter2 = "";
            if (listtmp.size() > 0) {
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",", "','");
                filter = " and hospital not in ('" + orgCodes + "') ";
                filter2 = " and org_code not in ('" + orgCodes + "') ";
            }
            String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status >= 0 "+filter2;
            Integer emergencyCallNum = jdbcTemplate.queryForObject(emergencyCallSql, Integer.class);
            String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 ";
            String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 "+filter;
            Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql, Integer.class);
            res.put("index_41", emergencyCallNum);
            res.put("index_43", securityMonitoringNum);
@ -289,10 +302,12 @@ public class StatisticsService {
            // activity-1   活动浏览次数
            // activity-2   公艺课程播放
            String sql = " SELECT activity_type, COUNT(id) FROM base_activity_click WHERE activity_type IN (1, 2) GROUP BY activity_type";
            String sql = " SELECT activity_type, COUNT(id) total FROM base_activity_click WHERE activity_type IN (1, 2) GROUP BY activity_type";
            res.put("activity_1",0);
            res.put("activity_2",0);
            List<Map<String, Object>> lists = jdbcTemplate.queryForList(sql);
            for (Map<String, Object> tmp : lists) {
                Integer num = Integer.parseInt(tmp.get("id").toString());
                Integer num = Integer.parseInt(tmp.get("total").toString());
                res.put("activity_" + tmp.get("activity_type").toString(), num);
            }
@ -1814,12 +1829,8 @@ public class StatisticsService {
        String[] split = index.split(",");
        for (String ind : split) {
            long total = 0l;
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, "330100", 2, ind, SaveModel.timeLevel_DDL, null, null, "2");
            for (int i = 0; i < list.size(); i++) {
                SaveModel saveModel = list.get(i);
                total+=saveModel.getResult2().longValue();
            }
            res.put("index_"+ind,total);
            SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, "330100", 2, ind, SaveModel.timeLevel_DDL, "6");
            res.put("index_"+ind, saveModelAdd.getResult2().longValue());
        }
        Long index_28 = (Long) res.get("index_28");
        Long index_29 = (Long) res.get("index_29");

+ 403 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/WlyygcStatisticsService.java

@ -0,0 +1,403 @@
package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2022/1/18.
 */
@Service
public class WlyygcStatisticsService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseEmergencyWarnLogDao logDao;
    /**
     * 社区签约老人数量
     * @return
     */
    public Integer signOlderNum(String code){
        String sql = "select count(DISTINCT p.id) FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r "+
                "WHERE p.del = 1 and p.archive_type =1  and r.patient = p.id";
        if("1".equals(code)){
            //1华联社区
            sql += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return 0;
        }
        Integer res = jdbcTemplate.queryForObject(sql,Integer.class);
        return res;
    }
    /**
     * 绑定设备在线数量,绑定设备总数
     * @return
     */
    public JSONObject deviceInfo(String code){
        JSONObject json = new JSONObject();
        Integer total = 0;
        Integer online = 0;
        String sql = "select count(DISTINCT d.id) c, IFNULL(d.contact_status,0) contact_status FROM   " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, wlyy_patient_device pd ,wlyy_devices d  " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = pd.`user` and d.device_code = pd.device_sn ";
        if("1".equals(code)){
            //1华联社区
            sql += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return json;
        }
        sql += "  GROUP BY d.contact_status ";
        List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : res){
            Integer num = Integer.valueOf(map.get("c").toString());
            Integer contact_status = Integer.valueOf(map.get("contact_status").toString());
            if(contact_status==1){
                online = num;
            }
            total += num;
        }
        json.put("total",total);
        json.put("online",online);
        return json;
    }
    /**
     * 紧急救助和安防监控数量
     * @param code
     * @return
     */
    public JSONObject emeAndSec(String code){
        JSONObject json = new JSONObject();
        String sqlEme = "select count(DISTINCT o.id) c,o.status FROM   " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o   " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient ";
        String sqlSec = "select count(DISTINCT o.id) c,o.status FROM   " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o  " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient ";
        String filter = "";
        if("1".equals(code)){
            filter += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return json;
        }
        filter += " GROUP BY o.status";
        Integer emeTotla = 0;
        Integer emeErrorWarning = 0;
        Integer emeCancel = 0;
        Integer emeComplete = 0;
        Integer emeApply = 0;
        Integer secTotla = 0;
        Integer secErrorWarning = 0;
        Integer secCancel = 0;
        Integer secComplete = 0;
        Integer secApply = 0;
        List<Map<String,Object>> res1 = jdbcTemplate.queryForList(sqlEme + filter);
        for (Map<String,Object> map : res1){
            Integer num = Integer.valueOf(map.get("c").toString());
            String status = map.get("status")+"";
            emeTotla += num;
            if("1".equals(status)){
                emeApply = num;
                continue;
            }
            if("0".equals(status)){
                emeComplete = num;
                continue;
            }
            if("-1".equals(status)){
                emeCancel = num;
                continue;
            }
            if("-2".equals(status)){
                emeErrorWarning = num;
                continue;
            }
        }
        List<Map<String,Object>> res2 = jdbcTemplate.queryForList(sqlSec + filter);
        for (Map<String,Object> map : res2){
            Integer num = Integer.valueOf(map.get("c").toString());
            String status = map.get("status")+"";
            secTotla += num;
            if("1".equals(status)){
                secApply = num;
                continue;
            }
            if("0".equals(status)){
                secComplete = num;
                continue;
            }
            if("-1".equals(status)){
                secCancel = num;
                continue;
            }
            if("-2".equals(status)){
                secErrorWarning = num;
                continue;
            }
        }
        json.put("secTotla",secTotla);
        json.put("secApply",secApply);
        json.put("secComplete",secComplete);
        json.put("secCancel",secCancel);
        json.put("secErrorWarning",secErrorWarning);
        json.put("emeTotla",emeTotla);
        json.put("emeApply",emeApply);
        json.put("emeComplete",emeComplete);
        json.put("emeCancel",emeCancel);
        json.put("emeErrorWarning",emeErrorWarning);
        return json;
    }
    /**
     * 安防/紧急呼叫概要
     * @param page
     * @param size
     * @param code
     * @return
     */
    public PageEnvelop emeAndSecInfo(Integer page, Integer size, String code, Integer type, Integer status){
        JSONArray jsonArray = new JSONArray();
        String filter = "";
        if("1".equals(code)){
            filter = " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return PageEnvelop.getSuccess("查询成功");
        }
        if(status!=null){
            filter += " and o.status = "+status;
        }
        if(page==null){
            page =1;
        }
        if(size==null){
            size = 10;
        }
        Map<String,String> statusMap = new HashMap<>();
        statusMap.put("-1","已取消");
        statusMap.put("-2","误报警");
        statusMap.put("0","已完成");
        statusMap.put("1","申请中");
        String sql = "SELECT * from ( " +
                "select o.id,p.name,p.idcard,p.residential_area,'1' type,o.serve_address,'紧急呼叫' serve_desc,o.status,o.create_time  FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                "UNION ALL " +
                "select o.id,p.name,p.idcard,p.residential_area,'2' type,o.serve_address,o.serve_desc,o.status,o.create_time FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sql += " and a.type = '"+type+"'";
        }
        sql += "ORDER BY a.create_time desc limit "+(page-1)*size+","+size;
        String sqlCount = "SELECT count(*) from ( " +
                "select o.id,'1' type  FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " UNION ALL " +
                "select o.id,'2' type FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sqlCount += " and a.type = '"+type+"'";
        }
        List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : res){
            JSONObject json = new JSONObject();
            json.put("name",map.get("name"));
            json.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard")+""));
            json.put("residentialArea",map.get("residential_area"));
            json.put("type",map.get("type"));
            json.put("serveAddress",map.get("serve_address"));
            json.put("serveDesc",map.get("serve_desc"));
            json.put("status",statusMap.get(map.get("status")+""));
            json.put("createTime",map.get("create_time").toString().substring(0,19));
            String orderLogInfo = "";
            List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(map.get("id")+"");
            if(logDOS.size()>0){
                BaseEmergencyWarnLogDO warnLogDO = logDOS.get(0);
                orderLogInfo = warnLogDO.getUserName()+":"+warnLogDO.getContent();
            }
            json.put("orderLogInfo",orderLogInfo);
            jsonArray.add(json);
        }
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",jsonArray,page,size,total);
    }
    public PageEnvelop signOldList(String code, Integer page, Integer size) {
        if (page == null) {
            page = 1;
        }
        if (size == null) {
            size = 10;
        }
        String sql = "SELECT DISTINCT p.`name`, p.mobile, p.idcard,(CASE WHEN p.sex = 1 THEN  '男' ELSE '女' END ) AS sex,p.address, TIMESTAMPDIFF(YEAR, p.birthday, CURDATE()) years,p.residential_area AS residentialArea" +
                " FROM base_patient p INNER JOIN base_service_package_sign_record br ON p.id = br.patient, base_service_package_record r" +
                " WHERE p.del = 1 AND br.`status` = 1 AND p.archive_type = 1 AND r.patient = p.id ";
        String sqlCount = "SELECT count(DISTINCT p.id) " +
                " FROM base_patient p INNER JOIN base_service_package_sign_record br ON p.id = br.patient, base_service_package_record r" +
                " WHERE p.del = 1 AND br.`status` = 1 AND p.archive_type = 1 AND r.patient = p.id ";
        if ("1".equals(code)) {
            //1华联社区
            sql += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
            sqlCount += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        } else {
            return PageEnvelop.getSuccess("查询成功");
        }
        sql += "ORDER BY p.`name` desc limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,total);
    }
    public PageEnvelop securityEmergencyList(String code,Integer type,Integer page,Integer size) {
        String filter = "";
        if("1".equals(code)){
            filter = " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return PageEnvelop.getSuccess("查询成功");
        }
        if(page==null){
            page =1;
        }
        if(size==null){
            size = 10;
        }
        String sql = "SELECT * from ( " +
                "select p.name,'紧急呼叫' serveDesc,'1' type,o.create_time createTime FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                "UNION ALL " +
                "select p.name,o.serve_desc serveDesc,'2' type,o.create_time createTime FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sql += " and a.type = '"+type+"'";
        }
        sql += "ORDER BY a.createTime desc limit "+(page-1)*size+","+size;
        String sqlCount = "SELECT count(*) from ( " +
                "select o.id,'1' type  FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " UNION ALL " +
                "select o.id,'2' type FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sqlCount += " and a.type = '"+type+"'";
        }
        List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : res){
            map.put("createTime",map.get("createTime").toString().substring(0,19));
        }
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",res,page,size,total);
    }
    public PageEnvelop deviceList(String code,Integer page,Integer size){
        if (page == null) {
            page = 1;
        }
        if (size == null) {
            size = 10;
        }
        String filter ="";
        if ("1".equals(code)){
            filter += "AND r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam'";
        }else {
            return PageEnvelop.getSuccess("查询成功");
        }
        String deviceSql = "SELECT DISTINCT" +
                " pd.device_name as deviceName," +
                "pd.device_type as deviceType," +
                "IFNULL(wd.collect_num,0) as collectNum " +
                "FROM " +
                "base_patient p " +
                "INNER JOIN base_service_package_sign_record sr ON p.id = sr.patient " +
                "AND sr.`status` = 1," +
                " base_service_package_record r," +
                " wlyy_patient_device pd," +
                " wlyy_devices wd " +
                "WHERE " +
                "p.del = 1 " +
                "AND p.archive_type = 1 " +
                "AND r.patient = p.id " +
                "AND p.id = pd.`user` " +
                "AND pd.del = 0 "+
                "AND wd.device_code = pd.device_sn "+filter+" ORDER BY pd.device_name DESC limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(deviceSql);
        String sqlCount = "SELECT count(DISTINCT pd.id) " +
                "FROM " +
                "base_patient p " +
                "INNER JOIN base_service_package_sign_record sr ON p.id = sr.patient " +
                "AND sr.`status` = 1," +
                " base_service_package_record r," +
                " wlyy_patient_device pd," +
                " wlyy_devices wd " +
                "WHERE " +
                "p.del = 1 " +
                "AND p.archive_type = 1 " +
                "AND r.patient = p.id " +
                "AND p.id = pd.`user` " +
                "AND pd.del = 0 "+
                "AND wd.device_code = pd.device_sn "+filter;
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,total);
    }
}

+ 38 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java

@ -10,6 +10,7 @@ import com.yihu.jw.entity.care.visit.BaseVisitDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -37,8 +38,12 @@ public class BaseVisitService {
    public List<Map<String, Object>> getListByDoctor(String doctorCode, String startTime, String endTime) throws Exception {
        List<Map<String, Object>> re = new ArrayList<>();
        Map<String, Map<String, Object>> temp = new HashMap<>();
        List<BaseVisitDO> list = baseVisitDao.findByDoctor(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime));
        List<BaseVisitDO> list = null;
        if(StringUtils.isNotBlank(doctorCode)){
            list = baseVisitDao.findByDoctor(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime));
        }else{
            list = baseVisitDao.findByDoctor2(DateUtil.strToDate(startTime), DateUtil.strToDate(endTime));
        }
        if (list != null && list.size() > 0) {
            for (BaseVisitDO visitDO : list) {
                String date = DateUtil.dateToStrShort(visitDO.getVisitPlanDate());
@ -121,6 +126,37 @@ public class BaseVisitService {
        return null;
    }
    /**
     * 直接新增走访--管理员端
     * @param visitContent
     * @param visitImg
     */
    public void adminAddVisit(String doctorCode,String patientCode,String visitContent,String visitImg) throws Exception{
        BaseVisitDO visitDO = new BaseVisitDO();
        //获取患者信息
        BasePatientDO patient = patientDao.findById(patientCode);
        if (patient == null) {
            throw new Exception("获取不到用户信息!");
        }
        BaseDoctorDO doctor = doctorDao.findById(doctorCode);
        if (doctor == null) {
            throw new Exception("获取不到医生信息!");
        }
        visitDO.setDoctor(doctorCode);
        visitDO.setDoctorName(doctor.getName());
        visitDO.setPatient(patientCode);
        visitDO.setPatientName(patient.getName());
        visitDO.setVisitPlanDate(new Date());
        visitDO.setVisitDate(new Date());
        visitDO.setStatus("1");
        visitDO.setType("2");
        visitDO.setVisitContent(visitContent);
        visitDO.setVisitImg(visitImg);
        baseVisitDao.save(visitDO);
    }
    /**
     * 完成走访
     * @param id

+ 5 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -243,6 +243,11 @@ public class MessageUtil {
            case 26://生日祝福
                wxTemplateConfigDO.setUrl(wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&id=" + json.getString("id"));
                break;
            case 28://视频请求
                //?channelName="'&nickName=''&token=' '
                wxTemplateConfigDO.setUrl(wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&channelName=" + json.getString("channelName")
                        + "&nickName=" + json.getString("nickName")+ "&token=" + json.getString("token"));
                break;
            case 30:
                //反馈通知 测试 TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
                if(json.containsKey("consult")) {

+ 98 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/BaseResultModel.java

@ -0,0 +1,98 @@
package com.yihu.jw.care.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel("返回实体")
public class BaseResultModel {
    @ApiModelProperty(value = "状态", required = false, access = "response")
    protected Integer status = statusEm.success.getCode();
    @ApiModelProperty(value = "信息", required = false, access = "response")
    protected String message = "成功";
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public enum statusEm {
        success(10000, "请求成功"),//请求成功
        error_Appid(-9000, "appid不存在"),//appid不存在
        error_AppSecret(-9001, "AppSecret不存在"),//AppSecret不存在
        token_out_effect(-9002, "无效的token"),//token无效
        token_no_power(-9003, "用户没权限"),// 没权限 包括未授权 或者uri错误
        token_out_time(-9004, "accesstoken已过期"),//token无效
        token_null(-9005, "accesstoken为空"),// 没权限 包括未授权 或者uri错误
        error_params(-10000, "请求失败 参数错误"),//请求失败 参数错误
        error_no_ip(-10010, "请求失败,获取IP失败"),//请求失败,获取IP失败
        login_system_error(-10020, "系统异常"),
        login_publickey_error(-10030, "获取公钥失败"),
        file_upload_error(-10040, "文件上传失败"),
        find_error(-10050, "查询失败"),
        opera_error(-10060, "操作失败"),
        no_openid(-30000,"用户openId为空无法发送"),
        login_account_error(-20010, "账号不存在"),
        login_password_error(-20020, "密码错误"),
        login_IMEI_error(-20030, "获取imei失败");
        ;
        statusEm(Integer code, String message) {
            this.code = code;
            this.message = message;
        }
        private Integer code;
        private String message;
        public Integer getCode() {
            return code;
        }
        public void setCode(Integer code) {
            this.code = code;
        }
        public String getMessage() {
            return message;
        }
        public void setMessage(String message) {
            this.message = message;
        }
    }
    public BaseResultModel() {
    }
    public BaseResultModel(String message) {
        this.message = message;
    }
    public BaseResultModel(Integer status, String message) {
        this.status = status;
        this.message = message;
    }
}

+ 33 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/GcClientDetailsModel.java

@ -0,0 +1,33 @@
package com.yihu.jw.care.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * GtClientDetails entity. @author MyEclipse Persistence Tools
 */
@ApiModel(description = "")
public class GcClientDetailsModel{
    // Fields
    @ApiModelProperty(value = "appId", required = false, access = "response")
    private String appId;
    @ApiModelProperty(value = "appSecret", required = false, access = "response")
    private String appSecret;
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
}

+ 51 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/GcTokenModel.java

@ -0,0 +1,51 @@
package com.yihu.jw.care.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/17.
 */
@ApiModel(description = "")
public class GcTokenModel {
    @ApiModelProperty(value = "请求凭证", required = false, access = "response")
    private String accesstoken;
    @ApiModelProperty(value = "创建时间", required = false, access = "response")
    private Date createTime;
    @ApiModelProperty(value = "过期时间", required = false, access = "response")
    private Long outTime;
    public String getAccesstoken() {
        return accesstoken;
    }
    public void setAccesstoken(String accesstoken) {
        this.accesstoken = accesstoken;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    /*public Date getOutTime() {
        return outTime;
    }
    public void setOutTime(Date outTime) {
        this.outTime = outTime;
    }*/
    public Long getOutTime() {
        return outTime;
    }
    public void setOutTime(Long outTime) {
        this.outTime = outTime;
    }
}

+ 39 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/ResultOneModel.java

@ -0,0 +1,39 @@
package com.yihu.jw.care.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by chenweida on 2017/8/17.
 * 对外放回的实体
 */
@ApiModel("返回的实体类")
public class ResultOneModel<T> extends BaseResultModel {
    @ApiModelProperty(value = "返回数据", required = false, access = "response")
    private T result;
    public T getResult() {
        return result;
    }
    public void setResult(T result) {
        this.result = result;
    }
    public ResultOneModel(T result) {
        this.result = result;
    }
    public ResultOneModel() {
    }
    public ResultOneModel(Integer code, String message) {
        super(code, message);
    }
    public ResultOneModel(Integer status, String message, T result) {
        super(status, message);
        this.result = result;
    }
}

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

@ -50,7 +50,7 @@ public class BirthdayReminderService {
                    messageUtil.sendTXYSJson("1099809",mobile,doctorName,c+"");
                }
                if(c>0){
                    String body = "您好,今天有"+c+"位老人走访计划,请及时处理";
                    String body = "您好,今天有"+c+"位老人过生日,赶紧去送上祝福吧";
                    messageUtil.sendDoctorGetuiMessage(doctorId,"1","/solicitude/birthday","生日祝福提醒",body);
                }
            }catch (Exception e){

+ 1 - 1
svr/svr-iot-sn/readme.MD

@ -1,6 +1,6 @@
Internet of things  物联网平台
IotAnalyzerController 的代码已经移到i健康的device项目
filters 字符串拼接规则
         * like:使用"?"来表示,如:name?'%医'

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/gateway/GcTokenController.java

@ -59,7 +59,7 @@ public class GcTokenController {
            ip = IpUtil.getIpAddress(request);
            //查询appId 的token是否过期
            GcToken gcToken = new GcToken();
            List<GcToken> gcTokenList = gcTokenService.findByAppId(appid);
            List<GcToken> gcTokenList = gcTokenService.findByAppId(appid,new Date());
            if(gcTokenList == null || gcTokenList.size() == 0){
                //得到用户
                GcClientDetails clientDetails = clientDetailsService.findByAppId(appid);

+ 3 - 2
svr/svr-iot/src/main/java/com/yihu/iot/dao/gateway/GcTokenDao.java

@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -20,6 +21,6 @@ public interface GcTokenDao extends PagingAndSortingRepository<GcToken, Long>, J
    @Query("from GcToken where accesstoken=?1")
    GcToken findByToken(String token);
    @Query("from GcToken where appid=?1 and outTime >= now()")
    List<GcToken> findByAppId(String token);
    @Query("from GcToken where appid=?1 and outTime >= ?2 and del=1 ")
    List<GcToken> findByAppId(String token, Date now);
}

+ 2 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/gateway/GcTokenService.java

@ -95,7 +95,7 @@ public class GcTokenService {
        return tokenDao.findByToken(token);
    }
    public List<GcToken> findByAppId(String appid){
        return tokenDao.findByAppId(appid);
    public List<GcToken> findByAppId(String appid, Date now){
        return tokenDao.findByAppId(appid,now);
    }
}