package com.ld.igds.m.service;
|
|
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
|
import com.ld.igds.models.AssetsLiability;
|
import com.ld.igds.models.CashFlow;
|
import com.ld.igds.models.Profit;
|
import com.ld.igds.util.ContextUtil;
|
import com.ld.igds.util.DateUtil;
|
import org.apache.commons.lang3.StringUtils;
|
import org.hibernate.Session;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Component;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author czt
|
* @date 2023-04-10 11:50
|
*/
|
@Component
|
public class HFinanceService extends HibernateDao {
|
|
|
/*----------资产负债----------*/
|
public List<AssetsLiability> getAssetsData(Map<String, Object> param){
|
|
String companyId = ContextUtil.getCompanyId();
|
|
String hql = " from " + AssetsLiability.class.getName()
|
+ " where companyId =:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
args.put("companyId", companyId);
|
|
if(null != param){
|
Date date = (Date) param.get("start");
|
if (null != date) {
|
hql += " and bbsj >=:start";
|
args.put("start", DateUtil.getCurZero(date));
|
}
|
|
date = (Date) param.get("end");
|
if (null != date) {
|
hql += " and bbsj <=:end";
|
args.put("end", DateUtil.getNextZero(date));
|
}
|
}
|
|
hql += " order by zhgxsj";
|
|
return this.query(hql, args);
|
}
|
|
public String saveAssetsData(AssetsLiability oldData) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
AssetsLiability data = new AssetsLiability();
|
BeanUtils.copyProperties(oldData, data);
|
if(StringUtils.isEmpty(data.getCompanyId())){
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if(StringUtils.isEmpty(data.getDeptId())){
|
data.setDeptId(ContextUtil.subDeptId(null));
|
}
|
data.setZhgxsj(new Date());
|
|
if (StringUtils.isEmpty(data.getId())) {
|
data.setId(ContextUtil.getCurTimeMillis());
|
session.save(data);
|
} else {
|
session.update(data);
|
}
|
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public String delAssetsData(AssetsLiability data) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
session.delete(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
|
/*----------现金流----------*/
|
|
public List<CashFlow> getCashFlowData(Map<String, Object> param){
|
|
String hql = " from " + CashFlow.class.getName()
|
+ " where companyId =:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
args.put("companyId", ContextUtil.getCompanyId());
|
|
if(null != param){
|
Date date = (Date) param.get("start");
|
if (null != date) {
|
hql += " and bbsj >=:start";
|
args.put("start", DateUtil.getCurZero(date));
|
}
|
|
date = (Date) param.get("end");
|
if (null != date) {
|
hql += " and bbsj <=:end";
|
args.put("end", DateUtil.getNextZero(date));
|
}
|
}
|
|
hql += " order by zhgxsj";
|
|
return this.query(hql, args);
|
}
|
|
public String saveCashFlowData(CashFlow oldData) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
CashFlow data = new CashFlow();
|
BeanUtils.copyProperties(oldData, data);
|
if(StringUtils.isEmpty(data.getCompanyId())){
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if(StringUtils.isEmpty(data.getDeptId())){
|
data.setDeptId(ContextUtil.subDeptId(null));
|
}
|
data.setZhgxsj(new Date());
|
|
if (StringUtils.isEmpty(data.getId())) {
|
data.setId(ContextUtil.getCurTimeMillis());
|
session.save(data);
|
} else {
|
session.update(data);
|
}
|
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public String delCashFlowData(CashFlow data) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
session.delete(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
|
/*----------利润----------*/
|
|
public List<Profit> getProfitData(Map<String, Object> param){
|
|
String hql = " from " + Profit.class.getName()
|
+ " where companyId =:companyId";
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
args.put("companyId", ContextUtil.getCompanyId());
|
|
if(null != param){
|
Date date = (Date) param.get("start");
|
if (null != date) {
|
hql += " and bbsj >=:start";
|
args.put("start", DateUtil.getCurZero(date));
|
}
|
|
date = (Date) param.get("end");
|
if (null != date) {
|
hql += " and bbsj <=:end";
|
args.put("end", DateUtil.getNextZero(date));
|
}
|
}
|
|
hql += " order by zhgxsj";
|
|
return this.query(hql, args);
|
}
|
|
public String saveProfitData(Profit oldData) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
Profit data = new Profit();
|
BeanUtils.copyProperties(oldData, data);
|
if(StringUtils.isEmpty(data.getCompanyId())){
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
if(StringUtils.isEmpty(data.getDeptId())){
|
data.setDeptId(ContextUtil.subDeptId(null));
|
}
|
data.setZhgxsj(new Date());
|
if (StringUtils.isEmpty(data.getId())) {
|
data.setId(ContextUtil.getCurTimeMillis());
|
session.save(data);
|
} else {
|
session.update(data);
|
}
|
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
|
public String delProfitData(Profit data) {
|
Session session = this.getSessionFactory().openSession();
|
try {
|
session.delete(data);
|
} finally {
|
session.flush();
|
session.close();
|
}
|
return null;
|
}
|
}
|