add fan zai device management

This commit is contained in:
wty 2023-02-27 11:20:05 +08:00
parent a6a2e4398f
commit 15ad247568
9 changed files with 181 additions and 8 deletions

View File

@ -75,7 +75,7 @@ public class DataForwardController {
public ResultRespons executeSql(@RequestParam String sql){
ArrayList resultData = null;
try {
resultData = TDengineJDBCUtil.executeSql(sql);
resultData = TDengineJDBCUtil.executeQuerySql(sql);
} catch (Exception e) {
log.error(e.getMessage());
}

View File

@ -0,0 +1,64 @@
package com.aiit.xiuos.controller;
import com.aiit.xiuos.Utils.Constant;
import com.aiit.xiuos.Utils.GenerateIdUtil;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.model.DeviceInfo;
import com.aiit.xiuos.model.FzDeviceInfo;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.FzDeviceInfoService;
import com.aiit.xiuos.tdengine.TDengineJDBCUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/fzDevice")
@Slf4j
public class FzDeviceManageController {
@Autowired
FzDeviceInfoService fzDeviceInfoService;
@PostMapping("/add")
public ResultRespons addDevice(@RequestBody FzDeviceInfo fzDeviceInfo, HttpServletRequest request){
int res = fzDeviceInfoService.addDevice(fzDeviceInfo);
if(1==res){
return new ResultRespons(Constant.SUCCESS_CODE,"新建设备信息成功!");
}
return new ResultRespons(Constant.ERROR_CODE,"新建设备信息失败!");
}
@PostMapping("/update")
public ResultRespons updateDevice(@RequestBody FzDeviceInfo fzDeviceInfo, HttpServletRequest request){
int res =fzDeviceInfoService.updateDevice(fzDeviceInfo);
if(1==res){
return new ResultRespons(Constant.SUCCESS_CODE,"更新设备信息成功!");
}
return new ResultRespons(Constant.ERROR_CODE,"更新设备信息失败!");
}
@PostMapping("/delete")
public ResultRespons deleteDevice(@RequestBody FzDeviceInfo fzDeviceInfo, HttpServletRequest request){
int res = fzDeviceInfoService.deleteDevice(fzDeviceInfo.getFzDeviceNo());
if(1==res){
return new ResultRespons(Constant.SUCCESS_CODE,"删除设备信息成功!");
}
return new ResultRespons(Constant.ERROR_CODE,"删除设备信息失败!");
}
@GetMapping("/select")
public ResultRespons selectDevice(@RequestParam("type") String type, HttpServletRequest request){
List<FzDeviceInfo> fzDeviceInfos = fzDeviceInfoService.selectByType(type);
return new ResultRespons(Constant.SUCCESS_CODE,"查询设备成功!",fzDeviceInfos);
}
@GetMapping("/selectAll")
public ResultRespons selectDevice(){
List<FzDeviceInfo> fzDeviceInfos = fzDeviceInfoService.selectAll();
return new ResultRespons(Constant.SUCCESS_CODE,"查询设备成功!",fzDeviceInfos);
}
}

View File

@ -0,0 +1,29 @@
package com.aiit.xiuos.dao.mappers;
import com.aiit.xiuos.model.FzDeviceInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface FzDeviceInfoMapper {
int deleteByPrimaryKey(String fzDeviceNo);
int insert(FzDeviceInfo record);
int insertSelective(FzDeviceInfo record);
FzDeviceInfo selectByPrimaryKey(String fzDeviceNo);
int updateByPrimaryKeySelective(FzDeviceInfo record);
int updateByPrimaryKey(FzDeviceInfo record);
@Select("select * from fz_device_info")
List<FzDeviceInfo> selectAll();
@Select("select * from fz_device_info where fz_device_type =#{type}")
List<FzDeviceInfo> selectByType(@Param("type") String type);
}

View File

@ -0,0 +1,33 @@
package com.aiit.xiuos.model;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class FzDeviceInfo {
private String fzDeviceNo;
private String fzDeviceStatus;
private String fzDeviceType;
private String fzDeviceUser;
private String fzOuttime;
private String fzRemark;
public FzDeviceInfo(String fzDeviceNo, String fzDeviceStatus, String fzDeviceType, String fzDeviceUser, String fzOuttime, String fzRemark) {
this.fzDeviceNo = fzDeviceNo;
this.fzDeviceStatus = fzDeviceStatus;
this.fzDeviceType = fzDeviceType;
this.fzDeviceUser = fzDeviceUser;
this.fzOuttime = fzOuttime;
this.fzRemark = fzRemark;
}
public FzDeviceInfo() {
super();
}
}

View File

@ -53,7 +53,6 @@ public class MqttConfiguration {
// /#结尾表示订阅所有以test开头的主题
myMqttClient.subscribe(defaultTopic, 0);
log.info("订阅成功"+defaultTopic);
System.out.println("订阅成功"+defaultTopic);
return myMqttClient;
}
}

View File

@ -0,0 +1,14 @@
package com.aiit.xiuos.service;
import com.aiit.xiuos.model.FzDeviceInfo;
import java.util.List;
public interface FzDeviceInfoService {
List<FzDeviceInfo> selectAll();
List<FzDeviceInfo> selectByType(String type);
int addDevice(FzDeviceInfo fzDeviceInfo);
int updateDevice(FzDeviceInfo fzDeviceInfo);
int deleteDevice(String deviceNo);
}

View File

@ -0,0 +1,38 @@
package com.aiit.xiuos.service.impl;
import com.aiit.xiuos.dao.mappers.FzDeviceInfoMapper;
import com.aiit.xiuos.model.FzDeviceInfo;
import com.aiit.xiuos.service.FzDeviceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class FzDeviceInfoServiceImpl implements FzDeviceInfoService {
@Autowired
FzDeviceInfoMapper fzDeviceInfoMapper;
@Override
public List<FzDeviceInfo> selectAll() {
return fzDeviceInfoMapper.selectAll();
}
@Override
public List<FzDeviceInfo> selectByType(String type) {
return fzDeviceInfoMapper.selectByType(type);
}
@Override
public int addDevice(FzDeviceInfo fzDeviceInfo) {
return fzDeviceInfoMapper.insert(fzDeviceInfo);
}
@Override
public int updateDevice(FzDeviceInfo fzDeviceInfo) {
return fzDeviceInfoMapper.updateByPrimaryKeySelective(fzDeviceInfo);
}
@Override
public int deleteDevice(String deviceNo) {
return fzDeviceInfoMapper.deleteByPrimaryKey(deviceNo);
}
}

View File

@ -71,7 +71,7 @@ public class TDengineJDBCUtil {
return null;
}
public static ArrayList<String> executeSql(String sql) throws Exception {
public static ArrayList<String> executeQuerySql(String sql) throws Exception {
Connection connection = null;
ArrayList<String> arrayList =new ArrayList<>();
try {
@ -89,12 +89,10 @@ public class TDengineJDBCUtil {
sb.append(columnLabel+":"+value+" ");
}
arrayList.add(sb.toString());
System.out.println(sb.toString());
log.info(sb.toString());
}
return arrayList;
} catch (SQLException e) {
System.out.println("ERROR Message: " + e.getMessage());
System.out.println("ERROR Code: " + e.getErrorCode());
log.error(e.getMessage());
}finally {
try {
@ -152,8 +150,6 @@ public class TDengineJDBCUtil {
log.info("tdengine executeQuery:"+sql);
stmt.executeUpdate(sql);
} catch (SQLException e) {
System.out.println("ERROR Message: " + e.getMessage());
System.out.println("ERROR Code: " + e.getErrorCode());
log.error(e.getMessage());
} catch (Exception e) {
log.error(e.getMessage());

View File