main
周文涛 2 years ago
parent c729f60980
commit 2cfffd648d

@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}

@ -16,20 +16,24 @@
<properties>
<java.version>1.8</java.version>
<commons.version>2.6</commons.version>
<mybatisplus.version>3.4.1</mybatisplus.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<sqlite-jdbc.version>3.21.0.1</sqlite-jdbc.version>
<!-- 持久层 -->
<mybatis-plus.version>3.5.1</mybatis-plus.version>
<dynamic-datasource-spring-boot-starter.version>3.2.0</dynamic-datasource-spring-boot-starter.version>
<druid.version>1.1.22</druid.version>
<mysql-connector-java.version>8.0.27</mysql-connector-java.version>
</properties>
<dependencies>
<!--springBoot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>-->
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
@ -42,7 +46,6 @@
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<!--接口文档-->
<dependency>
<groupId>com.spring4all</groupId>
@ -67,24 +70,40 @@
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons.version}</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!--mybatis-plus-->
<!--<dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
<version>${mybatis-plus.version}</version>
</dependency>
<!-- druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${dynamic-datasource-spring-boot-starter.version}</version>
</dependency>
&lt;!&ndash;SQLite&ndash;&gt;
<!-- 数据库驱动 -->
<!--mysql-->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite-jdbc.version}</version>
</dependency>-->
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>

@ -1,17 +1,32 @@
package com.example.zxweb;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Slf4j
@SpringBootApplication
public class KafkaApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(KafkaApplication.class, args);
Environment bean = context.getBean(Environment.class);
System.out.println("---启动完成,当前使用端口:[" + bean.getProperty("local.server.port") + "]---");
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext application = SpringApplication.run(KafkaApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
path=path==null?"":path;
log.info("---启动完成,当前使用端口:[" + port + "]---");
log.info("\n----------------------------------------------------------\n\t" +
"Application Jeecg-Boot is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
}

@ -0,0 +1,40 @@
package com.example.zxweb.common.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* jeecg.datasource.open = false
* @Author zhoujf
*
*/
@Configuration
@MapperScan(value={"com.example.zxweb.**.mapper*"})
public class MybatisPlusSaasConfig {
static {
//2.示例测试
//TENANT_TABLE.add("demo");
//3.online租户隔离测试
//TENANT_TABLE.add("ceapp_issue");
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 先 add TenantLineInnerInterceptor 再 add PaginationInnerInterceptor
//update-begin-author:zyf date:20220425 for:【VUEN-606】注入动态表名适配拦截器解决多表名问题
//interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor());
//update-end-author:zyf date:20220425 for:【VUEN-606】注入动态表名适配拦截器解决多表名问题
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
//【jeecg-boot/issues/3847】增加@Version乐观锁支持
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
}
}

@ -1,4 +1,4 @@
package com.example.zxweb.config;
package com.example.zxweb.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ -0,0 +1,19 @@
package com.example.zxweb.common.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 17:15
*/
@Configuration
public class WebMVCConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**")
.addResourceLocations("classpath:/static/");
}
}

@ -7,6 +7,9 @@ package com.example.zxweb.common.constant;
*/
public interface DevConstant {
class gateway{
private String gateway_5lhyslqh="0cefafd2a2ca";
@Deprecated
public static String gateway_5lhys="0cefafd2a2ca";//北京电信智慧楼宇-5层会议室龙桥华
public static String gateway_5lqh="0cefafd605f7";//北京电信智慧楼宇-5层龙桥华网关
public static String gateway_4llqh="0cefafd295a4";//比京电信智慧楼宇-4层龙桥华网关
}
}

@ -0,0 +1,94 @@
package com.example.zxweb.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zxweb.common.api.vo.Result;
import com.example.zxweb.entity.ZxCelue;
import com.example.zxweb.service.IZxCelueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 11:50
*/
@Api(tags = "策略管理")
@RequestMapping("/celue")
@RestController
public class CelueController {
@Resource
IZxCelueService zxCelueService;
@ApiOperation(value = "策略列表")
@GetMapping(value = "/list")
public Result<?> list(@RequestParam(value = "page",defaultValue = "1")Integer page,@RequestParam(value = "limit",defaultValue = "10")Integer limit,
@RequestParam(value = "name",defaultValue = "")String name,@RequestParam(value = "status",defaultValue = "")String status){
LambdaQueryWrapper<ZxCelue> queryWrapper=new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(name)) {
queryWrapper.like(ZxCelue::getName,name);
}
if (StringUtils.isNotBlank(status)) {
queryWrapper.eq(ZxCelue::getStatus,status);
}
Page<ZxCelue> pageList = zxCelueService.page(new Page<>(page, limit),queryWrapper);
return Result.OK(pageList);
}
@ApiOperation(value = "策略列表-全部")
@GetMapping(value = "/listAll")
public Result<?> listAll(){
return Result.OK(zxCelueService.list());
}
@ApiOperation(value = "详情")
@GetMapping
public Result<?> getDetail(@RequestParam String id){
return Result.OK(zxCelueService.getById(id));
}
@ApiOperation(value = "新增")
@PostMapping
public Result<?>add(@RequestBody ZxCelue zxCelue){
zxCelueService.save(zxCelue);
return Result.OK();
}
@ApiOperation(value = "编辑")
@PutMapping
public Result<?>edit(@RequestBody ZxCelue zxCelue){
zxCelueService.updateById(zxCelue);
return Result.OK();
}
@ApiOperation(value = "编辑")
@PutMapping("/status")
public Result<?>status(@RequestBody ZxCelue zxCelue){
ZxCelue celue = zxCelueService.getById(zxCelue.getCelueid());
LambdaUpdateWrapper<ZxCelue> updateWrapper=new LambdaUpdateWrapper<>();
updateWrapper.eq(ZxCelue::getCelueid,celue.getCelueid());
if ("0".equals(celue.getStatus())) {
updateWrapper.set(ZxCelue::getStatus,"1");
}else{
updateWrapper.set(ZxCelue::getStatus,"0");
}
zxCelueService.update(updateWrapper);
return Result.OK();
}
/**
*
*/
@ApiOperation(value="删除", notes="删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id") String id) {
zxCelueService.removeById(id);
return Result.OK();
}
}

@ -0,0 +1,38 @@
package com.example.zxweb.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zxweb.common.api.vo.Result;
import com.example.zxweb.entity.ZxCelue;
import com.example.zxweb.entity.ZxDevice;
import com.example.zxweb.service.IZxCelueService;
import com.example.zxweb.service.IZxDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/14 9:16
*/
@Api(tags = "设备管理")
@RequestMapping("/device")
@RestController
public class DeviceController {
@Resource
IZxDeviceService zxDeviceService;
@ApiOperation(value = "设备列表")
@GetMapping(value = "/list")
public Result<?> list(@RequestParam(value = "page",defaultValue = "1")Integer page,@RequestParam(value = "limit",defaultValue = "10")Integer limit){
LambdaQueryWrapper<ZxDevice> queryWrapper=new LambdaQueryWrapper<>();
return null;
}
}

@ -1,6 +1,5 @@
package com.example.zxweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.zxweb.common.api.vo.Result;
import com.example.zxweb.common.constant.enums.IotApiEnum;
@ -12,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;

@ -190,8 +190,6 @@ public class KafkaController {
@ApiOperation(value = "producer")
public Result<?> postProducerData(@RequestBody JSONObject requestBody){
String topic = requestBody.getString("topic");
String key = requestBody.getString("key");
String value = requestBody.getString("value");
// 创建 KafkaProducer
KafkaProducer<String, String> producer = new KafkaProducer<>(kafkaUtil.getSafeProducerPro());
// 发送消息

@ -6,7 +6,7 @@ import com.example.zxweb.utils.RmsUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
/**

@ -0,0 +1,22 @@
package com.example.zxweb.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 11:39
*/
@Controller
public class ThymeleafController {
@RequestMapping("/")
public String getString(HttpServletRequest request){
String name = "全栈学习笔记";
return "index.html";
}
}

@ -0,0 +1,60 @@
package com.example.zxweb.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 13:41
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="zx_celue对象", description="zx_celue对象")
@TableName(value = "zx_celue")
public class ZxCelue implements Serializable {
@TableId
@ApiModelProperty(value = "策略id")
private String celueid;
@ApiModelProperty(value = "设备id")
private String devid;
@ApiModelProperty(value = "策略名称")
private String name;
@ApiModelProperty(value = "循环周期")
@TableField(exist = false)
private String xunhuanzhouqi;
@ApiModelProperty(value = "状态(1启动中/0关闭中)")
private String status;
@ApiModelProperty(value = "备注")
private String description;
@ApiModelProperty(value = "定时触发条件")
private String triggereTime;
@ApiModelProperty(value = "触发条件")
private String triggerCondition;
@ApiModelProperty(value = "执行条件")
private String exeCondition;
@ApiModelProperty(value = "执行条件并列关系")
private String exeRelation;
@ApiModelProperty(value = "触发动作")
private String action;
/*动作延迟多少秒执行。不填则为0即不延迟取值范围为0~86400秒。*/
@ApiModelProperty(value = "动作延迟时间")
private String delayTime;
@ApiModelProperty(value = "生效开始时间")
private String startTime;
@ApiModelProperty(value = "生效结束时间")
private String endTime;
}

@ -0,0 +1,35 @@
package com.example.zxweb.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 13:41
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="zx_device对象", description="zx_device对象")
@TableName(value = "zx_device")
public class ZxDevice implements Serializable {
@TableId
@ApiModelProperty(value = "设备id")
private String serial;
@ApiModelProperty(value = "设备名称")
private String terminalName;
@ApiModelProperty(value = "设备类型")
private String modelCode;
}

@ -0,0 +1,49 @@
package com.example.zxweb.init;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.zxweb.common.constant.DevConstant;
import com.example.zxweb.common.constant.enums.IotApiEnum;
import com.example.zxweb.entity.ZxCelue;
import com.example.zxweb.service.IZxCelueService;
import com.example.zxweb.utils.IotUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 13:48
*/
@Configuration
@Slf4j
public class LoadCelueInit implements ApplicationRunner{
@Resource
IZxCelueService zxCelueService;
@Override
public void run(ApplicationArguments args) throws Exception {
//获取网关的数据,同步到数据库中
/*String gateway_5lqh = DevConstant.gateway.gateway_5lqh;//5楼网关
String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", gateway_5lqh,gateway_5lqh);
JSONObject requestBody = JSONObject.parseObject(format);
JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody);
JSONObject data = responseBody.getJSONObject("data");
if (data!=null) {
JSONObject outputData = data.getJSONObject("outputData");
if (outputData!=null) {
JSONArray list = outputData.getJSONArray("list");
if (!CollectionUtils.isEmpty(list)) {
List<ZxCelue> zxCelues = list.toJavaList(ZxCelue.class);
//更新库表
zxCelueService.saveOrUpdateBatch(zxCelues);
}
}
}*/
}
}

@ -0,0 +1,14 @@
package com.example.zxweb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.zxweb.entity.ZxCelue;
import org.apache.ibatis.annotations.Mapper;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 14:05
*/
@Mapper
public interface ZxCelueMapper extends BaseMapper<ZxCelue> {
}

@ -0,0 +1,14 @@
package com.example.zxweb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.zxweb.entity.ZxDevice;
import org.apache.ibatis.annotations.Mapper;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 14:05
*/
@Mapper
public interface ZxDeviceMapper extends BaseMapper<ZxDevice> {
}

@ -0,0 +1,4 @@
<?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.example.zxweb.mapper.ZxCelueMapper">
</mapper>

@ -0,0 +1,4 @@
<?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.example.zxweb.mapper.ZxDeviceMapper">
</mapper>

@ -0,0 +1,12 @@
package com.example.zxweb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.zxweb.entity.ZxCelue;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 14:07
*/
public interface IZxCelueService extends IService<ZxCelue> {
}

@ -0,0 +1,12 @@
package com.example.zxweb.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.zxweb.entity.ZxDevice;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/14 9:14
*/
public interface IZxDeviceService extends IService<ZxDevice> {
}

@ -0,0 +1,20 @@
package com.example.zxweb.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.zxweb.entity.ZxCelue;
import com.example.zxweb.mapper.ZxCelueMapper;
import com.example.zxweb.service.IZxCelueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/13 14:09
*/
@Service
@Slf4j
public class ZxCelueServiceImpl extends ServiceImpl<ZxCelueMapper, ZxCelue> implements IZxCelueService {
}

@ -0,0 +1,18 @@
package com.example.zxweb.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.zxweb.entity.ZxDevice;
import com.example.zxweb.mapper.ZxDeviceMapper;
import com.example.zxweb.service.IZxDeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/9/14 9:14
*/
@Service
@Slf4j
public class ZxDeviceServiceImpl extends ServiceImpl<ZxDeviceMapper, ZxDevice> implements IZxDeviceService {
}

@ -1,7 +1,7 @@
package com.example.zxweb.utils;
import com.example.zxweb.exception.BusinessException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
/**

@ -1,6 +1,6 @@
package com.example.zxweb.utils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@ -2,7 +2,7 @@ package com.example.zxweb.utils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;

@ -21,16 +21,73 @@ spring:
send.buffer.bytes: 131072 #??128KB???socket???????????-1??????????
request.timeout.ms: 10000 #??30000ms??????????????
transaction.timeout.ms: 5000
# #数据库配置
# datasource:
# driver-class-name: org.sqlite.JDBC
# url: jdbc:sqlite:E:\\demo.db
# #username:
# #password:
##控制台打印SQL语句
#mybatis-plus:
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# thymeleaf 页面配置
thymeleaf:
cache: false
prefix: classpath:/templates/
encoding: UTF-8 #编码
suffix: .html #模板后缀
mode: HTML #模板
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
#数据源
datasource:
druid:
stat-view-servlet:
enabled: false
loginUsername: admin
loginPassword: 123456
allow:
web-stat-filter:
enabled: true
dynamic:
druid: # 全局druid参数绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
# 连接池的配置信息
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters去掉后监控界面sql无法统计'wall'用于防火墙
filters: stat,wall,slf4j
# 通过connectProperties属性来打开mergeSql功能慢SQL记录
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://47.103.213.109:3306/zx-java?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
#password: zqzxdx123@321
password: Wang5322570..
driver-class-name: com.mysql.cj.jdbc.Driver
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:com/example/zxweb/**/xml/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
db-config:
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
id-type: ASSIGN_ID
# 默认数据库表下划线命名
table-underline: true
configuration:
# 这个配置会将执行的sql打印出来在开发或测试的时候可以用
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 返回类型为Map,显示null对应的字段
call-setters-on-nulls: true
key: dwVendor
secret: fEVcb^QFB;IN$K5
appCode: 42142fd0jkbf4515853b7fcec64748f6

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 322 KiB

File diff suppressed because one or more lines are too long

@ -0,0 +1,222 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org/">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- 引入 layui.css -->
<link href="../static/layui-v2.8.11/css/layui.css" rel="stylesheet">
<!-- 引入 layui.js -->
<script src="../static/layui-v2.8.11/layui.js"></script>
<style>
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
.body {
padding: 23.8px;
}
.left-title {
font-size: 22px;
margin-bottom: 15px;
margin-top: 15px;
}
.z-body {
}
.z-body .layui-form-label {
font-size: 14px;
}
.z-body .layui-input-inline .layui-btn {
padding: 0;
width: 56px;
}
.z-search {
}
.z-search .layui-form-item {
margin: 10px 0px;
display: flex;
justify-content: center;
align-items: center;
}
table th {
background-color: #fafafa;
color: #2c2a29;
}
.layui-form-onswitch {
border-color: #1890ff;
background-color: #1890ff;
}
.layui-table-body .layui-table-cell {
height: 56px;
line-height: 41px;
}
.layui-laypage {
margin-bottom: 15px !important;
}
.layui-table-column {
display: flex;
justify-content: flex-end;
}
</style>
</head>
<body>
<div class="body">
<div class="left-title layui-row">
<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-col-lg6 layui-col-xl6">
<p>控制策略</p>
</div>
<div class="layui-col-md6 layui-col-xs6 layui-col-sm6 layui-col-lg6 layui-col-xl6">
<button type="button" class="layui-btn" style="font-size: 16px;float: right;background-color: #41a69a">+新增</button>
</div>
</div>
<div class="z-body">
<div class="layui-card layui-panel">
<div class="layui-card-body z-search">
<form class="layui-form" action="form.html">
<div class="layui-form-item">
<label class="layui-form-label">策略名称:</label>
<div class="layui-input-inline" style="width: 240px">
<input type="text" id="name" name="name" lay-verify="required" placeholder="请填写关键字···"
autocomplete="off" class="layui-input">
</div>
<label class="layui-form-label">执行状态:</label>
<div class="layui-input-inline" style="width: 240px">
<select name="interest" id="status" lay-filter="aihao">
<option value="" selected>请选择···</option>
<option value="1">启动</option>
<option value="0">停用</option>
</select>
</div>
<div class="layui-input-inline">
<button type="button" onclick="loadTable()" class="layui-btn layui-btn-normal" style="width: 58px">查询</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</div>
</div>
<!-- 内容主体区域 -->
<div class="layui-card layui-panel">
<div class="layui-card-body">
<table class="layui-hide" id="ID-table-demo-data"></table>
<div id="demo-laypage-all"></div>
</div>
</div>
</div>
</div>
<script type="text/html" id="templet-status-switch">
<!-- 这里的 checked 的状态值判断仅作为演示 -->
<input type="checkbox" name="status" id="{{=d.celueid}}" value="{{=d.status}}" title="启用|停用" lay-skin="switch"
lay-filter="demo-templet-status" {{=d.status=='1'?"checked":"" }}>
</script>
<script type="text/html" id="templet-theads-tool">
<div class="layui-clear-space" style="padding-left: 20px">
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"
style="width: 46px;height: 26px;padding: 1px;background-color: #3cb754;color: white">
查看
</a>
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit"
style="width: 46px;height: 26px;padding: 1px;border: #f52f64 solid 1px;color: #f52f64">
删除
</a>
</div>
</script>
<script>
var pageNum=2;
var pageSize=10;
var total=0;
var laypage;
var name='';
var status='';
loadTable();
var form;
function loadTable(){
layui.use('table', function () {
var table = layui.table;
var $=layui.$;
form = layui.form;
name=$("#name").val();
status = $("#status").val();
laypage = layui.laypage;
// 已知数据渲染
var inst = table.render({
elem: '#ID-table-demo-data'
, cols: [ [ //标题栏
{field: 'number', title: '序号', width: 80, sort: false, align: 'center', type: 'numbers'}
, {field: 'name', title: '策略名称', width: 360}
, {field: 'xunhuanzhouqi', title: '循环周期', minwidth: 360}
, {field: 'status', title: '执行状态', width: 160, templet: '#templet-status-switch'}
, {field: 'description', title: '备注', minwidth: 344}
, {field: 'experience', title: '操作', width: 220, templet: '#templet-theads-tool', sort: false}
]
]
,url:'/celue/list?name='+name+"&status="+status
,method:'get'
,async: true
,headers: {//携带token
},/*data: []*/
parseData: function(res){ //res 即为原始返回的数据
console.log(res)
total=res.result.total;
return {
"code": res.code==200?0:res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.result.total, //解析数据长度
"data": res.result.records //解析数据列表
};
},
done: function (res, curr, count) {
if (res.success) {
//成功
loadpage();
}else{
//异常
}
},
limits: [5,10, 15, 20],
limit: 10,
page: true,
//,skin: 'line' // 表格风格
//,even: true
//,page: true // 是否显示分页
//,limits: [5, 10, 15]
//,limit: 5 // 每页默认显示的数量
});
form.on('switch(demo-templet-status)', function(obj){
var id = this.id;
var obj = JSON.stringify({'celueid':id});
$.ajax({
type: "PUT",
url: "/celue/status",
data: obj,
contentType: 'application/json;charset=utf-8',
success: function(res){
console.log(res)
}
});
console.log(id)
/*layer.tips(id + ' ' + name + ': '+ obj.elem.checked, obj.othis);*/
});
});
};
</script>
</body>
</html>

@ -0,0 +1 @@
[{"id":"1","celueName":"灯光-1F走廊","xunhuanzhouqi":"每天 18:00-6:00","status":"1","description":"夜间照明自动控制"},{"id":"2","celueName":"灯光-1F外墙广告牌","xunhuanzhouqi":"每天 19:00-23:00","status":"1","description":null}]
Loading…
Cancel
Save