Merge branch 'master' into docker_package
This commit is contained in:
commit
bd7e3848a4
|
@ -1,9 +1,7 @@
|
|||
package io.renren.common.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 流程流转消息通知
|
||||
*/
|
||||
|
@ -14,20 +12,16 @@ public @interface ActivitiNoticeOperation {
|
|||
|
||||
/**
|
||||
* 节点名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* 流程名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String process() default "";
|
||||
|
||||
/**
|
||||
* @return activiti 监听器类型 1:TaskListener 任务监听器; 2:ExecutionListener 执行监听器;
|
||||
* activiti 监听器类型 1:TaskListener 任务监听器; 2:ExecutionListener 执行监听器;
|
||||
*/
|
||||
int type() default 1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.renren.common.aspect;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.renren.common.annotation.ActivitiNoticeOperation;
|
||||
import io.renren.modules.notice.dto.SysNoticeDTO;
|
||||
|
@ -44,9 +43,9 @@ import java.util.concurrent.Executors;
|
|||
@Component
|
||||
public class ActivitiNoticeAspect {
|
||||
|
||||
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
|
||||
private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm * 3);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActivitiNoticeAspect.class);
|
||||
private static final Integer CPU_NUM = Runtime.getRuntime().availableProcessors();
|
||||
private static final ExecutorService EXECUTOR = Executors.newFixedThreadPool(CPU_NUM * 3);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActivitiNoticeAspect.class);
|
||||
|
||||
@Autowired
|
||||
private SysNoticeService sysNoticeService;
|
||||
|
@ -59,7 +58,7 @@ public class ActivitiNoticeAspect {
|
|||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
private Set<String> work_ = new CopyOnWriteArraySet<>();
|
||||
private Set<String> work = new CopyOnWriteArraySet<>();
|
||||
|
||||
@Value("${big_date.name}")
|
||||
private String bigDateDeptName; // 大数据局名称
|
||||
|
@ -67,28 +66,28 @@ public class ActivitiNoticeAspect {
|
|||
private String roleName; // 具备审批的角色名称
|
||||
|
||||
public ActivitiNoticeAspect() {
|
||||
logger.error("构造:ActivitiNoticeAspect");
|
||||
LOGGER.error("构造:ActivitiNoticeAspect");
|
||||
}
|
||||
|
||||
@Pointcut("@annotation(io.renren.common.annotation.ActivitiNoticeOperation)")
|
||||
public void activitiNoticePointCut() {
|
||||
logger.error("切面:ActivitiNoticeAspect");
|
||||
LOGGER.error("切面:ActivitiNoticeAspect");
|
||||
}
|
||||
|
||||
@After(value = "activitiNoticePointCut()")
|
||||
public void notice(JoinPoint joinPoint) throws NoSuchMethodException {
|
||||
logger.error("-------------------------------进入流程流转消息切面---------------------------------");
|
||||
LOGGER.error("-------------------------------进入流程流转消息切面---------------------------------");
|
||||
long beginTime = System.currentTimeMillis();
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = joinPoint.getTarget().getClass().getDeclaredMethod(signature.getName(), signature.getParameterTypes());
|
||||
final ActivitiNoticeOperation activitiNoticeOperation = method.getAnnotation(ActivitiNoticeOperation.class);
|
||||
logger.error("切面类型:" + activitiNoticeOperation.type());
|
||||
LOGGER.error("切面类型:{}", activitiNoticeOperation.type());
|
||||
switch (activitiNoticeOperation.type()) {
|
||||
case 1: {
|
||||
Arrays.asList(joinPoint.getArgs()).stream().findFirst().ifPresent(arg -> {
|
||||
Arrays.stream(joinPoint.getArgs()).findFirst().ifPresent(arg -> {
|
||||
final DelegateTask delegateTask = (DelegateTask) arg;
|
||||
final String eventName = delegateTask.getEventName();
|
||||
logger.error("任务监听器事件:" + eventName);
|
||||
LOGGER.error("任务监听器事件:{}", eventName);
|
||||
switch (eventName) {
|
||||
case TaskListener.EVENTNAME_ASSIGNMENT: // 节点被委派给某人
|
||||
assignment_notice(delegateTask, activitiNoticeOperation);
|
||||
|
@ -105,20 +104,19 @@ public class ActivitiNoticeAspect {
|
|||
Arrays.asList(joinPoint.getArgs()).stream().findFirst().ifPresent(arg -> {
|
||||
final DelegateExecution execution = (DelegateExecution) arg;
|
||||
final String eventName = execution.getEventName();
|
||||
logger.error("执行监听器事件:" + eventName);
|
||||
switch (eventName) {
|
||||
case ExecutionListener.EVENTNAME_END: // 流程完成
|
||||
end_notice(execution, activitiNoticeOperation);
|
||||
break;
|
||||
default:
|
||||
LOGGER.error("执行监听器事件:{}", eventName);
|
||||
if (ExecutionListener.EVENTNAME_END.equals(eventName)) { // 流程完成
|
||||
end_notice(execution, activitiNoticeOperation);
|
||||
}
|
||||
});
|
||||
} // 执行监听器
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime;
|
||||
logger.error("执行时长{} ms", time);
|
||||
LOGGER.error("执行时长{} ms", time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,12 +127,12 @@ public class ActivitiNoticeAspect {
|
|||
*/
|
||||
private void task_complete_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) {
|
||||
Map<String, Object> kv = delegateTask.getVariables();
|
||||
logger.error("表单:" + JSON.toJSONString(kv));
|
||||
if (work_.contains(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString())) {
|
||||
logger.error("------------出现重放------------");
|
||||
LOGGER.error("表单:" + JSON.toJSONString(kv));
|
||||
if (work.contains(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString())) {
|
||||
LOGGER.error("------------出现重放------------");
|
||||
return;
|
||||
}
|
||||
work_.add(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString());
|
||||
work.add(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString());
|
||||
String creator = null;
|
||||
if (kv.containsKey("creator")) { // 表单存在创建者
|
||||
creator = kv.get("creator").toString();
|
||||
|
@ -182,9 +180,9 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
sysNoticeService.save(dto);
|
||||
}, executor);
|
||||
}, EXECUTOR);
|
||||
} catch (Exception e) {
|
||||
logger.error("发送通知消息异常", e);
|
||||
LOGGER.error("发送通知消息异常", e);
|
||||
} finally {
|
||||
// 防止重放
|
||||
new Thread(() -> {
|
||||
|
@ -193,7 +191,7 @@ public class ActivitiNoticeAspect {
|
|||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
work_.remove(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString());
|
||||
work.remove(TaskListener.EVENTNAME_COMPLETE + kv.get("id").toString());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
@ -207,12 +205,12 @@ public class ActivitiNoticeAspect {
|
|||
*/
|
||||
private void end_notice(final DelegateExecution execution, final ActivitiNoticeOperation activitiNoticeOperation) {
|
||||
Map<String, Object> kv = execution.getVariables();
|
||||
logger.error("表单:" + JSON.toJSONString(kv));
|
||||
if (work_.contains(ExecutionListener.EVENTNAME_END + kv.get("id").toString())) {
|
||||
logger.error("------------出现重放------------");
|
||||
LOGGER.error("表单:" + JSON.toJSONString(kv));
|
||||
if (work.contains(ExecutionListener.EVENTNAME_END + kv.get("id").toString())) {
|
||||
LOGGER.error("------------出现重放------------");
|
||||
return;
|
||||
}
|
||||
work_.add(ExecutionListener.EVENTNAME_END + kv.get("id").toString());
|
||||
work.add(ExecutionListener.EVENTNAME_END + kv.get("id").toString());
|
||||
String creator = null;
|
||||
if (kv.containsKey("creator")) { // 表单存在创建者
|
||||
creator = kv.get("creator").toString();
|
||||
|
@ -262,12 +260,12 @@ public class ActivitiNoticeAspect {
|
|||
dto.setCreateDate(new Date());
|
||||
dto.setFrom("通知");
|
||||
sysNoticeService.save(dto);
|
||||
}, executor).thenRunAsync(() -> {
|
||||
logger.error("大数据局名称:" + bigDateDeptName);
|
||||
}, EXECUTOR).thenRunAsync(() -> {
|
||||
LOGGER.error("大数据局名称:" + bigDateDeptName);
|
||||
SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName);
|
||||
logger.error("deptDTOId:" + deptDTO.getId());
|
||||
LOGGER.error("deptDTOId:" + deptDTO.getId());
|
||||
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
||||
logger.error("roleDTOId:" + roleDTO.getId());
|
||||
LOGGER.error("roleDTOId:" + roleDTO.getId());
|
||||
Optional<SysUserDTO> userDTO = Optional.ofNullable(sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()));
|
||||
userDTO.ifPresent(user -> {
|
||||
SysUserDTO creatorDTO = sysUserService.get(Long.valueOf(finalCreator));
|
||||
|
@ -286,9 +284,9 @@ public class ActivitiNoticeAspect {
|
|||
dto.setFrom("通知");
|
||||
sysNoticeService.save(dto);
|
||||
});
|
||||
}, executor);
|
||||
}, EXECUTOR);
|
||||
} catch (Exception exception) {
|
||||
logger.error("发送通知消息异常", exception);
|
||||
LOGGER.error("发送通知消息异常", exception);
|
||||
} finally {
|
||||
// 防止重放
|
||||
new Thread(() -> {
|
||||
|
@ -297,7 +295,7 @@ public class ActivitiNoticeAspect {
|
|||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
work_.remove(ExecutionListener.EVENTNAME_END + kv.get("id").toString());
|
||||
work.remove(ExecutionListener.EVENTNAME_END + kv.get("id").toString());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
@ -312,12 +310,12 @@ public class ActivitiNoticeAspect {
|
|||
*/
|
||||
private void assignment_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) {
|
||||
Map<String, Object> kv = delegateTask.getVariables();
|
||||
logger.error("表单:" + JSON.toJSONString(kv));
|
||||
if (work_.contains(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString())) {
|
||||
logger.error("------------出现重放------------");
|
||||
LOGGER.error("表单:" + JSON.toJSONString(kv));
|
||||
if (work.contains(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString())) {
|
||||
LOGGER.error("------------出现重放------------");
|
||||
return;
|
||||
}
|
||||
work_.add(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString());
|
||||
work.add(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString());
|
||||
String creator = null;
|
||||
if (kv.containsKey("creator")) { // 表单存在创建者
|
||||
creator = kv.get("creator").toString();
|
||||
|
@ -332,9 +330,9 @@ public class ActivitiNoticeAspect {
|
|||
CompletableFuture.runAsync(() -> { // 发起人
|
||||
try {
|
||||
SysUserDTO assignee = sysUserService.get(Long.valueOf(delegateTask.getAssignee()));
|
||||
logger.error("审核人:" + assignee.getId());
|
||||
LOGGER.error("审核人:" + assignee.getId());
|
||||
String content = "【通知】您发起的流程 " + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核人为:\"" + assignee.getDeptName() + "\"审核负责人\"" + assignee.getRealName() + "\"";
|
||||
logger.info("通知内容:" + content);
|
||||
LOGGER.info("通知内容:" + content);
|
||||
SysNoticeDTO dto = new SysNoticeDTO();
|
||||
dto.setType(2);
|
||||
dto.setTitle("流程流转系统通知");
|
||||
|
@ -349,9 +347,9 @@ public class ActivitiNoticeAspect {
|
|||
dto.setFrom("通知");
|
||||
sysNoticeService.save(dto);
|
||||
} catch (Exception exception) {
|
||||
logger.error("通知发起人失败", exception);
|
||||
LOGGER.error("通知发起人失败", exception);
|
||||
}
|
||||
}, executor).thenRunAsync(() -> { // 审批者
|
||||
}, EXECUTOR).thenRunAsync(() -> { // 审批者
|
||||
try {
|
||||
SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator));
|
||||
String content = "【通知】" + owner.getRealName() + "发起的流程" + activitiNoticeOperation.process() + " 已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您";
|
||||
|
@ -369,16 +367,16 @@ public class ActivitiNoticeAspect {
|
|||
dto.setFrom("通知");
|
||||
sysNoticeService.save(dto);
|
||||
} catch (Exception exception) {
|
||||
logger.error("通知审批人失败", exception);
|
||||
LOGGER.error("通知审批人失败", exception);
|
||||
}
|
||||
}, executor);
|
||||
}, EXECUTOR);
|
||||
} catch (Exception e) {
|
||||
logger.error("发送通知消息异常", e);
|
||||
LOGGER.error("发送通知消息异常", e);
|
||||
} finally {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
work_.remove(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString());
|
||||
work.remove(TaskListener.EVENTNAME_ASSIGNMENT + kv.get("id").toString());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -671,7 +671,7 @@ public class Controller {
|
|||
*/
|
||||
@GetMapping("/saveOrgenization")
|
||||
public Result saveOrgenization() throws Exception{
|
||||
List<JSONObject> orgenizationByPage = monitorService.getOrgenization(new ArrayList<JSONObject>());
|
||||
List<JSONObject> orgenizationByPage = monitorService.getOrgenization(new ArrayList<JSONObject>(10000));
|
||||
List<Map> maps = JSONObject.parseArray(JSONObject.toJSONString(orgenizationByPage), Map.class);
|
||||
if(maps.size() > 0){
|
||||
List<List<Map>> lists = Lists.partition(maps,100);
|
||||
|
@ -693,20 +693,48 @@ public class Controller {
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件版的保存区域组织信息
|
||||
*/
|
||||
@GetMapping("/saveOrgenizationEvent")
|
||||
public Result saveOrgenizationEvent() throws Exception{
|
||||
monitorService.getAndSaveOrgenization();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存通道信息多线程版
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("saveChannelInfoAsync")
|
||||
public Result saveChannelInfoAsync() throws Exception{
|
||||
monitorService.saveChannelInfoAsync();
|
||||
return Result.success("成功收到指令,请耐心等待");
|
||||
monitorService.saveChannelInfoAsync();
|
||||
return Result.success();
|
||||
}
|
||||
/******************************2022/07/13 ytl修改视频资源 end********************************************/
|
||||
|
||||
/**
|
||||
* 07-25增加的判断视频资源是否在库中,
|
||||
* 以后可以删除,直接调用cameraChannelServicecheckCameraIfExists即可
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/checkCameraIfExists")
|
||||
public Result checkCameraIfExists(@RequestParam List<String> list){
|
||||
Result result = cameraChannelService.checkCameraIfExists(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
// //以下是7月26号的测试用的
|
||||
// @GetMapping("/getCameraChannelByPID")
|
||||
// public Result getCameraChannelByPID(@RequestParam String pid) throws Exception{
|
||||
// List<Map> channelInfo = monitorService.getChannelInfo(pid);
|
||||
// return Result.success(channelInfo);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/getOrganization")
|
||||
// public Result getOrganization() throws Exception{
|
||||
// List<JSONObject> orgenization = monitorService.getOrgenization(new ArrayList<>());
|
||||
// return Result.success(orgenization);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class GetAboutCameraChannelEventListener {
|
|||
//保存cache表信息到正式表
|
||||
monitorService.insertChannelCacheToCameraChannel();
|
||||
|
||||
//跟新t_region的channelcount
|
||||
//更新t_region的channelcount
|
||||
cameraOrgenMapper.updateRegionChannelCount();
|
||||
|
||||
//更新武伟达的标签表
|
||||
|
|
|
@ -39,8 +39,8 @@ public interface CameraOrgenizationMapper extends BaseDao<CameraOrganization> {
|
|||
@Select(" SELECT name FROM t_camera_organization where substring(id,5) = #{idPart} and left(id,3) = '006'")
|
||||
String getNameByidPart(@Param("idPart")String idPart);
|
||||
|
||||
@Update("UPDATE t_camera_organization SET COUNT = COUNT + 1 WHERE id = #{id}")
|
||||
void updateOrganizationCount(@Param("id") String id);
|
||||
// @Update("UPDATE t_camera_organization SET COUNT = COUNT + 1 WHERE id = #{id}")
|
||||
// void updateOrganizationCount(@Param("id") String id);
|
||||
|
||||
void batchSaveCameraChannel(List<Map> list);
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
@ -39,6 +41,7 @@ import java.awt.image.BufferedImage;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
|
@ -1137,7 +1140,7 @@ public class MonitorService {
|
|||
return Result.success(maps);
|
||||
}
|
||||
|
||||
//以此作为获取视频资源
|
||||
//以此作为获取视频资源的开始,获取地区和组织信息
|
||||
public void getAndSaveOrgenization(){
|
||||
List<JSONObject> orgenizationByPage = this.getOrgenization(new ArrayList<JSONObject>(10000));
|
||||
if(orgenizationByPage != null && orgenizationByPage.size() > 0){
|
||||
|
@ -1166,6 +1169,7 @@ public class MonitorService {
|
|||
}
|
||||
|
||||
public List<JSONObject> getOrgenization(List<JSONObject> list) {
|
||||
RestTemplate template = this.getRestTemplate();
|
||||
int count = 0;
|
||||
boolean flag = true;
|
||||
while(flag){
|
||||
|
@ -1174,21 +1178,17 @@ public class MonitorService {
|
|||
}
|
||||
count ++;
|
||||
try {
|
||||
List<JSONObject> list1 = this.getOrgenizationRoot();
|
||||
List<JSONObject> list1 = this.getOrgenizationRoot(template);
|
||||
list.addAll(list1);
|
||||
list1.forEach(a->{
|
||||
if(a.getBooleanValue("isParent")){
|
||||
getOrgenizationByParent(list,a.getString("id"));
|
||||
getOrgenizationByParent(list,a.getString("id"),template);
|
||||
}
|
||||
});
|
||||
// if(list != null && list.size() > 0){
|
||||
// cameraOrgenMapper.truncate("t_camera_organization");
|
||||
// }
|
||||
flag = false;
|
||||
return list;
|
||||
}catch (Exception e){
|
||||
System.out.println("第"+String.valueOf(count)+"次获取,错误是:");
|
||||
System.out.println(e.getMessage());
|
||||
log.error("第{}次获取视频通道组织信息失败,错误是:{}",count,e.getMessage());
|
||||
if(count >= 10){
|
||||
log.error("获取视频通道组织信息失败,失败原因:{}",e.getMessage());
|
||||
return new ArrayList<JSONObject>();
|
||||
|
@ -1206,7 +1206,7 @@ public class MonitorService {
|
|||
}
|
||||
|
||||
//获取根组织
|
||||
public List<JSONObject> getOrgenizationRoot(){
|
||||
public List<JSONObject> getOrgenizationRoot(RestTemplate restTemplate){
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
String url = monitorDomain + "/videoService/devicesManager/deviceTree?id=&nodeType=1&typeCode=01&page=1&pageSize=3000";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
@ -1221,7 +1221,7 @@ public class MonitorService {
|
|||
}
|
||||
|
||||
//组织递归根据父ID查,简化了分页
|
||||
public List<JSONObject> getOrgenizationByParent(List<JSONObject> list,String id){
|
||||
public List<JSONObject> getOrgenizationByParent(List<JSONObject> list,String id,RestTemplate restTemplate){
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("X-Subject-Token",token);
|
||||
String url;
|
||||
|
@ -1241,7 +1241,11 @@ public class MonitorService {
|
|||
list.addAll(jsonObjects);
|
||||
jsonObjects.forEach(js->{
|
||||
if(js.getBooleanValue("isParent")){
|
||||
getOrgenizationByParent(list,js.getString("id"));
|
||||
try {
|
||||
getOrgenizationByParent(list, js.getString("id"), restTemplate);
|
||||
}catch (Exception e){
|
||||
log.error("根据父id:{}获取下级组织信息失败",js.getString("id"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1260,48 +1264,48 @@ public class MonitorService {
|
|||
}
|
||||
|
||||
//保存通道信息
|
||||
public Result saveChannelInfo() throws Exception {
|
||||
List<Map> orgenList = cameraOrgenMapper.listOrgenization();
|
||||
for(Map m:orgenList){
|
||||
List<Map> cameChannels = getChannelInfo(m.get("id").toString());
|
||||
List<Map> needSave = new ArrayList<>();
|
||||
if(cameChannels.size() > 0){
|
||||
boolean flag = false;
|
||||
for(Map j:cameChannels){
|
||||
if(Integer.parseInt(j.get("nodeType").toString()) ==3){
|
||||
flag = true;
|
||||
String channelSn = j.get("channelSn").toString();
|
||||
String channelOrngin = channelSn.substring(0,6);
|
||||
String deptName = cameraOrgenMapper.getNameByidPart(channelOrngin);
|
||||
j.put("regionName",deptName);
|
||||
j.put("regionCode",channelOrngin);
|
||||
j.put("parentId",m.get("id").toString());
|
||||
j.put("nodeName","");
|
||||
needSave.add(j);
|
||||
}
|
||||
}
|
||||
if(!flag){//更新count字段
|
||||
cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
}
|
||||
}else{//更新count字段
|
||||
cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
}
|
||||
|
||||
needSave.forEach(map->setNodeName(map,map.get("parentId").toString()));
|
||||
//保存并更新count字段
|
||||
if(needSave.size() > 0){
|
||||
List<List<Map>> partition = Lists.partition(needSave, 100);
|
||||
partition.forEach(list->{
|
||||
cameraOrgenMapper.batchSaveCameraChannel(list);
|
||||
});
|
||||
cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
}
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
// public Result saveChannelInfo() throws Exception {
|
||||
// List<Map> orgenList = cameraOrgenMapper.listOrgenization();
|
||||
// for(Map m:orgenList){
|
||||
// List<Map> cameChannels = getChannelInfo(m.get("id").toString());
|
||||
// List<Map> needSave = new ArrayList<>();
|
||||
// if(cameChannels.size() > 0){
|
||||
// boolean flag = false;
|
||||
// for(Map j:cameChannels){
|
||||
// if(Integer.parseInt(j.get("nodeType").toString()) ==3){
|
||||
// flag = true;
|
||||
// String channelSn = j.get("channelSn").toString();
|
||||
// String channelOrngin = channelSn.substring(0,6);
|
||||
// String deptName = cameraOrgenMapper.getNameByidPart(channelOrngin);
|
||||
// j.put("regionName",deptName);
|
||||
// j.put("regionCode",channelOrngin);
|
||||
// j.put("parentId",m.get("id").toString());
|
||||
// j.put("nodeName","");
|
||||
// needSave.add(j);
|
||||
// }
|
||||
// }
|
||||
// if(!flag){//更新count字段
|
||||
// cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
// }
|
||||
// }else{//更新count字段
|
||||
// cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
// }
|
||||
//
|
||||
// needSave.forEach(map->setNodeName(map,map.get("parentId").toString()));
|
||||
// //保存并更新count字段
|
||||
// if(needSave.size() > 0){
|
||||
// List<List<Map>> partition = Lists.partition(needSave, 100);
|
||||
// partition.forEach(list->{
|
||||
// cameraOrgenMapper.batchSaveCameraChannel(list);
|
||||
// });
|
||||
// cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
// }
|
||||
// }
|
||||
// return Result.success();
|
||||
// }
|
||||
|
||||
//根据组织id获取通道信息
|
||||
public List<Map> getChannelInfo(String orgenId) throws Exception{
|
||||
public List<Map> getChannelInfo(String orgenId,RestTemplate restTemplate) throws Exception{
|
||||
String url = monitorDomain +"/videoService/devicesManager/deviceTree?nodeType=1&typeCode=01;0;ALL;ALL&page=1&pageSize=3000&id="+orgenId;
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("X-Subject-Token",token);
|
||||
|
@ -1314,7 +1318,7 @@ public class MonitorService {
|
|||
if(re.getJSONArray("results") != null){
|
||||
results = re.getJSONArray("results").toJavaList(Map.class);
|
||||
}else{
|
||||
log.info("根据地区id:{}获取摄像头信息失败,失败原因:{}",orgenId,re.toJSONString());
|
||||
log.info("根据组织id:{}获取摄像头信息失败,失败原因:{}",orgenId,re.toJSONString());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
@ -1331,8 +1335,8 @@ public class MonitorService {
|
|||
}
|
||||
|
||||
//2、获取视频通道信息并保存,多线程版
|
||||
//@Async
|
||||
public void saveChannelInfoAsync() throws Exception {
|
||||
RestTemplate restTemplate = this.getRestTemplate();
|
||||
AtomicInteger faulseCount = new AtomicInteger();//失败的次数
|
||||
//1-清空t_camera_channel
|
||||
cameraOrgenMapper.truncate("t_camera_channel_cache");
|
||||
|
@ -1360,13 +1364,13 @@ public class MonitorService {
|
|||
//4-根据地区id去查询视频通道信息
|
||||
List<Map> cameraChannels = new ArrayList<>();
|
||||
try {
|
||||
cameraChannels = getChannelInfo(m.get("id").toString());
|
||||
cameraChannels = getChannelInfo(m.get("id").toString(),restTemplate);
|
||||
|
||||
}catch (Exception e){
|
||||
log.info("根据地区id:{}查询视频通道失败,这是第{}次重试",m.get("id").toString(),tryCount);
|
||||
log.info("根据组织id:{}查询视频通道失败,这是第{}次重试",m.get("id").toString(),tryCount);
|
||||
if(tryCount >= 10){
|
||||
faulseCount.incrementAndGet();
|
||||
log.error("根据地区id:{},查询视频通道失败,超出重试次数",m.get("id").toString());
|
||||
log.error("根据组织id:{},查询视频通道失败,超出重试次数,将去正式表中查询",m.get("id").toString());
|
||||
//去t_camera_channel查询相关信息并保存
|
||||
cameraChannels = cameraChannelMapper.selectCameraChannelByPid(m.get("id").toString());
|
||||
if(cameraChannels.size() > 0){
|
||||
|
@ -1374,14 +1378,14 @@ public class MonitorService {
|
|||
for(List<Map> ll:channelList){
|
||||
cameraChannelMapper.batchSaveCameraChannel(ll);
|
||||
}
|
||||
} else {
|
||||
log.error("根据组织id:{},从正式表中查询视频通道失败,不存在该部门数据",m.get("id").toString());
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//5-保存视频通道信息
|
||||
batchSaveChannelInfos(cameraChannels,m.get("id").toString());
|
||||
//6-更新地区表的count
|
||||
//cameraOrgenMapper.updateOrganizationCount(m.get("id").toString());
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
|
@ -1399,12 +1403,6 @@ public class MonitorService {
|
|||
|
||||
//发布事件
|
||||
publisher.publishEvent(new SaveCameraChannelEndEvent(this,true));
|
||||
//以下方法将在事件后处理
|
||||
//将cache表数据保存到相应的主表中
|
||||
//insertChannelCacheToCameraChannel);
|
||||
//8-同步武伟达的t_channel_mtm_label数据
|
||||
//synchronizeMtmLabel();
|
||||
|
||||
}
|
||||
|
||||
//同步武伟达的t_channel_mtm_label数据
|
||||
|
@ -1468,9 +1466,6 @@ public class MonitorService {
|
|||
}
|
||||
}
|
||||
}
|
||||
// else{//更新count字段
|
||||
// cameraOrgenMapper.updateOrganizationCount(parentId);
|
||||
// }
|
||||
|
||||
//修改nodeName
|
||||
needSave.forEach(map->setNodeName(map,map.get("parentId").toString()));
|
||||
|
@ -1480,13 +1475,12 @@ public class MonitorService {
|
|||
partition.forEach(l->{
|
||||
cameraOrgenMapper.batchSaveCameraChannel(l);
|
||||
});
|
||||
//cameraOrgenMapper.updateOrganizationCount(parentId);
|
||||
}
|
||||
}
|
||||
|
||||
//更新完通道信息后,查询地区下通道的数量并更新到地区表中
|
||||
//更新完通道信息后,查询组织下通道的数量并更新到组织表中
|
||||
public void editChannelCount() throws Exception{
|
||||
//1-更新地区表中的每个地区下channelCount
|
||||
//更新地区表中的每个地区下channelCount
|
||||
List<Map> maps = cameraOrgenMapper.selectAllSubOrganizationMap();
|
||||
if(maps.size() > 0){
|
||||
for(int i=0;i< maps.size();i++){
|
||||
|
@ -1496,8 +1490,6 @@ public class MonitorService {
|
|||
cameraOrgenMapper.editChannelCount(count,orgaid);
|
||||
};
|
||||
}
|
||||
//2-更新市区表t_region表中的channelCount
|
||||
//cameraOrgenMapper.updateRegionChannelCount();
|
||||
}
|
||||
|
||||
public List<Map> listChildOrgenIds(String id){
|
||||
|
@ -1511,17 +1503,17 @@ public class MonitorService {
|
|||
return childs;
|
||||
}
|
||||
|
||||
public void test(){
|
||||
//保存cache表信息到正式表
|
||||
insertChannelCacheToCameraChannel();
|
||||
|
||||
cameraOrgenMapper.updateRegionChannelCount();
|
||||
|
||||
//更新武伟达的标签表
|
||||
//synchronizeMtmLabel();
|
||||
|
||||
public RestTemplate getRestTemplate(){
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(20000);//单位为ms
|
||||
factory.setConnectTimeout(3000);//单位为ms
|
||||
factory.setOutputStreaming(false);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate(factory);
|
||||
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(Charset.forName("UTF-8")));
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package io.renren.modules.monitor.task;
|
||||
|
||||
import io.renren.modules.job.task.ITask;
|
||||
import io.renren.modules.monitor.service.MonitorService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 定时获取视频资源的部门信息
|
||||
* @author ytl
|
||||
* @Date 2022/7/29 9:45
|
||||
**/
|
||||
|
||||
@Component("getAndSaveOrgenizationTask")
|
||||
public class GetAndSaveOrgenizationTask implements ITask {
|
||||
@Autowired
|
||||
private MonitorService monitorService;
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
monitorService.getAndSaveOrgenization();
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,6 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 通知管理
|
||||
*
|
||||
|
@ -50,10 +49,10 @@ public class SysNoticeController {
|
|||
@GetMapping("page")
|
||||
@ApiOperation("分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String")
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String")
|
||||
})
|
||||
// @RequiresPermissions("sys:notice:all")
|
||||
public Result<PageData<SysNoticeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
|
@ -165,7 +164,7 @@ public class SysNoticeController {
|
|||
@DeleteMapping
|
||||
@ApiOperation("删除")
|
||||
@LogOperation("删除")
|
||||
// @RequiresPermissions("sys:notice:all")
|
||||
//@RequiresPermissions("sys:notice:all")
|
||||
public Result delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
|
|
@ -237,7 +237,7 @@ public class ResourceController {
|
|||
//@RequiresPermissions("resource:resource:save")
|
||||
public Result save(@RequestBody ResourceDTO dto, @RequestParam String source) {
|
||||
// 效验数据
|
||||
logger.info("source:" + source);
|
||||
logger.info("source:{}", source);
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
if ("f".equals(source)) {
|
||||
dto.setDelFlag(2); // 来自前端页面 走审批流程
|
||||
|
@ -257,7 +257,7 @@ public class ResourceController {
|
|||
public Result importResource(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) {
|
||||
List<Map<String, Object>> dept =
|
||||
jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept");
|
||||
logger.info("上传文件:" + uploadFile.getOriginalFilename());
|
||||
logger.info("上传文件:{}" , uploadFile.getOriginalFilename());
|
||||
String format = sdf.format(new Date());
|
||||
File folder = new File(uploadPath + "upload" + File.separator + format);
|
||||
logger.info(folder.getPath());
|
||||
|
@ -266,30 +266,21 @@ public class ResourceController {
|
|||
}
|
||||
// 对上传的文件重命名,避免文件重名
|
||||
String oldName = uploadFile.getOriginalFilename();
|
||||
String newName = UUID.randomUUID().toString()
|
||||
+ oldName.substring(oldName.lastIndexOf("."));
|
||||
String newName = UUID.randomUUID() + oldName.substring(oldName.lastIndexOf("."));
|
||||
try {
|
||||
// 文件保存
|
||||
File file = new File(folder, newName);
|
||||
logger.info(file.getPath());
|
||||
uploadFile.transferTo(file);
|
||||
Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
|
||||
CompletableFuture.runAsync(() -> {
|
||||
EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync();
|
||||
}, executor);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync();
|
||||
}, executor);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync();
|
||||
}, executor);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync();
|
||||
}, executor);
|
||||
CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync(), executor);
|
||||
CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync(), executor);
|
||||
CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync(), executor);
|
||||
CompletableFuture.runAsync(() -> EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync(), executor);
|
||||
} catch (IOException e) {
|
||||
return new Result<String>().error(e.getMessage());
|
||||
}
|
||||
return new Result().ok(LocalDateTime.now().toString());
|
||||
return new Result<String>().ok(LocalDateTime.now().toString());
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
|
@ -319,7 +310,7 @@ public class ResourceController {
|
|||
@LogOperation("资源转发")
|
||||
public Result ZywMessage() {
|
||||
String url = "http://15.72.158.81/zyjk/ZywMessage.asmx";
|
||||
String parame = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||
String param = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
||||
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
||||
" <soap:Body>\n" +
|
||||
" </soap:Body>\n" +
|
||||
|
@ -327,11 +318,11 @@ public class ResourceController {
|
|||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("SOAPAction", "http://tempuri.org/ZywMessagePort");
|
||||
requestHeaders.setContentType(MediaType.TEXT_XML);
|
||||
HttpEntity<String> requestEntity = new HttpEntity(parame, requestHeaders);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(param, requestHeaders);
|
||||
try {
|
||||
String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody();
|
||||
String json = body.substring(body.indexOf("{"), body.indexOf("}") + 1);
|
||||
HashMap map = JSONObject.parseObject(json, HashMap.class);
|
||||
HashMap map = JSON.parseObject(json, HashMap.class);
|
||||
return new Result().ok(map);
|
||||
} catch (Exception e) {
|
||||
return new Result().ok(new HashMap<String, Object>() {{
|
||||
|
@ -373,13 +364,13 @@ public class ResourceController {
|
|||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("SOAPAction", "http://tempuri.org/ZWCJ_mainPort");
|
||||
requestHeaders.setContentType(new MediaType("text", "xml", Charset.forName("utf-8")));
|
||||
HttpEntity<String> requestEntity = new HttpEntity(parame, requestHeaders);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(parame, requestHeaders);
|
||||
try {
|
||||
String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody();
|
||||
String startTag = "<ZWCJ_mainPortResult>";
|
||||
String endTag = "</ZWCJ_mainPortResult>";
|
||||
String json = body.substring(body.indexOf(startTag) + startTag.length(), body.indexOf(endTag));
|
||||
HashMap result = JSONObject.parseObject(json, HashMap.class);
|
||||
HashMap result = JSON.parseObject(json, HashMap.class);
|
||||
|
||||
List<Map> rows = (List<Map>) result.get("data");
|
||||
List<Object> objects = rows.stream()
|
||||
|
@ -521,8 +512,8 @@ public class ResourceController {
|
|||
@GetMapping("/selectTotalByDept")
|
||||
@ApiOperation("按照资源类型统计本部门发布的资源")
|
||||
@LogOperation("按照资源类型统计本部门发布的资源")
|
||||
public Result selectTotalByDept() {
|
||||
return new Result().ok(resourceService.selectTotalByDept());
|
||||
public Result<Map<String, Object>> selectTotalByDept() {
|
||||
return new Result<Map<String, Object>>().ok(resourceService.selectTotalByDept());
|
||||
}
|
||||
|
||||
@GetMapping("/getApplyByDept")
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.renren.modules.resource.dto.ResourceDTO;
|
|||
import io.renren.modules.resource.entity.AttrEntity;
|
||||
import io.renren.modules.resource.entity.ResourceEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -111,7 +112,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
|||
|
||||
Object getByDept(Map<String, Object> params);
|
||||
|
||||
Object selectTotalByDept();
|
||||
HashMap<String, Object> selectTotalByDept();
|
||||
|
||||
Object getApplyByDept(Map<String, Object> params);
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Service
|
||||
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
||||
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
|
||||
private static final ExecutorService executor = Executors.newWorkStealingPool(cpuNUm * 3);
|
||||
private static final Integer CPU_NUM = Runtime.getRuntime().availableProcessors();
|
||||
private static final ExecutorService executor = Executors.newWorkStealingPool(CPU_NUM * 3);
|
||||
|
||||
/**
|
||||
* 公共http客户端
|
||||
|
@ -90,14 +90,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
private static final OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.connectionPool(new ConnectionPool(cpuNUm * 2, 2, TimeUnit.MINUTES))
|
||||
.connectionPool(new ConnectionPool(CPU_NUM * 2, 2, TimeUnit.MINUTES))
|
||||
.retryOnConnectionFailure(false)
|
||||
.build();
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
|
||||
|
||||
private static final String selectDeptListKey = "selectDeptList";
|
||||
private static final String selectDTOPageSpecilTotalKey = "selectDTOPageSpecilTotal";
|
||||
private static final String SELECT_DEPT_LIST_KEY = "selectDeptList";
|
||||
private static final String SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY = "selectDTOPageSpecilTotal";
|
||||
|
||||
@Value("${system.startDay}")
|
||||
private String systemDay;
|
||||
|
@ -201,6 +201,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
case "creator":
|
||||
wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
if (params.containsKey("selectType") && "1".equals(params.get("selectType").toString())) { // 创建者查询时
|
||||
|
@ -218,7 +220,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
@CacheEvict(cacheNames = {selectDeptListKey, selectDTOPageSpecilTotalKey}, allEntries = true)
|
||||
@CacheEvict(cacheNames = {SELECT_DEPT_LIST_KEY, SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY}, allEntries = true)
|
||||
public void insertWithAttrs(ResourceDTO dto) {
|
||||
ResourceEntity resourceEntity = new ResourceEntity();
|
||||
BeanUtils.copyProperties(dto, resourceEntity);
|
||||
|
@ -282,7 +284,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
@CacheEvict(cacheNames = {selectDeptListKey, selectDTOPageSpecilTotalKey}, allEntries = true)
|
||||
@CacheEvict(cacheNames = {SELECT_DEPT_LIST_KEY, SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY}, allEntries = true)
|
||||
public void createMixAbility(ResourceDTO dto) {
|
||||
ResourceEntity resourceEntity = new ResourceEntity();
|
||||
BeanUtils.copyProperties(dto, resourceEntity);
|
||||
|
@ -326,7 +328,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
@CacheEvict(cacheNames = {selectDeptListKey, selectDTOPageSpecilTotalKey}, allEntries = true)
|
||||
@CacheEvict(cacheNames = {SELECT_DEPT_LIST_KEY, SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY}, allEntries = true)
|
||||
public void deleteWithAttrs(JSONObject jsonObject) {
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("ids");
|
||||
List<Long> idList = jsonArray.toJavaList(Long.class);
|
||||
|
@ -340,7 +342,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
@CacheEvict(cacheNames = {selectDeptListKey, selectDTOPageSpecilTotalKey}, allEntries = true)
|
||||
@CacheEvict(cacheNames = {SELECT_DEPT_LIST_KEY, SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY}, allEntries = true)
|
||||
public void updateWithAttrs(ResourceDTO dto) {
|
||||
ResourceEntity resourceEntity = new ResourceEntity();
|
||||
BeanUtils.copyProperties(dto, resourceEntity);
|
||||
|
@ -451,9 +453,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
/**
|
||||
* 从本库内查询
|
||||
*
|
||||
* @param resultPage
|
||||
* @return
|
||||
*/
|
||||
private Page<ResourceDTO> common(Page<ResourceDTO> resultPage, List<Map> selectDTOPageSpecilTotal, ResourceDTO resourceDTO, String orderField, String orderType, Integer pageNum, Integer pageSize) {
|
||||
if (resourceDTO.getInfoList().isEmpty()) {
|
||||
|
@ -533,15 +532,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
public Object selectTotal() {
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
List<Map> re = resourceDao.selectTypeCount(null);
|
||||
/*//2022-07-05,ytl修改 start
|
||||
re.removeIf(r -> {
|
||||
return org.apache.commons.lang3.StringUtils.equals(r.get("type").toString(), "基础设施");
|
||||
});
|
||||
//2022-07-05,ytl修改 end*/
|
||||
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
|
||||
case TSINGTAO_XHA: { // 青岛西海岸
|
||||
CompletableFuture allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
|
||||
List<Long> result_ = new CopyOnWriteArrayList<>();
|
||||
List<Long> result = new CopyOnWriteArrayList<>();
|
||||
CompletableFuture cloud =
|
||||
CompletableFuture.runAsync(() -> { // 云脑专网
|
||||
String url = tsingtao_xhaProperties.getCloudcam();
|
||||
|
@ -551,7 +545,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
if (response.isSuccessful()) {
|
||||
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||
if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) {
|
||||
result_.add(jsonObject.getLongValue("body"));
|
||||
result.add(jsonObject.getLongValue("body"));
|
||||
}
|
||||
} else {
|
||||
logger.error("青岛西海岸获取失败");
|
||||
|
@ -568,11 +562,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
try (Response response = client.newCall(request).execute()) {
|
||||
if (response.isSuccessful()) {
|
||||
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||
//if (jsonObject.containsKey("data")) {
|
||||
// result_.add(jsonObject.getJSONObject("data").getLongValue("total"));
|
||||
//}
|
||||
if (jsonObject.containsKey("errorNo") && jsonObject.getLongValue("errorNo") == 200) {
|
||||
result_.add(jsonObject.getLongValue("body"));
|
||||
result.add(jsonObject.getLongValue("body"));
|
||||
}
|
||||
} else {
|
||||
logger.error("青岛西海岸获取失败");
|
||||
|
@ -583,16 +574,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}, executor);
|
||||
CompletableFuture all = CompletableFuture.allOf(cloud, local);
|
||||
all.join();
|
||||
return result_.stream().filter(Objects::nonNull).findAny().orElse(0l);
|
||||
}).thenAccept(sum -> {
|
||||
re.add(new HashMap<String, Object>() {
|
||||
{
|
||||
put("count", sum + "");
|
||||
put("type", "基础设施");
|
||||
}
|
||||
});
|
||||
});
|
||||
Long total = 0L;
|
||||
return result.stream().filter(Objects::nonNull).findAny().orElse(0L);
|
||||
}).thenAccept(sum -> re.add(new HashMap<String, Object>() {
|
||||
{
|
||||
put("count", sum + "");
|
||||
put("type", "基础设施");
|
||||
}
|
||||
}));
|
||||
Long total;
|
||||
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
@ -642,6 +631,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
List<String> temp = new ArrayList<>();
|
||||
re.forEach(map -> temp.add(map.get("type").toString()));
|
||||
|
@ -730,13 +721,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
if (page.getRecords().size() < 9) {
|
||||
Page<ResourceDTO> resultPage = (Page<ResourceDTO>) this.selectMostPopular(object);
|
||||
do {
|
||||
resultPage.getRecords().forEach(p->{
|
||||
resultPage.getRecords().forEach(p -> {
|
||||
//如果集合中不存在,则进行添加
|
||||
if (!page.getRecords().contains(p)){
|
||||
if (!page.getRecords().contains(p)) {
|
||||
page.getRecords().add(p);
|
||||
}
|
||||
});
|
||||
}while (page.getRecords().size() < 9);
|
||||
} while (page.getRecords().size() < 9);
|
||||
//for (int i = 0; page.getRecords().size() < 9; i++) {
|
||||
// for (int j = 0; j < page.getRecords().size(); j++) {
|
||||
// if (!page.getRecords().get(j).getId().equals(resultPage.getRecords().get(i).getId())) {
|
||||
|
@ -763,7 +754,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = selectDeptListKey, key = "#p1")
|
||||
@Cacheable(value = SELECT_DEPT_LIST_KEY, key = "#p1")
|
||||
public Object selectDeptList(JSONObject jsonObject, String type) {
|
||||
List<Map> resultList = new CopyOnWriteArrayList<>();
|
||||
HashMap<String, Object> resourceMap = new HashMap<>();
|
||||
|
@ -1054,7 +1045,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = selectDTOPageSpecilTotalKey, key = "#p0")
|
||||
@Cacheable(value = SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY, key = "#p0")
|
||||
public List<Map> selectDTOPageSpecilTotal(ResourceDTO resourceDTO) {
|
||||
return resourceDao.selectDTOPageSpecilTotal(resourceDTO);
|
||||
}
|
||||
|
@ -1126,12 +1117,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
* 同步知识库
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = {selectDeptListKey, selectDTOPageSpecilTotalKey}, allEntries = true)
|
||||
@CacheEvict(cacheNames = {SELECT_DEPT_LIST_KEY, SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY}, allEntries = true)
|
||||
public void KnowledgeBase() {
|
||||
final List<String> knowledgeUUID = jdbcTemplate.queryForList("SELECT note1 FROM tb_data_resource WHERE type ='知识库' AND note1 IS NOT NULL FOR UPDATE;", String.class).stream().distinct().collect(Collectors.toList());
|
||||
final int pageSize = cpuNUm * 10;
|
||||
final int pageSize = CPU_NUM * 10;
|
||||
Arrays.stream(catalogIds).map(index -> {
|
||||
logger.info("处理:" + index);
|
||||
logger.info("处理:{}", index);
|
||||
CopyOnWriteArrayList<CompletableFuture> task = new CopyOnWriteArrayList<>();
|
||||
AtomicBoolean end = new AtomicBoolean(true);
|
||||
AtomicInteger pageIndex = new AtomicInteger(1);
|
||||
|
@ -1139,33 +1130,39 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
do {
|
||||
final long timestamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
|
||||
int page = pageIndex.getAndIncrement();
|
||||
logger.info("处理:" + index + " 分页{}", page);
|
||||
logger.info("处理:{}分页{}", index, page);
|
||||
task.add(CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
logger.info("分页任务处理:" + index + " 分页{} 时间 -->" + timestamp, page);
|
||||
logger.info("分页任务处理:{}分页{} 时间--> {}", index, page, timestamp);
|
||||
JSONObject bizContentParam = new JSONObject();
|
||||
bizContentParam.put("appkey", appKey);
|
||||
bizContentParam.put("catalogId", index);
|
||||
bizContentParam.put("pageIndex", page);
|
||||
bizContentParam.put("pageSize", pageSize);
|
||||
String bizContent_ = bizContentParam.toJSONString();
|
||||
logger.info("biz_content参数:{}", bizContent_);
|
||||
String bizContent = bizContentParam.toJSONString();
|
||||
logger.info("biz_content参数:{}", bizContent);
|
||||
// 通过FormBody对象构建Builder来添加表单参数
|
||||
FormBody.Builder signFormBody = new FormBody.Builder().add("app_id", appId).add("interface_id", methodId).add("version", version).add("timestamp", String.valueOf(timestamp)).add("origin", origin).add("charset", charset).add("biz_content", bizContent_);
|
||||
logger.info(index + "分页{}对接知识库数据请求参数:" + signFormBody.build().contentType().toString(), page);
|
||||
FormBody.Builder signFormBody = new FormBody.Builder().add("app_id", appId)
|
||||
.add("interface_id", methodId).
|
||||
add("version", version).
|
||||
add("timestamp", String.valueOf(timestamp)).
|
||||
add("origin", origin).
|
||||
add("charset", charset).
|
||||
add("biz_content", bizContent);
|
||||
logger.info("{}分页{}对接知识库数据请求参数:{}", index, page, signFormBody.build().contentType().toString());
|
||||
|
||||
Request signRequest = new Request.Builder().url(sign).post(signFormBody.build()).build();
|
||||
Response signResponse = client.newCall(signRequest).execute();
|
||||
String signResult = signResponse.body().string();
|
||||
logger.info("{}分页signResult数据:" + signResult, page);
|
||||
logger.info("{}分页signResult数据:{}", page, signResult);
|
||||
JSONObject signJsonObject = JSON.parseObject(signResult);
|
||||
if (!signJsonObject.containsKey("data")) {
|
||||
logger.info("获取sign异常:" + signResult);
|
||||
logger.info("获取sign异常:{}", signResult);
|
||||
end.set(false);
|
||||
throw new RuntimeException("获取sign异常");
|
||||
}
|
||||
if (signJsonObject.get("data") == null) {
|
||||
logger.info("获取sign异常:" + signResult);
|
||||
logger.info("获取sign异常:{}", signResult);
|
||||
end.set(false);
|
||||
throw new RuntimeException("获取sign异常");
|
||||
}
|
||||
|
@ -1247,7 +1244,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
infoList.add(attrEntity);
|
||||
dto.setInfoList(infoList);
|
||||
this.insertWithAttrs(dto);
|
||||
logger.info("插入:" + dto.getName());
|
||||
logger.info("插入:{}", dto.getName());
|
||||
});
|
||||
}, executor));
|
||||
try {
|
||||
|
@ -1431,12 +1428,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
@Override
|
||||
public PageData<Map<String, Object>> resourceInfrastructureDetails(Map<String, Object> params) {
|
||||
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
|
||||
List<Map<String, Object>> result;
|
||||
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
|
||||
Integer pageSize = Integer.parseInt(params.get("limit").toString());
|
||||
Object[] pas = {params.get("id"), params.get("id")};
|
||||
|
||||
List<Map<String, Object>> result2 = new ArrayList<>();
|
||||
List<Map<String, Object>> result2;
|
||||
if (Long.parseLong(params.get("id").toString()) == 0) {
|
||||
result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
|
||||
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
|
||||
|
@ -1452,11 +1449,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
"ORDER BY a.dept_id,b.name\n", pas);
|
||||
}
|
||||
|
||||
if (result2.size() > 0) {
|
||||
if (!result2.isEmpty()) {
|
||||
List<List<Map<String, Object>>> partition = Lists.partition(result2, pageSize);
|
||||
result.addAll(partition.get(page));
|
||||
result = new CopyOnWriteArrayList<>(partition.get(page));
|
||||
} else {
|
||||
return new PageData<>(result2, result2.size());
|
||||
return new PageData<>(result2, 0);
|
||||
}
|
||||
|
||||
CompletableFuture<Void> resourceCollectionNum01 = CompletableFuture.runAsync(() -> {//被申请数量 resourceCarNum
|
||||
|
@ -1483,8 +1480,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
CompletableFuture<Void> all = CompletableFuture.allOf(resourceCollectionNum01, resourceCollectionNum02, resourceCollectionNum03);
|
||||
all.join();
|
||||
|
||||
PageData<Map<String, Object>> pageData = new PageData<>(result, result2.size());
|
||||
return pageData;
|
||||
return new PageData<>(result, result2.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1494,7 +1490,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
Integer pageSize = Integer.parseInt(params.get("limit").toString());
|
||||
Object[] pas = {params.get("id"), params.get("id")};
|
||||
|
||||
List<Map<String, Object>> result2 = new ArrayList<>();
|
||||
List<Map<String, Object>> result2;
|
||||
if (Long.parseLong(params.get("id").toString()) == 0) {
|
||||
result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
|
||||
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
|
||||
|
@ -1511,7 +1507,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
|
||||
|
||||
if (result2.size() > 0) {
|
||||
if (!result2.isEmpty()) {
|
||||
List<List<Map<String, Object>>> partition = Lists.partition(result2, pageSize);
|
||||
result.addAll(partition.get(page));
|
||||
} else {
|
||||
|
@ -1542,13 +1538,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
CompletableFuture<Void> all = CompletableFuture.allOf(resourceCarNum, resourceBrowseNum, resourceCollectionNum);
|
||||
all.join();
|
||||
|
||||
PageData<Map<String, Object>> pageData = new PageData<>(result, result2.size());
|
||||
return pageData;
|
||||
return new PageData<>(result, result2.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<Map<String, Object>> resourceKnowledgeDetails(Map<String, Object> params) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<Map<String, Object>> result;
|
||||
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
|
||||
Integer pageSize = Integer.parseInt(params.get("limit").toString());
|
||||
Object[] pas = {params.get("id"), params.get("id")};
|
||||
|
@ -1571,100 +1566,77 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
|
||||
List<List<Map<String, Object>>> partition = Lists.partition(result, pageSize);
|
||||
if (result.size() > 0) {
|
||||
PageData<Map<String, Object>> pageData = new PageData<>(partition.get(page), result.size());
|
||||
return pageData;
|
||||
if (!result.isEmpty()) {
|
||||
return new PageData<>(partition.get(page), result.size());
|
||||
} else {
|
||||
return new PageData<>(result, result.size());
|
||||
return new PageData<>(result, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<Map<String, Object>> resourceBusinessUseDetails(Map<String, Object> params) {
|
||||
List<Map<String, Object>> maps = new CopyOnWriteArrayList<>();
|
||||
List<Map<String, Object>> maps;
|
||||
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
|
||||
Integer pageSize = Integer.parseInt(params.get("limit").toString());
|
||||
Object[] ps = {params.get("id"), params.get("id")};
|
||||
//获取部门列表
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
List<Map<String, Object>> list;
|
||||
if (Long.parseLong(params.get("id").toString()) == 0) {
|
||||
list = jdbcTemplate.queryForList("SELECT id as deptId,name AS deptName FROM sys_dept");
|
||||
list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept");
|
||||
} else {
|
||||
list = jdbcTemplate.queryForList("SELECT id as deptId,name AS deptName FROM sys_dept WHERE id = ? OR INSTR(pids,?)", ps);
|
||||
list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept WHERE id = ? OR INSTR(pids,?)", ps);
|
||||
}
|
||||
|
||||
if (list.size() > 0) {
|
||||
if (!list.isEmpty()) {
|
||||
List<List<Map<String, Object>>> partition = Lists.partition(list, pageSize);
|
||||
maps.addAll(partition.get(page));
|
||||
maps = new CopyOnWriteArrayList<>(partition.get(page));
|
||||
} else {
|
||||
return new PageData<>(list, list.size());
|
||||
return new PageData<>(list, 0);
|
||||
}
|
||||
|
||||
Map<String, Object> paraMap = new ConcurrentHashMap<>();
|
||||
paraMap.put("resourceType", params.get("resourceType"));
|
||||
//分别根据部门获取组件使用总数和调用数
|
||||
//申请数
|
||||
// CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> {
|
||||
// maps.forEach(m -> {
|
||||
// paraMap.put("id", m.get("deptId"));
|
||||
// Map<String, Object> maps1 = new HashMap<>();
|
||||
// maps1 = baseDao.assemblyCarByDept(paraMap);
|
||||
// if (maps1 == null) {
|
||||
// m.put("resourceCarNum", 0);
|
||||
// } else {
|
||||
// m.put("resourceCarNum", maps1.get("carNum") == null ? 0 : maps1.get("carNum"));
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
//本部门的应用关联的组件数量
|
||||
CompletableFuture<Void> voidCompletableFuture02 = CompletableFuture.runAsync(() -> {
|
||||
maps.forEach(m -> {
|
||||
paraMap.put("id", m.get("deptId"));
|
||||
Map<String, Object> maps2 = new HashMap<>();
|
||||
maps2 = baseDao.assemblyUseByDept(paraMap);
|
||||
if (maps2 == null) {
|
||||
m.put("resourceUseNum", 0);
|
||||
} else {
|
||||
m.put("resourceUseNum", maps2.get("useNum") == null ? 0 : maps2.get("useNum"));
|
||||
}
|
||||
});
|
||||
}, executor);
|
||||
CompletableFuture<Void> voidCompletableFuture02 = CompletableFuture.runAsync(() -> maps.forEach(m -> {
|
||||
paraMap.put("id", m.get("deptId"));
|
||||
Map<String, Object> maps2 = new HashMap<>();
|
||||
maps2 = baseDao.assemblyUseByDept(paraMap);
|
||||
if (maps2 == null) {
|
||||
m.put("resourceUseNum", 0);
|
||||
} else {
|
||||
m.put("resourceUseNum", maps2.get("useNum") == null ? 0 : maps2.get("useNum"));
|
||||
}
|
||||
}), executor);
|
||||
//还缺少组件调用数,这先用假数据代替
|
||||
CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> {
|
||||
maps.forEach(m -> {
|
||||
m.put("resourceCallNum", 0);
|
||||
});
|
||||
}, executor);
|
||||
CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> maps.forEach(m -> m.put("resourceCallNum", 0)), executor);
|
||||
|
||||
CompletableFuture<Void> all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02);
|
||||
all.join();
|
||||
|
||||
PageData<Map<String, Object>> pageData = new PageData<>(maps, list.size());
|
||||
return pageData;
|
||||
return new PageData<>(maps, list.size());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageData<Map<String, Object>> resourceDatasUseDetails(Map<String, Object> params) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<Map<String, Object>> result;
|
||||
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
|
||||
Integer pageSize = Integer.parseInt(params.get("limit").toString());
|
||||
|
||||
//查询部门列表
|
||||
Object[] ps = {params.get("id"), params.get("id")};
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
List<Map<String, Object>> list;
|
||||
if (Long.parseLong(params.get("id").toString()) == 0) {
|
||||
list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept ");
|
||||
} else {
|
||||
list = jdbcTemplate.queryForList("SELECT id AS deptId,name AS deptName FROM sys_dept WHERE id = ? OR INSTR(pids,?) ", ps);
|
||||
}
|
||||
|
||||
if (list.size() > 0) {
|
||||
if (!list.isEmpty()) {
|
||||
List<List<Map<String, Object>>> partition = Lists.partition(list, pageSize);
|
||||
result.addAll(partition.get(page));
|
||||
result = new ArrayList<>(partition.get(page));
|
||||
} else {
|
||||
return new PageData<>(list, list.size());
|
||||
return new PageData<>(list, 0);
|
||||
}
|
||||
ConcurrentHashMap map = new ConcurrentHashMap();
|
||||
map.put("resourceType", params.get("resourceType"));
|
||||
|
@ -1679,13 +1651,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
});
|
||||
|
||||
PageData<Map<String, Object>> pageData = new PageData<>(result, list.size());
|
||||
return pageData;
|
||||
return new PageData<>(result, list.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> assemblerCarDetail(Map<String, Object> params) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<Map<String, Object>> result;
|
||||
Object[] ps = {params.get("resourceType"), params.get("id"), (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()), Integer.parseInt(params.get("limit").toString())};
|
||||
result = jdbcTemplate.queryForList("SELECT a.* FROM tb_resource_car a INNER JOIN sys_user b ON a.creator = b.id " +
|
||||
"INNER JOIN tb_data_resource d ON a.resource_id = d.id WHERE a.del_flag = 0 AND d.type = ? AND " +
|
||||
|
@ -1724,7 +1695,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object selectTotalByDept() {
|
||||
public HashMap<String, Object> selectTotalByDept() {
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
Long deptId = SecurityUser.getUser().getDeptId();
|
||||
List<Long> deptList = null;
|
||||
|
@ -1855,17 +1826,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
|
||||
@Override
|
||||
public Object selectInfrastructureList() {
|
||||
return new HashMap<String, Object>() {{
|
||||
Map map = (Map) selectTotal();
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("total");
|
||||
list.forEach(index -> {
|
||||
if ("基础设施".equals(index.get("type").toString())) {
|
||||
put("视频资源", Integer.parseInt(index.get("count").toString()));
|
||||
}
|
||||
});
|
||||
put("感知资源", 0);
|
||||
put("云资源", 0);
|
||||
}};
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
Map map = (Map) selectTotal();
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("total");
|
||||
list.forEach(index -> {
|
||||
if ("基础设施".equals(index.get("type").toString())) {
|
||||
resultMap.put("视频资源", Integer.parseInt(index.get("count").toString()));
|
||||
}
|
||||
});
|
||||
resultMap.put("感知资源", 0);
|
||||
resultMap.put("云资源", 0);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private List<Long> getSourceIdsByProcess(List<HistoricProcessInstance> list) {
|
||||
|
@ -1906,34 +1877,32 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
List<Map> result = new ArrayList<>();
|
||||
List<Map<String, Object>> dtoMaps = baseDao.selectDevelopDocResource();
|
||||
Map<String, List<Map<String, Object>>> resourceTypeMap = dtoMaps.stream().collect(Collectors.groupingBy(m -> m.get("type").toString()));
|
||||
resourceTypeMap.entrySet().stream().forEach(temp -> {
|
||||
if (!"组件服务".equals(temp.getKey())) {
|
||||
Map map = new HashMap();
|
||||
map.put("title", temp.getKey());
|
||||
map.put("children", temp.getValue());
|
||||
resourceTypeMap.forEach((key, value) -> {
|
||||
if (!"组件服务".equals(key)) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("title", key);
|
||||
map.put("children", value);
|
||||
result.add(map);
|
||||
}
|
||||
});
|
||||
if (resourceTypeMap.get("组件服务") != null) {
|
||||
Map componentMap = new HashMap();
|
||||
Map<String, Object> componentMap = new HashMap<>();
|
||||
componentMap.put("title", "组件服务");
|
||||
Map<String, List> map = new ConcurrentHashMap<>();
|
||||
List<CompletableFuture> tasks = resourceTypeMap.get("组件服务").stream().map(it -> {
|
||||
CompletableFuture task = CompletableFuture.runAsync(() -> {
|
||||
selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream().filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> {
|
||||
CompletableFuture[] completableFutures = resourceTypeMap.get("组件服务").stream().map(it -> CompletableFuture.runAsync(() -> selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream()
|
||||
.filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> {
|
||||
if (map.get(attr.getAttrValue()) != null) {
|
||||
map.get(attr.getAttrValue()).add(it);
|
||||
} else {
|
||||
map.put(attr.getAttrValue(), (List) Collections.synchronizedList(new ArrayList() {{
|
||||
map.put(attr.getAttrValue(), Collections.synchronizedList(new ArrayList() {{
|
||||
add(it);
|
||||
}}));
|
||||
}
|
||||
});
|
||||
}, executor);
|
||||
return task;
|
||||
}).collect(Collectors.toList());
|
||||
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join();
|
||||
componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{
|
||||
}), executor))
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new CompletableFuture[resourceTypeMap.get("组件服务").size()]);
|
||||
CompletableFuture.allOf(completableFutures).join();
|
||||
componentMap.put("children", map.entrySet().stream().map(it -> new HashMap<String, Object>() {{
|
||||
put("title", it.getKey());
|
||||
put("children", it.getValue());
|
||||
}}).collect(Collectors.toList()));
|
||||
|
|
|
@ -47,6 +47,7 @@ public class ShiroSessionManager extends DefaultWebSessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*@Override
|
||||
protected void onStart(Session session, SessionContext context) {
|
||||
log.info("执行onStart");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
tsingtao-xha.cloudhls=http://10.10.30.9:8001/hx-weather-warning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls
|
||||
tsingtao-xha.localhls=http://10.134.135.9:8001/hx-weather-warning/camera/getCameraLiveStreamByCode?cameraCode=%s&protocol=hls
|
||||
tsingtao-xha.cloudcam=http://10.10.30.9:8001/data_service/getCamera/getCameraCount
|
||||
tsingtao-xha.localcam=http://10.134.135.9:8001/data_service/getCamera/getCameraCount
|
||||
tsingtao-xha.localcam=http://10.10.30.57:9537/data_service/getCamera/getCameraCount
|
||||
tsingtao-xha.resourcecount=http://10.10.30.24:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=&type=&orderField=requestNum&orderType=desc&pageNum=1&pageSize=10&serviceType=data&rq=1655106309671.43
|
||||
tsingtao-xha.resourceapplyinfo=http://10.10.30.24:30058/share-portal/platform/index/abilityMarket/count
|
||||
tsingtao-xha.sjzy=http://10.10.30.24:30090/api/share-portal/platform/catalogue/query?catalogueId=&departmentId=&serviceName=%s&type=&orderField=%s&orderType=%s&pageNum=%s&pageSize=%s&serviceType=data&rq=1655106309671.43
|
Loading…
Reference in New Issue