提交 6925b5c2 authored 作者: 李秋林's avatar 李秋林

删除计划 计划日期大于今日可直接删除,如果计划日期是今日则必需是10点之前,包含过去日期不可删除

上级 416c68b9
package com.wangxiaolu.promotion.controller.activityplanv2; package com.wangxiaolu.promotion.controller.activityplanv2;
import com.wangxiaolu.promotion.common.excel.FileUtils;
import com.wangxiaolu.promotion.exception.DataException; import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo; import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import com.wangxiaolu.promotion.result.basedata.R; import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService; import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService;
import com.wangxiaolu.promotion.service.user.ManageEmployeeQueryService; import com.wangxiaolu.promotion.service.user.ManageEmployeeQueryService;
import io.jsonwebtoken.lang.Collections;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -45,14 +48,16 @@ public class PromPlanCoreController { ...@@ -45,14 +48,16 @@ public class PromPlanCoreController {
throw new DataException(RCode.ACTIVITY_PLAN_FILENAME_LONG); throw new DataException(RCode.ACTIVITY_PLAN_FILENAME_LONG);
} }
//todo String filePath = "/home/" + fileId; String filePath = "/home/" + fileId;
// FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath); FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
String filePath = "/Users/a02200059/Desktop/测试新增v3 2.xlsx"; // todo String filePath = "/Users/a02200059/Desktop/测试新增v3 2.xlsx";
activityPlanVo.setExcelId(fileId); activityPlanVo.setExcelId(fileId);
Map<String, Object> map = promPlanCoreService.selfPlanUp(activityPlanVo, filePath); Map<String, Object> map = promPlanCoreService.selfPlanUp(activityPlanVo, filePath);
return R.success(map); return R.success(map);
} catch (DataException e) { } catch (DataException e) {
return new R(e.getCode(), e.getMsg(), null); return new R(e.getCode(), e.getMsg(), null);
} catch (Exception e) {
return R.fail();
} }
} }
...@@ -66,9 +71,40 @@ public class PromPlanCoreController { ...@@ -66,9 +71,40 @@ public class PromPlanCoreController {
* 职能角色 - 上传计划 * 职能角色 - 上传计划
*/ */
@GetMapping("/auth/upload") @GetMapping("/auth/upload")
public void authPlan() { public void authPlan(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否是城市经理
// boolean isSelf = manageEmployeeQueryService.isOneSelf(activityPlanVo.getEmployeeId());
// if (!isSelf) {
// throw new DataException(RCode.EMP_PRIVILEGE_ERROR);
// }
//
// try {
// String[] urlArr = activityPlanVo.getExcelUrl().split("weda-uploader/");
// String fileId = urlArr[urlArr.length - 1];
// if (fileId.length() > 53) {
// throw new DataException(RCode.ACTIVITY_PLAN_FILENAME_LONG);
// }
//
// String filePath = "/home/" + fileId;
// FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
// String filePath = "/Users/a02200059/Desktop/测试新增v3 2.xlsx";
// activityPlanVo.setExcelId(fileId);
// Map<String, Object> map = promPlanCoreService.selfPlanUp(activityPlanVo, filePath);
// return R.success(map);
// } catch (DataException e) {
// return new R(e.getCode(), e.getMsg(), null);
}
/**
* 删除计划 计划日期大于今日可直接删除,如果计划日期是今日则必需是10点之前,包含过去日期不可删除
*/
@DeleteMapping("/delete")
public R deletePlan(@RequestBody ActivityPlanVo activityPlanVo){
if (Collections.isEmpty(activityPlanVo.getPlanIds())){
throw new ParamException(RCode.NEED_PARAM_ERROR);
}
promPlanCoreService.deletePlan(activityPlanVo.getPlanIds());
return R.success();
} }
......
...@@ -6,6 +6,7 @@ import com.wangxiaolu.promotion.pojo.PageInfo; ...@@ -6,6 +6,7 @@ import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto; import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author : liqiulin * @author : liqiulin
...@@ -18,4 +19,6 @@ public interface ActivityPlanInfoDao { ...@@ -18,4 +19,6 @@ public interface ActivityPlanInfoDao {
void page(PageInfo pageInfo, ActivityPlanInfoWrapper wrapper); void page(PageInfo pageInfo, ActivityPlanInfoWrapper wrapper);
ActivityPlanInfoDto selectPlan(String storeCode, Date date); ActivityPlanInfoDto selectPlan(String storeCode, Date date);
void deleteByPlanIds(List<Long> planIds);
} }
...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangxiaolu.promotion.common.enums.StatusType; import com.wangxiaolu.promotion.common.enums.StatusType;
import com.wangxiaolu.promotion.common.util.BeanUtils; import com.wangxiaolu.promotion.common.util.BeanUtils;
import com.wangxiaolu.promotion.common.util.DataUtils;
import com.wangxiaolu.promotion.domain.activityplanv2.dao.ActivityPlanInfoDao; import com.wangxiaolu.promotion.domain.activityplanv2.dao.ActivityPlanInfoDao;
import com.wangxiaolu.promotion.domain.activityplanv2.mapper.ActivityPlanInfoMapper; import com.wangxiaolu.promotion.domain.activityplanv2.mapper.ActivityPlanInfoMapper;
import com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlanInfoDo; import com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlanInfoDo;
...@@ -19,7 +18,9 @@ import org.apache.ibatis.exceptions.PersistenceException; ...@@ -19,7 +18,9 @@ import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalTime;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -58,6 +59,17 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao { ...@@ -58,6 +59,17 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
return BeanUtils.transitionDto(activityPlanInfoDo, ActivityPlanInfoDto.class); return BeanUtils.transitionDto(activityPlanInfoDo, ActivityPlanInfoDto.class);
} }
@Override
public void deleteByPlanIds(List<Long> planIds) {
// 判断ID中是否包含今日数据
Integer count = activityPlanInfoMapper.selectNotDelCount(planIds);
// 今日数据存在时,判断当前时间是否在今日10点前
if (count > 0 && (LocalTime.now().getHour() >= 10)) {
throw new DataException(RCode.ACTIVITY_PLAN_NOT_DELETE);
}
activityPlanInfoMapper.updateIsDelete(planIds);
}
private LambdaQueryWrapper<ActivityPlanInfoDo> buildWrapper(ActivityPlanInfoWrapper wrapper) { private LambdaQueryWrapper<ActivityPlanInfoDo> buildWrapper(ActivityPlanInfoWrapper wrapper) {
LambdaQueryWrapper<ActivityPlanInfoDo> qw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ActivityPlanInfoDo> qw = new LambdaQueryWrapper<>();
......
...@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author a02200059 * @author a02200059
...@@ -22,6 +23,10 @@ public interface ActivityPlanInfoMapper extends BaseMapper<ActivityPlanInfoDo> { ...@@ -22,6 +23,10 @@ public interface ActivityPlanInfoMapper extends BaseMapper<ActivityPlanInfoDo> {
void saveList(@Param("table") JSONArray table,@Param("recordId") Long recordId); void saveList(@Param("table") JSONArray table,@Param("recordId") Long recordId);
ActivityPlanInfoDo selectPlan(String storeCode, Date date); ActivityPlanInfoDo selectPlan(String storeCode, Date date);
void updateIsDelete(List<Long> planIds);
Integer selectNotDelCount(@Param("planIds") List<Long> planIds);
} }
......
...@@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; ...@@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author : liqiulin * @author : liqiulin
...@@ -41,4 +42,7 @@ public class ActivityPlanVo { ...@@ -41,4 +42,7 @@ public class ActivityPlanVo {
private Integer originalEmpId; private Integer originalEmpId;
private Integer transferEmpId; private Integer transferEmpId;
private Long planId;
private List<Long> planIds;
} }
...@@ -3,6 +3,7 @@ package com.wangxiaolu.promotion.service.activityplanv2; ...@@ -3,6 +3,7 @@ package com.wangxiaolu.promotion.service.activityplanv2;
import com.wangxiaolu.promotion.exception.DataException; import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo; import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -14,4 +15,7 @@ public interface PromPlanCoreService { ...@@ -14,4 +15,7 @@ public interface PromPlanCoreService {
Map<String,Object> selfPlanUp(ActivityPlanVo activityPlanVo, String filePath) throws DataException; Map<String,Object> selfPlanUp(ActivityPlanVo activityPlanVo, String filePath) throws DataException;
void selfPlanAf(String planUuid); void selfPlanAf(String planUuid);
void deletePlan(List<Long> planIds);
} }
...@@ -87,6 +87,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -87,6 +87,11 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
activityPlanInfoDao.saveList(table,recordId); activityPlanInfoDao.saveList(table,recordId);
} }
@Override
public void deletePlan(List<Long> planIds) {
activityPlanInfoDao.deleteByPlanIds(planIds);
}
/** /**
* 解析excel文件中的计划 * 解析excel文件中的计划
* @param planVo 请求信息(包含人员信息) * @param planVo 请求信息(包含人员信息)
......
...@@ -27,7 +27,7 @@ public class ManageEmployeeCoreServiceImpl implements ManageEmployeeCoreService ...@@ -27,7 +27,7 @@ public class ManageEmployeeCoreServiceImpl implements ManageEmployeeCoreService
@Override @Override
public void openAccount(UserLoginParam param) { public void openAccount(UserLoginParam param) {
// todo 判断账号在勤策中是否存在 // 判断账号在勤策中是否存在
int count = qinCeEmployeeDao.count(new EmployeeWrapper().setEmpCode(param.getLoginName())); int count = qinCeEmployeeDao.count(new EmployeeWrapper().setEmpCode(param.getLoginName()));
if (count <= 0){ if (count <= 0){
throw new DataException(RCode.QC_USER_IS_NULL_ERROR); throw new DataException(RCode.QC_USER_IS_NULL_ERROR);
......
...@@ -72,4 +72,24 @@ ...@@ -72,4 +72,24 @@
where date = #{date} and store_code = #{storeCode} and is_delete = 1; where date = #{date} and store_code = #{storeCode} and is_delete = 1;
</select> </select>
<update id="updateIsDelete" parameterType="java.util.List">
update activity_plan_info
set is_delete = 0
where id in
<foreach collection="planIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<select id="selectNotDelCount" 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 &lt;= now()
</select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论