当前位置:网站首页>Implementation of dynamic columns in EAS BOS doc list
Implementation of dynamic columns in EAS BOS doc list
2022-07-24 13:03:00 【Gecko (brain)】
1、 Sample code :
/**
* output package name
*/
package com.kingdee.eas.custom.rpt.client;
import java.awt.Color;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.kdf.table.IColumn;
import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.ctrl.kdf.table.KDTMergeManager;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.basedata.org.CtrlUnitInfo;
import com.kingdee.eas.basedata.org.OrgUnitInfo;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.custom.gzkd.util.GzKDUtils;
import com.kingdee.eas.custom.gzkd.util.GzKdDateUtils;
import com.kingdee.eas.custom.rpt.TimesheetDetailDataRptFacadeFactory;
import com.kingdee.eas.custom.rpt.util.TimeSheetRptConstant;
import com.kingdee.eas.framework.report.ICommRptBase;
import com.kingdee.eas.framework.report.client.CommRptBaseConditionUI;
import com.kingdee.eas.framework.report.util.RptRowSet;
/**
* output class name
*
*
* Modify the record :
* Add a status filter and display the work order number , And only query the working hours for submission 、 Under review 、 Approved status Modifier :XXX To pick up :XXX 20181107
* The doc list interface displays the doc number of the work hour summary Modifier :XXX To pick up :XXX 20181114
*
*
* Report logic personal notes XXX:
* adopt SQL Display all the working hours of the query employee , Press Organization name + Employee name + Work date Sort .
* If the employee is on duty that day , This sets the status to submit, And fill in the number of days +1, And the man hour number are summarized in the man hour number column .
* If there is no working hours , Then set the status of the day to miss, And the number of days missed +1. The working hours on holidays are not in the statistical range .
*
*/
public class TimesheetDetailDataRptUI extends AbstractTimesheetDetailDataRptUI {
private static final Logger logger = CoreUIObject.getLogger(TimesheetDetailDataRptUI.class);
/**
* output class constructor
*/
public TimesheetDetailDataRptUI() throws Exception {
super();
}
/**
* Create header
*/
protected void createHeader(RptRowSet rptSet) {
int colIndex = getFixCount();
/** Delete dynamically loaded columns */
List<Integer> removeCol = new ArrayList<Integer>();
for (int n = 0; n < getMainTab().getColumnCount(); n++) {
if (n >= getFixCount()) {
removeCol.add(n);
}
}
Collections.reverse(removeCol);
for (int index : removeCol) {
getMainTab().removeColumn(index);
}
String columnKey = null;
String columnTitle = null;
String columnTitle2 = null;
String upColumnTitle = null;
IRow row1 = getMainTab().getHeadRow(0);
IRow row2 = getMainTab().getHeadRow(1);
int thisTitleCount = 0;
KDTMergeManager mm = getMainTab().getHeadMergeManager();
Date startDate = (Date) params.getObject(TimeSheetRptConstant.STARTDATE);
Date endDate = (Date) params.getObject(TimeSheetRptConstant.ENDDATE);
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(endDate);
getMainTab().getColumn("timeSheetHours").getStyleAttributes().setHided(params.getBoolean(TimeSheetRptConstant.NOTSHOWSUMITDAYS));
getMainTab().getColumn("lessHours").getStyleAttributes().setHided(params.getBoolean(TimeSheetRptConstant.NOTSHOWMISSDAYS));
getMainTab().getColumn("workDays").getStyleAttributes().setHided(!params.getBoolean(TimeSheetRptConstant.SHOWWORKDAYS));
while (endCalendar.compareTo(calendar) >= 0) {
columnTitle = getYearMonth(calendar);
columnTitle2 = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
columnKey = String.valueOf(getYearMonthTitle(calendar));
if (GzKdDateUtils.isHoliday(null, calendar.getTime(), null)) {
columnKey = columnKey + "_HOLIDAY";
}
IColumn column = getMainTab().addColumn(colIndex);
column.setKey(columnKey);
row1.getCell(colIndex).setValue(columnTitle);
row2.getCell(colIndex).setValue(columnTitle2);
column.setWidth(50);
if (org.apache.commons.lang.StringUtils.isNotEmpty(upColumnTitle) && !columnTitle.equals(upColumnTitle)) {
mm.mergeBlock(0, colIndex - thisTitleCount, 0, colIndex - 1);
thisTitleCount = 0;
}
colIndex++;
thisTitleCount++;
upColumnTitle = columnTitle;
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
mm.mergeBlock(0, colIndex - thisTitleCount, 0, colIndex - 1);
}
private int getYearMonthTitle(Calendar calendar) {
if (calendar == null) {
return 0;
} else {
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
return (year * 10000) + (month * 100) + day;
}
}
private String getYearMonth(Calendar calendar) {
if (calendar == null) {
return "";
} else {
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
return year + "-" + month;
}
}
/*
* (non-Javadoc)
*
* @see
* com.kingdee.eas.custom.gzkd.rpt.client.GzKdRptBaseUI#doAfterQuery(com
* .kingdee.eas.framework.report.util.RptRowSet)
*/
@Override
protected void doAfterQuery(RptRowSet rs) throws Exception {
/*
* Personal remarks Tan Rongtao : according to organization staff date Sort , Statistics of working hours details .
* Filling days = Employee's working days ( It's also timely submit Days of )
* Missing days = Working days - Filling days
* Time sheet = The work hour number in the statistical time + ”,“ A summary of ( To repeat )
*
*/
getMainTab().gerGroupManager().setGroup(true);
getMainTab().getColumn("orgName").setGroup(true);
String person = null;
String upPerson = null;
IRow addRow = null;
String columnKey;
String oldKey = "";
int actualSubmitDays = 0;// Actual submission days , That is, the table value in the working date in the statistical report is "submit" Days of , Used to calculate missing days = Working days - Actual submission days
int submitDays = 0;
int workDays = 0;
int missDays = 0;
String organdperson1 = null; // It is used to summarize the work order number ( Judge whether it is new )
String organdperson2 = null; // It is used to summarize the work order number ( Judge whether it is new )
String workHoursNos = null; // It is used to summarize the work order number
Map<Object, Object> whMap = new HashMap<Object, Object>(); // It is used to summarize the work order number
while (rs.next()) {
person = rs.getString("PERSONNAME");
System.out.println(person);
if (!person.equals((upPerson))) {
if (addRow != null) {
addRow.getCell(5).setValue(actualSubmitDays);
//addRow.getCell(5).setValue(submitDays);//human Say that the submission days should be shown in the report as submit Days of notes by lws 2017-06-08
//addRow.getCell(6).setValue(workDays - submitDays);
if((workDays - actualSubmitDays)<0){// Missing days = Working days - Actual submission days
addRow.getCell(6).setValue(0);// Missing date , If the calculated value of missing days is less than zero , It is displayed as 0 that will do . ZenTao 5227
}else {
addRow.getCell(6).setValue(workDays - actualSubmitDays);// Missing date
}
}
submitDays = 0;
workDays = 0;
actualSubmitDays = 0;
addRow = getMainTab().addRow();
addRow.getCell(0).setValue(person);
addRow.getCell(1).setValue(rs.getObject("ORGNAME"));// organization
addRow.getCell(2).setValue(rs.getObject("PERSONNAME"));// staff member
addRow.getCell(3).setValue(rs.getObject("PERSONNAMEEN"));// English name of staff
addRow.getCell(4).setValue(rs.getObject("FZRNAME"));// The superior leaders of the staff
addRow.getCell(8).setValue(rs.getObject("workHoursNos")); // Time sheet
int n = getFixCount();
int allCount = getMainTab().getColumnCount();
for (int index = n; index < allCount; index++) {
String key = getMainTab().getColumn(index).getKey();
if (key.endsWith("_HOLIDAY")) {
addRow.getCell(key).getStyleAttributes().setBackground(Color.gray);
addRow.getCell(key).setValue(null);
} else {
workDays++;
addRow.getCell(index).getStyleAttributes().setBackground(Color.yellow);
addRow.getCell(index).setValue("miss");
}
}
addRow.getCell(7).setValue(workDays);// Working days
}
Object dateKey = rs.getObject("TIMESHEEDATE");
if (dateKey instanceof Timestamp) {
Timestamp dateTime = (Timestamp) dateKey;
Calendar date = Calendar.getInstance();
date.setTimeInMillis(dateTime.getTime());
columnKey = String.valueOf(getYearMonthTitle(date));
if (getMainTab().getColumnIndex(columnKey) != -1) {
if(!oldKey.equals(columnKey)){// Count the submission days in the working date. If there are multiple records on the same working date , Count only once , Avoid duplicate statistics
actualSubmitDays++;
}
submitDays++;// The same person may have multiple records on the same day
addRow.getCell(columnKey).getStyleAttributes().setBackground(Color.white);
addRow.getCell(columnKey).setValue("submit");
oldKey = columnKey;
// Summary of time sheet
organdperson1 = rs.getObject("ORGNAME").toString()+rs.getObject("PERSONNAME").toString();
organdperson2 = addRow.getCell(1).getValue().toString()+addRow.getCell(2).getValue().toString();
String only = rs.getObject("ORGNAME").toString()+rs.getObject("PERSONNAME").toString()+rs.getObject("workHoursNos");
if(whMap.isEmpty()){
whMap.put(only, rs.getObject("workHoursNos"));
}else{
if(!whMap.containsKey(only)){
workHoursNos = addRow.getCell(8).getValue() +","+ rs.getObject("workHoursNos");
addRow.getCell(8).setValue(workHoursNos);
whMap.clear();
whMap.put(only, rs.getObject("workHoursNos"));
}
}
}
}
upPerson = person;
}
if (addRow != null) {
addRow.getCell(5).setValue(actualSubmitDays);
//addRow.getCell(5).setValue(submitDays);// Filling days
if((workDays - actualSubmitDays)<0){
addRow.getCell(6).setValue(0);// Missing date , If the calculated value of missing days is less than zero , It is displayed as 0 that will do . ZenTao 5227
}else {
addRow.getCell(6).setValue(workDays - actualSubmitDays);// Missing date
}
}
getMainTab().gerGroupManager().group(); // Merge
}
public int getFixCount() {
return 9;
}
protected ICommRptBase getRemoteInstance() throws BOSException {
return TimesheetDetailDataRptFacadeFactory.getRemoteInstance();
}
/**
* Return to the user query panel instance
*/
protected CommRptBaseConditionUI getQueryDialogUserPanel() throws Exception {
return new TimesheetDetailDataFilterUI();
}
}2、 Tool class :
/**
*
*/
package com.kingdee.eas.custom.gzkd.util;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.query.server.ISQLDataAccess;
import com.kingdee.bos.dao.query.server.SQLDataAccessFactory;
import com.kingdee.jdbc.rowset.IRowSet;
/**
* @ Function description Time tools
* @ Modify the record :
* 2018-10-15 Construction method , Add methods to get holidays
* 2018-10-22 Add time formatting method
*/
public class GzKdDateUtils {
/**
* Find out whether the date is set to holiday from the work calendar
*
* @param ctx
* @param date
* @param cuID
* @return
* @throws BOSException
*/
public static boolean isHoliday(Context ctx, Date date, String cuID) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// If it is Saturday or Sunday, it is a holiday by default
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
boolean isHoliday = false;
if (1 == dayOfWeek || 7 == dayOfWeek) {
isHoliday = true;
} else {
isHoliday = false;
}
// Find the setting of the current date from the work calendar ,dateType by 1 It's a weekday .
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd");
String strDate = dateFm.format(date);
StringBuffer sql = new StringBuffer();
sql.append(" select entry.FDateType dateType ");
sql.append(" \n\t from T_WorkCalendarDayEntry entry ");
sql
.append(" \n\t left join T_WorkCalendar bill on bill.fid = entry.FWorkCanlendarID ");
sql
.append(" \n\t where bill.FOrgUnitID = '00000000-0000-0000-0000-000000000000CCE7AED4'");
sql.append(" \n\t and to_char(entry.fworkdate,'yyyy-MM-dd') = '");
sql.append(strDate).append("'");
try {
ISQLDataAccess iServer = SQLDataAccessFactory.getRemoteInstance();
if (ctx == null) {
iServer = SQLDataAccessFactory.getRemoteInstance();
} else {
iServer = SQLDataAccessFactory.getLocalInstance(ctx);
}
IRowSet row = iServer.getRowSet(sql.toString());
if (null != row) {
if (row.next()) {
int dateType = row.getInt("dateType");
if (1 == dateType) {
isHoliday = false;
} else {
isHoliday = true;
}
}
}
} catch (SQLException e) {
e.printStackTrace();
} catch (BOSException e) {
e.printStackTrace();
}
return isHoliday;
}
/**
* Get the Sunday of the week to which the specified date belongs
*/
public static Date getSunDay(Date day) {
// System.out.println("DAY:" + getYearMonthDay(day));
Calendar c = Calendar.getInstance();
c.setTime(day);
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
int lastSunday = dayOfWeek -1 ;
c.add(Calendar.DAY_OF_MONTH, -lastSunday);
// System.out.println(getYearMonthDay(c.getTime()));
return c.getTime();
}
/**
* Get by date Title
*/
public static int getYearMonthDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
if (calendar == null) {
return 0;
} else {
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
return (year * 10000) + (month * 100) + day;
}
}
/**
* Time format
*/
public static String getDataStr(String simFormat,Date date){
SimpleDateFormat sf = new SimpleDateFormat(simFormat);
return sf.format(date);
}
}
3、 Interface effect :

边栏推荐
- 猿人学第七题
- SSM hospital inpatient management system
- Modern data architecture selection: Data fabric, data mesh
- Usage of swipemenurecyclerview
- cookie
- Is it safe to open an account on Oriental Fortune online? Is there a threshold for opening an account?
- 基于matlab的语音处理
- Relevant laws of animation movement (judge where to move according to parameters)
- Is there any potential safety hazard for Xiaobai to open an account with Guotai Junan?
- Symbol
猜你喜欢

About the concept of thread (1)

27. Longest increasing subsequence

About thread (5) thread pool

SSM在线租房售房平台多城市版本

Mobilevit: challenge the end-to-side overlord of mobilenet

Teach you how to use power Bi to realize four kinds of visual charts
![[datasheet] interpretation of cs5480 data book of metering chip](/img/1a/e8a4ce5c393a6634b6dc8bf6d687e2.png)
[datasheet] interpretation of cs5480 data book of metering chip

The core capability of accelerating enterprise data application innovation flexibility

IUAP spring training data in 2022, Zhongtai training report

基于matlab的声音识别
随机推荐
Compatibility problems of call, apply, bind and bind
Custom scroll bar
Everything about native crash
[rust] reference and borrowing, string slice type (& STR) - rust language foundation 12
Get the current month and year and the previous 11 months
Leetcode's 302 weekly rematch
Video realizes the control of video progress, playback and pause
Localstorage
Cluster construction based on kubernetes v1.24.0 (I)
[C language] detailed knowledge of document operation
ESP32ADC
手把手教你用 Power BI 实现 4 种可视化图表
2022.07.21
About thread (4) thread interaction
Redis (13) -- on master-slave replication of redis
Digital intelligence integration accelerates enterprise business innovation
【C语言】详细的文件操作相关知识
Arduino框架下ESP32 EEPROM库函数实现对各数据类型保存示例
猿人学第五题
1.9. 触摸按钮(touch pad)测试