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

UUID保存促销计划时,进行区分,并修改保存逻辑

上级 7dca7bba
......@@ -54,7 +54,7 @@ public class PromPlanCoreController {
String[] urlArr = activityPlanVo.getExcelUrl().split("/");
String fileId = urlArr[urlArr.length - 1];
String filePath = "/root/promotion/planv2/" + fileId;
// String filePath = "/Users/a02200059/Desktop/2.0/" + fileId;
//todo String filePath = "/Users/a02200059/Desktop/2.0/" + fileId;
FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
activityPlanVo.setExcelId(fileId);
Map<String, Object> map = promPlanCoreService.selfPlanUp(activityPlanVo, filePath);
......@@ -87,8 +87,8 @@ public class PromPlanCoreController {
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.authPlanUp(activityPlanVo, filePath);
return R.success(map);
......@@ -109,9 +109,6 @@ public class PromPlanCoreController {
return R.success();
}
/**
* 促销计划修改
*/
......@@ -129,9 +126,9 @@ public class PromPlanCoreController {
try {
String[] urlArr = activityPlanVo.getExcelUrl().split("/");
String fileId = urlArr[urlArr.length - 1];
//todo String filePath = "/root/promotion/planv2/" + fileId;
String filePath = "/Users/a02200059/Desktop/2.0/" + fileId;
// FileUtils.downloadExcel(activityPlanVo.getExcelUrl(), filePath);
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);
......
......@@ -21,4 +21,6 @@ public interface ActivityPlanInfoDao {
ActivityPlanInfoDto selectPlan(String storeCode, Date date);
void deleteByPlanIds(List<Long> planIds);
void updateList(JSONArray table, Long recordId);
}
......@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......@@ -44,6 +45,22 @@ public class ActivityPlanInfoDaoImpl implements ActivityPlanInfoDao {
}
}
@Override
public void updateList(JSONArray table, Long recordId) {
try {
// 将table中的数据转换为ActivityPlanInfoDo
for (int i = 0; i < table.size(); i++) {
ActivityPlanInfoDo pdo = table.getObject(i, ActivityPlanInfoDo.class);
activityPlanInfoMapper.updateOne(pdo, recordId);
}
} catch (PersistenceException e) {
e.printStackTrace();
throw new DataException(RCode.ACTIVITY_PLAN_REPETITION_ERROR);
}
}
@Override
public void page(PageInfo pageInfo, ActivityPlanInfoWrapper wrapper) {
LambdaQueryWrapper<ActivityPlanInfoDo> qw = buildWrapper(wrapper);
......
......@@ -27,6 +27,8 @@ public interface ActivityPlanInfoMapper extends BaseMapper<ActivityPlanInfoDo> {
void updateIsDelete(List<Long> planIds);
Integer selectNotDelCount(@Param("planIds") List<Long> planIds);
void updateOne(@Param("pDo") ActivityPlanInfoDo pDo,@Param("recordId") Long recordId);
}
......
package com.wangxiaolu.promotion.enums.plan;
/**
* @author : liqiulin
* @date : 2025-02-14 13
* @describe :
*/
public enum OperationType {
/**
* up:新增
* put:修改
*/
UP("UP", "新增"),
PUT("PUT", "修改");
private final String code;
private final String desc;
OperationType(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
......@@ -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.user.dao.QinCeClienteleStoreDao;
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;
......@@ -72,6 +73,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
.setExcelUrl(planVo.getExcelUrl())
.setExcelFiledId(planVo.getExcelId());
map.put("record", record);
map.put("type", OperationType.UP.getCode());
// 保存到缓存(uuid)
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey()+map.get("uuid").toString(),map,30);
// 返回结果
......@@ -260,6 +262,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
.setExcelUrl(planVo.getExcelUrl())
.setExcelFiledId(planVo.getExcelId());
map.put("record", record);
map.put("type", OperationType.UP.getCode());
// 保存到缓存(uuid)
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey()+map.get("uuid").toString(),map,30);
// 返回结果
......@@ -394,7 +397,7 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
year += 1;
}
LocalDate planDate = LocalDate.of(year, month, day);
if (monthInt != nextMonthValue || monthInt != monthValue) {
if (monthInt != nextMonthValue && monthInt != monthValue) {
dto.setErrorMsg("月份只能是当月或次月;");
} else if (planDate.isBefore(LocalDate.now())) {
dto.setErrorMsg("日期不能是以前;");
......@@ -455,8 +458,9 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
.setExcelUrl(planVo.getExcelUrl())
.setExcelFiledId(planVo.getExcelId());
map.put("record", record);
map.put("type", OperationType.PUT.getCode());
// 保存到缓存(uuid)
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_PUT.getKey()+map.get("uuid").toString(),map,30);
redisCache.addToJsonToMinute(RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey()+map.get("uuid").toString(),map,30);
// 返回结果
return map;
}
......@@ -541,6 +545,8 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
if (StringUtils.isAnyBlank(storeDto.getLineName(), storeDto.getDealersName(), storeDto.getDealerId())) {
dto.setErrorMsg("门店「系统名称」或「经销商」为空,请到勤策中进充;");
}
dto.setStoreCode(sc);
dto.setStoreName(storeDto.getStoreName());
dto.setLineName(storeDto.getLineName());
dto.setDealerId(storeDto.getDealerId());
dto.setDealerName(storeDto.getDealersName());
......@@ -564,7 +570,9 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
} else if (!hasDto.getEmployeeNo().equals(row.get(0).toString())) {
dto.setErrorMsg("计划不属于"+row.get(0)+",归属人:" + hasDto.getEmployeeName() + ";");
}
dto.setEmployeeName(hasDto.getEmployeeName())
.setOrgQcId(hasDto.getOrgQcId())
.setOrgName(hasDto.getOrgName());
LocalTime inLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(6).toString());
LocalTime outLocalTime = DateUtils.parseLocalTimeByEmdtime(row.get(7).toString());
......@@ -577,8 +585,6 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
dto.setClockInTime(LocalDateTime.of(planDate, inLocalTime));
dto.setClockOutTime(LocalDateTime.of(planDate, outLocalTime));
}
LocalDateTime localDateTime = hasDto.getClockInTime().plusHours(1);
LocalDateTime now = LocalDateTime.now();
if (LocalDateTime.now().isAfter(hasDto.getClockInTime().plusHours(1))){
dto.setErrorMsg("已超促销员上班时间1小时,不可修改;");
}
......@@ -606,7 +612,6 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
}
dtos.add(dto);
}
return dtos;
}
......@@ -617,17 +622,22 @@ public class PromPlanCoreServiceImpl implements PromPlanCoreService {
public synchronized void selfPlanAf(String planUuid) {
String key = RedisKeys.Manage.ACTIVITY_PLAN_UP.getKey() + planUuid;
JSONObject mapJson = redisCache.getToJson(key);
if (Objects.isNull(mapJson)){
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);
String type = mapJson.getString("type");
if (OperationType.UP.getCode().equals(type)) {
// 保存上传记录
Long recordId = activityPlanRecordDao.save(record);
activityPlanInfoDao.saveList(table, recordId);
} else if (OperationType.PUT.getCode().equals(type)) {
Long recordId = activityPlanRecordDao.save(record);
activityPlanInfoDao.updateList(table, recordId);
}
}
@Override
......
......@@ -42,6 +42,8 @@
<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="orgQcId" column="org_qc_id" jdbcType="VARCHAR"/>
<result property="orgName" column="org_name" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
</resultMap>
......@@ -79,9 +81,20 @@
</insert>
<select id="selectPlan" resultMap="SimResultMap">
select id,employee_name,employee_no,province,plan_status,clock_in_time,create_time,modify_time
select id,
employee_name,
employee_no,
province,
plan_status,
clock_in_time,
create_time,
modify_time,
org_qc_id,
org_name
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>
<update id="updateIsDelete" parameterType="java.util.List">
......@@ -104,4 +117,22 @@
and date &lt;= now()
</select>
<update id="updateOne">
update activity_plan_info
set plan_file_id = #{recordId},
line_name = #{pDo.lineName},
store_name = #{pDo.storeName},
org_qc_id = #{pDo.orgQcId},
org_name = #{pDo.orgName},
pattern = #{pDo.pattern},
dealer_id = #{pDo.dealerId},
dealer_name = #{pDo.dealerName},
clock_in_time = #{pDo.clockInTime},
clock_out_time = #{pDo.clockOutTime},
salary = #{pDo.salary},
incidentals = #{pDo.incidentals}
where store_code = #{pDo.storeCode}
and date = #{pDo.date};
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论