|
|
@ -57,112 +57,113 @@ import org.springframework.stereotype.Service; |
|
|
|
@Service |
|
|
|
public class BaseVehicleOutApplyService extends MybatisBaseService<BaseVehicleOutApplyMapper, BaseVehicleOutApply> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
|
|
|
|
private QueryWrapper<BaseVehicleOutApply> createQueryWrapper(BaseVehicleOutApplyQueryNew params) { |
|
|
|
QueryWrapper<BaseVehicleOutApply> qw = new QueryWrapper<>(); |
|
|
|
if (params != null) { |
|
|
|
String orgSidPath = params.getOrgSidPath(); |
|
|
|
SysOrganizationVo data = sysOrganizationFeign.selectByOrgSidPath(orgSidPath).getData(); |
|
|
|
String orgLevelKey = data.getOrgLevelKey(); |
|
|
|
if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, 73); |
|
|
|
qw.like("so.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
qw.eq("bvoa.createOrgSid", params.getCreateOrgSid()); |
|
|
|
} |
|
|
|
//物料编码
|
|
|
|
if (StringUtils.isNotBlank(params.getMaterialCode())) { |
|
|
|
qw.like("bvo.materialCode", params.getMaterialCode()); |
|
|
|
} |
|
|
|
//车架号
|
|
|
|
if (StringUtils.isNotBlank(params.getVinNo())) { |
|
|
|
qw.like("bvo.vinNo", params.getVinNo()); |
|
|
|
} |
|
|
|
//销售类型
|
|
|
|
if (StringUtils.isNotBlank(params.getTypeKey())) { |
|
|
|
qw.eq("bvoa.saleTypeKey", params.getTypeKey()); |
|
|
|
} |
|
|
|
//销售日期开始-销售日期结束
|
|
|
|
qw.apply(StringUtils.isNotBlank(params.getSaleDateStart()), "date_format (bvoa.saleDate,'%Y-%m-%d') >= date_format('" + params.getSaleDateStart() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(params.getSaleDateEnd()), "date_format (bvoa.saleDate,'%Y-%m-%d') <= date_format('" + params.getSaleDateEnd() + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
//合同编号
|
|
|
|
if (StringUtils.isNotBlank(params.getConcatNo())) { |
|
|
|
qw.like("bvoa.contractNo", params.getConcatNo()); |
|
|
|
} |
|
|
|
//客户名称
|
|
|
|
if (StringUtils.isNotBlank(params.getCustomerName())) { |
|
|
|
qw.like("bvoa.customerName", params.getCustomerName()); |
|
|
|
} |
|
|
|
//销售部门
|
|
|
|
if (StringUtils.isNotBlank(params.getOrgDeptSid())) { |
|
|
|
qw.eq("bvoa.orgSid", params.getOrgDeptSid()); |
|
|
|
} |
|
|
|
//销售人员
|
|
|
|
if (StringUtils.isNotBlank(params.getStaffSid())) { |
|
|
|
qw.eq("bvoa.staffSid", params.getStaffSid()); |
|
|
|
} |
|
|
|
//内部编码
|
|
|
|
if (StringUtils.isNotBlank(params.getInsideCode())) { |
|
|
|
qw.like("bv.insideCode", params.getInsideCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(params.getOrgSid())) { |
|
|
|
qw.eq("bvoa.createOrgSid", params.getOrgSid()); |
|
|
|
} |
|
|
|
qw.orderByDesc("bvoa.saleDate"); |
|
|
|
} |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<BaseVehicleOutApplyVoNew> listPageVo(PagerQuery<BaseVehicleOutApplyQueryNew> pq) { |
|
|
|
BaseVehicleOutApplyQueryNew query = pq.getParams(); |
|
|
|
QueryWrapper<BaseVehicleOutApply> qw = createQueryWrapper(query); |
|
|
|
IPage<BaseVehicleOutApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BaseVehicleOutApplyVoNew> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
for (BaseVehicleOutApplyVoNew record : pagging.getRecords()) { |
|
|
|
String createOrgSid = record.getCreateOrgSid(); |
|
|
|
String createorgName = sysOrganizationFeign.fetchBySid(createOrgSid).getData().getName(); |
|
|
|
record.setCreateOrgName(createorgName); |
|
|
|
if (!"主车".equals(record.getMaterialName())){ |
|
|
|
record.setModelName(""); |
|
|
|
record.setInsideCode(""); |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<BaseVehicleOutApplyVoNew> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(BaseVehicleOutApplyDto dto){ |
|
|
|
private QueryWrapper<BaseVehicleOutApply> createQueryWrapper(BaseVehicleOutApplyQueryNew params) { |
|
|
|
QueryWrapper<BaseVehicleOutApply> qw = new QueryWrapper<>(); |
|
|
|
if (params != null) { |
|
|
|
qw.eq("bvoa.isDelete", 0); |
|
|
|
String orgSidPath = params.getOrgSidPath(); |
|
|
|
SysOrganizationVo data = sysOrganizationFeign.selectByOrgSidPath(orgSidPath).getData(); |
|
|
|
String orgLevelKey = data.getOrgLevelKey(); |
|
|
|
if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, 73); |
|
|
|
qw.like("so.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
qw.eq("bvoa.createOrgSid", params.getCreateOrgSid()); |
|
|
|
} |
|
|
|
//物料编码
|
|
|
|
if (StringUtils.isNotBlank(params.getMaterialCode())) { |
|
|
|
qw.like("bvo.materialCode", params.getMaterialCode()); |
|
|
|
} |
|
|
|
//车架号
|
|
|
|
if (StringUtils.isNotBlank(params.getVinNo())) { |
|
|
|
qw.like("bvo.vinNo", params.getVinNo()); |
|
|
|
} |
|
|
|
//销售类型
|
|
|
|
if (StringUtils.isNotBlank(params.getTypeKey())) { |
|
|
|
qw.eq("bvoa.saleTypeKey", params.getTypeKey()); |
|
|
|
} |
|
|
|
//销售日期开始-销售日期结束
|
|
|
|
qw.apply(StringUtils.isNotBlank(params.getSaleDateStart()), "date_format (bvoa.saleDate,'%Y-%m-%d') >= date_format('" + params.getSaleDateStart() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(params.getSaleDateEnd()), "date_format (bvoa.saleDate,'%Y-%m-%d') <= date_format('" + params.getSaleDateEnd() + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
//合同编号
|
|
|
|
if (StringUtils.isNotBlank(params.getConcatNo())) { |
|
|
|
qw.like("bvoa.contractNo", params.getConcatNo()); |
|
|
|
} |
|
|
|
//客户名称
|
|
|
|
if (StringUtils.isNotBlank(params.getCustomerName())) { |
|
|
|
qw.like("bvoa.customerName", params.getCustomerName()); |
|
|
|
} |
|
|
|
//销售部门
|
|
|
|
if (StringUtils.isNotBlank(params.getOrgDeptSid())) { |
|
|
|
qw.eq("bvoa.orgSid", params.getOrgDeptSid()); |
|
|
|
} |
|
|
|
//销售人员
|
|
|
|
if (StringUtils.isNotBlank(params.getStaffSid())) { |
|
|
|
qw.eq("bvoa.staffSid", params.getStaffSid()); |
|
|
|
} |
|
|
|
//内部编码
|
|
|
|
if (StringUtils.isNotBlank(params.getInsideCode())) { |
|
|
|
qw.like("bv.insideCode", params.getInsideCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(params.getOrgSid())) { |
|
|
|
qw.eq("bvoa.createOrgSid", params.getOrgSid()); |
|
|
|
} |
|
|
|
qw.orderByDesc("bvoa.saleDate"); |
|
|
|
} |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<BaseVehicleOutApplyVoNew> listPageVo(PagerQuery<BaseVehicleOutApplyQueryNew> pq) { |
|
|
|
BaseVehicleOutApplyQueryNew query = pq.getParams(); |
|
|
|
QueryWrapper<BaseVehicleOutApply> qw = createQueryWrapper(query); |
|
|
|
IPage<BaseVehicleOutApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BaseVehicleOutApplyVoNew> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
for (BaseVehicleOutApplyVoNew record : pagging.getRecords()) { |
|
|
|
String createOrgSid = record.getCreateOrgSid(); |
|
|
|
String createorgName = sysOrganizationFeign.fetchBySid(createOrgSid).getData().getName(); |
|
|
|
record.setCreateOrgName(createorgName); |
|
|
|
if (!"主车".equals(record.getMaterialName())) { |
|
|
|
record.setModelName(""); |
|
|
|
record.setInsideCode(""); |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<BaseVehicleOutApplyVoNew> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(BaseVehicleOutApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(BaseVehicleOutApplyDto dto){ |
|
|
|
BaseVehicleOutApply entity = new BaseVehicleOutApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(BaseVehicleOutApplyDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(BaseVehicleOutApplyDto dto) { |
|
|
|
BaseVehicleOutApply entity = new BaseVehicleOutApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(BaseVehicleOutApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
BaseVehicleOutApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public BaseVehicleOutApplyDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
BaseVehicleOutApply entity = fetchBySid(sid); |
|
|
|
BaseVehicleOutApplyDetailsVo vo = new BaseVehicleOutApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|
BaseVehicleOutApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public BaseVehicleOutApplyDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
BaseVehicleOutApply entity = fetchBySid(sid); |
|
|
|
BaseVehicleOutApplyDetailsVo vo = new BaseVehicleOutApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |