Commit 31b57e23 by 丁伟峰

日历设置多技术员多日删除功能

1 parent 3973410a
...@@ -93,6 +93,19 @@ public class EngineerCalendarController { ...@@ -93,6 +93,19 @@ public class EngineerCalendarController {
return res; return res;
} }
@PostMapping("/engineer/calendar/batch/delete")
public Result<?> BatchDeletePlan(@Validated @RequestBody CalendarBatDelDTO.Request reqDTO) {
Result<?> res = null;
try {
String userId = request.getHeader("userId");
res = engineerCalendarService.batchDeletePlan(userId, reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
@GetMapping("/engineer/calendar/plan/num") @GetMapping("/engineer/calendar/plan/num")
public Result<?> getEngineerPlanNum(@Validated CalendarQueryNumDTO.Request reqDTO) { public Result<?> getEngineerPlanNum(@Validated CalendarQueryNumDTO.Request reqDTO) {
Result<?> res = null; Result<?> res = null;
......
...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.dao; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity; import com.dituhui.pea.order.entity.CapacityEngineerCalendarEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -17,4 +18,8 @@ public interface CapacityEngineerCalendarDao extends JpaRepository<CapacityEngin ...@@ -17,4 +18,8 @@ public interface CapacityEngineerCalendarDao extends JpaRepository<CapacityEngin
@Query("select count(*) from CapacityEngineerCalendarEntity a where a.type = :type and a.startTime >= :startDate and a.endTime <= :endDate and a.engineerCode in :engineers") @Query("select count(*) from CapacityEngineerCalendarEntity a where a.type = :type and a.startTime >= :startDate and a.endTime <= :endDate and a.engineerCode in :engineers")
Integer queryEngineerPlanNum(List<String> engineers, LocalDateTime startDate, LocalDateTime endDate, String type); Integer queryEngineerPlanNum(List<String> engineers, LocalDateTime startDate, LocalDateTime endDate, String type);
@Modifying
@Query("delete from CapacityEngineerCalendarEntity a where a.engineerCode in :engineerCodes and a.type = :type and a.workday between :startDate and :endDate")
void deleteByTypeAndEngineerCodesAndBetweenDates(List<String> engineerCodes, String type, LocalDateTime startDate, LocalDateTime endDate);
} }
...@@ -18,4 +18,6 @@ public interface EngineerCalendarService { ...@@ -18,4 +18,6 @@ public interface EngineerCalendarService {
Result<?> batchAddPlan(String userId, CalendarBatAddDTO.Request reqDTO); Result<?> batchAddPlan(String userId, CalendarBatAddDTO.Request reqDTO);
Result<?> queryEngineerPlanNum(CalendarQueryNumDTO.Request reqDTO); Result<?> queryEngineerPlanNum(CalendarQueryNumDTO.Request reqDTO);
Result<?> batchDeletePlan(String userId, CalendarBatDelDTO.Request reqDTO);
} }
...@@ -177,7 +177,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService { ...@@ -177,7 +177,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
orgTeamDao.save(entity); orgTeamDao.save(entity);
// 技术员列表 // 技术员列表
if (req.getEngineerCodes() != null && req.getEngineerCodes().size() > 0) { if (req.getEngineerCodes() != null && !req.getEngineerCodes().isEmpty()) {
updateTeamEngineers(req.getTeamId(), req.getEngineerCodes()); updateTeamEngineers(req.getTeamId(), req.getEngineerCodes());
} }
return Result.success(null); return Result.success(null);
......
...@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -114,6 +115,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService { ...@@ -114,6 +115,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
} }
@Override @Override
@Transactional
public Result<?> updatePlan(String userId, CalendarUpdateDTO.Request reqDTO) { public Result<?> updatePlan(String userId, CalendarUpdateDTO.Request reqDTO) {
String userName = user.getUserInfo(userId).getResult().getNickname(); String userName = user.getUserInfo(userId).getResult().getNickname();
CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId()); CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId());
...@@ -140,6 +142,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService { ...@@ -140,6 +142,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
} }
@Override @Override
@Transactional
public Result<?> deletePlan(String userId, CalendarDeleteDTO.Request reqDTO) { public Result<?> deletePlan(String userId, CalendarDeleteDTO.Request reqDTO) {
CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId()); CapacityEngineerCalendarEntity entity = capacityEngineerCalendarDao.getByPlanId(reqDTO.getPlanId());
if (entity == null) { if (entity == null) {
...@@ -150,6 +153,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService { ...@@ -150,6 +153,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
} }
@Override @Override
@Transactional
public Result<?> batchAddPlan(String userId, CalendarBatAddDTO.Request reqDTO) { public Result<?> batchAddPlan(String userId, CalendarBatAddDTO.Request reqDTO) {
LocalDate beginDate = DateUtils.localDateFromStr(reqDTO.getStart()); LocalDate beginDate = DateUtils.localDateFromStr(reqDTO.getStart());
LocalDate endDate = DateUtils.localDateFromStr(reqDTO.getEnd()); LocalDate endDate = DateUtils.localDateFromStr(reqDTO.getEnd());
...@@ -301,6 +305,18 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService { ...@@ -301,6 +305,18 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
return Result.success(rs); return Result.success(rs);
} }
@Override
@Transactional
public Result<?> batchDeletePlan(String userId, CalendarBatDelDTO.Request reqDTO) {
if (reqDTO.getEngineerCodes().isEmpty()) {
return Result.failed("没有选中工程师");
}
LocalDateTime startDate = DateUtils.localDateFromStr(reqDTO.getStartDate()).atTime(LocalTime.MIDNIGHT);
LocalDateTime endDate = DateUtils.localDateFromStr(reqDTO.getEndDate()).atTime(LocalTime.MIDNIGHT);
capacityEngineerCalendarDao.deleteByTypeAndEngineerCodesAndBetweenDates(reqDTO.getEngineerCodes(), reqDTO.getType(), startDate, endDate);
return Result.success(null);
}
private List<EngineerCalendarDTO.Calendar> getOneEngineerCalendars(String engineerCode, String bdate, String edate) { private List<EngineerCalendarDTO.Calendar> getOneEngineerCalendars(String engineerCode, String bdate, String edate) {
// 返回某一个技术员,日期范围内的日历列表 // 返回某一个技术员,日期范围内的日历列表
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!