From 0aee8f3e8a6f40fba20a5472eb8470d03f34ab84 Mon Sep 17 00:00:00 2001 From: guoshengxiong <1923636941@qq.com> Date: Wed, 14 May 2025 18:14:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E6=95=B0=E6=8D=AE=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MockTowerAlarmConfigController.java | 15 ++++ .../MockTowerCurrentDataConfigController.java | 16 ++++ .../controller/TowerAlarmController.java | 19 ++++- .../TowerCurrentDataController.java | 1 + .../entity/MockTowerCurrentDataConfig.java | 2 + .../bigdevice/service/ITowerAlarmService.java | 9 +++ .../service/impl/TowerAlarmServiceImpl.java | 6 +- .../MockDustNoiseDataConfigController.java | 15 ++++ ...tectionDevCurrentDataConfigController.java | 16 ++++ ...rontierProtectionDevCurrentDataConfig.java | 9 ++- ...erProtectionNoNetDataConfigController.java | 17 ++++ .../MockLocationDataConfigController.java | 16 ++++ .../MockSafetyHatAlarmConfigController.java | 16 ++++ .../MockSafetyHatDataConfigController.java | 15 ++++ ...kVehiclePositionAlarmConfigController.java | 16 ++++ ...ckVehiclePositionDataConfigController.java | 16 ++++ ...iclePositionDayRecordConfigController.java | 17 ++++ .../MockWorkerAttendanceConfigController.java | 16 ++++ .../entity/MockWorkerAttendanceConfig.java | 4 +- src/main/java/com/zhgd/xmgl/util/RefUtil.java | 79 +++++++++++++++++++ 20 files changed, 312 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerAlarmConfigController.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerAlarmConfigController.java index 5937f46c2..664dd8e4f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerAlarmConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerAlarmConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.bigdevice.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -154,4 +157,16 @@ public class MockTowerAlarmConfigController { return Result.ok(); } + @OperLog(operModul = "模拟塔机报警数据配置管理", operType = "重置", operDesc = "重置模拟塔机报警数据配置信息") + @ApiOperation(value = "重置模拟塔机报警数据配置信息", notes = "重置模拟塔机报警数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockTowerAlarmConfig mockWorkerAttendanceConfig) { + MockTowerAlarmConfig one = mockTowerAlarmConfigService.getOne(new LambdaQueryWrapper() + .eq(MockTowerAlarmConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockTowerAlarmConfigService, MockTowerAlarmConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerCurrentDataConfigController.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerCurrentDataConfigController.java index 312071d56..dbd1b0073 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerCurrentDataConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/MockTowerCurrentDataConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.bigdevice.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.bigdevice.entity.MockTowerAlarmConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -153,4 +156,17 @@ public class MockTowerCurrentDataConfigController { mockTowerCurrentDataConfigService.saveEntity(mockTowerCurrentDataConfig); return Result.ok(); } + + @OperLog(operModul = "模拟塔基实时数据配置管理", operType = "重置", operDesc = "重置模拟塔基实时数据配置信息") + @ApiOperation(value = "重置模拟塔基实时数据配置信息", notes = "重置模拟塔基实时数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockTowerCurrentDataConfig mockWorkerAttendanceConfig) { + MockTowerCurrentDataConfig one = mockTowerCurrentDataConfigService.getOne(new LambdaQueryWrapper() + .eq(MockTowerCurrentDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockTowerCurrentDataConfigService, MockTowerCurrentDataConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerAlarmController.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerAlarmController.java index 64fbf2a34..50b20ad5c 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerAlarmController.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerAlarmController.java @@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zhgd.annotation.OperLog; @@ -21,6 +22,7 @@ import com.zhgd.xmgl.modules.bigdevice.entity.vo.DriverTowerAbnormalCountVo; import com.zhgd.xmgl.modules.bigdevice.service.IMockTowerAlarmConfigService; import com.zhgd.xmgl.modules.bigdevice.service.ITowerAlarmService; import com.zhgd.xmgl.modules.bigdevice.service.ITowerService; +import com.zhgd.xmgl.util.MessageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -111,11 +113,26 @@ public class TowerAlarmController { @PostMapping(value = "/add") public Result add(@RequestBody TowerAlarm towerAlarm) { log.info("添加塔机报警数据:{}", JSON.toJSONString(towerAlarm)); - towerAlarmService.saveTowerAlarm(towerAlarm); return Result.ok(); } + @OperLog(operModul = "塔机管理", operType = "编辑塔机报警数据", operDesc = "编辑塔机报警数据") + @ApiOperation(value = "编辑塔机报警数据", notes = "编辑塔机报警数据", httpMethod = "POST") + @PostMapping(value = "/edit") + public Result edit(@RequestBody TowerAlarm towerAlarm) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(Tower::getDevSn, towerAlarm.getDevSn()); + Tower tower = towerService.getOne(queryWrapper); + if (tower == null) { + throw new OpenAlertException(MessageUtil.get("EquipmentNumIncorrectErr")); + } + log.info("编辑塔机报警数据:{}", JSON.toJSONString(towerAlarm)); + towerAlarmService.updateById(towerAlarm); + towerAlarmService.sendAlarm(towerAlarm, tower); + return Result.ok(); + } + @ApiOperation(value = "列表查询塔机间碰撞报警", notes = "列表查询塔机间碰撞报警", httpMethod = "POST") @ApiImplicitParams({ @ApiImplicitParam(name = "opType", value = "类型,1当日,2本周,默认当日", dataType = "String", paramType = "body", required = true), diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerCurrentDataController.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerCurrentDataController.java index 62c5e3484..f82caba10 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerCurrentDataController.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/controller/TowerCurrentDataController.java @@ -205,6 +205,7 @@ public class TowerCurrentDataController { for (int i = 0; i < config.getDevGenerateNum(); i++) { TowerCurrentData data = new TowerCurrentData(); BeanUtils.copyProperties(config, data); + data.setId(null); data.setDevSn(devId); data.setDevName(Optional.ofNullable(devSnMap.get(devId)).map(m -> m.getDevName()).orElse(null)); data.setProjectSn(config.getProjectSn()); diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/entity/MockTowerCurrentDataConfig.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/entity/MockTowerCurrentDataConfig.java index 78673fb88..9fa0ed4a3 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/entity/MockTowerCurrentDataConfig.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/entity/MockTowerCurrentDataConfig.java @@ -433,4 +433,6 @@ public class MockTowerCurrentDataConfig implements Serializable { */ @ApiModelProperty(value = "回转状态 0:停止回转 1:向右回转 2:向左回转(多个数字,分割)") private java.lang.String angleDirections; + + } diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/ITowerAlarmService.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/ITowerAlarmService.java index f7737499c..7bd773293 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/ITowerAlarmService.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/ITowerAlarmService.java @@ -3,6 +3,7 @@ package com.zhgd.xmgl.modules.bigdevice.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.zhgd.jeecg.common.mybatis.EntityMap; +import com.zhgd.xmgl.modules.bigdevice.entity.Tower; import com.zhgd.xmgl.modules.bigdevice.entity.TowerAlarm; import com.zhgd.xmgl.modules.bigdevice.entity.TowerCurrentData; import com.zhgd.xmgl.modules.bigdevice.entity.vo.AlarmsDistinguishedNumberByAlarmType; @@ -42,6 +43,14 @@ public interface ITowerAlarmService extends IService { void saveTowerAlarm(TowerAlarm towerAlarm); + /** + * 发送报警 + * + * @param towerAlarm + * @param tower + */ + void sendAlarm(TowerAlarm towerAlarm, Tower tower); + void addEarlyWarning(TowerCurrentData towerCurrentData, int alarmType); IPage selectAllAlarmList(Map map); diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerAlarmServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerAlarmServiceImpl.java index 42e956b01..ec6580058 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerAlarmServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerAlarmServiceImpl.java @@ -348,7 +348,11 @@ public class TowerAlarmServiceImpl extends ServiceImpl() + .eq(MockDustNoiseDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockDustNoiseDataConfigService, MockDustNoiseDataConfig.class, one.getId()); + } + return Result.ok(); + } + } diff --git a/src/main/java/com/zhgd/xmgl/modules/frontier/controller/MockFrontierProtectionDevCurrentDataConfigController.java b/src/main/java/com/zhgd/xmgl/modules/frontier/controller/MockFrontierProtectionDevCurrentDataConfigController.java index 72504fef6..085128b22 100644 --- a/src/main/java/com/zhgd/xmgl/modules/frontier/controller/MockFrontierProtectionDevCurrentDataConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/frontier/controller/MockFrontierProtectionDevCurrentDataConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.frontier.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -154,4 +157,17 @@ public class MockFrontierProtectionDevCurrentDataConfigController { return Result.ok(); } + + @OperLog(operModul = "模拟临边防护设备实时数据配置管理", operType = "重置", operDesc = "重置模拟临边防护设备实时数据配置信息") + @ApiOperation(value = "重置模拟临边防护设备实时数据配置信息", notes = "重置模拟临边防护设备实时数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockFrontierProtectionDevCurrentDataConfig mockWorkerAttendanceConfig) { + MockFrontierProtectionDevCurrentDataConfig one = mockFrontierProtectionDevCurrentDataConfigService.getOne(new LambdaQueryWrapper() + .eq(MockFrontierProtectionDevCurrentDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockFrontierProtectionDevCurrentDataConfigService, MockFrontierProtectionDevCurrentDataConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/frontier/entity/MockFrontierProtectionDevCurrentDataConfig.java b/src/main/java/com/zhgd/xmgl/modules/frontier/entity/MockFrontierProtectionDevCurrentDataConfig.java index 5763d4f1a..11339ed7b 100644 --- a/src/main/java/com/zhgd/xmgl/modules/frontier/entity/MockFrontierProtectionDevCurrentDataConfig.java +++ b/src/main/java/com/zhgd/xmgl/modules/frontier/entity/MockFrontierProtectionDevCurrentDataConfig.java @@ -3,9 +3,7 @@ package com.zhgd.xmgl.modules.frontier.entity; import java.io.Serializable; import java.util.Date; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; @@ -45,6 +43,7 @@ public class MockFrontierProtectionDevCurrentDataConfig implements Serializable * 每个设备随机生成数量 */ @ApiModelProperty(value = "每个设备随机生成数量") + @TableField(updateStrategy = FieldStrategy.IGNORED) private java.lang.Integer devGenerateNum; /** * 开始时间 @@ -52,6 +51,7 @@ public class MockFrontierProtectionDevCurrentDataConfig implements Serializable @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "开始时间") + @TableField(updateStrategy = FieldStrategy.IGNORED) private java.util.Date startTime; /** * 结束时间 @@ -59,6 +59,7 @@ public class MockFrontierProtectionDevCurrentDataConfig implements Serializable @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "结束时间") + @TableField(updateStrategy = FieldStrategy.IGNORED) private java.util.Date endTime; /** * 创建时间 @@ -78,11 +79,13 @@ public class MockFrontierProtectionDevCurrentDataConfig implements Serializable * 剩余电量百分比(0-100)开始 */ @ApiModelProperty(value = "剩余电量百分比(0-100)开始") + @TableField(updateStrategy = FieldStrategy.IGNORED) private java.lang.Float batteryBegin; /** * 剩余电量百分比(0-100)结束 */ @ApiModelProperty(value = "剩余电量百分比(0-100)结束") + @TableField(updateStrategy = FieldStrategy.IGNORED) private java.lang.Float batteryEnd; /** * 线锁1 状态 1-正常;2-断开;3-正常断开(多个数字,分割) diff --git a/src/main/java/com/zhgd/xmgl/modules/frontierprotectionnonet/controller/MockFrontierProtectionNoNetDataConfigController.java b/src/main/java/com/zhgd/xmgl/modules/frontierprotectionnonet/controller/MockFrontierProtectionNoNetDataConfigController.java index 35d560c6a..373430f91 100644 --- a/src/main/java/com/zhgd/xmgl/modules/frontierprotectionnonet/controller/MockFrontierProtectionNoNetDataConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/frontierprotectionnonet/controller/MockFrontierProtectionNoNetDataConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.frontierprotectionnonet.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -153,4 +156,18 @@ public class MockFrontierProtectionNoNetDataConfigController { mockFrontierProtectionNoNetDataConfigService.saveEntity(mockFrontierProtectionNoNetDataConfig); return Result.ok(); } + + + @OperLog(operModul = "模拟临边防护(无网)数据配置管理", operType = "重置", operDesc = "重置模拟临边防护(无网)数据配置信息") + @ApiOperation(value = "重置模拟临边防护(无网)数据配置信息", notes = "重置模拟临边防护(无网)数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockFrontierProtectionNoNetDataConfig mockWorkerAttendanceConfig) { + MockFrontierProtectionNoNetDataConfig one = mockFrontierProtectionNoNetDataConfigService.getOne(new LambdaQueryWrapper() + .eq(MockFrontierProtectionNoNetDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockFrontierProtectionNoNetDataConfigService, MockFrontierProtectionNoNetDataConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/location/controller/MockLocationDataConfigController.java b/src/main/java/com/zhgd/xmgl/modules/location/controller/MockLocationDataConfigController.java index fca503761..38528765d 100644 --- a/src/main/java/com/zhgd/xmgl/modules/location/controller/MockLocationDataConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/location/controller/MockLocationDataConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.location.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -153,4 +156,17 @@ public class MockLocationDataConfigController { mockLocationDataConfigService.saveEntity(mockLocationDataConfig); return Result.ok(); } + + @OperLog(operModul = "模拟定位数据配置管理", operType = "重置", operDesc = "重置模拟定位数据配置信息") + @ApiOperation(value = "重置模拟定位数据配置信息", notes = "重置模拟定位数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockLocationDataConfig mockWorkerAttendanceConfig) { + MockLocationDataConfig one = mockLocationDataConfigService.getOne(new LambdaQueryWrapper() + .eq(MockLocationDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockLocationDataConfigService, MockLocationDataConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatAlarmConfigController.java b/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatAlarmConfigController.java index efd959c93..19ddded3d 100644 --- a/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatAlarmConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatAlarmConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.safetyhat.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -146,4 +149,17 @@ public class MockSafetyHatAlarmConfigController { mockSafetyHatAlarmConfigService.saveEntity(mockSafetyHatAlarmConfig); return Result.ok(); } + + @OperLog(operModul = "模拟智能安全帽报警配置管理", operType = "重置", operDesc = "重置模拟智能安全帽报警配置信息") + @ApiOperation(value = "重置模拟智能安全帽报警配置信息", notes = "重置模拟智能安全帽报警配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockSafetyHatAlarmConfig mockWorkerAttendanceConfig) { + MockSafetyHatAlarmConfig one = mockSafetyHatAlarmConfigService.getOne(new LambdaQueryWrapper() + .eq(MockSafetyHatAlarmConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockSafetyHatAlarmConfigService, MockSafetyHatAlarmConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatDataConfigController.java b/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatDataConfigController.java index b659beb74..646f8b8b7 100644 --- a/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatDataConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/safetyhat/controller/MockSafetyHatDataConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.safetyhat.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -154,4 +157,16 @@ public class MockSafetyHatDataConfigController { return Result.ok(); } + @OperLog(operModul = "模拟智能安全帽实时数据配置管理", operType = "重置", operDesc = "重置模拟智能安全帽实时数据配置信息") + @ApiOperation(value = "重置模拟智能安全帽实时数据配置信息", notes = "重置模拟智能安全帽实时数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockSafetyHatDataConfig mockWorkerAttendanceConfig) { + MockSafetyHatDataConfig one = mockSafetyHatDataConfigService.getOne(new LambdaQueryWrapper() + .eq(MockSafetyHatDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockSafetyHatDataConfigService, MockSafetyHatDataConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionAlarmConfigController.java b/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionAlarmConfigController.java index 52d8786f1..63d22cddd 100644 --- a/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionAlarmConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionAlarmConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.vehicleposition.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -153,4 +156,17 @@ public class MockVehiclePositionAlarmConfigController { mockVehiclePositionAlarmConfigService.saveEntity(mockVehiclePositionAlarmConfig); return Result.ok(); } + + @OperLog(operModul = "模拟车辆(人员)定位报警记录配置管理", operType = "重置", operDesc = "重置模拟车辆(人员)定位报警记录配置信息") + @ApiOperation(value = "重置模拟车辆(人员)定位报警记录配置信息", notes = "重置模拟车辆(人员)定位报警记录配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockVehiclePositionAlarmConfig mockWorkerAttendanceConfig) { + MockVehiclePositionAlarmConfig one = mockVehiclePositionAlarmConfigService.getOne(new LambdaQueryWrapper() + .eq(MockVehiclePositionAlarmConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockVehiclePositionAlarmConfigService, MockVehiclePositionAlarmConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDataConfigController.java b/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDataConfigController.java index 2028206e9..f8fb347ce 100644 --- a/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDataConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDataConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.vehicleposition.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -153,4 +156,17 @@ public class MockVehiclePositionDataConfigController { mockVehiclePositionDataConfigService.saveEntity(mockVehiclePositionDataConfig); return Result.ok(); } + + @OperLog(operModul = "模拟车辆(人员)定位实时数据配置管理", operType = "重置", operDesc = "重置模拟车辆(人员)定位实时数据配置信息") + @ApiOperation(value = "重置模拟车辆(人员)定位实时数据配置信息", notes = "重置模拟车辆(人员)定位实时数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockVehiclePositionDataConfig mockWorkerAttendanceConfig) { + MockVehiclePositionDataConfig one = mockVehiclePositionDataConfigService.getOne(new LambdaQueryWrapper() + .eq(MockVehiclePositionDataConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockVehiclePositionDataConfigService, MockVehiclePositionDataConfig.class, one.getId()); + } + return Result.ok(); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDayRecordConfigController.java b/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDayRecordConfigController.java index 9f5017070..4821176c7 100644 --- a/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDayRecordConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/vehicleposition/controller/MockVehiclePositionDayRecordConfigController.java @@ -1,7 +1,10 @@ package com.zhgd.xmgl.modules.vehicleposition.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.modules.worker.entity.MockWorkerAttendanceConfig; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -153,4 +156,18 @@ public class MockVehiclePositionDayRecordConfigController { mockVehiclePositionDayRecordConfigService.saveEntity(mockVehiclePositionDayRecordConfig); return Result.ok(); } + + @OperLog(operModul = "模拟车辆(人员)定位日行数据配置管理", operType = "重置", operDesc = "重置模拟车辆(人员)定位日行数据配置信息") + @ApiOperation(value = "重置模拟车辆(人员)定位日行数据配置信息", notes = "重置模拟车辆(人员)定位日行数据配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockVehiclePositionDayRecordConfig mockWorkerAttendanceConfig) { + MockVehiclePositionDayRecordConfig one = mockVehiclePositionDayRecordConfigService.getOne(new LambdaQueryWrapper() + .eq(MockVehiclePositionDayRecordConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockVehiclePositionDayRecordConfigService, MockVehiclePositionDayRecordConfig.class, one.getId()); + } + return Result.ok(); + } } + diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/controller/MockWorkerAttendanceConfigController.java b/src/main/java/com/zhgd/xmgl/modules/worker/controller/MockWorkerAttendanceConfigController.java index 3e2455ccd..67816a67f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/controller/MockWorkerAttendanceConfigController.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/controller/MockWorkerAttendanceConfigController.java @@ -2,7 +2,9 @@ package com.zhgd.xmgl.modules.worker.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.zhgd.annotation.OperLog; +import com.zhgd.xmgl.util.RefUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -154,5 +156,19 @@ public class MockWorkerAttendanceConfigController { mockWorkerAttendanceConfigService.saveEntity(mockWorkerAttendanceConfig); return Result.ok(); } + + @OperLog(operModul = "模拟人员考勤配置管理", operType = "重置", operDesc = "重置模拟人员考勤配置信息") + @ApiOperation(value = "重置模拟人员考勤配置信息", notes = "重置模拟人员考勤配置信息", httpMethod = "POST") + @PostMapping(value = "/reset") + public Result reset(@RequestBody @Validate MockWorkerAttendanceConfig mockWorkerAttendanceConfig) { + MockWorkerAttendanceConfig one = mockWorkerAttendanceConfigService.getOne(new LambdaQueryWrapper() + .eq(MockWorkerAttendanceConfig::getProjectSn, mockWorkerAttendanceConfig.getProjectSn()) + ); + if (one != null) { + RefUtil.setFieldsToNull(mockWorkerAttendanceConfigService, MockWorkerAttendanceConfig.class, one.getId()); + } + return Result.ok(); + } + } diff --git a/src/main/java/com/zhgd/xmgl/modules/worker/entity/MockWorkerAttendanceConfig.java b/src/main/java/com/zhgd/xmgl/modules/worker/entity/MockWorkerAttendanceConfig.java index 91aaed0f6..72c346f55 100644 --- a/src/main/java/com/zhgd/xmgl/modules/worker/entity/MockWorkerAttendanceConfig.java +++ b/src/main/java/com/zhgd/xmgl/modules/worker/entity/MockWorkerAttendanceConfig.java @@ -3,9 +3,7 @@ package com.zhgd.xmgl.modules.worker.entity; import java.io.Serializable; import java.util.Date; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; diff --git a/src/main/java/com/zhgd/xmgl/util/RefUtil.java b/src/main/java/com/zhgd/xmgl/util/RefUtil.java index c20f0d368..64d039dbd 100644 --- a/src/main/java/com/zhgd/xmgl/util/RefUtil.java +++ b/src/main/java/com/zhgd/xmgl/util/RefUtil.java @@ -1,6 +1,10 @@ package com.zhgd.xmgl.util; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.IService; import lombok.extern.slf4j.Slf4j; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; @@ -9,6 +13,7 @@ import java.beans.Introspector; import java.lang.invoke.SerializedLambda; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -102,4 +107,78 @@ public class RefUtil { } throw new NoSuchFieldError(fieldName); } + + /** + * 根据id清空实体类字段,保留id,projectSn不清除 + * + * @param service + * @param clazz + * @param id + * @param + * @param + */ + public static , T> void setFieldsToNull(S service, Class clazz, Object id) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + String idColumn = getIdColumnName(clazz); + + for (Field field : clazz.getDeclaredFields()) { + // 新增过滤条件:跳过静态字段和serialVersionUID字段 + if (Modifier.isStatic(field.getModifiers()) || "serialVersionUID".equals(field.getName()) || "projectSn".equals(field.getName())) { + continue; + } + if (field.isAnnotationPresent(TableId.class)) { + continue; + } + + TableField tableField = field.getAnnotation(TableField.class); + if (tableField != null && !tableField.exist()) { + continue; + } + + String columnName = getColumnName(field); + updateWrapper.set(columnName, null); + } + + updateWrapper.eq(idColumn, id); + service.update(updateWrapper); + } + + private static String getIdColumnName(Class clazz) { + // 保持原有逻辑不变 + for (Field field : clazz.getDeclaredFields()) { + if (field.isAnnotationPresent(TableId.class)) { + TableId tableId = field.getAnnotation(TableId.class); + if (tableId != null && !tableId.value().isEmpty()) { + return tableId.value(); + } + return camelToUnderline(field.getName()); + } + } + throw new IllegalArgumentException("No @TableId field found in " + clazz.getName()); + } + + private static String getColumnName(Field field) { + // 保持原有逻辑不变 + TableField tableField = field.getAnnotation(TableField.class); + if (tableField != null && !tableField.value().isEmpty()) { + return tableField.value(); + } + return camelToUnderline(field.getName()); + } + + private static String camelToUnderline(String camel) { + // 保持原有逻辑不变 + if (camel == null || camel.isEmpty()) return camel; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < camel.length(); i++) { + char c = camel.charAt(i); + if (Character.isUpperCase(c)) { + if (i > 0) sb.append('_'); + sb.append(Character.toLowerCase(c)); + } else { + sb.append(c); + } + } + return sb.toString(); + } }