huangzhiyong 6 лет назад
Родитель
Сommit
8cc58f0c28
27 измененных файлов с 982 добавлено и 155 удалено
  1. 43 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/ErrorCodeDO.java
  2. 11 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxWechatDO.java
  3. 80 0
      common/common-exception/src/main/java/com/yihu/jw/exception/code/BaseErrorCode.java
  4. 17 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  5. 4 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/house/HealthyHouseMapping.java
  6. 44 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/ErrorCodeVO.java
  7. 75 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/MenuVO.java
  8. 29 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxSaasVO.java
  9. 26 144
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxWechatVO.java
  10. 5 0
      svr/svr-base/pom.xml
  11. 15 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/errorCode/ErrorCodeDao.java
  12. 17 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/role/MenuDao.java
  13. 11 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/role/RoleMenuDao.java
  14. 92 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/errorCode/ErrorCodeEndpoint.java
  15. 103 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/role/MenuEndpoint.java
  16. 44 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java
  17. 6 0
      svr/svr-base/src/main/java/com/yihu/jw/base/listener/ApplicationReadyListener.java
  18. 69 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/errorCode/ErrorCodeService.java
  19. 29 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/role/MenuService.java
  20. 14 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/role/RoleMenuService.java
  21. 97 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java
  22. 26 0
      svr/svr-base/src/main/java/com/yihu/jw/base/util/ErrorCodeUtil.java
  23. 27 4
      svr/svr-base/src/main/resources/application.yml
  24. 35 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java
  25. 39 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FacilityUsedRecordController.java
  26. 2 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/user/FacilityUsedRecordDao.java
  27. 22 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/FacilityUsedRecordService.java

+ 43 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/ErrorCodeDO.java

@ -0,0 +1,43 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 错误码
 * @author yeshijie on 2018/9/26.
 */
@Entity
@Table(name = "base_error_code")
public class ErrorCodeDO extends UuidIdentityEntityWithOperator {
    private String model;//模块
    private String errorCode;//提示码
    private String errorMsg;//提示内容
    public String getModel() {
        return model;
    }
    public void setModel(String model) {
        this.model = model;
    }
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
}

+ 11 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxWechatDO.java

@ -23,7 +23,7 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    private String token;//token
    private String encodingAesKey;//加密密钥
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    private Integer status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
    private Integer status;//'类型 -1 已删除 0未认证 1已认证 2 审核中 3.审核未通过'
    private String type;//'1:服务号 2 订阅号
    private String appId;//'微信app_id'
    private String appSecret;//'微信app_secret'
@ -31,6 +31,7 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    private String baseUrl;//'微信base_url'
    private String userName;//公总号登录账户
    private String password;//用户密码
    private String publicType;//1.自运营,2.外接
    private String remark;//'备注'
@ -178,4 +179,13 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    public void setPassword(String password) {
        this.password = password;
    }
    @Column(name = "public_type", length = 200)
    public String getPublicType() {
        return publicType;
    }
    public void setPublicType(String publicType) {
        this.publicType = publicType;
    }
}

+ 80 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/code/BaseErrorCode.java

@ -0,0 +1,80 @@
package com.yihu.jw.exception.code;
/**
 * @author yeshijie on 2018/9/26.
 */
public class BaseErrorCode {
    public static final String PREFIX = "error:code:";//定义redis的前缀
    /**
     * 公共模块
     * -1 ~ -9999
     * 每个模块的错误码至少保留分100个值
     */
    public static class Common{
        public static final String FAIL_UPLOAD = "-1";//上传失败
        public static final String FAIL_UPDATE = "-2";//修改失败
        public static final String FAIL_CREATE = "-3";//新增失败
        public static final String FAIL_DELETE = "-4";//删除失败
        public static final String ID_IS_NULL = "-5";//ID不能为空
    }
    /**
     * 错误码模块
     */
    public static class ErrorCode{
        public static final String IS_EXIST = "-10000";
    }
    /**
     * 租户模块
     */
    public static class Saas{
        public static final String SAAS = "-101000";
    }
    /**
     * 菜单模块
     */
    public static class Menu{
        public static final String FINDDICTBYCODE = "-102000";
    }
    /**
     * 业务模块
     */
    public static class Module{
        public static final String FINDDICTBYCODE = "-103000";
    }
    /**
     * 字典模块
     */
    public static class Dict{
        public static final String FINDDICTBYCODE = "-104000";
    }
    /**
     * 通知公告模块
     */
    public static class Notice{
        public static final String FINDDICTBYCODE = "-105000";
    }
    /**
     * 接口模块
     */
    public static class Interface{
        public static final String FINDDICTBYCODE = "-106000";
    }
    /**
     * 微信模块
     */
    public static class Wechat{
        public static final String WECHAT = "-1000000";
    }
}

+ 17 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -123,6 +123,21 @@ public class BaseRequestMapping {
        public static final String PREFIX  = "/role";
    }
    /**
     * 菜单
     */
    public static class Menu extends Basic {
        public static final String PREFIX  = "/menu";
        public static final String STATUS  = "/status";
    }
    /**
     * 错误码
     */
    public static class ErrorCode extends Basic {
        public static final String PREFIX  = "/error";
    }
    /**
     * 角色权限
     */
@ -135,6 +150,8 @@ public class BaseRequestMapping {
     */
    public static class WeChat extends Basic {
        public static final String PREFIX  = "/wechat";
        public static final String api_success ="success";
        public static final String getWechatInfos ="/getWechatInfos";
    }
    /**

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

@ -52,6 +52,8 @@ public class HealthyHouseMapping {
            public static final String COUNT_FACILITIES_BY_TIME = "/count/facilitiesByTime";
            public static final String NEARBY_FACILITY = "/nearbyFacility";
            public static final String GET_FACILITIELIST = "/list/getAppFacilities";
            public static final String GET_ALL_FACILITIELISTS_COUNT = "/list/getAllFacilitiesCount";
        }
        //设施服务
@ -87,6 +89,8 @@ public class HealthyHouseMapping {
            public static final String GET_FACILITY_USED_RECORD_BY_ID = "/getFacilityUsedRecordById";
            public static final String GET_FACILITY_USED_RECORD_BY_FIELD = "/getFacilityUsedRecordByField";
            public static final String UPDATE_FACILITY_USED_RECORD_BY_ID = "/updateFacilityUsedRecordById";
            public static final String GET_FACILITY_USED_RECORD_AND_COUNT_BY_ID = "/getFacilityUsedRecordAndCountById";
            public static final String COUNT_FACILITY_USED_RECORD_BY_USERID = "/countFacilityUsedRecordByUserId";
        }
        //服务评价

+ 44 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/ErrorCodeVO.java

@ -0,0 +1,44 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * 错误码
 * @author yeshijie on 2018/9/26.
 */
@ApiModel(value = "ErrorCodeVO", description = "错误码")
public class ErrorCodeVO extends UuidIdentityEntityWithOperator {
    @ApiModelProperty(value = "模块", example = "common")
    private String model;
    @ApiModelProperty(value = "错误码", example = "-1")
    private String errorCode;
    @ApiModelProperty(value = "提示内容", example = "模块")
    private String errorMsg;
    public String getModel() {
        return model;
    }
    public void setModel(String model) {
        this.model = model;
    }
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
}

+ 75 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/MenuVO.java

@ -0,0 +1,75 @@
package com.yihu.jw.restmodel.base.role;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * @author yeshijie on 2018/9/26.
 */
@ApiModel(value = "MenuVO", description = "菜单")
public class MenuVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "名称", example = "预约挂号")
    private String name;
    @ApiModelProperty(value = "请求路径", example = "/usr/var")
    private String url;
//    @ApiModelProperty(value = "请求方式", example = "get,post")
//    private String method;
    @ApiModelProperty(value = "排序", example = "1")
    private Integer sort;
    @ApiModelProperty(value = "父级ID", example = "父级ID")
    private String parentId;
    @ApiModelProperty(value = "状态", example = "1生效,0失效")
    private Integer status;
    @ApiModelProperty(value = "备注", example = "说明")
    private String remark;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public String getParentId() {
        return parentId;
    }
    public void setParentId(String parentId) {
        this.parentId = parentId;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 29 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxSaasVO.java

@ -0,0 +1,29 @@
package com.yihu.jw.restmodel.base.wx;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by Trick on 2018/9/26.
 */
public class WxSaasVO {
    @ApiModelProperty(value = "saasid")
    private String saasid;
    @ApiModelProperty(value = "saas名称")
    private String saasName;
    public String getSaasid() {
        return saasid;
    }
    public void setSaasid(String saasid) {
        this.saasid = saasid;
    }
    public String getSaasName() {
        return saasName;
    }
    public void setSaasName(String saasName) {
        this.saasName = saasName;
    }
}

+ 26 - 144
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxWechatVO.java

@ -1,5 +1,7 @@
package com.yihu.jw.restmodel.base.wx;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -10,26 +12,18 @@ import java.util.Map;
 */
public class WxWechatVO {
    private String id;
    private String saasId;//'saas配置id'
    private String name;//名称
    private String token;//token
    private String encodingAesKey;//加密密钥
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    private Integer status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
    private String type;//'1:服务号 2 订阅号
    private String appId;//'微信app_id'
    private String appSecret;//'微信app_secret'
    private String baseUrl;//'微信base_url'
    private String createUser;//'创建人'
    private String createUserName;//'创建人名'
    private Date createTime;//'创建时间'
    private String updateUser;//'修改人
    private String updateUserName;//'修改人名'
    private Date updateTime;//'修改时间'
    private String remark;//'备注'
    private List<Map<String,Object>> children = new ArrayList<>();
    private String state;
    @ApiModelProperty(value = "id")
    private String id ;
    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "状态")
    private Integer status;
    @ApiModelProperty(value = "对接类型")
    private Integer publicType;
    @ApiModelProperty(value = "租户")
    private List<WxSaasVO> saas;
    public String getId() {
        return id;
@ -39,14 +33,6 @@ public class WxWechatVO {
        this.id = id;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }
@ -55,28 +41,12 @@ public class WxWechatVO {
        this.name = name;
    }
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public String getEncodingAesKey() {
        return encodingAesKey;
    }
    public void setEncodingAesKey(String encodingAesKey) {
        this.encodingAesKey = encodingAesKey;
    }
    public Integer getEncType() {
        return encType;
    public String getRemark() {
        return remark;
    }
    public void setEncType(Integer encType) {
        this.encType = encType;
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
@ -87,107 +57,19 @@ public class WxWechatVO {
        this.status = status;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    public String getBaseUrl() {
        return baseUrl;
    }
    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public List<Map<String, Object>> getChildren() {
        return children;
    public Integer getPublicType() {
        return publicType;
    }
    public void setChildren(List<Map<String, Object>> children) {
        this.children = children;
    public void setPublicType(Integer publicType) {
        this.publicType = publicType;
    }
    public String getState() {
        return state;
    public List<WxSaasVO> getSaas() {
        return saas;
    }
    public void setState(String state) {
        this.state = state;
    public void setSaas(List<WxSaasVO> saas) {
        this.saas = saas;
    }
}

+ 5 - 0
svr/svr-base/pom.xml

@ -46,10 +46,15 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <!--注释掉就不会读取git的配置,只会读取yml中的配置-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>

+ 15 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/errorCode/ErrorCodeDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.base.dao.errorCode;
import com.yihu.jw.entity.base.dict.ErrorCodeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/9/26.
 */
public interface ErrorCodeDao extends PagingAndSortingRepository<ErrorCodeDO, String>, JpaSpecificationExecutor<ErrorCodeDO> {
    @Query("select count(*) from ErrorCodeDO a where a.errorCode = ?1 ")
    int isExistsErrorCode(String errorCode);
}

+ 17 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/role/MenuDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.base.dao.role;
import com.yihu.jw.entity.base.role.MenuDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/9/26.
 */
public interface MenuDao extends PagingAndSortingRepository<MenuDO, String>, JpaSpecificationExecutor<MenuDO> {
    @Modifying
    @Query("update MenuDO p set p.status=?2 where p.id=?1")
    void updateStatus(String id,Integer status);
}

+ 11 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/role/RoleMenuDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.base.dao.role;
import com.yihu.jw.entity.base.role.RoleMenuDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author yeshijie on 2018/9/26.
 */
public interface RoleMenuDao extends PagingAndSortingRepository<RoleMenuDO, String>, JpaSpecificationExecutor<RoleMenuDO> {
}

+ 92 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/errorCode/ErrorCodeEndpoint.java

@ -0,0 +1,92 @@
package com.yihu.jw.base.endpoint.errorCode;
import com.yihu.jw.base.service.errorCode.ErrorCodeService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.entity.base.dict.ErrorCodeDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.restmodel.base.dict.ErrorCodeVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
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.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @author yeshijie on 2018/9/26.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.ErrorCode.PREFIX)
@Api(value = "错误码管理", description = "错误码管理服务接口", tags = {"基础服务 - 错误码管理服务接口"})
public class ErrorCodeEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ErrorCodeService errorCodeService;
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    @PostMapping(value = BaseRequestMapping.Menu.CREATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<ErrorCodeVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        ErrorCodeDO errorCodeDO = toEntity(jsonData, ErrorCodeDO.class);
        if(errorCodeService.isExistsErrorCode(errorCodeDO.getErrorCode())>0){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.ErrorCode.IS_EXIST), ObjEnvelop.class);
        }
        errorCodeDO = errorCodeService.addErrorCode(errorCodeDO);
        return success(errorCodeDO, ErrorCodeVO.class);
    }
    @PostMapping(value = BaseRequestMapping.Menu.UPDATE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<ErrorCodeVO> update (
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "errorMsg", value = "错误码")
            @RequestParam(value = "errorMsg", required = true) String errorMsg) throws Exception {
        if (null == id) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), ObjEnvelop.class);
        }
        ErrorCodeDO errorCodeDO = errorCodeService.updateMsg(id, errorMsg);
        return success(errorCodeDO, ErrorCodeVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Menu.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<ErrorCodeVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<ErrorCodeDO> errorCodeDOS = errorCodeService.search(fields, filters, sorts, page, size);
        int count = (int)errorCodeService.getCount(filters);
        return success(errorCodeDOS, count, page, size, ErrorCodeVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Menu.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<ErrorCodeVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<ErrorCodeDO> errorCodeDOS = errorCodeService.search(fields, filters, sorts);
        return success(errorCodeDOS, ErrorCodeVO.class);
    }
}

+ 103 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/role/MenuEndpoint.java

@ -0,0 +1,103 @@
package com.yihu.jw.base.endpoint.role;
import com.yihu.jw.base.service.role.MenuService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.entity.base.role.MenuDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.restmodel.base.role.MenuVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
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.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @author yeshijie on 2018/9/26.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.Menu.PREFIX)
@Api(value = "菜单管理", description = "菜单管理服务接口", tags = {"基础服务 - 菜单管理服务接口"})
public class MenuEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private MenuService menuService;
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    @PostMapping(value = BaseRequestMapping.Menu.CREATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<MenuVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        MenuDO menuDO = toEntity(jsonData, MenuDO.class);
        menuDO = menuService.save(menuDO);
        return success(menuDO, MenuVO.class);
    }
    @PostMapping(value = BaseRequestMapping.Menu.STATUS)
    @ApiOperation(value = "生效/失效")
    public Envelop delete(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "status", value = "1生效,0失效", required = true)
            @RequestParam(value = "status") Integer status) {
        menuService.updateStatus(id, status);
        return success("修改成功");
    }
    @PostMapping(value = BaseRequestMapping.Menu.UPDATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        MenuDO menuDO = toEntity(jsonData, MenuDO.class);
        if (null == menuDO.getId()) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), Envelop.class);
        }
        menuDO = menuService.save(menuDO);
        return success(menuDO);
    }
    @GetMapping(value = BaseRequestMapping.Menu.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<MenuVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<MenuDO> menuDOS = menuService.search(fields, filters, sorts, page, size);
        int count = (int)menuService.getCount(filters);
        return success(menuDOS, count, page, size, MenuVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Menu.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<MenuVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<MenuDO> menuDOS = menuService.search(fields, filters, sorts);
        return success(menuDOS, MenuVO.class);
    }
}

+ 44 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -0,0 +1,44 @@
package com.yihu.jw.base.endpoint.wx;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2018/9/26.
 */
@RestController
@RequestMapping(BaseRequestMapping.WeChat.PREFIX)
@Api(value = "微信基础信息管理", description = "微信基础信息管理", tags = {"微信基础 - 微信基础信息管理"})
public class WechatController extends EnvelopRestEndpoint {
    @Autowired
    private WechatService wechatService;
    @GetMapping(value = BaseRequestMapping.WeChat.getWechatInfos)
    @ApiOperation(value = "获取微信基本信息列表", notes = "获取微信基本信息列表")
    public MixEnvelop getWxWechatList(@ApiParam(name = "name", value = "微信名称")
                                      @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "saasName", value = "租户名称")
                                      @RequestParam(value = "saasName", required = false) String saasName,
                                      @ApiParam(name = "status", value = "状态")
                                      @RequestParam(value = "status", required = false) Integer status,
                                      @ApiParam(name = "publicType", value = "微信类型")
                                      @RequestParam(value = "publicType", required = false) Integer publicType,
                                      @ApiParam(name = "page", value = "页码")
                                      @RequestParam(value = "page", required = true) Integer page,
                                      @ApiParam(name = "size", value = "每页大小")
                                      @RequestParam(value = "size", required = true) Integer size) {
        return wechatService.getWxWechatList(name, saasName, status, publicType, page, size);
    }
}

+ 6 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/listener/ApplicationReadyListener.java

@ -1,6 +1,7 @@
package com.yihu.jw.base.listener;
import com.yihu.jw.base.activemq.MessageManager;
import com.yihu.jw.base.service.errorCode.ErrorCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
@ -15,10 +16,15 @@ public class ApplicationReadyListener implements ApplicationListener<Application
    @Autowired
    private MessageManager messageManager;
    @Autowired
    private ErrorCodeService errorCodeService;
    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        //mq消息队列
        messageManager.initConsumer();
        //初始化错误码
        errorCodeService.initErrorCode();
    }
}

+ 69 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/errorCode/ErrorCodeService.java

@ -0,0 +1,69 @@
package com.yihu.jw.base.service.errorCode;
import com.yihu.jw.base.dao.errorCode.ErrorCodeDao;
import com.yihu.jw.entity.base.dict.ErrorCodeDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
/**
 * @author yeshijie on 2018/9/26.
 */
@Service
public class ErrorCodeService extends BaseJpaService<ErrorCodeDO, ErrorCodeDao> {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private ErrorCodeDao errorCodeDao;
    /**
     * 初始化错误码,如果redis没有则查询数据库导入到redis中
     */
    public void initErrorCode(){
        String msg = redisTemplate.opsForValue().get(BaseErrorCode.PREFIX + BaseErrorCode.Common.FAIL_CREATE);
        if(StringUtils.isBlank(msg)){
            Iterable<ErrorCodeDO> list = errorCodeDao.findAll();
            list.forEach(code->{
                redisTemplate.opsForValue().set(BaseErrorCode.PREFIX + code.getErrorCode(),code.getErrorMsg());
            });
        }
    }
    /**
     * 新增
     * @param errorCodeDO
     */
    public ErrorCodeDO addErrorCode(ErrorCodeDO errorCodeDO){
        errorCodeDao.save(errorCodeDO);
        redisTemplate.opsForValue().set(BaseErrorCode.PREFIX + errorCodeDO.getErrorCode(),errorCodeDO.getErrorMsg());
        return errorCodeDO;
    }
    /**
     * 修改
     * @param id
     * @param msg
     */
    public ErrorCodeDO updateMsg(String id,String msg){
        ErrorCodeDO errorCodeDO = errorCodeDao.findOne(id);
        errorCodeDO.setErrorMsg(msg);
        errorCodeDao.save(errorCodeDO);
        redisTemplate.opsForValue().set(BaseErrorCode.PREFIX + errorCodeDO.getErrorCode(),msg);
        return errorCodeDO;
    }
    /**
     * 错误码是否存在
     * @param errorCode
     * @return
     */
    public int isExistsErrorCode(String errorCode){
        return errorCodeDao.isExistsErrorCode(errorCode);
    }
}

+ 29 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/role/MenuService.java

@ -0,0 +1,29 @@
package com.yihu.jw.base.service.role;
import com.yihu.jw.base.dao.role.MenuDao;
import com.yihu.jw.entity.base.role.MenuDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * 菜单
 * @author yeshijie on 2018/9/26.
 */
@Service
public class MenuService extends BaseJpaService<MenuDO, MenuDao> {
    @Autowired
    private MenuDao menuDao;
    /**
     * 设置生效和失效
     * @param id
     * @param status
     */
    @Transactional
    public void updateStatus(String id,Integer status){
        menuDao.updateStatus(id,status);
    }
}

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/role/RoleMenuService.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.service.role;
import com.yihu.jw.base.dao.role.RoleMenuDao;
import com.yihu.jw.entity.base.role.RoleMenuDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * 角色菜单
 * @author yeshijie on 2018/9/26.
 */
@Service
public class RoleMenuService extends BaseJpaService<RoleMenuDO, RoleMenuDao> {
}

+ 97 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -1,13 +1,109 @@
package com.yihu.jw.base.service.wx;
import com.yihu.jw.restmodel.base.saas.SaasVO;
import com.yihu.jw.restmodel.base.wx.WxSaasVO;
import com.yihu.jw.restmodel.base.wx.WxWechatVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/5/20 0020.
 * Created by trick on 2017/5/20 0020.
 */
@Service
@Transactional
public class WechatService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public MixEnvelop getWxWechatList(String name,String saasName,Integer status,Integer publicType,Integer page,Integer size){
        String sql = "SELECT " +
                " w.id, " +
                " w.name, " +
                " w.`status`, " +
                " w.type, " +
                " w.public_type AS publicType," +
                " w.remark " +
                " FROM " +
                " wx_wechat w ";
        if (StringUtils.isNotBlank(saasName)) {
            sql += " JOIN wx_wechat_saas s ON w.id = s.wechat_id" +
                    " JOIN base_saas bs ON s.saas_id = bs.id ";
        }
        sql += " WHERE 1=1 ";
        if (StringUtils.isNotBlank(name)) {
            sql += " AND w.`name` LIKE '%" + name + "%' ";
        }
        if (publicType!=null) {
            sql += " AND w.public_type = " + publicType + " " ;
        }
        if (status!=null) {
            sql += " AND w.`status` = " + status + "";
        }
        if (StringUtils.isNotBlank(saasName)) {
            sql += " AND bs.`name` like '%" + saasName + "%'";
        }
        sql += "LIMIT " + (page - 1) * size + "," + size + "";
        List<WxWechatVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxWechatVO.class));
        if(list!=null&&list.size()>0){
            for(WxWechatVO wx :list){
                wx.setSaas(getWxSaasVOs(wx.getId()));
            }
        }
        String countSql = "SELECT count(1) AS total"+
                " FROM " +
                " wx_wechat w ";;
        if (StringUtils.isNotBlank(saasName)) {
            countSql += " JOIN wx_wechat_saas s ON w.id = s.wechat_id" +
                    " JOIN base_saas bs ON s.saas_id = bs.id ";
        }
        countSql += " WHERE 1=1 ";
        if (StringUtils.isNotBlank(name)) {
            sql += " AND w.`name` LIKE '%" + name + "%' ";
        }
        if (publicType!=null) {
            sql += " AND w.public_type = " + publicType + " " ;
        }
        if (status!=null) {
            sql += " AND w.`status` = " + status + "";
        }
        if (StringUtils.isNotBlank(saasName)) {
            countSql += " AND bs.`name` like '%" + saasName + "%'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(countSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success, list, page, size, count);
    }
    public List<WxSaasVO> getWxSaasVOs(String id){
        String sql ="SELECT " +
                " bs.`name` AS saasName, " +
                " bs.id AS saasid" +
                " FROM " +
                " wx_wechat_saas s " +
                " JOIN base_saas bs ON s.saas_id = s.saas_id " +
                " WHERE " +
                " s.wechat_id = '"+id+"'";
        List<WxSaasVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxSaasVO.class));
        return list;
    }
}

+ 26 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/ErrorCodeUtil.java

@ -0,0 +1,26 @@
package com.yihu.jw.base.util;
import com.yihu.jw.exception.code.BaseErrorCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
/**
 * 错误码工具类
 * @author yeshijie on 2018/9/26.
 */
@Component
public class ErrorCodeUtil {
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 根据错误码获取错误提示信息
     * @param errorCode
     * @return
     */
    public String getErrorMsg(String errorCode){
        return redisTemplate.opsForValue().get(BaseErrorCode.PREFIX+errorCode);
    }
}

+ 27 - 4
svr/svr-base/src/main/resources/application.yml

@ -20,10 +20,18 @@ spring:
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  sleuth:
    sampler:
      percentage: 1.0 #采用需要的请求的百分比 默认是0.1 即 10%
#  sleuth:
#    sampler:
#      percentage: 1.0 #采用需要的请求的百分比 默认是0.1 即 10%
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.
    timeout: 120000 # 连接超时时间(毫秒) 60秒
    pool:
      max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
      max-wait: -1  # 连接池最大阻塞等待时间(使用负值表示没有限制)
      max-idle: 20  # 连接池中的最大空闲连接
      min-idle: 5  # 连接池中的最小空闲连接
es:
  index:
    servicePackLog: base_service_package_log
@ -43,6 +51,9 @@ fast-dfs:
    init-size: 5
    max-size: 20
    wait-time: 500
configDefault: # 默认配置
  saasId: xmjkzl_saasId
---
spring:
  profiles: jwdev
@ -62,6 +73,10 @@ spring:
    broker-url: tcp://172.19.103.87:61616
    user: admin
    password: admin
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#  zipkin:
#    base-url: http://localhost:9411 #日志追踪的地址
fastDFS:
@ -88,6 +103,10 @@ spring:
    broker-url: tcp://172.19.103.87:61616
    user: admin
    password: admin
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#  zipkin:
#    base-url: http://localhost:9411 #日志追踪的地址
fastDFS:
@ -112,6 +131,10 @@ spring:
    broker-url: tcp://59.61.92.90:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
#  zipkin:
#    base-url: http://localhost:9411 #日志追踪的地址
fastDFS:

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

@ -185,6 +185,9 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            @ApiParam(name = "facilitiesId", value = "设施ID")
            @RequestParam(value = "facilitiesId") String facilitiesId) throws Exception {
        Facility facility = facilityService.findById(facilitiesId);
        if (null == facility) {
            return failed("设施不存在!");
        }
        List<FacilityServerRelation> facilityServerRelationList = facilityServerRelationService.findByField("facilitieCode", facility.getCode());
        //通过设施与服务关系,变更设施服务使用数量
        for (FacilityServerRelation facilityServerRelation : facilityServerRelationList) {
@ -241,7 +244,6 @@ public class FacilitiesController extends EnvelopRestEndpoint {
    }
    @GetMapping("/exportToExcel")
    @ApiOperation(value = "设施列表导出excel")
    public void exportToExcel(
@ -259,7 +261,6 @@ public class FacilitiesController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = "/batchImport")
    @ApiOperation(value = "设施列表导入(经纬度重复的不导入)")
    public ObjEnvelop importData(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException, ManageException {
@ -279,6 +280,38 @@ public class FacilitiesController extends EnvelopRestEndpoint {
        return ObjEnvelop.getError("导入失败");
    }
    @ApiOperation(value = "获取设施列表--不分页(app)", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_FACILITIELIST)
    public ListEnvelop<Facility> getFacilitieLists(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<Facility> facilityList = facilityService.search(fields, filters, sorts);
        return success(facilityList);
    }
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.GET_ALL_FACILITIELISTS_COUNT)
    @ApiOperation(value = "设施统计-三个统计值")
    public ObjEnvelop<Map> usedFacilityCount() throws Exception {
        Map<String, Long> map = new HashMap<>();
        //今日使用设施数
        long countUsedFacilitieToday = facilityServerRelationService.countDistinctByFacilitieCodeAndCreateTimeBetween();
        map.put("countUsedFacilitieToday",countUsedFacilitieToday);
        long countAllFacilitie = facilityService.getCount("");
        map.put("countAllFacilitie",countAllFacilitie);
        //今日新增设施:false
        String todayStart = DateUtil.getStringDateShort() + " " + "00:00:00";
        String todayEnd = DateUtil.getStringDateShort() + " " + "23:59:59";
        String  filters = "createTime>=" + todayStart + ";createTime<=" + todayEnd;
        long countCreatedFacilitieToday = facilityService.getCount(filters);
        map.put("countCreatedFacilitieToday",countCreatedFacilitieToday);
        return ObjEnvelop.getSuccess("获取成功", map);
    }
//    @ApiOperation(value = "搜索附近的小屋", responseContainer = "List")
//    @GetMapping(value = HealthyHouseMapping.HealthyHouse.Facilities.NEARBY_FACILITY)

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

@ -32,7 +32,7 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
    @Autowired
    private FacilityUsedRecordService facilityUsedRecordService;
    @ApiOperation(value = "获取用户使用导航记录列表", responseContainer = "List")
    @ApiOperation(value = "获取用户使用导航记录列表--分页(web)", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.PAGE)
    public PageEnvelop<FacilityUsedRecord> getFacilityUsedRecords(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
@ -58,7 +58,7 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
        return success(facilityUsedRecord);
    }
    @ApiOperation(value = "获取用户使用导航记录")
    @ApiOperation(value = "获取记录id查找导航记录")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.GET_FACILITY_USED_RECORD_BY_ID)
    public ObjEnvelop<FacilityUsedRecord> getFacilityUsedRecord(
            @ApiParam(name = "id", value = "用户使用导航记录ID", defaultValue = "")
@ -91,4 +91,41 @@ public class FacilityUsedRecordController extends EnvelopRestEndpoint {
        return success("success");
    }
    @ApiOperation(value = "获取用户查找导航记录,包含设施使用次数统计")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.GET_FACILITY_USED_RECORD_AND_COUNT_BY_ID)
    public PageEnvelop<FacilityUsedRecord> getFacilityUsedRecordAndCountById(
            @ApiParam(name = "userId", value = "用户ID", defaultValue = "")
            @RequestParam(value = "userId") String userId,
            @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 {
        //根据用户id
        List<FacilityUsedRecord> facilityUsedRecordList = facilityUsedRecordService.countDistinctByFacilitieCodeAndUserId(userId, page, size);
        for (FacilityUsedRecord facilityUsedRecord1 : facilityUsedRecordList) {
            long count = facilityUsedRecordService.countByFacilitieCodeAndUserId(facilityUsedRecord1.getFacilitieCode(), userId);
            facilityUsedRecord1.setNum((int) count);
        }
        int total=(int)facilityUsedRecordService.countPageDistinctByFacilitieCodeAndUserId(userId);
        return success(facilityUsedRecordList, total, page, size);
    }
    @ApiOperation(value = "app-用户使用设施次数", responseContainer = "List")
    @GetMapping(value = HealthyHouseMapping.HealthyHouse.FacilityUsedRecord.COUNT_FACILITY_USED_RECORD_BY_USERID)
    public ObjEnvelop<Long> getFacilityUsedRecords(
            @ApiParam(name = "userId", value = "登录用户id", defaultValue = "")
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "facilitieCode", value = "设施id", defaultValue = "")
            @RequestParam(value = "facilitieCode", required = false) String facilitieCode) throws Exception {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("userId=" + userId + ";");
        if (StringUtils.isNotEmpty(facilitieCode)) {
            stringBuffer.append("facilitieCode=" + facilitieCode);
        }
        String filters = stringBuffer.toString();
        long count = facilityUsedRecordService.getCount(filters);
        return success(count);
    }
}

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

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

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

@ -4,9 +4,12 @@ import com.yihu.jw.healthyhouse.dao.user.FacilityUsedRecordDao;
import com.yihu.jw.healthyhouse.model.user.FacilityUsedRecord;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
 * 用户导航记录.
 *
@ -22,7 +25,7 @@ public class FacilityUsedRecordService extends BaseJpaService<FacilityUsedRecord
    private FacilityUsedRecordDao facilityUsedRecordDao;
    public FacilityUsedRecord findById(String id) {
        return  facilityUsedRecordDao.findById(id);
        return facilityUsedRecordDao.findById(id);
    }
    public Long countByUserId(String userId){
@ -33,4 +36,22 @@ public class FacilityUsedRecordService extends BaseJpaService<FacilityUsedRecord
        return facilityUsedRecordDao.countAllByUserIdIsNotNull();
    }
    public List<FacilityUsedRecord> countDistinctByFacilitieCodeAndUserId(String userId,Integer page,Integer size) throws Exception {
        Integer pageStart = (page - 1) * size;
        Integer pageEnd = page * size;
        String sql = "select fur.*  from facility_used_records  fur WHERE  fur.user_id=? GROUP BY fur.facilitie_code LIMIT "+pageStart+","+pageEnd;
        List<FacilityUsedRecord> facilityUsedRecords = jdbcTemplate.query(sql, new BeanPropertyRowMapper(FacilityUsedRecord.class), userId);
        return facilityUsedRecords;
    }
    public long countPageDistinctByFacilitieCodeAndUserId(String userId) throws Exception {
        String sql = "select count(DISTINCT facilitie_code )  from facility_used_records  fur WHERE  fur.user_id=? ";
        String count = jdbcTemplate.queryForObject(sql, String.class,userId);
        return Long.parseLong(count);
    }
    public long countByFacilitieCodeAndUserId(String facilitieCode,String userId) {
        return facilityUsedRecordDao.countByFacilitieCodeAndUserId( facilitieCode, userId);
    }
}