提交 2ccff0bc authored 作者: 李秋林's avatar 李秋林

删除计划做限制计划日期是今日则必需是10点之前,包含过去日期不可删除,非职能角色不可删除他人计划

上级 aa49c971
...@@ -72,7 +72,6 @@ public class PromPlanCoreController { ...@@ -72,7 +72,6 @@ public class PromPlanCoreController {
*/ */
@PostMapping("/auth/upload") @PostMapping("/auth/upload")
public R authPlan(@RequestBody ActivityPlanVo activityPlanVo) { public R authPlan(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否是城市经理
boolean isAuth = manageEmployeeQueryService.isAuth(activityPlanVo.getEmployeeNo()); boolean isAuth = manageEmployeeQueryService.isAuth(activityPlanVo.getEmployeeNo());
if (!isAuth) { if (!isAuth) {
throw new DataException(RCode.EMP_PRIVILEGE_ERROR); throw new DataException(RCode.EMP_PRIVILEGE_ERROR);
...@@ -148,7 +147,14 @@ public class PromPlanCoreController { ...@@ -148,7 +147,14 @@ public class PromPlanCoreController {
if (Collections.isEmpty(activityPlanVo.getPlanIds())){ if (Collections.isEmpty(activityPlanVo.getPlanIds())){
throw new ParamException(RCode.NEED_PARAM_ERROR); throw new ParamException(RCode.NEED_PARAM_ERROR);
} }
promPlanCoreService.deletePlan(activityPlanVo.getPlanIds());
// 判断当前账号是否是职能角色
String employeeNo = activityPlanVo.getEmployeeNo();
boolean isAuth = manageEmployeeQueryService.isAuth(employeeNo);
if (isAuth) {
employeeNo = "";
}
promPlanCoreService.deletePlan(activityPlanVo.getPlanIds(), employeeNo);
return R.success(); return R.success();
} }
......
...@@ -20,7 +20,7 @@ public interface ActivityPlanInfoDao { ...@@ -20,7 +20,7 @@ public interface ActivityPlanInfoDao {
ActivityPlanInfoDto selectPlan(String storeCode, Date date); ActivityPlanInfoDto selectPlan(String storeCode, Date date);
void deleteByPlanIds(List<Long> planIds); void deleteByPlanIds(List<Long> planIds, String employeeNo);
void updateList(JSONArray table, Long recordId); void updateList(JSONArray table, Long recordId);
} }
...@@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -77,11 +76,15 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao { ...@@ -77,11 +76,15 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
} }
@Override @Override
public void deleteByPlanIds(List<Long> planIds) { public void deleteByPlanIds(List<Long> planIds, String employeeNo) {
// 判断ID中是否包含今日数据 // 判断ID中是否包含之前数据、非个人数据
Integer count = activityPlanInfoMapper.selectNotDelCount(planIds); Integer count = activityPlanInfoMapper.selectNotDelCount(planIds,employeeNo);
if (count > 0 ) {
throw new DataException(RCode.ACTIVITY_PLAN_NOT_SELF_DELETE);
}
Integer countToday = activityPlanInfoMapper.selectTodayCount(planIds);
// 今日数据存在时,判断当前时间是否在今日10点前 // 今日数据存在时,判断当前时间是否在今日10点前
if (count > 0 && (LocalTime.now().getHour() >= 10)) { if (countToday > 0 && (LocalTime.now().getHour() >= 10)) {
throw new DataException(RCode.ACTIVITY_PLAN_NOT_DELETE); throw new DataException(RCode.ACTIVITY_PLAN_NOT_DELETE);
} }
activityPlanInfoMapper.updateIsDelete(planIds); activityPlanInfoMapper.updateIsDelete(planIds);
......
...@@ -26,9 +26,12 @@ public interface ActivityPlanInfoMapper extends BaseMapper<ActivityPlanInfoDo> { ...@@ -26,9 +26,12 @@ public interface ActivityPlanInfoMapper extends BaseMapper<ActivityPlanInfoDo> {
void updateIsDelete(List<Long> planIds); void updateIsDelete(List<Long> planIds);
Integer selectNotDelCount(@Param("planIds") List<Long> planIds); Integer selectNotDelCount(@Param("planIds") List<Long> planIds,@Param("employeeNo") String employeeNo);
void updateOne(@Param("pDo") ActivityPlanInfoDo pDo,@Param("recordId") Long recordId); void updateOne(@Param("pDo") ActivityPlanInfoDo pDo,@Param("recordId") Long recordId);
Integer selectTodayCount(List<Long> planIds);
} }
......
...@@ -16,7 +16,7 @@ public interface PromPlanCoreService { ...@@ -16,7 +16,7 @@ public interface PromPlanCoreService {
void selfPlanAf(String planUuid); void selfPlanAf(String planUuid);
void deletePlan(List<Long> planIds); void deletePlan(List<Long> planIds,String employeeNo);
Map<String, Object> authPlanUp(ActivityPlanVo activityPlanVo, String filePath) throws DataException; Map<String, Object> authPlanUp(ActivityPlanVo activityPlanVo, String filePath) throws DataException;
......
...@@ -641,7 +641,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -641,7 +641,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
} }
@Override @Override
public void deletePlan(List<Long> planIds) { public void deletePlan(List<Long> planIds,String employeeNo) {
activityPlanInfoDao.deleteByPlanIds(planIds); activityPlanInfoDao.deleteByPlanIds(planIds, employeeNo);
} }
} }
...@@ -114,7 +114,21 @@ ...@@ -114,7 +114,21 @@
#{item} #{item}
</foreach> </foreach>
and is_delete = 1 and is_delete = 1
and date &lt;= now() and date &lt; date_format(now(),'%Y-%m-%d')
<if test="employeeNo != null and employeeNo != ''">
or employee_no != #{employeeNo}
</if>
</select>
<select id="selectTodayCount" resultType="java.lang.Integer">
select count(*)
from activity_plan_info
where id in
<foreach collection="planIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
and is_delete = 1
and date = date_format(now(),'%Y-%m-%d')
</select> </select>
<update id="updateOne"> <update id="updateOne">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论