1
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
package com.ruoyi.jarvis.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.jarvis.domain.ErpProductRelation;
|
||||
|
||||
/**
|
||||
* ERP商品关联Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
public interface ErpProductRelationMapper
|
||||
{
|
||||
/**
|
||||
* 查询ERP商品关联
|
||||
*
|
||||
* @param id ERP商品关联主键
|
||||
* @return ERP商品关联
|
||||
*/
|
||||
public ErpProductRelation selectErpProductRelationById(Long id);
|
||||
|
||||
/**
|
||||
* 查询ERP商品关联列表
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
public List<ErpProductRelation> selectErpProductRelationList(ErpProductRelation erpProductRelation);
|
||||
|
||||
/**
|
||||
* 新增ERP商品关联
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertErpProductRelation(ErpProductRelation erpProductRelation);
|
||||
|
||||
/**
|
||||
* 修改ERP商品关联
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateErpProductRelation(ErpProductRelation erpProductRelation);
|
||||
|
||||
/**
|
||||
* 删除ERP商品关联
|
||||
*
|
||||
* @param id ERP商品关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteErpProductRelationById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除ERP商品关联
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteErpProductRelationByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据常用商品ID查询ERP商品关联列表
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
public List<ErpProductRelation> selectErpProductRelationByFavoriteId(Long favoriteProductId);
|
||||
|
||||
/**
|
||||
* 根据应用ID查询ERP商品关联列表
|
||||
*
|
||||
* @param appid 应用ID
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
public List<ErpProductRelation> selectErpProductRelationByAppid(String appid);
|
||||
|
||||
/**
|
||||
* 根据常用商品ID删除ERP商品关联
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteErpProductRelationByFavoriteId(Long favoriteProductId);
|
||||
|
||||
/**
|
||||
* 统计常用商品的ERP关联数量
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return 关联数量
|
||||
*/
|
||||
public int countErpProductRelationByFavoriteId(Long favoriteProductId);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.ruoyi.jarvis.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.jarvis.domain.ErpProductRelation;
|
||||
|
||||
/**
|
||||
* ERP商品关联Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
public interface IErpProductRelationService
|
||||
{
|
||||
/**
|
||||
* 查询ERP商品关联
|
||||
*
|
||||
* @param id ERP商品关联主键
|
||||
* @return ERP商品关联
|
||||
*/
|
||||
public ErpProductRelation selectErpProductRelationById(Long id);
|
||||
|
||||
/**
|
||||
* 查询ERP商品关联列表
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
public List<ErpProductRelation> selectErpProductRelationList(ErpProductRelation erpProductRelation);
|
||||
|
||||
/**
|
||||
* 新增ERP商品关联
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertErpProductRelation(ErpProductRelation erpProductRelation);
|
||||
|
||||
/**
|
||||
* 修改ERP商品关联
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateErpProductRelation(ErpProductRelation erpProductRelation);
|
||||
|
||||
/**
|
||||
* 批量删除ERP商品关联
|
||||
*
|
||||
* @param ids 需要删除的ERP商品关联主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteErpProductRelationByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除ERP商品关联信息
|
||||
*
|
||||
* @param id ERP商品关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteErpProductRelationById(Long id);
|
||||
|
||||
/**
|
||||
* 根据常用商品ID查询ERP商品关联列表
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
public List<ErpProductRelation> selectErpProductRelationByFavoriteId(Long favoriteProductId);
|
||||
|
||||
/**
|
||||
* 根据应用ID查询ERP商品关联列表
|
||||
*
|
||||
* @param appid 应用ID
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
public List<ErpProductRelation> selectErpProductRelationByAppid(String appid);
|
||||
|
||||
/**
|
||||
* 根据常用商品ID删除ERP商品关联
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteErpProductRelationByFavoriteId(Long favoriteProductId);
|
||||
|
||||
/**
|
||||
* 统计常用商品的ERP关联数量
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return 关联数量
|
||||
*/
|
||||
public int countErpProductRelationByFavoriteId(Long favoriteProductId);
|
||||
|
||||
/**
|
||||
* 批量添加ERP商品关联
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @param erpProductRelations ERP商品关联列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchInsertErpProductRelations(Long favoriteProductId, List<ErpProductRelation> erpProductRelations);
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.ruoyi.jarvis.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.jarvis.mapper.ErpProductRelationMapper;
|
||||
import com.ruoyi.jarvis.domain.ErpProductRelation;
|
||||
import com.ruoyi.jarvis.service.IErpProductRelationService;
|
||||
|
||||
/**
|
||||
* ERP商品关联Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Service
|
||||
public class ErpProductRelationServiceImpl implements IErpProductRelationService
|
||||
{
|
||||
@Autowired
|
||||
private ErpProductRelationMapper erpProductRelationMapper;
|
||||
|
||||
/**
|
||||
* 查询ERP商品关联
|
||||
*
|
||||
* @param id ERP商品关联主键
|
||||
* @return ERP商品关联
|
||||
*/
|
||||
@Override
|
||||
public ErpProductRelation selectErpProductRelationById(Long id)
|
||||
{
|
||||
return erpProductRelationMapper.selectErpProductRelationById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询ERP商品关联列表
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
@Override
|
||||
public List<ErpProductRelation> selectErpProductRelationList(ErpProductRelation erpProductRelation)
|
||||
{
|
||||
return erpProductRelationMapper.selectErpProductRelationList(erpProductRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增ERP商品关联
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertErpProductRelation(ErpProductRelation erpProductRelation)
|
||||
{
|
||||
return erpProductRelationMapper.insertErpProductRelation(erpProductRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改ERP商品关联
|
||||
*
|
||||
* @param erpProductRelation ERP商品关联
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateErpProductRelation(ErpProductRelation erpProductRelation)
|
||||
{
|
||||
return erpProductRelationMapper.updateErpProductRelation(erpProductRelation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除ERP商品关联
|
||||
*
|
||||
* @param ids 需要删除的ERP商品关联主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteErpProductRelationByIds(Long[] ids)
|
||||
{
|
||||
return erpProductRelationMapper.deleteErpProductRelationByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除ERP商品关联信息
|
||||
*
|
||||
* @param id ERP商品关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteErpProductRelationById(Long id)
|
||||
{
|
||||
return erpProductRelationMapper.deleteErpProductRelationById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据常用商品ID查询ERP商品关联列表
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
@Override
|
||||
public List<ErpProductRelation> selectErpProductRelationByFavoriteId(Long favoriteProductId)
|
||||
{
|
||||
return erpProductRelationMapper.selectErpProductRelationByFavoriteId(favoriteProductId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用ID查询ERP商品关联列表
|
||||
*
|
||||
* @param appid 应用ID
|
||||
* @return ERP商品关联集合
|
||||
*/
|
||||
@Override
|
||||
public List<ErpProductRelation> selectErpProductRelationByAppid(String appid)
|
||||
{
|
||||
return erpProductRelationMapper.selectErpProductRelationByAppid(appid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据常用商品ID删除ERP商品关联
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteErpProductRelationByFavoriteId(Long favoriteProductId)
|
||||
{
|
||||
return erpProductRelationMapper.deleteErpProductRelationByFavoriteId(favoriteProductId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计常用商品的ERP关联数量
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @return 关联数量
|
||||
*/
|
||||
@Override
|
||||
public int countErpProductRelationByFavoriteId(Long favoriteProductId)
|
||||
{
|
||||
return erpProductRelationMapper.countErpProductRelationByFavoriteId(favoriteProductId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加ERP商品关联
|
||||
*
|
||||
* @param favoriteProductId 常用商品ID
|
||||
* @param erpProductRelations ERP商品关联列表
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int batchInsertErpProductRelations(Long favoriteProductId, List<ErpProductRelation> erpProductRelations)
|
||||
{
|
||||
if (erpProductRelations == null || erpProductRelations.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
for (ErpProductRelation erpProductRelation : erpProductRelations) {
|
||||
erpProductRelation.setFavoriteProductId(favoriteProductId);
|
||||
result += insertErpProductRelation(erpProductRelation);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
package com.ruoyi.jarvis.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.jarvis.mapper.FavoriteProductMapper;
|
||||
import com.ruoyi.jarvis.mapper.ErpProductRelationMapper;
|
||||
import com.ruoyi.jarvis.domain.FavoriteProduct;
|
||||
import com.ruoyi.jarvis.domain.ErpProductRelation;
|
||||
import com.ruoyi.jarvis.service.IFavoriteProductService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
|
||||
/**
|
||||
* 常用商品Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@Service
|
||||
public class FavoriteProductServiceImpl implements IFavoriteProductService
|
||||
{
|
||||
@Autowired
|
||||
private FavoriteProductMapper favoriteProductMapper;
|
||||
|
||||
@Autowired
|
||||
private ErpProductRelationMapper erpProductRelationMapper;
|
||||
|
||||
/**
|
||||
* 查询常用商品
|
||||
*
|
||||
* @param id 常用商品主键
|
||||
* @return 常用商品
|
||||
*/
|
||||
@Override
|
||||
public FavoriteProduct selectFavoriteProductById(Long id)
|
||||
{
|
||||
FavoriteProduct favoriteProduct = favoriteProductMapper.selectFavoriteProductById(id);
|
||||
if (favoriteProduct != null) {
|
||||
// 查询关联的ERP商品
|
||||
List<ErpProductRelation> erpProducts = erpProductRelationMapper.selectErpProductRelationByFavoriteId(id);
|
||||
favoriteProduct.setErpProducts(erpProducts);
|
||||
}
|
||||
return favoriteProduct;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询常用商品列表
|
||||
*
|
||||
* @param favoriteProduct 常用商品
|
||||
* @return 常用商品
|
||||
*/
|
||||
@Override
|
||||
public List<FavoriteProduct> selectFavoriteProductList(FavoriteProduct favoriteProduct)
|
||||
{
|
||||
return favoriteProductMapper.selectFavoriteProductList(favoriteProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增常用商品
|
||||
*
|
||||
* @param favoriteProduct 常用商品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertFavoriteProduct(FavoriteProduct favoriteProduct)
|
||||
{
|
||||
// 设置创建用户信息
|
||||
if (favoriteProduct.getCreateUserId() == null) {
|
||||
favoriteProduct.setCreateUserId(SecurityUtils.getUserId());
|
||||
}
|
||||
if (StringUtils.isEmpty(favoriteProduct.getCreateUserName())) {
|
||||
favoriteProduct.setCreateUserName(SecurityUtils.getUsername());
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
if (favoriteProduct.getIsTop() == null) {
|
||||
favoriteProduct.setIsTop(0);
|
||||
}
|
||||
if (favoriteProduct.getSortWeight() == null) {
|
||||
favoriteProduct.setSortWeight(0);
|
||||
}
|
||||
if (favoriteProduct.getUseCount() == null) {
|
||||
favoriteProduct.setUseCount(0);
|
||||
}
|
||||
|
||||
return favoriteProductMapper.insertFavoriteProduct(favoriteProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改常用商品
|
||||
*
|
||||
* @param favoriteProduct 常用商品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateFavoriteProduct(FavoriteProduct favoriteProduct)
|
||||
{
|
||||
return favoriteProductMapper.updateFavoriteProduct(favoriteProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除常用商品
|
||||
*
|
||||
* @param ids 需要删除的常用商品主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteFavoriteProductByIds(Long[] ids)
|
||||
{
|
||||
// 先删除关联的ERP商品关系
|
||||
for (Long id : ids) {
|
||||
erpProductRelationMapper.deleteErpProductRelationByFavoriteId(id);
|
||||
}
|
||||
return favoriteProductMapper.deleteFavoriteProductByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除常用商品信息
|
||||
*
|
||||
* @param id 常用商品主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteFavoriteProductById(Long id)
|
||||
{
|
||||
// 先删除关联的ERP商品关系
|
||||
erpProductRelationMapper.deleteErpProductRelationByFavoriteId(id);
|
||||
return favoriteProductMapper.deleteFavoriteProductById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据SKUID查询常用商品
|
||||
*
|
||||
* @param skuid SKUID
|
||||
* @return 常用商品
|
||||
*/
|
||||
@Override
|
||||
public FavoriteProduct selectFavoriteProductBySkuid(String skuid)
|
||||
{
|
||||
return favoriteProductMapper.selectFavoriteProductBySkuid(skuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品到常用列表
|
||||
*
|
||||
* @param favoriteProduct 常用商品信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int addToFavorites(FavoriteProduct favoriteProduct)
|
||||
{
|
||||
// 检查是否已经存在
|
||||
FavoriteProduct existing = favoriteProductMapper.selectFavoriteProductBySkuid(favoriteProduct.getSkuid());
|
||||
if (existing != null) {
|
||||
// 如果已存在,更新使用次数和最后使用时间
|
||||
return updateUseCountAndTime(existing.getId());
|
||||
}
|
||||
|
||||
// 设置创建用户信息
|
||||
favoriteProduct.setCreateUserId(SecurityUtils.getUserId());
|
||||
favoriteProduct.setCreateUserName(SecurityUtils.getUsername());
|
||||
favoriteProduct.setIsTop(0);
|
||||
favoriteProduct.setSortWeight(0);
|
||||
favoriteProduct.setUseCount(1);
|
||||
favoriteProduct.setLastUsedTime(DateUtils.getTime());
|
||||
|
||||
return favoriteProductMapper.insertFavoriteProduct(favoriteProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从常用列表移除商品
|
||||
*
|
||||
* @param skuid SKUID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int removeFromFavorites(String skuid)
|
||||
{
|
||||
FavoriteProduct existing = favoriteProductMapper.selectFavoriteProductBySkuid(skuid);
|
||||
if (existing != null) {
|
||||
return deleteFavoriteProductById(existing.getId());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新使用次数和最后使用时间
|
||||
*
|
||||
* @param id 常用商品ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUseCountAndTime(Long id)
|
||||
{
|
||||
return favoriteProductMapper.updateUseCountAndTime(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新置顶状态
|
||||
*
|
||||
* @param id 常用商品ID
|
||||
* @param isTop 是否置顶
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTopStatus(Long id, Integer isTop)
|
||||
{
|
||||
FavoriteProduct favoriteProduct = new FavoriteProduct();
|
||||
favoriteProduct.setId(id);
|
||||
favoriteProduct.setIsTop(isTop);
|
||||
return favoriteProductMapper.updateTopStatus(favoriteProduct);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量置顶/取消置顶
|
||||
*
|
||||
* @param ids 常用商品ID数组
|
||||
* @param isTop 是否置顶
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int batchUpdateTopStatus(Long[] ids, Integer isTop)
|
||||
{
|
||||
int result = 0;
|
||||
for (Long id : ids) {
|
||||
result += updateTopStatus(id, isTop);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户的常用商品列表(按置顶和排序权重排序)
|
||||
*
|
||||
* @param createUserId 创建用户ID
|
||||
* @return 常用商品集合
|
||||
*/
|
||||
@Override
|
||||
public List<FavoriteProduct> selectUserFavoriteProducts(Long createUserId)
|
||||
{
|
||||
return favoriteProductMapper.selectUserFavoriteProducts(createUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据线报消息创建常用商品
|
||||
*
|
||||
* @param xbMessageItem 线报消息项
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int createFromXbMessage(Object xbMessageItem)
|
||||
{
|
||||
// 这里需要根据实际的线报消息结构来解析数据
|
||||
// 暂时返回0,具体实现需要根据实际数据结构调整
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速发品(从常用商品)
|
||||
*
|
||||
* @param id 常用商品ID
|
||||
* @param appid ERP应用ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public Object quickPublishFromFavorite(Long id, String appid)
|
||||
{
|
||||
// 更新使用次数和最后使用时间
|
||||
updateUseCountAndTime(id);
|
||||
|
||||
// 这里可以调用实际的发品接口
|
||||
// 暂时返回成功信息
|
||||
return "发品请求已提交,应用ID: " + appid;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user