Compare commits
2 Commits
28ee9e2915
...
108b3ebbfd
Author | SHA1 | Date |
---|---|---|
|
108b3ebbfd | |
|
74d5389012 |
|
@ -5,12 +5,16 @@ import kd.bos.algo.Row;
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.entity.datamodel.IDataModel;
|
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.entity.operate.Submit;
|
||||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
import kd.bos.logging.LogFactory;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.QueryServiceHelper;
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
@ -22,6 +26,7 @@ import java.time.temporal.ChronoUnit;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.EventObject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,247 +40,24 @@ public class DailyreimbursVisitCheckPlugin extends AbstractBillPlugIn implemen
|
||||||
private static final String prefix ="zcgj";
|
private static final String prefix ="zcgj";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
public void afterAddRow(AfterAddRowEventArgs e) {
|
||||||
try{
|
super.afterAddRow(e);
|
||||||
if((args.getSource() instanceof Submit) ){
|
//RowDataEntity[] rowDataEntities = e.getRowDataEntities();
|
||||||
Submit source = (Submit)args.getSource();
|
//for (RowDataEntity rowDataEntity : rowDataEntities) {
|
||||||
if(source.getOperateKey().equals("submit") ){
|
// int rowIndex = rowDataEntity.getRowIndex();
|
||||||
IDataModel model = this.getModel();
|
// QFilter nameQFilterAccItem = new QFilter("number",QCP.equals,"FYXM004.999");
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
|
// DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "number,name", new QFilter[]{nameQFilterAccItem});
|
||||||
//报销人
|
// this.getModel().setValue("expenseitem",dynamicObjectAccItem,rowIndex);
|
||||||
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");
|
|
||||||
|
|
||||||
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);
|
@Override
|
||||||
}catch (Exception e){
|
public void afterCreateNewData(EventObject e) {
|
||||||
log.error(e.getMessage());
|
super.afterCreateNewData(e);
|
||||||
this.getView().showErrorNotification("系统异常");
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -33,12 +34,14 @@ public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn imp
|
||||||
IDataModel model = this.getModel();
|
IDataModel model = this.getModel();
|
||||||
ChangeData[] changeSet = e.getChangeSet();
|
ChangeData[] changeSet = e.getChangeSet();
|
||||||
DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue();
|
DynamicObject newValue = (DynamicObject)changeSet[0].getNewValue();
|
||||||
|
if(newValue!=null){
|
||||||
long id = newValue.getLong("id");
|
long id = newValue.getLong("id");
|
||||||
//获取地域详细信息
|
//获取地域详细信息
|
||||||
//bd_admindivision
|
//bd_admindivision
|
||||||
DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country",
|
DynamicObject cityObj = BusinessDataServiceHelper.loadSingle("bd_admindivision", "country",
|
||||||
new QFilter[]{new QFilter("id", QCP.equals,id)});
|
new QFilter[]{new QFilter("id", QCP.equals,id)});
|
||||||
if(cityObj!=null){
|
if(cityObj!=null){
|
||||||
|
long cityId = cityObj.getLong("id");
|
||||||
DynamicObject country = cityObj.getDynamicObject("country");
|
DynamicObject country = cityObj.getDynamicObject("country");
|
||||||
long countryId = country.getLong("id");
|
long countryId = country.getLong("id");
|
||||||
//获取所属国家
|
//获取所属国家
|
||||||
|
@ -54,6 +57,7 @@ public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn imp
|
||||||
, new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)});
|
, new QFilter[]{new QFilter("zcgj_country", QCP.equals, countryId)});
|
||||||
BigDecimal otherAmount = BigDecimal.ZERO;
|
BigDecimal otherAmount = BigDecimal.ZERO;
|
||||||
BigDecimal cirtyAmount = BigDecimal.ZERO;
|
BigDecimal cirtyAmount = BigDecimal.ZERO;
|
||||||
|
BigDecimal rate = BigDecimal.ZERO;
|
||||||
String currencyName = "";
|
String currencyName = "";
|
||||||
String currencySign = "";
|
String currencySign = "";
|
||||||
if(load == null || load.length<1){
|
if(load == null || load.length<1){
|
||||||
|
@ -66,24 +70,29 @@ public class TripreimbursebillAbroadAlertedPlugin extends AbstractBillPlugIn imp
|
||||||
DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency");
|
DynamicObject zcgjCurrency = dynamicObject.getDynamicObject("zcgj_currency");
|
||||||
BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria");
|
BigDecimal zcgjStaysCriteria = dynamicObject.getBigDecimal("zcgj_stays_criteria");
|
||||||
BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate");
|
BigDecimal zcgjRate = dynamicObject.getBigDecimal("zcgj_rate");
|
||||||
|
rate=zcgjRate;
|
||||||
currencyName = zcgjCurrency.getString("name");
|
currencyName = zcgjCurrency.getString("name");
|
||||||
if(zcgjDistrictF7 ==null ){
|
if(zcgjDistrictF7 ==null ){
|
||||||
otherAmount = zcgjStaysCriteria.multiply(zcgjRate);
|
otherAmount = zcgjStaysCriteria.multiply(zcgjRate);
|
||||||
}else if(countryId == zcgjDistrictF7.getLong("id")){
|
}else if(cityId == zcgjDistrictF7.getLong("id")){
|
||||||
cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate);
|
cirtyAmount = zcgjStaysCriteria.multiply(zcgjRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){
|
if(!BigDecimal.ZERO.equals(otherAmount) && BigDecimal.ZERO.equals(cirtyAmount) ){
|
||||||
//this.getView().showTipNotification("当前出差国家为:"+countname+",币别为:"+currencyName+",住宿标准为:"+otherAmount.setScale(2, RoundingMode.HALF_UP));
|
this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币):"+otherAmount.setScale(4, RoundingMode.HALF_UP)+"元");
|
||||||
this.getView().showTipNotification("当前出差国家为:"+countname+",住宿标准为(人民币):"+otherAmount.setScale(2, RoundingMode.HALF_UP)+"元");
|
}else if(!BigDecimal.ZERO.equals(cirtyAmount) ){
|
||||||
}else if(BigDecimal.ZERO.equals(otherAmount) && !BigDecimal.ZERO.equals(cirtyAmount) ){
|
this.getView().showTipNotification("当前出差国家为:"+countname+",汇率为:"+rate.setScale(4, RoundingMode.HALF_UP)+",住宿标准每人每天为(人民币):"+cirtyAmount.setScale(4, RoundingMode.HALF_UP)+"元");
|
||||||
//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();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.DataSet;
|
||||||
import kd.bos.algo.Row;
|
import kd.bos.algo.Row;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
||||||
import kd.bos.entity.ExtendedDataEntity;
|
import kd.bos.entity.ExtendedDataEntity;
|
||||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
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.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.QueryServiceHelper;
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.Month;
|
import java.time.Month;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
|
@ -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.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
import kd.bos.entity.ExtendedDataEntity;
|
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.AbstractOperationServicePlugIn;
|
||||||
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||||
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
||||||
import kd.bos.entity.validate.AbstractValidator;
|
import kd.bos.entity.validate.AbstractValidator;
|
||||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
||||||
import kd.bos.logging.Log;
|
import kd.bos.logging.Log;
|
||||||
import kd.bos.logging.LogFactory;
|
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.math.BigDecimal;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 差旅报销单上浮20%控制
|
* 差旅报销单上浮20%控制
|
|
@ -156,4 +156,25 @@ class ExpenseReport {
|
||||||
public void setTotal(BigDecimal total) {
|
public void setTotal(BigDecimal total) {
|
||||||
this.total = 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
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -45,9 +45,9 @@ public class FeeDeductionRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*case DEV_KEY+"_query_org":
|
case DEV_KEY+"_query_org":
|
||||||
orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue()));
|
orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue()));
|
||||||
break;*/
|
break;
|
||||||
case DEV_KEY+"_query_year":
|
case DEV_KEY+"_query_year":
|
||||||
queryYear = filterItem.getDate();
|
queryYear = filterItem.getDate();
|
||||||
break;
|
break;
|
||||||
|
@ -76,9 +76,9 @@ public class FeeDeductionRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
|
|
||||||
// 日期格式化
|
// 日期格式化
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
|
||||||
/*if(orgId==null ){
|
if(orgId==null ){
|
||||||
return resultDataSet;
|
return resultDataSet;
|
||||||
}*/
|
}
|
||||||
List<QFilter> searchFilterList = new ArrayList<>();
|
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.large_equals, firstDay));
|
||||||
searchFilterList.add(new QFilter("tripentry.startdate", QCP.less_equals, lastDay));
|
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<>();
|
List<String> billStatuslist = new ArrayList<>();
|
||||||
//billStatuslist.add("A"); //暂存
|
//billStatuslist.add("A"); //暂存
|
||||||
//billStatuslist.add("B"); //已提交
|
//billStatuslist.add("B"); //已提交
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
Set<Long> applierId = new HashSet<>();
|
Set<Long> applierId = new HashSet<>();
|
||||||
Long orgId = null;
|
Long orgId = null;
|
||||||
Date queryYear = null;
|
Date queryYear = null;
|
||||||
|
boolean istax = false;
|
||||||
for (FilterItemInfo filterItem : filters) {
|
for (FilterItemInfo filterItem : filters) {
|
||||||
switch (filterItem.getPropName()) {
|
switch (filterItem.getPropName()) {
|
||||||
case DEV_KEY+"_query_users":
|
case DEV_KEY+"_query_users":
|
||||||
|
@ -63,6 +64,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
case DEV_KEY+"_query_org":
|
case DEV_KEY+"_query_org":
|
||||||
orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue()));
|
orgId = (filterItem.getValue() == null) ? null :Long.valueOf(String.valueOf(((DynamicObject) filterItem.getValue()).getPkValue()));
|
||||||
break;
|
break;
|
||||||
|
case DEV_KEY+"_query_istax":
|
||||||
|
istax = filterItem.getBoolean();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +111,7 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
}
|
}
|
||||||
LocalDate localDate = dateToLocalDate(queryYear);
|
LocalDate localDate = dateToLocalDate(queryYear);
|
||||||
int year = localDate.getYear();
|
int year = localDate.getYear();
|
||||||
|
Set<Long> userSet = new HashSet<>();
|
||||||
// 用 Map 来按照报销人、单据编号、费用发生日期分组
|
// 用 Map 来按照报销人、单据编号、费用发生日期分组
|
||||||
Map<String, ExpenseReport> reportMap = new LinkedHashMap<>();
|
Map<String, ExpenseReport> reportMap = new LinkedHashMap<>();
|
||||||
for (Long userId : allUsersOfOrg) {
|
for (Long userId : allUsersOfOrg) {
|
||||||
|
@ -127,11 +131,17 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
Date happendate = entry.getDate("happendate");//费用发生日期
|
Date happendate = entry.getDate("happendate");//费用发生日期
|
||||||
String itemNumber = expenseitemObj.getString("number");//费用项目编码
|
String itemNumber = expenseitemObj.getString("number");//费用项目编码
|
||||||
String happendateStr = dateFormat.format(happendate);//费用发生日期str
|
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;
|
String key = userId + "-" + billno + "-" + happendateStr;
|
||||||
|
userSet.add(userId);
|
||||||
// 根据键获取报表对象
|
// 根据键获取报表对象
|
||||||
ExpenseReport report = reportMap.get(key);
|
ExpenseReport report = reportMap.get(key);
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
|
@ -198,9 +208,15 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
String happendateStr = dateFormat.format(happendate);//费用发生日期str
|
String happendateStr = dateFormat.format(happendate);//费用发生日期str
|
||||||
DynamicObjectCollection entryentity = entry.getDynamicObjectCollection("entryentity");
|
DynamicObjectCollection entryentity = entry.getDynamicObjectCollection("entryentity");
|
||||||
for (DynamicObject object : 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;
|
String key = userId + "-" + billno + "-" + happendateStr;
|
||||||
|
userSet.add(userId);
|
||||||
// 根据键获取报表对象
|
// 根据键获取报表对象
|
||||||
ExpenseReport report = reportMap.get(key);
|
ExpenseReport report = reportMap.get(key);
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
|
@ -224,8 +240,20 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
//合计汇总
|
//合计汇总
|
||||||
ExpenseReport totalReport = new ExpenseReport(null, null, null);
|
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());
|
ArrayList<ExpenseReport> reportsList = new ArrayList<>(reportMap.values());
|
||||||
// 打印每一行报表
|
// 打印每一行报表
|
||||||
|
|
||||||
for (ExpenseReport report : reportsList) {
|
for (ExpenseReport report : reportsList) {
|
||||||
Map<String, Object> userInfoByID = UserServiceHelper.getUserInfoByID(report.getReimburser());
|
Map<String, Object> userInfoByID = UserServiceHelper.getUserInfoByID(report.getReimburser());
|
||||||
String username = String.valueOf(userInfoByID.get("name"));//报销人
|
String username = String.valueOf(userInfoByID.get("name"));//报销人
|
||||||
|
@ -324,7 +352,8 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
//billStatuslist.add("H"); //废弃
|
//billStatuslist.add("H"); //废弃
|
||||||
billStatuslist.add("I"); //关闭
|
billStatuslist.add("I"); //关闭
|
||||||
List<QFilter> searchFilterList = new ArrayList<>();
|
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.large_equals, firstDay));
|
||||||
searchFilterList.add(new QFilter("expenseentryentity.happendate", QCP.less_equals, lastDay));
|
searchFilterList.add(new QFilter("expenseentryentity.happendate", QCP.less_equals, lastDay));
|
||||||
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));//增加过滤
|
searchFilterList.add(new QFilter("billstatus", QCP.in, billStatuslist));//增加过滤
|
||||||
|
@ -333,7 +362,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
DEV_KEY+"_is_business_foreign,"+
|
DEV_KEY+"_is_business_foreign,"+
|
||||||
"expenseentryentity.happendate," + //费用发生日期
|
"expenseentryentity.happendate," + //费用发生日期
|
||||||
"expenseentryentity.expenseitem," + //费用项目
|
"expenseentryentity.expenseitem," + //费用项目
|
||||||
"expenseentryentity.expenseamount ", searchFilterList.toArray(new QFilter [] {}));
|
"expenseentryentity.expenseamount, "+//报销金额(含税)
|
||||||
|
"expenseentryentity.orientryamount " //不含税金额
|
||||||
|
, searchFilterList.toArray(new QFilter [] {}));
|
||||||
return load;
|
return load;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +396,8 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
||||||
"id,description,billno,expenseentryentity," +
|
"id,description,billno,expenseentryentity," +
|
||||||
DEV_KEY+"_is_business_foreign,"+
|
DEV_KEY+"_is_business_foreign,"+
|
||||||
"id,applier,billno,tripentry.startdate,tripentry.entryentity," + //费用发生日期
|
"id,applier,billno,tripentry.startdate,tripentry.entryentity," + //费用发生日期
|
||||||
"entryentity.orientryamount", //报销金额
|
"entryentity.orientryamount,"+ //报销金额
|
||||||
|
"entryentity.notaxamount", //不含税金额
|
||||||
searchFilterList.toArray(new QFilter [] {}));
|
searchFilterList.toArray(new QFilter [] {}));
|
||||||
return load;
|
return load;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue