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.SafetyHatData;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev; import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDataService; 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.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;

View File

@ -94,4 +94,8 @@ public class SafetyHatData implements Serializable {
@ApiModelProperty(value = "人员名称") @ApiModelProperty(value = "人员名称")
@TableField(exist = false) @TableField(exist = false)
private java.lang.String workerName; 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; 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.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; 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: 智能安全帽-围栏 * @Description: 智能安全帽-围栏
@ -92,4 +94,8 @@ public class SafetyHatFence implements Serializable {
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "围栏内人数") @ApiModelProperty(value = "围栏内人数")
private Integer workerNum; 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.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData; import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import org.apache.ibatis.annotations.Mapper; 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;
@ -25,7 +26,8 @@ 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> getNewestDataGroupByDevSn(String projectSn);
List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap); List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap);
} }

View File

@ -8,13 +8,16 @@
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </select>
<select id="getNewestData" resultType="com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData"> <select id="getNewestDataGroupByDevSn" resultType="com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData">
select * select shd.*,wi.worker_name,wi.id_card
from safety_hat_data shd from safety_hat_data shd
join (select max(create_time) as create_time, dev_sn join (select max(create_time) as create_time, dev_sn
from safety_hat_data from safety_hat_data
where project_sn = #{projectSn} where project_sn = #{projectSn}
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
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 group by shd.dev_sn
</select> </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.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev; import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -29,4 +30,5 @@ public interface ISafetyHatDataService extends IService<SafetyHatData> {
List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap); List<SafetyHatData> getNewestList(HashMap<String, Object> paramMap);
void updateStatus(SafetyHatDev safetyHatDev); 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.mapper.SafetyHatFenceMapper;
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatAlarmService; 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.modules.worker.entity.WorkerInfo;
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 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.SafetyHatDataMapper;
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatFenceMapper; import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatFenceMapper;
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatFenceService; import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatFenceService;
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.util.RegionUtil; 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;
@ -19,6 +20,7 @@ import com.zhgd.jeecg.common.system.query.QueryGenerator;
import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.PageUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Objects; 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) { private List<SafetyHatFence> dealList(List<SafetyHatFence> list, HashMap<String, Object> paramMap) {
String projectSn = MapUtils.getString(paramMap, "projectSn"); String projectSn = MapUtils.getString(paramMap, "projectSn");
for (SafetyHatFence fence : list) { if (CollUtil.isNotEmpty(list)) {
List<SafetyHatData> dataList = safetyHatDataMapper.getNewestData(projectSn); List<SafetyHatData> dataList = safetyHatDataMapper.getNewestDataGroupByDevSn(projectSn);
int workerNum = 0; for (SafetyHatFence fence : list) {
if (CollUtil.isNotEmpty(dataList)) { ArrayList<WorkerInfo> workerInfos = new ArrayList<>();
for (SafetyHatData d : dataList) { int workerNum = 0;
boolean inFence = false; if (CollUtil.isNotEmpty(dataList)) {
//判断是否在围栏范围内 for (SafetyHatData d : dataList) {
if (Objects.equals(fence.getRangeType(), 1)) { boolean inFence = false;
inFence = RegionUtil.isInCircle(d.getLongitude(), d.getLatitude(), fence.getLongitude(), fence.getLatitude(), fence.getAreaRadius()); //判断是否在围栏范围内
} else if (Objects.equals(fence.getRangeType(), 2)) { if (Objects.equals(fence.getRangeType(), 1)) {
String fenceShape = fence.getFenceShape(); inFence = RegionUtil.isInCircle(d.getLongitude(), d.getLatitude(), fence.getLongitude(), fence.getLatitude(), fence.getAreaRadius());
if (StrUtil.isNotBlank(fenceShape)) { } else if (Objects.equals(fence.getRangeType(), 2)) {
String[] couples = StringUtils.split(fenceShape, ","); String fenceShape = fence.getFenceShape();
Double[] lon = new Double[couples.length]; if (StrUtil.isNotBlank(fenceShape)) {
Double[] lat = new Double[couples.length]; String[] couples = StringUtils.split(fenceShape, ",");
for (int i = 0; i < couples.length; i++) { Double[] lon = new Double[couples.length];
String couple = couples[i]; Double[] lat = new Double[couples.length];
String[] two = StringUtils.split(couple, "|"); for (int i = 0; i < couples.length; i++) {
lon[i] = Double.valueOf(two[0]); String couple = couples[i];
lat[i] = Double.valueOf(two[1]); 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) {
if (inFence) { workerNum++;
workerNum++; WorkerInfo workerInfo = new WorkerInfo();
workerInfo.setWorkerName(d.getWorkerName());
workerInfo.setIdCard(d.getIdCard());
workerInfos.add(workerInfo);
}
} }
} }
fence.setWorkerNum(workerNum); fence.setWorkerNum(workerNum);
fence.setWorkerListInFence(workerInfos);
} }
} }
return list; return list;