Commit b81fe475 by kangxiaoshan

加 收款金额 开票金额

parent af0d3bd1
......@@ -112,6 +112,8 @@ public class Contract {
private String productType; //产品类型
private String acceptanceAmount;//验收金额
private String amountCollected;//收款金额
private String invoiceAmount;//开票金额
@Id
......@@ -832,4 +834,22 @@ public class Contract {
public void setAcceptanceAmount(String acceptanceAmount) {
this.acceptanceAmount = acceptanceAmount;
}
@Transient
public String getAmountCollected() {
return amountCollected;
}
public void setAmountCollected(String amountCollected) {
this.amountCollected = amountCollected;
}
@Transient
public String getInvoiceAmount() {
return invoiceAmount;
}
public void setInvoiceAmount(String invoiceAmount) {
this.invoiceAmount = invoiceAmount;
}
}
......@@ -12,17 +12,17 @@ import java.util.List;
@Transactional
public interface ContractMoneyRepository extends JpaRepository<ContractMoney, Long> {
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and contract_code = ?3 and del_flag is not true order by ds desc",nativeQuery=true)
List<ContractMoney> findByDs(String startDate, String endDate, String code);
@Query(value = "select * from contract_money where ds >= ?1 and ds <= ?2 and contract_code = ?3 and del_flag is not true order by ds desc", nativeQuery = true)
List<ContractMoney> findByDs(String startDate, String endDate, String code);
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and platform = ?3 order by ds desc",nativeQuery=true)
List<ContractMoney> findByDsAll(String startDate, String endDate, String platform);
@Query(value = "select * from contract_money where ds >= ?1 and ds <= ?2 and platform = ?3 order by ds desc", nativeQuery = true)
List<ContractMoney> findByDsAll(String startDate, String endDate, String platform);
@Query(value="select * from contract_money where ds >= ?1 and ds <= ?2 and email = ?3 and platform = ?4 order by ds desc",nativeQuery=true)
List<ContractMoney> findByDs(String startDate, String endDate, String email, String platform);
@Query(value = "select * from contract_money where ds >= ?1 and ds <= ?2 and email = ?3 and platform = ?4 order by ds desc", nativeQuery = true)
List<ContractMoney> findByDs(String startDate, String endDate, String email, String platform);
@Query(value="select * from contract_money where email = ?1 and platform = ?2 and type = 'pay' order by ds desc",nativeQuery=true)
List<ContractMoney> findByEmail(String email, String platform);
@Query(value = "select * from contract_money where email = ?1 and platform = ?2 and type = 'pay' order by ds desc", nativeQuery = true)
List<ContractMoney> findByEmail(String email, String platform);
// @Query(value = "select a.id,b.customer_body company,a.contract_code,u.name create_name,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,b.sale salse,b.price_level from contract_money a left join contract b on a.contract_code = b.contract_code left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 order by a.ds desc",nativeQuery = true)
// List<ContractMoney> findByDsAllContract(String startDate, String endDate, String platfrom);
......@@ -36,18 +36,21 @@ public interface ContractMoneyRepository extends JpaRepository<ContractMoney, Lo
// @Query(value = "select a.id,b.customer_body company,a.contract_code,u.name create_name,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,b.sale salse,b.price_level from contract_money a left join contract b on a.contract_code = b.contract_code left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and b.price_level = ?4 order by a.ds desc",nativeQuery = true)
// List<ContractMoney> findByDsAllContractPkSearch(String startDate, String endDate, String platfrom, String pkType);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.del_flag is false order by a.ds desc",nativeQuery = true)
List<ContractMoney> findByDsAllContract(String startDate, String endDate, String platfrom);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.del_flag is false order by a.ds desc", nativeQuery = true)
List<ContractMoney> findByDsAllContract(String startDate, String endDate, String platfrom);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.type = ?4 and a.price_level = ?5 and a.del_flag is false order by a.ds desc",nativeQuery = true)
List<ContractMoney> findByDsAllContractAll(String startDate, String endDate, String platfrom, String moneyType, String packageTypeSearch);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.type = ?4 and a.price_level = ?5 and a.del_flag is false order by a.ds desc", nativeQuery = true)
List<ContractMoney> findByDsAllContractAll(String startDate, String endDate, String platfrom, String moneyType, String packageTypeSearch);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.type = ?4 and a.del_flag is false order by a.ds desc",nativeQuery = true)
List<ContractMoney> findByDsAllContractMoneyType(String startDate, String endDate, String platfrom, String moneyType);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.type = ?4 and a.del_flag is false order by a.ds desc", nativeQuery = true)
List<ContractMoney> findByDsAllContractMoneyType(String startDate, String endDate, String platfrom, String moneyType);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.price_level = ?4 and a.del_flag is false order by a.ds desc",nativeQuery = true)
List<ContractMoney> findByDsAllContractPkSearch(String startDate, String endDate, String platfrom, String pkType);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.price_level = ?4 and a.del_flag is false order by a.ds desc", nativeQuery = true)
List<ContractMoney> findByDsAllContractPkSearch(String startDate, String endDate, String platfrom, String pkType);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.id in ?4 and a.del_flag is false order by a.ds desc",nativeQuery = true)
List<ContractMoney> findByDsAllContractMoneyIds(String startDate, String endDate, String platfrom,List moneyIds);
@Query(value = "select a.id,a.company,a.contract_code,a.create_account,a.create_time,a.ds,a.email,a.modify_account,a.modify_time,a.money,a.platform,a.type,a.user,a.del_flag,a.salse,a.price_level,u.name create_name from contract_money a left join user u on a.create_account = u.id where a.ds >= ?1 and a.ds <= ?2 and a.platform = ?3 and a.id in ?4 and a.del_flag is false order by a.ds desc", nativeQuery = true)
List<ContractMoney> findByDsAllContractMoneyIds(String startDate, String endDate, String platfrom, List moneyIds);
@Query(value = "select contract_code, sum(case when type = 'pay' then money else 0 end) as pay_money,sum(case when type = 'invoice' then money else 0 end) as invoice_money from contract_money where contract_code in ?2 and platform = ?1 and del_flag is false group by contract_code", nativeQuery = true)
List<Object[]> findGroupCode(String platform, List<String> coedIds);
}
......@@ -1591,15 +1591,24 @@ public class ContractServiceImpl implements ContractService {
if (ValidateUtil.isValid(contractList)) {
List<String> coedIds = contractList.stream().map(v -> v.getContractCode()).collect(Collectors.toList());
Map<String, String> acceptanceAmountMap = new HashMap<>();
if ("pd".equals(platform)) {
//私有化合同关联 验收收入
List<Object[]> objects = pdIncomeRepository.findGroupWithCode(contractList.stream().map(v -> v.getContractCode()).collect(Collectors.toList()));
List<Object[]> objects = pdIncomeRepository.findGroupWithCode(coedIds);
acceptanceAmountMap = objects.stream().collect(Collectors.toMap(v -> v[0] + "", v -> v[1] + "", (v1, v2) -> v1));
}
//处理收款开票金额
List<Object[]> codeMoneyList = contractMoneyRepository.findGroupCode(platform, coedIds);
Map<String, Object[]> codeMoneyMap = codeMoneyList.stream().collect(Collectors.toMap(v -> v[0] + "", v -> v, (v1, v2) -> v1));
List<BarrioCity> barrioCities = barrioCityRepository.findAll();
Map<Long, BarrioCity> barrioCitiesNameMap = barrioCities.stream().collect(Collectors.toMap(BarrioCity::getId, Function.identity(), (v1, v2) -> v1));
for (Contract c : contractList) {
c.setMyBodyName(bodyMap.get(c.getMyBodyCode()));
c.setTradeName(tradeTypeMap.get(c.getTradeType() + ""));
......@@ -1619,9 +1628,21 @@ public class ContractServiceImpl implements ContractService {
c.setRelationContract(-1L);
}
//验收金额
c.setAcceptanceAmount(acceptanceAmountMap.containsKey(c.getContractCode())
? acceptanceAmountMap.get(c.getContractCode()) : "0");
//收款开票金额
if (codeMoneyMap.containsKey(c.getContractCode())) {
c.setAmountCollected("0");
c.setInvoiceAmount("0");
} else {
Object[] value = codeMoneyMap.get(c.getContractCode());
c.setAmountCollected(value[1] + "");
c.setInvoiceAmount(value[2] + "");
}
/* if (ContractStatusEnum.MONEY_BACK_FIRST.getKey().equals(c.getStatus())) {
c.setStartDate(null);
}*/
......
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