Commit f71190f2 by 周海宝

Merge branch 'master' into 'devAqara'

Master

See merge request !4
2 parents 1e204042 d9209512
Showing 136 changed files with 4527 additions and 85 deletions
### IntelliJ project files
.idea/
*.iml
out/
gen/
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven template
target/
...@@ -27,6 +27,18 @@ ...@@ -27,6 +27,18 @@
<artifactId>rest-admin-registry</artifactId> <artifactId>rest-admin-registry</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-didicb-app-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--lombok--> <!--lombok-->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
...@@ -57,5 +69,52 @@ ...@@ -57,5 +69,52 @@
<version>${druid.version}</version> <version>${druid.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-swagger2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-redis</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 用户聚合服务 需要调用的dubbo服务 -->
<dependency>
<groupId>com.glsx.biz</groupId>
<artifactId>biz-user-service</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.1.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- protocol buf -->
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package com.glsx.smart; package com.glsx.smart;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;
/** /**
* @Title: ServiceApplication.java * @Title: ServiceApplication.java
* @Description: * @Description:
* @author deployer name * @author deployer name
* @version V1.0 * @version V1.0
* @Company: Didihu.com.cn * @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015 * @Copyright Copyright (c) 2015
*/ */
@Slf4j @Slf4j
@SpringBootApplication @EnableDubbo
@SpringBootApplication(scanBasePackages = {"com.glsx"})
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableTransactionManagement @EnableTransactionManagement
@ServletComponentScan @ServletComponentScan
@ComponentScan("com.glsx.smart") // 使用通用 Mapper 的注解
@MapperScan(basePackages={"com.glsx.smart.dao.mapper"}) @MapperScan(basePackages={"com.glsx.smart.dao.mapper"})
public class SmartServiceApplication extends SpringBootServletInitializer { public class SmartServiceApplication extends SpringBootServletInitializer {
/** /**
* 本地启动 ,内嵌tomcat方式 * 本地启动 ,内嵌tomcat方式
* @param args * @param args
......
package com.glsx.smart.config;
import com.alibaba.fastjson.JSON;
import com.glsx.smart.pojo.pb.InstanceFence.Fence;
import com.glsx.smart.utils.GCJ2WGS;
import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
/**
* @author think.wang
* @version 1.0.0
* @Title DeviceAddressProducer
* @Package com.glsx.smart.config
* @Description 设备围栏数据kafka推送
* @date 2021/4/11
*/
@Slf4j
@Component
public class DeviceAddressProducer {
@Resource
private Producer producer;
@Autowired
private KafkaConfig kafkaConfig;
/**
* 推送设备经纬度数据
* @param deviceId
* @param lngAndLat
* @param value 1新增 2删除 4更新
*/
public void pushUserDeviceData(String deviceId, String lngAndLat, Integer value) {
//kafka 发送消息数据封装
HashMap<String, Double> hm;
if(value == Fence.OperationType.DEL_VALUE
|| value == Fence.OperationType.GET_VALUE){ //删除和获取不需要经纬度数据
hm = new HashMap<>(2);
hm.put("lat", Double.valueOf(0));
hm.put("lon", Double.valueOf(0));
} else{
GCJ2WGS wg = new GCJ2WGS();
String[] lngLat = lngAndLat.split(":");
hm = wg.delta(Double.valueOf(lngLat[1]), Double.valueOf(lngLat[0]));
}
Fence.GpsLoc gpsLoc = this.buildGpsLoc(hm.get("lon"), hm.get("lat"));
Fence.FenceDeviceFamilyInfo deviceFamilyInfo = this.buildFenceDevice(deviceId, gpsLoc);
Fence.OptFamilyFenceInfo familyFenceInfo = this.buildFamilyFence(value, deviceFamilyInfo);
try {
String topic = kafkaConfig.getDeviceTopic();
log.info("推送kafka设备地址:{} {} {}", deviceId, lngAndLat, value);
log.info("推送kafka topic【{}】的数据:{} {} {}", topic, deviceId, JSON.toJSONString(hm), value);
KeyedMessage<byte[], byte[]> message = new KeyedMessage<>(topic, deviceId.getBytes(), familyFenceInfo.toByteArray());
producer.send(message);
}catch (Exception e){
log.error("消息推送kafka失败:{}", e);
}
}
/**
* 围栏设备经纬度数据封装
* @param lng
* @param lat
* @return
*/
private Fence.GpsLoc buildGpsLoc(double lng, double lat){
Fence.GpsLoc.Builder gpsLocBuilder = Fence.GpsLoc.newBuilder();
gpsLocBuilder.setLng((int)(lng * 1000000));
gpsLocBuilder.setLat((int)(lat * 1000000));
return gpsLocBuilder.build();
}
/**
* 围栏设备数据封装
* @param deviceId
* @param gpsLoc
* @return
*/
private Fence.FenceDeviceFamilyInfo buildFenceDevice(String deviceId, Fence.GpsLoc gpsLoc){
Fence.FenceDeviceFamilyInfo.Builder fenceDeviceBuilder = Fence.FenceDeviceFamilyInfo.newBuilder();
fenceDeviceBuilder.setSn(deviceId);
fenceDeviceBuilder.addGpslocs(gpsLoc);
return fenceDeviceBuilder.build();
}
/**
* 围栏整个数据封装
* @param value
* @param familyInfo
* @return
*/
private Fence.OptFamilyFenceInfo buildFamilyFence(Integer value, Fence.FenceDeviceFamilyInfo familyInfo){
Fence.OptFamilyFenceInfo.Builder familyFenceBuilder = Fence.OptFamilyFenceInfo.newBuilder();
familyFenceBuilder.addFamilyfenceInfos(familyInfo);
familyFenceBuilder.setOperationType(Fence.OperationType.valueOf(value));
return familyFenceBuilder.build();
}
}
package com.glsx.smart.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author fengzhi
* @version 1.0.0
* @ClassName KafkaProductorConfig.java
* @createTime 2020年03月12日 16:21:00
*/
@Data
@Configuration
@ConfigurationProperties("mq.kafka")
public class KafkaConfig {
/**
* kafka 生产者服务端地址
*/
private String productServer;
/**
* 设备围栏数据topic
*/
private String deviceTopic;
}
package com.glsx.smart.config;
import kafka.javaapi.producer.Producer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import kafka.producer.ProducerConfig;
import java.util.Properties;
/**
* @author fengzhi
* @version 1.0.0
* @ClassName KafkaProductorConfig.java
* @description: kafka生产消息
* @createTime 2021年03月12日 16:21:00
*/
@Slf4j
@Configuration
public class KafkaProducerConfig {
@Autowired
private KafkaConfig kafkaConfig;
@Bean("producer")
public Producer getProducer() {
ProducerConfig producerConfig = new ProducerConfig(initProperties());
return new Producer(producerConfig);
}
private Properties initProperties() {
Properties properties = new Properties();
properties.setProperty("serializer.class", "kafka.serializer.DefaultEncoder");
properties.setProperty("key.serializer.class", "kafka.serializer.DefaultEncoder");
properties.setProperty("metadata.broker.list", kafkaConfig.getProductServer());
properties.setProperty("producer.type", "async");
log.info("kafka_server" + kafkaConfig.getProductServer());
return properties;
}
}
package com.glsx.smart.constant;
/**
* @Title: Constants.java
* @Description: 常量
* @date 2021年3月12日 上午9:27:06
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2021
*/
public class Constants {
public final static String DEFAULT_PASSWORD = "123456";
public final static String DEFAULT_DEVICE = "万能遥控器";
public final static String SCENE_CONDITION_STATUS = "scene_condition_status";
public final static String SCENE_CONTENT_DEVICE = "scene_content_device";
public final static int REDIS_CACHE_TIME = 3; //redis缓存时间
}
package com.glsx.smart.controller;
import com.glsx.smart.pojo.request.*;
import com.glsx.smart.pojo.response.SmartCarKeyOpreateResponse;
import com.glsx.smart.pojo.response.SmartCarKeyResponse;
import com.glsx.smart.service.AiLockingKeyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/lockingKey")
public class AiLockingkeyController {
@Autowired
private AiLockingKeyService aiLockingKeyService;
//sn查询/新增车钥匙
@ResponseBody
@PostMapping(value = "/get")
public SmartCarKeyResponse getLockingKey(SmartCarKeyRequest request) {
return aiLockingKeyService.getLockingKey(request);
}
//智能车钥匙解绑
@ResponseBody
@PostMapping(value = "/remove")
public SmartCarKeyOpreateResponse removeLockingKey(SmartCarKeyRmRequest request) {
return aiLockingKeyService.removeLockingKey(request);
}
//智能车钥匙注册成功后的数据保存
@ResponseBody
@PostMapping(value = "/saveRegisterInfo")
public SmartCarKeyOpreateResponse saveLockingKeyRegisterInfo(SmartCarKeyRegisterRequest request) {
return aiLockingKeyService.saveLockingKeyRegisterInfo(request);
}
//车钥匙操作指令上报
@ResponseBody
@PostMapping(value = "/logCommand")
public SmartCarKeyOpreateResponse LogLockingKeyCommand(SmartCarKeyCommandRequest request) {
return aiLockingKeyService.LogLockingKeyCommand(request);
}
//车钥匙修改昵称
@ResponseBody
@PostMapping(value = "/setName")
public SmartCarKeyOpreateResponse setLockingKeyName(SmartCarKeyNameRequest request) {
return aiLockingKeyService.setLockingKeyName(request);
}
//车钥匙修改自动感应
@ResponseBody
@PostMapping(value = "/setAutoSense")
public SmartCarKeyOpreateResponse setLockingKeyAutoSense(SmartCarKeyAutoSenseRequest request) {
return aiLockingKeyService.setLockingKeyAutoSense(request);
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.glsx.smart.dao.entity.SmartScenceSupstatus;
import com.glsx.smart.service.SmartScenceSupstatusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Title: ConditionController.java
* @Description:获取场景指令触发条件
* @author think.wang
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Slf4j
@RestController
@RequestMapping("/condition")
public class ConditionController {
@Autowired
private SmartScenceSupstatusService statusService;
@ResponseBody
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartScenceSupstatus> getList(@RequestBody SmartScenceSupstatus record){
log.info("请求参数:{}", JSON.toJSONString(record));
return statusService.getList(record);
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.glsx.smart.dao.entity.SmartDeviceOrder;
import com.glsx.smart.service.SmartDeviceOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Title: ContentController.java
* @Description:获取场景指令执行内容
* @author think.wang
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Slf4j
@RestController
@RequestMapping("/content")
public class ContentController {
@Autowired
private SmartDeviceOrderService orderService;
@ResponseBody
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartDeviceOrder> getList(@RequestBody SmartDeviceOrder record){
log.info("请求参数:{}", JSON.toJSONString(record));
return orderService.getList(record);
}
}
package com.glsx.smart.controller; package com.glsx.smart.controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.glsx.smart.config.DeviceAddressProducer;
import org.springframework.web.bind.annotation.RequestMethod; import com.glsx.smart.dao.entity.SmartProduct;
import org.springframework.web.bind.annotation.ResponseBody; import com.glsx.smart.pojo.pb.InstanceFence.Fence;
import org.springframework.web.bind.annotation.RestController; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/** /**
* @Title: IndexController.java * @Title: IndexController.java
...@@ -13,13 +15,26 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -13,13 +15,26 @@ import org.springframework.web.bind.annotation.RestController;
* @Company: Didihu.com.cn * @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017 * @Copyright Copyright (c) 2017
*/ */
@Slf4j
@RestController @RestController
public class IndexController { public class IndexController {
@Autowired
private DeviceAddressProducer addressProducer;
@ResponseBody @ResponseBody
@RequestMapping(value = "/home", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/home", method = {RequestMethod.GET, RequestMethod.POST})
public String home(){ public String home(){
addressProducer.pushUserDeviceData("37717106ecfabc73037f",
"99.1233:56.3222", Fence.OperationType.DEL_VALUE);
return "hello, welcome to home!"; return "hello, welcome to home!";
} }
@ResponseBody
@RequestMapping(value = "/getProduct", method = {RequestMethod.POST})
public String getProduct(@RequestBody SmartProduct product){
log.info("获取参数:{}", product.toString());
return product.getIconUrl();
}
} }
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.glsx.smart.dao.entity.SmartDeviceOrdervalue;
import com.glsx.smart.service.SmartDeviceOrdervalueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Title: OrderValueController.java
* @Description:获取场景指令值列表
* @author think.wang
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Slf4j
@RestController
@RequestMapping("/orderValue")
public class OrderValueController {
@Autowired
private SmartDeviceOrdervalueService ordervalueService;
@ResponseBody
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartDeviceOrdervalue> getList(@RequestBody SmartDeviceOrdervalue record){
log.info("请求参数:{}", JSON.toJSONString(record));
return ordervalueService.getList(record);
}
}
package com.glsx.smart.controller;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartDeviceOrder;
import com.glsx.smart.dao.entity.SmartProduct;
import com.glsx.smart.service.SmartProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description: 产品列表业务
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/product")
public class ProductController {
@Autowired
private SmartProductService productService;
/**
* 分页获取产品列表。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getPageList", method = {RequestMethod.GET, RequestMethod.POST})
public PageInfo<SmartProduct> getPageList(SmartProduct req) {
log.info("$$$$ /product/getPageList param: {}", JSON.toJSONString(req));
return productService.getPageList(req);
}
/**
* 获取产品列表,不分页。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartProduct> getList(SmartProduct req) {
log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req));
return productService.getList(req);
}
/**
* 获取产品列表。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getListByCondition", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartProduct> getListByCondition(@RequestBody SmartProduct req) {
log.info("/product/getListByCondition param: {}", JSON.toJSONString(req));
return productService.getListByCondition(req);
}
/**
* 根据 id 查询产品详情。
*
* @param id 产品 id
* @return 结果
*/
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartProduct getById(Long id) {
log.info("$$$$ /product/getById param: {}", id);
return productService.getById(id);
}
/**
* 获取结构化的产品数据。
*
* @return 结果
*/
@RequestMapping(value = "/getProductAndCategory",
method = {RequestMethod.GET, RequestMethod.POST})
public JSONArray getProductAndCategory() {
log.info("$$$$ /product/getProductAndCategory...");
return productService.getProductTree();
}
/**
* 保存产品。无则插入,有则更新。
*
* @param product 产品
* @return 是否成功
*/
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public Boolean save(@RequestBody SmartProduct product) {
log.info("$$$$ /product/save param: {}", JSON.toJSONString(product));
return productService.save(product);
}
/**
* 根据产品 id 获取指令集。
*
* @param id 产品 id
*/
@RequestMapping(value = "/getCommandSetById", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartDeviceOrder> getCommandSetById(Long id) {
log.info("$$$$ /product/getCommandSetById param: {}", id);
return productService.getCommandSetById(id);
}
/**
* 上下架产品。
*
* @param id 产品 id
* @return 是否成功
*/
@RequestMapping(value = "/putOnOff", method = {RequestMethod.GET, RequestMethod.POST})
public Boolean putOnOff(Long id) {
log.info("$$$$ /product/putOnOff param: {}", id);
return productService.putOnOff(id);
}
}
package com.glsx.smart.controller;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartProductType;
import com.glsx.smart.service.SmartProductTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description: 产品类型业务
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/productType")
public class ProductTypeController {
@Autowired
private SmartProductTypeService productTypeService;
/**
* 分页获取产品类型列表。
*
* @param req 请求
* @return 结果
*/
@RequestMapping(value = "/getPageList", method = {RequestMethod.GET, RequestMethod.POST})
public PageInfo<SmartProductType> getPageList(SmartProductType req) {
log.info("$$$$ /productType/getPageList param: {}", JSON.toJSONString(req));
return productTypeService.getPageList(req);
}
/**
* 获取产品类型列表,不分页。
*
* @param req 请求
* @return 结果
*/
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartProductType> getList(SmartProductType req) {
log.info("$$$$ /productType/getList param: {}", JSON.toJSONString(req));
return productTypeService.getList(req);
}
/**
* 根据 id 获取产品类型。
*
* @param id 产品类型 id
* @return 结果
*/
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartProductType getById(Long id) {
return productTypeService.getById(id);
}
/**
* 保存产品类型。
*
* @param productType 产品类型
* @return 是否成功
*/
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public Boolean save(@RequestBody SmartProductType productType) {
log.info("$$$$ /productType/save param: {}", JSON.toJSONString(productType));
return productTypeService.save(productType);
}
/**
* 根据id列表获取指令执行内容
*
* @return 结果
*/
@RequestMapping(value = "/getListAndContent", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartProductType> getListAndContent(@RequestBody List<Long> list) {
return productTypeService.getListAndContent(list);
}
/**
* 根据id列表获取指令条件
*
* @return 结果
*/
@RequestMapping(value = "/getListAndCondition", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartProductType> getListAndCondition(@RequestBody List<Long> list) {
return productTypeService.getListAndCondition(list);
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.pojo.response.RemoteDeviceResp;
import com.glsx.smart.service.SmartProductService;
import com.glsx.smart.service.SmartProductTypeService;
import com.glsx.smart.service.SmartUserRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* 远程产品服务controller
* 暂时只有涂鸦
*/
@Slf4j
@RestController
@RequestMapping("/remoteProduct")
@Api(value = "设备管理", tags = {"设备管理"})
public class RemoteProductController {
@Value("${device_remote_url}")
private String remoteUrl;
@Autowired
private SmartProductService productService;
@Autowired
private SmartProductTypeService productTypeService;
@Autowired
private SmartUserRelationService userRelationService;
@Autowired
private SmartProductTypeService smartProductTypeService;
/**
* 用户获取远程产品列表数据
*
* @return 结果
*/
@ResponseBody
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<RemoteDeviceResp> getList(@RequestBody SmartUserRelation request) {
log.info("用户参数:{}", request);
// request.setUserId(91712228L);
SmartUserRelation user = userRelationService.getSingle(request);
if(user == null){
return null;
}
Byte status = request.getStatus() != null ? request.getStatus() : -1;
return this.getRemoteDevice(user.getThirdId(), status);
}
private List<RemoteDeviceResp> getRemoteDevice(String thirdId, Byte status) {
List<RemoteDeviceResp> deviceRespList = new ArrayList<>();
StringBuffer url = new StringBuffer(remoteUrl);
url.append("/device/").append(thirdId).append("/devices");
log.info("请求远程设备列表接口地址:{}", url.toString());
try {
String result = HttpUtils.get(url.toString());
log.info("获取用户设备列表数据返回结果:{}", result);
if (StringUtils.isNotEmpty(result)) {
JSONObject json = JSON.parseObject(result);
if (json.getInteger("code").equals(200)) {
JSONArray array = json.getJSONArray("message");
if(array == null || array.size() <= 0){
return deviceRespList;
}
return productTypeService.remoteDeviceHandler(array, status);
}
}
} catch (Exception e) {
log.error("获取用户设备列表数据失败:{}", e);
}
return deviceRespList;
}
/**
* 查询红外设备下的遥控器
*
* @return 结果
*/
@ResponseBody
@RequestMapping(value = "/findRemotes", method = {RequestMethod.GET, RequestMethod.POST})
@ApiOperation(value = "查询红外设备下的遥控器")
public String findRemotes(@RequestParam String infrared_id) {
return smartProductTypeService.findRemotesById(infrared_id);
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.glsx.smart.dao.entity.SmartScene;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.pojo.OrderResponse;
import com.glsx.smart.service.*;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/scene")
@Api(value = "场景管理", tags = {"场景管理"})
public class SceneController {
@Autowired
private SmartSceneService sceneService;
@Autowired
private SmartSceneLogService sceneLogService;
@Autowired
private SmartSceneDataService sceneDataService;
@Autowired
private UserKafkaService userKafkaService;
@Autowired
private SmartUserRelationService userRelationService;
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartScene> getList(@RequestBody SmartScene scene) {
log.info("/scene/getList param: {}", JSON.toJSONString(scene));
return sceneService.getList(scene);
}
@RequestMapping(value = "/getScenList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartScene> getScenList(@RequestBody SmartScene scene) {
log.info("/scene/getScenList param: {}", JSON.toJSONString(scene));
SmartUserRelation smartUserRelation = new SmartUserRelation();
smartUserRelation.setUserId(scene.getUserId());
SmartUserRelation user = userRelationService.getSingle(smartUserRelation);
if (user == null) {
return null;
}
scene.setUserId(user.getId());
return sceneService.getList(scene);
}
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartScene getById(Long id) {
log.info("/scene/getById param: {}", id);
SmartScene scene = sceneService.getById(id);
if (scene != null) {
scene.setDataList(sceneDataService.getBySceneId(id));
}
return scene;
}
@RequestMapping(value = "/add", method = {RequestMethod.POST})
public boolean save(@RequestBody SmartScene scene) {
scene.setCreateTime(new Date());
log.info("用户新增调用/scene/add param: {}", JSON.toJSONString(scene));
boolean flag = sceneService.insert(scene) > 0;
if (flag) {
userKafkaService.addDeviceData(scene); //推送数据至kafka
sceneLogService.insertWrapper(scene.getUserId(),
"新增场景数据:" + scene.getId(), JSON.toJSONString(scene));
}
return flag;
}
@RequestMapping(value = "/update", method = {RequestMethod.POST})
public boolean update(@RequestBody SmartScene scene) {
scene.setUpdateTime(new Date());
log.info("用户更新调用/scene/update param: {}", JSON.toJSONString(scene));
boolean flag = sceneService.update(scene) > 0;
if (flag) {
userKafkaService.addDeviceData(scene); //推送数据至kafka
sceneLogService.insertWrapper(scene.getUserId(),
"更新场景数据:" + scene.getId(), JSON.toJSONString(scene));
}
return flag;
}
@RequestMapping(value = "/delete", method = {RequestMethod.POST})
public boolean delete(@RequestBody SmartScene scene) {
log.info("用户删除场景调用/scene/delete param: {}", scene.getId());
SmartScene data = sceneService.getById(scene.getId());
int i = sceneService.deleteByPrimaryKey(scene.getId());
if (i > 0) {
sceneDataService.deleteBySceneId(scene.getId());
sceneLogService.insertWrapper(data.getUserId(),
"删除场景数据:" + data.getId(), JSON.toJSONString(data));
return true;
}
return false;
}
@RequestMapping(value = "/updateStatus", method = {RequestMethod.POST})
public boolean updateStatus(@RequestBody SmartScene scene) {
scene.setUpdateTime(new Date());
log.info("用户更新调用/scene/updateStatus param: {}", JSON.toJSONString(scene));
return sceneService.updateByPrimaryKeySelective(scene) > 0;
}
@RequestMapping(value = "/issueOrder", method = {RequestMethod.POST})
public List<OrderResponse> issueOrder(@RequestBody SmartScene scene) {
return sceneService.issueOrder(scene);
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartSceneTemplate;
import com.glsx.smart.service.SmartSceneTemplateService;
import com.glsx.smart.service.SmartTemplateParamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/sceneTemplate")
public class SceneTemplateController {
@Autowired
private SmartSceneTemplateService sceneTemplateService;
@Autowired
private SmartTemplateParamService templateParamService;
@RequestMapping(value = "/getPageList", method = {RequestMethod.GET, RequestMethod.POST})
public PageInfo<SmartSceneTemplate> getPageList(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("/sceneTemplate/getList param: {}", JSON.toJSONString(sceneTemplate));
List<SmartSceneTemplate> sceneList = sceneTemplateService.getList(sceneTemplate);
PageInfo<SmartSceneTemplate> pageInfo = PageInfo.of(sceneList);
return pageInfo;
}
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public List<SmartSceneTemplate> getList(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("/sceneTemplate/getList param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.getList(sceneTemplate);
}
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartSceneTemplate getById(@RequestParam("id") Long id) {
log.info("/sceneTemplate/getById param: {}", id);
SmartSceneTemplate template = sceneTemplateService.getById(id);
if(template != null){
template.setTemplateList(templateParamService.getByTemplateId(id));
}
return template;
}
@RequestMapping(value = "/add", method = {RequestMethod.POST})
public boolean save(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("新增调用/sceneTemplate/add param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.insert(sceneTemplate) > 0 ? true : false;
}
@RequestMapping(value = "/update", method = {RequestMethod.POST})
public boolean update(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("更新调用/sceneTemplate/update param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.update(sceneTemplate) > 0 ? true : false;
}
@RequestMapping(value = "/updateParam", method = {RequestMethod.POST})
public boolean updateParam(@RequestBody SmartSceneTemplate sceneTemplate) {
log.info("更新主表调用/sceneTemplate/updateParam param: {}", JSON.toJSONString(sceneTemplate));
return sceneTemplateService.updateByPrimaryKeySelective(sceneTemplate) > 0 ? true : false;
}
}
package com.glsx.smart.controller;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.glsx.smart.dao.entity.SmartSysCode;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartSysCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/sysCode")
public class SysCodeController {
@Autowired
private SmartSysCodeService sysCodeService;
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SmartSysCode code) {
log.info("/sysCode/getList param: {}", JSON.toJSONString(code));
if(StringUtils.isEmpty(code.getDictType())
|| StringUtils.isEmpty(code.getParentKey())){
return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
}
try {
List<SmartSysCode> sysCodeList = sysCodeService.getList(code);
return R.ok().data(sysCodeList);
} catch (Exception e) {
log.error("!!!! /sysCode/getList ERROR", e);
return R.error();
}
}
@RequestMapping(value = "/getListByCondition", method = {RequestMethod.POST})
public List<SmartSysCode> getListByCondition(@RequestBody SmartSysCode code) {
log.info("/sysCode/getListByCondition param: {}", JSON.toJSONString(code));
return sysCodeService.getList(code);
}
}
package com.glsx.smart.controller;
import java.util.List;
import java.util.Map;
import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.FileDTO;
import com.glsx.smart.service.SmartSysFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/sysFile")
@Api(value = "图片管理", tags = {"图片管理"})
public class SysFileController {
@Autowired
private SmartSysFileService sysFileService;
@RequestMapping(value = "/getList", method = {RequestMethod.GET})
@ApiOperation(value = "查询图片")
public R findAll(@RequestParam("type") Byte type) {
return R.ok().data(sysFileService.findByType(type));
}
@RequestMapping(value = "/batchSaveFile", method = {RequestMethod.POST})
@ApiOperation(value = "批量保存图片")
public R saveFile(@RequestBody List<FileDTO> files) {
List<Map<String, Object>> mapList = null;
try {
mapList = sysFileService.saveFile(files);
} catch (Exception e) {
log.error("批量保存图片失败:", e);
return R.error();
}
return R.ok().data(mapList);
}
@RequestMapping(value = "/saveFile", method = {RequestMethod.POST})
@ApiOperation(value = "保存更新图片")
public R updateFile(@RequestBody FileDTO fileDTO) {
try {
return R.ok().data(sysFileService.updateFile(fileDTO));
} catch (Exception e) {
log.error("保存更新图片失败:", e);
return R.error();
}
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.glsx.smart.config.DeviceAddressProducer;
import com.glsx.smart.dao.entity.SmartScene;
import com.glsx.smart.dao.entity.SmartSceneData;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.pojo.pb.InstanceFence.Fence;
import com.glsx.smart.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author think.wang
* @version 1.0.0
* @Title UserKafkaController
* @Package com.glsx.smart.controller
* @Description 嘀嘀虎用户数据推送处理controller
* @date 2021/4/10
*/
@Slf4j
@RestController
@RequestMapping("/userKafka")
public class UserKafkaController {
@Autowired
private UserKafkaService userKafkaService;
@Autowired
private SmartSceneService sceneService;
@Autowired
private SmartSceneLogService sceneLogService;
@Autowired
private SmartUserRelationService userRelationService;
@Autowired
private SmartSceneDataService sceneDataService;
@Autowired
private DeviceAddressProducer addressProducer;
/**
* 更新用户场景
*
* @param userId
* @param phone
* @param lngAndLat
* @return
*/
@ResponseBody
@RequestMapping(value = "/updateUserAddress", method = {RequestMethod.POST, RequestMethod.GET})
public boolean updateUserAddress(@RequestParam("userId") Long userId, @RequestParam("phone") String phone,
@RequestParam("lngAndLat") String lngAndLat){
SmartUserRelation relation = getUserRelation(userId, phone);
if(relation == null){
return false;
}
SmartScene record = new SmartScene();
record.setUserId(relation.getId());
List<SmartScene> sceneList = sceneService.getList(record);
if(sceneList.isEmpty()){
return false;
}
int len = sceneList.size();
for (int i = 0; i < len; i++) {
SmartScene scene = sceneList.get(i);
List<String> deviceList = userKafkaService.getSendDeviceList(
sceneDataService.getBySceneId(scene.getId()));
if(CollectionUtils.isNotEmpty(deviceList)){
for (String deviceId : deviceList) {
//更新设备家位置
addressProducer.pushUserDeviceData(deviceId, lngAndLat, Fence.OperationType.UPDATE_VALUE);
}
}
}
return true;
}
@ResponseBody
@RequestMapping(value = "/logoutUserScene", method = {RequestMethod.POST, RequestMethod.GET})
public boolean logoutUserScene(@RequestParam("userId") Long userId, @RequestParam("phone") String phone) {
SmartUserRelation relation = getUserRelation(userId, phone);
if (relation != null) {
SmartScene record = new SmartScene();
record.setUserId(relation.getId());
List<SmartScene> sceneList = sceneService.getList(record);
if (CollectionUtils.isNotEmpty(sceneList)) {
int len = sceneList.size();
for (int j = 0; j < len; j++) {
SmartScene scene = sceneList.get(j);
List<SmartSceneData> dataList = sceneDataService.getBySceneId(scene.getId());
if(CollectionUtils.isNotEmpty(dataList)){
List<String> deviceList = userKafkaService.getSendDeviceList(dataList);
if (CollectionUtils.isNotEmpty(deviceList)) {
for (String deviceId : deviceList) {
addressProducer.pushUserDeviceData(deviceId, null, Fence.OperationType.DEL_VALUE); //删除设备信息
}
}
}
//删除用户场景数据
int i = sceneService.deleteByPrimaryKey(scene.getId());
if(i > 0){
sceneDataService.deleteBySceneId(scene.getId());
sceneLogService.insertWrapper(scene.getUserId(),
"删除场景数据:" + scene.getId(), JSON.toJSONString(scene));
}
}
}
}
return true;
}
/**
* 获取车家智能用户关系
* @param userId
* @param phone
* @return
*/
private SmartUserRelation getUserRelation(Long userId, String phone){
SmartUserRelation record = new SmartUserRelation();
record.setUserId(userId);
record.setPhone(phone);
record.setChannel((byte)1);
return userRelationService.getSingle(record);
}
}
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.MD5Utils;
import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.glsx.plat.redis.utils.RedisUtils;
import com.glsx.smart.constant.Constants;
import com.glsx.smart.dao.entity.SmartUserRelation;
import com.glsx.smart.service.SmartUserRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @Title: UserRelationController.java
* @Description:用户关系控制类
* @author think.wang
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Slf4j
@RestController
@RequestMapping("/user")
public class UserRelationController {
@Value("${device_remote_url}")
private String remoteUrl;
@Value("${tuya_user_sync}")
private String syncUser;
@Autowired
private RedisUtils redisUtils;
@Autowired
private SmartUserRelationService userRelationService;
@ResponseBody
@RequestMapping(value = "/getSingle", method = {RequestMethod.POST})
public SmartUserRelation getSingle(@RequestBody SmartUserRelation userRelation){
return userRelationService.getSingle(userRelation);
}
@ResponseBody
@RequestMapping(value = "/add", method = {RequestMethod.POST})
public Long add(@RequestBody SmartUserRelation userRelation){
log.info("/user/add保存数据参数:{}", JSON.toJSONString(userRelation));
return userRelationService.insertSelective(userRelation);
}
@ResponseBody
@RequestMapping(value = "/update", method = {RequestMethod.POST})
public Integer update(@RequestBody SmartUserRelation userRelation){
log.info("/user/update保存数据参数:{}", JSON.toJSONString(userRelation));
return userRelationService.updateByPrimaryKeySelective(userRelation);
}
@ResponseBody
@RequestMapping(value = "/login", method = {RequestMethod.POST})
public R login(@RequestBody SmartUserRelation userRelation){
log.info("/user/login保存数据参数:{}", JSON.toJSONString(userRelation));
String key = new StringBuffer(userRelation.getPhone())
.append(userRelation.getChannel()).toString();
if(redisUtils.hasKey(key)){
log.info("{} 已发送请求", key);
return R.ok();
}
redisUtils.setex(key, key, Constants.REDIS_CACHE_TIME);
SmartUserRelation request = new SmartUserRelation();
request.setPhone(userRelation.getPhone());
request.setChannel(userRelation.getChannel()); //涂鸦
SmartUserRelation user = userRelationService.getSingle(request);
request.setUserId(userRelation.getUserId());
String password = MD5Utils.md5Hex(request.getPhone(), "utf-8");
request.setPassword(password);
if(user != null){
String tuYaId = user.getThirdId();
if(StringUtils.isEmpty(tuYaId)){
if(request.getChannel() == 1){
tuYaId = this.syncUser(user.getPhone(), user.getPassword());
request.setThirdId(tuYaId);
request.setId(user.getId());
}
}
userRelationService.updateByPrimaryKeySelective(request);
return R.ok().data(tuYaId);
}
// String password = MD5.create().digestHex(Constants.DEFAULT_PASSWORD);
request.setCreateTime(new Date());
if(request.getChannel() == 1){ //渠道为涂鸦
String tuYaId = this.syncUser(request.getPhone(), password);
request.setThirdId(tuYaId);
Long id = userRelationService.insertSelective(request);
if(id != null && id > 0){
return R.ok().data(tuYaId);
}
}
return R.error();
}
private String syncUser(String mobile, String password){
Map<String, String> object = new HashMap<>();
object.put("country_code", "86");
object.put("username", mobile);
object.put("username_type", "1");
object.put("password", password);
try {
StringBuffer syncUserUrl = new StringBuffer(remoteUrl);
syncUserUrl.append(syncUser);
log.info("请求注册涂鸦平台接口地址:{},参数:{}", syncUserUrl.toString(), JSON.toJSONString(object));
String result = HttpUtils.post(syncUserUrl.toString(), JSON.toJSONString(object));
log.info("注册涂鸦平台返回结果:{}", result);
if (!StringUtils.isEmpty(result)) {
JSONObject json = JSON.parseObject(result);
if (json.getInteger("code").equals(200)) {
return json.getJSONObject("message").getString("uid");
}
}
} catch (Exception e) {
log.error("同步涂鸦平台失败:{}", e);
}
return null;
}
}
package com.glsx.smart.dao.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
@Data
@Table(name = "smart_device_order")
public class SmartDeviceOrder {
@Id
@Column(name = "id")
private Integer id;
/**
* 产品id
*/
@Column(name = "product_id")
private String productId;
@Column(name = "order_code")
private String orderCode;
@Column(name = "order_value")
private String orderValue;
/**
* 设备类型 1.非固定值不需要查询 2.固定值需要查询
*/
@Column(name = "order_type")
private String orderType;
/**
* 1.String类型 2.Interger类型 3.boolean类型
*/
@Column(name = "order_value_type")
private String orderValueType;
/**
* 状态 1上线 0下线
*/
@Column(name = "status")
private Byte status;
}
package com.glsx.smart.dao.entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
/**
* 车家智能场景设备指令集表
*/
@Data
@Table(name = "smart_device_ordervalue")
public class SmartDeviceOrdervalue {
@Id
@Column(name = "id")
private Integer id;
/**
* 关联smart_device_order表中id
*/
@Column(name = "order_id")
private Integer orderId;
@Column(name = "device_status_code")
private String deviceStatusCode;
@Column(name = "device_status_value")
private String deviceStatusValue;
}
package com.glsx.smart.dao.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Data
@Table(name = "smart_device_status")
public class SmartDeviceStatus {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 设备id
*/
private String deviceId;
/**
* 设备指令
*/
private String deviceOrderCode;
/**
* 设备指令值
*/
private String deviceOrderValue;
/**
* 创建时间
*/
private Date createtime;
/**
* 更新时间
*/
private Date updatetime;
/**
* 产品id
*/
private String productKey;
}
package com.glsx.smart.dao.entity;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* 智能蓝牙车钥匙指令操作日志表
*/
@Data
@Table(name = "smart_key_command_log")
public class SmartKeyCommandLog implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 平台生成的唯一CREP信息(密文)
*/
private String crep;
/**
* 指令代码
*/
private String keyCommand;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import com.glsx.smart.pojo.BaseDTO;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品数据表
*/
@Data
@Table(name = "smart_product")
public class SmartProduct extends BaseDTO {
/**
* 图标 url
*/
@Transient
private String iconUrl;
/**
* 二级分类 key
*/
@Transient
private String categoryKey;
/**
* 产品类型名称
*/
@Transient
private String typeName;
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 产品名称
*/
private String productName;
/**
* 图片ID 关联smart_sys_file中id
*/
private Long icon;
/**
* 产品类型ID 关联smart_product_type中id
*/
private Long typeId;
/**
* 商城产品id
*/
private String shopProductId;
/**
* 接入平台key 关联smart_sys_code中dict_key
*/
private String platformKey;
/**
* 接入平台产品id
*/
private String platformProductId;
/**
* 配网方式key 关联smart_sys_code中dict_key
*/
private String networkKey;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package com.glsx.smart.dao.entity;
import com.glsx.smart.pojo.BaseDTO;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品类型表
*/
@Data
@Table(name = "smart_product_type")
public class SmartProductType extends BaseDTO {
/**
* 一级分类
*/
@Transient
private String firstCategory;
/**
* 内容列表
*/
@Transient
private List<SmartDeviceOrder> contentList;
/**
* 条件列表
*/
@Transient
private List<SmartScenceSupstatus> conditionList;
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 类型名称
*/
private String typeName;
/**
* 类别key 关联smart_sys_code中dict_key
*/
private String categoryKey;
/**
* 商城标签
*/
private String shopTag;
/**
* 关联涂鸦的产品类型
*/
private Integer tuyaCategoryId;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package com.glsx.smart.dao.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
/**
* 车家智能场景支持设备条件表
*/
@Data
@Table(name = "smart_scence_supstatus")
public class SmartScenceSupstatus {
@Id
@Column(name = "id")
@GeneratedValue(generator = "JDBC")
private Integer id;
/**
* 产品支持状态code
*/
@Column(name = "scene_supstatus_code")
private String sceneSupstatusCode;
/**
* 产品支持状态value
*/
@Column(name = "scene_supstatus_value")
private String sceneSupstatusValue;
/**
* 产品id
*/
@Column(name = "product_id")
private String productId;
/**
* 状态对应的指令code
*/
@Column(name = "order_code")
private String orderCode;
@Column(name = "order_value")
private String orderValue;
/**
* 1.等于 2.大于 3.小于
*/
@Column(name = "`type`")
private String type;
/**
* 状态 1上线 0下线
*/
@Column(name = "status")
private Byte status;
}
package com.glsx.smart.dao.entity;
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能用户场景表
*/
@Data
@Table(name = "smart_scene")
public class SmartScene implements Serializable {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户ID 关联smart_user_relation中id
*/
private Long userId;
/**
* 场景名称
*/
private String sceneName;
/**
* 场景类型key 关联smart_sys_code中dict_key
*/
private String typeKey;
/**
* 场景图标ID 关联smart_sys_file中id
*/
private Long icon;
/**
* 场景图标
*/
private String iconUrl;
/**
* 场景背景图ID 关联smart_sys_file中id
*/
private Long backPic;
/**
* 场景背景图
*/
private String backPicUrl;
/**
* 查看次数
*/
private Long viewTimes;
/**
* 场景描述
*/
private String description;
/**
* 条件规则 1任一条件 2全部条件
*/
private Byte conditionRule;
/**
* 执行周期 1每天 2工作日 3法定节假日
*/
private Byte executeCycle;
/**
* 开关说明:-1 无开关 0开关关 1开关开
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 场景关系数据
*/
private List<SmartSceneData> dataList;
}
package com.glsx.smart.dao.entity;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* 车家智能用户场景数据表
*/
@Data
@Table(name = "smart_scene_data")
public class SmartSceneData {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 场景ID 关联smart_scene中id
*/
private Long sceneId;
/**
* 类型 1触发条件 2执行内容
*/
private Byte type;
/**
* 排序
*/
private Byte sort;
/**
* 参数key
*/
private String paramKey;
/**
* 设备id,取自param_value中select
*/
private String deviceId;
/**
* 参数值 数组对象
*/
private String paramValue;
}
package com.glsx.smart.dao.entity;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-04-11
*/
/**
* 车家智能用户场景日志表
*/
@Data
@Table(name = "smart_scene_log")
public class SmartSceneLog {
/**
* 标识ID
*/
@Id
@Column(name = "id")
@GeneratedValue(generator = "JDBC")
private Long id;
/**
* 用户ID 关联smart_user_relation中id
*/
@Column(name = "user_id")
private Long userId;
/**
* 描述
*/
@Column(name = "descript")
private String descript;
/**
* 场景数据
*/
@Column(name = "remark")
private String remark;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
}
package com.glsx.smart.dao.entity;
import com.glsx.smart.pojo.BaseDTO;
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能场景模板表
*/
@Data
@Table(name = "smart_scene_template")
public class SmartSceneTemplate extends BaseDTO implements Serializable {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 场景名称
*/
private String sceneName;
/**
* 场景类型key 关联smart_sys_code中dict_key
*/
private String typeKey;
/**
* 场景图标ID 关联smart_sys_file中id
*/
private Long icon;
/**
* 场景图标
*/
private String iconUrl;
/**
* 场景背景图ID 关联smart_sys_file中id
*/
private Long backPic;
/**
* 场景背景图
*/
private String backPicUrl;
/**
* 查看次数
*/
private Long viewTimes;
/**
* 场景描述
*/
private String description;
/**
* 条件规则 1任一条件 2全部条件
*/
private Byte conditionRule;
/**
* 执行周期 1每天 2工作日 3法定节假日
*/
private Byte executeCycle;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
/**
* 场景关系数据
*/
private List<SmartTemplateParam> templateList;
}
package com.glsx.smart.dao.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
import com.glsx.smart.pojo.BaseDTO;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能系统代码集表
*/
@Data
@Table(name = "smart_sys_code")
public class SmartSysCode extends BaseDTO {
/**
*
*/
@Transient
private List<SmartSysCode> subCodeList;
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 字典类型
*/
private String dictType;
/**
* 字典键值
*/
private String dictKey;
/**
* 字典值
*/
private String dictValue;
/**
* 父级键值
*/
private String parentKey;
/**
* 排序
*/
private Byte sort;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 分级
*/
private Byte level;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package com.glsx.smart.dao.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能系统文件表
*/
@Data
@Table(name = "smart_sys_file")
public class SmartSysFile {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 文件名
*/
private String name;
/**
* 文件链接
*/
private String url;
/**
* 类型:0公共 1图片素材库
*/
private Byte type;
/**
* 创建时间
*/
private Date createTime;
}
package com.glsx.smart.dao.entity;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
* 车家智能场景模板参数表
*/
@Data
@Table(name = "smart_template_param")
public class SmartTemplateParam {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 模板ID 关联smart_scene_template中id
*/
private Long templateId;
/**
* 类型 1触发条件 2执行内容
*/
private Byte type;
/**
* 排序
*/
private Byte sort;
/**
* 参数key
*/
private String paramKey;
/**
* 模板值 数组对象
*/
private String paramValue;
}
package com.glsx.smart.dao.entity;
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能用户平台注册信息表
*/
@Data
@Table(name = "smart_user_relation")
public class SmartUserRelation implements Serializable {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 公司用户ID
*/
private Long userId;
/**
* 用户昵称
*/
private String name;
/**
* 手机号 来自嘀加平台用户
*/
private String phone;
/**
* 用户密码
*/
private String password;
/**
* 第三方平台标识 1涂鸦
*/
private Byte channel;
/**
* 用户来源 ANDROID iOS
*/
private String source;
/**
* 第三方平台用户id
*/
private String thirdId;
/**
* 状态 0注销 1正常
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
}
package com.glsx.smart.dao.entity;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
* 智能蓝牙车钥匙表
*/
@Data
public class SmartVehicleBlueKey implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 智能车钥匙设备号
*/
private String sn;
/**
* 平台生成的唯一CREP信息(密文)
*/
private String crepCode;
/**
* 注册成功后生成的密钥(密文)
*/
private String secretKey;
/**
* 手机蓝牙的MAC地址
*/
private String mobileBlueMac;
/**
* 智能车钥匙MAC地址
*/
private String smartLockMac;
/**
* 车牌号
*/
private String carNumber;
/**
* 昵称
*/
private String keyName;
/**
* 自动感应状态 0:关 1:开
*/
private Integer autoSenseStatus;
/**
* 逻辑删除 0:正常 1:删除
*/
private Integer isDelete;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartDeviceOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
@Mapper
public interface SmartDeviceOrderMapper extends tk.mybatis.mapper.common.Mapper<SmartDeviceOrder> {
List<SmartDeviceOrder> getListByProductId(@Param("productId") String productId);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartDeviceOrdervalue;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
@Mapper
public interface SmartDeviceOrdervalueMapper
extends tk.mybatis.mapper.common.Mapper<SmartDeviceOrdervalue> {
List<SmartDeviceOrdervalue> getList(SmartDeviceOrdervalue record);
}
package com.glsx.smart.dao.mapper;
import java.util.List;
import com.glsx.smart.dao.entity.SmartDeviceStatus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartDeviceStatusMapper
extends tk.mybatis.mapper.common.Mapper<SmartDeviceStatus> {
int insertOrUpdate(SmartDeviceStatus record);
int insertOrUpdateSelective(SmartDeviceStatus record);
int updateBatch(List<SmartDeviceStatus> list);
int updateBatchSelective(List<SmartDeviceStatus> list);
int batchInsert(@Param("list") List<SmartDeviceStatus> list);
SmartDeviceStatus findDevStatusByIdAndCode(@Param("deviceId") String devideId, @Param("code") String order);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SmartKeyCommandLogMapper {
long countByExample(SmartKeyCommandLogExample example);
int deleteByExample(SmartKeyCommandLogExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartKeyCommandLog record);
int insertSelective(SmartKeyCommandLog record);
List<SmartKeyCommandLog> selectByExample(SmartKeyCommandLogExample example);
SmartKeyCommandLog selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartKeyCommandLog record, @Param("example") SmartKeyCommandLogExample example);
int updateByExample(@Param("record") SmartKeyCommandLog record, @Param("example") SmartKeyCommandLogExample example);
int updateByPrimaryKeySelective(SmartKeyCommandLog record);
int updateByPrimaryKey(SmartKeyCommandLog record);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartProduct;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartProductMapper extends tk.mybatis.mapper.common.Mapper<SmartProduct> {
List<SmartProduct> getList(SmartProduct product);
List<SmartProduct> getByCondition(SmartProduct product);
List<SmartProduct> getByPlatProductIdList(List<String> list);
SmartProduct getById(Long id);
int countByProductName(String productName);
List<SmartProduct> getAllProductList();
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartProductType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartProductTypeMapper extends tk.mybatis.mapper.common.Mapper<SmartProductType> {
List<SmartProductType> getList(SmartProductType productType);
SmartProductType getById(Long id);
int countByProductTypeName(String typeName);
List<SmartProductType> getListAndContent(List<Long> list);
List<SmartProductType> getByIdList(List<Long> list);
List<SmartProductType> getAllConditionList();
List<SmartProductType> getAllContentList();
List<SmartProductType> getListAndCondition(List<Long> list);
SmartProductType getByCategoryId(@Param("categoryId") Integer categoryId);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartScenceSupstatus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
@Mapper
public interface SmartScenceSupstatusMapper
extends tk.mybatis.mapper.common.Mapper<SmartScenceSupstatus> {
List<SmartScenceSupstatus> getListByProductId(@Param("productId") String productId);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartSceneData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartSceneDataMapper extends tk.mybatis.mapper.common.Mapper<SmartSceneData> {
int insertOrUpdate(SmartSceneData record);
int deleteBySceneId(Long id);
int insertOrUpdateSelective(SmartSceneData record);
int updateBatch(List<SmartSceneData> list);
int updateBatchSelective(List<SmartSceneData> list);
int batchInsert(@Param("list") List<SmartSceneData> list);
List<SmartSceneData> getBySceneId(@Param("sceneId") Long sceneId);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartSceneLog;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-04-11
*/
@Mapper
public interface SmartSceneLogMapper extends tk.mybatis.mapper.common.Mapper<SmartSceneLog> {
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartScene;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartSceneMapper extends tk.mybatis.mapper.common.Mapper<SmartScene> {
int insertOrUpdate(SmartScene record);
int insertOrUpdateSelective(SmartScene record);
int updateBatch(List<SmartScene> list);
int updateBatchSelective(List<SmartScene> list);
int batchInsert(@Param("list") List<SmartScene> list);
List<SmartScene> getList(SmartScene record);
SmartScene getById(Long id);
Map<String, Object> getBySourceAndUserId(Long id);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartSceneTemplate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartSceneTemplateMapper
extends tk.mybatis.mapper.common.Mapper<SmartSceneTemplate> {
int insertOrUpdate(SmartSceneTemplate record);
int insertOrUpdateSelective(SmartSceneTemplate record);
int updateBatch(List<SmartSceneTemplate> list);
int updateBatchSelective(List<SmartSceneTemplate> list);
int batchInsert(@Param("list") List<SmartSceneTemplate> list);
List<SmartSceneTemplate> getList(SmartSceneTemplate record);
SmartSceneTemplate getById(Long id);
}
package com.glsx.smart.dao.mapper;
import java.util.List;
import com.glsx.smart.dao.entity.SmartSysCode;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartSysCodeMapper extends tk.mybatis.mapper.common.Mapper<SmartSysCode> {
List<SmartSysCode> getList(SmartSysCode code);
List<SmartSysCode> getTree(SmartSysCode code);
int insertOrUpdate(SmartSysCode record);
int insertOrUpdateSelective(SmartSysCode record);
int updateBatch(List<SmartSysCode> list);
int updateBatchSelective(List<SmartSysCode> list);
int batchInsert(@Param("list") List<SmartSysCode> list);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartSysFile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartSysFileMapper extends tk.mybatis.mapper.common.Mapper<SmartSysFile> {
int insertOrUpdate(SmartSysFile record);
int insertOrUpdateSelective(SmartSysFile record);
int updateBatch(List<SmartSysFile> list);
int updateBatchSelective(List<SmartSysFile> list);
int batchInsert(@Param("list") List<SmartSysFile> list);
List<SmartSysFile> findByType(@Param("type") Byte type);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartTemplateParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartTemplateParamMapper
extends tk.mybatis.mapper.common.Mapper<SmartTemplateParam> {
int insertOrUpdate(SmartTemplateParam record);
int deleteByTemplateId(Long id);
int insertOrUpdateSelective(SmartTemplateParam record);
int updateBatch(List<SmartTemplateParam> list);
int updateBatchSelective(List<SmartTemplateParam> list);
int batchInsert(@Param("list") List<SmartTemplateParam> list);
List<SmartTemplateParam> getByTemplateId(@Param("templateId") Long templateId);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartUserRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Mapper
public interface SmartUserRelationMapper
extends tk.mybatis.mapper.common.Mapper<SmartUserRelation> {
int insertOrUpdate(SmartUserRelation record);
int insertOrUpdateSelective(SmartUserRelation record);
int updateBatch(List<SmartUserRelation> list);
int updateBatchSelective(List<SmartUserRelation> list);
int batchInsert(@Param("list") List<SmartUserRelation> list);
SmartUserRelation getSingle(SmartUserRelation record);
}
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartVehicleBlueKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueKeyExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SmartVehicleBlueKeyMapper {
long countByExample(SmartVehicleBlueKeyExample example);
int deleteByExample(SmartVehicleBlueKeyExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartVehicleBlueKey record);
int insertSelective(SmartVehicleBlueKey record);
List<SmartVehicleBlueKey> selectByExample(SmartVehicleBlueKeyExample example);
SmartVehicleBlueKey selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartVehicleBlueKey record, @Param("example") SmartVehicleBlueKeyExample example);
int updateByExample(@Param("record") SmartVehicleBlueKey record, @Param("example") SmartVehicleBlueKeyExample example);
int updateByPrimaryKeySelective(SmartVehicleBlueKey record);
int updateByPrimaryKey(SmartVehicleBlueKey record);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.exception;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public class BusinessException extends RuntimeException {
private Integer code;
private String message;
public BusinessException() {}
public BusinessException(ResultEnum resultEnum) {
this.code = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static BusinessException create(int code, String message){
BusinessException businessException = new BusinessException();
businessException.code = code;
businessException.message = message;
return businessException;
}
public static BusinessException create(ResultEnum resultEnum) {
return create(resultEnum.getCode(), resultEnum.getMessage());
}
}
package com.glsx.smart.exception;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
* @deprecated 抛出异常,让上游服务捕获信息
*/
@Slf4j
//@RestControllerAdvice
@Deprecated
public class GlobalExceptionHandler {
@ExceptionHandler({BusinessException.class})
public R handleBusinessException(BusinessException e) {
log.error("业务异常", e);
return R.error(e.getMessage());
}
@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
BindException.class})
public R handleBindException(Exception e) {
log.error("参数错误", e);
return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
}
@ExceptionHandler(Exception.class)
public R handleException(Exception e) {
log.error("未知异常", e);
return R.error(e.getMessage());
}
}
package com.glsx.smart.exception;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public enum ResultEnum {
SUCCESS(200, "成功"),
ERROR(500, "系统异常"),
PARAM_ERROR(1001, "参数错误"),
ID_NOT_FOUND(1002, "ID不存在"),
PRODUCT_NOT_FOUND(2001, "产品ID未找到"),
PRODUCT_NAME_DUPLICATE(2002, "产品名称重复"),
PRODUCT_TYPE_NOT_FOUND(3001, "产品类型ID未找到"),
PRODUCT_TYPE_NAME_DUPLICATE(3002, "产品类型名称重复"),
;
private final Integer code;
private final String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}
package com.glsx.smart.filter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import com.glsx.plat.common.utils.StringUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
/**
* <p>Description: 跨域配置
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-18
*/
@Component
public class CorsFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
StringBuffer headersSb = new StringBuffer();
Enumeration<String> headerNames = httpRequest.getHeaderNames();
while (headerNames.hasMoreElements()) {
headersSb.append(headerNames.nextElement()).append(", ");
}
if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.CONTENT_TYPE)) {
headersSb.append(HttpHeaders.CONTENT_TYPE).append(", ");
}
if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.AUTHORIZATION)) {
headersSb.append(HttpHeaders.AUTHORIZATION).append(", ");
}
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
headersSb.toString().replaceAll(", +$", ""));
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
httpRequest.getHeader(HttpHeaders.ORIGIN));
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
httpRequest.getMethod());
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*");
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "18000L");
// 放行预检请求(preflight requests)
if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS.toString())) {
httpResponse.setStatus(HttpServletResponse.SC_OK);
httpResponse.getWriter().println("OK");
return;
}
chain.doFilter(request, response);
}
}
package com.glsx.smart.pojo; package com.glsx.smart.pojo;
import javax.persistence.Transient;
import lombok.Data;
/** /**
* @author think.wang * @author think.wang
* @version 1.0.0 * @version 1.0.0
...@@ -8,97 +11,47 @@ package com.glsx.smart.pojo; ...@@ -8,97 +11,47 @@ package com.glsx.smart.pojo;
* @Description 公共参数vo * @Description 公共参数vo
* @date 2020/9/4 * @date 2020/9/4
*/ */
@Data
public class BaseDTO { public class BaseDTO {
/** /**
* 第几页 * 第几页
*/ */
@Transient
private int pageIndex; private int pageIndex;
/** /**
* 每一页的记录数 * 每一页的记录数
*/ */
@Transient
private int pageSize; private int pageSize;
/** /**
* 搜索key * 搜索key
*/ */
@Transient
private String searchKey; private String searchKey;
/** /**
* 排序 * 排序
*/ */
@Transient
private String orderBy; private String orderBy;
/** /**
* 查询条件开始时间 * 查询条件开始时间
*/ */
@Transient
private String startTime; private String startTime;
/** /**
* 查询条件结束时间 * 查询条件结束时间
*/ */
@Transient
private String endTime; private String endTime;
/** /**
* 用户id * 用户id
*/ */
@Transient
private Long uid; private Long uid;
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public String getSearchKey() {
return searchKey;
}
public void setSearchKey(String searchKey) {
this.searchKey = searchKey;
}
public Long getUid() {
return uid;
}
public void setUid(Long uid) {
this.uid = uid;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
} }
package com.glsx.smart.pojo;
import lombok.Data;
/**
* <p>Description: 嘀加商城 API 实体类
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-24
*/
@Data
public class DjApiDTO {
private String code;
private String errId;
private String message;
private String data;
}
package com.glsx.smart.pojo;
import lombok.Data;
/**
* @author zhouhaibao
* @date 2021/3/22 15:52
*/
@Data
public class ExecuteTaskVo {
private String select;
private String order;
private String orderVal;
private String valType;
private String remoteId;
private String value;
private String deviceName;
private String msg;
}
package com.glsx.smart.pojo;
import lombok.Data;
/**
* @author zhouhaibao
* @date 2021/3/17 10:27
*/
@Data
public class FileDTO {
private String url;
private String name;
private Long id;
/**
* 类型:0公共 1图片素材库
*/
private Byte type;
}
package com.glsx.smart.pojo;
import lombok.Data;
/**
* @author zhouhaibao
* @date 2021/3/26 17:57
*/
@Data
public class OrderResponse {
private String deviceName;
private String message;
private boolean result;
private Integer code;
}
package com.glsx.smart.pojo;
import lombok.Data;
/**
* @author zhouhaibao
* @date 2021/3/22 16:18
*/
@Data
public class ResponseVo {
private String code;
private String message;
private String msg;
@Override
public String toString() {
return "ResponseVo{" +
"code='" + code + '\'' +
", message='" + message + '\'' +
", msg='" + msg + '\'' +
'}';
}
}
This diff could not be displayed because it is too large.
package com.glsx.smart.pojo.request;
/**
* 智能车钥匙,自动感应状态
*/
public class SmartCarKeyAutoSenseRequest{
//智能车钥匙自动感应状态
private Integer autoSenseStatus;
private String crep;
private Long userId;
public Integer getAutoSenseStatus() {
return autoSenseStatus;
}
public void setAutoSenseStatus(Integer autoSenseStatus) {
this.autoSenseStatus = autoSenseStatus;
}
public String getCrep() {
return crep;
}
public void setCrep(String crep) {
this.crep = crep;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "SmartCarKeyAutoSenseRequest{" +
"autoSenseStatus=" + autoSenseStatus +
", crep='" + crep + '\'' +
", userId=" + userId +
'}';
}
}
package com.glsx.smart.pojo.request;
/**
* 智能车钥匙,指令上报
*/
public class SmartCarKeyCommandRequest{
//平台生成的唯一CREP信息
private String crepCode;
//指令代码
//1、开锁;2、关锁;3、开尾门;4、寻车;5、自动感应近;
// 6、自动感应中;7、自动感应远;8、自动感应关
private String keyCommond;
//用户id
private Long userId;
public String getCrepCode() {
return crepCode;
}
public void setCrepCode(String crepCode) {
this.crepCode = crepCode;
}
public String getKeyCommond() {
return keyCommond;
}
public void setKeyCommond(String keyCommond) {
this.keyCommond = keyCommond;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "SmartCarKeyCommandRequest{" +
"crepCode='" + crepCode + '\'' +
", keyCommond='" + keyCommond + '\'' +
", userId=" + userId +
'}';
}
}
package com.glsx.smart.pojo.request;
/**
* 智能车钥匙,昵称
*/
public class SmartCarKeyNameRequest{
//昵称
private String name;
private String crep;
private Long userId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCrep() {
return crep;
}
public void setCrep(String crep) {
this.crep = crep;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "SmartCarKeyNameRequest{" +
"name='" + name + '\'' +
", crep='" + crep + '\'' +
", userId=" + userId +
'}';
}
}
package com.glsx.smart.pojo.request;
/**
* 智能车钥匙,注册信息保存
*/
public class SmartCarKeyRegisterRequest{
//手机蓝牙的MAC地址
private String mobileMac;
//平台生成的唯一CREP信息
private String crepCode;
//注册成功后生成的密钥
private String keyLock;
//智能车钥匙MAC地址
private String smartLockMac;
private Long userId;
public String getMobileMac() {
return mobileMac;
}
public void setMobileMac(String mobileMac) {
this.mobileMac = mobileMac;
}
public String getCrepCode() {
return crepCode;
}
public void setCrepCode(String crepCode) {
this.crepCode = crepCode;
}
public String getKeyLock() {
return keyLock;
}
public void setKeyLock(String keyLock) {
this.keyLock = keyLock;
}
public String getSmartLockMac() {
return smartLockMac;
}
public void setSmartLockMac(String smartLockMac) {
this.smartLockMac = smartLockMac;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "SmartCarKeyRegisterRequest{" +
"mobileMac='" + mobileMac + '\'' +
", crepCode='" + crepCode + '\'' +
", keyLock='" + keyLock + '\'' +
", smartLockMac='" + smartLockMac + '\'' +
", userId=" + userId +
'}';
}
}
package com.glsx.smart.pojo.request;
/**
* 智能车钥匙,查询车钥匙和生成crep接口
*/
public class SmartCarKeyRequest{
private String sn;
private Long userId;
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "SmartCarKeyRequest{" +
"sn='" + sn + '\'' +
", userId='" + userId + '\'' +
'}';
}
}
package com.glsx.smart.pojo.request;
/**
* 智能车钥匙,查询车钥匙和生成crep接口
*/
public class SmartCarKeyRmRequest {
private String crep;
private Long userId;
public String getCrep() {
return crep;
}
public void setCrep(String crep) {
this.crep = crep;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
@Override
public String toString() {
return "SmartCarKeyRmRequest{" +
"crep='" + crep + '\'' +
", userId='" + userId + '\'' +
'}';
}
}
package com.glsx.smart.pojo.response;
import lombok.Data;
/**
* @author think.wang
* @version 1.0.0
* @Title RemoteDeviceResp
* @Package com.glsx.smart.pojo.response
* @Description 远程设备返回数据
* @date 2021/4/12
*/
@Data
public class RemoteDeviceResp {
private String productId; //产品id
private String uuid; //设备id
private String productName; //产品名称
private String iconUrl; //产品图片url
private boolean flag; //是否万能遥控器 true是 false否
}
package com.glsx.smart.pojo.response;
import java.io.Serializable;
public class SmartCarKeyOpreateResponse implements Serializable {
private boolean isSuccess;
public boolean isSuccess() {
return isSuccess;
}
public void setSuccess(boolean success) {
isSuccess = success;
}
@Override
public String toString() {
return "SmartCarKeyOpreateResponse{" +
"isSuccess=" + isSuccess +
'}';
}
}
package com.glsx.smart.pojo.response;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class SmartCarKeyResponse implements Serializable {
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 智能车钥匙设备号
*/
private String sn;
/**
* 平台生成的唯一CREP信息(密文)
*/
private String crepCode;
/**
* 注册成功后生成的密钥(密文)
*/
private String secretKey;
/**
* 手机蓝牙的MAC地址
*/
private String mobileBlueMac;
/**
* 智能车钥匙MAC地址
*/
private String smartLockMac;
/**
* 车牌号
*/
private String carNumber;
/**
* 昵称
*/
private String keyName;
/**
* 自动感应状态 0:关 1:开
*/
private Integer autoSenseStatus;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}
package com.glsx.smart.redis;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
*
* redis 操作工具类
*/
@Component
public class RedisService {
@Resource(name = "redisTemplate")
protected RedisTemplate<Object,Object> redisTemplate;
protected Log logger = LogFactory.getLog(getClass());
public void set(String key, Object value) {
ValueOperations valueOperations = redisTemplate.opsForValue();
valueOperations.set(key, value);
}
public void setOutTime(String key, Object value,long timeout, TimeUnit unit) {
ValueOperations valueOperations = redisTemplate.opsForValue();
valueOperations.set(key, value,timeout,unit);
}
public Object get(String key) {
return redisTemplate.opsForValue().get(key);
}
public void setList(String key, List<?> value) {
ListOperations listOperations = redisTemplate.opsForList();
listOperations.leftPush(key, value);
}
public Object getList(String key) {
return redisTemplate.opsForList().leftPop(key);
}
public void setSet(String key, Set<?> value) {
SetOperations setOperations = redisTemplate.opsForSet();
setOperations.add(key, value);
}
public Object getSet(String key) {
return redisTemplate.opsForSet().members(key);
}
public void setHash(String key, Map<String, ?> value) {
HashOperations hashOperations = redisTemplate.opsForHash();
hashOperations.putAll(key, value);
}
public Object getHash(String key) {
return redisTemplate.opsForHash().entries(key);
}
public void delete(String key) {
redisTemplate.delete(key);
}
}
\ No newline at end of file \ No newline at end of file
package com.glsx.smart.service;
import com.glsx.smart.pojo.request.*;
import com.glsx.smart.pojo.response.SmartCarKeyOpreateResponse;
import com.glsx.smart.pojo.response.SmartCarKeyResponse;
/**
* <p>Description:智能车钥匙接口
* <p>Project: chejia-smart
*
* @author fenbgzhi
* @date 2021-04-19
*/
public interface AiLockingKeyService {
/**
* 通过sn获取车钥匙
*/
SmartCarKeyResponse getLockingKey(SmartCarKeyRequest request);
/**
* 通过sn解绑车钥匙
*/
SmartCarKeyOpreateResponse removeLockingKey(SmartCarKeyRmRequest request);
/**
* 车钥匙注册信息保存
*/
SmartCarKeyOpreateResponse saveLockingKeyRegisterInfo(SmartCarKeyRegisterRequest registerSaveRequest);
/**
* 车钥匙指令上报
*/
SmartCarKeyOpreateResponse LogLockingKeyCommand(SmartCarKeyCommandRequest carKeyCommandRequest);
/**
* 修改车钥匙昵称
*/
SmartCarKeyOpreateResponse setLockingKeyName(SmartCarKeyNameRequest name);
/**
* 修改车钥匙自动感应状态
*/
SmartCarKeyOpreateResponse setLockingKeyAutoSense(SmartCarKeyAutoSenseRequest autoSenseStatus);
}
package com.glsx.smart.service;
import com.github.pagehelper.PageHelper;
import com.glsx.smart.pojo.BaseDTO;
/**
* <p>Description: 公共 Service 业务
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public abstract class BaseService {
/**
* 按需开启分页,调用此方法后需紧跟查询 sql,否则分页将不生效
*
* @param req 请求体
* @param <T> 继承自 {@link BaseDTO}
*/
protected <T extends BaseDTO> void startPagination(T req) {
int pageIndex = req.getPageIndex();
int pageSize = req.getPageSize();
if (pageIndex > 0 && pageSize > 0) {
PageHelper.startPage(pageIndex, pageSize);
}
}
}
package com.glsx.smart.service;
import org.springframework.stereotype.Service;
/**
* @Title: DemoService.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Service
public class DemoService {
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartDeviceOrder;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
public interface SmartDeviceOrderService{
List<SmartDeviceOrder> getList(SmartDeviceOrder record);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartDeviceOrdervalue;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
public interface SmartDeviceOrdervalueService {
List<SmartDeviceOrdervalue> getList(SmartDeviceOrdervalue record);
}
package com.glsx.smart.service;
import java.util.List;
import com.glsx.smart.dao.entity.SmartDeviceStatus;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartDeviceStatusService {
int deleteByPrimaryKey(Integer id);
int insertOrUpdate(SmartDeviceStatus record);
int insertSelective(SmartDeviceStatus record);
List<SmartDeviceStatus> selectByExample(SmartDeviceStatus example);
SmartDeviceStatus selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SmartDeviceStatus record);
int updateBatchSelective(List<SmartDeviceStatus> list);
int batchInsert(List<SmartDeviceStatus> list);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import java.util.List;
import com.glsx.smart.dao.entity.SmartKeyCommandLogExample;
public interface SmartKeyCommandLogService {
long countByExample(SmartKeyCommandLogExample example);
int deleteByExample(SmartKeyCommandLogExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartKeyCommandLog record);
int insertSelective(SmartKeyCommandLog record);
List<SmartKeyCommandLog> selectByExample(SmartKeyCommandLogExample example);
SmartKeyCommandLog selectByPrimaryKey(Long id);
int updateByExampleSelective(SmartKeyCommandLog record, SmartKeyCommandLogExample example);
int updateByExample(SmartKeyCommandLog record, SmartKeyCommandLogExample example);
int updateByPrimaryKeySelective(SmartKeyCommandLog record);
int updateByPrimaryKey(SmartKeyCommandLog record);
}
package com.glsx.smart.service;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartDeviceOrder;
import com.glsx.smart.dao.entity.SmartProduct;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartProductService {
PageInfo<SmartProduct> getPageList(SmartProduct product);
List<SmartProduct> getList(SmartProduct product);
List<SmartProduct> getByPlatProductIdList(List<String> list);
List<SmartProduct> getListByCondition(SmartProduct product);
SmartProduct getById(Long id);
JSONArray getProductAndCategory();
JSONArray getProductTree();
Boolean save(SmartProduct product);
List<SmartDeviceOrder> getCommandSetById(Long id);
Boolean putOnOff(Long id);
}
package com.glsx.smart.service;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.glsx.smart.dao.entity.SmartProductType;
import com.glsx.smart.pojo.response.RemoteDeviceResp;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartProductTypeService {
PageInfo<SmartProductType> getPageList(SmartProductType productType);
List<SmartProductType> getList(SmartProductType productType);
List<SmartProductType> getByIdList(List<Long> list);
SmartProductType getById(Long id);
Boolean save(SmartProductType productType);
List<SmartProductType> getListAndContent(List<Long> list);
List<SmartProductType> getListAndCondition(List<Long> list);
String findRemotesById(String infrared_id);
List<RemoteDeviceResp> remoteDeviceHandler(JSONArray array, Byte status);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartScenceSupstatus;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
public interface SmartScenceSupstatusService {
List<SmartScenceSupstatus> getList(SmartScenceSupstatus record);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartSceneData;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartSceneDataService {
int deleteByPrimaryKey(Long id);
int insertOrUpdate(SmartSceneData record);
int insertSelective(SmartSceneData record);
List<SmartSceneData> getBySceneId(Long sceneId);
int deleteBySceneId(Long sceneId);
SmartSceneData selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(SmartSceneData record);
int updateBatchSelective(List<SmartSceneData> list);
int batchInsert(List<SmartSceneData> list);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartSceneLog;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-04-11
*/
public interface SmartSceneLogService {
SmartSceneLog selectByPrimaryKey(SmartSceneLog sceneLog);
int insertSelective(SmartSceneLog sceneLog);
int insertWrapper(Long userId, String description, String remark);
int deleteByPrimaryKey(SmartSceneLog sceneLog);
int updateByPrimaryKeySelective(SmartSceneLog sceneLog);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartScene;
import com.glsx.smart.pojo.OrderResponse;
import java.io.IOException;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartSceneService {
int deleteByPrimaryKey(Long id);
int insertOrUpdate(SmartScene record);
int insertSelective(SmartScene record);
int insert(SmartScene record);
int update(SmartScene record);
List<SmartScene> getList(SmartScene record);
SmartScene getById(Long id);
int updateByPrimaryKeySelective(SmartScene record);
List<OrderResponse> issueOrder(SmartScene scene);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartSceneTemplate;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartSceneTemplateService {
int deleteByPrimaryKey(Long id);
int insert(SmartSceneTemplate record);
int update(SmartSceneTemplate record);
List<SmartSceneTemplate> getList(SmartSceneTemplate record);
SmartSceneTemplate getById(Long id);
int updateByPrimaryKeySelective(SmartSceneTemplate record);
int getTotalCount(SmartSceneTemplate record);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartSysCode;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartSysCodeService {
List<SmartSysCode> getList(SmartSysCode req);
int deleteByPrimaryKey(Long id);
int insertOrUpdate(SmartSysCode record);
int insertSelective(SmartSysCode record);
SmartSysCode selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(SmartSysCode record);
int updateBatchSelective(List<SmartSysCode> list);
int batchInsert(List<SmartSysCode> list);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartSysFile;
import com.glsx.smart.pojo.FileDTO;
import java.util.List;
import java.util.Map;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartSysFileService {
Long insertOrUpdate(SmartSysFile record);
List<FileDTO> findByType(Byte type);
List<Map<String,Object>> saveFile(List<FileDTO> files);
FileDTO updateFile(FileDTO fileDTO);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartTemplateParam;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartTemplateParamService {
int deleteByPrimaryKey(Long id);
int insertOrUpdate(SmartTemplateParam record);
int insertSelective(SmartTemplateParam record);
List<SmartTemplateParam> getByTemplateId(Long templateId);
SmartTemplateParam selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(SmartTemplateParam record);
int updateBatchSelective(List<SmartTemplateParam> list);
int batchInsert(List<SmartTemplateParam> list);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartUserRelation;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
public interface SmartUserRelationService {
int deleteByPrimaryKey(Long id);
int insertOrUpdate(SmartUserRelation record);
Long insertSelective(SmartUserRelation record);
SmartUserRelation getSingle(SmartUserRelation record);
SmartUserRelation selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(SmartUserRelation record);
int updateBatchSelective(List<SmartUserRelation> list);
int batchInsert(List<SmartUserRelation> list);
}
package com.glsx.smart.service;
import com.glsx.smart.dao.entity.SmartVehicleBlueKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueKeyExample;
import java.util.List;
public interface SmartVehicleBlueKeyService {
long countByExample(SmartVehicleBlueKeyExample example);
int deleteByExample(SmartVehicleBlueKeyExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartVehicleBlueKey record);
int insertSelective(SmartVehicleBlueKey record);
List<SmartVehicleBlueKey> selectByExample(SmartVehicleBlueKeyExample example);
SmartVehicleBlueKey selectByPrimaryKey(Long id);
int updateByExampleSelective(SmartVehicleBlueKey record, SmartVehicleBlueKeyExample example);
int updateByExample(SmartVehicleBlueKey record, SmartVehicleBlueKeyExample example);
int updateByPrimaryKeySelective(SmartVehicleBlueKey record);
int updateByPrimaryKey(SmartVehicleBlueKey record);
}
package com.glsx.smart.service;
import com.glsx.platform.user.entity.UserAddressSmart;
import com.glsx.smart.dao.entity.SmartScene;
import com.glsx.smart.dao.entity.SmartSceneData;
import java.util.List;
public interface UserKafkaService {
void addDeviceData(SmartScene smartScene);
List<String> getSendDeviceList(List<SmartSceneData> list);
UserAddressSmart getPointUser(Long userId);
}
package com.glsx.smart.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.StringUtils;
import com.glsx.plat.common.utils.SnowFlake;
import com.glsx.smart.dao.entity.SmartKeyCommandLog;
import com.glsx.smart.dao.entity.SmartVehicleBlueKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueKeyExample;
import com.glsx.smart.pojo.request.*;
import com.glsx.smart.pojo.response.SmartCarKeyOpreateResponse;
import com.glsx.smart.pojo.response.SmartCarKeyResponse;
import com.glsx.smart.service.AiLockingKeyService;
import com.glsx.smart.service.SmartKeyCommandLogService;
import com.glsx.smart.service.SmartVehicleBlueKeyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* <p>Description:智能车钥匙service
* <p>Project: chejia-smart
*
* @author fengzhi
* @date 2021-04-19
*/
@Service
@Slf4j
public class AiLockingKeyServiceImpl implements AiLockingKeyService {
@Autowired
private SmartKeyCommandLogService smartKeyCommandLogService;
@Autowired
private SmartVehicleBlueKeyService smartVehicleBlueKeyService;
//sn查询/新增车钥匙
@Override
public SmartCarKeyResponse getLockingKey(SmartCarKeyRequest request) {
SmartCarKeyResponse response = new SmartCarKeyResponse();
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria().andUserIdEqualTo(request.getUserId()).andSnEqualTo(request.getSn()).andIsDeleteEqualTo(0);
List<SmartVehicleBlueKey> smartVehicleBlueKeys = smartVehicleBlueKeyService.selectByExample(example);
if(CollectionUtils.isEmpty(smartVehicleBlueKeys)){
//如果sn,userid没有数据,生成只含有crep钥匙信息返回
SmartVehicleBlueKey newKey = new SmartVehicleBlueKey();
//todo 雪花算法生成crep,对称加密
long id = SnowFlake.nextId();
long userId = request.getUserId();
newKey.setCrepCode("");
newKey.setCreateTime(new Date());
smartVehicleBlueKeyService.insert(newKey);
BeanUtils.copyProperties(newKey,response);
return response;
}else {
SmartVehicleBlueKey carkey = smartVehicleBlueKeys.get(0);
String crepCode = carkey.getCrepCode();
if(StringUtils.isNotEmpty(crepCode)){
//如果sn,userid有对应的crep,返回钥匙信息
BeanUtils.copyProperties(carkey,response);
return response;
}else {
//如果sn,userid没有对应的crep。生成只含有crep钥匙信息返回
carkey.setCrepCode(request.getSn());
carkey.setCreateTime(new Date());
smartVehicleBlueKeyService.updateByPrimaryKey(carkey);
BeanUtils.copyProperties(carkey,response);
return response;
}
}
}
//智能车钥匙解绑
@Override
public SmartCarKeyOpreateResponse removeLockingKey(SmartCarKeyRmRequest request) {
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setIsDelete(1);
int conut = smartVehicleBlueKeyService.updateByExample(smartVehicleBlueKey, getExample(request.getUserId(), request.getCrep()));
return getOpreateResponse(conut);
}
//车钥匙操作指令上报
@Override
public SmartCarKeyOpreateResponse LogLockingKeyCommand(SmartCarKeyCommandRequest carKeyCommandRequest) {
SmartKeyCommandLog log = new SmartKeyCommandLog();
log.setUserId(carKeyCommandRequest.getUserId());
log.setCrep(carKeyCommandRequest.getCrepCode());
log.setKeyCommand(carKeyCommandRequest.getKeyCommond());
log.setCreateTime(new Date());
int conut = smartKeyCommandLogService.insert(log);
return getOpreateResponse(conut);
}
//车钥匙修改昵称
@Override
public SmartCarKeyOpreateResponse setLockingKeyName(SmartCarKeyNameRequest request) {
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setKeyName(request.getName());
int conut = smartVehicleBlueKeyService.updateByExample(smartVehicleBlueKey, getExample(request.getUserId(), request.getCrep()));
return getOpreateResponse(conut);
}
//车钥匙修改自动感应
@Override
public SmartCarKeyOpreateResponse setLockingKeyAutoSense(SmartCarKeyAutoSenseRequest request) {
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setAutoSenseStatus(request.getAutoSenseStatus());
int conut = smartVehicleBlueKeyService.updateByExample(smartVehicleBlueKey, getExample(request.getUserId(), request.getCrep()));
return getOpreateResponse(conut);
}
//智能车钥匙注册成功后的数据保存
@Override
public SmartCarKeyOpreateResponse saveLockingKeyRegisterInfo(SmartCarKeyRegisterRequest request) {
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setMobileBlueMac(request.getMobileMac());
smartVehicleBlueKey.setSmartLockMac(request.getSmartLockMac());
smartVehicleBlueKey.setSecretKey(request.getKeyLock());
int conut = smartVehicleBlueKeyService.updateByExample(smartVehicleBlueKey, getExample(request.getUserId(), request.getCrepCode()));
return getOpreateResponse(conut);
}
//查询车钥匙example,根据用户ID和crep查
private SmartVehicleBlueKeyExample getExample(Long userId, String crep) {
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria().andUserIdEqualTo(userId).andCrepCodeEqualTo(crep).andIsDeleteEqualTo(0);
return example;
}
private SmartCarKeyOpreateResponse getOpreateResponse(int conut) {
SmartCarKeyOpreateResponse response = new SmartCarKeyOpreateResponse();
response.setSuccess(conut > 0);
return response;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!