Compare commits

...

2 Commits

Author SHA1 Message Date
zhangzhiguo 108b3ebbfd Merge remote-tracking branch 'origin/dev' into dev 2024-12-20 17:14:01 +08:00
zhangzhiguo 74d5389012 代码优化 2024-12-20 17:13:06 +08:00
8 changed files with 227 additions and 331 deletions

View File

@ -5,12 +5,16 @@ import kd.bos.algo.Row;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.RowDataEntity;
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
import kd.bos.entity.datamodel.events.BizDataEventArgs;
import kd.bos.entity.operate.Submit;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
@ -22,6 +26,7 @@ import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Date;
import java.util.EventObject;
import java.util.List;
/**
@ -35,247 +40,24 @@ public class DailyreimbursVisitCheckPlugin extends AbstractBillPlugIn implemen
private static final String prefix ="zcgj";
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
try{
if((args.getSource() instanceof Submit) ){
Submit source = (Submit)args.getSource();
if(source.getOperateKey().equals("submit") ){
IDataModel model = this.getModel();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
//报销人
DynamicObject applier = (DynamicObject)this.getModel().getValue("applier");
long applierId = applier.getLong("id");
//获取休假开始时间
Date startTime = (Date)model.getValue(prefix + "_holiday_start_time");
Date endTime = (Date)model.getValue(prefix + "_holiday_end_time");
//获取是否探亲
//如果是探亲则进行逻辑判断
Boolean isVisit = (Boolean)model.getValue(prefix+"_is_visit");
public void afterAddRow(AfterAddRowEventArgs e) {
super.afterAddRow(e);
//RowDataEntity[] rowDataEntities = e.getRowDataEntities();
//for (RowDataEntity rowDataEntity : rowDataEntities) {
// int rowIndex = rowDataEntity.getRowIndex();
// QFilter nameQFilterAccItem = new QFilter("number",QCP.equals,"FYXM004.999");
// DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "number,name", new QFilter[]{nameQFilterAccItem});
// this.getModel().setValue("expenseitem",dynamicObjectAccItem,rowIndex);
//}
if(isVisit){
//探亲类型 1探望父母2探望配偶
String visitType = (String)model.getValue(prefix + "_visit_type");
}
//获取当前人的探亲假配置
QFilter[] visitSetFilterArray = new QFilter[1];
visitSetFilterArray[0] = new QFilter(prefix+"_user", QCP.equals, applierId);
DynamicObject dynamicObject = QueryServiceHelper.queryOne( prefix+"_user_visit_set",
"id,zcgj_visit_times as visitTime,zcgj_visit_days as visitDays,zcgj_married_status as marriedStatus," +
"zcgj_married_parents_year as marriedParentsYear,zcgj_married_parents_time as marriedParentsTime," +
"zcgj_married_spouse_year as marriedSpouseYear,zcgj_married_spouse_time as marriedSpouseTime," +
"zcgj_unmarried_parents_y as unmarriedParentsYear,zcgj_unmarried_parents_t as unmarriedParentsTime",visitSetFilterArray);
if(dynamicObject == null){
this.getView().showErrorNotification("请设置人员探亲配置信息!");
//取消提交操作
args.setCancel(true);
return;
}
//探亲次数
int visitTime = 0;
//探亲年限
int visitYear = 0;
//总年探亲天数
int visitDays =dynamicObject.getInt("visitDays");
//婚姻状况1已婚2未婚
int marriedStatus =dynamicObject.getInt("marriedStatus");
//已婚探望父母年限
int marriedParentsYear =dynamicObject.getInt("marriedParentsYear");
//已婚探望父母次数
int marriedParentsTime =dynamicObject.getInt("marriedParentsTime");
//已婚探望配偶年限
int marriedSpouseYear =dynamicObject.getInt("marriedSpouseYear");
//已婚探望配偶次数
int marriedSpouseTime =dynamicObject.getInt("marriedSpouseTime");
//未婚探望父母年限
int unmarriedParentsYear =dynamicObject.getInt("unmarriedParentsYear");
//未婚探望父母次数
int unmarriedParentsTime =dynamicObject.getInt("unmarriedParentsTime");
if(visitDays == 0 ){
this.getView().showErrorNotification("人员探亲配置探亲假天数为空!");
//取消提交操作
args.setCancel(true);
return;
}
if(marriedStatus == 1 ){ // 已婚
if(marriedParentsYear == 0 ){
this.getView().showErrorNotification("人员探亲配置已婚探望父母年限为空!");
//取消提交操作
args.setCancel(true);
return;
}
if(marriedParentsTime == 0 ){
this.getView().showErrorNotification("人员探亲配置已婚探望父母次数为空!");
//取消提交操作
args.setCancel(true);
return;
}
if(marriedSpouseYear == 0 ){
this.getView().showErrorNotification("人员探亲配置已婚探望配偶年限为空!");
//取消提交操作
args.setCancel(true);
return;
}
if(marriedSpouseTime == 0 ){
this.getView().showErrorNotification("人员探亲配置已婚探望配偶次数为空!");
//取消提交操作
args.setCancel(true);
return;
}
//如果是探望父母
if("1".equals(visitType)){
visitYear = marriedParentsYear;
visitTime = marriedParentsTime;
}else
//如果是探望配偶
if("2".equals(visitType)){
visitTime = marriedSpouseTime;
visitYear = marriedSpouseYear;
}
}else if (marriedStatus == 2) { // 未婚
if(!"1".equals(visitType)){
this.getView().showErrorNotification("未婚状态下探亲类型只能选择探望父母!");
//取消提交操作
args.setCancel(true);
return;
}
if(unmarriedParentsYear == 0 ){
this.getView().showErrorNotification("人员探亲配置未婚探望父母年限为空!");
//取消提交操作
args.setCancel(true);
return;
}
if(unmarriedParentsTime == 0 ){
this.getView().showErrorNotification("人员探亲配置未婚探望父母次数为空!");
//取消提交操作
args.setCancel(true);
return;
}
visitTime = unmarriedParentsTime;
visitYear = unmarriedParentsYear;
}
Date firstDayOfYear = getFirstDayOfYear(startTime);
//年限开始时间
LocalDate firstDayYearsAgo = getFirstDayYearsAgo(dateToLocalDate(startTime), visitYear);
Date lastDayOfYear = getLastDayOfYear(startTime);
List<String> billStatuslist = new ArrayList<>();
billStatuslist.add("B");
billStatuslist.add("C");
billStatuslist.add("D");
billStatuslist.add("E");
billStatuslist.add("F");
billStatuslist.add("G");
// 查询条件
QFilter[] filterArray = new QFilter[5];
//查询申请人下的今年的探亲差旅单据
filterArray[0] = new QFilter(prefix+"_holiday_start_time", QCP.large_equals, firstDayOfYear);
filterArray[1] = new QFilter(prefix+"_holiday_start_time", QCP.less_equals, lastDayOfYear);
filterArray[2] = new QFilter("applier", QCP.equals, applierId);
filterArray[3] = new QFilter(prefix+"_is_visit", QCP.equals, true);
filterArray[4] = new QFilter("billstatus", QCP.in, billStatuslist);
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_holiday_days as days",
filterArray, null
);
//使用请假总天数
long allHolidayCount = 0;
//使用请假总次数
int holidayCount = 0;
for (Row itemRow : dateSet) {
String string = itemRow.getString("billno");
Date startTimeVal = itemRow.getDate("startTime");
Date endTimeVal = itemRow.getDate("endTime");
//long dayCount = ChronoUnit.DAYS.between(dateToLocalDate(startTimeVal), dateToLocalDate(endTimeVal));
Integer dayCount = itemRow.getInteger("days");
allHolidayCount+=dayCount;
holidayCount++;
System.out.println(string);
}
//剩余次数
int remainderTimes = visitTime-holidayCount;
//剩余天数
long remainderDays = visitDays-allHolidayCount;
//判断剩余天数和本次请假天数
long nowDays = ChronoUnit.DAYS.between(dateToLocalDate(startTime),dateToLocalDate(endTime))+1;
String message = String.format("您在%s年到%s年中已用%d次探亲休假剩余%d次探亲休假已用%d天探亲天数剩余%d天探亲天数。本次休假天数%d天。"
,firstDayYearsAgo.getYear(),dateFormat.format(startTime),holidayCount,remainderTimes,
allHolidayCount,remainderDays,nowDays);
if((remainderTimes > 0) && (remainderDays >= 0) &&((remainderDays - nowDays) >=0)){
this.getView().showTipNotification(message);
}else{
this.getView().showErrorNotification("探亲次数或探亲天数不足!"+message);
//取消提交操作
args.setCancel(true);
return;
}
}
//判断是否来往家居地
Boolean isHome = (Boolean)model.getValue(prefix+"_is_home");
if(isHome){
//获取当前人的往来家居地配置
QFilter[] visitSetFilterArray = new QFilter[1];
visitSetFilterArray[0] = new QFilter(prefix+"_user", QCP.equals, applierId);
DataSet homeDataSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
prefix+"_user_home_conf",
"id,zcgj_month_times as monthTime",
visitSetFilterArray, null
);
Integer monthTime = null;
for (Row row : homeDataSet) {
monthTime = row.getInteger("monthTime");
}
//获取申请日期
Date bizdate = (Date)model.getValue( "bizdate");
//获取申请人在月份的单据量
LocalDate firstDayOfMonth = getFirstDayOfMonth(bizdate);
LocalDate lastDayOfMonth = getLastDayOfMonth(bizdate);
QFilter[] filterArray = new QFilter[4];
//查询申请人下的今年的探亲差旅单据
filterArray[0] = new QFilter("bizdate", QCP.large_equals, firstDayOfMonth);
filterArray[1] = new QFilter("bizdate", QCP.less_equals, lastDayOfMonth);
filterArray[2] = new QFilter("applier", QCP.equals, applierId);
filterArray[3] = new QFilter(prefix+"_is_home", QCP.equals, true);
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_is_home as ishome",
filterArray, null
);
int goHomeCount = 0;
for (Row row : dateSet) {
Boolean ishome = row.getBoolean("ishome");
System.out.println(row.getString("billno"));
if(ishome){
goHomeCount++;
}
}
if(monthTime != null && monthTime != 0){
int monthVal = firstDayOfMonth.getMonth().getValue();
String message = String.format("请知悉:您每月共有%d次往来家居地报销次数在%d月中已进行过%d次来往家居地报销。",monthTime,monthVal,goHomeCount);
//this.getView().showSuccessNotification(message);
this.getView().showTipNotification(message);
}
}
}
}
super.beforeDoOperation(args);
}catch (Exception e){
log.error(e.getMessage());
this.getView().showErrorNotification("系统异常");
}
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
QFilter nameQFilterAccItem = new QFilter("number",QCP.equals,"FYXM004.999");
DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "number,name", new QFilter[]{nameQFilterAccItem});
this.getModel().setValue("expenseitem",dynamicObjectAccItem,0);
}
/**

View File

@ -0,0 +1,66 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.org.model.OrgTreeParam;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.org.OrgViewType;
import kd.hr.hbp.business.openservicehelper.odc.AdminOrgServiceHelper;
import kd.sdk.plugin.Plugin;
import kd.taxc.common.helper.OrgServiceHelper;
import java.util.*;
import java.util.stream.Collectors;
/**
* 报销单默认费用项目
*/
public class DefaultExpenseItemPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void afterCreateNewData(EventObject e) {
//中材矿山建设有限公司 10006431
//中材矿山建设有限公司本部 10006447
//中国建筑材料工业建设西安工程有限公司本部 10007186
//兖州中材建设有限公司本部 10006476
//中国非金属材料南京矿山工程有限公司本部 10006461
//天津矿山工程有限公司本部 10006939
//通过费用承担公司找到行政组织获取长名称排除编码为'10006447','10007186','10006476','10006461','10006939'
String rootOrgCode = "10006431";
super.afterCreateNewData(e);
DynamicObject costcompany = (DynamicObject)this.getModel().getValue("costcompany");
long id = costcompany.getLong("id");
List<String> orgNumList = new ArrayList<>();
orgNumList.add("10006447");
orgNumList.add("10007186");
orgNumList.add("10006476");
orgNumList.add("10006461");
orgNumList.add("10006939");
QFilter filterOrgDepId = new QFilter("number", QCP.in,orgNumList);
DynamicObject[] adminOrg1 = BusinessDataServiceHelper.load("bos_org", "number,name,fullname", new QFilter[]{filterOrgDepId});
Set<Long> idSet = Arrays.stream(adminOrg1).map(data -> data.getLong("id")).collect(Collectors.toSet());
//判断是不是在几家总部
if(!idSet.contains(id)){
QFilter filterOrgId = new QFilter("number", QCP.equals,rootOrgCode);//中材矿山建设有限公司
DynamicObject adminOrg = BusinessDataServiceHelper.loadSingle("bos_org", "number,name,fullname", new QFilter[]{filterOrgId});
long orgId = adminOrg.getLong("id");
List<Long> orgIds = new ArrayList<>(1);
//orgIds.add(1692204547985902592L);
orgIds.add(orgId);
List<Long> subOrgIds = OrgUnitServiceHelper.getAllSubordinateOrgs(1L, orgIds, true);
Set<Long> collect = subOrgIds.stream().filter(data -> !idSet.contains(id)).collect(Collectors.toSet());
if(collect.contains(id)){
QFilter nameQFilterAccItem = new QFilter("number", QCP.equals,"FYXM004.999");
DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "number,name", new QFilter[]{nameQFilterAccItem});
this.getModel().setValue("expenseitem",dynamicObjectAccItem,0);
}
}
}
}

View File

@ -10,6 +10,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
@ -33,57 +34,65 @@ public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn imp
IDataModel model = this.getModel();
ChangeData[] changeSet = e.getChangeSet();
DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue();
long id = newValue.getLong("id");
//获取地域详细信息
//bd_admindivision
DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country",
new QFilter[]{new QFilter("id", QCP.equals,id)});
if(cityObj!=null){
DynamicObject country = cityObj.getDynamicObject("country");
long countryId = country.getLong("id");
//获取所属国家
//bd_country
DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode",
new QFilter[]{new QFilter("id", QCP.equals,countryId)});
if(countryObj!=null){
String twocountrycode = countryObj.getString("twocountrycode");
String countname = countryObj.getString("name");
if(!"CN".equals(twocountrycode)){
DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_oversea_stays_limit",
"zcgj_district_f7,zcgj_country,zcgj_currency,zcgj_stays_criteria,zcgj_rate"
, new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)});
BigDecimal otherAmount = BigDecimal.ZERO;
BigDecimal cirtyAmount = BigDecimal.ZERO;
String currencyName = "";
String currencySign = "";
if(load == null || load.length<1){
// this.getView().showTipNotification("当前出差国家为:"+countname+",未设置住宿标准!");
}else{
Map<String,Object> map = new HashMap<>();
for (DynamicObject dynamicObject : load) {
DynamicObject zcgjCountry = dynamicObject.getDynamicObject("zcgj_country");
DynamicObject zcgjDistrictF7 = dynamicObject.getDynamicObject("zcgj_district_f7");
DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency");
BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria");
BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate");
currencyName = zcgjCurrency.getString("name");
if(zcgjDistrictF7 ==null ){
otherAmount = zcgjStaysCriteria.multiply(zcgjRate);
}else if(countryId == zcgjDistrictF7.getLong("id")){
cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate);
if(newValue!=null){
long id = newValue.getLong("id");
//获取地域详细信息
//bd_admindivision
DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country",
new QFilter[]{new QFilter("id", QCP.equals,id)});
if(cityObj!=null){
long cityId = cityObj.getLong("id");
DynamicObject country = cityObj.getDynamicObject("country");
long countryId = country.getLong("id");
//获取所属国家
//bd_country
DynamicObject countryObj = BusinessDataServiceHelper.loadSingle("bd_country", "number,name,twocountrycode",
new QFilter[]{new QFilter("id", QCP.equals,countryId)});
if(countryObj!=null){
String twocountrycode = countryObj.getString("twocountrycode");
String countname = countryObj.getString("name");
if(!"CN".equals(twocountrycode)){
DynamicObject[] load = BusinessDataServiceHelper.load("zcgj_oversea_stays_limit",
"zcgj_district_f7,zcgj_country,zcgj_currency,zcgj_stays_criteria,zcgj_rate"
, new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)});
BigDecimal otherAmount = BigDecimal.ZERO;
BigDecimal cirtyAmount = BigDecimal.ZERO;
BigDecimal rate = BigDecimal.ZERO;
String currencyName = "";
String currencySign = "";
if(load == null || load.length<1){
// this.getView().showTipNotification("当前出差国家为:"+countname+",未设置住宿标准!");
}else{
Map<String,Object> map = new HashMap<>();
for (DynamicObject dynamicObject : load) {
DynamicObject zcgjCountry = dynamicObject.getDynamicObject("zcgj_country");
DynamicObject zcgjDistrictF7 = dynamicObject.getDynamicObject("zcgj_district_f7");
DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency");
BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria");
BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate");
rate=zcgjRate;
currencyName = zcgjCurrency.getString("name");
if(zcgjDistrictF7 ==null ){
otherAmount = zcgjStaysCriteria.multiply(zcgjRate);
}else if(cityId == zcgjDistrictF7.getLong("id")){
cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate);
}
}
if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){
this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币)"+otherAmount.setScale(4, RoundingMode.HALF_UP)+"");
}else if(!BigDecimal.ZERO.equals(cirtyAmount) ){
this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币)"+cirtyAmount.setScale(4, RoundingMode.HALF_UP)+"");
}
}
if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){
//this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+otherAmount.setScale(2, RoundingMode.HALF_UP));
this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币)"+otherAmount.setScale(2, RoundingMode.HALF_UP)+"");
}else if(BigDecimal.ZERO.equals(otherAmount) && !BigDecimal.ZERO.equals(cirtyAmount) ){
//this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+cirtyAmount.setScale(2, RoundingMode.HALF_UP));
this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币)"+cirtyAmount.setScale(2, RoundingMode.HALF_UP)+"");
}
}
}
}
}
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("fs.properties");
System.out.println();
}
}
}

View File

@ -1,9 +1,8 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
package zcgj.zcdev.zcdev.fs.plugin.operate;
import kd.bos.algo.DataSet;
import kd.bos.algo.Row;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
@ -12,13 +11,11 @@ import kd.bos.entity.validate.AbstractValidator;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

View File

@ -1,31 +1,17 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
package zcgj.zcdev.zcdev.fs.plugin.operate;
import kd.bos.algo.DataSet;
import kd.bos.algo.Row;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.ExtendedDataEntity;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.operate.Submit;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.AddValidatorsEventArgs;
import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
/**
* 差旅报销单上浮20%控制

View File

@ -156,4 +156,25 @@ class ExpenseReport {
public void setTotal(BigDecimal total) {
this.total = total;
}
public Object[] toRow() {
return new Object[]{
this.reimburser,
this.billNumber,
this.happenDateStr,
this.businessEntertainment,
this.foreignEntertainment,
this.importantOfficial,
this.accommodation,
this.souvenirs,
this.other,
this.subtotal,
this.travel,
this.abroadTravel,
this.health,
this.correspondence,
this.training,
this.total
};
}
}

View File

@ -45,9 +45,9 @@ public class FeeDeductionRptQueryPlugin extends AbstractReportListDataPlugin {
}
}
break;
/*case DEV_KEY+"_query_org":
case DEV_KEY+"_query_org":
orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue()));
break;*/
break;
case DEV_KEY+"_query_year":
queryYear = filterItem.getDate();
break;
@ -76,9 +76,9 @@ public class FeeDeductionRptQueryPlugin extends AbstractReportListDataPlugin {
// 日期格式化
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
/*if(orgId==null ){
if(orgId==null ){
return resultDataSet;
}*/
}
List<QFilter> searchFilterList = new ArrayList<>();
// 查询条件
@ -93,6 +93,9 @@ public class FeeDeductionRptQueryPlugin extends AbstractReportListDataPlugin {
searchFilterList.add(new QFilter("tripentry.startdate", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("tripentry.startdate", QCP.less_equals, lastDay));
}
if(orgId!=null){
searchFilterList.add(new QFilter("company", QCP.equals, orgId));
}
List<String> billStatuslist = new ArrayList<>();
//billStatuslist.add("A"); //暂存
//billStatuslist.add("B"); //已提交

View File

@ -47,6 +47,7 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
Set<Long> applierId = new HashSet<>();
Long orgId = null;
Date queryYear = null;
boolean istax = false;
for (FilterItemInfo filterItem : filters) {
switch (filterItem.getPropName()) {
case DEV_KEY+"_query_users":
@ -63,6 +64,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
case DEV_KEY+"_query_org":
orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue()));
break;
case DEV_KEY+"_query_istax":
istax = filterItem.getBoolean();
break;
default:
break;
}
@ -107,7 +111,7 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
}
LocalDate localDate = dateToLocalDate(queryYear);
int year = localDate.getYear();
Set<Long> userSet = new HashSet<>();
// Map 来按照报销人单据编号费用发生日期分组
Map<String, ExpenseReport> reportMap = new LinkedHashMap<>();
for (Long userId : allUsersOfOrg) {
@ -127,11 +131,17 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
Date happendate = entry.getDate("happendate");//费用发生日期
String itemNumber = expenseitemObj.getString("number");//费用项目编码
String happendateStr = dateFormat.format(happendate);//费用发生日期str
BigDecimal expenseamount = entry.getBigDecimal("expenseamount");//报销金额
BigDecimal expenseamount = BigDecimal.ZERO;
if(istax){
expenseamount = entry.getBigDecimal("expenseamount");//报销金额
}else{
expenseamount = entry.getBigDecimal("orientryamount");//不含税金额
}
// 生成唯一的键报销人 + 单据编号 + 费用发生日期
String key = userId + "-" + billno + "-" + happendateStr;
userSet.add(userId);
// 根据键获取报表对象
ExpenseReport report = reportMap.get(key);
if (report == null) {
@ -198,9 +208,15 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
String happendateStr = dateFormat.format(happendate);//费用发生日期str
DynamicObjectCollection entryentity = entry.getDynamicObjectCollection("entryentity");
for (DynamicObject object : entryentity) {
BigDecimal orientryamount = object.getBigDecimal("orientryamount");//报销金额
BigDecimal orientryamount = BigDecimal.ZERO;
if(istax){
orientryamount = object.getBigDecimal("orientryamount");//报销金额
}else{
orientryamount = object.getBigDecimal("notaxamount");//不含税金额
}
// 生成唯一的键报销人 + 单据编号 + 费用发生日期
String key = userId + "-" + billno + "-" + happendateStr;
userSet.add(userId);
// 根据键获取报表对象
ExpenseReport report = reportMap.get(key);
if (report == null) {
@ -224,8 +240,20 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
//合计汇总
ExpenseReport totalReport = new ExpenseReport(null, null, null);
Set<String> strings = reportMap.keySet();
Map<Long,Map<String, ExpenseReport>> userIdDataMap = new HashMap<>();
//根据人员进行汇总
for (Long userId : userSet) {
for (String string : strings) {
if(string.startsWith(userId+"")){
// userIdDataMap.put(userId,reportMap.get(string));
}
}
}
ArrayList<ExpenseReport> reportsList = new ArrayList<>(reportMap.values());
// 打印每一行报表
for (ExpenseReport report : reportsList) {
Map<String, Object> userInfoByID = UserServiceHelper.getUserInfoByID(report.getReimburser());
String username = String.valueOf(userInfoByID.get("name"));//报销人
@ -282,22 +310,22 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
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();
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();
return resultDataSet;
@ -324,7 +352,8 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
//billStatuslist.add("H"); //废弃
billStatuslist.add("I"); //关闭
List<QFilter> searchFilterList = new ArrayList<>();
searchFilterList.add(new QFilter("applier", QCP.equals, userId));
//searchFilterList.add(new QFilter("applier", QCP.equals, userId));
searchFilterList.add(new QFilter("zcgj_costmanger", 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("billstatus", QCP.in, billStatuslist));//增加过滤
@ -333,7 +362,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
DEV_KEY+"_is_business_foreign,"+
"expenseentryentity.happendate," + //费用发生日期
"expenseentryentity.expenseitem," + //费用项目
"expenseentryentity.expenseamount ", searchFilterList.toArray(new QFilter [] {}));
"expenseentryentity.expenseamount, "+//报销金额(含税)
"expenseentryentity.orientryamount " //不含税金额
, searchFilterList.toArray(new QFilter [] {}));
return load;
}
@ -365,8 +396,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
"id,description,billno,expenseentryentity," +
DEV_KEY+"_is_business_foreign,"+
"id,applier,billno,tripentry.startdate,tripentry.entryentity," + //费用发生日期
"entryentity.orientryamount", //报销金额
searchFilterList.toArray(new QFilter [] {}));
"entryentity.orientryamount,"+ //报销金额
"entryentity.notaxamount", //不含税金额
searchFilterList.toArray(new QFilter [] {}));
return load;
}