Commit 9734460d by kangxiaoshan

计算确认收入

parent 2cdd47e9
......@@ -104,6 +104,9 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select contract_code,my_body_code, my_body_name, customer_body, customer_short, business_type, agreement_type,product_type from contract where platform = 'dmp' and contract_code in ?1", nativeQuery = true)
List<Object[]> findByDmpContractCode(List<String> codesList);
@Query(value = "select contract_code,my_body_code, my_body_name, customer_body, customer_short, business_type, agreement_type,product_type from contract where platform = ?2 and contract_code in ?1", nativeQuery = true)
List<Object[]> findShortByContractCode(List<String> codesList,String platform);
@Query(value = "select * from contract where ((start_date <= ?1 and end_date >= ?1) or (start_date <= ?2 and end_date >= ?2) or (start_date >= ?1 and end_date <= ?2) or (start_date <= ?1 and end_date >= ?2)) and platform=?3 and status!='del' and (share_sign = 1 or share_sign is null) ", nativeQuery = true)
List<Contract> findShareContranctByDate3(String startDate, String endDate, String platform);
......
......@@ -12,7 +12,7 @@ public interface PdIncomeRepository extends JpaRepository<PdIncome, Long> {
List<PdIncome> findByContractCode(String code);
@Query(value = "select * from pd_income where settlement_date > ?1 and settlement_date < ?2", nativeQuery = true)
@Query(value = "select * from pd_income where settlement_date >= ?1 and settlement_date <= ?2", nativeQuery = true)
List<PdIncome> findByDs(String startDate, String endDate);
@Query(value = "select contract_code, sum(acceptance_amount) from pd_income where contract_code in ?1 group by contract_code", nativeQuery = true)
......
......@@ -26,6 +26,7 @@ import util.ResultModel;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.MathContext;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
......@@ -133,8 +134,8 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if (pdIncomes.isEmpty()) {
return pdIncomes;
}
List<String> codes = pdIncomes.stream().map(v -> v.getContractCode()).collect(Collectors.toList());
List<Object[]> contracts = contractRepository.findByDmpContractCode(codes);
List<String> codes = pdIncomes.stream().map(v -> v.getContractCode()).distinct().collect(Collectors.toList());
List<Object[]> contracts = contractRepository.findShortByContractCode(codes, "pd");
Map<String, Object[]> names = contracts.stream().collect(Collectors.toMap(v -> v[0] + "", v -> v, (v1, v2) -> v1));
Map<String, String> cBodyMap = contractBodyRepository.findAllDis()
.stream().collect(Collectors.toMap(ContractBody::getCode, ContractBody::getName, (v1, v2) -> v1));
......@@ -628,10 +629,10 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
}
private PdIncome cacluConfirmIncome(PdIncome income) {
if (StringUtils.isEmpty(income.getAcceptanceAmount())) {
Long rax = Long.parseLong(income.getTaxRate().replace("%", "")) / 100 + 1;
Long confirmIncome = rax * Long.parseLong(income.getAcceptanceAmount());
income.setConfirmIncome(confirmIncome + "");
if (!StringUtils.isEmpty(income.getAcceptanceAmount())) {
Double rax = Double.parseDouble(income.getTaxRate().replace("%", "")) / 100 + 1;
Double confirmIncome = Double.parseDouble(income.getAcceptanceAmount()) / rax;
income.setConfirmIncome(new BigDecimal(confirmIncome).setScale(2, BigDecimal.ROUND_UP).toString());
} else {
income.setConfirmIncome("0");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment