|
@ -3,16 +3,22 @@ package com.ruoyi.system.service.impl; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.constant.BusinessKeysConstants; |
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysFieldDifferent; |
|
|
import com.ruoyi.common.exception.BusinessException; |
|
|
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.common.utils.ShiroUtils; |
|
|
|
|
|
import com.ruoyi.system.domain.SysDiffLog; |
|
|
import com.ruoyi.system.service.ISysDiffLogService; |
|
|
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 com.ruoyi.system.mapper.BaseExchangeRateMapper; |
|
|
import com.ruoyi.system.mapper.BaseExchangeRateMapper; |
|
|
import com.ruoyi.system.domain.BaseExchangeRate; |
|
|
import com.ruoyi.system.domain.BaseExchangeRate; |
|
|
import com.ruoyi.system.service.IBaseExchangeRateService; |
|
|
import com.ruoyi.system.service.IBaseExchangeRateService; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -27,6 +33,8 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService |
|
|
@Autowired |
|
|
@Autowired |
|
|
private BaseExchangeRateMapper baseExchangeRateMapper; |
|
|
private BaseExchangeRateMapper baseExchangeRateMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ISysDiffLogService diffLogService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询基础资料汇率管理 |
|
|
* 查询基础资料汇率管理 |
|
@ -58,6 +66,7 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService |
|
|
* @param baseExchangeRate 基础资料汇率管理 |
|
|
* @param baseExchangeRate 基础资料汇率管理 |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public int insertBaseExchangeRate(BaseExchangeRate baseExchangeRate) |
|
|
public int insertBaseExchangeRate(BaseExchangeRate baseExchangeRate) |
|
|
{ |
|
|
{ |
|
@ -75,7 +84,18 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService |
|
|
if (!CollectionUtils.isEmpty(exchangeRates)){ |
|
|
if (!CollectionUtils.isEmpty(exchangeRates)){ |
|
|
throw new BusinessException("新增汇率失败!该时间段内已存在汇率数据!"); |
|
|
throw new BusinessException("新增汇率失败!该时间段内已存在汇率数据!"); |
|
|
} |
|
|
} |
|
|
return baseExchangeRateMapper.insertBaseExchangeRate(baseExchangeRate); |
|
|
|
|
|
|
|
|
int result = baseExchangeRateMapper.insertBaseExchangeRate(baseExchangeRate); |
|
|
|
|
|
|
|
|
|
|
|
Long exchangeRateId = baseExchangeRate.getExchangeRateId(); |
|
|
|
|
|
SysDiffLog sysDiffLog = new SysDiffLog(); |
|
|
|
|
|
sysDiffLog.setBusinessId(exchangeRateId); |
|
|
|
|
|
sysDiffLog.setBusinessKey(BusinessKeysConstants.SYS_EXCHANGE_RATE); |
|
|
|
|
|
int insertSysDiffLog = diffLogService.insertSysDiffLog(sysDiffLog); |
|
|
|
|
|
if (insertSysDiffLog <= 0){ |
|
|
|
|
|
throw new BusinessException("新增汇率数据修改记录失败"); |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -84,12 +104,35 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService |
|
|
* @param baseExchangeRate 基础资料汇率管理 |
|
|
* @param baseExchangeRate 基础资料汇率管理 |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public int updateBaseExchangeRate(BaseExchangeRate baseExchangeRate) |
|
|
public int updateBaseExchangeRate(BaseExchangeRate baseExchangeRate) |
|
|
{ |
|
|
{ |
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
baseExchangeRate.setUpdateBy(loginName); |
|
|
baseExchangeRate.setUpdateBy(loginName); |
|
|
baseExchangeRate.setUpdateTime(DateUtils.getNowDate()); |
|
|
baseExchangeRate.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
Date startTime = baseExchangeRate.getStartTime(); |
|
|
|
|
|
Date endTime = baseExchangeRate.getEndTime(); |
|
|
|
|
|
|
|
|
|
|
|
if (startTime.after(endTime)){ |
|
|
|
|
|
throw new BusinessException("新增汇率失败!开始时间不能大于结束时间!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<BaseExchangeRate> exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRange(baseExchangeRate); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(exchangeRates)){ |
|
|
|
|
|
throw new BusinessException("新增汇率失败!该时间段内已存在汇率数据!"); |
|
|
|
|
|
} |
|
|
|
|
|
Long exchangeRateId = baseExchangeRate.getExchangeRateId(); |
|
|
|
|
|
BaseExchangeRate oldExchangeRate = baseExchangeRateMapper.selectBaseExchangeRateById(exchangeRateId); |
|
|
|
|
|
List<SysFieldDifferent> compare = FieldCompareUtil.compare(BaseExchangeRate.class, baseExchangeRate, oldExchangeRate); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(compare)){ |
|
|
|
|
|
int updateSysDiffLog = diffLogService.updateSysDiffLogByBusiness(exchangeRateId,BusinessKeysConstants.SYS_EXCHANGE_RATE,compare); |
|
|
|
|
|
if (updateSysDiffLog <= 0){ |
|
|
|
|
|
throw new BusinessException("修改汇率数据修改记录失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return baseExchangeRateMapper.updateBaseExchangeRate(baseExchangeRate); |
|
|
return baseExchangeRateMapper.updateBaseExchangeRate(baseExchangeRate); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|