数据bug修改

This commit is contained in:
haozq 2024-10-12 13:54:11 +08:00
parent 32815ac478
commit c0e8cac213
19 changed files with 154 additions and 46 deletions

View File

@ -24,7 +24,9 @@ public class BraceletVo
/** 手环编码 */
@Excel(name = "手环编码")
private String shCode;
/** 手环名称 */
@Excel(name = "手环名称")
private String shName;
/** 手环状态 */
@Excel(name = "手环状态")
private Integer shStatus;

View File

@ -50,6 +50,9 @@ public class ShboxVo
@Excel(name = "手环编码")
private String shCode;
@Excel(name = "手环名称")
private String shName;
/** 手环箱容量 */
@Excel(name = "手环箱容量")

View File

@ -9,6 +9,12 @@ import lombok.Data;
public class TcpMessage {
private String devCode;
/**
* 距离
*/
private float distance;
/**
* 电压等级
*/
private Integer nearelectric;
}

View File

@ -88,8 +88,8 @@ public class ParamSecureHandler implements AsyncHandlerInterceptor {
*/
String readerParam = requestWrapper.getReaderParam();
// 判断是否是文件上传是不对流参数进行验证
String uplFile = "uploadFile", upImage = "uploadImage",xmlAnalysis = "xmlAnalysis";
if (!requestUrl.contains(uplFile) && !requestUrl.contains(upImage) && !requestUrl.contains(xmlAnalysis)) {
String uplFile = "uploadFile", upImage = "uploadImage",xmlAnalysis = "xmlAnalysis",bast64="addLsUser";
if (!requestUrl.contains(uplFile) && !requestUrl.contains(upImage) && !requestUrl.contains(xmlAnalysis)&& !requestUrl.contains(bast64)) {
boolean checkReader = checkReader(readerParam, requestUrl);
if (!checkReader) {
returnJson(response, "请求重复", 500);

View File

@ -104,7 +104,7 @@ public class StayPersonController extends BaseController{
return service. getProList(data);
}
/**
* 所有人员进行人脸验证
*
* @param data
* @return
*/

View File

@ -108,4 +108,10 @@ public interface BraceletMapper {
* @param devId
*/
void updateShStatus(@Param("devId") String devId);
/**
* 删除临时人员
* @param user
*/
void deleteUser(LsUserEntity user);
}

View File

@ -88,7 +88,7 @@ public class BraceletServiceImpl implements BraceletService{
}
setDefaultVal(entity);
Integer ffNum=mapper.getBoxFfNum(entity);
Integer shUsedNum=mapper.getShUsed(entity);
Integer shUsedNum=mapper.getShUsed(entity);
//查询手环数据信息
List<BraceletEntity> list=mapper.getBoxInfo(entity);
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
@ -284,12 +284,12 @@ public class BraceletServiceImpl implements BraceletService{
user.setTeamId(loginUser.getSysUser().getTeamId());
String proId=mapper.getProIdByTeamId(loginUser.getSysUser().getTeamId());
user.setProId(proId);
//插入人员
mapper.insertLsUser(user);
if(StringUtils.isNotEmpty(user.getId())){
R result=fileService.singleUploadFile(file,SecurityConstants.INNER);
if (result != null && result.getCode() == HttpStatus.ERROR) {
return AjaxResult.error("人员图片上传失败");
return AjaxResult.error("人员图片上传失败,文件服务异常。");
} else if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
String jsonString = JSON.toJSONString(result.getData());
JSONObject item = JSON.parseObject(jsonString);
@ -298,18 +298,18 @@ public class BraceletServiceImpl implements BraceletService{
//添加图片到人脸库
R<Boolean> r= sourceService.addFileSource(fileVo, SecurityConstants.INNER);
if(r.getData()){
AjaxResult ajaxResult = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "ls-" + user.getId());
if(ajaxResult.get("data") == null){
throw new ServiceException("人脸照片未检测到人脸");
Map<String,Object> map = addFaceToLibrary(BytesToMultipartFileUtil.multipartFileToBase64(file), FaceCodeUtil.ADD, "ls-" + user.getId());
if(!map.get("code").toString().equals("200")){
mapper.deleteUser(user);
return AjaxResult.error(map.get("msg").toString());
}
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")));
Integer code = data.getInteger("code");
String msg = data.getString("msg");
if (Objects.equals(code, BusinessConstants.SUCCESS_CODE)) {
if(map.get("code").toString().equals("200")) {
return AjaxResult.success("添加成功");
}else{
throw new ServiceException(msg);
mapper.deleteUser(user);
throw new ServiceException(map.get("msg").toString());
}
}
}
}
@ -343,13 +343,13 @@ public class BraceletServiceImpl implements BraceletService{
return fileVo;
}
public AjaxResult addFaceToLibrary(String base64, String type, String id) {
public Map<String,Object> addFaceToLibrary(String base64, String type, String id) {
if (org.apache.commons.lang3.StringUtils.isEmpty(base64)) {
return null;
}
AjaxResult ajaxResult = faceInterService.addFace(base64, type, id);
log.info("添加人脸库返回结果:{}", ajaxResult);
return ajaxResult;
Map<String,Object> map = faceInterService.addFace(base64, type, id);
log.info("添加人脸库返回结果:{}", map);
return map;
}
/**

View File

@ -78,7 +78,7 @@ public class FaceInterUtilService {
* bz-
* @return
*/
public AjaxResult addFace(String image, String type, String id) {
public Map<String,Object> addFace(String image, String type, String id) {
Map<String,Object> result= Maps.newHashMap();
try{
Map<String,Object> map= Maps.newHashMap();
@ -102,11 +102,13 @@ public class FaceInterUtilService {
result.put("code",201);
result.put("msg","人脸识别接口异常!请检查人脸服务!");
}
return AjaxResult.success(result);
return result;
}catch (Exception e){
result.put("code",201);
result.put("msg","未检测到人脸!");
log.error(e.toString(),e);
}
return AjaxResult.error("人脸识别接口异常!请检查人脸服务!");
return result;
}

View File

@ -21,13 +21,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="updateBoxBraceletInfo">
UPDATE tb_bracelet
SET face_status=NLLL,peopel_type=NULL,bid_id=NULL,bid_time=NULL,sh_status=0
SET face_status=NULL,peopel_type=NULL,bid_id=NULL,bid_time=NULL,sh_status=0
WHERE id=#{devId}
</update>
<update id="updateShStatus">
update tb_sh_use set unbid_time=now() and time_type=0
WHERE dev_id=#{devId} and bid_type=1 and unbid_time is null
</update>
<delete id="deleteUser">
delete from tb_ls_user
where id=#{id}
</delete>
<select id="getBoxListById" resultType="com.bonus.app.entity.BoxEntity" >
select id boxId,box_name boxName
FROM tb_sh_box
@ -139,7 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getShUsed" resultType="java.lang.Integer">
SELECT count(1)
FROM tb_bracelet blt
where blt.box_id=#{boxId} and blt.bid_id is not null and blt.bid_id!='' and blt.del_flag=0
where blt.box_id=#{boxId} and blt.bid_id is not null and blt.bid_id!='' and blt.del_flag=0 and ( face_status is null or face_status=1)
</select>
<select id="getBoxShNum" resultType="java.lang.Integer">
SELECT count(1)

View File

@ -158,20 +158,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM tb_project_depart de
left join tb_project pro on de.id=pro.depart_id
left join sys_user su on de.id=su.dept_id
where 1=1 and de.del_flag=0 and pro.del_flag=0 and su.id=#{userId}
where 1=1 and de.del_flag=0 and pro.del_flag=0 and su.user_id=#{userId}
</if>
</select>
<select id="getGtList" resultType="com.bonus.common.entity.bracelet.vo.ProjectVo">
<if test="roleCode=='administrators' or roleCode=='depart'">
select id,power_name gtName,Lon gtLon,lat gtLat
from tb_project_power
where pro_id=#{proId}
where pro_id=#{proId} and del_flag=0
</if>
<if test="roleCode=='team'">
select power.id,power.power_name gtName,power.lon gtLon,power.lat gtLat
from tb_sh_box box
left join tb_project_power power on power.id=box.gt_id and power.del_flag=0
where power.pro_id=#{proId}
where power.pro_id=#{proId} and box.del_flag=0
and box.team_id=#{teamId}
</if>
</select>

View File

@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--手环箱绑定手环列表-->
<select id="getShBindLists" resultType="com.bonus.common.entity.bracelet.vo.BraceletVo">
select * from (
select tb.id as shId,tb.sh_code as shCode,
select tb.id as shId,tb.sh_code as shCode,tb.sh_name as shName,
case
WHEN tb.peopel_type=0 then tpe.name
WHEN tb.peopel_type=1 then tlu.name
@ -80,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--未绑定手环列表-->
<select id="getShBindNoLists" resultType="com.bonus.common.entity.bracelet.vo.BraceletVo">
select id as shId,sh_code as shCode
select id as shId,sh_code as shCode,sh_name as shName
from tb_bracelet
where box_id is NULL and del_flag = 0
order by id ASC
@ -160,7 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UPDATE tb_bracelet tb
set
box_id = #{shboxId},
sh_status = #{shStatus},bid_time = #{bidTime},sh_code = #{shCode},update_time = #{updateTime},update_user = #{updateUser}
sh_status = #{shStatus},bid_time = #{bidTime},sh_code = #{shCode},sh_name = #{shName},update_time = #{updateTime},update_user = #{updateUser}
where id = #{shId}
</update>
@ -234,6 +234,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into tb_bracelet(
<if test="shboxId != null">box_id,</if>
<if test="shCode != null and shCode != ''">sh_code,</if>
<if test="shName != null and shName != ''">sh_name,</if>
<if test="shStatus != null ">sh_status,</if>
create_time,
create_user,
@ -243,6 +244,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)values(
<if test=" shboxId != null">#{shboxId},</if>
<if test="shCode != null and shCode != ''">#{shCode},</if>
<if test="shName != null and shName != ''">#{shName},</if>
<if test="shStatus != null ">#{shStatus},</if>
#{createTime},
#{createUser},

View File

@ -26,8 +26,8 @@ import java.util.Map;
public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandlerAdapter {
public TcpDataService service = SpringUtils.getBean(TcpDataService.class);
public static int data_type=24;
public static int data_type1=24;
public static int data_type=22;
public static int warn_type=51;
/**
* 注册时执行
@ -81,6 +81,14 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
String jl=object.getString("data");
map.put("type",42);
service.updateDeviceInfo(channelId,dl,jl);
} if(data_type1==type){
JSONArray devArray=json.getJSONArray("device");
JSONObject object=devArray.getJSONObject(0);
channelId=object.getString("id");
String dl=object.getString("quantity");
String jl=object.getString("data");
map.put("type",42);
service.updateDeviceInfo(channelId,dl,jl);
}else if(warn_type==type){
map.put("type",52);
map.put("id",channelId);
@ -90,8 +98,12 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
service.insertWarnInfo(channelId,type,report,data);
}
if(type!=24){
System.err.println("data-->" + data);
}else{
System.err.println("data-->" + data);
}
System.err.println("通道号--->" + channelId );
System.err.println("data-->" + data);
BootNettyChannel b = BootNettyChannelCache.get("server:" + channelId);
if (b == null) {
//更新通道

View File

@ -2,6 +2,7 @@ package com.bonus.tcp.smartIdentify.controller;
import com.alibaba.fastjson.JSON;
import com.bonus.common.core.utils.StringHelper;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.tcp.TcpMessage;
@ -42,6 +43,35 @@ public class BootNettyController {
map.put("type",1);
map.put("id",message.getDevCode());
map.put("distance",message.getDistance());
String msg= JSON.toJSONString(map);
System.err.println("距离指令--"+msg);
String result= nettyServer.sendMessage(message.getDevCode(),msg);
if(message.getNearelectric()!=null){
map=new HashMap<>();
map.put("type",3);
map.put("id",message.getDevCode());
map.put("nearelectric",message.getNearelectric());
msg= JSON.toJSONString(map);
Thread.sleep(3000);
System.err.println("电压等级指令--"+msg);
result= nettyServer.sendMessage(message.getDevCode(),msg);
}
return AjaxResult.success(result);
}catch (Exception e){
return AjaxResult.error("服务异常,请联系管理员");
}
}
@PostMapping("/closeWarn")
public AjaxResult closeWarn(@RequestBody TcpMessage message) {
try{
Map<String,Object> map=new HashMap<>();
if(StringUtils.isEmpty(message.getDevCode())){
return AjaxResult.error("请选择设备!");
}
map.put("type",2);
map.put("id",message.getDevCode());
map.put("alarm",0);
String msg= JSON.toJSONString(map);
String result= nettyServer.sendMessage(message.getDevCode(),msg);
return AjaxResult.success(result);
@ -49,5 +79,4 @@ public class BootNettyController {
return AjaxResult.error("服务异常,请联系管理员");
}
}
}

View File

@ -87,10 +87,13 @@ public class BraceletImageController {
try{
if(StringHelper.isNotEmpty(vo.getDevCode())){
List<String> list= Arrays.asList(vo.getDevCode().split("@"));
list.forEach(devCode->{
service.updateVerdateStatus(devCode);
aqdSocketHandler.sendMessageToUser(devCode,"open");
});
List<String> shList=service.getBdShCode(list);
if(StringUtils.isNotEmpty(shList)){
shList.forEach(devCode->{
service.updateVerdateStatus(devCode);
aqdSocketHandler.sendMessageToUser(devCode,"open");
});
}
}
}catch (Exception e){

View File

@ -102,4 +102,6 @@ public interface BraceletImageMapper {
* @return
*/
List<String> getShCodeByGt(BraceletImageVo vo);
List<String> getBdShCode(@Param("list") List<String> list);
}

View File

@ -39,4 +39,11 @@ public interface BraceletImageService {
* @return
*/
List<String> getShCodeByGt(BraceletImageVo vo);
/**
* 查询已绑定的手环
* @param list
* @return
*/
List<String> getBdShCode(List<String> list);
}

View File

@ -260,6 +260,11 @@ public class BraceletImageServiceImpl implements BraceletImageService {
return mapper.getShCodeByGt(vo);
}
@Override
public List<String> getBdShCode(List<String> list) {
return mapper.getBdShCode(list);
}
/**
*
* @param devId

View File

@ -60,12 +60,11 @@ public class ScheduleServiceImpl implements ScheduleService {
taskVo.setCorn("0/30 * * * * ?");
taskVo.setJobClass("com.bonus.tcp.task.config.ConfigScanJob");
taskVo.setTaskCode("DEFAULT");
taskVo.setCode("0");
AtomicReference<Integer> code= new AtomicReference<>(0);
taskVo.setCode("1");
list.forEach(vo->{
code.getAndSet(code.get() + 1);
vo.setJobClass("com.bonus.tcp.task.job.TestJob");
vo.setTaskCode("TASK_"+code.get());
vo.setTaskCode("TASK_"+vo.getCode());
});
list.add(taskVo);
Set<String> currentScheduleCodeSet = this.getCurrentScheduleCodeSet();
@ -85,12 +84,28 @@ public class ScheduleServiceImpl implements ScheduleService {
if(null == task) {
continue;
}
if(!this.isTaskCodeExist(task.getCode(), currentScheduleCodeSet)) {//未在进程中
if(!this.isTaskCodeExist(task.getCode(), currentScheduleCodeSet)){//未在进程中
this.startTask(task);
}else{//已存在
this.updateJobTime(task);
}
}
for (String str : currentScheduleCodeSet) {
System.err.println(str);
Boolean isCz=true;
for (TaskVo vo:list){
if(vo.getCode().equals(str)){
isCz=false;
}
}
if(isCz){
TaskVo taskVo=new TaskVo();
taskVo.setJobClass("com.bonus.tcp.task.job.TestJob");
taskVo.setTaskCode("TASK_"+str);
taskVo.setCode(str);
stopTask(taskVo);
}
}
}
/**

View File

@ -90,8 +90,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getShCodeByGt" resultType="java.lang.String">
SELECT bt.sh_code
FROM tb_sh_box box
LEFT JOIN tb_bracelet bt on box.id=bt.box_id AND bt.del_flag=0
where box.del_flag=0 and box.gt_id=#{gtId}
LEFT JOIN tb_bracelet bt on box.id=bt.box_id AND bt.del_flag=0
where box.del_flag=0 and box.gt_id=#{gtId} and bid_id is not null
</select>
<select id="getBdShCode" resultType="java.lang.String">
select sh_code
from tb_bracelet
where sh_code in(
<foreach collection="list" item="shCode" separator=",">
#{shCode}
</foreach>
)
and bid_id is not null and del_flag=0
</select>
<update id="updateDetails">
update tb_dev_details SET data_val=#{dataVal} ,data_time=now()