|
|
@ -38,6 +38,7 @@ import com.yxt.anrui.riskcenter.api.loansecondarysalesapply.flowable.*; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansecondarysalescost.LoanSecondarySalesCostVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansecondarysalesveh.LoanSecondarySalesVeh; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansecondarysalesveh.LoanSecondarySalesVehVo; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanreturninboundapply.LoanReturnInboundApplyService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanreturnvehledger.LoanReturnVehLedgerService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loansecondarysalescost.LoanSecondarySalesCostService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loansecondarysalesveh.LoanSecondarySalesVehService; |
|
|
@ -89,6 +90,8 @@ public class LoanSecondarySalesApplyService extends MybatisBaseService<LoanSecon |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private LoanReturnVehLedgerService loanReturnVehLedgerService; |
|
|
|
@Autowired |
|
|
|
private LoanReturnInboundApplyService loanReturnInboundApplyService; |
|
|
|
|
|
|
|
public PagerVo<LoanSecondarySalesApplyVo> listPageVo(PagerQuery<LoanSecondarySalesApplyQuery> pq) { |
|
|
|
LoanSecondarySalesApplyQuery query = pq.getParams(); |
|
|
@ -488,7 +491,56 @@ public class LoanSecondarySalesApplyService extends MybatisBaseService<LoanSecon |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> saveOrUpdateSecondarySales(LoanSecondarySalesApplyDto dto) { |
|
|
|
return null; |
|
|
|
ResultBean<String> rb = ResultBean.fireFail(); |
|
|
|
String sid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(sid)) {//新增
|
|
|
|
LoanSecondarySalesApply loanSecondarySalesApply = new LoanSecondarySalesApply(); |
|
|
|
BeanUtil.copyProperties(dto, loanSecondarySalesApply, "sid"); |
|
|
|
loanSecondarySalesApply.setCreateBySid(dto.getUserSid()); |
|
|
|
loanSecondarySalesApply.setOrgSidPath(dto.getOrgPath()); |
|
|
|
String useOrgSid = sysStaffOrgFeign.getOrgSidByPath(dto.getOrgPath()).getData(); |
|
|
|
loanSecondarySalesApply.setUseOrgSid(useOrgSid); |
|
|
|
//创建组织使用组织
|
|
|
|
ResultBean<SysOrganizationVo> organizationResultBean = sysOrganizationFeign.fetchBySid(useOrgSid); |
|
|
|
if (organizationResultBean.getData() != null) { |
|
|
|
loanSecondarySalesApply.setUseOrgName(organizationResultBean.getData().getName()); |
|
|
|
} |
|
|
|
//申请部门
|
|
|
|
List<String> orgList = Arrays.asList(dto.getOrgPath().split("/")); |
|
|
|
String deptSid = orgList.get(orgList.size() - 1); |
|
|
|
ResultBean<SysOrganizationVo> sysOrganizationVoResultBean = sysOrganizationFeign.fetchBySid(deptSid); |
|
|
|
if (sysOrganizationVoResultBean.getData() != null) { |
|
|
|
loanSecondarySalesApply.setCreateDept(sysOrganizationVoResultBean.getData().getName()); |
|
|
|
loanSecondarySalesApply.setCreateDeptSid(deptSid); |
|
|
|
} |
|
|
|
//根据用户sid查询人员姓名
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(dto.getUserSid()); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
loanSecondarySalesApply.setCreateByName(userVoResultBean.getData().getName()); |
|
|
|
List<UrlQuery> filss = dto.getFilesList(); |
|
|
|
List<String> filesList = filss.stream().map(v -> v.getUrl()).collect(Collectors.toList()); |
|
|
|
if (!filesList.isEmpty()) { |
|
|
|
String files = String.join(",", filesList).replaceAll(fileUploadComponent.getUrlPrefix(), ""); |
|
|
|
loanSecondarySalesApply.setFiles(files); |
|
|
|
} |
|
|
|
baseMapper.insert(loanSecondarySalesApply); |
|
|
|
sid = loanSecondarySalesApply.getSid(); |
|
|
|
//保存车辆
|
|
|
|
List<LoanSecondarySalesVehVo> loanSecondarySalesVehVoList = dto.getLoanSecondarySalesVehVoList(); |
|
|
|
loanSecondarySalesVehVoList.removeAll(Collections.singleton(null)); |
|
|
|
if (!loanSecondarySalesVehVoList.isEmpty()) { |
|
|
|
loanSecondarySalesVehService.saveVeh(loanSecondarySalesVehVoList, sid); |
|
|
|
} |
|
|
|
LoanSecondarySalesCostVo loanSecondarySalesCost = dto.getLoanSecondarySalesCost(); |
|
|
|
if (loanSecondarySalesCost != null) { |
|
|
|
loanSecondarySalesCostService.saveCost(loanSecondarySalesCost, sid); |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
private int submitBusinessData(SubmitLoanSecondarySalesApplyDto dto, LoanSecondarySalesApply loanSecondarySalesApply) { |
|
|
@ -542,13 +594,71 @@ public class LoanSecondarySalesApplyService extends MybatisBaseService<LoanSecon |
|
|
|
} |
|
|
|
String busVinSid = ""; |
|
|
|
String vinNo = ""; |
|
|
|
String saleOrderSid = ""; |
|
|
|
List<String> vinNoLists = new ArrayList<>(); |
|
|
|
List<String> bankContractNoList = new ArrayList<>(); |
|
|
|
List<LoanSecondarySalesVehVo> loanSecondarySalesVehVoList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < chooseSidList.size(); i++) { |
|
|
|
LoanSecondarySalesVehVo loanSecondarySalesVehVo = new LoanSecondarySalesVehVo(); |
|
|
|
String s = chooseSidList.get(i); |
|
|
|
LoanReturnVehLedger loanReturnVehLedger = loanReturnVehLedgerService.fetchBySid(s); |
|
|
|
if ("未处置".equals(loanReturnVehLedger.getDisposal())) { |
|
|
|
if (!"未处置".equals(loanReturnVehLedger.getDisposal())) { |
|
|
|
vinNoLists.add(loanReturnVehLedger.getVinNo()); |
|
|
|
} |
|
|
|
LoanReturnInboundApply loanReturnInboundApply = loanReturnInboundApplyService.fetchBySid(loanReturnVehLedger.getBusSid()); |
|
|
|
if (StringUtils.isNotBlank(loanReturnInboundApply.getBankContractNo())) { |
|
|
|
bankContractNoList.add(loanReturnInboundApply.getBankContractNo()); |
|
|
|
} |
|
|
|
busVinSid = loanReturnInboundApply.getBusVinSid(); |
|
|
|
if ("主车".equals(loanReturnVehLedger.getVehType())) { |
|
|
|
if ("未处置".equals(loanReturnVehLedger.getVehType())) { |
|
|
|
loanSecondarySalesVehVo.setBusVinSid(loanReturnVehLedger.getBusVinSid()); |
|
|
|
loanSecondarySalesVehVo.setVinNo(loanReturnVehLedger.getVinNo()); |
|
|
|
loanSecondarySalesVehVo.setVehMark(loanReturnVehLedger.getVehMark()); |
|
|
|
loanSecondarySalesVehVo.setModelName(loanReturnVehLedger.getVehModel()); |
|
|
|
loanSecondarySalesVehVo.setModelSid(loanReturnVehLedger.getVehModelSid()); |
|
|
|
loanSecondarySalesVehVo.setConfigSid(loanReturnVehLedger.getConfigSid()); |
|
|
|
loanSecondarySalesVehVoList.add(loanSecondarySalesVehVo); |
|
|
|
} |
|
|
|
|
|
|
|
//根据主车查询挂车信息
|
|
|
|
LoanReturnVehLedger loanReturnVehLedgerT = loanReturnVehLedgerService.selectByPSid(loanReturnVehLedger.getSid()); |
|
|
|
if ("未处置".equals(loanReturnVehLedgerT.getVehType())) { |
|
|
|
loanSecondarySalesVehVo = new LoanSecondarySalesVehVo(); |
|
|
|
loanSecondarySalesVehVo.setVehType(loanReturnVehLedgerT.getVehType()); |
|
|
|
loanSecondarySalesVehVo.setVehMark(loanReturnVehLedgerT.getVehMark()); |
|
|
|
loanSecondarySalesVehVo.setVinNo(loanReturnVehLedgerT.getVinNo()); |
|
|
|
loanSecondarySalesVehVo.setModelName(loanReturnVehLedgerT.getVehModel()); |
|
|
|
loanSecondarySalesVehVoList.add(loanSecondarySalesVehVo); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if ("挂车".equals(loanReturnVehLedger.getVehType())) { |
|
|
|
if ("未处置".equals(loanReturnVehLedger.getVehType())) { |
|
|
|
loanSecondarySalesVehVo = new LoanSecondarySalesVehVo(); |
|
|
|
loanSecondarySalesVehVo.setVehType(loanReturnVehLedger.getVehType()); |
|
|
|
loanSecondarySalesVehVo.setVehMark(loanReturnVehLedger.getVehMark()); |
|
|
|
loanSecondarySalesVehVo.setVinNo(loanReturnVehLedger.getVinNo()); |
|
|
|
loanSecondarySalesVehVo.setModelName(loanReturnVehLedger.getVehModel()); |
|
|
|
loanSecondarySalesVehVoList.add(loanSecondarySalesVehVo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
vinNoLists.removeAll(Collections.singleton(null)); |
|
|
|
if (!vinNoLists.isEmpty()) { |
|
|
|
return rb.setMsg(String.join(",", vinNoLists) + "车架号处置方式非未处置,不能二次销售"); |
|
|
|
} |
|
|
|
loanSecondarySalesVehVoList.removeAll(Collections.singleton(null)); |
|
|
|
//去重车架号
|
|
|
|
loanSecondarySalesVehVoList = loanSecondarySalesVehVoList.stream() |
|
|
|
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getVinNo()))), ArrayList::new)); |
|
|
|
Set<String> set = new HashSet<>(bankContractNoList); // 创建HashSet对象,自动去重
|
|
|
|
List<String> distinctList = new ArrayList<>(set); |
|
|
|
distinctList.removeAll(Collections.singleton(null)); |
|
|
|
if (distinctList.size() != 1) { |
|
|
|
return rb.setMsg("请选择相同资方合同编号的车辆"); |
|
|
|
} |
|
|
|
loanSecondarySalesApplyDetailsVo.setLoanSecondarySalesVehVoList(loanSecondarySalesVehVoList); |
|
|
|
//根据用户查询发起人、发起部门、发起日期为当前日期
|
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|