|
|
@@ -1,11 +1,15 @@
|
|
|
package com.wx.blink.backend.manager;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.cloud.sa.flow.commom.domain.virentity.StInstanceEvent;
|
|
|
+import com.wx.blink.backend.domain.process.LoanApplyExpenseStatementVO;
|
|
|
+import com.wx.blink.backend.domain.process.LoanApplyVO;
|
|
|
import com.wx.blink.backend.factory.CustomizeProcessFactory;
|
|
|
import com.wx.blink.backend.handler.CustomizeProcessEventHandler;
|
|
|
import com.wx.blink.backend.repository.BlinkCustomerRepository;
|
|
|
+import com.wx.blink.backend.repository.BlinkCustomizeProcessRepository;
|
|
|
import com.wx.blink.backend.service.IBlinkCustomizeProcessService;
|
|
|
import com.wx.blink.base.common.code.SystemErrorCode;
|
|
|
import com.wx.blink.base.common.domain.ResponseDTO;
|
|
|
@@ -14,7 +18,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import static com.google.common.io.ByteStreams.toByteArray;
|
|
|
|
|
|
@@ -23,6 +30,8 @@ public class BlinkCustomizeProcessServiceImpl implements IBlinkCustomizeProcessS
|
|
|
|
|
|
@Resource
|
|
|
private BlinkCustomerRepository customerRepository;
|
|
|
+ @Resource
|
|
|
+ private BlinkCustomizeProcessRepository processRepository;
|
|
|
|
|
|
@Override
|
|
|
public ResponseDTO<String> supportCommonProcessHandle(StInstanceEvent event) {
|
|
|
@@ -41,10 +50,45 @@ public class BlinkCustomizeProcessServiceImpl implements IBlinkCustomizeProcessS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseDTO<String> supportProcessLoanApplyHandle(String loginName) {
|
|
|
+ public ResponseDTO<String> supportProcessLoanApplyHandle(String applicant) {
|
|
|
JSONObject obj = new JSONObject();
|
|
|
- obj.put("lj", "123");
|
|
|
- obj.put("zs", "231");
|
|
|
+ //获取该申请人已办结流程借款金额明细
|
|
|
+ List<LoanApplyVO> completeLoanApplyList = processRepository.queryCompleteLoanApplyList(applicant);
|
|
|
+ if (CollectionUtil.isEmpty(completeLoanApplyList)) {
|
|
|
+ BigDecimal loanAmount = completeLoanApplyList.stream()
|
|
|
+ .map(LoanApplyVO::getLoanAmount)
|
|
|
+ .filter(amount -> amount != null)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ obj.put("accumulateLoanAmount", loanAmount);
|
|
|
+
|
|
|
+ for (int i = 0; i < completeLoanApplyList.size(); i++) {
|
|
|
+ LoanApplyVO loanApply = completeLoanApplyList.get(i);
|
|
|
+ //在手借款金额 = 借款金额 - 报销流程进行中和办结的冲抵的借款金额和
|
|
|
+ List<LoanApplyExpenseStatementVO> offsetLoanAmountList = processRepository.queryTotalOffsetLoanAmountByExpenseStatement(loanApply.getBizObjectId());
|
|
|
+ if (CollectionUtil.isNotEmpty(offsetLoanAmountList)) {
|
|
|
+ BigDecimal offsetLoanAmount = offsetLoanAmountList.stream()
|
|
|
+ .map(LoanApplyExpenseStatementVO::getOffsetLoanAmount)
|
|
|
+ .filter(amount -> amount != null)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ loanApply.setSurplusLoanAmount(loanApply.getLoanAmount().subtract(offsetLoanAmount));
|
|
|
+ } else {
|
|
|
+ loanApply.setSurplusLoanAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal surplusLoanAmount = completeLoanApplyList.stream()
|
|
|
+ .map(LoanApplyVO::getSurplusLoanAmount)
|
|
|
+ .filter(amount -> amount != null)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ obj.put("surplusLoanAmount", surplusLoanAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ obj.put("accumulateLoanAmount", BigDecimal.ZERO);
|
|
|
+ obj.put("surplusLoanAmount", BigDecimal.ZERO);
|
|
|
+ }
|
|
|
return ResponseDTO.ok(obj.toJSONString());
|
|
|
}
|
|
|
|
|
|
@@ -76,8 +120,32 @@ public class BlinkCustomizeProcessServiceImpl implements IBlinkCustomizeProcessS
|
|
|
String createdBy = obj.getJSONObject("createdBy").getString("nickname");
|
|
|
|
|
|
System.out.println(number + "------" + name + "------" + type + "------" + dev_status + "------" + projectName + "------" + createdBy);
|
|
|
- customerRepository.createProjectBug(number,name,type,dev_status,projectName,createdBy);
|
|
|
+ customerRepository.createProjectBug(number, name, type, dev_status, projectName, createdBy);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseDTO<List<LoanApplyVO>> supportProcessQueryLoanApplyList(String applicant) {
|
|
|
+ List<LoanApplyVO> completeLoanApplyList = processRepository.queryCompleteLoanApplyList(applicant);
|
|
|
+ if (CollectionUtil.isNotEmpty(completeLoanApplyList)) {
|
|
|
+ //计算每个借款申请流程的剩余借款金额
|
|
|
+ for (int i = 0; i < completeLoanApplyList.size(); i++) {
|
|
|
+ LoanApplyVO loanApply = completeLoanApplyList.get(i);
|
|
|
+ //剩余借款金额 = 借款金额 - 报销流程进行中和办结的冲抵的借款金额和
|
|
|
+ List<LoanApplyExpenseStatementVO> offsetLoanAmountList = processRepository.queryTotalOffsetLoanAmountByExpenseStatement(loanApply.getBizObjectId());
|
|
|
+ if (CollectionUtil.isNotEmpty(offsetLoanAmountList)) {
|
|
|
+ BigDecimal offsetLoanAmount = offsetLoanAmountList.stream()
|
|
|
+ .map(LoanApplyExpenseStatementVO::getOffsetLoanAmount)
|
|
|
+ .filter(amount -> amount != null)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
+ loanApply.setSurplusLoanAmount(loanApply.getLoanAmount().subtract(offsetLoanAmount));
|
|
|
+ } else {
|
|
|
+ loanApply.setSurplusLoanAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseDTO.ok(completeLoanApplyList);
|
|
|
+ }
|
|
|
}
|