Explorar o código

超时及问卷bug修改

wangjun %!s(int64=4) %!d(string=hai) anos
pai
achega
df5641c53c

+ 10 - 25
business/base-service/src/main/java/com/yihu/jw/hospital/drugstore/service/BaseDrugStoreService.java

@ -54,31 +54,16 @@ public class BaseDrugStoreService extends BaseJpaService<BaseDrugStoreDO, BaseDr
        return list;
   }
       //根据经纬度计算距离sql
    public List<Map<String,Object>> countDistanceList(String latitude,String longitude,String drugStoreName,Integer page,Integer pageSize){
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT\n" +
                "    DISTINCT t.id as \"id\" ,(\n" +
                "    round(6371392.89 * acos (\n" +
                "    cos ( radians("+latitude+") )\n" +
                "    * cos( radians( t.latitude  ) )\n" +
                "    * cos( radians( t.longitude ) - radians("+longitude+") )\n" +
                "    + sin ( radians("+latitude+") )\n" +
                "    * sin( radians( t.latitude ) )\n" +
                "    ),2\n" +
                "    ) )AS distance,\n" +
                "t.drug_store_name as \"drugStoreName\""+
                "    FROM base_drug_store t where 1=1");
        if (StringUtils.isNotEmpty(drugStoreName)){
            sql.append(" and t.drug_store_name like '%"+drugStoreName+"%'");
        }
        sql.append(" ORDER BY distance asc");
        System.out.println(sql.toString());
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql.toString(),page,pageSize);
        return list;
    }
    public BaseDrugStoreDO getById(String id){
       return baseDrugStoreDao.findOne(id);
    public BaseDrugStoreDO getById(String id,String latitude,String longitude){
        BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findOne(id);
        CountDistance countDistance = new CountDistance();
        latitude=StringUtils.isEmpty(latitude)?"0":latitude;
        longitude=StringUtils.isEmpty(longitude)?"0":longitude;
        double storeLatitude = Double.parseDouble(baseDrugStoreDO.getLatitude());
        double storeLongitude = Double.parseDouble(baseDrugStoreDO.getLongitude());
        double distance = countDistance.getDistance(Double.parseDouble(latitude),Double.parseDouble(longitude),storeLatitude,storeLongitude);
        baseDrugStoreDO.setDistance(distance);
        return baseDrugStoreDO;
    }
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java

@ -19,7 +19,7 @@ public interface SurveyUserAnswerDao extends PagingAndSortingRepository<WlyySurv
    List<WlyySurveyUserAnswerDO> findByTempQuestionCode(String tempQuestionCode);
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode);
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode,String surveyTempCode);
    @Query("SELECT DISTINCT c.patient from WlyySurveyUserAnswerDO c WHERE c.tempQuestionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findByTempQuestionCodeDistinctPatient(String tempQuestionCode,String surveyTempCode );

+ 4 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/survey/service/SurveyService.java

@ -649,7 +649,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                object.put("content",answerDOs);
                object.put("id",surveyUserDO.getSurveyTempCode());
            }
            this.sendImMsg(basePatientBusinessDO.getDoctor(), basePatientBusinessDO.getDoctorName(), basePatientBusinessDO.getSessionId(), "36", object.toJSONString(),"1");
            this.sendImMsg(basePatientBusinessDO.getPatient(), basePatientBusinessDO.getPatientName(), basePatientBusinessDO.getSessionId(), "36", object.toJSONString(),"1");
        }
        return true;
    }
@ -716,7 +716,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                if(optionVOs!=null&&optionVOs.size()>0){
                    for(WlyySurveyTemplateOptionVO vo:optionVOs){
                        Integer answerCount =0;
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId());
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId(),vo.getTemplateCode());
                        if(answerDOs!=null&&answerDOs.size()>0){
                            answerCount = answerDOs.size();
                        }
@ -815,7 +815,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " COUNT(1) AS total" +
                " FROM " +
                " wlyy_survey_user t " +
                " WHERE 1=1 ";
                " WHERE 1=1 and t.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            totalSql += " AND t.survey_temp_title like '%"+title+"%' ";
        }
@ -853,7 +853,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " FROM " +
                " wlyy_survey_user t " +
                " JOIN base_patient p ON t.patient = p.id " +
                " WHERE 1=1 ";
                " WHERE 1=1 and t.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            sql += " AND t.survey_temp_title like '%"+title+"%' ";
        }

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1290,6 +1290,7 @@ public class BaseHospitalRequestMapping {
        public static final String findWorkTimeInfo="/findWorkTimeInfo";
        public static final String findLevelOneDoctorUpcoming="/findLevelOneDoctorUpcoming";
        public static final String getUpcomingByDoctor="/getUpcomingByDoctor";
        public static final String checkOperateTime="/checkOperateTime";
    }
    /**

+ 1 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/ResultStatus.java

@ -16,6 +16,7 @@ public class ResultStatus {
    public static final Integer INVALID_GRANT = 1102; //授权失败,看具体报错信息,如验证码错误,密码错误等,  [登陆时候,用户不存在/应用不存在,归位此类,方便前端判断]
    public static final Integer NO_PERMI = 1103; //无权限访问
    public static final Integer INVALID_TOKEN = 1104;//被踢了 ,账号在别处登陆
    public static final Integer OPERATE_TIME=1105;//长时间未操作
    /**

+ 40 - 2
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -1,9 +1,13 @@
package com.yihu.jw.gateway.filter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.yihu.jw.gateway.methlog.BaseLoginLogService;
import com.yihu.jw.gateway.methlog.BaseMethodLogService;
import com.yihu.jw.gateway.useragent.UserAgent;
import com.yihu.jw.restmodel.ResultStatus;
import com.yihu.jw.restmodel.web.Envelop;
import org.slf4j.Logger;
@ -26,6 +30,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
@ -46,6 +51,13 @@ public class BasicZuulFilter extends ZuulFilter {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private BaseMethodLogService baseMethodLogService;
    @Autowired
    private BaseLoginLogService baseLoginLogService;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private RedisTokenStore redisTokenStore;
    @Override
    public String filterType() {
@ -97,6 +109,7 @@ public class BasicZuulFilter extends ZuulFilter {
                || url.contains("/image/")) {//获取默认图片
            return true;
        }
        System.out.println("进入token验证");
        return this.authenticate(ctx, request, url);
    }
@ -108,7 +121,9 @@ public class BasicZuulFilter extends ZuulFilter {
     * @return
     */
    private Object authenticate(RequestContext ctx, HttpServletRequest request, String path) {
        System.out.println("获取token");
        String accessToken = this.extractToken(request);
        System.out.println("获取token"+accessToken);
        if (null == accessToken) {
            return this.forbidden(ctx, ResultStatus.NULL_TOKEN, "token can not be null");
        }
@ -130,9 +145,10 @@ public class BasicZuulFilter extends ZuulFilter {
        }
        //获取所有token资源
        String resourceIds[] = urls.split(",");
        for (String resourceId : resourceIds) {
            if (resourceId.equals("/**")) {
                System.out.println("/**"+true);
                this.checkTimeout(oAuth2AccessToken);
                return true;
            }
            if (!resourceId.startsWith("/")) {
@ -141,12 +157,34 @@ public class BasicZuulFilter extends ZuulFilter {
            path = path.toLowerCase();
            if (path.startsWith(resourceId)
                    && (path.length() == resourceId.length() || path.charAt(resourceId.length()) == '/')) {
                System.out.println("158"+true);
                this.checkTimeout(oAuth2AccessToken);
                return true;
            }
        }
        //判断用户操作间隔
        String userId = userAgent.getUID();
        System.out.println(userId);
        Boolean checkTimeOut = baseLoginLogService.checkTime(userId);
        System.out.println("即将进入验证操作时间接口");
        if (!checkTimeOut){
            tokenStore.removeAccessToken(oAuth2AccessToken);
            return this.forbidden(ctx, ResultStatus.OPERATE_TIME, "expired token");
        }
        return this.forbidden(ctx, ResultStatus.NO_PERMI, "invalid token does not contain request resource " + path);
    }
    private void checkTimeout(OAuth2AccessToken oAuth2AccessToken){
        //判断用户操作间隔
        String userId = userAgent.getUID();
        System.out.println(userId);
        Boolean checkTimeOut = baseLoginLogService.checkTime(userId);
        System.out.println("即将进入验证操作时间接口");
        if (!checkTimeOut){
            tokenStore.removeAccessToken(oAuth2AccessToken);
            redisTokenStore.removeAccessToken(oAuth2AccessToken.getValue());
            redisTokenStore.removeRefreshToken(oAuth2AccessToken.getRefreshToken().getValue());
        }
    }
    private String extractToken(HttpServletRequest request) {
        String accessToken = request.getHeader(ACCESS_TOKEN_PARAMETER);
        if (null == accessToken) {

+ 18 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseLoginLogDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseLoginLogDao extends PagingAndSortingRepository<BaseLoginLogDO, String>, JpaSpecificationExecutor<BaseLoginLogDO> {
    @Query("from BaseLoginLogDO l where l.openid=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByOpenId(String openid);
    @Query("from BaseLoginLogDO l where l.userId=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByUserId(String openid);
}

+ 78 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseLoginLogService.java

@ -0,0 +1,78 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
@Service
@Transactional
public class BaseLoginLogService {
    @Autowired
    private BaseLoginLogDao baseLoginLogDao;
    /**
     * 根据openid 获取最新的一条数据
     * @param openid
     * @return
     */
    public BaseLoginLogDO findByOpenId(String openid) {
        List<BaseLoginLogDO> loginLogs = baseLoginLogDao.findByOpenId(openid);
        if(!CollectionUtils.isEmpty(loginLogs)){
            return loginLogs.get(0);
        }
        return null;
    }
    /*
     *根据userid获取数据
     *
     */
    public Boolean checkTime(String userId){
        List<BaseLoginLogDO> list = baseLoginLogDao.findByUserId(userId);
        long between = 0l;
        long timeOut = 1000*60*5;
        if (list.size()>0){
            BaseLoginLogDO baseLoginLogDO = list.get(0);
            Date optiondate = baseLoginLogDO.getOperateTime();
            //如果操作时间为空则拿创建时间比较
            if (null==optiondate){
                optiondate = baseLoginLogDO.getCreateTime();
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }else {
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }
        }else {
            return false;
        }
    }
}

+ 45 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/login/service/BaseLoginLogService.java

@ -3,13 +3,16 @@ package com.yihu.jw.security.login.service;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.security.login.dao.BaseLoginLogDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Date;
@Service
public class BaseLoginLogService<T, R extends CrudRepository> extends BaseJpaService<BaseLoginLogDO, BaseLoginLogDao> {
@ -27,6 +30,47 @@ public class BaseLoginLogService<T, R extends CrudRepository> extends BaseJpaSer
            return loginLogs.get(0);
        }
        return null;
    }
    /*
     *根据userid获取数据
     *
     */
    public Boolean checkTime(String userId){
        List<BaseLoginLogDO> list = baseLoginLogDao.findByUserId(userId);
        long between = 0l;
        long timeOut = 1000*60*5;
        if (list.size()>0){
            BaseLoginLogDO baseLoginLogDO = list.get(0);
            Date optiondate = baseLoginLogDO.getOperateTime();
            //如果操作时间为空则拿创建时间比较
            if (null==optiondate){
                optiondate = baseLoginLogDO.getCreateTime();
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }else {
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }
        }else {
            return false;
        }
    }
}

+ 0 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthYlzConfigService.java

@ -44,8 +44,6 @@ public class OauthYlzConfigService {
    @Autowired
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private FileUploadService fileUploadService;
    @Autowired
    private BasePatientDao basePatientDao;
//    @Value("${fastDFS.fastdfs_file_url}")

+ 6 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/drugstore/BaseDrugStoreEndpoint.java

@ -68,9 +68,13 @@ public class BaseDrugStoreEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseRequestMapping.drugStoreManage.findDrugstoreById)
    @ApiOperation(value = "药店id查询")
    public Envelop findDrugStoreById(@ApiParam(name = "id", value = "药店id")
    public Envelop findDrugStoreById(@ApiParam(name = "latitude", value = "经度")
                                         @RequestParam(value = "latitude", required = false) String latitude,
                                     @ApiParam(name = "longitude", value = "纬度")
                                         @RequestParam(value = "longitude", required = false) String longitude,
                                        @ApiParam(name = "id", value = "药店id")
                                     @RequestParam(value = "id", required = false) String id){
        BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreService.getById(id);
        BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreService.getById(id,latitude,longitude);
        if (null!=baseDrugStoreDO){
            return success(baseDrugStoreDO);
        }else {

+ 4 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -42,6 +42,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.WechatDao;
@ -138,6 +139,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private WechatDao wechatDao;
    private String successxml = "SUCCESS";
    private String failedxml = "FALSE";
@ -728,4 +730,6 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        String uri = qrcodeService.makeSpecialistQrcode(doctor);
        return success("操作成功",uri);
    }
}