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

活动上报图片保存、jsyq

上级 365ceea5
......@@ -82,9 +82,6 @@ public class TemporaryActivityCoreController {
}
/**
* todo 促销员[今日活动]数据提交审批
*/
......
......@@ -14,6 +14,7 @@ public interface TemporaryActivityPhotoDao {
* 保存活动上报照片list
*/
void saveReportedList(Integer temporaryId, Long reportedId, Integer photoType, List<String> urls);
void saveReportedList(Integer temporaryId, Long reportedId, Integer photoType, List<String> urls, List<String> changeUrls);
/**
* 根据促销员id-活动上报id查询图片
......
......@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityPhotoDao;
import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityPhotoMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityPhotoDO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -17,6 +20,7 @@ import java.util.stream.Collectors;
* @date : 2024-05-09 11
* @describe :
*/
@Slf4j
@Service
public class TemporaryActivityPhotoDaoImpl implements TemporaryActivityPhotoDao {
......@@ -33,6 +37,41 @@ public class TemporaryActivityPhotoDaoImpl implements TemporaryActivityPhotoDao
}
}
@Override
public void saveReportedList(Integer temporaryId, Long reportedId, Integer photoType, List<String> urls, List<String> changeUrls) {
if (CollectionUtils.isEmpty(changeUrls)) {
log.info("活动id[{}]图片无改变值", reportedId);
return;
}
Map<String, String> urlTypeMap = new HashMap<>();
for (String changeUrl : changeUrls) {
String[] uArr = changeUrl.split("/");
String type = uArr[0];
String uId = uArr[uArr.length - 1];
urlTypeMap.put(uId, type);
}
log.info("活动id[{}]图片修改后的list为:{}", reportedId, urlTypeMap);
for (String photoUrl : urls) {
String[] photoArr = photoUrl.split("/");
String photoFiledId = photoArr[photoArr.length - 1];
String type = urlTypeMap.get(photoFiledId);
log.info("图片文件id[{}]类型为{}", photoFiledId, type);
// 现存图片列表中不存在,删除
if (StringUtils.isBlank(type)) {
temporaryActivityPhotoMapper.updateIsDelete(reportedId, photoFiledId);
} else if ("cloud:".equals(type)) {
// 新增数据
TemporaryActivityPhotoDO photoDo = new TemporaryActivityPhotoDO();
photoDo.setTemporaryId(temporaryId).setReportedId(reportedId).setType(photoType).setPhotoUrl(photoUrl).setPhotoFiledId(photoFiledId);
temporaryActivityPhotoMapper.insert(photoDo);
}
}
}
/**
* 活动上报图片查询
*
......
......@@ -3,11 +3,8 @@ package com.wangxiaolu.promotion.domain.activity.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityPhotoDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author a02200059
* @description 针对表【temporary_activity_photo】的数据库操作Mapper
......@@ -17,6 +14,7 @@ import java.util.List;
@Mapper
@Repository
public interface TemporaryActivityPhotoMapper extends BaseMapper<TemporaryActivityPhotoDO> {
void updateIsDelete(Long reportedId, String photoFiledId);
}
......
......@@ -15,7 +15,8 @@ public enum TemActApproveStatus {
/**
* 审批状态
*/
SUBMITTED("已提交"),
// 保存但未提交审批
SUBMITTED("已保存"),
IN_APPROVAL("审批中"),
APPROVED("审批通过"),
SEND_BACK("退回"),
......
......@@ -76,17 +76,19 @@ public class TemporaryActivityReportedDto {
* 推广试吃照片
*/
List<String> tgscPhotoUrls;
List<String> tgscChangePhotoUrls;
/**
* 推广互动照片
*/
List<String> tghdPhotoUrls;
List<String> tghdChangePhotoUrls;
/**
* 推广成交照片
*/
List<String> tgcjPhotoUrls;
List<String> tgcjChangePhotoUrls;
/**
* 创建时间
......
......@@ -45,20 +45,20 @@ public class TemporaryActivityDataVo {
/**
* 推广试吃照片
* 只传增量,存量数据前端不再返回,增量数据直接保存到DB中
*/
List<String> tgscPhotoUrls;
List<String> tgscChangePhotoUrls;
/**
* 推广互动照片
* 只传增量,存量数据前端不再返回,增量数据直接保存到DB中
*/
List<String> tghdPhotoUrls;
List<String> tghdChangePhotoUrls;
/**
* 推广成交照片
* 只传增量,存量数据前端不再返回,增量数据直接保存到DB中
*/
List<String> tgcjPhotoUrls;
List<String> tgcjChangePhotoUrls;
}
......@@ -68,7 +68,9 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
// 保存活动数据 temporary_activity_reported
long reportedId = temporaryActivityReportedDao.activityDataSave(temActDto);
temActDto.setId(reportedId);
// 保存图片
/**
* 保存图片
*/
saveActivityPhoto(temActDto);
return reportedId;
}
......@@ -101,17 +103,17 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
Long reportedId = temActDto.getId();
// 推广试吃照片
if (!CollectionUtils.isEmpty(temActDto.getTgscPhotoUrls())) {
tempActivityPhotoDao.saveReportedList(temporaryId, reportedId, ActivityPhotoType.tgsc.getType(), temActDto.getTgscPhotoUrls());
tempActivityPhotoDao.saveReportedList(temporaryId, reportedId, ActivityPhotoType.tgsc.getType(), temActDto.getTgscPhotoUrls(), temActDto.getTgscChangePhotoUrls());
}
// 推广互动照片
if (!CollectionUtils.isEmpty(temActDto.getTghdPhotoUrls())) {
tempActivityPhotoDao.saveReportedList(temporaryId, reportedId, ActivityPhotoType.tghd.getType(), temActDto.getTghdPhotoUrls());
tempActivityPhotoDao.saveReportedList(temporaryId, reportedId, ActivityPhotoType.tghd.getType(), temActDto.getTghdPhotoUrls(), temActDto.getTghdChangePhotoUrls());
}
// 推广成交照片
if (!CollectionUtils.isEmpty(temActDto.getTgcjPhotoUrls())) {
tempActivityPhotoDao.saveReportedList(temporaryId, reportedId, ActivityPhotoType.tgcj.getType(), temActDto.getTgcjPhotoUrls());
tempActivityPhotoDao.saveReportedList(temporaryId, reportedId, ActivityPhotoType.tgcj.getType(), temActDto.getTgcjPhotoUrls(), temActDto.getTgcjChangePhotoUrls());
}
log.info("促销员今日活动上报-图片保存成功,关联活动上报数据id[{}],数据信息:{}", temActDto.getId(), temActDto);
......
......@@ -45,20 +45,26 @@ public class TemporaryActivityQueryServiceImpl implements TemporaryActivityQuery
@Override
public TemporaryActivityReportedDto findtemporaryIdTodayActivityData(Integer temporaryId) {
TemporaryActivityReportedDto dto = temporaryActivityReportedDao.findOneByCurrentDate(temporaryId);
if (Objects.nonNull(dto)) {
Map<Integer, List<String>> reportedGroup = temporaryActivityPhotoDao.findReportedGroup(dto.getTemporaryId(), dto.getId());
if (!CollectionUtils.isEmpty(reportedGroup)) {
dto.setTgscPhotoUrls(reportedGroup.get(ActivityPhotoType.tgsc.getType()));
dto.setTghdPhotoUrls(reportedGroup.get(ActivityPhotoType.tghd.getType()));
dto.setTgcjPhotoUrls(reportedGroup.get(ActivityPhotoType.tgcj.getType()));
}
}
findActivityReportedPhoto(dto);
return dto;
}
@Override
public TemporaryActivityReportedDto findTemporaryActivityById(Long activityId) {
TemporaryActivityReportedDto dto = temporaryActivityReportedDao.findOneById(activityId);
findActivityReportedPhoto(dto);
return dto;
}
private void findActivityReportedPhoto(TemporaryActivityReportedDto dto) {
if (Objects.isNull(dto)) {
return;
}
Map<Integer, List<String>> reportedGroup = temporaryActivityPhotoDao.findReportedGroup(dto.getTemporaryId(), dto.getId());
if (!CollectionUtils.isEmpty(reportedGroup)) {
dto.setTgscPhotoUrls(reportedGroup.get(ActivityPhotoType.tgsc.getType()));
dto.setTghdPhotoUrls(reportedGroup.get(ActivityPhotoType.tghd.getType()));
dto.setTgcjPhotoUrls(reportedGroup.get(ActivityPhotoType.tgcj.getType()));
}
}
}
......@@ -19,4 +19,11 @@
photo_url,photo_field_id
</sql>
<update id="updateIsDelete">
update temporary_activity_photo
set is_delete = 0
where reported_id = #{reportedId}
and photo_filed_id = #{photoFiledId};
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论