Commit dea5a75f authored by wujiang's avatar wujiang

提交accessapi代码

parent f16d0b49
...@@ -137,6 +137,11 @@ ...@@ -137,6 +137,11 @@
<artifactId>jettison</artifactId> <artifactId>jettison</artifactId>
<version>1.3.7</version> <version>1.3.7</version>
</dependency> </dependency>
<dependency>
<groupId>fakepath</groupId>
<artifactId>license-sdk</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -5,16 +5,16 @@ import java.net.InetAddress; ...@@ -5,16 +5,16 @@ import java.net.InetAddress;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
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;
...@@ -22,9 +22,11 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -22,9 +22,11 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler; import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import com.yeejoin.amos.api.openapi.face.service.TaAccessConfigServiceImpl;
/** /**
* *
* <pre> * <pre>
* *
* </pre> * </pre>
* *
...@@ -40,11 +42,14 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler; ...@@ -40,11 +42,14 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
@EnableAsync @EnableAsync
@EnableEurekaClient @EnableEurekaClient
@EnableScheduling @EnableScheduling
@MapperScan(value = { "org.typroject.tyboot.*.*.face.orm.dao", "com.yeejoin.amos.api.*.face.orm.dao", "org.typroject.tyboot.face.*.orm.dao*", @MapperScan(value = { "org.typroject.tyboot.*.*.face.orm.dao", "com.yeejoin.amos.api.*.face.orm.dao",
"com.yeejoin.amos.boot.biz.common.dao.mapper" }) "org.typroject.tyboot.face.*.orm.dao*", "com.yeejoin.amos.boot.biz.common.dao.mapper" })
@ComponentScan({ "org.typroject", "com.yeejoin.amos" }) @ComponentScan({ "org.typroject", "com.yeejoin.amos" })
public class AccessapiApplication { public class AccessapiApplication {
@Autowired
private TaAccessConfigServiceImpl taAccessConfigServiceImpl;
private static final Logger logger = LogManager.getLogger(AccessapiApplication.class); private static final Logger logger = LogManager.getLogger(AccessapiApplication.class);
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
...@@ -63,4 +68,10 @@ public class AccessapiApplication { ...@@ -63,4 +68,10 @@ public class AccessapiApplication {
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port + "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------"); + path + "/doc.html\n" + "----------------------------------------------------------");
} }
@Bean
public void initAccessConfig() {
taAccessConfigServiceImpl.refreshConfig();
taAccessConfigServiceImpl.startTask();
}
} }
...@@ -39,7 +39,12 @@ public class ControllerAop { ...@@ -39,7 +39,12 @@ public class ControllerAop {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
// 不需要添加请求头的接口 // 不需要添加请求头的接口
String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany","/openapi/bizToken/applyToken","/openapi/bizToken/getAppId","/lift/upload","/lift/status","/lift/run","/lift/fault","/lift/video/preview","/cylinderPage/serviceProvider","/cylinderPage/getTableInfo","/cylinderPage/initCylinderNum"}; String[] url = new String[]{"/api/user/selectInfo",
"/api/user/save/curCompany","/openapi/bizToken/applyToken",
"/openapi/bizToken/getAppId","/lift/upload","/lift/status",
"/lift/run","/lift/fault","/lift/video/preview","/cylinderPage/serviceProvider",
"/cylinderPage/getTableInfo","/cylinderPage/initCylinderNum"
,"/license/saveLinceseBaseInfo","/license/saveLinceseDetailInfo","refreshConfig"};
// 获取请求路径 // 获取请求路径
for(String uri : url) { for(String uri : url) {
if(request.getRequestURI().indexOf(uri) != -1) { if(request.getRequestURI().indexOf(uri) != -1) {
......
...@@ -27,55 +27,70 @@ import java.util.List; ...@@ -27,55 +27,70 @@ import java.util.List;
@Api(tags = "许可数据对接") @Api(tags = "许可数据对接")
public class LicenseController { public class LicenseController {
@Autowired @Autowired
private TaAccessConfigServiceImpl taAccessConfigService; private TaAccessConfigServiceImpl taAccessConfigService;
@Autowired @Autowired
private TaLicenseDetailInfoServiceImpl taLicenseDetailInfoService; private TaLicenseDetailInfoServiceImpl taLicenseDetailInfoService;
@Autowired @Autowired
private TaLicenseBaseInfoServiceImpl taLicenseBaseInfoService; private TaLicenseBaseInfoServiceImpl taLicenseBaseInfoService;
// /**
// * 新增许可信息-接入配置表
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @RequestMapping(value = "/saveAccessConfig", method = RequestMethod.POST)
// @ApiOperation(httpMethod = "POST", value = "新增许可信息-接入配置表", notes = "新增许可信息-接入配置表")
// @RestEventTrigger(value = "openapiLogEventHandler")
// public ResponseModel<String> saveTaAccessConfig (@RequestBody List<TaAccessConfig> produceInfo) throws Exception
// {
// return ResponseHelper.buildResponse(taAccessConfigService.saveAccessConfig(produceInfo));
// }
/** /**
* 新增许可信息-接入配置表 * 新增许可信息-许可基本信息表
* @return *
*/ * @return
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) */
@RequestMapping(value = "/saveAccessConfig", method = RequestMethod.POST) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "POST", value = "新增许可信息-接入配置表", notes = "新增许可信息-接入配置表") @RequestMapping(value = "/saveLinceseBaseInfo", method = RequestMethod.GET)
@RestEventTrigger(value = "openapiLogEventHandler") @ApiOperation(httpMethod = "GET", value = "新增许可信息-许可基本信息表", notes = "新增许可信息-许可基本信息表")
public ResponseModel<String> saveTaAccessConfig (@RequestBody List<TaAccessConfig> produceInfo) throws Exception @RestEventTrigger(value = "openapiLogEventHandler")
{ public ResponseModel<String> saveTaLicenseBaseInfo() throws Exception {
return ResponseHelper.buildResponse(taAccessConfigService.saveAccessConfig(produceInfo)); taLicenseBaseInfoService.syncLicenseData();
} return ResponseHelper.buildResponse("");
}
/**
* 新增许可信息-许可基本信息表
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/saveLinceseBaseInfo", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增许可信息-许可基本信息表", notes = "新增许可信息-许可基本信息表")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> saveTaLicenseBaseInfo (@RequestBody List<TaLicenseBaseInfo> produceInfo) throws Exception
{
return ResponseHelper.buildResponse(taLicenseBaseInfoService.saveLicenseBaseInfo(produceInfo));
}
/**
* 新增许可信息-许可详细信息表
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/saveLinceseDetailInfo", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增许可信息-许可详细信息表", notes = "新增许可信息-许可详细信息表")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> saveTaLicenseDetailInfo (@RequestBody List<TaLicenseDetailInfo> produceInfo) throws Exception
{
return ResponseHelper.buildResponse(taLicenseDetailInfoService.saveLicenseDetailInfo(produceInfo));
}
/**
* 新增许可信息-许可详细信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/saveLinceseDetailInfo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "新增许可信息-许可详细信息表", notes = "新增许可信息-许可详细信息表")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> saveTaLicenseDetailInfo()
throws Exception {
taLicenseDetailInfoService.syncLicenseData();
return ResponseHelper.buildResponse("");
}
/**
* 新增许可信息-许可详细信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/refreshConfig", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "更新配置", notes = "更新配置")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> refreshConfig()
throws Exception {
taAccessConfigService.refreshConfig();
return ResponseHelper.buildResponse("");
}
} }
...@@ -28,10 +28,10 @@ public class TaAccessConfig extends BaseEntity { ...@@ -28,10 +28,10 @@ public class TaAccessConfig extends BaseEntity {
private String bizType; private String bizType;
@ApiModelProperty(value = "键") @ApiModelProperty(value = "键")
private String key; private String bizKey;
@ApiModelProperty(value = "值") @ApiModelProperty(value = "值")
private String value; private String bizValue;
@ApiModelProperty(value = "描述") @ApiModelProperty(value = "描述")
private String description; private String description;
......
...@@ -24,8 +24,7 @@ public class TaLicenseBaseInfo extends BaseEntity { ...@@ -24,8 +24,7 @@ public class TaLicenseBaseInfo extends BaseEntity {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private String id;
private Long id;
@ApiModelProperty(value = "国家") @ApiModelProperty(value = "国家")
private String country; private String country;
...@@ -67,7 +66,7 @@ public class TaLicenseBaseInfo extends BaseEntity { ...@@ -67,7 +66,7 @@ public class TaLicenseBaseInfo extends BaseEntity {
private Date issueDate; private Date issueDate;
@ApiModelProperty(value = "发证机关") @ApiModelProperty(value = "发证机关")
private String approvedOrga; private String approvedOrgan;
@ApiModelProperty(value = "变更日期") @ApiModelProperty(value = "变更日期")
private Date changeDate; private Date changeDate;
......
...@@ -24,11 +24,10 @@ public class TaLicenseDetailInfo extends BaseEntity { ...@@ -24,11 +24,10 @@ public class TaLicenseDetailInfo extends BaseEntity {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
private String id;
private Long id;
@ApiModelProperty(value = "base_info表id") @ApiModelProperty(value = "base_info表id")
private String basicInfoSequenceNbr; private String basicInfoId;
@ApiModelProperty(value = "单位统一社会信用代码") @ApiModelProperty(value = "单位统一社会信用代码")
private String unitCode; private String unitCode;
......
package com.yeejoin.amos.api.openapi.face.service; package com.yeejoin.amos.api.openapi.face.service;
import com.yeejoin.amos.api.openapi.face.model.TaAccessConfigModel; import java.util.HashMap;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaAccessConfigMapper; import java.util.List;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaAccessConfig; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.Date; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.util.List; import com.yeejoin.amos.api.openapi.face.model.TaAccessConfigModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaAccessConfigMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaAccessConfig;
import com.yeejoin.amos.openapi.enums.TaAccessConfigBizeEnum;
/** /**
* 附件表 服务实现类 * 附件表 服务实现类
...@@ -20,25 +24,65 @@ import java.util.List; ...@@ -20,25 +24,65 @@ import java.util.List;
*/ */
@Service @Service
public class TaAccessConfigServiceImpl extends BaseService<TaAccessConfigModel, TaAccessConfig, TaAccessConfigMapper> { public class TaAccessConfigServiceImpl extends BaseService<TaAccessConfigModel, TaAccessConfig, TaAccessConfigMapper> {
/**
* static Map<String, String> licenseConfig = new HashMap<String, String>();
* 新增许可信息-接入配置表
* @Autowired
* @param model 接入配置实体类集合 private TaLicenseDetailInfoServiceImpl taLicenseDetailInfoService;
* @return 成功返回“OK”
*/ @Autowired
@Transactional(rollbackFor= {Exception.class}) private TaLicenseBaseInfoServiceImpl taLicenseBaseInfoService;
public String saveAccessConfig(List<TaAccessConfig> model) {
//TODO Auto-generated method stub /**
if (ValidationUtil.isEmpty(model)) { *
throw new BadRequest("接入配置表信息为空."); * 新增许可信息-接入配置表
} *
for (TaAccessConfig models : model) { * @param model 接入配置实体类集合
// checkModel(models); * @return 成功返回“OK”
models.setRecDate(new Date()); */
// models.setAppId(getAppId()); // @Transactional(rollbackFor = { Exception.class })
} // public String saveAccessConfig(List<TaAccessConfig> model) {
this.saveBatch(model); // // TODO Auto-generated method stub
return "OK"; // if (ValidationUtil.isEmpty(model)) {
} // throw new BadRequest("接入配置表信息为空.");
// }
// for (TaAccessConfig models : model) {
//// checkModel(models);
// models.setRecDate(new Date());
//// models.setAppId(getAppId());
// }
// this.saveBatch(model);
// return "OK";
// }
public void refreshConfig() {
licenseConfig.clear();
List<TaAccessConfig> list = this.list(new LambdaQueryWrapper<TaAccessConfig>().eq(TaAccessConfig::getBizType,
TaAccessConfigBizeEnum.LICENSE.getAttribute()));
for (TaAccessConfig ta : list) {
licenseConfig.put(ta.getBizKey(), ta.getBizValue());
}
}
public void startTask() {
String cron = licenseConfig.get("cron");
// 创建带线程池的调度器
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
// 手动初始化
taskScheduler.initialize();
// 设置线程池
taskScheduler.setPoolSize(30);
System.out.println(taskScheduler);
taskScheduler.schedule(new Runnable() {
@Override
public void run() {
try {
taLicenseDetailInfoService.syncLicenseData();
taLicenseBaseInfoService.syncLicenseData();
} catch (Exception e) {
e.printStackTrace();
}
}
}, new CronTrigger(cron));// 这串字符串是cron表达式 代表每隔5秒执行一次
}
} }
package com.yeejoin.amos.api.openapi.face.service; package com.yeejoin.amos.api.openapi.face.service;
import com.yeejoin.amos.api.openapi.face.model.TaLicenseBaseInfoModel; import java.util.ArrayList;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaLicenseBaseInfoMapper; import java.util.Date;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseBaseInfo; import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; 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.util.Date; import com.alibaba.fastjson.JSONArray;
import java.util.List; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.csoft.sdk.client.CsoftDefaultSdkClient;
import com.csoft.sdk.domain.App;
import com.csoft.sdk.domain.CsoftDataTzsbJbxxListParam;
import com.csoft.sdk.domain.request.CsoftDataTzsbJbxxListRequest;
import com.csoft.sdk.domain.response.CsoftDataTzsbJbxxListResponse;
import com.yeejoin.amos.api.openapi.face.model.TaLicenseBaseInfoModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaLicenseBaseInfoMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseBaseInfo;
/** /**
* 附件表 服务实现类 * 附件表 服务实现类
...@@ -19,26 +30,117 @@ import java.util.List; ...@@ -19,26 +30,117 @@ import java.util.List;
* @date 2022-08-17 * @date 2022-08-17
*/ */
@Service @Service
public class TaLicenseBaseInfoServiceImpl extends BaseService<TaLicenseBaseInfoModel, TaLicenseBaseInfo, TaLicenseBaseInfoMapper> { public class TaLicenseBaseInfoServiceImpl
/** extends BaseService<TaLicenseBaseInfoModel, TaLicenseBaseInfo, TaLicenseBaseInfoMapper> {
* /**
* 新增许可信息-许可基本信息表 *
* * 新增许可信息-许可基本信息表
* @param model 许可基本信息实体类集合 *
* @return 成功返回“OK” * @param model 许可基本信息实体类集合
*/ * @return 成功返回“OK”
@Transactional(rollbackFor= {Exception.class}) */
public String saveLicenseBaseInfo(List<TaLicenseBaseInfo> model) { @Transactional(rollbackFor = { Exception.class })
//TODO Auto-generated method stub public String saveLicenseBaseInfo(List<TaLicenseBaseInfo> model) {
if (ValidationUtil.isEmpty(model)) { // TODO Auto-generated method stub
throw new BadRequest("接入配置表信息为空."); if (ValidationUtil.isEmpty(model)) {
} throw new BadRequest("接入配置表信息为空.");
for (TaLicenseBaseInfo models : model) { }
for (TaLicenseBaseInfo models : model) {
// checkModel(models); // checkModel(models);
models.setRecDate(new Date()); models.setRecDate(new Date());
// models.setAppId(getAppId()); // models.setAppId(getAppId());
} }
this.saveBatch(model); this.saveBatch(model);
return "OK"; return "OK";
} }
public void syncLicenseData() throws Exception {
Map<String, String> map = TaAccessConfigServiceImpl.licenseConfig;
String appId = map.get("appId");
String appKey = map.get("appKey");
String appSecret = map.get("appSecret");
String server = map.get("server");
String startTime = map.get("startTime");
String endTime = map.get("endTime");
App app = App.of(appId, appKey, appSecret, server);
int current = 1;
int size = Integer.valueOf(map.get("pageSize"));
// 2.初始化请求客户端
CsoftDefaultSdkClient client = CsoftDefaultSdkClient.of(app);
// 3.设置参数,发送请求,并处理结果
CsoftDataTzsbJbxxListParam csoftDataTzsbJbxxListParam = new CsoftDataTzsbJbxxListParam();
csoftDataTzsbJbxxListParam.setStaTime(startTime);
// 开始日期
csoftDataTzsbJbxxListParam.setEndTime(endTime);
// 结束日期
csoftDataTzsbJbxxListParam.setPageSize(size); // 每 页记录数
csoftDataTzsbJbxxListParam.setCurrentPage(current); // 当前页码
CsoftDataTzsbJbxxListRequest request = new CsoftDataTzsbJbxxListRequest(csoftDataTzsbJbxxListParam);
CsoftDataTzsbJbxxListResponse response = client.execute(request);
// 4.返回校验
if (response.isSuccess()) {
System.out.println("成功:" + response.getData());
System.out.println(response.getResult());
JSONObject jsonObject = JSONObject.parseObject(response.getData());
JSONObject data = jsonObject.getJSONObject("data");
JSONArray jsonArray = data.getJSONArray("objList");
List<TaLicenseBaseInfo> list = new ArrayList<TaLicenseBaseInfo>();
for (Object obj : jsonArray) {
String jsonString = JSONObject.toJSONString(obj);
TaLicenseBaseInfo taLicenseBaseInfo = JSONObject.parseObject(jsonString, TaLicenseBaseInfo.class);
taLicenseBaseInfo.setSyncDate(new Date());
taLicenseBaseInfo.setSyncState(0);
TaLicenseBaseInfo oldTaLicenseBaseInfo = this.getOne(new LambdaQueryWrapper<TaLicenseBaseInfo>()
.eq(TaLicenseBaseInfo::getId, taLicenseBaseInfo.getId()));
if (oldTaLicenseBaseInfo != null) {
taLicenseBaseInfo.setSequenceNbr(oldTaLicenseBaseInfo.getSequenceNbr());
}
list.add(taLicenseBaseInfo);
}
this.saveOrUpdateBatch(list);
while (data.getInteger("totalNum") > current * size) {
csoftDataTzsbJbxxListParam.setCurrentPage(++current);
saveData(client, csoftDataTzsbJbxxListParam);
}
} else {
System.out.println("失败:" + response.getErrorMsg());
System.out.println("失败:" + response.getErrorCode());
throw new Exception(response.getErrorMsg());
}
}
private void saveData(CsoftDefaultSdkClient client, CsoftDataTzsbJbxxListParam csoftDataTzsbJbxxListParam)
throws Exception {
// 2.初始化请求客户端
CsoftDataTzsbJbxxListRequest request = new CsoftDataTzsbJbxxListRequest(csoftDataTzsbJbxxListParam);
CsoftDataTzsbJbxxListResponse response = client.execute(request);
// 4.返回校验
if (response.isSuccess()) {
System.out.println("成功:" + response.getData());
System.out.println(response.getResult());
JSONObject jsonObject = JSONObject.parseObject(response.getData());
JSONObject data = jsonObject.getJSONObject("data");
JSONArray jsonArray = data.getJSONArray("objList");
List<TaLicenseBaseInfo> list = new ArrayList<TaLicenseBaseInfo>();
for (Object obj : jsonArray) {
String jsonString = JSONObject.toJSONString(obj);
TaLicenseBaseInfo taLicenseBaseInfo = JSONObject.parseObject(jsonString, TaLicenseBaseInfo.class);
taLicenseBaseInfo.setSyncDate(new Date());
taLicenseBaseInfo.setSyncState(0);
TaLicenseBaseInfo oldTaLicenseBaseInfo = this.getOne(new LambdaQueryWrapper<TaLicenseBaseInfo>()
.eq(TaLicenseBaseInfo::getId, taLicenseBaseInfo.getId()));
if (oldTaLicenseBaseInfo != null) {
taLicenseBaseInfo.setSequenceNbr(oldTaLicenseBaseInfo.getSequenceNbr());
}
list.add(taLicenseBaseInfo);
}
this.saveOrUpdateBatch(list);
} else {
System.out.println("失败:current:" + csoftDataTzsbJbxxListParam.getCurrentPage());
System.out.println("失败:" + response.getErrorMsg());
System.out.println("失败:" + response.getErrorCode());
throw new Exception(response.getErrorMsg());
}
}
} }
package com.yeejoin.amos.api.openapi.face.service; package com.yeejoin.amos.api.openapi.face.service;
import com.yeejoin.amos.api.openapi.face.model.TaLicenseDetailInfoModel; import java.util.ArrayList;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaLicenseDetailInfoMapper; import java.util.Date;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseDetailInfo; import java.util.List;
import java.util.Map;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; 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.util.Date; import com.alibaba.fastjson.JSONArray;
import java.util.List; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.csoft.sdk.client.CsoftDefaultSdkClient;
import com.csoft.sdk.domain.App;
import com.csoft.sdk.domain.CsoftDataTzsbXkxxListParam;
import com.csoft.sdk.domain.request.CsoftDataTzsbXkxxListRequest;
import com.csoft.sdk.domain.response.CsoftDataTzsbXkxxListResponse;
import com.yeejoin.amos.api.openapi.face.model.TaLicenseDetailInfoModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaLicenseDetailInfoMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseDetailInfo;
/** /**
* 附件表 服务实现类 * 附件表 服务实现类
...@@ -42,5 +54,94 @@ public class TaLicenseDetailInfoServiceImpl extends BaseService<TaLicenseDetailI ...@@ -42,5 +54,94 @@ public class TaLicenseDetailInfoServiceImpl extends BaseService<TaLicenseDetailI
this.saveBatch(model); this.saveBatch(model);
return "OK"; return "OK";
} }
public void syncLicenseData() throws Exception {
Map<String, String> map = TaAccessConfigServiceImpl.licenseConfig;
String appId = map.get("appId");
String appKey = map.get("appKey");
String appSecret = map.get("appSecret");
String server = map.get("server");
String startTime = map.get("startTime");
String endTime = map.get("endTime");
App app = App.of(appId, appKey, appSecret, server);
int current = 1;
int size = Integer.valueOf(map.get("pageSize"));
// 2.初始化请求客户端
CsoftDefaultSdkClient client = CsoftDefaultSdkClient.of(app);
// 3.设置参数,发送请求,并处理结果
CsoftDataTzsbXkxxListParam csoftDataTzsbXKxxListParam = new CsoftDataTzsbXkxxListParam();
csoftDataTzsbXKxxListParam.setStaTime(startTime);
// 开始日期
csoftDataTzsbXKxxListParam.setEndTime(endTime);
// 结束日期
csoftDataTzsbXKxxListParam.setPageSize(size); // 每 页记录数
csoftDataTzsbXKxxListParam.setCurrentPage(current); // 当前页码
CsoftDataTzsbXkxxListRequest request = new CsoftDataTzsbXkxxListRequest(csoftDataTzsbXKxxListParam);
CsoftDataTzsbXkxxListResponse response = client.execute(request);
// 4.返回校验
if (response.isSuccess()) {
System.out.println("成功:" + response.getData());
System.out.println(response.getResult());
JSONObject jsonObject = JSONObject.parseObject(response.getData());
JSONObject data = jsonObject.getJSONObject("data");
JSONArray jsonArray = data.getJSONArray("objList");
List<TaLicenseDetailInfo> list = new ArrayList<TaLicenseDetailInfo>();
for (Object obj : jsonArray) {
String jsonString = JSONObject.toJSONString(obj);
TaLicenseDetailInfo taLicenseDetailInfo = JSONObject.parseObject(jsonString, TaLicenseDetailInfo.class);
taLicenseDetailInfo.setSyncDate(new Date());
taLicenseDetailInfo.setSyncState(0);
TaLicenseDetailInfo oldTaLicenseDetailInfo = this.getOne(new LambdaQueryWrapper<TaLicenseDetailInfo>()
.eq(TaLicenseDetailInfo::getId, taLicenseDetailInfo.getId()));
if (oldTaLicenseDetailInfo != null) {
taLicenseDetailInfo.setSequenceNbr(oldTaLicenseDetailInfo.getSequenceNbr());
}
list.add(taLicenseDetailInfo);
}
this.saveOrUpdateBatch(list);
while (data.getInteger("totalNum") > current * size) {
csoftDataTzsbXKxxListParam.setCurrentPage(++current);
saveData(client, csoftDataTzsbXKxxListParam);
}
} else {
System.out.println("失败:" + response.getErrorMsg());
System.out.println("失败:" + response.getErrorCode());
throw new Exception(response.getErrorMsg());
}
}
private void saveData(CsoftDefaultSdkClient client, CsoftDataTzsbXkxxListParam csoftDataTzsbXKxxListParam) throws Exception {
// 2.初始化请求客户端
CsoftDataTzsbXkxxListRequest request = new CsoftDataTzsbXkxxListRequest(csoftDataTzsbXKxxListParam);
CsoftDataTzsbXkxxListResponse response = client.execute(request);
// 4.返回校验
if (response.isSuccess()) {
System.out.println("成功:" + response.getData());
System.out.println(response.getResult());
JSONObject jsonObject = JSONObject.parseObject(response.getData());
JSONObject data = jsonObject.getJSONObject("data");
JSONArray jsonArray = data.getJSONArray("objList");
List<TaLicenseDetailInfo> list = new ArrayList<TaLicenseDetailInfo>();
for (Object obj : jsonArray) {
String jsonString = JSONObject.toJSONString(obj);
TaLicenseDetailInfo taLicenseDetailInfo = JSONObject.parseObject(jsonString, TaLicenseDetailInfo.class);
taLicenseDetailInfo.setSyncDate(new Date());
taLicenseDetailInfo.setSyncState(0);
TaLicenseDetailInfo oldTaLicenseDetailInfo = this.getOne(new LambdaQueryWrapper<TaLicenseDetailInfo>()
.eq(TaLicenseDetailInfo::getId, taLicenseDetailInfo.getId()));
if (oldTaLicenseDetailInfo != null) {
taLicenseDetailInfo.setSequenceNbr(oldTaLicenseDetailInfo.getSequenceNbr());
}
list.add(taLicenseDetailInfo);
}
this.saveOrUpdateBatch(list);
} else {
System.out.println("失败:current:" + csoftDataTzsbXKxxListParam.getCurrentPage());
System.out.println("失败:" + response.getErrorMsg());
System.out.println("失败:" + response.getErrorCode());
throw new Exception(response.getErrorMsg());
}
}
} }
spring.application.name=AMOS-API-OPENAPI spring.application.name=AMOS-API-ACCESSAPI
server.servlet.context-path=/openapi server.servlet.context-path=/accessapi
server.port=11004 server.port=11005
# jdbc_config # jdbc_config
spring.datasource.url=jdbc:mysql://172.16.6.60:3306/amos_openapi?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root_123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_openapi?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
spring.datasource.type=com.zaxxer.hikari.HikariDataSource spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5 spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15 spring.datasource.hikari.maximum-pool-size=15
...@@ -17,10 +18,10 @@ spring.datasource.hikari.connection-timeout=30000 ...@@ -17,10 +18,10 @@ spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1 spring.datasource.hikari.connection-test-query=SELECT 1
# REDIS (RedisProperties) # REDIS (RedisProperties)
spring.redis.database=0 spring.redis.database=1
spring.redis.host=172.16.11.30 spring.redis.host=172.16.10.90
spring.redis.port=6379 spring.redis.port=6379
spring.redis.password=amos2019Redis spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200 spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1 spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10 spring.redis.lettuce.pool.max-idle=10
...@@ -28,7 +29,7 @@ spring.redis.lettuce.pool.min-idle=0 ...@@ -28,7 +29,7 @@ spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300 spring.redis.expire.time=300
#注册中心地址 #注册中心地址
eureka.client.service-url.defaultZone =http://172.16.11.30:10001/eureka/ eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=* management.endpoints.web.exposure.include=*
...@@ -40,10 +41,9 @@ eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port} ...@@ -40,10 +41,9 @@ eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}
##emqx ##emqx
emqx.clean-session=true emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]} emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://39.98.45.134:1883 emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=super emqx.user-name=admin
emqx.password=a123456 emqx.password=public
emqx.max-inflight=1000
##biz custem properties ##biz custem properties
biz.lxyd.lift.url=http://39.106.181.149:8088/elevatorapi biz.lxyd.lift.url=http://39.106.181.149:8088/elevatorapi
\ No newline at end of file
...@@ -11,4 +11,5 @@ redis.cache.failure.time=10800 ...@@ -11,4 +11,5 @@ redis.cache.failure.time=10800
# mybatis-plus # mybatis-plus
mybatis-plus.mapper-locations=classpath:mapper/*Mapper.xml mybatis-plus.mapper-locations=classpath:mapper/*Mapper.xml
mybatis-plus.type-aliases-super-type=org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity mybatis-plus.type-aliases-super-type=org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity
mybatis-plus.global-config.db-config.id-type=id_worker mybatis-plus.global-config.db-config.id-type=ID_WORKER
<?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"
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> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
...@@ -11,7 +13,7 @@ ...@@ -11,7 +13,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.11.RELEASE</version> <version>2.3.11.RELEASE</version>
<relativePath/> <relativePath />
</parent> </parent>
<properties> <properties>
...@@ -294,17 +296,9 @@ ...@@ -294,17 +296,9 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
<!--<repository> <!--<repository> <id>Releases</id> <name>Releases</name> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/releases/</url>
<id>Releases</id> </repository> <repository> <id>Snapshots</id> <name>Snapshots</name> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url>
<name>Releases</name> </repository> -->
<url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/releases/</url>
</repository>
<repository>
<id>Snapshots</id>
<name>Snapshots</name>
<url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url>
</repository>
-->
<repository> <repository>
<id>Releases</id> <id>Releases</id>
<name>Releases</name> <name>Releases</name>
...@@ -321,6 +315,13 @@ ...@@ -321,6 +315,13 @@
<name>Snapshots</name> <name>Snapshots</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url> <url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository>
<id>Snapshots</id>
<name>Snapshots</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/thirdparty/</url>
</repository>
</repositories> </repositories>
<modules> <modules>
...@@ -337,8 +338,8 @@ ...@@ -337,8 +338,8 @@
<module>amos-boot-core</module> <module>amos-boot-core</module>
<module>amos-boot-utils</module> <module>amos-boot-utils</module>
<module>amos-boot-system-latentdanger</module> <module>amos-boot-system-latentdanger</module>
<module>amos-boot-system-ccs</module> <module>amos-boot-system-ccs</module>
<module>amos-boot-data</module> <module>amos-boot-data</module>
<module>amos-boot-system-precontrol</module> <module>amos-boot-system-precontrol</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