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

修改计划逻辑;上传计划文件获取url中的文件名;

上级 764e15bd
...@@ -42,15 +42,11 @@ public class PromPlanCoreController { ...@@ -42,15 +42,11 @@ public class PromPlanCoreController {
} }
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) { String filePath = "/root/promotion/planv2/" + fileId;
throw new DataException(RCode.ACTIVITY_PLAN_FILENAME_LONG); //todo String filePath = "/Users/a02200059/Desktop/2.0/" + fileId;
}
String filePath = "/home/" + fileId;
FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath); FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
// 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);
...@@ -63,9 +59,31 @@ public class PromPlanCoreController { ...@@ -63,9 +59,31 @@ public class PromPlanCoreController {
/** /**
* todo 城市经理修改 * 城市经理修改
*/ */
@PutMapping("/self/put")
public R selfPlanPut(@RequestBody ActivityPlanVo activityPlanVo) {
// 判断当前账号是否是城市经理
boolean isSelf = manageEmployeeQueryService.isOneSelf(activityPlanVo.getEmployeeId());
if (!isSelf) {
throw new DataException(RCode.EMP_PRIVILEGE_ERROR);
}
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);
activityPlanVo.setExcelId(fileId);
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();
}
}
......
package com.wangxiaolu.promotion.enums.plan;
/**
* @author : liqiulin
* @date : 2025-02-12 17
* @describe :
*/
public enum PlanStatus {
/**
* 是否执行:1:执行;0:未执行;
*/
EXECUTION(1, "执行"),
NOT_EXECUTION(0, "未执行");
private final Integer code;
private final String desc;
PlanStatus(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
}
...@@ -18,5 +18,7 @@ public interface PromPlanCoreService { ...@@ -18,5 +18,7 @@ public interface PromPlanCoreService {
void deletePlan(List<Long> planIds); void deletePlan(List<Long> planIds);
Map<String, Object> authPlanUp(ActivityPlanVo activityPlanVo, String filePath); Map<String, Object> authPlanUp(ActivityPlanVo activityPlanVo, String filePath) throws DataException;
Map<String, Object> selfPlanPut(ActivityPlanVo activityPlanVo, String filePath) throws DataException;
} }
...@@ -14,6 +14,7 @@ import com.wangxiaolu.promotion.domain.activityplanv2.dao.ActivityPlanInfoDao; ...@@ -14,6 +14,7 @@ import com.wangxiaolu.promotion.domain.activityplanv2.dao.ActivityPlanInfoDao;
import com.wangxiaolu.promotion.domain.activityplanv2.dao.ActivityPlanRecordDao; import com.wangxiaolu.promotion.domain.activityplanv2.dao.ActivityPlanRecordDao;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao; import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao;
import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper; import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper;
import com.wangxiaolu.promotion.enums.plan.PlanStatus;
import com.wangxiaolu.promotion.exception.DataException; import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto; import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanInfoDto;
import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanRecordDto; import com.wangxiaolu.promotion.pojo.activity.manage.dto.ActivityPlanRecordDto;
...@@ -77,59 +78,9 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -77,59 +78,9 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
return map; return map;
} }
@Transactional(rollbackFor = Exception.class)
@Override
public synchronized void selfPlanAf(String planUuid) {
String key = RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey() + planUuid;
JSONObject mapJson = redisCache.getToJson(key);
if (Objects.isNull(mapJson)){
throw new DataException(RCode.REDIS_PUSH_DATA_NOT_EXIT);
}
redisCache.removeKey(key);
JSONObject record = mapJson.getJSONObject("record");
JSONArray table = mapJson.getJSONArray("table");
// 保存上传记录
Long recordId = activityPlanRecordDao.save(record);
activityPlanInfoDao.saveList(table,recordId);
}
@Override
public void deletePlan(List<Long> planIds) {
activityPlanInfoDao.deleteByPlanIds(planIds);
}
/**
* 职能角色 - 上传计划
*/
@Override
public Map<String, Object> authPlanUp(ActivityPlanVo planVo, String filePath) {
// 1、解析活动计划文件是否符合规范
Map<String, Object> map = readSheetByZNJSUp(planVo, filePath);
if (!map.containsKey("uuid")){
return map;
}
// 2、生成uuid并关联上传记录
ActivityPlanRecordDto record = new ActivityPlanRecordDto()
.setEmployeeId(planVo.getEmployeeId())
.setEmployeeName(planVo.getEmployeeName())
.setEmployeeNo(planVo.getEmployeeNo())
.setExcelUrl(planVo.getExcelUrl())
.setExcelFiledId(planVo.getExcelId());
map.put("record", record);
// 保存到缓存(uuid)
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey()+map.get("uuid").toString(),map,30);
// 返回结果
return map;
}
/** /**
* 解析excel文件中的计划 * 城市经理 - 上传计划
* @param planVo 请求信息(包含人员信息)
* @param filePath 文件地址
* @throws DataException 数据异常
*/ */
private Map<String, Object> readSheetByCSJLUp(ActivityPlanVo planVo, String filePath) throws DataException { private Map<String, Object> readSheetByCSJLUp(ActivityPlanVo planVo, String filePath) throws DataException {
ReadExcelUtils readExcelUtils = new ReadExcelUtils(filePath); ReadExcelUtils readExcelUtils = new ReadExcelUtils(filePath);
...@@ -170,11 +121,153 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -170,11 +121,153 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
} }
/**
* 城市经理 - 上传计划
*/
private List<ActivityPlanInfoDto> getRowByCSJLUp(ActivityPlanVo planVo, List<Object> row,Map<String, Object> rMap) {
List<ActivityPlanInfoDto> dtos = new ArrayList<>();
LocalDate now = LocalDate.now();
int nextMonthValue = now.plusMonths(1).getMonthValue();
/**
* 5:多日期
*/
String days = row.get(5).toString();
String[] dayArr = days.split("、");
for (int i = 0; i < dayArr.length; i++) {
ActivityPlanInfoDto dto = new ActivityPlanInfoDto();
try {
String dayStr = dayArr[i];
int day = Integer.parseInt(dayStr);
/**
* 0:工号
*/
Object empNoO = row.get(0);
if (!planVo.getEmployeeNo().equals(empNoO.toString())) {
dto.setErrorMsg("请填写您自己的工号;");
} else {
dto.setEmployeeId(planVo.getEmployeeId());
dto.setEmployeeNo(planVo.getEmployeeNo());
dto.setEmployeeName(planVo.getEmployeeName());
dto.setOrgQcId(planVo.getDeptQcId());
dto.setOrgName(planVo.getDeptQcName());
}
/**
* 1:门店编码
*/
String sc = row.get(1).toString();
StoreWrapper storeWrap = new StoreWrapper().setStoreCode(sc);
QinCeClienteleStoreDto storeDto = qinCeClienteleStoreDao.getOneStore(storeWrap);
if (ObjectUtil.isEmpty(storeDto)) {
dto.setErrorMsg("门店编码错误;");
} else {
if (StringUtils.isAnyBlank(storeDto.getLineName(), storeDto.getDealersName(), storeDto.getDealerId())) {
dto.setErrorMsg("门店「系统名称」或「经销商」为空,请到勤策中进充;");
}
dto.setLineName(storeDto.getLineName());
dto.setStoreCode(sc);
dto.setStoreName(storeDto.getStoreName());
dto.setDealerId(storeDto.getDealerId());
dto.setDealerName(storeDto.getDealersName());
dto.setProvince(storeDto.getStoreMssProvince());
dto.setCity(storeDto.getStoreMssCity());
dto.setArea(storeDto.getStoreMssArea());
dto.setAddr(storeDto.getStoreAddr());
}
/**
* 3:活动模式
*/
String pattern = row.get(3).toString();
if ("单点CP,常规MINI秀,校园活动".contains(pattern)) {
dto.setPattern(pattern);
} else {
dto.setErrorMsg("活动模式分为:单点CP、常规MINI秀、校园活动;");
}
/**
* 4:月份 新增逻辑只支持次月计划;
* 6:促销员上班时间 当月份错误,促销员上下班时间也不进行计算
* 7:促销员下班时间
* 年份:当月份为1时,判定为跨年
*/
int monthInt = Integer.parseInt(row.get(4).toString());
if (monthInt == nextMonthValue) {
int year = DateUtil.thisYear();
Month month = Month.of(monthInt);
if (month.equals(Month.JANUARY)) {
year += 1;
}
LocalDate planDate = LocalDate.of(year, month, day);
dto.setYear(year).setMonth(planDate.getMonthValue()).setDate(DateUtils.parseDateBylocalDate(planDate));
LocalTime inLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(6).toString());
LocalTime outLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(7).toString());
if (ObjectUtils.anyNull(inLocalTime, outLocalTime)) {
dto.setErrorMsg("上下班时间必填;");
}
if (ObjectUtils.allNotNull(inLocalTime, outLocalTime) && inLocalTime.isAfter(outLocalTime)) {
dto.setErrorMsg("下班时间需晚于上班时间;");
} else {
dto.setClockInTime(LocalDateTime.of(planDate, inLocalTime));
dto.setClockOutTime(LocalDateTime.of(planDate, outLocalTime));
}
} else {
dto.setErrorMsg("月份必需是下个月;");
}
// 8:工资
dto.setSalary(new BigDecimal(row.get(8).toString()));
// 9:杂费
dto.setIncidentals(new BigDecimal(row.get(9).toString()));
// 判断计划是否已存在
ActivityPlanInfoDto hasDto = activityPlanInfoDao.selectPlan(dto.getStoreCode(), dto.getDate());
if (Objects.nonNull(hasDto)) {
dto.setErrorMsg("计划已存在,创建人:" + hasDto.getEmployeeName() + ",创建时间:" + DateUtil.formatDate(hasDto.getCreateTime()) + ";");
}
} catch (DateTimeException e) {
dto.setErrorMsg("月份、日期、时间需要调整;");
}
if (StringUtils.isNotBlank(dto.getErrorMsg())){
rMap.remove("uuid");
}
dtos.add(dto);
}
return dtos;
}
/** /**
* 解析excel文件中的计划 * 职能角色 - 上传计划
* @param planVo 请求信息(包含人员信息) */
* @param filePath 文件地址 @Override
* @throws DataException 数据异常 public Map<String, Object> authPlanUp(ActivityPlanVo planVo, String filePath) throws DataException {
// 1、解析活动计划文件是否符合规范
Map<String, Object> map = readSheetByZNJSUp(planVo, filePath);
if (!map.containsKey("uuid")){
return map;
}
// 2、生成uuid并关联上传记录
ActivityPlanRecordDto record = new ActivityPlanRecordDto()
.setEmployeeId(planVo.getEmployeeId())
.setEmployeeName(planVo.getEmployeeName())
.setEmployeeNo(planVo.getEmployeeNo())
.setExcelUrl(planVo.getExcelUrl())
.setExcelFiledId(planVo.getExcelId());
map.put("record", record);
// 保存到缓存(uuid)
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey()+map.get("uuid").toString(),map,30);
// 返回结果
return map;
}
/**
* 职能角色 - 上传计划
*/ */
private Map<String, Object> readSheetByZNJSUp(ActivityPlanVo planVo, String filePath) throws DataException { private Map<String, Object> readSheetByZNJSUp(ActivityPlanVo planVo, String filePath) throws DataException {
ReadExcelUtils readExcelUtils = new ReadExcelUtils(filePath); ReadExcelUtils readExcelUtils = new ReadExcelUtils(filePath);
...@@ -215,11 +308,8 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -215,11 +308,8 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
} }
/** /**
* 城市经理上传的计划工号只能是自己 * 职能角色 - 上传计划
* @param row 表中的每一行数据
* @return
*/ */
private List<ActivityPlanInfoDto> getRowByZNJSUp(ActivityPlanVo planVo, List<Object> row,Map<String, Object> rMap) { private List<ActivityPlanInfoDto> getRowByZNJSUp(ActivityPlanVo planVo, List<Object> row,Map<String, Object> rMap) {
List<ActivityPlanInfoDto> dtos = new ArrayList<>(); List<ActivityPlanInfoDto> dtos = new ArrayList<>();
...@@ -346,17 +436,77 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -346,17 +436,77 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
return dtos; return dtos;
} }
/**
* 城市经理 - 修改计划
*/
@Override
public Map<String, Object> selfPlanPut(ActivityPlanVo planVo, String filePath) throws DataException {
// 1、解析活动计划文件是否符合规范
Map<String, Object> map = readSheetByCSJLPut(planVo, filePath);
if (!map.containsKey("uuid")){
return map;
}
// 2、生成uuid并关联上传记录
ActivityPlanRecordDto record = new ActivityPlanRecordDto()
.setEmployeeId(planVo.getEmployeeId())
.setEmployeeName(planVo.getEmployeeName())
.setEmployeeNo(planVo.getEmployeeNo())
.setExcelUrl(planVo.getExcelUrl())
.setExcelFiledId(planVo.getExcelId());
map.put("record", record);
// 保存到缓存(uuid)
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_PUT.getKey()+map.get("uuid").toString(),map,30);
// 返回结果
return map;
}
/** /**
* 城市经理上传的计划工号只能是自己 * 城市经理 - 修改计划
* @param row 表中的每一行数据
* @return
*/ */
private List<ActivityPlanInfoDto> getRowByCSJLUp(ActivityPlanVo planVo, List<Object> row,Map<String, Object> rMap) { 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();
if (headers.length != 10) {
throw new DataException(RCode.ACTIVITY_PLAN_TEM_ERROR);
}
if (CollectionUtil.isEmpty(rows)) {
throw new DataException(RCode.DATA_NOT_HAVE_ERROR);
}
boolean isEmpty = false;
ArrayList<Integer> indexList = new ArrayList<>();
for (Map.Entry<Integer, List<Object>> row : rows.entrySet()) {
List<Object> cells = row.getValue();
// 判断当前行是否有任一数据为空,如果有则报错,不进行解析
isEmpty = (cells.size() != 10) || cells.stream().anyMatch(cell -> ObjectUtil.isNull(cell) || StringUtils.isBlank(cell.toString()));
if (isEmpty) {
indexList.add(row.getKey() + 1);
}
}
if (CollectionUtil.isNotEmpty(indexList)) {
throw new DataException(RCode.ACTIVITY_PLAN_CELL_NOT_NULL, indexList);
}
Map<String, Object> rMap = new HashMap<>();
rMap.put("uuid", UUID.randomUUID().toString());
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);
rDtos.addAll(infoDtos);
}
rMap.put("table", rDtos);
return rMap;
}
/**
* 城市经理 - 修改计划
*/
private List<ActivityPlanInfoDto> getRowByCSJLPut(ActivityPlanVo planVo, List<Object> row, Map<String, Object> rMap) {
List<ActivityPlanInfoDto> dtos = new ArrayList<>(); List<ActivityPlanInfoDto> dtos = new ArrayList<>();
LocalDate now = LocalDate.now();
int nextMonthValue = now.plusMonths(1).getMonthValue();
/** /**
* 5:多日期 * 5:多日期
...@@ -368,20 +518,15 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -368,20 +518,15 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
try { try {
String dayStr = dayArr[i]; String dayStr = dayArr[i];
int day = Integer.parseInt(dayStr); int day = Integer.parseInt(dayStr);
int monthInt = Integer.parseInt(row.get(4).toString());
/** int year = DateUtil.thisYear();
* 0:工号 Month month = Month.of(monthInt);
*/ if (month.equals(Month.JANUARY)) {
Object empNoO = row.get(0); year += 1;
if (!planVo.getEmployeeNo().equals(empNoO.toString())) {
dto.setErrorMsg("请填写您自己的工号;");
} else {
dto.setEmployeeId(planVo.getEmployeeId());
dto.setEmployeeNo(planVo.getEmployeeNo());
dto.setEmployeeName(planVo.getEmployeeName());
dto.setOrgQcId(planVo.getDeptQcId());
dto.setOrgName(planVo.getDeptQcName());
} }
LocalDate planDate = LocalDate.of(year, month, day);
dto.setYear(year).setMonth(planDate.getMonthValue()).setDate(DateUtils.parseDateBylocalDate(planDate));
/** /**
* 1:门店编码 * 1:门店编码
...@@ -396,8 +541,6 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -396,8 +541,6 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setErrorMsg("门店「系统名称」或「经销商」为空,请到勤策中进充;"); dto.setErrorMsg("门店「系统名称」或「经销商」为空,请到勤策中进充;");
} }
dto.setLineName(storeDto.getLineName()); dto.setLineName(storeDto.getLineName());
dto.setStoreCode(sc);
dto.setStoreName(storeDto.getStoreName());
dto.setDealerId(storeDto.getDealerId()); dto.setDealerId(storeDto.getDealerId());
dto.setDealerName(storeDto.getDealersName()); dto.setDealerName(storeDto.getDealersName());
dto.setProvince(storeDto.getStoreMssProvince()); dto.setProvince(storeDto.getStoreMssProvince());
...@@ -406,6 +549,43 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -406,6 +549,43 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setAddr(storeDto.getStoreAddr()); 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);
} else if (PlanStatus.EXECUTION.getCode().equals(hasDto.getPlanStatus())) {
dto.setErrorMsg("计划已执行,不可修改;");
} else if (hasDto.getEmployeeNo().equals(row.get(0).toString())) {
dto.setErrorMsg("计划不属于"+row.get(0)+",归属人:" + hasDto.getEmployeeName() + ";");
}
LocalTime inLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(6).toString());
LocalTime outLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(7).toString());
if (ObjectUtils.anyNull(inLocalTime, outLocalTime)) {
dto.setErrorMsg("上下班时间必填;");
}
if (ObjectUtils.allNotNull(inLocalTime, outLocalTime) && inLocalTime.isAfter(outLocalTime)) {
dto.setErrorMsg("下班时间需晚于上班时间;");
} else {
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小时,不可修改;");
}
/** /**
* 3:活动模式 * 3:活动模式
*/ */
...@@ -416,51 +596,15 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -416,51 +596,15 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setErrorMsg("活动模式分为:单点CP、常规MINI秀、校园活动;"); dto.setErrorMsg("活动模式分为:单点CP、常规MINI秀、校园活动;");
} }
/**
* 4:月份 新增逻辑只支持次月计划;
* 6:促销员上班时间 当月份错误,促销员上下班时间也不进行计算
* 7:促销员下班时间
* 年份:当月份为1时,判定为跨年
*/
int monthInt = Integer.parseInt(row.get(4).toString());
if (monthInt == nextMonthValue) {
int year = DateUtil.thisYear();
Month month = Month.of(monthInt);
if (month.equals(Month.JANUARY)) {
year += 1;
}
LocalDate planDate = LocalDate.of(year, month, day);
dto.setYear(year).setMonth(planDate.getMonthValue()).setDate(DateUtils.parseDateBylocalDate(planDate));
LocalTime inLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(6).toString());
LocalTime outLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(7).toString());
if (ObjectUtils.anyNull(inLocalTime, outLocalTime)) {
dto.setErrorMsg("上下班时间必填;");
}
if (ObjectUtils.allNotNull(inLocalTime, outLocalTime) && inLocalTime.isAfter(outLocalTime)) {
dto.setErrorMsg("下班时间需晚于上班时间;");
} else {
dto.setClockInTime(LocalDateTime.of(planDate, inLocalTime));
dto.setClockOutTime(LocalDateTime.of(planDate, outLocalTime));
}
} else {
dto.setErrorMsg("月份必需是下个月;");
}
// 8:工资 // 8:工资
dto.setSalary(new BigDecimal(row.get(8).toString())); dto.setSalary(new BigDecimal(row.get(8).toString()));
// 9:杂费 // 9:杂费
dto.setIncidentals(new BigDecimal(row.get(9).toString())); dto.setIncidentals(new BigDecimal(row.get(9).toString()));
// 判断计划是否已存在
ActivityPlanInfoDto hasDto = activityPlanInfoDao.selectPlan(dto.getStoreCode(), dto.getDate());
if (Objects.nonNull(hasDto)) {
dto.setErrorMsg("计划已存在,创建人:" + hasDto.getEmployeeName() + ",创建时间:" + DateUtil.formatDate(hasDto.getCreateTime()) + ";");
}
} catch (DateTimeException e) { } catch (DateTimeException e) {
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);
...@@ -471,5 +615,26 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService { ...@@ -471,5 +615,26 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
@Transactional(rollbackFor = Exception.class)
@Override
public synchronized void selfPlanAf(String planUuid) {
String key = RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey() + planUuid;
JSONObject mapJson = redisCache.getToJson(key);
if (Objects.isNull(mapJson)){
throw new DataException(RCode.REDIS_PUSH_DATA_NOT_EXIT);
}
redisCache.removeKey(key);
JSONObject record = mapJson.getJSONObject("record");
JSONArray table = mapJson.getJSONArray("table");
// 保存上传记录
Long recordId = activityPlanRecordDao.save(record);
activityPlanInfoDao.saveList(table,recordId);
}
@Override
public void deletePlan(List<Long> planIds) {
activityPlanInfoDao.deleteByPlanIds(planIds);
}
} }
...@@ -3,19 +3,18 @@ package com.wangxiaolu.promotion.utils; ...@@ -3,19 +3,18 @@ package com.wangxiaolu.promotion.utils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.common.utils.BinaryUtil; import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.sts20150401.models.AssumeRoleResponseBody; import com.aliyun.sts20150401.Client;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64;
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient; import com.aliyuncs.IAcsClient;
import com.aliyuncs.auth.sts.AssumeRoleRequest; import com.aliyuncs.auth.sts.AssumeRoleRequest;
import com.aliyuncs.auth.sts.AssumeRoleResponse; import com.aliyuncs.auth.sts.AssumeRoleResponse;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.profile.DefaultProfile;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.aliyun.sts20150401.Client;
import javax.crypto.Mac; import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
......
...@@ -34,6 +34,16 @@ ...@@ -34,6 +34,16 @@
</resultMap> </resultMap>
<resultMap id="SimResultMap" type="com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlanInfoDo">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="employeeName" column="employee_name" jdbcType="VARCHAR"/>
<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="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="PlanBase" type="com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlanInfoDo"> <resultMap id="PlanBase" type="com.wangxiaolu.promotion.domain.activityplanv2.mapper.entity.ActivityPlanInfoDo">
<id property="id" column="id" jdbcType="BIGINT"/> <id property="id" column="id" jdbcType="BIGINT"/>
<result property="employeeName" column="employee_name" jdbcType="VARCHAR"/> <result property="employeeName" column="employee_name" jdbcType="VARCHAR"/>
...@@ -66,8 +76,8 @@ ...@@ -66,8 +76,8 @@
</foreach> </foreach>
</insert> </insert>
<select id="selectPlan" resultMap="BaseResultMap"> <select id="selectPlan" resultMap="SimResultMap">
select employee_name, create_time select id,employee_name,employee_no,province,plan_status,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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论