1.功能开发

This commit is contained in:
zhangzhiguo 2025-01-09 20:12:17 +08:00
parent 2f17723ba5
commit 97fe253709
22 changed files with 414 additions and 181 deletions

View File

@ -0,0 +1,42 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.BasedataItem;
import kd.bos.entity.datamodel.events.QueryImportBasedataEventArgs;
import kd.bos.entity.plugin.AbstractDataModelPlugin;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 会计科目与费用项目映射表 自定义引入
*/
public class AccountsitemsmapImpPlugin extends AbstractBillPlugIn {
public static final String ACCOUNT_ITEM = "zcgj_account_item";
//最新科目表编码
public static final String ACCOUNT_TABLE_NUMBER ="0003";
@Override
public void queryImportBasedata(QueryImportBasedataEventArgs e) {
Map<BasedataItem, List<Object>> searchResult = e.getSearchResult();
for (Map.Entry<BasedataItem, List<Object>> baseDataItemListEntry : searchResult.entrySet()) {
BasedataItem basedataItem = baseDataItemListEntry.getKey();
if (basedataItem.getFieldKey().equals(ACCOUNT_ITEM)) {//判断当前基础资料是否为 会计科目
//遍历物料的内码根据内码拿到物料的数据包选择长度为 20 电风扇
for (int i = 0;i < baseDataItemListEntry.getValue().size();i++){
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(baseDataItemListEntry.getValue().get(i), basedataItem.getEntityNumber());
String tableNumber = ((DynamicObject) dynamicObject.get("accounttable")).getString("number");
if(ACCOUNT_TABLE_NUMBER.equals(tableNumber)){
baseDataItemListEntry.setValue(Collections.singletonList(baseDataItemListEntry.getValue().get(i)));//设置科目id
}
}
}
}
}
}

View File

@ -1,54 +1,46 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.ConfirmCallBackListener;
import kd.bos.form.MessageBoxOptions;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.EventObject;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
/**
* 往返家居工作日天数自动计算插件
* 费用报销单往返家居工作日天数自动计算插件
*/
public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void propertyChanged(PropertyChangedArgs e) {
String name = e.getProperty().getName();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
if(name.equals("zcgj_startdate") ||name.equals("zcgj_enddate")){
ChangeData[] changeSet = e.getChangeSet();
//获取分录
DynamicObject dataEntity = this.getModel().getDataEntity(true);
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity");
DynamicObject dynamicObject = dynamicObjectCollection.get(changeSet[0].getRowIndex());
Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate");
Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate");
if(zcgjEnddate!=null){
int workDays = calculateWorkdays(zcgjStartdate, zcgjEnddate);
int allDays = calculateDaysBetween(zcgjStartdate, zcgjEnddate);
dynamicObject.set("zcgj_homedaycount",workDays);
int day = allDays - workDays;
if(day>=0&&workDays>0){
dynamicObject.set("zcgj_kccbdaycount",day);
//当前切换选择的组织
Long currentOrgId = RequestContext.get().getOrgId();
if(OrgCheckUtils.isKS(currentOrgId)){
String name = e.getProperty().getName();
if(name.equals("zcgj_startdate") ||name.equals("zcgj_enddate")){
ChangeData[] changeSet = e.getChangeSet();
int rowIndex = changeSet[0].getRowIndex();
int count = calHomeentityDay(rowIndex);
this.getModel().setValue("zcgj_kccbdays",count);
}else if("zcgj_holiday_start_time".equals(name) || "zcgj_holiday_end_time".equals(name)){
Date zcgjStartdate = (Date)this.getModel().getValue("zcgj_holiday_start_time");
Date zcgjEnddate = (Date)this.getModel().getValue("zcgj_holiday_end_time");
if(zcgjStartdate!=null && zcgjEnddate!=null){
Set<LocalDate> datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate));
this.getModel().setValue("zcgj_kccbdays",datesExcludingWeekends.size());
}else{
dynamicObject.set("zcgj_kccbdaycount",0);
this.getModel().setValue("zcgj_kccbdays",null);
}
int allHomeCount = 0;
for (DynamicObject entry : dynamicObjectCollection) {
allHomeCount += entry.getInt("zcgj_kccbdaycount");
}
this.getModel().setValue("zcgj_kccbdays",allHomeCount);
this.getView().updateView("zcgj_homeentity");
}
}
super.propertyChanged(e);
@ -59,7 +51,7 @@ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plug
public void registerListener(EventObject e) {
super.registerListener(e);
//监听工具栏按钮点击事件
//this.addItemClickListeners("zcgj_hometoolbarap");
this.addItemClickListeners("zcgj_hometoolbarap");
}
@Override
@ -78,57 +70,89 @@ public class AutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plug
}
}
// 计算工作日天数
public static int calculateWorkdays(Date startDate, Date endDate) {
// 使用 Calendar 类进行日期操作
Calendar startCalendar = Calendar.getInstance();
Calendar endCalendar = Calendar.getInstance();
startCalendar.setTime(startDate);
endCalendar.setTime(endDate);
// 特殊情况处理如果开始日期是周五且结束日期是周一返回0
if (startCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY &&
endCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
return 0;
public int calHomeentityDay(int rowIndex){
//获取分录
DynamicObject dataEntity = this.getModel().getDataEntity(true);
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity");
DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex);
Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate");
Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate");
int allHomeCount = 0;
if(zcgjStartdate!=null && zcgjEnddate!=null){
Set<LocalDate> datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate));
allHomeCount = datesExcludingWeekends.size();
this.getModel().setValue("zcgj_kccbdaycount",allHomeCount);
}
return allHomeCount;
}
// 计算工作日天数
int workdays = 0;
// 从开始日期到结束日期遍历
while (!startCalendar.after(endCalendar)) {
int dayOfWeek = startCalendar.get(Calendar.DAY_OF_WEEK);
// 只统计周一到周五排除周六和周日
if (dayOfWeek != Calendar.SATURDAY && dayOfWeek != Calendar.SUNDAY) {
workdays++;
public Set<LocalDate> calHomeentityDay(){
//获取分录
DynamicObject dataEntity = this.getModel().getDataEntity(true);
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity");
Set<LocalDate> addDateSet = new HashSet<>();
for (DynamicObject dynamicObject : dynamicObjectCollection) {
Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate");
Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate");
if(zcgjStartdate!=null && zcgjEnddate!=null){
Set<LocalDate> datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate));
addDateSet.addAll(datesExcludingWeekends);
}
startCalendar.add(Calendar.DAY_OF_MONTH, 1); // 移动到下一天
}
return addDateSet;
}
//获取开始结束时间
public static Set<LocalDate> getStartAndEnd(LocalDate startDate, LocalDate endDate) {
Set<LocalDate> result = new HashSet<>();
// 判断开始日期和结束日期是否为周末
if (!isWeekend(startDate)) {
result.add(startDate);
}
return workdays;
if (!isWeekend(endDate)) {
result.add(endDate);
}
return result;
}
// 计算开始日期和结束日期之间的天数
public static int calculateDaysBetween(Date startDate, Date endDate) {
// 日期格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//去除开始日期结束日期移除周六日
public static Set<LocalDate> getDatesExcludingWeekends(LocalDate startDate, LocalDate endDate) {
Set<LocalDate> result = new HashSet<>();
// 使用 Calendar 类来处理日期
Calendar startCalendar = Calendar.getInstance();
Calendar endCalendar = Calendar.getInstance();
// 计算从开始日期到结束日期之间的日期
LocalDate currentDate = startDate.plusDays(1); // 排除开始日期
LocalDate lastDate = endDate.minusDays(1); // 排除结束日期
startCalendar.setTime(startDate);
endCalendar.setTime(endDate);
// 遍历日期范围
while (!currentDate.isAfter(lastDate)) {
if (!isWeekend(currentDate)) {
result.add(currentDate);
}
currentDate = currentDate.plusDays(1);
}
// 计算两个日期之间的天数差
long startMillis = startCalendar.getTimeInMillis();
long endMillis = endCalendar.getTimeInMillis();
// 计算天数差注意加1天因为天数是区间的数量包含开始日期
long diffMillis = endMillis - startMillis;
int diffDays = (int) (diffMillis / (24 * 60 * 60 * 1000));
return diffDays + 1; // 因为差值是天数之间的差包含开始日期
return result;
}
private static boolean isWeekend(LocalDate date) {
return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY;
}
/**
* java.util.Date 转换为 java.time.LocalDate
* @param date java.util.Date
* @return java.time.LocalDate
*/
public static LocalDate dateToLocalDate(Date date) {
if (date == null) {
throw new IllegalArgumentException("日期不能为 null");
}
return date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
}
}

View File

@ -12,6 +12,7 @@ import kd.bos.exception.KDBizException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.servicehelper.DispatchServiceHelper;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.Arrays;
import java.util.List;

View File

@ -13,6 +13,7 @@ import kd.bos.exception.KDBizException;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.servicehelper.DispatchServiceHelper;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.Arrays;
import java.util.List;

View File

@ -4,16 +4,13 @@ import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.ConfirmCallBackListener;
import kd.bos.form.MessageBoxOptions;
import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.EventObject;

View File

@ -11,6 +11,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.EventObject;
@ -69,10 +70,13 @@ public class CostcompanyDefaultPlugin extends AbstractBillPlugIn implements Plu
QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number"));
DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter});
for (DynamicObject dynamicObject : dynamicObjectCollection) {
if(dynamicObjectAccItem!=null){
if(dynamicObjectAccItem!=null && dynamicObjectAccItem.length>0){
dynamicObject.set("std_entrycostcenter",dynamicObjectAccItem[0]);
getView().updateView("expenseentryentity");
}else{
dynamicObject.set("std_entrycostcenter",null);
}
getView().updateView("expenseentryentity");
}
}
}
@ -124,7 +128,7 @@ public class CostcompanyDefaultPlugin extends AbstractBillPlugIn implements Plu
//bos_costcenter
QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number"));
DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter});
if(dynamicObjectAccItem!=null){
if(dynamicObjectAccItem!=null && !dynamicObjectCollection.isEmpty()){
DynamicObject dynamicObject = dynamicObjectCollection.get(dynamicObjectCollection.size() - 1);
dynamicObject.set("std_entrycostcenter",dynamicObjectAccItem[0]);
}

View File

@ -21,16 +21,11 @@ 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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.bos.tree.TreeFilterParameter;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 借款单会计科目与费用项目关联插件

View File

@ -21,15 +21,11 @@ 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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 费用报销单会计科目与费用项目关联插件

View File

@ -3,13 +3,6 @@ package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.operate.Submit;
import kd.bos.form.FormShowParameter;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
@ -18,17 +11,11 @@ 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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 国外住宿费标准

View File

@ -2,35 +2,19 @@ package zcgj.zcdev.zcdev.fs.plugin.form;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.CloneUtils;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.operate.Submit;
import kd.bos.form.CloseCallBack;
import kd.bos.form.ShowFormHelper;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.field.BasedataEdit;
import kd.bos.form.field.events.AfterF7SelectEvent;
import kd.bos.form.field.events.AfterF7SelectListener;
import kd.bos.form.field.events.BeforeF7SelectEvent;
import kd.bos.form.field.events.BeforeF7SelectListener;
import kd.bos.list.ListShowParameter;
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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
/**
* 预付单去年合同提醒插件

View File

@ -21,15 +21,11 @@ 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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 预付单会计科目与费用项目关联插件

View File

@ -8,20 +8,13 @@ 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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 对公报销单去年合同提醒插件

View File

@ -21,15 +21,11 @@ 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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 对公报销单会计科目与费用项目关联插件

View File

@ -0,0 +1,209 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
import com.alibaba.druid.util.StringUtils;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.control.Button;
import kd.bos.form.control.Control;
import kd.bos.form.control.events.ItemClickEvent;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
/**
* 差旅报销单往返家居工作日天数自动计算插件
*/
public class TriprAutoCalWorkingDaysPlugin extends AbstractBillPlugIn implements Plugin {
@Override
public void propertyChanged(PropertyChangedArgs e) {
//当前切换选择的组织
Object company = this.getModel().getValue("costcompany");//核算组织
Long currentOrgId = RequestContext.get().getOrgId();
DynamicObject companyObj = (DynamicObject)company;
Long companyId = companyObj.getLong("id");
if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){
String name = e.getProperty().getName();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
if(name.equals("zcgj_startdate") ||name.equals("zcgj_enddate")){
ChangeData[] changeSet = e.getChangeSet();
int rowIndex = changeSet[0].getRowIndex();
calHomeentityDay(rowIndex);
Set<LocalDate> allSet = new HashSet<>();
Set<LocalDate> localDates1 = calHomeentityDay();
Set<LocalDate> localDates2 = calTripentryDay();
allSet.addAll(localDates1);
allSet.addAll(localDates2);
this.getModel().setValue("zcgj_kccbdays",allSet.size());
} else if(name.equals("startdate") ||name.equals("enddate")){
// 计算结果
Set<LocalDate> allSet = new HashSet<>();
Set<LocalDate> localDates1 = calHomeentityDay();
Set<LocalDate> localDates2 = calTripentryDay();
allSet.addAll(localDates1);
allSet.addAll(localDates2);
this.getModel().setValue("zcgj_kccbdays",allSet.size());
}
}
super.propertyChanged(e);
}
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
Object company = this.getModel().getValue("costcompany");//核算组织
if(company!=null){
Long currentOrgId = RequestContext.get().getOrgId();
DynamicObject companyObj = (DynamicObject)company;
Long companyId = companyObj.getLong("id");
String companyNumber = companyObj.getString("number");
if(OrgCheckUtils.isKS(currentOrgId) && OrgCheckUtils.isKS(companyId)){
//监听工具栏按钮点击事件
this.addItemClickListeners("zcgj_hometoolbarap");
// 按钮点击
Button button = this.getView().getControl("deltripentry");
button.addClickListener(this);
}
}
}
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
if (evt.getItemKey().equals("zcgj_delhome")) {
Set<LocalDate> allSet = new HashSet<>();
Set<LocalDate> localDates1 = calHomeentityDay();
Set<LocalDate> localDates2 = calTripentryDay();
allSet.addAll(localDates1);
allSet.addAll(localDates2);
this.getModel().setValue("zcgj_kccbdays",allSet.size());
getView().updateView();
}
}
@Override
public void click(EventObject evt) {
Control source = (Control)evt.getSource();
if (StringUtils.equals("deltripentry", source.getKey())){
Set<LocalDate> allSet = new HashSet<>();
Set<LocalDate> localDates1 = calHomeentityDay();
Set<LocalDate> localDates2 = calTripentryDay();
allSet.addAll(localDates1);
allSet.addAll(localDates2);
this.getModel().setValue("zcgj_kccbdays",allSet.size());
}
}
public int calHomeentityDay(int rowIndex){
//获取分录
DynamicObject dataEntity = this.getModel().getDataEntity(true);
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity");
DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex);
Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate");
Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate");
int allHomeCount = 0;
if(zcgjStartdate!=null && zcgjEnddate!=null){
Set<LocalDate> datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate));
allHomeCount = datesExcludingWeekends.size();
this.getModel().setValue("zcgj_kccbdaycount",allHomeCount);
}
return allHomeCount;
}
public Set<LocalDate> calHomeentityDay(){
//获取分录
DynamicObject dataEntity = this.getModel().getDataEntity(true);
DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection("zcgj_homeentity");
Set<LocalDate> addDateSet = new HashSet<>();
for (DynamicObject dynamicObject : dynamicObjectCollection) {
Date zcgjStartdate = dynamicObject.getDate("zcgj_startdate");
Date zcgjEnddate = dynamicObject.getDate("zcgj_enddate");
if(zcgjStartdate!=null && zcgjEnddate!=null){
Set<LocalDate> datesExcludingWeekends = getDatesExcludingWeekends(dateToLocalDate(zcgjStartdate), dateToLocalDate(zcgjEnddate));
addDateSet.addAll(datesExcludingWeekends);
}
}
return addDateSet;
}
public Set<LocalDate> calTripentryDay(){
int allHomeCount = 0;
DynamicObjectCollection dynamicObjectCollection = this.getModel().getDataEntity()
.getDynamicObjectCollection("tripentry");
Set<LocalDate> addDateSet = new HashSet<>();
for (DynamicObject dynamicObject : dynamicObjectCollection) {
Date startdate = dynamicObject.getDate("startdate");
Date enddate = dynamicObject.getDate("enddate");
if(startdate!=null && enddate!=null){
Set<LocalDate> datesExcludingWeekends = getStartAndEnd(dateToLocalDate(startdate), dateToLocalDate(enddate));
addDateSet.addAll(datesExcludingWeekends);
}
}
return addDateSet;
}
//获取开始结束时间
public static Set<LocalDate> getStartAndEnd(LocalDate startDate, LocalDate endDate) {
Set<LocalDate> result = new HashSet<>();
// 判断开始日期和结束日期是否为周末
if (!isWeekend(startDate)) {
result.add(startDate);
}
if (!isWeekend(endDate)) {
result.add(endDate);
}
return result;
}
//去除开始日期结束日期移除周六日
public static Set<LocalDate> getDatesExcludingWeekends(LocalDate startDate, LocalDate endDate) {
Set<LocalDate> result = new HashSet<>();
// 计算从开始日期到结束日期之间的日期
LocalDate currentDate = startDate.plusDays(1); // 排除开始日期
LocalDate lastDate = endDate.minusDays(1); // 排除结束日期
// 遍历日期范围
while (!currentDate.isAfter(lastDate)) {
if (!isWeekend(currentDate)) {
result.add(currentDate);
}
currentDate = currentDate.plusDays(1);
}
return result;
}
private static boolean isWeekend(LocalDate date) {
return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY;
}
/**
* java.util.Date 转换为 java.time.LocalDate
* @param date java.util.Date
* @return java.time.LocalDate
*/
public static LocalDate dateToLocalDate(Date date) {
if (date == null) {
throw new IllegalArgumentException("日期不能为 null");
}
return date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
}
}

View File

@ -11,6 +11,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.util.EventObject;
@ -65,7 +66,11 @@ public class TriprCostcompanyDefaultPlugin extends AbstractBillPlugIn implements
if(costcompanyObj!=null){
QFilter numberFilter = new QFilter("number",QCP.equals,costcompanyObj.getString("number"));
DynamicObject[] dynamicObjectAccItem = BusinessDataServiceHelper.load("bos_costcenter", "number,name", new QFilter[]{numberFilter});
this.getModel().setValue("std_costcenter",dynamicObjectAccItem[0]);
if(dynamicObjectAccItem != null && dynamicObjectAccItem.length>0){
this.getModel().setValue("std_costcenter",dynamicObjectAccItem[0]);
}else{
this.getModel().setValue("std_costcenter",null);
}
getView().updateView("std_costcenter");
}
}

View File

@ -9,15 +9,14 @@ import kd.bos.entity.datamodel.events.PropertyChangedArgs;
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.user.UserServiceHelper;
import kd.sdk.plugin.Plugin;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
/**
* 差旅报销单国外住宿标准提醒插件

View File

@ -15,7 +15,7 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.bos.util.StringUtils;
import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;

View File

@ -11,11 +11,9 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
@ -23,7 +21,6 @@ import java.time.Month;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
* 费用报销单探亲检查

View File

@ -15,13 +15,12 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import kd.bos.util.StringUtils;
import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

View File

@ -10,19 +10,11 @@ import kd.bos.entity.plugin.PreparePropertysEventArgs;
import kd.bos.entity.validate.AbstractValidator;
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.org.OrgUnitServiceHelper;
import kd.bos.servicehelper.user.UserServiceHelper;
import zcgj.zcdev.zcdev.fs.plugin.form.OrgCheckUtils;
import zcgj.zcdev.zcdev.fs.utils.OrgCheckUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 差旅报销单上浮20%控制

View File

@ -116,15 +116,14 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin {
for (Row row : tripreimbursebill) {
String billno = row.getString("billno");
int kccbdays = row.getInteger("kccbdays");//扣除餐补天数周六日节假日
String startdateStr = dateFormat.format(row.getDate("startdate"));//
LocalDate bizdate = dateToLocalDate(row.getDate("bizdate"));
/* String startdateStr = dateFormat.format(row.getDate("startdate"));//
String enddateStr = dateFormat.format(row.getDate("enddate"));
String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份
int homedaycount = row.getInteger("homedaycount");//工作天日数
LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth"));
monthDaysMap.put(bxmonth.getMonth().getValue(),
monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount);
int homedaycount = row.getInteger("homedaycount");//工作天日数*/
//LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth"));
monthDaysMap.put(bizdate.getMonth().getValue(),
monthDaysMap.getOrDefault(bizdate.getMonth().getValue(), 0) + kccbdays);
}
@ -132,15 +131,14 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin {
for (Row row : dailyreimbursebill) {
String billno = row.getString("billno");
int kccbdays = row.getInteger("kccbdays");//扣除餐补天数周六日节假日
String startdateStr = dateFormat.format(row.getDate("startdate"));//
/*String startdateStr = dateFormat.format(row.getDate("startdate"));//
String enddateStr = dateFormat.format(row.getDate("enddate"));
String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份
int homedaycount = row.getInteger("homedaycount");//工作天日数
LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth"));
monthDaysMap.put(bxmonth.getMonth().getValue(),
monthDaysMap.getOrDefault(bxmonth.getMonth().getValue(), 0) + homedaycount);
String bxmonthStr = dateFormat.format(row.getDate("bxmonth"));//归属月份*/
// int homedaycount = row.getInteger("homedaycount");//工作天日数
//LocalDate bxmonth = dateToLocalDate(row.getDate("bxmonth"));
LocalDate bizdate = dateToLocalDate(row.getDate("bizdate"));
monthDaysMap.put(bizdate.getMonth().getValue(),
monthDaysMap.getOrDefault(bizdate.getMonth().getValue(), 0) + kccbdays);
}
}
@ -196,15 +194,24 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin {
searchFilterList.add(new QFilter("applier", QCP.equals, applierId));
searchFilterList.add(new QFilter( "zcgj_is_include_home", QCP.equals, true));
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));
searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDay));
DataSet dateSet = QueryServiceHelper.queryDataSet(
searchFilterList.add( new QFilter("bizdate", QCP.large_equals, firstDay));
searchFilterList.add( new QFilter("bizdate", QCP.less_equals, lastDay));
//searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay));
//searchFilterList.add(new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDay));
/*DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_tripreimbursebill",
"id,billno,zcgj_kccbdays as kccbdays,zcgj_homeentity,zcgj_homeentity.zcgj_bxmonth as bxmonth," +
"zcgj_homeentity.zcgj_startdate as startdate,zcgj_homeentity.zcgj_enddate as enddate," +
"zcgj_homeentity.zcgj_homebz as homebz,zcgj_homeentity.zcgj_homedaycount as homedaycount",
searchFilterList.toArray(new QFilter [] {}), null
);*/
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_tripreimbursebill",
"id,billno,zcgj_kccbdays as kccbdays,bizdate",
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}
@ -233,9 +240,12 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin {
List<QFilter> searchFilterList = new ArrayList<>();
//查询申请人下的今年的探亲差旅单据
searchFilterList.add(new QFilter("applier", QCP.equals, applierId));
searchFilterList.add(new QFilter( "zcgj_is_home", QCP.equals, true));
searchFilterList.add(new QFilter( "zcgj_is_home", QCP.equals, true)
.or(new QFilter( "zcgj_is_visit", QCP.equals, true)));
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));
searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay));
searchFilterList.add( new QFilter("bizdate", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("bizdate", QCP.less_equals, lastDay));
/*searchFilterList.add( new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.large_equals, firstDay));
searchFilterList.add(new QFilter("zcgj_homeentity.zcgj_bxmonth", QCP.less_equals, lastDay));
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
@ -244,6 +254,12 @@ public class EmpTravelRptQueryPlugin extends AbstractReportListDataPlugin {
"zcgj_homeentity.zcgj_startdate as startdate,zcgj_homeentity.zcgj_enddate as enddate," +
"zcgj_homeentity.zcgj_homebz as homebz,zcgj_homeentity.zcgj_homedaycount as homedaycount",
searchFilterList.toArray(new QFilter [] {}), null
);*/
DataSet dateSet = QueryServiceHelper.queryDataSet(
this.getClass().getName(),
"er_dailyreimbursebill",
"id,billno,zcgj_kccbdays as kccbdays,bizdate",
searchFilterList.toArray(new QFilter [] {}), null
);
return dateSet;
}

View File

@ -1,4 +1,4 @@
package zcgj.zcdev.zcdev.fs.plugin.form;
package zcgj.zcdev.zcdev.fs.utils;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.orm.query.QCP;