Forráskód Böngészése

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

yeshijie 6 éve
szülő
commit
a8ecd3452e
28 módosított fájl, 575 hozzáadás és 157 törlés
  1. 2 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java
  2. 36 19
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  3. 232 0
      gateway/ag-basic/src/main/java/com/yihu/jw/security/core/userdetails/SaltUser.java
  4. 15 2
      gateway/ag-basic/src/main/resources/application.yml
  5. 7 3
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  6. 16 5
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  7. 3 3
      server/svr-authentication/src/main/resources/application.yml
  8. 3 3
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/constant/LoginInfo.java
  9. 6 6
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/LoginController.java
  10. 2 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictController.java
  11. 21 19
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictEntryController.java
  12. 7 5
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java
  13. 2 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesServerController.java
  14. 5 4
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/AppealController.java
  15. 56 11
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FacilityUsedRecordController.java
  16. 3 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FeedBackController.java
  17. 13 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/NavigationServiceEvaluationController.java
  18. 26 11
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/UserController.java
  19. 3 3
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/user/UserDao.java
  20. 25 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/FacilityUsedRecord.java
  21. 21 8
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/User.java
  22. 19 11
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityService.java
  23. 5 4
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/LoginService.java
  24. 4 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/NavigationServiceEvaluationService.java
  25. 4 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/UserService.java
  26. 29 29
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/util/facility/FacilityMsgReader.java
  27. 10 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/util/facility/msg/FacilityMsg.java
  28. BIN
      svr/svr-healthy-house/src/site/resources/健康小屋-设施列表导入模板.xlsx

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java

@ -99,6 +99,8 @@ public class HealthyHouseMapping {
            public static final String GET_FACILITY_USED_RECORD_AND_COUNT_BY_ID = "/getFacilityUsedRecordAndCountById";
            public static final String COUNT_FACILITY_USED_RECORD_BY_USERID = "/countFacilityUsedRecordByUserId";
            public static final String GET_FACILITY_USED_RECORD_DETAIL = "/getUsedRecordDetail";
            public static final String PAGE_FACILITY_USED_RECORD_BY_USERID = "/page/facilityUsedRecordsByUserId";
        }
        //服务评价

+ 36 - 19
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -10,12 +10,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@ -34,6 +36,8 @@ public class BasicZuulFilter extends ZuulFilter {
    private ObjectMapper objectMapper;
    @Autowired
    private TokenStore tokenStore;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Override
    public String filterType() {
@ -64,6 +68,13 @@ public class BasicZuulFilter extends ZuulFilter {
        return this.authenticate(ctx, request, url);
    }
    /**
     * 验证token 权限地址
     * @param ctx
     * @param request
     * @param path
     * @return
     */
    private Object authenticate(RequestContext ctx, HttpServletRequest request, String path) {
        String accessToken = this.extractToken(request);
        if (null == accessToken) {
@ -76,26 +87,32 @@ public class BasicZuulFilter extends ZuulFilter {
        if (oAuth2AccessToken.isExpired()) {
            return this.forbidden(ctx, HttpStatus.PAYMENT_REQUIRED.value(), "expired token"); //返回402 登陆过期
        }
//        //将token的认证信息附加到请求中,转发给下游微服务
//        OAuth2Authentication auth = tokenStore.readAuthentication(accessToken);
//        ctx.addZuulRequestHeader("x-auth-name", auth.getName());
//        //以下代码取消注释可开启Oauth2应用资源授权验证
        //将token的认证信息附加到请求中,转发给下游微服务
        OAuth2Authentication auth = tokenStore.readAuthentication(accessToken);
        ctx.addZuulRequestHeader("x-auth-name", auth.getName());
        //以下代码取消注释可开启Oauth2应用资源授权验证
//        Set<String> resourceIds = auth.getOAuth2Request().getResourceIds();
//        for (String resourceId : resourceIds) {
//            if (resourceId.equals("*")) {
//                return true;
//            }
//            if (!resourceId.startsWith("/")) {
//                resourceId = "/" + resourceId;
//            }
//            path = path.toLowerCase();
//            if (path.startsWith(resourceId)
//                    && (path.length() == resourceId.length() || path.charAt(resourceId.length()) == '/')) {
//                return true;
//            }
//        }
//        return this.forbidden(ctx, HttpStatus.FORBIDDEN.value(), "invalid token does not contain request resource " + path);
        return true;
        String urls = redisTemplate.opsForValue().get("wlyy2:auth:token:"+accessToken);
        if(StringUtils.isEmpty(urls)){
           return this.forbidden(ctx, HttpStatus.FORBIDDEN.value(), "invalid token does not contain request resource " + path);
        }
        //获取所有token资源
        String resourceIds[] = urls.split(",");
        for (String resourceId : resourceIds) {
            if (resourceId.equals("/**")) {
                return true;
            }
            if (!resourceId.startsWith("/")) {
                resourceId = "/" + resourceId;
            }
            path = path.toLowerCase();
            if (path.startsWith(resourceId)
                    && (path.length() == resourceId.length() || path.charAt(resourceId.length()) == '/')) {
                return true;
            }
        }
        return this.forbidden(ctx, HttpStatus.FORBIDDEN.value(), "invalid token does not contain request resource " + path);
    }
    private String extractToken(HttpServletRequest request) {

+ 232 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/security/core/userdetails/SaltUser.java

@ -0,0 +1,232 @@
package com.yihu.jw.security.core.userdetails;
import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.Assert;
import java.io.Serializable;
import java.util.*;
/**
 * Created by progr1mmer on 2018/8/29.
 */
public class SaltUser implements UserDetails, CredentialsContainer {
    private static final long serialVersionUID = 420L;
    private String password;
    private final String username;
    private final Set<GrantedAuthority> authorities;
    private final boolean accountNonExpired;
    private final boolean accountNonLocked;
    private final boolean credentialsNonExpired;
    private final boolean enabled;
    private final String salt;
    public SaltUser(String username, String password, String salt, Collection<? extends GrantedAuthority> authorities) {
        this(username, password, salt, true, true, true, true, authorities);
    }
    public SaltUser(String username, String password, String salt, boolean enabled, boolean locked, Collection<? extends GrantedAuthority> authorities) {
        this(username, password, salt, enabled, true, true, !locked, authorities);
    }
    public SaltUser(String username, String password, String salt, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
        if(username != null && !"".equals(username) && password != null) {
            this.username = username;
            this.password = password;
            this.salt = salt;
            this.enabled = enabled;
            this.accountNonExpired = accountNonExpired;
            this.credentialsNonExpired = credentialsNonExpired;
            this.accountNonLocked = accountNonLocked;
            this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));
        } else {
            throw new IllegalArgumentException("Cannot pass null or empty values to constructor");
        }
    }
    public Collection<GrantedAuthority> getAuthorities() {
        return this.authorities;
    }
    public String getPassword() {
        return this.password;
    }
    public String getUsername() {
        return this.username;
    }
    public String getSalt() {
        return salt;
    }
    public boolean isEnabled() {
        return this.enabled;
    }
    public boolean isAccountNonExpired() {
        return this.accountNonExpired;
    }
    public boolean isAccountNonLocked() {
        return this.accountNonLocked;
    }
    public boolean isCredentialsNonExpired() {
        return this.credentialsNonExpired;
    }
    public void eraseCredentials() {
        this.password = null;
    }
    private static SortedSet<GrantedAuthority> sortAuthorities(Collection<? extends GrantedAuthority> authorities) {
        Assert.notNull(authorities, "Cannot pass a null GrantedAuthority collection");
        SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet(new SaltUser.AuthorityComparator());
        Iterator var2 = authorities.iterator();
        while(var2.hasNext()) {
            GrantedAuthority grantedAuthority = (GrantedAuthority)var2.next();
            Assert.notNull(grantedAuthority, "GrantedAuthority list cannot contain any null elements");
            sortedAuthorities.add(grantedAuthority);
        }
        return sortedAuthorities;
    }
    public boolean equals(Object rhs) {
        return rhs instanceof SaltUser ?this.username.equals(((SaltUser)rhs).username):false;
    }
    public int hashCode() {
        return this.username.hashCode();
    }
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.toString()).append(": ");
        sb.append("Username: ").append(this.username).append("; ");
        sb.append("Password: [PROTECTED]; ");
        sb.append("Enabled: ").append(this.enabled).append("; ");
        sb.append("AccountNonExpired: ").append(this.accountNonExpired).append("; ");
        sb.append("credentialsNonExpired: ").append(this.credentialsNonExpired).append("; ");
        sb.append("AccountNonLocked: ").append(this.accountNonLocked).append("; ");
        if(!this.authorities.isEmpty()) {
            sb.append("Granted Authorities: ");
            boolean first = true;
            Iterator var3 = this.authorities.iterator();
            while(var3.hasNext()) {
                GrantedAuthority auth = (GrantedAuthority)var3.next();
                if(!first) {
                    sb.append(",");
                }
                first = false;
                sb.append(auth);
            }
        } else {
            sb.append("Not granted any authorities");
        }
        return sb.toString();
    }
    public static SaltUser.UserBuilder withUsername(String username) {
        return (new SaltUser.UserBuilder()).username(username);
    }
    public static class UserBuilder {
        private String username;
        private String password;
        private List<GrantedAuthority> authorities;
        private boolean accountExpired;
        private boolean accountLocked;
        private boolean credentialsExpired;
        private boolean disabled;
        private UserBuilder() {
        }
        private SaltUser.UserBuilder username(String username) {
            Assert.notNull(username, "username cannot be null");
            this.username = username;
            return this;
        }
        public SaltUser.UserBuilder password(String password) {
            Assert.notNull(password, "password cannot be null");
            this.password = password;
            return this;
        }
        public SaltUser.UserBuilder roles(String... roles) {
            List<GrantedAuthority> authorities = new ArrayList(roles.length);
            String[] var3 = roles;
            int var4 = roles.length;
            for(int var5 = 0; var5 < var4; ++var5) {
                String role = var3[var5];
                Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)");
                authorities.add(new SimpleGrantedAuthority("ROLE_" + role));
            }
            return this.authorities((List)authorities);
        }
        public SaltUser.UserBuilder authorities(GrantedAuthority... authorities) {
            return this.authorities(Arrays.asList(authorities));
        }
        public SaltUser.UserBuilder authorities(List<? extends GrantedAuthority> authorities) {
            this.authorities = new ArrayList(authorities);
            return this;
        }
        public SaltUser.UserBuilder authorities(String... authorities) {
            return this.authorities(AuthorityUtils.createAuthorityList(authorities));
        }
        public SaltUser.UserBuilder accountExpired(boolean accountExpired) {
            this.accountExpired = accountExpired;
            return this;
        }
        public SaltUser.UserBuilder accountLocked(boolean accountLocked) {
            this.accountLocked = accountLocked;
            return this;
        }
        public SaltUser.UserBuilder credentialsExpired(boolean credentialsExpired) {
            this.credentialsExpired = credentialsExpired;
            return this;
        }
        public SaltUser.UserBuilder disabled(boolean disabled) {
            this.disabled = disabled;
            return this;
        }
        public UserDetails build() {
            return new User(this.username, this.password, !this.disabled, !this.accountExpired, !this.credentialsExpired, !this.accountLocked, this.authorities);
        }
    }
    private static class AuthorityComparator implements Comparator<GrantedAuthority>, Serializable {
        private static final long serialVersionUID = 420L;
        private AuthorityComparator() {
        }
        public int compare(GrantedAuthority g1, GrantedAuthority g2) {
            return g2.getAuthority() == null?-1:(g1.getAuthority() == null?1:g1.getAuthority().compareTo(g2.getAuthority()));
        }
    }
}

+ 15 - 2
gateway/ag-basic/src/main/resources/application.yml

@ -19,6 +19,15 @@ spring:
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  redis:
    database: 0 # Database index used by the connection factory.
    timeout: 0 # Connection timeout in milliseconds.
    pool:
      max-active: 8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
      max-idle: 8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
      max-wait: -1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
      min-idle: 1 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
#  sleuth:
#    sampler:
#      percentage: 1.0 #采用需要的请求的百分比 默认是0.1 即 10%
@ -33,10 +42,10 @@ zuul:
      serviceId: svr-iot
    svr-base:
      path: /base/**
      serviceId: svr-base
      serviceId: svr-base-lyx
    svr-authentication:
      path: /auth/**
      serviceId: svr-authentication
      serviceId: svr-authentication-lyx
---
spring:
@ -45,6 +54,10 @@ spring:
    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#  zipkin:
#    base-url: http://localhost:9411 #日志追踪的地址

+ 7 - 3
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -5,7 +5,7 @@ import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.security.core.GrantedAuthority;
@ -13,6 +13,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -22,6 +23,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * Service - 用户信息
@ -243,10 +245,12 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    }
    public boolean setRolePhth(String loginType, String token, String id, RedisTemplate redisTemplate){
    public boolean setRolePhth(String loginType, OAuth2AccessToken token, String id, StringRedisTemplate redisTemplate){
        if(org.apache.commons.lang.StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
            String key = "wlyy2:auth:token:"+token.getValue();
            redisTemplate.opsForValue().set(key,"/**");
            redisTemplate.expire(key,token.getExpiresIn(), TimeUnit.SECONDS);
        }else if("2".equals(loginType)){//2.为医生账号
        }else if("3".equals(loginType)){ //3.患者账号

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

@ -1,23 +1,27 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.model.Captcha;
import com.yihu.jw.security.model.Oauth2Envelop;
import com.yihu.jw.security.model.PublicKey;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.model.Oauth2Envelop;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.utils.security.RSAUtils;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.*;
import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;
import org.springframework.security.oauth2.common.exceptions.InvalidRequestException;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
import org.springframework.security.oauth2.common.exceptions.UnsupportedGrantTypeException;
import org.springframework.security.oauth2.provider.*;
import org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint;
import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
@ -80,6 +84,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private RestTemplate restTemplate;
    @Autowired
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @PostConstruct
    private void init() {
@ -149,6 +155,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        userDetailsService.setRolePhth(loginType,token,wlyyUserSimple.getId(),redisTemplate);
        return getResponse(wlyyUserSimple);
    }

+ 3 - 3
server/svr-authentication/src/main/resources/application.yml

@ -32,7 +32,7 @@ spring:
    username: root
    password: 123456
  redis:
    host: 172.19.103.47
    port: 6379
    password: redis!@456
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr

+ 3 - 3
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/constant/LoginInfo.java

@ -18,8 +18,8 @@ public class LoginInfo {
    public static final String SAVE_TYPE_PHONE = "phoneLogin";//手机登录注册
    //用户类型
    public static final String USER_TYPE_PATIENT = "Patient";//居民
    public static final String USER_TYPE_AdminManager = "AdminManager";//超管
    public static final String USER_TYPE_Server = "Server";//运营维护
    public static final String USER_TYPE_PATIENT = "patient";//居民
    public static final String USER_TYPE_SUPER_AdminManager = "superAdmin";//超管
    public static final String USER_TYPE_Server = "admin";//运营维护
}

+ 6 - 6
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/LoginController.java

@ -62,18 +62,18 @@ public class LoginController extends EnvelopRestEndpoint {
    @PostMapping("/mobile/login")
    @ApiOperation(value = "【普通用户】-手机登录注册")
    public ObjEnvelop mobileLogin(
    public ObjEnvelop<User> mobileLogin(
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha) throws ManageException, ParseException {
        if (wlyyRedisVerifyCodeService.verification(clientId, username, captcha)) {
            User user = loginService.phoneLogin(request,username);
            ObjEnvelop envelop = new ObjEnvelop();
            envelop.setStatus(200);
            envelop.setMessage("登录成功");
            envelop.setObj(user);
            return envelop;
//            ObjEnvelop envelop = new ObjEnvelop();
//            envelop.setStatus(200);
//            envelop.setMessage("登录成功");
//            envelop.setObj(user);
            return success(user);
        } else {
            return ObjEnvelop.getError("验证码错误");

+ 2 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictController.java

@ -47,8 +47,8 @@ public class SystemDictController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<SystemDict> systemDictList = dictService.search(fields, filters, sorts, page, size);
        Long count = (long) (null == systemDictList ? 0 : systemDictList.size());
        return success(systemDictList, count.intValue(), page, size);
        int count = (int)dictService.getCount(filters);
        return success(systemDictList, count, page, size);
    }
    @ApiOperation(value = "创建字典")

+ 21 - 19
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictEntryController.java

@ -14,6 +14,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import java.io.IOException;
import java.util.*;
@ -45,19 +46,20 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<SystemDictEntry> systemDictEntryList = systemDictEntryService.search(fields,filters,sorts,page,size);
        return success(systemDictEntryList,(null==systemDictEntryList)?0:systemDictEntryList.size(),page, size);
        List<SystemDictEntry> systemDictEntryList = systemDictEntryService.search(fields, filters, sorts, page, size);
        int count = (int) systemDictEntryService.getCount(filters);
        return success(systemDictEntryList, count, page, size);
    }
    @ApiOperation(value = "创建字典项")
    @PostMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.CREATE)
    public ObjEnvelop<SystemDictEntry> createDictEntry (
    public ObjEnvelop<SystemDictEntry> createDictEntry(
            @ApiParam(name = "entryJson", value = "字典项JSON结构")
            @RequestParam(value = "entryJson") String entryJson) throws IOException{
            @RequestParam(value = "entryJson") String entryJson) throws IOException {
        SystemDictEntry entry = toEntity(entryJson, SystemDictEntry.class);
        SystemDict systemDict = dictService.retrieve(entry.getDictId());
        if (systemDict == null) {
            return  failed("所属字典不存在!",ObjEnvelop.class);
            return failed("所属字典不存在!", ObjEnvelop.class);
        }
        int nextSort = systemDictEntryService.getNextSN(entry.getDictId());
        entry.setSort(nextSort);
@ -72,7 +74,7 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
            @ApiParam(name = "dictId", value = "字典ID", required = true)
            @RequestParam(value = "dictId") String dictId,
            @ApiParam(name = "code", value = "字典项代码", required = true)
            @RequestParam(value = "code") String code) throws Exception{
            @RequestParam(value = "code") String code) throws Exception {
        SystemDictEntry systemDictEntry = systemDictEntryService.getDictEntry(dictId, code);
        return success(systemDictEntry);
    }
@ -83,46 +85,46 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
            @ApiParam(name = "dictId", value = "字典ID")
            @RequestParam(value = "dictId") String dictId,
            @ApiParam(name = "code", value = "字典项编码")
            @RequestParam(value = "code") String code) throws Exception{
            @RequestParam(value = "code") String code) throws Exception {
        systemDictEntryService.deleteDictEntry(dictId, code);
        return success("success");
    }
    @ApiOperation(value = "修改字典项")
    @PutMapping(value =HealthyHouseMapping.HealthyHouse.SystemDictEntry.UPDATE)
    @PutMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.UPDATE)
    public ObjEnvelop<SystemDictEntry> updateDictEntry(
            @ApiParam(name = "entryJson", value = "字典项JSON结构")
            @RequestParam(value = "entryJson") String entryJson) throws IOException {
        SystemDictEntry entry = toEntity(entryJson, SystemDictEntry.class);
        SystemDictEntry temp = systemDictEntryService.retrieve(new DictEntryKey(entry.getCode(), entry.getDictId()));
        if (null == temp) {
            failed("字典项不存在!",ObjEnvelop.class);
            failed("字典项不存在!", ObjEnvelop.class);
        }
        entry.setUpdateTime(new Date());
        systemDictEntryService.saveDictEntry(entry);
        return success(entry);
    }
    @GetMapping(value =HealthyHouseMapping.HealthyHouse.SystemDictEntry.ISEXISTSDICTENTRYBYDICTIDANDCODE)
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.ISEXISTSDICTENTRYBYDICTIDANDCODE)
    @ApiOperation(value = "根据dictId和code判断提交的字典项是否已经存在")
    public boolean isDictEntryCodeExists(
            @ApiParam(name = "dictId", value = "字典id", defaultValue = "")
            @RequestParam(value = "dictId",required = true) String dictId,
            @RequestParam(value = "dictId", required = true) String dictId,
            @ApiParam(name = "code", value = "字典项编码", defaultValue = "")
            @RequestParam(value = "code") String code){
            @RequestParam(value = "code") String code) {
        return systemDictEntryService.isDictContainEntry(dictId, code);
    }
    @GetMapping(value =HealthyHouseMapping.HealthyHouse.SystemDictEntry.GETDICTENTRYBYDICTIDANDNAME)
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.SystemDictEntry.GETDICTENTRYBYDICTIDANDNAME)
    @ApiOperation(value = "根据dictId和name判断提交的字典项是否已经存在")
    public boolean isDictEntryNameExists(
            @ApiParam(name = "dictId", value = "字典id", defaultValue = "")
            @RequestParam(value = "dictId",required = true) String dictId,
            @RequestParam(value = "dictId", required = true) String dictId,
            @ApiParam(name = "name", value = "字典项名称")
            @RequestParam(value = "name") String name){
        List<SystemDictEntry> systemDictEntryPage= systemDictEntryService.findByDictIdAndValueLike(dictId, name);
        if(null!=systemDictEntryPage&&systemDictEntryPage.size()>0){
            return  true;
            @RequestParam(value = "name") String name) {
        List<SystemDictEntry> systemDictEntryPage = systemDictEntryService.findByDictIdAndValueLike(dictId, name);
        if (null != systemDictEntryPage && systemDictEntryPage.size() > 0) {
            return true;
        }
        return false;
    }
@ -131,7 +133,7 @@ public class SystemDictEntryController extends EnvelopRestEndpoint {
    @ApiOperation(value = "根据dictId获取所有字典项")
    public ListEnvelop GetSystemDictEntryListByDictId(
            @ApiParam(name = "dictId", value = "字典id")
            @RequestParam(value = "dictId") String dictId) throws Exception{
            @RequestParam(value = "dictId") String dictId) throws Exception {
        List<SystemDictEntry> cardList = systemDictEntryService.getDictEntryCodeAndValueByDictId(dictId);
        return success(cardList);
    }

+ 7 - 5
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java

@ -1,6 +1,5 @@
package com.yihu.jw.healthyhouse.controller.facilities;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.facility.FacilityServer;
@ -24,10 +23,8 @@ import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yihu.jw.restmodel.web.Envelop;
@ -69,7 +66,8 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<Facility> facilityList = facilityService.search(fields, filters, sorts, page, size);
        return success(facilityList, (null == facilityList) ? 0 : facilityList.size(), page, size);
        int count = (int)facilityService.getCount(filters);
        return success(facilityList, count, page, size);
    }
    @ApiOperation(value = "创建设施,包含设施与服务的关联关系")
@ -289,7 +287,11 @@ public class FacilitiesController extends EnvelopRestEndpoint {
    @PostMapping(value = "/batchImport")
    @ApiOperation(value = "设施列表导入(经纬度重复的不导入)")
    public ObjEnvelop importData(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException, ManageException {
    public ObjEnvelop importData(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            HttpServletRequest request,
            HttpServletResponse response) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
            AExcelReader excelReader = new FacilityMsgReader();

+ 2 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesServerController.java

@ -46,7 +46,8 @@ public class FacilitiesServerController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<FacilityServer> facilityServerList = facilityServerService.search(fields, filters, sorts, page, size);
        return success(facilityServerList, (null==facilityServerList)?0:facilityServerList.size(), page, size);
        int count = (int)facilityServerService.getCount(filters);
        return success(facilityServerList,count, page, size);
    }
    @ApiOperation(value = "创建设施服务")

+ 5 - 4
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/AppealController.java

@ -46,7 +46,8 @@ public class AppealController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<Appeal> appealList = AppealService.search(fields, filters, sorts, page, size);
        return success(appealList, (null == appealList) ? 0 : appealList.size(), page, size);
        int count = (int)AppealService.getCount(filters);
        return success(appealList, count, page, size);
    }
    @ApiOperation(value = "创建/更新(id存在)账号申诉")
@ -54,9 +55,9 @@ public class AppealController extends EnvelopRestEndpoint {
    public ObjEnvelop<Appeal> createAppeal(
            @ApiParam(name = "Appeal", value = "账号申诉JSON结构")
            @RequestBody Appeal appeal) throws IOException {
        if(StringUtils.isEmpty(appeal.getCreateUser())){
            return failed("账号申诉人(createUser)不能为空!",ObjEnvelop.class);
        }
//        if(StringUtils.isEmpty(appeal.getCreateUser())){
//            return failed("账号申诉人(createUser)不能为空!",ObjEnvelop.class);
//        }
        appeal = AppealService.save(appeal);
        return success(appeal);
    }

+ 56 - 11
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FacilityUsedRecordController.java

@ -1,11 +1,16 @@
package com.yihu.jw.healthyhouse.controller.user;
import com.google.common.base.Joiner;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.model.facility.FacilityServerRelation;
import com.yihu.jw.healthyhouse.model.user.FacilityUsedRecord;
import com.yihu.jw.healthyhouse.model.user.NavigationServiceEvaluation;
import com.yihu.jw.healthyhouse.service.facility.FacilityServerRelationService;
import com.yihu.jw.healthyhouse.service.facility.FacilityService;
import com.yihu.jw.healthyhouse.service.user.FacilityUsedRecordService;
import com.yihu.jw.healthyhouse.service.user.NavigationServiceEvaluationService;
import com.yihu.jw.healthyhouse.service.user.UserService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -18,12 +23,14 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -41,6 +48,10 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
    private UserService userService;
    @Autowired
    private FacilityService facilityService;
    @Autowired
    private NavigationServiceEvaluationService navigationServiceEvaluationService;
    @Autowired
    private FacilityServerRelationService facilityServerRelationService;
    @ApiOperation(value = "获取用户使用导航记录列表--分页(web)", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.PAGE)
@ -56,16 +67,18 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<FacilityUsedRecord> facilityUsedRecordList = facilityUsedRecordService.search(fields, filters, sorts, page, size);
        return success(facilityUsedRecordList, (null == facilityUsedRecordList) ? 0 : facilityUsedRecordList.size(), page, size);
        int count = (int) facilityUsedRecordService.getCount(filters);
        return success(facilityUsedRecordList, count, page, size);
    }
    @ApiOperation(value = "创建/更新(id存在)用户使用导航记录")
    @Transactional(rollbackFor = Exception.class)
    @PostMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.CREATE)
    public ObjEnvelop<FacilityUsedRecord> createFacilityUsedRecord(
            @ApiParam(name = "facilityUsedRecord", value = "用户使用导航记录JSON结构")
            @RequestBody FacilityUsedRecord facilityUsedRecord) throws IOException, ManageException {
        facilityUsedRecord = facilityUsedRecordService.save(facilityUsedRecord);
        userService.updateFacilityUse(facilityUsedRecord.getUserId());
        userService.updateFacilityUse(facilityUsedRecord.getCreateUser());
        return success(facilityUsedRecord);
    }
@ -108,19 +121,19 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
            @ApiParam(name = "userId", value = "用户ID", defaultValue = "")
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "filters", value = "检索字段", defaultValue = "")
            @RequestParam(value = "filters",required = false) String filters,
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "nearbyFlag", value = "是否为“附近”的功能", defaultValue = "false")
            @RequestParam(value = "nearbyFlag") boolean nearbyFlag) throws Exception {
        List<FacilityUsedRecord> facilityUsedRecordList =new ArrayList<>();
        List<FacilityUsedRecord> facilityUsedRecordList = new ArrayList<>();
        FacilityUsedRecord facilityUsedRecord;
        if(nearbyFlag){
            if(StringUtils.isNotEmpty(filters)){
                filters=  "name?"+filters+" g1;cityName?"+filters+" g1;countyName?"+filters+" g1;street?"+filters+" g1";
        if (nearbyFlag) {
            if (StringUtils.isNotEmpty(filters)) {
                filters = "name?" + filters + " g1;cityName?" + filters + " g1;countyName?" + filters + " g1;street?" + filters + " g1;address?"  + filters + " g1";
            }
            //获取所有设施,并根据设施编码及用户id查找使用次数
            List<Facility> facilityList = facilityService.search(filters);
            for(Facility facility:facilityList){
                facilityUsedRecord=new FacilityUsedRecord();
            for (Facility facility : facilityList) {
                facilityUsedRecord = new FacilityUsedRecord();
                facilityUsedRecord.setFacilitieCode(facility.getCode());
                facilityUsedRecord.setFacilitieName(facility.getName());
                facilityUsedRecord.setFacilitieLongitude(facility.getLongitude());
@ -129,10 +142,10 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
                facilityUsedRecord.setCreateUser(userId);
                facilityUsedRecord.setFacilitieId(facility.getId());
                long count = facilityUsedRecordService.countByFacilitieCodeAndUserId(facility.getCode(), userId);
                facilityUsedRecord.setNum((int)count);
                facilityUsedRecord.setNum((int) count);
                facilityUsedRecordList.add(facilityUsedRecord);
            }
        }else{
        } else {
            //根据用户id,获取我的历史记录
            facilityUsedRecordList = facilityUsedRecordService.countDistinctByFacilitieCodeAndUserId(userId);
            for (FacilityUsedRecord facilityUsedRecord1 : facilityUsedRecordList) {
@ -170,5 +183,37 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
        return success(usedRecordDetail);
    }
    @ApiOperation(value = "获取用户使用导航记录列表--分页(app)", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.PAGE_FACILITY_USED_RECORD_BY_USERID)
    public PageEnvelop<FacilityUsedRecord> getFacilityUsedRecordsByUserId(
            @ApiParam(name = "userId", value = "必输参数:登录用户id", defaultValue = "")
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "-createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        String filters = "createUser=" + userId;
        sorts = "-createTime";
        List<FacilityUsedRecord> facilityUsedRecordList = facilityUsedRecordService.search("", filters, sorts, page, size);
        for (FacilityUsedRecord record : facilityUsedRecordList) {
            //根据设施编码获取关联服务的名称
            String facilityCode = record.getFacilitieCode();
            List<FacilityServerRelation> facilityServerRelations = facilityServerRelationService.findByField("facilitieCode", facilityCode);
            List<String> services = facilityServerRelations.stream().map(FacilityServerRelation::getServiceName).collect(Collectors.toList());
            String servicesValue = Joiner.on("、").join(services);
            record.setFacilityRelationServiceName(servicesValue);
            //根据记录获取评价记录
            NavigationServiceEvaluation comment = navigationServiceEvaluationService.findByUseRecordId(record.getId());
            if (comment == null) {
                record.setNavigationServiceEvaluationFlag("未评价");
            } else {
                record.setNavigationServiceEvaluationFlag("已评价");
            }
        }
        int count = (int) facilityUsedRecordService.getCount(filters);
        return success(facilityUsedRecordList, count, page, size);
    }
}

+ 3 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FeedBackController.java

@ -53,7 +53,8 @@ public class FeedBackController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<FeedBack> feedBackList = feedBackService.search(fields, filters, sorts, page, size);
        return success(feedBackList, (null == feedBackList) ? 0 : feedBackList.size(), page, size);
        int count = (int)feedBackService.getCount(filters);
        return success(feedBackList,count, page, size);
    }
    @ApiOperation(value = "创建/更新(id存在)意见反馈")
@ -78,7 +79,7 @@ public class FeedBackController extends EnvelopRestEndpoint {
    }
    @ApiOperation(value = "管理员根据id获取/或回复意见反馈,需改变意见反馈回复状态")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FeedBack.UPDATE_FEEDBACKS_BY_ID)
    @PostMapping(value = HealthyHouseMapping.HealthyHouse.FeedBack.UPDATE_FEEDBACKS_BY_ID)
    public ObjEnvelop<FeedBack> getFeedBackAndUpdate(
            @ApiParam(name = "id", value = "意见反馈ID(必要)", defaultValue = "")
            @RequestParam(value = "id", required = true) String id,

+ 13 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/NavigationServiceEvaluationController.java

@ -46,7 +46,8 @@ public class NavigationServiceEvaluationController extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) Integer page) throws Exception {
        List<NavigationServiceEvaluation> navigationServiceEvaluationList = navigationServiceEvaluationService.search(fields, filters, sorts, page, size);
        return success(navigationServiceEvaluationList, (null == navigationServiceEvaluationList) ? 0 : navigationServiceEvaluationList.size(), page, size);
        int count = (int) navigationServiceEvaluationService.getCount(filters);
        return success(navigationServiceEvaluationList, count, page, size);
    }
    @ApiOperation(value = "创建/更新(id存在)服务评价")
@ -54,7 +55,17 @@ public class NavigationServiceEvaluationController extends EnvelopRestEndpoint {
    public ObjEnvelop<NavigationServiceEvaluation> createNavigationServiceEvaluation(
            @ApiParam(name = "navigationServiceEvaluation", value = "服务评价JSON结构")
            @RequestBody NavigationServiceEvaluation navigationServiceEvaluation) throws IOException {
        navigationServiceEvaluation = navigationServiceEvaluationService.save(navigationServiceEvaluation);
        //判断该导航记录是否已经评价
        NavigationServiceEvaluation navi = navigationServiceEvaluationService.findByUseRecordId(navigationServiceEvaluation.getUseRecordId());
        if (null != navi) {
            navi.setScore(navigationServiceEvaluation.getScore());
            navi.setRemark(navigationServiceEvaluation.getRemark());
            navigationServiceEvaluation = navigationServiceEvaluationService.save(navi);
        } else {
            navigationServiceEvaluation = navigationServiceEvaluationService.save(navigationServiceEvaluation);
        }
        return success(navigationServiceEvaluation);
    }

+ 26 - 11
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/UserController.java

@ -10,6 +10,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.wlyy.HouseUserContant;
import com.yihu.jw.rm.health.house.HealthyHouseMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -64,7 +65,8 @@ public class UserController  extends EnvelopRestEndpoint {
            @RequestParam(value = "page", required = false) Integer page ) throws ManageException, ParseException {
        List<User> userList = userService.search(fields, filters, sorts, page, size);
        return success(userList, userList == null ? 0 : userList.size(), page, size);
        int count = (int)userService.getCount(filters);
        return success(userList,count, page, size);
    }
@ -84,28 +86,41 @@ public class UserController  extends EnvelopRestEndpoint {
        return ObjEnvelop.getSuccess("获取成功",userStatistics);
    }
    @PostMapping("/activateUser")
    @ApiOperation(value = "用户激活")
    public Envelop activeUser(
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "operator", value = "操作者", required = true)@RequestParam(required = true, name = "operator") String operator ) {
         userService.updateStatus(userId,operator, HouseUserContant.activated_active,null);
        return ObjEnvelop.getSuccess("激活成功");
    }
    @ApiOperation(value = "新增/更新(idy已存在)用户信息")
    @PostMapping(value = "saveOrUpdate")
    public ObjEnvelop<User> saveOrUpdateUser(
            @ApiParam(name = "user", value = "用户JSON结构")
            @RequestBody User user) throws Exception {
        if (org.apache.commons.lang3.StringUtils.isEmpty(user.getName())) {
            return failed("用户名称不能为空!", ObjEnvelop.class);
        }
        user = userService.save(user);
        return success(user);
    }
    @PostMapping("/freezeUser")
    @ApiOperation(value = "用户冻结")
    public Envelop freezeUser(
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "reason", value = "冻结原因", required = true)@RequestParam(required = true, name = "reason") String reason ,
            @ApiParam(name = "operator", value = "操作者", required = true)@RequestParam(required = true, name = "operator") String operator ) {
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
        userService.updateStatus(userId,operator, HouseUserContant.activated_lock,reason);
        return ObjEnvelop.getSuccess("冻结成功");
    }
    @PostMapping("/activateUser")
    @ApiOperation(value = "用户激活")
    public Envelop activeUser(
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
        userService.updateStatus(userId,operator, HouseUserContant.activated_active,null);
        return ObjEnvelop.getSuccess("激活成功");
    }
    @PostMapping("/updatePwd")
    @ApiOperation(value = "更新密码")
    public Envelop updatePwd(
@ -153,7 +168,7 @@ public class UserController  extends EnvelopRestEndpoint {
            @ApiParam(name = "activated", value = "用户状态", required = false)@RequestParam(required = false, name = "activated") String activated ,
            @ApiParam(name = "name", value = "姓名/手机号", required = false)@RequestParam(required = false, name = "name") String name ,
            @ApiParam(name = "sort", value = "使用次数排序", required = false)@RequestParam(required = false, name = "sort") String sort) throws ManageException {
        Envelop envelop = new Envelop();
        response.setCharacterEncoding("UTF-8");
        //获取用户数据
        Map<String, String> map = new HashMap<>();
        map.put("cityCode",city);

+ 3 - 3
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/user/UserDao.java

@ -15,14 +15,14 @@ import java.util.Date;
 */
public interface UserDao extends PagingAndSortingRepository<User, String>, JpaSpecificationExecutor<User> {
    @Query("from User u where u.id=?1 and u.activated<>0 ")
    User findByIdAndActivated(String id,String activated);
    User findById(String id);
    @Query("from User u where u.loginCode=?1 and u.activated<>0 ")
    User findByLoginCode(String loginCode);
    @Query("from User u where u.name=?1 and u.activated<>0 ")
    User findByName(String name);
    @Query("from User u where u.name=?1 and u.activated=?2 ")
    User findByNameAAndActivated(String name,String activated);
    @Override
    @Transactional

+ 25 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/FacilityUsedRecord.java

@ -7,6 +7,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/**
 * 用户导航记录
@ -41,10 +42,10 @@ public class FacilityUsedRecord extends UuidIdentityEntityWithOperator {
    //设施id
    @Column(name = "facilitie_id")
    private String facilitieId;
    //服务编码
    //使用的服务编码--冗余
    @Column(name = "service_code")
    private String serviceCode;
    //服务名称
    //使用的服务名称--冗余
    @Column(name = "service_name")
    private String serviceName;
    //导航时长
@ -61,6 +62,12 @@ public class FacilityUsedRecord extends UuidIdentityEntityWithOperator {
    @Column(name = "num")
    private Integer num;
    //设施关联的服务名称
    private String facilityRelationServiceName;
    //评价记录
    private String navigationServiceEvaluationFlag;
    public double getUserInitialLongitude() {
        return userInitialLongitude;
    }
@ -172,4 +179,20 @@ public class FacilityUsedRecord extends UuidIdentityEntityWithOperator {
    public void setFacilitieId(String facilitieId) {
        this.facilitieId = facilitieId;
    }
    @Transient
    public String getFacilityRelationServiceName() {
        return facilityRelationServiceName;
    }
    public void setFacilityRelationServiceName(String facilityRelationServiceName) {
        this.facilityRelationServiceName =facilityRelationServiceName;
    }
    @Transient
    public String getNavigationServiceEvaluationFlag() {
        return navigationServiceEvaluationFlag;
    }
    public void setNavigationServiceEvaluationFlag(String navigationServiceEvaluationFlag) {
        this.navigationServiceEvaluationFlag = navigationServiceEvaluationFlag;
    }
}

+ 21 - 8
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/User.java

@ -24,10 +24,10 @@ public class User extends UuidIdentityEntityWithOperator {
    private String name;
    @Column(name = "password", nullable = false)
    private String password;
    @Column(name = "gender" )
    @Column(name = "gender")
    private String gender;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    @Column(name = "birthday" )
    @Column(name = "birthday")
    private Date birthday;
    @Column(name = "id_card_no", nullable = false)
    private String idCardNo;
@ -255,17 +255,30 @@ public class User extends UuidIdentityEntityWithOperator {
    }
    @Transient
    public String getAddress(){
        String address ="";
        if (this.getCityName()!=null) {
    public String getAddress() {
        String address = "";
        if (this.getCityName() != null) {
            address += this.getCityName();
        }
        if (this.getAreaName()!=null) {
        if (this.getAreaName() != null) {
            address += this.getAreaName();
        }
        if (this.getStreet() !=null ){
        if (this.getStreet() != null) {
            address += this.getStreet();
        }
        return address;
    }
}
    @Transient
    public String getGenderValue() {
        String genderValue = "";
        if (null != this.getGender() && this.getGender().equals("male")) {
            genderValue = "男";
        }
        if (null != this.getGender() && this.getGender().equals("female")) {
            genderValue = "女";
        }
        return genderValue;
    }
}

+ 19 - 11
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityService.java

@ -123,15 +123,16 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
                row=j+1;
                ExcelUtils.addCellData(sheet,0,row,j+1+"");//序号
                ExcelUtils.addCellData(sheet,1,row, metaData.getCode());//设施编码
                ExcelUtils.addCellData(sheet,2,row, metaData.getCategory().toString());//类型名称
                ExcelUtils.addCellData(sheet,3,row, metaData.getAddress());//信息地址
                ExcelUtils.addCellData(sheet,4,row, metaData.getUserName());//联系人
                ExcelUtils.addCellData(sheet,5,row, metaData.getUserTelephone());//联系电话
                ExcelUtils.addCellData(sheet,6,row, metaData.getProvinceId());//省
                ExcelUtils.addCellData(sheet,7,row, metaData.getCityName());//市
                ExcelUtils.addCellData(sheet,8,row, metaData.getCountyName());//区县
                ExcelUtils.addCellData(sheet,9,row, metaData.getStreet());//街道
                ExcelUtils.addCellData(sheet,10,row, metaData.getStatus());//运营状态
                ExcelUtils.addCellData(sheet,2,row, metaData.getName());//设施名称
                ExcelUtils.addCellData(sheet,3,row, metaData.getCategory().toString());//类型名称
                ExcelUtils.addCellData(sheet,4,row, metaData.getAddress());//信息地址
                ExcelUtils.addCellData(sheet,5,row, metaData.getUserName());//联系人
                ExcelUtils.addCellData(sheet,6,row, metaData.getUserTelephone());//联系电话
                ExcelUtils.addCellData(sheet,7,row, metaData.getProvinceId());//省
                ExcelUtils.addCellData(sheet,8,row, metaData.getCityName());//市
                ExcelUtils.addCellData(sheet,9,row, metaData.getCountyName());//区县
                ExcelUtils.addCellData(sheet,10,row, metaData.getStreet());//街道
                ExcelUtils.addCellData(sheet,11,row, metaData.getStatus());//运营状态
            }
@ -147,7 +148,7 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
    /**
     * 批量存储的集合
     * 批量导入设施的集合
     * @param facilities    设施列表
     */
    public Map<String,Object> batchInsertFacility(List<FacilityMsg> facilities) throws ManageException{
@ -167,6 +168,7 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            String townCode = baseTownService.getCodeByname(facilityMsg.getCounty());
            Integer categoryCode = systemDictEntryService.getDictEntryCodeByName("FacilityType",facilityMsg.getCategory());
            facility.setCode(genFacilityCode());
            facility.setName(facilityMsg.getName());
            facility.setCategory(categoryCode);
            facility.setCategoryValue(facilityMsg.getCategory());
            facility.setUserName(facilityMsg.getUserName());
@ -212,7 +214,13 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
     * @return
     */
    public String genFacilityCode(){
        return "CSHF" + randomString(5);
        String code = "CSHF" + randomString(5);
        Facility facility = facilityDao.findByCode(code);
        while (facility!=null) {
            code = "CSHF" + randomString(5);
            facility = facilityDao.findByCode(code);
        }
        return code;
    }
    /**

+ 5 - 4
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/LoginService.java

@ -1,7 +1,6 @@
package com.yihu.jw.healthyhouse.service.user;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.sms.SmsGatewayDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
@ -25,7 +24,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -64,6 +62,7 @@ public class LoginService  extends BaseJpaService {
            // 更新身份证验证字段
            user.setPhoneAuthentication(UserConstant.AUTHORIZED);
            user.setPassword(LoginInfo.DEFAULT_PASSWORD);
            user.setUserType(LoginInfo.USER_TYPE_PATIENT);
        }
        //已注册用户更改用户状态
        user.setActivated(HouseUserContant.activated_active);
@ -101,6 +100,8 @@ public class LoginService  extends BaseJpaService {
                user.setGender((String) data.get("gender"));
                user.setIdCardNo((String) data.get("idcard"));
                user.setTelephone((String) data.get("mobile"));
                user.setUserType(LoginInfo.USER_TYPE_PATIENT);
                user.setIjkAuthentication(UserConstant.AUTHORIZED);
            } else {
                String message = "账号不存在";
@ -264,7 +265,7 @@ public class LoginService  extends BaseJpaService {
    @Transactional(noRollbackForClassName = "ManageException")
    public User managerPhoneLogin(HttpServletRequest request, String loginCode) throws ManageException {
        //判断管理员用户信息是否存在
        User user = userService.findByLoginCodeAndUserType(loginCode, LoginInfo.USER_TYPE_AdminManager);
        User user = userService.findByLoginCodeAndUserType(loginCode, LoginInfo.USER_TYPE_SUPER_AdminManager);
        if (user == null) {
            throw new ManageException("该管理员账号不存在!");
        } else {
@ -294,7 +295,7 @@ public class LoginService  extends BaseJpaService {
    @Transactional(noRollbackForClassName = "ManageException")
    public User managerLogin(HttpServletRequest request, String clientId, String loginCode, String password) throws ManageException {
        //判断登陆信息是否正确
        User user = userService.findByCode(loginCode);
        User user = userService.findByLoginCodeAndUserType(loginCode, LoginInfo.USER_TYPE_SUPER_AdminManager);
        if (user == null) {
            String message = "该管理员账号不存在!";
            throw new ManageException(message);

+ 4 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/NavigationServiceEvaluationService.java

@ -25,4 +25,8 @@ public class NavigationServiceEvaluationService extends BaseJpaService<Navigatio
        return  navigationServiceEvaluationDao.findById(id);
    }
    public NavigationServiceEvaluation findByUseRecordId(String useRecordId) {
        return  navigationServiceEvaluationDao.findByUseRecordId(useRecordId);
    }
}

+ 4 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/UserService.java

@ -151,9 +151,12 @@ public class UserService extends BaseJpaService<User, UserDao> {
     * @param reason   更改状态原因
     */
    @Transactional
    public void updateStatus(String id, String userCode, Integer status, String reason) {
    public void updateStatus(String id, String userCode, Integer status, String reason) throws ManageException {
        User user = userDao.findByLoginCode(userCode);
        User user1 = findById(id);
        if (user1 == null) {
            throw new ManageException("激活用户不存在!");
        }
        user1.setActivated(status);
        user1.setActivatedContent(reason);
        if (user != null) {

+ 29 - 29
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/util/facility/FacilityMsgReader.java

@ -30,56 +30,56 @@ public class FacilityMsgReader extends AExcelReader {
                for (int i = 1; i <= rows; i++) {
                    facilityMsg = new FacilityMsg();
                    //设施编码
//                    if(null != getCellCont(sheet, i, 2)){
//                        //去除空格、回车、换行、制表符
//                        facilityMsg.setCode(replaceBlank(getCellCont(sheet, i, 1)));
//                    }else{
//                        facilityMsg.setCode(getCellCont(sheet, i, 1));
//                    }
                    //设施名称
                    if(null != getCellCont(sheet, i, 0)){
                        //去除空格、回车、换行、制表符
                        facilityMsg.setName(replaceBlank(getCellCont(sheet, i, 0)));
                    }else{
                        facilityMsg.setName(getCellCont(sheet, i, 0));
                    }
                    //设施类型名称
                    if(null != getCellCont(sheet, i, 0)){
                    if(null != getCellCont(sheet, i, 1)){
                        //去除空格、回车、换行、制表符
                        facilityMsg.setCategory(replaceBlank(getCellCont(sheet, i, 0)));
                        facilityMsg.setCategory(replaceBlank(getCellCont(sheet, i, 1)));
                    }else{
                        facilityMsg.setCategory(getCellCont(sheet, i, 0));
                        facilityMsg.setCategory(getCellCont(sheet, i, 1));
                    }
                    facilityMsg.setUserName(getCellCont(sheet, i, 1));
                    facilityMsg.setUserTelePhone(getCellCont(sheet, i, 2));
                    facilityMsg.setUserName(getCellCont(sheet, i, 2));
                    facilityMsg.setUserTelePhone(getCellCont(sheet, i, 3));
                    //省
                    if(null != getCellCont(sheet, i, 3)){
                    if(null != getCellCont(sheet, i, 4)){
                        //去除空格、回车、换行、制表符
                        facilityMsg.setProvince(replaceBlank(getCellCont(sheet, i, 3)));
                        facilityMsg.setProvince(replaceBlank(getCellCont(sheet, i, 4)));
                    }else{
                        facilityMsg.setProvince(getCellCont(sheet, i, 3));
                        facilityMsg.setProvince(getCellCont(sheet, i, 4));
                    }
                    //市
                    if(null != getCellCont(sheet, i, 4)){
                    if(null != getCellCont(sheet, i, 5)){
                        //去除空格、回车、换行、制表符
                        facilityMsg.setCity(replaceBlank(getCellCont(sheet, i, 4)));
                        facilityMsg.setCity(replaceBlank(getCellCont(sheet, i, 5)));
                    }else{
                        facilityMsg.setCity(getCellCont(sheet, i, 4));
                        facilityMsg.setCity(getCellCont(sheet, i, 5));
                    }
                    //区
                    if(null != getCellCont(sheet, i, 5)){
                    if(null != getCellCont(sheet, i, 6)){
                        //去除空格、回车、换行、制表符
                        facilityMsg.setCounty(replaceBlank(getCellCont(sheet, i, 5)));
                        facilityMsg.setCounty(replaceBlank(getCellCont(sheet, i, 6)));
                    }else{
                        facilityMsg.setCounty(getCellCont(sheet, i, 5));
                        facilityMsg.setCounty(getCellCont(sheet, i, 6));
                    }
                    facilityMsg.setStreet(getCellCont(sheet, i, 6));
                    facilityMsg.setStatus(getCellCont(sheet, i, 7));
                    facilityMsg.setOrgName(getCellCont(sheet, i, 8));
                    facilityMsg.setServiceDate(getCellCont(sheet, i, 9));
                    facilityMsg.setServiceStartTime(getCellCont(sheet, i, 10));
                    facilityMsg.setServiceEndTime(getCellCont(sheet, i, 11));
                    facilityMsg.setLongitude(getCellCont(sheet, i, 12));
                    facilityMsg.setLatitude(getCellCont(sheet, i, 13));
                    facilityMsg.setStreet(getCellCont(sheet, i, 7));
                    facilityMsg.setStatus(getCellCont(sheet, i, 8));
                    facilityMsg.setOrgName(getCellCont(sheet, i, 9));
                    facilityMsg.setServiceDate(getCellCont(sheet, i, 10));
                    facilityMsg.setServiceStartTime(getCellCont(sheet, i, 11));
                    facilityMsg.setServiceEndTime(getCellCont(sheet, i, 12));
                    facilityMsg.setLongitude(getCellCont(sheet, i, 13));
                    facilityMsg.setLatitude(getCellCont(sheet, i, 14));
                    facilityMsg.setExcelSeq(i);
                    correctLs.add(facilityMsg);

+ 10 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/util/facility/msg/FacilityMsg.java

@ -52,10 +52,11 @@ public class FacilityMsg extends ExcelUtil implements Validation {
    String longitude; //经度
    @Location(x=15)
    String latitude; //纬度
    @Location(x=16)
    String name; //设施名称
    int hashCode;
    @Override
    public int validate(Map<String, Set> repeatMap) {
        int rs = 1;
@ -264,4 +265,12 @@ public class FacilityMsg extends ExcelUtil implements Validation {
    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

BIN
svr/svr-healthy-house/src/site/resources/健康小屋-设施列表导入模板.xlsx