315 lines
12 KiB
Java
315 lines
12 KiB
Java
package com.tenwa.leasing.serviceImpl.voucher;
|
||
|
||
import java.math.BigDecimal;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import com.amarsoft.app.als.sys.tools.JBOHelper;
|
||
import com.amarsoft.app.util.StringUtil;
|
||
import com.amarsoft.are.jbo.BizObject;
|
||
import com.amarsoft.are.jbo.BizObjectManager;
|
||
import com.amarsoft.are.jbo.JBOException;
|
||
import com.amarsoft.are.jbo.JBOFactory;
|
||
import com.amarsoft.are.jbo.JBOTransaction;
|
||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||
import com.tenwa.leasing.service.voucher.CreateVoucherService;
|
||
import com.tenwa.reckon.util.DateUtils;
|
||
import com.tenwa.reckon.util.Tools;
|
||
|
||
import jbo.app.VOUCHERASSSTACTS_INFO;
|
||
import jbo.app.VOUCHER_CONNECTION;
|
||
import jbo.app.VOUCHER_V8;
|
||
import jbo.sys.USER_INFO;
|
||
|
||
public class VoucherAction {
|
||
|
||
private String f3;
|
||
private String control_;//凭证生成控制开关 open OR close
|
||
private String userid;//当前用户id
|
||
private String ids;//多凭证号字符串
|
||
private String interest;//成本均摊中的利息--用来计算 成本均摊
|
||
private String handling;//成本均摊中的手续费
|
||
private String loan_contract_id;//借款合同号
|
||
private String bill_id;//借款借据号
|
||
private String accured_month;//计提月份
|
||
|
||
|
||
public String getBill_id() {
|
||
return bill_id;
|
||
}
|
||
|
||
public void setBill_id(String bill_id) {
|
||
this.bill_id = bill_id;
|
||
}
|
||
|
||
public String getAccured_month() {
|
||
return accured_month;
|
||
}
|
||
|
||
public void setAccured_month(String accured_month) {
|
||
this.accured_month = accured_month;
|
||
}
|
||
|
||
public String getLoan_contract_id() {
|
||
return loan_contract_id;
|
||
}
|
||
|
||
public void setLoan_contract_id(String loan_contract_id) {
|
||
this.loan_contract_id = loan_contract_id;
|
||
}
|
||
|
||
public String getHandling() {
|
||
return handling;
|
||
}
|
||
|
||
public void setHandling(String handling) {
|
||
this.handling = handling;
|
||
}
|
||
|
||
public String getIds() {
|
||
return ids;
|
||
}
|
||
|
||
public void setIds(String ids) {
|
||
this.ids = ids;
|
||
}
|
||
|
||
public String getUserid() {
|
||
return userid;
|
||
}
|
||
|
||
public void setUserid(String userid) {
|
||
this.userid = userid;
|
||
}
|
||
|
||
public String getInterest() {
|
||
return interest;
|
||
}
|
||
|
||
public void setInterest(String interest) {
|
||
this.interest = interest;
|
||
}
|
||
|
||
public String getF3() {
|
||
return f3;
|
||
}
|
||
|
||
public String getControl_() {
|
||
return control_;
|
||
}
|
||
|
||
public void setControl_(String control_) {
|
||
this.control_ = control_;
|
||
}
|
||
|
||
public void setF3(String f3) {
|
||
this.f3 = f3;
|
||
}
|
||
//导出凭证 修改状态
|
||
public void updateVoucherStatus(JBOTransaction tx) throws JBOException
|
||
{
|
||
// String str=f3;
|
||
// JBOFactory.createBizObjectQuery(VOUCHER_V8.CLASS_NAME, "update O set v8_flag='1',v8_memo='已导出',exp_date=:date where f3 in ("+f3+")")
|
||
// .setParameter("date", DateUtils.getSystemDate(3)).executeUpdate();
|
||
JBOFactory.createBizObjectQuery(VOUCHER_V8.CLASS_NAME, "update O set v8_flag='1',v8_memo='已导出',exp_date=:date,f89=f89+1 where f3=:f3")
|
||
.setParameter("date", DateUtils.getSystemDate(3)).setParameter("f3", f3).executeUpdate();
|
||
}
|
||
|
||
public String controlCreate(JBOTransaction tx) throws Exception{
|
||
String mes=null;
|
||
int i = JBOHelper.executeUpdate(tx, "jbo.app.VOUCHER_HELP","update o set is_create_voucher=:control_ where id='control_voucher_create' ", control_);
|
||
if(i==1){
|
||
mes = "success";
|
||
}else{
|
||
mes = "fail";
|
||
}
|
||
return mes;
|
||
}
|
||
|
||
/**
|
||
* 成本均摊 计算逻辑:(A项目的未还本金*天数)/(全部项目的(未还本金*天数)的和)
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String costSharing(JBOTransaction tx) throws Exception{
|
||
// String mes = null;
|
||
// //生成成本均摊凭证
|
||
// BizObject curUser = JBOHelper.querySingle(USER_INFO.CLASS_NAME, "select * from o where o.userid=:userid", userid);
|
||
// if(curUser==null){
|
||
// curUser = new BizObject(USER_INFO.CLASS_NAME);
|
||
// }
|
||
// CreateVoucherService c = new CreateVoucherServiceImpl();
|
||
// Map<String,String> paraMap = new HashMap<String, String>();
|
||
// paraMap.put("loan_contract_id", loan_contract_id);
|
||
// paraMap.put("bill_id", bill_id);
|
||
// paraMap.put("accured_month", accured_month);
|
||
// //param :利息,手续费,当前用户,借据合同id,事务
|
||
// c.createVoucher_costSharing(new BigDecimal(StringUtil.nullToString(interest, "0")),new BigDecimal(StringUtil.nullToString(handling, "0")),curUser,paraMap, tx);
|
||
// //conn.close();
|
||
return "success";
|
||
}
|
||
|
||
|
||
public String synVoucherCode(JBOTransaction tx) throws Exception{
|
||
String mes="";
|
||
String config_id = null;//凭证科目配置表
|
||
String proj_id = null;//项目id
|
||
String voucher_code = null;//凭证辅助账编码
|
||
String f3 = null;
|
||
|
||
BizObjectManager v8m = JBOFactory.getBizObjectManager(VOUCHER_V8.CLASS_NAME);
|
||
tx.join(v8m);
|
||
String f3s = ids.replace("@", "','");
|
||
f3s = "'"+f3s+"'";
|
||
//F6-配置科目id, F18-客户编码,F19-供应商编码,F21-项目编码, F22,F24,F25,-项目id,
|
||
List<BizObject> list = JBOHelper.queryList(VOUCHER_V8.CLASS_NAME, "select id,F3,F6,F18,F19,F21,NVL(nvl(F22,F24),F25) as v.proj_id_tag from O where o.f3 in ("+f3s+") order by generate_date desc");
|
||
for(int i=0;i<list.size();i++){
|
||
f3 = list.get(i).getAttribute("F3").toString();
|
||
config_id = list.get(i).getAttribute("F6").toString();
|
||
//清除原先的辅助账编码
|
||
list.get(i).setAttributeValue("F18", "");
|
||
list.get(i).setAttributeValue("F19", "");
|
||
list.get(i).setAttributeValue("F21", "");
|
||
//获取配置子表的完整信息,主要是统计该科目存在多少个辅助核算信息
|
||
Map<String,String> propertiesMap = new HashMap<String, String>();
|
||
propertiesMap.put("CONFIG_ID", config_id);
|
||
propertiesMap.put("status","0");//0是有效; 1为作废
|
||
//根据具体的字段条件查询一个entity,条件使用map封装
|
||
List<BizObject> voucherConnection_l=DataOperatorUtil.getSetJBO(VOUCHER_CONNECTION.CLASS_NAME, propertiesMap, tx);
|
||
for (int j = 0; j < voucherConnection_l.size(); j++) {
|
||
BizObject voucherConnection = voucherConnection_l.get(j);
|
||
//辅助账类型编号
|
||
propertiesMap.clear();
|
||
propertiesMap.put("id", voucherConnection.getAttribute("ASSTACTTYPE").toString());
|
||
BizObject obj = DataOperatorUtil.getSingleJBO(VOUCHERASSSTACTS_INFO.CLASS_NAME, propertiesMap, tx);
|
||
String voucherassStactsInfoId = Tools.getStr( obj.getAttribute("id").toString() );//辅助账类型表主键
|
||
/**
|
||
*辅助核算5:按客户核算
|
||
*/
|
||
if("voucherassstacts_info_id_1".equals(voucherassStactsInfoId)){
|
||
//F24-项目id F18-客户编码
|
||
proj_id = list.get(i).getAttribute("proj_id_tag").toString();
|
||
if("".equals(proj_id)){mes+="凭证"+f3+":刷新失败,承租人信息未关联到凭证信息中!<br/>";}
|
||
BizObject boProj = JBOHelper.querySingle("jbo.com.tenwa.entity.project.PROJ_INFO","SELECT cust_voucher_code FROM o where o.id=:proj_id",proj_id);
|
||
if(boProj!=null){
|
||
voucher_code = boProj.getAttribute("cust_voucher_code").toString();
|
||
list.get(i).setAttributeValue("F18", voucher_code);
|
||
if("".equals(voucher_code)){
|
||
mes += "凭证"+f3+":刷新失败,客户辅助账编码为空!<br/>";
|
||
}else{
|
||
mes +="凭证"+f3+":刷新成功!<br/>";
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
*辅助核算4:按项目核算
|
||
*/
|
||
if("voucherassstacts_info_id_4".equals(voucherassStactsInfoId)){
|
||
//F22-项目id F21-项目编码
|
||
proj_id = list.get(i).getAttribute("proj_id_tag").toString();
|
||
if("".equals(proj_id)){mes+="凭证"+f3+":刷新失败,项目信息未关联到凭证信息中!<br/>";}
|
||
BizObject boProj = JBOHelper.querySingle("jbo.com.tenwa.entity.project.PROJ_INFO","select voucher_code from o where o.id=:proj_id",proj_id);
|
||
if(boProj!=null){
|
||
voucher_code = boProj.getAttribute("voucher_code").toString();
|
||
list.get(i).setAttributeValue("F21",voucher_code);
|
||
if("".equals(voucher_code)){
|
||
mes += "凭证"+f3+":刷新失败,项目辅助账编码为空!<br/>";
|
||
}else{
|
||
mes +="凭证"+f3+":刷新成功!<br/>";
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
*辅助核算2:按供应商核算
|
||
*
|
||
*/
|
||
if("voucherassstacts_info_id_2".equals(voucherassStactsInfoId)){
|
||
//F25-供应商id F19-供应商编码
|
||
proj_id = list.get(i).getAttribute("proj_id_tag").toString();
|
||
if("".equals(proj_id)){mes+="凭证"+f3+":刷新失败,供应商信息未关联到凭证信息中!<br/>";}
|
||
//BizObject bosup = JBOHelper.querySingle(CUSTOMER_INFO.CLASS_NAME, "select o.customername,o.voucher_code from o where o.customerid=:sup_id", supp_id);
|
||
BizObject boProj = JBOHelper.querySingle("jbo.com.tenwa.entity.project.PROJ_INFO","select supp_voucher_code from o where o.id=:proj_id",proj_id);
|
||
if(boProj!=null){
|
||
voucher_code = boProj.getAttribute("supp_voucher_code").toString();
|
||
list.get(i).setAttributeValue("F19", voucher_code);
|
||
if("".equals(voucher_code)){
|
||
mes += "凭证"+f3+":刷新失败,供应商辅助账编码为空!<br/>";
|
||
}else{
|
||
mes +="凭证"+f3+":刷新成功!<br/>";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
v8m.saveObject(list.get(i));
|
||
}
|
||
return mes;
|
||
}
|
||
|
||
|
||
public static String getContractByProjId(String proj_id) throws Exception{
|
||
String contract_numbers = "";
|
||
String ids = "";
|
||
String contract_info = "";
|
||
List<BizObject> listCon = JBOHelper.queryList("jbo.com.tenwa.entity.contract.CONTRACT_INFO", "select id,contract_number from o where o.proj_id=:proj_id", proj_id);
|
||
for (int i = 0; i < listCon.size(); i++) {
|
||
contract_numbers += listCon.get(i).getAttribute("contract_number").toString()+",";
|
||
ids += listCon.get(i).getAttribute("id").toString()+",";
|
||
contract_info += listCon.get(i).getAttribute("contract_number").toString()+"##"+listCon.get(i).getAttribute("id").toString()+",";
|
||
}
|
||
if(contract_numbers.length()>0){
|
||
contract_numbers = contract_numbers.substring(0,contract_numbers.length()-1);
|
||
ids = ids.substring(0,ids.length()-1);
|
||
contract_info = contract_info.substring(0,contract_info.length()-1);
|
||
}
|
||
|
||
|
||
return contract_info;//ids;//contract_numbers;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 复制数据到同一张表中
|
||
*/
|
||
public void copyProjData(JBOTransaction tx) throws Exception{
|
||
int i = 1/0;//抛异常
|
||
Map<String, String> fromCondtion = new HashMap<String, String>();
|
||
Map<String, String> toCondtion = new HashMap<String, String>();
|
||
Map<String, String> otherProperty = new HashMap<String, String>();
|
||
//toCondtion.put(key, value)
|
||
fromCondtion.put("id", "2017052000000013");
|
||
otherProperty.put("proj_status", "11");
|
||
otherProperty.put("repeal_date", "");
|
||
otherProperty.put("repeal_reason_type", "");
|
||
otherProperty.put("repeal_reason", "");
|
||
//String id = DataOperatorUtil.copySingleJBO(PROJ_INFO.CLASS_NAME, fromCondtion, PROJ_INFO.CLASS_NAME, toCondtion, otherProperty, tx);
|
||
fromCondtion.clear();
|
||
otherProperty.clear();
|
||
|
||
fromCondtion.put("proj_id", "2017052000000013");
|
||
otherProperty.put("proj_id", "2017052000000113");
|
||
// List<BizObject> list1 = DataOperatorUtil.copyJBOSet(PROJ_EQUIP.CLASS_NAME, fromCondtion, PROJ_EQUIP.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list2 = DataOperatorUtil.copyJBOSet(PROJ_GUARANTEE_METHOD.CLASS_NAME, fromCondtion, PROJ_GUARANTEE_METHOD.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list3 = DataOperatorUtil.copyJBOSet(PROJ_GUARANTEE_EQUIP.CLASS_NAME, fromCondtion, PROJ_GUARANTEE_EQUIP.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list4 = DataOperatorUtil.copyJBOSet(PROJ_CONDITION.CLASS_NAME, fromCondtion, PROJ_CONDITION.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list5 = DataOperatorUtil.copyJBOSet(PROJ_FUND_RENT_PLAN.CLASS_NAME, fromCondtion, PROJ_FUND_RENT_PLAN.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list6 = DataOperatorUtil.copyJBOSet(PROJ_FUND_FUND_PLAN.CLASS_NAME, fromCondtion, PROJ_FUND_FUND_PLAN.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list7 = DataOperatorUtil.copyJBOSet(PROJ_CASH_DETAIL.CLASS_NAME, fromCondtion, PROJ_CASH_DETAIL.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
// List<BizObject> list8 = DataOperatorUtil.copyJBOSet(PROJ_OTHER_FUND.CLASS_NAME, fromCondtion, PROJ_OTHER_FUND.CLASS_NAME, toCondtion, otherProperty, null, tx);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
}
|