Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -139,6 +139,6 @@ public interface CollectionElementService extends IService<CollectionElement> {
|
||||
|
||||
List<CollectionElement> getByProjectId(Long projectId);
|
||||
|
||||
List<CollectionElementVO> selectedImageSeg(List<MultipartFile> files, Long id, String type);
|
||||
List<CollectionElementVO> selectedImageSeg(List<MultipartFile> files, Long id, String type, String sourceType);
|
||||
|
||||
}
|
||||
|
||||
@@ -991,13 +991,14 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
|
||||
// 对于上传图片或者从library选择的图片进行图片分割
|
||||
public List<CollectionElementVO> selectedImageSeg(List<MultipartFile> files, Long id, String type) {
|
||||
public List<CollectionElementVO> selectedImageSeg(List<MultipartFile> files, Long id, String type, String sourceType) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
List<CollectionElementVO> resp = new ArrayList<>();
|
||||
List<ImageSegmentation.ImageDate> imageDates = new ArrayList<>();
|
||||
|
||||
boolean isUploadMode = !files.isEmpty();
|
||||
Library library = null;
|
||||
CollectionElement collectionElement = null;
|
||||
|
||||
// 判断是否是上传的图片
|
||||
if (isUploadMode) {
|
||||
@@ -1017,7 +1018,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
resp.add(createCollectionElementVO(accountId, null, null, imageData.getImage_url(), imageData.getClothing_url()));
|
||||
}
|
||||
}
|
||||
} else if (Objects.nonNull(id)) {
|
||||
} else if (Objects.nonNull(id) && sourceType.equals("library")) {
|
||||
library = libraryService.getById(id);
|
||||
// 判断从library中选择的图片是否有分割数据
|
||||
if (Objects.isNull(library)) {
|
||||
@@ -1032,6 +1033,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
List<String> restoredList = Arrays.asList(library.getSegmentedData().split(","));
|
||||
resp.add(createCollectionElementVO(accountId, id, library.getLevel1Type(), library.getUrl(), restoredList));
|
||||
}
|
||||
} else if (Objects.nonNull(id) && sourceType.equals("upload")) {
|
||||
collectionElement = collectionElementMapper.selectById(id);
|
||||
// 判断id对应的数据是否存在
|
||||
if (Objects.isNull(collectionElement)) {
|
||||
throw new BusinessException("get.file.failed");
|
||||
}
|
||||
// 上传的图片分割数据没存(原因:上传的数据一般不会被再次使用,存储意义不大;上传存储表中数据复杂,添加字段,浪费多)
|
||||
ImageSegmentation.ImageDate imageDate = new ImageSegmentation().new ImageDate();
|
||||
imageDate.setImage_url(collectionElement.getUrl());
|
||||
imageDate.setImage_type(type);
|
||||
imageDates.add(imageDate);
|
||||
}
|
||||
|
||||
// 处理需要分割的图片
|
||||
@@ -1052,13 +1064,15 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
(imageData.getImage_url(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false);
|
||||
redisUtil.addToString(key, new Gson().toJson(imageData), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
resp.add(createCollectionElementVO(accountId, null, null, imageData.getImage_url(), imageData.getClothing_url()));
|
||||
} else {
|
||||
} else if (sourceType.equals("library")){
|
||||
// 从library中选择的图片需要更新数据库中对应图片的分割数据
|
||||
String segmentedData = String.join(",", imageData.getClothing_url());
|
||||
library.setSegmentedData(segmentedData);
|
||||
library.setUpdateDate(new Date());
|
||||
libraryService.updateById(library);
|
||||
resp.add(createCollectionElementVO(accountId, id, library.getLevel1Type(), library.getUrl(), imageData.getClothing_url()));
|
||||
}else {
|
||||
resp.add(createCollectionElementVO(accountId, id, collectionElement.getLevel1Type(), collectionElement.getUrl(), imageData.getClothing_url()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@@ -218,7 +219,12 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
sum = sum.add(currentDeduction);
|
||||
|
||||
// 3、获取当前积分
|
||||
BigDecimal existingCredits = accountMapper.selectById(accountId).getCredits();
|
||||
Account account = accountMapper.selectById(accountId);
|
||||
if (account == null) {
|
||||
log.error("账户:{} 不存在", accountId);
|
||||
throw new BusinessException("账户不存在");
|
||||
}
|
||||
BigDecimal existingCredits = Optional.ofNullable(account.getCredits()).orElse(BigDecimal.ZERO);
|
||||
BigDecimal subtract = existingCredits.subtract(sum);
|
||||
|
||||
// 4、判断剩余积分是否够本次操作
|
||||
@@ -272,6 +278,7 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
String key = creditsDeduction + ":" + accountId + ":" + taskId;
|
||||
// 1、获取当前任务id对应的积分
|
||||
String value = redisUtil.getFromString(key);
|
||||
log.info("taskId为:{},需消耗积分:{}", taskId, value);
|
||||
|
||||
// 1.1 没有。返回,报错,未找到当前任务
|
||||
if (StringUtil.isNullOrEmpty(value)) {
|
||||
@@ -325,7 +332,11 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
String changeEvent = creditsDetail.getChangeEvent();
|
||||
BigDecimal currentCredits = accountMapper.selectById(accountId).getCredits();
|
||||
String credits = "0";
|
||||
if (changeEvent.equals("Logo") ||
|
||||
CreditsEventsEnum eventsEnum = CreditsEventsEnum.getByTaskName(changeEvent);
|
||||
if (Objects.nonNull(eventsEnum)){
|
||||
credits = eventsEnum.getValue();
|
||||
}
|
||||
/*if (changeEvent.equals("Logo") ||
|
||||
changeEvent.equals("Pattern") ||
|
||||
changeEvent.equals("MoodBoard") ||
|
||||
changeEvent.equals("SketchBoard")) {
|
||||
@@ -336,10 +347,11 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
credits = CreditsEventsEnum.POSE_TRANSFORMATION.getValue();
|
||||
}else if (changeEvent.equals("Other")){
|
||||
credits = CreditsEventsEnum.OTHER.getValue();
|
||||
}
|
||||
}*/
|
||||
|
||||
// BigDecimal finalCredits = currentCredits.subtract(new BigDecimal(credits));
|
||||
String changeCredits = "-" + credits;
|
||||
log.info("taskId:{},扣除的积分为:{}", taskId, changeCredits);
|
||||
|
||||
UpdateWrapper<CreditsDetail> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda()
|
||||
@@ -348,7 +360,6 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
.set(CreditsDetail::getCredits, currentCredits);
|
||||
|
||||
baseMapper.update(null, updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
public CreditsDetail queryDetailByTaskId(String taskId) {
|
||||
|
||||
Reference in New Issue
Block a user