Parcourir la source

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

Shi Kejing il y a 4 ans
Parent
commit
0b235a2c8c

+ 4 - 1
common/common-entity/pom.xml

@ -23,6 +23,9 @@
            <groupId>com.fasterxml.jackson.core</groupId>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
    </dependencies>
    </dependencies>
</project>
</project>

+ 8 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java

@ -1,11 +1,9 @@
package com.yihu.jw.entity.iot.company;
package com.yihu.jw.entity.iot.company;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.util.StringFStringEncryptConverter;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
import java.util.Date;
import java.util.Date;
import java.util.List;
import java.util.List;
@ -92,6 +90,7 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.status = status;
        this.status = status;
    }
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getName() {
    public String getName() {
        return name;
        return name;
    }
    }
@ -140,6 +139,7 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.organizationAddress = organizationAddress;
        this.organizationAddress = organizationAddress;
    }
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getOfficePhone() {
    public String getOfficePhone() {
        return officePhone;
        return officePhone;
    }
    }
@ -148,6 +148,7 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.officePhone = officePhone;
        this.officePhone = officePhone;
    }
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getContactsName() {
    public String getContactsName() {
        return contactsName;
        return contactsName;
    }
    }
@ -156,6 +157,7 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.contactsName = contactsName;
        this.contactsName = contactsName;
    }
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getContactsMobile() {
    public String getContactsMobile() {
        return contactsMobile;
        return contactsMobile;
    }
    }
@ -164,6 +166,7 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.contactsMobile = contactsMobile;
        this.contactsMobile = contactsMobile;
    }
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getContactsIdcard() {
    public String getContactsIdcard() {
        return contactsIdcard;
        return contactsIdcard;
    }
    }
@ -277,6 +280,7 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.auditTime = auditTime;
        this.auditTime = auditTime;
    }
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getAuditName() {
    public String getAuditName() {
        return auditName;
        return auditName;
    }
    }

+ 81 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/util/AesEncryptUtils.java

@ -0,0 +1,81 @@
package com.yihu.jw.entity.util;
import org.apache.commons.codec.binary.Base64;
import org.springframework.util.StringUtils;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
/**
 * 前后端数据传输加密工具类
 * @author monkey
 *
 */
public class AesEncryptUtils {
    //可配置到Constant中,并读取配置文件注入,16位,自己定义
    private static final String KEY = "jkzl2021ZJXL*#%a";
    //参数分别代表 算法名称/加密模式/数据填充方式
    private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding";
    /**
     * 加密
     * @param content 加密的字符串
     * @param encryptKey key值
     * @return
     * @throws Exception
     */
    public static String encrypt(String content, String encryptKey){
        try {
            KeyGenerator kgen = KeyGenerator.getInstance("AES");
            kgen.init(128);
            Cipher cipher = Cipher.getInstance(ALGORITHMSTR);
            cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(encryptKey.getBytes(), "AES"));
            byte[] b = cipher.doFinal(content.getBytes("utf-8"));
            // 采用base64算法进行转码,避免出现中文乱码
            return Base64.encodeBase64String(b);
        }catch (Exception e){
            e.printStackTrace();
            return content;
        }
    }
    /**
     * 解密
     * @param encryptStr 解密的字符串
     * @param decryptKey 解密的key值
     * @return
     * @throws Exception
     */
    public static String decrypt(String encryptStr, String decryptKey) {
        try {
            KeyGenerator kgen = KeyGenerator.getInstance("AES");
            kgen.init(128);
            Cipher cipher = Cipher.getInstance(ALGORITHMSTR);
            cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decryptKey.getBytes(), "AES"));
            // 采用base64算法进行转码,避免出现中文乱码
            byte[] encryptBytes = Base64.decodeBase64(encryptStr);
            byte[] decryptBytes = cipher.doFinal(encryptBytes);
            return new String(decryptBytes);
        }catch (Exception e){
            e.printStackTrace();
            return encryptStr;
        }
    }
    public static String encrypt(String content){
        if(content == null){
            return content;
        }
        return encrypt(content, KEY);
    }
    public static String decrypt(String encryptStr){
        if(StringUtils.isEmpty(encryptStr)){
            return encryptStr;
        }
        return decrypt(encryptStr, KEY);
    }
}

+ 18 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/util/StringFStringEncryptConverter.java

@ -0,0 +1,18 @@
package com.yihu.jw.entity.util;
import javax.persistence.AttributeConverter;
/**
 * Created by yeshijie on 2021/1/21.
 */
public class StringFStringEncryptConverter implements AttributeConverter<String, String> {
    @Override
    public String convertToDatabaseColumn(String attribute) {
        return AesEncryptUtils.encrypt(attribute);
    }
    @Override
    public String convertToEntityAttribute(String dbData) {
        return AesEncryptUtils.decrypt(dbData);
    }
}

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

@ -295,8 +295,8 @@ spring:
  profiles: iotprod
  profiles: iotprod
  datasource:
  datasource:
    url: jdbc:mysql://59.61.92.90:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    url: jdbc:mysql://59.61.92.90:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy
    password: jkzlehr@123
    username: wlyy_new
    password: J4&y9sk#1G
  redis:
  redis:
    host: 59.61.92.90 # Redis server host.
    host: 59.61.92.90 # Redis server host.
    port: 9054  # Redis server port.
    port: 9054  # Redis server port.

+ 2 - 2
svr/svr-base/src/main/resources/application.yml

@ -415,8 +415,8 @@ spring:
  profiles: iotprod
  profiles: iotprod
  datasource:
  datasource:
    url: jdbc:mysql://10.90.32.3:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.90.32.3:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    username: wlyy_new
    password: J4&y9sk#1G
#    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
#    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
#    username: root
#    username: root
#    password: 123456
#    password: 123456

+ 2 - 2
svr/svr-iot-job/src/main/resources/application.yml

@ -154,8 +154,8 @@ spring:
  profiles: iotprod
  profiles: iotprod
  datasource:
  datasource:
    url: jdbc:mysql://10.90.32.3:20002/xmiot?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.90.32.3:20002/xmiot?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    username: wlyy_new
    password: J4&y9sk#1G
wlyy:
wlyy:
  url: http://www.xmtyw.cn/wlyy/
  url: http://www.xmtyw.cn/wlyy/

+ 72 - 5
svr/svr-iot/pom.xml

@ -142,16 +142,83 @@
        <finalName>svr-iot</finalName>
        <finalName>svr-iot</finalName>
        <plugins>
        <plugins>
            <plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin </artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <!-- 是否要把第三方jar加入到类构建路径 -->
                            <addClasspath>true</addClasspath>
                            <!-- 外部依赖jar包的最终位置 -->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.yihu.SvrDoorServiceApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--拷贝依赖到jar外面的lib目录-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- 依赖包输出目录,将来不打进jar包里 -->
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <stripVersion>false</stripVersion>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            </plugin>
            <!--指定配置文件,将resources打成外部resource-->
            <plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
                        <manifestEntries>
                            <Class-Path>resources/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
                    <excludes>
                        <exclude>**/*.yml</exclude>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
                </configuration>
            </plugin>
            </plugin>
            <!-- 拷贝资源文件 外面的resource目录-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 资源文件输出目录 -->
                            <outputDirectory>${project.build.directory}/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        </plugins>
    </build>
    </build>
</project>
</project>

+ 2 - 2
svr/svr-iot/src/main/resources/application.yml

@ -232,8 +232,8 @@ spring:
  profiles: iotprod
  profiles: iotprod
  datasource:
  datasource:
    url: jdbc:mysql://10.90.32.3:20002/xmiot?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.90.32.3:20002/xmiot?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
    username: wlyy_new
    password: J4&y9sk#1G
  elasticsearch:
  elasticsearch:
    cluster-name: jkzl #默认即为elasticsearch  集群名
    cluster-name: jkzl #默认即为elasticsearch  集群名
    cluster-nodes: 10.90.32.3:20011,10.90.32.3:20011 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    cluster-nodes: 10.90.32.3:20011,10.90.32.3:20011 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode