Num70 債權查詢 & 債權審覈

債權查詢:

//債權查詢
	@Action("getCreditorlist")
	public void getCreditorlist(){
			this.getResponse().setCharacterEncoding("utf-8");
		//一、獲取請求參數
	
              String dDebtNo = this.getRequest().getParameter("dDebtNo");//標的編號
              String dContractNo = this.getRequest().getParameter("dContractNo"); //借款ID
              String dDebtTransferredDateStart = this.getRequest().getParameter("dDebtTransferredDateStart");//債權轉入日期
              String dDebtTransferredDateEnd = this.getRequest().getParameter("dDebtTransferredDateEnd");//債權轉出日期
              String dDebtStatus = this.getRequest().getParameter("dDebtStatus");//債權狀態
              String dMatchedStatus = this.getRequest().getParameter("dMatchedStatus");//債權匹配狀態
              String offsetnum = this.getRequest().getParameter("offsetnum");
              
              Map<String, Object> map = new HashMap<String, Object>();
              if (StringUtils.isNotEmpty(dDebtNo)) {
            	  map.put("dDebtNo", dDebtNo.trim());
              }
              if (StringUtils.isNotEmpty(dContractNo)) {
            	  map.put("dContractNo", dContractNo.trim());
              }
              if (StringUtils.isNotEmpty(dDebtTransferredDateStart)) {
            	  map.put("dDebtTransferredDateStart", dDebtTransferredDateStart.trim());
              }
              if (StringUtils.isNotEmpty(dDebtTransferredDateEnd)) {
            	  map.put("dDebtTransferredDateEnd", dDebtTransferredDateEnd.trim());
              }
              if (StringUtils.isNotEmpty(dDebtStatus)) {
            	  map.put("dDebtStatus", Integer.parseInt(dDebtStatus.trim()));
              }
              if (StringUtils.isNotEmpty(dMatchedStatus)) {
            	  map.put("dMatchedStatus", Integer.parseInt(dMatchedStatus.trim()));
              }
              if (StringUtils.isNotEmpty(offsetnum)) {
            	  map.put("offsetnum", Integer.parseInt(offsetnum.trim()));
              }
              //查詢債券信息
              List<CreditorModel> list = creditorService.findCreditorList(map);
              for (CreditorModel cm:list){
            	  switch(cm.getDebtStatus()){
            	  	case 11301: cm.setDebtStatusDesc("未審覈");break;
            	  	case 11302: cm.setDebtStatusDesc("已審覈");break;
            	  	case 11303: cm.setDebtStatusDesc("正常還款");break;
            	  	case 11304: cm.setDebtStatusDesc("已結清");break;
            	  	case 11305: cm.setDebtStatusDesc("提早結清");break;
            	  	case 11306: cm.setDebtStatusDesc("結算失敗");
            	  }
            	  switch(cm.getMatchedStatus()){
            	  	case 11401: cm.setDebtStatusDesc("部分匹配");break;
            	  	case 11402: cm.setDebtStatusDesc("徹底匹配");break;
            	  	case 11403: cm.setDebtStatusDesc("未匹配");
            	  }
            	  
              }
              
              //查詢債券統計信息
              Object[] cmsSum = creditorService.findCreditorListSum(map);
              CreditorSumModel csum = new CreditorSumModel();
              csum.setdIdCount(Integer.parseInt(cmsSum[0].toString()));
              csum.setdDebtMoneySum(Double.parseDouble(cmsSum[1].toString()));
              csum.setdAvailableMoneySum(Double.parseDouble(cmsSum[2].toString()));
		//二、驗證請求參數
		//三、調用service完成查詢操做
		//四、響應數據到瀏覽器
             Map<String, Object> data = new HashMap<String, Object>();
             data.put("date", list);
             data.put("datasum", csum);
             try {
				this.getResponse().getWriter().write(Response.build().setStatus("1").setData(data).toJSON());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}
package cn.facebook.dao.creditor.impl;

import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import cn.facebook.dao.creditor.ICreditor4SqlDAO;
import cn.facebook.domain.creditor.CreditorModel;

@Repository
public class ICreditor4SqlDAOImpl implements ICreditor4SqlDAO {

	@PersistenceContext
	private EntityManager em;
	
	@Override
	public List<CreditorModel> findCreditorList(Map<String, Object> map) {
		String sql = "select a.* "
		             +"  from t_debt_info a, (select rownum rn, d_id from t_debt_info) b "
		             +" where 1=1 ";
		String dDebtNo = (String) map.get("dDebtNo");
		if (StringUtils.isNotBlank(dDebtNo)) {
			sql += " and d_debt_no='" + dDebtNo + "'";
		}
		String dContractNo = (String) map.get("dContractNo");
		if (StringUtils.isNotBlank(dDebtNo)) {
			sql += " and d_contract_No='" + dContractNo + "'";
		}
		
        String dDebtTransferredDateStart = (String) map.get("dDebtTransferredDateStart");
        String dDebtTransferredDateEnd = (String) map.get("dDebtTransferredDateEnd");
        
        if (StringUtils.isNotBlank(dDebtTransferredDateStart) && StringUtils.isNotBlank(dDebtTransferredDateEnd)) {
			sql += " and d_debt_Transferred_Date between to_date('" + dDebtTransferredDateStart
					+ "','yyyy-mm-dd') and to_date('" + dDebtTransferredDateEnd + "','yyyy-mm-dd')";
		}
        
        Integer dDebtStatus = (Integer) map.get("dDebtStatus");
		if (dDebtStatus != null && dDebtStatus != 0) {
			sql += " and d_debt_Status='" + dDebtStatus + "'";
		}
		Integer dMatchedStatus = (Integer) map.get("dMatchedStatus");
		if (dMatchedStatus != null && dMatchedStatus != 0) {
			sql += " and d_matched_Status='" + dMatchedStatus + "'";
		}
        int offsetnum = (int) map.get("offsetnum");
        int start = (offsetnum - 1) * 3;
		int end = start + 3;
		sql += " and a.d_id=b.d_id and b.rn>'" + start + "' and b.rn<='" + end + "'";
		if (StringUtils.isNotBlank(dDebtNo)) {
			sql += " and d_debt_no='" + dDebtNo + "'";
		}
		Query query = em.createNativeQuery(sql, CreditorModel.class);
		List<CreditorModel> list = query.getResultList();
		return list;                                                                     
	}

	@Override
	public Object[] findCreditorListSum(Map<String, Object> map) {
		String sql = "select count(d_id),count(d_debt_Money),count(d_available_Money)  "
	             +"  from t_debt_info a  "
	             +" where 1=1 ";
	  	String dDebtNo = (String) map.get("dDebtNo");
	  	if (StringUtils.isNotBlank(dDebtNo)) {
	  		sql += " and d_debt_no='" + dDebtNo + "'";
	  	}
	  	String dContractNo = (String) map.get("dContractNo");
	  	if (StringUtils.isNotBlank(dDebtNo)) {
	  		sql += " and d_contract_No='" + dContractNo + "'";
	  	}
	  	
	     String dDebtTransferredDateStart = (String) map.get("dDebtTransferredDateStart");
	     String dDebtTransferredDateEnd = (String) map.get("dDebtTransferredDateEnd");
	     
	     if (StringUtils.isNotBlank(dDebtTransferredDateStart) && StringUtils.isNotBlank(dDebtTransferredDateEnd)) {
	  		sql += " and d_debt_Transferred_Date between to_date('" + dDebtTransferredDateStart
	  				+ "','yyyy-mm-dd') and to_date('" + dDebtTransferredDateEnd + "','yyyy-mm-dd')";
	  	}
	     
	     Integer dDebtStatus = (Integer) map.get("dDebtStatus");
	  	if (dDebtStatus != null && dDebtStatus != 0) {
	  		sql += " and d_debt_Status='" + dDebtStatus + "'";
	  	}
	  	Integer dMatchedStatus = (Integer) map.get("dMatchedStatus");
	  	if (dMatchedStatus != null && dMatchedStatus != 0) {
	  		sql += " and d_matched_Status='" + dMatchedStatus + "'";
	  	}
	     
	  	Query query = em.createNativeQuery(sql);
	  	Object[] obj = (Object[]) query.getSingleResult();
	  	return obj; 
	  	}

}

債權審覈:

代碼連接:

https://github.com/lqingfang/p2pjava

相關文章
相關標籤/搜索