Commit 0201c49f by kangxiaoshan

pd分摊收入

parent 4655491f
......@@ -514,6 +514,8 @@ public class ContractController {
if (platform.equals("dmp")) {
//展示dmp上传的收入相关数据
return ResultModel.OK(dmpIncomeService.listByDs(startDate, endDate));
}else if(platform.equals("pd")){
return ResultModel.OK(dmpIncomeService.pdListByDs(startDate, endDate));
}
return ResultModel.OK(shareIncomeService.shareIncomeList(loginAccount, startDate, endDate, platform, bodyCode, serchName));
......@@ -534,6 +536,9 @@ public class ContractController {
//dmp 分摊报表导出
HSSFWorkbook workbook = dmpIncomeService.exportIncomeList(startDate,endDate,bodyCode,serchName);
this.exportWrite(fileName, workbook, "分摊收入报表", response);
}else if("pd".equals(platform)){
HSSFWorkbook workbook = dmpIncomeService.exportPdIncomeList(startDate,endDate,bodyCode,serchName);
this.exportWrite(fileName, workbook, "分摊收入报表", response);
}
List<Contract> contracts = shareIncomeService.shareIncomeList(loginAccount, startDate, endDate, platform, bodyCode, serchName);
......
......@@ -29,7 +29,8 @@ public class PdIncome {
customerBody,
customerShort,
businessType,
agreementType;
agreementType,
productType; //产品类型
@Id
......@@ -166,4 +167,13 @@ public class PdIncome {
public void setAgreementType(String agreementType) {
this.agreementType = agreementType;
}
@Transient
public String getProductType() {
return productType;
}
public void setProductType(String productType) {
this.productType = productType;
}
}
......@@ -101,7 +101,7 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value = "select contract_code,my_body_code,sale,platform from contract where contract_code in ?1", nativeQuery = true)
List<Object[]> findByContractCode(List<String> codesList);
@Query(value = "select contract_code,my_body_code, my_body_name, customer_body, customer_short, business_type, agreement_type from contract where platform = 'dmp' and contract_code in ?1", nativeQuery = true)
@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 * 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)
......
......@@ -8,9 +8,10 @@ import java.util.List;
public interface PdIncomeRepository extends JpaRepository<PdIncome, Long> {
@Query(value = "select * from pd_income where contract_code = ? order by input_date desc ",nativeQuery = true)
@Query(value = "select * from pd_income where contract_code = ? order by input_date desc ", nativeQuery = true)
List<PdIncome> findByContractCode(String code);
@Query(value = "select * from pd_income where settlement_date > ?1 and settlement_date < ?2", nativeQuery = true)
List<PdIncome> findByDs(String startDate, String endDate);
}
......@@ -41,4 +41,8 @@ public interface DmpIncomeService {
ResponseEntity<byte[]> downloadAttach(Long id);
PdAttachment deleteAttach(Long id);
List pdListByDs(String startDate, String endDate);
HSSFWorkbook exportPdIncomeList(String startDate, String endDate, String bodyCode, String serchName);
}
......@@ -128,6 +128,75 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
}
@Override
public List<PdIncome> pdListByDs(String startDate, String endDate) {
List<PdIncome> pdIncomes = pdIncomeRepository.findByDs(startDate, endDate);
if (pdIncomes.isEmpty()) {
return pdIncomes;
}
List<String> codes = pdIncomes.stream().map(v -> v.getContractCode()).collect(Collectors.toList());
List<Object[]> contracts = contractRepository.findByDmpContractCode(codes);
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));
for (PdIncome pdIncome : pdIncomes) {
Object[] nameItem = names.get(pdIncome.getContractCode());
//my_body_name, customer_body, customer_short, business_type, agreement_type
if (nameItem != null) {
pdIncome.setMyBodyName(nameItem[2] + "");
pdIncome.setCustomerBody(nameItem[3] + "");
pdIncome.setCustomerShort(nameItem[4] + "");
pdIncome.setBusinessType(nameItem[5] + "");
pdIncome.setAgreementType(nameItem[6] + "");
pdIncome.setProductType(nameItem[7] + "");
if (StringUtils.isEmpty(pdIncome.getMyBodyName()) || pdIncome.getMyBodyName().equals("null")) {
pdIncome.setMyBodyName(cBodyMap.get(nameItem[1]));
}
}
}
return pdIncomes;
}
@Override
public HSSFWorkbook exportPdIncomeList(String startDate, String endDate, String bodyCode, String serchName) {
List<PdIncome> pdIncomes = this.pdListByDs(startDate, endDate);
pdIncomes = pdIncomes.stream()
.filter(v -> StringUtils.isEmpty(bodyCode) || "all".equals(bodyCode) || bodyCode.equals(v.getMyBodyName()))
.filter(v -> StringUtils.isEmpty(serchName) || (v.getContractCode().contains(serchName) || v.getCustomerBody().contains(serchName) || v.getMyBodyName().contains(serchName)))
.collect(Collectors.toList());
DecimalFormat df = new DecimalFormat("##,##0.00");
//创建工作薄对象
HSSFWorkbook workbook = new HSSFWorkbook();//这里也可以设置sheet的Name
//创建工作表对象
HSSFSheet sheet = workbook.createSheet();
//创建工作表的行
HSSFRow row = sheet.createRow(0);
//表头
String[] title = "我方签约主体,签约方,客户简称,合同编号,录入日期,结算日期,产品类型,收入类型,税率,确认收入".split(",");
for (int i = 0; i < title.length; i++) {
row.createCell(i).setCellValue(title[i]);
}
for (int j = 0; j < pdIncomes.size(); j++) {
HSSFRow rowBody = sheet.createRow(j + 1);
PdIncome income = pdIncomes.get(j);
String[] dataItem = new String[]{
income.getMyBodyName(), income.getCustomerBody(), income.getCustomerShort(),
income.getContractCode(), income.getInputDate(), income.getSettlementDate(),
income.getProductType(), income.getIncomeType(),
income.getTaxRate(), income.getConfirmIncome()
};
for (int w = 0; w < dataItem.length; w++) {
rowBody.createCell(w).setCellValue(dataItem[w]);
}
}
return workbook;
}
@Override
public HSSFWorkbook exportIncomeList(String startDate, String endDate, String bodyCode, String serchName) {
List<DmpIncome> dmpIncomes = this.listByDs(startDate, endDate);
dmpIncomes = dmpIncomes.stream()
......
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