ignoregit
parent
8e0662064b
commit
e2fe790dfe
@ -0,0 +1,28 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### Java template
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
.idea
|
||||||
|
.log
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
#ifndef AVGLOBAL_H
|
|
||||||
#define AVGLOBAL_H
|
|
||||||
|
|
||||||
typedef int AV_int32;
|
|
||||||
typedef unsigned int AV_uint32;
|
|
||||||
|
|
||||||
#ifndef __OBJC__
|
|
||||||
typedef int AV_BOOL;
|
|
||||||
#else
|
|
||||||
typedef BOOL AV_BOOL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void* AV_HANDLE;
|
|
||||||
typedef unsigned char AV_BYTE;
|
|
||||||
typedef float AV_float;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
typedef __int64 AV_int64;
|
|
||||||
typedef unsigned __int64 AV_uint64;
|
|
||||||
#else
|
|
||||||
typedef long long AV_int64;
|
|
||||||
typedef unsigned long long AV_uint64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -1,21 +0,0 @@
|
|||||||
# 返回的分页数据 请用pagehelp的PageInfo
|
|
||||||
|
|
||||||
# 引入redis
|
|
||||||
## 需要在yml文件中配置prefix指定前缀
|
|
||||||
```yaml
|
|
||||||
zhehe:
|
|
||||||
common:
|
|
||||||
redis:
|
|
||||||
prefix:
|
|
||||||
```
|
|
||||||
# 引入md5加密
|
|
||||||
## 需配置secretSalt
|
|
||||||
```yaml
|
|
||||||
zhehe:
|
|
||||||
common:
|
|
||||||
md5:
|
|
||||||
secretSalt:
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,130 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
|
|
||||||
<fastjson.version>1.2.47</fastjson.version>
|
|
||||||
<qrcode.version>2.1</qrcode.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<product.center.api>1.0.0</product.center.api>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>fastjson</artifactId>
|
|
||||||
<version>${fastjson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.zxing</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>${qrcode.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.zxing</groupId>
|
|
||||||
<artifactId>javase</artifactId>
|
|
||||||
<version>${qrcode.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>redis.clients</groupId>
|
|
||||||
<artifactId>jedis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>base-assembly</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<!--指定编译的jdk版本-->
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>nexus</id>
|
|
||||||
<name>Nexus</name>
|
|
||||||
<url>http://47.99.98.250:28888/repository/maven-public/</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</project>
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.zhehekeji.common;
|
|
||||||
|
|
||||||
import com.zhehekeji.common.properities.Md5Properity;
|
|
||||||
import com.zhehekeji.common.properities.RedisProperity;
|
|
||||||
import com.zhehekeji.common.util.MD5Util;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description
|
|
||||||
* @Author wangyiming1031@aliyun.com
|
|
||||||
* @Date 2019/10/28 15:39
|
|
||||||
**/
|
|
||||||
@Configuration
|
|
||||||
@EnableConfigurationProperties({RedisProperity.class, Md5Properity.class})
|
|
||||||
public class CommonConfigure {
|
|
||||||
//todo 把result的version放进来
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public MD5Util md5Util(Md5Properity md5Properity){
|
|
||||||
return new MD5Util(md5Properity);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
package com.zhehekeji.common.constant;
|
|
||||||
|
|
||||||
public abstract class CommonConstant {
|
|
||||||
|
|
||||||
public static final Integer RESULT_ERROR_CODE = 500;
|
|
||||||
|
|
||||||
public static final String RESULT_ADD_OK_MSG = "新增成功";
|
|
||||||
|
|
||||||
public static final String RESULT_ADD_ERROR_MSG = "新增失败";
|
|
||||||
|
|
||||||
public static final String RESULT_DELETE_OK_MSG = "删除成功";
|
|
||||||
|
|
||||||
public static final String RESULT_DELETE_ERROR_MSG = "删除失败";
|
|
||||||
|
|
||||||
public static final String RESULT_EDIT_OK_MSG = "修改成功";
|
|
||||||
|
|
||||||
public static final String RESULT_EDIT_ERROR_MSG = "修改失败";
|
|
||||||
|
|
||||||
public static final String RESULT_OK_MSG = "操作成功";
|
|
||||||
|
|
||||||
public static final String RESULT_ERROR_MSG = "生成失败";
|
|
||||||
|
|
||||||
public static final String MODULE_URL = "/module";
|
|
||||||
|
|
||||||
public static final String PROJECT_URL = "/project";
|
|
||||||
|
|
||||||
public static final String ACCOUNT_URL = "/account";
|
|
||||||
|
|
||||||
public static final String ROLE_URL = "/role";
|
|
||||||
|
|
||||||
public static final String DEPARTMENT_URL = "/department";
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package com.zhehekeji.common.properities;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
@ConfigurationProperties("zhehe.common.md5")
|
|
||||||
public class Md5Properity {
|
|
||||||
|
|
||||||
private String secretSalt = "zheHeKeJi";
|
|
||||||
|
|
||||||
public String getSecretSalt() {
|
|
||||||
return secretSalt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSecretSalt(String secretSalt) {
|
|
||||||
this.secretSalt = secretSalt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package com.zhehekeji.common.properities;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
@ConfigurationProperties("zhehe.common")
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class Properity {
|
|
||||||
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
private String successMsg = "SUCCESS";
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.zhehekeji.common.properities;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
@ConfigurationProperties("zhehe.common.redis")
|
|
||||||
@Data
|
|
||||||
public class RedisProperity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* redis前缀
|
|
||||||
*/
|
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
package com.zhehekeji.common.util;
|
|
||||||
|
|
||||||
import com.zhehekeji.common.properities.Md5Properity;
|
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
|
|
||||||
public class MD5Util {
|
|
||||||
|
|
||||||
private String salt;
|
|
||||||
|
|
||||||
public MD5Util(Md5Properity md5Properity){
|
|
||||||
this.salt = md5Properity.getSecretSalt();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMD5(String content) {
|
|
||||||
try {
|
|
||||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
|
||||||
digest.update(content.getBytes());
|
|
||||||
return getHashString(digest);
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取加盐md5
|
|
||||||
* @param content
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getMD5WithSalt(String content) {
|
|
||||||
return getMD5(getMD5(content) + salt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getHashString(MessageDigest digest) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (byte b : digest.digest()) {
|
|
||||||
builder.append(Integer.toHexString((b >> 4) & 0xf));
|
|
||||||
builder.append(Integer.toHexString(b & 0xf));
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检验密码是否正确
|
|
||||||
* @param password
|
|
||||||
* @param md5
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Boolean checkPassword(String password,String md5){
|
|
||||||
return md5.equals(getMD5WithSalt(password));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
package com.zhehekeji.common.util;
|
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
|
||||||
import com.google.zxing.EncodeHintType;
|
|
||||||
import com.google.zxing.MultiFormatWriter;
|
|
||||||
import com.google.zxing.WriterException;
|
|
||||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
||||||
import com.google.zxing.common.BitMatrix;
|
|
||||||
import com.zhehekeji.core.util.Assert;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 二维码Util
|
|
||||||
*/
|
|
||||||
public class QrUtil {
|
|
||||||
|
|
||||||
private static String BASE64 = "data:image/jpg;base64,";
|
|
||||||
|
|
||||||
public static BufferedImage createCode(String content, BarcodeFormat format,Integer width,Integer height) throws WriterException {
|
|
||||||
Assert.isTrue(!StringUtils.isEmpty(content),"二维码生成要素为空");
|
|
||||||
Hashtable<EncodeHintType, String> hints = new Hashtable<>();
|
|
||||||
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
|
|
||||||
|
|
||||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, format , width, height, hints);
|
|
||||||
return MatrixToImageWriter.toBufferedImage(bitMatrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将二维码显示在web上
|
|
||||||
* @param os OutputStream
|
|
||||||
* @param extension 图片类型 jpg jpeg
|
|
||||||
* @param content 二维码要素
|
|
||||||
* @param format 二维码类型 QR_CODE : 正方形二维码
|
|
||||||
* 见 com.google.zxing.BarcodeFormat
|
|
||||||
* @param width 宽
|
|
||||||
* @param height 高
|
|
||||||
* @throws IOException
|
|
||||||
* @throws WriterException
|
|
||||||
*/
|
|
||||||
public static void outPut2Web(OutputStream os, String extension, String content, BarcodeFormat format, Integer width, Integer height) throws IOException, WriterException {
|
|
||||||
BufferedImage image = createCode(content,format,width,height);
|
|
||||||
ImageIO.write(image, extension, os);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 二维码转base64
|
|
||||||
* @param content 二维码要素
|
|
||||||
* @param format 二维码类型 QR_CODE : 正方形二维码
|
|
||||||
* @param width 宽
|
|
||||||
* @param height 高
|
|
||||||
* @param extension 图片类型 jpg/jpeg
|
|
||||||
* @return
|
|
||||||
* @throws WriterException
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static String image2Base64(String content, BarcodeFormat format,Integer width,Integer height,String extension) throws WriterException, IOException {
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
BufferedImage image = createCode(content,format,width,height);
|
|
||||||
ImageIO.write(image, extension, outputStream);
|
|
||||||
String base = Base64.encodeBase64String(outputStream.toByteArray());
|
|
||||||
return BASE64 + base;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
package com.zhehekeji.common.util;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.ApplicationContextAware;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class SpringContextUtil implements ApplicationContextAware {
|
|
||||||
|
|
||||||
private static ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
||||||
SpringContextUtil.applicationContext = applicationContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getBean(String id, Class<T> type) {
|
|
||||||
return applicationContext.getBean(id, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getBean(Class<T> type) {
|
|
||||||
return applicationContext.getBean(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Map<String, T> getBeansOfType(Class<T> type) {
|
|
||||||
return applicationContext.getBeansOfType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package com.zhehekeji.common.util;
|
|
||||||
|
|
||||||
import com.zhehekeji.core.util.Assert;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintViolation;
|
|
||||||
import javax.validation.Validator;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ValidatorUtil {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Validator validator;
|
|
||||||
|
|
||||||
public <T> void validate(T object, Class<?>... groups) {
|
|
||||||
Set<ConstraintViolation<T>> constraintViolations = validator.validate(object, groups);
|
|
||||||
if (!constraintViolations.isEmpty()) {
|
|
||||||
StringBuilder msg = new StringBuilder();
|
|
||||||
for (ConstraintViolation<T> violation : constraintViolations) {
|
|
||||||
msg.append(violation.getMessage()).append(";");
|
|
||||||
}
|
|
||||||
Assert.isTrue(Boolean.FALSE, msg != null ? msg.toString() : "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
{
|
|
||||||
"groups": [
|
|
||||||
{
|
|
||||||
"name": "zhehe.common",
|
|
||||||
"type": "com.zhehekeji.common.properities.Properity",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.Properity"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "zhehe.common.md5",
|
|
||||||
"type": "com.zhehekeji.common.properities.Md5Properity",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.Md5Properity"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "zhehe.common.redis",
|
|
||||||
"type": "com.zhehekeji.common.properities.RedisProperity",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.RedisProperity"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"properties": [
|
|
||||||
{
|
|
||||||
"name": "zhehe.common.md5.secret-salt",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.Md5Properity",
|
|
||||||
"defaultValue": "zheHeKeJi"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "zhehe.common.redis.prefix",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"description": "redis前缀",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.RedisProperity"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "zhehe.common.success-msg",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.Properity",
|
|
||||||
"defaultValue": "SUCCESS"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "zhehe.common.version",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"sourceType": "com.zhehekeji.common.properities.Properity"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"hints": []
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
#Generated by Maven
|
|
||||||
#Wed Nov 17 10:41:00 CST 2021
|
|
||||||
version=1.0.0
|
|
||||||
groupId=com.zhehekeji
|
|
||||||
artifactId=common
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
com\zhehekeji\common\properities\Properity.class
|
|
||||||
com\zhehekeji\common\util\QrUtil.class
|
|
||||||
com\zhehekeji\common\util\SpringContextUtil.class
|
|
||||||
com\zhehekeji\common\util\PathUtil.class
|
|
||||||
com\zhehekeji\common\util\ValidatorUtil.class
|
|
||||||
com\zhehekeji\common\properities\Md5Properity.class
|
|
||||||
com\zhehekeji\common\util\Tools.class
|
|
||||||
META-INF\spring-configuration-metadata.json
|
|
||||||
com\zhehekeji\common\properities\RedisProperity.class
|
|
||||||
com\zhehekeji\common\constant\CommonConstant.class
|
|
||||||
com\zhehekeji\common\util\MD5Util.class
|
|
||||||
com\zhehekeji\common\util\HttpUtil.class
|
|
||||||
com\zhehekeji\common\CommonConfigure.class
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\QrUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\Tools.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\HttpUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\SpringContextUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\MD5Util.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\CommonConfigure.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\PathUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\properities\Properity.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\properities\RedisProperity.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\util\ValidatorUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\constant\CommonConstant.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\common\src\main\java\com\zhehekeji\common\properities\Md5Properity.java
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>modules</artifactId>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<artifactId>filter</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
|
|
||||||
<jwt.version>0.7.0</jwt.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
|
||||||
<artifactId>jjwt</artifactId>
|
|
||||||
<version>${jwt.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
package com.zhehekeji.filter;
|
|
||||||
|
|
||||||
public interface FilterConstance {
|
|
||||||
|
|
||||||
String HEADER = "token";
|
|
||||||
|
|
||||||
String JWT_KEY = "zhehekeji";
|
|
||||||
|
|
||||||
String SESSION_PREFIX = "session:";
|
|
||||||
|
|
||||||
Long SESSION_EXPIRE = 10800l;
|
|
||||||
}
|
|
||||||
@ -1,73 +0,0 @@
|
|||||||
package com.zhehekeji.filter.aspect;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.zhehekeji.common.util.HttpUtil;
|
|
||||||
import com.zhehekeji.core.pojo.HttpStatus;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.core.util.Assert;
|
|
||||||
import com.zhehekeji.filter.FilterConstance;
|
|
||||||
import com.zhehekeji.filter.pojo.CurrentUser;
|
|
||||||
import com.zhehekeji.filter.pojo.SessionHandler;
|
|
||||||
import com.zhehekeji.filter.pojo.UserType;
|
|
||||||
import com.zhehekeji.filter.util.CurrentUserUtil;
|
|
||||||
import com.zhehekeji.filter.util.JwtUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.aspectj.lang.annotation.Before;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description Session切面
|
|
||||||
* @Author wangyiming1031@aliyun.com
|
|
||||||
* @Date 2019/10/28 19:26
|
|
||||||
**/
|
|
||||||
@Aspect
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class SessionAspect {
|
|
||||||
|
|
||||||
@Value("${zhehe.filter.enable}")
|
|
||||||
private Boolean enable;
|
|
||||||
@Value("${userUrl}")
|
|
||||||
private String userUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* zhehekeji..*.controller
|
|
||||||
* 匹配zhehekeji 到controller多级目录
|
|
||||||
*
|
|
||||||
* @param sessionHandler
|
|
||||||
*/
|
|
||||||
@Before("execution(public * com.zhehekeji..*.controller.*.*(..))&&@annotation(sessionHandler)")
|
|
||||||
public void handler(SessionHandler sessionHandler){
|
|
||||||
if(!enable){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
||||||
String token = request.getHeader(FilterConstance.HEADER);
|
|
||||||
CurrentUser currentUser = null;
|
|
||||||
try {
|
|
||||||
String res = HttpUtil.token(userUrl+"/api/account/checkToken",token);
|
|
||||||
Result currentUserResult = JSONObject.parseObject(res,Result.class);
|
|
||||||
if(currentUserResult != null && currentUserResult.getCode() == 200){
|
|
||||||
currentUser = JSONObject.parseObject(JSONObject.toJSONString(currentUserResult.getData()),CurrentUser.class);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sessionHandler.login()) {
|
|
||||||
Assert.isTrue(currentUser != null, HttpStatus.UNAUTHORIZED.getCode(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
|
|
||||||
}
|
|
||||||
if (sessionHandler.auth()) {
|
|
||||||
//todo 权限检验
|
|
||||||
}
|
|
||||||
CurrentUserUtil.setCurrentUser(currentUser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
package com.zhehekeji.filter.pojo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CurrentUser {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键
|
|
||||||
*/
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*/
|
|
||||||
private String phone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 账号 某些系统可能账号就是手机号
|
|
||||||
*/
|
|
||||||
private String account;
|
|
||||||
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 昵称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型
|
|
||||||
*/
|
|
||||||
private UserType userType;
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.zhehekeji.filter.pojo;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
public @interface SessionHandler {
|
|
||||||
|
|
||||||
String value() default "";
|
|
||||||
|
|
||||||
UserType userType() default UserType.USER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否检验登录
|
|
||||||
* @return true:检验 false:不检验
|
|
||||||
*/
|
|
||||||
boolean login() default true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否检验权限
|
|
||||||
* @return true:检验 false:不检验 默认检验
|
|
||||||
*/
|
|
||||||
boolean auth() default true;
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
package com.zhehekeji.filter.pojo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description 用户分类
|
|
||||||
* @Author wangyiming1031@aliyun.com
|
|
||||||
* @Date 2019/10/28 19:30
|
|
||||||
**/
|
|
||||||
public enum UserType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后台用户
|
|
||||||
*/
|
|
||||||
ACCOUNT,
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*/
|
|
||||||
USER,
|
|
||||||
;
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
package com.zhehekeji.filter.util;
|
|
||||||
|
|
||||||
import com.zhehekeji.filter.pojo.CurrentUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description 当前操作人线程
|
|
||||||
* @Author wangyiming1031@aliyun.com
|
|
||||||
* @Date 2019/10/28 19:22
|
|
||||||
**/
|
|
||||||
public class CurrentUserUtil {
|
|
||||||
|
|
||||||
private static ThreadLocal<CurrentUser> currentUser = new ThreadLocal<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前操作人
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static CurrentUser getCurrentUser() {
|
|
||||||
return currentUser.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCurrentUser(CurrentUser user) {
|
|
||||||
currentUser.set(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void delCurrentUser() {
|
|
||||||
currentUser.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,85 +0,0 @@
|
|||||||
package com.zhehekeji.filter.util;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.zhehekeji.filter.FilterConstance;
|
|
||||||
import com.zhehekeji.filter.pojo.CurrentUser;
|
|
||||||
import io.jsonwebtoken.Claims;
|
|
||||||
import io.jsonwebtoken.JwtBuilder;
|
|
||||||
import io.jsonwebtoken.Jwts;
|
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description JWTUtil
|
|
||||||
* @Author wangyiming1031@aliyun.com
|
|
||||||
* @Date 2019/10/28 19:11
|
|
||||||
**/
|
|
||||||
public class JwtUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成JWT
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String createJWT(CurrentUser currentUser) {
|
|
||||||
String userJson = JSONObject.toJSONString(currentUser);
|
|
||||||
JwtBuilder builder = Jwts.builder()
|
|
||||||
.setSubject(userJson)
|
|
||||||
.setIssuedAt(new Date())
|
|
||||||
.signWith(SignatureAlgorithm.HS256, FilterConstance.JWT_KEY);
|
|
||||||
return builder.compact();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析JWT
|
|
||||||
* 抛出异常 则jwt错误
|
|
||||||
* @param jwtStr
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Claims parseJWT(String jwtStr) {
|
|
||||||
return Jwts.parser()
|
|
||||||
.setSigningKey(FilterConstance.JWT_KEY)
|
|
||||||
.parseClaimsJws(jwtStr)
|
|
||||||
.getBody();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前操作人
|
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static CurrentUser getUser(HttpServletRequest request) {
|
|
||||||
String token = getToken(request);
|
|
||||||
Claims claims;
|
|
||||||
try {
|
|
||||||
claims = parseJWT(token);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String json = claims.getSubject();
|
|
||||||
CurrentUser userInfo = JSONObject.parseObject(json, CurrentUser.class);
|
|
||||||
return userInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getToken(HttpServletRequest request) {
|
|
||||||
return request.getHeader(FilterConstance.HEADER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成jwt,并将jwt放入返回头
|
|
||||||
* 主要考虑的是 返回header 由用户过滤模块维护
|
|
||||||
* @param response
|
|
||||||
* @param currentUser
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String createTokenAndHeader(HttpServletResponse response,CurrentUser currentUser){
|
|
||||||
String jwt = createJWT(currentUser);
|
|
||||||
response.setHeader(FilterConstance.HEADER,jwt);
|
|
||||||
return jwt;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
zhehe:
|
|
||||||
filter:
|
|
||||||
enable: true
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
zhehe:
|
|
||||||
filter:
|
|
||||||
enable: true
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
version=1.0.0
|
|
||||||
groupId=com.zhehekeji
|
|
||||||
artifactId=filter
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
com\zhehekeji\filter\pojo\SessionHandler.class
|
|
||||||
com\zhehekeji\filter\pojo\CurrentUser.class
|
|
||||||
com\zhehekeji\filter\pojo\UserType.class
|
|
||||||
com\zhehekeji\filter\aspect\SessionAspect.class
|
|
||||||
com\zhehekeji\filter\util\CurrentUserUtil.class
|
|
||||||
com\zhehekeji\filter\pojo\CurrentUser$CurrentUserBuilder.class
|
|
||||||
com\zhehekeji\filter\util\JwtUtil.class
|
|
||||||
com\zhehekeji\filter\FilterConstance.class
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\util\JwtUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\pojo\SessionHandler.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\aspect\SessionAspect.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\pojo\UserType.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\util\CurrentUserUtil.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\FilterConstance.java
|
|
||||||
E:\workspace\backend-duoji-monitor\modules\filter\src\main\java\com\zhehekeji\filter\pojo\CurrentUser.java
|
|
||||||
@ -1,55 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>springbootstart</artifactId>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>modules</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<common.version>1.0.0</common.version>
|
|
||||||
<base.assembly.version>1.0.0</base.assembly.version>
|
|
||||||
<filter.version>1.0.0</filter.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>base-assembly</artifactId>
|
|
||||||
<version>${base.assembly.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>common</artifactId>
|
|
||||||
<version>${common.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>nexus</id>
|
|
||||||
<name>Nexus</name>
|
|
||||||
<url>http://47.99.98.250:28888/repository/maven-public/</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 360 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 299 KiB |
@ -1,157 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<modules>
|
|
||||||
<module>web</module>
|
|
||||||
<module>modules</module>
|
|
||||||
<module>modules/common</module>
|
|
||||||
<module>modules/filter</module>
|
|
||||||
</modules>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>2.1.9.RELEASE</version>
|
|
||||||
<relativePath/>
|
|
||||||
</parent>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>springbootstart</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>duoji</name>
|
|
||||||
<description>Demo project for Spring Boot</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--json工具 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>fastjson</artifactId>
|
|
||||||
<version>1.2.47</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<!-- 测试环境 -->
|
|
||||||
<id>dev</id>
|
|
||||||
<properties>
|
|
||||||
<profileActive>dev</profileActive>
|
|
||||||
</properties>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<!-- 测试环境 -->
|
|
||||||
<id>test</id>
|
|
||||||
<properties>
|
|
||||||
<profileActive>test</profileActive>
|
|
||||||
</properties>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<!-- 生产环境 -->
|
|
||||||
<id>prod</id>
|
|
||||||
<properties>
|
|
||||||
<profileActive>prod</profileActive>
|
|
||||||
</properties>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>false</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>nexus</id>
|
|
||||||
<name>Nexus</name>
|
|
||||||
<url>http://47.99.98.250:28888/repository/maven-public/</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<excludes>
|
|
||||||
<exclude>application*.yml</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<includes>
|
|
||||||
<include>bootstrap.yml</include>
|
|
||||||
<include>application.yml</include>
|
|
||||||
<include>application-${profileActive}.yml</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<!--指定编译的jdk版本-->
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<!--执行单元测试的插件-->
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skipTests>true</skipTests>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<nonFilteredFileExtensions>
|
|
||||||
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
|
|
||||||
<nonFilteredFileExtension>xls</nonFilteredFileExtension>
|
|
||||||
<nonFilteredFileExtension>zip</nonFilteredFileExtension>
|
|
||||||
<nonFilteredFileExtension>cer</nonFilteredFileExtension>
|
|
||||||
<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
|
|
||||||
<nonFilteredFileExtension>py</nonFilteredFileExtension>
|
|
||||||
<nonFilteredFileExtension>keystore</nonFilteredFileExtension>
|
|
||||||
</nonFilteredFileExtensions>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
@echo off
|
|
||||||
start cmd /k "cd/d D:\workspace\duoji && javaw -jar duoji-1.0.0.jar --spring.profile.path=application-prod.yml"
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
@echo off&setlocal EnableDelayedExpansion
|
|
||||||
set Port=
|
|
||||||
set Dstport=9091
|
|
||||||
|
|
||||||
for /F "usebackq skip=4 tokens=2,5" %%a in (`"netstat -ano -p tcp"`) do (
|
|
||||||
for /F "tokens=2 delims=:" %%k in ("%%a") do (
|
|
||||||
set Port=%%k
|
|
||||||
)
|
|
||||||
echo !Port! %%b >>portandpid.txt
|
|
||||||
)
|
|
||||||
for /F "tokens=2 delims=:" %%c in ("%1") do (
|
|
||||||
set Port=%%c
|
|
||||||
)
|
|
||||||
for /F "tokens=1,2 delims= " %%d in (portandpid.txt) do (
|
|
||||||
echo %%d
|
|
||||||
echo %Dstport%
|
|
||||||
if %%d == %Dstport% taskkill /f /pid %%e
|
|
||||||
)
|
|
||||||
del portandpid.txt
|
|
||||||
set Port=
|
|
||||||
set Dstport=
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
echo '结束了'
|
|
||||||
@ -1,77 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>springbootstart</artifactId>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>duoji</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<common.version>1.0.0</common.version>
|
|
||||||
<base.assembly.version>1.0.0</base.assembly.version>
|
|
||||||
<filter.version>1.0.0</filter.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>base-assembly</artifactId>
|
|
||||||
<version>${base.assembly.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.netty</groupId>
|
|
||||||
<artifactId>netty-all</artifactId>
|
|
||||||
<version>4.1.50.Final</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zhehekeji</groupId>
|
|
||||||
<artifactId>filter</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>easyexcel</artifactId>
|
|
||||||
<version>2.1.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.jna</groupId>
|
|
||||||
<artifactId>jna</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${project.basedir}/src/main/resources/libs/jna.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<includeSystemScope>true</includeSystemScope>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.zhehekeji.web;
|
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = {"com.zhehekeji"})
|
|
||||||
@MapperScan("com.zhehekeji.**.mapper.**")
|
|
||||||
public class Application {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication springApplication = new SpringApplication(Application.class);
|
|
||||||
springApplication.run(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
package com.zhehekeji.web.config;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
||||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
|
||||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
|
||||||
import org.springframework.core.type.classreading.MetadataReader;
|
|
||||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
|
||||||
import org.springframework.util.ClassUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class PackagesSqlSessionFactory extends SqlSessionFactoryBean {
|
|
||||||
|
|
||||||
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTypeAliasesPackage(String typeAliasesPackage) {
|
|
||||||
ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
|
|
||||||
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
|
|
||||||
typeAliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
|
|
||||||
ClassUtils.convertClassNameToResourcePath(typeAliasesPackage) + "/" + DEFAULT_RESOURCE_PATTERN;
|
|
||||||
|
|
||||||
//将加载多个绝对匹配的所有Resource
|
|
||||||
//将首先通过ClassLoader.getResource("META-INF")加载非模式路径部分
|
|
||||||
//然后进行遍历模式匹配
|
|
||||||
try {
|
|
||||||
List<String> result = new ArrayList<String>();
|
|
||||||
Resource[] resources = resolver.getResources(typeAliasesPackage);
|
|
||||||
if (resources != null && resources.length > 0) {
|
|
||||||
MetadataReader metadataReader = null;
|
|
||||||
for (Resource resource : resources) {
|
|
||||||
if (resource.isReadable()) {
|
|
||||||
metadataReader = metadataReaderFactory.getMetadataReader(resource);
|
|
||||||
try {
|
|
||||||
result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (result.size() > 0) {
|
|
||||||
super.setTypeAliasesPackage(String.join(",", result));
|
|
||||||
} else {
|
|
||||||
log.error("参数typeAliasesPackage:" + typeAliasesPackage + ",未找到任何包");
|
|
||||||
}
|
|
||||||
//logger.info("d");
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
package com.zhehekeji.web.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Profile;
|
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
|
||||||
import springfox.documentation.service.ApiInfo;
|
|
||||||
import springfox.documentation.service.Contact;
|
|
||||||
import springfox.documentation.spi.DocumentationType;
|
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableSwagger2
|
|
||||||
@Profile({"test", "dev","prod"})
|
|
||||||
public class SwaggerConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Docket petApi() {
|
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
|
||||||
.apiInfo(apiInfo())
|
|
||||||
.select()
|
|
||||||
//指定提供接口所在的基包
|
|
||||||
.apis(RequestHandlerSelectors.basePackage("com.zhehekeji"))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ApiInfo apiInfo() {
|
|
||||||
return new ApiInfoBuilder()
|
|
||||||
.title("舵机Api")
|
|
||||||
.version("1.0.0")
|
|
||||||
.description("web 舵机Api")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.zhehekeji.common.util.HttpUtil;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.core.util.Assert;
|
|
||||||
import com.zhehekeji.web.pojo.IndexVO;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Api(value = "AppCenterController", tags = "用户中心")
|
|
||||||
@RequestMapping(value = "/app")
|
|
||||||
@RestController(value = "AppCenterController")
|
|
||||||
@Slf4j
|
|
||||||
public class AppCenterController {
|
|
||||||
|
|
||||||
@Value("${userUrl}")
|
|
||||||
private String userUrl;
|
|
||||||
|
|
||||||
@GetMapping("/userCenter")
|
|
||||||
@ApiOperation(value = "用户中心")
|
|
||||||
public Result<IndexVO> userCenter() {
|
|
||||||
Result result = null;
|
|
||||||
try {
|
|
||||||
String res = HttpUtil.doGet(userUrl+"/api/app/userCenter");
|
|
||||||
result = JSONObject.parseObject(res,Result.class);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("请求用户中心地址失败:{}",e);
|
|
||||||
Assert.isTrue(false,"请求用户中心地址失败");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,305 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.core.util.Assert;
|
|
||||||
import com.zhehekeji.web.entity.Camera;
|
|
||||||
import com.zhehekeji.web.lib.*;
|
|
||||||
import com.zhehekeji.web.mapper.CameraMapper;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Api(value = "CameraControl",tags = "球机控制管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/camera/control")
|
|
||||||
@Slf4j
|
|
||||||
public class CameraControlController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CameraMapper cameraMapper;
|
|
||||||
|
|
||||||
@PostMapping("/{id}")
|
|
||||||
@ApiOperation(value = "球机登录")
|
|
||||||
public Result login(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
private NetSDKLib.LLong cameraLogin(Integer cameraId){
|
|
||||||
log.info("相机登录 cameraId:{}",cameraId);
|
|
||||||
Camera camera = cameraMapper.selectById(cameraId);
|
|
||||||
Assert.notNull(camera,"球机不存在");
|
|
||||||
NetSDKLib.LLong lLong = LoginModule.login(camera.getIp(),camera.getPort(),camera.getUser(),camera.getPassword(),cameraId);
|
|
||||||
Assert.isTrue(lLong.longValue() > 0,"登陆失败");
|
|
||||||
CameraConnMap.conn(cameraId,lLong);
|
|
||||||
return lLong;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/up/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向上")
|
|
||||||
public Result up(@PathVariable Integer id) {
|
|
||||||
log.debug("球机控制向上");
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlUpStart(id,0,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/up/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向上 停止")
|
|
||||||
public Result upStop(@PathVariable Integer id) {
|
|
||||||
log.debug("球机控制向上 停止");
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlUpEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/down/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向下")
|
|
||||||
public Result down(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlDownStart(id,0,0,1);
|
|
||||||
log.debug("球机控制向下");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/down/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向下-停止")
|
|
||||||
public Result downStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlDownEnd(id,0);
|
|
||||||
log.debug("球机控制向下 停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/left/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向左")
|
|
||||||
public Result left(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlLeftStart(id,0,0,1);
|
|
||||||
log.debug("球机控制向左");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/left/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制左-停止")
|
|
||||||
public Result leftStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlLeftEnd(id,0);
|
|
||||||
log.debug("球机控制向左 -停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/leftUp/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向左上")
|
|
||||||
public Result leftUp(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlLeftUpStart(id,0,1,1);
|
|
||||||
log.debug("球机控制向上");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/leftUp/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制左上-停止")
|
|
||||||
public Result leftUpStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlLeftUpEnd(id,0);
|
|
||||||
log.debug("球机控制向上 停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/leftDown/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向左下")
|
|
||||||
public Result leftDown(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlLeftDownStart(id,0,1,1);
|
|
||||||
log.debug("球机控制左下");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/leftDown/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制左下-停止")
|
|
||||||
public Result leftDownStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlLeftDownEnd(id,0);
|
|
||||||
log.debug("球机控制左下 停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/right/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向右")
|
|
||||||
public Result right(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlRightStart(id,0,0,1);
|
|
||||||
log.debug("球机控制右");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/right/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制右-停止")
|
|
||||||
public Result rightStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlRightEnd(id,0);
|
|
||||||
log.debug("球机控制右 停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/rightUp/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向右上")
|
|
||||||
public Result rightUp(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlRightUpStart(id,0,1,1);
|
|
||||||
log.debug("球机控制右上");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/rightUp/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制右上-停止")
|
|
||||||
public Result rightUpStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlRightUpEnd(id,0);
|
|
||||||
log.debug("球机控制右上 -停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/rightDown/{id}")
|
|
||||||
@ApiOperation(value = "球机控制向右下")
|
|
||||||
public Result rightDown(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlRightDownStart(id,0,1,1);
|
|
||||||
log.debug("球机控制右下");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/rightDown/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制右下-停止")
|
|
||||||
public Result rightDownStop(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlRightDownEnd(id,0);
|
|
||||||
log.debug("球机控制右下 -停止");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/zoomAdd/start/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变倍+")
|
|
||||||
public Result ZoomAddStart(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlZoomAddStart(id,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/zoomAdd/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变倍+ 停止")
|
|
||||||
public Result ZoomAddEnd(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlZoomAddEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/zoomDec/start/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变倍-")
|
|
||||||
public Result ZoomDecStart(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlZoomDecStart(id,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/zoomDec/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变倍- 停止")
|
|
||||||
public Result ZoomDecEnd(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlZoomDecEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/focusAdd/start/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变焦 +")
|
|
||||||
public Result FocusAddStart(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlFocusAddStart(id,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/focusAdd/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变焦+ 停止")
|
|
||||||
public Result focusAddEnd(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlFocusAddEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/focusDec/start/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变焦 -")
|
|
||||||
public Result FocusDecStart(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlFocusDecStart(id,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/focusDec/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 变焦- 停止")
|
|
||||||
public Result focusDecEnd(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlFocusDecEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/irisAdd/start/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 光圈 +")
|
|
||||||
public Result irisAddStart(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlIrisAddStart(id,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/irisAdd/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 光圈+ 停止")
|
|
||||||
public Result irisAddEnd(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlIrisAddEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/irisDec/start/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 光圈 -")
|
|
||||||
public Result irisDecStart(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlIrisDecStart(id,0,1);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/irisDec/stop/{id}")
|
|
||||||
@ApiOperation(value = "球机控制 光圈- 停止")
|
|
||||||
public Result irisDecEnd(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
PtzControlModule.ptzControlIrisDecEnd(id,0);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/pic/{id}")
|
|
||||||
@ApiOperation(value = "立即拍照")
|
|
||||||
public Result pic(@PathVariable Integer id) {
|
|
||||||
checkLogin(id);
|
|
||||||
OrderInfo orderInfo = new OrderInfo(0L,"SRM123","AAA",1,1,"C5",true);
|
|
||||||
System.out.println(PtzControlModule.pic(id,0,orderInfo));
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @PostMapping("/mp4/{id}")
|
|
||||||
// @ApiOperation(value = "录像")
|
|
||||||
// public Result MP4(@PathVariable Integer id) {
|
|
||||||
// checkLogin(id);
|
|
||||||
// PtzControlModule.downloadMp4(id);
|
|
||||||
// return Result.success();
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void checkLogin(Integer cameraId){
|
|
||||||
if(CameraConnMap.getConnId(cameraId) == null){
|
|
||||||
cameraLogin(cameraId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,114 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.zhehekeji.common.util.ValidatorUtil;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.entity.Camera;
|
|
||||||
import com.zhehekeji.web.entity.CameraIO;
|
|
||||||
import com.zhehekeji.web.entity.CameraIOConfig;
|
|
||||||
import com.zhehekeji.web.lib.PtzControlModule;
|
|
||||||
import com.zhehekeji.web.pojo.camera.CameraConfigSearchReq;
|
|
||||||
import com.zhehekeji.web.pojo.camera.CameraIOPtz;
|
|
||||||
import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
||||||
import com.zhehekeji.web.service.CameraService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Api(value = "camera",tags = "球机管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/camera")
|
|
||||||
public class CameraController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CameraService cameraService;
|
|
||||||
@Resource
|
|
||||||
private ValidatorUtil validatorUtil;
|
|
||||||
|
|
||||||
@PostMapping("/page")
|
|
||||||
@ApiOperation(value = "球机列表分页 ")
|
|
||||||
public Result<PageInfo<Camera>> list(@RequestBody StreetSearch streetSearch) {
|
|
||||||
return new Result<>(cameraService.cameras(streetSearch));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("")
|
|
||||||
@ApiOperation(value = "球机新增 ")
|
|
||||||
public Result<Integer> add(@RequestBody Camera camera) {
|
|
||||||
return new Result<>(cameraService.add(camera));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/config/import")
|
|
||||||
@ApiOperation(value = "球机IO导入 ")
|
|
||||||
public Result upload(MultipartFile file) throws IOException {
|
|
||||||
cameraService.importExcel(file);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/config")
|
|
||||||
@ApiOperation(value = "球机IO配置新增 ")
|
|
||||||
public Result<Integer> addConfig (@RequestBody CameraIOConfig config) {
|
|
||||||
return Result.success(cameraService.addConfig(config));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/config/page")
|
|
||||||
@ApiOperation(value = "球机IO配置分页列表")
|
|
||||||
public Result<PageInfo<CameraIOConfig>> configPage (@RequestBody CameraConfigSearchReq req) {
|
|
||||||
return Result.success(cameraService.configPageInfo(req));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/config")
|
|
||||||
@ApiOperation(value = "球机IO配置修改 ")
|
|
||||||
public Result editConfig (@RequestBody CameraIOConfig config) {
|
|
||||||
cameraService.editConfig(config);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/config/{id}")
|
|
||||||
@ApiOperation(value = "球机IO配置删除 ")
|
|
||||||
public Result delConfig (@PathVariable Integer id) {
|
|
||||||
cameraService.delConfig(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("")
|
|
||||||
@ApiOperation(value = "球机修改")
|
|
||||||
public Result edit(@RequestBody Camera camera) {
|
|
||||||
cameraService.edit(camera);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
@ApiOperation(value = "球机删除")
|
|
||||||
public Result del(@PathVariable Integer id){
|
|
||||||
cameraService.del(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/{cameraId}/io/list")
|
|
||||||
@ApiOperation(value = "球机IO列表")
|
|
||||||
public Result<List<CameraIO>> IOPage(@PathVariable Integer cameraId) {
|
|
||||||
return Result.success(cameraService.ioList(cameraId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/io/ptz")
|
|
||||||
@ApiOperation(value = "球机IO配置")
|
|
||||||
public Result<Integer> ptz(@RequestBody CameraIOPtz req) {
|
|
||||||
validatorUtil.validate(req);
|
|
||||||
return Result.success(cameraService.ptz(req.getCameraIOId(),req.getCameraId(),req.getName(),req.getType(),req.getCode()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/io/toPtz")
|
|
||||||
@ApiOperation(value = "转至球机IO配置点")
|
|
||||||
public Result toPtz(@RequestBody CameraIOPtz req) {
|
|
||||||
//todo
|
|
||||||
//validatorUtil.validate(req);
|
|
||||||
Integer ptzId = cameraService.getPtzId(req.getCameraIOId());
|
|
||||||
PtzControlModule.toPtz(ptzId,req.getCameraId());
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.entity.Category;
|
|
||||||
import com.zhehekeji.web.pojo.category.PageSearch;
|
|
||||||
import com.zhehekeji.web.service.CategoryService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Api(value = "category",tags = "分类管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/category")
|
|
||||||
public class CategoryController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CategoryService categoryService;
|
|
||||||
|
|
||||||
@PostMapping("/import")
|
|
||||||
@ApiOperation(value = "分类导入")
|
|
||||||
public Result upload(MultipartFile file) throws IOException {
|
|
||||||
Integer rows = categoryService.importExcel(file);
|
|
||||||
Result result = Result.success();
|
|
||||||
result.setMessage("成功导入"+rows+"行");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("分页列表")
|
|
||||||
@PostMapping("/page")
|
|
||||||
public Result<PageInfo<Category>> page(@RequestBody PageSearch pageSearch){
|
|
||||||
return Result.success(categoryService.list(pageSearch));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("列表")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Result<List<Category>> list(@RequestParam String name){
|
|
||||||
return Result.success(categoryService.list(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("修改")
|
|
||||||
@PutMapping()
|
|
||||||
public Result edit(@RequestBody Category category){
|
|
||||||
categoryService.edit(category);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("新增")
|
|
||||||
@PostMapping()
|
|
||||||
public Result add(@RequestBody Category category){
|
|
||||||
return Result.success(categoryService.add(category));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("删除")
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public Result del(@PathVariable Integer id){
|
|
||||||
categoryService.del(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/export/model")
|
|
||||||
@ApiOperation(value = "品规模板下载")
|
|
||||||
public void download(HttpServletResponse response) throws IOException {
|
|
||||||
OutputStream os = response.getOutputStream();
|
|
||||||
byte[] buffer = new byte[4096];
|
|
||||||
int n;
|
|
||||||
response.setContentType("application/vnd.ms-excel");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
||||||
String fileName = URLEncoder.encode("品规模板", "UTF-8");
|
|
||||||
response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
|
|
||||||
ClassPathResource classPathResource = new ClassPathResource("品规模板.xlsx");
|
|
||||||
InputStream in = classPathResource.getInputStream();
|
|
||||||
while ((n = in.read(buffer)) > 0) {
|
|
||||||
os.write(buffer, 0, n);
|
|
||||||
}
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
response.flushBuffer();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class Login {
|
|
||||||
|
|
||||||
private String user;
|
|
||||||
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
private Integer port;
|
|
||||||
}
|
|
||||||
@ -1,87 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.zhehekeji.common.util.ValidatorUtil;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.pojo.OrderSaveReq;
|
|
||||||
import com.zhehekeji.web.pojo.OrderSearch;
|
|
||||||
import com.zhehekeji.web.pojo.OrderVO;
|
|
||||||
import com.zhehekeji.web.service.OrderService;
|
|
||||||
import com.zhehekeji.web.service.PlcOrderInfo;
|
|
||||||
import com.zhehekeji.web.service.PlcService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Api(value = "OrderController",tags = "订单管理")
|
|
||||||
@RestController(value = "OrderController")
|
|
||||||
@RequestMapping("/order")
|
|
||||||
public class OrderController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private OrderService orderService;
|
|
||||||
@Resource
|
|
||||||
private PlcService plcService;
|
|
||||||
@Resource
|
|
||||||
private ValidatorUtil validatorUtil;
|
|
||||||
|
|
||||||
@Value("${zhehe.filter.postToken}")
|
|
||||||
private String postToken;
|
|
||||||
|
|
||||||
@ApiOperation("新增")
|
|
||||||
@PostMapping("/")
|
|
||||||
public Result<Long> save(@RequestBody OrderSaveReq saveReq){
|
|
||||||
validatorUtil.validate(saveReq);
|
|
||||||
//Assert.isTrue(postToken.equals(saveReq.getToken()),"token不正确");
|
|
||||||
return Result.success(orderService.add(saveReq));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("工单拍照")
|
|
||||||
@GetMapping("/camera")
|
|
||||||
public Result camera(@ApiParam("工单号") @RequestParam String orderNum,@ApiParam("plcId") @RequestParam String plcId){
|
|
||||||
//orderService.pic(orderNum,plcId);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("工单开始信号")
|
|
||||||
@PostMapping("/start")
|
|
||||||
public Result orderStart(@ApiParam("工单号") @RequestBody PlcOrderInfo orderNum, @ApiParam("plc")@RequestParam String plcId){
|
|
||||||
orderNum.setOrderNum(plcId+"_"+orderNum.getTaskId());
|
|
||||||
plcService.orderStart(orderNum,plcId);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("工单结束信号")
|
|
||||||
@GetMapping("/stop")
|
|
||||||
public Result orderStop(@ApiParam("工单号") @RequestParam String orderNum,@ApiParam("plc")@RequestParam String plcId){
|
|
||||||
plcService.orderStop(plcId,orderNum);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("发生告警")
|
|
||||||
@GetMapping("/error")
|
|
||||||
public Result orderError(@ApiParam("plc") @RequestParam String plcId){
|
|
||||||
plcService.warnStart(plcId,"D1");
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("告警结束")
|
|
||||||
@GetMapping("/errorStop")
|
|
||||||
public Result errorStop(@ApiParam("plc") @RequestParam String plcId){
|
|
||||||
plcService.warnStop(plcId);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
|
||||||
@ApiOperation(value = "查询")
|
|
||||||
//@SessionHandler
|
|
||||||
public Result<PageInfo<OrderVO>> orders(@RequestBody OrderSearch orderSearch) {
|
|
||||||
//validatorUtil.validate(orderSearch);
|
|
||||||
return Result.success(orderService.orders(orderSearch));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.pojo.realTime.RealTime;
|
|
||||||
import com.zhehekeji.web.service.RealTimeService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Api(value = "realTime",tags = "实时监控")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/realTime")
|
|
||||||
public class RealTimeController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RealTimeService realTimeService;
|
|
||||||
|
|
||||||
@PostMapping("")
|
|
||||||
@ApiOperation(value = "实时列表")
|
|
||||||
//@SessionHandler
|
|
||||||
public Result<List<RealTime>> realTimes() {
|
|
||||||
return Result.success(realTimeService.realTimes());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.zhehekeji.common.util.ValidatorUtil;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.entity.Stock;
|
|
||||||
import com.zhehekeji.web.lib.PtzControlModule;
|
|
||||||
import com.zhehekeji.web.pojo.category.PageSearch;
|
|
||||||
import com.zhehekeji.web.pojo.stock.CheckByMan;
|
|
||||||
import com.zhehekeji.web.pojo.stock.StockCheck;
|
|
||||||
import com.zhehekeji.web.pojo.stock.StockExportExcel;
|
|
||||||
import com.zhehekeji.web.service.StockService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.util.ResourceUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Api(value = "Stock", tags = "库存管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/stock")
|
|
||||||
public class StockController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private StockService stockService;
|
|
||||||
@Resource
|
|
||||||
private ValidatorUtil validatorUtil;
|
|
||||||
|
|
||||||
@PostMapping("/import")
|
|
||||||
@ApiOperation(value = "库存导入")
|
|
||||||
public Result upload(MultipartFile file) {
|
|
||||||
stockService.importExcel(file);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/export/model")
|
|
||||||
@ApiOperation(value = "库存模板下载")
|
|
||||||
public void download(HttpServletResponse response) throws IOException {
|
|
||||||
OutputStream os = response.getOutputStream();
|
|
||||||
byte[] buffer = new byte[4096];
|
|
||||||
int n;
|
|
||||||
response.setContentType("application/vnd.ms-excel");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
||||||
String fileName = URLEncoder.encode("库存模板", "UTF-8");
|
|
||||||
response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
|
|
||||||
ClassPathResource classPathResource = new ClassPathResource("库存模板.xlsx");
|
|
||||||
InputStream in = classPathResource.getInputStream();
|
|
||||||
while ((n = in.read(buffer)) > 0) {
|
|
||||||
os.write(buffer, 0, n);
|
|
||||||
}
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
response.flushBuffer();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
@ApiOperation(value = "盘点页面 返回map key:货架号 value:库存信息")
|
|
||||||
public Result<Map<String, List<Stock>>> stockByStreet(@RequestParam(required = true) Integer streetId) {
|
|
||||||
return Result.success(stockService.stocksByStreetId(streetId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/page")
|
|
||||||
@ApiOperation(value = "库存列表")
|
|
||||||
public Result<PageInfo<Stock>> page(@RequestBody PageSearch pageSearch) {
|
|
||||||
return Result.success(stockService.page(pageSearch));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "导出全部巷道excel")
|
|
||||||
@RequestMapping(value = "/export", method = RequestMethod.GET)
|
|
||||||
public void export(@RequestParam Integer streetId, HttpServletResponse response) throws IOException {
|
|
||||||
OutputStream os = response.getOutputStream();
|
|
||||||
response.setContentType("application/vnd.ms-excel");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
String fileName = URLEncoder.encode("盘点" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")), "UTF-8");
|
|
||||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
||||||
List<StockExportExcel> excels = stockService.exportExcels(streetId);
|
|
||||||
EasyExcel.write(os, StockExportExcel.class).sheet().doWrite(excels);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "复核页面的核对信息")
|
|
||||||
@RequestMapping(value = "/info", method = RequestMethod.POST)
|
|
||||||
public Result<Stock> stockInfo(@RequestBody StockCheck stockCheck) {
|
|
||||||
validatorUtil.validate(stockCheck);
|
|
||||||
return Result.success(stockService.stockInfo(stockCheck));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "复核正确")
|
|
||||||
@RequestMapping(value = "/checkCorrect", method = RequestMethod.POST)
|
|
||||||
public Result<Stock> check(@RequestBody StockCheck stockCheck) {
|
|
||||||
validatorUtil.validate(stockCheck);
|
|
||||||
return Result.success(stockService.checkCorrect(stockCheck));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "人工复核")
|
|
||||||
@RequestMapping(value = "/checkByMan", method = RequestMethod.POST)
|
|
||||||
public Result<Stock> checkByMan(@RequestBody CheckByMan checkByMan) {
|
|
||||||
validatorUtil.validate(checkByMan);
|
|
||||||
return Result.success(stockService.checkByMan(checkByMan));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "slow")
|
|
||||||
@RequestMapping(value = "/slow", method = RequestMethod.GET)
|
|
||||||
public Result slow(Integer cameraId,Integer x) {
|
|
||||||
PtzControlModule.toPtzSlow(cameraId,x);
|
|
||||||
return Result.success();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "currentPosition")
|
|
||||||
@RequestMapping(value = "/currentPosition", method = RequestMethod.GET)
|
|
||||||
public Result currentPosition(Integer cameraId,Integer ptzId) {
|
|
||||||
PtzControlModule.turn360C8(cameraId,ptzId);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.entity.Street;
|
|
||||||
import com.zhehekeji.web.pojo.street.StreetSearch;
|
|
||||||
import com.zhehekeji.web.pojo.street.StreetVO;
|
|
||||||
import com.zhehekeji.web.service.StreetService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Api(value = "StreetController",tags = "巷道管理")
|
|
||||||
@RestController(value = "StreetController")
|
|
||||||
@RequestMapping("/street")
|
|
||||||
public class StreetController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private StreetService streetService;
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/page")
|
|
||||||
@ApiOperation(value = "巷道列表")
|
|
||||||
//@SessionHandler
|
|
||||||
public Result<PageInfo<StreetVO>> list(@RequestBody StreetSearch search) {
|
|
||||||
return new Result<>(streetService.page(search));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("")
|
|
||||||
@ApiOperation(value = "巷道新增")
|
|
||||||
public Result add(@RequestBody Street street){
|
|
||||||
return Result.success(streetService.add(street));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("")
|
|
||||||
@ApiOperation(value = "巷道修改")
|
|
||||||
public Result edit(@RequestBody Street street){
|
|
||||||
streetService.edit(street);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
@ApiOperation(value = "巷道删除")
|
|
||||||
public Result del(@PathVariable Integer id){
|
|
||||||
streetService.del(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
@ApiOperation(value = "巷道详情")
|
|
||||||
public Result<Street> detail(@PathVariable Integer id){
|
|
||||||
return Result.success(streetService.streetById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
package com.zhehekeji.web.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.zhehekeji.common.util.ValidatorUtil;
|
|
||||||
import com.zhehekeji.core.pojo.Result;
|
|
||||||
import com.zhehekeji.web.pojo.warn.WarnSearch;
|
|
||||||
import com.zhehekeji.web.pojo.warn.WarnVO;
|
|
||||||
import com.zhehekeji.web.service.WarnService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Api(value = "Warn",tags = "告警管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/warn")
|
|
||||||
public class WarnController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private WarnService warnService;
|
|
||||||
@Resource
|
|
||||||
private ValidatorUtil validatorUtil;
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
|
||||||
@ApiOperation(value = "告警日志 和告警视频 都用这个接口")
|
|
||||||
//@SessionHandler
|
|
||||||
public Result<PageInfo<WarnVO>> orders(@RequestBody WarnSearch warnSearch) {
|
|
||||||
validatorUtil.validate(warnSearch);
|
|
||||||
return Result.success(warnService.page(warnSearch));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("`camera`")
|
|
||||||
public class Camera {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
private Integer port;
|
|
||||||
|
|
||||||
private String user;
|
|
||||||
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
private String rtsp;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "预置点 增长值",hidden = true)
|
|
||||||
private Integer ptzId;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("camera_io")
|
|
||||||
public class CameraIO {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private Integer cameraId;
|
|
||||||
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@ApiModelProperty("位置")
|
|
||||||
private String position;
|
|
||||||
|
|
||||||
@ApiModelProperty("对焦")
|
|
||||||
private String focusing;
|
|
||||||
|
|
||||||
@ApiModelProperty("光圈")
|
|
||||||
private String aperture;
|
|
||||||
|
|
||||||
@ApiModelProperty("倍率")
|
|
||||||
private String multiple;
|
|
||||||
|
|
||||||
private Integer ptzId;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("camera_io_config")
|
|
||||||
public class CameraIOConfig {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("category")
|
|
||||||
public class Category {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@TableName
|
|
||||||
@Data
|
|
||||||
public class OrderLastMedia {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
@TableField
|
|
||||||
private String shelveId;
|
|
||||||
|
|
||||||
@TableField("`row`")
|
|
||||||
private Integer row;
|
|
||||||
|
|
||||||
@TableField("`column`")
|
|
||||||
private Integer column;
|
|
||||||
|
|
||||||
private String lastOrderNum;
|
|
||||||
|
|
||||||
// private String lastPutOrderNum;
|
|
||||||
//
|
|
||||||
// @ApiModelProperty("入库照片")
|
|
||||||
// private String putPath;
|
|
||||||
//
|
|
||||||
// private String lastOutOrderNum;
|
|
||||||
//
|
|
||||||
// @ApiModelProperty("出库照片")
|
|
||||||
// private String outPutPath;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @ApiModelProperty("货位照片")
|
|
||||||
// private String goodsPath;
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class StockLog {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private Integer userId;
|
|
||||||
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
private String shelveId;
|
|
||||||
|
|
||||||
@TableField("`row`")
|
|
||||||
private Integer row;
|
|
||||||
|
|
||||||
@TableField("`column`")
|
|
||||||
private Integer column;
|
|
||||||
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
@ApiModelProperty("之前的状态")
|
|
||||||
private Integer oldStatus;
|
|
||||||
|
|
||||||
@ApiModelProperty("更改之后的状态")
|
|
||||||
private Integer newStatus;
|
|
||||||
|
|
||||||
private String orderNum;
|
|
||||||
|
|
||||||
@ApiModelProperty("操作前的图片")
|
|
||||||
private String preoperationPic;
|
|
||||||
|
|
||||||
@ApiModelProperty("操作后的图片")
|
|
||||||
private String overoperationPic;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName
|
|
||||||
public class StreetShelve {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private Integer streetId;
|
|
||||||
|
|
||||||
private String shelveId;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
package com.zhehekeji.web.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName
|
|
||||||
public class Warn {
|
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private Integer streetId;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private LocalDateTime startTime;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
private LocalDateTime endTime;
|
|
||||||
|
|
||||||
@ApiModelProperty("视频图片地址")
|
|
||||||
@TableField("`video_path_1`")
|
|
||||||
private String videoPath1;
|
|
||||||
|
|
||||||
@ApiModelProperty("视频图片地址")
|
|
||||||
@TableField("`video_path_2`")
|
|
||||||
private String videoPath2;
|
|
||||||
|
|
||||||
private String location;
|
|
||||||
|
|
||||||
@TableField("`signal`")
|
|
||||||
private String signal;
|
|
||||||
}
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import com.sun.jna.Pointer;
|
|
||||||
import com.zhehekeji.web.entity.Order;
|
|
||||||
import com.zhehekeji.web.mapper.OrderMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class CallBack {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 球机掉线回调
|
|
||||||
*/
|
|
||||||
public static class DisConnectCallBack implements NetSDKLib.fDisConnect {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invoke(NetSDKLib.LLong lLoginID, String pchDVRIP, int nDVRPort, Pointer dwUser) {
|
|
||||||
Integer cameraId = CameraConnMap.getCameraIdByLoginId(lLoginID);
|
|
||||||
log.error("球机:{}掉线",cameraId);
|
|
||||||
//CameraConnMap.disConn(cameraId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mp4下载回调
|
|
||||||
*/
|
|
||||||
public static class Mp4ReceiveCB implements NetSDKLib.fTimeDownLoadPosCallBack {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invoke(NetSDKLib.LLong lPlayHandle, int dwTotalSize, int dwDownLoadSize, int index, NetSDKLib.NET_RECORDFILE_INFO.ByValue recordfileinfo, Pointer dwUser) {
|
|
||||||
if(dwDownLoadSize == -1) {
|
|
||||||
OrderRealtime.overDownload(lPlayHandle);
|
|
||||||
StopDownLoadThread stopDownLoadThread = new StopDownLoadThread(lPlayHandle);
|
|
||||||
stopDownLoadThread.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class HaveReConnect implements NetSDKLib.fHaveReConnect {
|
|
||||||
@Override
|
|
||||||
public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
|
|
||||||
log.info("球机:{}重连,loginId:{}",pchDVRIP,m_hLoginHandle.longValue());
|
|
||||||
System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CBPTZStatusProcCallBack implements NetSDKLib.fPTZStatusProcCallBack{
|
|
||||||
|
|
||||||
private CBPTZStatusProcCallBack() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class CallBackHolder {
|
|
||||||
private static CBPTZStatusProcCallBack instance = new CBPTZStatusProcCallBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CBPTZStatusProcCallBack getInstance() {
|
|
||||||
return CallBackHolder.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invoke(NetSDKLib.LLong lLoginId, NetSDKLib.LLong lAttachHandle, Pointer pBuf, int dwBufLen, long dwUser) {
|
|
||||||
NetSDKLib.NET_PTZ_LOCATION_INFO PTZInfo = new NetSDKLib.NET_PTZ_LOCATION_INFO();
|
|
||||||
ToolKits.GetPointerData(pBuf, PTZInfo);
|
|
||||||
// if(PTZInfo.bState == 2){
|
|
||||||
// Integer cameraId = CameraConnMap.getCameraIdByLoginId(lLoginId);
|
|
||||||
// if(cameraId != null){
|
|
||||||
// OrderInfo orderInfo = CameraCaptureMap.getOrderInfoByStreetId(cameraId);
|
|
||||||
// log.info("cameraId:{}",cameraId);
|
|
||||||
// if(orderInfo != null && !"C6".equals(orderInfo.getCode())){
|
|
||||||
// log.info("cameraId:{} 到位 拍照,code:{},orderNUm:{}",cameraId,orderInfo.getCode(),orderInfo.getOrderNum());
|
|
||||||
// //PtzControlModule.pic(cameraId,0,orderInfo);
|
|
||||||
// }
|
|
||||||
// CameraCaptureMap.remove(cameraId);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
|
|
||||||
public class CameraAction implements ApplicationRunner {
|
|
||||||
@Override
|
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class CameraCaptureMap {
|
|
||||||
|
|
||||||
private static Map<Integer,OrderInfo> cameraMap = new HashMap<>();
|
|
||||||
|
|
||||||
public static void put(Integer cameraId,OrderInfo orderInfo){
|
|
||||||
if(cameraId != null && orderInfo != null){
|
|
||||||
cameraMap.put(cameraId,orderInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void remove(Integer cameraId){
|
|
||||||
cameraMap.remove(cameraId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OrderInfo getOrderInfoByStreetId(Integer cameraId){
|
|
||||||
return cameraMap.get(cameraId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CameraConnMap{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* key :cameraId
|
|
||||||
* value: loginId
|
|
||||||
*/
|
|
||||||
public static Map<Integer, NetSDKLib.LLong> cameraMap = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* key:loginId
|
|
||||||
* value: cameraId
|
|
||||||
*/
|
|
||||||
public static Map<NetSDKLib.LLong,Integer> loginMap = new HashMap<>();
|
|
||||||
|
|
||||||
public static void conn(Integer cameraId,NetSDKLib.LLong handlerId){
|
|
||||||
synchronized (cameraId.toString().intern()){
|
|
||||||
cameraMap.put(cameraId,handlerId);
|
|
||||||
loginMap.put(handlerId,cameraId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void disConn(Integer cameraId){
|
|
||||||
synchronized (cameraId.toString().intern()){
|
|
||||||
NetSDKLib.LLong lLong = cameraMap.get(cameraId);
|
|
||||||
cameraMap.remove(cameraId);
|
|
||||||
loginMap.remove(lLong);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NetSDKLib.LLong getConnId(Integer cameraId){
|
|
||||||
return cameraMap.get(cameraId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getCameraIdByLoginId(NetSDKLib.LLong lLong){
|
|
||||||
return loginMap.get(lLong);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import com.sun.jna.Pointer;
|
|
||||||
import com.zhehekeji.web.mapper.OrderLastMediaMapper;
|
|
||||||
import com.zhehekeji.web.mapper.OrderMapper;
|
|
||||||
import com.zhehekeji.web.mapper.StockMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description 抓图回调函数
|
|
||||||
* @Author wangyiming1031@aliyun.com
|
|
||||||
* @Date 2020/12/14 16:11
|
|
||||||
**/
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class CaptureReceiveCB implements NetSDKLib.fSnapRev{
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private OrderMapper orderMapper;
|
|
||||||
|
|
||||||
@Value("${mediaPath}")
|
|
||||||
private String mediaPath;
|
|
||||||
|
|
||||||
private static String fileType = "jpg";
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private StockMapper stockMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行线程池
|
|
||||||
*/
|
|
||||||
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 10, 200,
|
|
||||||
TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(10000000));
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invoke(NetSDKLib.LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) {
|
|
||||||
CaptureRunnable captureRunnable = new CaptureRunnable(CmdSerial,fileType,RevLen,mediaPath,pBuf,orderMapper,stockMapper);
|
|
||||||
threadPoolExecutor.execute(captureRunnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,122 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import com.sun.jna.Pointer;
|
|
||||||
import com.zhehekeji.common.util.PathUtil;
|
|
||||||
import com.zhehekeji.web.entity.Order;
|
|
||||||
import com.zhehekeji.web.entity.Stock;
|
|
||||||
import com.zhehekeji.web.mapper.OrderMapper;
|
|
||||||
import com.zhehekeji.web.mapper.StockMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class CaptureRunnable implements Runnable {
|
|
||||||
|
|
||||||
private int CmdSerial;
|
|
||||||
|
|
||||||
private String fileType;
|
|
||||||
|
|
||||||
private Integer RevLen;
|
|
||||||
|
|
||||||
private String mediaPath;
|
|
||||||
|
|
||||||
private Pointer pBuf;
|
|
||||||
|
|
||||||
private OrderMapper orderMapper;
|
|
||||||
|
|
||||||
private StockMapper stockMapper;
|
|
||||||
|
|
||||||
public CaptureRunnable(int cmdSerial, String fileType, Integer revLen, String mediaPath,
|
|
||||||
Pointer pBuf, OrderMapper orderMapper, StockMapper stockMapper) {
|
|
||||||
this.CmdSerial = cmdSerial;
|
|
||||||
this.fileType = fileType;
|
|
||||||
this.RevLen = revLen;
|
|
||||||
this.mediaPath = mediaPath;
|
|
||||||
this.pBuf = pBuf;
|
|
||||||
this.orderMapper = orderMapper;
|
|
||||||
this.stockMapper = stockMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
OrderInfo orderInfo = OrderCmdSerial.getOrderInfo(CmdSerial);
|
|
||||||
OrderCmdSerial.remove(CmdSerial);
|
|
||||||
if (orderInfo != null) {
|
|
||||||
String path = PathUtil.createFileName(fileType);
|
|
||||||
String picPath = savePic(pBuf, RevLen, mediaPath + path);
|
|
||||||
if (picPath == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String shelveId = orderInfo.getShelveId();
|
|
||||||
Integer row = orderInfo.getRow();
|
|
||||||
Integer column = orderInfo.getColumn();
|
|
||||||
|
|
||||||
//同步 防止有照片丢失
|
|
||||||
synchronized (orderInfo.getOrderNum().intern()) {
|
|
||||||
Order order = orderMapper.getOneByOrderNum(orderInfo.getOrderNum());
|
|
||||||
if (order != null) {
|
|
||||||
Stock stock = stockMapper.getByShelveIdAndRowColumn(orderInfo.getShelveId(), orderInfo.getRow(), orderInfo.getColumn());
|
|
||||||
if (stock == null) {
|
|
||||||
stock = new Stock();
|
|
||||||
stock.setShelveId(shelveId);
|
|
||||||
stock.setColumn(column);
|
|
||||||
stock.setRow(row);
|
|
||||||
stock.setStatus(0);
|
|
||||||
}
|
|
||||||
if (orderInfo.getIsPre()) {
|
|
||||||
stock.setOveroperationPic(path);
|
|
||||||
} else {
|
|
||||||
stock.setOveroperationPic(path);
|
|
||||||
}
|
|
||||||
stock.setOrderNum(order.getOrderNum());
|
|
||||||
stockMapper.updateById(stock);
|
|
||||||
String pics = order.getPicPaths();
|
|
||||||
if (StringUtils.isEmpty(pics)) {
|
|
||||||
order.setPicPaths(path);
|
|
||||||
} else {
|
|
||||||
order.setPicPaths(pics + "," + path);
|
|
||||||
}
|
|
||||||
Order update = new Order();
|
|
||||||
update.setId(order.getId());
|
|
||||||
update.setPicPaths(order.getPicPaths());
|
|
||||||
log.info(" update order set pics:{},orderNum:{}", update.getPicPaths(), orderInfo.getOrderNum());
|
|
||||||
orderMapper.updateById(update);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.warn("no order");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String savePic(Pointer pBuf, int RevLen, String path) {
|
|
||||||
BufferedImage bufferedImage = null;
|
|
||||||
if (pBuf != null && RevLen > 0) {
|
|
||||||
byte[] buf = pBuf.getByteArray(0, RevLen);
|
|
||||||
ByteArrayInputStream byteArrInput = new ByteArrayInputStream(buf);
|
|
||||||
try {
|
|
||||||
bufferedImage = ImageIO.read(byteArrInput);
|
|
||||||
if (bufferedImage == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
File file = PathUtil.getFile(path);
|
|
||||||
ImageIO.write(bufferedImage, fileType, file);
|
|
||||||
return path;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (bufferedImage != null) {
|
|
||||||
bufferedImage.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 251823
|
|
||||||
* @description 订阅云台元数据接口输入参数
|
|
||||||
* @date 2021/02/26
|
|
||||||
*/
|
|
||||||
public class NET_IN_PTZ_STATUS_PROC extends NetSDKLib.SdkStructure{
|
|
||||||
/**
|
|
||||||
* dwSize;
|
|
||||||
*/
|
|
||||||
public int dwSize;
|
|
||||||
/**
|
|
||||||
* 云台通道
|
|
||||||
*/
|
|
||||||
public int nChannel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态回调函数
|
|
||||||
*/
|
|
||||||
public NetSDKLib.fPTZStatusProcCallBack cbPTZStatusProc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户数据
|
|
||||||
*/
|
|
||||||
public long dwUser;
|
|
||||||
|
|
||||||
public NET_IN_PTZ_STATUS_PROC(){
|
|
||||||
this.dwSize = this.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
/**
|
|
||||||
* @author 251823
|
|
||||||
* @description 订阅云台元数据接口输输出参数
|
|
||||||
* @date 2021/02/26
|
|
||||||
*/
|
|
||||||
public class NET_OUT_PTZ_STATUS_PROC extends NetSDKLib.SdkStructure{
|
|
||||||
/**
|
|
||||||
* dwSize;
|
|
||||||
*/
|
|
||||||
public int dwSize;
|
|
||||||
public NET_OUT_PTZ_STATUS_PROC(){
|
|
||||||
this.dwSize = this.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,124 +0,0 @@
|
|||||||
package com.zhehekeji.web.lib;
|
|
||||||
|
|
||||||
import com.sun.jna.Memory;
|
|
||||||
import com.sun.jna.Native;
|
|
||||||
import com.sun.jna.Pointer;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.nio.CharBuffer;
|
|
||||||
|
|
||||||
|
|
||||||
/** Provides a temporary allocation of an immutable C string
|
|
||||||
* (<code>const char*</code> or <code>const wchar_t*</code>) for use when
|
|
||||||
* converting a Java String into a native memory function argument.
|
|
||||||
*
|
|
||||||
* @author Todd Fast, todd.fast@sun.com
|
|
||||||
* @author twall@users.sf.net
|
|
||||||
*/
|
|
||||||
public class NativeString implements CharSequence, Comparable<Object> {
|
|
||||||
|
|
||||||
private Pointer pointer;
|
|
||||||
private boolean wide;
|
|
||||||
|
|
||||||
/** Create a native string (NUL-terminated array of <code>char</code>).<p>
|
|
||||||
* If the system property <code>jna.encoding</code> is set, its value will
|
|
||||||
* be used to encode the native string. If not set or if the encoding
|
|
||||||
* is unavailable, the default platform encoding will be used.
|
|
||||||
*/
|
|
||||||
public NativeString(String string) {
|
|
||||||
this(string, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a native string as a NUL-terminated array of <code>wchar_t</code>
|
|
||||||
* (if <code>wide</code> is true) or <code>char</code>.<p>
|
|
||||||
* If the system property <code>jna.encoding</code> is set, its value will
|
|
||||||
* be used to encode the native <code>char</code>string.
|
|
||||||
* If not set or if the encoding is unavailable, the default platform
|
|
||||||
* encoding will be used.
|
|
||||||
*
|
|
||||||
* @param string value to write to native memory
|
|
||||||
* @param wide whether to store the String as <code>wchar_t</code>
|
|
||||||
*/
|
|
||||||
public NativeString(String string, boolean wide) {
|
|
||||||
if (string == null) {
|
|
||||||
throw new NullPointerException("String must not be null");
|
|
||||||
}
|
|
||||||
// Allocate the memory to hold the string. Note, we have to
|
|
||||||
// make this 1 element longer in order to accommodate the terminating
|
|
||||||
// NUL (which is generated in Pointer.setString()).
|
|
||||||
this.wide = wide;
|
|
||||||
if (wide) {
|
|
||||||
int len = (string.length() + 1 ) * Native.WCHAR_SIZE;
|
|
||||||
pointer = new Memory(len);
|
|
||||||
pointer.setString(0, string);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
byte[] data = getBytes(string);
|
|
||||||
pointer = new Memory(data.length + 1);
|
|
||||||
pointer.write(0, data, 0, data.length);
|
|
||||||
pointer.setByte(data.length, (byte)0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static byte[] getBytes(String s) {
|
|
||||||
try {
|
|
||||||
return getBytes(s, System.getProperty("jna.encoding"));
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException e) {
|
|
||||||
return s.getBytes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return a byte array corresponding to the given String, using the given
|
|
||||||
encoding.
|
|
||||||
*/
|
|
||||||
static byte[] getBytes(String s, String encoding) throws UnsupportedEncodingException {
|
|
||||||
if (encoding != null) {
|
|
||||||
return s.getBytes(encoding);
|
|
||||||
}
|
|
||||||
return s.getBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
return toString().hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
|
|
||||||
if (other instanceof CharSequence) {
|
|
||||||
return compareTo(other) == 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
String s = wide ? "const wchar_t*" : "const char*";
|
|
||||||
s += "(" + pointer.getString(0) + ")";
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pointer getPointer() {
|
|
||||||
return pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public char charAt(int index) {
|
|
||||||
return toString().charAt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int length() {
|
|
||||||
return toString().length();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CharSequence subSequence(int start, int end) {
|
|
||||||
return CharBuffer.wrap(toString()).subSequence(start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(Object other) {
|
|
||||||
|
|
||||||
if (other == null)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return toString().compareTo(other.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue