bug修复
This commit is contained in:
parent
00bd41f195
commit
bc940987a4
@ -84,4 +84,8 @@ public class MechanicalEquipmentPositionDev implements Serializable {
|
|||||||
@ApiModelProperty(value = "司机名称")
|
@ApiModelProperty(value = "司机名称")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private java.lang.String driverName;
|
private java.lang.String driverName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "在线状态(0.离线 1.在线)")
|
||||||
|
private java.lang.Integer online;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,15 +16,19 @@ import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
|||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionAlarm;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionAlarm;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionData;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionData;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionDev;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionDev;
|
||||||
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.MechanicalEquipmentPositionFence;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.vo.PositionAddData;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.entity.vo.PositionAddData;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionAlarmMapper;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionAlarmMapper;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionDataMapper;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionDataMapper;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionDevMapper;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionDevMapper;
|
||||||
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.mapper.MechanicalEquipmentPositionFenceMapper;
|
||||||
import com.zhgd.xmgl.modules.mechanicalequipmentposition.service.IMechanicalEquipmentPositionDataService;
|
import com.zhgd.xmgl.modules.mechanicalequipmentposition.service.IMechanicalEquipmentPositionDataService;
|
||||||
import com.zhgd.xmgl.util.PageUtil;
|
import com.zhgd.xmgl.util.PageUtil;
|
||||||
import com.zhgd.xmgl.util.RefUtil;
|
import com.zhgd.xmgl.util.RefUtil;
|
||||||
|
import com.zhgd.xmgl.util.RegionUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -50,6 +54,10 @@ public class MechanicalEquipmentPositionDataServiceImpl extends ServiceImpl<Mech
|
|||||||
private MechanicalEquipmentPositionDevMapper mechanicalEquipmentPositionDevMapper;
|
private MechanicalEquipmentPositionDevMapper mechanicalEquipmentPositionDevMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MechanicalEquipmentPositionAlarmMapper alarmMapper;
|
private MechanicalEquipmentPositionAlarmMapper alarmMapper;
|
||||||
|
@Autowired
|
||||||
|
private MechanicalEquipmentPositionFenceMapper mechanicalEquipmentPositionFenceMapper;
|
||||||
|
@Autowired
|
||||||
|
private MechanicalEquipmentPositionAlarmServiceImpl mechanicalEquipmentPositionAlarmService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<MechanicalEquipmentPositionData> queryPageList(HashMap<String, Object> paramMap) {
|
public IPage<MechanicalEquipmentPositionData> queryPageList(HashMap<String, Object> paramMap) {
|
||||||
@ -91,6 +99,41 @@ public class MechanicalEquipmentPositionDataServiceImpl extends ServiceImpl<Mech
|
|||||||
mechanicalEquipmentPositionData.setProjectSn(dev.getProjectSn());
|
mechanicalEquipmentPositionData.setProjectSn(dev.getProjectSn());
|
||||||
mechanicalEquipmentPositionData.setId(null);
|
mechanicalEquipmentPositionData.setId(null);
|
||||||
baseMapper.insert(mechanicalEquipmentPositionData);
|
baseMapper.insert(mechanicalEquipmentPositionData);
|
||||||
|
|
||||||
|
//超过围栏报警,只要在一个围栏内就不报警
|
||||||
|
List<MechanicalEquipmentPositionFence> fenceList = mechanicalEquipmentPositionFenceMapper.selectList(new LambdaQueryWrapper<MechanicalEquipmentPositionFence>()
|
||||||
|
.eq(MechanicalEquipmentPositionFence::getProjectSn, dev.getProjectSn()));
|
||||||
|
boolean inFence = false;
|
||||||
|
for (MechanicalEquipmentPositionFence fence : fenceList) {
|
||||||
|
//判断是否在围栏范围内
|
||||||
|
if (Objects.equals(fence.getRangeType(), 1)) {
|
||||||
|
inFence = RegionUtil.isInCircle(mechanicalEquipmentPositionData.getLongitude(), mechanicalEquipmentPositionData.getLatitude(), fence.getLongitude(), fence.getLatitude(), fence.getAreaRadius());
|
||||||
|
} else if (Objects.equals(fence.getRangeType(), 2)) {
|
||||||
|
String fenceShape = fence.getFenceShape();
|
||||||
|
if (StrUtil.isNotBlank(fenceShape)) {
|
||||||
|
String[] couples = StringUtils.split(fenceShape, ",");
|
||||||
|
Double[] lon = new Double[couples.length];
|
||||||
|
Double[] lat = new Double[couples.length];
|
||||||
|
for (int i = 0; i < couples.length; i++) {
|
||||||
|
String couple = couples[i];
|
||||||
|
String[] two = StringUtils.split(couple, "|");
|
||||||
|
lon[i] = Double.valueOf(two[0]);
|
||||||
|
lat[i] = Double.valueOf(two[1]);
|
||||||
|
}
|
||||||
|
inFence = RegionUtil.isInPolygon(mechanicalEquipmentPositionData.getLongitude(), mechanicalEquipmentPositionData.getLatitude(), lon, lat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inFence) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!inFence) {
|
||||||
|
MechanicalEquipmentPositionAlarm alarm = new MechanicalEquipmentPositionAlarm();
|
||||||
|
alarm.setDevSn(dev.getDevSn());
|
||||||
|
alarm.setAlarmTime(new Date());
|
||||||
|
alarm.setAlarmInfo("翻越围栏报警");
|
||||||
|
mechanicalEquipmentPositionAlarmService.add(alarm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -63,7 +63,8 @@ public class MechanicalEquipmentPositionDevServiceImpl extends ServiceImpl<Mecha
|
|||||||
if (online == 1) {
|
if (online == 1) {
|
||||||
queryWrapper.ge(alias + RefUtil.fieldNameUlc(MechanicalEquipmentPositionDev::getHeartbeatTime), dateTime);
|
queryWrapper.ge(alias + RefUtil.fieldNameUlc(MechanicalEquipmentPositionDev::getHeartbeatTime), dateTime);
|
||||||
} else {
|
} else {
|
||||||
queryWrapper.lt(alias + RefUtil.fieldNameUlc(MechanicalEquipmentPositionDev::getHeartbeatTime), dateTime);
|
queryWrapper.and(qw -> qw.lt(alias + RefUtil.fieldNameUlc(MechanicalEquipmentPositionDev::getHeartbeatTime), dateTime).or()
|
||||||
|
.isNull(alias + RefUtil.fieldNameUlc(MechanicalEquipmentPositionDev::getHeartbeatTime)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
|
|||||||
@ -1,28 +1,23 @@
|
|||||||
package com.zhgd.xmgl.modules.safetyhat.controller;
|
package com.zhgd.xmgl.modules.safetyhat.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.gexin.fastjson.JSON;
|
import com.gexin.fastjson.JSON;
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
|
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
|
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.zhgd.jeecg.common.api.vo.Result;
|
|
||||||
import org.apache.commons.collections.MapUtils;
|
|
||||||
|
|
||||||
import org.simpleframework.xml.core.Validate;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.simpleframework.xml.core.Validate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,95 +32,111 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(tags = "智能安全帽-实时数据相关Api")
|
@Api(tags = "智能安全帽-实时数据相关Api")
|
||||||
public class SafetyHatDataController {
|
public class SafetyHatDataController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISafetyHatDataService safetyHatDataService;
|
private ISafetyHatDataService safetyHatDataService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "分页列表查询智能安全帽-实时数据信息", notes = "分页列表查询智能安全帽-实时数据信息", httpMethod = "GET")
|
@ApiOperation(value = "分页列表查询智能安全帽-实时数据信息", notes = "分页列表查询智能安全帽-实时数据信息", httpMethod = "GET")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
||||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
||||||
@ApiImplicitParam(name = "day", value = "日(yyyy-MM-dd)", paramType = "query", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "day", value = "日(yyyy-MM-dd)", paramType = "query", required = false, dataType = "String"),
|
||||||
})
|
})
|
||||||
@GetMapping(value = "/page")
|
@GetMapping(value = "/page")
|
||||||
public Result<IPage<SafetyHatData>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
public Result<IPage<SafetyHatData>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||||
return Result.success(safetyHatDataService.queryPageList(paramMap));
|
return Result.success(safetyHatDataService.queryPageList(paramMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表查询
|
* 列表查询
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "列表查询智能安全帽-实时数据信息", notes = "列表查询智能安全帽-实时数据信息", httpMethod = "GET")
|
@ApiOperation(value = "列表查询智能安全帽-实时数据信息", notes = "列表查询智能安全帽-实时数据信息", httpMethod = "GET")
|
||||||
@GetMapping(value = "/list")
|
@GetMapping(value = "/list")
|
||||||
public Result<List<SafetyHatData>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
public Result<List<SafetyHatData>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||||
return Result.success(safetyHatDataService.queryList(paramMap));
|
return Result.success(safetyHatDataService.queryList(paramMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
*
|
*
|
||||||
* @param safetyHatData
|
* @param safetyHatData
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "添加智能安全帽-实时数据信息", notes = "添加智能安全帽-实时数据信息", httpMethod = "POST")
|
@ApiOperation(value = "添加智能安全帽-实时数据信息", notes = "添加智能安全帽-实时数据信息", httpMethod = "POST")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public Result<SafetyHatData> add(@RequestBody @Validate SafetyHatData safetyHatData) {
|
public Result<SafetyHatData> add(@RequestBody @Validate SafetyHatData safetyHatData) {
|
||||||
log.info("列表查询智能安全帽-实时数据信息:{}", JSON.toJSONString(safetyHatData));
|
log.info("列表查询智能安全帽-实时数据信息:{}", JSON.toJSONString(safetyHatData));
|
||||||
safetyHatDataService.add(safetyHatData);
|
safetyHatDataService.add(safetyHatData);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param safetyHatData
|
* @param safetyHatData
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "编辑智能安全帽-实时数据信息", notes = "编辑智能安全帽-实时数据信息", httpMethod = "POST")
|
@ApiOperation(value = "编辑智能安全帽-实时数据信息", notes = "编辑智能安全帽-实时数据信息", httpMethod = "POST")
|
||||||
@PostMapping(value = "/edit")
|
@PostMapping(value = "/edit")
|
||||||
public Result<SafetyHatData> edit(@RequestBody SafetyHatData safetyHatData) {
|
public Result<SafetyHatData> edit(@RequestBody SafetyHatData safetyHatData) {
|
||||||
safetyHatDataService.edit(safetyHatData);
|
safetyHatDataService.edit(safetyHatData);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "删除智能安全帽-实时数据信息", notes = "删除智能安全帽-实时数据信息", httpMethod = "POST")
|
@ApiOperation(value = "删除智能安全帽-实时数据信息", notes = "删除智能安全帽-实时数据信息", httpMethod = "POST")
|
||||||
@ApiImplicitParam(name = "id", value = "智能安全帽-实时数据ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
|
@ApiImplicitParam(name = "id", value = "智能安全帽-实时数据ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
|
||||||
@PostMapping(value = "/delete")
|
@PostMapping(value = "/delete")
|
||||||
public Result<SafetyHatData> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
|
public Result<SafetyHatData> delete(@ApiIgnore @RequestBody HashMap<String, Object> map) {
|
||||||
safetyHatDataService.delete(MapUtils.getString(map, "id"));
|
safetyHatDataService.delete(MapUtils.getString(map, "id"));
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询
|
* 通过id查询
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "通过id查询智能安全帽-实时数据信息", notes = "通过id查询智能安全帽-实时数据信息", httpMethod = "GET")
|
@ApiOperation(value = "通过id查询智能安全帽-实时数据信息", notes = "通过id查询智能安全帽-实时数据信息", httpMethod = "GET")
|
||||||
@ApiImplicitParam(name = "id", value = "智能安全帽-实时数据ID", paramType = "query", required = true, dataType = "Integer")
|
@ApiImplicitParam(name = "id", value = "智能安全帽-实时数据ID", paramType = "query", required = true, dataType = "Integer")
|
||||||
@GetMapping(value = "/queryById")
|
@GetMapping(value = "/queryById")
|
||||||
public Result<SafetyHatData> queryById(@RequestParam(name = "id", required = true) String id) {
|
public Result<SafetyHatData> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
Result<SafetyHatData> result = new Result<SafetyHatData>();
|
Result<SafetyHatData> result = new Result<SafetyHatData>();
|
||||||
SafetyHatData safetyHatData = safetyHatDataService.getById(id);
|
SafetyHatData safetyHatData = safetyHatDataService.getById(id);
|
||||||
if (safetyHatData == null) {
|
if (safetyHatData == null) {
|
||||||
result.error500("未找到对应实体");
|
result.error500("未找到对应实体");
|
||||||
} else {
|
} else {
|
||||||
result.setResult(safetyHatData);
|
result.setResult(safetyHatData);
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂时没有使用
|
||||||
|
*
|
||||||
|
* @param paramMap
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取每个设备最新一条实时数据信息", notes = "获取每个设备最新一条实时数据信息", httpMethod = "POST")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "devSns", value = "设备sns(不传查全部)", paramType = "query", required = false, dataType = "String"),
|
||||||
|
})
|
||||||
|
@PostMapping(value = "/getNewestList")
|
||||||
|
public Result<List<SafetyHatData>> getNewestList(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
|
||||||
|
return Result.success(safetyHatDataService.getNewestList(paramMap));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,4 +26,6 @@ public interface SafetyHatDataMapper extends BaseMapper<SafetyHatData> {
|
|||||||
List<SafetyHatData> queryList(@Param(Constants.WRAPPER) QueryWrapper<SafetyHatData> queryWrapper);
|
List<SafetyHatData> queryList(@Param(Constants.WRAPPER) QueryWrapper<SafetyHatData> queryWrapper);
|
||||||
|
|
||||||
List<SafetyHatData> getNewestData(String projectSn);
|
List<SafetyHatData> getNewestData(String projectSn);
|
||||||
|
|
||||||
|
List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
from safety_hat_alarm
|
from safety_hat_alarm
|
||||||
where project_sn = #{projectSn}
|
where project_sn = #{projectSn}
|
||||||
and alarm_time > date_sub(now(), interval 8 day)
|
and alarm_time > date_sub(now(), interval 8 day)
|
||||||
|
and alarm_type is not null
|
||||||
group by alarm_type, date_format(alarm_time, '%Y-%m-%d')
|
group by alarm_type, date_format(alarm_time, '%Y-%m-%d')
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -17,4 +17,21 @@
|
|||||||
group by dev_sn) t on t.create_time = shd.create_time and t.dev_sn=shd.dev_sn
|
group by dev_sn) t on t.create_time = shd.create_time and t.dev_sn=shd.dev_sn
|
||||||
group by shd.dev_sn
|
group by shd.dev_sn
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getNewestList" resultType="com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData">
|
||||||
|
select shd.*, wi.worker_name from safety_hat_data shd join (
|
||||||
|
select max(upload_time) as upload_time, dev_sn
|
||||||
|
from safety_hat_data
|
||||||
|
where project_sn = #{projectSn}
|
||||||
|
<if test="devSns != null and devSns != ''">
|
||||||
|
and dev_sn in
|
||||||
|
<foreach collection="devSns" index="index" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
group by dev_sn
|
||||||
|
)t on t.upload_time=shd.upload_time and t.dev_sn=shd.dev_sn
|
||||||
|
left join worker_info wi on wi.id = shd.worker_info_id
|
||||||
|
group by t.dev_sn
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -24,4 +24,6 @@ public interface ISafetyHatDataService extends IService<SafetyHatData> {
|
|||||||
void edit(SafetyHatData safetyHatData);
|
void edit(SafetyHatData safetyHatData);
|
||||||
|
|
||||||
void delete(String id);
|
void delete(String id);
|
||||||
|
|
||||||
|
List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.zhgd.xmgl.modules.safetyhat.service.impl;
|
package com.zhgd.xmgl.modules.safetyhat.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -7,13 +8,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatAlarm;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
|
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||||
|
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatFence;
|
||||||
|
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatAlarmMapper;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDataMapper;
|
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDataMapper;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper;
|
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper;
|
||||||
|
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatFenceMapper;
|
||||||
|
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatAlarmService;
|
||||||
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
|
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
|
||||||
import com.zhgd.xmgl.util.PageUtil;
|
import com.zhgd.xmgl.util.PageUtil;
|
||||||
import com.zhgd.xmgl.util.RefUtil;
|
import com.zhgd.xmgl.util.RefUtil;
|
||||||
|
import com.zhgd.xmgl.util.RegionUtil;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -23,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 智能安全帽-实时数据
|
* @Description: 智能安全帽-实时数据
|
||||||
@ -37,6 +45,12 @@ public class SafetyHatDataServiceImpl extends ServiceImpl<SafetyHatDataMapper, S
|
|||||||
private SafetyHatDataMapper safetyHatDataMapper;
|
private SafetyHatDataMapper safetyHatDataMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SafetyHatDevMapper safetyHatDevMapper;
|
private SafetyHatDevMapper safetyHatDevMapper;
|
||||||
|
@Autowired
|
||||||
|
private SafetyHatFenceMapper safetyHatFenceMapper;
|
||||||
|
@Autowired
|
||||||
|
private SafetyHatAlarmMapper safetyHatAlarmMapper;
|
||||||
|
@Autowired
|
||||||
|
private ISafetyHatAlarmService safetyHatAlarmService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<SafetyHatData> queryPageList(HashMap<String, Object> paramMap) {
|
public IPage<SafetyHatData> queryPageList(HashMap<String, Object> paramMap) {
|
||||||
@ -84,6 +98,43 @@ public class SafetyHatDataServiceImpl extends ServiceImpl<SafetyHatDataMapper, S
|
|||||||
safetyHatData.setId(null);
|
safetyHatData.setId(null);
|
||||||
safetyHatData.setWorkerInfoId(dev.getWorkerInfoId());
|
safetyHatData.setWorkerInfoId(dev.getWorkerInfoId());
|
||||||
baseMapper.insert(safetyHatData);
|
baseMapper.insert(safetyHatData);
|
||||||
|
|
||||||
|
//超过围栏报警,只要在一个围栏内就不报警
|
||||||
|
List<SafetyHatFence> fenceList = safetyHatFenceMapper.selectList(new LambdaQueryWrapper<SafetyHatFence>()
|
||||||
|
.eq(SafetyHatFence::getProjectSn, dev.getProjectSn()));
|
||||||
|
boolean inFence = false;
|
||||||
|
for (SafetyHatFence fence : fenceList) {
|
||||||
|
//判断是否在围栏范围内
|
||||||
|
if (Objects.equals(fence.getRangeType(), 1)) {
|
||||||
|
inFence = RegionUtil.isInCircle(safetyHatData.getLongitude(), safetyHatData.getLatitude(), fence.getLongitude(), fence.getLatitude(), fence.getAreaRadius());
|
||||||
|
} else if (Objects.equals(fence.getRangeType(), 2)) {
|
||||||
|
String fenceShape = fence.getFenceShape();
|
||||||
|
if (StrUtil.isNotBlank(fenceShape)) {
|
||||||
|
String[] couples = StringUtils.split(fenceShape, ",");
|
||||||
|
Double[] lon = new Double[couples.length];
|
||||||
|
Double[] lat = new Double[couples.length];
|
||||||
|
for (int i = 0; i < couples.length; i++) {
|
||||||
|
String couple = couples[i];
|
||||||
|
String[] two = StringUtils.split(couple, "|");
|
||||||
|
lon[i] = Double.valueOf(two[0]);
|
||||||
|
lat[i] = Double.valueOf(two[1]);
|
||||||
|
}
|
||||||
|
inFence = RegionUtil.isInPolygon(safetyHatData.getLongitude(), safetyHatData.getLatitude(), lon, lat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inFence) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!inFence) {
|
||||||
|
SafetyHatAlarm alarm = new SafetyHatAlarm();
|
||||||
|
alarm.setDevSn(dev.getDevSn());
|
||||||
|
alarm.setAlarmTime(new Date());
|
||||||
|
alarm.setAlarmType(2);
|
||||||
|
alarm.setLatitude(safetyHatData.getLatitude());
|
||||||
|
alarm.setLongitude(safetyHatData.getLongitude());
|
||||||
|
safetyHatAlarmService.add(alarm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,5 +151,10 @@ public class SafetyHatDataServiceImpl extends ServiceImpl<SafetyHatDataMapper, S
|
|||||||
baseMapper.deleteById(id);
|
baseMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap) {
|
||||||
|
return baseMapper.getNewestList(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,6 +152,7 @@ public class ProjectTask {
|
|||||||
@RequestMapping("getMonthAttendanceStatistics")
|
@RequestMapping("getMonthAttendanceStatistics")
|
||||||
public void getMonthAttendanceStatistics() {
|
public void getMonthAttendanceStatistics() {
|
||||||
try {
|
try {
|
||||||
|
log.info("定时统计前一天的考勤状况");
|
||||||
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
//计算前一天的考勤状况
|
//计算前一天的考勤状况
|
||||||
Date date = DateUtils.addDays(new Date(), -1);
|
Date date = DateUtils.addDays(new Date(), -1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user