Commit d004ffb2 authored by 李成龙's avatar 李成龙

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

# Conflicts: # amos-boot-system-tzs/src/main/resources/application-dev.properties # amos-boot-system-tzs/src/main/resources/application.properties
parents 5c047b9e 2fbf82de
...@@ -11,21 +11,21 @@ ...@@ -11,21 +11,21 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
......
...@@ -3,11 +3,7 @@ ...@@ -3,11 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>amos-boot-biz-common</artifactId> <artifactId>amos-boot-biz-common</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent> <parent>
<artifactId>amos-biz-boot</artifactId> <artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
...@@ -15,6 +11,73 @@ ...@@ -15,6 +11,73 @@
</parent> </parent>
<dependencies> <dependencies>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-rdbms</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-restful</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId> <artifactId>mybatis-plus-generator</artifactId>
...@@ -27,18 +90,7 @@ ...@@ -27,18 +90,7 @@
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
</dependency> </dependency>
<!-- knife4j -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j-spring-boot-starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.javassist</groupId> <groupId>org.javassist</groupId>
<artifactId>javassist</artifactId> <artifactId>javassist</artifactId>
......
...@@ -3,33 +3,18 @@ ...@@ -3,33 +3,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>amos-boot-core</artifactId>
<packaging>jar</packaging>
<parent> <parent>
<artifactId>amos-biz-boot</artifactId> <artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<version>1.0.0</version> <version>1.0.0</version>
</parent> </parent>
<artifactId>amos-boot-system-jpush</artifactId>
<version>8.0.0</version>
<dependencies> <dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jpush-biz</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
package com.yeejoin.amos.boot.biz.config; package com.yeejoin.amos.boot.core.config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -7,8 +7,6 @@ import org.springframework.context.annotation.Bean; ...@@ -7,8 +7,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.ParameterBuilder;
...@@ -23,10 +21,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; ...@@ -23,10 +21,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
/** /**
* @Author lichenglong * @Author lichenglong
*/ */
//@Configuration
//@EnableSwagger2
//@EnableKnife4j
//@Import(BeanValidatorPluginsConfiguration.class)
@Configuration @Configuration
@EnableSwagger2WebMvc @EnableSwagger2WebMvc
public class Swagger2Config { public class Swagger2Config {
...@@ -67,16 +61,6 @@ public class Swagger2Config { ...@@ -67,16 +61,6 @@ public class Swagger2Config {
.globalOperationParameters(setHeaderToken()); .globalOperationParameters(setHeaderToken());
} }
/***
* oauth2配置
* 需要增加swagger授权回调地址
* http://localhost:8888/webjars/springfox-swagger-ui/o2c.html
* @return
*/
// @Bean
// SecurityScheme securityScheme() {
// return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header");
// }
/** /**
* JWT token * JWT token
* @return * @return
...@@ -116,25 +100,5 @@ public class Swagger2Config { ...@@ -116,25 +100,5 @@ public class Swagger2Config {
.build(); .build();
} }
/**
* 新增 securityContexts 保持登录状态
*/
// private List<SecurityContext> securityContexts() {
// return new ArrayList(
// Collections.singleton(SecurityContext.builder()
// .securityReferences(defaultAuth())
// .forPaths(PathSelectors.regex("^(?!auth).*$"))
// .build())
// );
// }
//
// private List<SecurityReference> defaultAuth() {
// AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
// AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
// authorizationScopes[0] = authorizationScope;
// return new ArrayList(
// Collections.singleton(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes)));
// }
} }
package org.typroject.tyboot.core.restful.doc;
/**
* 此类是为了覆盖原有类,为空,不用写具体实现
* @author lichenglong
*
*/
public class Swagger2 {
}
...@@ -43,6 +43,11 @@ ...@@ -43,6 +43,11 @@
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.11.2</version> <version>1.11.2</version>
</dependency> </dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.10</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
<?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>
<parent>
<artifactId>amos-boot-module-api</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-jpush-api</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
<module>amos-boot-module-fas-api</module> <module>amos-boot-module-fas-api</module>
<module>amos-boot-module-maintenance-api</module> <module>amos-boot-module-maintenance-api</module>
<module>amos-boot-module-supervision-api</module> <module>amos-boot-module-supervision-api</module>
<module>amos-boot-module-jpush-api</module>
<module>amos-boot-module-knowledgebase-api</module> <module>amos-boot-module-knowledgebase-api</module>
</modules> </modules>
</project> </project>
\ No newline at end of file
...@@ -24,11 +24,22 @@ ...@@ -24,11 +24,22 @@
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.typroject</groupId> <groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId> <artifactId>*</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-emq</artifactId>
<version>${tyboot-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId> <artifactId>poi-scratchpad</artifactId>
<version>3.15</version> <version>3.15</version>
......
...@@ -95,7 +95,10 @@ ...@@ -95,7 +95,10 @@
<dependency> <dependency>
<groupId>org.liquibase</groupId> <groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId> <artifactId>liquibase-core</artifactId>
<version>3.8.9</version> </dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -95,6 +95,10 @@ ...@@ -95,6 +95,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
<?xml version="1.0" encoding="UTF-8"?> <?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"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>amos-boot-module-biz</artifactId> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <parent>
<version>1.0.0</version> <artifactId>amos-boot-module-biz</artifactId>
</parent> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-supervision-biz</artifactId> <version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-supervision-biz</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-supervision-api</artifactId> <artifactId>amos-boot-module-supervision-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
...@@ -92,6 +94,10 @@ ...@@ -92,6 +94,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
</dependency>
</dependencies>
</project> </project>
...@@ -81,10 +81,13 @@ public class CtiController extends BaseController { ...@@ -81,10 +81,13 @@ public class CtiController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/info/{connectId}") @GetMapping(value = "/info/{serviceconnectionid}")
@ApiOperation(httpMethod = "GET", value = "获取通话话单详情", notes = "获取通话话单详情") @ApiOperation(httpMethod = "GET", value = "获取通话话单详情", notes = "获取通话话单详情")
public ResponseModel<JSONObject> getCallInfo(@PathVariable String connectId) { public ResponseModel<JSONObject> getCallInfo(@PathVariable String serviceconnectionid) {
JSONArray recordInfos = ctiService.getCallInfo(connectId); JSONArray recordInfos = ctiService.getCallInfo(serviceconnectionid);
if(recordInfos.size() == 0) {
throw new BadRequest("未找到相关通话信息");
}
JSONObject recordInfo = recordInfos.getJSONObject(0); JSONObject recordInfo = recordInfos.getJSONObject(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
return ResponseHelper.buildResponse(recordInfo); return ResponseHelper.buildResponse(recordInfo);
......
...@@ -116,7 +116,7 @@ public class VoiceRecordFileController extends BaseController { ...@@ -116,7 +116,7 @@ public class VoiceRecordFileController extends BaseController {
/** /**
* 新增通话记录 * 新增-通话记录
* *
* @return * @return
*/ */
...@@ -135,13 +135,13 @@ public class VoiceRecordFileController extends BaseController { ...@@ -135,13 +135,13 @@ public class VoiceRecordFileController extends BaseController {
} }
JSONObject recordInfo = recordInfos.getJSONObject(0); JSONObject recordInfo = recordInfos.getJSONObject(0);
model.setTel(recordInfo.getString("telephone")); model.setTel(recordInfo.getString("telephone"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date telStartTime = null; Date telStartTime = null;
Date telEndTime = null; Date telEndTime = null;
try { try {
telStartTime = sdf.parse(recordInfo.getString("connectTime")); telStartTime = DateUtils.longStr2Date(recordInfo.getString("connectTime"));
telEndTime = sdf.parse(recordInfo.getString("hangupTime")); telEndTime = DateUtils.longStr2Date(recordInfo.getString("hangupTime"));
} catch (ParseException e) { } catch (Exception e) {
throw new BadRequest("日期转换错误"); throw new BadRequest("日期转换错误");
} }
model.setTelStartTime(telStartTime); model.setTelStartTime(telStartTime);
...@@ -152,8 +152,13 @@ public class VoiceRecordFileController extends BaseController { ...@@ -152,8 +152,13 @@ public class VoiceRecordFileController extends BaseController {
model.setFileType("坐席呼出"); model.setFileType("坐席呼出");
} }
// 获取附件 // 获取附件 需要延时5S
Map<String, String> downloadFile = ctiService.downLoadRecordFile(model.getConnectId()); try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, String> downloadFile = ctiService.downLoadRecordFile(recordInfo.getString("connectionid"));
if(downloadFile.isEmpty()) { if(downloadFile.isEmpty()) {
throw new BadRequest("未找到附件文件"); throw new BadRequest("未找到附件文件");
} }
......
package com.yeejoin.amos.boot.module.tzs.biz.service.impl; package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.FormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.tzs.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService;
import com.yeejoin.amos.boot.module.tzs.api.service.ICtiService; import com.yeejoin.amos.boot.module.tzs.api.service.ICtiService;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils; import com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.FileInfoModel;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -70,11 +36,14 @@ public class CtiServiceImpl implements ICtiService { ...@@ -70,11 +36,14 @@ public class CtiServiceImpl implements ICtiService {
*/ */
private long time = 6000l; private long time = 6000l;
private final String APP_KEY = "4e805006-3fef-ae43-3915-a153731007c4"; @Value("${tzs.cti.appkey}")
private String APP_KEY;
private final String SECRET_KEY = "7bd29115-99ee-4f7d-1fb1-7c4719d5f43a"; @Value("${tzs.cti.secretkey}")
private String SECRET_KEY;
private String ctiUrl = "http://36.46.151.113:8000"; @Value("${tzs.cti.url}")
private String ctiUrl;
@Override @Override
public String getAccessToken() { public String getAccessToken() {
...@@ -144,11 +113,11 @@ public class CtiServiceImpl implements ICtiService { ...@@ -144,11 +113,11 @@ public class CtiServiceImpl implements ICtiService {
} }
@Override @Override
public JSONArray getCallInfo(String connectionid) { public JSONArray getCallInfo(String serviceconnectionid) {
String token = this.getAccessToken(); String token = this.getAccessToken();
String url = ctiUrl + "/onOpenAuth/cti/openApi/querycalllist1"; String url = ctiUrl + "/onOpenAuth/cti/openApi/queryservicelist1";
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("connectionid",connectionid); params.put("serviceconnectionid",serviceconnectionid);
Map<String,String> header = new HashMap<>(); Map<String,String> header = new HashMap<>();
header.put("accessToken",token); header.put("accessToken",token);
String responseStr = HttpUtils.doPostWithHeader(url,params.toJSONString(),header); String responseStr = HttpUtils.doPostWithHeader(url,params.toJSONString(),header);
......
...@@ -51,6 +51,5 @@ ...@@ -51,6 +51,5 @@
<module>amos-boot-module-fas-biz</module> <module>amos-boot-module-fas-biz</module>
<module>amos-boot-module-maintenance-biz</module> <module>amos-boot-module-maintenance-biz</module>
<module>amos-boot-module-supervision-biz</module> <module>amos-boot-module-supervision-biz</module>
<module>amos-boot-module-jpush-biz</module>
</modules> </modules>
</project> </project>
\ No newline at end of file
spring.application.name=JCS spring.application.name=JCS-lll
server.servlet.context-path=/jcs server.servlet.context-path=/jcs
server.port=11100 server.port=11100
spring.profiles.active=dev spring.profiles.active=dev
......
<?xml version="1.0" encoding="UTF-8"?> <?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" <project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <modelVersion>4.0.0</modelVersion>
<artifactId>amos-biz-boot</artifactId> <parent>
<groupId>com.amosframework.boot</groupId> <artifactId>amos-biz-boot</artifactId>
<version>1.0.0</version> <groupId>com.amosframework.boot</groupId>
</parent> <version>1.0.0</version>
<artifactId>amos-boot-system-supervision</artifactId> </parent>
<dependencies> <artifactId>amos-boot-system-supervision</artifactId>
<dependency> <dependencies>
<groupId>com.amosframework.boot</groupId> <dependency>
<artifactId>amos-boot-module-supervision-biz</artifactId> <groupId>com.amosframework.boot</groupId>
<version>${amos-biz-boot.version}</version> <artifactId>amos-boot-module-supervision-biz</artifactId>
</dependency> <version>${amos-biz-boot.version}</version>
</dependencies> </dependency>
<build> <dependency>
<plugins> <groupId>cn.jpush.api</groupId>
<plugin> <artifactId>jpush-client</artifactId>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-maven-plugin</artifactId> </dependencies>
</plugin> <build>
</plugins> <plugins>
</build> <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -36,3 +36,7 @@ emqx.client-id=${spring.application.name}-${random.int[1024,65536]} ...@@ -36,3 +36,7 @@ emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.85:1883 emqx.broker=tcp://172.16.10.85:1883
emqx.user-name=super emqx.user-name=super
emqx.password=a123456 emqx.password=a123456
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
...@@ -8,6 +8,8 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss ...@@ -8,6 +8,8 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
logging.config=classpath:logback-${spring.profiles.active}.xml logging.config=classpath:logback-${spring.profiles.active}.xml
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
## DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=10 spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=25 spring.datasource.hikari.maximum-pool-size=25
...@@ -17,6 +19,24 @@ spring.datasource.hikari.pool-name=DatebookHikariCP ...@@ -17,6 +19,24 @@ spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=120000 spring.datasource.hikari.max-lifetime=120000
spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1 spring.datasource.hikari.connection-test-query=SELECT 1
## eureka properties:
eureka.client.registry-fetch-interval-seconds=5
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url-path=/actuator/health
eureka.instance.lease-expiration-duration-in-seconds=10
eureka.instance.lease-renewal-interval-in-seconds=5
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## redis properties:
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
iot.fegin.name=AMOS-API-IOT iot.fegin.name=AMOS-API-IOT
...@@ -25,10 +45,11 @@ equip.fegin.name=AMOS-EQUIPMANAGE ...@@ -25,10 +45,11 @@ equip.fegin.name=AMOS-EQUIPMANAGE
supervision.feign.name = AMOS-SUPERVISION-API supervision.feign.name = AMOS-SUPERVISION-API
security.systemctl.name=AMOS-API-SYSTEMCTL security.systemctl.name=AMOS-API-SYSTEMCTL
jcs.company.topic.add=jcs/company/topic/add jcs.company.topic.add=jcs/company/topic/add
jcs.company.topic.delete=jcs/company/topic/delete jcs.company.topic.delete=jcs/company/topic/delete
## 设备联动服务(车库门、广播、警铃) ## 设备联动服务(车库门、广播、警铃)
control.fegin.name=JCS-API-CONTROL control.fegin.name=JCS-API-CONTROL
## redis超时时间 ## redis超时时间
redis.cache.failure.time=10800 redis.cache.failure.time=10800
failure.work.flow.processDefinitionKey=malfunction_repair failure.work.flow.processDefinitionKey=malfunction_repair
\ No newline at end of file
...@@ -4,34 +4,23 @@ ...@@ -4,34 +4,23 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>amos-boot-module-biz</artifactId> <artifactId>amos-boot-utils</artifactId>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<version>1.0.0</version> <version>1.0.0</version>
</parent> </parent>
<artifactId>amos-boot-module-jpush-biz</artifactId> <artifactId>amos-boot-utils-jpush</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jpush-api</artifactId> <artifactId>amos-boot-core</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>cn.jpush.api</groupId>
<artifactId>amos-boot-biz-common</artifactId> <artifactId>jpush-client</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -16,7 +16,7 @@ import org.springframework.context.ConfigurableApplicationContext; ...@@ -16,7 +16,7 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler; //import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
/** /**
* <pre> * <pre>
...@@ -40,7 +40,7 @@ public class JpushApplication { ...@@ -40,7 +40,7 @@ public class JpushApplication {
public static void main(String[] args) throws UnknownHostException { public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(JpushApplication.class, args); ConfigurableApplicationContext context = SpringApplication.run(JpushApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true); // GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment(); Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress(); String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port"); String port = env.getProperty("server.port");
......
package com.yeejoin.amos.jpush.service.business.controller; package com.yeejoin.amos.jpush.service.business.controller;
import com.yeejoin.amos.jpush.common.entity.CommonResponse;
import com.yeejoin.amos.jpush.common.entity.CommonResponseUtil;
import com.yeejoin.amos.jpush.service.business.param.PushMsgParam;
import com.yeejoin.amos.jpush.service.jpush.AppMessagePushService;
import cn.jpush.api.push.model.PushPayload; import cn.jpush.api.push.model.PushPayload;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -17,8 +12,11 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -17,8 +12,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import com.yeejoin.amos.jpush.common.entity.CommonResponse;
import com.yeejoin.amos.jpush.common.entity.CommonResponseUtil;
import com.yeejoin.amos.jpush.service.business.param.PushMsgParam;
import com.yeejoin.amos.jpush.service.jpush.AppMessagePushService;
/** /**
...@@ -40,7 +38,7 @@ public class UserController { ...@@ -40,7 +38,7 @@ public class UserController {
//极光推送 //极光推送
@ApiOperation(value = "发送消息", notes = "发送消息") @ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/sendMessage", method = RequestMethod.POST) @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
public CommonResponse sendMessage(@RequestBody List<PushMsgParam> responses) { public CommonResponse sendMessage(@RequestBody List<PushMsgParam> responses) {
...@@ -53,7 +51,7 @@ public class UserController { ...@@ -53,7 +51,7 @@ public class UserController {
return CommonResponseUtil.failure("发送失败"); return CommonResponseUtil.failure("发送失败");
} }
} }
@ApiOperation(value = "发送消息", notes = "发送消息") @ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/sendMessageone", method = RequestMethod.POST) @RequestMapping(value = "/sendMessageone", method = RequestMethod.POST)
public CommonResponse sendMessageone(@RequestBody PushMsgParam responses) { public CommonResponse sendMessageone(@RequestBody PushMsgParam responses) {
...@@ -66,7 +64,6 @@ public class UserController { ...@@ -66,7 +64,6 @@ public class UserController {
return CommonResponseUtil.failure("发送失败"); return CommonResponseUtil.failure("发送失败");
} }
} }
@ApiOperation(value = "发送消息", notes = "发送消息") @ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/pushNoticeMany", method = RequestMethod.POST) @RequestMapping(value = "/pushNoticeMany", method = RequestMethod.POST)
public CommonResponse pushNoticeMany(@RequestBody PushMsgParam responses) { public CommonResponse pushNoticeMany(@RequestBody PushMsgParam responses) {
...@@ -79,7 +76,6 @@ public class UserController { ...@@ -79,7 +76,6 @@ public class UserController {
return CommonResponseUtil.failure("发送失败"); return CommonResponseUtil.failure("发送失败");
} }
} }
@ApiOperation(value = "发送消息", notes = "发送消息") @ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/buildPushPayload", method = RequestMethod.POST) @RequestMapping(value = "/buildPushPayload", method = RequestMethod.POST)
public CommonResponse buildPushPayload(@RequestBody PushMsgParam responses) { public CommonResponse buildPushPayload(@RequestBody PushMsgParam responses) {
...@@ -92,7 +88,7 @@ public class UserController { ...@@ -92,7 +88,7 @@ public class UserController {
return CommonResponseUtil.failure("发送失败"); return CommonResponseUtil.failure("发送失败");
} }
} }
@ApiOperation(value = "删除别名关联设备", notes = "删除别名关联设备") @ApiOperation(value = "删除别名关联设备", notes = "删除别名关联设备")
@RequestMapping(value = "/pushDevice", method = RequestMethod.GET) @RequestMapping(value = "/pushDevice", method = RequestMethod.GET)
public CommonResponse pushDevice(@RequestParam("alias") String alias) { public CommonResponse pushDevice(@RequestParam("alias") String alias) {
...@@ -108,7 +104,6 @@ public class UserController { ...@@ -108,7 +104,6 @@ public class UserController {
return CommonResponseUtil.failure(); return CommonResponseUtil.failure();
} }
} }
@ApiOperation(value = "别名关联设备", notes = "别名关联设备") @ApiOperation(value = "别名关联设备", notes = "别名关联设备")
@RequestMapping(value = "/PushDeviceRegistration", method = RequestMethod.GET) @RequestMapping(value = "/PushDeviceRegistration", method = RequestMethod.GET)
public CommonResponse PushDeviceRegistration(@RequestParam("registrationId") String registrationId,@RequestParam("alias") String alias) { public CommonResponse PushDeviceRegistration(@RequestParam("registrationId") String registrationId,@RequestParam("alias") String alias) {
......
...@@ -3,20 +3,16 @@ ...@@ -3,20 +3,16 @@
*/ */
package com.yeejoin.amos.jpush.service.constants; package com.yeejoin.amos.jpush.service.constants;
import java.text.SimpleDateFormat;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
/** /**
* 常量 * 常量
*/ */
public class XJConstant { public class XJConstant {
private static final Logger logger = LoggerFactory.getLogger(XJConstant.class); private static final Logger logger = LoggerFactory.getLogger(XJConstant.class);
/**
* 构造方法
*/
private XJConstant() { private XJConstant() {
logger.debug(XJConstant.CONSTRUCTOR); logger.debug(XJConstant.CONSTRUCTOR);
} }
......
...@@ -42,203 +42,203 @@ import cn.jpush.api.push.model.notification.Notification; ...@@ -42,203 +42,203 @@ import cn.jpush.api.push.model.notification.Notification;
@Component @Component
public class AppMessagePushService { public class AppMessagePushService {
protected static final Logger log = LoggerFactory.getLogger(AppMessagePushService.class);
protected static final Logger log = LoggerFactory @Value("${params.isPush}")
.getLogger(AppMessagePushService.class); private String isPush;
@Value("${params.isPush}") private static RestTemplate restTemplate;
private String isPush; private static ObjectMapper objectMapper = new ObjectMapper();
// 端口443
private static RestTemplate restTemplate; protected static final String URL = "https://device.jpush.cn/";
private static ObjectMapper objectMapper = new ObjectMapper();
//端口443 protected static final String APP_KEY = "1b3f7b961200f4b236811dfe";
protected static final String URL ="https://device.jpush.cn/"; protected static final String MASTER_SECRET = "8b650e645fb3a43c96be02b2";
private static JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
protected static final String APP_KEY = "1b3f7b961200f4b236811dfe";
protected static final String MASTER_SECRET = "8b650e645fb3a43c96be02b2"; public static String buildJpushUserKey(String userId) {
private static JPushClient jpushClient = new JPushClient(MASTER_SECRET,
APP_KEY);
public static String buildJpushUserKey(String userId) {
// return XJConstant.JPUSH_USER_KEY + "_" + userId; // return XJConstant.JPUSH_USER_KEY + "_" + userId;
return userId; return userId;
} }
public void sendMessage(List<PushMsgParam> responses) {
try { public void sendMessage(List<PushMsgParam> responses) {
if (responses != null && "true".equals(isPush)) { try {
for (PushMsgParam response : responses) { if (responses != null && "true".equals(isPush)) {
PushPayload payload = buildPushPayload(response); for (PushMsgParam response : responses) {
jpushClient.sendPush(payload); PushPayload payload = buildPushPayload(response);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static PushPayload buildPushPayload(PushMsgParam response) {
Builder builder= PushPayload.newBuilder();
builder.setPlatform(Platform.all());
//设置如果用户不在线、离线消息保存的时间
Options options=Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
//设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
if (JPushTypeEnum.ALL.getCode().equals(response.getType())) {
builder.setAudience(Audience.all());//Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
} else if (JPushTypeEnum.TAG.getCode().equals(response.getType())) {
builder.setAudience(Audience.tag(users));//根据标签推送
} else {
builder.setAudience(Audience.alias(users));//根据别名推送
}
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras()).setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload pushPayload=builder.build();
return pushPayload;
}
public void sendMessage(PushMsgParam response) {
try {
if (null != response && "true".equals(isPush)) {
Builder builder= PushPayload.newBuilder();
builder.setPlatform(Platform.all());
Options options=Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
//设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
builder.setAudience(Audience.all());
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras()).setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload payload=builder.build();
jpushClient.sendPush(payload);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static void pushNoticeMany( PushMsgParam response){
PushPayload payload = buildPushPayload(response);
try {
jpushClient.sendPush(payload); jpushClient.sendPush(payload);
} catch (APIConnectionException e) { }
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static PushPayload buildPushPayload(PushMsgParam response) {
Builder builder = PushPayload.newBuilder();
builder.setPlatform(Platform.all());
// 设置如果用户不在线、离线消息保存的时间
Options options = Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
// 设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
if (JPushTypeEnum.ALL.getCode().equals(response.getType())) {
builder.setAudience(Audience.all());// Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
} else if (JPushTypeEnum.TAG.getCode().equals(response.getType())) {
builder.setAudience(Audience.tag(users));// 根据标签推送
} else {
builder.setAudience(Audience.alias(users));// 根据别名推送
}
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras())
.setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload pushPayload = builder.build();
return pushPayload;
}
public void sendMessage(PushMsgParam response) {
try {
if (null != response && "true".equals(isPush)) {
Builder builder = PushPayload.newBuilder();
builder.setPlatform(Platform.all());
Options options = Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
// 设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
builder.setAudience(Audience.all());
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras())
.setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload payload = builder.build();
jpushClient.sendPush(payload);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static void pushNoticeMany(PushMsgParam response) {
PushPayload payload = buildPushPayload(response);
try {
jpushClient.sendPush(payload);
} catch (APIConnectionException e) {
e.printStackTrace();
} catch (APIRequestException e) {
e.printStackTrace();
}
}
// 删除一个别名,以及该别名与设备的绑定关系。
public static boolean PushDevice(String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpDelete httpDelete = new HttpDelete(URL + "v3/aliases/" + alias);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
httpDelete.setConfig(requestConfig);
httpDelete.addHeader("Accept", "application/json");
httpDelete.addHeader("Authorization", "Basic " + Base64(APP_KEY + ":" + MASTER_SECRET));
httpResponse = httpClient.execute(httpDelete);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (APIRequestException e) { }
}
}
}
// 设置设备的别名与标签
public static boolean PushDeviceRegistration(String registrationId, String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(URL + "v3/devices/" + registrationId);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
httpPost.setConfig(requestConfig);
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Authorization", "Basic " + Base64(APP_KEY + ":" + MASTER_SECRET));
if (null != alias) {
Map<String, Object> nvps = new HashMap<>();
// 通过map集成entrySet方法获取entity
nvps.put("alias", alias);
nvps.put("tags", "");
nvps.put("mobile", "");
String json = JSON.toJSONString(nvps);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
httpPost.setEntity(stringEntity);
httpResponse = httpClient.execute(httpPost);
return true;
} else {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
//删除一个别名,以及该别名与设备的绑定关系。 }
public static boolean PushDevice(String alias) {
CloseableHttpClient httpClient = null; // Base64转码
CloseableHttpResponse httpResponse = null; public static String Base64(String code) {
try { final Base64.Encoder encoder = Base64.getEncoder();
httpClient = HttpClients.createDefault(); byte[] textByte;
HttpDelete httpDelete = new HttpDelete(URL +"v3/aliases/"+alias); try {
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000) textByte = code.getBytes("UTF-8");
.setConnectionRequestTimeout(35000) // 编码
.setSocketTimeout(60000) String encodedText = encoder.encodeToString(textByte);
.build(); return encodedText;
httpDelete.setConfig(requestConfig); } catch (UnsupportedEncodingException e) {
httpDelete.addHeader("Accept", "application/json");
httpDelete.addHeader("Authorization", "Basic "+Base64(APP_KEY+":"+MASTER_SECRET));
httpResponse = httpClient.execute(httpDelete);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//设置设备的别名与标签
public static boolean PushDeviceRegistration(String registrationId,String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(URL +"v3/devices/"+registrationId);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000)
.setSocketTimeout(60000)
.build();
httpPost.setConfig(requestConfig);
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Authorization", "Basic "+Base64(APP_KEY+":"+MASTER_SECRET));
if (null != alias ) {
Map<String, Object> nvps = new HashMap<>();
// 通过map集成entrySet方法获取entity
nvps.put("alias", alias);
nvps.put("tags", "");
nvps.put("mobile", "");
String json= JSON.toJSONString(nvps);
StringEntity stringEntity = new StringEntity(json,"UTF-8");//解决中文乱码问题
httpPost.setEntity(stringEntity);
httpResponse = httpClient.execute(httpPost);
return true;
}else{
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//Base64转码
public static String Base64(String code) {
final Base64.Encoder encoder = Base64.getEncoder();
byte[] textByte;
try {
textByte = code.getBytes("UTF-8");
//编码
String encodedText = encoder.encodeToString(textByte);
return encodedText;
} catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
return ""; return "";
} }
} }
} }
...@@ -1159,10 +1159,10 @@ public class DateUtil { ...@@ -1159,10 +1159,10 @@ public class DateUtil {
return true; return true;
} }
public static void main(String[] args) // public static void main(String[] args)
{ // {
// // //
} // }
/** /**
* 将date 按照指定 的 格式 formatStr 转换成 字符串 * 将date 按照指定 的 格式 formatStr 转换成 字符串
......
...@@ -8,5 +8,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa ...@@ -8,5 +8,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa
eureka.instance.status-page-url-path=/actuator/info eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
## redis properties:
spring.redis.database=0
spring.redis.host=172.16.10.85
spring.redis.port=6379
spring.redis.password=amos2019Redis
params.isPush=true params.isPush=true
\ No newline at end of file
server.port=7800
spring.application.name=AMOS-PUSH spring.application.name=AMOS-PUSH
server.servlet.context-path=/jpush
server.port=7800
spring.profiles.active=dev spring.profiles.active=dev
spring.jackson.time-zone=GMT+8 spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
ribbon.eureka.enabled=true
ribbon.ConnectTimeout=60000
ribbon.ReadTimeout=60000
ribbon.OkToRetryOnAllOperations=true
ribbon.MaxAutoRetriesNextServer=2
ribbon.MaxAutoRetries=1
spring.jackson.serialization.write-dates-as-timestamps=true spring.jackson.serialization.write-dates-as-timestamps=true
<?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>
<parent>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-utils</artifactId>
<packaging>pom</packaging>
<dependencies>
</dependencies>
<modules>
<module>amos-boot-utils-jpush</module>
</modules>
</project>
...@@ -37,9 +37,12 @@ ...@@ -37,9 +37,12 @@
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId> <groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId> <artifactId>hystrix-javanica</artifactId>
<version>1.5.18</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
...@@ -61,7 +64,11 @@ ...@@ -61,7 +64,11 @@
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.67</version> <version>1.2.67</version>
</dependency> </dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
...@@ -162,16 +169,11 @@ ...@@ -162,16 +169,11 @@
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-jexl</artifactId> <artifactId>commons-jexl</artifactId>
<version>2.1.1</version> <version>2.1.1</version>
</dependency> </dependency>
<!-- MQTT依赖 --> <!-- MQTT���� -->
<dependency> <dependency>
<groupId>org.springframework.integration</groupId> <groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-stream</artifactId> <artifactId>spring-integration-stream</artifactId>
...@@ -185,73 +187,22 @@ ...@@ -185,73 +187,22 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- knife4j -->
<dependency> <dependency>
<groupId>org.typroject</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>tyboot-core-restful</artifactId> <artifactId>knife4j-spring-boot-starter</artifactId>
<version>${tyboot-version}</version> <version>${knife4j-spring-boot-starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-rdbms</artifactId>
<version>${tyboot-version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.typroject</groupId> <groupId>org.javassist</groupId>
<artifactId>*</artifactId> <artifactId>javassist</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<artifactId>mysql-connector-java</artifactId>
<groupId>mysql</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<artifactId>mysql-connector-java</artifactId> <groupId>io.swagger</groupId>
<groupId>mysql</groupId> <artifactId>swagger-annotations</artifactId>
<version>8.0.22</version> <version>1.5.13</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
...@@ -291,6 +242,16 @@ ...@@ -291,6 +242,16 @@
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.3.10</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.4.3</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
...@@ -308,16 +269,16 @@ ...@@ -308,16 +269,16 @@
<name>maven-public</name> <name>maven-public</name>
<url>http://172.16.1.6:8081/nexus/content/repositories/maven-public/</url> <url>http://172.16.1.6:8081/nexus/content/repositories/maven-public/</url>
</repository> </repository>
<!-- <repository>--> <!-- <repository> -->
<!-- <id>maven-public1</id>--> <!-- <id>maven-public1</id> -->
<!-- <name>maven-public</name>--> <!-- <name>maven-public</name> -->
<!-- <url>http://repo.typroject.org:8081/repository/maven-public/</url>--> <!-- <url>http://repo.typroject.org:8081/repository/maven-public/</url> -->
<!-- </repository>--> <!-- </repository> -->
<!-- <repository>--> <!-- <repository> -->
<!-- <id>maven-snapshot</id>--> <!-- <id>maven-snapshot</id> -->
<!-- <name>maven-snapshot</name>--> <!-- <name>maven-snapshot</name> -->
<!-- <url>http://repo.typroject.org:8081/repository/maven-snapshots/</url>--> <!-- <url>http://repo.typroject.org:8081/repository/maven-snapshots/</url> -->
<!-- </repository>--> <!-- </repository> -->
</repositories> </repositories>
<modules> <modules>
...@@ -330,6 +291,7 @@ ...@@ -330,6 +291,7 @@
<module>amos-boot-system-patrol</module> <module>amos-boot-system-patrol</module>
<module>amos-boot-system-maintenance</module> <module>amos-boot-system-maintenance</module>
<module>amos-boot-system-supervision</module> <module>amos-boot-system-supervision</module>
<module>amos-boot-system-jpush</module> <module>amos-boot-core</module>
<module>amos-boot-utils</module>
</modules> </modules>
</project> </project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment