|
@@ -1,6 +1,7 @@
|
|
|
package com.gis.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.gis.common.constant.ConfigConstant;
|
|
|
import com.gis.common.util.ExcelUtils;
|
|
|
import com.gis.common.util.Result;
|
|
@@ -21,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@@ -42,6 +44,13 @@ public class TaskesTimateServiceImpl extends ZtBaseServiceImpl<TaskesTimateEntit
|
|
|
@Autowired
|
|
|
ConfigConstant configConstant;
|
|
|
|
|
|
+ // 部门id分类
|
|
|
+ private static HashMap<String, Object> deptMap = new HashMap<>();
|
|
|
+ static {
|
|
|
+ deptMap.put("age", "");
|
|
|
+ deptMap.put("wufu", "17,18,19,25");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Result<DetailVo> search(PageDto param) {
|
|
@@ -210,5 +219,56 @@ public class TaskesTimateServiceImpl extends ZtBaseServiceImpl<TaskesTimateEntit
|
|
|
return Result.success(result);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result<DetailVo> excelByYearDetail(Integer year, String type) {
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ String yearDate = LocalDate.of(year, 1, 1).toString();
|
|
|
+// builder.append("select a.task, a.date, a.account, ROUND(a.consumed/8,2) as consumed, b.project, b.name as taskName, c.name as projectName,c.code,d.realname as realname, d.slack, e.id as deptId, e.name as deptName, g.name as moduleName");
|
|
|
+ builder.append("select a.task, DATE_FORMAT( a.date, '%Y-%m-%d') as date, a.account, ROUND(a.consumed/8,2) as consumed, b.project, b.name as taskName, c.name as projectName,c.code,d.realname as realname, d.slack, e.id as deptId, e.name as deptName, g.name as moduleName");
|
|
|
+ builder.append(" from zt_taskestimate a left join zt_task b on b.id = a.task left join zt_module g on g.id=b.module left join zt_project c on c.id=b.project left join zt_user d on d.account = a.account left join zt_dept e on d.dept = e.id");
|
|
|
+ builder.append(StrUtil.format(" where b.deleted = '0' AND DATE_FORMAT( date, '%Y') = DATE_FORMAT('{}' , '%Y') ", yearDate));
|
|
|
+ if (StrUtil.isNotBlank(type)){
|
|
|
+ Object deptIds = deptMap.get(type);
|
|
|
+ builder.append(" and e.id in (").append(deptIds).append(")");
|
|
|
+ }
|
|
|
+ builder.append(" order by a.account asc");
|
|
|
+
|
|
|
+ List<DetailVo> effortVos = entityMapper.excelByYearDetail(builder.toString());
|
|
|
+ return Result.success(createExcel(effortVos));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private HashMap<String, Object> createExcel(List rows){
|
|
|
+
|
|
|
+ String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmss");
|
|
|
+ String savePath = configConstant.serverBasePath + time + ".xlsx";
|
|
|
+ HashMap<String, String> rowTitle = new HashMap<>();
|
|
|
+
|
|
|
+ rowTitle.put("slack", "工号");
|
|
|
+ rowTitle.put("date", "日期");
|
|
|
+ rowTitle.put("task", "任务号");
|
|
|
+ rowTitle.put("project", "项目id");
|
|
|
+ rowTitle.put("code", "项目号");
|
|
|
+ rowTitle.put("projectName", "项目名称");
|
|
|
+ rowTitle.put("account", "账号");
|
|
|
+ rowTitle.put("realname", "姓名");
|
|
|
+ rowTitle.put("consumed", "消耗时间(天)");
|
|
|
+ rowTitle.put("deptId", "部门Id");
|
|
|
+ rowTitle.put("deptName", "部门名称");
|
|
|
+
|
|
|
+ // 2022-2-24 by owen 新增
|
|
|
+ rowTitle.put("taskName", "任务名称");
|
|
|
+ rowTitle.put("moduleName", "模块名称");
|
|
|
+ ExcelUtils.createExcel(rows, savePath, rowTitle);
|
|
|
+
|
|
|
+
|
|
|
+ String domain = configConstant.serverDomain + time + ".xlsx";
|
|
|
+
|
|
|
+ HashMap<String, Object> result = new HashMap<>();
|
|
|
+ result.put("size", rows.size());
|
|
|
+ result.put("path", domain);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|