Quellcode durchsuchen

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

LiTaohong vor 6 Jahren
Ursprung
Commit
f31747023c
27 geänderte Dateien mit 880 neuen und 177 gelöschten Zeilen
  1. 78 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/notice/NoticeDO.java
  2. 57 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/notice/UserNoticeDO.java
  3. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java
  4. 76 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/notice/NoticeVO.java
  5. 86 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/notice/UserNoticeVO.java
  6. 14 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/notice/NoticeDao.java
  7. 14 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/notice/UserNoticeDao.java
  8. 16 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/notice/NoticeService.java
  9. 16 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/notice/UserNoticeService.java
  10. 28 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/cache/Receiver.java
  11. 68 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/config/RedisConfig.java
  12. 12 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/constant/SystemDictConstant.java
  13. 70 49
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/LoginController.java
  14. 24 15
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java
  15. 31 5
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesServerController.java
  16. 8 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FacilityUsedRecordController.java
  17. 4 6
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FeedBackController.java
  18. 87 21
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/UserController.java
  19. 1 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/facility/FacilityDao.java
  20. 1 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/user/FacilityUsedRecordDao.java
  21. 6 3
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/user/UserDao.java
  22. 25 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/listener/MyKeyExpirationEventMessageListener.java
  23. 1 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/User.java
  24. 85 59
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityService.java
  25. 1 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/FacilityUsedRecordService.java
  26. 18 6
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/LoginService.java
  27. 52 8
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/UserService.java

+ 78 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/notice/NoticeDO.java

@ -0,0 +1,78 @@
package com.yihu.jw.entity.base.notice;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 公告通知
 * @author yeshijie on 2018/9/30.
 */
@Entity
@Table(name = "base_notice")
public class NoticeDO extends UuidIdentityEntityWithOperator{
    private String title;//公告标题
    private Integer status;//状态(1待发布,2已发布)
    private Date sendTime;//发布时间
    private String content;//公告内容
    private Integer sendType;//发布方式(1手动发布,2自动发布)
    private Integer del;//删除标志(1正常,0删除)
    @Column(name = "title")
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "send_time")
    public Date getSendTime() {
        return sendTime;
    }
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }
    @Column(name = "send_type")
    public Integer getSendType() {
        return sendType;
    }
    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 57 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/notice/UserNoticeDO.java

@ -0,0 +1,57 @@
package com.yihu.jw.entity.base.notice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 用户公告通知
 * @author yeshijie on 2018/9/30.
 */
@Entity
@Table(name = "base_user_notice")
public class UserNoticeDO extends UuidIdentityEntity{
    private String noticeId;//公告id
    private String userId;//用户id
    private Integer isRead;//是否已读(1已读,0未读)
    private Integer del;//删除标志(1正常,0删除)
    @Column(name = "notice_id")
    public String getNoticeId() {
        return noticeId;
    }
    public void setNoticeId(String noticeId) {
        this.noticeId = noticeId;
    }
    @Column(name = "user_id")
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    @Column(name = "is_read")
    public Integer getIsRead() {
        return isRead;
    }
    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

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

@ -71,6 +71,7 @@ public class HealthyHouseMapping {
            public static final String GET_FACILITIESERVERS_BY_ID = "/getFacilitieServersById";
            public static final String GET_FACILITIESERVERS_BY_FIELD = "/getFacilitieServersByField";
            public static final String LIST_FACILITIESERVERS = "/list/listFacilitieServers";
            public static final String LIST_FACILITIESERVERS_BY_TYPE = "/list/listFacilitieServersByType";
        }
        //意见反馈

+ 76 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/notice/NoticeVO.java

@ -0,0 +1,76 @@
package com.yihu.jw.restmodel.base.notice;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 *
 * @author yeshijie on 2018/9/30.
 */
@ApiModel(value = "NoticeVO", description = "公告通知")
public class NoticeVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "公告标题", example = "标题")
    private String title;
    @ApiModelProperty(value = "状态(1待发布,2已发布)", example = "1")
    private Integer status;
    @ApiModelProperty(value = "发布时间", example = "2019-01-01 12:20:59")
    private Date sendTime;
    @ApiModelProperty(value = "公告内容", example = "内容")
    private String content;
    @ApiModelProperty(value = "发布方式(1手动发布,2自动发布)", example = "1")
    private Integer sendType;
    @ApiModelProperty(value = "删除标志(1正常,0删除)", example = "1")
    private Integer del;
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getSendTime() {
        return sendTime;
    }
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Integer getSendType() {
        return sendType;
    }
    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 86 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/notice/UserNoticeVO.java

@ -0,0 +1,86 @@
package com.yihu.jw.restmodel.base.notice;
import com.yihu.jw.entity.UuidIdentityEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 *
 * @author yeshijie on 2018/9/30.
 */
@ApiModel(value = "UserNoticeVO", description = "用户公告通知")
public class UserNoticeVO extends UuidIdentityEntity{
    @ApiModelProperty(value = "公告id", example = "公告id")
    private String noticeId;
    @ApiModelProperty(value = "用户id", example = "用户id")
    private String userId;
    @ApiModelProperty(value = "是否已读(1已读,0未读)", example = "1")
    private Integer isRead;
    @ApiModelProperty(value = "删除标志(1正常,0删除)", example = "1")
    private Integer del;
    @ApiModelProperty(value = "公告标题", example = "标题")
    private String title;
    @ApiModelProperty(value = "发布时间", example = "2019-01-01 12:20:59")
    private Date sendTime;
    @ApiModelProperty(value = "公告内容", example = "内容")
    private String content;
    public String getNoticeId() {
        return noticeId;
    }
    public void setNoticeId(String noticeId) {
        this.noticeId = noticeId;
    }
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    public Integer getIsRead() {
        return isRead;
    }
    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public Date getSendTime() {
        return sendTime;
    }
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
}

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/notice/NoticeDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.dao.notice;
import com.yihu.jw.entity.base.notice.NoticeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 公告通知
 * @author yeshijie on 2018/9/30.
 */
public interface NoticeDao extends PagingAndSortingRepository<NoticeDO, String>, JpaSpecificationExecutor<NoticeDO> {
}

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/notice/UserNoticeDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.dao.notice;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 用户公告通知
 * @author yeshijie on 2018/9/30.
 */
public interface UserNoticeDao extends PagingAndSortingRepository<UserNoticeDO, String>, JpaSpecificationExecutor<UserNoticeDO> {
}

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/notice/NoticeService.java

@ -0,0 +1,16 @@
package com.yihu.jw.base.service.notice;
import com.yihu.jw.base.dao.notice.NoticeDao;
import com.yihu.jw.entity.base.notice.NoticeDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * 公告通知
 * @author yeshijie on 2018/9/30.
 */
@Service
public class NoticeService extends BaseJpaService<NoticeDO, NoticeDao> {
}

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/notice/UserNoticeService.java

@ -0,0 +1,16 @@
package com.yihu.jw.base.service.notice;
import com.yihu.jw.base.dao.notice.UserNoticeDao;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * 用户公告通知
 * @author yeshijie on 2018/9/30.
 */
@Service
public class UserNoticeService extends BaseJpaService<UserNoticeDO, UserNoticeDao> {
}

+ 28 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/cache/Receiver.java

@ -0,0 +1,28 @@
package com.yihu.jw.healthyhouse.cache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.concurrent.CountDownLatch;
/**
 * @author HZY
 * @created 2018/10/8 15:05
 */
public class Receiver {
    private static final Logger LOGGER = LoggerFactory.getLogger(Receiver.class);
    private CountDownLatch latch;
    @Autowired
    public Receiver(CountDownLatch latch) {
        this.latch = latch;
    }
    public void receiveMessage(String message) {
        LOGGER.info("Received <" + message + ">");
        latch.countDown();
    }
    }

+ 68 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/config/RedisConfig.java

@ -0,0 +1,68 @@
package com.yihu.jw.healthyhouse.config;
import com.yihu.jw.healthyhouse.cache.Receiver;
import org.springframework.boot.SpringApplication;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import java.util.concurrent.CountDownLatch;
/**
 * @author HZY
 * @created 2018/10/8 15:12
 */
@Configuration
public class RedisConfig  {
    /*
     * Redis消息监听器容器
     * 这个容器加载了RedisConnectionFactory和消息监听器
     */
    @Bean
    RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory,
                                            MessageListenerAdapter listenerAdapter){
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        container.addMessageListener(listenerAdapter, new PatternTopic("sprinboot-redis-messaage"));
        return container;
    }
    /*
     * 将Receiver注册为一个消息监听器,并指定消息接收的方法(receiveMessage)
     * 如果不指定消息接收的方法,消息监听器会默认的寻找Receiver中的handleMessage这个方法作为消息接收的方法
     */
    @Bean
    MessageListenerAdapter listenerAdapter(Receiver receiver){
        return new MessageListenerAdapter(receiver, "receiveMessage");
    }
    /*
     * Receiver实例
     */
    @Bean
    Receiver receiver(CountDownLatch latch){
        return new Receiver(latch);
    }
    @Bean
    CountDownLatch latch(){
        return new CountDownLatch(1);
    }
    /*
     * Redis Template 用来发送消息
     */
    @Bean
    StringRedisTemplate template(RedisConnectionFactory connectionFactory){
        return new StringRedisTemplate(connectionFactory);
    }
}

+ 12 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/constant/SystemDictConstant.java

@ -0,0 +1,12 @@
package com.yihu.jw.healthyhouse.constant;
/**
 * @author zdm
 * @created 2018/10/8 9:10
 */
public class SystemDictConstant {
    //设施服务
    public static final String FACILITIE_SERVERS_TYPE_DICT_ID = "7";
}

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

@ -4,9 +4,11 @@ import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.service.user.LoginService;
import com.yihu.jw.healthyhouse.service.user.UserService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.wlyy.HouseUserContant;
import com.yihu.jw.util.security.RandomValidateCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -37,27 +39,35 @@ public class LoginController extends EnvelopRestEndpoint {
    private RestTemplate restTemplate;
    @Autowired
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @Autowired
    private UserService userService;
    /******************************************    用户相关    **********************************/
    @ApiOperation(value = "发送短信验证码")
    @GetMapping(value = "/captcha/send")
    public ResponseEntity<HashMap> captcha(
            @ApiParam(name = "clientId", value = "应用id",defaultValue = "EwC0iRSrcS", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "msgType", value = "消息类型(login:登录验证,checkPhone:验证安全手机,resetPhone:重设安全手机", required = true)@RequestParam(required = true, name = "msgType") String msgType,
            @ApiParam(name = "username", value = "手机账号", required = true)@RequestParam(required = true, name = "username") String username ) throws  Exception{
            @ApiParam(name = "clientId", value = "应用id", defaultValue = "EwC0iRSrcS", required = true) @RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "msgType", value = "消息类型(login:登录验证,checkPhone:验证安全手机,resetPhone:重设安全手机", required = true) @RequestParam(required = true, name = "msgType") String msgType,
            @ApiParam(name = "userType", value = "账号类型(patient:普通账号,superAdmin:炒鸡管理员", required = true) @RequestParam(required = true, name = "userType") String userType,
            @ApiParam(name = "username", value = "手机账号", required = true) @RequestParam(required = true, name = "username") String username) throws Exception {
        if (StringUtils.isEmpty(clientId)) {
            failed("clientId 为空!");
        }
        if (StringUtils.isEmpty(username)){
        if (StringUtils.isEmpty(username)) {
            failed("username 为空!");
        }
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(clientId, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        //验证用户是否被冻结
        User user = userService.findByTelephoneAndUserType(username,userType);
        if (HouseUserContant.activated_lock.equals(user)) {
            failed("该用户已被冻结,无法发送验证码!");
        }
        //验证请求间隔超时,防止频繁获取验证码
//        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(clientId, username)) {
//            throw new IllegalAccessException("SMS request frequency is too fast");
//        }
        //发送短信获取验证码
        ResponseEntity<HashMap> result = loginService.sendSms(clientId,msgType,username);
        ResponseEntity<HashMap> result = loginService.sendDemoSms(clientId,msgType,username);
        return result;
    }
@ -66,9 +76,9 @@ public class LoginController extends EnvelopRestEndpoint {
    @ApiOperation(value = "验证短信验证码")
    public Envelop checkCaptcha(
            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 {
            @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)) {
            return success("验证码正确");
        } else {
@ -80,15 +90,16 @@ public class LoginController extends EnvelopRestEndpoint {
    @ApiOperation(value = "【普通用户】-手机登录注册")
    public Envelop 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 {
            @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 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);
            User user = null;
            try {
                user = loginService.phoneLogin(request, username);
            } catch (ManageException e) {
                return failed(e.getMessage());
            }
            return success(user);
        } else {
@ -100,13 +111,18 @@ public class LoginController extends EnvelopRestEndpoint {
    @ApiOperation(value = "【普通用户】-i健康用户登陆")
    public Envelop ijkLogin(
            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 = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
        User user = loginService.iJklogin(request,clientId,username, password);
        if (user !=null) {
            return success("登录成功",user);
        }else {
            @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 = "password", value = "密码", required = true) @RequestParam(required = true, name = "password") String password) {
        User user = null;
        try {
            user = loginService.iJklogin(request, clientId, username, password);
        } catch (ManageException e) {
            failed(e.getMessage());
        }
        if (user != null) {
            return success("登录成功", user);
        } else {
            return failed("登录失败");
        }
    }
@ -115,10 +131,10 @@ public class LoginController extends EnvelopRestEndpoint {
    @ApiOperation(value = "登出")
    public Envelop loginout(
            HttpServletRequest request,
            @ApiParam(name = "userCode", value = "用户code", required = true)@RequestParam(required = true, name = "userCode") String userCode) {
            @ApiParam(name = "userCode", value = "用户code", required = true) @RequestParam(required = true, name = "userCode") String userCode) {
        try {
            //修改用户状态  离线
           return success("登出成功");
            return success("登出成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("登出失败");
@ -132,17 +148,17 @@ public class LoginController extends EnvelopRestEndpoint {
    @ApiOperation(value = "【管理员】-手机验证登录")
    public Envelop administratorMobileLogin(
            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 ParseException {
            @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 ParseException {
        if (wlyyRedisVerifyCodeService.verification(clientId, username, captcha)) {
            User user = null;
            try {
                user = loginService.managerPhoneLogin(request,username);
                user = loginService.managerPhoneLogin(request, username);
            } catch (ManageException e) {
                return failed(e.getMessage());
            }
            return success("登录成功",user);
            return success("登录成功", user);
        } else {
            return failed("验证码错误");
        }
@ -152,20 +168,25 @@ public class LoginController extends EnvelopRestEndpoint {
    @ApiOperation(value = "【管理员】-用户账号登陆")
    public Envelop administratorLogin(
            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 = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
        User user = loginService.managerLogin(request,clientId,username, password);
        if (user !=null) {
            return success("登录成功",user);
        }else {
            return failed("登录失败");
            @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 = "password", value = "密码", required = true) @RequestParam(required = true, name = "password") String password) {
        try {
            User user = loginService.managerLogin(request, clientId, username, password);
            if (user != null) {
                return success("登录成功", user);
            } else {
                return failed("登录失败");
            }
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
    }
    @GetMapping(value = "/getRandomImageCode")
    @ApiOperation(value = "修改密码时生成图形验证码",notes = "修改密码时生成图形验证码")
    public Envelop getImageCode (HttpServletRequest request, HttpServletResponse response)throws Exception{
    @ApiOperation(value = "修改密码时生成图形验证码", notes = "修改密码时生成图形验证码")
    public Envelop getImageCode(HttpServletRequest request, HttpServletResponse response) throws Exception {
        try {
            response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
            response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容
@ -180,17 +201,17 @@ public class LoginController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = "/checkRandomImageCode")
    @ApiOperation(value = "检验图片验证码",notes = "检验图片验证码")
    public Envelop checkImageCode(@ApiParam(name = "code",value = "输入的验证码")@RequestParam(value = "code",required = true)String code,
                                     HttpServletRequest request){
        if (StringUtils.isEmpty(code)){
    @ApiOperation(value = "检验图片验证码", notes = "检验图片验证码")
    public Envelop checkImageCode(@ApiParam(name = "code", value = "输入的验证码") @RequestParam(value = "code", required = true) String code,
                                  HttpServletRequest request) {
        if (StringUtils.isEmpty(code)) {
            return failed("请输入验证码!");
        }
        String codeRescource = String.valueOf(request.getSession().getAttribute(RandomValidateCode.RANDOMCODEKEY));
        if (code.toLowerCase().equals(codeRescource.toLowerCase())){
        if (code.toLowerCase().equals(codeRescource.toLowerCase())) {
            request.getSession().removeAttribute(RandomValidateCode.RANDOMCODEKEY);
            return success("验证码正确!");
        }else {
        } else {
            return failed("验证码错误!");
        }
    }

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

@ -66,7 +66,7 @@ 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);
        int count = (int)facilityService.getCount(filters);
        int count = (int) facilityService.getCount(filters);
        return success(facilityList, count, page, size);
    }
@ -77,7 +77,7 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            @ApiParam(name = "facility", value = "设施JSON结构")
            @RequestParam(value = "facility") String facility,
            @ApiParam(name = "facilityServerJson", value = "设施关联的服务字符串用,号隔开")
            @RequestParam(value = "facilityServerJson") String facilityServerJson) throws IOException {
            @RequestParam(value = "facilityServerJson") String facilityServerJson) throws Exception {
        Facility facility1 = toEntity(facility, Facility.class);
        List<Facility> facilityList = null;
        if (StringUtils.isEmpty(facility1.getCode())) {
@ -120,28 +120,29 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            @ApiParam(name = "facilityServerJson", value = "设施关联的服务字符串用,号隔开")
            @RequestParam(value = "facilityServerJson") String facilityServerJson) throws Exception {
        Facility facility1 = toEntity(facility, Facility.class);
        List<Facility> facilityList = null;
        List<Facility> faList = facilityService.findByField("id", facility1.getId());
        if (!(faList != null && faList.size() > 0)) {
        Facility facility2 = facilityService.findById(facility1.getId());
        if (null == facility2) {
            return failed("设施不存在!", ObjEnvelop.class);
        }
        facility1.setCreateTime(facility2.getCreateTime());
        if (StringUtils.isNotEmpty(facility1.getId())) {
            //删除设施,设施关联关系,设施服务使用设施数
            deleteFacilityByCode(facility1);
        }
        if (StringUtils.isEmpty(facility1.getCode())) {
            return failed("设施编码不能为空!", ObjEnvelop.class);
        } else {
            facilityList = facilityService.findByField("code", facility1.getCode());
            if (null != facilityList && facilityList.size() > 0) {
            boolean existFlag = facilityService.checkFacilityByFacilityId(facility1.getId(),"code",facility1.getCode());
            if (existFlag) {
                return failed("设施编码已存在!", ObjEnvelop.class);
            }
        }
        if (StringUtils.isEmpty(facility1.getName())) {
            return failed("设施名称不能为空!", ObjEnvelop.class);
        } else {
            facilityList = facilityService.findByField("name", facility1.getName());
            if (null != facilityList && facilityList.size() > 0) {
            boolean existFlag = facilityService.checkFacilityByFacilityId(facility1.getId(),"name",facility1.getName());;
            if (existFlag) {
                return failed("设施名称已存在!", ObjEnvelop.class);
            }
        }
@ -302,7 +303,7 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            }
        } catch (Exception e) {
            throw new ManageException("导入设施列表异常!", e);
            return failed("导入异常");
        }
        return failed("导入失败");
    }
@ -327,16 +328,25 @@ public class FacilitiesController extends EnvelopRestEndpoint {
        if (StringUtils.isNotEmpty(facilityServerCodes)) {
            String[] faServerCodes = facilityServerCodes.split(",");
            List<String> facilityCodeList = facilityService.getFacilityCodeByServerCode(faServerCodes);
            facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
            if (null != facilityCodeList && facilityCodeList.size() > 0) {
                facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
            }
        } else if (StringUtils.isNotEmpty(facilityServerType)) {
            //设施编码为空,设施服务类型不为空,按设施服务类型获取设施
            List<String> facilityCodeList = facilityService.getFacilityCodeByServerType(facilityServerType);
            facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
            if (null != facilityCodeList && facilityCodeList.size() > 0) {
                facilityList = facilityService.getFacilityByFacilityCode(facilityCodeList);
            }
        } else if (StringUtils.isNotEmpty(facilityCategory)) {
            //设施编码为空,设施服务类型为空,按照设施分类获取按设施服务类型获取设施
            filters = "category=" + facilityCategory;
            filters = "category=" + facilityCategory + ";status=0;";
            facilityList = facilityService.search(fields, filters, sorts);
        } else {
            if (StringUtils.isEmpty(filters)) {
                filters = "status=0;";
            } else {
                filters = filters + ";status=0;";
            }
            facilityList = facilityService.search(fields, filters, sorts);
        }
        return success(facilityList);
@ -396,7 +406,6 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            }
        }
        facilityServerRelationService.deleteByFacilitieCode(facility.getCode());
        facilityService.delete(facility);
    }
    /**
@ -406,7 +415,7 @@ public class FacilitiesController extends EnvelopRestEndpoint {
     * @param facilityServerJson 设施服务编码
     * @return
     */
    public List<FacilityServerRelation> createRelationByServerCode(Facility facility1, String facilityServerJson) {
    public List<FacilityServerRelation> createRelationByServerCode(Facility facility1, String facilityServerJson) throws Exception{
        List<FacilityServerRelation> list = new ArrayList<>();
        if (StringUtils.isNotEmpty(facilityServerJson)) {
            //设施编码

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

@ -1,6 +1,9 @@
package com.yihu.jw.healthyhouse.controller.facilities;
import com.yihu.jw.healthyhouse.constant.SystemDictConstant;
import com.yihu.jw.healthyhouse.model.dict.SystemDictEntry;
import com.yihu.jw.healthyhouse.model.facility.FacilityServer;
import com.yihu.jw.healthyhouse.service.dict.SystemDictEntryService;
import com.yihu.jw.healthyhouse.service.facility.FacilityServerService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -17,7 +20,9 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -31,9 +36,11 @@ public class FacilitiesServerController extends EnvelopRestEndpoint {
    @Autowired
    private FacilityServerService facilityServerService;
    @Autowired
    private SystemDictEntryService systemDictEntryService;
    @ApiOperation(value = "获取设施服务列表", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.PAGE )
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.PAGE)
    public PageEnvelop<FacilityServer> getFacilitiesServer(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
@ -46,12 +53,12 @@ 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);
        int count = (int)facilityServerService.getCount(filters);
        return success(facilityServerList,count, page, size);
        int count = (int) facilityServerService.getCount(filters);
        return success(facilityServerList, count, page, size);
    }
    @ApiOperation(value = "创建设施服务")
    @PostMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.CREATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ObjEnvelop<FacilityServer> createFacilitiesServer(
            @ApiParam(name = "FacilityServer", value = "设施服务JSON结构")
            @RequestBody FacilityServer facilityServer) throws IOException {
@ -134,7 +141,7 @@ public class FacilitiesServerController extends EnvelopRestEndpoint {
    }
    @ApiOperation(value = "获取设施服务列表", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.LIST_FACILITIESERVERS )
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.LIST_FACILITIESERVERS)
    public ListEnvelop<FacilityServer> getFacilitiesServer(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
@ -146,5 +153,24 @@ public class FacilitiesServerController extends EnvelopRestEndpoint {
        return success(facilityServerList);
    }
    @ApiOperation(value = "app按照分类获取-设施服务列表", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilitiesServer.LIST_FACILITIESERVERS_BY_TYPE)
    public ObjEnvelop<Map> getFacilitiesServerByType() throws Exception {
        Map<String, List<FacilityServer>> map = new HashMap<>();
        List<FacilityServer> facilityServerList;
        //获取系统字典-设施服务类型
        List<SystemDictEntry> systemDictEntryList = systemDictEntryService.getDictEntryCodeAndValueByDictId(SystemDictConstant.FACILITIE_SERVERS_TYPE_DICT_ID);
        for (Object object : systemDictEntryList) {
            Object[] obj=(Object[])object;
            if(null!=obj[0]&&StringUtils.isNotEmpty(obj[0].toString()) ){
                String filters = "type=" + obj[0].toString();
                facilityServerList = facilityServerService.search("", filters, "");
                map.put(obj[0].toString(), facilityServerList);
            }
        }
        return success(map);
    }
}

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

@ -77,6 +77,7 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
    public ObjEnvelop<FacilityUsedRecord> createFacilityUsedRecord(
            @ApiParam(name = "facilityUsedRecord", value = "用户使用导航记录JSON结构")
            @RequestBody FacilityUsedRecord facilityUsedRecord) throws IOException, ManageException {
        facilityUsedRecord.setUserId(facilityUsedRecord.getCreateUser());
        facilityUsedRecord = facilityUsedRecordService.save(facilityUsedRecord);
        userService.updateFacilityUse(facilityUsedRecord.getCreateUser());
        return success(facilityUsedRecord);
@ -128,7 +129,9 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
        FacilityUsedRecord facilityUsedRecord;
        if (nearbyFlag) {
            if (StringUtils.isNotEmpty(filters)) {
                filters = "name?" + filters + " g1;cityName?" + filters + " g1;countyName?" + filters + " g1;street?" + filters + " g1;address?"  + filters + " g1";
                filters =  "status=0;"+"name?" + filters + " g1;cityName?" + filters + " g1;countyName?" + filters + " g1;street?" + filters + " g1;address?"  + filters + " g1;";
            }else{
                filters =  "status=0;";
            }
            //获取所有设施,并根据设施编码及用户id查找使用次数
            List<Facility> facilityList = facilityService.search(filters);
@ -140,6 +143,7 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
                facilityUsedRecord.setFacilitieLatitudes(facility.getLatitude());
                facilityUsedRecord.setFacilitieAddr(facility.getAddress());
                facilityUsedRecord.setCreateUser(userId);
                facilityUsedRecord.setUserId(userId);
                facilityUsedRecord.setFacilitieId(facility.getId());
                long count = facilityUsedRecordService.countByFacilitieCodeAndUserId(facility.getCode(), userId);
                facilityUsedRecord.setNum((int) count);
@ -179,6 +183,9 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
    public ObjEnvelop facilityUsedRecordDetail(
            @ApiParam(name = "id", value = "使用记录ID", defaultValue = "")
            @RequestParam(value = "id") String id) throws Exception {
        if (id == null ){
            throw new ManageException("使用记录ID为空!");
        }
        Map<String, Object> usedRecordDetail = facilityUsedRecordService.getUsedRecordDetail(id);
        return success(usedRecordDetail);
    }

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

@ -53,8 +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);
        int count = (int)feedBackService.getCount(filters);
        return success(feedBackList,count, page, size);
        int count = (int) feedBackService.getCount(filters);
        return success(feedBackList, count, page, size);
    }
    @ApiOperation(value = "创建/更新(id存在)意见反馈")
@ -62,6 +62,7 @@ public class FeedBackController extends EnvelopRestEndpoint {
    public ObjEnvelop<FeedBack> createFeedBack(
            @ApiParam(name = "feedBack", value = "意见反馈JSON结构")
            @RequestBody FeedBack feedBack) throws IOException {
        feedBack.setFlag(1);
        feedBack = feedBackService.save(feedBack);
        return success(feedBack);
    }
@ -94,9 +95,6 @@ public class FeedBackController extends EnvelopRestEndpoint {
            feedBackOld.setFlag(2);
            feedBackOld.setReplyContent(feedBack.getReplyContent());
            feedBackOld.setUpdateUser(feedBack.getUpdateUser());
        } else {
            //根据id获取意见反馈,打开待反馈信息
            feedBackOld.setFlag(1);
        }
        feedBackOld = feedBackService.save(feedBackOld);
        return success(feedBackOld);
@ -134,7 +132,7 @@ public class FeedBackController extends EnvelopRestEndpoint {
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts) throws ManageException, ParseException {
        List<FeedBack> feedBackList = feedBackService.search(fields, filters, sorts);
        feedBackService.exportUsersExcel(response,feedBackList);
        feedBackService.exportUsersExcel(response, feedBackList);
    }
}

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

@ -107,9 +107,13 @@ public class UserController  extends EnvelopRestEndpoint {
    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 = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) {
        userService.updateStatus(userId,operator, HouseUserContant.activated_lock,reason);
        try {
            userService.updateStatus(userId,operator, HouseUserContant.activated_lock,reason);
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
        return success("冻结成功");
    }
@ -118,8 +122,12 @@ public class UserController  extends EnvelopRestEndpoint {
    @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);
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) {
        try {
            userService.updateStatus(userId,operator, HouseUserContant.activated_active,null);
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
        return success("激活成功");
    }
@ -128,27 +136,57 @@ public class UserController  extends EnvelopRestEndpoint {
    public Envelop updatePwd(
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "oldPwd", value = "原密码", required = true)@RequestParam(required = true, name = "oldPwd") String oldPwd ,
            @ApiParam(name = "newPwd", value = "新密码", required = true)@RequestParam(required = true, name = "newPwd") String newPwd ) throws ManageException {
            @ApiParam(name = "newPwd", value = "新密码", required = true)@RequestParam(required = true, name = "newPwd") String newPwd ) {
        userService.updatePwd(userId,oldPwd,newPwd);
        try {
            userService.updatePwd(userId,oldPwd,newPwd);
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
        return success("更新密码成功");
    }
    @PostMapping("/updatePhone")
    @ApiOperation(value = "更新安全手机号码")
    @ApiOperation(value = "【app端普通用户】更新安全手机号码")
    public Envelop updatePhone(
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "oldPhone", value = "旧安全手机号", required = true)@RequestParam(required = true, name = "oldPhone") String oldPhone ,
            @ApiParam(name = "newPhone", value = "新安全手机号", required = true)@RequestParam(required = true, name = "newPhone") String newPhone ,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha ) {
        try {
            //验证码
            if (wlyyRedisVerifyCodeService.verification(clientId, oldPhone, captcha)) {
                userService.updateSecurePhone(userId, newPhone);
                return success("更新安全手机号码成功");
            } else {
                return failed("验证码错误");
            }
        }catch (ManageException e){
            return failed(e.getMessage());
        }
    }
    @PostMapping("/updateAdminPhone")
    @ApiOperation(value = "【web端管理员】更新安全手机号码")
    public Envelop updateAdminPhone(
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "newPhone", value = "新安全手机号", required = true)@RequestParam(required = true, name = "newPhone") String newPhone ,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha ) throws ManageException {
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha ) {
        try {
        //验证码
        if (wlyyRedisVerifyCodeService.verification(clientId, newPhone, captcha)) {
            userService.updateSecurePhone(userId,newPhone);
            userService.updateAdministorSecurePhone(userId,newPhone);
            return success("更新安全手机号码成功");
        } else {
            return failed("验证码错误");
        }
        }catch (ManageException e) {
            return failed(e.getMessage());
        }
    }
    @PostMapping("/checkIdCardNo")
@ -156,35 +194,43 @@ public class UserController  extends EnvelopRestEndpoint {
    public Envelop checkIdCardNo(
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "name", value = "用户姓名", required = true)@RequestParam(required = true, name = "name") String name ,
            @ApiParam(name = "idCardNo", value = "身份证号码", required = true)@RequestParam(required = true, name = "idCardNo") String idCardNo ) throws ManageException {
            @ApiParam(name = "idCardNo", value = "身份证号码", required = true)@RequestParam(required = true, name = "idCardNo") String idCardNo ) {
        userService.checkIdCardNo(userId,name,idCardNo);
        try {
            userService.checkIdCardNo(userId,name,idCardNo);
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
        return success("用户实名认证完成!");
    }
    @GetMapping("/existence")
    @ApiOperation(value = "【管理员】-验证管理员是否存在")
    public Envelop existence(
            @ApiParam(name = "telephone", value = "管理员账号", required = true)@RequestParam(required = true, name = "telephone") String telephone  ) throws ManageException {
            @ApiParam(name = "telephone", value = "管理员账号", required = true)@RequestParam(required = true, name = "telephone") String telephone  ) {
        boolean b = userService.checkManageUser(telephone);
        if (b) {
            return success("该管理员账号存在!",b);
        }else {
            return success("该管理员账号不存在!",b);
        try {
            boolean b = userService.checkManageUser(telephone);
            if (b) {
                return success("该管理员账号存在!", b);
            } else {
                return failed("该管理员账号不存在!");
            }
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
    }
    @GetMapping("/findUserByPhoneOrName")
    @ApiOperation(value = "根据手机号或者用户查询用户",notes = "找回密码时验证")
    public Envelop findUserByPhoneOrName(
            @ApiParam(name = "loginName", value = "管理员登录账号", required = true)@RequestParam(required = true, name = "loginName") String loginName  ) throws ManageException {
            @ApiParam(name = "loginName", value = "管理员登录账号", required = true)@RequestParam(required = true, name = "loginName") String loginName  ) {
        User user = userService.findByLoginCodeAndUserType(loginName, LoginInfo.USER_TYPE_SUPER_AdminManager);
        if (user != null) {
            return success("该管理员账号存在!",user);
        }else {
            return success("该管理员账号不存在!",user);
            return failed("该管理员账号不存在!");
        }
    }
@ -208,13 +254,14 @@ public class UserController  extends EnvelopRestEndpoint {
    @GetMapping("/exportToExcel")
    @ApiOperation(value = "用户列表导出excel")
    public void exportToExcel(
    public Envelop exportToExcel(
            HttpServletResponse response,
            @ApiParam(name = "city", value = "所在市区", required = false)@RequestParam(required = false, name = "city") String city,
            @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 {
            @ApiParam(name = "sort", value = "使用次数排序", required = false)@RequestParam(required = false, name = "sort") String sort) {
        response.setCharacterEncoding("UTF-8");
        try {
        //获取用户数据
        Map<String, String> map = new HashMap<>();
        map.put("cityCode",city);
@ -223,8 +270,27 @@ public class UserController  extends EnvelopRestEndpoint {
        map.put("telephone",name);
        List<User> userList = userService.userList( map, sort);
        userService.exportUsersExcel(response,userList);
        return success("导出成功");
        }catch (ManageException e){
            return failed(e.getMessage());
        }
    }
    @PostMapping(value = "/heartbeat")
    @ApiOperation(value = "用户在线-心跳接口", notes = "心跳接口")
    public Envelop heartbeat(
            @ApiParam(name = "userId", value = "用户ID", defaultValue = "")
            @RequestParam(value = "userId") String userId) {
        try {
              userService.setUserActivated(userId, 60);
            return success("心跳正常");
        } catch (Exception e) {
            return failed("心跳异常");
        }
    }
}

+ 1 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/facility/FacilityDao.java

@ -22,7 +22,7 @@ public interface FacilityDao extends JpaRepository<Facility, String> {
    Facility findByCode(String code);
    @Query("select f from Facility f where f.code in :code ")
    @Query("select f from Facility f where  f.status = 0 and f.code in (:code) ")
    List<Facility> findByCode(@Param("code") List<String> code);
}

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

@ -14,7 +14,7 @@ public interface FacilityUsedRecordDao extends JpaRepository<FacilityUsedRecord,
    FacilityUsedRecord findById(String id);
    Long countByUserId(String userId);
    Long countAllByUserIdIsNotNull();
    Long countAllByCreateUserIsNotNull();
    long countByFacilitieCodeAndCreateUser(String facilitieCode,String createUser);
}

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

@ -18,9 +18,11 @@ public interface UserDao extends PagingAndSortingRepository<User, String>, JpaSp
    User findByIdAndActivated(String id,String activated);
    User findById(String id);
    @Query("from User u where u.loginCode=?1 and u.activated<>0 ")
    User findByLoginCodeAndActivated(String loginCode,String activated);
    User findByLoginCode(String loginCode);
    @Query("from User u where u.name=?1 and u.activated=?2 ")
    User findByNameAAndActivated(String name,String activated);
@ -33,12 +35,13 @@ public interface UserDao extends PagingAndSortingRepository<User, String>, JpaSp
    @Query("select sum (u.facilityUsedCount) from User u")
    Long sumFacilityUseCout();
    Long countAllByActivated(Integer activated);
    Long countAllByActivatedAndUserType(Integer activated,String userType);
    Long countAllByUserType(String userType);
    Long countAllByCreateTimeBetween(Date start,Date end);
    Long countAllByUserTypeAndCreateTimeBetween(String userType,Date start,Date end);
    User findByLoginCodeAndUserType(String loginCode,String userType);
    User findByTelephoneAndUserType(String telephone,String userType);
}

+ 25 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/listener/MyKeyExpirationEventMessageListener.java

@ -0,0 +1,25 @@
package com.yihu.jw.healthyhouse.listener;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
/**
 * @author HZY
 * @created 2018/10/8 15:11
 */
public class MyKeyExpirationEventMessageListener extends KeyExpirationEventMessageListener {
    public MyKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }
    @Override
    public void onMessage(Message message, byte[] pattern) {
//      System.out.println(new String(message.getBody()));
//      System.out.println(new String(message.getChannel()));
//      System.out.println(new String(pattern));
//      super.onMessage(message, pattern);
    }
}

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

@ -59,7 +59,7 @@ public class User extends UuidIdentityEntityWithOperator {
    @Column(name = "salt")
    private String salt; //加密种子
    @Column(name = "facility_used_count")
    @Column(name = "facility_used_count",columnDefinition="int default 1")
    private Integer facilityUsedCount;//设施使用次数
    @Column(name = "realname_authentication")

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

@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -52,20 +53,20 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
    public Facility findById(String id) {
        return  facilityDao.findById(id);
        return facilityDao.findById(id);
    }
    public boolean isHasFacility(double longitude,double latitude){
    public boolean isHasFacility(double longitude, double latitude) {
        boolean flag = false;
        List<Facility> facilitys = facilityDao.findByLongitudeAndLatitude(longitude, latitude);
        if (facilitys!=null && facilitys.size()>0) {
        if (facilitys != null && facilitys.size() > 0) {
            flag = true;
        }
        return flag;
    }
    //excel中添加固定内容
    private void addStaticCell(Sheet sheet){
    private void addStaticCell(Sheet sheet) {
        //设置样式
        Workbook workbook = sheet.getWorkbook();
        CellStyle style = workbook.createCellStyle();
@ -76,22 +77,24 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
        style.setFont(font);
        ExcelUtils.addCellData(sheet,0,0,"序号",style);
        ExcelUtils.addCellData(sheet,1,0,"设施编码",style);
        ExcelUtils.addCellData(sheet,2,0,"设施类型名称",style);
        ExcelUtils.addCellData(sheet,3,0,"设施详细地址",style);
        ExcelUtils.addCellData(sheet,4,0,"联系人",style);
        ExcelUtils.addCellData(sheet,5,0,"联系方式",style);
        ExcelUtils.addCellData(sheet,6,0,"所在省",style);
        ExcelUtils.addCellData(sheet,7,0,"所在市",style);
        ExcelUtils.addCellData(sheet,8,0,"所在区",style);
        ExcelUtils.addCellData(sheet,9,0,"所在街道",style);
        ExcelUtils.addCellData(sheet,10,0,"运营状态",style);
        ExcelUtils.addCellData(sheet,2,0,"设施名称",style);
        ExcelUtils.addCellData(sheet,3,0,"设施类型名称",style);
        ExcelUtils.addCellData(sheet,4,0,"设施详细地址",style);
        ExcelUtils.addCellData(sheet,5,0,"联系人",style);
        ExcelUtils.addCellData(sheet,6,0,"联系方式",style);
        ExcelUtils.addCellData(sheet,7,0,"所在省",style);
        ExcelUtils.addCellData(sheet,8,0,"所在市",style);
        ExcelUtils.addCellData(sheet,9,0,"所在区",style);
        ExcelUtils.addCellData(sheet,10,0,"所在街道",style);
        ExcelUtils.addCellData(sheet,11,0,"运营状态",style);
    }
    /**
     *  导出设施列表excel
     * @param response  响应体
     * @param facilityList  用户列表
     * 导出设施列表excel
     *
     * @param response     响应体
     * @param facilityList 用户列表
     * @throws ManageException
     */
    public void exportFacilityExcel(HttpServletResponse response, List<Facility> facilityList) throws ManageException {
@ -100,17 +103,17 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            //设置下载
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="
                    + new String( fileName.getBytes("gb2312"), "ISO8859-1" )+".xlsx");
                    + new String(fileName.getBytes("gb2312"), "ISO8859-1") + ".xlsx");
            OutputStream os = response.getOutputStream();
            //获取导出数据集
            JSONObject order = new JSONObject();
            order.put("id","asc");
            order.put("id", "asc");
            //写excel
            Workbook workbook = new XSSFWorkbook();
            int k=0;
            int k = 0;
            Facility metaData = null;
            int row=0;
            int row = 0;
            //创建Excel工作表 指定名称和位置
            String streetName = "健康小屋-设施列表";
            Sheet sheet = workbook.createSheet(streetName);
@ -118,21 +121,21 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            //添加数据元信息
            WritableCellFormat wc = new WritableCellFormat();
            wc.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN, Colour.SKY_BLUE);//边框
            for(int j=0;k<facilityList.size(); j++,k++){
            for (int j = 0; k < facilityList.size(); j++, k++) {
                metaData = facilityList.get(k);
                row=j+1;
                ExcelUtils.addCellData(sheet,0,row,j+1+"");//序号
                ExcelUtils.addCellData(sheet,1,row, metaData.getCode());//设施编码
                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());//运营状态
                row = j + 1;
                ExcelUtils.addCellData(sheet, 0, row, j + 1 + "");//序号
                ExcelUtils.addCellData(sheet, 1, row, metaData.getCode());//设施编码
                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());//运营状态
            }
@ -142,17 +145,18 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            os.flush();
            os.close();
        } catch (Exception e) {
            throw new ManageException("导出设施列表异常",e);
            throw new ManageException("导出设施列表异常", e);
        }
    }
    /**
     * 批量导入设施的集合
     * @param facilities    设施列表
     *
     * @param facilities 设施列表
     */
    public Map<String,Object> batchInsertFacility(List<FacilityMsg> facilities) throws ManageException{
        Map<String,Object> result = new HashMap<>();
    public Map<String, Object> batchInsertFacility(List<FacilityMsg> facilities) throws ManageException {
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
        int correctCount = 0;
        List<Facility> corrects = new ArrayList<>();
@ -160,13 +164,13 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
        Facility facility = null;
        //批量存储
        for(FacilityMsg facilityMsg : facilities) {
        for (FacilityMsg facilityMsg : facilities) {
            facility = new Facility();
            Double longitude = StringUtils.isEmpty(facilityMsg.getLongitude()) ? null :Double.parseDouble(facilityMsg.getLongitude());
            Double latitude = StringUtils.isEmpty(facilityMsg.getLongitude()) ? null :Double.parseDouble(facilityMsg.getLongitude());
            Double longitude = StringUtils.isEmpty(facilityMsg.getLongitude()) ? null : Double.parseDouble(facilityMsg.getLongitude());
            Double latitude = StringUtils.isEmpty(facilityMsg.getLongitude()) ? null : Double.parseDouble(facilityMsg.getLongitude());
            String cityCode = baseCityService.getCodeByname(facilityMsg.getCity());
            String townCode = baseTownService.getCodeByname(facilityMsg.getCounty());
            Integer categoryCode = systemDictEntryService.getDictEntryCodeByName("FacilityType",facilityMsg.getCategory());
            Integer categoryCode = systemDictEntryService.getDictEntryCodeByName("FacilityType", facilityMsg.getCategory());
            facility.setCode(genFacilityCode());
            facility.setName(facilityMsg.getName());
            facility.setCategory(categoryCode);
@ -179,7 +183,7 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            facility.setCountyCode(townCode);
            facility.setCountyName(facilityMsg.getCounty());
            facility.setStreet(facilityMsg.getStreet());
            facility.setAddress( facilityMsg.getCity() + facilityMsg.getCounty() + facilityMsg.getStreet());
            facility.setAddress(facilityMsg.getCity() + facilityMsg.getCounty() + facilityMsg.getStreet());
            facility.setStatus(facilityMsg.getStatus());
            facility.setOrgName(facilityMsg.getOrgName());
            facility.setServiceDay(facilityMsg.getServiceDate());
@ -188,36 +192,37 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
            facility.setLongitude(longitude);
            facility.setLatitude(latitude);
            if (isHasFacility(longitude,latitude)) {
            if (isHasFacility(longitude, latitude)) {
                errors.add(facility);
            }else {
            } else {
                corrects.add(facility);
            }
            if (corrects.size()>100){
            if (corrects.size() > 100) {
                facilityDao.save(corrects);
                correctCount +=corrects.size();
                correctCount += corrects.size();
                corrects.clear();
            }
        }
        if(!corrects.isEmpty()) {
        if (!corrects.isEmpty()) {
            facilityDao.save(corrects);
            correctCount +=corrects.size();
            correctCount += corrects.size();
        }
        result.put("correctCount",correctCount);
        result.put("errors",errors);
        result.put("correctCount", correctCount);
        result.put("errors", errors);
        return result;
    }
    /**
     * 设施编码生成
     *
     * @return
     */
    public String genFacilityCode(){
    public String genFacilityCode() {
        String code = "CSHF" + randomString(5);
        Facility facility = facilityDao.findByCode(code);
        while (facility!=null) {
        while (facility != null) {
            code = "CSHF" + randomString(5);
            facility = facilityDao.findByCode(code);
        }
@ -227,25 +232,46 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
    /**
     * 根据服务类型获取设施
     */
    public List<String> getFacilityCodeByServerType(String type){
    public List<String> getFacilityCodeByServerType(String type) {
        Session s = currentSession();
        String hql = "(SELECT  DISTINCT fsr.facilitie_code FROM  facility_server_relation fsr,facility_server fs WHERE fsr.service_code=fs.code and fs.type=:type)";
        Query query = s.createSQLQuery(hql);
        query.setParameter("type",type);
        query.setParameter("type", type);
        return query.list();
    }
    public List<String> getFacilityCodeByServerCode( String[] codes)
    {
        String sql =  "(SELECT  DISTINCT fsr.facilitie_code FROM  facility_server_relation fsr WHERE fsr.service_code IN(:codes))";
    public List<String> getFacilityCodeByServerCode(String[] codes) {
        String sql = "(SELECT  DISTINCT fsr.facilitie_code FROM  facility_server_relation fsr WHERE fsr.service_code IN(:codes))";
        SQLQuery sqlQuery = currentSession().createSQLQuery(sql);
        sqlQuery.setParameterList("codes", codes);
        return sqlQuery.list();
    }
    public List<Facility> getFacilityByFacilityCode( List<String> facilityCodes){
    public List<Facility> getFacilityByFacilityCode(List<String> facilityCodes) {
        return facilityDao.findByCode(facilityCodes);
    }
    public boolean checkFacilityByFacilityId(String id, String fild, String value) {
        SQLQuery sqlQuery;
        String sql = "";
        if (fild.equals("code")) {
            //验证编码
            sql = "select count(1) from facility f where  f.status = 0 and f.code =:code and f.id !=:id";
            sqlQuery = currentSession().createSQLQuery(sql);
            sqlQuery.setParameter("id", id);
            sqlQuery.setParameter("code", value);
            BigInteger count = (BigInteger) sqlQuery.uniqueResult();
            return count.compareTo(new BigInteger("0")) > 0;
        } else {
            //验证名称
            sql = "select count(1) from facility f where  f.status = 0 and f.name =:name and f.id !=:id";
            sqlQuery = currentSession().createSQLQuery(sql);
            sqlQuery.setParameter("id", id);
            sqlQuery.setParameter("name", value);
            BigInteger count = (BigInteger) sqlQuery.uniqueResult();
            return count.compareTo(new BigInteger("0")) > 0;
        }
    }
}

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

@ -58,7 +58,7 @@ public class FacilityUsedRecordService extends BaseJpaService<FacilityUsedRecord
    }
    public Long countAll() {
        return facilityUsedRecordDao.countAllByUserIdIsNotNull();
        return facilityUsedRecordDao.countAllByCreateUserIsNotNull();
    }
    //根据用户id及设施编码统计历史导航记录总数

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

@ -1,6 +1,7 @@
package com.yihu.jw.healthyhouse.service.user;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.org.apache.bcel.internal.generic.I2F;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
@ -64,6 +65,10 @@ public class LoginService  extends BaseJpaService {
            user.setPassword(LoginInfo.DEFAULT_PASSWORD);
            user.setUserType(LoginInfo.USER_TYPE_PATIENT);
        }
        if (HouseUserContant.activated_lock.equals(user.getActivated())) {
            throw new ManageException("该用户已被冻结!");
        }
        //已注册用户更改用户状态
        user.setActivated(HouseUserContant.activated_active);
        request.getSession().setAttribute(LoginInfo.IS_LOGIN, true);
@ -72,7 +77,7 @@ public class LoginService  extends BaseJpaService {
        request.getSession().setAttribute(LoginInfo.LOGIN_CODE, user.getLoginCode());
        request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
        user.setLastLoginTime(new Date());
        userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_PHONE);
        user= userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_PHONE);
        return user;
    }
@ -118,7 +123,7 @@ public class LoginService  extends BaseJpaService {
        request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
        user.setActivated(HouseUserContant.activated_active);
        user.setLastLoginTime(new Date());
        userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_IJK);
        user= userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_IJK);
        return user;
    }
@ -178,7 +183,7 @@ public class LoginService  extends BaseJpaService {
        request.getSession().removeAttribute(LoginInfo.LOGIN_NAME);
        request.getSession().removeAttribute(LoginInfo.USER_ID);
        user.setActivated(HouseUserContant.activated_offline);
        userService.saveOrUpdate(user, "systemLogin");
        user= userService.saveOrUpdate(user, "systemLogin");
        return user;
    }
@ -265,10 +270,13 @@ 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_SUPER_AdminManager);
        User user = userService.findByTelephoneAndUserType(loginCode, LoginInfo.USER_TYPE_SUPER_AdminManager);
        if (user == null) {
            throw new ManageException("该管理员账号不存在!");
        } else {
            if (HouseUserContant.activated_lock.equals(user.getActivated())) {
                throw new ManageException("该用户已被冻结!");
            }
            //已注册用户更改用户状态
            user.setActivated(HouseUserContant.activated_active);
            request.getSession().setAttribute(LoginInfo.IS_LOGIN, true);
@ -277,7 +285,7 @@ public class LoginService  extends BaseJpaService {
            request.getSession().setAttribute(LoginInfo.LOGIN_CODE, user.getLoginCode());
            request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
            user.setLastLoginTime(new Date());
            userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_PHONE);
            user=  userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_PHONE);
        }
        return user;
    }
@ -300,6 +308,10 @@ public class LoginService  extends BaseJpaService {
            String message = "该管理员账号不存在!";
            throw new ManageException(message);
        } else {
            if (HouseUserContant.activated_lock.equals(user.getActivated())) {
                throw new ManageException("该用户已被冻结!");
            }
            if (!user.getPassword().equals(MD5.GetMD5Code(password + user.getSalt()))) {
                String message = "密码错误";
                throw new ManageException(message);
@ -310,7 +322,7 @@ public class LoginService  extends BaseJpaService {
            request.getSession().setAttribute(LoginInfo.USER_ID, user.getId());
            user.setActivated(HouseUserContant.activated_active);
            user.setLastLoginTime(new Date());
            userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_IJK);
            user= userService.saveOrUpdate(user, LoginInfo.SAVE_TYPE_IJK);
            return user;
        }
    }

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

@ -24,6 +24,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springside.modules.persistence.DynamicSpecifications;
@ -33,6 +34,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
/**
@ -41,11 +43,26 @@ import java.util.regex.Pattern;
 */
@Service
public class UserService extends BaseJpaService<User, UserDao> {
    private final String KEY_PREFIX = ":healthyHouse";
    private final String KEY_SUFFIX = ":activated";
    @Autowired
    private UserDao userDao;
    @Autowired
    private FacilityUsedRecordService facilityUsedRecordService;
    @Autowired
    private  RedisTemplate redisTemplate;
    /**
     * 设置用户在线状态
     * @param userId
     * @param expire
     */
    public void setUserActivated ( String userId, int expire) {
        String key =  KEY_PREFIX + userId + KEY_SUFFIX;
        redisTemplate.opsForValue().set(key, userId);
        redisTemplate.expire(key, expire, TimeUnit.SECONDS);
    }
    public User findById(String id) {
        return userDao.findById(id);
@ -59,6 +76,9 @@ public class UserService extends BaseJpaService<User, UserDao> {
        return userDao.findByLoginCodeAndUserType(loginCode,userType);
    }
    public User findByTelephoneAndUserType(String telephone,String userType) {
        return userDao.findByTelephoneAndUserType(telephone,userType);
    }
    /**
     * 分页获取用户列表
@ -175,7 +195,7 @@ public class UserService extends BaseJpaService<User, UserDao> {
     * @return
     * @throws ManageException
     */
    public Envelop saveOrUpdate(User user, String userCode) throws ManageException {
    public User saveOrUpdate(User user, String userCode) throws ManageException {
        User loginUser = userDao.findByLoginCode(userCode);
        if (user.getId() == null) {//保存
            //判断登陆账号是否存在
@ -190,16 +210,17 @@ public class UserService extends BaseJpaService<User, UserDao> {
            user.setCreateUser(userCode);
            user.setCreateTime(new Date());
            user.setActivated(1);
            userDao.save(user);
            return Envelop.getSuccess("保存成功");
            user.setFacilityUsedCount(0);
            user=userDao.save(user);
            return user;
        } else {//修改
            if (loginUser != null) {
                String userName = loginUser.getName();
                user.setUpdateUserName(userName);
            }
            user.setUpdateUser(userCode);
            userDao.save(user);
            return Envelop.getSuccess("修改成功");
            user=userDao.save(user);
            return user;
        }
    }
@ -249,19 +270,42 @@ public class UserService extends BaseJpaService<User, UserDao> {
    }
    /**
     * 普通用户密保手机修改
     * @param userId    普通用户id
     * @param phone     手机号
     * @throws ManageException
     */
    @Transactional
    public void updateSecurePhone(String userId, String phone) throws ManageException {
        User user = findById(userId);
        if (user==null) {
            throw new ManageException("该账号不存在");
        }
        user.setLoginCode(phone);
        user.setTelephone(phone);
        userDao.save(user);
    }
    /**
     * 修改管理员密保手机
     * @param userId    用户id
     * @param phone     密保手机
     * @throws ManageException
     */
    @Transactional
    public void updateAdministorSecurePhone(String userId, String phone) throws ManageException {
        User user = findById(userId);
        if (user==null) {
            throw new ManageException("该账号不存在");
        }
        user.setTelephone(phone);
        userDao.save(user);
    }
    /**
     * 获取 用户统计信息
     * 获取 健康小屋用户统计信息
     *
     * @return
     */
@ -272,9 +316,9 @@ public class UserService extends BaseJpaService<User, UserDao> {
        //今日新增数
        Date start = DateUtil.getDateStart();
        Date end = DateUtil.getDateEnd();
        Long newCount = userDao.countAllByCreateTimeBetween(start, end);
        Long newCount = userDao.countAllByUserTypeAndCreateTimeBetween(LoginInfo.USER_TYPE_PATIENT,start, end);
        //在线用户数
        Long activeCount = userDao.countAllByActivated(HouseUserContant.activated_active);
        Long activeCount = userDao.countAllByActivatedAndUserType(HouseUserContant.activated_active,LoginInfo.USER_TYPE_PATIENT);
        //用户设施使用总次数
        Long usePricilityCount = facilityUsedRecordService.countAll();
        result.put("totalCount",totalCount);