|
|
@@ -1,24 +1,30 @@
|
|
|
package org.dromara.backstage.consumption.service.impl;
|
|
|
|
|
|
-import org.dromara.common.core.utils.MapstructUtils;
|
|
|
-import org.dromara.common.core.utils.StringUtils;
|
|
|
-import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
-import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.dromara.backstage.consumption.domain.XfException;
|
|
|
import org.dromara.backstage.consumption.domain.bo.XfExceptionBo;
|
|
|
import org.dromara.backstage.consumption.domain.vo.XfExceptionVo;
|
|
|
-import org.dromara.backstage.consumption.domain.XfException;
|
|
|
import org.dromara.backstage.consumption.mapper.XfExceptionMapper;
|
|
|
import org.dromara.backstage.consumption.service.IXfExceptionService;
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.domain.model.ErrorInfo;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.consume.api.RemoteConsumeService;
|
|
|
+import org.dromara.consume.api.domain.bo.RemoteXfExceptionDto;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Collection;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 消费明细异常Service业务层处理
|
|
|
@@ -29,9 +35,11 @@ import java.util.Collection;
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
public class XfExceptionServiceImpl implements IXfExceptionService {
|
|
|
-
|
|
|
private final XfExceptionMapper baseMapper;
|
|
|
|
|
|
+ @DubboReference
|
|
|
+ private final RemoteConsumeService remoteConsumeService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询消费明细异常
|
|
|
*
|
|
|
@@ -39,7 +47,7 @@ public class XfExceptionServiceImpl implements IXfExceptionService {
|
|
|
* @return 消费明细异常
|
|
|
*/
|
|
|
@Override
|
|
|
- public XfExceptionVo queryById(Long exceptId){
|
|
|
+ public XfExceptionVo queryById(Long exceptId) {
|
|
|
return baseMapper.selectVoById(exceptId);
|
|
|
}
|
|
|
|
|
|
@@ -80,17 +88,17 @@ public class XfExceptionServiceImpl implements IXfExceptionService {
|
|
|
return lqw;
|
|
|
}
|
|
|
|
|
|
- private QueryWrapper<XfException> buildQueryWrapper(XfExceptionBo bo,String tableAlias) {
|
|
|
+ private QueryWrapper<XfException> buildQueryWrapper(XfExceptionBo bo, String tableAlias) {
|
|
|
QueryWrapper<XfException> lqw = new QueryWrapper<>();
|
|
|
String columnPrefix = "";
|
|
|
- if(StringUtils.isNotBlank(tableAlias)){
|
|
|
+ if (StringUtils.isNotBlank(tableAlias)) {
|
|
|
columnPrefix = tableAlias + ".";
|
|
|
}
|
|
|
- lqw.eq(bo.getFactoryId() != null, columnPrefix+"factory_id", bo.getFactoryId());
|
|
|
- lqw.eq(bo.getTermNo() != null, columnPrefix+"term_no", bo.getTermNo());
|
|
|
- lqw.like(StringUtils.isNotBlank(bo.getRealName()), columnPrefix+"real_name", bo.getRealName());
|
|
|
- lqw.eq(bo.getConsumeDate() != null, columnPrefix+"consume_date", bo.getConsumeDate());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getStatus()), columnPrefix+"status", bo.getStatus());
|
|
|
+ lqw.eq(bo.getFactoryId() != null, columnPrefix + "factory_id", bo.getFactoryId());
|
|
|
+ lqw.eq(bo.getTermNo() != null, columnPrefix + "term_no", bo.getTermNo());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getRealName()), columnPrefix + "real_name", bo.getRealName());
|
|
|
+ lqw.eq(bo.getConsumeDate() != null, columnPrefix + "consume_date", bo.getConsumeDate());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getStatus()), columnPrefix + "status", bo.getStatus());
|
|
|
return lqw;
|
|
|
}
|
|
|
|
|
|
@@ -127,7 +135,7 @@ public class XfExceptionServiceImpl implements IXfExceptionService {
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(XfException entity){
|
|
|
+ private void validEntityBeforeSave(XfException entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
@@ -140,9 +148,38 @@ public class XfExceptionServiceImpl implements IXfExceptionService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R<ErrorInfo> rePostXfException(Collection<Long> ids) {
|
|
|
+ //List<XfExceptionVo> list =
|
|
|
+ LambdaQueryWrapper<XfException> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.in(XfException::getExceptId, ids);
|
|
|
+ List<XfException> list = baseMapper.selectList(lqw);
|
|
|
+ List<RemoteXfExceptionDto> records = new ArrayList<>();
|
|
|
+ for (XfException entity : list) {
|
|
|
+ records.add(BeanUtil.copyProperties(entity, RemoteXfExceptionDto.class));
|
|
|
+ }
|
|
|
+ List<RemoteXfExceptionDto> returns = remoteConsumeService.rePostConsumeData(records);
|
|
|
+ returns.forEach(p -> {
|
|
|
+ XfExceptionBo bo = BeanUtil.copyProperties(p, XfExceptionBo.class);
|
|
|
+ updteRepostResult(bo);
|
|
|
+ });
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updteRepostResult(XfExceptionBo bo) {
|
|
|
+ LambdaUpdateWrapper<XfException> luw = new LambdaUpdateWrapper<>();
|
|
|
+ luw.set(XfException::getStatus, bo.getStatus());
|
|
|
+ luw.set(XfException::getDealInfo, bo.getDealInfo());
|
|
|
+ luw.set(XfException::getUpdateBy, LoginHelper.getUserId());
|
|
|
+ luw.set(XfException::getUpdateTime, new Date());
|
|
|
+ luw.eq(XfException::getExceptId, bo.getExceptId());
|
|
|
+ return baseMapper.update(null, luw) > 0;
|
|
|
+ }
|
|
|
}
|