瀏覽代碼

工作计划导出编写

yusm 1 月之前
父節點
當前提交
b5bc0ede6c

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/entity/vo/GantExportVo.java

@@ -13,6 +13,7 @@ public class GantExportVo {
     private String projectName;
     private Integer projectId;
     private Integer taskId;
+    private Integer allocateTaskId;
     private String taskName;
     private Double duration;
     private Integer taskPlanType;

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/ExcelExportService.java

@@ -10,6 +10,7 @@ import java.util.Map;
 public interface ExcelExportService {
     public void testRead(String jobId);
     public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
+    public HttpRespMsg exportGeneralExcelByTitleAndListGant(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportGeneralExcelByTitleAndListByZheZhong(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;

+ 125 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -196,6 +196,131 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return httpRespMsg;
     }
 
+    @Override
+    public HttpRespMsg exportGeneralExcelByTitleAndListGant(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        if (title.contains("/")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("/", "@");
+        }
+        if (title.contains("\\")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("\\", "@");
+        }
+        String resp = ExcelUtil.exportGeneralExcelByTitleAndListGant(title, list, downloadPath);
+        String fileUrlSuffix = title + ".xlsx";
+        if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
+            FileSystemResource fileSystemResource = new FileSystemResource(path+fileUrlSuffix);
+//            String md5 = DigestUtils.md5Hex(FileUtil.readBytes(fileSystemResource.getFile()));
+
+            Long checkSize = 20L*1024*1024;
+            if(fileSystemResource.getFile().length() >= checkSize){
+                httpRespMsg.setError("文件过大,请缩短查询日期范围");
+                return httpRespMsg;
+            }
+            String jobId = "";
+            String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+            jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//            if(fileSystemResource.getFile().length() >= checkSize){
+//                String tmpFileJobId = wxCorpInfoService.getTranslationJobId(fileUrlSuffix,md5,wxCorpInfo);
+//                if(!StringUtils.isEmpty(tmpFileJobId)){
+//                    String mediaId = wxCorpInfoService.getAsyncJobResult(tmpFileJobId,wxCorpInfo);
+//                    jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//                }
+//            }else{
+//                String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+//                jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+//            }
+
+            System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
+//            if(StringUtils.isEmpty(jobId)){
+//                httpRespMsg.setError("转义jobId为空,请联系管理员");
+//                return httpRespMsg;
+//            }
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 40) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
+                if (corpwxJobResult != null) {
+                    if (corpwxJobResult.getErrCode() == 0) {
+                        syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        corpwxJobCenter.remove(jobId);
+                    } else {
+                        long t2 = System.currentTimeMillis();
+                        System.out.println("222企业微信转译报错:"+corpwxJobResult.getErrMsg()+",耗时:" + (t2 - t) + "ms");
+                        httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                        return httpRespMsg;
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
+            User user = userMapper.selectById(request.getHeader("token"));
+            String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
+            String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
+            System.out.println("上传待转译文件到钉钉, jobId==" + jobId);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            long t = System.currentTimeMillis();
+            while (i < 30) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else if (i < 20){
+                    Thread.sleep(1000);
+                } else {
+                    Thread.sleep(3000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
+                Integer status = corpddJobCenter.get(jobId);
+                if (status != null) {
+                    if (status == 1) {
+                        syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
+                        corpddJobCenter.remove(jobId);
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }else {
+            httpRespMsg.data = resp;
+        }
+        return httpRespMsg;
+    }
+
 
     public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
         HttpRespMsg httpRespMsg = new HttpRespMsg();

+ 97 - 10
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -58,6 +58,7 @@ import java.io.*;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.net.URLDecoder;
+import java.sql.Array;
 import java.sql.Timestamp;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
@@ -13848,12 +13849,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         //根据人员权限来获取,
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        List<ProjectLeader> projectLeaderList = projectLeaderService.list(new QueryWrapper<ProjectLeader>().eq("company_id", user.getCompanyId()));
+        List<List<String>> dataList=new ArrayList<>();
+        List<String> titleList=new ArrayList<>();
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", user.getCompanyId()));
         List<String> userIds = new ArrayList<>();
-        List<String> userIdsExtra = new ArrayList<>();
         List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部项目");
         List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
-        List<User> AllUser = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
+        List<User> allUser = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
         List<Integer> projectIds = null;
         if (functionList.size() == 0) {
             //担任部门主要负责人
@@ -13887,22 +13890,106 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             userIds = userIds.stream().filter(u->u.equals(targetUserId)).collect(Collectors.toList());
         }
 
-        List<Map> mapList = projectMapper.getTaskPlanByMemb(userIds, startDate + " 00:00:00", endDate + " 23:59:59", user.getCompanyId(), user.getId(), deptId, taskStatus);
-
+        List<GantExportVo> gantExportVos = projectMapper.getexportTaskPlanByMemb(userIds, startDate + " 00:00:00", endDate + " 23:59:59", user.getCompanyId(), user.getId(), deptId, taskStatus);
         QueryWrapper<LeaveSheet> lsQueryWrapper=new QueryWrapper();
         lsQueryWrapper.in("owner_id", userIds);
         if (startDate != null && endDate != null) {
             lsQueryWrapper.le("start_date", endDate).ge("end_date", startDate);
         }
-        List<LeaveSheet> leaveSheetList = leaveSheetMapper.selectList(lsQueryWrapper);
 
-        HashMap<String, Object> map = new HashMap<>();
-        map.put("mapList",mapList);
-        map.put("leaveSheetList",leaveSheetList);
-        msg.data=map;
+        List<String> headerList = new ArrayList<>();
+        headerList.add("姓名");
+        headerList.add("部门");
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate startDateParse = LocalDate.parse(startDate, formatter);
+        LocalDate endDateParse = LocalDate.parse(endDate, formatter);
+        List<String> headersDate = generateDateHeaders(startDateParse, endDateParse);// 返回: [5.30(周五), 5.31(周六)]
+        List<String> dateStrList = generateDateList(startDateParse, endDateParse);// 返回: [2025-05-30, 2025-05-31]
+        headerList.addAll(headersDate);
+        dataList.add(headerList);
+        List<GantExportVo> gantExportVoListCollect = gantExportVos.stream().filter(g -> g.getAllocateTaskId() != null).collect(Collectors.toList());
+        Map<String, List<GantExportVo>> gantByUserIdCollect = gantExportVoListCollect.stream().collect(Collectors.groupingBy(GantExportVo::getUserId));
+        Set<Map.Entry<String, List<GantExportVo>>> entries = gantByUserIdCollect.entrySet();
+        for (Map.Entry<String, List<GantExportVo>> entry : entries) {
+            List<String> strings = new ArrayList<>();
+            String userId = entry.getKey();
+            List<GantExportVo> voList = entry.getValue();
+            GantExportVo gantExportVo = voList.get(0);
+            strings.add(gantExportVo.getUserName());
+            strings.add(gantExportVo.getDeptName());
+            for (String dateStr : dateStrList) {
+                List<GantExportVo> gantExportVoList = voList.stream().filter(v -> v.getAllocateDate() != null && formatter.format(v.getAllocateDate()).equals(dateStr)).collect(Collectors.toList());
+                if (!gantExportVoList.isEmpty()) {
+                    StringBuilder content= new StringBuilder();
+                    double sum = gantExportVoList.stream().mapToDouble(GantExportVo::getTotalWorkHour).sum();
+                    double remain = 7.5 - sum;
+                    content.append("共").append(sum).append("h(剩余工时)").append(remain).append("h\n");
+
+                    for (GantExportVo exportVo : gantExportVoList) {
+                        content.append(exportVo.getProjectName()).append(" ").append(exportVo.getTotalWorkHour()).append("h\n");
+                    }
+                    strings.add(content.toString());
+
+                }else {
+                    strings.add("共0h(剩余工时7.5h)");
+                }
+            }
+            dataList.add(strings);
+        }
+        String fileName = "工作计划导出报表"+System.currentTimeMillis();
+        try {
+            return excelExportService.exportGeneralExcelByTitleAndListGant(wxCorpInfo,dingding,fileName, dataList, path);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        msg.data =  pathPrefix + fileName+".xlsx";
         return  msg;
     }
 
+    public static List<String> generateDateHeaders(LocalDate startDate, LocalDate endDate) {
+        List<String> headers = new ArrayList<>();
+        DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern("M.d");
+
+        LocalDate current = startDate;
+        while (!current.isAfter(endDate)) {
+            String dayOfWeek = getChineseDayOfWeek(current.getDayOfWeek());
+            String formattedDate = current.format(dayFormatter) + "(" + dayOfWeek + ")";
+            headers.add(formattedDate);
+            current = current.plusDays(1);
+        }
+
+        return headers;
+    }
+
+    public static List<String> generateDateList(LocalDate startDate, LocalDate endDate) {
+        List<String> headers = new ArrayList<>();
+        DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+        LocalDate current = startDate;
+        while (!current.isAfter(endDate)) {
+
+            String formattedDate = current.format(dayFormatter);
+            headers.add(formattedDate);
+            current = current.plusDays(1);
+        }
+        return headers;
+    }
+
+    private static String getChineseDayOfWeek(DayOfWeek dayOfWeek) {
+        switch (dayOfWeek) {
+            case MONDAY:    return "周一";
+            case TUESDAY:   return "周二";
+            case WEDNESDAY: return "周三";
+            case THURSDAY: return "周四";
+            case FRIDAY:   return "周五";
+            case SATURDAY:  return "周六";
+            case SUNDAY:   return "周日";
+            default:        return "";
+        }
+    }
+
+
     //导出FTE报表数据
     @Override
     public HttpRespMsg exportFTEData(String monthStart,String monthEnd, String area,Integer departmentId,HttpServletRequest request) {

+ 120 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/util/ExcelUtil.java

@@ -6,12 +6,14 @@ import org.apache.poi.ss.util.RegionUtil;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFColor;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
@@ -1478,4 +1480,122 @@ public class ExcelUtil {
         }
         return "/upload/"+fileName;
     }
+
+    /**
+     * 通用Excel导出方法
+     * @param title 导出的文件名(不需要带.xlsx后缀)
+     * @param list 所有数据(包括表头行和数据行),每个List<String>代表一行
+     * @param downloadPath 文件保存路径(如:"/export/")
+     * @return 返回导出文件的完整路径
+     * @throws IOException
+     */
+    public static String exportGeneralExcelByTitleAndListGant(String title, List<List<String>> list, String downloadPath) throws IOException {
+        // 1. 校验参数
+        if (list == null || list.isEmpty()) {
+            throw new IllegalArgumentException("导出数据不能为空");
+        }
+
+        // 2. 创建Workbook和工作表
+        Workbook workbook = new XSSFWorkbook(); // 创建XLSX格式的Excel
+        Sheet sheet = workbook.createSheet("Sheet1");
+
+        // 3. 创建样式(表头样式和内容样式)
+        // 表头样式(加粗、居中、带边框)
+        CellStyle headerStyle = createHeaderCellStyle(workbook);
+        // 内容样式(带边框)
+        CellStyle contentStyle = createContentCellStyle(workbook);
+
+        // 4. 填充数据
+        for (int rowNum = 0; rowNum < list.size(); rowNum++) {
+            List<String> rowData = list.get(rowNum);
+            Row row = sheet.createRow(rowNum);
+
+            for (int colNum = 0; colNum < rowData.size(); colNum++) {
+                Cell cell = row.createCell(colNum);
+                cell.setCellValue(rowData.get(colNum));
+
+                // 应用样式:第一行是表头,其他是内容
+                if (rowNum == 0) {
+                    cell.setCellStyle(headerStyle);
+                } else {
+                    cell.setCellStyle(contentStyle);
+                }
+            }
+        }
+
+        // 5. 自动调整列宽(对所有列)
+        for (int i = 0; i < list.get(0).size(); i++) {
+            sheet.autoSizeColumn(i);
+            // 解决自动调整列宽中文失效问题
+            sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 17 / 10);
+        }
+
+        // 6. 确保下载路径存在
+        File path = new File(downloadPath);
+        if (!path.exists()) {
+            path.mkdirs();
+        }
+
+        // 7. 生成完整文件名
+        String fileName = title + ".xlsx";
+        String fullPath = downloadPath  + fileName;
+
+        // 8. 写入文件
+        try (FileOutputStream fos = new FileOutputStream(fullPath)) {
+            workbook.write(fos);
+        } finally {
+            workbook.close();
+        }
+        return fullPath;
+    }
+
+    /**
+     * 创建表头单元格样式
+     */
+    private static CellStyle createHeaderCellStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+
+        // 设置字体(加粗)
+        Font font = workbook.createFont();
+        font.setBold(true);
+        style.setFont(font);
+
+        // 设置对齐方式
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+
+        // 设置边框
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+
+        // 可选:设置背景色
+        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+
+        return style;
+    }
+
+    /**
+     * 创建内容单元格样式
+     */
+    private static CellStyle createContentCellStyle(Workbook workbook) {
+        CellStyle style = workbook.createCellStyle();
+
+        // 设置对齐方式
+        style.setAlignment(HorizontalAlignment.LEFT);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+
+        // 设置边框
+        style.setBorderTop(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+
+        // 设置自动换行
+        style.setWrapText(true);
+
+        return style;
+    }
 }

+ 40 - 19
fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/ProjectMapper.xml

@@ -2973,16 +2973,16 @@
           and project_code in <foreach collection="projectCodes" item="projectCode" separator="," open="(" close=")">#{projectCode}</foreach>
     </select>
     <select id="getexportTaskPlanByMemb" resultType="com.management.platform.entity.vo.GantExportVo">
-        SELECT  user.`id` as user_id,
-                user.`name`,
-                project.`project_name`,
+        SELECT  user.`id` as userId,
+                user.`name` userName,
+                project.`project_name` projectName,
                 project.id projectId,
-                task.id as task_id,
-                task.name as task_name,
+                tda.task_id as allocateTaskId,
+                task.id as taskId,
+                task.name as taskName,
                 task_executor.plan_hours as duration,
                 task.task_plan_type as taskPlanType,
                 task.task_status as taskStatus,
-                task.id as taskId,
                 d.department_name deptName,
                 tda.allocate_date allocateDate,
                 SUM(tda.work_hour) as totalWorkHour,
@@ -2992,21 +2992,41 @@
                  left join task on task.id = task_executor.task_id
                  left join task_type on task_type.id = task.task_plan_type
                  LEFT JOIN project ON project.`id` = task.`project_id`
-                 LEFT join task_daily_allocate tda on tda.user_id=user.id
+                 LEFT join task_daily_allocate tda on tda.user_id=user.id AND tda.task_id = task.id
                  LEFT JOIN department d on user.department_id=d.department_id
-        WHERE
-            ((IFNULL(task.start_date , task.end_date) between '2025-05-28 00:00:00' and '2025-05-31 18:00:00') or (task.end_date between '2025-05-28 00:00:00' and '2025-05-31 18:00:00'))
-          and task.end_date is not null
-          and (project.`status` = 1 or project.`status` is null )
-          and task.id =2714
-        GROUP BY
-            user.`id`,
-            user.`name`,
-            project.`project_name`,
-            project.id,
-            d.department_name,
-            tda.allocate_date
+        <where>
+            and task.end_date is not null
+            AND (project.`status` = 1 or project.`status` is null)
+            <if test="userIds!=null and userIds.size()>0">
+               and user.`id` IN
+               <foreach collection="userIds" close=")" open="(" separator="," index="" item="item">
+                  #{item}
+               </foreach>
+            </if>
+            <if test="startDate !=null and startDate!='' and endDate !=null and endDate!=''">
+                and ((IFNULL(task.start_date , task.end_date) between #{startDate} and #{endDate}) or (task.end_date between #{startDate} and #{endDate}))
+            </if>
+            <if test="deptId !=null">
+                and user.department_id= #{deptId}
+            </if>
+            <if test="taskStatus != null">
+                <choose>
+                    <when test="taskStatus == 0">
+                        and task.task_status in (3, 4)
+                    </when>
+                    <when test="taskStatus == 1">
+                        and task.task_status = 1
+                    </when>
+                    <when test="taskStatus == 2">
+                        and task.task_status in (5, 6)
+                    </when>
+                    <when test="taskStatus == 3">
+                        and task.task_status = 2
+                    </when>
+                </choose>
+            </if>
+        </where>
+        GROUP BY user.`id`,user.`name`,tda.task_id,project.`project_name`,project.id,tda.allocate_date
         ORDER BY user.id, task.start_date
     </select>
 

+ 21 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/TaskDailyAllocateMapper.xml

@@ -19,4 +19,25 @@
         id, task_id, user_id, start_time, end_time, allocate_date, work_hour, over_work_hour
     </sql>
 
+    <select id="getUserTaskTimeList" resultType="com.management.platform.entity.TaskDailyAllocate">
+        SELECT tda.*,p.project_name projectName,t.name taskName
+        FROM task_daily_allocate tda
+        LEFT JOIN task  t ON t.id = tda.`task_id`
+        left join project p on p.id = t.`project_id`
+        WHERE
+        tda.user_id = #{userId}
+        and t.task_status not in (1,2)
+        <if test="taskId != null">
+            and t.id != #{taskId}
+        </if>
+        and tda.start_time &lt;= #{endTime} and tda.end_time &gt;= #{stateTime}
+    </select>
+    <select id="getConflict" resultType="java.lang.Integer">
+        select count(*) from task_daily_allocate
+        where start_time &lt;= #{endTime} and end_time &gt;= #{stateTime}
+        <if test="taskId != null">
+            and task_id != #{taskId}
+        </if>
+    </select>
+
 </mapper>