diff --git a/lib/yawei-pso-2.0.2.jar b/lib/yawei-pso-2.0.2.jar new file mode 100644 index 00000000..d3e0a29b Binary files /dev/null and b/lib/yawei-pso-2.0.2.jar differ diff --git a/renren-admin/pom.xml b/renren-admin/pom.xml index 6592369f..2c5300ba 100644 --- a/renren-admin/pom.xml +++ b/renren-admin/pom.xml @@ -32,6 +32,12 @@ 2.9.0 2.4.17 2.5.1 + 2.4.4 + 1.2.72 + 2.10.6 + 1.5.7 + linux-x86_64 + 5.0 1.8 @@ -223,6 +229,43 @@ org.springframework.boot spring-boot-test-autoconfigure + + + com.alibaba + fastjson + ${fastjson.version} + + + + org.springframework.boot + spring-boot-starter-cache + ${spring-boot-starter-cache.version} + + + + net.sf.ehcache + ehcache + ${ehcache.version} + + + + + org.bytedeco + javacv + ${javacv.version} + + + org.bytedeco + javacpp-platform + ${javacv.version} + + + + org.bytedeco + ffmpeg + ${ffmpeg.version}-${javacv.version} + ${system.linux-x86_64} + @@ -232,7 +275,7 @@ src/main/resources - application-prod.yml + diff --git a/renren-admin/src/main/java/io/renren/AdminApplication.java b/renren-admin/src/main/java/io/renren/AdminApplication.java index a21188a0..e8bd16f8 100644 --- a/renren-admin/src/main/java/io/renren/AdminApplication.java +++ b/renren-admin/src/main/java/io/renren/AdminApplication.java @@ -1,9 +1,14 @@ package io.renren; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; +import springfox.documentation.swagger2.annotations.EnableSwagger2; /** @@ -14,10 +19,15 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer org.activiti.spring.boot.SecurityAutoConfiguration.class, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class }) +@EnableSwagger2 +//@MapperScan("io.renren.modules.monitor.mapper") +@EnableCaching +@EnableScheduling public class AdminApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(AdminApplication.class, args); + System.out.println("项目启动成功"); } @Override diff --git a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java index b1de7dfe..63b55082 100644 --- a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java +++ b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java @@ -5,7 +5,13 @@ import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.notice.dto.SysNoticeDTO; import io.renren.modules.notice.enums.NoticeStatusEnum; import io.renren.modules.notice.service.SysNoticeService; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; +import io.renren.modules.sys.dto.SysDeptDTO; +import io.renren.modules.sys.dto.SysRoleDTO; import io.renren.modules.sys.dto.SysUserDTO; +import io.renren.modules.sys.service.SysDeptService; +import io.renren.modules.sys.service.SysRoleService; import io.renren.modules.sys.service.SysUserService; import org.activiti.engine.delegate.DelegateExecution; import org.activiti.engine.delegate.DelegateTask; @@ -20,6 +26,7 @@ import org.aspectj.lang.reflect.MethodSignature; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.lang.reflect.Method; @@ -38,8 +45,19 @@ public class ActivitiNoticeAspect { private SysNoticeService sysNoticeService; @Autowired private SysUserService sysUserService; + @Autowired + private ResourceService resourceService; + @Autowired + private SysDeptService sysDeptService; + @Autowired + private SysRoleService sysRoleService; private Set work_ = new CopyOnWriteArraySet<>(); + @Value("${big_date.name}") + private String bigDateDeptName; // 大数据局名称 + @Value("${big_date.assignee_role_name}") + private String roleName; // 具备审批的角色名称 + public ActivitiNoticeAspect() { logger.error("构造:ActivitiNoticeAspect"); } @@ -62,11 +80,14 @@ public class ActivitiNoticeAspect { Arrays.asList(joinPoint.getArgs()).stream().findFirst().ifPresent(arg -> { final DelegateTask delegateTask = (DelegateTask) arg; final String eventName = delegateTask.getEventName(); + logger.error("任务监听器事件:" + eventName); switch (eventName) { case TaskListener.EVENTNAME_ASSIGNMENT: // 节点被委派给某人 - logger.error("任务监听器事件:" + eventName); assignment_notice(delegateTask, activitiNoticeOperation); break; + case TaskListener.EVENTNAME_COMPLETE: // 节点执行完成 + task_complete_notice(delegateTask, activitiNoticeOperation); + break; default: } }); @@ -76,9 +97,9 @@ 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: // 节点被委派给某人 - logger.error("执行监听器事件:" + eventName); + case ExecutionListener.EVENTNAME_END: // 流程完成 end_notice(execution, activitiNoticeOperation); break; default: @@ -92,6 +113,86 @@ public class ActivitiNoticeAspect { logger.error("执行时长{} ms", time); } + /** + * 进行节点流转 + * + * @param delegateTask + * @param activitiNoticeOperation + */ + private void task_complete_notice(final DelegateTask delegateTask, final ActivitiNoticeOperation activitiNoticeOperation) { + Map kv = delegateTask.getVariables(); + logger.error("表单:" + kv.toString()); + if (work_.contains(kv.get("id").toString())) { + logger.error("------------出现重放------------"); + return; + } + work_.add(kv.get("id").toString()); + String creator = null; + if (kv.containsKey("creator")) { // 表单存在创建者 + creator = kv.get("creator").toString(); + } else if (kv.containsKey("userId")) { + creator = kv.get("userId").toString(); + } + if (StringUtils.isEmpty(creator)) { + return; + } + try { + String result; + Boolean termination = + Boolean.valueOf(kv.get("termination") != null ? kv.get("termination").toString() : Boolean.FALSE.toString()); // 直接终结 + Boolean reject = + Boolean.valueOf(kv.get("reject") != null ? kv.get("reject").toString() : Boolean.FALSE.toString()); // 被拒绝 + if (termination) { + result = "终止被拒"; + } else if (reject) { + result = "被拒"; + } else { + result = "通过"; + } + String finalCreator = creator; + String finalResult = result; + CompletableFuture.runAsync(() -> { // 发起人 + SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); + Long resourceId = null; + if (kv.containsKey("resourceId")) { + resourceId = Long.valueOf(kv.get("resourceId").toString()); + } else if (kv.containsKey("id")) { + resourceId = Long.valueOf(kv.get("id").toString()); + } + Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); + kv.get("resourceId"); + kv.get("id"); + String content = "【通知】" + userDTO.getRealName() + ",您发起的" + (resourceDTO.isPresent() ? resourceDTO.get().getName() : "") + + activitiNoticeOperation.process() + " " + activitiNoticeOperation.value() + "节点" + finalResult; + SysNoticeDTO dto = new SysNoticeDTO(); + dto.setType(2); + dto.setTitle("流程结束系统通知"); + dto.setContent(content); // 通知内容 + dto.setReceiverType(1); + dto.setReceiverTypeIds(finalCreator); + dto.setStatus(NoticeStatusEnum.SEND.value()); + dto.setSenderName("流程系统"); + dto.setSenderDate(new Date()); + dto.setCreator(sysUserService.getByUsername("admin").getId()); + dto.setCreateDate(new Date()); + sysNoticeService.save(dto); + }).thenRunAsync(() -> { + // 防止重放 + new Thread(() -> { + try { + Thread.sleep(200); + work_.remove(kv.get("id").toString()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }).start(); + }); + + } catch (Exception e) { + + } + } + /** * 流程结束时通知 * @@ -130,8 +231,19 @@ public class ActivitiNoticeAspect { } String finalCreator = creator; String finalResult = result; + Long resourceId = null; + if (kv.containsKey("resourceId")) { + resourceId = Long.valueOf(kv.get("resourceId").toString()); + } else if (kv.containsKey("id")) { + resourceId = Long.valueOf(kv.get("id").toString()); + } + Optional resourceDTO = Optional.ofNullable(resourceService.get(resourceId)); CompletableFuture.runAsync(() -> { // 发起人 - String content = "您发起的流程<" + activitiNoticeOperation.process() + "> 已结束。审核结果为:" + finalResult; + SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); + kv.get("resourceId"); + kv.get("id"); + String content = "【通知】" + userDTO.getRealName() + ",您发起的" + (resourceDTO.isPresent() ? resourceDTO.get().getName() : "") + + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; SysNoticeDTO dto = new SysNoticeDTO(); dto.setType(2); dto.setTitle("流程结束系统通知"); @@ -144,6 +256,30 @@ public class ActivitiNoticeAspect { dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreateDate(new Date()); sysNoticeService.save(dto); + }).thenRunAsync(() -> { + logger.error("大数据局名称:" + bigDateDeptName); + SysDeptDTO deptDTO = sysDeptService.getByName(bigDateDeptName); + logger.error("deptDTOId:" + deptDTO.getId()); + SysRoleDTO roleDTO = sysRoleService.getByName(roleName); + logger.error("roleDTOId:" + roleDTO.getId()); + Optional userDTO = Optional.ofNullable(sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId())); + userDTO.ifPresent(user -> { + SysUserDTO creatorDTO = sysUserService.get(Long.valueOf(finalCreator)); + SysNoticeDTO dto = new SysNoticeDTO(); + dto.setType(2); + dto.setTitle("流程结束系统通知"); + String content = "【通知】" + user.getRealName() + "," + creatorDTO.getRealName() + "发起的" + (resourceDTO.isPresent() ? resourceDTO.get().getName() : "") + + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; + dto.setContent(content); // 通知内容 + dto.setReceiverType(1); + dto.setReceiverTypeIds(finalCreator); + dto.setStatus(NoticeStatusEnum.SEND.value()); + dto.setSenderName("流程系统"); + dto.setSenderDate(new Date()); + dto.setCreator(sysUserService.getByUsername("admin").getId()); + dto.setCreateDate(new Date()); + sysNoticeService.save(dto); + }); }).thenRunAsync(() -> { // 防止重放 new Thread(() -> { diff --git a/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java b/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java index f910548b..dcaeef28 100644 --- a/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java +++ b/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java @@ -9,6 +9,9 @@ import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.web.client.RestTemplate; import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.SocketAddress; import java.nio.charset.Charset; import java.util.Collections; @@ -27,6 +30,10 @@ public class RestTemplateConfig { SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); factory.setReadTimeout(30000);//单位为ms factory.setConnectTimeout(30000);//单位为ms + +// SocketAddress address = new InetSocketAddress("127.0.0.1", 8888); +// Proxy proxy = new Proxy(Proxy.Type.HTTP, address); +// factory.setProxy(proxy); return factory; } } diff --git a/renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java b/renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java deleted file mode 100644 index fbba7ca1..00000000 --- a/renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java +++ /dev/null @@ -1,112 +0,0 @@ -package io.renren.common.interceptor; - -import com.yawei.pso.PSORequest; -import com.yawei.pso.SSOResponse; -import com.yawei.pso.TicketManager; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.net.URLEncoder; -import java.util.Iterator; -import java.util.Map.Entry; - -/** - * 亚微 sso拦截 - */ -@Component -public class IdentityInterceptor implements HandlerInterceptor { - private static Logger logger = LoggerFactory.getLogger(IdentityInterceptor.class); - - public final static String SEESION_USER = "seesion_user"; - - @Autowired - private YaweiSSOProperties yaweiSSOProperties; - - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - logger.info("==============执行顺序: 1、preHandle================"); - // 获取当前请求的url - String requestUri = request.getRequestURI(); - - Validator validator = Validator.getInstance(); - - String strResponse = request.getParameter(yaweiSSOProperties.getSsoKey()); - if (StringUtils.isEmpty(strResponse)) { - TicketManager tm = new TicketManager(); - if (!tm.LoadTicket(request)) { - PSORequest psoRequest = new PSORequest(request); - String requeststr = psoRequest.CreateHash(); - - String keeperUrl = yaweiSSOProperties.getKeeperUrl(); - keeperUrl = keeperUrl + "?" + yaweiSSOProperties.getSsoKey() + "=" - + URLEncoder.encode(requeststr, "UTF-8"); - response.addHeader("REDIRECT", keeperUrl); - response.sendRedirect(keeperUrl); - return false; - } - } else { - // 如果服务器端通过认证后,会返回后执行改操作,然后写入cookie - SSOResponse ssoResp = new SSOResponse(strResponse); - TicketManager tm = ssoResp.CreatePSOTicket(); - if (tm == null) { - PSORequest psoRequest = new PSORequest(request); - String requeststr = psoRequest.CreateHash(); - - String keeperUrl = yaweiSSOProperties.getKeeperUrl(); - keeperUrl = keeperUrl + "?" + yaweiSSOProperties.getSsoKey() + "=" - + URLEncoder.encode(requeststr, "UTF-8"); - response.sendRedirect(keeperUrl); - } else { - String domainName = yaweiSSOProperties.getDomain(); - tm.SaveTicket(response, domainName); - Iterator> iterator = request - .getParameterMap().entrySet().iterator(); - StringBuffer param = new StringBuffer(); - int i = 0; - while (iterator.hasNext()) { - Entry entry = (Entry) iterator - .next(); - if (entry.getKey().equals(yaweiSSOProperties.getSsoKey())) - continue; - else { - i++; - if (i == 1) - param.append("?").append(entry.getKey()) - .append("="); - else - param.append("&").append(entry.getKey()) - .append("="); - - if (entry.getValue() instanceof String[]) { - param.append(((String[]) entry.getValue())[0]); - } else { - param.append(entry.getValue()); - } - } - } - response.sendRedirect(requestUri + param.toString()); - return false; - } - } - validator.SetUserTicket(request); - return true; - } - - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { - logger.info("==============执行顺序: 2、postHandle================"); - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { - logger.info("==============执行顺序: 3、afterCompletion================"); - } -} diff --git a/renren-admin/src/main/java/io/renren/common/interceptor/Validator.java b/renren-admin/src/main/java/io/renren/common/interceptor/Validator.java deleted file mode 100644 index b02bc2f7..00000000 --- a/renren-admin/src/main/java/io/renren/common/interceptor/Validator.java +++ /dev/null @@ -1,83 +0,0 @@ -package io.renren.common.interceptor; - -import com.yawei.pso.TicketManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -/** - * 验证器 - */ -public class Validator { - private static Logger logger = LoggerFactory.getLogger(Validator.class); - private static ThreadLocal validatorHolder = new ThreadLocal() { - - protected Validator initialValue() { - return new Validator(); - } - - }; - - // 当前请求的session - private HttpSession session = null; - - // 当前的请求 - private HttpServletRequest request = null; - - private Validator() { - - } - - public static Validator getInstance() { - return validatorHolder.get(); - } - - /** - * 执行初始化 - * - * @param httpRequest - */ - public void init(HttpServletRequest httpRequest) { - this.request = httpRequest; - this.session = request.getSession(); - } - - /** - * 将凭证身份加入到session - * - * @param httpRequest - */ - public void SetUserTicket(HttpServletRequest httpRequest) { - try { - if (httpRequest.getSession() - .getAttribute(IdentityInterceptor.SEESION_USER) == null) { - TicketManager ticket = new TicketManager(); - if (ticket.LoadTicket(httpRequest)) { - // 登录用户姓名 - String userName = ticket.getUserName(); - // 登录用户账号 - String userAccount = ticket.getUserID(); - // 登录用户标识 - String userGuid = ticket.getADGUID(); - logger.info("===userName===" + userName); - logger.info("===userAccount===" + userAccount); - logger.info("===userGuid===" + userGuid); - } - } else { - - } - } catch (Exception ex) { - logger.error("", ex); - } - } - - /** - * 清除session - */ - public void cancel() { - this.session = null; - } - -} diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActModelService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActModelService.java index db654be6..0cd8dd97 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActModelService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActModelService.java @@ -172,7 +172,7 @@ public class ActModelService { BufferedImage bufferedImage = ImageIO.read(in); ImageIO.write(bufferedImage, "png", response.getOutputStream()); } else { - response.getWriter().println("No image Info!"); + response.getOutputStream().println("No image Info!"); } } catch (IOException e) { e.printStackTrace(); diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/config/CachingConfig.java b/renren-admin/src/main/java/io/renren/modules/monitor/config/CachingConfig.java new file mode 100644 index 00000000..16d299ed --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/monitor/config/CachingConfig.java @@ -0,0 +1,33 @@ +package io.renren.modules.monitor.config; + +import net.sf.ehcache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.ehcache.EhCacheCacheManager; +import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; + + +/** + * @author admin + * @version 1.0.0 + * @ClassName CachingConfig.java + * @Description cache配置 + * @createTime 2022年05月12日 09:45:00 + */ +@Configuration +@EnableCaching +public class CachingConfig { + @Bean + public EhCacheCacheManager cacheManager(CacheManager cm) { + return new EhCacheCacheManager(cm); + } + + @Bean + public EhCacheManagerFactoryBean ehcache() { + EhCacheManagerFactoryBean cacheManagerFactoryBean = new EhCacheManagerFactoryBean(); + cacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml")); + return cacheManagerFactoryBean; + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/config/GlobalCorsConfig.java b/renren-admin/src/main/java/io/renren/modules/monitor/config/GlobalCorsConfig.java new file mode 100644 index 00000000..4aa28724 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/monitor/config/GlobalCorsConfig.java @@ -0,0 +1,32 @@ +package io.renren.modules.monitor.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +@Configuration +public class GlobalCorsConfig { + + @Bean + public CorsFilter corsFilter() { + //1. 添加 CORS配置信息 + CorsConfiguration config = new CorsConfiguration(); + //放行哪些原始域 + config.addAllowedOrigin("*"); + //是否发送 Cookie + config.setAllowCredentials(true); + //放行哪些请求方式 + config.addAllowedMethod("*"); + //放行哪些原始请求头部信息 + config.addAllowedHeader("*"); + //暴露哪些头部信息 + config.addExposedHeader("*"); + //2. 添加映射路径 + UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource(); + corsConfigurationSource.registerCorsConfiguration("/**",config); + //3. 返回新的CorsFilter + return new CorsFilter(corsConfigurationSource); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/controller/BuildingController.java b/renren-admin/src/main/java/io/renren/modules/monitor/controller/BuildingController.java new file mode 100644 index 00000000..c0738eb0 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/monitor/controller/BuildingController.java @@ -0,0 +1,58 @@ +package io.renren.modules.monitor.controller; + +import io.renren.modules.monitor.entity.BuildingRecords; +import io.renren.modules.monitor.entity.Result; +import io.renren.modules.monitor.service.BuildingRecordsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @author admin + * @version 1.0.0 + * @ClassName BuildingController.java + * @Description 工地 + * @createTime 2022年05月17日 15:26:00 + */ +@Api(tags = "工地") +@RequestMapping("api/project/building") +@RestController +public class BuildingController { + @Autowired + private BuildingRecordsService buildingRecordsService; + + @GetMapping("/getRecords") + @ApiOperation("测试,获取工地实时数据--调用接口") + public List getRecords(){ + return buildingRecordsService.getRecords(); + } + + @GetMapping("/getAndSaveRecords") + @ApiOperation("获取工地实时数据并保存到表中--调用接口获取") + public Result getAndSaveRecords(){ + boolean result = buildingRecordsService.getAndSaveRecords(); + if(result){ + return Result.success(); + }else{ + return Result.error(String.valueOf(result)); + } + } + + @GetMapping("/listRecords") + @ApiOperation("获取工地实时数据列表-从t_building_records表中查询") + @ApiImplicitParam(name="pushTime",value="上传时间",paramType = "query",required = true,dataType = "string",example = "2022-01-01") + public List listRecords( + @RequestParam(value="pushTime") String pushTime + ){ + return buildingRecordsService.listRecords(pushTime); + } + +} diff --git a/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java b/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java new file mode 100644 index 00000000..81de3c72 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/monitor/controller/Controller.java @@ -0,0 +1,565 @@ +package io.renren.modules.monitor.controller; + +import io.renren.modules.monitor.dto.*; +import io.renren.modules.monitor.entity.*; +import io.renren.modules.monitor.mapper.*; +import io.renren.modules.monitor.service.*; +import io.renren.modules.monitor.utils.LongLatUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("api/project") +@Api(tags="通用") +public class Controller { + + @Autowired + private ProjectMapper projectMapper; + + @Autowired + private CameraMapper cameraMapper; + + @Autowired + private ScenicMapper scenicMapper; + + @Autowired + private MonitorService monitorService; + + @Autowired + private SedimentTrailService sedimentTrailService; + + @Autowired + private CameraChannelMapper cameraChannelMapper; + + @Autowired + private CameraOrgenizationMapper cameraOrgenMapper; + + @Autowired + private PassengerFlowService passengerFlowService; + + @Autowired + private TrailSanitationService trailSanitationService; + + @Autowired + private RoadDataService roadDataService; + + @Autowired + private CameraChannelService cameraChannelService; + + @Autowired + private BuildingSiteService buildingSitrService; + + @Autowired + private BuildingSiteMapper buildingSiteMapper; + + @Autowired + private ChannelPictureMapper channelPictureMapper; + + + @GetMapping("all") + public Object all(){ + List projects = projectMapper.selectList(null); + projects.forEach(project -> { + List pics = cameraMapper.selectPicByProjectId(project.getId()); + project.setPics(pics); + }); + + return projects; + } + + /** + * 推送给城管接口用的 + * @return + */ + @GetMapping("cameras") + public Result cameras(){ + List channelPictureDtos = channelPictureMapper.selectByProject(); + Result success = Result.success(channelPictureDtos); + success.setCount(channelPictureDtos.size()); + return success; + } + + /** + * 景区人流识别 + * @return + */ + @GetMapping("scenicCamera") + public Result scenicCamera(){ + List scenicCameraDtos = scenicMapper.selectScenicCameras(); + Result success = Result.success(scenicCameraDtos); + success.setCount(scenicCameraDtos.size()); + return success; + } + + @GetMapping("capture") + public Object capture(){ + monitorService.start(); + + return "finish capture"; + } + + @GetMapping("startScenic") + public Object startScenic(){ + monitorService.startScenic(); + + return "startScenic finish"; + } + + @GetMapping("capture1") + public Object capture1(){ + monitorService.listChannelPlayStates(); + + return "finish capture"; + } + + + /** + * 查询所有摄像头 + * @param + * @return + */ + @GetMapping("selectAll") + @ApiOperation("查询所有摄像头") + public String selectAll(){ + return cameraChannelService.selectAll(); + } + + /** + * 根据channelCode查询摄像头详细信息 + * @param channelCode + * @return + */ + @GetMapping("selectByChannelCode") + @ApiOperation("根据摄像头编号查询摄像头详细信息") + @ApiImplicitParam(name = "channelCode",value = "摄像头标识",required = true,dataType = "String") + public Result selectByChannelCode(String channelCode){ + + List list = cameraChannelMapper.selectByChannelCode(channelCode); + + Result success = Result.success(list); + + return success; + + + } + + /** + * 根据摄像头名字模糊查询摄像头 + * @param channelName + * @return + */ + @GetMapping("selectByChannelName") + @ApiOperation("根据摄像头名字模糊查询摄像头") + @ApiImplicitParam(name = "channelName",value = "摄像头名称",required = true,dataType = "String") + public Result selectByChannelName(String channelName){ + + List labels = cameraChannelMapper.selectByChannelName(channelName); + + Result success = Result.success(labels); + + return success; + } + + /** + * 根据parentId和checkStatus查询摄像头 + * @param parentId + * @return + */ + @GetMapping("selectByParentId") + @ApiOperation("根据摄像头的组织Id和异常状态查询摄像头") + @ApiImplicitParams({ + @ApiImplicitParam(name = "parentId",value = "摄像头的组织Id",required = true,dataType = "String"), + @ApiImplicitParam(name = "checkStatus",value = "异常状态 1正常,0异常",required = true,dataType = "String") + }) + public Result selectByParentId(String parentId,String checkStatus){ + + List list = cameraChannelMapper.selectByParentId(parentId,checkStatus); + + Result success = Result.success(list); + + return success; + + } + + /** + * 根据标签查询对应摄像头 + * @return + */ + @GetMapping("selectLabel") + @ApiOperation("根据标签查询对应摄像头") + @ApiImplicitParam(name = "labelCode",value = "标签号",required = true,dataType = "String") + public Result selectLabel(String labelCode){ + + List channelLabelDtos = cameraChannelMapper.selectLabel(labelCode); + + for (ChannelLabelDto channelLabelDto :channelLabelDtos) { + String nodeName = channelLabelDto.getNodeName(); + String[] splits = nodeName.split("->"); + String split = splits[1]; + channelLabelDto.setNodeName(split); + + } + + return Result.success(channelLabelDtos); + } + + /** + * 根据经纬度查询半径内所有的摄像头 + * @param gpsX + * @param gpsY + * @param radius + * @return + */ + @GetMapping ("selectAllByGps") + @ApiOperation("根据经纬度查询半径内所有的摄像头") + @ApiImplicitParams({ + @ApiImplicitParam(name = "gpsX", value = "经度",required = true,dataType ="Double"), + @ApiImplicitParam(name = "gpsY", value = "纬度",required = true,dataType ="Double"), + @ApiImplicitParam(name = "radius", value = "半径,米",required = true,dataType ="Integer"),} + ) + public Result selectAllByGps(Double gpsX,Double gpsY,Integer radius){ + double[] around = LongLatUtil.getAround(gpsX, gpsY, radius); + List c = cameraChannelMapper.selectAllByGps(around[0], around[2], around[1], around[3]); + Result success = Result.success(c); + return success; + } + + /** + * 查询所有标签 + * @return + */ + @GetMapping("selectAllLabel") + @ApiOperation("查询所有标签") + public Result selectAllLabel(){ + + List