diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/abnormal/service/impl/AbnormalConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/abnormal/service/impl/AbnormalConverterImpl.java index d9974f4c..c39fa534 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/abnormal/service/impl/AbnormalConverterImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/abnormal/service/impl/AbnormalConverterImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.ss.abnormal.service.impl; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.ss.abnormal.domain.Abnormal; import com.ruoyi.ss.abnormal.domain.dto.AbnormalSubmitDTO; @@ -10,6 +11,8 @@ import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.mapper.DeviceMapper; import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.store.service.StoreService; +import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO; +import com.ruoyi.ss.transactionBill.service.TransactionBillService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,6 +32,9 @@ public class AbnormalConverterImpl implements AbnormalConverter { @Autowired private StoreService storeService; + @Autowired + private TransactionBillService transactionBillService; + @Override public Abnormal toPo(AbnormalSubmitDTO dto) { @@ -51,6 +57,30 @@ public class AbnormalConverterImpl implements AbnormalConverter { po.setAddress(dto.getAddress()); po.setStatus(AbnormalStatus.UNDO.getStatus()); po.setCreateBy(dto.getCreateBy()); + + TransactionBillVO transactionBillVO = transactionBillService.selectSmTransactionBillByBillId(dto.getOrderId()); + if (dto.getOrderId() != null && dto.getDeviceNo() != null) { + if (transactionBillVO == null) { + ServiceUtil.assertion(true,"当前订单不存在"); + } + if (!transactionBillVO.getDeviceNo().equals(dto.getDeviceNo())) { + ServiceUtil.assertion(true,"当前设备与订单无关联"); + } + } + // 获取订单商户id + if ( dto.getOrderId()!= null) { + po.setOrderNo(transactionBillVO.getBillNo()); + if(transactionBillVO.getMchId()!=null){ + po.setStoreId(transactionBillVO.getMchId()); + } + } + // 获取设备商户id + if (dto.getDeviceNo() != null) { + Long storeId = device.getStoreId(); + if (storeId != null) { + po.setStoreId(storeId); + } + } return po; } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index 75f38566..c98ffffb 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -245,13 +245,17 @@ public class DeviceServiceImpl implements DeviceService data.setUpdateTime(DateUtils.getNowDate()); Integer result = transactionTemplate.execute(status -> { - // deviceMapper.selectByDeviceId(data.getDeviceNo()); + + DeviceVO deviceVO = deviceMapper.selectSmDeviceByDeviceId(data.getDeviceId()); // 生成SnLog记录 SnLog snLog = new SnLog(); snLog.setDeviceId(data.getDeviceId()); snLog.setUserId(SecurityUtils.getUserId()); snLog.setMac(data.getMac()); + snLog.setOldSn(deviceVO.getDeviceNo()); + snLog.setNewSn(data.getDeviceNo()); + snLog.setUpdateTime(DateUtils.getNowDate()); // 更新主表 int update = deviceMapper.updateSmDevice(data); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java index 97bb1c09..0b79d6c1 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAbnormalController.java @@ -53,33 +53,6 @@ public class AppAbnormalController extends BaseController { public AjaxResult submit(@RequestBody @Validated(ValidGroup.FrontCreate.class) AbnormalSubmitDTO data) { data.setUserId(getUserId()); data.setCreateBy(getUsername()); - TransactionBillVO transactionBillVO = transactionBillService.selectSmTransactionBillByBillId(data.getOrderId()); - DeviceVO deviceVO = deviceService.selectByDeviceNo(data.getDeviceNo()); - if (data.getOrderId() != null && data.getDeviceNo() != null) { - if (transactionBillVO == null) { - return AjaxResult.error("当前订单不存在"); - } - if (deviceVO == null) { - return AjaxResult.error("当前设备不存在"); - } - if (!transactionBillVO.getDeviceNo().equals(data.getDeviceNo())) { - return AjaxResult.error("当前设备与订单无关联"); - } - } - // 获取订单商户id - if ( data.getOrderId()!= null) { - data.setOrderNo(transactionBillVO.getBillNo()); - if(transactionBillVO.getMchId()!=null){ - data.setStoreId(transactionBillVO.getMchId()); - } - } - // 获取设备商户id - if (data.getDeviceNo() != null) { - Long storeId = deviceVO.getStoreId(); - if (storeId != null) { - data.setStoreId(storeId); - } - } return success(abnormalService.insertAbnormal(abnormalConverter.toPo(data))); }