费用项目与会计科目映射配置
This commit is contained in:
parent
469940ddc6
commit
f789d6765d
|
@ -3,14 +3,26 @@ 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.CloneUtils;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
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.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.QueryServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
|
@ -21,15 +33,30 @@ import java.time.ZoneId;
|
|||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.Date;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* 费用报销单探亲检查插件
|
||||
*/
|
||||
public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin {
|
||||
public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
|
||||
private static final Log log = LogFactory.getLog(DailyreimbursPlugin.class);
|
||||
//开发商标识
|
||||
private static final String prefix ="zcgj";
|
||||
|
||||
//界面回调标识(自定义)
|
||||
private final static String ACTION_ID="accountview_form";
|
||||
//费用报销单的费用明细标识
|
||||
private final static String EXPENSE_ENTRY_ENTITY = "expenseentryentity";
|
||||
//会计科目与费用项目映射表分录
|
||||
private final static String MAP_TABLE = "zcgj_accountsitemsmap";
|
||||
//会计科目与费用项目映射表分录标识
|
||||
private final static String MAP_ENTRY_ENTITY = "zcgj_entryentity";
|
||||
|
||||
//费用报销中的费用项目标识
|
||||
private final static String EXPENSE_ITEM ="expenseitem";
|
||||
//费用报销中的会计科目标识
|
||||
private final static String ACCOUNT_ITEM ="zcgj_account_item";
|
||||
|
||||
@Override
|
||||
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
||||
try{
|
||||
|
@ -264,6 +291,87 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener(EventObject e) {
|
||||
super.registerListener(e);
|
||||
BasedataEdit fieldEdit = this.getView().getControl(ACCOUNT_ITEM);
|
||||
fieldEdit.addBeforeF7SelectListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeF7Select(BeforeF7SelectEvent arg0) {
|
||||
String name = arg0.getProperty().getName();
|
||||
if(name.equals(ACCOUNT_ITEM)){
|
||||
arg0.setCancel(true);
|
||||
ListShowParameter showParameter = ShowFormHelper.createShowListForm("bd_accountview", true);
|
||||
showParameter.setCloseCallBack(new CloseCallBack(this,ACTION_ID));
|
||||
this.getView().showForm(showParameter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
|
||||
super.closedCallBack(closedCallBackEvent);
|
||||
String actionId = closedCallBackEvent.getActionId();
|
||||
Object returnData = closedCallBackEvent.getReturnData();
|
||||
boolean current= true;
|
||||
|
||||
if(returnData!=null && actionId.equals(ACTION_ID)){
|
||||
//获取选中的索引
|
||||
int index = this.getModel().getEntryCurrentRowIndex(EXPENSE_ENTRY_ENTITY);
|
||||
//操作的行数据,获取之前的数据
|
||||
DynamicObject selectRow = this.getModel().getEntryRowEntity(EXPENSE_ENTRY_ENTITY, index);
|
||||
//克隆新的行
|
||||
DynamicObject insertRow = (DynamicObject) (new CloneUtils(false, false)).clone(selectRow);
|
||||
ListSelectedRowCollection listSelectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
|
||||
|
||||
for (ListSelectedRow listSelectedRow : listSelectedRows) {
|
||||
if(current){
|
||||
//选择行进行更改,其他行进行插入
|
||||
//给会计科目赋值
|
||||
this.getModel().setValue(ACCOUNT_ITEM,listSelectedRow.getPrimaryKeyValue(),index);
|
||||
QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue());
|
||||
DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter});
|
||||
if(dynamicObject1!=null){
|
||||
DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY);
|
||||
if(zcgjEntryentity!=null){
|
||||
DynamicObject dynamicObject = zcgjEntryentity.get(0);
|
||||
DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items");
|
||||
long aLong = itemDynamicObject.getLong("id");
|
||||
this.getModel().setValue(EXPENSE_ITEM,aLong,index);
|
||||
}else{
|
||||
this.getModel().setValue(EXPENSE_ITEM,null,index);
|
||||
}
|
||||
}else{
|
||||
this.getModel().setValue(EXPENSE_ITEM,null,index);
|
||||
}
|
||||
current = false;
|
||||
}else{
|
||||
QFilter nameQFilter = new QFilter(prefix+"_accounts",QCP.equals,listSelectedRow.getPrimaryKeyValue());
|
||||
DynamicObject dynamicObject1 = BusinessDataServiceHelper.loadSingle(MAP_TABLE, "createorg,zcgj_entryentity,zcgj_entryentity.zcgj_entity_items", new QFilter[]{nameQFilter});
|
||||
if(dynamicObject1!=null){
|
||||
DynamicObjectCollection zcgjEntryentity = (DynamicObjectCollection) dynamicObject1.get(MAP_ENTRY_ENTITY);
|
||||
if(zcgjEntryentity!=null){
|
||||
DynamicObject dynamicObject = zcgjEntryentity.get(0);
|
||||
DynamicObject itemDynamicObject= dynamicObject.getDynamicObject(prefix+"_entity_items");
|
||||
//费用项目
|
||||
insertRow.set(EXPENSE_ITEM,itemDynamicObject);
|
||||
}
|
||||
}else{
|
||||
insertRow.set(EXPENSE_ITEM,null);
|
||||
}
|
||||
//会计科目
|
||||
QFilter nameQFilterAccItem = new QFilter("id",QCP.equals,listSelectedRow.getPrimaryKeyValue());
|
||||
DynamicObject dynamicObjectAccItem = BusinessDataServiceHelper.loadSingle("bd_accountview", "number,name", new QFilter[]{nameQFilterAccItem});
|
||||
insertRow.set(ACCOUNT_ITEM,dynamicObjectAccItem);
|
||||
this.getModel().createNewEntryRow(EXPENSE_ENTRY_ENTITY,insertRow);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 java.util.Date 转换为 java.time.LocalDate
|
||||
|
@ -336,4 +444,7 @@ public class DailyreimbursPlugin extends AbstractBillPlugIn implements Plugin
|
|||
}
|
||||
return LocalDate.of(date.getYear() - (years - 1), Month.JANUARY, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -70,22 +70,18 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
|||
// 报表字段及数据类型
|
||||
String[] FIELDS = {
|
||||
DEV_KEY+"_user", DEV_KEY+"_username", DEV_KEY+"_date",DEV_KEY+"_bill_number",
|
||||
|
||||
DEV_KEY+"_serve_business", DEV_KEY+"_serve_outside",DEV_KEY+"_serve_significant",
|
||||
DEV_KEY+"_serve_other_business",DEV_KEY+"_serve_lodging",
|
||||
DEV_KEY+"_serve_souvenir",DEV_KEY+"_serve_total",
|
||||
|
||||
DEV_KEY+"_travel",DEV_KEY+"_abroad_travel",
|
||||
DEV_KEY+"_health",DEV_KEY+"_correspondence",DEV_KEY+"_training",
|
||||
DEV_KEY+"_total"
|
||||
};
|
||||
DataType[] DATATYPES = {
|
||||
DataType.LongType,DataType.StringType, DataType.StringType,DataType.StringType,
|
||||
|
||||
DataType.BigDecimalType, DataType.BigDecimalType,DataType.BigDecimalType,
|
||||
DataType.BigDecimalType,DataType.BigDecimalType,
|
||||
DataType.BigDecimalType,DataType.BigDecimalType,
|
||||
|
||||
DataType.BigDecimalType,DataType.BigDecimalType,
|
||||
DataType.BigDecimalType,DataType.BigDecimalType,DataType.BigDecimalType,
|
||||
DataType.BigDecimalType
|
||||
|
@ -125,6 +121,9 @@ public class PositionFeesRptQueryPlugin extends AbstractReportListDataPlugin {
|
|||
DynamicObjectCollection entrys = dynamicObject.getDynamicObjectCollection("expenseentryentity");
|
||||
for (DynamicObject entry : entrys) {
|
||||
DynamicObject expenseitemObj = entry.getDynamicObject("expenseitem"); //费用项目
|
||||
if(expenseitemObj == null){
|
||||
continue;
|
||||
}
|
||||
Date happendate = entry.getDate("happendate");//费用发生日期
|
||||
String itemNumber = expenseitemObj.getString("number");//费用项目编码
|
||||
String happendateStr = dateFormat.format(happendate);//费用发生日期str
|
||||
|
|
Loading…
Reference in New Issue