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

创建计划,修改计划(web页面)-城+职

上级 44b65bac
......@@ -5,6 +5,7 @@ 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.ManageEmployeeVo;
import com.wangxiaolu.promotion.pojo.activity.planv2.vo.ActivityPlanOperVo;
import com.wangxiaolu.promotion.pojo.user.dto.ManageEmployeeInfoDto;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode;
......@@ -158,6 +159,23 @@ public class PromPlanCoreController {
return R.success();
}
@PostMapping("/save")
public R saveWebActivityPlan(@RequestBody ActivityPlanOperVo operVo){
boolean oneSelf = manageEmployeeQueryService.isOneSelf(operVo.getEmployeeNo());
if (!oneSelf){
throw new ParamException(RCode.ACTIVITY_PLAN_EMPLOYEE_ERROR);
}
promPlanCoreService.saveActivityPlan(operVo);
return R.success();
}
@PutMapping("/update")
public R putActivityPlan(@RequestBody ActivityPlanOperVo operVo){
if (Objects.isNull(operVo.getId())){
throw new ParamException(RCode.NEED_PARAM_ERROR);
}
promPlanCoreService.putActivityPlan(operVo);
return R.success();
}
}
......@@ -3,7 +3,7 @@ package com.wangxiaolu.promotion.domain.activityplanv2.dao;
import com.alibaba.fastjson.JSONArray;
import com.wangxiaolu.promotion.domain.manage.wrapperQo.ActivityPlanInfoWrapper;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanInfoDto;
import java.util.Date;
import java.util.List;
......@@ -23,4 +23,10 @@ public interface ActivityPlanInfoDao {
void deleteByPlanIds(List<Long> planIds, String employeeNo);
void updateList(JSONArray table, Long recordId);
ActivityPlanInfoDto selectById(Long id);
void updateById(ActivityPlanInfoDto planDto);
void save(ActivityPlanInfoDto planDto);
}
package com.wangxiaolu.promotion.domain.activityplanv2.dao.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangxiaolu.promotion.common.enums.StatusType;
......@@ -11,7 +12,7 @@ import com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlan
import com.wangxiaolu.promotion.domain.manage.wrapperQo.ActivityPlanInfoWrapper;
import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.result.basedata.RCode;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.exceptions.PersistenceException;
......@@ -60,6 +61,25 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
}
}
@Override
public ActivityPlanInfoDto selectById(Long id) {
ActivityPlanInfoDo activityPlanInfoDo = activityPlanInfoMapper.selectById(id);
return BeanUtils.transitionDto(activityPlanInfoDo, ActivityPlanInfoDto.class);
}
@Override
public void updateById(ActivityPlanInfoDto planDto) {
ActivityPlanInfoDo planDo = BeanUtils.transitionDto(planDto, ActivityPlanInfoDo.class);
activityPlanInfoMapper.updateById(planDo);
}
@Override
public void save(ActivityPlanInfoDto planDto) {
ActivityPlanInfoDo planDo = new ActivityPlanInfoDo();
BeanUtils.copyProperties(planDto,planDo);
activityPlanInfoMapper.insert(planDo);
}
@Override
public void page(PageInfo pageInfo, ActivityPlanInfoWrapper wrapper) {
LambdaQueryWrapper<ActivityPlanInfoDo> qw = buildWrapper(wrapper);
......
......@@ -168,6 +168,16 @@ public class ActivityPlanInfoDo implements Serializable {
*/
private Integer isDelete;
/**
* 创建人
*/
private String createBy;
/**
* 最近修改人
*/
private String modifyBy;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.wangxiaolu.promotion.pojo.activity.manage.dto;
package com.wangxiaolu.promotion.pojo.activity.planv2.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
......@@ -164,7 +164,13 @@ public class ActivityPlanInfoDto implements Serializable {
* 错误信息
*/
private String errorMsg;
/**
* 操作人
*/
// private Long createId;
private String createBy;
private String modifyBy;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
......
package com.wangxiaolu.promotion.pojo.activity.manage.dto;
package com.wangxiaolu.promotion.pojo.activity.planv2.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
......
package com.wangxiaolu.promotion.pojo.activity.planv2.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @author : liqiulin
* @date : 2025-02-17 13
* @describe :
*/
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Data
public class ActivityPlanOperVo {
/**
* 主键id
*/
private Long id;
/**
* 计划归属人
*/
private String employeeNo;
/**
* 操作人
*/
// private Long operId;
private String operName;
private String operNo;
/**
* 日期
*/
private Date date;
/**
* 门店编码
*/
private String storeCode;
/**
* 活动模式
*/
private String pattern;
/**
* 上班时间
*/
private LocalDateTime clockInTime;
/**
* 下班时间
*/
private LocalDateTime clockOutTime;
/**
* 工资
*/
private BigDecimal salary;
/**
* 杂费
*/
private BigDecimal incidentals;
}
......@@ -70,7 +70,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
// 判断是否已存在保存数据
TemporaryActivityReportedDto haveDate = temporaryActivityReportedDao.findOneByCurrentDate(temActDto.getTemporaryId());
if (Objects.nonNull(haveDate)) {
throw new FlowException(RCode.DATA_HAVE_ERROR, null);
throw new FlowException(RCode.DATA_HAVE_ERROR);
}
// 返回生成的活动id
......
......@@ -2,6 +2,7 @@ package com.wangxiaolu.promotion.service.activityplanv2;
import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import com.wangxiaolu.promotion.pojo.activity.planv2.vo.ActivityPlanOperVo;
import java.util.List;
import java.util.Map;
......@@ -21,4 +22,8 @@ public interface PromPlanCoreService {
Map<String, Object> authPlanUp(ActivityPlanVo activityPlanVo, String filePath) throws DataException;
Map<String, Object> selfPlanPut(ActivityPlanVo activityPlanVo, String filePath) throws DataException;
void putActivityPlan(ActivityPlanOperVo activityPlanOperVo);
void saveActivityPlan(ActivityPlanOperVo operVo);
}
package com.wangxiaolu.promotion.service.activityplanv2.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
......@@ -17,14 +18,18 @@ import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper;
import com.wangxiaolu.promotion.enums.plan.OperationType;
import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanRecordDto;
import com.wangxiaolu.promotion.exception.FlowException;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.pojo.activity.planv2.dto.ActivityPlanRecordDto;
import com.wangxiaolu.promotion.pojo.activity.manage.vo.ActivityPlanVo;
import com.wangxiaolu.promotion.pojo.activity.planv2.vo.ActivityPlanOperVo;
import com.wangxiaolu.promotion.pojo.user.dto.ManageEmployeeInfoDto;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activityplanv2.PromPlanCoreService;
import com.wangxiaolu.promotion.utils.DateUtils;
import groovyjarjarpicocli.CommandLine;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -155,6 +160,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setEmployeeName(planVo.getEmployeeName());
dto.setOrgQcId(planVo.getDeptQcId());
dto.setOrgName(planVo.getDeptQcName());
dto.setCreateBy(planVo.getEmployeeName());
}
/**
......@@ -348,6 +354,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setEmployeeName(employeeInfoDto.getName());
dto.setOrgQcId(employeeInfoDto.getDeptQcId());
dto.setOrgName(employeeInfoDto.getDeptQcName());
dto.setCreateBy(planVo.getEmployeeName());
}
}
......@@ -445,7 +452,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
@Override
public Map<String, Object> selfPlanPut(ActivityPlanVo planVo, String filePath) throws DataException {
// 1、解析活动计划文件是否符合规范
Map<String, Object> map = readSheetByCSJLPut(filePath);
Map<String, Object> map = readSheetByCSJLPut(planVo,filePath);
if (!map.containsKey("uuid")){
return map;
}
......@@ -465,10 +472,78 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
return map;
}
@Override
public void putActivityPlan(ActivityPlanOperVo operVo) {
// if (activityPlanOperVo.getClockInTime().isAfter(activityPlanOperVo.getClockOutTime())) {
// throw new ParamException(RCode.API_DATA_ERROR);
// }
ActivityPlanInfoDto dto = activityPlanInfoDao.selectById(operVo.getId());
// 已执行的计划不可修改
if (PlanStatus.EXECUTION.getCode().equals(dto.getPlanStatus())){
throw new FlowException(RCode.ACTIVITY_PLAN_EXECUTE_ERROR);
}
// 判断修改时间是否在促销员上班1小时内
if (LocalDateTime.now().isAfter(dto.getClockInTime().plusHours(1))){
dto.setErrorMsg("已超促销员上班时间1小时,不可修改;");
}
ActivityPlanInfoDto planDto = new ActivityPlanInfoDto();
planDto.setId(operVo.getId())
.setPattern(operVo.getPattern())
.setClockInTime(operVo.getClockInTime())
.setClockOutTime(operVo.getClockOutTime())
.setSalary(operVo.getSalary())
.setIncidentals(operVo.getIncidentals())
.setModifyBy(operVo.getOperName());
activityPlanInfoDao.updateById(planDto);
}
@Override
public void saveActivityPlan(ActivityPlanOperVo operVo) {
ActivityPlanInfoDto planDto = new ActivityPlanInfoDto();
StoreWrapper storeWrap = new StoreWrapper().setStoreCode(operVo.getStoreCode());
QinCeClienteleStoreDto storeDto = qinCeClienteleStoreDao.getOneStore(storeWrap);
if (ObjectUtil.isEmpty(storeDto)) {
throw new ParamException(RCode.QINCE_STORE_CODE_ERROR);
}
if (StringUtils.isAnyBlank(storeDto.getLineName(), storeDto.getDealersName(), storeDto.getDealerId())) {
throw new ParamException(RCode.ACTIVITY_PLAN_EXECUTE_ERROR);
}
ManageEmployeeInfoDto empDto = manageEmployeeInfoDao.selectOne(new ManageEmployeeWrapper().setEmployeeNo(operVo.getEmployeeNo()));
LocalDate planDate = operVo.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
planDto.setPlanFileId(0L)
.setEmployeeId(empDto.getId())
.setEmployeeName(empDto.getName())
.setEmployeeNo(empDto.getEmployeeNo())
.setYear(planDate.getYear())
.setMonth(planDate.getMonthValue())
.setDate(operVo.getDate())
.setLineName(storeDto.getLineName())
.setStoreName(storeDto.getStoreName())
.setStoreCode(operVo.getStoreCode())
.setOrgName(empDto.getDeptQcName())
.setOrgQcId(empDto.getDeptQcId())
.setPattern(operVo.getPattern())
.setDealerId(storeDto.getDealerId())
.setDealerName(storeDto.getDealersName())
.setProvince(storeDto.getStoreMssProvince())
.setCity(storeDto.getStoreMssCity())
.setArea(storeDto.getStoreMssArea())
.setAddr(storeDto.getStoreAddr())
.setClockInTime(operVo.getClockInTime())
.setClockOutTime(operVo.getClockOutTime())
.setSalary(operVo.getSalary())
.setIncidentals(operVo.getIncidentals())
.setCreateBy(operVo.getOperName());
activityPlanInfoDao.save(planDto);
}
/**
* 城市经理 - 修改计划
*/
private Map<String, Object> readSheetByCSJLPut(String filePath) throws DataException {
private Map<String, Object> readSheetByCSJLPut(ActivityPlanVo planVo,String filePath) throws DataException {
ReadExcelUtils readExcelUtils = new ReadExcelUtils(filePath);
String[] headers = readExcelUtils.readTitle();
Map<Integer, List<Object>> rows = readExcelUtils.readContent();
......@@ -499,7 +574,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
List<ActivityPlanInfoDto> rDtos = new ArrayList<>(rows.size() * 4);
for (Map.Entry<Integer, List<Object>> row : rows.entrySet()) {
List<ActivityPlanInfoDto> infoDtos = getRowByCSJLPut(row.getValue(),rMap);
List<ActivityPlanInfoDto> infoDtos = getRowByCSJLPut(planVo,row.getValue(),rMap);
rDtos.addAll(infoDtos);
}
rMap.put("table", rDtos);
......@@ -509,7 +584,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
/**
* 城市经理 - 修改计划
*/
private List<ActivityPlanInfoDto> getRowByCSJLPut(List<Object> row, Map<String, Object> rMap) {
private List<ActivityPlanInfoDto> getRowByCSJLPut(ActivityPlanVo planVo,List<Object> row, Map<String, Object> rMap) {
List<ActivityPlanInfoDto> dtos = new ArrayList<>();
/**
......@@ -554,9 +629,10 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setCity(storeDto.getStoreMssCity());
dto.setArea(storeDto.getStoreMssArea());
dto.setAddr(storeDto.getStoreAddr());
dto.setModifyBy(planVo.getEmployeeName());
}
// todo 判断计划是否已存在,不存在的计划直接跳过
// 判断计划是否已存在,不存在的计划直接跳过
ActivityPlanInfoDto hasDto = activityPlanInfoDao.selectPlan(dto.getStoreCode(), dto.getDate());
if (Objects.isNull(hasDto)) {
dto.setErrorMsg("计划不存在;");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论