套餐校验设备是否支持电量
This commit is contained in:
parent
9877f3a1f6
commit
d7c8581bdd
|
@ -170,14 +170,14 @@ public interface DeviceService
|
|||
/**
|
||||
* ids查询列表
|
||||
*/
|
||||
default List<DeviceVO> selectListByIds(List<Long> ids) {
|
||||
return selectListByIds(ids, null);
|
||||
default List<DeviceVO> selectByIds(List<Long> ids) {
|
||||
return selectByIds(ids, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* ids查询列表
|
||||
*/
|
||||
List<DeviceVO> selectListByIds(List<Long> ids, Long userId);
|
||||
List<DeviceVO> selectByIds(List<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 查询各店铺的设备数量,并分组
|
||||
|
@ -348,11 +348,6 @@ public interface DeviceService
|
|||
|
||||
int setWifi(DeviceWifiDTO dto);
|
||||
|
||||
/**
|
||||
* 根据设备ID列表查询
|
||||
*/
|
||||
List<DeviceVO> selectByDeviceIds(List<Long> deviceIds);
|
||||
|
||||
/**
|
||||
* 根据mac查询设备
|
||||
*/
|
||||
|
|
|
@ -376,7 +376,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
List<TransactionBillVO> usingBills = transactionBillService.selectUsingBill(userId);
|
||||
List<Long> deviceIds = usingBills.stream().map(TransactionBillVO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
// 查询设备列表
|
||||
return this.selectListByIds(deviceIds);
|
||||
return this.selectByIds(deviceIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -640,13 +640,6 @@ public class DeviceServiceImpl implements DeviceService
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceVO> selectByDeviceIds(List<Long> deviceIds) {
|
||||
DeviceQuery query = new DeviceQuery();
|
||||
query.setDeviceIds(deviceIds);
|
||||
return this.selectSmDeviceList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceVO selectByAnyMac(String mac) {
|
||||
return deviceMapper.selectByAnyMac(mac);
|
||||
|
@ -774,7 +767,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
// 拉取最新数据
|
||||
this.pullDeviceInfo(deviceIds);
|
||||
// 查询设备列表
|
||||
List<DeviceVO> deviceList = this.selectByDeviceIds(deviceIds);
|
||||
List<DeviceVO> deviceList = this.selectByIds(deviceIds);
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 关闭设备订单
|
||||
|
@ -1172,7 +1165,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
* @param userId
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceVO> selectListByIds(List<Long> ids, Long userId) {
|
||||
public List<DeviceVO> selectByIds(List<Long> ids, Long userId) {
|
||||
if (CollectionUtils.isEmptyElement(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,13 @@ import com.ruoyi.common.core.domain.BaseValidator;
|
|||
import com.ruoyi.common.core.domain.ValidateResult;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.device.service.DeviceValidator;
|
||||
import com.ruoyi.ss.model.domain.enums.ModelTag;
|
||||
import com.ruoyi.ss.suit.domain.SuitBO;
|
||||
import com.ruoyi.ss.suit.domain.SuitQuery;
|
||||
import com.ruoyi.ss.suit.domain.SuitVO;
|
||||
|
@ -42,6 +46,9 @@ public class SuitValidatorImpl extends BaseValidator implements SuitValidator {
|
|||
@Autowired
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Override
|
||||
public ValidateResult preLogicDel(List<Long> suitIds) {
|
||||
if (CollectionUtils.isEmptyElement(suitIds)) {
|
||||
|
@ -143,7 +150,6 @@ public class SuitValidatorImpl extends BaseValidator implements SuitValidator {
|
|||
SuitVO old = suitService.selectSuitBySuitId(suit.getSuitId());
|
||||
boolean create = old == null; // 是否新建
|
||||
|
||||
|
||||
// 创建或者修改其中一个时
|
||||
if (create || suit.getFeeType() != null || suit.getFeeMode() != null) {
|
||||
|
||||
|
@ -182,6 +188,20 @@ public class SuitValidatorImpl extends BaseValidator implements SuitValidator {
|
|||
}
|
||||
}
|
||||
|
||||
// 判断设备是否支持电量
|
||||
if (SuitFeeType.rechargeCountList().contains(suit.getFeeType()) && CollectionUtils.isNotEmptyElement(suit.getDeviceIds())) {
|
||||
List<DeviceVO> deviceList = deviceService.selectByIds(new ArrayList<>(suit.getDeviceIds()));
|
||||
List<String> unSupport = new ArrayList<>();
|
||||
for (DeviceVO device : deviceList) {
|
||||
if (!ModelTag.hasTag(device.getModelTags(), ModelTag.ELE)) {
|
||||
unSupport.add(device.getDeviceNo());
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmptyElement(unSupport)) {
|
||||
return error("以下设备不支持电量套餐:" + StringUtils.join(unSupport, ","));
|
||||
}
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +28,7 @@ public class MchDeviceController extends BaseController {
|
|||
@GetMapping("/listByIds/{ids}")
|
||||
public AjaxResult listByIds(@PathVariable List<Long> ids)
|
||||
{
|
||||
List<DeviceVO> list = deviceService.selectListByIds(ids, getUserId());
|
||||
List<DeviceVO> list = deviceService.selectByIds(ids, getUserId());
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SmDeviceController extends BaseController
|
|||
@GetMapping("/listByIds/{ids}")
|
||||
public AjaxResult listByIds(@PathVariable Long[] ids)
|
||||
{
|
||||
List<DeviceVO> list = deviceService.selectListByIds(Arrays.asList(ids));
|
||||
List<DeviceVO> list = deviceService.selectByIds(Arrays.asList(ids));
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user