Pārlūkot izejas kodu

测试修改mld

yusm 4 nedēļas atpakaļ
vecāks
revīzija
f5790377b5

+ 29 - 13
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/TaskController.java

@@ -35,16 +35,15 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.time.Duration;
 import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
+import static com.management.platform.controller.TaskDailyAllocateController.isTaskTimeNonOverlapping;
+
 /**
 /**
  * <p>
  * <p>
  *  前端控制器
  *  前端控制器
@@ -275,17 +274,34 @@ public class TaskController {
                     }
                     }
                 }
                 }
                 //检查人员在其他任务上是否有时间冲突
                 //检查人员在其他任务上是否有时间冲突
-                Integer count = taskMapper.getUserConflitTaskCount(ex.getExecutorId(), task.getId(), task.getStartDate(), task.getEndDate());
-                if (count > 0) {
-                    conflictExecutor.append(ex.getExecutorName()).append(",");
-                }
+//                Integer count = taskMapper.getUserConflitTaskCount(ex.getExecutorId(), task.getId(), task.getStartDate(), task.getEndDate());
+//                if (count > 0) {
+//                    conflictExecutor.append(ex.getExecutorName()).append(",");
+//                }
             });
             });
-//            if (conflictExecutor.length() > 0) {
-//                conflictExecutor.deleteCharAt(conflictExecutor.length() - 1);
-//                msg.setError("执行人[" + conflictExecutor.toString() + "]在其他任务上有时间冲突");
-//            }
-            if (msg.code.equals("error")) {
-                return msg;
+            if (!allocateArrayList.isEmpty()) {
+                Map<String, List<TaskDailyAllocate>> map = allocateArrayList.stream().collect(Collectors.groupingBy(TaskDailyAllocate::getUserId));
+                Set<Map.Entry<String, List<TaskDailyAllocate>>> entries = map.entrySet();
+                for (Map.Entry<String, List<TaskDailyAllocate>> entry : entries) {
+                    String userIdStr = entry.getKey();
+                    List<TaskDailyAllocate> allocates = entry.getValue();
+                    User selectUser = userMapper.selectById(userIdStr);
+                    if (!allocates.isEmpty()) {
+                        String taskTimeNonOverlapping = isTaskTimeNonOverlapping(allocates);
+                        if (org.apache.commons.lang3.StringUtils.isNotEmpty(taskTimeNonOverlapping)){
+                            msg.setError("参与人:"+selectUser.getName()+taskTimeNonOverlapping);
+                            return msg;
+                        }
+
+                        for (TaskDailyAllocate taskDailyAllocate : allocates) {
+                            int count=taskDailyAllocateService.getConflict(taskDailyAllocate, request);
+                            if(count>0){
+                                msg.setError("参与人:"+selectUser.getName()+"选择时间段:"+taskDailyAllocate.getAllocateDate()+"日:"+taskDailyAllocate.getStartTime()+"--"+taskDailyAllocate.getEndTime()+"跟其他时间段存在冲突");
+                                return msg;
+                            }
+                        }
+                    }
+                }
             }
             }
             executorList.stream().forEach(ex->{
             executorList.stream().forEach(ex->{
                 ex.setProjectId(task.getProjectId());
                 ex.setProjectId(task.getProjectId());

+ 17 - 6
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -717,12 +717,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
 
 
                         XSSFCell researchCell = row.getCell(2);//研究中心
                         XSSFCell researchCell = row.getCell(2);//研究中心
                         if (researchCell != null && StringUtils.isNotEmpty(researchCell.getStringCellValue())) {
                         if (researchCell != null && StringUtils.isNotEmpty(researchCell.getStringCellValue())) {
-                            Optional<ReportExtraDegree> first = customerInfoList.stream().filter(c -> c.getName().equals(researchCell.getStringCellValue().trim())).findFirst();
-                            if (first.isPresent()) {
-                                task.setCenterId(first.get().getId());
-                                task.setCenterName(first.get().getName());
-                            } else {
-                                throw new Exception("第" + (rowIndex + 1) + "行,研究中心填写有误");
+                            Optional<Project> projectFirst = allProjectList.stream().filter(t -> t.getId().equals(task.getProjectId())).findFirst();
+                            if (projectFirst.isPresent()) {
+                                Project project = projectFirst.get();
+                                String associateDegreeNames = project.getAssociateDegreeNames();
+                                if (!StringUtils.isEmpty(associateDegreeNames)) {
+                                    if (associateDegreeNames.contains(researchCell.getStringCellValue().trim())) {
+                                        Optional<ReportExtraDegree> first = customerInfoList.stream().filter(c -> c.getName().equals(researchCell.getStringCellValue().trim())).findFirst();
+                                        if (first.isPresent()) {
+                                            task.setCenterId(first.get().getId());
+                                            task.setCenterName(first.get().getName());
+                                        } else {
+                                            throw new Exception("第" + (rowIndex + 1) + "行,研究中心填写有误");
+                                        }
+                                    }else {
+                                        throw new Exception("第" + (rowIndex + 1) + "行,研究中心,不在所填写的项目中,填写有误");
+                                    }
+                                }
                             }
                             }
                         }
                         }
 
 

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

@@ -35,7 +35,9 @@
     </select>
     </select>
     <select id="getConflict" resultType="java.lang.Integer">
     <select id="getConflict" resultType="java.lang.Integer">
         select count(*) from task_daily_allocate
         select count(*) from task_daily_allocate
+        LEFT JOIN task  t ON t.id = task_daily_allocate.`task_id`
             where start_time &lt;= #{endTime} and end_time &gt;= #{startTime} and allocate_date=#{allocateDate} and user_id=#{userId}
             where start_time &lt;= #{endTime} and end_time &gt;= #{startTime} and allocate_date=#{allocateDate} and user_id=#{userId}
+                and t.task_status not in (1,2)
             <if test="taskId != null">
             <if test="taskId != null">
                 and task_id != #{taskId}
                 and task_id != #{taskId}
             </if>
             </if>

+ 5 - 3
fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/TaskMapper.xml

@@ -853,7 +853,8 @@
         LEFT JOIN `user` u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN `user` u2 ON u2.id = task_executor.`second_auditor_id`
         LEFT JOIN `user` u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN `user` u2 ON u2.id = task_executor.`second_auditor_id`
         left join stages on stages.id = task.stages_id
         left join stages on stages.id = task.stages_id
         ${ew.customSqlSegment}
         ${ew.customSqlSegment}
-        and (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.task_status = 4 and task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
+        and ( (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or ( task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} ))
+        and task.task_status in (3,4)
         group by task.id
         group by task.id
         order by task.id desc
         order by task.id desc
         <if test="pageStart != null and pageSize != null">
         <if test="pageStart != null and pageSize != null">
@@ -865,8 +866,9 @@
         SELECT count(DISTINCT task.id) FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
         SELECT count(DISTINCT task.id) FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
                                                  LEFT JOIN `user` u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN `user` u2 ON u2.id = task_executor.`second_auditor_id`
                                                  LEFT JOIN `user` u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN `user` u2 ON u2.id = task_executor.`second_auditor_id`
             ${ew.customSqlSegment}
             ${ew.customSqlSegment}
-        and (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.task_status = 4 and task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
-    </select>
+            and ( (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or ( task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} ))
+            and task.task_status in (3,4)
+        </select>
     <select id="getUserConflitTaskCount"
     <select id="getUserConflitTaskCount"
             resultType="java.lang.Integer">
             resultType="java.lang.Integer">
         SELECT count(1) FROM task_executor LEFT JOIN task ON task.id = task_executor.`task_id`
         SELECT count(1) FROM task_executor LEFT JOIN task ON task.id = task_executor.`task_id`