This commit is contained in:
龚祖望 2022-11-30 19:15:59 +08:00
commit 8d781e9b19
24 changed files with 1409 additions and 102 deletions

View File

@ -0,0 +1,25 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings>
</code_scheme>
</component>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@ -113,6 +113,12 @@
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>

View File

@ -17,7 +17,6 @@ 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;
@ -37,10 +36,18 @@ public class AroundLogAspect {
public void normalPointcut() {
}
@Pointcut("execution(* com.aiit.xiuos.controller.LoginController.*(..))")
public void excludePointcut() {
public void excludeLogPointcut() {
}
@Pointcut("normalPointcut() && !excludePointcut()")
@Pointcut("execution(* com.aiit.xiuos.controller.UserController.*(..))")
public void excludeUserPointcut() {
}
@Pointcut("execution(* com.aiit.xiuos.controller.ExcludeController.*(..))")
public void excludeController() {
}
@Pointcut("normalPointcut() && !excludeUserPointcut()&& !excludeLogPointcut()&&!excludeController()")
public void pointCutMethod() {
}
@ -87,25 +94,26 @@ public class AroundLogAspect {
requestLogInfo.setMethodname(methodName);
//参数名
Parameter[] parameters = method.getParameters();
requestLogInfo.setRequestparam(parameters[0].getName());
String param ="";
for(int i=0;i<parameters.length;i++){
param+=parameters[i]+",";
}
requestLogInfo.setRequestparam(param);
//计时开始
started.start();
ResultRespons proceed = (ResultRespons) point.proceed();
//计时结束
started.stop();
//请求耗时
requestLogInfo.setProcesstime(String.valueOf(started.getTotalTimeMillis()));
log.info("method:"+methodName);
log.info("processtime:"+started.getTotalTimeMillis());
//请求结果
requestLogInfo.setRequestresult("resultCoe="+proceed.getCode()+" resultMsg="+proceed.getMessage());
requestLogInfoService.addLog(requestLogInfo);
return proceed;
} catch (RuntimeException e) {
throw e;
} catch (Throwable throwable) {

View File

@ -0,0 +1,4 @@
package com.aiit.xiuos.Utils;
public class BeanUtil {
}

View File

@ -0,0 +1,31 @@
package com.aiit.xiuos.Utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
@Slf4j
public class CsvUtils {
public static StringBuffer FinsJson2CSV(JSONArray jsonArray) {
StringBuffer stringBuffer=new StringBuffer();
// "value_name": "启动",
// "value_type": 1,
// "area_char": "W",
// "data_type": 0,
// "start_address": 0,
// "bit_address": 0,
// "data_length": 1
for(int i=0;i<jsonArray.size();i++){
JSONObject items =jsonArray.getJSONObject(i);
stringBuffer.append(items.getString("value_name")).append(",")
.append(items.getString("area_char")).append(",")
.append(items.getInteger("data_type")).append(",")
.append(items.getInteger("start_address")).append(",")
.append(items.getInteger("bit_address")).append(",")
.append(items.getInteger("data_length")).append("\n");
}
return stringBuffer;
}
}

View File

@ -0,0 +1,4 @@
package com.aiit.xiuos.Utils;
public class DINGUtils {
}

View File

@ -1,5 +1,6 @@
package com.aiit.xiuos.Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
@ -10,6 +11,7 @@ import org.springframework.stereotype.Component;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
@Slf4j
@Component
public class EmailUtil {
@ -60,7 +62,7 @@ public class EmailUtil {
}
}
} catch (MessagingException e) {
e.printStackTrace();
log.error(e.getMessage());
}
// 发送邮件
mailSender.send(mimeMessage);
@ -83,7 +85,7 @@ public class EmailUtil {
helper.setText(content); // 设置邮件内容
helper.addAttachment(file.getName(), file); // 单个附件
} catch (MessagingException e) {
e.printStackTrace();
log.error(e.getMessage());
}
// 发送邮件
mailSender.send(mimeMessage);

View File

@ -2,14 +2,19 @@ package com.aiit.xiuos.Utils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ParseException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
@ -20,7 +25,16 @@ public class HttpClientUtil {
private static String tokenString = "";
private static String AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED";
private static CloseableHttpClient httpClient = null;
private static CloseableHttpClient httpClient;
static {
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
connManager.setMaxTotal(1000);
connManager.setDefaultMaxPerRoute(1000);
httpClient = HttpClients.custom().setConnectionManager(connManager).setConnectionManagerShared(true).build();
}
/**
* 以get方式调用第三方接口
@ -29,7 +43,6 @@ public class HttpClientUtil {
*/
public static JSONObject doGet(String url) {
//创建HttpClient对象
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(url);
// if (null != tokenString && !tokenString.equals("")) {
// tokenString = getToken();
@ -56,44 +69,55 @@ public class HttpClientUtil {
* @param json
* @return
*/
public static String doPost(String url, JSONObject json) {
if (null == httpClient) {
httpClient = HttpClientBuilder.create().build();
public static String doPost(String url, String json, String token)
throws IOException {
if (StringUtils.isBlank(url)) {
return null;
}
HttpPost httpPost = new HttpPost(url);
if (null != tokenString && tokenString.equals("")) {
tokenString = getToken();
httpPost.addHeader("Content-Type", "application/json");
httpPost.addHeader("Accept", "application/json");
if (!StringUtils.isEmpty(token)) {
httpPost.addHeader("openToken", token);
}
//api_gateway_auth_token自定义header头用于token验证使用
httpPost.addHeader("api_gateway_auth_token", tokenString);
httpPost.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
CloseableHttpResponse response = null;
try {
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding("UTF-8");
if (!"".equals(json)) {
// 这里是关键,后面要跟上字符集格式
StringEntity params = new StringEntity(json, "utf-8");
params.setContentEncoding("utf-8");
// 发送json数据需要设置contentType
se.setContentType("application/x-www-form-urlencoded");
//设置请求参数
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
//返回json格式
String res = EntityUtils.toString(response.getEntity());
return res;
params.setContentType("application/json");
httpPost.setEntity(params);
}
} catch (IOException e) {
log.error(e.getMessage());
response = httpClient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) {
httpPost.abort();
log.error(response.toString());
}
HttpEntity entity = response.getEntity();
String result = null;
if (entity != null) {
result = EntityUtils.toString(entity, "utf-8");
}
EntityUtils.consume(entity);
return result;
} catch (ParseException e) {
e.printStackTrace();
} finally {
if (httpClient != null){
try {
httpClient.close();
} catch (IOException e) {
log.error(e.getMessage());
}
if (response != null) {
response.close();
}
}
return null;
}
/**
* 获取第三方接口的token
*/
@ -128,21 +152,6 @@ public class HttpClientUtil {
return token;
}
/**
* 测试
*/
public static void test(String telephone) {
JSONObject object = new JSONObject();
object.put("telephone", telephone);
//首先获取token
tokenString = getToken();
String response = doPost("http://localhost/searchUrl", object);
//如果返回的结果是list形式的需要使用JSONObject.parseArray转换
//List<Result> list = JSONObject.parseArray(response, Result.class);
System.out.println(response);
}

View File

@ -5,6 +5,7 @@ import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -13,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@RestController
@Slf4j
public class LoginController {
@Autowired
private UserInfoService userInfoService;
@ -24,10 +25,10 @@ public class LoginController {
if(null!=user){
HttpSession session = request.getSession();
session.setAttribute("user",user);//session存用户
System.out.println("session======="+session.getId());
log.info("session======="+session.getId());
String ip = MyUtils.getIp(request);
userInfoService.updateLoginInfo(MyUtils.getTime(),ip,user.getId());
System.out.println("ip++++++++===="+ip);
log.info("ip++++++++===="+ip);
return new ResultRespons(Constant.SUCCESS_CODE,"登录成功");
}
return new ResultRespons(Constant.ERROR_CODE,"登录失败,用户名或密码有误");

View File

@ -8,11 +8,10 @@ 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 lombok.extern.slf4j.Slf4j;
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;
@ -22,7 +21,7 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/protocolProduct")
public class ProtocolProductInfoController {
@ -116,7 +115,7 @@ public class ProtocolProductInfoController {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage());
}
return new ResultRespons(Constant.ERROR_CODE, "导出csv成功");
}

View File

@ -0,0 +1,19 @@
package com.aiit.xiuos.dao.mappers;
import com.aiit.xiuos.model.QjdqElectric;
import org.springframework.stereotype.Repository;
@Repository
public interface QjdqElectricMapper {
int deleteByPrimaryKey(Integer id);
int insert(QjdqElectric record);
int insertSelective(QjdqElectric record);
QjdqElectric selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(QjdqElectric record);
int updateByPrimaryKey(QjdqElectric record);
}

View File

@ -0,0 +1,136 @@
package com.aiit.xiuos.model;
import java.math.BigDecimal;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class QjdqElectric {
private Integer id;
private BigDecimal electric2;
private BigDecimal electric3;
private BigDecimal electric4;
private BigDecimal electric5;
private BigDecimal electric6;
private BigDecimal electric7;
private BigDecimal electric8;
private BigDecimal electric9;
private BigDecimal electric10;
private BigDecimal electric11;
private BigDecimal electric12;
private BigDecimal electric13;
private BigDecimal electric14;
private BigDecimal electric15;
private BigDecimal electric16;
private BigDecimal electric17;
private BigDecimal electric18;
private BigDecimal electric19;
private BigDecimal electric20;
private BigDecimal electric21;
private BigDecimal electric22;
private BigDecimal electric23;
private BigDecimal electric24;
private BigDecimal electric25;
private BigDecimal electric26;
private BigDecimal electric27;
private BigDecimal electric28;
private BigDecimal electric29;
private BigDecimal electric30;
private BigDecimal electric31;
private BigDecimal electric32;
private BigDecimal electric33;
private BigDecimal electric34;
private BigDecimal electric35;
private BigDecimal electric36;
private BigDecimal electric37;
private BigDecimal electric38;
private BigDecimal electric39;
private BigDecimal electric40;
public QjdqElectric(Integer id, BigDecimal electric2, BigDecimal electric3, BigDecimal electric4, BigDecimal electric5, BigDecimal electric6, BigDecimal electric7, BigDecimal electric8, BigDecimal electric9, BigDecimal electric10, BigDecimal electric11, BigDecimal electric12, BigDecimal electric13, BigDecimal electric14, BigDecimal electric15, BigDecimal electric16, BigDecimal electric17, BigDecimal electric18, BigDecimal electric19, BigDecimal electric20, BigDecimal electric21, BigDecimal electric22, BigDecimal electric23, BigDecimal electric24, BigDecimal electric25, BigDecimal electric26, BigDecimal electric27, BigDecimal electric28, BigDecimal electric29, BigDecimal electric30, BigDecimal electric31, BigDecimal electric32, BigDecimal electric33, BigDecimal electric34, BigDecimal electric35, BigDecimal electric36, BigDecimal electric37, BigDecimal electric38, BigDecimal electric39, BigDecimal electric40) {
this.id = id;
this.electric2 = electric2;
this.electric3 = electric3;
this.electric4 = electric4;
this.electric5 = electric5;
this.electric6 = electric6;
this.electric7 = electric7;
this.electric8 = electric8;
this.electric9 = electric9;
this.electric10 = electric10;
this.electric11 = electric11;
this.electric12 = electric12;
this.electric13 = electric13;
this.electric14 = electric14;
this.electric15 = electric15;
this.electric16 = electric16;
this.electric17 = electric17;
this.electric18 = electric18;
this.electric19 = electric19;
this.electric20 = electric20;
this.electric21 = electric21;
this.electric22 = electric22;
this.electric23 = electric23;
this.electric24 = electric24;
this.electric25 = electric25;
this.electric26 = electric26;
this.electric27 = electric27;
this.electric28 = electric28;
this.electric29 = electric29;
this.electric30 = electric30;
this.electric31 = electric31;
this.electric32 = electric32;
this.electric33 = electric33;
this.electric34 = electric34;
this.electric35 = electric35;
this.electric36 = electric36;
this.electric37 = electric37;
this.electric38 = electric38;
this.electric39 = electric39;
this.electric40 = electric40;
}
public QjdqElectric() {
super();
}
}

View File

@ -28,8 +28,9 @@ public class ProtocolProductVo {
private JSONObject socketConfig;
private String readPeriod;
private String org;
public ProtocolProductVo(String productName, String protocolType, JSONArray readItemList, Date updatetime, String deviceId, String deviceName, JSONObject socketConfig, String readPeriod) {
public ProtocolProductVo(String productName, String protocolType, JSONArray readItemList, Date updatetime, String deviceId, String deviceName, JSONObject socketConfig, String readPeriod,String org) {
this.productName = productName;
this.protocolType = protocolType;
this.readItemList = readItemList;
@ -38,6 +39,7 @@ public class ProtocolProductVo {
this.deviceName = deviceName;
this.socketConfig = socketConfig;
this.readPeriod = readPeriod;
this.org =org;
}
public ProtocolProductVo(){
@ -54,6 +56,7 @@ public class ProtocolProductVo {
protocolProductInfo.setSocketConfig(protocolProductVo.getSocketConfig().toJSONString());
protocolProductInfo.setReadPeriod(protocolProductVo.getReadPeriod());
protocolProductInfo.setUpdatetime(MyUtils.getDateTime());
protocolProductInfo.setOrg(protocolProductVo.getOrg());
return protocolProductInfo;
}
@ -67,7 +70,7 @@ public class ProtocolProductVo {
protocolProductVo.setUpdatetime(protocolProductInfo.getUpdatetime());
protocolProductVo.setSocketConfig((JSONObject) JSONObject.parse(protocolProductInfo.getSocketConfig()));
protocolProductVo.setReadItemList((JSONArray)JSONArray.parse(protocolProductInfo.getReadItemList()));
protocolProductVo.setOrg(protocolProductInfo.getOrg());
return protocolProductVo;
}

View File

@ -0,0 +1,73 @@
package com.aiit.xiuos.redis;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* Redis配置
*/
@Configuration
public class RedisConfig {
@Autowired
private RedisConnectionFactory factory;
@Bean
public RedisTemplate<String, Object> redisTemplate() {
// 创建一个模板类
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
// 设置key的序列化器
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
// 设置value的序列化器
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值默认使用JDK的序列化方式
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域field,get和set,以及修饰符范围ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型类必须是非final修饰的final修饰的类比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
redisTemplate.setValueSerializer(jacksonSeial);
// 将刚才的redis连接工厂设置到模板类中
//spring默认帮我们读取application.properties文件并且注册了一个factorybean
redisTemplate.setConnectionFactory(factory);
return redisTemplate;
}
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
@Bean
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
return redisTemplate.opsForValue();
}
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}

View File

@ -0,0 +1,191 @@
package com.aiit.xiuos.redis;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
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;
@Component
public class RedisUtil {
@Autowired
private RedisTemplate redisTemplate;
@Resource(name="redisTemplate")
private ValueOperations<String, String> valueOperations;
@Resource(name="redisTemplate")
private HashOperations<String, String, Object> hashOperations;
@Resource(name="redisTemplate")
private ListOperations<String, Object> listOperations;
@Resource(name="redisTemplate")
private SetOperations<String, Object> setOperations;
@Resource(name="redisTemplate")
private ZSetOperations<String, Object> zSetOperations;
/** 默认过期时长,单位:秒 */
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
/** 不设置过期时长 */
public final static long NOT_EXPIRE = -1;
public void set(String key, Object value, long expire){
valueOperations.set(key, toJson(value));
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
}
public void set(String key, Object value){
set(key, value, DEFAULT_EXPIRE);
}
public <T> T get(String key, Class<T> clazz, long expire) {
String value = valueOperations.get(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value == null ? null : fromJson(value, clazz);
}
public <T> T get(String key, Class<T> clazz) {
return get(key, clazz, NOT_EXPIRE);
}
public String get(String key, long expire) {
String value = valueOperations.get(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value;
}
public String get(String key) {
return get(key, NOT_EXPIRE);
}
public void delete(String key) {
redisTemplate.delete(key);
}
/**
* Object转成JSON数据
*/
private String toJson(Object object){
if(object instanceof Integer || object instanceof Long || object instanceof Float ||
object instanceof Double || object instanceof Boolean || object instanceof String){
return String.valueOf(object);
}
return JSON.toJSONString(object);
}
/**
* JSON数据转成Object
*/
private <T> T fromJson(String json, Class<T> clazz){
return JSON.parseObject(json, clazz);
}
/**
* listOperations使用
*/
public void lset(String key, List<Object> list, long expire){
listOperations.leftPush(key,list);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
}
public void lset(String key, List<Object> list){
lset(key, list, DEFAULT_EXPIRE);
}
public List<Object> lget(String key, long expire) {
List<Object> list = (List<Object>)listOperations.leftPop(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return list;
}
public List<Object> lget(String key) {
return lget(key, NOT_EXPIRE);
}
/**
* hashOperations的使用
*/
public void hset(String key, Map<String,Object> map, long expire){
hashOperations.putAll(key,map);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
}
public void hset(String key,Map<String,Object> map){
hset(key, map, DEFAULT_EXPIRE);
}
/**
* 获取整个map
*/
public Map<String,Object> hget(String key, long expire) {
Map<String,Object> map = hashOperations.entries(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return map;
}
public Map<String,Object> hget(String key) {
return hget(key, NOT_EXPIRE);
}
/**
* 获取map里的一个值
*/
public Object hget(String key,String mkey, long expire) {
Object value = hashOperations.get(key,mkey);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value;
}
public Object hget(String key,String mkey) {
return hget(key,mkey,NOT_EXPIRE);
}
/**
* 获取map里的所有值
*/
public List<Object> hgetv(String key,long expire) {
List<Object> list = hashOperations.values(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return list;
}
public List<Object> hgetv(String key) {
return hgetv(key,NOT_EXPIRE);
}
/**
* 获取map里的所有key
*/
public Set<String> hgetk(String key,long expire) {
Set<String> list = hashOperations.keys(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return list;
}
public Set<String> hgetk(String key) {
return hgetk(key,NOT_EXPIRE);
}
}

View File

@ -1,10 +1,13 @@
package com.aiit.xiuos.scheduled;
import com.aiit.xiuos.Utils.DingUtil;
import com.aiit.xiuos.Utils.EmailUtil;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.socket.QJDQWebSocketServer;
import com.aiit.xiuos.tdengine.TDengineJDBCUtil;
import com.aiit.xiuos.model.*;
import com.aiit.xiuos.service.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
@ -33,6 +36,10 @@ public class TaskScheduled {
DeviceInfoService deviceInfoService;
@Autowired
EmailUtil emailUtil;
@Autowired
QjdqElectricService qjdqElectricService;
@Autowired
QJDQWebSocketServer qjdqWebSocketServer;
@Scheduled(cron = "0 0 */1 * * ?")//every hour
public void insertAvgDayData() throws ParseException {
AvgDayData avgDayData =new AvgDayData();
@ -86,14 +93,102 @@ public class TaskScheduled {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse(MyUtils.getTime());
avgDayData.setDatatime(date);
avgDayDataService.addAvgDayData(avgDayData);
}
@Scheduled(cron = "0 */1 8-20 * * ?")//every minute 8-20 clock
public void updateQJDQ(){
QjdqElectric qjdqElectric =qjdqElectricService.selectElectric(1);
ArrayList<BigDecimal> arrayList =new ArrayList<>();
QjdqElectric newRecord =new QjdqElectric();
newRecord.setId(1);
newRecord.setElectric2(qjdqElectric.getElectric2().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric2());
newRecord.setElectric3(qjdqElectric.getElectric3().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric3());
newRecord.setElectric4(qjdqElectric.getElectric4().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric4());
newRecord.setElectric5(qjdqElectric.getElectric5().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric5());
newRecord.setElectric6(qjdqElectric.getElectric6().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric6());
newRecord.setElectric7(qjdqElectric.getElectric7().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric7());
newRecord.setElectric8(qjdqElectric.getElectric8().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric8());
newRecord.setElectric9(qjdqElectric.getElectric9().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric9());
newRecord.setElectric10(qjdqElectric.getElectric10().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric10());
newRecord.setElectric11(qjdqElectric.getElectric11().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric11());
newRecord.setElectric12(qjdqElectric.getElectric12().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric12());
newRecord.setElectric13(qjdqElectric.getElectric13().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric13());
newRecord.setElectric14(qjdqElectric.getElectric14().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric14());
newRecord.setElectric15(qjdqElectric.getElectric15().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric15());
newRecord.setElectric16(qjdqElectric.getElectric16().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric16());
newRecord.setElectric17(qjdqElectric.getElectric17().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric17());
newRecord.setElectric18(qjdqElectric.getElectric18().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric18());
newRecord.setElectric19(qjdqElectric.getElectric19().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric19());
newRecord.setElectric20(qjdqElectric.getElectric20().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric20());
newRecord.setElectric21(qjdqElectric.getElectric21().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric21());
newRecord.setElectric22(qjdqElectric.getElectric22().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric22());
newRecord.setElectric23(qjdqElectric.getElectric23().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric23());
newRecord.setElectric24(qjdqElectric.getElectric24().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric24());
newRecord.setElectric25(qjdqElectric.getElectric25().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric25());
newRecord.setElectric26(qjdqElectric.getElectric26().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric26());
newRecord.setElectric27(qjdqElectric.getElectric27().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric27());
newRecord.setElectric28(qjdqElectric.getElectric28().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric28());
newRecord.setElectric29(qjdqElectric.getElectric29().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric29());
newRecord.setElectric30(qjdqElectric.getElectric30().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric30());
newRecord.setElectric31(qjdqElectric.getElectric31().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric31());
newRecord.setElectric32(qjdqElectric.getElectric32().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric32());
newRecord.setElectric33(qjdqElectric.getElectric33().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric33());
newRecord.setElectric34(qjdqElectric.getElectric34().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric34());
newRecord.setElectric35(qjdqElectric.getElectric35().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric35());
newRecord.setElectric36(qjdqElectric.getElectric36().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric36());
newRecord.setElectric37(qjdqElectric.getElectric37().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric37());
newRecord.setElectric38(qjdqElectric.getElectric38().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric38());
newRecord.setElectric39(qjdqElectric.getElectric39().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric39());
newRecord.setElectric40(qjdqElectric.getElectric40().add(new BigDecimal(Math.random())));
arrayList.add(qjdqElectric.getElectric40());
log.info( "返回数据"+arrayList.toString());
qjdqWebSocketServer.sendInfo(arrayList.toString());
qjdqElectricService.updateElectric(newRecord);
}
@Scheduled(cron = "0 0 0 * * ?")//every 0:0:0
public void ExecuteRule() throws Exception {
public void ExecuteRule() {
//查询保存的每一条告警规则
List<AlarmRule> alarmRules =alarmRuleService.selectActive();
for(int i=0;i<alarmRules.size();i++){
@ -103,7 +198,7 @@ public class TaskScheduled {
String tdString = "select count(*) from " + deviceNo+" where ";
//拼接每一条规则
for(int j=0;j<jsonArray.size();j++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
JSONObject jsonObject = jsonArray.getJSONObject(j);
String param = jsonObject.getString("param");
String condition = jsonObject.getString("condition");
int value =jsonObject.getInteger("value");
@ -111,13 +206,16 @@ public class TaskScheduled {
}
//取前一天数据
tdString+="ts>now-1d";
System.out.println("sql+++++++++:"+tdString);
log.info("sql+++++++++:"+tdString);
//去Tdengine执行sql
int count = TDengineJDBCUtil.getCount(tdString);
int count = 0;
AlarmInfo alarmInfo = new AlarmInfo();
try {
count = TDengineJDBCUtil.getCount(tdString);
if (count <= 0) {
log.info("ruleID" + alarmRule.getId() + "不存在告警数据!!!");
continue;
} else {
AlarmInfo alarmInfo =new AlarmInfo();
alarmInfo.setDeviceNo(deviceNo);
alarmInfo.setAlarmTime(MyUtils.getDateTime());
alarmInfo.setAlarmName(alarmRule.getAlarmName());
@ -127,21 +225,21 @@ public class TaskScheduled {
alarmInfo.setAlarmStatus(1);
alarmInfo.setAlarmLevel(alarmRule.getAlarmLevel());
alarmInfo.setOrg(alarmRule.getOrg());
//保存告警信息告警级别高的插入,低的因主键冲突可自动排除
try{
//保存告警信息若已存在执行更新
alarmInfoService.addAlarmInfo(alarmInfo);
if (alarmRule.getNoticeType().equals("email")) {
emailUtil.sendMessage(alarmRule.getNoticeAddress(), "设备告警", alarmRule.getNoticeContent());
log.info("邮件发送成功");
} else if (alarmRule.getNoticeType().equals("dingRob")) {
DingUtil.sendMsg(alarmRule.getNoticeAddress(), alarmRule.getNoticeContent());
log.info("钉钉发送成功");
}
}
}catch (Exception e){
log.info(e.getMessage());
alarmInfoService.updateAlarmInfo(alarmInfo);
log.error(e.getMessage());
}
}
}
}
}
}

View File

@ -0,0 +1,8 @@
package com.aiit.xiuos.service;
import com.aiit.xiuos.model.QjdqElectric;
public interface QjdqElectricService {
int updateElectric(QjdqElectric qjdqElectric);
QjdqElectric selectElectric(int id);
}

View File

@ -44,4 +44,9 @@ public class AlarmInfoServiceImpl implements AlarmInfoService {
return alarmInfoMapper.getCount(org);
}
@Override
public int addAlarmInfo(AlarmInfo alarmInfo) {
return alarmInfoMapper.insertSelective(alarmInfo);
}
}

View File

@ -0,0 +1,22 @@
package com.aiit.xiuos.service.impl;
import com.aiit.xiuos.dao.mappers.QjdqElectricMapper;
import com.aiit.xiuos.model.QjdqElectric;
import com.aiit.xiuos.service.QjdqElectricService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class QjdqElectricServiceImpl implements QjdqElectricService {
@Autowired
QjdqElectricMapper qjdqElectricMapper;
@Override
public int updateElectric(QjdqElectric qjdqElectric) {
return qjdqElectricMapper.updateByPrimaryKeySelective(qjdqElectric);
}
@Override
public QjdqElectric selectElectric(int id) {
return qjdqElectricMapper.selectByPrimaryKey(id);
}
}

View File

@ -0,0 +1,153 @@
package com.aiit.xiuos.socket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint(value = "/websocket/qjdq/{clientId}")
@Component
@Slf4j
public class QJDQWebSocketServer {
/**
* 静态变量用来记录当前在线连接数应该把它设计成线程安全的
*/
private static int onlineCount = 0;
/**
* concurrent包的线程安全Set用来存放每个客户端对应的MyWebSocket对象
*/
public static ConcurrentHashMap<String, QJDQWebSocketServer> webSocketSet = new ConcurrentHashMap<String, QJDQWebSocketServer>();
public HashMap<String,Integer> cntofParam=new HashMap<String,Integer>();
public HashMap<String,Integer> numofAccount=new HashMap<String,Integer>();
/**
* 与某个客户端的连接会话需要通过它来给客户端发送数据
*/
private Session session;
/**
* 传过来的id
*/
private String name = "";
/**
* 连接建立成功调用的方法*/
@OnOpen
public void onOpen(@PathParam(value = "clientId") String clientId, Session session) {
//接收到发送消息的人员编号
name = clientId;
this.session = session;
/**加入set中*/
webSocketSet.put(clientId,this);
/**在线数加1*/
addOnlineCount();
log.info("有新连接"+clientId+"加入!当前在线人数为" + getOnlineCount());
try {
sendMessage(clientId+"-连接已建立-");
} catch (IOException e) {
log.error("IO异常");
}
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
if (name != null && name != "") {
/** 从set中删除 */
webSocketSet.remove(name);
/** 在线数减1 */
subOnlineCount();
log.info("有一连接"+name+"关闭!当前在线人数为" + getOnlineCount());
}
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息*/
@OnMessage
public void onMessage(String message, Session session) {
log.info("来自客户端的消息:" + message);
try {
this.sendMessage("收到!");
} catch (IOException e) {
log.error(e.getMessage());
}
}
/**
* 发生错误时调用
* **/
@OnError
public void onError(Session session, Throwable error) {
log.error("发生错误");
error.printStackTrace();
}
public void sendMessage(String message) throws IOException {
synchronized (session) {
getSession().getBasicRemote().sendText(message);
}
}
/**
* 给指定的人发送消息
* @param message
*/
public void sendToMessageById(String id,String message) {
try {
if (webSocketSet.get(id) != null) {
webSocketSet.get(id).sendMessage(message);
} else {
System.out.println("webSocketSet中没有此key不推送消息");
log.info("webSocketSet中没有此key不推送消息");
}
} catch (IOException e) {
log.error(e.getMessage());
}
}
/**
* 群发自定义消息
* */
public static void sendInfo(String message) {
try {
for (Map.Entry<String, QJDQWebSocketServer> entry : webSocketSet.entrySet()) {
String name = entry.getKey();
log.info("发送信息至客户端:"+name);
QJDQWebSocketServer value = entry.getValue();
value.sendMessage(message);
}
}catch(IOException e){
log.error(e.getMessage());
}
}
public Session getSession() {
return session;
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
QJDQWebSocketServer.onlineCount++;
}
public static synchronized void subOnlineCount() {
QJDQWebSocketServer.onlineCount--;
}
}

View File

@ -9,7 +9,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint(value = "/websocket/{clientId}")
@ServerEndpoint(value = "/websocket/jxsd/{clientId}")
@Component
@Slf4j
public class WebSocketServer {
@ -41,7 +41,6 @@ public class WebSocketServer {
* 连接建立成功调用的方法*/
@OnOpen
public void onOpen(@PathParam(value = "clientId") String clientId, Session session) {
//接收到发送消息的人员编号
name = clientId;
this.session = session;
@ -49,12 +48,11 @@ public class WebSocketServer {
webSocketSet.put(clientId,this);
/**在线数加1*/
addOnlineCount();
System.out.println("有新连接"+clientId+"加入!当前在线人数为" + getOnlineCount());
log.info("有新连接"+clientId+"加入!当前在线人数为" + getOnlineCount());
try {
sendMessage(clientId+"-连接已建立-");
} catch (IOException e) {
System.out.println("IO异常");
log.error("IO异常");
}
}
@ -68,7 +66,6 @@ public class WebSocketServer {
webSocketSet.remove(name);
/** 在线数减1 */
subOnlineCount();
System.out.println("有一连接关闭!当前在线人数为" + getOnlineCount());
log.info("有一连接"+name+"关闭!当前在线人数为" + getOnlineCount());
}
}
@ -79,7 +76,6 @@ public class WebSocketServer {
* @param message 客户端发送过来的消息*/
@OnMessage
public void onMessage(String message, Session session) {
System.out.println("来自客户端的消息:" + message);
log.info("来自客户端的消息:" + message);
try {
this.sendMessage("收到!");
@ -93,7 +89,7 @@ public class WebSocketServer {
* **/
@OnError
public void onError(Session session, Throwable error) {
System.out.println("发生错误");
log.error("发生错误");
error.printStackTrace();
}
@ -124,7 +120,7 @@ public class WebSocketServer {
/**
* 群发自定义消息
* */
public static void sendInfo(String message) throws IOException {
public static void sendInfo(String message) {
try {
for (Map.Entry<String, WebSocketServer> entry : webSocketSet.entrySet()) {
String name = entry.getKey();

View File

@ -8,7 +8,7 @@ spring:
nama: xiuosiot
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://115.238.53.59:5432/xiuosiot
url: jdbc:postgresql://localhost:5432/xiuosiot
username: xiuosiot
password: 123456
hikari:
@ -20,7 +20,7 @@ spring:
connection-test-query: select 'x'
pool-name: xiuosiots
password: 123456
jdbc-url: jdbc:postgresql://115.238.53.59:5432/xiuosiot
jdbc-url: jdbc:postgresql://localhost:5432/xiuosiot
# 发送邮件配置
mail:

View File

@ -0,0 +1,509 @@
<?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.QjdqElectricMapper">
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.QjdqElectric">
<constructor>
<idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="electric2" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric3" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric4" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric5" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric6" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric7" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric8" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric9" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric10" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric11" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric12" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric13" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric14" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric15" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric16" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric17" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric18" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric19" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric20" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric21" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric22" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric23" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric24" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric25" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric26" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric27" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric28" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric29" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric30" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric31" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric32" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric33" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric34" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric35" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric36" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric37" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric38" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric39" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="electric40" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
</constructor>
</resultMap>
<sql id="Base_Column_List">
id, electric2, electric3, electric4, electric5, electric6, electric7, electric8,
electric9, electric10, electric11, electric12, electric13, electric14, electric15,
electric16, electric17, electric18, electric19, electric20, electric21, electric22,
electric23, electric24, electric25, electric26, electric27, electric28, electric29,
electric30, electric31, electric32, electric33, electric34, electric35, electric36,
electric37, electric38, electric39, electric40
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from qjdq_electric
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from qjdq_electric
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.aiit.xiuos.model.QjdqElectric">
insert into qjdq_electric (id, electric2, electric3,
electric4, electric5, electric6,
electric7, electric8, electric9,
electric10, electric11, electric12,
electric13, electric14, electric15,
electric16, electric17, electric18,
electric19, electric20, electric21,
electric22, electric23, electric24,
electric25, electric26, electric27,
electric28, electric29, electric30,
electric31, electric32, electric33,
electric34, electric35, electric36,
electric37, electric38, electric39,
electric40)
values (#{id,jdbcType=INTEGER}, #{electric2,jdbcType=NUMERIC}, #{electric3,jdbcType=NUMERIC},
#{electric4,jdbcType=NUMERIC}, #{electric5,jdbcType=NUMERIC}, #{electric6,jdbcType=NUMERIC},
#{electric7,jdbcType=NUMERIC}, #{electric8,jdbcType=NUMERIC}, #{electric9,jdbcType=NUMERIC},
#{electric10,jdbcType=NUMERIC}, #{electric11,jdbcType=NUMERIC}, #{electric12,jdbcType=NUMERIC},
#{electric13,jdbcType=NUMERIC}, #{electric14,jdbcType=NUMERIC}, #{electric15,jdbcType=NUMERIC},
#{electric16,jdbcType=NUMERIC}, #{electric17,jdbcType=NUMERIC}, #{electric18,jdbcType=NUMERIC},
#{electric19,jdbcType=NUMERIC}, #{electric20,jdbcType=NUMERIC}, #{electric21,jdbcType=NUMERIC},
#{electric22,jdbcType=NUMERIC}, #{electric23,jdbcType=NUMERIC}, #{electric24,jdbcType=NUMERIC},
#{electric25,jdbcType=NUMERIC}, #{electric26,jdbcType=NUMERIC}, #{electric27,jdbcType=NUMERIC},
#{electric28,jdbcType=NUMERIC}, #{electric29,jdbcType=NUMERIC}, #{electric30,jdbcType=NUMERIC},
#{electric31,jdbcType=NUMERIC}, #{electric32,jdbcType=NUMERIC}, #{electric33,jdbcType=NUMERIC},
#{electric34,jdbcType=NUMERIC}, #{electric35,jdbcType=NUMERIC}, #{electric36,jdbcType=NUMERIC},
#{electric37,jdbcType=NUMERIC}, #{electric38,jdbcType=NUMERIC}, #{electric39,jdbcType=NUMERIC},
#{electric40,jdbcType=NUMERIC})
</insert>
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.QjdqElectric">
insert into qjdq_electric
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="electric2 != null">
electric2,
</if>
<if test="electric3 != null">
electric3,
</if>
<if test="electric4 != null">
electric4,
</if>
<if test="electric5 != null">
electric5,
</if>
<if test="electric6 != null">
electric6,
</if>
<if test="electric7 != null">
electric7,
</if>
<if test="electric8 != null">
electric8,
</if>
<if test="electric9 != null">
electric9,
</if>
<if test="electric10 != null">
electric10,
</if>
<if test="electric11 != null">
electric11,
</if>
<if test="electric12 != null">
electric12,
</if>
<if test="electric13 != null">
electric13,
</if>
<if test="electric14 != null">
electric14,
</if>
<if test="electric15 != null">
electric15,
</if>
<if test="electric16 != null">
electric16,
</if>
<if test="electric17 != null">
electric17,
</if>
<if test="electric18 != null">
electric18,
</if>
<if test="electric19 != null">
electric19,
</if>
<if test="electric20 != null">
electric20,
</if>
<if test="electric21 != null">
electric21,
</if>
<if test="electric22 != null">
electric22,
</if>
<if test="electric23 != null">
electric23,
</if>
<if test="electric24 != null">
electric24,
</if>
<if test="electric25 != null">
electric25,
</if>
<if test="electric26 != null">
electric26,
</if>
<if test="electric27 != null">
electric27,
</if>
<if test="electric28 != null">
electric28,
</if>
<if test="electric29 != null">
electric29,
</if>
<if test="electric30 != null">
electric30,
</if>
<if test="electric31 != null">
electric31,
</if>
<if test="electric32 != null">
electric32,
</if>
<if test="electric33 != null">
electric33,
</if>
<if test="electric34 != null">
electric34,
</if>
<if test="electric35 != null">
electric35,
</if>
<if test="electric36 != null">
electric36,
</if>
<if test="electric37 != null">
electric37,
</if>
<if test="electric38 != null">
electric38,
</if>
<if test="electric39 != null">
electric39,
</if>
<if test="electric40 != null">
electric40,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="electric2 != null">
#{electric2,jdbcType=NUMERIC},
</if>
<if test="electric3 != null">
#{electric3,jdbcType=NUMERIC},
</if>
<if test="electric4 != null">
#{electric4,jdbcType=NUMERIC},
</if>
<if test="electric5 != null">
#{electric5,jdbcType=NUMERIC},
</if>
<if test="electric6 != null">
#{electric6,jdbcType=NUMERIC},
</if>
<if test="electric7 != null">
#{electric7,jdbcType=NUMERIC},
</if>
<if test="electric8 != null">
#{electric8,jdbcType=NUMERIC},
</if>
<if test="electric9 != null">
#{electric9,jdbcType=NUMERIC},
</if>
<if test="electric10 != null">
#{electric10,jdbcType=NUMERIC},
</if>
<if test="electric11 != null">
#{electric11,jdbcType=NUMERIC},
</if>
<if test="electric12 != null">
#{electric12,jdbcType=NUMERIC},
</if>
<if test="electric13 != null">
#{electric13,jdbcType=NUMERIC},
</if>
<if test="electric14 != null">
#{electric14,jdbcType=NUMERIC},
</if>
<if test="electric15 != null">
#{electric15,jdbcType=NUMERIC},
</if>
<if test="electric16 != null">
#{electric16,jdbcType=NUMERIC},
</if>
<if test="electric17 != null">
#{electric17,jdbcType=NUMERIC},
</if>
<if test="electric18 != null">
#{electric18,jdbcType=NUMERIC},
</if>
<if test="electric19 != null">
#{electric19,jdbcType=NUMERIC},
</if>
<if test="electric20 != null">
#{electric20,jdbcType=NUMERIC},
</if>
<if test="electric21 != null">
#{electric21,jdbcType=NUMERIC},
</if>
<if test="electric22 != null">
#{electric22,jdbcType=NUMERIC},
</if>
<if test="electric23 != null">
#{electric23,jdbcType=NUMERIC},
</if>
<if test="electric24 != null">
#{electric24,jdbcType=NUMERIC},
</if>
<if test="electric25 != null">
#{electric25,jdbcType=NUMERIC},
</if>
<if test="electric26 != null">
#{electric26,jdbcType=NUMERIC},
</if>
<if test="electric27 != null">
#{electric27,jdbcType=NUMERIC},
</if>
<if test="electric28 != null">
#{electric28,jdbcType=NUMERIC},
</if>
<if test="electric29 != null">
#{electric29,jdbcType=NUMERIC},
</if>
<if test="electric30 != null">
#{electric30,jdbcType=NUMERIC},
</if>
<if test="electric31 != null">
#{electric31,jdbcType=NUMERIC},
</if>
<if test="electric32 != null">
#{electric32,jdbcType=NUMERIC},
</if>
<if test="electric33 != null">
#{electric33,jdbcType=NUMERIC},
</if>
<if test="electric34 != null">
#{electric34,jdbcType=NUMERIC},
</if>
<if test="electric35 != null">
#{electric35,jdbcType=NUMERIC},
</if>
<if test="electric36 != null">
#{electric36,jdbcType=NUMERIC},
</if>
<if test="electric37 != null">
#{electric37,jdbcType=NUMERIC},
</if>
<if test="electric38 != null">
#{electric38,jdbcType=NUMERIC},
</if>
<if test="electric39 != null">
#{electric39,jdbcType=NUMERIC},
</if>
<if test="electric40 != null">
#{electric40,jdbcType=NUMERIC},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.QjdqElectric">
update qjdq_electric
<set>
<if test="electric2 != null">
electric2 = #{electric2,jdbcType=NUMERIC},
</if>
<if test="electric3 != null">
electric3 = #{electric3,jdbcType=NUMERIC},
</if>
<if test="electric4 != null">
electric4 = #{electric4,jdbcType=NUMERIC},
</if>
<if test="electric5 != null">
electric5 = #{electric5,jdbcType=NUMERIC},
</if>
<if test="electric6 != null">
electric6 = #{electric6,jdbcType=NUMERIC},
</if>
<if test="electric7 != null">
electric7 = #{electric7,jdbcType=NUMERIC},
</if>
<if test="electric8 != null">
electric8 = #{electric8,jdbcType=NUMERIC},
</if>
<if test="electric9 != null">
electric9 = #{electric9,jdbcType=NUMERIC},
</if>
<if test="electric10 != null">
electric10 = #{electric10,jdbcType=NUMERIC},
</if>
<if test="electric11 != null">
electric11 = #{electric11,jdbcType=NUMERIC},
</if>
<if test="electric12 != null">
electric12 = #{electric12,jdbcType=NUMERIC},
</if>
<if test="electric13 != null">
electric13 = #{electric13,jdbcType=NUMERIC},
</if>
<if test="electric14 != null">
electric14 = #{electric14,jdbcType=NUMERIC},
</if>
<if test="electric15 != null">
electric15 = #{electric15,jdbcType=NUMERIC},
</if>
<if test="electric16 != null">
electric16 = #{electric16,jdbcType=NUMERIC},
</if>
<if test="electric17 != null">
electric17 = #{electric17,jdbcType=NUMERIC},
</if>
<if test="electric18 != null">
electric18 = #{electric18,jdbcType=NUMERIC},
</if>
<if test="electric19 != null">
electric19 = #{electric19,jdbcType=NUMERIC},
</if>
<if test="electric20 != null">
electric20 = #{electric20,jdbcType=NUMERIC},
</if>
<if test="electric21 != null">
electric21 = #{electric21,jdbcType=NUMERIC},
</if>
<if test="electric22 != null">
electric22 = #{electric22,jdbcType=NUMERIC},
</if>
<if test="electric23 != null">
electric23 = #{electric23,jdbcType=NUMERIC},
</if>
<if test="electric24 != null">
electric24 = #{electric24,jdbcType=NUMERIC},
</if>
<if test="electric25 != null">
electric25 = #{electric25,jdbcType=NUMERIC},
</if>
<if test="electric26 != null">
electric26 = #{electric26,jdbcType=NUMERIC},
</if>
<if test="electric27 != null">
electric27 = #{electric27,jdbcType=NUMERIC},
</if>
<if test="electric28 != null">
electric28 = #{electric28,jdbcType=NUMERIC},
</if>
<if test="electric29 != null">
electric29 = #{electric29,jdbcType=NUMERIC},
</if>
<if test="electric30 != null">
electric30 = #{electric30,jdbcType=NUMERIC},
</if>
<if test="electric31 != null">
electric31 = #{electric31,jdbcType=NUMERIC},
</if>
<if test="electric32 != null">
electric32 = #{electric32,jdbcType=NUMERIC},
</if>
<if test="electric33 != null">
electric33 = #{electric33,jdbcType=NUMERIC},
</if>
<if test="electric34 != null">
electric34 = #{electric34,jdbcType=NUMERIC},
</if>
<if test="electric35 != null">
electric35 = #{electric35,jdbcType=NUMERIC},
</if>
<if test="electric36 != null">
electric36 = #{electric36,jdbcType=NUMERIC},
</if>
<if test="electric37 != null">
electric37 = #{electric37,jdbcType=NUMERIC},
</if>
<if test="electric38 != null">
electric38 = #{electric38,jdbcType=NUMERIC},
</if>
<if test="electric39 != null">
electric39 = #{electric39,jdbcType=NUMERIC},
</if>
<if test="electric40 != null">
electric40 = #{electric40,jdbcType=NUMERIC},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.QjdqElectric">
update qjdq_electric
set electric2 = #{electric2,jdbcType=NUMERIC},
electric3 = #{electric3,jdbcType=NUMERIC},
electric4 = #{electric4,jdbcType=NUMERIC},
electric5 = #{electric5,jdbcType=NUMERIC},
electric6 = #{electric6,jdbcType=NUMERIC},
electric7 = #{electric7,jdbcType=NUMERIC},
electric8 = #{electric8,jdbcType=NUMERIC},
electric9 = #{electric9,jdbcType=NUMERIC},
electric10 = #{electric10,jdbcType=NUMERIC},
electric11 = #{electric11,jdbcType=NUMERIC},
electric12 = #{electric12,jdbcType=NUMERIC},
electric13 = #{electric13,jdbcType=NUMERIC},
electric14 = #{electric14,jdbcType=NUMERIC},
electric15 = #{electric15,jdbcType=NUMERIC},
electric16 = #{electric16,jdbcType=NUMERIC},
electric17 = #{electric17,jdbcType=NUMERIC},
electric18 = #{electric18,jdbcType=NUMERIC},
electric19 = #{electric19,jdbcType=NUMERIC},
electric20 = #{electric20,jdbcType=NUMERIC},
electric21 = #{electric21,jdbcType=NUMERIC},
electric22 = #{electric22,jdbcType=NUMERIC},
electric23 = #{electric23,jdbcType=NUMERIC},
electric24 = #{electric24,jdbcType=NUMERIC},
electric25 = #{electric25,jdbcType=NUMERIC},
electric26 = #{electric26,jdbcType=NUMERIC},
electric27 = #{electric27,jdbcType=NUMERIC},
electric28 = #{electric28,jdbcType=NUMERIC},
electric29 = #{electric29,jdbcType=NUMERIC},
electric30 = #{electric30,jdbcType=NUMERIC},
electric31 = #{electric31,jdbcType=NUMERIC},
electric32 = #{electric32,jdbcType=NUMERIC},
electric33 = #{electric33,jdbcType=NUMERIC},
electric34 = #{electric34,jdbcType=NUMERIC},
electric35 = #{electric35,jdbcType=NUMERIC},
electric36 = #{electric36,jdbcType=NUMERIC},
electric37 = #{electric37,jdbcType=NUMERIC},
electric38 = #{electric38,jdbcType=NUMERIC},
electric39 = #{electric39,jdbcType=NUMERIC},
electric40 = #{electric40,jdbcType=NUMERIC}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>