From bc3a15116b4c8c455522563f5161548f5d0dbbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Sat, 15 Nov 2025 22:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AgvStationServiceImpl.java | 80 +++++++++++++++++++ .../service/impl/PalletServiceImpl.java | 48 +++++++++++ 2 files changed, 128 insertions(+) diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AgvStationServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AgvStationServiceImpl.java index f4c04a9..c98ca77 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AgvStationServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AgvStationServiceImpl.java @@ -13,6 +13,8 @@ import com.gaotao.modules.automatedWarehouse.mapper.AgvStationMapper; import com.gaotao.modules.automatedWarehouse.service.AgvStationService; import com.gaotao.modules.warehouse.entity.Location; import com.gaotao.modules.warehouse.dao.LocationMapper; +import com.gaotao.modules.system.entity.SensitiveFieldChangeLog; // 新增 - rqrq +import com.gaotao.modules.system.service.SensitiveFieldChangeLogService; // 新增 - rqrq import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -30,6 +32,8 @@ public class AgvStationServiceImpl extends ServiceImpl diff --git a/src/main/java/com/gaotao/modules/warehouse/service/impl/PalletServiceImpl.java b/src/main/java/com/gaotao/modules/warehouse/service/impl/PalletServiceImpl.java index 654bf06..c2b6d5f 100644 --- a/src/main/java/com/gaotao/modules/warehouse/service/impl/PalletServiceImpl.java +++ b/src/main/java/com/gaotao/modules/warehouse/service/impl/PalletServiceImpl.java @@ -16,6 +16,8 @@ import com.gaotao.modules.warehouse.entity.PalletData; import com.gaotao.modules.warehouse.entity.dto.PalletQueryDto; import com.gaotao.modules.warehouse.entity.vo.PalletVo; import com.gaotao.modules.warehouse.service.PalletService; +import com.gaotao.modules.system.entity.SensitiveFieldChangeLog; // 新增 - rqrq +import com.gaotao.modules.system.service.SensitiveFieldChangeLogService; // 新增 - rqrq import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,6 +40,8 @@ public class PalletServiceImpl extends ServiceImpl impleme private TransNoControlService transNoControlService; @Autowired private WcsIntegrationMapper wcsIntegrationMapper; + @Autowired + private SensitiveFieldChangeLogService sensitiveFieldChangeLogService; // 新增 - rqrq @Override public PageUtils queryPage(PalletData queryDto) { @@ -121,6 +125,9 @@ public class PalletServiceImpl extends ServiceImpl impleme public boolean updatePallet(PalletData palletData) { System.out.println("开始修改托盘 - rqrq,托盘ID:" + palletData.getPalletId()); + // 查询修改前的托盘信息 - rqrq + Pallet oldPallet = this.getById(palletData.getId()); + // 检查托盘ID是否已被其他记录使用 - rqrq if (checkPalletIdExists(palletData.getPalletId(), palletData.getId())) { throw new RuntimeException("托盘ID [" + palletData.getPalletId() + "] 已被其他记录使用"); @@ -139,6 +146,47 @@ public class PalletServiceImpl extends ServiceImpl impleme palletData.setUpdatedTime(new Date()); boolean result = this.updateById(palletData); + + // 记录location_code变化 - rqrq + if (oldPallet != null) { + String oldLocationCode = oldPallet.getLocationCode(); + String newLocationCode = palletData.getLocationCode(); + + // 判断location_code是否发生变化 - rqrq + boolean locationChanged = false; + if (oldLocationCode == null && newLocationCode != null) { + locationChanged = true; + } else if (oldLocationCode != null && !oldLocationCode.equals(newLocationCode)) { + locationChanged = true; + } + + if (locationChanged) { + System.out.println("检测到location_code变化 - rqrq,原值:" + oldLocationCode + ",新值:" + newLocationCode); + + try { + SensitiveFieldChangeLog log = new SensitiveFieldChangeLog(); + log.setSite(palletData.getSite()); + log.setFunctionPage("托盘管理"); + log.setOperationName("修改托盘"); + log.setOperationObject("托盘" + palletData.getPalletId()); + log.setTableName("pallet"); + log.setFieldName("location_code"); + log.setOldValue(oldLocationCode != null ? oldLocationCode : ""); + log.setNewValue(newLocationCode != null ? newLocationCode : ""); + log.setOperator("SYSTEM"); // 可根据实际情况从上下文获取 - rqrq + log.setOperationTime(new Date()); + log.setRecordId(palletData.getId()); + log.setOperationType("UPDATE"); + + sensitiveFieldChangeLogService.recordFieldChange(log); + } catch (Exception e) { + System.out.println("记录location_code变化失败 - rqrq:" + e.getMessage()); + e.printStackTrace(); + // 不影响主流程,只记录异常 - rqrq + } + } + } + System.out.println("托盘修改完成 - rqrq"); return result; }