diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 02c44510..17521c1b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -1,15 +1,14 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.ImmutableList; import com.nflg.product.base.core.api.BaseApi; -import com.nflg.product.bomnew.pojo.dto.BomNewEBomCreateDTO; -import com.nflg.product.bomnew.pojo.dto.BomNewEBomImportExcelDTO; -import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO; -import com.nflg.product.bomnew.pojo.dto.VirtualPackageParamDto; +import com.nflg.product.base.core.conmon.util.SessionUtil; +import com.nflg.product.bomnew.pojo.dto.*; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; @@ -24,6 +23,7 @@ import com.nflg.product.bomnew.util.EecExcelUtil; import com.nflg.product.bomnew.util.VUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -133,4 +133,18 @@ public class EbomApi extends BaseApi { } + @PostMapping("revertDesign") + @ApiOperation("退回到设计") + public ResultVO revertDesign(@RequestBody BomNewEBomRevertDTO dto) { + if (CollectionUtil.isEmpty(dto.getRowIdList())) { + return ResultVO.error(STATE.ParamErr, "请选择要退回的数据"); + } + + bomNewEbomParentService.revertDesign(dto); + + return ResultVO.success(true); + + } + + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java new file mode 100644 index 00000000..c3946094 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEBomRevertDTO.java @@ -0,0 +1,23 @@ +package com.nflg.product.bomnew.pojo.dto; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** +* 退回 + +*/ +@Data +public class BomNewEBomRevertDTO { + + +//退回人 + private String revertUserName; + + + @ApiModelProperty("行id列表") + private List rowIdList; +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 7513fa03..6fa11fd7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -3,9 +3,11 @@ package com.nflg.product.bomnew.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -17,6 +19,7 @@ import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper; import com.nflg.product.bomnew.pojo.dto.BomNewEBomCreateDTO; +import com.nflg.product.bomnew.pojo.dto.BomNewEBomRevertDTO; import com.nflg.product.bomnew.pojo.dto.VirtualPackageParamDto; import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; @@ -49,6 +52,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; @@ -242,9 +246,8 @@ public class BomNewEbomParentService extends ServiceImpl rowIds = dto.getRowIdList(); + List bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds); + if (CollUtil.isEmpty(bomNewEbomParentEntityList)) { + throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回"); + } + + + if (rowIds.size() != bomNewEbomParentEntityList.size()) { + throw new NflgBusinessException(STATE.BusinessError, "选择数据中包含有下级BOM无法进行退回"); + } + + + List waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList()); + List revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList()); + List pbomList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(waitList)) { + List materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); + + throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList))); + } + if (CollUtil.isNotEmpty(revertList)) { + List materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); + + throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList))); + } + if (pbomList.size() > 0) { + List materialNoList = pbomList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()); + + throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM,无法退回设计", StrUtil.join(",", materialNoList))); + + } + + + //重新创建保存list 避免污染 + List updateList=new ArrayList<>(); + bomNewEbomParentEntityList.forEach(item->{ + BomNewEbomParentEntity entity=new BomNewEbomParentEntity(); + entity.setRowId(item.getRowId()); + entity .setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + entity.setRevertTime(LocalDateTime.now()); + entity.setRevertUserName(dto.getRevertUserName()); + updateList.add(entity); + }); + + + + if (! this.updateBatchById(updateList)) { + throw new NflgBusinessException(STATE.Error, "退回设计失败"); + } + + } }