7 files added
18 files modified
New file |
| | |
| | | package com.moral.common.util; |
| | | |
| | | import com.moral.entity.charts.TimePeriod; |
| | | import com.moral.entity.charts.TimeUnits; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public class ReportTimeFormat { |
| | | public static String toMySqlTimeFormat(TimeUnits timeUnits){ |
| | | switch (timeUnits){ |
| | | case YEAR: return "%Y"; |
| | | case MONTH: return "%Y-%m"; |
| | | case DAY: return "%Y-%m-%d"; |
| | | case HOUR: return "%Y-%m-%d/%H"; |
| | | case MINUTE:return "%Y-%m-%d/%H:%i"; |
| | | } |
| | | return "%Y-%m-%d%H:%i:%s"; |
| | | } |
| | | public static String toMySqlActualTimeFormat(TimeUnits timeUnits){ |
| | | switch (timeUnits){ |
| | | case YEAR: return "%Y"; |
| | | case MONTH: return "%m"; |
| | | case DAY: return "%d"; |
| | | case HOUR: return "%H"; |
| | | case MINUTE:return "%i"; |
| | | } |
| | | return "%s"; |
| | | } |
| | | public static List<String> makeTimeList(TimePeriod timePeriod){ |
| | | Calendar start = Calendar.getInstance(); |
| | | start.setTime(timePeriod.getStartTime()); |
| | | Calendar end = Calendar.getInstance(); |
| | | end.setTime(timePeriod.getEndTime()); |
| | | List<String> timeList = new ArrayList<>(); |
| | | String formatStyle = ""; |
| | | int timeUnit = 0; |
| | | switch (timePeriod.getTimeUnits()){ |
| | | case YEAR: formatStyle ="yyyy"; |
| | | timeUnit = Calendar.YEAR;break; |
| | | case MONTH: formatStyle ="yyyy-MM"; |
| | | timeUnit = Calendar.MONTH;break; |
| | | case DAY: formatStyle ="yyyy-MM-dd"; |
| | | timeUnit = Calendar.DAY_OF_YEAR;break; |
| | | case HOUR: formatStyle ="yyyy-MM-dd/HH"; |
| | | timeUnit = Calendar.HOUR;break; |
| | | case MINUTE: formatStyle ="yyyy-MM-dd/HH:mm"; |
| | | timeUnit = Calendar.MINUTE;break; |
| | | } |
| | | do{ |
| | | String time = dateToString(start.getTime(),formatStyle); |
| | | timeList.add(time); |
| | | start.add(timeUnit,1); |
| | | } |
| | | while (start.getTimeInMillis()<end.getTimeInMillis()); |
| | | return timeList; |
| | | } |
| | | /**"yyyy-MM-dd hh:mm:ss" |
| | | * 把指定的date类型时间转换为指定格式的字符串 |
| | | * @param date |
| | | * @return |
| | | */ |
| | | private static String dateToString(Date date,String formatStyle) { |
| | | SimpleDateFormat format = new SimpleDateFormat(formatStyle); |
| | | String dateFormat = format.format(date); |
| | | return dateFormat; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.bean.ResultBean; |
| | | import com.moral.entity.Organization; |
| | | import com.moral.security.auth.JwtAuthenticationToken; |
| | | import com.moral.security.model.UserContext; |
| | | import com.moral.service.OrganizationService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | List<Organization> organizations = organizationService.getOrganizationsByName(name); |
| | | return new ResultBean<List<Organization>>(organizations); |
| | | } |
| | | |
| | | @GetMapping("get-my-org") |
| | | public ResultBean<Organization> getMyOrganization(JwtAuthenticationToken token){ |
| | | UserContext userContext = token.getPrincipal(); |
| | | Organization organization = organizationService.getOrganizationsById(userContext.getOrganizationId()); |
| | | return new ResultBean<>(organization); |
| | | } |
| | | } |
| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.entity.charts.PairData;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | |
| | | Map<String, List<Object>> demo = historyMinutelyService.getCompareReport(parameters);
|
| | | return new ResultBean<Map<String,List<Object>>>(demo);
|
| | | }
|
| | |
|
| | | @PostMapping("line-chart")
|
| | | public ResultBean <List<List<PairData>>> lineChart(@RequestBody LineChartCriteria lineChartCriteria){
|
| | | return new ResultBean<>(historyMinutelyService.queryLineChartDateByCrieria(lineChartCriteria));
|
| | | }
|
| | | @GetMapping("excel")
|
| | | public ResultBean<Boolean> getExcelReport(HttpServletRequest request,HttpServletResponse response) throws Exception {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
New file |
| | |
| | | package com.moral.entity.charts; |
| | | |
| | | public enum AreaRange { |
| | | PROVINCE,CITY,AREA,MONITORPOINT,DEVICE |
| | | } |
New file |
| | |
| | | package com.moral.entity.charts; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class DataCondition { |
| | | private TimeUnits timeUnits;//单位 |
| | | private Integer actualTime;//实际时间 |
| | | private AreaRange areaRange;//区域范围 |
| | | private Integer areaRangeId;//区域范围的ID |
| | | } |
New file |
| | |
| | | package com.moral.entity.charts; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class LineChartCriteria { |
| | | private String sensorKey;//传感器类别 |
| | | private TimePeriod timePeriod;//时间区间 |
| | | private List<DataCondition> dataConditions;//数据取样条件 |
| | | } |
New file |
| | |
| | | package com.moral.entity.charts; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class PairData { |
| | | private String category ; |
| | | private Double Value; |
| | | } |
New file |
| | |
| | | package com.moral.entity.charts; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class TimePeriod { |
| | | private TimeUnits timeUnits;//区间单位 |
| | | private Date startTime;//开始时间 |
| | | private Date endTime;//结束时间 |
| | | } |
New file |
| | |
| | | package com.moral.entity.charts; |
| | | |
| | | public enum TimeUnits { |
| | | YEAR,MONTH,DAY,HOUR,MINUTE |
| | | } |
| | |
| | | package com.moral.mapper;
|
| | |
|
| | | import com.moral.entity.charts.DataCondition;
|
| | | import com.moral.entity.charts.PairData;
|
| | | import com.moral.entity.charts.TimePeriod;
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | Map<String, Double> getSersionAvgByDevice(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getMonitorPointOrDeviceAvgData(Map<String, Object> parameters);
|
| | |
|
| | | List<PairData> selectLineChartDateByCrieria(@Param("sensorKey") String sensorKey, @Param("timePeriod") TimePeriod timePeriod, @Param("dataCondition") DataCondition dataCondition);
|
| | | } |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private RequestMatcher processingMatcher; |
| | | |
| | | public SkipPathRequestMatcher(List<String> pathsToSkip, String processingPath) { |
| | | Assert.notNull(pathsToSkip); |
| | | pathsToSkip = Optional.of(pathsToSkip) |
| | | .orElseThrow(()-> new NullPointerException("In Method SkipPathRequestMatcher,Param pathsToSkip can't be null.")); |
| | | List<RequestMatcher> m = pathsToSkip.stream().map(path -> new AntPathRequestMatcher(path)).collect(Collectors.toList()); |
| | | matchers = new OrRequestMatcher(m); |
| | | processingMatcher = new AntPathRequestMatcher(processingPath); |
| | |
| | | package com.moral.security.auth.login; |
| | | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.moral.security.config.JwtSettings; |
| | | import com.moral.security.model.UserContext; |
| | | import com.moral.security.model.token.JwtToken; |
| | | import com.moral.security.model.token.JwtTokenFactory; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | public class LoginAwareAuthenticationSuccessHandler implements AuthenticationSuccessHandler { |
| | | private final ObjectMapper mapper; |
| | | private final JwtTokenFactory tokenFactory; |
| | | |
| | | @Autowired |
| | | private JwtSettings jwtSettings; |
| | | @Autowired |
| | | public LoginAwareAuthenticationSuccessHandler(final ObjectMapper mapper, final JwtTokenFactory tokenFactory) { |
| | | this.mapper = mapper; |
| | |
| | | Map<String, String> tokenMap = new HashMap<String, String>(); |
| | | tokenMap.put("token", accessToken.getToken()); |
| | | tokenMap.put("refreshToken", refreshToken.getToken()); |
| | | |
| | | tokenMap.put("expiredTime",jwtSettings.getTokenExpirationTime().toString()); |
| | | response.setStatus(HttpStatus.OK.value()); |
| | | response.setContentType(MediaType.APPLICATION_JSON_VALUE); |
| | | mapper.writeValue(response.getWriter(), tokenMap); |
| | |
| | | @EnableWebSecurity |
| | | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| | | public static final String AUTHENTICATION_HEADER_NAME = "X-Authorization"; |
| | | public static final String REFRESH_TOKEN_HEADER_NAME = "X-Refrsh-Token"; |
| | | public static final String AUTHENTICATION_PARAM_NAME = "_token"; |
| | | public static final String AUTHENTICATION_URL = "/auth/login"; |
| | | public static final String REFRESH_TOKEN_URL = "/auth/token"; |
| | |
| | | @RequestMapping(value="/auth/token", method= RequestMethod.GET, produces={ MediaType.APPLICATION_JSON_VALUE }) |
| | | public @ResponseBody |
| | | JwtToken refreshToken(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
| | | String tokenPayload = tokenExtractor.extract(request.getHeader(WebSecurityConfig.AUTHENTICATION_HEADER_NAME)); |
| | | String tokenPayload = tokenExtractor.extract(request.getHeader(WebSecurityConfig.REFRESH_TOKEN_HEADER_NAME)); |
| | | |
| | | RawAccessJwtToken rawToken = new RawAccessJwtToken(tokenPayload); |
| | | RefreshToken refreshToken = RefreshToken.create(rawToken, jwtSettings.getTokenSigningKey()).orElseThrow(() -> new InvalidJwtToken()); |
| | |
| | | package com.moral.service;
|
| | |
|
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.entity.charts.PairData;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | Map<String, Object> getMonthAverageBySensor(Map<String, Object> parameters);
|
| | |
|
| | |
|
| | | List<List<PairData>> queryLineChartDateByCrieria(LineChartCriteria lineChartCriteria);
|
| | | }
|
| | |
| | | public void deleteByIds(Integer... ids);
|
| | |
|
| | | List<Organization> getOrganizationsByName(String name);
|
| | |
|
| | | public Organization getOrganizationsById(int id);
|
| | | }
|
| | |
| | | public Optional queryValueByOrganizationId(int organizationId) { |
| | | String key = RedisUtils.getAlarmKey(organizationId); |
| | | AlarmConfigValue alarmConfigValue = redisUtils.get(key,new TypeReference<AlarmConfigValue>(){}); |
| | | if(alarmConfigValue==null){ |
| | | if(alarmConfigValue==null) { |
| | | AlarmConfig alarmConfig = alarmConfigMapper.selectByOrganizationId(organizationId); |
| | | if(alarmConfig!=null&&alarmConfig.getValue()!=null){ |
| | | alarmConfigValue = alarmConfig.getValue(); |
| | | }else{ |
| | | if (alarmConfig != null && alarmConfig.getValue() != null) { |
| | | alarmConfigValue = alarmConfig.getValue(); |
| | | } else { |
| | | alarmConfigValue = getDefaultAlarmConfigValue(); |
| | | } |
| | | } |
| | |
| | | package com.moral.service.impl; |
| | | |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.util.ExampleUtil; |
| | | import com.moral.common.util.MyBatisBaseMapUtil; |
| | | import com.moral.entity.DeviceVersion; |
| | | import com.moral.entity.DeviceVersionSensor; |
| | | import com.moral.mapper.DeviceVersionMapper; |
| | | import com.moral.mapper.DeviceVersionSensorMapper; |
| | | import com.moral.service.DeviceVersionService; |
| | | import org.springframework.data.mongodb.core.aggregation.ArrayOperators; |
| | | import org.springframework.stereotype.Service; |
| | | import tk.mybatis.mapper.entity.Example; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | import java.util.concurrent.ExecutorCompletionService;
|
| | | import java.util.concurrent.ExecutorService;
|
| | | import java.util.concurrent.Executors;
|
| | | import java.util.stream.Collector;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.moral.common.util.ReportTimeFormat;
|
| | | import com.moral.entity.charts.DataCondition;
|
| | | import com.moral.entity.charts.LineChartCriteria;
|
| | | import com.moral.entity.charts.PairData;
|
| | | import com.moral.entity.charts.TimePeriod;
|
| | | import org.apache.commons.lang3.time.DateUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据线性表单的条件规则,获取多条线性表单数据
|
| | | * @param lineChartCriteria
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public List<List<PairData>> queryLineChartDateByCrieria(LineChartCriteria lineChartCriteria){
|
| | | String sensorKey = lineChartCriteria.getSensorKey();
|
| | | TimePeriod timePeriod = lineChartCriteria.getTimePeriod();
|
| | | List<DataCondition> dataConditionList = lineChartCriteria.getDataConditions();
|
| | | List<List<PairData>> list = new ArrayList<>();
|
| | | dataConditionList.forEach(item -> {
|
| | | List<PairData> pairDataList = queryOneLineChartDateByCrieria(sensorKey,timePeriod,item);
|
| | | list.add(pairDataList);
|
| | | });
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据线性表单的条件规则,获取一条线性表单数据
|
| | | * @param sensorKey
|
| | | * @param timePeriod
|
| | | * @param dataCondition
|
| | | * @return
|
| | | */
|
| | | public List<PairData> queryOneLineChartDateByCrieria(String sensorKey, TimePeriod timePeriod, DataCondition dataCondition){
|
| | | List<String> timeList = ReportTimeFormat.makeTimeList(timePeriod);
|
| | | List<PairData> lineChartDatas = historyMinutelyMapper.selectLineChartDateByCrieria(sensorKey,timePeriod,dataCondition);
|
| | | List<PairData> lineChartDatasWithEmpty = new ArrayList<>();
|
| | | int m = 0;
|
| | | int dataLength = lineChartDatas.size()-1;
|
| | | m = dataLength>-1?0:-1;
|
| | | if(m>-1){
|
| | | for(int n =0;n<timeList.size();n++){
|
| | | String time = timeList.get(n);
|
| | | if(m>-1){
|
| | | PairData pairData = lineChartDatas.get(m);
|
| | | String keyTime = pairData.getCategory();
|
| | | if(time.equals(keyTime)){
|
| | | lineChartDatasWithEmpty.add(pairData);
|
| | | m = m<dataLength ? m+1 : -1;
|
| | | }else{
|
| | | lineChartDatasWithEmpty.add(generateEmptyData(time));
|
| | | }
|
| | | }else {
|
| | | lineChartDatasWithEmpty.add(generateEmptyData(time));
|
| | | }
|
| | |
|
| | | }
|
| | | }else{
|
| | | fillEmptyDataToList(timeList,lineChartDatasWithEmpty);
|
| | | }
|
| | | return lineChartDatasWithEmpty;
|
| | | }
|
| | | private PairData generateEmptyData(String time) {
|
| | | PairData pairData = new PairData();
|
| | | pairData.setCategory(time);
|
| | | pairData.setValue(null);
|
| | | return pairData;
|
| | | }
|
| | | private void fillEmptyDataToList(List<String> timeList,List<PairData> lineChartDatasWithEmpty){
|
| | | timeList.forEach( time ->{
|
| | | PairData pairData = generateEmptyData(time);
|
| | | lineChartDatasWithEmpty.add(pairData);
|
| | | });
|
| | | }
|
| | | }
|
| | |
| | | return organizations;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Organization getOrganizationsById(int id) {
|
| | | Example example = new Example(ENTITY_CLASS);
|
| | | example.or().andEqualTo("id",id);
|
| | | List<Organization> organizationList = organizationMapper.selectWithAreaNameByExample(example);
|
| | | return organizationList.size()>0?organizationList.get(0):null;
|
| | | }
|
| | | }
|
| | |
| | | public List<Sensor> queryAll(){ |
| | | return sensorMapper.selectByExample(null); |
| | | } |
| | | public PageBean queryByPageBean(PageBean pageBean){ |
| | | public PageBean<Sensor> queryByPageBean(PageBean pageBean){ |
| | | return MyBatisBaseMapUtil.queryPage(sensorMapper,pageBean,ENTITY_CLASS); |
| | | } |
| | | @Override |
| | |
| | | |
| | | server: |
| | | port: 8001 |
| | | port: 8080 |
| | | session-timeout: 30 |
| | | tomcat.max-threads: 0 |
| | | tomcat.uri-encoding: UTF-8 |
| | | jsp-servlet: |
| | | init-parameters: |
| | | development: true |
| | | |
| | | spring: |
| | | thymeleaf: |
| | | cache: false |
| | | datasource: |
| | | url: jdbc:mysql://47.96.19.115:3306/monitor_db?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC |
| | | url: jdbc:mysql://47.96.26.152:3306/monitor_db?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC |
| | | username: root |
| | | password: xOlx8z9L7Pt6y9YI |
| | | #driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | min-idle: 0 |
| | | |
| | | |
| | | data: |
| | | mongodb: |
| | | uri: mongodb://47.96.171.62:27017/monitor |
| | | # data: |
| | | # mongodb: |
| | | # uri: mongodb://47.96.171.62:27017/monitor |
| | | |
| | | mybatis: |
| | | mapper-locations: classpath*:/mapper/*Mapper.xml |
| | |
| | | spring.profiles: default |
| | | |
| | | moral.security.jwt: |
| | | tokenExpirationTime: 15 # Number of minutes |
| | | tokenExpirationTime: 5 # Number of minutes |
| | | refreshTokenExpTime: 60 # Minutes |
| | | tokenIssuer: http://monitor.7drlb.com |
| | | tokenSigningKey: xm9EV6Hy5RAFL8EEACIDAwQus |
| | | tokenSigningKey: xm9EV6Hy5RAFL8EEACIDAwQus |
| | | |
| | |
| | | <?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.moral.mapper.HistoryMinutelyMapper"> |
| | |
|
| | | <select id="getSersionAvgByDevice" resultType="java.util.LinkedHashMap">
|
| | | <mapper namespace="com.moral.mapper.HistoryMinutelyMapper">
|
| | | <resultMap id="PairDataResultMap" type="com.moral.entity.charts.PairData" >
|
| | | <result column="format_time" property="category" jdbcType="VARCHAR" />
|
| | | <result column="value" property="value" jdbcType="DOUBLE" />
|
| | | </resultMap>
|
| | | <select id="getSersionAvgByDevice" resultType="java.util.Map">
|
| | | SELECT
|
| | | ${sensorKeyColumn}
|
| | | FROM
|
| | |
| | | AND time < #{end}
|
| | | </select>
|
| | |
|
| | | <select id="getMonitorPointOrDeviceAvgData" resultType="java.util.LinkedHashMap">
|
| | | <select id="getMonitorPointOrDeviceAvgData" resultType="java.util.Map">
|
| | | SELECT
|
| | | DATE_FORMAT(time, #{typeFormat}) time,
|
| | | ${sensorKeyColumn}
|
| | |
| | | ORDER BY
|
| | | time
|
| | | </select>
|
| | | |
| | | <select id="selectLineChartDateByCrieria" resultMap="PairDataResultMap">
|
| | | SELECT
|
| | | <if test='"MINUTE"!=dataCondition.timeUnits.toString()'>
|
| | | AVG(json->'$.${sensorKey}[0]')
|
| | | </if>
|
| | | <if test='"MINUTE"==dataCondition.timeUnits.toString()'>
|
| | | json->'$.${sensorKey}[0]'
|
| | | </if>
|
| | | as value,
|
| | | DATE_FORMAT(time,'${@com.moral.common.util.ReportTimeFormat@toMySqlTimeFormat(timePeriod.timeUnits)}') as format_time
|
| | | FROM
|
| | | `history_minutely` hmi
|
| | | <where>
|
| | | and hmi.time >= #{timePeriod.startTime}
|
| | | and hmi.time <![CDATA[<=]]> #{timePeriod.endTime}
|
| | | <if test="dataCondition.actualTime != null">
|
| | | and DATE_FORMAT(time, '${@com.moral.common.util.ReportTimeFormat@toMySqlActualTimeFormat(dataCondition.timeUnits)}') = #{dataCondition.actualTime}
|
| | | </if>
|
| | | and hmi.mac in (
|
| | | select mac from device dev
|
| | | join monitor_point mpt on dev.monitor_point_id = mpt.id
|
| | | <where>
|
| | | <if test='"DEVICE"==dataCondition.areaRange.toString()'>
|
| | | and dev.id = #{dataCondition.areaRangeId}
|
| | | </if>
|
| | | <if test='"MONITORPOINT"==dataCondition.areaRange.toString()'>
|
| | | and mpt.id = #{dataCondition.areaRangeId}
|
| | | </if>
|
| | | <if test='"PROVINCE"==dataCondition.areaRange.toString()'>
|
| | | and mpt.provice_code = #{dataCondition.areaRangeId}
|
| | | </if>
|
| | | <if test='"CITY"==dataCondition.areaRange.toString()'>
|
| | | and mpt.city_code = #{dataCondition.areaRangeId}
|
| | | </if>
|
| | | <if test='"AREA"==dataCondition.areaRange.toString()'>
|
| | | and mpt.area_code = #{dataCondition.areaRangeId}
|
| | | </if>
|
| | | </where>
|
| | | )
|
| | | </where>
|
| | | <if test='"MINUTE"!=dataCondition.timeUnits.toString()'>
|
| | | GROUP BY format_time
|
| | | </if>
|
| | | ORDER BY format_time asc
|
| | | </select>
|
| | | </mapper> |
| | |
| | | import com.moral.entity.Device; |
| | | import com.moral.entity.DeviceAdjustValue; |
| | | import com.moral.entity.alarm.AlarmConfig; |
| | | import com.moral.entity.charts.*; |
| | | import com.moral.security.auth.login.LoginMode; |
| | | import com.moral.security.model.UserContext; |
| | | import org.junit.Test; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | public class JavaBeanToJsonOutPrint { |
| | | @Test |
| | | public void jsonOutPrintTest(){ |
| | | UserContext userContext = UserContext.create("312", LoginMode.Andriod,1,new ArrayList<>()); |
| | | // adjustValue.setCreateTime(new Date()); |
| | | // adjustValue.setUpdateTime(new Date()); |
| | | // adjustValue.setId(0); |
| | | // Map<String,Float> value = new HashMap(); |
| | | // value.put("e1", (float) 1.2); |
| | | // adjustValue.setValue(value); |
| | | String json = "{\"createTime\":1516342989358,\"deviceId\":null,\"id\":0,\"updateTime\":1516342989358,\"value\":{\"e1\":1.2}}"; |
| | | // UserContext userContext = UserContext.create("312", LoginMode.Andriod,1,new ArrayList<>()); |
| | | //// adjustValue.setCreateTime(new Date()); |
| | | //// adjustValue.setUpdateTime(new Date()); |
| | | //// adjustValue.setId(0); |
| | | //// Map<String,Float> value = new HashMap(); |
| | | //// value.put("e1", (float) 1.2); |
| | | //// adjustValue.setValue(value); |
| | | // String json = "{\"createTime\":1516342989358,\"deviceId\":null,\"id\":0,\"updateTime\":1516342989358,\"value\":{\"e1\":1.2}}"; |
| | | // LineChartCriteria lineChartCriteria = new LineChartCriteria(); |
| | | // List<DataCondition> dataConditions = new ArrayList<>(); |
| | | // DataCondition dataCondition = new DataCondition(); |
| | | // dataCondition.setActualTime(1); |
| | | // dataCondition.setAreaRange(AreaRange.AREA); |
| | | // dataCondition.setAreaRangeId(1); |
| | | // dataCondition.setTimeUnits(TimeUnits.DAY); |
| | | // dataConditions.add(dataCondition); |
| | | // lineChartCriteria.setDataConditions(dataConditions); |
| | | // lineChartCriteria.setSensorKey("e1"); |
| | | // TimePeriod timePeriod = new TimePeriod(); |
| | | // timePeriod.setEndTime(new Date()); |
| | | // timePeriod.setStartTime(new Date()); |
| | | // timePeriod.setTimeUnits(TimeUnits.DAY); |
| | | // lineChartCriteria.setTimePeriod(timePeriod); |
| | | // Map map = JSON.parseObject("{\"e1\":0.0}"); |
| | | String json1 = JSON.toJSONString(userContext); |
| | | String str = "{\"sensorKey\":\"e1\",\"timePeriod\":{\"startTime\":\"2018-03-09T07:53:53.463Z\",\"endTime\":\"2018-03-09T07:53:53.463Z\",\"timeUnits\":\"DAY\"},\"dataConditions\":[{\"timeUnits\":\"DAY\",\"actualTime\":null,\"areaRange\":\"AREA\",\"areaRangeId\":320583}]}"; |
| | | LineChartCriteria lineChartCriteria = JSON.parseObject(str,LineChartCriteria.class); |
| | | // TimePeriod timePeriod = JSON.parseObject(str,TimePeriod.class); |
| | | String json1 = JSON.toJSONString(lineChartCriteria); |
| | | System.out.printf("\n\n\n\n"); |
| | | System.out.printf(json1); |
| | | System.out.printf("\n\n\n\n"); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.test.context.junit4.SpringRunner; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @RunWith(SpringRunner.class) |
| | | @SpringBootTest |
| | |
| | | @Test |
| | | public void contextLoads() { |
| | | } |
| | | @Resource |
| | | private BCryptPasswordEncoder encoder; |
| | | @Test |
| | | public void testEncoder(){ |
| | | String hash = encoder.encode("123456"); |
| | | System.out.printf("\n============================\n"); |
| | | System.out.printf("hash:"+hash); |
| | | // Boolean result = encoder.matches("123456",hash); |
| | | |
| | | // System.out.printf("result:"+result); |
| | | System.out.printf("\n============================\n"); |
| | | } |
| | | } |