From dbcf202d226d754e45801d4306173cfdc2a34a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Tue, 11 May 2021 11:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=BB=E5=8A=A1=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=B0=8F=E8=AE=A1=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shenjian/statistics/ProjectExport.groovy | 4 +- .../shenjian/statistics/TaskExport.groovy | 41 ++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/ProjectExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/ProjectExport.groovy index d08846701..317fd8fdb 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/ProjectExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/ProjectExport.groovy @@ -14,8 +14,8 @@ import org.apache.commons.collections.CollectionUtils class ProjectExport { static final String time = "2021年4月1日-2021年4月30日"; - static final String startTime = "2021-04-01" - static final String endTime = "2021-04-30" + static final String startTime = "2021-04-01 00:00:00" + static final String endTime = "2021-04-30 23:59:59" static void main(String[] args) { List> mergeData = new ArrayList<>() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/TaskExport.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/TaskExport.groovy index 196e9950b..7d05209bc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/TaskExport.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/statistics/TaskExport.groovy @@ -19,6 +19,7 @@ class TaskExport { static final String endTime = "2021-04-30 23:59:59" static void main(String[] args) { + List> mergeData = new ArrayList<>() List list = new ArrayList<>() def result = [] result << ['姓名', '所属项目', '参与任务', '任务绩效值', '投入时间(天)'] @@ -38,6 +39,7 @@ class TaskExport { Collections.sort(list) + Map> map = new HashMap<>() for (TaskPersonDTO dto : list) { def ret = [] ret[0] = dto.name; @@ -45,10 +47,47 @@ class TaskExport { ret[2] = dto.taskName; ret[3] = dto.score; ret[4] = dto.workTime; + if (map.containsKey(dto.name)) { + Map info = map.get(dto.name) + info.put("endRow", Double.valueOf(info.get("endRow") + 1)) + info.put("totalScore", Double.valueOf(info.get("totalScore") + dto.score)) + info.put("workTime", Double.valueOf(info.get("workTime") + dto.workTime)) + map.put(dto.name, info); + } else { + if (result.size() > 1) { + def total = [] + total[2] = "小计" + total[3] = map.get(result[result.size() - 1][0]).get("totalScore") + total[4] = map.get(result[result.size() - 1][0]).get("workTime") + result << total + } + Map info = new HashMap<>() + info.put("startRow", Double.valueOf(result.size())) + info.put("endRow", Double.valueOf(result.size())) + info.put("startCell", 0D) + info.put("endCell", 0D) + info.put("totalScore", Double.valueOf(dto.score)) + info.put("workTime", Double.valueOf(dto.workTime)) + map.put(dto.name, info) + } result << ret } + def total = [] + total[2] = "小计" + total[3] = map.get(result[result.size() - 1][0]).get("totalScore") + total[4] = map.get(result[result.size() - 1][0]).get("workTime") + result << total - com.fangjia.script.util.ExcelUtils.write("F:\\数据\\绩效\\任务统计.xlsx", result, "任务统计"); + for (Map info : map.values()) { + List data = new ArrayList<>() + data.add(info.get("startRow").toInteger()) + data.add(info.get("endRow").toInteger()) + data.add(info.get("startCell").toInteger()) + data.add(info.get("endCell").toInteger()) + mergeData.add(data) + } + + com.fangjia.script.util.ExcelUtils.write("F:\\数据\\绩效\\任务统计.xlsx", result, "任务统计", mergeData); } }