智能安全帽bug修复
This commit is contained in:
parent
fb7d09cf09
commit
7303ab9ec7
@ -105,12 +105,10 @@ public class SafetyHatWSClient {
|
||||
Double yPoint = joData.getDouble("y_point");
|
||||
Long ctime = joData.getLong("c_time");
|
||||
Integer sosType = joData.getInteger("sos_type");
|
||||
String str = ParamEnum.getStr(ParamEnum.SafetyHatAlarmAlarmType.values(), sosType);
|
||||
SafetyHatAlarm alarm = new SafetyHatAlarm();
|
||||
alarm.setWorkerInfoId(dev.getWorkerInfoId());
|
||||
alarm.setDevSn(dev.getDevSn());
|
||||
alarm.setAlarmTime(new Date(ctime * 1000L));
|
||||
alarm.setAlarmInfo(str);
|
||||
alarm.setProjectSn(dev.getProjectSn());
|
||||
alarm.setAlarmType(sosType);
|
||||
alarm.setLatitude(yPoint);
|
||||
|
||||
@ -86,7 +86,6 @@ public class SafetyHatDayRecordController {
|
||||
@ApiOperation(value = "添加智能安全帽-日行数据信息", notes = "添加智能安全帽-日行数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SafetyHatDayRecord> add(@RequestBody SafetyHatDayRecord safetyHatDayRecord) {
|
||||
log.info("添加智能安全帽-日行数据信息:{}", JSON.toJSONString(safetyHatDayRecord));
|
||||
safetyHatDayRecordService.add(safetyHatDayRecord);
|
||||
return Result.ok();
|
||||
}
|
||||
@ -104,6 +103,14 @@ public class SafetyHatDayRecordController {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存智能安全帽-日行数据信息", notes = "保存智能安全帽-日行数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/saveData")
|
||||
public Result<SafetyHatDayRecord> saveData(@RequestBody SafetyHatDayRecord safetyHatDayRecord) {
|
||||
log.info("保存智能安全帽-日行数据信息:{}", JSON.toJSONString(safetyHatDayRecord));
|
||||
safetyHatDayRecordService.saveData(safetyHatDayRecord);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
|
||||
@ -20,4 +20,6 @@ public interface ISafetyHatDayRecordService extends IService<SafetyHatDayRecord>
|
||||
List<SafetyHatDayRecord> queryList(HashMap<String, Object> paramMap);
|
||||
|
||||
void add(SafetyHatDayRecord safetyHatDayRecord);
|
||||
|
||||
void saveData(SafetyHatDayRecord safetyHatDayRecord);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.zhgd.xmgl.modules.safetyhat.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendVo;
|
||||
import com.zhgd.xmgl.enums.ParamEnum;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatAlarm;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatAlarmMapper;
|
||||
@ -55,7 +56,7 @@ public class SafetyHatAlarmServiceImpl extends ServiceImpl<SafetyHatAlarmMapper,
|
||||
private QueryWrapper<SafetyHatAlarm> getQueryWrapper(HashMap<String, Object> paramMap) {
|
||||
String alias = "sha.";
|
||||
QueryWrapper<SafetyHatAlarm> queryWrapper = QueryGenerator.initPageQueryWrapper(SafetyHatAlarm.class, paramMap, alias);
|
||||
queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(SafetyHatAlarm::getId));
|
||||
queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(SafetyHatAlarm::getAlarmTime));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@ -70,6 +71,8 @@ public class SafetyHatAlarmServiceImpl extends ServiceImpl<SafetyHatAlarmMapper,
|
||||
if (dev == null) {
|
||||
throw new OpenAlertException("设备编号不正确");
|
||||
}
|
||||
String str = ParamEnum.getStr(ParamEnum.SafetyHatAlarmAlarmType.values(), safetyHatAlarm.getAlarmType());
|
||||
safetyHatAlarm.setAlarmInfo(str);
|
||||
safetyHatAlarm.setWorkerInfoId(dev.getWorkerInfoId());
|
||||
safetyHatAlarm.setProjectSn(dev.getProjectSn());
|
||||
safetyHatAlarm.setId(null);
|
||||
|
||||
@ -54,7 +54,7 @@ public class SafetyHatDataServiceImpl extends ServiceImpl<SafetyHatDataMapper, S
|
||||
private QueryWrapper<SafetyHatData> getQueryWrapper(HashMap<String, Object> paramMap) {
|
||||
String alias = "shd.";
|
||||
QueryWrapper<SafetyHatData> queryWrapper = QueryGenerator.initPageQueryWrapper(SafetyHatData.class, paramMap, alias);
|
||||
queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(SafetyHatData::getId));
|
||||
queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(SafetyHatData::getUploadTime));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@ -76,7 +76,6 @@ public class SafetyHatDataServiceImpl extends ServiceImpl<SafetyHatDataMapper, S
|
||||
safetyHatData.setProjectSn(dev.getProjectSn());
|
||||
safetyHatData.setId(null);
|
||||
safetyHatData.setWorkerInfoId(dev.getWorkerInfoId());
|
||||
safetyHatData.setUploadTime(new Date());
|
||||
baseMapper.insert(safetyHatData);
|
||||
}
|
||||
|
||||
|
||||
@ -1,26 +1,23 @@
|
||||
package com.zhgd.xmgl.modules.safetyhat.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDayRecord;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDayRecordMapper;
|
||||
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper;
|
||||
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDayRecordService;
|
||||
import com.zhgd.xmgl.util.DateUtils;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
|
||||
/**
|
||||
* @Description: 智能安全帽-日行数据
|
||||
* @author: pds
|
||||
@ -31,6 +28,8 @@ import com.zhgd.xmgl.util.RefUtil;
|
||||
public class SafetyHatDayRecordServiceImpl extends ServiceImpl<SafetyHatDayRecordMapper, SafetyHatDayRecord> implements ISafetyHatDayRecordService {
|
||||
@Autowired
|
||||
SafetyHatDevMapper safetyHatDevMapper;
|
||||
@Autowired
|
||||
SafetyHatDayRecordMapper safetyHatDayRecordMapper;
|
||||
|
||||
@Override
|
||||
public IPage<SafetyHatDayRecord> queryPageList(HashMap<String, Object> paramMap) {
|
||||
@ -57,6 +56,30 @@ public class SafetyHatDayRecordServiceImpl extends ServiceImpl<SafetyHatDayRecor
|
||||
baseMapper.insert(safetyHatDayRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData(SafetyHatDayRecord safetyHatDayRecord) {
|
||||
boolean b = DateUtils.isValidDateFormat(safetyHatDayRecord.getDay(), 1);
|
||||
if (!b) {
|
||||
throw new OpenAlertException("日期格式不正确");
|
||||
}
|
||||
SafetyHatDev dev = safetyHatDevMapper.selectOne(new LambdaQueryWrapper<SafetyHatDev>()
|
||||
.eq(SafetyHatDev::getDevSn, safetyHatDayRecord.getDevSn()));
|
||||
if (dev == null) {
|
||||
throw new OpenAlertException("设备编号不正确");
|
||||
}
|
||||
SafetyHatDayRecord record = safetyHatDayRecordMapper.selectOne(new LambdaQueryWrapper<SafetyHatDayRecord>()
|
||||
.eq(SafetyHatDayRecord::getDay, safetyHatDayRecord.getDay())
|
||||
.eq(SafetyHatDayRecord::getDevSn, safetyHatDayRecord.getDevSn())
|
||||
);
|
||||
safetyHatDayRecord.setProjectSn(dev.getProjectSn());
|
||||
safetyHatDayRecord.setId(null);
|
||||
if (record != null) {
|
||||
baseMapper.update(safetyHatDayRecord, new LambdaQueryWrapper<SafetyHatDayRecord>()
|
||||
.eq(SafetyHatDayRecord::getDevSn, safetyHatDayRecord.getDevSn()));
|
||||
} else {
|
||||
baseMapper.insert(safetyHatDayRecord);
|
||||
}
|
||||
}
|
||||
|
||||
private List<SafetyHatDayRecord> dealList(List<SafetyHatDayRecord> list) {
|
||||
return list;
|
||||
|
||||
@ -330,7 +330,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/xmgl/upload/uploadBase64").permitAll()
|
||||
.antMatchers("/xmgl/massReboundSurveyArea/getMassReboundSurveyArea").permitAll()
|
||||
.antMatchers("/xmgl/safetyHatData/add").permitAll()
|
||||
.antMatchers("/xmgl/safetyHatDayRecord/add").permitAll()
|
||||
.antMatchers("/xmgl/safetyHatDayRecord/saveData").permitAll()
|
||||
.antMatchers("/xmgl/safetyHatAlarm/add").permitAll()
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||
.anyRequest().authenticated() // 剩下所有的验证都需要验证.
|
||||
|
||||
@ -13,6 +13,8 @@ import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
@ -561,4 +563,28 @@ public class DateUtils {
|
||||
System.out.println(getNowWeekAllDayList());
|
||||
System.out.println(getDateTimeStrList(100, "HH:mm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否正确的日期格式:1:yyyy-MM-dd
|
||||
*
|
||||
* @param timeStr
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValidDateFormat(String timeStr, int type) {
|
||||
if (type == 1) {
|
||||
String datePattern = "\\d{4}-\\d{2}-\\d{2}";
|
||||
// 编译正则表达式模式
|
||||
Pattern pattern = Pattern.compile(datePattern);
|
||||
// 创建 Matcher 对象
|
||||
Matcher matcher = pattern.matcher(timeStr);
|
||||
// 检查是否匹配
|
||||
if (matcher.matches()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user