选项删除软删除

This commit is contained in:
jing's 2024-01-27 17:59:03 +08:00
parent 4383367efb
commit a4aa03958d
3 changed files with 32 additions and 14 deletions

View File

@ -49,6 +49,18 @@ public class OptionalBomConstant {
}
@AllArgsConstructor
@Getter
public enum DeleteEnum implements ValueEnum<Integer> {
UN_DEL(0, "未删"),
DEL (1, "已删");
private final Integer value;
private final String description;
}
@AllArgsConstructor
@Getter
public enum PublishEnum implements ValueEnum<Integer> {

View File

@ -7,6 +7,7 @@ import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -28,6 +29,7 @@ import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigRVO;
import com.nflg.product.bomnew.pojo.vo.OptionalEbomImportChildVO;
import nflg.product.common.constant.STATE;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -250,17 +252,20 @@ public class OptionalEbomImportChildService extends ServiceImpl<OptionalEbomImpo
//已发布提示
if (CollectionUtil.isNotEmpty(intersectionList)) {
QueryWrapper<OptionalEbomImportChildEntity> queryWrapper = new QueryWrapper();
queryWrapper.lambda().in(OptionalEbomImportChildEntity::getRowId, intersectionList);
//软删除
UpdateWrapper<OptionalEbomImportChildEntity> updateWrapper = new UpdateWrapper();
updateWrapper.lambda().in(OptionalEbomImportChildEntity::getRowId, intersectionList);
updateWrapper.lambda().set(OptionalEbomImportChildEntity::getIsDel, OptionalBomConstant.DeleteEnum.DEL.getValue());
update(updateWrapper);
List<OptionalEbomImportChildEntity> entityList = getBaseMapper().selectList(queryWrapper);
StringBuffer stringBuffer = new StringBuffer();
for (OptionalEbomImportChildEntity item :
entityList) {
stringBuffer.append(StrUtil.format("{}({}) , ", item.getMaterialName(), item.getMaterialNo()));
}
stringBuffer.append("以上数据已发布不能删除");
throw new NflgBusinessException(STATE.Error, stringBuffer.toString());
// List<OptionalEbomImportChildEntity> entityList = getBaseMapper().selectList(queryWrapper);
// StringBuffer stringBuffer = new StringBuffer();
// for (OptionalEbomImportChildEntity item :
// entityList) {
// stringBuffer.append(StrUtil.format("{}({}) , ", item.getMaterialName(), item.getMaterialNo()));
// }
// stringBuffer.append("以上数据已发布不能删除");
// throw new NflgBusinessException(STATE.Error, stringBuffer.toString());
}

View File

@ -133,14 +133,13 @@ public class OptionalEbomMainService extends ServiceImpl<OptionalEbomMainMapper,
List<OptionalEbomConfigEntity> publishList = configList.stream().filter(item -> item.getEditStatus().equals(OptionalBomConstant.PublishEnum.PUBLISH.getValue())).collect(Collectors.toList());
List<OptionalEbomConfigEntity> tmpList = configList.stream().filter(item -> item.getEditStatus().equals(OptionalBomConstant.PublishEnum.TMP.getValue())).collect(Collectors.toList());
//机型下无发布数据可全删
if (CollectionUtil.isNotEmpty(publishList)) {
updateList.add(rowId);
} else {
delList.add(rowId);
}
if (CollectionUtil.isNotEmpty(tmpList)) {
delTmpList.addAll(tmpList.stream().map(OptionalEbomConfigEntity::getRowId).collect(Collectors.toList()));
}
@ -159,12 +158,14 @@ public class OptionalEbomMainService extends ServiceImpl<OptionalEbomMainMapper,
// optionalEbomImportService.updateDelStatusByRooId(updateList);
// optionalEbomImportChildService.updateDelStatusByRootId(updateList);
// }
//操作删除或更新
//操作删除机型
deleteByRowIds(dto.getRowIdList());
//联动删除机型下选配数据
//删除机型下暂存数据
if (CollectionUtil.isNotEmpty(delTmpList)) {
//删暂存
SpringUtil.getBean(OptionalEbomConfigService.class).deleteByIds(delTmpList);
QueryWrapper<OptionalEbomConfigREntity> delOptionWrapper= new QueryWrapper();
delOptionWrapper.lambda().in(OptionalEbomConfigREntity::getParentRowId,delTmpList);
SpringUtil.getBean(OptionalEbomConfigRService.class).remove(delOptionWrapper);