소스 검색

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

LiTaohong 6 년 전
부모
커밋
dd24bc9ea2
37개의 변경된 파일582개의 추가작업 그리고 80개의 파일을 삭제
  1. 14 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/role/MenuDO.java
  2. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/user/UserDO.java
  3. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxReplySceneDO.java
  4. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxTemplateConfigDO.java
  5. 2 10
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxTemplateDO.java
  6. 8 0
      common/common-exception/src/main/java/com/yihu/jw/exception/code/BaseErrorCode.java
  7. 7 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  8. 9 0
      common/common-rest-model/pom.xml
  9. 10 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/MenuVO.java
  10. 11 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/user/UserVO.java
  11. 21 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java
  12. 4 0
      common/common-util/src/main/java/com/yihu/jw/util/wechat/WeiXinMessageUtils.java
  13. 12 4
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  14. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasModuleDao.java
  15. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/saas/SaasDao.java
  16. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/user/UserDao.java
  17. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxReplySceneDao.java
  18. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxTemplateConfigDao.java
  19. 5 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxTemplateDao.java
  20. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/InterfaceEndpoint.java
  21. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/ModuleEndpoint.java
  22. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/SaasInterfaceEndpoint.java
  23. 8 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java
  24. 14 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/population/BasePopulationEndpoint.java
  25. 6 7
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/role/MenuEndpoint.java
  26. 41 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java
  27. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEndpoint.java
  28. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEntryEndpoint.java
  29. 46 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java
  30. 2 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WxTemplateController.java
  31. 46 12
      svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java
  32. 30 9
      svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java
  33. 5 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatCoreService.java
  34. 58 4
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java
  35. 56 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WxTemplateService.java
  36. 48 0
      svr/svr-base/src/main/java/com/yihu/jw/base/util/ValidateUtil.java
  37. 30 20
      svr/svr-iot/src/main/java/com/yihu/iot/controller/analyzer/IotAnalyzerController.java

+ 14 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/role/MenuDO.java

@ -48,6 +48,11 @@ public class MenuDO extends UuidIdentityEntityWithOperator {
	 */
	 */
	private String remark;
	private String remark;
	/**
	 * 是否展示(1是,2否)
     */
	private Integer show;
	@Column(name = "saas_id", length = 50)
	@Column(name = "saas_id", length = 50)
	public String getSaasId() {
	public String getSaasId() {
		return this.saasId;
		return this.saasId;
@ -128,4 +133,13 @@ public class MenuDO extends UuidIdentityEntityWithOperator {
	public void setMethod(String method) {
	public void setMethod(String method) {
		this.method = method;
		this.method = method;
	}
	}
	@Column(name = "is_show")
	public Integer getShow() {
		return show;
	}
	public void setShow(Integer show) {
		this.show = show;
	}
}
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/user/UserDO.java

@ -55,6 +55,8 @@ public class UserDO extends UuidIdentityEntityWithOperator {
    private Date loginDate;
    private Date loginDate;
    //登陆失败次数
    //登陆失败次数
    private Integer loginFailureCount;
    private Integer loginFailureCount;
    //saas化的id
    private String  saasId;
    public UserDO(){}
    public UserDO(){}
@ -189,4 +191,12 @@ public class UserDO extends UuidIdentityEntityWithOperator {
    public void setLoginFailureCount(Integer loginFailureCount) {
    public void setLoginFailureCount(Integer loginFailureCount) {
        this.loginFailureCount = loginFailureCount;
        this.loginFailureCount = loginFailureCount;
    }
    }
    @Column(name = "saas_id",nullable = false)
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
}
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxReplySceneDO.java

@ -20,6 +20,7 @@ public class WxReplySceneDO extends UuidIdentityEntityWithOperator implements ja
    private String event;//微信事件类型:SCAN,LOCATION,CLICK,subscribe,unsubscribe
    private String event;//微信事件类型:SCAN,LOCATION,CLICK,subscribe,unsubscribe
    private String scene;//图文消息/自定义消息,分组场景,微信的eventKey
    private String scene;//图文消息/自定义消息,分组场景,微信的eventKey
    private String content;//居民回复内容,消息字段
    private String content;//居民回复内容,消息字段
    private String defaultReply;//如果值为:default, 则是微信默认回复配置发送的图文
    private Integer status;//状态(-1删除 0 冻结 1可用
    private Integer status;//状态(-1删除 0 冻结 1可用
    @Column(name = "wechat_id")
    @Column(name = "wechat_id")
@ -76,6 +77,15 @@ public class WxReplySceneDO extends UuidIdentityEntityWithOperator implements ja
        this.content = content;
        this.content = content;
    }
    }
    @Column(name = "default_reply")
    public String getDefaultReply() {
        return defaultReply;
    }
    public void setDefaultReply(String defaultReply) {
        this.defaultReply = defaultReply;
    }
    @Column(name = "status")
    @Column(name = "status")
    public Integer getStatus() {
    public Integer getStatus() {
        return status;
        return status;

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxTemplateConfigDO.java

@ -30,6 +30,7 @@ public class WxTemplateConfigDO extends UuidIdentityEntityWithOperator implement
    private String keyword7;//项目
    private String keyword7;//项目
    private String appid;//跳转小程序的appid
    private String appid;//跳转小程序的appid
    private String pagepath;//跳转小程序路径
    private String pagepath;//跳转小程序路径
    private Integer status;//状态 1:正常 -1:删除
    @Column(name = "wechat_id")
    @Column(name = "wechat_id")
    public String getWechatId() {
    public String getWechatId() {
@ -185,4 +186,13 @@ public class WxTemplateConfigDO extends UuidIdentityEntityWithOperator implement
    public void setPagepath(String pagepath) {
    public void setPagepath(String pagepath) {
        this.pagepath = pagepath;
        this.pagepath = pagepath;
    }
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}
}

+ 2 - 10
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxTemplateDO.java

@ -17,8 +17,6 @@ public class WxTemplateDO extends UuidIdentityEntityWithOperator implements java
    // Fields
    // Fields
    private String title;//模板标题
    private String title;//模板标题
    private String wechatId;//关联的微信code 关联表 Wx_Wechat
    private String wechatId;//关联的微信code 关联表 Wx_Wechat
    @Transient
    private String wechatName;
    private String templateId;//微信模板id
    private String templateId;//微信模板id
    private String templateName;//模板名称(模板检索名称)
    private String templateName;//模板名称(模板检索名称)
    private String content;//模板内容
    private String content;//模板内容
@ -76,10 +74,11 @@ public class WxTemplateDO extends UuidIdentityEntityWithOperator implements java
        this.content = content;
        this.content = content;
    }
    }
    @Column(name = "status", length = 2)
    public Integer getStatus() {
    public Integer getStatus() {
        return status;
        return status;
    }
    }
    // Constructors
    public void setStatus(Integer status) {
    public void setStatus(Integer status) {
        this.status = status;
        this.status = status;
@ -94,11 +93,4 @@ public class WxTemplateDO extends UuidIdentityEntityWithOperator implements java
        this.remark = remark;
        this.remark = remark;
    }
    }
    public String getWechatName() {
        return wechatName;
    }
    public void setWechatName(String wechatName) {
        this.wechatName = wechatName;
    }
}
}

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

@ -59,6 +59,14 @@ public class BaseErrorCode {
         * 只有审核未通过才可以查看
         * 只有审核未通过才可以查看
         */
         */
        public static final String IS_NOT_AUDITNOTPASSED = "-101006";
        public static final String IS_NOT_AUDITNOTPASSED = "-101006";
        /**
         * 邮箱地址格式错误
         */
        public static final String EMAIL_IS_NOT_FORMAT = "-101007";
        /**
         * 手机号码格式错误
         */
        public static final String PHONE_IS_NOT_FORMAT = "-101008";
    }
    }
    /**
    /**

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

@ -19,6 +19,7 @@ public class BaseRequestMapping {
        public static final String PAGE = "/page";
        public static final String PAGE = "/page";
        public static final String LIST = "/list";
        public static final String LIST = "/list";
        public static final String FINDBYID = "/findById";
        public static final String FINDBYID = "/findById";
        public static final String FIND_MODULE_BY_SAASID = "/findModuleBySaasId";
        public static final String STATUS = "/status";
        public static final String STATUS = "/status";
    }
    }
@ -136,6 +137,7 @@ public class BaseRequestMapping {
    public static class SystemDict extends Basic {
    public static class SystemDict extends Basic {
        public static final String PREFIX  = "/system_dict";
        public static final String PREFIX  = "/system_dict";
        public static final String ALL  = "/query_all";
        public static final String ALL  = "/query_all";
        public static final String QUERY_BY_SAASID = "/queryBySaasId";
        public static final String QUERY_BY_TYPE  = "/query_by_type";
        public static final String QUERY_BY_TYPE  = "/query_by_type";
    }
    }
@ -144,6 +146,7 @@ public class BaseRequestMapping {
     */
     */
    public static class SystemDictEntry extends Basic {
    public static class SystemDictEntry extends Basic {
        public static final String PREFIX  = "/system_dict_entry";
        public static final String PREFIX  = "/system_dict_entry";
        public static final String PAGE_SAASID  = "/pageSaasId";
    }
    }
    /**
    /**
@ -256,14 +259,17 @@ public class BaseRequestMapping {
        public static final String deleteImgGroupRelation ="/deleteImgGroupRelation";
        public static final String deleteImgGroupRelation ="/deleteImgGroupRelation";
        public static final String saveWxReplyScene ="/saveWxReplyScene";
        public static final String saveWxReplyScene ="/saveWxReplyScene";
        public static final String findDefaultReply ="/findDefaultReply";
        public static final String findWxReplySceneExist ="/findWxReplySceneExist";
        public static final String findWxReplySceneExist ="/findWxReplySceneExist";
        public static final String findWxReplyScene ="/findWxReplyScene";
        public static final String findWxReplyScene ="/findWxReplyScene";
        public static final String saveWxTemp ="/saveWxTemp";
        public static final String saveWxTemp ="/saveWxTemp";
        public static final String findWxTempExist ="/findWxTempExist";
        public static final String findWxtemp ="/findWxtemp";
        public static final String findWxtemp ="/findWxtemp";
        public static final String saveWxTempConfig ="/saveWxTempConfig";
        public static final String saveWxTempConfig ="/saveWxTempConfig";
        public static final String findWxTempConfigList ="/findWxTempConfigList";
        public static final String findWxTempConfigList ="/findWxTempConfigList";
        public static final String findWxTemplateConfig ="/findWxTemplateConfig";
        public static final String findWxTemplateConfig ="/findWxTemplateConfig";
        public static final String findWxTemplateConfigExist ="/findWxTemplateConfigExist";
        public static final String getAllTemp ="/getAllTemp";
        public static final String getusersummary ="/getusersummary";
        public static final String getusersummary ="/getusersummary";
        public static final String getusercumulate ="/getusercumulate";
        public static final String getusercumulate ="/getusercumulate";

+ 9 - 0
common/common-rest-model/pom.xml

@ -51,5 +51,14 @@
            <groupId>org.slf4j</groupId>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
    </dependencies>
    </dependencies>
</project>
</project>

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

@ -29,6 +29,8 @@ public class MenuVO extends UuidIdentityVOWithOperator {
    private Integer status;
    private Integer status;
    @ApiModelProperty(value = "备注", example = "说明")
    @ApiModelProperty(value = "备注", example = "说明")
    private String remark;
    private String remark;
    @ApiModelProperty(value = "是否展示(1是,2否)", example = "1")
    private Integer show;
    @ApiModelProperty(value = "子集")
    @ApiModelProperty(value = "子集")
    private List<MenuVO> children = new ArrayList<>();
    private List<MenuVO> children = new ArrayList<>();
@ -88,6 +90,14 @@ public class MenuVO extends UuidIdentityVOWithOperator {
        this.remark = remark;
        this.remark = remark;
    }
    }
    public Integer getShow() {
        return show;
    }
    public void setShow(Integer show) {
        this.show = show;
    }
    public List<MenuVO> getChildren() {
    public List<MenuVO> getChildren() {
        return children;
        return children;
    }
    }

+ 11 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/user/UserVO.java

@ -56,6 +56,9 @@ public class UserVO extends UuidIdentityVOWithOperator {
    //登陆失败次数
    //登陆失败次数
    @ApiModelProperty(value = "登陆失败次数", example = "0")
    @ApiModelProperty(value = "登陆失败次数", example = "0")
    private Integer loginFailureCount;
    private Integer loginFailureCount;
    //saas化的id
    @ApiModelProperty(value = "saadid", example = "25f9e794323b453885f5181f1b620009")
    private String  saasId;
    public String getUsername() {
    public String getUsername() {
        return username;
        return username;
@ -170,4 +173,12 @@ public class UserVO extends UuidIdentityVOWithOperator {
    public void setLoginFailureCount(Integer loginFailureCount) {
    public void setLoginFailureCount(Integer loginFailureCount) {
        this.loginFailureCount = loginFailureCount;
        this.loginFailureCount = loginFailureCount;
    }
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
}
}

+ 21 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java

@ -1,11 +1,16 @@
package com.yihu.jw.restmodel.web.endpoint;
package com.yihu.jw.restmodel.web.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
@ -332,4 +337,20 @@ public abstract class EnvelopRestEndpoint {
        return links.toString();
        return links.toString();
    }
    }
    public String getUID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
}
}

+ 4 - 0
common/common-util/src/main/java/com/yihu/jw/util/wechat/WeiXinMessageUtils.java

@ -46,6 +46,10 @@ public class WeiXinMessageUtils {
    // 响应消息类型:图文
    // 响应消息类型:图文
    public static final String RESP_MESSAGE_TYPE_NEWS = "news";
    public static final String RESP_MESSAGE_TYPE_NEWS = "news";
    //默认值
    public static final String RESP_MESSAGE_DEFAULT = "default";
//    public static BaseMessage messageProcess(){
//    public static BaseMessage messageProcess(){
//        BaseMessage message = null;
//        BaseMessage message = null;
//
//

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

@ -10,6 +10,7 @@ import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.utils.security.RSAUtils;
import com.yihu.utils.security.RSAUtils;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -38,11 +39,13 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.PostConstruct;
import javax.annotation.PostConstruct;
import javax.crypto.Cipher;
import javax.servlet.http.Cookie;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.IOException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
@ -118,10 +121,12 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            parameters.put("grant_type", "password");
            //解密密码
            //解密密码
            if (parameters.get("password") != null) {
                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
            }
//            if (parameters.get("password") != null) {
//                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
////                byte[] en_data = Hex.decodeHex(parameters.get("password").toCharArray());
////                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(en_data), rsaPrivateKey));
//                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
//            }
        } else {
        } else {
            parameters.put("grant_type", "captcha");
            parameters.put("grant_type", "captcha");
        }
        }
@ -246,6 +251,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        PublicKey publicKey = new PublicKey();
        PublicKey publicKey = new PublicKey();
        publicKey.setModulus(Base64.encodeBase64String(rsaPublicKey.getModulus().toByteArray()));
        publicKey.setModulus(Base64.encodeBase64String(rsaPublicKey.getModulus().toByteArray()));
        publicKey.setExponent(Base64.encodeBase64String(rsaPublicKey.getPublicExponent().toByteArray()));
        publicKey.setExponent(Base64.encodeBase64String(rsaPublicKey.getPublicExponent().toByteArray()));
//        publicKey.setModulus(new String(Hex.encodeHex(rsaPublicKey.getModulus().toByteArray())));
//        publicKey.setExponent(new String(Hex.encodeHex(rsaPublicKey.getPublicExponent().toByteArray())));
        httpSession.setAttribute("privateKey", rsaPrivateKey);
        httpSession.setAttribute("privateKey", rsaPrivateKey);
        //生成Cookie
        //生成Cookie
        Cookie cookie = new Cookie("oauth2", UUID.randomUUID().toString());
        Cookie cookie = new Cookie("oauth2", UUID.randomUUID().toString());
@ -415,4 +422,5 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        return response;
        return response;
    }
    }
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasModuleDao.java

@ -21,5 +21,9 @@ public interface SaasModuleDao extends PagingAndSortingRepository<SaasModuleDO,
    @Query("delete from SaasModuleDO p where p.moduleId=?1 ")
    @Query("delete from SaasModuleDO p where p.moduleId=?1 ")
    void deleteByModuleId(String moduleId);
    void deleteByModuleId(String moduleId);
    @Modifying
    @Query("delete from SaasModuleDO p where p.saasId=?1 ")
    void deleteBySaasId(String saasId);
    List<SaasModuleDO> findByModuleId(String moduleId);
    List<SaasModuleDO> findByModuleId(String moduleId);
}
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/saas/SaasDao.java

@ -12,4 +12,6 @@ public interface SaasDao extends PagingAndSortingRepository<SaasDO, String> {
    SaasDO findByName(String name);
    SaasDO findByName(String name);
    SaasDO findById(String id);
    SaasDO findById(String id);
    SaasDO findByCreateUser(String createUser);
}
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/user/UserDao.java

@ -21,4 +21,6 @@ public interface UserDao extends PagingAndSortingRepository<UserDO, String>, Jpa
    boolean existsByMobile(String mobile);
    boolean existsByMobile(String mobile);
    boolean existsByUsername(String username);
    boolean existsByUsername(String username);
    UserDO findByUsername(String username);
}
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxReplySceneDao.java

@ -25,5 +25,7 @@ public interface WxReplySceneDao extends PagingAndSortingRepository<WxReplyScene
    //点击事件,扫码事件,是否存在相同场景值
    //点击事件,扫码事件,是否存在相同场景值
    List<WxReplySceneDO> findByWechatIdAndMsgTypeAndEventAndSceneAndStatus(String wechatId,String msgType,String event,String scene,Integer status);
    List<WxReplySceneDO> findByWechatIdAndMsgTypeAndEventAndSceneAndStatus(String wechatId,String msgType,String event,String scene,Integer status);
    List<WxReplySceneDO> findByWechatIdAndDefaultReply(String wechatId,String defaultReply);
    List<WxReplySceneDO> findByAppOriginIdAndAndDefaultReply(String appOriginId,String defaultReply);
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxTemplateConfigDao.java

@ -5,11 +5,15 @@ import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
/**
 * Created by Trick on 2018/8/21.
 * Created by Trick on 2018/8/21.
 */
 */
public interface WxTemplateConfigDao extends PagingAndSortingRepository<WxTemplateConfigDO, String>, JpaSpecificationExecutor<WxTemplateConfigDO> {
public interface WxTemplateConfigDao extends PagingAndSortingRepository<WxTemplateConfigDO, String>, JpaSpecificationExecutor<WxTemplateConfigDO> {
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndSceneAndStatus(String wechatId, String templateName, String scene,Integer status);
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndScene(String wechatId, String templateName, String scene);
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndScene(String wechatId, String templateName, String scene);
    List<WxTemplateConfigDO> findByWechatIdAndScene(String wechatId,String scene);
}
}

+ 5 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxTemplateDao.java

@ -18,4 +18,9 @@ public interface WxTemplateDao extends PagingAndSortingRepository<WxTemplateDO,
    @Query("from WxTemplateDO w where w.wechatId = ?1 and w.status =1")
    @Query("from WxTemplateDO w where w.wechatId = ?1 and w.status =1")
    List<WxTemplateDO> findByWxId(String wechatId);
    List<WxTemplateDO> findByWxId(String wechatId);
    List<WxTemplateDO> findByTemplateIdAndWechatId(String templateId,String wechatId);
    List<WxTemplateDO> findByTemplateNameAndWechatId(String templateId,String wechatId);
}
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/InterfaceEndpoint.java

@ -37,7 +37,7 @@ public class InterfaceEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Interface.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Interface.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    @ApiOperation(value = "创建")
    public ObjEnvelop<InterfaceVO> create (
    public ObjEnvelop<InterfaceVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData) throws Exception {
        InterfaceDO interfaceDO = toEntity(jsonData, InterfaceDO.class);
        InterfaceDO interfaceDO = toEntity(jsonData, InterfaceDO.class);
@ -78,7 +78,7 @@ public class InterfaceEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Interface.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Interface.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    @ApiOperation(value = "更新")
    public ObjEnvelop<InterfaceVO> update (
    public ObjEnvelop<InterfaceVO> update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData) throws Exception {
        InterfaceDO interfaceDO = toEntity(jsonData, InterfaceDO.class);
        InterfaceDO interfaceDO = toEntity(jsonData, InterfaceDO.class);
        if (null == interfaceDO.getId()) {
        if (null == interfaceDO.getId()) {

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/ModuleEndpoint.java

@ -41,7 +41,7 @@ public class ModuleEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Module.CREATE)
    @PostMapping(value = BaseRequestMapping.Module.CREATE)
    @ApiOperation(value = "创建")
    @ApiOperation(value = "创建")
    public ObjEnvelop<ModuleVO> create (
    public ObjEnvelop<ModuleVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData) throws Exception {
        ModuleDO module = toEntity(jsonData, ModuleDO.class);
        ModuleDO module = toEntity(jsonData, ModuleDO.class);
        int count = moduleService.isExistName(module.getName());
        int count = moduleService.isExistName(module.getName());
@ -83,7 +83,7 @@ public class ModuleEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Module.UPDATE)
    @PostMapping(value = BaseRequestMapping.Module.UPDATE)
    @ApiOperation(value = "更新")
    @ApiOperation(value = "更新")
    public ObjEnvelop<ModuleVO> update (
    public ObjEnvelop<ModuleVO> update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData) throws Exception {
        ModuleDO module = toEntity(jsonData, ModuleDO.class);
        ModuleDO module = toEntity(jsonData, ModuleDO.class);
        if (null == module.getId()) {
        if (null == module.getId()) {

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/SaasInterfaceEndpoint.java

@ -37,7 +37,7 @@ public class SaasInterfaceEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.SaasInterface.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.SaasInterface.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    @ApiOperation(value = "创建")
    public ObjEnvelop<SaasInterfaceVO> create (
    public ObjEnvelop<SaasInterfaceVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData) throws Exception {
        SaasInterfaceDO interfaceDO = toEntity(jsonData, SaasInterfaceDO.class);
        SaasInterfaceDO interfaceDO = toEntity(jsonData, SaasInterfaceDO.class);
@ -78,7 +78,7 @@ public class SaasInterfaceEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.SaasInterface.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.SaasInterface.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    @ApiOperation(value = "更新")
    public ObjEnvelop<SaasInterfaceVO> update (
    public ObjEnvelop<SaasInterfaceVO> update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData) throws Exception {
        SaasInterfaceDO interfaceDO = toEntity(jsonData, SaasInterfaceDO.class);
        SaasInterfaceDO interfaceDO = toEntity(jsonData, SaasInterfaceDO.class);
        if (null == interfaceDO.getId()) {
        if (null == interfaceDO.getId()) {

+ 8 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java

@ -5,6 +5,7 @@ import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.ValidateUtil;
import com.yihu.jw.entity.base.saas.BaseEmailTemplateConfigDO;
import com.yihu.jw.entity.base.saas.BaseEmailTemplateConfigDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
@ -68,6 +69,13 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
            @RequestParam String captcha) throws Exception {
            @RequestParam String captcha) throws Exception {
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        if(!ValidateUtil.isValidMobileNo(saasDO.getMobile())){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
        }
        if(!ValidateUtil.isValidEmail(saasDO.getEmail())){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
        }
        String redisKey = redisPrefix + saasDO.getEmail();
        String redisKey = redisPrefix + saasDO.getEmail();
        String verificationCode = redisTemplate.opsForValue().get(redisKey);
        String verificationCode = redisTemplate.opsForValue().get(redisKey);
        if(!captcha.equals(verificationCode)){
        if(!captcha.equals(verificationCode)){

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/population/BasePopulationEndpoint.java

@ -120,12 +120,15 @@ public class BasePopulationEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "provinceCode", required = false) String provinceCode,
            @RequestParam(value = "provinceCode", required = false) String provinceCode,
            @ApiParam(name = "cityCode", value = "城市编码")
            @ApiParam(name = "cityCode", value = "城市编码")
            @RequestParam(value = "cityCode", required = false) String cityCode,
            @RequestParam(value = "cityCode", required = false) String cityCode,
            @ApiParam(name = "createUser", value = "当前用户id-必填")
            @RequestParam(value = "createUser", required = true) String createUser,
            @ApiParam(name = "year", value = "时间")
            @ApiParam(name = "year", value = "时间")
            @RequestParam(value = "year", required = false) String year,
            @RequestParam(value = "year", required = false) String year,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
            @RequestParam(value = "size") int size) throws Exception {
       SaasDO saasDO= saasService.findByCreateUser(createUser);
        StringBuffer s = new StringBuffer();
        StringBuffer s = new StringBuffer();
        if (StringUtils.isNotBlank(saasName)) {
        if (StringUtils.isNotBlank(saasName)) {
            s.append("saasName?" + saasName + " g1;");
            s.append("saasName?" + saasName + " g1;");
@ -139,6 +142,10 @@ public class BasePopulationEndpoint extends EnvelopRestEndpoint {
        if (StringUtils.isNotBlank(year)) {
        if (StringUtils.isNotBlank(year)) {
            s.append("year=" + year + ";");
            s.append("year=" + year + ";");
        }
        }
        //一个用户对应一个租户,若没有关联的租户,则为超管,查询所有租户
        if (null != saasDO) {
            s.append("saasId=" + saasDO.getId() + ";");
        }
        //时间(最近时间排最前)>租户创建时间(最新创建租户排最前)
        //时间(最近时间排最前)>租户创建时间(最新创建租户排最前)
        String sorts = "-createTime,-saasCreateTime";
        String sorts = "-createTime,-saasCreateTime";
        String filters = s.toString();
        String filters = s.toString();
@ -154,8 +161,15 @@ public class BasePopulationEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "createUser", value = "当前用户id-必填")
            @RequestParam(value = "createUser", required = true) String createUser,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        SaasDO saasDO = saasService.findByCreateUser(createUser);
        //一个用户对应一个租户,若没有关联的租户,则为超管,查询所有租户
        if (null != saasDO) {
            filters = filters + "saasId=" + saasDO.getId() + ";";
        }
        List<BasePopulationDO> basePopulations = basePopulationService.search(fields, filters, sorts);
        List<BasePopulationDO> basePopulations = basePopulationService.search(fields, filters, sorts);
        return success(basePopulations, BasePopulationVO.class);
        return success(basePopulations, BasePopulationVO.class);
    }
    }

+ 6 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/role/MenuEndpoint.java

@ -17,7 +17,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.ArrayList;
@ -39,11 +38,11 @@ public class MenuEndpoint extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    private ErrorCodeUtil errorCodeUtil;
    @PostMapping(value = BaseRequestMapping.Menu.CREATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Menu.CREATE)
    @ApiOperation(value = "创建")
    @ApiOperation(value = "创建")
    public ObjEnvelop<MenuVO> create (
    public ObjEnvelop<MenuVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        MenuDO menuDO = toEntity(jsonData, MenuDO.class);
        MenuDO menuDO = toEntity(jsonData, MenuDO.class);
        int count = menuService.isExistName(menuDO.getName());
        int count = menuService.isExistName(menuDO.getName());
        if(count>0){
        if(count>0){
@ -90,11 +89,11 @@ public class MenuEndpoint extends EnvelopRestEndpoint {
        return success(menuService.isExistName(name));
        return success(menuService.isExistName(name));
    }
    }
    @PostMapping(value = BaseRequestMapping.Menu.UPDATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Menu.UPDATE)
    @ApiOperation(value = "更新")
    @ApiOperation(value = "更新")
    public Envelop update (
    public Envelop update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        MenuDO menuDO = toEntity(jsonData, MenuDO.class);
        MenuDO menuDO = toEntity(jsonData, MenuDO.class);
        if (null == menuDO.getId()) {
        if (null == menuDO.getId()) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), Envelop.class);

+ 41 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java

@ -1,15 +1,21 @@
package com.yihu.jw.base.endpoint.saas;
package com.yihu.jw.base.endpoint.saas;
import com.yihu.jw.base.contant.CommonContant;
import com.yihu.jw.base.service.module.SaasModuleService;
import com.yihu.jw.base.service.saas.BaseEmailTemplateConfigService;
import com.yihu.jw.base.service.saas.BaseEmailTemplateConfigService;
import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.ValidateUtil;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.module.SaasModuleDO;
import com.yihu.jw.entity.base.saas.BaseEmailTemplateConfigDO;
import com.yihu.jw.entity.base.saas.BaseEmailTemplateConfigDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.restmodel.base.module.SaasModuleVO;
import com.yihu.jw.restmodel.base.saas.SaasVO;
import com.yihu.jw.restmodel.base.saas.SaasVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -20,6 +26,7 @@ import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.MailException;
import org.springframework.mail.MailException;
@ -27,8 +34,11 @@ import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.UUID;
import java.util.stream.Collectors;
/**
/**
 * Endpoint - SAAS
 * Endpoint - SAAS
@ -50,6 +60,8 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private BaseEmailTemplateConfigService baseEmailTemplateConfigService;
    private BaseEmailTemplateConfigService baseEmailTemplateConfigService;
    @Autowired
    @Autowired
    private SaasModuleService saasModuleService;
    @Autowired
    JavaMailSender jms;
    JavaMailSender jms;
    @Value("${spring.mail.username}")
    @Value("${spring.mail.username}")
    private String username;
    private String username;
@ -60,6 +72,12 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "jsonSaas", value = "租户数据", required = true)
            @ApiParam(name = "jsonSaas", value = "租户数据", required = true)
            @RequestParam String jsonSaas) throws Exception {
            @RequestParam String jsonSaas) throws Exception {
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        if(!ValidateUtil.isValidMobileNo(saasDO.getMobile())){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
        }
        if(!ValidateUtil.isValidEmail(saasDO.getEmail())){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
        }
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
        }
        }
@ -199,6 +217,29 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
        return success(saasVO);
        return success(saasVO);
    }
    }
    @GetMapping(value = BaseRequestMapping.Saas.FIND_MODULE_BY_SAASID)
    @ApiOperation(value = "获取租户的模块列表")
    public ListEnvelop<SaasModuleVO> findModuleBySaasId (
            @ApiParam(name = "saasId", value = "saasId")
            @RequestParam(value = "saasId", required = true) String saasId) throws Exception {
        String filters = "status="+ ModuleDO.Status.available.getValue()+";";
        if(StringUtils.isNotBlank(saasId)){
            filters = "saasId="+saasId;
        }
        List<SaasModuleDO> modules = saasModuleService.search(null, filters, null);
        List<SaasModuleVO> moduleVOs = convertToModels(modules,new ArrayList<>(modules.size()),SaasModuleVO.class);
        Map<String,List<SaasModuleVO>> map = moduleVOs.stream().collect(Collectors.groupingBy(SaasModuleVO::getParentModuleId));
        moduleVOs.forEach(module->{
            List<SaasModuleVO> tmp = map.get(module.getId());
            module.setChildren(tmp);
        });
        moduleVOs = moduleVOs.stream()
                .filter(module -> CommonContant.DEFAULT_PARENTID.equals(module.getParentModuleId()))
                .collect(Collectors.toList());
        return success(moduleVOs);
    }
    @PostMapping(value = BaseRequestMapping.Saas.AUDIT)
    @PostMapping(value = BaseRequestMapping.Saas.AUDIT)
    @ApiOperation(value = "审核")
    @ApiOperation(value = "审核")
    public ObjEnvelop<SaasDO> audit(
    public ObjEnvelop<SaasDO> audit(
@ -241,7 +282,6 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
            //发送者
            //发送者
            mainMessage.setFrom(username);
            mainMessage.setFrom(username);
            //接收者
            //接收者
//            mainMessage.setTo("763558454@qq.com");
            mainMessage.setTo(saasDO.getEmail());
            mainMessage.setTo(saasDO.getEmail());
            //发送的标题
            //发送的标题
            mainMessage.setSubject(baseEmailTemplateConfigDO.getTemplateName());
            mainMessage.setSubject(baseEmailTemplateConfigDO.getTemplateName());

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEndpoint.java

@ -100,6 +100,24 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
        return failed(message);
        return failed(message);
    }
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.QUERY_BY_SAASID)
    @ApiOperation(value = "根据字典类型获取字典")
    public ListEnvelop queryDictBySaasId(
            @ApiParam(name = "saasId", value = "saasId")
            @RequestParam(value = "saasId", required = true) String saasId,
            @ApiParam(name = "type", value = "字典类型")
            @RequestParam(value = "type", required = true) String type,
            @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 {
        JSONArray list = systemDictService.getDistListBySaasId(type,saasId,sorts,page,size);
        return success(list);
    }
    @PostMapping(value = BaseRequestMapping.SystemDict.QUERY_BY_TYPE)
    @PostMapping(value = BaseRequestMapping.SystemDict.QUERY_BY_TYPE)
    @ApiOperation(value = "根据字典类型获取字典")
    @ApiOperation(value = "根据字典类型获取字典")
    public ListEnvelop queryDictByType(
    public ListEnvelop queryDictByType(

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEntryEndpoint.java

@ -62,6 +62,27 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
        return success(systemDictEntryDO, SystemDictEntryVO.class);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
    }
    @GetMapping(value = BaseRequestMapping.SystemDictEntry.PAGE_SAASID)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SystemDictEntryVO> pageSaasId (
            @ApiParam(name = "saasId", value = "true")
            @RequestParam(value = "saasId", required = true) String saasId,
            @ApiParam(name = "dictCode", value = "字典code")
            @RequestParam(value = "dictCode", required = true) String dictCode,
            @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 {
        StringBuilder filters = new StringBuilder();
        filters.append("saasId=").append(saasId).append(";")
                .append("dictCode=").append(dictCode).append(";");
        List<SystemDictEntryDO> systemDictEntryDOS = systemDictEntryService.search(null, filters.toString(), sorts, page, size);
        int count = (int)systemDictEntryService.getCount(filters.toString());
        return success(systemDictEntryDOS, count, page, size, SystemDictEntryVO.class);
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.PAGE)
    @GetMapping(value = BaseRequestMapping.SystemDict.PAGE)
    @ApiOperation(value = "获取分页")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SystemDictEntryVO> page (
    public PageEnvelop<SystemDictEntryVO> page (

+ 46 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -2,6 +2,7 @@ package com.yihu.jw.base.endpoint.wx;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.restmodel.base.wx.*;
import com.yihu.jw.restmodel.base.wx.*;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
@ -9,10 +10,12 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.List;
@ -27,6 +30,8 @@ public class WechatController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private WechatService wechatService;
    private WechatService wechatService;
    @Autowired
    private WxTemplateService wxTemplateService;
    //====================微信与租户管理=======================
    //====================微信与租户管理=======================
@ -199,6 +204,13 @@ public class WechatController extends EnvelopRestEndpoint {
    }
    }
    @PostMapping(value = BaseRequestMapping.WeChat.findDefaultReply)
    @ApiOperation(value = "获取默认事件配置", notes = "获取默认事件配置")
    public ObjEnvelop<WxReplySceneVO> findDefaultReply(@ApiParam(name = "wechatId", value = "事件配置json")
                                                       @RequestParam(value = "wechatId", required = true)String wechatId) {
        return success(wechatService.findDefaultReply(wechatId),WxReplySceneVO.class);
    }
    @GetMapping(value = BaseRequestMapping.WeChat.findWxReplySceneExist)
    @GetMapping(value = BaseRequestMapping.WeChat.findWxReplySceneExist)
    @ApiOperation(value = "验证事件配置是否存在", notes = "验证事件配置是否存在")
    @ApiOperation(value = "验证事件配置是否存在", notes = "验证事件配置是否存在")
    public Envelop findWxReplySceneExist(@ApiParam(name = "wechatId", value = "微信id")
    public Envelop findWxReplySceneExist(@ApiParam(name = "wechatId", value = "微信id")
@ -224,11 +236,13 @@ public class WechatController extends EnvelopRestEndpoint {
                                                                      @RequestParam(value = "event", required = false)String event,
                                                                      @RequestParam(value = "event", required = false)String event,
                                                                      @ApiParam(name = "content", value = "回复内容")
                                                                      @ApiParam(name = "content", value = "回复内容")
                                                                      @RequestParam(value = "content", required = false)String content,
                                                                      @RequestParam(value = "content", required = false)String content,
                                                                      @ApiParam(name = "status", value = "删除状态")
                                                                      @RequestParam(value = "status", required = true)Integer status,
                                                                      @ApiParam(name = "page", value = "页数")
                                                                      @ApiParam(name = "page", value = "页数")
                                                                      @RequestParam(value = "page", required = true)Integer page,
                                                                      @RequestParam(value = "page", required = true)Integer page,
                                                                      @ApiParam(name = "size", value = "每页大小")
                                                                      @ApiParam(name = "size", value = "每页大小")
                                                                      @RequestParam(value = "size", required = true)Integer size) {
                                                                      @RequestParam(value = "size", required = true)Integer size) {
        return wechatService.findWxReplyScene(wechatId, msgType, event, content, page, size);
        return wechatService.findWxReplyScene(wechatId, msgType, event, content,status, page, size);
    }
    }
    //====================图文素材管理end============================
    //====================图文素材管理end============================
@ -242,6 +256,17 @@ public class WechatController extends EnvelopRestEndpoint {
        return wechatService.saveWxTemp(wxTemplate);
        return wechatService.saveWxTemp(wxTemplate);
    }
    }
    @PostMapping(value = BaseRequestMapping.WeChat.findWxTempExist)
    @ApiOperation(value = "判断微信模板(模板id且模板名称)是否存在", notes = "判断微信模板(模板id且模板名称)是否存在")
    public Envelop findWxTempExist(@ApiParam(name = "wechatId", value = "微信id")
                                   @RequestParam(value = "wechatId", required = true)String wechatId,
                                   @ApiParam(name = "templateName", value = "微信id")
                                   @RequestParam(value = "templateName", required = true)String templateName,
                                   @ApiParam(name = "templateId", value = "微信模板id(微信的同步的id)")
                                   @RequestParam(value = "templateId", required = true)String templateId) {
       return success(BaseRequestMapping.WeChat.api_success,wechatService.findWxTempExist(wechatId,templateId,templateName));
    }
    @GetMapping(value = BaseRequestMapping.WeChat.findWxtemp)
    @GetMapping(value = BaseRequestMapping.WeChat.findWxtemp)
    @ApiOperation(value = "获取微信模板消息基础信息(列表)", notes = "获取微信模板消息基础信息(列表)")
    @ApiOperation(value = "获取微信模板消息基础信息(列表)", notes = "获取微信模板消息基础信息(列表)")
    public MixEnvelop<WxTemplateVO,WxTemplateVO> findWxtemp(@ApiParam(name = "wechatId", value = "微信id")
    public MixEnvelop<WxTemplateVO,WxTemplateVO> findWxtemp(@ApiParam(name = "wechatId", value = "微信id")
@ -273,13 +298,17 @@ public class WechatController extends EnvelopRestEndpoint {
                                                                                  @RequestParam(value = "wechatId", required = true)String wechatId,
                                                                                  @RequestParam(value = "wechatId", required = true)String wechatId,
                                                                                  @ApiParam(name = "scene", value = "微信场景值")
                                                                                  @ApiParam(name = "scene", value = "微信场景值")
                                                                                  @RequestParam(value = "scene", required = true)String scene,
                                                                                  @RequestParam(value = "scene", required = true)String scene,
                                                                                  @ApiParam(name = "templateId", value = "微信公众号模板id")
                                                                                  @RequestParam(value = "templateId", required = true)String templateId,
                                                                                  @ApiParam(name = "page", value = "第几页")
                                                                                  @ApiParam(name = "page", value = "第几页")
                                                                                  @RequestParam(value = "page", required = true)Integer page,
                                                                                  @RequestParam(value = "page", required = true)Integer page,
                                                                                  @ApiParam(name = "size", value = "分页大小")
                                                                                  @ApiParam(name = "size", value = "分页大小")
                                                                                  @RequestParam(value = "size", required = true)Integer size) {
                                                                                  @RequestParam(value = "size", required = true)Integer size) {
        return wechatService.findWxTempConfigList(wechatId, scene, page, size);
        return wechatService.findWxTempConfigList(wechatId,templateId,scene, page, size);
    }
    }
    @GetMapping(value = BaseRequestMapping.WeChat.findWxTemplateConfig)
    @GetMapping(value = BaseRequestMapping.WeChat.findWxTemplateConfig)
    @ApiOperation(value = "获取微信模板列表(单条)", notes = "获取微信模板列表(单条)")
    @ApiOperation(value = "获取微信模板列表(单条)", notes = "获取微信模板列表(单条)")
    public ObjEnvelop<WxTemplateConfigVO>  findWxTemplateConfig(@ApiParam(name = "wechatId", value = "微信id")
    public ObjEnvelop<WxTemplateConfigVO>  findWxTemplateConfig(@ApiParam(name = "wechatId", value = "微信id")
@ -289,7 +318,22 @@ public class WechatController extends EnvelopRestEndpoint {
                                                                @ApiParam(name = "scene", value = "场景值")
                                                                @ApiParam(name = "scene", value = "场景值")
                                                                @RequestParam(value = "scene", required = true)String scene) {
                                                                @RequestParam(value = "scene", required = true)String scene) {
        return success(wechatService.findWxTemplateConfig(wechatId,name,scene), WxTemplateConfigVO.class);
        return success(wechatService.findWxTemplateConfig(wechatId,name,scene), WxTemplateConfigVO.class);
    }
    @GetMapping(value = BaseRequestMapping.WeChat.findWxTemplateConfigExist)
    @ApiOperation(value = "判断微信配置模板场景值是否存在", notes = "判断微信配置模板场景值是否存在(单条)")
    public Envelop findWxTemplateConfigExist(@ApiParam(name = "wechatId", value = "微信id")
                                             @RequestParam(value = "wechatId", required = true)String wechatId,
                                             @ApiParam(name = "scene", value = "场景值")
                                             @RequestParam(value = "scene", required = true)String scene) {
        return success(BaseRequestMapping.WeChat.api_success,wechatService.findWxTemplateConfigExist(wechatId,scene));
    }
    @PostMapping(value = BaseRequestMapping.WeChat.getAllTemp)
    @ApiOperation(value = "获取所有微信模板(微信拉取)", notes = "获取所有微信模板(微信拉取)")
    public Envelop getAllTemp(@ApiParam(name = "wechatId", value = "微信id")
                              @RequestParam(value = "wechatId", required = true)String wechatId) {
        return wxTemplateService.getAllTemp(wechatId);
    }
    }
    //===================模板消息end==========================================
    //===================模板消息end==========================================

+ 2 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WxTemplateController.java

@ -1,6 +1,7 @@
package com.yihu.jw.base.endpoint.wx;
package com.yihu.jw.base.endpoint.wx;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.base.service.wx.WxTemplateService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
@ -30,7 +31,7 @@ public class WxTemplateController extends EnvelopRestEndpoint {
    @PostMapping(value = WechatRequestMapping.WxTemplate.api_getAllTemplate, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = WechatRequestMapping.WxTemplate.api_getAllTemplate, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "获取所有微信模板", notes = "获取所有微信模板")
    @ApiOperation(value = "获取所有微信模板", notes = "获取所有微信模板")
    public String  getAllTemp(String wechatId) {
    public Envelop getAllTemp(String wechatId) {
        return wxTemplateService.getAllTemp(wechatId);
        return wxTemplateService.getAllTemp(wechatId);
    }
    }

+ 46 - 12
svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java

@ -1,6 +1,7 @@
package com.yihu.jw.base.service.saas;
package com.yihu.jw.base.service.saas;
import com.yihu.jw.base.dao.dict.*;
import com.yihu.jw.base.dao.dict.*;
import com.yihu.jw.base.dao.module.ModuleDao;
import com.yihu.jw.base.dao.module.SaasModuleDao;
import com.yihu.jw.base.dao.module.SaasModuleDao;
import com.yihu.jw.base.dao.org.BaseOrgDao;
import com.yihu.jw.base.dao.org.BaseOrgDao;
import com.yihu.jw.base.dao.role.RoleDao;
import com.yihu.jw.base.dao.role.RoleDao;
@ -13,6 +14,7 @@ import com.yihu.jw.base.dao.user.UserDao;
import com.yihu.jw.base.dao.user.UserRoleDao;
import com.yihu.jw.base.dao.user.UserRoleDao;
import com.yihu.jw.base.service.dict.DictHospitalDeptService;
import com.yihu.jw.base.service.dict.DictHospitalDeptService;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.module.SaasModuleDO;
import com.yihu.jw.entity.base.module.SaasModuleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.role.RoleDO;
@ -78,6 +80,8 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
    @Autowired
    @Autowired
    private SaasModuleDao saasModuleDao;
    private SaasModuleDao saasModuleDao;
    @Autowired
    @Autowired
    private ModuleDao moduleDao;
    @Autowired
    private SaasThemeDao saasThemeDao;
    private SaasThemeDao saasThemeDao;
    @Autowired
    @Autowired
    private SaasThemeExtendDao saasThemeExtendDao;
    private SaasThemeExtendDao saasThemeExtendDao;
@ -279,18 +283,31 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
     * @param saasDO
     * @param saasDO
     */
     */
    @Transactional(rollbackFor = Exception.class)
    @Transactional(rollbackFor = Exception.class)
    public void saveSystemConfig(SaasDO saasDO){
    public SaasDO saveSystemConfig(SaasDO saasDO){
        SaasDO oldSaas = saasDao.findById(saasDO.getId());
        SaasDO oldSaas = saasDao.findById(saasDO.getId());
        oldSaas.setSystemName(saasDO.getSystemName());
        oldSaas.setSystemName(saasDO.getSystemName());
        oldSaas.setLogo(saasDO.getLogo());
        oldSaas.setLogo(saasDO.getLogo());
        oldSaas.setAreaNumber(saasDO.getAreaNumber());
        oldSaas.setAreaNumber(saasDO.getAreaNumber());
        List<SaasModuleDO> saasModuleDOList = saasDO.getSaasModuleList();
        List<SaasModuleDO> saasModuleDOList = saasDO.getSaasModuleList();
        saasModuleDao.deleteBySaasId(saasDO.getId());
        saasModuleDOList.forEach(saasModuleDO -> {
        saasModuleDOList.forEach(saasModuleDO -> {
            ModuleDO moduleDO = moduleDao.findOne(saasModuleDO.getModuleId());
            saasModuleDO.setSaasId(saasDO.getId());
            saasModuleDO.setSaasId(saasDO.getId());
            saasModuleDO.setDel(moduleDO.getDel());
            saasModuleDO.setCreateTime(new Date());
            saasModuleDO.setIsEnd(moduleDO.getIsEnd());
            saasModuleDO.setIsMust(moduleDO.getIsMust());
            saasModuleDO.setName(moduleDO.getName());
            saasModuleDO.setParentModuleId(moduleDO.getParentId());
            saasModuleDO.setRemark(moduleDO.getRemark());
            saasModuleDO.setStatus(moduleDO.getStatus());
            saasModuleDO.setType(moduleDO.getType());
            saasModuleDO.setUrl(moduleDO.getUrl());
        });
        });
        saasDao.save(oldSaas);
        saasDao.save(oldSaas);
        saasModuleDao.save(saasModuleDOList);
        saasModuleDao.save(saasModuleDOList);
        return oldSaas;
    }
    }
    public void updateStatus(String id,SaasDO.Status status){
    public void updateStatus(String id,SaasDO.Status status){
@ -337,6 +354,9 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
    public SaasDO findById(String id){
    public SaasDO findById(String id){
        return saasDao.findById(id);
        return saasDao.findById(id);
    }
    }
    public SaasDO findByCreateUser(String createUser){
        return saasDao.findByCreateUser(createUser);
    }
    public SaasDO findByName(String name){
    public SaasDO findByName(String name){
        return saasDao.findByName(name);
        return saasDao.findByName(name);
@ -352,24 +372,38 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
    public SaasDO saasAudit(SaasDO saas, UserDO user) {
    public SaasDO saasAudit(SaasDO saas, UserDO user) {
        //初始化角色
        //初始化角色
        RoleDO roleDO = roleDao.findByCode(roleCode);
        RoleDO roleDO = roleDao.findByCode(roleCode);
        //初始化租户管理员
        user.setEnabled(true);
        user.setLocked(false);
        user.setSalt(randomString(5));
        user.setName(user.getEmail());
        String password = user.getPassword();
        //密码默认手机号后6位
        if (StringUtils.isEmpty(password)) {
            password = user.getMobile().substring(0, 6);
        //判断该用户是否已经存在
       UserDO userDO= userDao.findByUsername(saas.getEmail());
        if (null == userDO) {
            //初始化租户管理员
            user.setEnabled(true);
            user.setLocked(false);
            user.setSalt(randomString(5));
            //姓名
            user.setName(user.getEmail());
            //账号
            user.setUsername(user.getEmail());
            String password = user.getPassword();
            //密码默认手机号后6位
            if (StringUtils.isEmpty(password)) {
                password = user.getMobile().substring(0, 6);
            }
            user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
            user.setSaasId(saas.getId());
            user = userDao.save(user);
        } else {
            userDO.setSaasId(saas.getId());
            user = userDao.save(userDO);
        }
        }
        user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
        //初始化管理员角色
        //初始化管理员角色
        UserRoleDO userRoleDO = new UserRoleDO();
        UserRoleDO userRoleDO = new UserRoleDO();
        userRoleDO.setRoleId(roleDO.getId());
        userRoleDO.setRoleId(roleDO.getId());
        userDao.save(user);
        userRoleDO.setUserId(user.getId());
        userRoleDO.setUserId(user.getId());
        userRoleDao.save(userRoleDO);
        userRoleDao.save(userRoleDO);
        saas.setManager(user.getId());
        saas.setManager(user.getId());
        saas.setManagerName(user.getName());
        saas.setAppId(getCode());
        saas.setAppId(getCode());
        saas.setAppSecret(getCode());
        saas.setAppSecret(getCode());
        saas = saasDao.save(saas);
        saas = saasDao.save(saas);

+ 30 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java

@ -3,28 +3,20 @@ package com.yihu.jw.base.service.system;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.discovery.converters.Auto;
import com.yihu.jw.base.dao.system.SystemDictDao;
import com.yihu.jw.base.enums.SystemDictEnum;
import com.yihu.jw.base.enums.SystemDictEnum;
import com.yihu.jw.base.service.dict.*;
import com.yihu.jw.base.service.dict.*;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.base.dao.system.SystemDictDao;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.Order;
import java.text.ParseException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -67,6 +59,35 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        return super.getCount(filters);
        return super.getCount(filters);
    }
    }
    /**
     * 根据字典类型获取系统所有相关字典,
     * @param saasId
     * @return
     */
    public JSONArray getDistListBySaasId(String type, String saasId, String sorts, int page, int size) throws Exception {
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(saasId, createPage(page,size,sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll(saasId, createPage(page,size,sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll(saasId, createPage(page,size,sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll(saasId, createPage(page,size,sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll(saasId, createPage(page,size,sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll(saasId, createPage(page,size,sorts));
        }
        jsonArray.add(jsonObject);
        return jsonArray;
    }
    /**
    /**
     * 获取系统所有相关字典,
     * 获取系统所有相关字典,
     * @param userId
     * @param userId

+ 5 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatCoreService.java

@ -267,6 +267,11 @@ public class WechatCoreService {
                    return getGraphicXMl(scene.getScene(),scene.getWechatId(),message);
                    return getGraphicXMl(scene.getScene(),scene.getWechatId(),message);
                }
                }
            }
            }
            //如果都没有发送默认消息
            List<WxReplySceneDO> list = wxReplySceneDao.findByAppOriginIdAndAndDefaultReply(toUserName,WeiXinMessageUtils.RESP_MESSAGE_DEFAULT);
            WxReplySceneDO wxReplySceneDO = list.get(0);
            return getGraphicXMl(wxReplySceneDO.getScene(),wxReplySceneDO.getWechatId(),message);
        }
        }
        return null;
        return null;

+ 58 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -7,6 +7,8 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.wechat.WeiXinMessageReplyUtils;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanUtils;
@ -331,10 +333,25 @@ public class WechatService {
    }
    }
    public Envelop saveWxReplyScene(WxReplySceneDO wxReplySceneDO){
    public Envelop saveWxReplyScene(WxReplySceneDO wxReplySceneDO){
        if(StringUtils.isNotBlank(wxReplySceneDO.getDefaultReply())){
           List<WxReplySceneDO> list = wxReplySceneDao.findByWechatIdAndDefaultReply(wxReplySceneDO.getWechatId(),wxReplySceneDO.getDefaultReply());
            if(list!=null&&list.size()>0){
                wxReplySceneDao.delete(list);
            }
        }
        wxReplySceneDao.save(wxReplySceneDO);
        wxReplySceneDao.save(wxReplySceneDO);
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
    }
    public WxReplySceneDO findDefaultReply(String wechatId){
        List<WxReplySceneDO> list = wxReplySceneDao.findByWechatIdAndDefaultReply(wechatId, WeiXinMessageUtils.RESP_MESSAGE_DEFAULT);
        if(list!=null&&list.size()>0){
            return list.get(0);
        }
       return null;
    }
    public Map<String,Object> findWxReplySceneExist(String wechatId,String msgType,String event,String content,String scene){
    public Map<String,Object> findWxReplySceneExist(String wechatId,String msgType,String event,String content,String scene){
        Map<String,Object> map = new HashedMap();
        Map<String,Object> map = new HashedMap();
@ -374,13 +391,14 @@ public class WechatService {
        return map;
        return map;
    }
    }
    public MixEnvelop findWxReplyScene(String wechatId,String msgType,String event,String content,Integer page,Integer size){
    public MixEnvelop findWxReplyScene(String wechatId,String msgType,String event,String content,Integer status,Integer page,Integer size){
        String totalSql = "SELECT " +
        String totalSql = "SELECT " +
                " COUNT(1) AS total " +
                " COUNT(1) AS total " +
                " FROM " +
                " FROM " +
                " wx_reply_scene s " +
                " wx_reply_scene s " +
                " WHERE " +
                " WHERE " +
                " s.wechat_id = '"+wechatId+"'";
                " s.wechat_id = '"+wechatId+"' " +
                " AND s.default_Reply is null ";
        if(StringUtils.isNotBlank(msgType)){
        if(StringUtils.isNotBlank(msgType)){
            totalSql += " AND s.msg_type ='"+msgType+"'";
            totalSql += " AND s.msg_type ='"+msgType+"'";
        }
        }
@ -390,6 +408,9 @@ public class WechatService {
        if(StringUtils.isNotBlank(content)){
        if(StringUtils.isNotBlank(content)){
            totalSql += " AND s.content like '%"+content+"%'";
            totalSql += " AND s.content like '%"+content+"%'";
        }
        }
        if(status!=null){
            totalSql += " AND s.status = "+status;
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
        if (rstotal != null && rstotal.size() > 0) {
@ -409,7 +430,8 @@ public class WechatService {
                " FROM " +
                " FROM " +
                " wx_reply_scene s " +
                " wx_reply_scene s " +
                " WHERE " +
                " WHERE " +
                " s.wechat_id = '"+wechatId+"'";
                " s.wechat_id = '"+wechatId+"'" +
                " AND s.default_Reply is null ";
        if(StringUtils.isNotBlank(msgType)){
        if(StringUtils.isNotBlank(msgType)){
            sql += " AND s.msg_type ='"+msgType+"'";
            sql += " AND s.msg_type ='"+msgType+"'";
        }
        }
@ -419,12 +441,16 @@ public class WechatService {
        if(StringUtils.isNotBlank(content)){
        if(StringUtils.isNotBlank(content)){
            sql += " AND s.content like '%"+content+"%'";
            sql += " AND s.content like '%"+content+"%'";
        }
        }
        if(status!=null){
            sql += " AND s.status = "+status;
        }
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxReplySceneVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        List<WxReplySceneVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
    }
    }
    //===================图文素材管理end====================================
    //===================图文素材管理end====================================
    //===================模板消息==========================================
    //===================模板消息==========================================
@ -434,6 +460,18 @@ public class WechatService {
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
    }
    public Boolean findWxTempExist(String wechatId,String templateId,String templateName){
        List<WxTemplateDO> list = wxTemplateDao.findByTemplateIdAndWechatId(templateId,wechatId);
        if(list!=null&&list.size()>0){
            return true;
        }
        List<WxTemplateDO> list2 = wxTemplateDao.findByTemplateNameAndWechatId(templateName,wechatId);
        if(list2!=null&&list2.size()>0){
            return true;
        }
        return false;
    }
    public MixEnvelop findWxtemp(String wechatId,Integer status,String name,String key,Integer page,Integer size){
    public MixEnvelop findWxtemp(String wechatId,Integer status,String name,String key,Integer page,Integer size){
        String totalSql = "SELECT " +
        String totalSql = "SELECT " +
                " COUNT(1) AS total " +
                " COUNT(1) AS total " +
@ -485,7 +523,7 @@ public class WechatService {
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
    }
    public MixEnvelop findWxTempConfigList(String wechatId,String scene,Integer page,Integer size){
    public MixEnvelop findWxTempConfigList(String wechatId,String templateId,String scene,Integer page,Integer size){
        String totalSql ="SELECT " +
        String totalSql ="SELECT " +
                " COUNT(1) AS total " +
                " COUNT(1) AS total " +
                " FROM " +
                " FROM " +
@ -495,6 +533,9 @@ public class WechatService {
        if(StringUtils.isNotBlank(scene)){
        if(StringUtils.isNotBlank(scene)){
            totalSql += " AND g.scene = '"+scene+"'";
            totalSql += " AND g.scene = '"+scene+"'";
        }
        }
        if(StringUtils.isNotBlank(templateId)){
            totalSql += " AND g.template_id = '"+templateId+"'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
        if (rstotal != null && rstotal.size() > 0) {
@ -531,6 +572,9 @@ public class WechatService {
        if(StringUtils.isNotBlank(scene)){
        if(StringUtils.isNotBlank(scene)){
            sql += " AND g.scene = '"+scene+"'";
            sql += " AND g.scene = '"+scene+"'";
        }
        }
        if(StringUtils.isNotBlank(templateId)){
            totalSql += " AND g.template_id = '"+templateId+"'";
        }
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxTemplateConfigVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxTemplateConfigVO.class));
        List<WxTemplateConfigVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxTemplateConfigVO.class));
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
@ -540,6 +584,16 @@ public class WechatService {
        WxTemplateConfigDO wxTemplateConfigDO =  wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene(wechatId,name,scene);
        WxTemplateConfigDO wxTemplateConfigDO =  wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene(wechatId,name,scene);
        return wxTemplateConfigDO;
        return wxTemplateConfigDO;
    }
    }
    public Boolean findWxTemplateConfigExist(String wechatId,String scene){
        List<WxTemplateConfigDO> list =  wxTemplateConfigDao.findByWechatIdAndScene(wechatId,scene);
        if(list!=null&&list.size()>0){
            return true;
        }
        return false;
    }
    //===================模板消息end=======================================
    //===================模板消息end=======================================
    //===================微信统计==========================================
    //===================微信统计==========================================

+ 56 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WxTemplateService.java

@ -1,8 +1,15 @@
package com.yihu.jw.base.service.wx;
package com.yihu.jw.base.service.wx;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.wx.WxTemplateConfigDao;
import com.yihu.jw.base.dao.wx.WxTemplateConfigDao;
import com.yihu.jw.base.dao.wx.WxTemplateDao;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.Logger;
@ -10,6 +17,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
/**
 * Created by Administrator on 2017/5/19 0019.
 * Created by Administrator on 2017/5/19 0019.
 */
 */
@ -20,6 +31,8 @@ public class WxTemplateService {
    @Autowired
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private WxTemplateDao wxTemplateDao;
    @Autowired
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    private WxAccessTokenService wxAccessTokenService;
@ -28,20 +41,60 @@ public class WxTemplateService {
    private WeixinMessagePushUtils weixinMessagePushUtils;
    private WeixinMessagePushUtils weixinMessagePushUtils;
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene(wechatId,"template_survey","test");
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_survey","test",1);
        config.setFirst(config.getFirst().replace("key1","小明"));
        config.setFirst(config.getFirst().replace("key1","小明"));
        config.setKeyword2("2018-08-21");
        config.setKeyword2("2018-08-21");
        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),openid,config);
        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),openid,config);
        return "success";
        return "success";
    }
    }
    public String  getAllTemp(String wechatId){
    public Envelop getAllTemp(String wechatId){
        String url ="https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token="+wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String url ="https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token="+wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String result = HttpUtil.sendGet(url);
        String result = HttpUtil.sendGet(url);
        return result;
        JSONObject tempJsons = JSON.parseObject(result);
        //获取所有本地模板
        List<String> localTemps = findAllTempDos(wechatId);
        //解析公众号模板
        JSONArray temps = tempJsons.getJSONArray("template_list");
        List<WxTemplateDO> savelist = new ArrayList<>();
        if(temps!=null&&!temps.isEmpty()){
            for(int i=0;i<temps.size();i++){
                JSONObject tp = (JSONObject) temps.get(i);
                String tpid = tp.getString("template_id");
                if(!localTemps.contains(tpid)){
                    WxTemplateDO wxTemplateDO = new WxTemplateDO();
                    wxTemplateDO.setWechatId(wechatId);
                    wxTemplateDO.setTemplateId(tpid);
                    wxTemplateDO.setTitle(tp.getString("title"));
                    wxTemplateDO.setContent(tp.getString("content"));
                    wxTemplateDO.setStatus(1);
                    wxTemplateDO.setCreateTime(new Date());
                    savelist.add(wxTemplateDO);
                }
            }
            wxTemplateDao.save(savelist);
        }
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
    }
    public List<String> findAllTempDos(String wechatId){
        List<WxTemplateDO> list =  wxTemplateDao.findByWxId(wechatId);
        List<String> rs = new ArrayList<>();
        if(list!=null&&list.size()>0){
            for(WxTemplateDO wxTemplateDO:list){
                rs.add(wxTemplateDO.getTemplateId());
            }
        }
        return rs;
    }
//    public WxTemplateDO createWxTemplate(WxTemplateDO wxTemplate) {
//    public WxTemplateDO createWxTemplate(WxTemplateDO wxTemplate) {
//        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
//        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {

+ 48 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/ValidateUtil.java

@ -0,0 +1,48 @@
package com.yihu.jw.base.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * @author yeshijie on 2018/10/18.
 */
public class ValidateUtil {
    /**
     * 验证是否为正确的邮箱号
     *
     * @param email
     * @return
     */
    public static boolean isValidEmail(String email) {
        // 1、\\w+表示@之前至少要输入一个匹配字母或数字或下划线 \\w 单词字符:[a-zA-Z_0-9]
        // 2、(\\w+\\.)表示域名. 如新浪邮箱域名是sina.com.cn
        // {1,3}表示可以出现一次或两次或者三次.
        String reg = "\\w+@(\\w+\\.){1,3}\\w+";
        Pattern pattern = Pattern.compile(reg);
        boolean flag = false;
        if (email != null) {
            Matcher matcher = pattern.matcher(email);
            flag = matcher.matches();
        }
        return flag;
    }
    /**
     * 验证是否为手机号
     *
     * @param mobileNo
     * @return
     */
    public static boolean isValidMobileNo(String mobileNo) {
        // 1、1开头 11位数字
        boolean flag = false;
        String reg = "^1\\d{10}$";
        Pattern pattern = Pattern.compile(reg);
        Matcher match = pattern.matcher(mobileNo);
        if (mobileNo != null) {
            flag = match.matches();
        }
        return flag;
    }
}

+ 30 - 20
svr/svr-iot/src/main/java/com/yihu/iot/controller/analyzer/IotAnalyzerController.java

@ -3,26 +3,23 @@ package com.yihu.iot.controller.analyzer;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.company.IotCompanyCertificateService;
import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.DataRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.HashMap;
@ -43,27 +40,33 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    ObjectMapper objectMapper;
    ObjectMapper objectMapper;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastDfsPublicServers;
    /**
    /**
     * 基于奕拓小屋上传的体征数据,进行解析入库
     * 基于奕拓小屋上传的体征数据,进行解析入库
     * @param dataJson
     * @param jsonData
     * @return
     * @return
     */
     */
    @GetMapping(value = "/yitouxiaowu")
    @ApiOperation(value = "基于传入的JSON串采集数据,进行解析并入库", notes = "JSON串采集数据解析入库")
    public String findCompanyPage(
            @ApiParam(name = "dataJson", value = "采集数据JSON串", defaultValue = "")
            @RequestParam(value = "dataJson", required = false) String dataJson){
    @PostMapping(value = "/yitouxiaowu" ,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "奕拓体征数据解析入库", notes = "奕拓体征数据解析入库")
    public String updateDeviceDataTest(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData){
        Envelop envelop = new Envelop();
        Envelop envelop = new Envelop();
        String str = "";
        String str = "";
        String strResult = "";
        String strResult = "";
        //1. 基础数据初始化
        //1. 基础数据初始化
        String accessToken  = "yitouxiaowu";  // 奕拓小屋
        String accessToken  = "yitouxiaowu";  // 奕拓小屋
        try {
        try {
            //JSON数据解析
            //JSON数据解析
            Map dataDetail = objectMapper.readValue(dataJson, HashMap.class);
            Map dataDetail = objectMapper.readValue(jsonData, HashMap.class);
            // 用户信息
            // 用户信息
            LinkedHashMap memberMap = (LinkedHashMap)dataDetail.get("Member");
            LinkedHashMap memberMap = (LinkedHashMap)dataDetail.get("Member");
            // 身高体重
            // 身高体重
@ -188,6 +191,13 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
            if (ecgMap != null) {
            if (ecgMap != null) {
                data.put("ecg",ecgMap.get("Hr") == null? "": ecgMap.get("Hr").toString());
                data.put("ecg",ecgMap.get("Hr") == null? "": ecgMap.get("Hr").toString());
                data.put("ecg_unit","次/分");
                data.put("ecg_unit","次/分");
                if(!(ecgMap.get("EcgImg") == null)){
                    String ecgData = ecgMap.get("EcgImg").toString();
                    byte[] imgByte = Base64.decodeBase64(ecgData);
                    ObjectNode objectNode = fastDFSHelper.upload(imgByte,"png","");
                    String resPath = fastDfsPublicServers + objectNode.get("fileId").toString().replaceAll("\"", "");
                    data.put("filepath",resPath);
                }
            }
            }
            data.put("hbalc","");
            data.put("hbalc","");
            data.put("hbalc_unit","");
            data.put("hbalc_unit","");