职务消费台账开发

This commit is contained in:
zhangzhiguo 2024-12-03 17:55:18 +08:00
parent 7b994eac74
commit fa0411db49
1 changed files with 128 additions and 125 deletions

View File

@ -116,9 +116,11 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
Map<String, ExpenseReport> reportMap = new LinkedHashMap<>();
for (Long userId : allUsersOfOrg) {
//费用报销单数据
DynamicObject[] dailyreimbursebillDataSet = getDailyreimbursebillDataSet(userId, year, false);
DynamicObject[] dailyreimbursebillDataSet = getDailyreimbursebillDataSet(userId, year);
for (DynamicObject dynamicObject : dailyreimbursebillDataSet) {
String billno = dynamicObject.getString("billno");//单据编号
//判罚是否因公出国
Boolean isBusinessForeign = dynamicObject.getBoolean(DEV_KEY+"_is_business_foreign");//单据编号
DynamicObjectCollection entrys = dynamicObject.getDynamicObjectCollection("expenseentryentity");
for (DynamicObject entry : entrys) {
@ -137,7 +139,7 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
report = new ExpenseReport(userId, billno, happendateStr);
reportMap.put(key, report);
}
if(!isBusinessForeign){
// 为该行添加费用
//report.addExpense(expenseType, amount);
if(itemNumber.startsWith(FYF)){//防疫费
@ -177,9 +179,52 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
BigDecimal other = report.getOther().add(expenseamount);
report.setOther(other);
}
}else{
//费用明细中的所有金额因公临时出国费用
BigDecimal abroadTravel = report.getAbroadTravel().add(expenseamount);
report.setAbroadTravel(abroadTravel);
}
}
}
//差旅报销单数据
DynamicObject[] tripreimburseDataSet = getTripreimburseDataSet(userId, year);
for (DynamicObject dynamicObject : tripreimburseDataSet) {
String billno = dynamicObject.getString("billno");//单据编号
//判罚是否因公出国
Boolean isBusinessForeign = dynamicObject.getBoolean(DEV_KEY+"_is_business_foreign");//单据编号
DynamicObjectCollection entrys = dynamicObject.getDynamicObjectCollection("tripentry");
for (DynamicObject entry : entrys) {
Date happendate = entry.getDate("startdate");//出差开始日期
String happendateStr = dateFormat.format(happendate);//费用发生日期str
DynamicObjectCollection entryentity = entry.getDynamicObjectCollection("entryentity");
for (DynamicObject object : entryentity) {
BigDecimal orientryamount = object.getBigDecimal("orientryamount");//报销金额
// 生成唯一的键报销人 + 单据编号 + 费用发生日期
String key = userId + "-" + billno + "-" + happendateStr;
// 根据键获取报表对象
ExpenseReport report = reportMap.get(key);
if (report == null) {
report = new ExpenseReport(userId, billno, happendateStr);
reportMap.put(key, report);
}
if(!isBusinessForeign){
//费用明细中的所有金额因公临时出国费用
BigDecimal travel = report.getTravel().add(orientryamount);
report.setTravel(travel);
}else{
//费用明细中的所有金额因公临时出国费用
BigDecimal abroadTravel = report.getAbroadTravel().add(orientryamount);
report.setAbroadTravel(abroadTravel);
}
}
}
}
}
//合计汇总
ExpenseReport totalReport = new ExpenseReport(null, null, null);
ArrayList<ExpenseReport> reportsList = new ArrayList<>(reportMap.values());
// 打印每一行报表
for (ExpenseReport report : reportsList) {
@ -193,138 +238,92 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
tempData[2] = report.getHappenDateStr();
tempData[3] = report.getBillNumber();
BigDecimal businessEntertainment = report.getBusinessEntertainment();
totalReport.setBusinessEntertainment(totalReport.getBusinessEntertainment().add(businessEntertainment));
tempData[4] = businessEntertainment;
BigDecimal foreignEntertainment = report.getForeignEntertainment();
totalReport.setForeignEntertainment(totalReport.getForeignEntertainment().add(foreignEntertainment));
tempData[5] = foreignEntertainment;
BigDecimal importantOfficial = report.getImportantOfficial();
totalReport.setImportantOfficial(totalReport.getImportantOfficial().add(importantOfficial));
tempData[6] = importantOfficial;
BigDecimal other = report.getOther();
totalReport.setOther(totalReport.getOther().add(other));
tempData[7] = other;
BigDecimal accommodation = report.getAccommodation();
totalReport.setAccommodation(totalReport.getAccommodation().add(accommodation));
tempData[8] = accommodation;
BigDecimal souvenirs = report.getSouvenirs();
totalReport.setSouvenirs(totalReport.getSouvenirs().add(souvenirs));
tempData[9] = souvenirs;
BigDecimal subtotal = businessEntertainment.add(foreignEntertainment)
.add(importantOfficial).add(other)
.add(accommodation).add(souvenirs);
totalReport.setSubtotal(totalReport.getSubtotal().add(subtotal));
tempData[10] = subtotal;
//private BigDecimal abroadTravel = BigDecimal.ZERO;//因公临时出国费用
// private BigDecimal health = BigDecimal.ZERO;//防疫费用
// private BigDecimal correspondence = BigDecimal.ZERO;//通信费用
// private BigDecimal training = BigDecimal.ZERO;//培训费用
BigDecimal travel = report.getTravel();
totalReport.setTravel(totalReport.getTravel().add(travel));
tempData[11] = travel;//travel
BigDecimal abroadTravel = report.getAbroadTravel();
totalReport.setAbroadTravel(totalReport.getAbroadTravel().add(abroadTravel));
tempData[12] = abroadTravel;
BigDecimal health = report.getHealth();
totalReport.setHealth(totalReport.getHealth().add(health));
tempData[13] = health;
BigDecimal correspondence = report.getCorrespondence();
totalReport.setCorrespondence(totalReport.getCorrespondence().add(correspondence));
tempData[14] = correspondence;
BigDecimal training = report.getTraining();
totalReport.setTraining(totalReport.getTraining().add(training));
tempData[15] = training;
BigDecimal total = subtotal.add(travel).add(abroadTravel).add(health).add(correspondence).add(training);
totalReport.setTotal(totalReport.getTotal().add(total));
tempData[16] = total;
}
/*Map<String,BigDecimal> expenseamountMap = new HashMap<>();
Map<String,Map<String,BigDecimal>> dateMap = new HashMap<>();
Map<String,Map<String,Map<String,BigDecimal>>> billMap = new HashMap<>();
Map<Long,Map<String,Map<String,Map<String,BigDecimal>>>> userMap = new HashMap<>();*/
/*for (Long userId : allUsersOfOrg) {
//费用报销单数据
DynamicObject[] dailyreimbursebillDataSet = getDailyreimbursebillDataSet(userId, year, false);
for (DynamicObject dynamicObject : dailyreimbursebillDataSet) {
String billno = dynamicObject.getString("billno");
DynamicObjectCollection entrys = dynamicObject.getDynamicObjectCollection("expenseentryentity");
for (DynamicObject entry : entrys) {
DynamicObject expenseitemObj = entry.getDynamicObject("expenseitem");
Date happendate = entry.getDate("happendate");
String expenseamount = entry.getString("expenseamount");
System.out.println(happendate);
}
}
if(userMap.containsKey(userId)){
}else{
}*/
Object [] tempData = new Object [FIELDS.length];
coll.add(tempData);
tempData[1] = "合计";
tempData[4] = totalReport.getBusinessEntertainment();
tempData[5] = totalReport.getForeignEntertainment();
tempData[6] = totalReport.getImportantOfficial();
tempData[7] = totalReport.getOther();
tempData[8] = totalReport.getAccommodation();
tempData[9] = totalReport.getSouvenirs();
tempData[10] = totalReport.getSubtotal();
tempData[11] = totalReport.getTravel();
tempData[12] = totalReport.getAbroadTravel();
tempData[13] = totalReport.getHealth();
tempData[14] = totalReport.getCorrespondence();
tempData[15] = totalReport.getTraining();
tempData[16] = totalReport.getTotal();
/**/
/*for (Row itemRow : dailyreimbursebillDataSet) {
//汇总国内差旅费 FYXM0015.001防疫费 FYXM002-CUS.001
String itemnumber = itemRow.getString("itemnumber");
String happendateStr = dateFormat.format(itemRow.getDate("happendate"));
BigDecimal expenseamount = itemRow.getBigDecimal("expenseamount");
if(itemnumber.startsWith(FYF)){//防疫费
//healthRealTotal = healthRealTotal.add(expenseamount);
}else if(itemnumber.startsWith(TXF)){//日常费用-通信费用
//correspondenceTotal = correspondenceTotal.add(expenseamount);
}else if(itemnumber.startsWith(PXF)){//日常费用-培训费用
//trainingTotal = trainingTotal.add(expenseamount);
}else if(itemnumber.startsWith(YWZDF)){//日常费用-业务招待费
// entertainTotal = entertainTotal.add(expenseamount);
}
}*/
//}
/**/
return resultDataSet;
}
/**
* 获取费用报销单数据
* @param userId 用户id
* @param year 统计年份
* @param isBusinessForeign 是否因公临时出国
* @return 数据集
*/
private DataSet getDailyreimbursebillDataSet1(Long userId, Integer year,Boolean isBusinessForeign) {
LocalDate firstDay = getFirstDayOfYear(year);
LocalDate lastDay = getLastDayOfYear(year);
List<QFilter> searchFilterList = new ArrayList<>();
//searchFilterList.add(new QFilter(DEV_KEY+"_year", QCP.equals, getFirstDayOfYear(year)));
searchFilterList.add(new QFilter("applier", QCP.equals, userId));
searchFilterList.add(new QFilter("expenseentryentity.happendate", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("expenseentryentity.happendate", QCP.less_equals, lastDay));
searchFilterList.add(new QFilter(DEV_KEY+"_is_business_foreign", QCP.equals, isBusinessForeign));
DataSet bdMaterialDataSet = QueryServiceHelper.queryDataSet(this.getClass().getName(),
"er_dailyreimbursebill",
"id,description,billno,expenseentryentity," +
"expenseentryentity.happendate as happendate," + //费用发生日期
"expenseentryentity.expenseitem.number as itemnumber," + //费用项目编码
"expenseentryentity.expenseamount as expenseamount",searchFilterList.toArray(new QFilter [] {}), null);
return bdMaterialDataSet;
}
public DynamicObject[] getDailyreimbursebillDataSet(Long userId, Integer year,Boolean isBusinessForeign){
public DynamicObject[] getDailyreimbursebillDataSet(Long userId, Integer year){
LocalDate firstDay = getFirstDayOfYear(year);
LocalDate lastDay = getLastDayOfYear(year);
List<QFilter> searchFilterList = new ArrayList<>();
searchFilterList.add(new QFilter("applier", QCP.equals, userId));
searchFilterList.add(new QFilter("expenseentryentity.happendate", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("expenseentryentity.happendate", QCP.less_equals, lastDay));
searchFilterList.add(new QFilter(DEV_KEY+"_is_business_foreign", QCP.equals, isBusinessForeign));
DynamicObject[] load = BusinessDataServiceHelper.load("er_dailyreimbursebill",
"id,description,billno,expenseentryentity," +
DEV_KEY+"_is_business_foreign,"+
"expenseentryentity.happendate," + //费用发生日期
"expenseentryentity.expenseitem," + //费用项目
"expenseentryentity.expenseamount ", searchFilterList.toArray(new QFilter [] {}));
/*for (DynamicObject doj : load) {
DynamicObjectCollection entrys = doj.getDynamicObjectCollection("expenseentryentity");
for (DynamicObject entry : entrys) {
entry.getString("happendate");
}
}*/
return load;
}
@ -332,10 +331,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
* 获取差旅报销单数据
* @param userId 用户id
* @param year 统计年份
* @param isBusinessForeign 是否因公临时出国
* @return 数据集
*/
private DataSet getTripreimburseDataSet(Long userId, Integer year,Boolean isBusinessForeign) {
private DynamicObject[] getTripreimburseDataSet(Long userId, Integer year) {
LocalDate firstDay = getFirstDayOfYear(year);
LocalDate lastDay = getLastDayOfYear(year);
List<QFilter> searchFilterList = new ArrayList<>();
@ -343,16 +341,21 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
searchFilterList.add(new QFilter("applier", QCP.equals, userId));
searchFilterList.add(new QFilter("tripentry.startdate", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("tripentry.startdate", QCP.less_equals, lastDay));
searchFilterList.add(new QFilter(DEV_KEY+"_is_business_foreign", QCP.equals, isBusinessForeign));
DataSet bdMaterialDataSet = QueryServiceHelper.queryDataSet(
//searchFilterList.add(new QFilter(DEV_KEY+"_is_business_foreign", QCP.equals, isBusinessForeign));
/*DataSet bdMaterialDataSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_tripreimbursebill",
"id,applier,billno,tripentry.startdate as startdate," +
"tripentry.entryentity.orientryamount as orientryamount" ,
searchFilterList.toArray(new QFilter [] {}), null
).orderBy(new String[]{"applier", "startdate"});
return bdMaterialDataSet;
).orderBy(new String[]{"applier", "startdate"});*/
DynamicObject[] load = BusinessDataServiceHelper.load("er_tripreimbursebill",
"id,description,billno,expenseentryentity," +
DEV_KEY+"_is_business_foreign,"+
"id,applier,billno,tripentry.startdate,tripentry.entryentity," + //费用发生日期
"entryentity.orientryamount", //报销金额
searchFilterList.toArray(new QFilter [] {}));
return load;
}
// 获取某年份的第一天