From 36d6553a5db54e2a69a531c762b74f5a6497e634 Mon Sep 17 00:00:00 2001 From: yunuo970428 <405378304@qq.com> Date: Sat, 11 May 2024 16:22:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=BF=98=E6=AC=BE?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E8=A1=A8--=E5=A2=9E=E5=8A=A0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD=E3=80=81=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5=E3=80=81=E5=8A=9E?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=85=B6=E4=B8=AD?= =?UTF-8?q?=E4=B8=80=E5=8F=B0=E8=BD=A6=E4=B8=8D=E5=90=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repaymentschedule/repaymentschedule.js | 10 ++ .../repaymentschedule/repaymentschedule.vue | 90 +++++++++++- .../repaymentscheduleAdd.vue | 130 ++++++++++++++++++ 3 files changed, 226 insertions(+), 4 deletions(-) diff --git a/anrui-riskcenter-ui/src/api/repaymentschedule/repaymentschedule.js b/anrui-riskcenter-ui/src/api/repaymentschedule/repaymentschedule.js index eb8aae5733..4bb3cf8939 100644 --- a/anrui-riskcenter-ui/src/api/repaymentschedule/repaymentschedule.js +++ b/anrui-riskcenter-ui/src/api/repaymentschedule/repaymentschedule.js @@ -51,5 +51,15 @@ export default { data: data, headers: { 'Content-Type': 'application/json' } }) + }, + // 导出 + exportExcel(data) { + return request({ + url: '/buscenter/v1/bussalesorderloancontract/exportExcel', + method: 'post', + responseType: 'blob', // 表明返回服务器返回的数据类型 + data: data, + headers: { 'Content-Type': 'application/json' } + }) } } diff --git a/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentschedule.vue b/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentschedule.vue index 1f880aa3f6..b37a55c9dc 100644 --- a/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentschedule.vue +++ b/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentschedule.vue @@ -31,6 +31,16 @@ + + + + + + + + + +
查询 @@ -55,16 +65,21 @@ - + + - + + + + +
@@ -120,6 +135,13 @@ export default { btnKey: 'downloadRepaymentPlan', btnLabel: '下载还款计划表' }, + { + type: 'success', + size: 'small', + icon: 'export', + btnKey: 'doExport', + btnLabel: '导出' + }, { type: 'info', size: 'small', @@ -134,6 +156,16 @@ export default { tableKey: 0, list: [], sids: [], + builded_list: [ + { + dictKey: '1', + dictValue: '是' + }, + { + dictKey: '0', + dictValue: '否' + } + ], state_list: [], multipleSelection: [], FormLoading: false, @@ -153,7 +185,10 @@ export default { loanContractNo: '', borrowerName: '', bankName: '', - policyName: '' + policyName: '', + createStartDate: '', + createEndDate: '', + builded: '' } } } @@ -177,6 +212,18 @@ export default { }) }, methods: { + // 限制日期不可选择开始日期之前的 + pickerStartData(newtime) { + return { + disabledDate(time) { return time.getTime() > new Date(newtime) - 1000 * 60 * 60 * 24 } + } + }, + // 限制日期不可选择开始日期之前的 + pickerEndData(newtime) { + return { + disabledDate(time) { return time.getTime() < new Date(newtime) - 1000 * 60 * 60 * 24 } + } + }, // 搜索条件效果 clicksearchShow() { this.isSearchShow = !this.isSearchShow @@ -198,6 +245,9 @@ export default { case 'doClose': this.doClose() break + case 'doExport': + this.doExport() + break default: break } @@ -262,7 +312,10 @@ export default { loanContractNo: '', borrowerName: '', bankName: '', - policyName: '' + policyName: '', + createStartDate: '', + createEndDate: '', + builded: '' } } this.getList() @@ -319,6 +372,35 @@ export default { this.$message({ showClose: true, type: 'error', message: '请至少选择一条记录进行下载操作' }) } }, + doExport() { + if (this.listQuery.params.createStartDate === '' || this.listQuery.params.createEndDate === '') { + this.$message({ showClose: true, type: 'error', message: '查询条件中的生成日期请选择开始日期和截止日期' }) + return + } + const loading = this.$loading({ + lock: true, + text: 'Loading', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + req.exportExcel(this.listQuery.params).then((resp) => { + loading.close() + const blob = new Blob([resp], { + type: 'application/vnd.ms-excel' + }) + const fileName = '消贷合同列表' + '.xls' + const elink = document.createElement('a') + elink.download = fileName + elink.style.display = 'nonde' + elink.href = URL.createObjectURL(blob) + document.body.appendChild(elink) + elink.click() + URL.revokeObjectURL(elink.href) + document.body.removeChild(elink) + }).catch(() => { + loading.close() + }) + }, toInfo(row) { this.viewState = 3 this.$refs['divInfo'].showInfo(row) diff --git a/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentscheduleAdd.vue b/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentscheduleAdd.vue index 3466d4aaff..0c4c09f5dc 100644 --- a/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentscheduleAdd.vue +++ b/anrui-riskcenter-ui/src/views/repaymentschedule/repaymentscheduleAdd.vue @@ -98,6 +98,45 @@ +
+ + + 其中一台车不同 + + +
+
主金融产品{{ (formobj.policyName) }}
+ + +
*首期月还
+ +
+ +
*期间月还
+ +
+ +
*末期月还
+ +
+
+
其它融({{ formobj.otherPolicyName }})
+ + +
*首期月还
+ +
+ +
*期间月还
+ +
+ +
*末期月还
+ +
+
+
+
@@ -182,9 +221,76 @@ export default { } } } + var singleMainFirstRepay = (rule, value, callback) => { + if (value === '') { + callback(new Error('主金融产品期间月还不能为空')) + } else { + if (value == '0') { + callback(new Error('主金融产品期间月还不能为零')) + } else { + callback() + } + } + } + var singleMainMidRepay = (rule, value, callback) => { + if (value === '') { + callback(new Error('主金融产品期间月还不能为空')) + } else { + if (value == '0') { + callback(new Error('主金融产品期间月还不能为零')) + } else { + callback() + } + } + } + var singleMainLastRepay = (rule, value, callback) => { + if (value === '') { + callback(new Error('主金融产品末期月还不能为空')) + } else { + if (value == '0') { + callback(new Error('主金融产品末期月还不能为零')) + } else { + callback() + } + } + } + var singleOtherFirstRepay = (rule, value, callback) => { + if (value === '') { + callback(new Error('其它融首期月还不能为空')) + } else { + if (value == '0') { + callback(new Error('其它融首期月还不能为零')) + } else { + callback() + } + } + } + var singleOtherMidRepay = (rule, value, callback) => { + if (value === '') { + callback(new Error('其它融期间月还不能为空')) + } else { + if (value == '0') { + callback(new Error('其它融期间月还不能为零')) + } else { + callback() + } + } + } + var singleOtherLastRepay = (rule, value, callback) => { + if (value === '') { + callback(new Error('其它融末期月还不能为空')) + } else { + if (value == '0') { + callback(new Error('其它融末期月还不能为零')) + } else { + callback() + } + } + } return { viewState: 1, submitdisabled: false, + different: false, formobj: { salesOrderSid: '', solutionsSid: '', @@ -208,6 +314,13 @@ export default { otherMidRepay: '', otherLastRepay: '', isOtherPolicy: '', + isDifferent: false, + singleMainFirstRepay: '', + singleMainMidRepay: '', + singleMainLastRepay: '', + singleOtherFirstRepay: '', + singleOtherMidRepay: '', + singleOtherLastRepay: '', userSid: '', solutionsDetailsssVo: [] }, @@ -219,6 +332,12 @@ export default { otherFirstRepay: [{ required: true, validator: otherFirstRepay, trigger: 'blur' }], otherMidRepay: [{ required: true, validator: otherMdRepay, trigger: 'blur' }], otherLastRepay: [{ required: true, validator: otherLastRepay, trigger: 'blur' }], + singleMainFirstRepay: [{ required: true, validator: singleMainFirstRepay, trigger: 'blur' }], + singleMainMidRepay: [{ required: true, validator: singleMainMidRepay, trigger: 'blur' }], + singleMainLastRepay: [{ required: true, validator: singleMainLastRepay, trigger: 'blur' }], + singleOtherFirstRepay: [{ required: true, validator: singleOtherFirstRepay, trigger: 'blur' }], + singleOtherMidRepay: [{ required: true, validator: singleOtherMidRepay, trigger: 'blur' }], + singleOtherLastRepay: [{ required: true, validator: singleOtherLastRepay, trigger: 'blur' }], otherBankNo: [{ required: true, message: '其它融资方合同号不能为空', trigger: 'blur' }], otherRepayDate: [{ required: true, message: '其它融首期还款日不能为空', trigger: 'change' }] } @@ -232,6 +351,9 @@ export default { req.loanCreateSchedule({ salesOrderSid: sid }).then((res) => { if (res.success) { this.formobj = res.data + if (parseInt(this.formobj.vehCount) > 1) { + this.different = true + } } }) }, @@ -295,10 +417,18 @@ export default { otherMidRepay: '', otherLastRepay: '', isOtherPolicy: '', + isDifferent: false, + singleMainFirstRepay: '', + singleMainMidRepay: '', + singleMainLastRepay: '', + singleOtherFirstRepay: '', + singleOtherMidRepay: '', + singleOtherLastRepay: '', userSid: '', solutionsDetailsssVo: [] } this.submitdisabled = false + this.different = false this.$emit('doback') } } From 374c7c2ea6c67c0ce572e20ead123bd5b0ce3fb2 Mon Sep 17 00:00:00 2001 From: fanzongzhe <285169773@qq.com> Date: Sat, 11 May 2024 16:22:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=98=E6=AC=BE?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E8=A1=A8=E5=8F=8A=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusLoancontractForRepayQuery.java | 6 + .../BusLoancontractForRepayVo.java | 6 + .../BusSalesOrderLoancontractFeign.java | 5 + ...usSalesOrderLoancontractFeignFallback.java | 5 + .../LoanRepaymentPlanDetailsExportVo.java | 49 + .../BusSalesOrderLoancontractMapper.java | 2 + .../BusSalesOrderLoancontractMapper.xml | 49 +- .../BusSalesOrderLoancontractRest.java | 24 +- .../BusSalesOrderLoancontractService.java | 191 +- .../LoanCreateSchedulePdfVo.java | 14 + .../LoanRepaymentSchedule.java | 15 +- .../LoanRepaymentScheduleFeign.java | 9 +- .../LoanRepaymentScheduleFeignFallback.java | 8 + .../LoanRepaymentScheduleMapper.java | 6 +- .../LoanRepaymentScheduleMapper.xml | 46 +- .../LoanRepaymentScheduleRest.java | 13 +- .../LoanRepaymentScheduleService.java | 2376 ++++++++++++----- 17 files changed, 2152 insertions(+), 672 deletions(-) create mode 100644 anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/LoanRepaymentPlanDetailsExportVo.java diff --git a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayQuery.java b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayQuery.java index e3ded64066..3184dc5f90 100644 --- a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayQuery.java +++ b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayQuery.java @@ -4,6 +4,9 @@ import com.yxt.common.core.query.Query; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * @author Administrator * @description @@ -26,6 +29,7 @@ public class BusLoancontractForRepayQuery implements Query { private String bankName; @ApiModelProperty("金融产品名称") private String policyName; // 金融产品名称 + private String builded; //是否生成还款计划表 @ApiModelProperty("组织全路径") private String orgPath; @ApiModelProperty("菜单sid") @@ -34,4 +38,6 @@ public class BusLoancontractForRepayQuery implements Query { private String menuUrl; @ApiModelProperty("用户sid") private String userSid; + private String createStartDate; + private String createEndDate; } diff --git a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayVo.java b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayVo.java index 7f419c16b9..81b9e5501f 100644 --- a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayVo.java +++ b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusLoancontractForRepayVo.java @@ -35,4 +35,10 @@ public class BusLoancontractForRepayVo implements Vo { private String orderSid; private String builded; //是否生成还款计划表 private boolean handleBtn; //ture 可以办理 false 不能 + private String repaymentCreateTime; //生成时间 + private String cwDeptNo; //财务中部门编码 + private String mainAmount; //主产品还款总金额 + private String otherAmount; //其他融还款总金额 + private String amountAll; // 总金额 + } diff --git a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeign.java b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeign.java index c703ff0197..a272a441e4 100644 --- a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeign.java +++ b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeign.java @@ -102,6 +102,11 @@ public interface BusSalesOrderLoancontractFeign { @PostMapping("/setRepaymentState") public ResultBean setRepaymentState(@RequestParam("sid") String sid, @RequestParam("createTime")String createTime); + @PostMapping("/exportExcel") + @ApiOperation(value = "还款计划表导出") + public void exportExcel(@RequestBody BusLoancontractForRepayQuery query); + + @ApiOperation("推送融资放款的应收") @PostMapping("/pushLoanOrder") @ResponseBody diff --git a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeignFallback.java b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeignFallback.java index bc25cbe4e2..fac1719426 100644 --- a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeignFallback.java +++ b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/BusSalesOrderLoancontractFeignFallback.java @@ -97,6 +97,11 @@ public class BusSalesOrderLoancontractFeignFallback implements BusSalesOrderLoan return null; } + @Override + public void exportExcel(BusLoancontractForRepayQuery query) { + + } + @Override public ResultBean pushLoanOrder(LoanContractPush loanContractPush) { return null; diff --git a/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/LoanRepaymentPlanDetailsExportVo.java b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/LoanRepaymentPlanDetailsExportVo.java new file mode 100644 index 0000000000..06a2c34c65 --- /dev/null +++ b/anrui-buscenter/anrui-buscenter-api/src/main/java/com/yxt/anrui/buscenter/api/bussalesorderloancontract/LoanRepaymentPlanDetailsExportVo.java @@ -0,0 +1,49 @@ +package com.yxt.anrui.buscenter.api.bussalesorderloancontract; + +import com.yxt.common.core.utils.ExportEntityMap; +import lombok.Data; + +/** + * @author Administrator + * @description + * @date 2023/11/13 9:34 + */ +@Data +public class LoanRepaymentPlanDetailsExportVo { + + @ExportEntityMap(CnName = "序号", EnName = "rankNo") + private Integer rankNo; + @ExportEntityMap(CnName = "生成日期", EnName = "createTime") + private String createTime; + @ExportEntityMap(CnName = "客户", EnName = "customer") + private String customer; + @ExportEntityMap(CnName = " 销售专员", EnName = "staffName") + private String staffName; + @ExportEntityMap(CnName = "贷款人", EnName = "borrowerName") + private String borrowerName; + @ExportEntityMap(CnName = "车架号", EnName = "vinNo") + private String vinNo; + @ExportEntityMap(CnName = "车牌号", EnName = "vehMark") + private String vehMark; + @ExportEntityMap(CnName = "消贷合同号", EnName = "loanContractNo") + private String loanContractNo; + @ExportEntityMap(CnName = "资方合同号", EnName = "bankContractNo") + private String bankContractNo; + @ExportEntityMap(CnName = "资方", EnName = "bankName") + private String bankName; + @ExportEntityMap(CnName = "金融产品政策", EnName = "policyName") + private String policyName; + @ExportEntityMap(CnName = "期数", EnName = "period") + private String period; + @ExportEntityMap(CnName = "应还", EnName = "dueMoney") + private String dueMoney; + @ExportEntityMap(CnName = "应还日期", EnName = "dueDate") + private String dueDate; + @ExportEntityMap(CnName = "是否存在其他融", EnName = "policyOrOther") + private String policyOrOther; + @ExportEntityMap(CnName = "销售部门", EnName = "dept") + private String dept; + @ExportEntityMap(CnName = "分公司", EnName = "useOrgName") + private String useOrgName; + +} diff --git a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.java b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.java index 601b9e5bcf..9ef7187a01 100644 --- a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.java +++ b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.java @@ -94,4 +94,6 @@ public interface BusSalesOrderLoancontractMapper extends BaseMapper selLoancontractsForExport(@Param(Constants.WRAPPER) QueryWrapper qw); } diff --git a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.xml b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.xml index 97d291f66b..e4a1a6a2e7 100644 --- a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.xml +++ b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractMapper.xml @@ -17,23 +17,24 @@ + diff --git a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractRest.java b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractRest.java index 6f645a8457..c4b8446973 100644 --- a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractRest.java +++ b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractRest.java @@ -27,6 +27,7 @@ package com.yxt.anrui.buscenter.biz.bussalesorderloancontract; import com.yxt.anrui.buscenter.api.busdeliveredapply.PushOtherDocument; import com.yxt.anrui.buscenter.api.bussalesorderloancontract.*; +import com.yxt.common.base.utils.ExportExcelUtils; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; @@ -35,6 +36,9 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; import java.util.List; @@ -58,7 +62,8 @@ public class BusSalesOrderLoancontractRest implements BusSalesOrderLoancontractF @Autowired private BusSalesOrderLoancontractService busSalesOrderLoancontractService; - + @Autowired + private HttpServletResponse response; @Override @ApiOperation("根据条件分页查询数据的列表") @PostMapping("/listPage") @@ -121,6 +126,23 @@ public class BusSalesOrderLoancontractRest implements BusSalesOrderLoancontractF return rb.success().setData(pv); } + @Override + public void exportExcel(BusLoancontractForRepayQuery query) { + //得到所有要导出的数据 + List list = busSalesOrderLoancontractService.exportExcel(query); + //定义导出的excel名字 + String excelName = "还款计划表列表"; + String fileNameURL = ""; + try { + fileNameURL = URLEncoder.encode(excelName, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + //导出车辆管理列表 + ExportExcelUtils.export(fileNameURL, list, LoanRepaymentPlanDetailsExportVo.class, response); + } + + @Override public ResultBean setRepaymentState(String sid, String createTime) { ResultBean rb = ResultBean.fireFail(); diff --git a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractService.java b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractService.java index b836206a31..63f89ab7d9 100644 --- a/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractService.java +++ b/anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorderloancontract/BusSalesOrderLoancontractService.java @@ -198,6 +198,97 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService exportExcel(BusLoancontractForRepayQuery pagerQuery) { + QueryWrapper qw = new QueryWrapper<>(); + //======================= + PrivilegeQuery privilegeQuery = new PrivilegeQuery(); + privilegeQuery.setOrgPath(pagerQuery.getOrgPath()); + privilegeQuery.setMenuSid(pagerQuery.getMenuSid()); + privilegeQuery.setMenuUrl(pagerQuery.getMenuUrl()); + privilegeQuery.setUserSid(pagerQuery.getUserSid()); + ResultBean defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); + if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { + //数据权限ID(1集团、2事业部、3分公司、4部门、5个人) + String orgSidPath = pagerQuery.getOrgPath(); + 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("bs.orgSidPath", orgSidPath); + } else if ("2".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i2); + qw.like("bs.orgSidPath", orgSidPath); + } else if ("3".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i3); + qw.like("bs.orgSidPath", orgSidPath); + } else if ("4".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i4); + qw.like("bs.orgSidPath", orgSidPath); + } else if ("5".equals(orgLevelKey)) { + qw.eq("bs.createBySid", pagerQuery.getUserSid()); + } else { + return new ArrayList<>(); + } + } else { + return new ArrayList<>(); + } + //======================= + //分公司 + if (StringUtils.isNotBlank(pagerQuery.getUseOrgName())) { + qw.like("bs.useOrgName", pagerQuery.getUseOrgName()); + } + //销售部门 + if (StringUtils.isNotBlank(pagerQuery.getOrgName())) { + qw.like("bs.orgName", pagerQuery.getOrgName()); + } + //销售专员 + if (StringUtils.isNotBlank(pagerQuery.getStaffName())) { + qw.like("bs.staffName", pagerQuery.getStaffName()); + } + //消贷合同编号 + if (StringUtils.isNotBlank(pagerQuery.getLoanContractNo())) { + qw.like("co.loanContractNo", pagerQuery.getLoanContractNo()); + } + //贷款人 + if (StringUtils.isNotBlank(pagerQuery.getBorrowerName())) { + qw.like("co.borrowerName", pagerQuery.getBorrowerName()); + } + //资方 + if (StringUtils.isNotBlank(pagerQuery.getBankName())) { + qw.like("co.bankName", pagerQuery.getBankName()); + } + //金融产品 + if (StringUtils.isNotBlank(pagerQuery.getPolicyName())) { + qw.like("co.policyName", pagerQuery.getPolicyName()); + } + //金融产品 + if (StringUtils.isNotBlank(pagerQuery.getBuilded())) { + qw.like("co.repaymentState", pagerQuery.getBuilded()); + } + String createStartTime = pagerQuery.getCreateStartDate(); + String createEndTime = pagerQuery.getCreateEndDate(); + qw.apply(StringUtils.isNotEmpty(createStartTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). + apply(StringUtils.isNotEmpty(createEndTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" + ); + qw.ne("co.state", 0); + qw.eq("co.isDelete", 0); + qw.eq("co.busNo", "305"); + qw.orderByDesc("co.createTime"); + List loancontracts = baseMapper.selLoancontractsForExport(qw); + if (!loancontracts.isEmpty()) { + List sids = loancontracts.stream().map(BusLoancontractForRepayVo::getSalesOrderSid).collect(Collectors.toList()); + List exportVos = repaymentScheduleFeign.exportExcel(sids).getData(); + if (!exportVos.isEmpty()) { + return exportVos; + } + } + return new ArrayList<>(); + } + /** * 消贷合同生成还款计划表列表 * @@ -256,8 +347,8 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService= date_format('" + createStartTime + "','%Y-%m-%d')"). + apply(StringUtils.isNotEmpty(createEndTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" + ); + qw.ne("co.state", 0); qw.eq("co.isDelete", 0); + qw.eq("co.busNo", "305"); qw.orderByDesc("co.createTime"); IPage pagging = baseMapper.listPageForRepay(page, qw); List records = pagging.getRecords(); @@ -293,14 +394,88 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService repaymentSchedule = repaymentScheduleFeign.selByLoanContractSid(record.getSalesOrderSid()); -// if (repaymentSchedule.getData() != null) { + ResultBean repaymentSchedule = repaymentScheduleFeign.selByLoanContractSid(record.getSalesOrderSid()); + if (repaymentSchedule.getData() != null) { + LoanRepaymentSchedule schedule = repaymentSchedule.getData(); + if (StringUtils.isNotBlank(schedule.getCwDeptNo())) { + record.setCwDeptNo(schedule.getCwDeptNo()); + } + BigDecimal mainAmount; //主产品还款总金额 + BigDecimal otherAmount; //其他融还款总金额 + BigDecimal amountAll; // 总金额 + //车辆数 + BigDecimal vehCount = new BigDecimal(schedule.getVehCount()); + if (StringUtils.isNotBlank(schedule.getIsDifferent())) { + if (schedule.getIsDifferent().equals("是")) { + //判断是否有一台车不同月还金额 + //主产品期数 + BigDecimal mainPeriod = new BigDecimal(schedule.getMainPeriod()); + //主产品首期月还 + BigDecimal mainFirstRepay = schedule.getMainFirstRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleMainFirstRepay()); + //主产品期间月还 + BigDecimal mainMidRepay = schedule.getMainMidRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleMainMidRepay()).multiply(mainPeriod.subtract(new BigDecimal("2"))); + //主产品末期月还 + BigDecimal mainLastRepay = schedule.getMainLastRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleMainLastRepay()); + mainAmount = mainFirstRepay.add(mainMidRepay).add(mainLastRepay); + if (schedule.getIsOtherPolicy().equals("1")) { + //有其他融 + //其他融期数 + BigDecimal otherPeriod = new BigDecimal(schedule.getOtherPeriod()); + //其他融首期月还 + BigDecimal otherFirstRepay = schedule.getOtherFirstRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleOtherFirstRepay()); + //其他融期间月还 + BigDecimal otherMidRepay = schedule.getOtherMidRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleOtherMidRepay()).multiply(mainPeriod.subtract(new BigDecimal("2"))); + //其他融末期月还 + BigDecimal otherLastRepay = schedule.getOtherLastRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleOtherLastRepay()); + otherAmount = otherFirstRepay.add(otherMidRepay).add(otherLastRepay); + amountAll = mainAmount.add(otherAmount); + record.setMainAmount(mainAmount.toString()); + record.setOtherAmount(otherAmount.toString()); + record.setAmountAll(amountAll.toString()); + } else if (schedule.getIsOtherPolicy().equals("0")) { + //没有其他融 + record.setMainAmount(mainAmount.toString()); + record.setAmountAll(mainAmount.toString()); + } + } + } else { + //主产品期数 + BigDecimal mainPeriod = new BigDecimal(schedule.getMainPeriod()); + //主产品首期月还 + BigDecimal mainFirstRepay = schedule.getMainFirstRepay().multiply(vehCount); + //主产品期间月还 + BigDecimal mainMidRepay = mainPeriod.subtract(new BigDecimal("2")).multiply(schedule.getMainMidRepay()).multiply(vehCount); + //主产品末期月还 + BigDecimal mainLastRepay = schedule.getMainLastRepay().multiply(vehCount); + mainAmount = mainFirstRepay.add(mainMidRepay).add(mainLastRepay); + if (schedule.getIsOtherPolicy().equals("1")) { + //有其他融 + //其他融期数 + BigDecimal otherPeriod = new BigDecimal(schedule.getOtherPeriod()); + //其他融首期月还 + BigDecimal otherFirstRepay = schedule.getOtherFirstRepay().multiply(vehCount); + //其他融期间月还 + BigDecimal otherMidRepay = otherPeriod.subtract(new BigDecimal("2")).multiply(schedule.getOtherMidRepay()).multiply(vehCount); + //其他融末期月还 + BigDecimal otherLastRepay = schedule.getOtherLastRepay().multiply(vehCount); + otherAmount = otherFirstRepay.add(otherMidRepay).add(otherLastRepay); + amountAll = mainAmount.add(otherAmount); + record.setMainAmount(mainAmount.toString()); + record.setOtherAmount(otherAmount.toString()); + record.setAmountAll(amountAll.toString()); + } else if (schedule.getIsOtherPolicy().equals("0")) { + //没有其他融 + record.setMainAmount(mainAmount.toString()); + record.setAmountAll(mainAmount.toString()); + } + } // record.setBuilded("是"); // List histories = repaymentScheduleFeign.selHistoryBySid(repaymentSchedule.getData().getSid()).getData(); // if (histories.isEmpty() || histories == null) { // record.setHandleBtn(true); // } -// } else { + } +// else { // record.setBuilded("否"); // if (StringUtils.isNotBlank(record.getBankContractNo())) { // record.setHandleBtn(true); @@ -1095,7 +1270,7 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService fetchBySid(@RequestParam("sid") String sid); + @PostMapping("/exportExcel") + @ApiOperation(value = "还款计划表导出") + public ResultBean> exportExcel(@RequestBody List sids); + + @ApiOperation("生成还款计划表") @PostMapping("/loanCreateSchedulePdf") @ResponseBody diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymentschedule/LoanRepaymentScheduleFeignFallback.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymentschedule/LoanRepaymentScheduleFeignFallback.java index 2b4aa92a42..33f3d71490 100644 --- a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymentschedule/LoanRepaymentScheduleFeignFallback.java +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymentschedule/LoanRepaymentScheduleFeignFallback.java @@ -1,5 +1,7 @@ package com.yxt.anrui.riskcenter.api.loanrepaymentschedule; +import com.yxt.anrui.buscenter.api.bussalesorderloancontract.BusLoancontractForRepayQuery; +import com.yxt.anrui.buscenter.api.bussalesorderloancontract.LoanRepaymentPlanDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; @@ -26,6 +28,12 @@ public class LoanRepaymentScheduleFeignFallback implements LoanRepaymentSchedule return null; } + @Override + public ResultBean exportExcel(List sids) { + return null; + } + + @Override public ResultBean loanCreateSchedulePdf(LoanCreateSchedulePdfVo dto) { return null; diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.java index 7f9838ad4b..b299075f45 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.java @@ -4,12 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.yxt.anrui.buscenter.api.bussalesorderloancontract.LoanRepaymentPlanDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.*; import com.yxt.anrui.riskcenter.api.loanwarrantinformation.LoanWarrantInformation; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; import java.util.List; @@ -40,4 +40,8 @@ public interface LoanRepaymentScheduleMapper extends BaseMapper selPlansInfoByMainSidAndVinNo(@Param("mainSid") String mainSid, @Param("vinNo") String vinNo,@Param("mainOrOther") String mainOrOther); String selSumAmountDueMoney(@Param("mainSid") String mainSid, @Param("vinNo") String vinNo,@Param("mainOrOther") String mainOrOther); + + String selSumAmountDueMoneyByBusVinSid(@Param("mainSid") String mainSid,@Param("busVinSid") String busVinSid,@Param("mainOrOther") String mainOrOther); + + List selPlansExcel(@Param("sids") List sids); } diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.xml b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.xml index a2dbe453d2..7bc0b8f38a 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.xml +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleMapper.xml @@ -94,4 +94,48 @@ WHERE scheduleSid = #{mainSid} AND policyOrOther = #{mainOrOther} AND vinNo LIKE CONCAT( '%', #{vinNo}, '%' ) - \ No newline at end of file + + + diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleRest.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleRest.java index dcc3e95ee1..549fbe283c 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleRest.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleRest.java @@ -1,9 +1,11 @@ package com.yxt.anrui.riskcenter.biz.loanrepaymentschedule; +import com.yxt.anrui.buscenter.api.bussalesorderloancontract.BusLoancontractForRepayQuery; +import com.yxt.anrui.buscenter.api.bussalesorderloancontract.LoanRepaymentPlanDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.*; -import com.yxt.anrui.riskcenter.api.loanwarrantinformation.LoanWarrantInformationVo; +import com.yxt.common.base.utils.ExportExcelUtils; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; @@ -12,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletResponse; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.List; /** @@ -39,6 +44,12 @@ public class LoanRepaymentScheduleRest implements LoanRepaymentScheduleFeign { return rb.success().setData(repaymentSchedule); } + @Override + public ResultBean> exportExcel(List sids) { + return loanRepaymentScheduleService.exportExcel(sids); + } + + @Override public ResultBean loanCreateSchedulePdf(LoanCreateSchedulePdfVo dto) { return loanRepaymentScheduleService.loanCreateSchedulePdf(dto); diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleService.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleService.java index 8f9813e38a..d43364dc38 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleService.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentschedule/LoanRepaymentScheduleService.java @@ -1,29 +1,19 @@ package com.yxt.anrui.riskcenter.biz.loanrepaymentschedule; 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.baomidou.mybatisplus.extension.api.R; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemDetailsVo; import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemFeign; -import com.yxt.anrui.buscenter.api.bushandover.BusHandover; -import com.yxt.anrui.buscenter.api.bushandoveritems.BusHandoverItems; import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder; import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrderFeign; -import com.yxt.anrui.buscenter.api.bussalesorder.SolutionsDetailsssVo; import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerDetailsVo; import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerFeign; -import com.yxt.anrui.buscenter.api.bussalesorderloancontract.BusSalesOrderLoancontract; -import com.yxt.anrui.buscenter.api.bussalesorderloancontract.BusSalesOrderLoancontractDetailsVo; -import com.yxt.anrui.buscenter.api.bussalesorderloancontract.BusSalesOrderLoancontractFeign; -import com.yxt.anrui.buscenter.api.bussalesorderloancontract.BusSalesOrderLoancontractVo; +import com.yxt.anrui.buscenter.api.bussalesorderloancontract.*; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign; -import com.yxt.anrui.buscenter.api.busvehicledatahandover.BusDataListPdfVo; -import com.yxt.anrui.buscenter.api.busvehicledatahandover.BusVehicleDataHandoverPdfVo; import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempFeign; import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempVo; import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign; @@ -32,15 +22,11 @@ import com.yxt.anrui.fin.api.kingdee.voucher.GeneralVoucher; 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.SysUserInfoVo; import com.yxt.anrui.portal.api.sysuser.SysUserVo; import com.yxt.anrui.riskcenter.api.loanfinbank.LoanFinBank; import com.yxt.anrui.riskcenter.api.loanfinotherPolicy.LoanFinOtherPolicy; import com.yxt.anrui.riskcenter.api.loanfinpolicy.LoanFinPolicy; -import com.yxt.anrui.riskcenter.api.loanfinpolicy.LoanFinPolicyVo; -import com.yxt.anrui.riskcenter.api.loanmortgageinformationtransact.LoanMortgageInformationTransactDto; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsDto; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.*; @@ -48,19 +34,15 @@ import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; import com.yxt.anrui.riskcenter.api.loansolutions.app.SolutionsDetailsVo; import com.yxt.anrui.riskcenter.api.loansolutionsotherpolicy.LoanSolutionsOtherpolicy; import com.yxt.anrui.riskcenter.api.loanwarrantinformation.LoanWarrantInformation; -import com.yxt.anrui.riskcenter.api.loanwarrantinformation.LoanWarrantInformationQuery; -import com.yxt.anrui.riskcenter.api.loanwarrantinformation.LoanWarrantInformationVo; import com.yxt.anrui.riskcenter.biz.loanfinbank.LoanFinBankService; import com.yxt.anrui.riskcenter.biz.loanfinotherPolicy.LoanFinOtherPolicyService; import com.yxt.anrui.riskcenter.biz.loanfinpolicy.LoanFinPolicyService; -import com.yxt.anrui.riskcenter.biz.loanrepaymenthistory.LoanRepaymentHistoryService; import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; import com.yxt.anrui.riskcenter.biz.loansolutions.LoanSolutionsService; import com.yxt.anrui.riskcenter.biz.loansolutionsotherpolicy.LoanSolutionsOtherpolicyService; import com.yxt.anrui.riskcenter.biz.loanwarrantinformation.LoanWarrantInformationService; import com.yxt.common.base.config.component.DocPdfComponent; import com.yxt.common.base.service.MybatisBaseService; -import com.yxt.common.base.utils.MsgWs; import com.yxt.common.base.utils.PagerUtil; import com.yxt.common.base.utils.StringUtils; import com.yxt.common.base.utils.WordConvertUtils; @@ -68,14 +50,10 @@ import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; import com.yxt.messagecenter.api.message.MessageFeign; -import com.yxt.messagecenter.api.message.MessagePushTransferDto; import com.yxt.messagecenter.api.message.PushMessageQuery; import com.yxt.messagecenter.api.message.PushSmsDto; -import com.yxt.messagecenter.api.messagelist.MessageListDto; -import org.apache.poi.hpsf.Decimal; import org.apache.tomcat.util.threads.ThreadPoolExecutor; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -200,6 +178,13 @@ public class LoanRepaymentScheduleService extends MybatisBaseService mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); - List otherDays = new ArrayList<>(); - String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); - String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); - String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); - String otherPeriod = ""; - String otherDate = ""; - String otherFirstPay = ""; - String otherMidPay = ""; - String otherLastPay = ""; - String deptSid = ""; - String dept = ""; - String useOrgName = ""; - String useOrgSid = ""; - String orgSidPath = ""; - String bankContractNo = ""; - String customer = ""; - String customerSid = ""; - if (scheduleDetails.getIsOtherPolicy().equals("1")) { - otherPeriod = scheduleDetails.getOtherPeriod(); - otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); - otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); - otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); - otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); - otherDays = returnRepayDate(otherDate, otherPeriod); - } - if (null != busSalesOrder) { - if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { - customer = busSalesOrder.getCustomerName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { - customerSid = busSalesOrder.getCustomerSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { - deptSid = busSalesOrder.getOrgSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { - dept = busSalesOrder.getOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { - orgSidPath = busSalesOrder.getOrgSidPath(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { - useOrgName = busSalesOrder.getUseOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { - useOrgSid = busSalesOrder.getUseOrgSid(); - } - } - BusSalesOrderLoancontractDetailsVo loancontractVo = busSalesOrderLoancontractFeign.fetchDetailsBySid(dto.getSalesOrderSid()).getData(); - if (null != loancontractVo) { - if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { - bankContractNo = loancontractVo.getBankContractNo(); - } - } - String otherBankNo = ""; - if (StringUtils.isNotBlank(scheduleDetails.getOtherBankNo())) { - otherBankNo = scheduleDetails.getOtherBankNo(); - } - List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); - if (!vehicles.isEmpty()) { - for (BusSalesOrderVehicle vehicle : vehicles) { - String linkNo = vehicle.getLinkNo(); - String vinNo = ""; - if (linkNo.length() > 8) { - vinNo = linkNo.substring(linkNo.length() - 8); - } else { - vinNo = linkNo; - } - String busVinSid = vehicle.getSid(); - String vehMark = ""; - LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); - if (null != loanWarrantInformation) { - if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { - vehMark = loanWarrantInformation.getVehicleMark(); - } - } - //主方案 - for (int i = 0; i < mainPeriod; i++) { - LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); - mainDto.setSalesOrderSid(salesOrderSid); - mainDto.setLoanContractNo(loanContractNo); - mainDto.setLoanContractSid(loanContractSid); - mainDto.setPolicyName(policyName); - mainDto.setBankContractNo(bankContractNo); - mainDto.setCreateBySid(createBySid); - mainDto.setCustomer(customer); - mainDto.setCustomerSid(customerSid); - mainDto.setBorrowerSid(borrowerSid); - mainDto.setBorrowerName(borrowerName); - mainDto.setPeriod(String.valueOf(i + 1)); - mainDto.setScheduleSid(scheduleDetails.getSid()); - mainDto.setBankName(bankName); - mainDto.setDept(dept); - mainDto.setDeptSid(deptSid); - mainDto.setUseOrgSid(useOrgSid); - mainDto.setUseOrgName(useOrgName); - mainDto.setOrgSidPath(orgSidPath); - mainDto.setBusVinSid(busVinSid); - mainDto.setVinNo(vinNo); - mainDto.setVehMark(vehMark); - mainDto.setSalesUserSid(staffSid); - mainDto.setStaffName(staffName); - mainDto.setPolicyOrOther("0"); - if (i == 0) { - mainDto.setDueMoney(mainFirstRepay); - } else if (i == mainPeriod - 1) { - mainDto.setDueMoney(mainLastRepay); + if (scheduleDetails.getIsDifferent().equals("1")) { + if (scheduleDetails.getSameBank().equals("0")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + List otherDays = new ArrayList<>(); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String singleMainFirstRepay = String.valueOf(scheduleDetails.getSingleMainFirstRepay()); + String singleMainMidRepay = String.valueOf(scheduleDetails.getSingleMainMidRepay()); + String singleMainLastRepay = String.valueOf(scheduleDetails.getSingleMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String singleOtherFirstPay = ""; + String singleOtherMidPay = ""; + String singleOtherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + singleOtherFirstPay = String.valueOf(scheduleDetails.getSingleOtherFirstRepay()); + singleOtherMidPay = String.valueOf(scheduleDetails.getSingleOtherMidRepay()); + singleOtherLastPay = String.valueOf(scheduleDetails.getSingleOtherLastRepay()); + otherDays = returnRepayDate(otherDate, otherPeriod); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + BusSalesOrderLoancontractDetailsVo loancontractVo = busSalesOrderLoancontractFeign.fetchDetailsBySid(dto.getSalesOrderSid()).getData(); + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + String otherBankNo = ""; + if (StringUtils.isNotBlank(scheduleDetails.getOtherBankNo())) { + otherBankNo = scheduleDetails.getOtherBankNo(); + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (int j = 0; j < vehicles.size(); j++) { + BusSalesOrderVehicle vehicle = vehicles.get(j); + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); } else { - mainDto.setDueMoney(mainMidRepay); - } - if (!mainDays.isEmpty()) { - mainDto.setDueDate(mainDays.get(i)); - } - loanRepaymentPlanDetailsService.savePlanDetails(mainDto); - } - //其他融 - if (scheduleDetails.getIsOtherPolicy().equals("1")) { - OtherPolicyVo otherPolicyVo = baseMapper.selOtherPolicyByOrderSid(scheduleDetails.getSalesOrderSid()); - for (int i = 0; i < Integer.parseInt(otherPeriod); i++) { - LoanRepaymentPlanDetailsDto otherDto = new LoanRepaymentPlanDetailsDto(); - otherDto.setSalesOrderSid(salesOrderSid); - otherDto.setLoanContractNo(loanContractNo); - otherDto.setLoanContractSid(loanContractSid); - if (null != otherPolicyVo) { - if (StringUtils.isNotBlank(otherPolicyVo.getOtherPolicyName())) { - otherDto.setPolicyName(otherPolicyVo.getOtherPolicyName()); + vinNo = linkNo; + } + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(scheduleDetails.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("0"); + if (i == 0) { + if (j == vehicles.size() - 1) { + mainDto.setDueMoney(singleMainFirstRepay); + } else { + mainDto.setDueMoney(mainFirstRepay); + } + } else if (i == mainPeriod - 1) { + if (j == vehicles.size() - 1) { + mainDto.setDueMoney(singleMainLastRepay); + } else { + mainDto.setDueMoney(mainLastRepay); } - if (StringUtils.isNotBlank(otherPolicyVo.getOtherBankName())) { - otherDto.setBankName(otherPolicyVo.getOtherBankName()); + } else { + if (j == vehicles.size() - 1) { + mainDto.setDueMoney(singleMainMidRepay); + } else { + mainDto.setDueMoney(mainMidRepay); } } - otherDto.setBankContractNo(otherBankNo); - otherDto.setCreateBySid(createBySid); - otherDto.setCustomer(customer); - otherDto.setCustomerSid(customerSid); - otherDto.setBorrowerSid(borrowerSid); - otherDto.setBorrowerName(borrowerName); - otherDto.setPeriod(String.valueOf(i + 1)); - otherDto.setScheduleSid(scheduleDetails.getSid()); - otherDto.setDept(dept); - otherDto.setDeptSid(deptSid); - otherDto.setUseOrgSid(useOrgSid); - otherDto.setUseOrgName(useOrgName); - otherDto.setOrgSidPath(orgSidPath); - otherDto.setBusVinSid(busVinSid); - otherDto.setVinNo(vinNo); - otherDto.setVehMark(vehMark); - otherDto.setSalesUserSid(staffSid); - otherDto.setStaffName(staffName); - otherDto.setPolicyOrOther("1"); + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); + } + //其他融 + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + OtherPolicyVo otherPolicyVo = baseMapper.selOtherPolicyByOrderSid(scheduleDetails.getSalesOrderSid()); + for (int i = 0; i < Integer.parseInt(otherPeriod); i++) { + LoanRepaymentPlanDetailsDto otherDto = new LoanRepaymentPlanDetailsDto(); + otherDto.setSalesOrderSid(salesOrderSid); + otherDto.setLoanContractNo(loanContractNo); + otherDto.setLoanContractSid(loanContractSid); + if (null != otherPolicyVo) { + if (StringUtils.isNotBlank(otherPolicyVo.getOtherPolicyName())) { + otherDto.setPolicyName(otherPolicyVo.getOtherPolicyName()); + } + if (StringUtils.isNotBlank(otherPolicyVo.getOtherBankName())) { + otherDto.setBankName(otherPolicyVo.getOtherBankName()); + } + } + otherDto.setBankContractNo(otherBankNo); + otherDto.setCreateBySid(createBySid); + otherDto.setCustomer(customer); + otherDto.setCustomerSid(customerSid); + otherDto.setBorrowerSid(borrowerSid); + otherDto.setBorrowerName(borrowerName); + otherDto.setPeriod(String.valueOf(i + 1)); + otherDto.setScheduleSid(scheduleDetails.getSid()); + otherDto.setDept(dept); + otherDto.setDeptSid(deptSid); + otherDto.setUseOrgSid(useOrgSid); + otherDto.setUseOrgName(useOrgName); + otherDto.setOrgSidPath(orgSidPath); + otherDto.setBusVinSid(busVinSid); + otherDto.setVinNo(vinNo); + otherDto.setVehMark(vehMark); + otherDto.setSalesUserSid(staffSid); + otherDto.setStaffName(staffName); + otherDto.setPolicyOrOther("1"); + if (i == 0) { + if (j == vehicles.size() - 1) { + otherDto.setDueMoney(singleOtherFirstPay); + } else { + otherDto.setDueMoney(otherFirstPay); + } + } else if (i == Integer.parseInt(otherPeriod) - 1) { + if (j == vehicles.size() - 1) { + otherDto.setDueMoney(singleOtherLastPay); + } else { + otherDto.setDueMoney(otherLastPay); + } + } else { + if (j == vehicles.size() - 1) { + otherDto.setDueMoney(singleOtherMidPay); + } else { + otherDto.setDueMoney(otherMidPay); + } + } + if (!otherDays.isEmpty()) { + otherDto.setDueDate(otherDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(otherDto); + } + } + } + } + } + if (scheduleDetails.getSameBank().equals("1")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String singleMainFirstRepay = String.valueOf(scheduleDetails.getSingleMainFirstRepay()); + String singleMainMidRepay = String.valueOf(scheduleDetails.getSingleMainMidRepay()); + String singleMainLastRepay = String.valueOf(scheduleDetails.getSingleMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String singleOtherFirstPay = ""; + String singleOtherMidPay = ""; + String singleOtherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + singleOtherFirstPay = String.valueOf(scheduleDetails.getSingleOtherFirstRepay()); + singleOtherMidPay = String.valueOf(scheduleDetails.getSingleOtherMidRepay()); + singleOtherLastPay = String.valueOf(scheduleDetails.getSingleOtherLastRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + BusSalesOrderLoancontractDetailsVo loancontractVo = busSalesOrderLoancontractFeign.fetchDetailsBySid(dto.getSalesOrderSid()).getData(); + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (int j = 0; j < vehicles.size(); j++) { + BusSalesOrderVehicle vehicle = vehicles.get(j); + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); + } else { + vinNo = linkNo; + } + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(scheduleDetails.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("1"); + BigDecimal otherRepay = new BigDecimal(0); if (i == 0) { - otherDto.setDueMoney(otherFirstPay); + if (j == vehicles.size() - 1) { + otherRepay = new BigDecimal(singleOtherFirstPay); + } else { + otherRepay = new BigDecimal(otherFirstPay); + } } else if (i == Integer.parseInt(otherPeriod) - 1) { - otherDto.setDueMoney(otherLastPay); + if (j == vehicles.size() - 1) { + otherRepay = new BigDecimal(singleOtherLastPay); + } else { + otherRepay = new BigDecimal(otherLastPay); + } + } else if (i > 0 && i < Integer.parseInt(otherPeriod) - 1) { + if (j == vehicles.size() - 1) { + otherRepay = new BigDecimal(singleOtherMidPay); + } else { + otherRepay = new BigDecimal(otherMidPay); + } + } + if (i == 0) { + if (j == vehicles.size() - 1) { + BigDecimal mainF = new BigDecimal(singleMainFirstRepay); + BigDecimal add = mainF.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainF = new BigDecimal(mainFirstRepay); + BigDecimal add = mainF.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } + } else if (i == mainPeriod - 1) { + if (j == vehicles.size() - 1) { + BigDecimal mainL = new BigDecimal(singleMainLastRepay); + BigDecimal add = mainL.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainL = new BigDecimal(mainLastRepay); + BigDecimal add = mainL.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } } else { - otherDto.setDueMoney(otherMidPay); + if (j == vehicles.size() - 1) { + BigDecimal mainM = new BigDecimal(singleMainMidRepay); + BigDecimal add = mainM.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainM = new BigDecimal(mainMidRepay); + BigDecimal add = mainM.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } } - if (!otherDays.isEmpty()) { - otherDto.setDueDate(otherDays.get(i)); + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); } - loanRepaymentPlanDetailsService.savePlanDetails(otherDto); + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); } } - } } - } - if (scheduleDetails.getSameBank().equals("1")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String createBySid = scheduleDetails.getCreateBySid(); - String staffSid = scheduleDetails.getStaffSid(); - String bankName = scheduleDetails.getBankName(); - String borrowerSid = scheduleDetails.getBorrowerSid(); - String borrowerName = scheduleDetails.getBorrowerName(); - String staffName = scheduleDetails.getStaffName(); - String salesOrderSid = scheduleDetails.getSalesOrderSid(); - String policyName = scheduleDetails.getPolicyName(); - String loanContractSid = scheduleDetails.getLoanContractSid(); - String loanContractNo = scheduleDetails.getLoanContractNo(); - int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); - String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); - List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); - String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); - String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); - String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); - String otherPeriod = ""; - String otherDate = ""; - String otherFirstPay = ""; - String otherMidPay = ""; - String otherLastPay = ""; - String deptSid = ""; - String dept = ""; - String useOrgName = ""; - String useOrgSid = ""; - String orgSidPath = ""; - String bankContractNo = ""; - String customer = ""; - String customerSid = ""; - if (scheduleDetails.getIsOtherPolicy().equals("1")) { - otherPeriod = scheduleDetails.getOtherPeriod(); - otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); - otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); - otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); - otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); - } - if (null != busSalesOrder) { - if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { - customer = busSalesOrder.getCustomerName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { - customerSid = busSalesOrder.getCustomerSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { - deptSid = busSalesOrder.getOrgSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { - dept = busSalesOrder.getOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { - orgSidPath = busSalesOrder.getOrgSidPath(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { - useOrgName = busSalesOrder.getUseOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { - useOrgSid = busSalesOrder.getUseOrgSid(); - } - } - BusSalesOrderLoancontractDetailsVo loancontractVo = busSalesOrderLoancontractFeign.fetchDetailsBySid(dto.getSalesOrderSid()).getData(); - if (null != loancontractVo) { - if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { - bankContractNo = loancontractVo.getBankContractNo(); - } - } - List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); - if (!vehicles.isEmpty()) { - for (BusSalesOrderVehicle vehicle : vehicles) { - String linkNo = vehicle.getLinkNo(); - String vinNo = ""; - if (linkNo.length() > 8) { - vinNo = linkNo.substring(linkNo.length() - 8); - } else { - vinNo = linkNo; - } - String busVinSid = vehicle.getSid(); - String vehMark = ""; - LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); - if (null != loanWarrantInformation) { - if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { - vehMark = loanWarrantInformation.getVehicleMark(); - } - } - //主方案 - for (int i = 0; i < mainPeriod; i++) { - LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); - mainDto.setSalesOrderSid(salesOrderSid); - mainDto.setLoanContractNo(loanContractNo); - mainDto.setLoanContractSid(loanContractSid); - mainDto.setPolicyName(policyName); - mainDto.setBankContractNo(bankContractNo); - mainDto.setCreateBySid(createBySid); - mainDto.setCustomer(customer); - mainDto.setCustomerSid(customerSid); - mainDto.setBorrowerSid(borrowerSid); - mainDto.setBorrowerName(borrowerName); - mainDto.setPeriod(String.valueOf(i + 1)); - mainDto.setScheduleSid(scheduleDetails.getSid()); - mainDto.setBankName(bankName); - mainDto.setDept(dept); - mainDto.setDeptSid(deptSid); - mainDto.setUseOrgSid(useOrgSid); - mainDto.setUseOrgName(useOrgName); - mainDto.setOrgSidPath(orgSidPath); - mainDto.setBusVinSid(busVinSid); - mainDto.setVinNo(vinNo); - mainDto.setVehMark(vehMark); - mainDto.setSalesUserSid(staffSid); - mainDto.setStaffName(staffName); - mainDto.setPolicyOrOther("1"); - BigDecimal otherRepay = new BigDecimal(0); - if (i == 0) { - otherRepay = new BigDecimal(otherFirstPay); - } else if (i == Integer.parseInt(otherPeriod) - 1) { - otherRepay = new BigDecimal(otherLastPay); - } else if (i < Integer.parseInt(otherPeriod) - 1) { - otherRepay = new BigDecimal(otherMidPay); + } else if (scheduleDetails.getIsDifferent().equals("0")) { + if (scheduleDetails.getSameBank().equals("0")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + List otherDays = new ArrayList<>(); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + otherDays = returnRepayDate(otherDate, otherPeriod); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + BusSalesOrderLoancontractDetailsVo loancontractVo = busSalesOrderLoancontractFeign.fetchDetailsBySid(dto.getSalesOrderSid()).getData(); + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + String otherBankNo = ""; + if (StringUtils.isNotBlank(scheduleDetails.getOtherBankNo())) { + otherBankNo = scheduleDetails.getOtherBankNo(); + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (BusSalesOrderVehicle vehicle : vehicles) { + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); + } else { + vinNo = linkNo; } - if (i == 0) { - BigDecimal mainF = new BigDecimal(mainFirstRepay); - BigDecimal add = mainF.add(otherRepay); - mainDto.setDueMoney(String.valueOf(add)); - } else if (i == mainPeriod - 1) { - BigDecimal mainL = new BigDecimal(mainLastRepay); - BigDecimal add = mainL.add(otherRepay); - mainDto.setDueMoney(String.valueOf(add)); + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(scheduleDetails.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("0"); + if (i == 0) { + mainDto.setDueMoney(mainFirstRepay); + } else if (i == mainPeriod - 1) { + mainDto.setDueMoney(mainLastRepay); + } else { + mainDto.setDueMoney(mainMidRepay); + } + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); + } + //其他融 + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + OtherPolicyVo otherPolicyVo = baseMapper.selOtherPolicyByOrderSid(scheduleDetails.getSalesOrderSid()); + for (int i = 0; i < Integer.parseInt(otherPeriod); i++) { + LoanRepaymentPlanDetailsDto otherDto = new LoanRepaymentPlanDetailsDto(); + otherDto.setSalesOrderSid(salesOrderSid); + otherDto.setLoanContractNo(loanContractNo); + otherDto.setLoanContractSid(loanContractSid); + if (null != otherPolicyVo) { + if (StringUtils.isNotBlank(otherPolicyVo.getOtherPolicyName())) { + otherDto.setPolicyName(otherPolicyVo.getOtherPolicyName()); + } + if (StringUtils.isNotBlank(otherPolicyVo.getOtherBankName())) { + otherDto.setBankName(otherPolicyVo.getOtherBankName()); + } + } + otherDto.setBankContractNo(otherBankNo); + otherDto.setCreateBySid(createBySid); + otherDto.setCustomer(customer); + otherDto.setCustomerSid(customerSid); + otherDto.setBorrowerSid(borrowerSid); + otherDto.setBorrowerName(borrowerName); + otherDto.setPeriod(String.valueOf(i + 1)); + otherDto.setScheduleSid(scheduleDetails.getSid()); + otherDto.setDept(dept); + otherDto.setDeptSid(deptSid); + otherDto.setUseOrgSid(useOrgSid); + otherDto.setUseOrgName(useOrgName); + otherDto.setOrgSidPath(orgSidPath); + otherDto.setBusVinSid(busVinSid); + otherDto.setVinNo(vinNo); + otherDto.setVehMark(vehMark); + otherDto.setSalesUserSid(staffSid); + otherDto.setStaffName(staffName); + otherDto.setPolicyOrOther("1"); + if (i == 0) { + otherDto.setDueMoney(otherFirstPay); + } else if (i == Integer.parseInt(otherPeriod) - 1) { + otherDto.setDueMoney(otherLastPay); + } else { + otherDto.setDueMoney(otherMidPay); + } + if (!otherDays.isEmpty()) { + otherDto.setDueDate(otherDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(otherDto); + } + } + + } + } + } + if (scheduleDetails.getSameBank().equals("1")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + BusSalesOrderLoancontractDetailsVo loancontractVo = busSalesOrderLoancontractFeign.fetchDetailsBySid(dto.getSalesOrderSid()).getData(); + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (BusSalesOrderVehicle vehicle : vehicles) { + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); } else { - BigDecimal mainM = new BigDecimal(mainMidRepay); - BigDecimal add = mainM.add(otherRepay); - mainDto.setDueMoney(String.valueOf(add)); + vinNo = linkNo; } - if (!mainDays.isEmpty()) { - mainDto.setDueDate(mainDays.get(i)); + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(scheduleDetails.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("1"); + BigDecimal otherRepay = new BigDecimal(0); + if (i == 0) { + otherRepay = new BigDecimal(otherFirstPay); + } else if (i == Integer.parseInt(otherPeriod) - 1) { + otherRepay = new BigDecimal(otherLastPay); + } else if (i < Integer.parseInt(otherPeriod) - 1) { + otherRepay = new BigDecimal(otherMidPay); + } + if (i == 0) { + BigDecimal mainF = new BigDecimal(mainFirstRepay); + BigDecimal add = mainF.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else if (i == mainPeriod - 1) { + BigDecimal mainL = new BigDecimal(mainLastRepay); + BigDecimal add = mainL.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainM = new BigDecimal(mainMidRepay); + BigDecimal add = mainM.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); } - loanRepaymentPlanDetailsService.savePlanDetails(mainDto); } } } @@ -794,327 +1229,729 @@ public class LoanRepaymentScheduleService extends MybatisBaseService mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); - List otherDays = new ArrayList<>(); - String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); - String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); - String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); - String otherPeriod = ""; - String otherDate = ""; - String otherFirstPay = ""; - String otherMidPay = ""; - String otherLastPay = ""; - String deptSid = ""; - String dept = ""; - String useOrgName = ""; - String useOrgSid = ""; - String orgSidPath = ""; - String bankContractNo = ""; - String customer = ""; - String customerSid = ""; - if (scheduleDetails.getIsOtherPolicy().equals("1")) { - otherPeriod = scheduleDetails.getOtherPeriod(); - otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); - otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); - otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); - otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); - otherDays = returnRepayDate(otherDate, otherPeriod); - } - if (null != busSalesOrder) { - if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { - customer = busSalesOrder.getCustomerName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { - customerSid = busSalesOrder.getCustomerSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { - deptSid = busSalesOrder.getOrgSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { - dept = busSalesOrder.getOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { - orgSidPath = busSalesOrder.getOrgSidPath(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { - useOrgName = busSalesOrder.getUseOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { - useOrgSid = busSalesOrder.getUseOrgSid(); - } - } - if (null != loancontractVo) { - if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { - bankContractNo = loancontractVo.getBankContractNo(); - } - } - String otherBankNo = ""; - if (StringUtils.isNotBlank(scheduleDetails.getOtherBankNo())) { - otherBankNo = scheduleDetails.getOtherBankNo(); - } - List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); - if (!vehicles.isEmpty()) { - for (BusSalesOrderVehicle vehicle : vehicles) { - String linkNo = vehicle.getLinkNo(); - String vinNo = ""; - if (linkNo.length() > 8) { - vinNo = linkNo.substring(linkNo.length() - 8); - } else { - vinNo = linkNo; - } - String busVinSid = vehicle.getSid(); - String vehMark = ""; - LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); - if (null != loanWarrantInformation) { - if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { - vehMark = loanWarrantInformation.getVehicleMark(); - } - } - //主方案 - for (int i = 0; i < mainPeriod; i++) { - LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); - mainDto.setSalesOrderSid(salesOrderSid); - mainDto.setLoanContractNo(loanContractNo); - mainDto.setLoanContractSid(loanContractSid); - mainDto.setPolicyName(policyName); - mainDto.setBankContractNo(bankContractNo); - mainDto.setCreateBySid(createBySid); - mainDto.setCustomer(customer); - mainDto.setCustomerSid(customerSid); - mainDto.setBorrowerSid(borrowerSid); - mainDto.setBorrowerName(borrowerName); - mainDto.setPeriod(String.valueOf(i + 1)); - mainDto.setScheduleSid(entity.getSid()); - mainDto.setBankName(bankName); - mainDto.setDept(dept); - mainDto.setDeptSid(deptSid); - mainDto.setUseOrgSid(useOrgSid); - mainDto.setUseOrgName(useOrgName); - mainDto.setOrgSidPath(orgSidPath); - mainDto.setBusVinSid(busVinSid); - mainDto.setVinNo(vinNo); - mainDto.setVehMark(vehMark); - mainDto.setSalesUserSid(staffSid); - mainDto.setStaffName(staffName); - mainDto.setPolicyOrOther("0"); - if (i == 0) { - mainDto.setDueMoney(mainFirstRepay); - } else if (i == mainPeriod - 1) { - mainDto.setDueMoney(mainLastRepay); + if (scheduleDetails.getIsDifferent().equals("1")) { + if (scheduleDetails.getSameBank().equals("0")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + List otherDays = new ArrayList<>(); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String singleMainFirstRepay = String.valueOf(scheduleDetails.getSingleMainFirstRepay()); + String singleMainMidRepay = String.valueOf(scheduleDetails.getSingleMainMidRepay()); + String singleMainLastRepay = String.valueOf(scheduleDetails.getSingleMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String singleOtherFirstPay = ""; + String singleOtherMidPay = ""; + String singleOtherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + singleOtherFirstPay = String.valueOf(scheduleDetails.getSingleOtherFirstRepay()); + singleOtherMidPay = String.valueOf(scheduleDetails.getSingleOtherMidRepay()); + singleOtherLastPay = String.valueOf(scheduleDetails.getSingleOtherLastRepay()); + otherDays = returnRepayDate(otherDate, otherPeriod); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + String otherBankNo = ""; + if (StringUtils.isNotBlank(scheduleDetails.getOtherBankNo())) { + otherBankNo = scheduleDetails.getOtherBankNo(); + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (int j = 0; j < vehicles.size(); j++) { + BusSalesOrderVehicle vehicle = vehicles.get(j); + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); + } else { + vinNo = linkNo; + } + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(entity.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("0"); + if (i == 0) { + if (j == vehicles.size() - 1) { + mainDto.setDueMoney(singleMainFirstRepay); + } else { + mainDto.setDueMoney(mainFirstRepay); + } + } else if (i == mainPeriod - 1) { + if (j == vehicles.size() - 1) { + mainDto.setDueMoney(singleMainLastRepay); + } else { + mainDto.setDueMoney(mainLastRepay); + } + } else { + if (j == vehicles.size() - 1) { + mainDto.setDueMoney(singleMainMidRepay); + } else { + mainDto.setDueMoney(mainMidRepay); + } + } + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); + } + //其他融 + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + OtherPolicyVo otherPolicyVo = baseMapper.selOtherPolicyByOrderSid(scheduleDetails.getSalesOrderSid()); + for (int i = 0; i < Integer.parseInt(otherPeriod); i++) { + LoanRepaymentPlanDetailsDto otherDto = new LoanRepaymentPlanDetailsDto(); + otherDto.setSalesOrderSid(salesOrderSid); + otherDto.setLoanContractNo(loanContractNo); + otherDto.setLoanContractSid(loanContractSid); + if (null != otherPolicyVo) { + if (StringUtils.isNotBlank(otherPolicyVo.getOtherPolicyName())) { + otherDto.setPolicyName(otherPolicyVo.getOtherPolicyName()); + } + if (StringUtils.isNotBlank(otherPolicyVo.getOtherBankName())) { + otherDto.setBankName(otherPolicyVo.getOtherBankName()); + } + } + otherDto.setBankContractNo(otherBankNo); + otherDto.setCreateBySid(createBySid); + otherDto.setCustomer(customer); + otherDto.setCustomerSid(customerSid); + otherDto.setBorrowerSid(borrowerSid); + otherDto.setBorrowerName(borrowerName); + otherDto.setPeriod(String.valueOf(i + 1)); + otherDto.setScheduleSid(entity.getSid()); + otherDto.setDept(dept); + otherDto.setDeptSid(deptSid); + otherDto.setUseOrgSid(useOrgSid); + otherDto.setUseOrgName(useOrgName); + otherDto.setOrgSidPath(orgSidPath); + otherDto.setBusVinSid(busVinSid); + otherDto.setVinNo(vinNo); + otherDto.setVehMark(vehMark); + otherDto.setSalesUserSid(staffSid); + otherDto.setStaffName(staffName); + otherDto.setPolicyOrOther("1"); + if (i == 0) { + if (j == vehicles.size() - 1) { + otherDto.setDueMoney(singleOtherFirstPay); + } else { + otherDto.setDueMoney(otherFirstPay); + } + } else if (i == Integer.parseInt(otherPeriod) - 1) { + if (j == vehicles.size() - 1) { + otherDto.setDueMoney(singleOtherLastPay); + } else { + otherDto.setDueMoney(otherLastPay); + } + } else { + if (j == vehicles.size() - 1) { + otherDto.setDueMoney(singleOtherMidPay); + } else { + otherDto.setDueMoney(otherMidPay); + } + } + if (!otherDays.isEmpty()) { + otherDto.setDueDate(otherDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(otherDto); + } + } + } + } + } + if (scheduleDetails.getSameBank().equals("1")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String singleMainFirstRepay = String.valueOf(scheduleDetails.getSingleMainFirstRepay()); + String singleMainMidRepay = String.valueOf(scheduleDetails.getSingleMainMidRepay()); + String singleMainLastRepay = String.valueOf(scheduleDetails.getSingleMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String singleOtherFirstPay = ""; + String singleOtherMidPay = ""; + String singleOtherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + singleOtherFirstPay = String.valueOf(scheduleDetails.getSingleOtherFirstRepay()); + singleOtherMidPay = String.valueOf(scheduleDetails.getSingleOtherMidRepay()); + singleOtherLastPay = String.valueOf(scheduleDetails.getSingleOtherLastRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (int j = 0; j < vehicles.size(); j++) { + BusSalesOrderVehicle vehicle = vehicles.get(j); + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); + } else { + vinNo = linkNo; + } + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(entity.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("1"); + BigDecimal otherRepay = new BigDecimal(0); + if (i == 0) { + if (j == vehicles.size() - 1) { + otherRepay = new BigDecimal(singleOtherFirstPay); + } else { + otherRepay = new BigDecimal(otherFirstPay); + } + } else if (i == Integer.parseInt(otherPeriod) - 1) { + if (j == vehicles.size() - 1) { + otherRepay = new BigDecimal(singleOtherLastPay); + } else { + otherRepay = new BigDecimal(otherLastPay); + } + } else if (i > 0 && i < Integer.parseInt(otherPeriod) - 1) { + if (j == vehicles.size() - 1) { + otherRepay = new BigDecimal(singleOtherMidPay); + } else { + otherRepay = new BigDecimal(otherMidPay); + } + } + if (i == 0) { + if (j == vehicles.size() - 1) { + BigDecimal mainF = new BigDecimal(singleMainFirstRepay); + BigDecimal add = mainF.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainF = new BigDecimal(mainFirstRepay); + BigDecimal add = mainF.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } + } else if (i == mainPeriod - 1) { + if (j == vehicles.size() - 1) { + BigDecimal mainL = new BigDecimal(singleMainLastRepay); + BigDecimal add = mainL.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainL = new BigDecimal(mainLastRepay); + BigDecimal add = mainL.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } + } else { + if (j == vehicles.size() - 1) { + BigDecimal mainM = new BigDecimal(singleMainMidRepay); + BigDecimal add = mainM.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else { + BigDecimal mainM = new BigDecimal(mainMidRepay); + BigDecimal add = mainM.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } + } + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); + } + } + } + } + } else if (scheduleDetails.getIsDifferent().equals("0")) { + if (scheduleDetails.getSameBank().equals("0")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + List otherDays = new ArrayList<>(); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + otherDays = returnRepayDate(otherDate, otherPeriod); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + String otherBankNo = ""; + if (StringUtils.isNotBlank(scheduleDetails.getOtherBankNo())) { + otherBankNo = scheduleDetails.getOtherBankNo(); + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (BusSalesOrderVehicle vehicle : vehicles) { + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); + } else { + vinNo = linkNo; + } + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); + } + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(entity.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("0"); + if (i == 0) { + mainDto.setDueMoney(mainFirstRepay); + } else if (i == mainPeriod - 1) { + mainDto.setDueMoney(mainLastRepay); + } else { + mainDto.setDueMoney(mainMidRepay); + } + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); + } + //其他融 + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + OtherPolicyVo otherPolicyVo = baseMapper.selOtherPolicyByOrderSid(scheduleDetails.getSalesOrderSid()); + for (int i = 0; i < Integer.parseInt(otherPeriod); i++) { + LoanRepaymentPlanDetailsDto otherDto = new LoanRepaymentPlanDetailsDto(); + otherDto.setSalesOrderSid(salesOrderSid); + otherDto.setLoanContractNo(loanContractNo); + otherDto.setLoanContractSid(loanContractSid); + if (null != otherPolicyVo) { + if (StringUtils.isNotBlank(otherPolicyVo.getOtherPolicyName())) { + otherDto.setPolicyName(otherPolicyVo.getOtherPolicyName()); + } + if (StringUtils.isNotBlank(otherPolicyVo.getOtherBankName())) { + otherDto.setBankName(otherPolicyVo.getOtherBankName()); + } + } + otherDto.setBankContractNo(otherBankNo); + otherDto.setCreateBySid(createBySid); + otherDto.setCustomer(customer); + otherDto.setCustomerSid(customerSid); + otherDto.setBorrowerSid(borrowerSid); + otherDto.setBorrowerName(borrowerName); + otherDto.setPeriod(String.valueOf(i + 1)); + otherDto.setScheduleSid(entity.getSid()); + otherDto.setDept(dept); + otherDto.setDeptSid(deptSid); + otherDto.setUseOrgSid(useOrgSid); + otherDto.setUseOrgName(useOrgName); + otherDto.setOrgSidPath(orgSidPath); + otherDto.setBusVinSid(busVinSid); + otherDto.setVinNo(vinNo); + otherDto.setVehMark(vehMark); + otherDto.setSalesUserSid(staffSid); + otherDto.setStaffName(staffName); + otherDto.setPolicyOrOther("1"); + if (i == 0) { + otherDto.setDueMoney(otherFirstPay); + } else if (i == Integer.parseInt(otherPeriod) - 1) { + otherDto.setDueMoney(otherLastPay); + } else { + otherDto.setDueMoney(otherMidPay); + } + if (!otherDays.isEmpty()) { + otherDto.setDueDate(otherDays.get(i)); + } + loanRepaymentPlanDetailsService.savePlanDetails(otherDto); + } + } + + } + } + } + if (scheduleDetails.getSameBank().equals("1")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String createBySid = scheduleDetails.getCreateBySid(); + String staffSid = scheduleDetails.getStaffSid(); + String bankName = scheduleDetails.getBankName(); + String borrowerSid = scheduleDetails.getBorrowerSid(); + String borrowerName = scheduleDetails.getBorrowerName(); + String staffName = scheduleDetails.getStaffName(); + String salesOrderSid = scheduleDetails.getSalesOrderSid(); + String policyName = scheduleDetails.getPolicyName(); + String loanContractSid = scheduleDetails.getLoanContractSid(); + String loanContractNo = scheduleDetails.getLoanContractNo(); + int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); + String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); + List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); + String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); + String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); + String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); + String otherPeriod = ""; + String otherDate = ""; + String otherFirstPay = ""; + String otherMidPay = ""; + String otherLastPay = ""; + String deptSid = ""; + String dept = ""; + String useOrgName = ""; + String useOrgSid = ""; + String orgSidPath = ""; + String bankContractNo = ""; + String customer = ""; + String customerSid = ""; + if (scheduleDetails.getIsOtherPolicy().equals("1")) { + otherPeriod = scheduleDetails.getOtherPeriod(); + otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); + otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); + otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); + otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); + } + if (null != busSalesOrder) { + if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { + customer = busSalesOrder.getCustomerName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { + customerSid = busSalesOrder.getCustomerSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { + deptSid = busSalesOrder.getOrgSid(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { + dept = busSalesOrder.getOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { + orgSidPath = busSalesOrder.getOrgSidPath(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { + useOrgName = busSalesOrder.getUseOrgName(); + } + if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { + useOrgSid = busSalesOrder.getUseOrgSid(); + } + } + if (null != loancontractVo) { + if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { + bankContractNo = loancontractVo.getBankContractNo(); + } + } + List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); + if (!vehicles.isEmpty()) { + for (BusSalesOrderVehicle vehicle : vehicles) { + String linkNo = vehicle.getLinkNo(); + String vinNo = ""; + if (linkNo.length() > 8) { + vinNo = linkNo.substring(linkNo.length() - 8); } else { - mainDto.setDueMoney(mainMidRepay); - } - if (!mainDays.isEmpty()) { - mainDto.setDueDate(mainDays.get(i)); - } - loanRepaymentPlanDetailsService.savePlanDetails(mainDto); - } - //其他融 - if (scheduleDetails.getIsOtherPolicy().equals("1")) { - OtherPolicyVo otherPolicyVo = baseMapper.selOtherPolicyByOrderSid(scheduleDetails.getSalesOrderSid()); - for (int i = 0; i < Integer.parseInt(otherPeriod); i++) { - LoanRepaymentPlanDetailsDto otherDto = new LoanRepaymentPlanDetailsDto(); - otherDto.setSalesOrderSid(salesOrderSid); - otherDto.setLoanContractNo(loanContractNo); - otherDto.setLoanContractSid(loanContractSid); - if (null != otherPolicyVo) { - if (StringUtils.isNotBlank(otherPolicyVo.getOtherPolicyName())) { - otherDto.setPolicyName(otherPolicyVo.getOtherPolicyName()); - } - if (StringUtils.isNotBlank(otherPolicyVo.getOtherBankName())) { - otherDto.setBankName(otherPolicyVo.getOtherBankName()); - } + vinNo = linkNo; + } + String busVinSid = vehicle.getSid(); + String vehMark = ""; + LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); + if (null != loanWarrantInformation) { + if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { + vehMark = loanWarrantInformation.getVehicleMark(); } - otherDto.setBankContractNo(otherBankNo); - otherDto.setCreateBySid(createBySid); - otherDto.setCustomer(customer); - otherDto.setCustomerSid(customerSid); - otherDto.setBorrowerSid(borrowerSid); - otherDto.setBorrowerName(borrowerName); - otherDto.setPeriod(String.valueOf(i + 1)); - otherDto.setScheduleSid(entity.getSid()); - otherDto.setDept(dept); - otherDto.setDeptSid(deptSid); - otherDto.setUseOrgSid(useOrgSid); - otherDto.setUseOrgName(useOrgName); - otherDto.setOrgSidPath(orgSidPath); - otherDto.setBusVinSid(busVinSid); - otherDto.setVinNo(vinNo); - otherDto.setVehMark(vehMark); - otherDto.setSalesUserSid(staffSid); - otherDto.setStaffName(staffName); - otherDto.setPolicyOrOther("1"); + } + //主方案 + for (int i = 0; i < mainPeriod; i++) { + LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); + mainDto.setSalesOrderSid(salesOrderSid); + mainDto.setLoanContractNo(loanContractNo); + mainDto.setLoanContractSid(loanContractSid); + mainDto.setPolicyName(policyName); + mainDto.setBankContractNo(bankContractNo); + mainDto.setCreateBySid(createBySid); + mainDto.setCustomer(customer); + mainDto.setCustomerSid(customerSid); + mainDto.setBorrowerSid(borrowerSid); + mainDto.setBorrowerName(borrowerName); + mainDto.setPeriod(String.valueOf(i + 1)); + mainDto.setScheduleSid(entity.getSid()); + mainDto.setBankName(bankName); + mainDto.setDept(dept); + mainDto.setDeptSid(deptSid); + mainDto.setUseOrgSid(useOrgSid); + mainDto.setUseOrgName(useOrgName); + mainDto.setOrgSidPath(orgSidPath); + mainDto.setBusVinSid(busVinSid); + mainDto.setVinNo(vinNo); + mainDto.setVehMark(vehMark); + mainDto.setSalesUserSid(staffSid); + mainDto.setStaffName(staffName); + mainDto.setPolicyOrOther("1"); + BigDecimal otherRepay = new BigDecimal(0); if (i == 0) { - otherDto.setDueMoney(otherFirstPay); + otherRepay = new BigDecimal(otherFirstPay); } else if (i == Integer.parseInt(otherPeriod) - 1) { - otherDto.setDueMoney(otherLastPay); + otherRepay = new BigDecimal(otherLastPay); + } else if (i > 0 && i < Integer.parseInt(otherPeriod) - 1) { + otherRepay = new BigDecimal(otherMidPay); + } + if (i == 0) { + BigDecimal mainF = new BigDecimal(mainFirstRepay); + BigDecimal add = mainF.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); + } else if (i == mainPeriod - 1) { + BigDecimal mainL = new BigDecimal(mainLastRepay); + BigDecimal add = mainL.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); } else { - otherDto.setDueMoney(otherMidPay); + BigDecimal mainM = new BigDecimal(mainMidRepay); + BigDecimal add = mainM.add(otherRepay); + mainDto.setDueMoney(String.valueOf(add)); } - if (!otherDays.isEmpty()) { - otherDto.setDueDate(otherDays.get(i)); + if (!mainDays.isEmpty()) { + mainDto.setDueDate(mainDays.get(i)); } - loanRepaymentPlanDetailsService.savePlanDetails(otherDto); - } - } - - } - } - } - if (scheduleDetails.getSameBank().equals("1")) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String createBySid = scheduleDetails.getCreateBySid(); - String staffSid = scheduleDetails.getStaffSid(); - String bankName = scheduleDetails.getBankName(); - String borrowerSid = scheduleDetails.getBorrowerSid(); - String borrowerName = scheduleDetails.getBorrowerName(); - String staffName = scheduleDetails.getStaffName(); - String salesOrderSid = scheduleDetails.getSalesOrderSid(); - String policyName = scheduleDetails.getPolicyName(); - String loanContractSid = scheduleDetails.getLoanContractSid(); - String loanContractNo = scheduleDetails.getLoanContractNo(); - int mainPeriod = Integer.parseInt(scheduleDetails.getMainPeriod()); - String mainDate = sdf.format(scheduleDetails.getMainRepayDate()); - List mainDays = returnRepayDate(mainDate, scheduleDetails.getMainPeriod()); - String mainFirstRepay = String.valueOf(scheduleDetails.getMainFirstRepay()); - String mainMidRepay = String.valueOf(scheduleDetails.getMainMidRepay()); - String mainLastRepay = String.valueOf(scheduleDetails.getMainLastRepay()); - String otherPeriod = ""; - String otherDate = ""; - String otherFirstPay = ""; - String otherMidPay = ""; - String otherLastPay = ""; - String deptSid = ""; - String dept = ""; - String useOrgName = ""; - String useOrgSid = ""; - String orgSidPath = ""; - String bankContractNo = ""; - String customer = ""; - String customerSid = ""; - if (scheduleDetails.getIsOtherPolicy().equals("1")) { - otherPeriod = scheduleDetails.getOtherPeriod(); - otherDate = sdf.format(scheduleDetails.getOtherRepayDate()); - otherFirstPay = String.valueOf(scheduleDetails.getOtherFirstRepay()); - otherMidPay = String.valueOf(scheduleDetails.getOtherMidRepay()); - otherLastPay = String.valueOf(scheduleDetails.getOtherLastRepay()); - } - if (null != busSalesOrder) { - if (StringUtils.isNotBlank(busSalesOrder.getCustomerName())) { - customer = busSalesOrder.getCustomerName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getCustomerSid())) { - customerSid = busSalesOrder.getCustomerSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSid())) { - deptSid = busSalesOrder.getOrgSid(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgName())) { - dept = busSalesOrder.getOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getOrgSidPath())) { - orgSidPath = busSalesOrder.getOrgSidPath(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgName())) { - useOrgName = busSalesOrder.getUseOrgName(); - } - if (StringUtils.isNotBlank(busSalesOrder.getUseOrgSid())) { - useOrgSid = busSalesOrder.getUseOrgSid(); - } - } - if (null != loancontractVo) { - if (StringUtils.isNotBlank(loancontractVo.getBankContractNo())) { - bankContractNo = loancontractVo.getBankContractNo(); - } - } - List vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndDkrSid(salesOrderSid, borrowerSid).getData(); - if (!vehicles.isEmpty()) { - for (BusSalesOrderVehicle vehicle : vehicles) { - String linkNo = vehicle.getLinkNo(); - String vinNo = ""; - if (linkNo.length() > 8) { - vinNo = linkNo.substring(linkNo.length() - 8); - } else { - vinNo = linkNo; - } - String busVinSid = vehicle.getSid(); - String vehMark = ""; - LoanWarrantInformation loanWarrantInformation = loanWarrantInformationService.fetchByBusVinSid(busVinSid); - if (null != loanWarrantInformation) { - if (StringUtils.isNotBlank(loanWarrantInformation.getVehicleMark())) { - vehMark = loanWarrantInformation.getVehicleMark(); - } - } - //主方案 - for (int i = 0; i < mainPeriod; i++) { - LoanRepaymentPlanDetailsDto mainDto = new LoanRepaymentPlanDetailsDto(); - mainDto.setSalesOrderSid(salesOrderSid); - mainDto.setLoanContractNo(loanContractNo); - mainDto.setLoanContractSid(loanContractSid); - mainDto.setPolicyName(policyName); - mainDto.setBankContractNo(bankContractNo); - mainDto.setCreateBySid(createBySid); - mainDto.setCustomer(customer); - mainDto.setCustomerSid(customerSid); - mainDto.setBorrowerSid(borrowerSid); - mainDto.setBorrowerName(borrowerName); - mainDto.setPeriod(String.valueOf(i + 1)); - mainDto.setScheduleSid(entity.getSid()); - mainDto.setBankName(bankName); - mainDto.setDept(dept); - mainDto.setDeptSid(deptSid); - mainDto.setUseOrgSid(useOrgSid); - mainDto.setUseOrgName(useOrgName); - mainDto.setOrgSidPath(orgSidPath); - mainDto.setBusVinSid(busVinSid); - mainDto.setVinNo(vinNo); - mainDto.setVehMark(vehMark); - mainDto.setSalesUserSid(staffSid); - mainDto.setStaffName(staffName); - mainDto.setPolicyOrOther("1"); - BigDecimal otherRepay = new BigDecimal(0); - if (i == 0) { - otherRepay = new BigDecimal(otherFirstPay); - } else if (i == Integer.parseInt(otherPeriod) - 1) { - otherRepay = new BigDecimal(otherLastPay); - } else if (i > 0 && i < Integer.parseInt(otherPeriod) - 1) { - otherRepay = new BigDecimal(otherMidPay); + loanRepaymentPlanDetailsService.savePlanDetails(mainDto); } - if (i == 0) { - BigDecimal mainF = new BigDecimal(mainFirstRepay); - BigDecimal add = mainF.add(otherRepay); - mainDto.setDueMoney(String.valueOf(add)); - } else if (i == mainPeriod - 1) { - BigDecimal mainL = new BigDecimal(mainLastRepay); - BigDecimal add = mainL.add(otherRepay); - mainDto.setDueMoney(String.valueOf(add)); - } else { - BigDecimal mainM = new BigDecimal(mainMidRepay); - BigDecimal add = mainM.add(otherRepay); - mainDto.setDueMoney(String.valueOf(add)); - } - if (!mainDays.isEmpty()) { - mainDto.setDueDate(mainDays.get(i)); - } - loanRepaymentPlanDetailsService.savePlanDetails(mainDto); } } } @@ -1234,12 +2071,12 @@ public class LoanRepaymentScheduleService extends MybatisBaseService { - pushScheduleVoucher(schedule); + pushScheduleVoucher3(schedule); }); //设置消贷合同是否生成还款计划状态 Future future3 = pool.submit(() -> { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - busSalesOrderLoancontractFeign.setRepaymentState(dto.getSalesOrderSid(),sdf.format(new Date())); + busSalesOrderLoancontractFeign.setRepaymentState(dto.getSalesOrderSid(), sdf.format(new Date())); }); } catch (Exception e) { e.printStackTrace(); @@ -1539,6 +2376,248 @@ public class LoanRepaymentScheduleService extends MybatisBaseService vehicles = busSalesOrderVehicleFeign.selectListByOrderSidAndXdConSid(salesOrderSid, loanContractSid).getData(); + String bankName = ""; + String otherBankName = ""; + String isOtherPolicy = schedule.getIsOtherPolicy(); + String sameBank = schedule.getSameBank(); + if (isOtherPolicy.equals("1")) { + if (sameBank.equals("0")) { + LoanSolutions loanSolutions = loanSolutionsService.selectBySaleOrderSid(salesOrderSid); + //查看是否有其他融 + LoanSolutionsOtherpolicy otherpolicy = loanSolutionsOtherpolicyService.selectByLoanSid(loanSolutions.getSid()); + if (null != otherpolicy) { + if (StringUtils.isNotBlank(otherpolicy.getOtherPolicyPeriod())) { + String otherPolicySid = otherpolicy.getOtherPolicySid(); + LoanFinOtherPolicy loanFinOtherPolicy = loanFinOtherPolicyService.fetchBySid(otherPolicySid); + if (loanFinOtherPolicy != null) { + if (StringUtils.isNotBlank(loanFinOtherPolicy.getBankSid())) { + String otherBankSid = loanFinOtherPolicy.getBankSid(); + LoanFinBank loanFinBank = loanFinBankService.fetchBySid(otherBankSid); + if (null != loanFinBank) { + otherBankName = loanFinBank.getBankShortName(); + } + } + } + } + } + } + } + LoanFinBank loanFinBank = loanFinBankService.selBankByOrderSid(salesOrderSid); + if (null != loanFinBank) { + bankName = loanFinBank.getBankShortName(); + } + if (null != salesOrder) { + if (!vehicles.isEmpty()) { + for (BusSalesOrderVehicle busSalesOrderVehicle : vehicles) { + if (isOtherPolicy.equals("0")) { + GeneralVoucher generalVoucher = new GeneralVoucher(); + List voucherDetails = new ArrayList<>(); + String useOrgSid = salesOrder.getUseOrgSid(); + SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); + if (null != organizationVo) { + generalVoucher.setUseOrgCode(organizationVo.getOrgCode()); + } + GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); + if (StringUtils.isNotBlank(bankName)) { + voucherDetail.setBankName(bankName); + } + if (StringUtils.isNotBlank(schedule.getCwDeptNo())) { + voucherDetail.setDeptCode(schedule.getCwDeptNo()); + } + // String busVinSid = vehicle.getSid(); + // BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.details(busVinSid).getData(); + if (null != busSalesOrderVehicle) { + String customerNumber = ""; + //判断财务系统是否有客户 + Boolean aBoolean = finKingDeeFeign.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData(); + String linkNo = ""; + BusSalesOrderBorrowerDetailsVo borrowerDetailsVo = busSalesOrderBorrowerFeign.fetchDetailsBySid(busSalesOrderVehicle.getBorrowerSid()).getData(); + if (!aBoolean) { + // List bdCustomers = new ArrayList<>(); + BdCustomer bdCustomer = new BdCustomer(); + bdCustomer.setFNumber(busSalesOrderVehicle.getTemporaryNo()); + bdCustomer.setFShortName(salesOrder.getContractNo()); + BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(salesOrder.getPurchaseSystemSid()).getData(); + bdCustomer.setTOrgIds(data.getOrgCode()); + if (org.apache.commons.lang3.StringUtils.isNotBlank(busSalesOrderVehicle.getLinkNo())) { + String vinNo = busSalesOrderVehicle.getLinkNo(); + if (vinNo.length() > 8) { + linkNo = vinNo.substring(vinNo.length() - 8); + } else { + linkNo = busSalesOrderVehicle.getLinkNo(); + } + if (null != borrowerDetailsVo) { + bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + linkNo); + } + } else { + if (null != borrowerDetailsVo) { + bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo()); + } + } + // bdCustomers.add(bdCustomer); + ResultBean resultBean = finKingDeeFeign.draftBdCustomer(bdCustomer); + if (resultBean.getSuccess()) { + customerNumber = bdCustomer.getFNumber(); + } + } else { + customerNumber = busSalesOrderVehicle.getTemporaryNo(); + } + voucherDetail.setCustomerCode(customerNumber); + } + String amount = baseMapper.selSumAmountDueMoneyByBusVinSid(schedule.getSid(), busSalesOrderVehicle.getSid(), "0"); + voucherDetail.setAmount(new BigDecimal(amount)); + voucherDetails.add(voucherDetail); + generalVoucher.setVoucherDetails(voucherDetails); + finKingDeeFeign.saveScheduleVoucher(generalVoucher); + } + if (isOtherPolicy.equals("1")) { + if (sameBank.equals("0")) { + for (int i = 0; i <= 1; i++) { + GeneralVoucher generalVoucher = new GeneralVoucher(); + List voucherDetails = new ArrayList<>(); + String useOrgSid = salesOrder.getUseOrgSid(); + SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); + if (null != organizationVo) { + generalVoucher.setUseOrgCode(organizationVo.getOrgCode()); + } + GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); + if (i == 0) { + if (StringUtils.isNotBlank(bankName)) { + voucherDetail.setBankName(bankName); + } + } else if (i == 1) { + if (StringUtils.isNotBlank(otherBankName)) { + voucherDetail.setBankName(otherBankName); + } + } + if (StringUtils.isNotBlank(schedule.getCwDeptNo())) { + voucherDetail.setDeptCode(schedule.getCwDeptNo()); + } + // String busVinSid = vehicle.getSid(); + // BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.details(busVinSid).getData(); + if (null != busSalesOrderVehicle) { + String customerNumber = ""; + //判断财务系统是否有客户 + Boolean aBoolean = finKingDeeFeign.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData(); + String linkNo = ""; + BusSalesOrderBorrowerDetailsVo borrowerDetailsVo = busSalesOrderBorrowerFeign.fetchDetailsBySid(busSalesOrderVehicle.getBorrowerSid()).getData(); + if (!aBoolean) { + // List bdCustomers = new ArrayList<>(); + BdCustomer bdCustomer = new BdCustomer(); + bdCustomer.setFNumber(busSalesOrderVehicle.getTemporaryNo()); + bdCustomer.setFShortName(salesOrder.getContractNo()); + BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(salesOrder.getPurchaseSystemSid()).getData(); + bdCustomer.setTOrgIds(data.getOrgCode()); + if (org.apache.commons.lang3.StringUtils.isNotBlank(busSalesOrderVehicle.getLinkNo())) { + String vinNo = busSalesOrderVehicle.getLinkNo(); + if (vinNo.length() > 8) { + linkNo = vinNo.substring(vinNo.length() - 8); + } else { + linkNo = busSalesOrderVehicle.getLinkNo(); + } + if (null != borrowerDetailsVo) { + bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + linkNo); + } + } else { + if (null != borrowerDetailsVo) { + bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo()); + } + } + // bdCustomers.add(bdCustomer); + ResultBean resultBean = finKingDeeFeign.draftBdCustomer(bdCustomer); + if (resultBean.getSuccess()) { + customerNumber = bdCustomer.getFNumber(); + } + } else { + customerNumber = busSalesOrderVehicle.getTemporaryNo(); + } + voucherDetail.setCustomerCode(customerNumber); + } + if (i == 0) { + String amount = baseMapper.selSumAmountDueMoneyByBusVinSid(schedule.getSid(), busSalesOrderVehicle.getSid(), "0"); + voucherDetail.setAmount(new BigDecimal(amount)); + } else if (i == 1) { + String amount = baseMapper.selSumAmountDueMoneyByBusVinSid(schedule.getSid(), busSalesOrderVehicle.getSid(), "1"); + voucherDetail.setAmount(new BigDecimal(amount)); + } + voucherDetails.add(voucherDetail); + generalVoucher.setVoucherDetails(voucherDetails); + finKingDeeFeign.saveScheduleVoucher(generalVoucher); + } + } + if (sameBank.equals("1")) { + GeneralVoucher generalVoucher = new GeneralVoucher(); + List voucherDetails = new ArrayList<>(); + String useOrgSid = salesOrder.getUseOrgSid(); + SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); + if (null != organizationVo) { + generalVoucher.setUseOrgCode(organizationVo.getOrgCode()); + } + GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); + if (StringUtils.isNotBlank(bankName)) { + voucherDetail.setBankName(bankName); + } + if (StringUtils.isNotBlank(schedule.getCwDeptNo())) { + voucherDetail.setDeptCode(schedule.getCwDeptNo()); + } + // String busVinSid = vehicle.getSid(); + // BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.details(busVinSid).getData(); + if (null != busSalesOrderVehicle) { + String customerNumber = ""; + //判断财务系统是否有客户 + Boolean aBoolean = finKingDeeFeign.customerExistState(busSalesOrderVehicle.getTemporaryNo()).getData(); + String linkNo = ""; + BusSalesOrderBorrowerDetailsVo borrowerDetailsVo = busSalesOrderBorrowerFeign.fetchDetailsBySid(busSalesOrderVehicle.getBorrowerSid()).getData(); + if (!aBoolean) { + // List bdCustomers = new ArrayList<>(); + BdCustomer bdCustomer = new BdCustomer(); + bdCustomer.setFNumber(busSalesOrderVehicle.getTemporaryNo()); + bdCustomer.setFShortName(salesOrder.getContractNo()); + BasePurchaseSystemDetailsVo data = basePurchaseSystemFeign.fetchDetailsByDeptSid(salesOrder.getPurchaseSystemSid()).getData(); + bdCustomer.setTOrgIds(data.getOrgCode()); + if (org.apache.commons.lang3.StringUtils.isNotBlank(busSalesOrderVehicle.getLinkNo())) { + String vinNo = busSalesOrderVehicle.getLinkNo(); + if (vinNo.length() > 8) { + linkNo = vinNo.substring(vinNo.length() - 8); + } else { + linkNo = busSalesOrderVehicle.getLinkNo(); + } + if (null != borrowerDetailsVo) { + bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + linkNo); + } + } else { + if (null != borrowerDetailsVo) { + bdCustomer.setFName(borrowerDetailsVo.getBorrowerName() + busSalesOrderVehicle.getTemporaryNo()); + } + } + // bdCustomers.add(bdCustomer); + ResultBean resultBean = finKingDeeFeign.draftBdCustomer(bdCustomer); + if (resultBean.getSuccess()) { + customerNumber = bdCustomer.getFNumber(); + } + } else { + customerNumber = busSalesOrderVehicle.getTemporaryNo(); + } + voucherDetail.setCustomerCode(customerNumber); + } + String amount = baseMapper.selSumAmountDueMoneyByBusVinSid(schedule.getSid(), busSalesOrderVehicle.getSid(), "1"); + voucherDetail.setAmount(new BigDecimal(amount)); + voucherDetails.add(voucherDetail); + generalVoucher.setVoucherDetails(voucherDetails); + finKingDeeFeign.saveScheduleVoucher(generalVoucher); + } + } + } + } + + } + } + public List returnVoucherPdf2(LoanRepaymentSchedule schedule) { List pdfs = new ArrayList<>(); String salesOrderSid = schedule.getSalesOrderSid(); @@ -1560,7 +2639,7 @@ public class LoanRepaymentScheduleService extends MybatisBaseService moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(),vinNo,mainOrOther); + List moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(), vinNo, mainOrOther); if (!moneyAndPeriodVos.isEmpty()) { MoneyAndPeriodVo f = moneyAndPeriodVos.get(0); MoneyAndPeriodVo m = moneyAndPeriodVos.get(1); @@ -1602,7 +2681,7 @@ public class LoanRepaymentScheduleService extends MybatisBaseService moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(),vinNo,mainOrOther); + List moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(), vinNo, mainOrOther); if (!moneyAndPeriodVos.isEmpty()) { MoneyAndPeriodVo f = moneyAndPeriodVos.get(0); MoneyAndPeriodVo m = moneyAndPeriodVos.get(1); @@ -1656,14 +2735,14 @@ public class LoanRepaymentScheduleService extends MybatisBaseService moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(),vinNo,mainOrOther); + List moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(), vinNo, mainOrOther); if (!moneyAndPeriodVos.isEmpty()) { MoneyAndPeriodVo f = moneyAndPeriodVos.get(0); MoneyAndPeriodVo m = moneyAndPeriodVos.get(1); @@ -1686,7 +2765,7 @@ public class LoanRepaymentScheduleService extends MybatisBaseService moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(),vinNo,mainOrOther); + List moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(), vinNo, mainOrOther); if (!moneyAndPeriodVos.isEmpty()) { MoneyAndPeriodVo f = moneyAndPeriodVos.get(0); if (StringUtils.isNotBlank(f.getBankName())) { @@ -1739,7 +2818,7 @@ public class LoanRepaymentScheduleService extends MybatisBaseService moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(),vinNo,mainOrOther); + List moneyAndPeriodVos = baseMapper.selPlansInfoByMainSidAndVinNo(schedule.getSid(), vinNo, mainOrOther); if (!moneyAndPeriodVos.isEmpty()) { MoneyAndPeriodVo f = moneyAndPeriodVos.get(0); MoneyAndPeriodVo m = moneyAndPeriodVos.get(1); @@ -1789,7 +2868,7 @@ public class LoanRepaymentScheduleService extends MybatisBaseService> exportExcel(List sids) { + ResultBean rb = ResultBean.fireFail(); + List vos = baseMapper.selPlansExcel(sids); + return rb.success().setData(vos); + } }