optimise-当同时启动mall和iot的时候会出现bean冲突[produt和productCategory相关的bean],重新命名了一下
parent
18e4b1f33e
commit
2a74003fa8
|
@ -30,20 +30,20 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||
public class IotProductCategoryController {
|
||||
|
||||
@Resource
|
||||
private IotProductCategoryService productCategoryService;
|
||||
private IotProductCategoryService iotProductCategoryService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建产品分类")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product-category:create')")
|
||||
public CommonResult<Long> createProductCategory(@Valid @RequestBody IotProductCategorySaveReqVO createReqVO) {
|
||||
return success(productCategoryService.createProductCategory(createReqVO));
|
||||
return success(iotProductCategoryService.createProductCategory(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新产品分类")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product-category:update')")
|
||||
public CommonResult<Boolean> updateProductCategory(@Valid @RequestBody IotProductCategorySaveReqVO updateReqVO) {
|
||||
productCategoryService.updateProductCategory(updateReqVO);
|
||||
iotProductCategoryService.updateProductCategory(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class IotProductCategoryController {
|
|||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:product-category:delete')")
|
||||
public CommonResult<Boolean> deleteProductCategory(@RequestParam("id") Long id) {
|
||||
productCategoryService.deleteProductCategory(id);
|
||||
iotProductCategoryService.deleteProductCategory(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class IotProductCategoryController {
|
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product-category:query')")
|
||||
public CommonResult<IotProductCategoryRespVO> getProductCategory(@RequestParam("id") Long id) {
|
||||
IotProductCategoryDO productCategory = productCategoryService.getProductCategory(id);
|
||||
IotProductCategoryDO productCategory = iotProductCategoryService.getProductCategory(id);
|
||||
return success(BeanUtils.toBean(productCategory, IotProductCategoryRespVO.class));
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class IotProductCategoryController {
|
|||
@Operation(summary = "获得产品分类分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product-category:query')")
|
||||
public CommonResult<PageResult<IotProductCategoryRespVO>> getProductCategoryPage(@Valid IotProductCategoryPageReqVO pageReqVO) {
|
||||
PageResult<IotProductCategoryDO> pageResult = productCategoryService.getProductCategoryPage(pageReqVO);
|
||||
PageResult<IotProductCategoryDO> pageResult = iotProductCategoryService.getProductCategoryPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, IotProductCategoryRespVO.class));
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class IotProductCategoryController {
|
|||
@Operation(summary = "获得所有产品分类列表")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product-category:query')")
|
||||
public CommonResult<List<IotProductCategoryRespVO>> getSimpleProductCategoryList() {
|
||||
List<IotProductCategoryDO> list = productCategoryService.getProductCategoryListByStatus(
|
||||
List<IotProductCategoryDO> list = iotProductCategoryService.getProductCategoryListByStatus(
|
||||
CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(convertList(list, category ->
|
||||
new IotProductCategoryRespVO().setId(category.getId()).setName(category.getName())));
|
||||
|
|
|
@ -39,22 +39,22 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||
public class IotProductController {
|
||||
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
@Resource
|
||||
private IotProductCategoryService categoryService;
|
||||
private IotProductCategoryService iotProductCategoryService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建产品")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:create')")
|
||||
public CommonResult<Long> createProduct(@Valid @RequestBody IotProductSaveReqVO createReqVO) {
|
||||
return success(productService.createProduct(createReqVO));
|
||||
return success(iotProductService.createProduct(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新产品")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:update')")
|
||||
public CommonResult<Boolean> updateProduct(@Valid @RequestBody IotProductSaveReqVO updateReqVO) {
|
||||
productService.updateProduct(updateReqVO);
|
||||
iotProductService.updateProduct(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class IotProductController {
|
|||
@PreAuthorize("@ss.hasPermission('iot:product:update')")
|
||||
public CommonResult<Boolean> updateProductStatus(@RequestParam("id") Long id,
|
||||
@RequestParam("status") Integer status) {
|
||||
productService.updateProductStatus(id, status);
|
||||
iotProductService.updateProductStatus(id, status);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class IotProductController {
|
|||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:delete')")
|
||||
public CommonResult<Boolean> deleteProduct(@RequestParam("id") Long id) {
|
||||
productService.deleteProduct(id);
|
||||
iotProductService.deleteProduct(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,9 @@ public class IotProductController {
|
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:query')")
|
||||
public CommonResult<IotProductRespVO> getProduct(@RequestParam("id") Long id) {
|
||||
IotProductDO product = productService.getProduct(id);
|
||||
IotProductDO product = iotProductService.getProduct(id);
|
||||
// 拼接数据
|
||||
IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
|
||||
IotProductCategoryDO category = iotProductCategoryService.getProductCategory(product.getCategoryId());
|
||||
return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
|
||||
if (category != null) {
|
||||
bean.setCategoryName(category.getName());
|
||||
|
@ -97,9 +97,9 @@ public class IotProductController {
|
|||
@Operation(summary = "获得产品分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:query')")
|
||||
public CommonResult<PageResult<IotProductRespVO>> getProductPage(@Valid IotProductPageReqVO pageReqVO) {
|
||||
PageResult<IotProductDO> pageResult = productService.getProductPage(pageReqVO);
|
||||
PageResult<IotProductDO> pageResult = iotProductService.getProductPage(pageReqVO);
|
||||
// 拼接数据
|
||||
Map<Long, IotProductCategoryDO> categoryMap = categoryService.getProductCategoryMap(
|
||||
Map<Long, IotProductCategoryDO> categoryMap = iotProductCategoryService.getProductCategoryMap(
|
||||
convertList(pageResult.getList(), IotProductDO::getCategoryId));
|
||||
return success(BeanUtils.toBean(pageResult, IotProductRespVO.class, bean -> {
|
||||
MapUtils.findAndThen(categoryMap, bean.getCategoryId(),
|
||||
|
@ -123,7 +123,7 @@ public class IotProductController {
|
|||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获取产品的精简信息列表", description = "主要用于前端的下拉选项")
|
||||
public CommonResult<List<IotProductRespVO>> getSimpleProductList() {
|
||||
List<IotProductDO> list = productService.getProductList();
|
||||
List<IotProductDO> list = iotProductService.getProductList();
|
||||
return success(convertList(list, product -> // 只返回 id、name 字段
|
||||
new IotProductRespVO().setId(product.getId()).setName(product.getName())
|
||||
.setDeviceType(product.getDeviceType())));
|
||||
|
|
|
@ -32,9 +32,9 @@ public class IotStatisticsController {
|
|||
@Resource
|
||||
private IotDeviceService deviceService;
|
||||
@Resource
|
||||
private IotProductCategoryService productCategoryService;
|
||||
private IotProductCategoryService iotProductCategoryService;
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
@Resource
|
||||
private IotDeviceLogService deviceLogService;
|
||||
|
||||
|
@ -43,20 +43,20 @@ public class IotStatisticsController {
|
|||
public CommonResult<IotStatisticsSummaryRespVO> getIotStatisticsSummary(){
|
||||
IotStatisticsSummaryRespVO respVO = new IotStatisticsSummaryRespVO();
|
||||
// 1.1 获取总数
|
||||
respVO.setProductCategoryCount(productCategoryService.getProductCategoryCount(null));
|
||||
respVO.setProductCount(productService.getProductCount(null));
|
||||
respVO.setProductCategoryCount(iotProductCategoryService.getProductCategoryCount(null));
|
||||
respVO.setProductCount(iotProductService.getProductCount(null));
|
||||
respVO.setDeviceCount(deviceService.getDeviceCount(null));
|
||||
respVO.setDeviceMessageCount(deviceLogService.getDeviceLogCount(null));
|
||||
// 1.2 获取今日新增数量
|
||||
// TODO @super:使用 LocalDateTimeUtils.getToday()
|
||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
|
||||
respVO.setProductCategoryTodayCount(productCategoryService.getProductCategoryCount(todayStart));
|
||||
respVO.setProductTodayCount(productService.getProductCount(todayStart));
|
||||
respVO.setProductCategoryTodayCount(iotProductCategoryService.getProductCategoryCount(todayStart));
|
||||
respVO.setProductTodayCount(iotProductService.getProductCount(todayStart));
|
||||
respVO.setDeviceTodayCount(deviceService.getDeviceCount(todayStart));
|
||||
respVO.setDeviceMessageTodayCount(deviceLogService.getDeviceLogCount(todayStart));
|
||||
|
||||
// 2. 获取各个品类下设备数量统计
|
||||
respVO.setProductCategoryDeviceCounts(productCategoryService.getProductCategoryDeviceCountMap());
|
||||
respVO.setProductCategoryDeviceCounts(iotProductCategoryService.getProductCategoryDeviceCountMap());
|
||||
|
||||
// 3. 获取设备状态数量统计
|
||||
Map<Integer, Long> deviceCountMap = deviceService.getDeviceCountMapByState();
|
||||
|
|
|
@ -55,7 +55,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||
private IotDeviceMapper deviceMapper;
|
||||
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
@Resource
|
||||
@Lazy // 延迟加载,解决循环依赖
|
||||
private IotDeviceGroupService deviceGroupService;
|
||||
|
@ -63,7 +63,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||
@Override
|
||||
public Long createDevice(IotDeviceSaveReqVO createReqVO) {
|
||||
// 1.1 校验产品是否存在
|
||||
IotProductDO product = productService.getProduct(createReqVO.getProductId());
|
||||
IotProductDO product = iotProductService.getProduct(createReqVO.getProductId());
|
||||
if (product == null) {
|
||||
throw exception(PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||
public IotDeviceDO createDevice(String productKey, String deviceName, Long gatewayId) {
|
||||
String deviceKey = generateDeviceKey();
|
||||
// 1.1 校验产品是否存在
|
||||
IotProductDO product = TenantUtils.executeIgnore(() -> productService.getProductByProductKey(productKey));
|
||||
IotProductDO product = TenantUtils.executeIgnore(() -> iotProductService.getProductByProductKey(productKey));
|
||||
if (product == null) {
|
||||
throw exception(PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||
return;
|
||||
}
|
||||
// 2.1.2 校验产品是否存在
|
||||
IotProductDO product = productService.validateProductExists(importDevice.getProductKey());
|
||||
IotProductDO product = iotProductService.validateProductExists(importDevice.getProductKey());
|
||||
// 2.1.3 校验父设备是否存在
|
||||
Long gatewayId = null;
|
||||
if (StrUtil.isNotEmpty(importDevice.getParentDeviceName())) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService {
|
|||
@Resource
|
||||
private IotThingModelService thingModelService;
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
|
||||
@Resource
|
||||
private DevicePropertyRedisDAO deviceDataRedisDAO;
|
||||
|
@ -79,7 +79,7 @@ public class IotDevicePropertyServiceImpl implements IotDevicePropertyService {
|
|||
@Override
|
||||
public void defineDevicePropertyData(Long productId) {
|
||||
// 1.1 查询产品和物模型
|
||||
IotProductDO product = productService.validateProductExists(productId);
|
||||
IotProductDO product = iotProductService.validateProductExists(productId);
|
||||
List<IotThingModelDO> thingModels = filterList(thingModelService.getThingModelListByProductId(productId),
|
||||
thingModel -> IotThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType()));
|
||||
// 1.2 解析 DB 里的字段
|
||||
|
|
|
@ -33,7 +33,7 @@ public class IotOtaFirmwareServiceImpl implements IotOtaFirmwareService {
|
|||
private IotOtaFirmwareMapper otaFirmwareMapper;
|
||||
@Lazy
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
|
||||
@Override
|
||||
public Long createOtaFirmware(IotOtaFirmwareCreateReqVO saveReqVO) {
|
||||
|
@ -43,8 +43,8 @@ public class IotOtaFirmwareServiceImpl implements IotOtaFirmwareService {
|
|||
// 2.1.转化数据格式,准备存储到数据库中
|
||||
IotOtaFirmwareDO firmware = BeanUtils.toBean(saveReqVO, IotOtaFirmwareDO.class);
|
||||
// 2.2.查询ProductKey
|
||||
// TODO @li:productService.getProduct(Convert.toLong(firmware.getProductId())) 放到 1. 后面,先做参考校验。逻辑两段:1)先参数校验;2)构建对象 + 存储
|
||||
IotProductDO product = productService.getProduct(Convert.toLong(firmware.getProductId()));
|
||||
// TODO @li:iotProductService.getProduct(Convert.toLong(firmware.getProductId())) 放到 1. 后面,先做参考校验。逻辑两段:1)先参数校验;2)构建对象 + 存储
|
||||
IotProductDO product = iotProductService.getProduct(Convert.toLong(firmware.getProductId()));
|
||||
firmware.setProductKey(Objects.requireNonNull(product).getProductKey());
|
||||
// TODO @芋艿: 附件、附件签名等属性的计算
|
||||
otaFirmwareMapper.insert(firmware);
|
||||
|
|
|
@ -29,10 +29,10 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_CATEG
|
|||
public class IotProductCategoryServiceImpl implements IotProductCategoryService {
|
||||
|
||||
@Resource
|
||||
private IotProductCategoryMapper productCategoryMapper;
|
||||
private IotProductCategoryMapper iotProductCategoryMapper;
|
||||
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
|
||||
@Resource
|
||||
private IotDeviceService deviceService;
|
||||
|
@ -40,7 +40,7 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
|
|||
public Long createProductCategory(IotProductCategorySaveReqVO createReqVO) {
|
||||
// 插入
|
||||
IotProductCategoryDO productCategory = BeanUtils.toBean(createReqVO, IotProductCategoryDO.class);
|
||||
productCategoryMapper.insert(productCategory);
|
||||
iotProductCategoryMapper.insert(productCategory);
|
||||
// 返回
|
||||
return productCategory.getId();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
|
|||
validateProductCategoryExists(updateReqVO.getId());
|
||||
// 更新
|
||||
IotProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, IotProductCategoryDO.class);
|
||||
productCategoryMapper.updateById(updateObj);
|
||||
iotProductCategoryMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,18 +59,18 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
|
|||
// 校验存在
|
||||
validateProductCategoryExists(id);
|
||||
// 删除
|
||||
productCategoryMapper.deleteById(id);
|
||||
iotProductCategoryMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateProductCategoryExists(Long id) {
|
||||
if (productCategoryMapper.selectById(id) == null) {
|
||||
if (iotProductCategoryMapper.selectById(id) == null) {
|
||||
throw exception(PRODUCT_CATEGORY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IotProductCategoryDO getProductCategory(Long id) {
|
||||
return productCategoryMapper.selectById(id);
|
||||
return iotProductCategoryMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,29 +78,29 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
|
|||
if (CollUtil.isEmpty(ids)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return productCategoryMapper.selectBatchIds(ids);
|
||||
return iotProductCategoryMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<IotProductCategoryDO> getProductCategoryPage(IotProductCategoryPageReqVO pageReqVO) {
|
||||
return productCategoryMapper.selectPage(pageReqVO);
|
||||
return iotProductCategoryMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IotProductCategoryDO> getProductCategoryListByStatus(Integer status) {
|
||||
return productCategoryMapper.selectListByStatus(status);
|
||||
return iotProductCategoryMapper.selectListByStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getProductCategoryCount(LocalDateTime createTime) {
|
||||
return productCategoryMapper.selectCountByCreateTime(createTime);
|
||||
return iotProductCategoryMapper.selectCountByCreateTime(createTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getProductCategoryDeviceCountMap() {
|
||||
// 1. 获取所有数据
|
||||
List<IotProductCategoryDO> categoryList = productCategoryMapper.selectList();
|
||||
List<IotProductDO> productList = productService.getProductList();
|
||||
List<IotProductCategoryDO> categoryList = iotProductCategoryMapper.selectList();
|
||||
List<IotProductDO> productList = iotProductService.getProductList();
|
||||
// TODO @super:不要 list 查询,返回内存,而是查询一个 Map<productId, count>
|
||||
Map<Long, Integer> deviceCountMapByProductId = deviceService.getDeviceCountMapByProductId();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class IotThingModelServiceImpl implements IotThingModelService {
|
|||
private IotThingModelMapper thingModelMapper;
|
||||
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
private IotProductService iotProductService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -184,7 +184,7 @@ public class IotThingModelServiceImpl implements IotThingModelService {
|
|||
}
|
||||
|
||||
private void validateProductStatus(Long createReqVO) {
|
||||
IotProductDO product = productService.validateProductExists(createReqVO);
|
||||
IotProductDO product = iotProductService.validateProductExists(createReqVO);
|
||||
if (Objects.equals(product.getStatus(), IotProductStatusEnum.PUBLISHED.getStatus())) {
|
||||
throw exception(PRODUCT_STATUS_NOT_ALLOW_THING_MODEL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue