|
@ -1,13 +1,23 @@ |
|
|
package com.ruoyi.stock.service.impl; |
|
|
package com.ruoyi.stock.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.constant.BusinessKeysConstants; |
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysFieldDifferent; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
|
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
|
|
import com.ruoyi.common.utils.FieldCompareUtil; |
|
|
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.stock.domain.StockInfo; |
|
|
import com.ruoyi.stock.domain.StockInfo; |
|
|
import com.ruoyi.stock.mapper.StockInfoMapper; |
|
|
import com.ruoyi.stock.mapper.StockInfoMapper; |
|
|
import com.ruoyi.stock.service.IStockInfoService; |
|
|
import com.ruoyi.stock.service.IStockInfoService; |
|
|
|
|
|
import com.ruoyi.system.domain.SysDiffLog; |
|
|
|
|
|
import com.ruoyi.system.service.ISysDiffLogService; |
|
|
|
|
|
import lombok.SneakyThrows; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
@ -23,6 +33,9 @@ public class StockInfoServiceImpl implements IStockInfoService |
|
|
@Autowired |
|
|
@Autowired |
|
|
private StockInfoMapper stockInfoMapper; |
|
|
private StockInfoMapper stockInfoMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ISysDiffLogService diffLogService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private RedisCache redisCache; |
|
|
private RedisCache redisCache; |
|
|
|
|
|
|
|
@ -56,11 +69,22 @@ public class StockInfoServiceImpl implements IStockInfoService |
|
|
* @param stockInfo 仓库信息 |
|
|
* @param stockInfo 仓库信息 |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public int insertStockInfo(StockInfo stockInfo) |
|
|
public int insertStockInfo(StockInfo stockInfo) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
SysDiffLog sysDiffLog = new SysDiffLog(); |
|
|
stockInfo.setFirstAddTime(DateUtils.getNowDate()); |
|
|
stockInfo.setFirstAddTime(DateUtils.getNowDate()); |
|
|
return stockInfoMapper.insertStockInfo(stockInfo); |
|
|
int insertStockInfo = stockInfoMapper.insertStockInfo(stockInfo); |
|
|
|
|
|
Long stockId = stockInfo.getStockId(); |
|
|
|
|
|
sysDiffLog.setBusinessId(stockId); |
|
|
|
|
|
sysDiffLog.setBusinessKey(BusinessKeysConstants.STOCK_INFO); |
|
|
|
|
|
int insertSysDiffLog = diffLogService.insertSysDiffLog(sysDiffLog); |
|
|
|
|
|
if (insertSysDiffLog <= 0){ |
|
|
|
|
|
throw new BusinessException("新增仓库信息数据修改记录失败"); |
|
|
|
|
|
} |
|
|
|
|
|
return insertStockInfo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -69,10 +93,24 @@ public class StockInfoServiceImpl implements IStockInfoService |
|
|
* @param stockInfo 仓库信息 |
|
|
* @param stockInfo 仓库信息 |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public int updateStockInfo(StockInfo stockInfo) |
|
|
public int updateStockInfo(StockInfo stockInfo) |
|
|
{ |
|
|
{ |
|
|
stockInfo.setUpdateInfoTime(DateUtils.getNowDate()); |
|
|
stockInfo.setUpdateInfoTime(DateUtils.getNowDate()); |
|
|
|
|
|
Long stockId = stockInfo.getStockId(); |
|
|
|
|
|
StockInfo oldStockInfo = stockInfoMapper.selectStockInfoById(stockId); |
|
|
|
|
|
if (oldStockInfo == null){ |
|
|
|
|
|
throw new RuntimeException("仓库信息数据不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
List<SysFieldDifferent> compare = FieldCompareUtil.compare(StockInfo.class, stockInfo, oldStockInfo); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(compare)){ |
|
|
|
|
|
int updateSysDiffLog = diffLogService.updateSysDiffLogByBusiness(stockId,BusinessKeysConstants.STOCK_INFO,compare); |
|
|
|
|
|
if (updateSysDiffLog <= 0){ |
|
|
|
|
|
throw new RuntimeException("修改仓库信息数据修改记录失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return stockInfoMapper.updateStockInfo(stockInfo); |
|
|
return stockInfoMapper.updateStockInfo(stockInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|