提交 cc876d47 authored 作者: 000516's avatar 000516

在CP计划中,删除多个计划需要逐一确认,计划是否被执行,计划是否已开始并超过1小时

......@@ -11,6 +11,7 @@ import com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlan
import com.wangxiaolu.promotion.domain.manage.wrapperQo.ActivityPlanInfoWrapper;
import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.exception.FlowException;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.result.basedata.RCode;
......@@ -19,7 +20,7 @@ import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......@@ -118,12 +119,17 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
// 判断ID中是否包含之前数据、非个人数据
Integer count = activityPlanInfoMapper.selectNotDelCount(planIds,employeeNo);
if (count > 0 ) {
throw new DataException(RCode.ACTIVITY_PLAN_NOT_SELF_DELETE);
throw new FlowException(RCode.ACTIVITY_PLAN_NOT_SELF_DELETE);
}
Integer countToday = activityPlanInfoMapper.selectTodayCount(planIds);
List<ActivityPlanInfoDo> todayPlans = activityPlanInfoMapper.selectTodayCount(planIds);
// 今日数据存在时,判断当前时间是否在今日10点前
if (countToday > 0 && (LocalTime.now().getHour() >= 10)) {
throw new DataException(RCode.ACTIVITY_PLAN_NOT_DELETE);
for (ActivityPlanInfoDo todayPlan : todayPlans) {
if (PlanStatus.EXECUTION.getCode().equals(todayPlan.getPlanStatus())) {
throw new FlowException(RCode.ACTIVITY_ID_IS_START.getCode(),String.format(RCode.ACTIVITY_ID_IS_START.getMsg(),todayPlan.getId()));
}
if (LocalDateTime.now().isAfter(todayPlan.getClockInTime().plusHours(1))){
throw new FlowException(RCode.ACTIVITY_PLAN_ID_NOT_DELETE.getCode(),String.format(RCode.ACTIVITY_PLAN_ID_NOT_DELETE.getMsg(),todayPlan.getId()));
}
}
activityPlanInfoMapper.updateIsDelete(planIds);
}
......
......@@ -32,7 +32,7 @@ public interface ActivityPlanInfoMapper extends BaseMapper<ActivityPlanInfoDo> {
void updateOne(@Param("pDo") ActivityPlanInfoDo pDo,@Param("recordId") Long recordId);
Integer selectTodayCount(List<Long> planIds);
List<ActivityPlanInfoDo> selectTodayCount(List<Long> planIds);
void updatePlanStatus(@Param("id") Long planId, @Param("status") Integer status);
......
......@@ -482,11 +482,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
ActivityPlanInfoDto dto = activityPlanInfoDao.selectById(operVo.getId());
// 已执行的计划不可修改
if (PlanStatus.EXECUTION.getCode().equals(dto.getPlanStatus())){
throw new FlowException(RCode.ACTIVITY_PLAN_EXECUTE_ERROR);
throw new FlowException(RCode.ACTIVITY_IS_START);
}
// 判断修改时间是否在促销员上班1小时内
if (LocalDateTime.now().isAfter(dto.getClockInTime().plusHours(1))){
dto.setErrorMsg("已超促销员上班时间1小时,不可修改;");
throw new FlowException(RCode.ACTIVITY_PLAN_NOT_DELETE);
}
ActivityPlanInfoDto planDto = new ActivityPlanInfoDto();
......
......@@ -120,9 +120,8 @@
</if>
</select>
<select id="selectTodayCount" resultType="java.lang.Integer">
select count(*)
from activity_plan_info
<select id="selectTodayCount" resultMap="SimResultMap">
select id,clock_in_time, plan_status
where id in
<foreach collection="planIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论