* 'master' of http://124.222.94.39:3000/wangliwen/share-platform:
  定时任务集群关闭
  dev 配置文件关闭亚微单点登录
  编目修改字段,修改属性表对应字段的值
  ...
  ...
  不要阻塞程序启动!!!
  ...
This commit is contained in:
huangweixiong 2022-06-08 14:31:00 +08:00
commit d64d2744d9
12 changed files with 246 additions and 210 deletions

View File

@ -178,9 +178,10 @@ public class ActivitiNoticeAspect {
new Thread(() -> {
try {
Thread.sleep(200);
work_.remove(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString());
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
work_.remove(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString());
}
}).start();
});
@ -278,9 +279,10 @@ public class ActivitiNoticeAspect {
new Thread(() -> {
try {
Thread.sleep(200);
work_.remove(ExecutionListener.EVENTNAME_END + kv.get("id").toString());
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
work_.remove(ExecutionListener.EVENTNAME_END + kv.get("id").toString());
}
}).start();
});

View File

@ -18,6 +18,8 @@ import io.renren.modules.security.user.SecurityUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -38,6 +40,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/ability/center")
public class AbilityCenterController {
private static Logger logger = LoggerFactory.getLogger(AbilityCenterController.class);
@Autowired
private ActProcessService actProcessService;
@Autowired
@ -70,6 +73,7 @@ public class AbilityCenterController {
}
return new Result().ok(abilityBatchApplicationDTO.getSystem().stream().map(index -> {
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
logger.error("重复发起申请");
return null;
}
TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO();

View File

@ -17,7 +17,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.File;
@ -60,7 +59,6 @@ public class CategoryController {
@PostMapping("/insert")
@ApiOperation("保存")
@Transactional(rollbackFor = Exception.class)
public Object insert(@RequestBody CategoryDTO categoryDTO) {
//效验数据
ValidatorUtils.validateEntity(categoryDTO, AddGroup.class, DefaultGroup.class);
@ -74,10 +72,8 @@ public class CategoryController {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return new Result<>().error("开发指南文件夹创建失败!");
return new Result<>().error("创建开发指南文件夹失败!");
}
} else {
return new Result<>().error("开发指南文件夹创建失败!");
}
}
categoryService.save(categoryDTO);

View File

@ -8,18 +8,24 @@ import io.renren.modules.category.dao.CategoryDao;
import io.renren.modules.category.dto.CategoryDTO;
import io.renren.modules.category.entity.Category;
import io.renren.modules.category.service.CategoryService;
import io.renren.modules.resource.dao.AttrDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category, CategoryDTO> implements CategoryService {
@Autowired
private CategoryDao categoryDao;
@Autowired
private AttrDao attrDao;
@Override
public Object getTopCategory() {
@ -46,7 +52,7 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
} else {
ArrayList<CategoryDTO> list = new ArrayList<>();
categoryDao.selectByParentId(categoryDto.getId())
.stream().forEach(item -> {
.forEach(item -> {
CategoryDTO dto = new CategoryDTO();
BeanUtils.copyProperties(item, dto);
list.add(dto);
@ -74,8 +80,7 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
.eq("del_flag",0)
.eq("is_attr", "true")
.orderByAsc("xh");
List<Category> categories = categoryDao.selectList(wrapper);
return categories;
return categoryDao.selectList(wrapper);
}
@Override
@ -101,4 +106,14 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
public QueryWrapper<Category> getWrapper(Map<String, Object> params) {
return null;
}
@Override
@Transactional
public void update(CategoryDTO categoryDTO) {
super.update(categoryDTO);
String oldName = categoryDao.selectById(categoryDTO.getId()).getName();
if (!oldName.equals(categoryDTO.getName())) {
attrDao.updateAttrType(oldName, categoryDTO.getName());
}
}
}

View File

@ -30,7 +30,7 @@ public class ScheduleConfig {
//JobStore配置
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
//集群配置
prop.put("org.quartz.jobStore.isClustered", "true");
prop.put("org.quartz.jobStore.isClustered", "false");
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");

View File

@ -10,10 +10,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
@RestController
@RequestMapping("api/project")
@Api(tags="视频流")
@Api(tags = "视频流")
public class FileController {
@Autowired
@ -21,21 +22,22 @@ public class FileController {
/**
* 根据摄像头标识获取视频流
*
* @param channelCode
* @return
* @throws IOException
*/
@GetMapping("file")
@ApiOperation("根据摄像头标识获取视频流")
public Result File(String channelCode)throws IOException {
public Result File(String channelCode) throws IOException {
String s = monitorService.fileCode(channelCode);
Result success = Result.success(s);
return success;
}
@GetMapping("token")
public Result token( ) {
String s = monitorService.init();
public Result token() throws ExecutionException, InterruptedException {
String s = monitorService.init().get();
Result success = Result.success(s);
return success;
}

View File

@ -36,6 +36,7 @@ import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@Service
@ -86,19 +87,19 @@ public class MonitorService {
static int keepaliveCount = 16;
@PostConstruct
public String init(){
try {
return monitorLogin();
}catch (Exception e){
log.warn("摄像头登录异常,跳过", e);
}
return null;
public CompletableFuture<String> init() {
// 不要阻塞程序启动
return CompletableFuture.supplyAsync(() -> {
try {
return monitorLogin();
} catch (Exception e) {
log.warn("摄像头登录异常,跳过", e);
}
return null;
});
}
public String monitorLogin(){
public String monitorLogin() {
String loginUrl = monitorDomain + "/videoService/accounts/authorize";
HashMap<String, String> loginParam = new HashMap<>();
@ -110,14 +111,14 @@ public class MonitorService {
try {
ResponseEntity<HashMap> loginResEntity = restTemplate.postForEntity(loginUrl, loginParam, HashMap.class, new HashMap<>());
reponse = loginResEntity.getBody();
}catch (HttpClientErrorException e){
} catch (HttpClientErrorException e) {
if (e.getStatusCode() == HttpStatus.UNAUTHORIZED) {
String responseString = e.getResponseBodyAsString();
reponse = JSONObject.parseObject(responseString, HashMap.class);
}
}
if (reponse == null){
if (reponse == null) {
log.error("[monitor-capture]:" + "监控系统登录握手失败");
throw new RuntimeException("监控系统登录握手失败");
}
@ -125,22 +126,22 @@ public class MonitorService {
//登录
loginParam.putAll(reponse);
String sigin = SecureUtil.md5(password);
sigin = SecureUtil.md5(userName+sigin);
sigin = SecureUtil.md5(userName + sigin);
sigin = SecureUtil.md5(sigin);
sigin = SecureUtil.md5(userName+":"+loginParam.get("realm")+":"+sigin);
sigin = SecureUtil.md5(sigin+":"+loginParam.get("randomKey"));
sigin = SecureUtil.md5(userName + ":" + loginParam.get("realm") + ":" + sigin);
sigin = SecureUtil.md5(sigin + ":" + loginParam.get("randomKey"));
loginParam.put("signature", sigin);
reponse = restTemplate.postForEntity(loginUrl, loginParam, HashMap.class, new HashMap<>()).getBody();
if (reponse != null){
if (reponse != null) {
String token = (String) reponse.get("token");
if (token== null || StringUtils.isEmpty(token)){
if (token == null || StringUtils.isEmpty(token)) {
log.error("[monitor-capture]:" + "监控系统登录失败");
return "";
}
this.token = token;
Integer duration = (Integer) reponse.get("duration");
if (duration == null || duration < 20){
if (duration == null || duration < 20) {
log.error("[monitor-capture]:" + "监控系统失效时间异常" + duration);
return "";
}
@ -151,27 +152,27 @@ public class MonitorService {
//会话保活
Timer timer = new Timer("monitor-capture-keepalive");
timer.scheduleAtFixedRate(new TimerTask(){
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
try{
String keepaliveUrl = monitorDomain + "/videoService/accounts/token/keepalive";
try {
String keepaliveUrl = monitorDomain + "/videoService/accounts/token/keepalive";
HttpHeaders headers = new HttpHeaders();
headers.add("X-Subject-Token",token);
headers.add("X-Subject-Token", token);
HashMap<Object, Object> keepaliveParam = new HashMap<>();
keepaliveParam.put("token", token);
HttpEntity<Object> httpEntity = new HttpEntity<>(keepaliveParam, headers);
restTemplate.put(keepaliveUrl, httpEntity);
if (keepaliveCount++ > 12){//大概36分钟输出一次日志
if (keepaliveCount++ > 12) {//大概36分钟输出一次日志
log.info("[monitor-capture]: keepalive success");
keepaliveCount = 0;
}
}catch (Exception e){
} catch (Exception e) {
log.info("[monitor-capture]: keepalive faild, restart.....");
e.printStackTrace();
@ -181,7 +182,6 @@ public class MonitorService {
}
}
}, 0, duration * 1000);
}
@ -208,14 +208,14 @@ public class MonitorService {
camera.setPic(picUrl);
camera.setCaptureTime(new Date());
cameraMapper.updateById(camera);
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +cameraCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + cameraCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
@ -243,25 +243,26 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 特定摊点8:50抓图
*/
@ -285,25 +286,26 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 特定摊点9:50抓图
*/
@ -327,25 +329,26 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 特定摊点9:20抓图
*/
@ -369,25 +372,26 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 特定摊点11:20抓图
*/
@ -411,25 +415,26 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 特定摊点12:20抓图
*/
@ -453,25 +458,26 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 特定摊点19:20抓图
*/
@ -495,22 +501,22 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
@ -538,22 +544,22 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
@ -583,22 +589,22 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture1");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
@ -628,22 +634,22 @@ public class MonitorService {
picture.setPicUrl(picUrl);
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
if (channelCode == null){
if (channelCode == null) {
channelPictureMapper.insert(picture);
}else {
} else {
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code", channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture, queryWrapper);
}
}catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
log.info("[monitor-capture] " + channelCode + " 截图图片失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: end capture");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
@ -680,7 +686,7 @@ public class MonitorService {
personImage.put("img_base64", imgBase64);
ResponseEntity<HashMap> responseEntity = restTemplate.postForEntity(personNumUrl, personImage, HashMap.class);
HashMap body = responseEntity.getBody();
if (body != null && (Integer) body.get("code") == 200){
if (body != null && (Integer) body.get("code") == 200) {
Map data = (Map) body.get("data");
Integer personNum = (Integer) data.get("person_num");
CameraScenic cameraScenic = new CameraScenic();
@ -688,33 +694,33 @@ public class MonitorService {
cameraScenic.setPersonNum(personNum);
CameraScenic cs = cameraScenicMapper.selectById(cameraCode);
if (cs == null){
if (cs == null) {
cameraScenicMapper.insert(cameraScenic);
}else {
} else {
cameraScenicMapper.updateById(cameraScenic);
}
}
}
catch (Exception e){
} catch (Exception e) {
log.info( "[monitor-capture] " +cameraCode + " 人流识别失败 " + e.getMessage());
log.info("[monitor-capture] " + cameraCode + " 人流识别失败 " + e.getMessage());
}
});
log.info("[monitor-capture]: startScenic end capture");
}catch (Exception exception){
} catch (Exception exception) {
exception.printStackTrace();
}
}
private BufferedImage capturecreenshot(String code) throws IOException {
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
HttpHeaders headers = new HttpHeaders();
headers.add("X-Subject-Token",token);
headers.add("X-Subject-Token", token);
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class );
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class);
HashMap body = forEntity.getBody();
@ -734,7 +740,7 @@ public class MonitorService {
int frameIndex = 60;
Java2DFrameConverter converter = new Java2DFrameConverter();
while (true){
while (true) {
Frame frame = grabber.grabImage();
if (frame != null) {
log.debug("grabber 跳帧:" + frameIndex);
@ -744,23 +750,24 @@ public class MonitorService {
}
}
}catch (Exception e){
} catch (Exception e) {
throw e;
}finally {
} finally {
grabber.stop();
grabber.release();
}
}
public String fileCode(String code)throws IOException{
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
public String fileCode(String code) throws IOException {
String url = monitorDomain + "/videoService/realmonitor/uri?scheme=HLS&channelId=" + code;
HttpHeaders headers = new HttpHeaders();
headers.add("X-Subject-Token",token);
headers.add("X-Subject-Token", token);
System.out.println(token);
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class );
ResponseEntity<HashMap> forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), HashMap.class);
HashMap body = forEntity.getBody();
@ -779,17 +786,17 @@ public class MonitorService {
HttpHeaders headers = new HttpHeaders();
headers.add("X-Subject-Token",token);
headers.add("X-Subject-Token", token);
ResponseEntity<List> forEntity = null;
for (int i = 0; i < 10; i++) {
try {
forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), List.class );
forEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity(headers), List.class);
break;
}catch (Exception e){
log.error("重试次数:{} url:{}",i,url);
} catch (Exception e) {
log.error("重试次数:{} url:{}", i, url);
log.error(e);
Thread.sleep(5*1000);
Thread.sleep(5 * 1000);
}
}
@ -802,17 +809,17 @@ public class MonitorService {
for (Map result : results) {
Boolean isParent = (Boolean) result.get("isParent");
if (isParent){
if (isParent) {
CameraOrganization cameraOrganization = JSONObject.parseObject(JSONObject.toJSONString(result), CameraOrganization.class);
cameraOrgenMapper.insert(cameraOrganization);
videoService((String) result.get("id"),path + sep + result.get("name"));
}else {
if (result.get("channelId") != null){
videoService((String) result.get("id"), path + sep + result.get("name"));
} else {
if (result.get("channelId") != null) {
CameraChannel cameraChannel = JSONObject.parseObject(JSONObject.toJSONString(result), CameraChannel.class);
String id = (String)result.get("orgCode");
String id = (String) result.get("orgCode");
if (path != null && path.startsWith(sep)) {
path = path.substring(sep.length());
@ -830,49 +837,49 @@ public class MonitorService {
}
//查询视频点播巡检结果
@Scheduled(cron="0 5 6 * * ?")
public Result listChannelPlayStates(){
@Scheduled(cron = "0 5 6 * * ?")
public Result listChannelPlayStates() {
//获取当前时间和前一天的UTC时间
Map<String,Object> condition = new HashMap<>();
Map<String, Object> condition = new HashMap<>();
ZonedDateTime endUTC = ZonedDateTime.now(ZoneOffset.UTC);
ZonedDateTime startUTC = endUTC.minusDays(60);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
condition.put("checkStatus",0);
condition.put("startTime",dateTimeFormatter.format(startUTC));
condition.put("endTime",dateTimeFormatter.format(endUTC));
condition.put("checkStatus", 0);
condition.put("startTime", dateTimeFormatter.format(startUTC));
condition.put("endTime", dateTimeFormatter.format(endUTC));
//组装查询条件经过验证pageSize设置过大也没效果最大512
Map<String,Object> map = new HashMap<>();
map.put("condition",condition);
map.put("page",1);
map.put("pageSize",500);//最多一次512条
Map<String, Object> map = new HashMap<>();
map.put("condition", condition);
map.put("page", 1);
map.put("pageSize", 500);//最多一次512条
//查询路径和请求头信息
String url = monitorDomain + "/nms/api/channel/play/list";
HttpHeaders headers = new HttpHeaders();
headers.add("X-Subject-Token",token);
headers.add("X-Subject-Token", token);
//查询数据的页数
int pageCount = 0;
//查询结果
List<Map> list = new ArrayList<>();
HttpEntity<Map<String,Object>> request = new HttpEntity<>(map,headers);
ResponseEntity<JSONObject> responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class );
HttpEntity<Map<String, Object>> request = new HttpEntity<>(map, headers);
ResponseEntity<JSONObject> responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
JSONObject entityBody = responseEntity.getBody();
if (entityBody.get("i18n") != null && entityBody.get("i18n").toString() == "error"){
log.info("{}程序异常{}",entityBody.get("message").toString());
if (entityBody.get("i18n") != null && entityBody.get("i18n").toString() == "error") {
log.info("{}程序异常{}", entityBody.get("message").toString());
}
List<Map> results = (List<Map>) entityBody.get("results");
if(!results.isEmpty()){
if (!results.isEmpty()) {
list.addAll(results);
pageCount = entityBody.getIntValue("totalCount")/500 + 1;
pageCount = entityBody.getIntValue("totalCount") / 500 + 1;
}
for(int i = 2;i<=pageCount;i++){
map.put("page",i);
HttpEntity<Map<String,Object>> request2 = new HttpEntity<>(map,headers);
ResponseEntity<JSONObject> responseEntity2 = restTemplate.exchange(url, HttpMethod.POST, request2, JSONObject.class );
for (int i = 2; i <= pageCount; i++) {
map.put("page", i);
HttpEntity<Map<String, Object>> request2 = new HttpEntity<>(map, headers);
ResponseEntity<JSONObject> responseEntity2 = restTemplate.exchange(url, HttpMethod.POST, request2, JSONObject.class);
JSONObject entityBody2 = responseEntity2.getBody();
List<Map> results2 = (List<Map>) entityBody2.get("results");
if(!results2.isEmpty()){
if (!results2.isEmpty()) {
list.addAll(results);
}
}
@ -887,29 +894,29 @@ public class MonitorService {
//通过set对channel_code去重
Set<String> set = new HashSet<>();
for(Map m:list){
for (Map m : list) {
set.add(m.get("channelCode").toString());
}
List<String> lists = new ArrayList<>(set.size());
lists.addAll(set);
//根据channel_code对t_camera_channel表的status字段进行更新0
List<List<String>> listMap = Lists.partition(lists,100);
for(List<String> ll:listMap){
List<List<String>> listMap = Lists.partition(lists, 100);
for (List<String> ll : listMap) {
cameraChannelMapper.updateCameraStatus(ll);
}
log.info("{} 查询视频点播巡检成功,发现异常数量:{}",LocalDateTime.now(),set.size());
return Result.success();
log.info("{} 查询视频点播巡检成功,发现异常数量:{}", LocalDateTime.now(), set.size());
return Result.success();
}
//道路统计数据与排名调用公开接口
public List<Map> roadData(){
public List<Map> roadData() {
String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}";
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
map.put("dt",this.dateTimeStr());
map.put("groupId",1);
map.put("timeType","");
map.put("dt", this.dateTimeStr());
map.put("groupId", 1);
map.put("timeType", "");
ResponseEntity<JSONObject> responseEntity;
List<Map> list = new ArrayList<>();
@ -932,7 +939,7 @@ public class MonitorService {
//启迪数据中台相关
//1.登录
public String qidiToken () {
public String qidiToken() {
String url = "http://120.221.95.13:9090/apin/authorization/oauth/token";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ=");
@ -963,32 +970,32 @@ public class MonitorService {
}
//渣土车轨迹数据,最新的
public List<Map> resCatalogApplyZTYS () {
public List<Map> resCatalogApplyZTYS() {
String token = this.qidiToken();
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
JSONObject search = new JSONObject();
search.put("opt","LIKE");
search.put("key","UPLOADTIME");
search.put("val",this.dateStr());
search.put("opt", "LIKE");
search.put("key", "UPLOADTIME");
search.put("val", this.dateStr());
// search.put("opt","EQ");
// search.put("key","SPEED");
// search.put("val","0");
map.put("json",search);
map.put("json", search);
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2?search=[{json}]";
HttpEntity<Map> httpEntity = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,map);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class, map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}",jsonArray.size());
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}", jsonArray.size());
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
} catch (Exception e) {
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage());
@ -997,26 +1004,26 @@ public class MonitorService {
}
//环卫车轨迹数据
public List<Map> resCatalogApplyHJWS () {
public List<Map> resCatalogApplyHJWS() {
String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
JSONObject search = new JSONObject();
search.put("opt","LIKE");
search.put("key","updatetime");
search.put("val",this.dateStr());
search.put("opt", "LIKE");
search.put("key", "updatetime");
search.put("val", this.dateStr());
// search.put("opt","EQ");
// search.put("key","SIMKH");
// search.put("val","13302959786");
map.put("json",search);
map.put("json", search);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class, map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
@ -1027,22 +1034,22 @@ public class MonitorService {
}
//工地信息
public List<Map> resCatalogApplyGDYS () {
public List<Map> resCatalogApplyGDYS() {
String token = this.qidiToken();
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1?search=[{json}]";
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
Map<String,Object> map = new HashMap<>();
JSONObject search = new JSONObject();
search.put("opt","LIKE");
search.put("key","updatetime");
search.put("val",this.dateStr());
Map<String, Object> map = new HashMap<>();
JSONObject search = new JSONObject();
search.put("opt", "LIKE");
search.put("key", "updatetime");
search.put("val", this.dateStr());
// search.put("opt","EQ");
// search.put("key","SSDQ");
// search.put("val","西海岸新区");
map.put("json",search);
map.put("json", search);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
@ -1059,22 +1066,22 @@ public class MonitorService {
}
//环卫车辆数据1基础
public List<Map> resCatalogApplyHJWSBase () {
public List<Map> resCatalogApplyHJWSBase() {
String token = this.qidiToken();
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]";
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
JSONObject search = new JSONObject();
// search.put("opt","LIKE");
// search.put("key","updatetime");
// search.put("val",this.dateStr());
search.put("opt","EQ");
search.put("key","SSQY");
search.put("val","胶州市");
map.put("json",search);
search.put("opt", "EQ");
search.put("key", "SSQY");
search.put("val", "胶州市");
map.put("json", search);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
@ -1091,24 +1098,24 @@ public class MonitorService {
}
//环卫车辆数据2,作业,5月20号已经把能查到的都保存到表中了(忘了保存updatetime)
public List<Map> resCatalogApplyHJWSZY () {
public List<Map> resCatalogApplyHJWSZY() {
String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1";
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
JSONObject search = new JSONObject();
// search.put("opt","LIKE");
// search.put("key","ZYRQ");
// search.put("val",this.dateStr());
map.put("json",search);
map.put("json", search);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class, map);
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
@ -1119,39 +1126,40 @@ public class MonitorService {
}
}
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception{
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception {
String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
List<Map> maps = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
JSONObject search = new JSONObject();
search.put("opt","GT");
search.put("key","updatetime");
search.put("val",updatetime);
map.put("json",search);
search.put("opt", "GT");
search.put("key", "updatetime");
search.put("val", updatetime);
map.put("json", search);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class, map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
maps = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
return maps;
}
//环卫道路明细数据
public List<Map> resCatalogApplyHJWSRoad () {
public List<Map> resCatalogApplyHJWSRoad() {
String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2";
//String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]";
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
Map<String,Object> map = new HashMap<>();
// JSONObject search = new JSONObject();
Map<String, Object> map = new HashMap<>();
// JSONObject search = new JSONObject();
// search.put("opt","LIKE");
// search.put("key","updatetime");
// search.put("val",this.dateStr());
@ -1173,16 +1181,18 @@ public class MonitorService {
return new ArrayList<>();
}
}
//获取当前日期的时间串2022-05-08 00:00:00
private String dateTimeStr(){
private String dateTimeStr() {
LocalDate localDate = LocalDate.now();
LocalDate yestDay = localDate.minusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(),yestDay.getMonth(),yestDay.getDayOfMonth(),0,0,0);
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(), yestDay.getMonth(), yestDay.getDayOfMonth(), 0, 0, 0);
return dateTime.format(formatter);
}
//获取当前日期的时间串2022-05-08
private String dateStr(){
private String dateStr() {
LocalDate localDate = LocalDate.now();
LocalDate yestDay = localDate.minusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

View File

@ -1,13 +1,10 @@
package io.renren.modules.resource.dao;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.common.dao.BaseDao;
import io.renren.modules.resource.entity.AttrEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.sql.SQLOutput;
import java.util.List;
/**
@ -20,5 +17,6 @@ import java.util.List;
public interface AttrDao extends BaseDao<AttrEntity> {
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
Integer updateAttrType(String oldName, String newName);
}

View File

@ -64,7 +64,7 @@ public class WebSocketServer {
@OnMessage
public void onMessage(Session session, String msg) {
log.info("session id: " + session.getId() + " message" + msg);
log.info("session id: " + session.getId() + "userId{} message" + msg, servers.get(session.getId()).getUserId());
}
/**

View File

@ -70,6 +70,9 @@ hisense:
qdyjj:
ipAndPort: 15.2.21.238:9015
yawei:
enable: false
##多数据源的配置需要引用renren-dynamic-datasource
#dynamic:
# datasource:

View File

@ -50,4 +50,4 @@ hisense:
url: http://devtest-security-app.hismarttv.com:8080
qdyjj:
ipAndPort: 15.2.21.238:9015
ipAndPort: 15.72.178.136:9494

View File

@ -21,14 +21,20 @@
</resultMap>
<update id="delete4Resource">
update tb_data_attr
set del_flag = 1,
UPDATE tb_data_attr
SET del_flag = 1,
update_date = now()
where 1 = 1
and data_resource_id in
WHERE 1 = 1
AND data_resource_id IN
<foreach collection="resourceIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updateAttrType">
UPDATE tb_data_attr
SET attr_type = #{newName}
WHERE attr_type = #{oldName}
</update>
</mapper>