bug修复

This commit is contained in:
guo 2024-03-27 16:26:12 +08:00
parent c73dc341c7
commit e29b68ad1b
8 changed files with 62 additions and 33 deletions

View File

@ -6,6 +6,7 @@ import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

View File

@ -94,4 +94,8 @@ public class SafetyHatData implements Serializable {
@ApiModelProperty(value = "人员名称")
@TableField(exist = false)
private java.lang.String workerName;
@TableField(exist = false)
@ApiModelProperty(value = "身份证号")
private java.lang.String idCard;
}

View File

@ -1,18 +1,20 @@
package com.zhgd.xmgl.modules.safetyhat.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @Description: 智能安全帽-围栏
@ -92,4 +94,8 @@ public class SafetyHatFence implements Serializable {
@TableField(exist = false)
@ApiModelProperty(value = "围栏内人数")
private Integer workerNum;
@TableField(exist = false)
@ApiModelProperty(value = "围栏内人员列表")
private List<WorkerInfo> workerListInFence;
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@ -25,7 +26,8 @@ public interface SafetyHatDataMapper extends BaseMapper<SafetyHatData> {
List<SafetyHatData> queryList(@Param(Constants.WRAPPER) QueryWrapper<SafetyHatData> queryWrapper);
List<SafetyHatData> getNewestData(String projectSn);
List<SafetyHatData> getNewestDataGroupByDevSn(String projectSn);
List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap);
}

View File

@ -8,13 +8,16 @@
${ew.customSqlSegment}
</select>
<select id="getNewestData" resultType="com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData">
select *
<select id="getNewestDataGroupByDevSn" resultType="com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData">
select shd.*,wi.worker_name,wi.id_card
from safety_hat_data shd
join (select max(create_time) as create_time, dev_sn
from safety_hat_data
where project_sn = #{projectSn}
group by dev_sn) t on t.create_time = shd.create_time and t.dev_sn=shd.dev_sn
join safety_hat_dev shd2 on shd2.dev_sn = shd.dev_sn
left join worker_info wi on wi.id = shd.worker_info_id
where shd2.online=1
group by shd.dev_sn
</select>

View File

@ -4,6 +4,7 @@ import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import java.util.HashMap;
import java.util.List;
@ -29,4 +30,5 @@ public interface ISafetyHatDataService extends IService<SafetyHatData> {
List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap);
void updateStatus(SafetyHatDev safetyHatDev);
}

View File

@ -19,6 +19,7 @@ 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.worker.entity.WorkerInfo;
import com.zhgd.xmgl.util.PageUtil;
import com.zhgd.xmgl.util.RefUtil;
import com.zhgd.xmgl.util.RegionUtil;

View File

@ -7,6 +7,7 @@ import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatFence;
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDataMapper;
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatFenceMapper;
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatFenceService;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.util.RegionUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -19,6 +20,7 @@ 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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@ -59,35 +61,43 @@ public class SafetyHatFenceServiceImpl extends ServiceImpl<SafetyHatFenceMapper,
private List<SafetyHatFence> dealList(List<SafetyHatFence> list, HashMap<String, Object> paramMap) {
String projectSn = MapUtils.getString(paramMap, "projectSn");
for (SafetyHatFence fence : list) {
List<SafetyHatData> dataList = safetyHatDataMapper.getNewestData(projectSn);
int workerNum = 0;
if (CollUtil.isNotEmpty(dataList)) {
for (SafetyHatData d : dataList) {
boolean inFence = false;
//判断是否在围栏范围内
if (Objects.equals(fence.getRangeType(), 1)) {
inFence = RegionUtil.isInCircle(d.getLongitude(), d.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]);
if (CollUtil.isNotEmpty(list)) {
List<SafetyHatData> dataList = safetyHatDataMapper.getNewestDataGroupByDevSn(projectSn);
for (SafetyHatFence fence : list) {
ArrayList<WorkerInfo> workerInfos = new ArrayList<>();
int workerNum = 0;
if (CollUtil.isNotEmpty(dataList)) {
for (SafetyHatData d : dataList) {
boolean inFence = false;
//判断是否在围栏范围内
if (Objects.equals(fence.getRangeType(), 1)) {
inFence = RegionUtil.isInCircle(d.getLongitude(), d.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(d.getLongitude(), d.getLatitude(), lon, lat);
}
inFence = RegionUtil.isInPolygon(d.getLongitude(), d.getLatitude(), lon, lat);
}
}
if (inFence) {
workerNum++;
if (inFence) {
workerNum++;
WorkerInfo workerInfo = new WorkerInfo();
workerInfo.setWorkerName(d.getWorkerName());
workerInfo.setIdCard(d.getIdCard());
workerInfos.add(workerInfo);
}
}
}
fence.setWorkerNum(workerNum);
fence.setWorkerListInFence(workerInfos);
}
}
return list;