Merge branch 'dev' of http://blit.7drlb.com:8888/r/moral into dev
3 files deleted
43 files added
39 files modified
| | |
| | | myBatisPlusGenerator/src/test/ |
| | | screen-common/src/main/resources/ |
| | | screen-manage/src/test/ |
| | | /home |
| | | /screen-api/screen-api.iml |
| | | /screen-job/screen-job.iml |
| | | /screen-common/screen-common.iml |
| | | /screen-manage/screen-manage.iml |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> |
| | | <component name="FacetManager"> |
| | | <facet type="web" name="Web"> |
| | | <configuration> |
| | | <webroots /> |
| | | </configuration> |
| | | </facet> |
| | | <facet type="Spring" name="Spring"> |
| | | <configuration /> |
| | | </facet> |
| | | </component> |
| | | <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> |
| | | <output url="file://$MODULE_DIR$/target/classes" /> |
| | | <output-test url="file://$MODULE_DIR$/target/test-classes" /> |
| | | <content url="file://$MODULE_DIR$"> |
| | | <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> |
| | | <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> |
| | | <excludeFolder url="file://$MODULE_DIR$/target" /> |
| | | </content> |
| | | <orderEntry type="inheritedJdk" /> |
| | | <orderEntry type="sourceFolder" forTests="false" /> |
| | | <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.12" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-generator:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.4" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.4" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.velocity:velocity-engine-core:2.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.23" level="project" /> |
| | | <orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.19" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba:druid:1.1.5" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" /> |
| | | <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" /> |
| | | <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.10.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.31" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.31" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.31" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.3.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-web:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.13" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.13" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-core:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.xiaoymin:swagger-bootstrap-ui:1.9.6" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.kafka:spring-kafka:2.2.12.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.retry:spring-retry:1.2.5.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:kafka-streams:2.2.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:connect-json:2.0.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:connect-api:2.0.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.rocksdb:rocksdbjni:5.15.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:kafka-clients:2.2.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.luben:zstd-jni:1.3.8-1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.lz4:lz4-java:1.5.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.2" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.11.1" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:2.23.4" level="project" /> |
| | | <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.16" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.16" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.code.kaptcha:kaptcha:2.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.5" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.xuxueli:xxl-job-core:2.3.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.45.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.codehaus.groovy:groovy:2.5.9" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.googlecode.aviator:aviator:5.2.5" level="project" /> |
| | | </component> |
| | | </module> |
| | |
| | | // 全局配置 |
| | | GlobalConfig gc = new GlobalConfig(); |
| | | //String projectPath = System.getProperty("user.dir"); |
| | | String projectPath="C:\\Users\\cdl\\Desktop\\comProject\\newProject\\moral\\screen-manage\\"; |
| | | String projectPath="D:\\tools\\IdeaProjects\\moral\\screen-job"; |
| | | gc.setOutputDir(projectPath + "/src/main/java"); |
| | | gc.setAuthor("moral"); |
| | | gc.setOpen(false); |
| | |
| | | |
| | | // 数据源配置 |
| | | DataSourceConfig dsc = new DataSourceConfig(); |
| | | dsc.setUrl("jdbc:mysql://rm-bp1pr3rx9m3fnkwsk8o.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"); |
| | | dsc.setUrl("jdbc:mysql://rm-bp1pr3rx9m3fnkwsk8o.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai"); |
| | | dsc.setDriverName("com.mysql.cj.jdbc.Driver"); |
| | | dsc.setUsername("root"); |
| | |
| | | <swagger-bootstrap-ui.version>1.9.6</swagger-bootstrap-ui.version> |
| | | <spring.kafka.version>2.2.2</spring.kafka.version> |
| | | <xxl-job.version>2.3.0</xxl-job.version> |
| | | <aviator.version>5.2.5</aviator.version> |
| | | </properties> |
| | | |
| | | |
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | | <artifactId>springfox-swagger2</artifactId> |
| | |
| | | <artifactId>xxl-job-core</artifactId> |
| | | <version>${xxl-job.version}</version> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/com.googlecode.aviator/aviator --> |
| | | <dependency> |
| | | <groupId>com.googlecode.aviator</groupId> |
| | | <artifactId>aviator</artifactId> |
| | | <version>${aviator.version}</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.Group; |
| | | import com.moral.api.service.GroupService; |
| | |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.PageResult; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"组管理"}) |
| | |
| | | |
| | | @ApiOperation(value = "删除组", notes = "删除组") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "组id", required = true, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "delete", method = RequestMethod.POST) |
| | | public ResultMessage delete(@RequestBody Group group) { |
| | | if (group.getId() == null) { |
| | | @RequestMapping(value = "delete", method = RequestMethod.GET) |
| | | public ResultMessage delete(Integer id) { |
| | | if (id == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("id", group.getId()); |
| | | group = groupService.getOne(queryWrapper); |
| | | if (group == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode(), ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | } |
| | | groupService.deleteGroup(group); |
| | | groupService.deleteGroup(id); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "update", method = RequestMethod.POST) |
| | | public ResultMessage update(@RequestBody Group group, HttpServletRequest request) { |
| | | String token = request.getHeader("token"); |
| | | public ResultMessage update(@RequestBody Group group) { |
| | | Map<String, Object> result = groupService.updateGroup(group); |
| | | if (!result.isEmpty()) { |
| | | return ResultMessage.fail((int) result.get("code"), result.get("msg").toString()); |
| | |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | | @ApiImplicitParam(name = "groupName", value = "组名模糊查询", required = false, paramType = "query", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "select", method = RequestMethod.POST) |
| | | public ResultMessage select(@RequestBody Map<String, Object> parameters) { |
| | | @RequestMapping(value = "select", method = RequestMethod.GET) |
| | | public ResultMessage select(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | Page<Group> userPage = groupService.selectGroups(parameters); |
| | | PageResult<Group> pageResult = new PageResult<>( |
| | | userPage.getTotal(), userPage.getPages(), userPage.getRecords() |
| | |
| | | |
| | | @ApiOperation(value = "获取用户所属组ids", notes = "获取用户所属组ids") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "get-group-ids", method = RequestMethod.GET) |
| | | @RequestMapping(value = "getGroupIds", method = RequestMethod.GET) |
| | | public ResultMessage getGroupIds(Integer userId) { |
| | | List<Integer> groupIds = userGroupService.getGroupIds(userId); |
| | | return ResultMessage.ok(groupIds); |
| | | System.out.println(userId); |
| | | if (userId == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<Map<String, Object>> groups = groupService.getGroupIds(userId); |
| | | return ResultMessage.ok(groups); |
| | | } |
| | | |
| | | @ApiOperation(value = "用户分配组", notes = "用户分配组") |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.SysConfig; |
| | | import com.moral.api.service.SysConfigService; |
| | | import com.moral.api.service.UserLogService; |
| | | import com.moral.api.service.UserService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Map<String, Object> result = userService.login(parameters); |
| | | if (!result.containsKey("data")) { |
| | | if (!result.containsKey("token")) { |
| | | return ResultMessage.fail((int) result.get("code"), (String) result.get("msg")); |
| | | } |
| | | Map<String, Object> data = (Map<String, Object>) result.get("data"); |
| | | return ResultMessage.ok(data); |
| | | return ResultMessage.ok(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "退出", notes = "退出") |
| | | @RequestMapping(value = "logout", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取用户信息", notes = "获取用户信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | public ResultMessage logout(@RequestBody Map<String, Object> parameters, HttpServletRequest request) { |
| | | if (!parameters.containsKey("uid")) { |
| | | @RequestMapping(value = "getUserInfo", method = RequestMethod.POST) |
| | | public ResultMessage getUserInfo(HttpServletRequest request) { |
| | | String token = request.getHeader("token"); |
| | | Map<String, Object> result = userService.getUserInfo(token); |
| | | return ResultMessage.ok(result); |
| | | } |
| | | |
| | | @ApiOperation(value = "退出", notes = "退出") |
| | | @RequestMapping(value = "logout", method = RequestMethod.GET) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | public ResultMessage logout(Integer userId, HttpServletRequest request) { |
| | | if (userId == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | String token = request.getHeader("token"); |
| | | TokenUtils.destoryToken(parameters.get("uid").toString(), token); |
| | | TokenUtils.destoryToken(userId.toString(), token); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | queryWrapper.eq(Constants.FRONT_VERIFICATIONCODE_COLUMN, Constants.FRONT_ERIFICATIONCODE_VALUE); |
| | | SysConfig sysConfig = sysConfigService.getOne(queryWrapper); |
| | | if (Constants.VERFICATIONCODE_OPEN.equals(sysConfig.getCode())) { |
| | | return new ResultMessage(ResponseCodeEnum.VERIFICATION_OPEN,null); |
| | | return new ResultMessage(ResponseCodeEnum.VERIFICATION_OPEN, null); |
| | | } |
| | | return new ResultMessage(ResponseCodeEnum.VERIFICATION_CLOSE,null); |
| | | return new ResultMessage(ResponseCodeEnum.VERIFICATION_CLOSE, null); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取验证码", notes = "获取验证码") |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | | }) |
| | | @RequestMapping(value = "select", method = RequestMethod.POST) |
| | | @RequestMapping(value = "select", method = RequestMethod.GET) |
| | | public ResultMessage select(HttpServletRequest request) { |
| | | String token = request.getHeader("token"); |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "get-menu-ids", method = RequestMethod.GET) |
| | | @RequestMapping(value = "getMenuIds", method = RequestMethod.GET) |
| | | public ResultMessage getMenuIds(Integer groupId) { |
| | | List<Integer> menusIds = groupMenuService.getMenusIds(groupId); |
| | | return ResultMessage.ok(menusIds); |
| | |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.PageResult; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"用户管理"}) |
| | |
| | | }) |
| | | @RequestMapping(value = "insert", method = RequestMethod.POST) |
| | | public ResultMessage insert(@RequestBody User user) { |
| | | System.out.println(user); |
| | | if (user.getAccount().isEmpty() || user.getPassword().isEmpty()) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | |
| | | |
| | | @ApiOperation(value = "删除账户", notes = "删除账户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "delete", method = RequestMethod.POST) |
| | | public ResultMessage delete(@RequestBody User user) { |
| | | if (user.getId() == null) { |
| | | @RequestMapping(value = "delete", method = RequestMethod.GET) |
| | | public ResultMessage delete(Integer id) { |
| | | if (id == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("id", user.getId()); |
| | | user = userService.getOne(queryWrapper); |
| | | if (user == null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode(), |
| | | ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | } |
| | | userService.deleteUser(user); |
| | | userService.deleteUser(id); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "分页查询账户列表", notes = "分页查询账户列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "Integer"), |
| | | @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "Integer"), |
| | | @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "int"), |
| | | @ApiImplicitParam(name = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", defaultValue = "0", required = false, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), |
| | |
| | | @ApiImplicitParam(name = "wechat", value = "微信模糊查询", required = false, paramType = "query", dataType = "String"), |
| | | |
| | | }) |
| | | @RequestMapping(value = "select", method = RequestMethod.POST) |
| | | public ResultMessage select(@RequestBody Map<String, Object> parameters) { |
| | | @RequestMapping(value = "select", method = RequestMethod.GET) |
| | | public ResultMessage select(HttpServletRequest request) { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | if (!parameters.containsKey("page") || !parameters.containsKey("size")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | Page<User> userPage = userService.selectUsers(parameters); |
| | | PageResult<User> pageResult = new PageResult<>( |
| | | userPage.getTotal(), userPage.getPages(), userPage.getRecords() |
| | |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @TableName("`groupMenu`") |
| | | @TableName("`group`") |
| | | public class Group extends Model<Group> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.persistence.Transient; |
| | | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | /** |
| | | * 过期时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date expireTime; |
| | | |
| | | /** |
| | |
| | | * @Date 2021/6/15 14:49 |
| | | * @Version TODO |
| | | **/ |
| | | @Component |
| | | //@Component |
| | | public class SecondsDataConsumer implements ConsumerSeekAware { |
| | | |
| | | @KafkaListener(topics = "test",groupId = "SecondsDataGroup3") |
| | |
| | | */ |
| | | public interface GroupMenuService extends IService<GroupMenu> { |
| | | |
| | | //分配菜单 |
| | | void allotMenus(Map<String, Object> parameters); |
| | | |
| | | //获取组(角色)所有菜单集合 |
| | | List<Integer> getMenusIds(Integer groupId); |
| | | } |
| | |
| | | */ |
| | | public interface GroupService extends IService<Group> { |
| | | |
| | | //新增组(角色) |
| | | Map<String, Object> addGroup(Group group); |
| | | |
| | | void deleteGroup(Group group); |
| | | //删除组(角色) |
| | | void deleteGroup(Integer id); |
| | | |
| | | //修改组(角色) |
| | | Map<String, Object> updateGroup(Group group); |
| | | |
| | | //分页组(角色)列表 |
| | | Page<Group> selectGroups(Map<String, Object> parameters); |
| | | |
| | | //获取用户组(角色) |
| | | List<Map<String, Object>> getGroupIds(Integer userId); |
| | | |
| | | } |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.UserGroup; |
| | |
| | | */ |
| | | public interface UserGroupService extends IService<UserGroup> { |
| | | |
| | | //用户分配组(角色) |
| | | void allotGroups(Map<String, Object> parameters); |
| | | |
| | | List<Integer> getGroupIds(Integer userId); |
| | | } |
| | |
| | | */ |
| | | public interface UserService extends IService<User> { |
| | | |
| | | //登陆 |
| | | Map<String, Object> login(Map<String, Object> parameters); |
| | | |
| | | //根据token获取用户信息 |
| | | Map<String,Object> getUserInfo(String token); |
| | | |
| | | //获取菜单 |
| | | Map<String, Object> getMenus(Map<String, Object> parameters); |
| | | |
| | | //新增用户 |
| | | Map<String, Object> addUser(User user); |
| | | |
| | | void deleteUser(User user); |
| | | //删除用户 |
| | | void deleteUser(Integer userId); |
| | | |
| | | //更新用户 |
| | | Map<String, Object> updateUser(User user); |
| | | |
| | | //分页用户列表 |
| | | Page<User> selectUsers(Map<String, Object> parameters); |
| | | |
| | | //根据所传条件获取用户信息 |
| | | UserBO selectUserInfo(Map<String, Object> parameters); |
| | | |
| | | } |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | deleteWrapper.eq("group_id", groupId).eq("channel_key", Constants.WEB_CHANNEL); |
| | | groupMenuMapper.delete(deleteWrapper); |
| | | List<String> menus = new ArrayList<>(); |
| | | if (menuIds != null && !menuIds.isEmpty()) { |
| | | if (!ObjectUtils.isEmpty(menuIds)) { |
| | | menuIds.forEach(menuId -> { |
| | | menus.add(menuMapper.selectById(menuId).getName()); |
| | | GroupMenu groupMenu = new GroupMenu(); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | //日志 |
| | | String groupName = groupMapper.selectById((Integer) parameters.get("groupId")).getGroupName(); |
| | | String content = "给组:" + groupName + "分配了菜单:" + menus.toString(); |
| | | String content = "给组:" + groupName + "分配了菜单:" + menus; |
| | | operationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void deleteGroup(Group group) { |
| | | public void deleteGroup(Integer id) { |
| | | //逻辑删除group |
| | | group.setIsDelete(Constants.DELETE); |
| | | groupMapper.updateById(group); |
| | | UpdateWrapper<Group> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", id).set("is_delete", Constants.DELETE); |
| | | groupMapper.update(null, updateWrapper); |
| | | //删除group_menu |
| | | UpdateWrapper<GroupMenu> deleteGroupWrapper = new UpdateWrapper<>(); |
| | | deleteGroupWrapper.eq("group_id", group.getId()); |
| | | deleteGroupWrapper.eq("group_id", id); |
| | | groupMenuMapper.delete(deleteGroupWrapper); |
| | | //删除user_group |
| | | UpdateWrapper<UserGroup> deleteUserGroupWrapper = new UpdateWrapper<>(); |
| | | deleteUserGroupWrapper.eq("group_id", group.getId()); |
| | | deleteUserGroupWrapper.eq("group_id", id); |
| | | userGroupMapper.delete(deleteUserGroupWrapper); |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String content = "删除了组:" + group.getGroupName(); |
| | | String content = "删除了组:" + groupMapper.selectById(id).getGroupName(); |
| | | operationLogUtils.insertLog(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("organization_id", orgId) |
| | | .eq("is_delete", Constants.NOT_DELETE); |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .ne("group_name", "admin"); |
| | | Object order = parameters.get("order"); |
| | | Object orderType = parameters.get("orderType"); |
| | | Object groupName = parameters.get("groupName"); |
| | |
| | | queryWrapper.like("group_name", groupName); |
| | | } |
| | | |
| | | //分页参数 |
| | | if (!parameters.containsKey("page")) { |
| | | parameters.put("page", 0); |
| | | } |
| | | if (!parameters.containsKey("size")) { |
| | | parameters.put("size", 10); |
| | | } |
| | | |
| | | int page = Integer.parseInt(parameters.get("page").toString()); |
| | | int size = Integer.parseInt(parameters.get("size").toString()); |
| | | Page<Group> pageData = new Page<>(page, size); |
| | | //排序参数,默认id升序 |
| | | //排序参数,默认create_time降序 |
| | | if (order != null && orderType != null) { |
| | | if (Constants.ORDER_ASC.equals(orderType)) { |
| | |
| | | return pageData; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getGroupIds(Integer userId) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("userId", userId); |
| | | return groupMapper.selectUserGroup(params); |
| | | } |
| | | } |
| | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.moral.api.entity.UserGroup; |
| | | import com.moral.api.mapper.GroupMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | deleteWrapper.eq("user_id", userId); |
| | | userGroupMapper.delete(deleteWrapper); |
| | | List<String> groups = new ArrayList<>(); |
| | | if (groupIds != null && !groupIds.isEmpty()) { |
| | | if (!ObjectUtils.isEmpty(groupIds)) { |
| | | groupIds.forEach(groupId -> { |
| | | groups.add(groupMapper.selectById(groupId).getGroupName()); |
| | | UserGroup userGroup = new UserGroup(); |
| | |
| | | |
| | | //日志 |
| | | String account = userMapper.selectById((Integer) parameters.get("userId")).getAccount(); |
| | | String content = "给用户:" + account + "分配了组:" + groups.toString(); |
| | | String content = "给用户:" + account + "分配了组:" + groups; |
| | | operationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getGroupIds(Integer userId) { |
| | | QueryWrapper<UserGroup> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id", userId).eq("is_delete", Constants.NOT_DELETE); |
| | | List<UserGroup> userGroups = userGroupMapper.selectList(queryWrapper); |
| | | List<Integer> groupIds = new ArrayList<>(); |
| | | userGroups.forEach(userGroup -> groupIds.add(userGroup.getGroupId())); |
| | | return groupIds; |
| | | } |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | * @since 2021-03-09 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Value("${AES.KEY}") |
| | | private String AESKey; |
| | | |
| | | |
| | | @Override |
| | | public UserBO selectUserInfo(Map<String, Object> parameters) { |
| | |
| | | try { |
| | | //生成token,并存入redis |
| | | String token = TokenUtils.getToken(userBo.getId().toString(), userInfo); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("token", token); |
| | | data.put("user", userInfo); |
| | | result.put("data", data); |
| | | result.put("token", token); |
| | | } catch (Exception e) { |
| | | log.error("token生成异常:" + e.getMessage()); |
| | | result.put("code", ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode()); |
| | | result.put("msg", ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg()); |
| | | return result; |
| | | } |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | |
| | | userLog.setContent("登陆了用户:" + userBo.getAccount()); |
| | | userLogMapper.insert(userLog); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getUserInfo(String token) { |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | | return userInfo; |
| | | } |
| | | |
| | | @Override |
| | |
| | | oneMenu.forEach(o -> { |
| | | Map<String, Object> menuMap = new LinkedHashMap<>(); |
| | | menuMap.put("id", o.getId()); |
| | | menuMap.put("name", o.getName()); |
| | | menuMap.put("label", o.getName()); |
| | | menuMap.put("url", o.getUrl()); |
| | | menuMap.put("icon", o.getIcon()); |
| | | menuMap.put("child", getMenusByRecursion(o, allMenus)); |
| | | menuMap.put("children", getMenusByRecursion(o, allMenus)); |
| | | newList.add(menuMap); |
| | | }); |
| | | resultMap.put("menus", newList); |
| | |
| | | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("account", user.getAccount()).eq("is_delete", Constants.NOT_DELETE); |
| | | //校验账户是否存在 |
| | | if (user.selectOne(queryWrapper) != null) { |
| | | if (user.selectCount(queryWrapper) > 0) { |
| | | result.put("code", ResponseCodeEnum.ACCOUNT_EXIST.getCode()); |
| | | result.put("msg", ResponseCodeEnum.ACCOUNT_EXIST.getMsg()); |
| | | return result; |
| | | } |
| | | //正则校验账户 |
| | | //校验账户 |
| | | if (!RegexUtils.checkAccount(user.getAccount())) { |
| | | result.put("code", ResponseCodeEnum.ACCOUNT_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.ACCOUNT_INVALID.getMsg()); |
| | | return result; |
| | | } |
| | | //正则校验账户 |
| | | if (user.getEmail() != null && !RegexUtils.checkEmail(user.getEmail())) { |
| | | |
| | | //校验邮箱 |
| | | if (!ObjectUtils.isEmpty(user.getEmail()) && !RegexUtils.checkEmail(user.getEmail())) { |
| | | result.put("code", ResponseCodeEnum.EMAIL_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.EMAIL_INVALID.getMsg()); |
| | | return result; |
| | | } |
| | | //正则校验密码 |
| | | //校验密码 |
| | | String password = user.getPassword(); |
| | | //密码解密 |
| | | password = AESUtils.decrypt(password, AESKey); |
| | |
| | | result.put("msg", ResponseCodeEnum.PASSWORD_INVALID.getMsg()); |
| | | return result; |
| | | } |
| | | //正则校验手机号 |
| | | if (user.getMobile() != null && !RegexUtils.checkMobile(user.getMobile())) { |
| | | //校验手机号 |
| | | if (!ObjectUtils.isEmpty(user.getMobile()) && !RegexUtils.checkMobile(user.getMobile())) { |
| | | result.put("code", ResponseCodeEnum.MOBILE_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.MOBILE_INVALID.getMsg()); |
| | | return result; |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void deleteUser(User user) { |
| | | String userId = user.getId().toString(); |
| | | public void deleteUser(Integer userId) { |
| | | User user = userMapper.selectById(userId); |
| | | //逻辑删除user |
| | | user.setIsDelete(Constants.DELETE); |
| | | userMapper.updateById(user); |
| | | UpdateWrapper<User> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", userId).set("is_delete", Constants.DELETE); |
| | | userMapper.update(null, updateWrapper); |
| | | //删除user_group |
| | | UpdateWrapper<UserGroup> deleteWrapper = new UpdateWrapper<>(); |
| | | deleteWrapper.eq("user_id", userId); |
| | | userGroupMapper.delete(deleteWrapper); |
| | | //更新redis |
| | | if (TokenUtils.hHasKey(userId)) { |
| | | String token = TokenUtils.hget(userId).toString(); |
| | | TokenUtils.destoryToken(userId, token); |
| | | //清楚redis |
| | | if (TokenUtils.hHasKey(userId.toString())) { |
| | | String token = TokenUtils.hget(userId.toString()).toString(); |
| | | TokenUtils.destoryToken(userId.toString(), token); |
| | | } |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String token = request.getHeader("token"); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | //更新的属性 |
| | | Map<String, Object> update = JSONObject.parseObject(JSON.toJSONString(user), Map.class); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | | User beforeUser = userMapper.selectById(user.getId()); |
| | | Map<String, Object> before = JSONObject.parseObject(JSON.toJSONString(beforeUser), Map.class); |
| | | String account = beforeUser.getAccount(); |
| | | /*String account = beforeUser.getAccount(); |
| | | //account不可修改 |
| | | user.setAccount(account); |
| | | user.setAccount(account);*/ |
| | | System.out.println(user); |
| | | if (!ObjectUtils.isEmpty(user.getAccount())) { |
| | | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE).eq("account", user.getAccount()); |
| | | if (userMapper.selectCount(queryWrapper) > 0) { |
| | | result.put("code", ResponseCodeEnum.ACCOUNT_EXIST.getCode()); |
| | | result.put("msg", ResponseCodeEnum.ACCOUNT_EXIST.getMsg()); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | //邮箱校验 |
| | | if (user.getEmail() != null && !RegexUtils.checkEmail(user.getEmail())) { |
| | | if (!ObjectUtils.isEmpty(user.getEmail()) && !RegexUtils.checkEmail(user.getEmail())) { |
| | | result.put("code", ResponseCodeEnum.EMAIL_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.EMAIL_INVALID.getMsg()); |
| | | return result; |
| | | } |
| | | //密码校验 |
| | | String password = user.getPassword(); |
| | | if (password != null) { |
| | | System.out.println("password==" + password); |
| | | if (!ObjectUtils.isEmpty(password)) { |
| | | //密码解密 |
| | | password = AESUtils.decrypt(password, AESKey); |
| | | if (!RegexUtils.checkPassword(password)) { |
| | |
| | | } |
| | | |
| | | //正则校验手机号 |
| | | if (user.getMobile() != null && !RegexUtils.checkMobile(user.getMobile())) { |
| | | if (!ObjectUtils.isEmpty(user.getMobile()) && !RegexUtils.checkMobile(user.getMobile())) { |
| | | result.put("code", ResponseCodeEnum.MOBILE_INVALID.getCode()); |
| | | result.put("msg", ResponseCodeEnum.MOBILE_INVALID.getMsg()); |
| | | return result; |
| | |
| | | } |
| | | } |
| | | operationLogUtils.insertLog(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization"); |
| | | QueryWrapper<User> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("organization_id", orgInfo.get("id")) |
| | | .eq("is_delete", Constants.NOT_DELETE); |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .eq("is_admin", false); |
| | | Object order = parameters.get("order"); |
| | | Object orderType = parameters.get("orderType"); |
| | | Object account = parameters.get("account"); |
| | |
| | | queryWrapper.like("wechat", wechat); |
| | | } |
| | | |
| | | Integer page = (Integer) parameters.get("page"); |
| | | Integer size = (Integer) parameters.get("size"); |
| | | int page = Integer.parseInt(parameters.get("page").toString()); |
| | | int size = Integer.parseInt(parameters.get("size").toString()); |
| | | Page<User> pageData = new Page<>(page, size); |
| | | //排序参数,默认create_time降序 |
| | | if (order != null && orderType != null) { |
| | |
| | | spring: |
| | | profiles: |
| | | active: dev |
| | | include: |
| | | moduleFormColumn |
| | | application: |
| | | name: screen-manage |
| | | name: screen-api |
| | | redis: |
| | | host: r-bp1xdlb9wfc6zt0msp.redis.rds.aliyuncs.com |
| | | port: 6379 |
| | |
| | | enable: |
| | | auto: |
| | | commit: false |
| | | group: |
| | | id: test |
| | | servers: 192.168.0.191:9092 |
| | | servers: 172.16.44.65:9092,172.16.44.67:9092,172.16.44.66:9092 |
| | | session: |
| | | timeout: 6000 |
| | | topic: test_topic |
| | | zookeeper: |
| | | connect: 192.168.0.16:2181,192.168.0.17:2181,192.168.0.18:2181 |
| | | connect: 172.16.44.65:2181,172.16.44.67:2181,172.16.44.66:2181 |
| | | producer: |
| | | batch: |
| | | size: 4096 |
| | |
| | | memory: 40960 |
| | | linger: 1 |
| | | retries: 0 |
| | | servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092 |
| | | servers: 172.16.44.65:9092,172.16.44.67:9092,172.16.44.66:9092 |
| | | mvc: |
| | | interceptor: |
| | | exclude: |
| | |
| | | <result column="is_delete" property="isDelete"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="GroupResultMap" type="java.util.LinkedHashMap"> |
| | | <id column="id" property="id"/> |
| | | <result column="group_name" property="groupName"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectUserGroup" resultMap="GroupResultMap"> |
| | | SELECT g.id,g.group_name |
| | | FROM `group` g,`user_group` ug |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.GroupMenuMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.GroupMenu"> |
| | | <id column="id" property="id" /> |
| | | <result column="group_id" property="groupId" /> |
| | | <result column="menu_id" property="menuId" /> |
| | | <result column="channel_key" property="channelKey" /> |
| | | <result column="organization_id" property="organizationId" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="is_delete" property="isDelete" /> |
| | | </resultMap> |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.GroupMenu"> |
| | | <id column="id" property="id"/> |
| | | <result column="group_id" property="groupId"/> |
| | | <result column="menu_id" property="menuId"/> |
| | | <result column="channel_key" property="channelKey"/> |
| | | <result column="organization_id" property="organizationId"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="is_delete" property="isDelete"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | </sql> |
| | | |
| | | <select id="selectUserMenu" resultMap="BaseResultMap"> |
| | | select |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | FROM `user_group` ug,`group_menu` gm,`menu` m |
| | | WHERE ug.user_id = #{userId} |
| | |
| | | </select> |
| | | |
| | | <select id="selectOrganizationMenu" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | FROM `menu` m, `organization_menu` om |
| | | WHERE om.organization_id = #{orgId} |
| | | AND m.id = om.menu_id |
| | | AND om.channel_key = 0 |
| | | AND om.menu_id = m.id |
| | | AND om.is_delete = 0 |
| | | SELECT |
| | | DISTINCT m.id, m.name, m.url, m.icon, m.parent_id, m.order, m.create_time, m.update_time |
| | | FROM `menu` m, `group_menu` gm |
| | | WHERE gm.organization_id = #{orgId} |
| | | AND m.id = gm.menu_id |
| | | AND gm.channel_key = 0 |
| | | AND gm.is_delete = 0 |
| | | AND m.is_delete = 0 |
| | | </select> |
| | | </mapper> |
| | |
| | | * */ |
| | | public static final String UN_ADJUST = "unadjust"; |
| | | |
| | | /* |
| | | * 离线设备状态码 |
| | | * */ |
| | | public static final String DEVICE_STATE_OFFLINE = "4"; |
| | | |
| | | |
| | | } |
| | |
| | | /** |
| | | * 分钟数据主题 |
| | | */ |
| | | public static final String TOPIC_MINUTE = "test_topic"; |
| | | public static final String TOPIC_MINUTE = "minute"; |
| | | |
| | | /** |
| | | * 小时数据主题 |
| | | */ |
| | | public static final String TOPIC_HOUR = "hour"; |
| | | |
| | | /* |
| | | * 秒数据主题 |
| | | * */ |
| | | public static final String TOPIC_SECOND = "test"; |
| | | |
| | | /** |
| | | * 消费组 |
| | | * 用于将数据存入数据库的消费组 |
| | | */ |
| | | public static final String GROUP_ID = "test"; |
| | | public static final String GROUP_ID_INSERT = "insert"; |
| | | |
| | | /** |
| | | * 用于判断设备状态消费组 |
| | | */ |
| | | public static final String GROUP_ID_STATE = "state"; |
| | | } |
| | |
| | | /* |
| | | * 设备信息前缀 |
| | | * */ |
| | | public static final String DEVICE = "device"; |
| | | public static final String DEVICE = "device_"; |
| | | |
| | | /* |
| | | * 设备状态信息前缀 |
| | | * 存储设备显示单位,报警等级以及单位转换公式 |
| | | * 数据类型:hash |
| | | * key:mac |
| | | * value:Device |
| | | * 接收类型:Map<String,Device> |
| | | * */ |
| | | public static final String STATE = "state"; |
| | | public static final String DEVICE_INFO = "device_alarm_info"; |
| | | |
| | | /* |
| | | * 存储设备显示单位,报警等级以及单位转换公式 |
| | | * 数据类型:hash |
| | | * key:mac |
| | | * value:Device |
| | | * 接收类型:Map<String,Device> |
| | | * */ |
| | | public static final String DEVICE_INFO = "device_alarm_info"; |
| | | * 设备校准公式前缀 |
| | | * */ |
| | | public static final String ADJUST = "adjust_"; |
| | | |
| | | /* |
| | | * 设备实时数据 |
| | | * */ |
| | | public static final String DEVICE_DATA = "data_"; |
| | | |
| | | /* |
| | | * 设备实时数据 |
| | | * */ |
| | | public static final String AQI_DATA = "aqi_"; |
| | | |
| | | |
| | | } |
| | |
| | | * 日期格式(HH:mm:ss) |
| | | */ |
| | | public static final String HH_mm_ss_EN = "HH:mm:ss"; |
| | | /* |
| | | * 日期格式(yyyy-MM-dd HH:mm) |
| | | * */ |
| | | public static final String yyyy_MM_dd_HH_mm_EN = "yyyy-MM-dd HH:mm"; |
| | | /* |
| | | * 日期格式(yyyy-MM-dd HH) |
| | | * */ |
| | | public static final String yyyy_MM_dd_HH_EN = "yyyy-MM-dd HH"; |
| | | /** |
| | | * DateFormat缓存 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description: 获取指定日期day天后的日期 |
| | | * @Param: [date, day] |
| | | * @return: java.util.Date |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/30 |
| | | */ |
| | | * @Description: 获取指定日期day天后的日期 |
| | | * @Param: [date, day] |
| | | * @return: java.util.Date |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/30 |
| | | */ |
| | | public static Date getDateOfDay(Date date, int day) { |
| | | if(date==null) |
| | | if (date == null) |
| | | return null; |
| | | Calendar now = Calendar.getInstance(TimeZone.getDefault()); |
| | | now.setTime(date); |
| | |
| | | return date; |
| | | } |
| | | |
| | | //当前时间转换,只取到分钟 |
| | | public static Date convertDate(Date date) { |
| | | String dateString = dateToDateString(date, yyyy_MM_dd_HH_mm_EN); |
| | | return getDate(dateString, yyyy_MM_dd_HH_mm_EN); |
| | | } |
| | | |
| | | //时间戳转换,只取时分秒 |
| | | public static Date dataToTimeStampTime(Date time, String dateFormat) { |
| | | String dateString = dateToDateString(time, dateFormat); |
| | | try { |
| | | return getDateFormat(dateFormat).parse(dateString); |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) throws InterruptedException { |
| | | Date date1 = new Date(); |
| | | Thread.sleep(1000); |
| | | Date date2 = new Date(); |
| | | System.out.println(DateUtils.compareDateStr(date1, date2)); |
| | | System.out.println(new Date().getTime()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.config.redis; |
| | | |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.data.redis.connection.RedisConnectionFactory; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
| | | import com.fasterxml.jackson.annotation.PropertyAccessor; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | |
| | | |
| | | @Configuration |
| | | public class RedisConfig { |
| | | |
| | | @Bean(name = "redisTemplate") |
| | | @ConditionalOnMissingBean(StringRedisTemplate.class) //此注解的作用 如果容器中没有RedisTemplate 那就注入 有就不注入了 |
| | | public RedisTemplate<String, Object> stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) { |
| | | RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); |
| | | redisTemplate.setConnectionFactory(redisConnectionFactory); |
| | | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
| | | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
| | | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); |
| | | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); |
| | | // key采用String的序列化方式 |
| | | redisTemplate.setKeySerializer(stringRedisSerializer); |
| | | // hash的key也采用String的序列化方式 |
| | | redisTemplate.setHashKeySerializer(stringRedisSerializer); |
| | | // valuevalue采用jackson序列化方式 |
| | | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); |
| | | // hash的value采用jackson序列化方式 |
| | | redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); |
| | | redisTemplate.afterPropertiesSet(); |
| | | redisTemplate.afterPropertiesSet(); |
| | | return redisTemplate; |
| | | } |
| | | |
| | | public RedisTemplate createRedisTemplate(RedisConnectionFactory redisConnectionFactory) { |
| | | RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); |
| | | redisTemplate.setConnectionFactory(redisConnectionFactory); |
| | | |
| | | Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
| | | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
| | | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); |
| | | |
| | | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); |
| | | // key采用String的序列化方式 |
| | | redisTemplate.setKeySerializer(stringRedisSerializer); |
| | | // hash的key也采用String的序列化方式 |
| | | redisTemplate.setHashKeySerializer(stringRedisSerializer); |
| | | // valuevalue采用jackson序列化方式 |
| | | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); |
| | | // hash的value采用jackson序列化方式 |
| | | redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); |
| | | redisTemplate.afterPropertiesSet(); |
| | | redisTemplate.afterPropertiesSet(); |
| | | return redisTemplate; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.config.xxljob; |
| | | |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; |
| | | |
| | | @Configuration |
| | | @ComponentScan(basePackages = "com.moral.api.job") |
| | | @Slf4j |
| | | public class XxlJobConfig { |
| | | |
| | | @Value("${xxl.job.admin.addresses}") |
| | | private String adminAddresses; |
| | | |
| | | @Value("${xxl.job.executor.appname}") |
| | | private String appName; |
| | | |
| | | @Value("${xxl.job.executor.ip}") |
| | | private String ip; |
| | | |
| | | @Value("${xxl.job.executor.port}") |
| | | private Integer port; |
| | | |
| | | @Value("${xxl.job.accessToken}") |
| | | private String accessToken; |
| | | |
| | | @Value("${xxl.job.executor.logpath}") |
| | | private String logPath; |
| | | |
| | | @Value("${xxl.job.executor.logretentiondays}") |
| | | private Integer logRetentionDays; |
| | | |
| | | @Bean |
| | | public XxlJobSpringExecutor xxlJobSpringExecutor() { |
| | | log.info("xxl jon config init"); |
| | | XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); |
| | | xxlJobSpringExecutor.setAdminAddresses(adminAddresses); |
| | | xxlJobSpringExecutor.setAppname(appName); |
| | | xxlJobSpringExecutor.setIp(ip); |
| | | xxlJobSpringExecutor.setPort(port); |
| | | xxlJobSpringExecutor.setAccessToken(accessToken); |
| | | xxlJobSpringExecutor.setLogPath(logPath); |
| | | xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); |
| | | return xxlJobSpringExecutor; |
| | | } |
| | | |
| | | /** |
| | | * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP; |
| | | * |
| | | * 1、引入依赖: |
| | | * <dependency> |
| | | * <groupId>org.springframework.cloud</groupId> |
| | | * <artifactId>spring-cloud-commons</artifactId> |
| | | * <version>${version}</version> |
| | | * </dependency> |
| | | * |
| | | * 2、配置文件,或者容器启动变量 |
| | | * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.' |
| | | * |
| | | * 3、获取IP |
| | | * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
| | | */ |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * 墨迹天气aqi城市配置 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class CityAqiConfig extends Model<CityAqiConfig> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 城市code |
| | | */ |
| | | private String cityCode; |
| | | |
| | | /** |
| | | * 城市名字 |
| | | */ |
| | | private String cityName; |
| | | |
| | | /** |
| | | * 墨迹天气接口中城市id |
| | | */ |
| | | private Integer cityId; |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * 设备表 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-22 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class Device extends Model<Device> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * mac号 |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * 设备地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 经度 |
| | | */ |
| | | private Double longitude; |
| | | |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | private Double latitude; |
| | | |
| | | /** |
| | | * 设备状态,与字典表关联 |
| | | */ |
| | | private String state; |
| | | |
| | | /** |
| | | * 维护人id,多个逗号隔开,来源于manage_account |
| | | */ |
| | | private String operateIds; |
| | | |
| | | /** |
| | | * 站点id |
| | | */ |
| | | private Integer monitorPointId; |
| | | |
| | | /** |
| | | * 组织id |
| | | */ |
| | | private Integer organizationId; |
| | | |
| | | /** |
| | | * 设备型号id |
| | | */ |
| | | private Integer deviceVersionId; |
| | | |
| | | /** |
| | | * 行业,与字典表关联 |
| | | */ |
| | | private String profession; |
| | | |
| | | /** |
| | | * 设备工艺,1:烟道;2:厂界;3:车间,基本数据在字典表 |
| | | */ |
| | | private String tech; |
| | | |
| | | /** |
| | | * 设备检测器,与字典表关联 |
| | | */ |
| | | private String detector; |
| | | |
| | | /** |
| | | * 采购商,与字典表关联 |
| | | */ |
| | | private String purchaser; |
| | | |
| | | /** |
| | | * 创建(生产)时间 |
| | | */ |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * 安装时间 |
| | | */ |
| | | private LocalDateTime installTime; |
| | | |
| | | /** |
| | | * 逻辑删除,0:不删除;1:删除 |
| | | */ |
| | | private String isDelete; |
| | | |
| | | /** |
| | | * 设备工艺扩展字段 |
| | | */ |
| | | private String extend; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * 国控aqi数据表 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class HistoryAqi extends Model<HistoryAqi> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 城市code |
| | | */ |
| | | private String cityCode; |
| | | |
| | | /** |
| | | * 时间 |
| | | */ |
| | | private Date time; |
| | | |
| | | /** |
| | | * 数据 |
| | | */ |
| | | private String value; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-11 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class HistoryDaily extends Model<HistoryDaily> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String mac; |
| | | |
| | | private Date time; |
| | | |
| | | private String value; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import com.moral.api.entity.CityAqiConfig; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * 墨迹天气aqi城市配置 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | public interface CityAqiConfigMapper extends BaseMapper<CityAqiConfig> { |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * 设备表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-22 |
| | | */ |
| | | public interface DeviceMapper extends BaseMapper<Device> { |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import com.moral.api.entity.HistoryAqi; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * 国控aqi数据表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | public interface HistoryAqiMapper extends BaseMapper<HistoryAqi> { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.HistoryDaily; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-11 |
| | | */ |
| | | public interface HistoryDailyMapper extends BaseMapper<HistoryDaily> { |
| | | |
| | | void insertHistoryDaily(List<HistoryDaily> list); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface HistoryFiveMinutelyMapper { |
| | | |
| | | void createTable(String timeUnits); |
| | | |
| | | void insertHistoryFiveMinutely(@Param("list") List<Map<String, Object>> list, @Param("timeUnits") String timeUnits); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface HistoryMinutelyMapper { |
| | | |
| | | void createTable(String timeUnits); |
| | | |
| | | List<Map<String, Object>> getHistoryFiveMinutelyData(Map<String,Object> params); |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.moral.api.entity.CityAqiConfig; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 墨迹天气aqi城市配置 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | public interface CityAqiConfigService extends IService<CityAqiConfig> { |
| | | |
| | | List<CityAqiConfig> getCityAqiConfigs(); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 设备表 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-22 |
| | | */ |
| | | public interface DeviceService extends IService<Device> { |
| | | |
| | | void judgeOffLineDevice(); |
| | | |
| | | void updateDeviceState(Device device); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.entity.HistoryAqi; |
| | | |
| | | public interface HistoryAqiService extends IService<HistoryAqi> { |
| | | |
| | | void insertHistoryAqi(); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.HistoryDaily; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-11 |
| | | */ |
| | | public interface HistoryDailyService extends IService<HistoryDaily> { |
| | | |
| | | void insertHistoryDaily(List<HistoryDaily> list); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | public interface HistoryFiveMinutelyService { |
| | | |
| | | void createTable(String timeUnits); |
| | | |
| | | void insertHistoryFiveMinutely(); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface HistoryMinutelyService { |
| | | |
| | | void createTable(String timeUnits); |
| | | |
| | | List<Map<String, Object>> getHistoryFiveMinutelyData(Map<String, Object> params); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.moral.api.entity.CityAqiConfig; |
| | | import com.moral.api.mapper.CityAqiConfigMapper; |
| | | import com.moral.api.service.CityAqiConfigService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 墨迹天气aqi城市配置 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | @Service |
| | | public class CityAqiConfigServiceImpl extends ServiceImpl<CityAqiConfigMapper, CityAqiConfig> implements CityAqiConfigService { |
| | | |
| | | @Autowired |
| | | private CityAqiConfigMapper cityAqiConfigMapper; |
| | | |
| | | @Override |
| | | public List<CityAqiConfig> getCityAqiConfigs() { |
| | | return cityAqiConfigMapper.selectList(null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 设备表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-22 |
| | | */ |
| | | @Service |
| | | public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements DeviceService { |
| | | |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | | public void judgeOffLineDevice() { |
| | | QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne("state", Constants.DEVICE_STATE_OFFLINE); |
| | | //获取所有在线设备 |
| | | List<Device> devices = deviceMapper.selectList(queryWrapper); |
| | | for (Device device : devices) { |
| | | Map<String, Object> data = getDataFromRedis(device.getMac()); |
| | | device.setState(Constants.DEVICE_STATE_OFFLINE); |
| | | if (data != null && data.containsKey("DataTime")) { |
| | | long time = Long.parseLong(data.get("DataTime").toString()); |
| | | //超过两分钟无数据就离线 |
| | | if (DateUtils.getDateOfMin(new Date(time), 2).getTime() < new Date().getTime()) { |
| | | updateDeviceState(device); |
| | | } |
| | | } else { |
| | | updateDeviceState(device); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateDeviceState(Device device) { |
| | | UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", device.getId()).set("state", device.getState()); |
| | | deviceMapper.update(null, updateWrapper); |
| | | } |
| | | |
| | | private Map<String, Object> getDataFromRedis(String mac) { |
| | | return (Map<String, Object>) redisTemplate.opsForValue().get(RedisConstants.DEVICE_DATA + mac); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.entity.CityAqiConfig; |
| | | import com.moral.api.entity.HistoryAqi; |
| | | import com.moral.api.mapper.HistoryAqiMapper; |
| | | import com.moral.api.service.CityAqiConfigService; |
| | | import com.moral.api.service.HistoryAqiService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 国控aqi数据表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-15 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class HistoryAqiServiceImpl extends ServiceImpl<HistoryAqiMapper, HistoryAqi> implements HistoryAqiService { |
| | | |
| | | @Autowired |
| | | private HistoryAqiMapper historyAqiMapper; |
| | | |
| | | @Autowired |
| | | private CityAqiConfigService cityAqiConfigService; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | | public void insertHistoryAqi() { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | //获取aqi城市配置 |
| | | List<CityAqiConfig> cityAqiConfigs = cityAqiConfigService.getCityAqiConfigs(); |
| | | for (CityAqiConfig cityAqiConfig : cityAqiConfigs) { |
| | | Map<String, Object> mjMap = restTemplate.getForObject("http://sapi.7drlb.com/api/mj?cityID={1}&apiKey=aqi", Map.class, cityAqiConfig.getCityId()); |
| | | if (ObjectUtils.isEmpty(mjMap)) { |
| | | continue; |
| | | } |
| | | HistoryAqi historyAqi = new HistoryAqi(); |
| | | //city_code |
| | | String cityCode = cityAqiConfig.getCityCode(); |
| | | historyAqi.setCityCode(cityCode); |
| | | Map<String, Object> value = new HashMap<>(); |
| | | Map<String, Object> data = (Map<String, Object>) ((Map) mjMap.get("data")).get("aqi"); |
| | | //数据时间 |
| | | historyAqi.setTime(new Date(Long.parseLong(data.get("pubtime").toString()))); |
| | | value.put("PM25", data.get("pm25C")); |
| | | value.put("PM10", data.get("pm10C")); |
| | | value.put("SO2", data.get("so2C")); |
| | | value.put("NO2", data.get("no2C")); |
| | | value.put("CO", data.get("coC")); |
| | | value.put("O3", data.get("o3C")); |
| | | value.put("AQI", data.get("value")); |
| | | //数据 |
| | | historyAqi.setValue(JSON.toJSONString(value)); |
| | | //数据存入数据库 |
| | | historyAqiMapper.insert(historyAqi); |
| | | //存入redis |
| | | redisTemplate.opsForHash().putAll("aqi_" + cityCode, value); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.moral.api.entity.HistoryDaily; |
| | | import com.moral.api.mapper.HistoryDailyMapper; |
| | | import com.moral.api.service.HistoryDailyService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-11 |
| | | */ |
| | | @Service |
| | | public class HistoryDailyServiceImpl extends ServiceImpl<HistoryDailyMapper, HistoryDaily> implements HistoryDailyService { |
| | | |
| | | @Autowired |
| | | private HistoryDailyMapper historyDailyMapper; |
| | | |
| | | @Override |
| | | public void insertHistoryDaily(List<HistoryDaily> list) { |
| | | System.out.println(list); |
| | | historyDailyMapper.insertHistoryDaily(list); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.mapper.HistoryFiveMinutelyMapper; |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | | import com.moral.api.service.HistoryMinutelyService; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | @Service |
| | | public class HistoryFiveMinutelyServiceImpl implements HistoryFiveMinutelyService { |
| | | |
| | | @Autowired |
| | | private HistoryFiveMinutelyMapper historyFiveMinutelyMapper; |
| | | |
| | | @Autowired |
| | | private HistoryMinutelyService historyMinutelyService; |
| | | |
| | | @Override |
| | | public void createTable(String timeUnits) { |
| | | historyFiveMinutelyMapper.createTable(timeUnits); |
| | | } |
| | | |
| | | @Override |
| | | public void insertHistoryFiveMinutely() { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //开始时间(分钟) |
| | | Date start = DateUtils.convertDate(DateUtils.getDateOfMin(-5)); |
| | | //结束时间(分钟) |
| | | Date end = DateUtils.convertDate(new Date()); |
| | | params.put("start", start); |
| | | params.put("end", end); |
| | | //分钟表后缀 |
| | | String timeUnits = DateUtils.dateToDateString(start, DateUtils.yyyyMM_EN); |
| | | params.put("timeUnits", timeUnits); |
| | | |
| | | //因子 |
| | | |
| | | params.put("sensorKeys", null); |
| | | |
| | | historyMinutelyService.getHistoryFiveMinutelyData(params); |
| | | /*List<Map<String, Object>> list = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mac", "123456"); |
| | | Date date = new Date(); |
| | | map.put("time", date); |
| | | Map<String, Object> value = new HashMap<>(); |
| | | value.put("e1", 10); |
| | | value.put("e2", 20); |
| | | map.put("value", JSON.toJSONString(value)); |
| | | list.add(map);*/ |
| | | |
| | | historyFiveMinutelyMapper.insertHistoryFiveMinutely(null, null); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.mapper.HistoryMinutelyMapper; |
| | | import com.moral.api.service.HistoryMinutelyService; |
| | | |
| | | @Service |
| | | public class HistoryMinutelyServiceImpl implements HistoryMinutelyService { |
| | | |
| | | @Autowired |
| | | private HistoryMinutelyMapper historyMinutelyMapper; |
| | | |
| | | @Override |
| | | public void createTable(String timeUnits) { |
| | | historyMinutelyMapper.createTable(timeUnits); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getHistoryFiveMinutelyData(Map<String, Object> params) { |
| | | return historyMinutelyMapper.getHistoryFiveMinutelyData(params); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.task; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | | import com.moral.api.service.HistoryMinutelyService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.DateUtils; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | |
| | | @Component |
| | | public class CreateTableTask { |
| | | |
| | | @Autowired |
| | | private HistoryFiveMinutelyService historyFiveMinutelyService; |
| | | |
| | | @Autowired |
| | | private HistoryMinutelyService historyMinutelyService; |
| | | |
| | | |
| | | //分钟表创建任务 |
| | | @XxlJob("createHistoryMinutelyTable") |
| | | public ReturnT createHistoryMinutelyTable() { |
| | | String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN); |
| | | try { |
| | | //已校准分钟表 |
| | | historyMinutelyService.createTable(timeUnits); |
| | | //未校准分钟表 |
| | | historyMinutelyService.createTable(timeUnits + "_" + Constants.UN_ADJUST); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return ReturnT.FAIL; |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | //5分钟表创建任务 |
| | | @XxlJob("createHistoryFiveMinutelyTable") |
| | | public ReturnT createHistoryFiveMinutelyTable() { |
| | | String timeUnits = DateUtils.getDateStringOfMon(1, DateUtils.yyyyMM_EN); |
| | | try { |
| | | historyFiveMinutelyService.createTable(timeUnits); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return ReturnT.FAIL; |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.task; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.moral.api.service.HistoryAqiService; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | |
| | | @Component |
| | | public class HistoryAqiInsertTask { |
| | | |
| | | @Autowired |
| | | private HistoryAqiService historyAqiService; |
| | | |
| | | @XxlJob("insertHistoryAqi") |
| | | public ReturnT insertHistoryAqi() { |
| | | try { |
| | | historyAqiService.insertHistoryAqi(); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return ReturnT.FAIL; |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.task; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.entity.HistoryDaily; |
| | | import com.moral.api.service.HistoryDailyService; |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | |
| | | @Component |
| | | public class HistoryTableInsertTask { |
| | | |
| | | @Autowired |
| | | private HistoryDailyService historyDailyService; |
| | | |
| | | @Autowired |
| | | private HistoryFiveMinutelyService historyFiveMinutelyService; |
| | | |
| | | //5分钟数据统计 |
| | | @XxlJob("insertHistoryFiveMinutely") |
| | | public ReturnT insertHistoryFiveMinutely() { |
| | | try { |
| | | /* List<Map<String, Object>> list = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mac", "123456"); |
| | | Date date = new Date(); |
| | | map.put("time", date); |
| | | Map<String, Object> value = new HashMap<>(); |
| | | value.put("e1", 10); value.put("e2", 20); |
| | | map.put("value", JSON.toJSONString(value)); |
| | | list.add(map); |
| | | String timeUnits = DateUtils.dateToDateString(date, DateUtils.yyyyMM_EN);*/ |
| | | |
| | | historyFiveMinutelyService.insertHistoryFiveMinutely(); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return ReturnT.FAIL; |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | //天数据统计 |
| | | @XxlJob("insertHistoryDaily") |
| | | public ReturnT insertHistoryDaily() { |
| | | try { |
| | | List<HistoryDaily> list = new ArrayList<>(); |
| | | HistoryDaily historyDaily = new HistoryDaily(); |
| | | historyDaily.setMac("123456"); |
| | | historyDaily.setTime(new Date()); |
| | | Map<String, Object> value = new HashMap<>(); |
| | | value.put("e1", 1); |
| | | value.put("e2", 2); |
| | | historyDaily.setValue(JSON.toJSONString(value)); |
| | | for (int i = 0; i < 20000; i++) { |
| | | list.add(historyDaily); |
| | | } |
| | | historyDailyService.insertHistoryDaily(list); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return ReturnT.FAIL; |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.task; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.moral.api.service.DeviceService; |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | | import com.xxl.job.core.context.XxlJobHelper; |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | |
| | | @Component |
| | | public class JudgeOffLineDeviceTask { |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | //判断设备是否离线 |
| | | @XxlJob("judgeOffLineDevice") |
| | | public ReturnT judgeOffLineDevice() { |
| | | try { |
| | | deviceService.judgeOffLineDevice(); |
| | | } catch (Exception e) { |
| | | XxlJobHelper.log(e.getMessage()); |
| | | return ReturnT.FAIL; |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | } |
| | |
| | | |
| | | logging: |
| | | config: classpath:logback.xml |
| | | |
| | | xxl: |
| | | job: |
| | | admin: |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <configuration> |
| | | <include resource="org/springframework/boot/logging/logback/defaults.xml"/> |
| | | |
| | | <springProperty scope="context" name="springAppName" source="spring.application.name"/> |
| | | <!-- 日志在工程中的输出位置 --> |
| | | <property name="LOG_FILE" value="/home/moral/soft/log/${springAppName}"/> |
| | | <!-- 控制台的日志输出样式 --> |
| | | <property name="CONSOLE_LOG_PATTERN" |
| | | value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%X{logseq}]{faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr([${springAppName}]){yellow} %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/> |
| | | |
| | | <property name="FILE_LOG_PATTERN" |
| | | value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{logseq}] [%thread] %X{T} [%level] %logger.%method:%line %msg%n"/> |
| | | |
| | | <!-- 控制台Appender --> |
| | | <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> |
| | | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
| | | <level>INFO</level> |
| | | </filter> |
| | | <encoder> |
| | | <pattern>${CONSOLE_LOG_PATTERN}</pattern> |
| | | <charset>utf8</charset> |
| | | </encoder> |
| | | </appender> |
| | | <!-- 日志记录Appender --> |
| | | <appender name="screenJobLog" class="ch.qos.logback.classic.sift.SiftingAppender"> |
| | | <discriminator> |
| | | <key>taskId</key> |
| | | <defaultValue>default</defaultValue> |
| | | </discriminator> |
| | | <sift> |
| | | <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | |
| | | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
| | | <level>INFO</level> |
| | | </filter> |
| | | <file>${LOG_FILE}/%d{yyyy-MM-dd}/${springAppName}.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
| | | <maxFileSize>30MB</maxFileSize> |
| | | <fileNamePattern>${LOG_FILE}/%d{yyyy-MM-dd}/${springAppName}-%d{yyyy-MM-dd}.log%i.log</fileNamePattern> |
| | | <maxHistory>30</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${FILE_LOG_PATTERN}</pattern> |
| | | <charset>utf8</charset> |
| | | </encoder> |
| | | </appender> |
| | | </sift> |
| | | </appender> |
| | | |
| | | |
| | | <root level="INFO"> |
| | | <appender-ref ref="console"/> |
| | | <appender-ref ref="screenJobLog"/> |
| | | </root> |
| | | </configuration> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.CityAqiConfigMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.CityAqiConfig"> |
| | | <id column="id" property="id"/> |
| | | <result column="city_code" property="cityCode"/> |
| | | <result column="city_name" property="cityName"/> |
| | | <result column="city_id" property="cityId"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.DeviceMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.Device"> |
| | | <id column="id" property="id" /> |
| | | <result column="name" property="name" /> |
| | | <result column="mac" property="mac" /> |
| | | <result column="address" property="address" /> |
| | | <result column="longitude" property="longitude" /> |
| | | <result column="latitude" property="latitude" /> |
| | | <result column="state" property="state" /> |
| | | <result column="operate_ids" property="operateIds" /> |
| | | <result column="monitor_point_id" property="monitorPointId" /> |
| | | <result column="organization_id" property="organizationId" /> |
| | | <result column="device_version_id" property="deviceVersionId" /> |
| | | <result column="profession" property="profession" /> |
| | | <result column="tech" property="tech" /> |
| | | <result column="detector" property="detector" /> |
| | | <result column="purchaser" property="purchaser" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="install_time" property="installTime" /> |
| | | <result column="is_delete" property="isDelete" /> |
| | | <result column="extend" property="extend" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistoryAqiMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HistoryAqi"> |
| | | <result column="city_code" property="cityCode" /> |
| | | <result column="time" property="time" /> |
| | | <result column="value" property="value" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistoryDailyMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HistoryDaily"> |
| | | <result column="mac" property="mac"/> |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | </resultMap> |
| | | |
| | | <insert id="insertHistoryDaily" parameterType="com.moral.api.entity.HistoryDaily"> |
| | | INSERT INTO history_daily |
| | | VALUES |
| | | <foreach collection="list" item="item" separator=","> |
| | | (#{item.mac},#{item.time},#{item.value}) |
| | | </foreach> |
| | | </insert> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistoryFiveMinutelyMapper"> |
| | | |
| | | <update id="createTable" parameterType="String"> |
| | | CREATE TABLE IF NOT EXISTS `history_five_minutely_${timeUnits}` ( |
| | | `mac` VARCHAR (20) DEFAULT NULL COMMENT '设备mac', |
| | | `time` datetime DEFAULT NULL COMMENT '数据时间', |
| | | `value` json DEFAULT NULL COMMENT '数据', |
| | | KEY `idx_mac` (`mac`), |
| | | KEY `idx_time` (`time`), |
| | | KEY `idx_mac_time` (`mac`,`time`) |
| | | ) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '5分钟数据表' |
| | | </update> |
| | | |
| | | <insert id="insertHistoryFiveMinutely"> |
| | | INSERT INTO |
| | | history_five_minutely_${timeUnits} |
| | | VALUES |
| | | <foreach collection="list" item="item" separator=","> |
| | | (#{item.mac}, #{item.time}, #{item.value}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistoryMinutelyMapper"> |
| | | |
| | | <update id="createTable" parameterType="String"> |
| | | CREATE TABLE IF NOT EXISTS `history_minutely_${timeUnits}` ( |
| | | `mac` VARCHAR (20) DEFAULT NULL COMMENT '设备mac', |
| | | `time` datetime DEFAULT NULL COMMENT '数据时间', |
| | | `value` json DEFAULT NULL COMMENT '数据', |
| | | `version` INT (11) DEFAULT NULL COMMENT '型号', |
| | | KEY `idx_mac` (`mac`), |
| | | KEY `idx_time` (`time`), |
| | | KEY `idx_mac_time` (`mac`,`time`) |
| | | ) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '分钟数据表' |
| | | </update> |
| | | |
| | | <select id="getHistoryFiveMinutelyData" resultType="java.util.LinkedHashMap"> |
| | | SELECT |
| | | mac |
| | | <foreach collection="sensorKeys" open="," separator="," item="sensorKey"> |
| | | <choose> |
| | | <when test="sensorKey=='e23[0]'"> |
| | | ROUND((CASE WHEN AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))<![CDATA[>]]>0 AND |
| | | AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI()))<![CDATA[>]]>0 |
| | | THEN |
| | | ATAN(AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))/AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI())))*180/PI() |
| | | WHEN AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))>0 AND |
| | | AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI()))<![CDATA[<]]>0 |
| | | THEN |
| | | (ATAN(AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))/AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI())))*180/PI())+180 |
| | | WHEN AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))<![CDATA[<]]>0 AND |
| | | AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI()))<![CDATA[<]]>0 |
| | | THEN |
| | | (ATAN(AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))/AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI())))*180/PI())+180 |
| | | ELSE |
| | | (ATAN(AVG(value->'$.e18[0]'*SIN((value->'$.e23[0]'/180)*PI()))/AVG(value->'$.e18[0]'*COS((value->'$.e23[0]'/180)*PI())))*180/PI())+360 |
| | | END),3) AS '${sensorKey}' |
| | | </when> |
| | | <otherwise> |
| | | ROUND(AVG(value->'$.${sensorKey}[0]'),3) AS '${sensorKey}' |
| | | </otherwise> |
| | | </choose> |
| | | </foreach> |
| | | FROM |
| | | history_minutely_${timeUnits} |
| | | WHERE time <![CDATA[>=]]> #{start} AND time <![CDATA[<]]> #{end} |
| | | GROUP BY mac |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | |
| | | import org.apache.kafka.clients.consumer.ConsumerConfig; |
| | | import org.apache.kafka.common.serialization.StringDeserializer; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; |
| | | import org.springframework.kafka.listener.ConcurrentMessageListenerContainer; |
| | | import org.springframework.kafka.listener.ContainerProperties; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /*@Configuration |
| | | @EnableKafka*/ |
| | | @Configuration |
| | | @EnableKafka |
| | | public class KafkaConsumerConfig { |
| | | @Value("${kafka.consumer.servers}") |
| | | private String servers; |
| | |
| | | private String sessionTimeout; |
| | | @Value("${kafka.consumer.auto.commit.interval}") |
| | | private String autoCommitInterval; |
| | | @Value("${kafka.consumer.groupMenu.id}") |
| | | private String groupId; |
| | | @Value("${kafka.consumer.auto.offset.reset}") |
| | | private String autoOffsetReset; |
| | | @Value("${kafka.consumer.concurrency}") |
| | |
| | | factory.setConcurrency(concurrency); |
| | | factory.getContainerProperties().setPollTimeout(1500); |
| | | factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE); |
| | | |
| | | /*factory.setBatchListener(true);//@KafkaListener 批量消费 每个批次数量在Kafka配置参数中设置ConsumerConfig.MAX_POLL_RECORDS_CONFIG |
| | | factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);//设置提交偏移量的方式*/ |
| | | return factory; |
| | | } |
| | | |
| | | public ConsumerFactory<String, String> consumerFactory() { |
| | | return new DefaultKafkaConsumerFactory<>(consumerConfigs()); |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> consumerConfigs() { |
| | | Map<String, Object> propsMap = new HashMap<>(); |
| | |
| | | propsMap.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, sessionTimeout); |
| | | propsMap.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); |
| | | propsMap.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); |
| | | propsMap.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); |
| | | propsMap.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, autoOffsetReset); |
| | | return propsMap; |
| | | } |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /*@Configuration |
| | | @EnableKafka*/ |
| | | @Configuration |
| | | @EnableKafka |
| | | public class KafkaProducerConfig { |
| | | @Value("${kafka.producer.servers}") |
| | | private String servers; |
| | |
| | | //判断mac是否已存在 |
| | | QueryWrapper<Device> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac", device.getMac()); |
| | | if (deviceService.getOne(queryWrapper) != null) { |
| | | if (deviceService.count(queryWrapper) > 0) { |
| | | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); |
| | | } |
| | | deviceService.insert(device); |
| | |
| | | import com.moral.api.entity.Test; |
| | | import com.moral.api.service.TestService; |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.redis.RedisUtil; |
| | | import com.moral.util.PageResult; |
| | |
| | | } |
| | | |
| | | /** |
| | | * kafka測試 |
| | | * 分钟主题kafka測試 |
| | | */ |
| | | @ApiOperation(value = "kafka測試", notes = "kafka測試") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "data", value = "data", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "kafkaTest", method = RequestMethod.GET) |
| | | public void kafkaTest() { |
| | | kafkaTemplate.send("test_topic", "{'mac': 'p5dnd1234567','DataTime':1623058244104,'e1':10,'e2':20,'ver':2}"); |
| | | @RequestMapping(value = "minuteKafkaTest", method = RequestMethod.GET) |
| | | public void minuteKafkaTest(String data) { |
| | | System.out.println(data); |
| | | kafkaTemplate.send(KafkaConstants.TOPIC_MINUTE, data); |
| | | } |
| | | |
| | | /** |
| | | * 小时主题kafka測試 |
| | | */ |
| | | @ApiOperation(value = "kafka測試", notes = "kafka測試") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "data", value = "data", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | @RequestMapping(value = "hourKafkaTest", method = RequestMethod.GET) |
| | | public void hourKafkaTest(String data) { |
| | | System.out.println(data); |
| | | kafkaTemplate.send(KafkaConstants.TOPIC_HOUR, data); |
| | | } |
| | | |
| | | @GetMapping("testToken") |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <p> |
| | | * 已校准小时表 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-04 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class HistoryHourly extends Model<HistoryHourly> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 设备mac |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * 数据时间 |
| | | */ |
| | | private Date time; |
| | | |
| | | /** |
| | | * 数据 |
| | | */ |
| | | private String value; |
| | | |
| | | /** |
| | | * 型号 |
| | | */ |
| | | private Integer version; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.moral.api.kafka.consumer; |
| | | |
| | | import com.moral.api.constant.TopicConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.kafka.clients.consumer.ConsumerRecord; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.kafka.annotation.KafkaListener; |
| | | import org.springframework.kafka.support.Acknowledgment; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Random; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | | import com.moral.api.service.HistoryMinutelyService; |
| | | import com.moral.constant.KafkaConstants; |
| | | import com.moral.constant.RedisConstants; |
| | | |
| | | //@Component |
| | | @Slf4j |
| | | public class KafkaConsumer { |
| | | |
| | | /* *//** |
| | | * 这是手动提交的消费方式 |
| | | * @param record |
| | | * @param ack |
| | | * @throws Exception |
| | | *//* |
| | | @KafkaListener(topics = TopicConstants.TEST_TOPIC_MESSAGE,groupId = "test") |
| | | public void listenTest(ConsumerRecord<String, String> record , Acknowledgment ack) throws Exception { |
| | | @Autowired |
| | | private HistoryMinutelyService historyMinutelyService; |
| | | |
| | | @Autowired |
| | | private HistoryHourlyService historyHourlyService; |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | //分钟数据 |
| | | @KafkaListener(topics = KafkaConstants.TOPIC_MINUTE, groupId = KafkaConstants.GROUP_ID_INSERT, containerFactory = "kafkaListenerContainerFactory") |
| | | public void listenMinute(ConsumerRecord<String, String> record, Acknowledgment ack) { |
| | | String msg = record.value(); |
| | | System.out.println(msg); |
| | | if (new Random().nextInt(100)<50){ |
| | | log.info(String.format("kafka 消费消息成功---------------- listen1 topic = %s, offset = %d, value = %s ", record.topic(), record.offset(), record.value())); |
| | | try { |
| | | Map<String, Object> data = JSON.parseObject(msg, HashMap.class); |
| | | Object mac = data.get("mac"); |
| | | Object time = data.get("DataTime"); |
| | | Object ver = data.get("ver"); |
| | | if (StringUtils.isEmpty(ver) || StringUtils.isEmpty(time) || StringUtils.isEmpty(mac)) { |
| | | log.warn("some properties is null, param{}", msg); |
| | | ack.acknowledge(); |
| | | return; |
| | | } |
| | | |
| | | //数据过滤 |
| | | data = data.entrySet().stream() |
| | | .filter(map -> { |
| | | String key = map.getKey(); |
| | | return !(key.contains("Min") || key.contains("Max") || key.contains("Cou")); |
| | | }).collect(Collectors.toMap(m -> m.getKey().replaceAll("-Avg", ""), Map.Entry::getValue)); |
| | | data.remove("time"); |
| | | //存入数据库 |
| | | historyMinutelyService.insertHistoryMinutely(data); |
| | | ack.acknowledge(); |
| | | } catch (Exception e) { |
| | | //log.error("param{}" + msg); |
| | | } |
| | | } |
| | | |
| | | }*/ |
| | | //小时数据 |
| | | @KafkaListener(topics = KafkaConstants.TOPIC_HOUR, groupId = KafkaConstants.GROUP_ID_INSERT, containerFactory = "kafkaListenerContainerFactory") |
| | | public void listenHour(ConsumerRecord<String, String> record, Acknowledgment ack) { |
| | | String msg = record.value(); |
| | | try { |
| | | Map<String, Object> data = JSON.parseObject(msg, HashMap.class); |
| | | Object mac = data.get("mac"); |
| | | Object time = data.get("DataTime"); |
| | | Object ver = data.get("ver"); |
| | | if (StringUtils.isEmpty(ver) || StringUtils.isEmpty(time) || StringUtils.isEmpty(mac)) { |
| | | log.warn("some properties is null, param{}", msg); |
| | | ack.acknowledge(); |
| | | return; |
| | | } |
| | | |
| | | //数据过滤 |
| | | data = data.entrySet().stream() |
| | | .filter(map -> { |
| | | String key = map.getKey(); |
| | | return !(key.contains("Min") || key.contains("Max") || key.contains("Cou")); |
| | | }).collect(Collectors.toMap(m -> m.getKey().replaceAll("-Avg", ""), Map.Entry::getValue)); |
| | | data.remove("time"); |
| | | //存入数据库 |
| | | historyHourlyService.insertHistoryHourly(data); |
| | | ack.acknowledge(); |
| | | } catch (Exception e) { |
| | | //log.error("param{}" + msg); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //秒数据,修改设备状态,缓存最新秒数据 |
| | | @KafkaListener(topics = KafkaConstants.TOPIC_SECOND, groupId = KafkaConstants.GROUP_ID_STATE, containerFactory = "kafkaListenerContainerFactory") |
| | | public void listenSecond(ConsumerRecord<String, String> record, Acknowledgment ack) { |
| | | String msg = record.value(); |
| | | //System.out.println(record.offset() + "===>" + msg); |
| | | try { |
| | | Map<String, Object> data = JSON.parseObject(msg, HashMap.class); |
| | | Object mac = data.get("mac"); |
| | | Object time = data.get("DataTime"); |
| | | Object ver = data.get("ver"); |
| | | if (StringUtils.isEmpty(ver) || StringUtils.isEmpty(time) || StringUtils.isEmpty(mac)) { |
| | | log.warn("some properties is null, param{}", msg); |
| | | ack.acknowledge(); |
| | | return; |
| | | } |
| | | //数据校准 |
| | | data = deviceService.adjustDeviceData(data); |
| | | //存入redis |
| | | redisTemplate.opsForValue().set(RedisConstants.DEVICE_DATA + mac, data); |
| | | //判断并修改设备状态 |
| | | deviceService.judgeDeviceState(data); |
| | | ack.acknowledge(); |
| | | } catch (Exception e) { |
| | | //log.error("param{}" + msg); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * 小时表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-04 |
| | | */ |
| | | public interface HistoryHourlyMapper extends BaseMapper<HistoryHourly> { |
| | | |
| | | void insertHistoryHourlyUnAdjust(Map<String, Object> params); |
| | | |
| | | } |
| | |
| | | Map<String, Object> getDeviceByMac(String mac); |
| | | |
| | | //设备数据校准 |
| | | Map<String, Object> adjustDeviceData(Map<String, Object> deviceData, Map<String, Object> deviceInfo); |
| | | Map<String, Object> adjustDeviceData(Map<String, Object> deviceData); |
| | | |
| | | //判断并缓存设备状态 |
| | | Map<String, Object> judgeDeviceState(Map<String, Object> data, Map<String, Object> deviceInfo); |
| | | //判断并修改设备状态 |
| | | void judgeDeviceState(Map<String, Object> data); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * 小时表 服务类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-04 |
| | | */ |
| | | public interface HistoryHourlyService extends IService<HistoryHourly> { |
| | | |
| | | void insertHistoryHourly(Map<String, Object> data); |
| | | |
| | | } |
| | |
| | | */ |
| | | public interface HistoryMinutelyService { |
| | | |
| | | void insertHistoryMinutely(Map<String, Object> deviceData); |
| | | void insertHistoryMinutely(Map<String, Object> data); |
| | | |
| | | } |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.googlecode.aviator.AviatorEvaluator; |
| | | import com.googlecode.aviator.Expression; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.*; |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import com.moral.api.util.CacheUtils; |
| | | import com.moral.api.util.AdjustDataUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.ConvertUtils; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | |
| | | * @since 2021-05-11 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements DeviceService { |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private VersionSensorUnitMapper versionSensorUnitMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private AdjustDataUtils adjustDataUtils; |
| | | |
| | | /* |
| | | * 从redis获取设备信息 |
| | | * */ |
| | | private Map<String, Object> getDeviceInfoFromRedis(String mac) { |
| | | Map<String, Object> deviceInfo = (Map<String, Object>) redisTemplate.opsForValue().get(RedisConstants.DEVICE + mac); |
| | | return deviceInfo; |
| | | return (Map<String, Object>) redisTemplate.opsForValue().get(RedisConstants.DEVICE + mac); |
| | | } |
| | | |
| | | /* |
| | | * 设备信息存入redis |
| | | */ |
| | | private void setDeviceInfoToRedis(String mac, Map<String, Object> deviceInfo) { |
| | | redisTemplate.opsForValue().set(getDeviceKey(mac), deviceInfo); |
| | | redisTemplate.opsForValue().set(RedisConstants.DEVICE + mac, deviceInfo); |
| | | } |
| | | |
| | | /* |
| | | * 从redis删除设备信息 |
| | | */ |
| | | private void delDeviceInfoFromRedis(String mac) { |
| | | redisTemplate.delete(getDeviceKey(mac)); |
| | | } |
| | | |
| | | /* |
| | | * 获取设备信息在redis里的key |
| | | */ |
| | | private String getDeviceKey(String mac) { |
| | | return keysConnect(RedisConstants.DEVICE, mac); |
| | | } |
| | | |
| | | //redis key前缀 |
| | | private String keysConnect(String... keys) { |
| | | StringBuilder key = new StringBuilder(keys[0]); |
| | | for (int i = 1; i < keys.length; i++) { |
| | | key.append("_"); |
| | | key.append(keys[i]); |
| | | } |
| | | return key.toString().toLowerCase(); |
| | | redisTemplate.delete(RedisConstants.DEVICE + mac); |
| | | } |
| | | |
| | | @Override |
| | |
| | | deviceMapper.insert(device); |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(device.getId()); |
| | | //维护组织型号关系表 |
| | | insertOrganizationUnitAlarm(orgId,device.getDeviceVersionId()); |
| | | insertOrganizationUnitAlarm(orgId, device.getDeviceVersionId()); |
| | | //新增设备信息存入redis |
| | | String mac = device.getMac(); |
| | | //从redis中删除设备信息 |
| | |
| | | @Override |
| | | @Transactional |
| | | public void delete(Integer deviceId) { |
| | | Device device = deviceMapper.selectById(deviceId); |
| | | UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", deviceId).set("is_delete", Constants.DELETE); |
| | | deviceMapper.update(null, updateWrapper); |
| | | Device device = deviceMapper.selectById(deviceId); |
| | | String mac = device.getMac(); |
| | | //从redis中删除设备信息 |
| | | delDeviceInfoFromRedis(mac); |
| | | //维护组织型号关系表 |
| | | Integer versionId = device.getDeviceVersionId(); |
| | | Integer orgId = device.getOrganizationId(); |
| | | deleteOrganizationUnitAlarm(orgId,versionId); |
| | | deleteOrganizationUnitAlarm(orgId, versionId); |
| | | //刷新deviceInfo缓存 |
| | | CacheUtils.flushDeviceAlarmInfo(); |
| | | //操作日志记录 |
| | |
| | | Integer deviceId = device.getId(); |
| | | Device oldDevice = deviceMapper.selectById(deviceId); |
| | | //判断是否更新了站点,如果更新了站点则查询对应站点的组织id进行更新 |
| | | if(!ObjectUtils.isEmpty(device.getMonitorPointId())){ |
| | | if (!ObjectUtils.isEmpty(device.getMonitorPointId())) { |
| | | MonitorPoint monitorPoint = monitorPointMapper.selectById(device.getMonitorPointId()); |
| | | device.setOrganizationId(monitorPoint.getOrganizationId()); |
| | | } |
| | |
| | | Device updateDevice = deviceMapper.selectById(deviceId); |
| | | String mac = updateDevice.getMac(); |
| | | //维护组织型号关系表 |
| | | Integer oldOrgId = oldDevice.getOrganizationId(); |
| | | Integer newOrgId = updateDevice.getOrganizationId(); |
| | | Integer oldVersionId = oldDevice.getDeviceVersionId(); |
| | | Integer newVersionId = updateDevice.getDeviceVersionId(); |
| | | if(!oldOrgId.equals(newOrgId)||!oldVersionId.equals(newVersionId)){ |
| | | deleteOrganizationUnitAlarm(oldOrgId,oldVersionId); |
| | | insertOrganizationUnitAlarm(newOrgId,newVersionId); |
| | | } |
| | | Integer oldOrgId = oldDevice.getOrganizationId(); |
| | | Integer newOrgId = updateDevice.getOrganizationId(); |
| | | Integer oldVersionId = oldDevice.getDeviceVersionId(); |
| | | Integer newVersionId = updateDevice.getDeviceVersionId(); |
| | | if (!oldOrgId.equals(newOrgId) || !oldVersionId.equals(newVersionId)) { |
| | | deleteOrganizationUnitAlarm(oldOrgId, oldVersionId); |
| | | insertOrganizationUnitAlarm(newOrgId, newVersionId); |
| | | } |
| | | //从redis中删除设备信息 |
| | | delDeviceInfoFromRedis(mac); |
| | | Map<String, Object> deviceInfo = selectDeviceInfoById(deviceId); |
| | |
| | | queryWrapper.eq("monitor_point_id", mpId); |
| | | } |
| | | |
| | | //设备名模糊查询 |
| | | if (name != null) { |
| | | queryWrapper.like("name", name); |
| | | } |
| | | |
| | | //mac模糊查询 |
| | | if (mac != null) { |
| | | queryWrapper.like("mac", mac); |
| | | } |
| | | |
| | | |
| | | //排序参数,默认create_time降序 |
| | | if (order != null && orderType != null) { |
| | |
| | | result.put("item", items); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<String, Object> selectDeviceInfoById(Integer deviceId) { |
| | |
| | | MonitorPoint monitorPoint = device.getMonitorPoint(); |
| | | mpInfo.put("id", monitorPoint.getId()); |
| | | mpInfo.put("name", monitorPoint.getName()); |
| | | mpInfo.put("areaCode", monitorPoint.getAreaCode()); |
| | | mpInfo.put("cityCode", monitorPoint.getCityCode()); |
| | | mpInfo.put("provinceCode", monitorPoint.getProvinceCode()); |
| | | deviceInfo.put("monitorPoint", mpInfo); |
| | | |
| | | setDeviceInfoToRedis(mac, deviceInfo); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> adjustDeviceData(Map<String, Object> deviceData, Map<String, Object> deviceInfo) { |
| | | return null; |
| | | public Map<String, Object> adjustDeviceData(Map<String, Object> deviceData) { |
| | | String mac = deviceData.get("mac").toString(); |
| | | //从redis获取校准公式 |
| | | Map<String, Object> adjustFormula = redisTemplate.opsForHash().entries(RedisConstants.ADJUST + mac); |
| | | if (!ObjectUtils.isEmpty(adjustFormula)) { |
| | | Map<String, Object> deviceInfo = getDeviceByMac(mac); |
| | | Map<String, Object> monitorPoint = (Map<String, Object>) deviceInfo.get("monitorPoint"); |
| | | Object areaCode = monitorPoint.get("areaCode"); |
| | | Object cityCode = monitorPoint.get("cityCode"); |
| | | |
| | | Map<String, Object> aqiMap = redisTemplate.opsForHash().entries(RedisConstants.AQI_DATA + areaCode); |
| | | if (ObjectUtils.isEmpty(aqiMap)) { |
| | | aqiMap = redisTemplate.opsForHash().entries(RedisConstants.AQI_DATA + cityCode); |
| | | } |
| | | return adjustDataUtils.adjust(deviceData, adjustFormula, ObjectUtils.isEmpty(aqiMap) ? null : aqiMap); |
| | | } |
| | | return deviceData; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> judgeDeviceState(Map<String, Object> deviceData, Map<String, Object> deviceInfo) { |
| | | return null; |
| | | public void judgeDeviceState(Map<String, Object> deviceData) { |
| | | String mac = deviceData.remove("mac").toString(); |
| | | Device device = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO, mac); |
| | | Version version = device.getVersion(); |
| | | List<Sensor> sensors = version.getSensors(); |
| | | Expression expression; |
| | | int state = 1; |
| | | for (Sensor sensor : sensors) { |
| | | //因子报警等级 |
| | | String alarmLevel = sensor.getAlarmLevel(); |
| | | if (StringUtils.isEmpty(alarmLevel)) { |
| | | continue; |
| | | } |
| | | List<Double> list = JSONObject.parseObject(alarmLevel, List.class); |
| | | String sensorCode = sensor.getCode(); |
| | | //转换公式 |
| | | String formula = sensor.getFormula(); |
| | | //转换单位前因子值 |
| | | String sensorValue = (String) deviceData.get(sensorCode); |
| | | double value = Double.parseDouble(String.format("%.3f", sensorValue)); |
| | | //单位转换 |
| | | if (formula != null) { |
| | | //转换后因子值 |
| | | sensorValue = formula.replace("{0}", sensorValue); |
| | | expression = AviatorEvaluator.compile(sensorValue); |
| | | value = Double.parseDouble(String.format("%.3f", expression.execute())); |
| | | } |
| | | int sensorState = judgeState(list, value); |
| | | if (sensorState > state) { |
| | | state = sensorState; |
| | | } |
| | | } |
| | | //修改设备状态 |
| | | UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", device.getId()).set("state", state); |
| | | deviceMapper.update(null, updateWrapper); |
| | | } |
| | | |
| | | private void insertOrganizationUnitAlarm(Integer orgId,Integer versionId){ |
| | | //根据因子值判断状态 |
| | | private int judgeState(List<Double> levels, Double data) { |
| | | int state = 1; |
| | | for (int i = levels.size() - 1; i >= 0; i--) { |
| | | Double level = levels.get(i); |
| | | if (data >= level) { |
| | | state = i + 2; |
| | | break; |
| | | } |
| | | } |
| | | return state; |
| | | } |
| | | |
| | | private void insertOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | QueryWrapper<OrganizationUnitAlarm> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | | queryOrganizationVersionWrapper.eq("organization_id",orgId); |
| | | queryOrganizationVersionWrapper.eq("version_id",versionId); |
| | | queryOrganizationVersionWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | queryOrganizationVersionWrapper.eq("organization_id", orgId); |
| | | queryOrganizationVersionWrapper.eq("version_id", versionId); |
| | | queryOrganizationVersionWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<OrganizationUnitAlarm> organizationUnitAlarms = organizationUnitAlarmMapper.selectList(queryOrganizationVersionWrapper); |
| | | if(ObjectUtils.isEmpty(organizationUnitAlarms)){ |
| | | QueryWrapper<VersionSensorUnit> queryVersionSensorUnitWrapper =new QueryWrapper<>(); |
| | | queryVersionSensorUnitWrapper.eq("version_id",versionId); |
| | | queryVersionSensorUnitWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | if (ObjectUtils.isEmpty(organizationUnitAlarms)) { |
| | | QueryWrapper<VersionSensorUnit> queryVersionSensorUnitWrapper = new QueryWrapper<>(); |
| | | queryVersionSensorUnitWrapper.eq("version_id", versionId); |
| | | queryVersionSensorUnitWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<VersionSensorUnit> versionSensorUnits = versionSensorUnitMapper.selectList(queryVersionSensorUnitWrapper); |
| | | if(!ObjectUtils.isEmpty(versionSensorUnits)){ |
| | | if (!ObjectUtils.isEmpty(versionSensorUnits)) { |
| | | for (VersionSensorUnit versionSensorUnit : versionSensorUnits) { |
| | | OrganizationUnitAlarm organizationUnitAlarm = new OrganizationUnitAlarm(); |
| | | organizationUnitAlarm.setOrganizationId(orgId); |
| | |
| | | } |
| | | } |
| | | |
| | | private void deleteOrganizationUnitAlarm(Integer orgId,Integer versionId){ |
| | | private void deleteOrganizationUnitAlarm(Integer orgId, Integer versionId) { |
| | | QueryWrapper<Device> queryOrganizationVersionWrapper = new QueryWrapper<>(); |
| | | queryOrganizationVersionWrapper.eq("organization_id",orgId); |
| | | queryOrganizationVersionWrapper.eq("device_version_id",versionId); |
| | | queryOrganizationVersionWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | queryOrganizationVersionWrapper.eq("organization_id", orgId); |
| | | queryOrganizationVersionWrapper.eq("device_version_id", versionId); |
| | | queryOrganizationVersionWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<Device> devices = deviceMapper.selectList(queryOrganizationVersionWrapper); |
| | | if(ObjectUtils.isEmpty(devices)){//如果为空,则组织没有该型号的设备了。 |
| | | if (ObjectUtils.isEmpty(devices)) {//如果为空,则组织没有该型号的设备了。 |
| | | UpdateWrapper deleteWrapper = new UpdateWrapper(); |
| | | deleteWrapper.eq("organization_id",orgId); |
| | | deleteWrapper.eq("version_id",versionId); |
| | | deleteWrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | deleteWrapper.set("is_delete",Constants.DELETE); |
| | | organizationUnitAlarmMapper.update(null,deleteWrapper); |
| | | deleteWrapper.eq("organization_id", orgId); |
| | | deleteWrapper.eq("version_id", versionId); |
| | | deleteWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | deleteWrapper.set("is_delete", Constants.DELETE); |
| | | organizationUnitAlarmMapper.update(null, deleteWrapper); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.moral.api.mapper.HistoryHourlyMapper; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 小时表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-04 |
| | | */ |
| | | @Service |
| | | public class HistoryHourlyServiceImpl extends ServiceImpl<HistoryHourlyMapper, HistoryHourly> implements HistoryHourlyService { |
| | | |
| | | @Autowired |
| | | private HistoryHourlyMapper historyHourlyMapper; |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @Override |
| | | public void insertHistoryHourly(Map<String, Object> data) { |
| | | Map<String, Object> dataAdjust = new HashMap<>(data); |
| | | String mac = data.remove("mac").toString(); |
| | | Date time = DateUtils.dataToTimeStampTime(new Date(new Long((String) data.remove("DataTime"))), DateUtils.yyyy_MM_dd_HH_EN); |
| | | Integer version = (Integer) data.remove("ver"); |
| | | Map<String, Object> result = new HashMap<>(data); |
| | | result.put("mac", mac); |
| | | result.put("time", time); |
| | | result.put("version", version); |
| | | result.put("timeUnits", Constants.UN_ADJUST); |
| | | result.put("value", JSONObject.toJSONString(data)); |
| | | //原始数据(未校准) |
| | | historyHourlyMapper.insertHistoryHourlyUnAdjust(result); |
| | | |
| | | //数据校准 |
| | | dataAdjust = deviceService.adjustDeviceData(dataAdjust); |
| | | dataAdjust.remove("mac"); |
| | | dataAdjust.remove("DataTime"); |
| | | dataAdjust.remove("ver"); |
| | | HistoryHourly historyHourly = new HistoryHourly(); |
| | | historyHourly.setMac(mac); |
| | | historyHourly.setTime(time); |
| | | historyHourly.setVersion(version); |
| | | historyHourly.setValue(JSONObject.toJSONString(dataAdjust)); |
| | | historyHourlyMapper.insert(historyHourly); |
| | | } |
| | | } |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.api.mapper.HistoryMinutelyMapper; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.HistoryMinutelyService; |
| | |
| | | private DeviceService deviceService; |
| | | |
| | | @Override |
| | | public void insertHistoryMinutely(Map<String, Object> deviceData) { |
| | | public void insertHistoryMinutely(Map<String, Object> data) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | Object mac = deviceData.remove("mac"); |
| | | Map<String, Object> dataAdjust = new HashMap<>(data); |
| | | Object mac = data.remove("mac"); |
| | | result.put("mac", mac); |
| | | result.put("version", deviceData.remove("ver")); |
| | | Date time = new Date((Long) deviceData.remove("DataTime")); |
| | | result.put("time", DateUtils.dateToDateString(time)); |
| | | result.put("value", JSON.toJSONString(deviceData)); |
| | | result.put("version", data.remove("ver")); |
| | | Date time = new Date(new Long((String) data.remove("DataTime"))); |
| | | result.put("time", DateUtils.dataToTimeStampTime(time,DateUtils.yyyy_MM_dd_HH_mm_EN)); |
| | | result.put("value", JSONObject.toJSONString(data)); |
| | | String timeUnits = DateUtils.dateToDateString(time, DateUtils.yyyyMM_EN); |
| | | result.put("timeUnits", tableSuffix(timeUnits, Constants.UN_ADJUST)); |
| | | //未校准 |
| | | |
| | | //原始数据(未校准) |
| | | historyMinutelyMapper.insertHistoryMinutely(result); |
| | | |
| | | //设备信息 |
| | | Map<String, Object> deviceInfo = deviceService.getDeviceByMac(mac.toString()); |
| | | |
| | | //设备数据校准,并存入数据库 |
| | | //数据校准 |
| | | dataAdjust = deviceService.adjustDeviceData(dataAdjust); |
| | | dataAdjust.remove("mac"); |
| | | dataAdjust.remove("DataTime"); |
| | | dataAdjust.remove("ver"); |
| | | result.put("timeUnits", timeUnits); |
| | | deviceData = deviceService.adjustDeviceData(deviceData, deviceInfo); |
| | | result.put("value", JSON.toJSONString(deviceData)); |
| | | result.put("value", JSONObject.toJSONString(dataAdjust)); |
| | | historyMinutelyMapper.insertHistoryMinutely(result); |
| | | |
| | | //判断设备状态 |
| | | Map<String, Object> deviceState = deviceService.judgeDeviceState(deviceData, deviceInfo); |
| | | |
| | | } |
| | | |
| | | //表后缀 |
| | |
| | | } |
| | | return key.toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.entity.SysDictData; |
| | | import com.moral.api.entity.VersionSensorUnit; |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.OrganizationUnitAlarmMapper; |
| | | import com.moral.api.mapper.SensorMapper; |
| | | import com.moral.api.mapper.SysDictDataMapper; |
| | | import com.moral.api.mapper.VersionSensorUnitMapper; |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private SysDictDataMapper sysDictDataMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private OrganizationUnitAlarmMapper organizationUnitAlarmMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | |
| | | return resultMap; |
| | | } |
| | | sensorMapper.updateSensor(updateSensorMap); |
| | | if (!ObjectUtils.isEmpty(updateSensorMap.get("code"))&&!oldSensor.getCode().equals(updateSensorMap.get("code"))){ |
| | | QueryWrapper<OrganizationUnitAlarm> wrapper_OUA = new QueryWrapper<>(); |
| | | wrapper_OUA.eq("is_delete",Constants.NOT_DELETE); |
| | | wrapper_OUA.eq("sensor_code",oldSensor.getCode()); |
| | | OrganizationUnitAlarm organizationUnitAlarm = new OrganizationUnitAlarm(); |
| | | organizationUnitAlarm.setSensorCode(updateSensorMap.get("code").toString()); |
| | | organizationUnitAlarmMapper.update(organizationUnitAlarm,wrapper_OUA); |
| | | } |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "修改因子:"+oldSensor.getName()+";"; |
| | | for (Object key:updateSensorMap.keySet()) { |
| | |
| | | VersionSensorUnit versionSensorUnit = new VersionSensorUnit(); |
| | | versionSensorUnit.setIsDelete(Constants.DELETE); |
| | | versionSensorUnitMapper.update(versionSensorUnit,wrapper_Version); |
| | | if (!ObjectUtils.isEmpty(sensor.getCode())&&!sensor.getCode().equals("")){ |
| | | QueryWrapper<OrganizationUnitAlarm> wrapper_OUA = new QueryWrapper<>(); |
| | | wrapper_OUA.eq("is_delete",Constants.NOT_DELETE); |
| | | wrapper_OUA.eq("sensor_code",sensor.getCode()); |
| | | OrganizationUnitAlarm organizationUnitAlarm = new OrganizationUnitAlarm(); |
| | | organizationUnitAlarm.setIsDelete(Constants.DELETE); |
| | | organizationUnitAlarmMapper.update(organizationUnitAlarm,wrapper_OUA); |
| | | } |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "删除因子:"+sensor.getName()+";"; |
New file |
| | |
| | | package com.moral.api.util; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.googlecode.aviator.AviatorEvaluator; |
| | | import com.googlecode.aviator.Expression; |
| | | import com.moral.api.entity.DeviceAdjustValue; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class AdjustDataUtils { |
| | | //数据,公式 |
| | | public Map<String, Object> adjust(Map<String, Object> deviceData, Map<String, Object> adjustFormula, Map<String, Object> aqiMap) { |
| | | try { |
| | | Object dataTime = deviceData.get("DataTime"); |
| | | //清除毫秒,四舍五入 |
| | | long time = Math.round(new Double((String) dataTime) / 1000) * 1000L; |
| | | long finalTime = DateUtils.dataToTimeStampTime(new Date(time), DateUtils.HH_mm_ss_EN).getTime(); |
| | | for (String key : deviceData.keySet()) { |
| | | if (!key.equals("mac") && !key.equals("time") && !key.equals("DataTime") && !key.equals("ver") && !key.contains("Flag")) { |
| | | //测量值 |
| | | Object measuredValue = deviceData.get(key); |
| | | //单个因子校准公式 |
| | | List<DeviceAdjustValue> sensorFormulas = (List<DeviceAdjustValue>) adjustFormula.get(key); |
| | | if (ObjectUtils.isEmpty(sensorFormulas)) { |
| | | deviceData.put(key, measuredValue); |
| | | continue; |
| | | } |
| | | |
| | | //根据时间段筛选校准公式 |
| | | DeviceAdjustValue deviceAdjustValue = sensorFormulas.stream() |
| | | .filter(o -> o.getStartTime().getTime() <= finalTime && o.getEndTime().getTime() > finalTime) |
| | | .findFirst().get(); |
| | | String formula = deviceAdjustValue.getValue(); |
| | | if (StringUtils.isEmpty(formula)) { |
| | | deviceData.put(key, measuredValue); |
| | | continue; |
| | | } |
| | | |
| | | Expression expression = AviatorEvaluator.compile(formula); |
| | | Map<String, Object> env = new HashMap<>(); |
| | | if (formula.contains("aqi")) { |
| | | Object aqiValue = null; |
| | | if (aqiMap != null) { |
| | | aqiValue = aqiMap.get(key); |
| | | } |
| | | env.put("aqi", ObjectUtils.isEmpty(aqiValue) ? 0F : Float.parseFloat((String) aqiValue)); |
| | | } |
| | | if (formula.contains("vocs")) { |
| | | Object vocsValue = ObjectUtils.isEmpty(deviceData.get("a99054")) ? 0F : deviceData.get("a99054"); |
| | | env.put("vocs", vocsValue); |
| | | } |
| | | if (formula.contains("cel")) { |
| | | env.put("cel", Float.parseFloat((String) measuredValue)); |
| | | } |
| | | //校准 |
| | | measuredValue = expression.execute(env); |
| | | //温度处理 |
| | | if (Float.parseFloat(measuredValue.toString()) < 0 && !"a01001".equals(measuredValue)) { |
| | | measuredValue = 0F; |
| | | } |
| | | deviceData.put(key, Double.parseDouble(String.format("%.3f", measuredValue))); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("param[0] deviceData:" + JSON.toJSONString(deviceData)); |
| | | log.error(e.getMessage()); |
| | | } |
| | | return deviceData; |
| | | } |
| | | } |
| | |
| | | enable: |
| | | auto: |
| | | commit: false |
| | | group: |
| | | id: test |
| | | servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092 |
| | | servers: 172.16.44.65:9092,172.16.44.67:9092,172.16.44.66:9092 |
| | | session: |
| | | timeout: 6000 |
| | | topic: test_topic |
| | | zookeeper: |
| | | connect: 192.168.0.16:2181,192.168.0.17:2181,192.168.0.18:2181 |
| | | connect: 172.16.44.65:2181,172.16.44.67:2181,172.16.44.66:2181 |
| | | producer: |
| | | batch: |
| | | size: 4096 |
| | |
| | | memory: 40960 |
| | | linger: 1 |
| | | retries: 0 |
| | | servers: 192.168.0.16:9092,192.168.0.17:9092,192.168.0.18:9092 |
| | | servers: 172.16.44.65:9092,172.16.44.67:9092,172.16.44.66:9092 |
| | | mvc: |
| | | interceptor: |
| | | exclude: |
| | |
| | | <association property="monitorPoint" javaType="com.moral.api.entity.MonitorPoint"> |
| | | <result column="mp_id" property="id"/> |
| | | <result column="mp_name" property="name"/> |
| | | <result column="mp_address" property="address"/> |
| | | <result column="mp_area_code" property="areaCode"/> |
| | | <result column="mp_city_code" property="cityCode"/> |
| | | <result column="mp_province_code" property="provinceCode"/> |
| | | </association> |
| | | |
| | | <!--型号--> |
| | |
| | | o.`name` org_name, |
| | | mp.id mp_id, |
| | | mp.`name` mp_name, |
| | | mp.address mp_address, |
| | | mp.area_code mp_area_code, |
| | | mp.city_code mp_city_code, |
| | | mp.province_code mp_province_code, |
| | | ma.id operate_id, |
| | | v.id version_id, |
| | | v.`name` version_name, |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistoryHourlyMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HistoryHourly"> |
| | | <result column="mac" property="mac"/> |
| | | <result column="time" property="time"/> |
| | | <result column="value" property="value"/> |
| | | <result column="version" property="version"/> |
| | | </resultMap> |
| | | |
| | | <insert id="insertHistoryHourlyUnAdjust"> |
| | | INSERT INTO history_hourly_${timeUnits} VALUES (#{mac}, #{time}, #{value}, #{version}) |
| | | </insert> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> |
| | | <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> |
| | | <output url="file://$MODULE_DIR$/target/classes" /> |
| | | <output-test url="file://$MODULE_DIR$/target/test-classes" /> |
| | | <content url="file://$MODULE_DIR$"> |
| | | <excludeFolder url="file://$MODULE_DIR$/target" /> |
| | | <excludeFolder url="file://$MODULE_DIR$/home/moral/soft/log/screen-manage/%d{yyyy-MM-dd}" /> |
| | | <excludeFolder url="file://$MODULE_DIR$/home/moral/soft/log/screen-manage/2021-06-08" /> |
| | | <excludeFolder url="file://$MODULE_DIR$/home/moral/soft/log/springAppName_IS_UNDEFINED" /> |
| | | <excludeFolder url="file://$MODULE_DIR$/home" /> |
| | | </content> |
| | | <orderEntry type="inheritedJdk" /> |
| | | <orderEntry type="sourceFolder" forTests="false" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" /> |
| | | <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" /> |
| | | <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.10.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.31" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.31" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.31" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.3.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-web:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.13" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.13" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-core:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.xiaoymin:swagger-bootstrap-ui:1.9.6" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.18" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.4" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.4" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.kafka:spring-kafka:2.2.12.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.retry:spring-retry:1.2.5.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:kafka-streams:2.2.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:connect-json:2.0.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:connect-api:2.0.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.rocksdb:rocksdbjni:5.15.10" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.kafka:kafka-clients:2.2.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.github.luben:zstd-jni:1.3.8-1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.lz4:lz4-java:1.5.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.7.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba:druid:1.1.5" level="project" /> |
| | | <orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.19" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.11.1" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:2.23.4" level="project" /> |
| | | <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.16" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.16" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.3" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" /> |
| | | <orderEntry type="library" scope="TEST" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.code.kaptcha:kaptcha:2.3.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.1.13.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.14.RELEASE" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.5" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.xuxueli:xxl-job-core:2.3.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.45.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.codehaus.groovy:groovy:2.5.9" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.googlecode.aviator:aviator:5.2.5" level="project" /> |
| | | </component> |
| | | </module> |