|
|
@ -10,7 +10,9 @@ import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
import com.win.module.wms.controller.currencyexchange.vo.*; |
|
|
|
import com.win.module.wms.convert.bom.BomConvert; |
|
|
|
import com.win.module.wms.convert.currencyexchange.CurrencyexchangeConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.bom.BomDO; |
|
|
|
import com.win.module.wms.dal.dataobject.currencyexchange.CurrencyexchangeDO; |
|
|
|
import com.win.module.wms.dal.mysql.currencyexchange.CurrencyexchangeMapper; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -97,57 +99,80 @@ public class CurrencyexchangeServiceImpl implements CurrencyexchangeService { |
|
|
|
return currencyexchangeMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CurrencyexchangeImportExcelVo> importCurrencyexchangeList(List<CurrencyexchangeImportExcelVo> currencyexchanges, Integer mode, Boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(currencyexchanges)) { |
|
|
|
throw exception(CURRENCYEXCHANGE_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<CurrencyexchangeImportExcelVo> errorList = new ArrayList<>(); |
|
|
|
currencyexchanges.forEach(currencyexchange -> { |
|
|
|
String massage = ""; |
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
|
if(mode != null){ |
|
|
|
|
|
|
|
public String validateCurrencyexchangeImport(CurrencyexchangeDO currencyExchange ){ |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateConfigurationSettingExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCurrencyExists(currencyexchange.getCurrency()); |
|
|
|
validateCurrencyExists(currencyExchange.getCurrency()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateBasiccurrencyExists(currencyexchange.getBasiccurrency()); |
|
|
|
validateBasiccurrencyExists(currencyExchange.getBasiccurrency()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(currencyexchange.getAvailable()); |
|
|
|
validateAvailableExists(currencyExchange.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
}if(StrUtil.isNotEmpty(massage)){ |
|
|
|
massage.substring(0,massage.length()-1); |
|
|
|
errorList.add(currencyexchange); |
|
|
|
} |
|
|
|
if(errorList == null){ |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
CurrencyexchangeDO existConfigurationSetting = null; |
|
|
|
if (existConfigurationSetting == null&& mode != 3) { |
|
|
|
currencyexchangeMapper.insert(CurrencyexchangeConvert.INSTANCE.convert(currencyexchange)); |
|
|
|
} |
|
|
|
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
CurrencyexchangeDO currencyexchangeDO = CurrencyexchangeConvert.INSTANCE.convert(currencyexchange); |
|
|
|
currencyexchangeDO.setId(existConfigurationSetting.getId()); |
|
|
|
currencyexchangeMapper.updateById(currencyexchangeDO); |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public CurrencyexchangeDO existCurrencyExchange(CurrencyexchangeDO currencyexchangeDO){ |
|
|
|
QueryWrapper<CurrencyexchangeDO> queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.eq("currency",currencyexchangeDO.getCurrency()); |
|
|
|
queryWrapper.eq("basiccurrency",currencyexchangeDO.getBasiccurrency()); |
|
|
|
queryWrapper.eq("rate",currencyexchangeDO.getRate()); |
|
|
|
queryWrapper.eq("available",currencyexchangeDO.getAvailable()); |
|
|
|
queryWrapper.eq("active_time",currencyexchangeDO.getActiveTime()); |
|
|
|
queryWrapper.eq("expire_time",currencyexchangeDO.getExpireTime()); |
|
|
|
CurrencyexchangeDO CurrencyexchangeDO = currencyexchangeMapper.selectOne(queryWrapper); |
|
|
|
return CurrencyexchangeDO; |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CurrencyexchangeImportErrorVO> importCurrencyexchangeList(List<CurrencyexchangeImportExcelVo> currencyexchanges, Integer mode, Boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(currencyexchanges)) { |
|
|
|
throw exception(CURRENCYEXCHANGE_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<CurrencyexchangeImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
currencyexchanges.forEach(currencyExchange -> { |
|
|
|
CurrencyexchangeDO currencyexchangeDO = CurrencyexchangeConvert.INSTANCE.convert(currencyExchange); |
|
|
|
String message = this.validateCurrencyexchangeImport(currencyexchangeDO); |
|
|
|
boolean flag = true; |
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
|
if(!message.isEmpty()){ |
|
|
|
CurrencyexchangeImportErrorVO importErrorVO = CurrencyexchangeConvert.INSTANCE.convert2(currencyexchangeDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
importErrorVO.setImportRemark(message.substring(0, message.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
if(flag){ |
|
|
|
CurrencyexchangeDO existAccountcalendar = existCurrencyExchange(currencyexchangeDO); |
|
|
|
if (existAccountcalendar==null&& mode != 3) { |
|
|
|
currencyexchangeMapper.insert(CurrencyexchangeConvert.INSTANCE.convert(currencyExchange)); |
|
|
|
} |
|
|
|
else if (existAccountcalendar!=null&& mode != 2) { |
|
|
|
currencyexchangeDO.setId(existAccountcalendar.getId()); |
|
|
|
currencyexchangeMapper.updateById(currencyexchangeDO); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|