parent
de4a2d76a6
commit
9aad5b82b7
|
@ -0,0 +1,378 @@
|
|||
package zcgj.zcdev.zcdev.fs.plugin.form;
|
||||
|
||||
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;
|
||||
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.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.*;
|
||||
|
||||
/**
|
||||
* 费用报销单探亲检查
|
||||
*/
|
||||
public class DailyreimbursVisitCheckOp extends AbstractOperationServicePlugIn {
|
||||
private static final String prefix ="zcgj";
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("zcgj_holiday_start_time");
|
||||
e.getFieldKeys().add("zcgj_holiday_end_time");
|
||||
e.getFieldKeys().add("applier");
|
||||
e.getFieldKeys().add("zcgj_is_visit");
|
||||
e.getFieldKeys().add("zcgj_visit_type");
|
||||
e.getFieldKeys().add("zcgj_is_home");
|
||||
e.getFieldKeys().add("zcgj_visit_type");
|
||||
e.getFieldKeys().add("zcgj_holiday_days");
|
||||
e.getFieldKeys().add("bizdate");
|
||||
e.getFieldKeys().add("billstatus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
e.getValidators().add(new ValidatorExt());
|
||||
}
|
||||
|
||||
class ValidatorExt extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
|
||||
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
||||
int i =0;
|
||||
Map<Long,Map<String,Object>> allMap = new HashMap<>();
|
||||
//当前提交的探亲单据id集合
|
||||
Map<Long,List<Long>> currentBillIdListMap = new HashMap<>();
|
||||
|
||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
long aLong = dataEntity.getLong("id");
|
||||
//获取报销人
|
||||
DynamicObject applier = dataEntity.getDynamicObject("applier");
|
||||
long applierId = applier.getLong("id");
|
||||
//获取休假开始时间
|
||||
Date startTime = dataEntity.getDate(prefix + "_holiday_start_time");
|
||||
//获取休假结束时间
|
||||
Date endTime = dataEntity.getDate(prefix + "_holiday_end_time");
|
||||
//获取休假天数
|
||||
Integer days = dataEntity.getInt(prefix + "_holiday_days");
|
||||
//获取申请日期
|
||||
Date bizdate = dataEntity.getDate( "bizdate");
|
||||
//获取是否探亲
|
||||
//如果是探亲,则进行逻辑判断
|
||||
boolean isVisit = dataEntity.getBoolean(prefix + "_is_visit");
|
||||
boolean isHome = dataEntity.getBoolean(prefix + "_is_home");
|
||||
//探亲类型 1:探望父母,2:探望配偶
|
||||
String visitType = dataEntity.getString(prefix + "_visit_type");
|
||||
|
||||
|
||||
if(isVisit){
|
||||
|
||||
//获取当前人的探亲假配置
|
||||
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.addFatalErrorMessage(extendedDataEntity, "请设置人员探亲配置信息!");
|
||||
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.addFatalErrorMessage(extendedDataEntity, "人员探亲配置探亲假天数为空!");
|
||||
return;
|
||||
}
|
||||
if(marriedStatus == 1 ){ // 已婚
|
||||
if(marriedParentsYear == 0 ){
|
||||
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望父母年限为空!");
|
||||
return;
|
||||
}
|
||||
if(marriedParentsTime == 0 ){
|
||||
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望父母次数为空!");
|
||||
return;
|
||||
}
|
||||
if(marriedSpouseYear == 0 ){
|
||||
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望配偶年限为空!");
|
||||
return;
|
||||
}
|
||||
if(marriedSpouseTime == 0 ){
|
||||
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置已婚探望配偶次数为空!");
|
||||
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.addFatalErrorMessage(extendedDataEntity, "未婚状态下探亲类型只能选择探望父母!");
|
||||
return;
|
||||
}
|
||||
if(unmarriedParentsYear == 0 ){
|
||||
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置未婚探望父母年限为空!");
|
||||
return;
|
||||
}
|
||||
if(unmarriedParentsTime == 0 ){
|
||||
this.addFatalErrorMessage(extendedDataEntity, "人员探亲配置未婚探望父母次数为空!");
|
||||
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
|
||||
);
|
||||
|
||||
if(currentBillIdListMap.containsKey(applierId)){
|
||||
List<Long> longs = currentBillIdListMap.get(applierId);
|
||||
longs.add(aLong);
|
||||
}else{
|
||||
List<Long> currentBillIdList = new ArrayList<>();
|
||||
currentBillIdList.add(aLong);
|
||||
currentBillIdListMap.put(applierId,currentBillIdList);
|
||||
}
|
||||
List<Long> longs = currentBillIdListMap.get(applierId);
|
||||
if(!longs.isEmpty()&&extendedDataEntities.length>1){
|
||||
QFilter[] filterArray1 = new QFilter[1];
|
||||
filterArray1[0] = new QFilter("id", QCP.in, longs);
|
||||
DataSet dateSetSave = 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",
|
||||
filterArray1, null
|
||||
);
|
||||
dateSet = dateSet.union(dateSetSave) ;
|
||||
}
|
||||
|
||||
//使用请假总天数
|
||||
int allHolidayCount = 0;
|
||||
//使用请假总次数
|
||||
int holidayCount = 0;
|
||||
for (Row itemRow : dateSet) {
|
||||
String string = itemRow.getString("billno");
|
||||
Date startTimeVal = itemRow.getDate("startTime");
|
||||
Date endTimeVal = itemRow.getDate("endTime");
|
||||
Integer dayCount = itemRow.getInteger("days");
|
||||
//long dayCount = ChronoUnit.DAYS.between(dateToLocalDate(startTimeVal), dateToLocalDate(endTimeVal));
|
||||
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,days);
|
||||
if((remainderTimes > 0) && (remainderDays >= 0) &&((remainderDays - days) >=0)){
|
||||
//this.getView().showTipNotification(message);
|
||||
//this.addMessage(extendedDataEntity, message);
|
||||
}else{
|
||||
this.addFatalErrorMessage(extendedDataEntity, "探亲次数或探亲天数不足!"+message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//判断是否来往家居地
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
//获取申请人在月份的单据量
|
||||
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.addMessage(extendedDataEntity, message);
|
||||
}
|
||||
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期所在年份的第一天
|
||||
* @param date java.util.Date
|
||||
* @return java.util.Date
|
||||
*/
|
||||
public static Date getFirstDayOfYear(Date date) {
|
||||
LocalDate localDate = dateToLocalDate(date);
|
||||
LocalDate firstDayOfYear = LocalDate.of(localDate.getYear(), Month.JANUARY, 1);
|
||||
return Date.from(firstDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期所在年份的最后一天
|
||||
* @param date java.util.Date
|
||||
* @return java.util.Date
|
||||
*/
|
||||
public static Date getLastDayOfYear(Date date) {
|
||||
LocalDate localDate = dateToLocalDate(date);
|
||||
LocalDate lastDayOfYear = LocalDate.of(localDate.getYear(), Month.DECEMBER, 31);
|
||||
return Date.from(lastDayOfYear.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期所在月份的第一天
|
||||
* @param date 指定日期
|
||||
* @return LocalDate 所在月份的第一天
|
||||
*/
|
||||
public static LocalDate getFirstDayOfMonth(Date date) {
|
||||
LocalDate localDate = dateToLocalDate(date);
|
||||
return localDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期所在月份的最后一天
|
||||
* @param date 指定日期
|
||||
* @return LocalDate 所在月份的最后一天
|
||||
*/
|
||||
public static LocalDate getLastDayOfMonth(Date date) {
|
||||
LocalDate localDate = dateToLocalDate(date);
|
||||
return localDate.with(TemporalAdjusters.lastDayOfMonth());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定年限-1年前的第一天
|
||||
* @param date 指定日期
|
||||
* @param years 年限值
|
||||
* @return LocalDate 年限-1年前的第一天
|
||||
*/
|
||||
public static LocalDate getFirstDayYearsAgo(LocalDate date, int years) {
|
||||
if (date == null) {
|
||||
throw new IllegalArgumentException("日期不能为空");
|
||||
}
|
||||
if (years < 1) {
|
||||
throw new IllegalArgumentException("年限值必须大于等于 1");
|
||||
}
|
||||
return LocalDate.of(date.getYear() - (years - 1), Month.JANUARY, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,8 +25,10 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 费用报销单探亲检查插件
|
||||
* 费用报销单探亲检查插件(废弃)
|
||||
* 使用 DailyreimbursVisitCheckOp
|
||||
*/
|
||||
@Deprecated
|
||||
public class DailyreimbursVisitCheckPlugin extends AbstractBillPlugIn implements Plugin{
|
||||
private static final Log log = LogFactory.getLog(DailyreimbursVisitCheckPlugin.class);
|
||||
//开发商标识
|
||||
|
@ -47,7 +49,7 @@ public class DailyreimbursVisitCheckPlugin extends AbstractBillPlugIn implemen
|
|||
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){
|
||||
|
@ -180,7 +182,7 @@ public class DailyreimbursVisitCheckPlugin extends AbstractBillPlugIn implemen
|
|||
DataSet dateSet = QueryServiceHelper.queryDataSet(
|
||||
this.getClass().getName(),
|
||||
"er_dailyreimbursebill",
|
||||
"id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime",
|
||||
"id,billno,zcgj_holiday_start_time as startTime,zcgj_holiday_end_time as endTime,zcgj_holiday_days as days",
|
||||
filterArray, null
|
||||
);
|
||||
//使用请假总天数
|
||||
|
@ -191,7 +193,8 @@ public class DailyreimbursVisitCheckPlugin extends AbstractBillPlugIn implemen
|
|||
String string = itemRow.getString("billno");
|
||||
Date startTimeVal = itemRow.getDate("startTime");
|
||||
Date endTimeVal = itemRow.getDate("endTime");
|
||||
long dayCount = ChronoUnit.DAYS.between(dateToLocalDate(startTimeVal), dateToLocalDate(endTimeVal));
|
||||
//long dayCount = ChronoUnit.DAYS.between(dateToLocalDate(startTimeVal), dateToLocalDate(endTimeVal));
|
||||
Integer dayCount = itemRow.getInteger("days");
|
||||
allHolidayCount+=dayCount;
|
||||
holidayCount++;
|
||||
System.out.println(string);
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
package zcgj.zcdev.zcdev.fs.plugin.form;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.entity.operate.Submit;
|
||||
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* 报销单附件控制插件
|
||||
* 差旅报销、费用报销、对公报销
|
||||
*/
|
||||
public class ReimbursementCheckAttachmentPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
|
||||
//开发商标识
|
||||
private static final String prefix ="zcgj";
|
||||
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
//zcgj_attachmentcount
|
||||
Object source = args.getSource();
|
||||
if(args.getSource() instanceof Submit){
|
||||
// 根据类型进行安全转换
|
||||
String operateKey = ((Submit) source).getOperateKey();
|
||||
//重写返回的数据
|
||||
if("submit".equals(operateKey)){
|
||||
//提交时校验附件是否必填
|
||||
IDataModel model = this.getModel();
|
||||
int attachmentcount = Integer.parseInt(model.getValue(prefix+"_attachmentcount")+"");
|
||||
if(attachmentcount == 0){
|
||||
this.getView().showErrorNotification("请上传附件");
|
||||
//取消提交操作
|
||||
args.setCancel(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
super.beforeDoOperation(args);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ import java.math.BigDecimal;
|
|||
/**
|
||||
* 差旅报销单插件
|
||||
*/
|
||||
@Deprecated
|
||||
public class TripreimbursebillPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TripreimbursebillPlugin.class);
|
||||
|
@ -81,7 +82,7 @@ public class TripreimbursebillPlugin extends AbstractBillPlugIn implements Plug
|
|||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
String name = e.getProperty().getName();
|
||||
if(name.equals("zcgj_isfloating20")){
|
||||
/*if(name.equals("zcgj_isfloating20")){
|
||||
IDataModel model = this.getModel();
|
||||
ChangeData[] changeSet = e.getChangeSet();
|
||||
Boolean isfloating20 = (Boolean)changeSet[0].getNewValue();
|
||||
|
@ -109,11 +110,11 @@ public class TripreimbursebillPlugin extends AbstractBillPlugIn implements Plug
|
|||
entryentity.set("tripstandardamount",tripstandardamountOld);
|
||||
}
|
||||
this.getView().updateView("entryentity");
|
||||
this.getView().showTipNotification(tripstandardamount+" "+tripstandardamountOld);
|
||||
//this.getView().showTipNotification(tripstandardamount+" "+tripstandardamountOld);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
package zcgj.zcdev.zcdev.fs.plugin.form;
|
||||
|
||||
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%控制
|
||||
*/
|
||||
public class TripreimbursebillUpOp extends AbstractOperationServicePlugIn {
|
||||
|
||||
private static final Log log = LogFactory.getLog(TripreimbursebillUpOp.class);
|
||||
//开发商标识
|
||||
private static final String prefix ="zcgj";
|
||||
|
||||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
e.getFieldKeys().add("zcgj_isfloating20");
|
||||
e.getFieldKeys().add("tripentry");
|
||||
e.getFieldKeys().add("entryentity");
|
||||
e.getFieldKeys().add("zcgj_zs_key");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||
super.onAddValidators(e);
|
||||
e.getValidators().add(new ValidatorExt());
|
||||
}
|
||||
|
||||
class ValidatorExt extends AbstractValidator {
|
||||
@Override
|
||||
public void validate() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
|
||||
ExtendedDataEntity[] extendedDataEntities = this.getDataEntities();
|
||||
//当前提交的探亲单据id集合
|
||||
for (ExtendedDataEntity extendedDataEntity : extendedDataEntities) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
String zskey = dataEntity.getString("zcgj_zs_key");
|
||||
boolean isfloating20 = dataEntity.getBoolean("zcgj_isfloating20");
|
||||
|
||||
DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("tripentry");//oa流程分录
|
||||
int trip = 1;
|
||||
for (DynamicObject dynamicObject : tripentry) {
|
||||
DynamicObjectCollection dynamicObjectCollection = dynamicObject.getDynamicObjectCollection("entryentity");
|
||||
for (DynamicObject dy : dynamicObjectCollection) {
|
||||
DynamicObject expenseObj = dy.getDynamicObject("expenseitem");
|
||||
String expenseitem = expenseObj.getString("number");
|
||||
if(zskey.equals(expenseitem)){
|
||||
BigDecimal orientryamount = dy.getBigDecimal("orientryamount");//报销金额
|
||||
BigDecimal tripstandardamount = dy.getBigDecimal("tripstandardamount");//差旅标准金额
|
||||
Integer caldaycount = dy.getInt("caldaycount");//标准天数
|
||||
int isover = dy.getInt("isover");//是否超标,1是,0否
|
||||
//如果选择了上浮20%,则按照上浮20%进行判断
|
||||
if(isfloating20){
|
||||
//BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount));
|
||||
BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount));
|
||||
//-1表示小于,0是等于,1是大于
|
||||
if(orientryamount.compareTo(multiply) <= 0){
|
||||
//第1段行程,第4行明细住宿费已超标,不允许提交。
|
||||
// this.addFatalErrorMessage(extendedDataEntity, "第"+trip+"段行程,报销住宿超出标准!(上浮20%)");
|
||||
dy.set("isover",0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
trip++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
if((args.getSource() instanceof Submit) ){
|
||||
Submit source = (Submit)args.getSource();
|
||||
if(source.getOperateKey().equals("submit") ){
|
||||
//highseasontripstdshow
|
||||
//提交时校验附件是否必填
|
||||
IDataModel model = this.getModel();
|
||||
String zsKey = String.valueOf(model.getValue("zcgj_zs_key"));
|
||||
boolean isfloating20 = Boolean.parseBoolean(model.getValue("zcgj_isfloating20")+"");
|
||||
|
||||
//获取当前费用为住宿的
|
||||
DynamicObjectCollection tripentryCollection = model.getEntryEntity("tripentry");
|
||||
//tripentry.get(0).getDynamicObjectCollection("entryentity").get(2).getDynamicObject("expenseitem").getString("number");
|
||||
for (DynamicObject tripentry : tripentryCollection) {
|
||||
DynamicObjectCollection entryentityCollection = tripentry.getDynamicObjectCollection("entryentity");
|
||||
for (DynamicObject entryentity : entryentityCollection) {
|
||||
DynamicObject expenseitem = entryentity.getDynamicObject("expenseitem");
|
||||
String zsNumber = expenseitem.getString("number");
|
||||
if(zsKey.equals(zsNumber)){
|
||||
BigDecimal orientryamount = entryentity.getBigDecimal("orientryamount");//报销金额
|
||||
BigDecimal tripstandardamount = entryentity.getBigDecimal("tripstandardamount");//差旅标准金额
|
||||
Integer caldaycount = entryentity.getInt("caldaycount");//标准天数
|
||||
//如果选择了上浮20%,则按照上浮20%进行判断
|
||||
if(isfloating20){
|
||||
//BigDecimal multiply = tripstandardamount.multiply(new BigDecimal("1.2")).multiply(new BigDecimal(caldaycount));
|
||||
BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount));
|
||||
//-1表示小于,0是等于,1是大于
|
||||
if(orientryamount.compareTo(multiply) > 0){
|
||||
this.getView().showTipNotification("报销住宿超出标准!(上浮20%)");
|
||||
//取消提交操作
|
||||
args.setCancel(true);
|
||||
}
|
||||
}else{
|
||||
BigDecimal multiply = tripstandardamount.multiply(new BigDecimal(caldaycount));
|
||||
//-1表示小于,0是等于,1是大于
|
||||
if(orientryamount.compareTo(multiply) > 0){
|
||||
this.getView().showTipNotification("报销住宿超出标准!");
|
||||
//取消提交操作
|
||||
args.setCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
Loading…
Reference in New Issue