lin
2024-03-29 5123f48f469dba99f6929a3f6abbe3690ce3e8c2
短信验证码+导出议事报名人员+居住证申请统计bug
21 files modified
9 files renamed
1 files copied
14 files added
2167 ■■■■■ changed files
pom.xml 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/config/SmsConfig.java 25 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/HttpClientUtils.java 27 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/UtilRandom.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/AlipayApiException.java 49 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/AlipayConstants.java 97 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/AlipaySignature.java 607 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/PerfectSend.java 91 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/ReplyContent.java 63 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/StatusReport.java 91 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/StreamUtil.java 135 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/sms/StringUtils.java 171 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/controller/TopicsController.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/excel/UserTopicsExcel.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/excel/householdExcel.java 71 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/excel/topicsExcel.java 54 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml 102 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/service/IUserTopicsService.java 5 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/service/impl/PublicDiscussServiceImpl.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java 143 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/vo/TopicsVO.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/discuss/vo/UserTopicsVO.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/property/mapper/PropertyCompanyDistrictMapper.xml 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/controller/SmsSendController.java 65 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/controller/SmsTemplateController.java 11 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/dto/SmsTemplateDTO.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/mapper/SmsTemplateMapper.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/mapper/SmsTemplateMapper.xml 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/service/ISmsSendService.java 27 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/service/ISmsTemplateService.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/service/impl/SmsSendServiceImpl.java 166 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/service/impl/SmsTemplateServiceImpl.java 13 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/vo/SmsTemplateVO.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sms/wrapper/SmsTemplateWrapper.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/MenuController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IMenuService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java 11 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/mapper/TaskResidencePermitApplyMapper.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/mapper/TaskResidencePermitApplyMapper.xml 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/ITaskResidencePermitApplyService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/task/service/impl/TaskResidencePermitApplyServiceImpl.java 4 ●●●● patch | view | raw | blame | history
pom.xml
@@ -263,6 +263,10 @@
            <artifactId>thumbnailator</artifactId>
            <version>0.4.8</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
    </dependencies>
src/main/java/org/springblade/common/config/SmsConfig.java
New file
@@ -0,0 +1,25 @@
package org.springblade.common.config;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
//@ConfigurationProperties(prefix = "sms") //读取sms节点
@Data
public class SmsConfig {
    @Value("${sms.url}")
    private String smsUrl;
    // 平台提供的appId 仅供测试使用
    @Value("${sms.appId}")
    private String smsAppId;
    // 平台提供的私钥 仅供测试使用
    @Value("${sms.privateKey}")
    private String smsPrivateKey;
    @Value("${sms.sopCreateBy}")
    private String sopCreateBy;
}
src/main/java/org/springblade/common/utils/HttpClientUtils.java
@@ -100,13 +100,13 @@
    /**
     * 执行有参GET请求,带请求头
     *
     * @param url 请求url
     * @param params 参数
     * @param key 请求头Key
     * @param url       请求url
     * @param params    参数
     * @param key       请求头Key
     * @param secretKey 秘钥
     * @return
     */
    public static String doGetHeader(String url, String key, String secretKey,Map<String, String> params) {
    public static String doGetHeader(String url, String key, String secretKey, Map<String, String> params) {
//获取httpclient客户端
        CloseableHttpClient httpclient = HttpClients.createDefault();
@@ -120,7 +120,7 @@
            if (null != params) {
                for (String keys : params.keySet()) {
                    builder.addParameter(keys,params.get(keys));
                    builder.addParameter(keys, params.get(keys));
//builder.setParameter(keys, params.get(keys));
                }
            }
@@ -128,7 +128,7 @@
            HttpGet httpGet = new HttpGet(builder.build());
//设置请求头
            httpGet.addHeader(key,secretKey);
            httpGet.addHeader(key, secretKey);
// 传输的类型
            httpGet.addHeader("Content-Type", "application/x-www-form-urlencoded");
//执行Http请求调用
@@ -164,13 +164,13 @@
    /**
     * 执行有参GET请求,带请求头,接收图片流
     *
     * @param url 请求url
     * @param params 参数
     * @param key 请求头Key
     * @param url       请求url
     * @param params    参数
     * @param key       请求头Key
     * @param secretKey 秘钥
     * @return
     */
    public static String doGetHeaderPictureBase64(String url, String key, String secretKey,Map<String, String> params) {
    public static String doGetHeaderPictureBase64(String url, String key, String secretKey, Map<String, String> params) {
//获取httpclient客户端
        CloseableHttpClient httpclient = HttpClients.createDefault();
@@ -180,12 +180,12 @@
            URIBuilder builder = new URIBuilder(url);
            if (null != params) {
                for (String keys : params.keySet()) {
                    builder.addParameter(keys,params.get(keys));
                    builder.addParameter(keys, params.get(keys));
                }
            }
            HttpGet httpGet = new HttpGet(builder.build());
//设置请求头
            httpGet.addHeader(key,secretKey);
            httpGet.addHeader(key, secretKey);
// 传输的类型
            httpGet.addHeader("Content-Type", "application/x-www-form-urlencoded");
//执行Http请求调用
@@ -328,6 +328,7 @@
    /**
     * post 请求 header 带 秘钥
     *
     * @param url
     * @param appKey
     * @param appKeyValue
@@ -439,7 +440,6 @@
        }
        return "";
    }
    //适用于post请求并传送form-data数据(同样适用于post的Raw类型的application-json格式)
@@ -562,6 +562,7 @@
    /**
     * json  body
     *
     * @param url
     * @param json
     * @return
src/main/java/org/springblade/common/utils/UtilRandom.java
New file
@@ -0,0 +1,7 @@
package org.springblade.common.utils;
public class UtilRandom {
    public static Integer randomCount(Integer start, Integer end) {
        return (int) (Math.random() * (end - start + 1) + start);
    }
}
src/main/java/org/springblade/common/utils/sms/AlipayApiException.java
New file
@@ -0,0 +1,49 @@
/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2012 All Rights Reserved.
 */
package org.springblade.common.utils.sms;
/**
 *
 * @author runzhi
 */
public class AlipayApiException extends Exception {
    private static final long serialVersionUID = -238091758285157331L;
    private String            errCode;
    private String            errMsg;
    public AlipayApiException() {
        super();
    }
    public AlipayApiException(String message, Throwable cause) {
        super(message, cause);
    }
    public AlipayApiException(String message) {
        super(message);
    }
    public AlipayApiException(Throwable cause) {
        super(cause);
    }
    public AlipayApiException(String errCode, String errMsg) {
        super(errCode + ":" + errMsg);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }
    public String getErrCode() {
        return this.errCode;
    }
    public String getErrMsg() {
        return this.errMsg;
    }
}
src/main/java/org/springblade/common/utils/sms/AlipayConstants.java
New file
@@ -0,0 +1,97 @@
/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2012 All Rights Reserved.
 */
package org.springblade.common.utils.sms;
/**
 *
 * @author runzhi
 */
public class AlipayConstants {
    public static final String SIGN_TYPE                      = "sign_type";
    public static final String SIGN_TYPE_RSA                  = "RSA";
    /**
     * sha256WithRsa 算法请求类型
     */
    public static final String SIGN_TYPE_RSA2                 = "RSA2";
    public static final String SIGN_ALGORITHMS                = "SHA1WithRSA";
    public static final String SIGN_SHA256RSA_ALGORITHMS      = "SHA256WithRSA";
    public static final String ENCRYPT_TYPE_AES               = "AES";
    public static final String APP_ID                         = "app_id";
    public static final String FORMAT                         = "format";
    public static final String METHOD                         = "method";
    public static final String TIMESTAMP                      = "timestamp";
    public static final String VERSION                        = "version";
    public static final String SIGN                           = "sign";
    public static final String ALIPAY_SDK                     = "alipay_sdk";
    public static final String ACCESS_TOKEN                   = "auth_token";
    public static final String APP_AUTH_TOKEN                 = "app_auth_token";
    public static final String TERMINAL_TYPE                  = "terminal_type";
    public static final String TERMINAL_INFO                  = "terminal_info";
    public static final String CHARSET                        = "charset";
    public static final String NOTIFY_URL                     = "notify_url";
    public static final String RETURN_URL                     = "return_url";
    public static final String ENCRYPT_TYPE                   = "encrypt_type";
    //-----===-------///
    public static final String BIZ_CONTENT_KEY                = "biz_content";
    /** 默认时间格式 **/
    public static final String DATE_TIME_FORMAT               = "yyyy-MM-dd HH:mm:ss";
    /**  Date默认时区 **/
    public static final String DATE_TIMEZONE                  = "GMT+8";
    /** UTF-8字符集 **/
    public static final String CHARSET_UTF8                   = "UTF-8";
    /** GBK字符集 **/
    public static final String CHARSET_GBK                    = "GBK";
    /** JSON 应格式 */
    public static final String FORMAT_JSON                    = "json";
    /** XML 应格式 */
    public static final String FORMAT_XML                     = "xml";
    /** SDK版本号 */
    public static final String SDK_VERSION                    = "alipay-sdk-java-3.6.0.ALL";
    public static final String PROD_CODE                      = "prod_code";
    /** 老版本失败节点 */
    public static final String ERROR_RESPONSE                 = "error_response";
    /** 新版本节点后缀 */
    public static final String RESPONSE_SUFFIX                = "_response";
    /** 加密后XML返回报文的节点名字 */
    public static final String RESPONSE_XML_ENCRYPT_NODE_NAME = "response_encrypted";
    /** 批量请求id **/
    public static final String BATCH_REQUEST_ID               = "batch_request_id";
}
src/main/java/org/springblade/common/utils/sms/AlipaySignature.java
New file
@@ -0,0 +1,607 @@
/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2012 All Rights Reserved.
 */
package org.springblade.common.utils.sms;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.io.*;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
 *
 * @author runzhi
 */
public class AlipaySignature {
    /** RSA最大加密明文大小  */
    private static final int MAX_ENCRYPT_BLOCK = 117;
    /** RSA最大解密密文大小   */
    private static final int MAX_DECRYPT_BLOCK = 128;
    /**
     *
     * @param sortedParams
     * @return
     */
    public static String getSignContent(Map<String, String> sortedParams) {
        StringBuffer content = new StringBuffer();
        List<String> keys = new ArrayList<String>(sortedParams.keySet());
        Collections.sort(keys);
        int index = 0;
        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = sortedParams.get(key);
            if (StringUtils.areNotEmpty(key, value)) {
                content.append((index == 0 ? "" : "&") + key + "=" + value);
                index++;
            }
        }
        return content.toString();
    }
    /**
     *  rsa内容签名
     *
     * @param content
     * @param privateKey
     * @param charset
     * @return
     * @throws AlipayApiException
     */
    public static String rsaSign(String content, String privateKey, String charset,
                                 String signType) throws AlipayApiException {
        if (AlipayConstants.SIGN_TYPE_RSA.equals(signType)) {
            return rsaSign(content, privateKey, charset);
        } else if (AlipayConstants.SIGN_TYPE_RSA2.equals(signType)) {
            return rsa256Sign(content, privateKey, charset);
        } else {
            throw new AlipayApiException("Sign Type is Not Support : signType=" + signType);
        }
    }
    /**
     * sha256WithRsa 加签
     *
     * @param content
     * @param privateKey
     * @param charset
     * @return
     * @throws AlipayApiException
     */
    public static String rsa256Sign(String content, String privateKey,
                                    String charset) throws AlipayApiException {
        try {
            PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
                new ByteArrayInputStream(privateKey.getBytes()));
            java.security.Signature signature = java.security.Signature
                .getInstance(AlipayConstants.SIGN_SHA256RSA_ALGORITHMS);
            signature.initSign(priKey);
            if (StringUtils.isEmpty(charset)) {
                signature.update(content.getBytes());
            } else {
                signature.update(content.getBytes(charset));
            }
            byte[] signed = signature.sign();
            return new String(Base64.encodeBase64(signed));
        } catch (Exception e) {
            throw new AlipayApiException("RSAcontent = " + content + "; charset = " + charset, e);
        }
    }
    /**
     * sha1WithRsa 加签
     *
     * @param content
     * @param privateKey
     * @param charset
     * @return
     * @throws AlipayApiException
     */
    public static String rsaSign(String content, String privateKey,
                                 String charset) throws AlipayApiException {
        try {
            PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
                new ByteArrayInputStream(privateKey.getBytes()));
            java.security.Signature signature = java.security.Signature
                .getInstance(AlipayConstants.SIGN_ALGORITHMS);
            signature.initSign(priKey);
            if (StringUtils.isEmpty(charset)) {
                signature.update(content.getBytes());
            } else {
                signature.update(content.getBytes(charset));
            }
            byte[] signed = signature.sign();
            return new String(Base64.encodeBase64(signed));
        } catch (InvalidKeySpecException ie) {
            throw new AlipayApiException("RSA私钥格式不正确,请检查是否正确配置了PKCS8格式的私钥", ie);
        } catch (Exception e) {
            throw new AlipayApiException("RSAcontent = " + content + "; charset = " + charset, e);
        }
    }
    public static String rsaSign(Map<String, String> params, String privateKey,
                                 String charset) throws AlipayApiException {
        String signContent = getSignContent(params);
        return rsaSign(signContent, privateKey, charset);
    }
    public static PrivateKey getPrivateKeyFromPKCS8(String algorithm,
                                                    InputStream ins) throws Exception {
        if (ins == null || StringUtils.isEmpty(algorithm)) {
            return null;
        }
        KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
        byte[] encodedKey = StreamUtil.readText(ins).getBytes();
        encodedKey = Base64.decodeBase64(encodedKey);
        return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(encodedKey));
    }
    public static String getSignCheckContentV1(Map<String, String> params) {
        if (params == null) {
            return null;
        }
        params.remove("sign");
        params.remove("sign_type");
        StringBuffer content = new StringBuffer();
        List<String> keys = new ArrayList<String>(params.keySet());
        Collections.sort(keys);
        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = params.get(key);
            content.append((i == 0 ? "" : "&") + key + "=" + value);
        }
        return content.toString();
    }
    public static String getSignCheckContentV2(Map<String, String> params) {
        if (params == null) {
            return null;
        }
        params.remove("sign");
        StringBuffer content = new StringBuffer();
        List<String> keys = new ArrayList<String>(params.keySet());
        Collections.sort(keys);
        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            String value = params.get(key);
            content.append((i == 0 ? "" : "&") + key + "=" + value);
        }
        return content.toString();
    }
    public static boolean rsaCheckV1(Map<String, String> params, String publicKey,
                                     String charset) throws AlipayApiException {
        String sign = params.get("sign");
        String content = getSignCheckContentV1(params);
        return rsaCheckContent(content, sign, publicKey, charset);
    }
    public static boolean rsaCheckV1(Map<String, String> params, String publicKey,
            String charset,String signType) throws AlipayApiException {
        String sign = params.get("sign");
        String content = getSignCheckContentV1(params);
        return rsaCheck(content, sign, publicKey, charset,signType);
    }
    public static boolean rsaCheckV2(Map<String, String> params, String publicKey,
                                     String charset) throws AlipayApiException {
        String sign = params.get("sign");
        String content = getSignCheckContentV2(params);
        return rsaCheckContent(content, sign, publicKey, charset);
    }
    public static boolean rsaCheckV2(Map<String, String> params, String publicKey,
            String charset,String signType) throws AlipayApiException {
        String sign = params.get("sign");
        String content = getSignCheckContentV2(params);
        return rsaCheck(content, sign, publicKey, charset,signType);
    }
    public static boolean rsaCheck(String content, String sign, String publicKey, String charset,
                                   String signType) throws AlipayApiException {
        if (AlipayConstants.SIGN_TYPE_RSA.equals(signType)) {
            return rsaCheckContent(content, sign, publicKey, charset);
        } else if (AlipayConstants.SIGN_TYPE_RSA2.equals(signType)) {
            return rsa256CheckContent(content, sign, publicKey, charset);
        } else {
            throw new AlipayApiException("Sign Type is Not Support : signType=" + signType);
        }
    }
    public static boolean rsa256CheckContent(String content, String sign, String publicKey,
                                             String charset) throws AlipayApiException {
        try {
            PublicKey pubKey = getPublicKeyFromX509("RSA",
                new ByteArrayInputStream(publicKey.getBytes()));
            java.security.Signature signature = java.security.Signature
                .getInstance(AlipayConstants.SIGN_SHA256RSA_ALGORITHMS);
            signature.initVerify(pubKey);
            if (StringUtils.isEmpty(charset)) {
                signature.update(content.getBytes());
            } else {
                signature.update(content.getBytes(charset));
            }
            return signature.verify(Base64.decodeBase64(sign.getBytes()));
        } catch (Exception e) {
            throw new AlipayApiException(
                "RSAcontent = " + content + ",sign=" + sign + ",charset = " + charset, e);
        }
    }
    public static boolean rsaCheckContent(String content, String sign, String publicKey,
                                          String charset) throws AlipayApiException {
        try {
            PublicKey pubKey = getPublicKeyFromX509("RSA",
                new ByteArrayInputStream(publicKey.getBytes()));
            java.security.Signature signature = java.security.Signature
                .getInstance(AlipayConstants.SIGN_ALGORITHMS);
            signature.initVerify(pubKey);
            if (StringUtils.isEmpty(charset)) {
                signature.update(content.getBytes());
            } else {
                signature.update(content.getBytes(charset));
            }
            return signature.verify(Base64.decodeBase64(sign.getBytes()));
        } catch (Exception e) {
            throw new AlipayApiException(
                "RSAcontent = " + content + ",sign=" + sign + ",charset = " + charset, e);
        }
    }
    public static PublicKey getPublicKeyFromX509(String algorithm,
                                                 InputStream ins) throws Exception {
        KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
        StringWriter writer = new StringWriter();
        StreamUtil.io(new InputStreamReader(ins), writer);
        byte[] encodedKey = writer.toString().getBytes();
        encodedKey = Base64.decodeBase64(encodedKey);
        return keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
    }
    /**
     * 验签并解密
     * <p>
     * <b>目前适用于公众号</b><br>
     * params参数示例:
     * <br>{
     *    <br>biz_content=M0qGiGz+8kIpxe8aF4geWJdBn0aBTuJRQItLHo9R7o5JGhpic/MIUjvXo2BLB++BbkSq2OsJCEQFDZ0zK5AJYwvBgeRX30gvEj6eXqXRt16/IkB9HzAccEqKmRHrZJ7PjQWE0KfvDAHsJqFIeMvEYk1Zei2QkwSQPlso7K0oheo/iT+HYE8aTATnkqD/ByD9iNDtGg38pCa2xnnns63abKsKoV8h0DfHWgPH62urGY7Pye3r9FCOXA2Ykm8X4/Bl1bWFN/PFCEJHWe/HXj8KJKjWMO6ttsoV0xRGfeyUO8agu6t587Dl5ux5zD/s8Lbg5QXygaOwo3Fz1G8EqmGhi4+soEIQb8DBYanQOS3X+m46tVqBGMw8Oe+hsyIMpsjwF4HaPKMr37zpW3fe7xOMuimbZ0wq53YP/jhQv6XWodjT3mL0H5ACqcsSn727B5ztquzCPiwrqyjUHjJQQefFTzOse8snaWNQTUsQS7aLsHq0FveGpSBYORyA90qPdiTjXIkVP7mAiYiAIWW9pCEC7F3XtViKTZ8FRMM9ySicfuAlf3jtap6v2KPMtQv70X+hlmzO/IXB6W0Ep8DovkF5rB4r/BJYJLw/6AS0LZM9w5JfnAZhfGM2rKzpfNsgpOgEZS1WleG4I2hoQC0nxg9IcP0Hs+nWIPkEUcYNaiXqeBc=,
     *    <br>sign=rlqgA8O+RzHBVYLyHmrbODVSANWPXf3pSrr82OCO/bm3upZiXSYrX5fZr6UBmG6BZRAydEyTIguEW6VRuAKjnaO/sOiR9BsSrOdXbD5Rhos/Xt7/mGUWbTOt/F+3W0/XLuDNmuYg1yIC/6hzkg44kgtdSTsQbOC9gWM7ayB4J4c=,
     *    sign_type=RSA,
     *    <br>charset=UTF-8
     * <br>}
     * </p>
     * @param params
     * @param alipayPublicKey 支付宝公钥
     * @param cusPrivateKey   商户私钥
     * @param isCheckSign     是否验签
     * @param isDecrypt       是否解密
     * @return 解密后明文,验签失败则异常抛出
     * @throws AlipayApiException
     */
    public static String checkSignAndDecrypt(Map<String, String> params, String alipayPublicKey,
                                             String cusPrivateKey, boolean isCheckSign,
                                             boolean isDecrypt) throws AlipayApiException {
        String charset = params.get("charset");
        String bizContent = params.get("biz_content");
        if (isCheckSign) {
            if (!rsaCheckV2(params, alipayPublicKey, charset)) {
                throw new AlipayApiException("rsaCheck failure:rsaParams=" + params);
            }
        }
        if (isDecrypt) {
            return rsaDecrypt(bizContent, cusPrivateKey, charset);
        }
        return bizContent;
    }
    /**
     * 验签并解密
     * <p>
     * <b>目前适用于公众号</b><br>
     * params参数示例:
     * <br>{
     *    <br>biz_content=M0qGiGz+8kIpxe8aF4geWJdBn0aBTuJRQItLHo9R7o5JGhpic/MIUjvXo2BLB++BbkSq2OsJCEQFDZ0zK5AJYwvBgeRX30gvEj6eXqXRt16/IkB9HzAccEqKmRHrZJ7PjQWE0KfvDAHsJqFIeMvEYk1Zei2QkwSQPlso7K0oheo/iT+HYE8aTATnkqD/ByD9iNDtGg38pCa2xnnns63abKsKoV8h0DfHWgPH62urGY7Pye3r9FCOXA2Ykm8X4/Bl1bWFN/PFCEJHWe/HXj8KJKjWMO6ttsoV0xRGfeyUO8agu6t587Dl5ux5zD/s8Lbg5QXygaOwo3Fz1G8EqmGhi4+soEIQb8DBYanQOS3X+m46tVqBGMw8Oe+hsyIMpsjwF4HaPKMr37zpW3fe7xOMuimbZ0wq53YP/jhQv6XWodjT3mL0H5ACqcsSn727B5ztquzCPiwrqyjUHjJQQefFTzOse8snaWNQTUsQS7aLsHq0FveGpSBYORyA90qPdiTjXIkVP7mAiYiAIWW9pCEC7F3XtViKTZ8FRMM9ySicfuAlf3jtap6v2KPMtQv70X+hlmzO/IXB6W0Ep8DovkF5rB4r/BJYJLw/6AS0LZM9w5JfnAZhfGM2rKzpfNsgpOgEZS1WleG4I2hoQC0nxg9IcP0Hs+nWIPkEUcYNaiXqeBc=,
     *    <br>sign=rlqgA8O+RzHBVYLyHmrbODVSANWPXf3pSrr82OCO/bm3upZiXSYrX5fZr6UBmG6BZRAydEyTIguEW6VRuAKjnaO/sOiR9BsSrOdXbD5Rhos/Xt7/mGUWbTOt/F+3W0/XLuDNmuYg1yIC/6hzkg44kgtdSTsQbOC9gWM7ayB4J4c=,
     *    sign_type=RSA,
     *    <br>charset=UTF-8
     * <br>}
     * </p>
     * @param params
     * @param alipayPublicKey 支付宝公钥
     * @param cusPrivateKey   商户私钥
     * @param isCheckSign     是否验签
     * @param isDecrypt       是否解密
     * @return 解密后明文,验签失败则异常抛出
     * @throws AlipayApiException
     */
    public static String checkSignAndDecrypt(Map<String, String> params, String alipayPublicKey,
                                             String cusPrivateKey, boolean isCheckSign,
                                             boolean isDecrypt, String signType) throws AlipayApiException {
        String charset = params.get("charset");
        String bizContent = params.get("biz_content");
        if (isCheckSign) {
            if (!rsaCheckV2(params, alipayPublicKey, charset,signType)) {
                throw new AlipayApiException("rsaCheck failure:rsaParams=" + params);
            }
        }
        if (isDecrypt) {
            return rsaDecrypt(bizContent, cusPrivateKey, charset);
        }
        return bizContent;
    }
    /**
     * 加密并签名<br>
     * <b>目前适用于公众号</b>
     * @param bizContent      待加密、签名内容
     * @param alipayPublicKey 支付宝公钥
     * @param cusPrivateKey   商户私钥
     * @param charset         字符集,如UTF-8, GBK, GB2312
     * @param isEncrypt       是否加密,true-加密  false-不加密
     * @param isSign          是否签名,true-签名  false-不签名
     * @return 加密、签名后xml内容字符串
     * <p>
     * 返回示例:
     * <alipay>
     *  <response>密文</response>
     *  <encryption_type>RSA</encryption_type>
     *  <sign>sign</sign>
     *  <sign_type>RSA</sign_type>
     * </alipay>
     * </p>
     * @throws AlipayApiException
     */
    public static String encryptAndSign(String bizContent, String alipayPublicKey,
                                        String cusPrivateKey, String charset, boolean isEncrypt,
                                        boolean isSign) throws AlipayApiException {
        StringBuilder sb = new StringBuilder();
        if (StringUtils.isEmpty(charset)) {
            charset = AlipayConstants.CHARSET_GBK;
        }
        sb.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>");
        if (isEncrypt) {// 加密
            sb.append("<alipay>");
            String encrypted = rsaEncrypt(bizContent, alipayPublicKey, charset);
            sb.append("<response>" + encrypted + "</response>");
            sb.append("<encryption_type>RSA</encryption_type>");
            if (isSign) {
                String sign = rsaSign(encrypted, cusPrivateKey, charset);
                sb.append("<sign>" + sign + "</sign>");
                sb.append("<sign_type>RSA</sign_type>");
            }
            sb.append("</alipay>");
        } else if (isSign) {// 不加密,但需要签名
            sb.append("<alipay>");
            sb.append("<response>" + bizContent + "</response>");
            String sign = rsaSign(bizContent, cusPrivateKey, charset);
            sb.append("<sign>" + sign + "</sign>");
            sb.append("<sign_type>RSA</sign_type>");
            sb.append("</alipay>");
        } else {// 不加密,不加签
            sb.append(bizContent);
        }
        return sb.toString();
    }
    /**
     * 加密并签名<br>
     * <b>目前适用于公众号</b>
     * @param bizContent      待加密、签名内容
     * @param alipayPublicKey 支付宝公钥
     * @param cusPrivateKey   商户私钥
     * @param charset         字符集,如UTF-8, GBK, GB2312
     * @param isEncrypt       是否加密,true-加密  false-不加密
     * @param isSign          是否签名,true-签名  false-不签名
     * @return 加密、签名后xml内容字符串
     * <p>
     * 返回示例:
     * <alipay>
     *  <response>密文</response>
     *  <encryption_type>RSA</encryption_type>
     *  <sign>sign</sign>
     *  <sign_type>RSA</sign_type>
     * </alipay>
     * </p>
     * @throws AlipayApiException
     */
    public static String encryptAndSign(String bizContent, String alipayPublicKey,
                                        String cusPrivateKey, String charset, boolean isEncrypt,
                                        boolean isSign,String signType) throws AlipayApiException {
        StringBuilder sb = new StringBuilder();
        if (StringUtils.isEmpty(charset)) {
            charset = AlipayConstants.CHARSET_GBK;
        }
        sb.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>");
        if (isEncrypt) {// 加密
            sb.append("<alipay>");
            String encrypted = rsaEncrypt(bizContent, alipayPublicKey, charset);
            sb.append("<response>" + encrypted + "</response>");
            sb.append("<encryption_type>RSA</encryption_type>");
            if (isSign) {
                String sign = rsaSign(encrypted, cusPrivateKey, charset, signType);
                sb.append("<sign>" + sign + "</sign>");
                sb.append("<sign_type>");
                sb.append(signType);
                sb.append("</sign_type>");
            }
            sb.append("</alipay>");
        } else if (isSign) {// 不加密,但需要签名
            sb.append("<alipay>");
            sb.append("<response>" + bizContent + "</response>");
            String sign = rsaSign(bizContent, cusPrivateKey, charset, signType);
            sb.append("<sign>" + sign + "</sign>");
            sb.append("<sign_type>");
            sb.append(signType);
            sb.append("</sign_type>");
            sb.append("</alipay>");
        } else {// 不加密,不加签
            sb.append(bizContent);
        }
        return sb.toString();
    }
    /**
     * 公钥加密
     *
     * @param content   待加密内容
     * @param publicKey 公钥
     * @param charset   字符集,如UTF-8, GBK, GB2312
     * @return 密文内容
     * @throws AlipayApiException
     */
    public static String rsaEncrypt(String content, String publicKey,
                                    String charset) throws AlipayApiException {
        try {
            PublicKey pubKey = getPublicKeyFromX509(AlipayConstants.SIGN_TYPE_RSA,
                new ByteArrayInputStream(publicKey.getBytes()));
            Cipher cipher = Cipher.getInstance(AlipayConstants.SIGN_TYPE_RSA);
            cipher.init(Cipher.ENCRYPT_MODE, pubKey);
            byte[] data = StringUtils.isEmpty(charset) ? content.getBytes()
                : content.getBytes(charset);
            int inputLen = data.length;
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int offSet = 0;
            byte[] cache;
            int i = 0;
            // 对数据分段加密
            while (inputLen - offSet > 0) {
                if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
                    cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
                } else {
                    cache = cipher.doFinal(data, offSet, inputLen - offSet);
                }
                out.write(cache, 0, cache.length);
                i++;
                offSet = i * MAX_ENCRYPT_BLOCK;
            }
            byte[] encryptedData = Base64.encodeBase64(out.toByteArray());
            out.close();
            return StringUtils.isEmpty(charset) ? new String(encryptedData)
                : new String(encryptedData, charset);
        } catch (Exception e) {
            throw new AlipayApiException("EncryptContent = " + content + ",charset = " + charset,
                e);
        }
    }
    /**
     * 私钥解密
     *
     * @param content    待解密内容
     * @param privateKey 私钥
     * @param charset    字符集,如UTF-8, GBK, GB2312
     * @return 明文内容
     * @throws AlipayApiException
     */
    public static String rsaDecrypt(String content, String privateKey,
                                    String charset) throws AlipayApiException {
        try {
            PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
                new ByteArrayInputStream(privateKey.getBytes()));
            Cipher cipher = Cipher.getInstance(AlipayConstants.SIGN_TYPE_RSA);
            cipher.init(Cipher.DECRYPT_MODE, priKey);
            byte[] encryptedData = StringUtils.isEmpty(charset)
                ? Base64.decodeBase64(content.getBytes())
                : Base64.decodeBase64(content.getBytes(charset));
            int inputLen = encryptedData.length;
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int offSet = 0;
            byte[] cache;
            int i = 0;
            // 对数据分段解密
            while (inputLen - offSet > 0) {
                if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
                    cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
                } else {
                    cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
                }
                out.write(cache, 0, cache.length);
                i++;
                offSet = i * MAX_DECRYPT_BLOCK;
            }
            byte[] decryptedData = out.toByteArray();
            out.close();
            return StringUtils.isEmpty(charset) ? new String(decryptedData)
                : new String(decryptedData, charset);
        } catch (Exception e) {
            throw new AlipayApiException("EncodeContent = " + content + ",charset = " + charset, e);
        }
    }
}
src/main/java/org/springblade/common/utils/sms/PerfectSend.java
New file
@@ -0,0 +1,91 @@
package org.springblade.common.utils.sms;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
 * 完美发送任务对象 perfect_send
 *
 * @author chen
 * @date 2021-06-23
 */
public class PerfectSend
{
    private static final long serialVersionUID = 1L;
    /** 通知时间间隔 */
    private String timeInterval;
    /** 通知次数 */
    private int sendNum;
    /** 通知内容 */
    private String sendContent;
    /** 发送用户 */
    private String phones;
    /** 优先级 */
    private Integer priority;
    /** 创建者 */
    private String createBy;
    public String getTimeInterval() {
        return timeInterval;
    }
    public void setTimeInterval(String timeInterval) {
        this.timeInterval = timeInterval;
    }
    public int getSendNum() {
        return sendNum;
    }
    public void setSendNum(int sendNum) {
        this.sendNum = sendNum;
    }
    public String getSendContent() {
        return sendContent;
    }
    public void setSendContent(String sendContent) {
        this.sendContent = sendContent;
    }
    public String getPhones() {
        return phones;
    }
    public void setPhones(String phones) {
        this.phones = phones;
    }
    public Integer getPriority() {
        return priority;
    }
    public void setPriority(Integer priority) {
        this.priority = priority;
    }
    public String getCreateBy() {
        return createBy;
    }
    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("timeInterval", getTimeInterval())
            .append("sendNum", getSendNum())
            .append("sendContent", getSendContent())
            .append("createBy", getCreateBy())
            .toString();
    }
}
src/main/java/org/springblade/common/utils/sms/ReplyContent.java
New file
@@ -0,0 +1,63 @@
package org.springblade.common.utils.sms;
import java.util.Date;
/**
 * 回复内容对象 reply_content
 *
 * @author chen
 * @date 2021-06-24
 */
public class ReplyContent {
    /**
     * 发送号码
     */
    private String sendPhones;
    /**
     * 上行记录时间-起始
     */
    private String createTimeStart;
    /**
     * 上行记录时间-结束
     */
    private String createTimeEnd;
    /**
     * 创建者
     */
    private String sopCreateBy;
    public String getSendPhones() {
        return sendPhones;
    }
    public void setSendPhones(String sendPhones) {
        this.sendPhones = sendPhones;
    }
    public String getCreateTimeStart() {
        return createTimeStart;
    }
    public void setCreateTimeStart(String createTimeStart) {
        this.createTimeStart = createTimeStart;
    }
    public String getCreateTimeEnd() {
        return createTimeEnd;
    }
    public void setCreateTimeEnd(String createTimeEnd) {
        this.createTimeEnd = createTimeEnd;
    }
    public String getSopCreateBy() {
        return sopCreateBy;
    }
    public void setSopCreateBy(String sopCreateBy) {
        this.sopCreateBy = sopCreateBy;
    }
}
src/main/java/org/springblade/common/utils/sms/StatusReport.java
New file
@@ -0,0 +1,91 @@
package org.springblade.common.utils.sms;
import java.util.Date;
/**
 * 状态报告对象 status_report
 *
 * @author chen
 * @date 2021-06-24
 */
public class StatusReport
{
    /**
     * 接收号码
     */
    private String phones;
    /**
     * 发送类型(0相同内容,1不同内容,2完美发送)
     */
    private int type;
    /**
     * 发送时间-起始
     */
    private String sendTimeStart;
    /**
     * 发送时间-结束
     */
    private String sendTimeEnd;
    /**
     * 发送类型
     */
    private int parentType;
    /**
     * 创建者
     */
    private String sopCreateBy;
    public String getPhones() {
        return phones;
    }
    public void setPhones(String phones) {
        this.phones = phones;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
    public String getSendTimeStart() {
        return sendTimeStart;
    }
    public void setSendTimeStart(String sendTimeStart) {
        this.sendTimeStart = sendTimeStart;
    }
    public String getSendTimeEnd() {
        return sendTimeEnd;
    }
    public void setSendTimeEnd(String sendTimeEnd) {
        this.sendTimeEnd = sendTimeEnd;
    }
    public int getParentType() {
        return parentType;
    }
    public void setParentType(int parentType) {
        this.parentType = parentType;
    }
    public String getSopCreateBy() {
        return sopCreateBy;
    }
    public void setSopCreateBy(String sopCreateBy) {
        this.sopCreateBy = sopCreateBy;
    }
}
src/main/java/org/springblade/common/utils/sms/StreamUtil.java
New file
@@ -0,0 +1,135 @@
/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2012 All Rights Reserved.
 */
package org.springblade.common.utils.sms;
import java.io.*;
/**
 *
 * @author runzhi
 */
public class StreamUtil {
    private StreamUtil(){}
    private static final int DEFAULT_BUFFER_SIZE = 8192;
    public static void io(InputStream in, OutputStream out) throws IOException {
        io(in, out, -1);
    }
    public static void io(InputStream in, OutputStream out, int bufferSize) throws IOException {
        if (bufferSize == -1) {
            bufferSize = DEFAULT_BUFFER_SIZE;
        }
        byte[] buffer = new byte[bufferSize];
        int amount;
        while ((amount = in.read(buffer)) >= 0) {
            out.write(buffer, 0, amount);
        }
    }
    public static void io(Reader in, Writer out) throws IOException {
        io(in, out, -1);
    }
    public static void io(Reader in, Writer out, int bufferSize) throws IOException {
        if (bufferSize == -1) {
            bufferSize = DEFAULT_BUFFER_SIZE >> 1;
        }
        char[] buffer = new char[bufferSize];
        int amount;
        while ((amount = in.read(buffer)) >= 0) {
            out.write(buffer, 0, amount);
        }
    }
    public static OutputStream synchronizedOutputStream(OutputStream out) {
        return new SynchronizedOutputStream(out);
    }
    public static OutputStream synchronizedOutputStream(OutputStream out, Object lock) {
        return new SynchronizedOutputStream(out, lock);
    }
    public static String readText(InputStream in) throws IOException {
        return readText(in, null, -1);
    }
    public static String readText(InputStream in, String encoding) throws IOException {
        return readText(in, encoding, -1);
    }
    public static String readText(InputStream in, String encoding, int bufferSize)
                                                                                  throws IOException {
        Reader reader = (encoding == null) ? new InputStreamReader(in) : new InputStreamReader(in,
            encoding);
        return readText(reader, bufferSize);
    }
    public static String readText(Reader reader) throws IOException {
        return readText(reader, -1);
    }
    public static String readText(Reader reader, int bufferSize) throws IOException {
        StringWriter writer = new StringWriter();
        io(reader, writer, bufferSize);
        return writer.toString();
    }
    private static class SynchronizedOutputStream extends OutputStream {
        private OutputStream out;
        private Object       lock;
        SynchronizedOutputStream(OutputStream out) {
            this(out, out);
        }
        SynchronizedOutputStream(OutputStream out, Object lock) {
            this.out = out;
            this.lock = lock;
        }
        @Override
        public void write(int datum) throws IOException {
            synchronized (lock) {
                out.write(datum);
            }
        }
        @Override
        public void write(byte[] data) throws IOException {
            synchronized (lock) {
                out.write(data);
            }
        }
        @Override
        public void write(byte[] data, int offset, int length) throws IOException {
            synchronized (lock) {
                out.write(data, offset, length);
            }
        }
        @Override
        public void flush() throws IOException {
            synchronized (lock) {
                out.flush();
            }
        }
        @Override
        public void close() throws IOException {
            synchronized (lock) {
                out.close();
            }
        }
    }
}
src/main/java/org/springblade/common/utils/sms/StringUtils.java
New file
@@ -0,0 +1,171 @@
package org.springblade.common.utils.sms;
/**
 * 字符串工具类。
 *
 * @author carver.gu
 * @since 1.0, Sep 12, 2009
 */
public abstract class StringUtils {
    private StringUtils() {}
    /**
     * 检查指定的字符串是否为空。
     * <ul>
     * <li>SysUtils.isEmpty(null) = true</li>
     * <li>SysUtils.isEmpty("") = true</li>
     * <li>SysUtils.isEmpty("   ") = true</li>
     * <li>SysUtils.isEmpty("abc") = false</li>
     * </ul>
     *
     * @param value 待检查的字符串
     * @return true/false
     */
    public static boolean isEmpty(String value) {
        int strLen;
        if (value == null || (strLen = value.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if ((Character.isWhitespace(value.charAt(i)) == false)) {
                return false;
            }
        }
        return true;
    }
    /**
     * 检查对象是否为数字型字符串,包含负数开头的。
     */
    public static boolean isNumeric(Object obj) {
        if (obj == null) {
            return false;
        }
        char[] chars = obj.toString().toCharArray();
        int length = chars.length;
        if(length < 1) {
            return false;
        }
        int i = 0;
        if(length > 1 && chars[0] == '-') {
            i = 1;
        }
        for (; i < length; i++) {
            if (!Character.isDigit(chars[i])) {
                return false;
            }
        }
        return true;
    }
    /**
     * 检查指定的字符串列表是否不为空。
     */
    public static boolean areNotEmpty(String... values) {
        boolean result = true;
        if (values == null || values.length == 0) {
            result = false;
        } else {
            for (String value : values) {
                result &= !isEmpty(value);
            }
        }
        return result;
    }
    /**
     * 把通用字符编码的字符串转化为汉字编码。
     */
    public static String unicodeToChinese(String unicode) {
        StringBuilder out = new StringBuilder();
        if (!isEmpty(unicode)) {
            for (int i = 0; i < unicode.length(); i++) {
                out.append(unicode.charAt(i));
            }
        }
        return out.toString();
    }
    /**
     * 过滤不可见字符
     */
    public static String stripNonValidXMLCharacters(String input) {
        if (input == null || ("".equals(input))) {
            return "";
        }
        StringBuilder out = new StringBuilder();
        char current;
        for (int i = 0; i < input.length(); i++) {
            current = input.charAt(i);
            if ((current == 0x9) || (current == 0xA) || (current == 0xD)
                    || ((current >= 0x20) && (current <= 0xD7FF))
                    || ((current >= 0xE000) && (current <= 0xFFFD))
                    || ((current >= 0x10000) && (current <= 0x10FFFF))) {
                out.append(current);
            }
        }
        return out.toString();
    }
    public static String leftPad(String str, int size, char padChar) {
        if (str == null) {
            return null;
        } else {
            int pads = size - str.length();
            if (pads <= 0) {
                return str;
            } else {
                return pads > 8192 ? leftPad(str, size, String.valueOf(padChar)) : padding(pads, padChar).concat(str);
            }
        }
    }
    public static String leftPad(String str, int size, String padStr) {
        if (str == null) {
            return null;
        } else {
            if (isEmpty(padStr)) {
                padStr = " ";
            }
            int padLen = padStr.length();
            int strLen = str.length();
            int pads = size - strLen;
            if (pads <= 0) {
                return str;
            } else if (padLen == 1 && pads <= 8192) {
                return leftPad(str, size, padStr.charAt(0));
            } else if (pads == padLen) {
                return padStr.concat(str);
            } else if (pads < padLen) {
                return padStr.substring(0, pads).concat(str);
            } else {
                char[] padding = new char[pads];
                char[] padChars = padStr.toCharArray();
                for(int i = 0; i < pads; ++i) {
                    padding[i] = padChars[i % padLen];
                }
                return (new String(padding)).concat(str);
            }
        }
    }
    private static String padding(int repeat, char padChar) throws IndexOutOfBoundsException {
        if (repeat < 0) {
            throw new IndexOutOfBoundsException("Cannot pad a negative amount: " + repeat);
        } else {
            char[] buf = new char[repeat];
            for(int i = 0; i < buf.length; ++i) {
                buf[i] = padChar;
            }
            return new String(buf);
        }
    }
}
src/main/java/org/springblade/modules/discuss/controller/TopicsController.java
@@ -131,6 +131,7 @@
            List<TopicsDTO> children = topics.getChildren();
            for (TopicsDTO child : children) {
                child.setParentId(topics.getId());
                child.setDiscussContent(topics.getDiscussContent());
                child.setLevel(2);
                boolean b2 = topicsService.saveOrUpdate(child);
            }
src/main/java/org/springblade/modules/discuss/controller/UserTopicsController.java
@@ -19,10 +19,13 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.xxl.job.core.biz.impl.ExecutorBizImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
@@ -45,6 +48,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
/**
@@ -58,6 +63,8 @@
@RequestMapping("blade-userTopics/userTopics")
@Api(value = "用户议题报表", tags = "用户议题报表接口")
public class UserTopicsController extends BladeController {
    private static Logger logger = LoggerFactory.getLogger(UserTopicsController.class);
    private final IUserTopicsService userTopicsService;
@@ -143,7 +150,7 @@
    @PostMapping("/updateBath")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "批量更新", notes = "传入topics")
    public R updateBath(@Valid @RequestBody List<TopicsVO> topics) throws Exception {
    public R updateBath(@Valid @RequestBody TopicsVO topics) throws Exception {
        String result = userTopicsService.batchSave(topics);
        if (result.equals("200")) {
            return R.data("操作成功");
@@ -162,5 +169,18 @@
        ExcelUtil.export(response, "投票人员" + DateUtil.time(), "投票人员数据表", list, UserTopicsExcel.class);
    }
    @GetMapping("/exportDataIndex")
    public void exportExcel(HttpServletResponse response,UserTopicsVO userTopics) {
        try (OutputStream out = response.getOutputStream()) {
            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            response.setCharacterEncoding("utf-8");
            String fileName = URLEncoder.encode("投票人员", "UTF-8").replaceAll("\\+", "%20");
            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
            userTopicsService.handleExcel(out,userTopics);
            out.flush();
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
        }}
}
src/main/java/org/springblade/modules/discuss/excel/UserTopicsExcel.java
@@ -40,9 +40,18 @@
    @ExcelProperty( "小区")
    private String aoiName;
    @ExcelProperty( "面积")
    private String area;
    @ExcelProperty( "地块")
    private String remark;
    @ExcelProperty( "投票项")
    private String optionContent;
    @ExcelProperty( "houseCode")
    private String houseCode;
    @ExcelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
src/main/java/org/springblade/modules/discuss/excel/householdExcel.java
New file
@@ -0,0 +1,71 @@
package org.springblade.modules.discuss.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * HouseExcel
 *
 * @author Chill
 */
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class householdExcel implements Serializable {
    private static final long serialVersionUID = 2L;
    @ExcelProperty( "业主姓名")
    private String name;
    @ExcelProperty( "业主电话")
    private String phone;
    @ExcelProperty( "地块")
    private String remark;
    @ExcelProperty( "栋号")
    private String building;
    @ExcelProperty( "房号")
    private String room;
    @ExcelProperty( "地址")
    private String addressName;
//    @ExcelProperty( "小区")
//    private String aoiName;
    @ExcelProperty( "面积")
    private BigDecimal area;
    @ExcelProperty( "是否投票")
    private String voteFlag;
    @ExcelProperty( "管理规约")
    private String managementRegulations;
    @ExcelProperty( "议事规则")
    private String rulesOfProcedure;
//    @ExcelProperty( "投票项")
//    private String optionContent;
//    @ExcelProperty(value = "创建时间")
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
//    private Date createTime;
}
src/main/java/org/springblade/modules/discuss/excel/topicsExcel.java
New file
@@ -0,0 +1,54 @@
package org.springblade.modules.discuss.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * HouseExcel
 *
 * @author Chill
 */
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class topicsExcel implements Serializable {
    private static final long serialVersionUID = 2L;
    @ExcelProperty( "姓名")
    private String name;
    @ExcelProperty( "手机号")
    private String phone;
    @ExcelProperty( "地址")
    private String addressName;
    @ExcelProperty( "小区")
    private String aoiName;
    @ExcelProperty( "面积")
    private String area;
    @ExcelProperty( "地块")
    private String remark;
    @ExcelProperty( "投票项")
    private String optionContent;
    @ExcelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.java
@@ -20,9 +20,12 @@
import org.springblade.modules.discuss.dto.UserTopicsDTO;
import org.springblade.modules.discuss.entity.UserTopicsEntity;
import org.springblade.modules.discuss.excel.UserTopicsExcel;
import org.springblade.modules.discuss.excel.householdExcel;
import org.springblade.modules.discuss.vo.UserTopicsVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.house.vo.HouseholdVO;
import java.util.List;
/**
@@ -52,4 +55,9 @@
    public List<UserTopicsDTO> selectUserTopicsList(UserTopicsDTO userTopicsDTO);
    List<UserTopicsExcel> exportUser( @Param("userTopics") UserTopicsVO userTopics);
    List<UserTopicsExcel> getresultTwo( @Param("userTopics") UserTopicsVO userTopics);
    UserTopicsVO getresult(UserTopicsVO userTopics);
    List<householdExcel> getHouseholdList(UserTopicsVO userTopics);
}
src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml
@@ -109,6 +109,9 @@
        jh.name,
        jh.phone_number phone,
        jda.address_name,
        jhs.area,
        jhs.remark,
        jda.houseCode,
        jda.aoi_name
        <if test="articleId != null ">,
            group_concat(jt.option_content) optionContent  </if>
@@ -118,6 +121,7 @@
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
        LEFT JOIN jczz_topics jt on jt.id = jut.topics_id
        LEFT JOIN blade_user bu ON jh.associated_user_id = bu.id AND bu.is_deleted = 0
        LEFT JOIN jczz_house jhs on jhs.house_code= jda.address_code
        <where>
            <if test="id != null ">and jut.id = #{id}</if>
            <if test="name != null and name != ''">
@@ -147,6 +151,9 @@
                jh.name,
                jh.phone_number,
                jda.address_name,
                jhs.area,
                jhs.remark,
                jda.houseCode,
                jda.aoi_name
            </if>
        </where>
@@ -154,4 +161,99 @@
    </select>
    <select id="getresult" resultMap="userTopicsResultMap">
        SELECT
            jts.option_content
        FROM
            jczz_user_topics jut
                LEFT JOIN jczz_topics jts ON jts.id = jut.topics_id
        WHERE
            jut.article_id = #{articleId}
          and jut.household_id=#{householdId}
          and jts.discuss_content=#{discussContent}
    </select>
    <select id="getresultTwo" resultType="org.springblade.modules.discuss.excel.UserTopicsExcel">
        SELECT
        jut.article_id,
        jut.delete_flag,
        jut.signature_path,
        jut.create_time,
        jut.household_id,
        bu.avatar,
        jh.name,
        jh.phone_number phone,
        jda.address_name,
        jhs.area,
        jhs.remark,
        jda.address_code houseCode,
        jda.aoi_name,
        jt.option_content
        FROM
        jczz_user_topics as jut
        LEFT JOIN jczz_household jh ON jh.id = jut.household_id and jh.is_deleted = 0
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
        LEFT JOIN jczz_topics jt on jt.id = jut.topics_id
        LEFT JOIN blade_user bu ON jh.associated_user_id = bu.id AND bu.is_deleted = 0
        LEFT JOIN jczz_house jhs on jhs.house_code= jda.address_code
        <where>
            <if test="id != null ">and jut.id = #{id}</if>
            <if test="name != null and name != ''">
                and bu.name like concat('%',#{name},'%')
            </if>
            <if test="phone != null and phone != ''">
                and bu.phone like concat('%',#{phone},'%')
            </if>
            <if test="aoiCodeList != null and aoiCodeList.size() > 0">
                and jda.aoi_code in
                <foreach collection="aoiCodeList" item="code" open="(" close=")" separator=",">
                    #{code}
                </foreach>
            </if>
            <if test="householdId != null ">and jut.household_id = #{householdId}</if>
            <if test="topicsId != null ">and jut.topics_id = #{topicsId}</if>
            <if test="createTime != null ">and jut.create_time = #{createTime}</if>
            <if test="updateTime != null ">and jut.update_time = #{updateTime}</if>
            <if test="deleteFlag != null ">and jut.delete_flag = #{deleteFlag}</if>
            <if test="articleId != null ">
                and jut.article_id = #{articleId}
                and jut.delete_flag = 0
            </if>
        </where>
    </select>
    <select id="getHouseholdList" resultType="org.springblade.modules.discuss.excel.householdExcel">
        SELECT
        DISTINCT(jh.id),
        jh.*,
        (
        SELECT
        group_concat( jt.option_content ) AS optionContent
        FROM
        jczz_user_topics jut
        LEFT JOIN jczz_topics jt ON jt.id = jut.topics_id
        WHERE
        jut.house_code = jh.house_code
        AND jut.article_id = #{articleId}
        ) selectd
        FROM
        jczz_house jh
        LEFT JOIN jczz_household jhd ON jhd.house_code = jh.house_code
        AND jh.is_deleted = 0
        LEFT JOIN jczz_user_topics jut on jut.household_id = jhd.id
        <where>
            <if test="districtIdList != null and districtIdList.size() > 0">
                and jh.district_code in
                <foreach collection="districtIdList" item="code" open="(" close=")" separator=",">
                    #{code}
                </foreach>
            </if>
        </where>
    </select>
</mapper>
src/main/java/org/springblade/modules/discuss/service/IUserTopicsService.java
@@ -23,6 +23,7 @@
import org.springblade.modules.discuss.vo.TopicsVO;
import org.springblade.modules.discuss.vo.UserTopicsVO;
import java.io.OutputStream;
import java.util.List;
/**
@@ -43,11 +44,13 @@
    IPage<UserTopicsVO> selectUserTopicsPage(IPage<UserTopicsVO> page, UserTopicsVO userTopics);
    String batchSave(List<TopicsVO> topics) throws Exception;
    String batchSave(TopicsVO topics) throws Exception;
    Integer getCount(Integer id);
    List<UserTopicsExcel> exportUser(UserTopicsVO userTopics);
    Boolean saveUserTopicsEntity(UserTopicsEntity userTopics);
    void handleExcel(OutputStream out,UserTopicsVO userTopics);
}
src/main/java/org/springblade/modules/discuss/service/impl/PublicDiscussServiceImpl.java
@@ -109,6 +109,7 @@
                    publicDiscussVO.setDisabled(true);
                }
            }
            // 判断是否业主,只有业主可以投票
        }
        return publicDiscussVO;
    }
src/main/java/org/springblade/modules/discuss/service/impl/UserTopicsServiceImpl.java
@@ -16,23 +16,30 @@
 */
package org.springblade.modules.discuss.service.impl;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import liquibase.pro.packaged.H;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.jetbrains.annotations.Nullable;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.discuss.entity.PublicDiscussEntity;
import org.springblade.modules.discuss.entity.TopicsEntity;
import org.springblade.modules.discuss.entity.UserTopicsEntity;
import org.springblade.modules.discuss.excel.UserTopicsExcel;
import org.springblade.modules.discuss.excel.householdExcel;
import org.springblade.modules.discuss.mapper.UserTopicsMapper;
import org.springblade.modules.discuss.service.IPublicDiscussService;
import org.springblade.modules.discuss.service.ITopicsService;
@@ -41,12 +48,18 @@
import org.springblade.modules.discuss.vo.UserTopicsVO;
import org.springblade.modules.district.entity.DistrictEntity;
import org.springblade.modules.district.service.IDistrictService;
import org.springblade.modules.house.entity.HouseEntity;
import org.springblade.modules.house.entity.HouseholdEntity;
import org.springblade.modules.house.excel.HouseHoldExcel;
import org.springblade.modules.house.service.IHouseService;
import org.springblade.modules.house.service.IHouseholdService;
import org.springblade.modules.house.vo.HouseholdVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -61,6 +74,10 @@
public class UserTopicsServiceImpl extends ServiceImpl<UserTopicsMapper, UserTopicsEntity> implements IUserTopicsService {
    @Resource
    private ITopicsService topicsService;
    public static final String SMS_VALIDATE_PHONE = "sms:validate:code:";
    @Autowired
    private BladeRedis redisTemplate;
    @Override
    public IPage<UserTopicsVO> selectUserTopicsPage(IPage<UserTopicsVO> page, UserTopicsVO userTopics) {
@@ -91,21 +108,33 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String batchSave(List<TopicsVO> topics) throws Exception {
    public String batchSave(TopicsVO topics) throws Exception {
        if (StringUtils.isNotBlank(topics.getPhone())) {
            Object validateCode = redisTemplate.get(SMS_VALIDATE_PHONE + topics.getPhone());
            if (validateCode == null) {
                return "验证码已过期";
            }
            if (!validateCode.toString().equals(topics.getCode())) {
                return "验证码错误";
            }
            //删除验证码
            redisTemplate.del(SMS_VALIDATE_PHONE + topics.getPhone());
        }
        // 判断是否一户一票 还是一人一票
        List<TopicsVO> topicsList = topics.getChildren();
        IHouseholdService householdService = SpringUtils.getBean(IHouseholdService.class);
        HouseholdEntity householdEntity = householdService.getOne(Wrappers.<HouseholdEntity>lambdaQuery()
            .eq(HouseholdEntity::getHouseCode, topics.get(0).getHouseCode())
            .eq(HouseholdEntity::getHouseCode, topicsList.get(0).getHouseCode())
            .eq(HouseholdEntity::getAssociatedUserId, AuthUtil.getUserId())
            .eq(HouseholdEntity::getIsDeleted, 0)
            .last("limit 1"));
        IPublicDiscussService bean = SpringUtil.getBean(IPublicDiscussService.class);
        PublicDiscussEntity one = bean.getOne(Wrappers.<PublicDiscussEntity>lambdaQuery().eq(PublicDiscussEntity::getArticleId, topics.get(0).getArticleId()));
        PublicDiscussEntity one = bean.getOne(Wrappers.<PublicDiscussEntity>lambdaQuery().eq(PublicDiscussEntity::getArticleId, topicsList.get(0).getArticleId()));
        // 一户一票
        if (one.getVoteRestrictions().equals(CommonConstant.NUMBER_ONE)) {
            long count = count(Wrappers.<UserTopicsEntity>lambdaQuery()
                .eq(UserTopicsEntity::getHouseCode, topics.get(0).getHouseCode())
                .eq(UserTopicsEntity::getArticleId, topics.get(0).getArticleId()));
                .eq(UserTopicsEntity::getHouseCode, topicsList.get(0).getHouseCode())
                .eq(UserTopicsEntity::getArticleId, topicsList.get(0).getArticleId()));
            if (count > 0) {
                return "您的房屋已投票,不能重复投票!";
            }
@@ -113,12 +142,12 @@
            //
            long count = count(Wrappers.<UserTopicsEntity>lambdaQuery()
                .eq(UserTopicsEntity::getHouseholdId, householdEntity.getId())
                .eq(UserTopicsEntity::getArticleId, topics.get(0).getArticleId()));
                .eq(UserTopicsEntity::getArticleId, topicsList.get(0).getArticleId()));
            if (count > 0) {
                return "您已投票,不能重复投票!";
            }
        }
        for (TopicsVO topic : topics) {
        for (TopicsVO topic : topicsList) {
            if (topic.getMandatoryFlag().equals(2)) {
                if (topic.getOptionNumberMin() > 1) {
                    JSONArray objects1 = JSON.parseArray(topic.getSelected());
@@ -134,13 +163,13 @@
                }
            }
        }
        Boolean userTopics = getaBoolean(topics,householdEntity);
        Boolean userTopics = getaBoolean(topicsList, householdEntity);
        if (userTopics) return "200";
        return "操作失败!";
    }
    @Nullable
    private Boolean getaBoolean(List<TopicsVO> topics,HouseholdEntity householdEntity) {
    private Boolean getaBoolean(List<TopicsVO> topics, HouseholdEntity householdEntity) {
        List<UserTopicsEntity> objects = new ArrayList<>();
        Boolean result = false;
        for (TopicsVO topic : topics) {
@@ -235,4 +264,98 @@
        }
        return save(userTopics);
    }
    @Override
    public void handleExcel(OutputStream out, UserTopicsVO userTopics) {
        ExcelWriter excelWriter = EasyExcelFactory.write(out).build();
        //设置内容样式
        WriteCellStyle contentStyle = new WriteCellStyle();
        contentStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//居中
        contentStyle.setWrapped(true);//自动换行
        //设置头部样式
        WriteCellStyle headerStyle = new WriteCellStyle();
        headerStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        //设置策略
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headerStyle, contentStyle);
        WriteSheet proposalSheet = EasyExcelFactory.writerSheet(0, "委员提案").head(HouseHoldExcel.class).registerWriteHandler(horizontalCellStyleStrategy).build();
        WriteSheet publicopinionSheet = EasyExcelFactory.writerSheet(1, "社情民意").head(HouseHoldExcel.class).registerWriteHandler(horizontalCellStyleStrategy).build();
        excelWriter.write(getProposal(userTopics), proposalSheet);
        excelWriter.write(getPublicopinion(userTopics), publicopinionSheet);
    }
    //首页-房屋记录
    private List<householdExcel> getProposal(UserTopicsVO userTopics) {
        List<householdExcel> list = new ArrayList<>();
        JSONArray objects1 = JSON.parseArray(userTopics.getDistrictId());
        List<String> collect1 = objects1.stream().map(item -> (String)item).collect(Collectors.toList());
        IDistrictService bean3 = SpringUtils.getBean(IDistrictService.class);
        List<DistrictEntity> list3 = bean3.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, collect1));
        List<String> aoiCodeList = list3.stream().map(item -> item.getAoiCode() ).collect(Collectors.toList());
        userTopics.setAoiCodeList(aoiCodeList);
        List<householdExcel> householdList = baseMapper.getHouseholdList(userTopics);
//
//        householdExcel vo = new householdExcel();
//        list.add(vo);
//        IHouseService bean = SpringUtils.getBean(IHouseService.class);
//        JSONArray objects = JSON.parseArray(userTopics.getDistrictId());
//
//        List<HouseEntity> list1 = bean.list(Wrappers.<HouseEntity>lambdaQuery().in(HouseEntity::getDistrictCode, aoiCodeList));
//
//        IHouseholdService bean1 = SpringUtils.getBean(IHouseholdService.class);
//
//        IUserTopicsService bean2 = SpringUtils.getBean(IUserTopicsService.class);
//
//        for (HouseEntity houseEntity : list1) {
//            householdExcel householdExcel = new householdExcel();
//            householdExcel.setArea(houseEntity.getArea());
//            householdExcel.setBuilding(houseEntity.getBuilding());
//            householdExcel.setRoom(houseEntity.getRoom());
//            householdExcel.setRemark(houseEntity.getRemark());
//            // 查询住户
//            List<HouseholdEntity> list2 = bean1.list(Wrappers.<HouseholdEntity>lambdaQuery()
//                .eq(HouseholdEntity::getHouseCode, houseEntity.getHouseCode())
//                .eq(HouseholdEntity::getIsDeleted, 0)
//                .ne(HouseholdEntity::getRelationship, 18));
//            // 判断住户是否有投票
//            for (HouseholdEntity householdEntity : list2) {
//                householdExcel.setName(householdEntity.getName());
//                householdExcel.setPhone(householdEntity.getPhoneNumber());
//                long count = bean2.count(Wrappers.<UserTopicsEntity>lambdaQuery()
//                    .eq(UserTopicsEntity::getHouseholdId, householdEntity.getId()));
//                if (count > 0) {
//                    // 查询选择的结果
//                    userTopics.setDiscussContent("管理规约");
//                    userTopics.setHouseholdId(householdEntity.getId());
//                    UserTopicsVO getresult = baseMapper.getresult(userTopics);
//                    if (getresult != null) {
//                        householdExcel.setManagementRegulations(getresult.getOptionContent());
//                    }
//                    userTopics.setDiscussContent("议事规则");
//                    UserTopicsVO getresult2 = baseMapper.getresult(userTopics);
//                    if (getresult2 != null) {
//                        householdExcel.setRulesOfProcedure(getresult2.getOptionContent());
//                    }
//                    householdExcel.setVoteFlag("是");
//                    break;
//                } else {
//                    householdExcel.setVoteFlag("否");
//                }
//            }
            // 添加
            list.addAll(householdList);
//        }
        return list;
    }
    //首页-议事
    private List<UserTopicsExcel> getPublicopinion(UserTopicsVO userTopics) {
        List<UserTopicsExcel> list = new ArrayList<>();
        List<UserTopicsExcel> userTopicsExcels = baseMapper.getresultTwo(userTopics);
        UserTopicsExcel vo = new UserTopicsExcel();
        list.add(vo);
        list.addAll(userTopicsExcels);
        return list;
    }
}
src/main/java/org/springblade/modules/discuss/vo/TopicsVO.java
@@ -39,5 +39,7 @@
    private String houseCode;
    private String signaturePath;
    private String phone;
    private String code;
}
src/main/java/org/springblade/modules/discuss/vo/UserTopicsVO.java
@@ -17,6 +17,8 @@
package org.springblade.modules.discuss.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import org.springblade.modules.discuss.entity.UserTopicsEntity;
import org.springblade.core.tool.node.INode;
import lombok.Data;
@@ -49,5 +51,10 @@
    private String districtId;
    private String optionContent;
    /** 议题内容 */
    @ApiModelProperty(value = "议题内容", example = "")
    private String discussContent;
}
src/main/java/org/springblade/modules/property/mapper/PropertyCompanyDistrictMapper.xml
@@ -90,7 +90,7 @@
        SELECT bu.*,
               jpc.name distictName
        FROM blade_user bu
                 LEFT JOIN jczz_property_district_user jpdu ON bu.id = jpdu.user_id
                 LEFT JOIN jczz_property_district_user jpdu ON bu.id = jpdu.user_id and bu.is_deleted = 0
                 LEFT JOIN jczz_property_company_district jpcd ON jpdu.property_company_district_id = jpcd.id
                 LEFT JOIN jczz_property_company jpc on jpc.id = jpcd.property_company_id
                 LEFT JOIN jczz_district jd ON jd.id = jpcd.district_id
src/main/java/org/springblade/modules/sms/controller/SmsSendController.java
New file
@@ -0,0 +1,65 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.sms.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.service.ISmsSendService;
import org.springblade.modules.sms.service.ISmsTemplateService;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import org.springblade.modules.sms.wrapper.SmsTemplateWrapper;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
 * 短信模版表 控制器
 *
 * @author BladeX
 * @since 2024-03-06
 */
@RestController
@AllArgsConstructor
@RequestMapping("blade-smsSend/smsSend")
@Api(value = "发送短信验证码", tags = "发送短信验证码")
public class SmsSendController extends BladeController {
    private final ISmsSendService iSmsSendService;
    /**
     * 短信模版表 详情
     */
    @GetMapping("/send")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "发送短信验证码")
    public R<SmsTemplateVO> detail(@RequestParam String phone) {
        Boolean aBoolean = iSmsSendService.smsSend(phone);
        return R.status(aBoolean);
    }
}
src/main/java/org/springblade/modules/sms/controller/SmsTemplateController.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/controller/SmsTemplateController.java
@@ -14,7 +14,7 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.controller;
package org.springblade.modules.sms.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -23,17 +23,16 @@
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.modules.smsTemplate.vo.SmsTemplateVO;
import org.springblade.modules.smsTemplate.wrapper.SmsTemplateWrapper;
import org.springblade.modules.smsTemplate.service.ISmsTemplateService;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import org.springblade.modules.sms.wrapper.SmsTemplateWrapper;
import org.springblade.modules.sms.service.ISmsTemplateService;
import org.springblade.core.boot.ctrl.BladeController;
/**
src/main/java/org/springblade/modules/sms/dto/SmsTemplateDTO.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/dto/SmsTemplateDTO.java
@@ -14,9 +14,9 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.dto;
package org.springblade.modules.sms.dto;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
src/main/java/org/springblade/modules/sms/entity/SmsTemplateEntity.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/entity/SmsTemplateEntity.java
@@ -14,24 +14,18 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.entity;
package org.springblade.modules.sms.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
/**
 * 短信模版表对象 blade_sms_template
src/main/java/org/springblade/modules/sms/mapper/SmsTemplateMapper.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/mapper/SmsTemplateMapper.java
@@ -14,11 +14,11 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.mapper;
package org.springblade.modules.sms.mapper;
import org.springblade.modules.smsTemplate.dto.SmsTemplateDTO;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.modules.smsTemplate.vo.SmsTemplateVO;
import org.springblade.modules.sms.dto.SmsTemplateDTO;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
src/main/java/org/springblade/modules/sms/mapper/SmsTemplateMapper.xml
File was renamed from src/main/java/org/springblade/modules/smsTemplate/mapper/SmsTemplateMapper.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.smsTemplate.mapper.SmsTemplateMapper">
<mapper namespace="org.springblade.modules.sms.mapper.SmsTemplateMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="smsTemplateResultMap" type="org.springblade.modules.smsTemplate.entity.SmsTemplateEntity">
    <resultMap id="smsTemplateResultMap" type="org.springblade.modules.sms.entity.SmsTemplateEntity">
    </resultMap>
@@ -13,7 +13,7 @@
    <resultMap type="org.springblade.modules.smsTemplate.dto.SmsTemplateDTO" id="BladeSmsTemplateDTOResult">
    <resultMap type="org.springblade.modules.sms.dto.SmsTemplateDTO" id="BladeSmsTemplateDTOResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="content"    column="content"    />
@@ -42,7 +42,7 @@
        id = #{id}
    </select>
    <select id="selectBladeSmsTemplateList" parameterType="org.springblade.modules.smsTemplate.dto.SmsTemplateDTO" resultMap="BladeSmsTemplateDTOResult">
    <select id="selectBladeSmsTemplateList" parameterType="org.springblade.modules.sms.dto.SmsTemplateDTO" resultMap="BladeSmsTemplateDTOResult">
        <include refid="selectBladeSmsTemplate"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
src/main/java/org/springblade/modules/sms/service/ISmsSendService.java
copy from src/main/java/org/springblade/modules/smsTemplate/dto/SmsTemplateDTO.java copy to src/main/java/org/springblade/modules/sms/service/ISmsSendService.java
File was copied from src/main/java/org/springblade/modules/smsTemplate/dto/SmsTemplateDTO.java
@@ -14,21 +14,30 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.dto;
package org.springblade.modules.sms.service;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.sms.dto.SmsTemplateDTO;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import java.util.List;
/**
 * 短信模版表 数据传输对象实体类
 * 短信模版表 服务类
 *
 * @author BladeX
 * @since 2024-03-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SmsTemplateDTO extends SmsTemplateEntity {
    private static final long serialVersionUID = 1L;
public interface ISmsSendService extends IService<SmsTemplateEntity> {
    /**
     *
     *
     * @return
     */
    Boolean smsSend(String phone);
}
src/main/java/org/springblade/modules/sms/service/ISmsTemplateService.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/service/ISmsTemplateService.java
@@ -14,13 +14,12 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.service;
package org.springblade.modules.sms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.smsTemplate.dto.SmsTemplateDTO;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.modules.smsTemplate.vo.SmsTemplateVO;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.sms.dto.SmsTemplateDTO;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
src/main/java/org/springblade/modules/sms/service/impl/SmsSendServiceImpl.java
New file
@@ -0,0 +1,166 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.sms.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.config.SmsConfig;
import org.springblade.common.utils.HttpClientUtils;
import org.springblade.common.utils.UtilRandom;
import org.springblade.common.utils.sms.AlipaySignature;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.mapper.SmsTemplateMapper;
import org.springblade.modules.sms.service.ISmsSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
 * 短信模版表 服务实现类
 *
 * @author BladeX
 * @since 2024-03-06
 */
@Service
public class SmsSendServiceImpl extends ServiceImpl<SmsTemplateMapper, SmsTemplateEntity> implements ISmsSendService {
    @Autowired
    private  BladeRedis redisTemplate;
    private static Logger logger = LoggerFactory.getLogger(SmsSendServiceImpl.class);
    public static final String SMS_VALIDATE_PHONE = "sms:validate:code:";
    public static final String SMS_VALIDATE_PHONE_NUM = "sms:validate:phone:";
    @Autowired
    private SmsConfig smsConfig;
    @Override
    public Boolean smsSend(String phone) {
        //发送的手机号
        List<Map> phonesList = new ArrayList<>();
        Map phoneMap = new HashMap();
        phoneMap.put("phone", phone);
        List<String> varList = new ArrayList<>();
        Integer code = UtilRandom.randomCount(111111, 999999);
        varList.add(code.toString());
        phoneMap.put("varList", varList);
        phonesList.add(phoneMap);
        //短信主题
        String subject = "对外接口不同内容发送-动态模板";
        //短信内容
        String content = "您正在验证投票操作,验证码:#P_1#。如非本人操作,则密码可能已泄露,建议立即修改密码或联系客服。";
//        String content = "尊敬的#P_1#,你得工资#P_2#,测试#P_3#";
        //短信模板
        String template_id = null;
        //发送时间
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String send_time = df.format(new Date());
        //优先级,高级=5,中级=3,低级=1
        String priority = "1";
        //不同内容发送类型,1=动态模板发送,2=文件内容发送
        String type = "1";
        Map params = new HashMap();
        params.put("phones", phonesList);
        params.put("subject", subject);
        params.put("content", content);
        params.put("template_id", template_id);
        params.put("send_time", send_time);
        params.put("priority", priority);
        params.put("type", type);
        //创建人主键
        params.put("sop_create_by", smsConfig.getSopCreateBy());
        String s = null;
        try {
            s = testGet(params, "message.sop.differentMes");
            JSONObject jsonObject = JSON.parseObject(s);
            JSONObject messageSopEqualsMesResponse = (JSONObject) jsonObject.get("message_sop_equalsMes_response");
            if (messageSopEqualsMesResponse.get("code").equals(200)) {
                // 将验证码存入redis
                redisTemplate.setEx(SMS_VALIDATE_PHONE + phone, code, 300L);
                redisTemplate.setEx(SMS_VALIDATE_PHONE_NUM + phone, 1, 60L);
                return true;
            }
        } catch (Exception e) {
            logger.error("短信发送失败!", e);
            throw new RuntimeException(e);
        }
        return false;
    }
    public String testGet(Object bizContent, String method) throws Exception {
        // 公共请求参数
        Map<String, String> params = new HashMap<String, String>();
        params.put("app_id", smsConfig.getSmsAppId());
        params.put("method", method);
        params.put("format", "json");
        params.put("charset", "utf-8");
        params.put("sign_type", "RSA2");
        params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        params.put("version", "1.0");
        // 业务参数
        params.put("biz_content", JSON.toJSONString(bizContent));
        String content = AlipaySignature.getSignContent(params);
        String sign = AlipaySignature.rsa256Sign(content, smsConfig.getSmsPrivateKey(), "utf-8");
        params.put("sign", sign);
        System.out.println("----------- 请求信息 -----------");
        System.out.println("请求参数:" + buildParamQuery(params));
        System.out.println("商户秘钥:" + smsConfig.getSmsPrivateKey());
        System.out.println("待签名内容:" + content);
        System.out.println("签名(sign):" + sign);
        System.out.println("URL参数:" + buildUrlQuery(params));
        System.out.println("----------- 返回结果 -----------");
        String responseData = HttpClientUtils.doGet(smsConfig.getSmsUrl(), params);// 发送请求
        System.out.println("返回数据" + responseData);
        return responseData;
    }
    protected static String buildParamQuery(Map<String, String> params) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> entry : params.entrySet()) {
            sb.append("&").append(entry.getKey()).append("=").append(entry.getValue());
        }
        return sb.toString().substring(1);
    }
    protected static String buildUrlQuery(Map<String, String> params) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> entry : params.entrySet()) {
            try {
                sb.append("&").append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return sb.toString().substring(1);
    }
}
src/main/java/org/springblade/modules/sms/service/impl/SmsTemplateServiceImpl.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/service/impl/SmsTemplateServiceImpl.java
@@ -14,15 +14,14 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.service.impl;
package org.springblade.modules.sms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.smsTemplate.dto.SmsTemplateDTO;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.modules.smsTemplate.vo.SmsTemplateVO;
import org.springblade.modules.smsTemplate.mapper.SmsTemplateMapper;
import org.springblade.modules.smsTemplate.service.ISmsTemplateService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.sms.dto.SmsTemplateDTO;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import org.springblade.modules.sms.mapper.SmsTemplateMapper;
import org.springblade.modules.sms.service.ISmsTemplateService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
src/main/java/org/springblade/modules/sms/vo/SmsTemplateVO.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/vo/SmsTemplateVO.java
@@ -14,10 +14,9 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.vo;
package org.springblade.modules.sms.vo;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.core.tool.node.INode;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
src/main/java/org/springblade/modules/sms/wrapper/SmsTemplateWrapper.java
File was renamed from src/main/java/org/springblade/modules/smsTemplate/wrapper/SmsTemplateWrapper.java
@@ -14,12 +14,12 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.smsTemplate.wrapper;
package org.springblade.modules.sms.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.smsTemplate.entity.SmsTemplateEntity;
import org.springblade.modules.smsTemplate.vo.SmsTemplateVO;
import org.springblade.modules.sms.entity.SmsTemplateEntity;
import org.springblade.modules.sms.vo.SmsTemplateVO;
import java.util.Objects;
/**
src/main/java/org/springblade/modules/system/controller/MenuController.java
@@ -138,8 +138,11 @@
     */
    @GetMapping("/dynamicMenu")
    @ApiOperation(value = "菜单列表", notes = "传入menu")
    public R<List<MenuVO>> dynamicMenu(String roleId, Long topMenuId, @RequestParam(value = "labelType", required = false,defaultValue = "0") Integer labelType, @RequestParam(value = "roleName",required = false) String roleName) {
        List<MenuVO> list = menuService.routes(roleId, topMenuId,labelType,1,roleName);
    public R<List<MenuVO>> dynamicMenu(String roleId, Long topMenuId,
                                       @RequestParam(value = "labelType", required = false,defaultValue = "0") Integer labelType,
                                       @RequestParam(value = "roleName",required = false) String roleName,
                                       @RequestParam(value = "houseCode",required = false) String houseCode) {
        List<MenuVO> list = menuService.routes(roleId, topMenuId,labelType,1,roleName,houseCode);
        return R.data(list);
    }
@@ -200,7 +203,7 @@
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "前端菜单数据", notes = "前端菜单数据")
    public R<List<MenuVO>> routes(BladeUser user, Long topMenuId) {
        List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId,null,0,"");
        List<MenuVO> list = menuService.routes((user == null) ? null : user.getRoleId(), topMenuId,null,0,"","");
        return R.data(list);
    }
src/main/java/org/springblade/modules/system/service/IMenuService.java
@@ -59,7 +59,7 @@
     * @param topMenuId
     * @return
     */
    List<MenuVO> routes(String roleId, Long topMenuId,Integer labelType,Integer menuType,String roleName);
    List<MenuVO> routes(String roleId, Long topMenuId,Integer labelType,Integer menuType,String roleName,String houseCode);
    /**
     * 菜单树形结构
src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java
@@ -111,7 +111,7 @@
    @Override
    public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType, Integer menuType, String roleName) {
    public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType, Integer menuType, String roleName,String houseCode) {
        if (StringUtil.isBlank(roleId)) {
            return null;
        }
@@ -126,7 +126,7 @@
            roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId), menuType));
            // 1:居民,居民需要通过人的标签来显示取保候审
            if (CommonConstant.RESIDENT.equals(roleName)) {
                 extracted(labelType, roleMenus);
                 extracted(labelType, roleMenus,houseCode);
            }
        }
        // 顶部菜单请求返回对应角色权限菜单
@@ -153,10 +153,11 @@
     * @param roleMenus
     * @param labelType
     */
    private void extracted(Integer labelType, List<Menu> roleMenus) {
    private void extracted(Integer labelType, List<Menu> roleMenus,String houseCode) {
        UserHouseLabelDTO userHouseLabelDTO = new UserHouseLabelDTO();
        userHouseLabelDTO.setUserId(AuthUtil.getUserId());
        userHouseLabelDTO.setLableType(labelType);
        userHouseLabelDTO.setHouseCode(houseCode);
        List<Integer> integers = iUserHouseLabelService.selectUserLabelList(userHouseLabelDTO);
        Iterator<Menu> iterator = roleMenus.iterator();
        while (iterator.hasNext()) {
@@ -171,12 +172,12 @@
                        // 场所的时候,删除取保候审
                    } else if (CommonConstant.NUMBER_TWO.equals(labelType)) {
                        if (next.getName().trim().equals("取保候审")) {
                        if (next.getName().trim().equals("取保监居")) {
                            iterator.remove();
                        }
                    }
                } else {
                    if (next.getName().trim().equals("取保候审")) {
                    if (next.getName().trim().equals("取保监居")) {
                        iterator.remove();
                    }
                }
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -54,6 +54,7 @@
import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
import org.springblade.modules.police.service.IPoliceAffairsGridService;
import org.springblade.modules.property.entity.PropertyCompanyEntity;
import org.springblade.modules.property.service.IPropertyCompanyDistrictService;
import org.springblade.modules.property.service.IPropertyCompanyService;
import org.springblade.modules.system.entity.*;
import org.springblade.modules.system.excel.PoliceUserExcel;
@@ -603,11 +604,12 @@
            IGridmanService bean = SpringUtil.getBean(IGridmanService.class);
            return bean.getGridManByCode(houseCode);
        } else {
//            IPropertyCompanyDistrictService bean1 = SpringUtil.getBean(IPropertyCompanyDistrictService.class);
//            return bean1.getDistictUserByCode(houseCode);
            String deptId = AuthUtil.getDeptId();
            List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
            return baseMapper.selectUserByDept(deptIdList);
            IPropertyCompanyDistrictService bean1 = SpringUtil.getBean(IPropertyCompanyDistrictService.class);
            return bean1.getDistictUserByCode(houseCode);
            // 通过huosecode 查询物业工作人员
//            String deptId = AuthUtil.getDeptId();
//            List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
//            return baseMapper.selectUserByDept(deptIdList);
        }
    }
src/main/java/org/springblade/modules/task/mapper/TaskResidencePermitApplyMapper.java
@@ -47,7 +47,7 @@
                                                                        @Param("gridCodeList") List<String> gridCodeList);
    Integer getCount(String neiCode, int i, Long userId,@Param("regionChildCodesList") List<String> regionChildCodesList,
    Integer getCount(String neiCode, int status, Long userId,@Param("regionChildCodesList") List<String> regionChildCodesList,
                     @Param("isAdministrator") Integer isAdministrator,
                     @Param("gridCodeList") List<String> gridCodeList);
}
src/main/java/org/springblade/modules/task/mapper/TaskResidencePermitApplyMapper.xml
@@ -107,6 +107,7 @@
        <where>
            and jtrpa.is_deleted = 0
            <if test="neiCode != null  and neiCode != ''"> and jg.community_code = #{neiCode}</if>
            <if test="status != null  and status != ''"> and jtrpa.confirm_flag = #{status}</if>
           <if test="isAdministrator==2">
<!--                <if test="residen.roleType ==null ">-->
src/main/java/org/springblade/modules/task/service/ITaskResidencePermitApplyService.java
@@ -54,7 +54,7 @@
     * @param i
     * @return
     */
    Integer getCount(String neiCode, int i);
    Integer getCount(String neiCode, int status);
    /**
     * 审核
src/main/java/org/springblade/modules/task/service/impl/TaskResidencePermitApplyServiceImpl.java
@@ -98,7 +98,7 @@
    }
    @Override
    public Integer getCount(String neiCode, int i) {
    public Integer getCount(String neiCode, int status) {
        TaskResidencePermitApplyVO taskResidencePermitApply = new TaskResidencePermitApplyVO();
        taskResidencePermitApply.setCommunityCode(neiCode);
        // 获取请求头中的角色别名
@@ -106,7 +106,7 @@
        if (AuthUtils.isMj(roleName)) {
            // todo 需要改造
            CommonParamSet commonParamSet = new CommonParamSet().invoke(TaskResidencePermitApplyVO.class, taskResidencePermitApply);
            return baseMapper.getCount(neiCode, i, AuthUtil.getUserId(),commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList());
            return baseMapper.getCount(neiCode, status, AuthUtil.getUserId(),commonParamSet.getRegionChildCodesList(), commonParamSet.getIsAdministrator(), commonParamSet.getGridCodeList());
        }
        return 0;
    }