This commit is contained in:
parent
eec1b3e67a
commit
b241177dbd
|
|
@ -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<Boolean> revertDesign(@RequestBody BomNewEBomRevertDTO dto) {
|
||||
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
|
||||
return ResultVO.error(STATE.ParamErr, "请选择要退回的数据");
|
||||
}
|
||||
|
||||
bomNewEbomParentService.revertDesign(dto);
|
||||
|
||||
return ResultVO.success(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Long> rowIdList;
|
||||
}
|
||||
|
|
@ -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<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex){
|
||||
throw new NflgBusinessException (STATE.BusinessError,ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
throw new NflgBusinessException(STATE.BusinessError, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,4 +328,60 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退回设计
|
||||
*/
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
public void revertDesign(BomNewEBomRevertDTO dto) {
|
||||
List<Long> rowIds = dto.getRowIdList();
|
||||
List<BomNewEbomParentEntity> 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<BomNewEbomParentEntity> waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList());
|
||||
List<BomNewEbomParentEntity> revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList());
|
||||
List<BomNewEbomParentEntity> pbomList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(waitList)) {
|
||||
List<String> materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
|
||||
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList)));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(revertList)) {
|
||||
List<String> materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
|
||||
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
|
||||
}
|
||||
if (pbomList.size() > 0) {
|
||||
List<String> materialNoList = pbomList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
|
||||
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM,无法退回设计", StrUtil.join(",", materialNoList)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//重新创建保存list 避免污染
|
||||
List<BomNewEbomParentEntity> 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, "退回设计失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue