Merge branch 'master' of https://gitlink.org.cn/xuos/xiuos_IoT
This commit is contained in:
commit
37104a19c2
|
@ -4,3 +4,4 @@ xiuosiot-backend/.mvn/
|
||||||
xiuosiot-backend/src/resources/mybatisGenerate/
|
xiuosiot-backend/src/resources/mybatisGenerate/
|
||||||
xiuosiot-frontend/dist/
|
xiuosiot-frontend/dist/
|
||||||
xiuosiot-frontend/node_modules/
|
xiuosiot-frontend/node_modules/
|
||||||
|
xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/ProtocolProductInfoMapper.java
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
class MyMvcConfigurer implements WebMvcConfigurer {
|
class MyMvcConfigurer implements WebMvcConfigurer {
|
||||||
|
@ -22,8 +22,8 @@ class MyMvcConfigurer implements WebMvcConfigurer {
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(sessionInterceptor)
|
registry.addInterceptor(sessionInterceptor)
|
||||||
// .addPathPatterns() 是配置需要拦截的路径
|
// .addPathPatterns() 是配置需要拦截的路径
|
||||||
.addPathPatterns("/**")
|
//.addPathPatterns("/**") //默认拦截所有路径
|
||||||
// .excludePathPatterns() 用于排除拦截
|
.excludePathPatterns("/**") //用于排除拦截
|
||||||
.excludePathPatterns("/login") // 排除登录接口
|
.excludePathPatterns("/login") // 排除登录接口
|
||||||
.excludePathPatterns("/loginOut") //排除登出接口
|
.excludePathPatterns("/loginOut") //排除登出接口
|
||||||
.excludePathPatterns("/**/register") //排除注册接口
|
.excludePathPatterns("/**/register") //排除注册接口
|
|
@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,96 +59,14 @@ public class MyUtils {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Date getDateTime() throws ParseException {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date date = sdf.parse(MyUtils.getTime());
|
||||||
/**
|
return date;
|
||||||
* 导出
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* csv文件(路径+文件名),csv文件不存在会自动创建
|
|
||||||
* @param dataList
|
|
||||||
* 数据
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean exportCsv(File file, List<String> dataList) {
|
|
||||||
boolean isSucess = false;
|
|
||||||
|
|
||||||
FileOutputStream out = null;
|
|
||||||
OutputStreamWriter osw = null;
|
|
||||||
BufferedWriter bw = null;
|
|
||||||
try {
|
|
||||||
out = new FileOutputStream(file);
|
|
||||||
osw = new OutputStreamWriter(out);
|
|
||||||
bw = new BufferedWriter(osw);
|
|
||||||
if (dataList != null && !dataList.isEmpty()) {
|
|
||||||
for (String data : dataList) {
|
|
||||||
bw.append(data).append("\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isSucess = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
isSucess = false;
|
|
||||||
} finally {
|
|
||||||
if (bw != null) {
|
|
||||||
try {
|
|
||||||
bw.close();
|
|
||||||
bw = null;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (osw != null) {
|
|
||||||
try {
|
|
||||||
osw.close();
|
|
||||||
osw = null;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (out != null) {
|
|
||||||
try {
|
|
||||||
out.close();
|
|
||||||
out = null;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isSucess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* csv文件(路径+文件)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<String> importCsv(File file) {
|
|
||||||
List<String> dataList = new ArrayList<String>();
|
|
||||||
|
|
||||||
BufferedReader br = null;
|
|
||||||
try {
|
|
||||||
br = new BufferedReader(new FileReader(file));
|
|
||||||
String line = "";
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
dataList.add(line);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
} finally {
|
|
||||||
if (br != null) {
|
|
||||||
try {
|
|
||||||
br.close();
|
|
||||||
br = null;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JSONObject StringToJson(String jsonString){
|
public static JSONObject StringToJson(String jsonString){
|
||||||
JSONObject jsonObject =JSONObject.parseObject(jsonString);
|
JSONObject jsonObject =JSONObject.parseObject(jsonString);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class DeviceController {
|
||||||
return new ResultRespons(Constant.ERROR_CODE,"新增设备失败!");
|
return new ResultRespons(Constant.ERROR_CODE,"新增设备失败!");
|
||||||
}
|
}
|
||||||
@GetMapping("/select")
|
@GetMapping("/select")
|
||||||
public ResultRespons selectDevice(@RequestParam int activestatus, HttpServletRequest request){
|
public ResultRespons selectDevice(@RequestParam("activestatus") int activestatus, HttpServletRequest request){
|
||||||
List<DeviceInfo> deviceInfoList =null;
|
List<DeviceInfo> deviceInfoList =null;
|
||||||
if(1==activestatus){
|
if(1==activestatus){
|
||||||
deviceInfoList=deviceInfoService.selectActiveDevice();
|
deviceInfoList=deviceInfoService.selectActiveDevice();
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.aiit.xiuos.controller;
|
||||||
|
|
||||||
|
import com.aiit.xiuos.Utils.*;
|
||||||
|
import com.aiit.xiuos.model.DeviceInfo;
|
||||||
|
import com.aiit.xiuos.model.ProtocolProductInfo;
|
||||||
|
import com.aiit.xiuos.model.UserInfo;
|
||||||
|
import com.aiit.xiuos.model.VO.ProtocolProductVo;
|
||||||
|
import com.aiit.xiuos.service.DeviceInfoService;
|
||||||
|
import com.aiit.xiuos.service.ProtocolService;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import sun.nio.ch.IOUtil;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/protocolProduct")
|
||||||
|
public class ProtocolProductInfoController {
|
||||||
|
@Autowired
|
||||||
|
private ProtocolService protocolService;
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResultRespons addProtocolProduct(@RequestBody ProtocolProductVo protocolProductVo, HttpServletRequest request) throws ParseException {
|
||||||
|
ProtocolProductInfo productInfo = protocolService.getProtocolByName(protocolProductVo.getProductName());
|
||||||
|
if (productInfo != null) {
|
||||||
|
return new ResultRespons(Constant.ERROR_CODE, "该协议配方已存在!");
|
||||||
|
}
|
||||||
|
productInfo = ProtocolProductVo.changeVoToModel(protocolProductVo);
|
||||||
|
|
||||||
|
int res = protocolService.addProtocolProduct(productInfo);
|
||||||
|
if (1 == res) {
|
||||||
|
return new ResultRespons(Constant.SUCCESS_CODE, "新增协议配方成功!");
|
||||||
|
}
|
||||||
|
return new ResultRespons(Constant.ERROR_CODE, "新增协议配方失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResultRespons deleteProtocolProduct(@RequestBody Map<String, Object> jsonMap, HttpServletRequest request) throws ParseException {
|
||||||
|
|
||||||
|
int res = protocolService.deleteProtocolProduct(jsonMap.get("productName").toString());
|
||||||
|
if (1 == res) {
|
||||||
|
return new ResultRespons(Constant.SUCCESS_CODE, "删除协议配方成功!");
|
||||||
|
}
|
||||||
|
return new ResultRespons(Constant.ERROR_CODE, "删除协议配方失败!请检查协议名称是否存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/selectAll")
|
||||||
|
public ResultRespons selectProtocolProductList(HttpServletRequest request) throws ParseException {
|
||||||
|
List<ProtocolProductInfo> protocolProductInfos = protocolService.getProtocolAll();
|
||||||
|
List<ProtocolProductVo> protocolProductVos= new ArrayList<>();
|
||||||
|
if (protocolProductInfos != null && protocolProductInfos.size() > 0) {
|
||||||
|
for(int i=0;i<protocolProductInfos.size();i++){
|
||||||
|
ProtocolProductVo protocolProductVo = ProtocolProductVo.changeModelToVo(protocolProductInfos.get(i));
|
||||||
|
protocolProductVos.add(protocolProductVo);
|
||||||
|
|
||||||
|
}
|
||||||
|
return new ResultRespons(Constant.SUCCESS_CODE, "查询协议配方成功!", protocolProductVos);
|
||||||
|
}
|
||||||
|
return new ResultRespons(Constant.ERROR_CODE, "查询协议配方失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/selectOne")
|
||||||
|
public ResultRespons selectProtocolProduct(@RequestBody Map<String, Object> jsonMap, HttpServletRequest request) throws ParseException {
|
||||||
|
String productName= jsonMap.get("productName").toString();
|
||||||
|
ProtocolProductInfo protocolProductInfo = protocolService.getProtocolByName(productName);
|
||||||
|
|
||||||
|
if (protocolProductInfo != null) {
|
||||||
|
ProtocolProductVo protocolProductVo = ProtocolProductVo.changeModelToVo(protocolProductInfo);
|
||||||
|
return new ResultRespons(Constant.SUCCESS_CODE, "查询协议配方成功!", protocolProductVo);
|
||||||
|
}
|
||||||
|
return new ResultRespons(Constant.ERROR_CODE, "查询协议配方失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/exportCSV")
|
||||||
|
public ResultRespons exportCSV(@RequestBody Map<String, Object> jsonMap, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
String productName = jsonMap.get("productName").toString();
|
||||||
|
ProtocolProductInfo protocolProductInfo = protocolService.getProtocolByName(productName);
|
||||||
|
JSONArray readItemList= (JSONArray) JSONArray.parse(protocolProductInfo.getReadItemList());
|
||||||
|
|
||||||
|
String filestring = CsvUtils.FinsJson2CSV(readItemList).toString();
|
||||||
|
try{ InputStream inputStream = new ByteArrayInputStream(filestring.getBytes());
|
||||||
|
OutputStream outputStream = response.getOutputStream();//获取response的输出流对象
|
||||||
|
|
||||||
|
//设置ContentType字段告知浏览器返回内容类型
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
//设置Header字段
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" +
|
||||||
|
URLEncoder.encode(productName, "utf-8"));
|
||||||
|
//下面这行代码必须加,否则前端获取不到Content-Disposition字段,即无法获取文件名
|
||||||
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
//将读取的文件流复制到response的输出流中
|
||||||
|
IOUtils.copy(inputStream, outputStream);
|
||||||
|
//刷新输出流
|
||||||
|
outputStream.flush();
|
||||||
|
//关闭输出流
|
||||||
|
outputStream.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new ResultRespons(Constant.ERROR_CODE, "导出csv成功!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.aiit.xiuos.dao.mappers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.aiit.xiuos.model.ProtocolProductInfo;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ProtocolProductInfoMapper {
|
||||||
|
int deleteByPrimaryKey(String productId);
|
||||||
|
|
||||||
|
int insert(ProtocolProductInfo record);
|
||||||
|
|
||||||
|
int insertSelective(ProtocolProductInfo record);
|
||||||
|
|
||||||
|
ProtocolProductInfo selectByPrimaryKey(String productId);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(ProtocolProductInfo record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(ProtocolProductInfo record);
|
||||||
|
|
||||||
|
@Select("select * from protocol_product_info")
|
||||||
|
List<ProtocolProductInfo> selectAll();
|
||||||
|
|
||||||
|
@Select("select * from protocol_product_info where protocol_type =#{type}")
|
||||||
|
List<ProtocolProductInfo> selectByType(@Param("type") String protocolType);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.aiit.xiuos.model;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class ProtocolProductInfo {
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
private String protocolType;
|
||||||
|
|
||||||
|
private String readItemList;
|
||||||
|
|
||||||
|
private Date updatetime;
|
||||||
|
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
private String socketConfig;
|
||||||
|
|
||||||
|
private String readPeriod;
|
||||||
|
|
||||||
|
public ProtocolProductInfo(String productName, String protocolType, String readItemList, Date updatetime, String deviceId, String deviceName, String socketConfig, String readPeriod) {
|
||||||
|
this.productName = productName;
|
||||||
|
this.protocolType = protocolType;
|
||||||
|
this.readItemList = readItemList;
|
||||||
|
this.updatetime = updatetime;
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
this.deviceName = deviceName;
|
||||||
|
this.socketConfig = socketConfig;
|
||||||
|
this.readPeriod = readPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtocolProductInfo() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.aiit.xiuos.model.VO;
|
||||||
|
|
||||||
|
import com.aiit.xiuos.Utils.MyUtils;
|
||||||
|
import com.aiit.xiuos.model.ProtocolProductInfo;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class ProtocolProductVo {
|
||||||
|
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
private String protocolType;
|
||||||
|
|
||||||
|
private JSONArray readItemList;
|
||||||
|
|
||||||
|
private Date updatetime;
|
||||||
|
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
private JSONObject socketConfig;
|
||||||
|
|
||||||
|
private String readPeriod;
|
||||||
|
|
||||||
|
public ProtocolProductVo(String productName, String protocolType, JSONArray readItemList, Date updatetime, String deviceId, String deviceName, JSONObject socketConfig, String readPeriod) {
|
||||||
|
this.productName = productName;
|
||||||
|
this.protocolType = protocolType;
|
||||||
|
this.readItemList = readItemList;
|
||||||
|
this.updatetime = updatetime;
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
this.deviceName = deviceName;
|
||||||
|
this.socketConfig = socketConfig;
|
||||||
|
this.readPeriod = readPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProtocolProductVo(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProtocolProductInfo changeVoToModel(ProtocolProductVo protocolProductVo) throws ParseException {
|
||||||
|
ProtocolProductInfo protocolProductInfo = new ProtocolProductInfo();
|
||||||
|
protocolProductInfo.setProductName(protocolProductVo.getProductName());
|
||||||
|
protocolProductInfo.setProtocolType(protocolProductVo.getProtocolType());
|
||||||
|
protocolProductInfo.setReadItemList(protocolProductVo.getReadItemList().toJSONString());
|
||||||
|
protocolProductInfo.setDeviceId(protocolProductVo.getDeviceId());
|
||||||
|
protocolProductInfo.setDeviceName(protocolProductVo.getDeviceName());
|
||||||
|
protocolProductInfo.setSocketConfig(protocolProductVo.getSocketConfig().toJSONString());
|
||||||
|
protocolProductInfo.setReadPeriod(protocolProductVo.getReadPeriod());
|
||||||
|
protocolProductInfo.setUpdatetime(MyUtils.getDateTime());
|
||||||
|
return protocolProductInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProtocolProductVo changeModelToVo(ProtocolProductInfo protocolProductInfo) throws ParseException {
|
||||||
|
ProtocolProductVo protocolProductVo = new ProtocolProductVo();
|
||||||
|
protocolProductVo.setProductName(protocolProductInfo.getProductName());
|
||||||
|
protocolProductVo.setProtocolType(protocolProductInfo.getProtocolType());
|
||||||
|
protocolProductVo.setDeviceId(protocolProductInfo.getDeviceId());
|
||||||
|
protocolProductVo.setReadPeriod(protocolProductInfo.getReadPeriod());
|
||||||
|
protocolProductVo.setDeviceName(protocolProductInfo.getDeviceName());
|
||||||
|
protocolProductVo.setUpdatetime(protocolProductInfo.getUpdatetime());
|
||||||
|
protocolProductVo.setSocketConfig((JSONObject) JSONObject.parse(protocolProductInfo.getSocketConfig()));
|
||||||
|
protocolProductVo.setReadItemList((JSONArray)JSONArray.parse(protocolProductInfo.getReadItemList()));
|
||||||
|
|
||||||
|
return protocolProductVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.aiit.xiuos.service;
|
||||||
|
|
||||||
|
import com.aiit.xiuos.model.ProtocolProductInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProtocolService {
|
||||||
|
List<ProtocolProductInfo> getProtocolByType(String protocolType);
|
||||||
|
List<ProtocolProductInfo> getProtocolAll();
|
||||||
|
ProtocolProductInfo getProtocolByName(String productName);
|
||||||
|
int addProtocolProduct(ProtocolProductInfo protocolProductInfo);
|
||||||
|
int deleteProtocolProduct(String productName);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.aiit.xiuos.service.impl;
|
||||||
|
|
||||||
|
import com.aiit.xiuos.dao.mappers.ProtocolProductInfoMapper;
|
||||||
|
import com.aiit.xiuos.model.ProtocolProductInfo;
|
||||||
|
import com.aiit.xiuos.service.ProtocolService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
@Service
|
||||||
|
public class ProtocolServiceImpl implements ProtocolService {
|
||||||
|
@Autowired
|
||||||
|
ProtocolProductInfoMapper protocolProductInfoMapper;
|
||||||
|
@Override
|
||||||
|
public List<ProtocolProductInfo> getProtocolByType(String protocolType) {
|
||||||
|
return protocolProductInfoMapper.selectByType(protocolType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProtocolProductInfo> getProtocolAll() {
|
||||||
|
return protocolProductInfoMapper.selectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProtocolProductInfo getProtocolByName(String productName) {
|
||||||
|
return protocolProductInfoMapper.selectByPrimaryKey(productName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addProtocolProduct(ProtocolProductInfo protocolProductInfo) {
|
||||||
|
return protocolProductInfoMapper.insertSelective(protocolProductInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteProtocolProduct(String productId) {
|
||||||
|
return protocolProductInfoMapper.deleteByPrimaryKey(productId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
package com.aiit.xiuos.dao.mappers;
|
|
||||||
|
|
||||||
import com.aiit.xiuos.model.AvgDayData;
|
|
||||||
|
|
||||||
public interface AvgDayDataMapper {
|
|
||||||
int deleteByPrimaryKey(Integer id);
|
|
||||||
|
|
||||||
int insert(AvgDayData record);
|
|
||||||
|
|
||||||
int insertSelective(AvgDayData record);
|
|
||||||
|
|
||||||
AvgDayData selectByPrimaryKey(Integer id);
|
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(AvgDayData record);
|
|
||||||
|
|
||||||
int updateByPrimaryKey(AvgDayData record);
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package com.aiit.xiuos.model;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
public class AvgDayData {
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
private String windspeed;
|
|
||||||
|
|
||||||
private String noise;
|
|
||||||
|
|
||||||
private String methanal;
|
|
||||||
|
|
||||||
private String pm1_0;
|
|
||||||
|
|
||||||
private String pm2_5;
|
|
||||||
|
|
||||||
private String pm10;
|
|
||||||
|
|
||||||
private String so2;
|
|
||||||
|
|
||||||
private String temperature;
|
|
||||||
|
|
||||||
private String humidness;
|
|
||||||
|
|
||||||
private String co2;
|
|
||||||
|
|
||||||
private String airpressure;
|
|
||||||
|
|
||||||
private String tvoc;
|
|
||||||
|
|
||||||
private String ethanol;
|
|
||||||
|
|
||||||
private String methane;
|
|
||||||
|
|
||||||
private Date datatime;
|
|
||||||
|
|
||||||
public AvgDayData(String id, String windspeed, String noise, String methanal, String pm1_0, String pm2_5, String pm10, String so2, String temperature, String humidness, String co2, String airpressure, String tvoc, String ethanol, String methane, Date datatime) {
|
|
||||||
this.id = id;
|
|
||||||
this.windspeed = windspeed;
|
|
||||||
this.noise = noise;
|
|
||||||
this.methanal = methanal;
|
|
||||||
this.pm1_0 = pm1_0;
|
|
||||||
this.pm2_5 = pm2_5;
|
|
||||||
this.pm10 = pm10;
|
|
||||||
this.so2 = so2;
|
|
||||||
this.temperature = temperature;
|
|
||||||
this.humidness = humidness;
|
|
||||||
this.co2 = co2;
|
|
||||||
this.airpressure = airpressure;
|
|
||||||
this.tvoc = tvoc;
|
|
||||||
this.ethanol = ethanol;
|
|
||||||
this.methane = methane;
|
|
||||||
this.datatime = datatime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AvgDayData() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -82,7 +82,7 @@
|
||||||
<!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"-->
|
<!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"-->
|
||||||
<!-- enableSelectByExample="false" selectByExampleQueryId="false"/>-->
|
<!-- enableSelectByExample="false" selectByExampleQueryId="false"/>-->
|
||||||
|
|
||||||
<table tableName="avg_day_data" domainObjectName="AvgDayData"
|
<table tableName="protocol_product_info" domainObjectName="ProtocolProductInfo"
|
||||||
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||||
enableSelectByExample="false" selectByExampleQueryId="false"/>
|
enableSelectByExample="false" selectByExampleQueryId="false"/>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
<?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.ProtocolProductInfoMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.ProtocolProductInfo">
|
||||||
|
<constructor>
|
||||||
|
<idArg column="product_name" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
<arg column="protocol_type" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
<arg column="read_item_list" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
<arg column="updatetime" javaType="java.util.Date" jdbcType="TIMESTAMP" />
|
||||||
|
<arg column="device_id" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
<arg column="device_name" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
<arg column="socket_config" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
<arg column="read_period" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||||
|
</constructor>
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
product_name, protocol_type, read_item_list, updatetime, device_id, device_name,
|
||||||
|
socket_config, read_period
|
||||||
|
</sql>
|
||||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from protocol_product_info
|
||||||
|
where product_name = #{productName,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||||
|
delete from protocol_product_info
|
||||||
|
where product_name = #{productName,jdbcType=VARCHAR}
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" parameterType="com.aiit.xiuos.model.ProtocolProductInfo">
|
||||||
|
insert into protocol_product_info (product_name, protocol_type, read_item_list,
|
||||||
|
updatetime, device_id, device_name,
|
||||||
|
socket_config, read_period)
|
||||||
|
values (#{productName,jdbcType=VARCHAR}, #{protocolType,jdbcType=VARCHAR}, #{readItemList,jdbcType=VARCHAR},
|
||||||
|
#{updatetime,jdbcType=TIMESTAMP}, #{deviceId,jdbcType=VARCHAR}, #{deviceName,jdbcType=VARCHAR},
|
||||||
|
#{socketConfig,jdbcType=VARCHAR}, #{readPeriod,jdbcType=VARCHAR})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.ProtocolProductInfo">
|
||||||
|
insert into protocol_product_info
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="productName != null">
|
||||||
|
product_name,
|
||||||
|
</if>
|
||||||
|
<if test="protocolType != null">
|
||||||
|
protocol_type,
|
||||||
|
</if>
|
||||||
|
<if test="readItemList != null">
|
||||||
|
read_item_list,
|
||||||
|
</if>
|
||||||
|
<if test="updatetime != null">
|
||||||
|
updatetime,
|
||||||
|
</if>
|
||||||
|
<if test="deviceId != null">
|
||||||
|
device_id,
|
||||||
|
</if>
|
||||||
|
<if test="deviceName != null">
|
||||||
|
device_name,
|
||||||
|
</if>
|
||||||
|
<if test="socketConfig != null">
|
||||||
|
socket_config,
|
||||||
|
</if>
|
||||||
|
<if test="readPeriod != null">
|
||||||
|
read_period,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="productName != null">
|
||||||
|
#{productName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="protocolType != null">
|
||||||
|
#{protocolType,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="readItemList != null">
|
||||||
|
#{readItemList,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="updatetime != null">
|
||||||
|
#{updatetime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="deviceId != null">
|
||||||
|
#{deviceId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="deviceName != null">
|
||||||
|
#{deviceName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="socketConfig != null">
|
||||||
|
#{socketConfig,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="readPeriod != null">
|
||||||
|
#{readPeriod,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.ProtocolProductInfo">
|
||||||
|
update protocol_product_info
|
||||||
|
<set>
|
||||||
|
<if test="protocolType != null">
|
||||||
|
protocol_type = #{protocolType,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="readItemList != null">
|
||||||
|
read_item_list = #{readItemList,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="updatetime != null">
|
||||||
|
updatetime = #{updatetime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="deviceId != null">
|
||||||
|
device_id = #{deviceId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="deviceName != null">
|
||||||
|
device_name = #{deviceName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="socketConfig != null">
|
||||||
|
socket_config = #{socketConfig,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="readPeriod != null">
|
||||||
|
read_period = #{readPeriod,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where product_name = #{productName,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.ProtocolProductInfo">
|
||||||
|
update protocol_product_info
|
||||||
|
set protocol_type = #{protocolType,jdbcType=VARCHAR},
|
||||||
|
read_item_list = #{readItemList,jdbcType=VARCHAR},
|
||||||
|
updatetime = #{updatetime,jdbcType=TIMESTAMP},
|
||||||
|
device_id = #{deviceId,jdbcType=VARCHAR},
|
||||||
|
device_name = #{deviceName,jdbcType=VARCHAR},
|
||||||
|
socket_config = #{socketConfig,jdbcType=VARCHAR},
|
||||||
|
read_period = #{readPeriod,jdbcType=VARCHAR}
|
||||||
|
where product_name = #{productName,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue