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

职能角色上传促销计划,文件名获取修改;修改部分促销计划修改逻辑

上级 504ca33b
......@@ -4,11 +4,9 @@
mvn package -DskipTests
docker stop promotion-service
docker stop promotion-service && docker rm promotion-service
docker rm promotion-service
docker rmi
docker rmi promotion-service
docker build -t promotion-service:latest .
......@@ -17,6 +15,7 @@ Live启动:
docker run -d -p 8011:8011 --name promotion-service \
-v /var/logs/promotion-service/:/var/logs/promotion-service/ \
-v /var/logs/xxl_job/:/var/logs/xxl_job/ \
-v /root/promotion/planv2/:/root/promotion/planv2/ \
--restart=always \
--network host \
promotion-service:latest
......@@ -26,6 +25,7 @@ QA启动:
docker run -d -p 8011:8011 --name promotion-service \
-v /var/logs/promotion-service/:/var/logs/promotion-service/ \
-v /var/logs/xxl_job/:/var/logs/xxl_job/ \
-v /root/promotion/planv2/:/root/promotion/planv2/ \
--restart=always \
--network host \
promotion-service:latest \
......
......@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.Objects;
/**
* @author : liqiulin
......@@ -67,13 +68,13 @@ public class PromPlanCoreController {
/**
* 城市经理修改
* 职能角色 - 上传计划(新增)
*/
@PutMapping("/self/put")
public R selfPlanPut(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否是城市经理
boolean isSelf = manageEmployeeQueryService.isOneSelf(activityPlanVo.getEmployeeNo());
if (!isSelf) {
@PostMapping("/auth/upload")
public R authPlan(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否是城市经理
boolean isAuth = manageEmployeeQueryService.isAuth(activityPlanVo.getEmployeeNo());
if (!isAuth) {
throw new DataException(RCode.EMP_PRIVILEGE_ERROR);
}else {
ManageEmployeeInfoDto one = manageEmployeeQueryService.findOne(new ManageEmployeeVo().setEmployeeNo(activityPlanVo.getEmployeeNo()));
......@@ -82,76 +83,63 @@ public class PromPlanCoreController {
.setDeptQcId(one.getDeptQcId())
.setDeptQcName(one.getDeptQcName());
}
try {
String[] urlArr = activityPlanVo.getExcelUrl().split("/");
String fileId = urlArr[urlArr.length - 1];
String filePath = "/root/promotion/planv2/" + fileId;
//todo String filePath = "/Users/a02200059/Desktop/2.0/" + fileId;
FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
// todo String filePath = "/Users/a02200059/Desktop/职能角色-新增-1.xlsx";
activityPlanVo.setExcelId(fileId);
Map<String, Object> map = promPlanCoreService.selfPlanPut(activityPlanVo, filePath);
Map<String, Object> map = promPlanCoreService.authPlanUp(activityPlanVo, filePath);
return R.success(map);
} catch (DataException e) {
return new R(e.getCode(), e.getMsg(), null);
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
}
/**
* todo 职能角色修改
* 确认上传(根据任一UUID)
*/
@GetMapping("/upload/{uuid}")
public R selfPlanAf(@PathVariable("uuid") String planUuid){
promPlanCoreService.selfPlanAf(planUuid);
return R.success();
}
/**
* 职能角色 - 上传计划(新增)
* 促销计划修改
*/
@PostMapping("/auth/upload")
public R authPlan(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否是城市经理
boolean isAuth = manageEmployeeQueryService.isAuth(activityPlanVo.getEmployeeNo());
if (!isAuth) {
@PutMapping("/put")
public R planPut(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否正常
ManageEmployeeInfoDto one = manageEmployeeQueryService.findOne(new ManageEmployeeVo().setEmployeeNo(activityPlanVo.getEmployeeNo()));
if (Objects.isNull(one)) {
throw new DataException(RCode.EMP_PRIVILEGE_ERROR);
}else {
ManageEmployeeInfoDto one = manageEmployeeQueryService.findOne(new ManageEmployeeVo().setEmployeeNo(activityPlanVo.getEmployeeNo()));
activityPlanVo.setEmployeeId(one.getId())
.setEmployeeName(one.getName())
.setDeptQcId(one.getDeptQcId())
.setDeptQcName(one.getDeptQcName());
}
activityPlanVo.setEmployeeId(one.getId())
.setEmployeeName(one.getName())
.setDeptQcId(one.getDeptQcId())
.setDeptQcName(one.getDeptQcName());
try {
String[] urlArr = activityPlanVo.getExcelUrl().split("weda-uploader/");
String[] urlArr = activityPlanVo.getExcelUrl().split("/");
String fileId = urlArr[urlArr.length - 1];
if (fileId.length() > 53) {
throw new DataException(RCode.ACTIVITY_PLAN_FILENAME_LONG);
}
String filePath = "/root/promotion/planv2/" + fileId;
FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
// todo String filePath = "/Users/a02200059/Desktop/职能角色-新增-1.xlsx";
//todo String filePath = "/root/promotion/planv2/" + fileId;
String filePath = "/Users/a02200059/Desktop/2.0/" + fileId;
// FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
activityPlanVo.setExcelId(fileId);
Map<String, Object> map = promPlanCoreService.authPlanUp(activityPlanVo, filePath);
Map<String, Object> map = promPlanCoreService.selfPlanPut(activityPlanVo, filePath);
return R.success(map);
} catch (DataException e) {
return new R(e.getCode(), e.getMsg(), null);
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
/**
* 确认上传(根据任一UUID)
*/
@GetMapping("/upload/{uuid}")
public R selfPlanAf(@PathVariable("uuid") String planUuid){
promPlanCoreService.selfPlanAf(planUuid);
return R.success();
}
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
......@@ -130,12 +131,12 @@ public class ActivityPlanInfoDo implements Serializable {
/**
* 上班时间
*/
private Date clockInTime;
private LocalDateTime clockInTime;
/**
* 下班时间
*/
private Date clockOutTime;
private LocalDateTime clockOutTime;
/**
* 工资
......
......@@ -442,7 +442,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
@Override
public Map<String, Object> selfPlanPut(ActivityPlanVo planVo, String filePath) throws DataException {
// 1、解析活动计划文件是否符合规范
Map<String, Object> map = readSheetByCSJLPut(planVo, filePath);
Map<String, Object> map = readSheetByCSJLPut(filePath);
if (!map.containsKey("uuid")){
return map;
}
......@@ -464,7 +464,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
/**
* 城市经理 - 修改计划
*/
private Map<String, Object> readSheetByCSJLPut(ActivityPlanVo planVo, String filePath) throws DataException {
private Map<String, Object> readSheetByCSJLPut(String filePath) throws DataException {
ReadExcelUtils readExcelUtils = new ReadExcelUtils(filePath);
String[] headers = readExcelUtils.readTitle();
Map<Integer, List<Object>> rows = readExcelUtils.readContent();
......@@ -495,7 +495,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(planVo, row.getValue(),rMap);
List<ActivityPlanInfoDto> infoDtos = getRowByCSJLPut(row.getValue(),rMap);
rDtos.addAll(infoDtos);
}
rMap.put("table", rDtos);
......@@ -505,7 +505,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
/**
* 城市经理 - 修改计划
*/
private List<ActivityPlanInfoDto> getRowByCSJLPut(ActivityPlanVo planVo, List<Object> row, Map<String, Object> rMap) {
private List<ActivityPlanInfoDto> getRowByCSJLPut(List<Object> row, Map<String, Object> rMap) {
List<ActivityPlanInfoDto> dtos = new ArrayList<>();
/**
......@@ -532,6 +532,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
* 1:门店编码
*/
String sc = row.get(1).toString();
dto.setStoreCode(sc);
StoreWrapper storeWrap = new StoreWrapper().setStoreCode(sc);
QinCeClienteleStoreDto storeDto = qinCeClienteleStoreDao.getOneStore(storeWrap);
if (ObjectUtil.isEmpty(storeDto)) {
......@@ -549,23 +550,18 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setAddr(storeDto.getStoreAddr());
}
// todo 判断计划是否已存在,不存在的计划直接跳过
ActivityPlanInfoDto hasDto = activityPlanInfoDao.selectPlan(dto.getStoreCode(), dto.getDate());
if (Objects.isNull(hasDto)) {
dto.setErrorMsg("计划不存在;");
if (StringUtils.isNotBlank(dto.getErrorMsg())) {
rMap.remove("uuid");
}
dtos.add(dto);
continue;
} else if (PlanStatus.EXECUTION.getCode().equals(hasDto.getPlanStatus())) {
dto.setErrorMsg("计划已执行,不可修改;");
} else if (hasDto.getEmployeeNo().equals(row.get(0).toString())) {
} else if (!hasDto.getEmployeeNo().equals(row.get(0).toString())) {
dto.setErrorMsg("计划不属于"+row.get(0)+",归属人:" + hasDto.getEmployeeName() + ";");
}
......@@ -581,9 +577,10 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setClockInTime(LocalDateTime.of(planDate, inLocalTime));
dto.setClockOutTime(LocalDateTime.of(planDate, outLocalTime));
}
if (DateUtil.isSameDay(dto.getDate(), hasDto.getDate()) && hasDto.getClockInTime().plusHours(1).isAfter(LocalDateTime.now())){
dto.setErrorMsg("已超当天上班时间1小时,不可修改;");
LocalDateTime localDateTime = hasDto.getClockInTime().plusHours(1);
LocalDateTime now = LocalDateTime.now();
if (LocalDateTime.now().isAfter(hasDto.getClockInTime().plusHours(1))){
dto.setErrorMsg("已超促销员上班时间1小时,不可修改;");
}
/**
......
......@@ -30,6 +30,7 @@
<result property="planStatus" column="plan_status" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="clockInTime" column="clock_in_time" jdbcType="TIMESTAMP"/>
<result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
</resultMap>
......@@ -40,6 +41,7 @@
<result property="employeeNo" column="employee_no" jdbcType="VARCHAR"/>
<result property="province" column="province" jdbcType="VARCHAR"/>
<result property="planStatus" column="plan_status" jdbcType="INTEGER"/>
<result property="clockInTime" column="clock_in_time" jdbcType="DATE"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
</resultMap>
......@@ -77,7 +79,7 @@
</insert>
<select id="selectPlan" resultMap="SimResultMap">
select id,employee_name,employee_no,province,plan_status,create_time,modify_time
select id,employee_name,employee_no,province,plan_status,clock_in_time,create_time,modify_time
from activity_plan_info
where date = #{date} and store_code = #{storeCode} and is_delete = 1;
</select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论