@Override
protected void _creat(Context ctx, IObjectValue model) throws BOSException, EASBizException {
LoanBillTempInfo tempInfo = (LoanBillTempInfo) model;
String applier = tempInfo.getApplier();
String cause = tempInfo.getCause();
String bizReqDate = tempInfo.getBizReqDate();
StringBuffer sql = new StringBuffer();
// sql.append(" /dialect/ “);
sql.append(” select loanbill.fnumber “);
sql.append(” from T_BC_DailyLoanBill loanbill “);
sql.append(” left join T_BD_Person person on loanbill.FApplierId = person.FId “);
sql.append(” where person.FNumber = ‘"+applier+"’ “);
sql.append(” and loanbill.FCause = ‘"+cause+"’ “);
sql.append(” and to_char(loanbill.FBizReqDate,‘yyyy-MM-dd’) = ‘"+bizReqDate+"’");
IRowSet rs = SQLExecutorFactory.getRemoteInstance(sql.toString()).executeSQL();
if(rs.size()>0){
try {
throw new EASBizException(new NumericExceptionSubItem("","当前数据已生成借款单,编码:"+rs.getString("fnumber")));
} catch (SQLException e) {
e.printStackTrace();
}
}
JSONArray arr = new JSONArray();
// 测试数据
JSONObject dailyLoanBill = new JSONObject();
dailyLoanBill.put("bizReqDate", bizReqDate);
dailyLoanBill.put("cause", cause);
dailyLoanBill.put("applier",applier);
dailyLoanBill.put("orgUnit", tempInfo.getOrgUnit());
dailyLoanBill.put("applierCompany", tempInfo.getApplierCompany());
dailyLoanBill.put("payMode", tempInfo.getPayMode());
dailyLoanBill.put("state", tempInfo.getState());
dailyLoanBill.put("billTypeCode",tempInfo.getBillTypeCode());
dailyLoanBill.put("applierCompany", tempInfo.getApplierCompany());
JSONObject entry = new JSONObject();// 分录json
int rowCount = tempInfo.getEntries().size();
LoanBillTempEntryInfo entryInfo = null;
for (int i = 0; i < rowCount; i++) {
entryInfo = tempInfo.getEntries().get(i);
entry.put("happenTime", entryInfo.getHappenTime());// *必录*费用发生时间
entry.put("expenseType", entryInfo.getExpenseType());// *必录*费用发生时间
entry.put("amount", entryInfo.getAmount());// *必录*费用发生时间
entry.put("amountApproved", entryInfo.getAmountApproved());// *必录*费用发生时间
entry.put("amountApprovedOri", entryInfo.getAmountApprovedOri());
entry.put("budgetDo", entryInfo.getBudgetDo());
entry.put("budgetDoOri", entryInfo.getBudgetDoOri());
entry.put("amountUsed", entryInfo.getAmountUsed());
entry.put("amountUsedOri", entryInfo.getAmountUsedOri());
entry.put("amountBalance", entryInfo.getAmountBalance());
entry.put("amountBalanceOri", entryInfo.getAmountBalanceOri());
entry.put("budgetBalance",entryInfo.getBudgetBalance());
entry.put("budgetUsed", entryInfo.getBudgetUsed());
entry.put("amountPaid", entryInfo.getAmountPaid());
entry.put("purpose", entryInfo.getPurpose());
entry.put("amountOri", entryInfo.getAmountOri());
entry.put("budgetUsedOri", entryInfo.getBudgetUsedOri());
}
JSONArray entrys = new JSONArray();
entrys.add(entry);
dailyLoanBill.put("entrys", entrys);
JSONObject collectionEntry = new JSONObject();
int rowCounts = tempInfo.getCollectionEntries().size();
LoanBillTempCollectionEntryInfo collectionEntryInfo = null;
for(int i = 0;i < rowCounts;i++){
collectionEntryInfo = tempInfo.getCollectionEntries().get(i);
collectionEntry.put("payMode", collectionEntryInfo.getPayMode());// 必录*支付方式
collectionEntry.put("payerName", collectionEntryInfo.getPayerName());// 必录*收款人
collectionEntry.put("payerBank", collectionEntryInfo.getPayerBank());// 必录*开户银行
collectionEntry.put("payerAccount", collectionEntryInfo.getPayerAccount());// 必录*开户银行
collectionEntry.put("amount", collectionEntryInfo.getAmount());// 必录*开户银行
collectionEntry.put("amountOri", collectionEntryInfo.getAmountOri());// 必录*开户银行
}
JSONArray collectionEntrys = new JSONArray();
collectionEntrys.add(collectionEntry);
dailyLoanBill.put("collectionEntry", collectionEntrys);
arr.add(dailyLoanBill);
CustCommWSFacadeFactory.getRemoteInstance().commWSMethod("com.kingdee.eas.rct.si.content.tools.SyncDailyLoanBill","addnew",arr.toString());
}