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

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

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