|
|
@ -26,8 +26,15 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmvehrebatewith; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebate; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebateDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebateDto; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebateVehDto; |
|
|
|
import com.yxt.anrui.scm.biz.scmvehrebate.ScmVehRebateService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
@ -41,8 +48,13 @@ import com.yxt.anrui.scm.api.scmvehrebatewith.ScmVehRebateWithDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatewith.ScmVehRebateWithDto; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatewith.ScmVehRebateWithFeign; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.text.DateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -60,56 +72,83 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class ScmVehRebateWithService extends MybatisBaseService<ScmVehRebateWithMapper, ScmVehRebateWith> { |
|
|
|
private QueryWrapper<ScmVehRebateWith> createQueryWrapper(ScmVehRebateWithQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ScmVehRebateWith> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmVehRebateWithVo> listPageVo(PagerQuery<ScmVehRebateWithQuery> pq) { |
|
|
|
ScmVehRebateWithQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmVehRebateWith> qw = createQueryWrapper(query); |
|
|
|
IPage<ScmVehRebateWith> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmVehRebateWithVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmVehRebateWithVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(ScmVehRebateWithDto dto){ |
|
|
|
@Autowired |
|
|
|
private ScmVehRebateService scmVehRebateService; |
|
|
|
|
|
|
|
private QueryWrapper<ScmVehRebateWith> createQueryWrapper(ScmVehRebateWithQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ScmVehRebateWith> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmVehRebateWithVo> listPageVo(PagerQuery<ScmVehRebateWithQuery> pq) { |
|
|
|
ScmVehRebateWithQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmVehRebateWith> qw = createQueryWrapper(query); |
|
|
|
IPage<ScmVehRebateWith> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmVehRebateWithVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmVehRebateWithVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(ScmVehRebateWithDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(ScmVehRebateWithDto dto){ |
|
|
|
ScmVehRebateWith entity = new ScmVehRebateWith(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ScmVehRebateWithDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(ScmVehRebateWithDto dto) { |
|
|
|
ScmVehRebateWith entity = new ScmVehRebateWith(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
List<String> vehRebateSids = dto.getVehRebateSids(); |
|
|
|
StringBuilder vehRebateSid = new StringBuilder(); |
|
|
|
for (String sid : vehRebateSids) { |
|
|
|
vehRebateSid.append(sid).append(","); |
|
|
|
} |
|
|
|
entity.setVehRebateSid(vehRebateSid.substring(0,vehRebateSid.lastIndexOf(","))); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ScmVehRebateWithDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ScmVehRebateWith entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ScmVehRebateWithDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
ScmVehRebateWith entity = fetchBySid(sid); |
|
|
|
ScmVehRebateWithDetailsVo vo = new ScmVehRebateWithDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|
ScmVehRebateWith entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ScmVehRebateWithDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
ScmVehRebateWith entity = fetchBySid(sid); |
|
|
|
ScmVehRebateWithDetailsVo vo = new ScmVehRebateWithDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void delByMainSid(String dtoSid) { |
|
|
|
baseMapper.delByMainSid(dtoSid); |
|
|
|
} |
|
|
|
|
|
|
|
public List<ScmVehRebateWithDetailsVo> fetchByMainSid(String sid) { |
|
|
|
return baseMapper.fetchByMainSid(sid); |
|
|
|
} |
|
|
|
|
|
|
|
public void delByMainSid(String dtoSid) { |
|
|
|
baseMapper.delByMainSid(dtoSid); |
|
|
|
} |
|
|
|
public ResultBean<List<ScmVehRebateDetailsVo>> vehRebateWithDetails(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<ScmVehRebateDetailsVo> scmVehRebateDetailsVos = new ArrayList<>(); |
|
|
|
String[] sids = sid.split(","); |
|
|
|
for (String s : sids) { |
|
|
|
ScmVehRebate scmVehRebate = scmVehRebateService.fetchBySid(s); |
|
|
|
ScmVehRebateDetailsVo scmVehRebateDetailsVo = new ScmVehRebateDetailsVo(); |
|
|
|
BeanUtil.copyProperties(scmVehRebate,scmVehRebateDetailsVo); |
|
|
|
scmVehRebateDetailsVos.add(scmVehRebateDetailsVo); |
|
|
|
} |
|
|
|
return rb.success().setData(scmVehRebateDetailsVos); |
|
|
|
} |
|
|
|
} |