add feature about firmware add select update delete
This commit is contained in:
parent
8b68509a99
commit
55751ac714
|
@ -9,3 +9,5 @@ xiuosiot-backend/src/main/resources/generatorConfig.xml
|
|||
xiuosiot-backend/src/main/resources/mybatisGenerate/
|
||||
*.log
|
||||
*.gz
|
||||
xiuosiot-backend/otafiles/
|
||||
.idea/
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-mqtt</artifactId>
|
||||
<version>5.5.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
|
@ -30,11 +31,14 @@ import java.util.Map;
|
|||
public class AroundLogAspect {
|
||||
@Autowired
|
||||
LogInfoService requestLogInfoService;
|
||||
public AroundLogAspect(){}
|
||||
|
||||
public AroundLogAspect() {
|
||||
}
|
||||
|
||||
@Pointcut("execution(* com.aiit.xiuos.controller..*.*(..))")
|
||||
public void normalPointcut() {
|
||||
}
|
||||
|
||||
@Pointcut("execution(* com.aiit.xiuos.controller.LoginController.*(..))")
|
||||
public void excludeLogPointcut() {
|
||||
}
|
||||
|
@ -59,7 +63,7 @@ public class AroundLogAspect {
|
|||
@Around("pointCutMethod()")
|
||||
public Object aroundLog(ProceedingJoinPoint point) throws ParseException {
|
||||
|
||||
RequestLogInfo requestLogInfo =new RequestLogInfo();
|
||||
RequestLogInfo requestLogInfo = new RequestLogInfo();
|
||||
StopWatch started = new StopWatch();
|
||||
//请求时间
|
||||
requestLogInfo.setRequesttime(MyUtils.getDateTime());
|
||||
|
@ -69,9 +73,9 @@ public class AroundLogAspect {
|
|||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
//所属公司
|
||||
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
|
||||
if(userInfo==null){
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
|
||||
UserInfo userInfo = (UserInfo) request.getSession().getAttribute("user");
|
||||
if (userInfo == null) {
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE, "用户尚未登录,请先登录!");
|
||||
}
|
||||
requestLogInfo.setOrg(userInfo.getOrg());
|
||||
//IP
|
||||
|
@ -85,22 +89,22 @@ public class AroundLogAspect {
|
|||
requestLogInfo.setRequesttype(type);
|
||||
//header 根据header名获取header值
|
||||
Map<String, String> headerMap = new HashMap<>();
|
||||
headerMap.put("accept-encoding",request.getHeader("accept-encoding"));
|
||||
headerMap.put("user-agent",request.getHeader("user-agent"));
|
||||
headerMap.put("connection",request.getHeader("connection"));
|
||||
headerMap.put("content-type",request.getHeader("content-type"));
|
||||
headerMap.put("accept-encoding", request.getHeader("accept-encoding"));
|
||||
headerMap.put("user-agent", request.getHeader("user-agent"));
|
||||
headerMap.put("connection", request.getHeader("connection"));
|
||||
headerMap.put("content-type", request.getHeader("content-type"));
|
||||
requestLogInfo.setRequestheader(headerMap.toString());
|
||||
//类名
|
||||
String className= point.getTarget().getClass().getName();
|
||||
String className = point.getTarget().getClass().getName();
|
||||
requestLogInfo.setClassname(className);
|
||||
//方法名
|
||||
String methodName = method.getName();
|
||||
requestLogInfo.setMethodname(methodName);
|
||||
//参数名
|
||||
Parameter[] parameters = method.getParameters();
|
||||
String param ="";
|
||||
for(int i=0;i<parameters.length;i++){
|
||||
param+=parameters[i]+",";
|
||||
String param = "";
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
param += parameters[i] + ",";
|
||||
}
|
||||
requestLogInfo.setRequestparam(param);
|
||||
//计时开始
|
||||
|
@ -111,10 +115,12 @@ public class AroundLogAspect {
|
|||
started.stop();
|
||||
//请求耗时
|
||||
requestLogInfo.setProcesstime(String.valueOf(started.getTotalTimeMillis()));
|
||||
log.info("method:"+methodName);
|
||||
log.info("processtime:"+started.getTotalTimeMillis());
|
||||
log.info("method:" + methodName);
|
||||
log.info("processtime:" + started.getTotalTimeMillis());
|
||||
//请求结果
|
||||
requestLogInfo.setRequestresult("resultCoe="+proceed.getCode()+" resultMsg="+proceed.getMessage());
|
||||
if (null != proceed) {
|
||||
requestLogInfo.setRequestresult("resultCoe=" + proceed.getCode() + " resultMsg=" + proceed.getMessage());
|
||||
}
|
||||
requestLogInfoService.addLog(requestLogInfo);
|
||||
return proceed;
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.aiit.xiuos.Utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
||||
public class SpringUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
SpringUtil.applicationContext = applicationContext;
|
||||
}
|
||||
public static <T> T getBeanByName(String beanName) {
|
||||
if(applicationContext.containsBean(beanName)){
|
||||
return (T) applicationContext.getBean(beanName);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static <T> T getBeanByClass(Class<T> className) {
|
||||
T result = (T) applicationContext.getBean(className);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,14 +20,11 @@ public class DeviceController {
|
|||
|
||||
@PostMapping("/add")
|
||||
public ResultRespons addDevice(@RequestBody DeviceInfo deviceInfo, HttpServletRequest request){
|
||||
List<DeviceInfo> devs =deviceInfoService.selectbyNo(deviceInfo.getNo());
|
||||
if(devs==null||devs.size()>0){
|
||||
DeviceInfo devs =deviceInfoService.selectbyNo(deviceInfo.getNo());
|
||||
if(devs!=null){
|
||||
return new ResultRespons(Constant.ERROR_CODE,"设备已存在!");
|
||||
}
|
||||
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
|
||||
if(userInfo==null){
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
|
||||
}
|
||||
String id =GenerateIdUtil.getId(userInfo.getUsername(),userInfo.getOrg());
|
||||
deviceInfo.setId(id);
|
||||
deviceInfo.setUpdatetime(MyUtils.getTime());
|
||||
|
@ -49,9 +46,6 @@ public class DeviceController {
|
|||
@GetMapping("/select")
|
||||
public ResultRespons selectDevice(@RequestParam("activestatus") int activestatus, HttpServletRequest request){
|
||||
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
|
||||
if(userInfo==null){
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
|
||||
}
|
||||
List<DeviceInfo> deviceInfoList =null;
|
||||
if(1==activestatus){
|
||||
deviceInfoList=deviceInfoService.selectActiveDevice(userInfo.getOrg());
|
||||
|
@ -83,9 +77,6 @@ public class DeviceController {
|
|||
@GetMapping("/getTypeCount")
|
||||
public ResultRespons getTypeCount(HttpServletRequest request){
|
||||
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
|
||||
if(userInfo==null){
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
|
||||
}
|
||||
List<Map<String,String>> list=deviceInfoService.getDeviceTypeCount(userInfo.getOrg());
|
||||
if(list!=null){
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"查询设备成功!",list);
|
||||
|
@ -96,13 +87,23 @@ public class DeviceController {
|
|||
@GetMapping("/getRunStatusCount")
|
||||
public ResultRespons getRunStatusCount(HttpServletRequest request){
|
||||
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
|
||||
if(userInfo==null){
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
|
||||
}
|
||||
List<Map<String,String>> list=deviceInfoService.getDeviceRunStautsCount(userInfo.getOrg());
|
||||
if(list!=null){
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"查询设备成功!",list);
|
||||
}
|
||||
return new ResultRespons(Constant.ERROR_CODE,"查询设备失败!");
|
||||
}
|
||||
|
||||
@GetMapping("/updateDeviceStatus")
|
||||
public ResultRespons updateDeviceStatus(HttpServletRequest request){
|
||||
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
|
||||
if(userInfo==null){
|
||||
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
|
||||
}
|
||||
List<DeviceInfo> list=deviceInfoService.selectActiveDevice(userInfo.getOrg());
|
||||
if(list!=null){
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"查询设备成功!",list);
|
||||
}
|
||||
return new ResultRespons(Constant.ERROR_CODE,"查询设备失败!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,10 +52,7 @@ public class DeviceDataController {
|
|||
|
||||
}
|
||||
@PostMapping("/publishData")
|
||||
public ResultRespons publishData(@RequestBody Map<String, Object> jsonMap){
|
||||
if(myMqttClient==null){
|
||||
myMqttClient=new MqttConfiguration().getMqttPushClient();
|
||||
}
|
||||
public ResultRespons publishData(@RequestBody Map<String, Object> jsonMap) {
|
||||
myMqttClient.publish("xiuosiot/"+jsonMap.get("deviceno"), JSONObject.toJSONString(jsonMap));
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"数据发送成功");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
package com.aiit.xiuos.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.aiit.xiuos.Utils.Constant;
|
||||
import com.aiit.xiuos.Utils.ResultRespons;
|
||||
import com.aiit.xiuos.model.FirmwareInfo;
|
||||
import com.aiit.xiuos.model.UserInfo;
|
||||
import com.aiit.xiuos.service.FirmwareInfoService;
|
||||
import com.aiit.xiuos.service.OtaInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.hutool.core.io.FileUtil.exist;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/firmware")
|
||||
@Slf4j
|
||||
public class FirmwareController {
|
||||
@Autowired
|
||||
FirmwareInfoService firmwareInfoService;
|
||||
|
||||
@Autowired
|
||||
OtaInfoService otaInfoService;
|
||||
|
||||
/*
|
||||
上传固件接口
|
||||
*/
|
||||
//MultipartFile用于接受前端传过来的file对象
|
||||
@PostMapping("/upload")
|
||||
public ResultRespons upload(MultipartFile file,String version) throws IOException {
|
||||
Long fileSize = file.getSize();
|
||||
String md5 = SecureUtil.md5(file.getInputStream());
|
||||
String filename = file.getOriginalFilename();//获取文件的名称
|
||||
String rootFilePath = System.getProperty("user.dir") + "/otafiles/" + version+"_"+filename;
|
||||
boolean fileExist=FileUtil.exist(rootFilePath);
|
||||
if(fileExist){
|
||||
return new ResultRespons(Constant.ERROR_CODE, "上传失败,已存在相同文件名,相同版本号的固件");
|
||||
}
|
||||
FileUtil.writeBytes(file.getBytes(), rootFilePath);//使用Hutool工具包将我们接收到文件保存到rootFilePath中
|
||||
FirmwareInfo firmwareInfo = new FirmwareInfo();
|
||||
firmwareInfo.setFileName(filename);
|
||||
firmwareInfo.setFileMd5(md5);
|
||||
firmwareInfo.setFileSize(fileSize);
|
||||
firmwareInfo.setFileVersion(version);
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "上传成功", firmwareInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public ResultRespons addFirmwareInfo(@RequestBody FirmwareInfo firmwareInfo, HttpServletRequest request) throws IOException {
|
||||
UserInfo userInfo = (UserInfo) request.getSession().getAttribute("user");
|
||||
firmwareInfo.setOrg(userInfo.getOrg());
|
||||
int res = firmwareInfoService.addFirmware(firmwareInfo);
|
||||
if (1 == res) {
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "新增固件成功");
|
||||
} else {
|
||||
return new ResultRespons(Constant.ERROR_CODE, "新增固件失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
下载固件接口
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
public void getFiles(@RequestParam("fileName") String name, @RequestParam("fileVersion") String version,HttpServletResponse response) {
|
||||
String realName =version+"_"+name;
|
||||
OutputStream os;//新建一个输出流对象
|
||||
String basePath = System.getProperty("user.dir") + "/otafiles/"; //定义文件上传的根路径
|
||||
List<String> fileNames = FileUtil.listFileNames(basePath);//获取所有的文件名称
|
||||
String fileName = fileNames.stream().filter(filename -> filename.contains(realName)).findAny().orElse("");//找到跟参数一致的文件
|
||||
try {
|
||||
if (StrUtil.isNotEmpty(fileName)) {
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
response.setContentType("application/octet-stream");
|
||||
byte[] bytes = FileUtil.readBytes(basePath + fileName);//通过文件的路径读取文件字节流
|
||||
os = response.getOutputStream();//通过response的输出流返回文件
|
||||
os.write(bytes);
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/delete")
|
||||
public ResultRespons deleteFile(@RequestBody FirmwareInfo firmwareInfo) {
|
||||
int id = firmwareInfo.getId();
|
||||
String fileName = firmwareInfo.getFileName();
|
||||
String version = firmwareInfo.getFileVersion();
|
||||
String filePath = System.getProperty("user.dir") + "/otafiles/" + version+"_"+fileName;
|
||||
Boolean flag = FileUtil.del(filePath);
|
||||
|
||||
if (flag) {
|
||||
int res = firmwareInfoService.deleteFirmware(id);
|
||||
|
||||
if (1 == res) {
|
||||
otaInfoService.deleteOtaInfo(fileName,version);
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "删除成功");
|
||||
} else {
|
||||
return new ResultRespons(Constant.ERROR_CODE, "删除失败");
|
||||
}
|
||||
|
||||
} else {
|
||||
return new ResultRespons(Constant.ERROR_CODE, "固件不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/verify")
|
||||
public ResultRespons verifyFile(@RequestBody FirmwareInfo firmwareInfo) throws IOException {
|
||||
int id = firmwareInfo.getId();
|
||||
FirmwareInfo info = firmwareInfoService.getById(id);
|
||||
String fileName = info.getFileName();
|
||||
String fileVersion = info.getFileVersion();
|
||||
String filePath = System.getProperty("user.dir") + "/otafiles/" + fileVersion+"_"+fileName;
|
||||
String md5 = SecureUtil.md5(FileUtil.getInputStream(filePath));
|
||||
|
||||
if (info.getFileMd5().equals(md5)) {
|
||||
info.setVerify("验证成功");
|
||||
firmwareInfoService.updateFirmware(info);
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "验证成功");
|
||||
} else {
|
||||
info.setVerify("验证失败");
|
||||
firmwareInfoService.updateFirmware(info);
|
||||
return new ResultRespons(Constant.ERROR_CODE, "验证失败");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getAll")
|
||||
public ResultRespons getAllFirmware(HttpServletRequest request) {
|
||||
UserInfo userInfo = (UserInfo) request.getSession().getAttribute("user");
|
||||
List<FirmwareInfo> firmwareInfoList = firmwareInfoService.getAll(userInfo.getOrg());
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "查询成功", firmwareInfoList);
|
||||
}
|
||||
|
||||
@GetMapping("/getVerify")
|
||||
public ResultRespons getAllFirmware(@RequestParam("verify") String verify,HttpServletRequest request) {
|
||||
UserInfo userInfo = (UserInfo) request.getSession().getAttribute("user");
|
||||
List<FirmwareInfo> firmwareInfoList = firmwareInfoService.getByVerify(userInfo.getOrg(),verify);
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "查询成功", firmwareInfoList);
|
||||
}
|
||||
|
||||
@GetMapping("/getByName")
|
||||
public ResultRespons getFirmware(@RequestParam("fileName") String name,HttpServletRequest request) {
|
||||
List<FirmwareInfo> infos = firmwareInfoService.getInfo(name);
|
||||
return new ResultRespons(Constant.SUCCESS_CODE, "查询成功", infos);
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ public class LoginController {
|
|||
HttpSession session = request.getSession();
|
||||
session.removeAttribute("user");
|
||||
session.invalidate();
|
||||
redisUtil.delete("user");
|
||||
//redisUtil.delete("user");
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"用户登出");
|
||||
}
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ import java.util.Map;
|
|||
|
||||
@Repository
|
||||
public interface DeviceInfoMapper {
|
||||
int deleteByPrimaryKey(@Param("id") String id, @Param("no") String no);
|
||||
int deleteByPrimaryKey(String no);
|
||||
|
||||
int insert(DeviceInfo record);
|
||||
|
||||
int insertSelective(DeviceInfo record);
|
||||
|
||||
DeviceInfo selectByPrimaryKey(@Param("id") String id, @Param("no") String no);
|
||||
DeviceInfo selectByPrimaryKey(String no);
|
||||
|
||||
int updateByPrimaryKeySelective(DeviceInfo record);
|
||||
|
||||
|
@ -36,9 +36,6 @@ public interface DeviceInfoMapper {
|
|||
@Delete("delete from device_info where no =#{no}")
|
||||
int deleteByNo(@Param("no") String no);
|
||||
|
||||
@Select("select * from device_info where no=#{no}")
|
||||
List<DeviceInfo> selectByNo(@Param("no") String no);
|
||||
|
||||
@Select("select type from device_info where no =#{deviceNo}")
|
||||
List<String> selectTypeByNo(@Param("deviceNo") String deviceNo);
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.aiit.xiuos.dao.mappers;
|
||||
|
||||
import com.aiit.xiuos.model.FirmwareInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface FirmwareInfoMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(FirmwareInfo record);
|
||||
|
||||
int insertSelective(FirmwareInfo record);
|
||||
|
||||
FirmwareInfo selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(FirmwareInfo record);
|
||||
|
||||
int updateByPrimaryKey(FirmwareInfo record);
|
||||
|
||||
@Select("select * from firmware_info where org=#{org}")
|
||||
List<FirmwareInfo> getAll(@Param("org") String org);
|
||||
|
||||
@Select("select * from firmware_info where org=#{org} and verify=#{verify}")
|
||||
List<FirmwareInfo> getByVerify(@Param("org") String org,@Param("verify") String verify);
|
||||
|
||||
@Select("select * from firmware_info where file_name=#{name}")
|
||||
List<FirmwareInfo> getByName(@Param("name") String name);
|
||||
|
||||
@Select("select * from firmware_info where file_name=#{name} and file_version=#{version}")
|
||||
FirmwareInfo getByNameAndVersion(@Param("name") String name,@Param("version") String version);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.aiit.xiuos.dao.mappers;
|
||||
|
||||
import com.aiit.xiuos.model.OtaInfo;
|
||||
|
||||
public interface OtaInfoMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(OtaInfo record);
|
||||
|
||||
int insertSelective(OtaInfo record);
|
||||
|
||||
OtaInfo selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(OtaInfo record);
|
||||
|
||||
int updateByPrimaryKey(OtaInfo record);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.aiit.xiuos.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class FirmwareInfo {
|
||||
private Integer id;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String fileVersion;
|
||||
@JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
private String fileMd5;
|
||||
|
||||
private String fileDesc;
|
||||
|
||||
private String org;
|
||||
|
||||
private String verify;
|
||||
|
||||
private Long fileSize;
|
||||
|
||||
public FirmwareInfo(Integer id, String fileName, String fileVersion, Date createTime, String fileMd5, String fileDesc, String org, String verify, Long fileSize) {
|
||||
this.id = id;
|
||||
this.fileName = fileName;
|
||||
this.fileVersion = fileVersion;
|
||||
this.createTime = createTime;
|
||||
this.fileMd5 = fileMd5;
|
||||
this.fileDesc = fileDesc;
|
||||
this.org = org;
|
||||
this.verify = verify;
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
public FirmwareInfo() {
|
||||
super();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.aiit.xiuos.model;
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class OtaInfo {
|
||||
private Integer id;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private Integer currentProcess;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Integer updateType;
|
||||
|
||||
private Date timeout;
|
||||
|
||||
private String fileVersion;
|
||||
|
||||
public OtaInfo(Integer id, String fileName, String deviceId, Integer currentProcess, Integer status, Date createTime, Integer updateType, Date timeout, String fileVersion) {
|
||||
this.id = id;
|
||||
this.fileName = fileName;
|
||||
this.deviceId = deviceId;
|
||||
this.currentProcess = currentProcess;
|
||||
this.status = status;
|
||||
this.createTime = createTime;
|
||||
this.updateType = updateType;
|
||||
this.timeout = timeout;
|
||||
this.fileVersion = fileVersion;
|
||||
}
|
||||
|
||||
public OtaInfo() {
|
||||
super();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.aiit.xiuos.mqtt;
|
||||
|
||||
public class MsgReceiveHandle {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.aiit.xiuos.scheduled;
|
||||
|
||||
public class OTATaskScheduled {
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.aiit.xiuos.service;
|
||||
|
||||
import com.aiit.xiuos.model.FirmwareInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FirmwareInfoService {
|
||||
List<FirmwareInfo> getAll(String org);
|
||||
int updateFirmware(FirmwareInfo firmwareInfo);
|
||||
int deleteFirmware(int id);
|
||||
int addFirmware(FirmwareInfo firmwareInfo);
|
||||
FirmwareInfo getById(int id);
|
||||
FirmwareInfo getByNameAndVersion(String name,String version);
|
||||
List<FirmwareInfo> getInfo(String name);
|
||||
List<FirmwareInfo> getByVerify(String org,String verify);
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.aiit.xiuos.service;
|
||||
|
||||
public interface OtaInfoService {
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.aiit.xiuos.service.impl;
|
||||
|
||||
import com.aiit.xiuos.dao.mappers.FirmwareInfoMapper;
|
||||
import com.aiit.xiuos.model.FirmwareInfo;
|
||||
import com.aiit.xiuos.service.FirmwareInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@Service
|
||||
public class FirmwareInfoServiceImpl implements FirmwareInfoService {
|
||||
@Autowired
|
||||
FirmwareInfoMapper firmwareInfoMapper;
|
||||
@Override
|
||||
public List<FirmwareInfo> getAll(String org) {
|
||||
return firmwareInfoMapper.getAll(org);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateFirmware(FirmwareInfo firmwareInfo) {
|
||||
return firmwareInfoMapper.updateByPrimaryKeySelective(firmwareInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteFirmware(int id) {
|
||||
return firmwareInfoMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addFirmware(FirmwareInfo firmwareInfo) {
|
||||
return firmwareInfoMapper.insertSelective(firmwareInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirmwareInfo getById(int id) {
|
||||
return firmwareInfoMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirmwareInfo getByNameAndVersion(String name, String version) {
|
||||
return firmwareInfoMapper.getByNameAndVersion(name,version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FirmwareInfo> getInfo(String name) {
|
||||
return firmwareInfoMapper.getByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FirmwareInfo> getByVerify(String org, String verify) {
|
||||
return firmwareInfoMapper.getByVerify(org,verify);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.aiit.xiuos.service.impl;
|
||||
|
||||
public class OtaInfoServiceImpl {
|
||||
}
|
|
@ -62,19 +62,23 @@ mybatis:
|
|||
#MQTT Config
|
||||
mqtt:
|
||||
#MQTT-服务器连接地
|
||||
hostUrl: tcp://115.238.53.59:1883
|
||||
hostUrl: tcp://8.140.53.225:1883
|
||||
#MQTT-连接服务器默认客户端ID
|
||||
clientId: local-xiuosiot
|
||||
#MQTT-用户名
|
||||
username: xiuosiot
|
||||
username: xiuos
|
||||
#MQTT-密码
|
||||
password: xiuosiot
|
||||
password: xiuos
|
||||
#连接超时
|
||||
timeout: 100
|
||||
#设置会话心跳时间
|
||||
keepalive: 100
|
||||
#默认主题
|
||||
default-topic: xiuosiot/#
|
||||
#api key
|
||||
apikey: 6eea245a7f531f2f
|
||||
#secret key
|
||||
secretkey: XsyKpCXGvPfWifwOjsK2J2JP3E9AouxezXm8SqaJXcYP
|
||||
|
||||
tdengine:
|
||||
url: jdbc:TAOS://taosnode1:6030/xiuosiot?user=root&password=taosdata
|
||||
|
|
|
@ -43,6 +43,7 @@ spring:
|
|||
max-idle: 10
|
||||
min-idle: 2
|
||||
timeout: 6000
|
||||
|
||||
config:
|
||||
activate:
|
||||
on-profile: prod
|
||||
|
@ -56,7 +57,7 @@ mybatis:
|
|||
#MQTT Config
|
||||
mqtt:
|
||||
#MQTT-服务器连接地
|
||||
hostUrl: tcp://115.238.53.59:1883
|
||||
hostUrl: tcp://localhost:1883
|
||||
#MQTT-连接服务器默认客户端ID
|
||||
clientId: xiuosiot-client
|
||||
#MQTT-用户名
|
||||
|
@ -69,6 +70,10 @@ mqtt:
|
|||
keepalive: 100
|
||||
#默认主题
|
||||
default-topic: xiuosiot/#
|
||||
#api key
|
||||
apikey: 13e1c0be6d573f86
|
||||
#secret key
|
||||
secretkey: 9BLxyWslygS5oFTz8TX5ssJ7JMiBY9CefU9B35uWx3ltqN
|
||||
tdengine:
|
||||
url: jdbc:TAOS://xiuosiot.taosnode1:6030/xiuosiot?user=root&password=taosdata
|
||||
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.aiit.xiuos.dao.mappers.FirmwareInfoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.FirmwareInfo">
|
||||
<constructor>
|
||||
<idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
<arg column="file_name" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="file_version" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
|
||||
<arg column="file_md5" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="file_desc" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="org" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="verify" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="file_size" javaType="java.lang.Long" jdbcType="BIGINT" />
|
||||
</constructor>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, file_name, file_version, create_time, file_md5, file_desc, org, verify, file_size
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from firmware_info
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from firmware_info
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.aiit.xiuos.model.FirmwareInfo">
|
||||
insert into firmware_info (id, file_name, file_version,
|
||||
create_time, file_md5, file_desc,
|
||||
org, verify, file_size
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER}, #{fileName,jdbcType=VARCHAR}, #{fileVersion,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=TIMESTAMP}, #{fileMd5,jdbcType=VARCHAR}, #{fileDesc,jdbcType=VARCHAR},
|
||||
#{org,jdbcType=VARCHAR}, #{verify,jdbcType=VARCHAR}, #{fileSize,jdbcType=BIGINT}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.FirmwareInfo">
|
||||
insert into firmware_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="fileName != null">
|
||||
file_name,
|
||||
</if>
|
||||
<if test="fileVersion != null">
|
||||
file_version,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="fileMd5 != null">
|
||||
file_md5,
|
||||
</if>
|
||||
<if test="fileDesc != null">
|
||||
file_desc,
|
||||
</if>
|
||||
<if test="org != null">
|
||||
org,
|
||||
</if>
|
||||
<if test="verify != null">
|
||||
verify,
|
||||
</if>
|
||||
<if test="fileSize != null">
|
||||
file_size,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="fileName != null">
|
||||
#{fileName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileVersion != null">
|
||||
#{fileVersion,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="fileMd5 != null">
|
||||
#{fileMd5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileDesc != null">
|
||||
#{fileDesc,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="org != null">
|
||||
#{org,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="verify != null">
|
||||
#{verify,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileSize != null">
|
||||
#{fileSize,jdbcType=BIGINT},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.FirmwareInfo">
|
||||
update firmware_info
|
||||
<set>
|
||||
<if test="fileName != null">
|
||||
file_name = #{fileName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileVersion != null">
|
||||
file_version = #{fileVersion,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="fileMd5 != null">
|
||||
file_md5 = #{fileMd5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileDesc != null">
|
||||
file_desc = #{fileDesc,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="org != null">
|
||||
org = #{org,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="verify != null">
|
||||
verify = #{verify,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="fileSize != null">
|
||||
file_size = #{fileSize,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.FirmwareInfo">
|
||||
update firmware_info
|
||||
set file_name = #{fileName,jdbcType=VARCHAR},
|
||||
file_version = #{fileVersion,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
file_md5 = #{fileMd5,jdbcType=VARCHAR},
|
||||
file_desc = #{fileDesc,jdbcType=VARCHAR},
|
||||
org = #{org,jdbcType=VARCHAR},
|
||||
verify = #{verify,jdbcType=VARCHAR},
|
||||
file_size = #{fileSize,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
Loading…
Reference in New Issue