161 lines
4.9 KiB
Java
161 lines
4.9 KiB
Java
package com.tenwa.customer.controller.finance;
|
|
|
|
import java.util.List;
|
|
|
|
import jbo.finasys.REPORT_CATALOG;
|
|
import jbo.finasys.REPORT_DATA;
|
|
import jbo.finasys.REPORT_RECORD;
|
|
|
|
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.amarsoft.biz.finance.ReportManager;
|
|
|
|
public class CustomerFSAction {
|
|
|
|
private String objectNo;
|
|
private String reportScope;
|
|
private String reportDate;
|
|
private String newReportDate;
|
|
private String reportStatus;
|
|
private String customerId;
|
|
private String recordNo;
|
|
|
|
public String getRecordNo() {
|
|
return recordNo;
|
|
}
|
|
|
|
public void setRecordNo(String recordNo) {
|
|
this.recordNo = recordNo;
|
|
}
|
|
|
|
public String deleteFSReport(JBOTransaction tx) throws JBOException {
|
|
//连带删除report_date和report_record
|
|
BizObject bo = JBOFactory.getBizObjectManager(REPORT_RECORD.CLASS_NAME)
|
|
.createQuery("ObjectNo=:CustomerId and ReportDate=:ReportDate and ReportScope=:ReportScope")
|
|
.setParameter("CustomerId", customerId).setParameter("ReportDate", reportDate).setParameter("ReportScope", reportScope).getSingleResult(false);
|
|
|
|
String modelNo = "";
|
|
|
|
String reportNo = "";
|
|
|
|
if(bo!=null){
|
|
modelNo = bo.getAttribute("modelno").getString();
|
|
|
|
reportNo = bo.getAttribute("reportno").getString();
|
|
}
|
|
String modelClass = "";
|
|
if(!"".equals(modelNo)){
|
|
modelClass = JBOFactory.getBizObjectManager(REPORT_CATALOG.CLASS_NAME)
|
|
.createQuery("ModelNo=:ModelNo").setParameter("ModelNo", modelNo).getSingleResult(false).getAttribute("ModelClass").getString();
|
|
}
|
|
int rows = 0;
|
|
if(!"".equals(modelClass)){
|
|
rows = JBOFactory.getBizObjectManager(REPORT_CATALOG.CLASS_NAME).createQuery("ModelClass=:ModelClass")
|
|
.setParameter("ModelClass", modelClass).getResultList(false).size();
|
|
}
|
|
long l =Long.parseLong(reportNo);
|
|
String reportNoMax = l+rows-1+"";
|
|
|
|
//获取财务报表报告数量
|
|
List<BizObject> bos = JBOFactory.getBizObjectManager(REPORT_RECORD.CLASS_NAME)
|
|
.createQuery("reportno>=:ReportNo and reportno<=:ReportNoMax and ObjectNo=:ObjectNo and reportScope=:ReportScope and ReportDate=:ReportDate")
|
|
.setParameter("ReportNo", reportNo).setParameter("ReportNoMax", reportNoMax)
|
|
.setParameter("ObjectNo", customerId).setParameter("ReportScope", reportScope).setParameter("ReportDate", reportDate).getResultList(false);
|
|
|
|
//获取需要删除的报告ID
|
|
String reportNos = "";
|
|
if(bos.size()>0){
|
|
for(int i=0;i<bos.size();i++){
|
|
reportNos +=","+"'"+bos.get(i).getAttribute("ReportNo").getString()+"'";
|
|
}
|
|
reportNos = reportNos.substring(1,reportNos.length());
|
|
reportNos = "("+reportNos+")";
|
|
}
|
|
BizObjectManager bomR = JBOFactory.getBizObjectManager(REPORT_RECORD.CLASS_NAME);
|
|
BizObjectManager bomD = JBOFactory.getBizObjectManager(REPORT_DATA.CLASS_NAME);
|
|
|
|
tx.join(bomR);
|
|
tx.join(bomD);
|
|
|
|
int row1 =bomR.createQuery("delete from O where reportno in "+reportNos).executeUpdate();
|
|
int row2 =bomD.createQuery("delete from O where reportno in "+reportNos).executeUpdate();
|
|
if(row1>0&&row2>0){
|
|
return "OK";
|
|
}else{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
// 更新指定报表的会计月份
|
|
public String modifyReportDate(JBOTransaction tx) throws JBOException {
|
|
ReportManager.modifyReportDate(objectNo, reportScope, reportDate, newReportDate, tx);
|
|
return "ok";
|
|
}
|
|
|
|
//检测财务报表状态标志位
|
|
public String checkFSStatus() throws JBOException{
|
|
String sql = "select ReportStatus from O where CustomerID = :CustomerID and ReportDate = :ReportDate and ReportScope = :ReportScope";
|
|
BizObject bo = JBOFactory.createBizObjectQuery("jbo.finasys.CUSTOMER_FSRECORD", sql).setParameter("CustomerID", objectNo)
|
|
.setParameter("ReportDate", reportDate).setParameter("ReportScope", reportScope).getSingleResult(false);
|
|
if(bo == null) return "";
|
|
else return bo.getAttribute("ReportStatus").getString();
|
|
}
|
|
|
|
//更新财务报表状态标志位
|
|
public void updateFSStatus(JBOTransaction tx) throws JBOException{
|
|
ReportManager.updateFSStatus(objectNo, reportDate, reportScope, reportStatus, tx);
|
|
}
|
|
|
|
public String getObjectNo() {
|
|
return objectNo;
|
|
}
|
|
|
|
public void setObjectNo(String objectNo) {
|
|
this.objectNo = objectNo;
|
|
}
|
|
|
|
public String getReportScope() {
|
|
return reportScope;
|
|
}
|
|
|
|
public void setReportScope(String reportScope) {
|
|
this.reportScope = reportScope;
|
|
}
|
|
|
|
public String getReportDate() {
|
|
return reportDate;
|
|
}
|
|
|
|
public void setReportDate(String reportDate) {
|
|
this.reportDate = reportDate;
|
|
}
|
|
|
|
public String getNewReportDate() {
|
|
return newReportDate;
|
|
}
|
|
|
|
public void setNewReportDate(String newReportDate) {
|
|
this.newReportDate = newReportDate;
|
|
}
|
|
|
|
public String getReportStatus() {
|
|
return reportStatus;
|
|
}
|
|
|
|
public void setReportStatus(String reportStatus) {
|
|
this.reportStatus = reportStatus;
|
|
}
|
|
|
|
public String getCustomerId() {
|
|
return customerId;
|
|
}
|
|
|
|
public void setCustomerId(String customerId) {
|
|
this.customerId = customerId;
|
|
}
|
|
|
|
}
|