Commit a0f36d5d authored by Administrator's avatar Administrator

2023-11.25 增加浸润线 干滩等一下接口

2023.12.19 添加简易的登录过期
parent 4dc55a00
......@@ -132,7 +132,7 @@
<!-- 打包 -->
<build>
<finalName>MineTRS_new0.16</finalName>
<finalName>MineTRS_NEW</finalName>
<plugins>
<!-- 跳过单元测试 -->
<plugin>
......
......@@ -246,7 +246,7 @@ public class DrybeachequipinforController {
@ApiOperation(value = "在线设备统计")
@GetMapping("count")
public ResponseEntity<Object> getdryInfo(HttpServletRequest request) {
HashMap<String, Integer> map = drybeachequipinforService.getdyinfo(request);
HashMap<String, Object> map = drybeachequipinforService.getdyinfo(request);
return new ResponseEntity<>(new PageResult().success(map), HttpStatus.OK);
}
......
......@@ -185,6 +185,8 @@ public class MpData implements Serializable {
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@TableField(exist = false)
private Date jctime;
@TableField(exist = false)
private String difference;
}
......@@ -104,6 +104,14 @@ public class StData implements Serializable {
public Date jctime;
@TableField(exist = false)
public String danwei;
@TableField(exist = false)
public String jrxHoleTopElevation;
@TableField(exist = false)
public String jrxHoleBottomElevation;
@TableField(exist = false)
public String jrxTrepanning;
@TableField(exist = false)
public String jrxBurial;
/**
* 差值
......
......@@ -209,7 +209,8 @@ public class Drybeachequipinfor implements Serializable {
* 浸润线埋深
*/
@ApiModelProperty(value = "浸润线埋深")
private Double burial_depth;
@TableField(value = "hole_base_elevation")
private Double HoleBaseElevation;
/**
* 检验周期(天),单位是天,
......@@ -272,10 +273,6 @@ public class Drybeachequipinfor implements Serializable {
*/
@ApiModelProperty(value = "干滩安全超高,只用于干滩监测")
private String gtsafeheight;
/**
* .浸润线设备到开孔位置的距离
*/
private Double jrx_burial;
/**
* 浸润线开孔深度
*/
......@@ -285,8 +282,12 @@ public class Drybeachequipinfor implements Serializable {
* 设备距离坡面左侧距离(单位:m)
*/
private Double jrx_coord_x;
/**
*
*/
private Double jrx_burial;
@TableField(value = "hole_bottom_elevation")
public String jrxHoleBottomElevation;
private Integer sensortype;
/**
* 排水量流速(单位是m/s),只用于排水量,表示流速
......
......@@ -40,6 +40,10 @@ public class JrxDissect implements Serializable {
* 剖面编号
*/
private String code;
/**
*
*/
private String type;
private Double height;
......
......@@ -22,6 +22,6 @@ public interface DmDataMapper extends BaseMapper<DmData> {
@Select("select a.* from tb_dm_data a join (select max(time) as time ,sensorid from tb_dm_data GROUP BY sensorid,DATE_FORMAT( time, '%y-%m-%d' ))b on a.time =b.time and a.sensorid=b.sensorid where a.sensorid=#{sensorid} and a.time>=#{start} and a.time <=#{end}GROUP BY DATE_FORMAT(a.time,'%y-%m-%d')")
List<DmData> dealmonth(String sensorid, String start, String end);
@Select(value = "select b.eqdanwei as eqdanwei,b.equipname as sensorname,b.equipno equipno,a.dispA as dispA,a.dispB as dispB , DATE_FORMAT(a.time,'%Y-%m-%d %H:%i:%m') as time from tb_dm_data a join tb_drybeachequipinfor b on a.sensorid=b.equipno join (select max(time) as time ,sensorid from tb_dm_data GROUP BY sensorid) c on a.time =c.time and a.sensorid=c.sensorid where a.datasource =1 and b.tailingid=#{tailingid} ORDER BY time DESC ")
@Select(value = "select b.eqdanwei as eqdanwei,b.sensortype,b.equipname as sensorname,b.equipno equipno,a.dispA as dispA,a.dispB as dispB , DATE_FORMAT(a.time,'%Y-%m-%d %H:%i:%m') as time from tb_dm_data a join tb_drybeachequipinfor b on a.sensorid=b.equipno join (select max(time) as time ,sensorid from tb_dm_data GROUP BY sensorid) c on a.time =c.time and a.sensorid=c.sensorid where a.datasource =1 and b.tailingid=#{tailingid} ORDER BY time DESC ")
List<HashMap<String, Object>> real(String tailingid);
}
package me.zhengjie.gemho.mapper.data;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.gemho.entity.data.StData;
import me.zhengjie.gemho.x_datavo.tab.visual.JrxDryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.HashMap;
......@@ -19,10 +22,13 @@ import java.util.List;
*/
@Mapper
public interface StDataMapper extends BaseMapper<StData> {
@Select("select a.* from tb_sl_data a join (select max(time) as time ,sensorid from tb_sl_data GROUP BY sensorid,DATE_FORMAT( time, '%y-%m-%d' ))b on a.time =b.time and a.sensorid=b.sensorid where a.sensorid=#{deviceid} and a.time>=#{start} and a.time <=#{end}GROUP BY DATE_FORMAT(a.time,'%y-%m-%d')")
@Select(value = "SELECT a.*,b.jrx_trepanning as jrxTrepanning ,b.hole_base_elevation as jrxHoleTopElevation,b.hole_bottom_elevation as jrxHoleBottomElevation, b.jrx_burial as jrxBurial from `tb_st_data` a left join tb_drybeachequipinfor b on a.sensorid =b.equipno ${ew.customSqlSegment} ")
Page<StData> pageAll(Page<StData> page, @Param("ew") Wrapper wrapper);
@Select("select a.* from tb_st_data a join (select max(time) as time ,sensorid from tb_st_data GROUP BY sensorid,DATE_FORMAT( time, '%y-%m-%d' ))b on a.time =b.time and a.sensorid=b.sensorid where a.sensorid=#{deviceid} and a.time>=#{start} and a.time <=#{end}GROUP BY DATE_FORMAT(a.time,'%y-%m-%d')")
List<StData> dealmonth(String deviceid, String start, String end);
@Select(value = "select b.eqdanwei as eqdanwei,b.equipno equipno,b.equipname as sensorname,a.stage as stage,a.depth as depth ,DATE_FORMAT(a.time,'%Y-%m-%d %H:%i:%m') as time from tb_st_data a join tb_drybeachequipinfor b on a.sensorid=b.equipno join (select max(time) as time ,sensorid from tb_sl_data GROUP BY sensorid) c on a.time =c.time and a.sensorid=c.sensorid where a.datasource =1 and b.tailingid=#{tailingid} ORDER BY time DESC")
@Select(value = "select b.eqdanwei as eqdanwei,b.equipno equipno,b.equipname as sensorname,a.stage as stage,a.depth as depth ,DATE_FORMAT(a.time,'%Y-%m-%d %H:%i:%m') as time from tb_st_data a join tb_drybeachequipinfor b on a.sensorid=b.equipno join (select max(time) as time ,sensorid from tb_st_data GROUP BY sensorid) c on a.time =c.time and a.sensorid=c.sensorid where a.datasource =1 and b.tailingid=#{tailingid} ORDER BY time DESC")
List<HashMap<String, Object>> real(String tailingid);
List<JrxDryVo> getStageDepth(List<String> sensorids);
......
......@@ -13,6 +13,7 @@ import org.apache.ibatis.annotations.Update;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
......@@ -90,6 +91,7 @@ public interface DrybeachequipinforMapper extends BaseMapper<Drybeachequipinfor>
List<HashMap<String, Object>> dryStateCount(String tailingid);
Integer dryUnCount(String tailingid);
List<Map> dryUnDetails(String tailingid);
int enforceOnline(String equipno);
}
......@@ -488,6 +488,7 @@ public class DbDataServiceImpl extends ServiceImpl<DbDataMapper, DbData> impleme
map.put("人工监测项", dbdata.getJcziitemname());
map.put("人工监测值", dbdata.getJcvalue());
map.put("人工监测时间", dbdata.getJctime());
map.put("人工监测差异", dbdata.getDifference());
}
list.add(map);
}
......
......@@ -44,6 +44,7 @@ public class DmDataServiceImpl extends ServiceImpl<DmDataMapper, DmData> impleme
@Autowired
private DrybeachequipinforMapper drybeachequipinforMapper;
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
@Override
public DataVo day(String date, String values, String deviceid, String subitem) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......@@ -185,7 +186,7 @@ public class DmDataServiceImpl extends ServiceImpl<DmDataMapper, DmData> impleme
String name = field.getName();
if (dmdatum.equals(name)) {
hashMap.put(dmdatum, Double.parseDouble((String) field.get(data1)));
rgdate=sdf2.parse(sdf2.format(data1.getTime()));
rgdate = sdf2.parse(sdf2.format(data1.getTime()));
}
}
}
......@@ -277,7 +278,7 @@ public class DmDataServiceImpl extends ServiceImpl<DmDataMapper, DmData> impleme
for (String dmdatum : dmdata) {
if (dmdatum.equals(field.getName())) {
hashMap.put(dmdatum, Double.parseDouble((String) field.get(data1)));
rgdate=sdf2.parse(sdf2.format(data1.getTime()));
rgdate = sdf2.parse(sdf2.format(data1.getTime()));
}
}
}
......@@ -367,7 +368,7 @@ public class DmDataServiceImpl extends ServiceImpl<DmDataMapper, DmData> impleme
Integer integer = sensorType.get(record.getSensorid());
record.setSensorname(noName.get(record.getSensorid()));
record.setDanwei(noDan.get(record.getSensorid()));
if(!ObjectUtils.isEmpty(integer)){
if (!ObjectUtils.isEmpty(integer)) {
if (3 == integer) {
String dispB = record.getDispB();
record.setCjvalue(dispB);
......@@ -406,7 +407,13 @@ public class DmDataServiceImpl extends ServiceImpl<DmDataMapper, DmData> impleme
realDataVo.setTime(time);
realDataVo.setEquipno(equipno);
realDataVo.setData(real);
String sensortype = real.get("sensortype") + "";
if ("3".equals(sensortype)) {
Object keys2 = dbdata.get("dmdata1");
realDataVo.setKeys(keys2);
}else{
realDataVo.setKeys(keys1);
}
realDataVo.setName(sensorname);
realDataVo.setType(equipno1);
realDataVo.setEqdanwei(eqdanwei);
......@@ -471,10 +478,10 @@ public class DmDataServiceImpl extends ServiceImpl<DmDataMapper, DmData> impleme
ImgDataVo imgDataVo = new ImgDataVo();
if (3 == sensortype) {
//处理封装数据
imgDataVo = ServiceUtil.deal("dmdata1", sensorname, dmData, danwei);
imgDataVo = ServiceUtil.deal("dmdata1", sensorname, dmData, danwei,dataQueryCriteria.getCode());
} else {
//处理封装数据
imgDataVo = ServiceUtil.deal("dmdata", sensorname, dmData, danwei);
imgDataVo = ServiceUtil.deal("dmdata", sensorname, dmData, danwei,dataQueryCriteria.getCode());
}
return imgDataVo;
}
......
......@@ -47,6 +47,7 @@ public class MpDataServiceImpl extends ServiceImpl<MpDataMapper, MpData> impleme
@Autowired
private ArtificialDataMapper artificialDataMapper;
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
@Override
public DataVo day(String date, String values, String deviceid) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......@@ -194,7 +195,7 @@ public class MpDataServiceImpl extends ServiceImpl<MpDataMapper, MpData> impleme
for (Field field : data1.getClass().getDeclaredFields()) {
if (mpdata.equals(field.getName())) {
hashMap.put(mpdata, Double.parseDouble((String) field.get(data1)));
rgdate=sdf2.parse(sdf2.format(data1.getTime()));
rgdate = sdf2.parse(sdf2.format(data1.getTime()));
}
}
}
......@@ -290,7 +291,7 @@ public class MpDataServiceImpl extends ServiceImpl<MpDataMapper, MpData> impleme
for (Field field : data1.getClass().getDeclaredFields()) {
if (mpdata.equals(field.getName())) {
hashMap.put(mpdata, Double.parseDouble((String) field.get(data1)));
rgdate=sdf2.parse(sdf2.format(data1.getTime()));
rgdate = sdf2.parse(sdf2.format(data1.getTime()));
}
}
}
......@@ -388,6 +389,26 @@ public class MpDataServiceImpl extends ServiceImpl<MpDataMapper, MpData> impleme
record.setJcziitemname(jczx.get(artificialDataPageRecord.getJczx_id()));
record.setJcvalue(artificialDataPageRecord.getValue());
record.setJctime(time1);
//计算差值
if (checkArtificial.equals("14")) {
Double aDouble = Double.valueOf(record.getDispx());
Double aDouble1 = Double.valueOf(record.getJcvalue());
Double difference = aDouble - aDouble1;
double v = (difference < 0) ? -difference : difference;
record.setDifference(String.valueOf(v));
} else if (checkArtificial.equals("22")) {
Double aDouble = Double.valueOf(record.getDispy());
Double aDouble1 = Double.valueOf(record.getJcvalue());
Double difference = aDouble - aDouble1;
double v = (difference < 0) ? -difference : difference;
record.setDifference(String.valueOf(v));
} else if (checkArtificial.equals("23")) {
Double aDouble = Double.valueOf(record.getDisph());
Double aDouble1 = Double.valueOf(record.getJcvalue());
Double difference = aDouble - aDouble1;
double v = (difference < 0) ? -difference : difference;
record.setDifference(String.format("%.3f", v));
}
}
}
}
......@@ -488,7 +509,7 @@ public class MpDataServiceImpl extends ServiceImpl<MpDataMapper, MpData> impleme
String danwei = noDan.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("mpdata1", sensorname, mpData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("mpdata1", sensorname, mpData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......@@ -512,12 +533,16 @@ public class MpDataServiceImpl extends ServiceImpl<MpDataMapper, MpData> impleme
map.put("x变化量", mpDatum.getDispx());
map.put("y变化量", mpDatum.getDispy());
map.put("z变化量", mpDatum.getDisph());
map.put("大地坐标x", mpDatum.getVelocityx());
map.put("大地坐标y", mpDatum.getVelocityy());
map.put("大地坐标h", mpDatum.getVelocityh());
map.put("是否报警", mpDatum.getState() == 0 ? "否" : "是");
map.put("监测时间", mpDatum.getTime());
if (result) {
map.put("人工监测项", mpDatum.getJcziitemname());
map.put("人工监测值", mpDatum.getJcvalue());
map.put("人工监测时间", mpDatum.getJctime());
map.put("人工监测差异", mpDatum.getDifference());
}
list.add(map);
}
......
......@@ -365,7 +365,7 @@ public class PslDataServiceImpl extends ServiceImpl<PslDataMapper, PslData> impl
String sensorname = noName.get(dataQueryCriteria.getCode());
String danwei = noDan.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("psldata1", sensorname, pslData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("psldata1", sensorname, pslData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......
......@@ -375,7 +375,7 @@ public class RgDataServiceImpl extends ServiceImpl<RgDataMapper, RgData> impleme
String sensorname = noName.get(dataQueryCriteria.getCode());
String danwei = noDan.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("rgdata", sensorname, rgData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("rgdata", sensorname, rgData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......
......@@ -406,7 +406,7 @@ public class SlDataServiceImpl extends ServiceImpl<SlDataMapper, SlData> impleme
String sensorname = noName.get(dataQueryCriteria.getCode());
String danwei = noDan.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("sldata1", sensorname, pslData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("sldata1", sensorname, pslData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......
......@@ -372,7 +372,7 @@ public class StDataServiceImpl extends ServiceImpl<StDataMapper, StData> impleme
QueryWrapper<StData> stDataQueryWrapper = new QueryWrapper<>();
ServiceUtil.dbquery(stDataQueryWrapper, dataQueryCriteria, request);
Page<StData> stDataPage = new Page<>(page + 1, size);
stDataPage = stDataMapper.selectPage(stDataPage, stDataQueryWrapper);
stDataPage = stDataMapper.pageAll(stDataPage, stDataQueryWrapper);
List<StData> records = stDataPage.getRecords();
HashMap<String, Object> hashMap = new HashMap<>();
//获取编号名字map
......@@ -403,7 +403,7 @@ public class StDataServiceImpl extends ServiceImpl<StDataMapper, StData> impleme
record.setJcvalue(artificialDataPageRecord.getValue());
record.setJctime(time1);
//计算差值
Double aDouble = Double.valueOf(record.getStage());
Double aDouble = Double.valueOf(record.getDepth());
Double aDouble1 = Double.valueOf(record.getJcvalue());
Double difference = aDouble-aDouble1;
double v = (difference < 0) ? -difference : difference;
......@@ -445,7 +445,7 @@ public class StDataServiceImpl extends ServiceImpl<StDataMapper, StData> impleme
String sensorname = noName.get(dataQueryCriteria.getCode());
String danwei = noDan.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("stdata", sensorname, stData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("stdata", sensorname, stData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......@@ -474,6 +474,7 @@ public class StDataServiceImpl extends ServiceImpl<StDataMapper, StData> impleme
map.put("人工监测项", stDatum.getJcziitemname());
map.put("人工监测值", stDatum.getJcvalue());
map.put("人工监测时间", stDatum.getJctime());
map.put("人工监测差异", stDatum.getDifference());
}
list.add(map);
}
......
......@@ -378,7 +378,7 @@ public class WpbDataServiceImpl extends ServiceImpl<WpbDataMapper, WpbData> impl
String sensorname = noName.get(dataQueryCriteria.getCode());
String danwei = noDan.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("wpbdata", sensorname, wpbData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("wpbdata", sensorname, wpbData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......
......@@ -387,7 +387,7 @@ public class WtDataServiceImpl extends ServiceImpl<WtDataMapper, WtData> impleme
String danwei = noDan.get(dataQueryCriteria.getCode());
String sensorname = noName.get(dataQueryCriteria.getCode());
//处理封装数据
ImgDataVo mpdata = ServiceUtil.deal("wtdata", sensorname, wtData, danwei);
ImgDataVo mpdata = ServiceUtil.deal("wtdata", sensorname, wtData, danwei,dataQueryCriteria.getCode());
return mpdata;
}
......@@ -407,7 +407,7 @@ public class WtDataServiceImpl extends ServiceImpl<WtDataMapper, WtData> impleme
Map<String, Object> map = new LinkedHashMap<>();
map.put("设备名称", wtDatum.getSensorname());
map.put("设备ID", wtDatum.getSensorid());
map.put("水位", wtDatum.getStage());
map.put("压力(MPa)", wtDatum.getStage());
map.put("是否报警", wtDatum.getState() == 0 ? "否" : "是");
map.put("监测时间", wtDatum.getTime());
if (result) {
......@@ -418,7 +418,7 @@ public class WtDataServiceImpl extends ServiceImpl<WtDataMapper, WtData> impleme
list.add(map);
}
}
FileUtil.downloadExcel(list, "监测数据: 库水位", response);
FileUtil.downloadExcel(list, "监测数据: 压力", response);
}
@Override
......
......@@ -25,7 +25,12 @@ public interface DrybeachequipinforService extends IService<Drybeachequipinfor>
ArrayList<HashMap<String, String>> getDryCode();
HashMap<String, Integer> getdyinfo(HttpServletRequest request);
/**
* 大屏 设备在线离线统计
* @param request
* @return
*/
HashMap<String, Object> getdyinfo(HttpServletRequest request);
/**
* 删除设备并且删除检测项和配置信息
......
......@@ -53,7 +53,7 @@ public class DrybeachequipinforServiceImpl extends ServiceImpl<Drybeachequipinfo
String gettailno = onlineUserService.gettailno(currentUsername, request);
drybeachequipinforQueryWrapper.eq("tailingid", gettailno);
ServiceUtil.query(drybeachequipinforQueryWrapper, dataQueryCriteria);
drybeachequipinforQueryWrapper.ne("equipname","基准点");
drybeachequipinforQueryWrapper.ne("equipname", "基准点");
Page<Drybeachequipinfor> drybeachequipinforPage = new Page<>(page + 1, size);
drybeachequipinforPage = drybeachequipinforMapper.selectPage(drybeachequipinforPage, drybeachequipinforQueryWrapper);
hashMap.put("list", drybeachequipinforPage.getRecords());
......@@ -83,27 +83,22 @@ public class DrybeachequipinforServiceImpl extends ServiceImpl<Drybeachequipinfo
}
@Override
public HashMap<String, Integer> getdyinfo(HttpServletRequest request) {
/* String tailInfoNo = TailNoForInfoUtil.getTailInfoNo(request);if(tailInfoNo==null){return null;}
int onlinecount = 0;
ArrayList<Integer> getonlinecount = drybeachequipinforMapper.getonlinecount(tailInfoNo);
for (Integer integer : getonlinecount) {
onlinecount += integer;
}
int getallcount = drybeachequipinforMapper.getallcount(tailInfoNo);
int unlinecount = getallcount - onlinecount;*/
public HashMap<String, Object> getdyinfo(HttpServletRequest request) {
//获取不在线数量
String tailInfoNo = TailNoForInfoUtil.getTailInfoNo(request);
if (tailInfoNo == null) {
return null;
}
Integer unlinecount = drybeachequipinforMapper.dryUnCount(tailInfoNo);
List<Map> maps = drybeachequipinforMapper.dryUnDetails(tailInfoNo);
int unlinecount = maps.size();
//获取所有设备
int getallcount = drybeachequipinforMapper.getallcount(tailInfoNo);
int onlinecount = getallcount - unlinecount;
HashMap<String, Integer> map = new HashMap<>();
HashMap<String, Object> map = new HashMap<>();
map.put("online", onlinecount);
map.put("unline", unlinecount);
map.put("unlineList", maps);
map.put("all", getallcount);
return map;
}
......
package me.zhengjie.gemho.util;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
......@@ -160,4 +164,22 @@ public class DateUtil {
LocalDateTime localDateTime = instant.atZone(zone).toLocalDateTime();
return localDateTime;
}
public static LocalDateTime getNetworkTime(String webUrl) {
try {
URL url = new URL(webUrl);
URLConnection conn = url.openConnection();
conn.connect();
long dateL = conn.getDate();
Date date = new Date(dateL);
LocalDateTime localDateTime = dateToLocalDateTime(date);
return localDateTime;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
\ No newline at end of file
package me.zhengjie.gemho.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ObjectUtils;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -16,18 +22,106 @@ import java.util.Map;
public class ReadJsonFileUtil {
public static HashMap<String, List<Map>> getMap(String path) {
path = "/json/" + path + ".json";
HashMap<String, List<Map>> map = new LinkedHashMap();
try {
//路径
ClassPathResource classPathResource = new ClassPathResource(path);
String externalFilePath = System.getProperty("user.dir") + "\\jsons\\" + path + ".json"; // 外部文件路径
String resourceName = "\\json\\" + path + ".json"; // 资源文件名
String json = readJsonFile(externalFilePath, resourceName);
if (json != null) {
// 处理读取到的 JSON 数据
System.out.println(json);
HashMap<String, List<Map>> stringListHashMap = parseJsonToHashMap(json);
return stringListHashMap;
} else {
System.err.println("JSON file not found.");
return null;
}
}
public static void main(String[] args) {
String externalFilePath = System.getProperty("user.dir") + "\\json\\realdata1.json"; // 外部文件路径
String resourceName = "\\json\\realdata.json"; // 资源文件名
String json = readJsonFile(externalFilePath, resourceName);
if (json != null) {
// 处理读取到的 JSON 数据
System.out.println(json);
} else {
System.err.println("JSON file not found.");
}
}
public static String readJsonFile(String externalFilePath, String resourceName) {
String json = null;
// 优先尝试读取外部文件
if (externalFilePath != null && !externalFilePath.isEmpty()) {
json = readExternalJsonFile(externalFilePath);
}
if (ObjectUtils.isEmpty(json)) {
// 如果外部文件不存在或读取失败,则读取资源文件
System.out.println("外部文件不存在,读取 内部资源 ");
json = readResourceJsonFile(resourceName);
} else {
System.out.println("外部文件读取完毕");
}
return json;
}
public static String readResourceJsonFile(String resourceName) {
ClassPathResource classPathResource = new ClassPathResource(resourceName);
//读取文件信息
try {
String str = IOUtils.toString(new InputStreamReader(classPathResource.getInputStream(), "UTF-8"));
//转换为Map对象
map = JSONObject.parseObject(str, LinkedHashMap.class);
return str;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static String readExternalJsonFile(String filePath) {
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
String line;
StringBuilder jsonContent = new StringBuilder();
while ((line = reader.readLine()) != null) {
jsonContent.append(line);
}
return jsonContent.toString();
} catch (IOException e) {
// 文件不存在或读取失败
return null;
}
}
public static HashMap<String, List<Map>> parseJsonToHashMap(String json) {
try {
JSONObject jsonObject = JSON.parseObject(json);
HashMap<String, List<Map>> resultMap = new HashMap<>();
// 遍历 JSON 对象的键值对
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
String key = entry.getKey();
JSONArray jsonArray = (JSONArray) entry.getValue();
List<Map> list = new ArrayList<>();
// 遍历 JSON 数组中的元素,将其转换为 Map
for (Object obj : jsonArray) {
if (obj instanceof Map) {
list.add((Map<String, Object>) obj);
}
}
resultMap.put(key, list);
}
return resultMap;
} catch (Exception e) {
e.printStackTrace();
return null;
}
return map;
}
}
\ No newline at end of file
......@@ -664,6 +664,62 @@ public class ServiceUtil {
return imgDataVo;
}
/**
* 处理图表数据
*
* @param str
* @param sensorname
* @param data
* @return
*/
public static ImgDataVo deal(String str, String sensorname, List<?> data, String danwei, String deviceid) {
//获取json 数据
HashMap<String, List<Map>> realdata = ReadJsonFileUtil.getMap("realdata");
List<Map> dbdata = realdata.get(str);
//返回对象
ImgDataVo imgDataVo = new ImgDataVo();
ArrayList<Result> results = new ArrayList<>();
//遍历数据
if (!ObjectUtils.isEmpty(data)) {
for (Object dbDatum : data) {
Date time = null;
HashMap map = new HashMap<String, Object>();
for (Field declaredField : dbDatum.getClass().getDeclaredFields()) {
for (Map dbmap : dbdata) {
String key = dbmap.get("key").toString();
if (declaredField.getName().equals(key)) {
try {
map.put(declaredField.getName(), declaredField.get(dbDatum));
break;
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
if (declaredField.getName().equals("time")) {
try {
time = (Date) declaredField.get(dbDatum);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
Result result = new Result();
result.setDate(time);
result.setValues(map);
results.add(result);
}
}
HashMap<String, Object> dealalarm = DataUtil.dealalarm(deviceid);
imgDataVo.setLists(results);
imgDataVo.setSensorname(sensorname);
imgDataVo.setNames(dbdata);
imgDataVo.setDanwei(danwei);
imgDataVo.setAlarm(dealalarm);
return imgDataVo;
}
/**
* 获取编码-名的map
*
......
......@@ -28,6 +28,11 @@ public class JrxDissectDto implements Serializable {
*/
private String name;
/**
* 剖面名称
*/
private String type;
private Double height;
......
package me.zhengjie.gemho.x_datavo.tab.visual;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.time.LocalDateTime;
......@@ -27,6 +28,8 @@ public class JrxDryVo {
*/
private Double jrx_coord_x;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime time;
private String name;
}
......@@ -25,6 +25,8 @@ import me.zhengjie.annotation.rest.AnonymousDeleteMapping;
import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.annotation.rest.AnonymousPostMapping;
import me.zhengjie.config.RsaProperties;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.gemho.util.DateUtil;
import me.zhengjie.gemho.util.PostOrPutResult;
import me.zhengjie.gemho.x_generato.modules.security.config.bean.LoginCodeEnum;
import me.zhengjie.gemho.x_generato.modules.security.config.bean.LoginProperties;
......@@ -43,6 +45,7 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -51,6 +54,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -78,6 +84,19 @@ public class AuthorizationController {
@ApiOperation("登录授权")
@AnonymousPostMapping(value = "/login")
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
//获取当前计算机时间
LocalDateTime networkTime = DateUtil.getNetworkTime("http://www.baidu.com");
if (ObjectUtils.isEmpty(networkTime)){
networkTime=LocalDateTime.now();
}
//和日期比较
String expirationTimeString="2023-12-26 07:00:00";
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime expirationTime = LocalDateTime.parse(expirationTimeString,dateTimeFormatter);
boolean after = networkTime.isAfter(expirationTime);
if (after){
throw new BadRequestException("用户已过期 请联系厂商!!!");
}
boolean b = userService.JuUserName(authUser.getUsername());
if (!b) {
return new ResponseEntity<>(new PostOrPutResult().noUserFailed(), HttpStatus.OK);
......
......@@ -72,7 +72,7 @@
"stdata": [
{
"key": "stage",
"name": "水位"
"name": "水位1"
},
{
"key": "depth",
......
......@@ -9,7 +9,8 @@
c.jrx_burial,
c.jrx_trepanning,
c.jrx_coord_x,
c.equipno as sensorid
c.equipno as sensorid,
c.equipname as name
FROM
(
SELECT CONVERT
......
......@@ -30,6 +30,15 @@
and (DATE_FORMAT(datarealtime, '%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 2 Hour), '%Y-%m-%d %H:%i:%s')
or datarealtime is Null) and equipname !='基准点'
</select>
<select id="dryUnDetails" resultType="map">
SELECT equipname as equipname,
equipno as equipno,
IFNULL(DATE_FORMAT(datarealtime, '%Y-%m-%d %H:%i:%s'), '111') as datarealtime
FROM tb_drybeachequipinfor
where tailingid = #{tailingid}
and (DATE_FORMAT(datarealtime, '%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 2 Hour), '%Y-%m-%d %H:%i:%s')
or datarealtime is Null) and equipname !='基准点'
</select>
<update id="enforceOnline">
update tb_drybeachequipinfor
set initialstateno = '1'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment