|
|
@ -26,23 +26,34 @@ |
|
|
|
package com.yxt.anrui.fin.biz.finfundscarriedforwardapply; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
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.fin.api.fincollectionconfirmation.FinCollectionConfirmation; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.*; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardveh.FinFundsCarriedForwardVehDetailsVo; |
|
|
|
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectReceivablesDetailedWCKCLRKVo; |
|
|
|
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed; |
|
|
|
import com.yxt.anrui.fin.biz.fincollectionconfirmation.FinCollectionConfirmationService; |
|
|
|
import com.yxt.anrui.fin.biz.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedService; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; |
|
|
|
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinFundsCarriedForwardApply; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinFundsCarriedForwardApplyQuery; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinFundsCarriedForwardApplyVo; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinFundsCarriedForwardApplyDetailsVo; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinFundsCarriedForwardApplyDto; |
|
|
|
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinFundsCarriedForwardApplyFeign; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -60,51 +71,153 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFundsCarriedForwardApplyMapper, FinFundsCarriedForwardApply> { |
|
|
|
private QueryWrapper<FinFundsCarriedForwardApply> createQueryWrapper(FinFundsCarriedForwardApplyQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<FinFundsCarriedForwardApply> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<FinFundsCarriedForwardApplyVo> listPageVo(PagerQuery<FinFundsCarriedForwardApplyQuery> pq) { |
|
|
|
FinFundsCarriedForwardApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<FinFundsCarriedForwardApply> qw = createQueryWrapper(query); |
|
|
|
IPage<FinFundsCarriedForwardApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<FinFundsCarriedForwardApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<FinFundsCarriedForwardApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(FinFundsCarriedForwardApplyDto dto){ |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private SysStaffOrgFeign sysStaffOrgFeign; |
|
|
|
@Autowired |
|
|
|
private FinCollectionConfirmationService finCollectionConfirmationService; |
|
|
|
@Autowired |
|
|
|
private FinSelectedReceivablesDetailedService finSelectedReceivablesDetailedService; |
|
|
|
|
|
|
|
public PagerVo<FinFundsCarriedForwardApplyVo> listPageVo(PagerQuery<FinFundsCarriedForwardApplyQuery> pq) { |
|
|
|
FinFundsCarriedForwardApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<FinFundsCarriedForwardApply> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getMenuUrl()) || StringUtils.isNotBlank(query.getMenuSid())) { |
|
|
|
//=======================
|
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(query.getOrgSidPath()); |
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
privilegeQuery.setMenuSid(query.getMenuSid()); |
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = query.getOrgSidPath(); |
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
qw.like("fa.orgSidPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("fa.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("fa.orgSidPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("fa.orgSidPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("fa.createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<FinFundsCarriedForwardApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<FinFundsCarriedForwardApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getApplyDeptName())) { |
|
|
|
qw.like("fa.applyDeptName", query.getApplyDeptName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())) { |
|
|
|
qw.like("fa.createByName", query.getCreateByName()); |
|
|
|
} |
|
|
|
String applyStartDate = query.getApplyStartDate(); |
|
|
|
String applyEndDate = query.getApplyEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(applyStartDate), "date_format (bacva.createTime,'%Y-%m-%d') >= date_format('" + applyStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(applyEndDate), "date_format (bacva.createTime,'%Y-%m-%d') <= date_format('" + applyEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<FinFundsCarriedForwardApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<FinFundsCarriedForwardApplyVo> pagging = baseMapper.selectPageVo(page, qw, query.getJzSmallMoney(), query.getJzBigMoney()); |
|
|
|
PagerVo<FinFundsCarriedForwardApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(FinFundsCarriedForwardApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(FinFundsCarriedForwardApplyDto dto){ |
|
|
|
FinFundsCarriedForwardApply entity = new FinFundsCarriedForwardApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(FinFundsCarriedForwardApplyDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(FinFundsCarriedForwardApplyDto dto) { |
|
|
|
FinFundsCarriedForwardApply entity = new FinFundsCarriedForwardApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(FinFundsCarriedForwardApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
FinFundsCarriedForwardApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public FinFundsCarriedForwardApplyDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
FinFundsCarriedForwardApply entity = fetchBySid(sid); |
|
|
|
FinFundsCarriedForwardApplyDetailsVo vo = new FinFundsCarriedForwardApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|
FinFundsCarriedForwardApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public FinFundsCarriedForwardApplyDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
FinFundsCarriedForwardApply entity = fetchBySid(sid); |
|
|
|
FinFundsCarriedForwardApplyDetailsVo vo = new FinFundsCarriedForwardApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<FinFundsCarriedForwardApplyDetailsVo> init(FinFundsCarriedForwardApplyInitQuery finFundsCarriedForwardApplyInitQuery) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<String> busSids = finFundsCarriedForwardApplyInitQuery.getBusSids(); |
|
|
|
List<FinFundsCarriedForwardVehDetailsVo> finFundsCarriedForwardVehDetailsVos = new ArrayList<>(); |
|
|
|
FinFundsCarriedForwardApplyDetailsVo finFundsCarriedForwardApplyDetailsVo = new FinFundsCarriedForwardApplyDetailsVo(); |
|
|
|
SysUserVo sysUserVo = sysUserFeign.fetchBySid(finFundsCarriedForwardApplyInitQuery.getUserSid()).getData(); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setCreateBySid(sysUserVo.getSid()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setCreateByName(sysUserVo.getName()); |
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationFeign.selectByOrgSidPath(finFundsCarriedForwardApplyInitQuery.getOrgSidPath()).getData(); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setApplyDeptSid(sysOrganizationVo.getSid()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setApplyDeptName(sysOrganizationVo.getName()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setPublishInfo(sysOrganizationVo.getName() + "-" + sysUserVo.getName()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setCreateByDate(DateUtil.formatDate(new Date())); |
|
|
|
FinCollectionConfirmation finCollectionConfirmation = null; |
|
|
|
for (String busSid : busSids) { |
|
|
|
FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo = new FinFundsCarriedForwardVehDetailsVo(); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setBusSid(busSid); |
|
|
|
if ("简易订单订金".equals(finFundsCarriedForwardApplyInitQuery.getSource())){ |
|
|
|
finCollectionConfirmation = finCollectionConfirmationService.fetchBySid(busSid); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setBusBillNo(finCollectionConfirmation.getBillNo()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setCustomerName(finCollectionConfirmation.getPayerName()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setBalance(finCollectionConfirmation.getBalance().toString()); |
|
|
|
}else if ("已认款".equals(finFundsCarriedForwardApplyInitQuery.getSource())){ |
|
|
|
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(busSid); |
|
|
|
finCollectionConfirmation = finCollectionConfirmationService.fetchBySid(finSelectedReceivablesDetailed.getCollSid()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setBusBillNo(finSelectedReceivablesDetailed.getContractNo()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setCustomerSid(finSelectedReceivablesDetailed.getCustomerSid()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setCustomerName(finSelectedReceivablesDetailed.getCustomerName()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setVinNo(finSelectedReceivablesDetailed.getVIN()); |
|
|
|
finFundsCarriedForwardVehDetailsVo.setBalance(finSelectedReceivablesDetailed.getBalance()); |
|
|
|
} |
|
|
|
finFundsCarriedForwardVehDetailsVos.add(finFundsCarriedForwardVehDetailsVo); |
|
|
|
} |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setSaleDeptSid(finCollectionConfirmation.getStaffDeptSid()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setSaleDeptName(finCollectionConfirmation.getStaffDeptName()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setStaffSid(finCollectionConfirmation.getStaffUserSid()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setStaffName(finCollectionConfirmation.getStaffName()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setSource(finFundsCarriedForwardApplyInitQuery.getSource()); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setFinFundsCarriedForwardVehDetailsVos(finFundsCarriedForwardVehDetailsVos); |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(finFundsCarriedForwardApplyInitQuery.getOrgSidPath()).getData(); |
|
|
|
String useOrgName = sysOrganizationFeign.fetchBySid(useOrgSid).getData().getName(); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setUseOrgSid(useOrgSid); |
|
|
|
finFundsCarriedForwardApplyDetailsVo.setUseOrgName(useOrgName); |
|
|
|
return rb.success().setData(finFundsCarriedForwardApplyDetailsVo); |
|
|
|
} |
|
|
|
} |