删除调整
This commit is contained in:
parent
cfc4280ba5
commit
d9332c5bc6
|
|
@ -193,17 +193,17 @@ public class EbomApi extends BaseApi {
|
|||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("createBom")
|
||||
@ApiOperation("创建BOM")
|
||||
public ResultVO<Boolean> createBom(@RequestBody BomNewEBomCreateDTO createDTO) {
|
||||
VUtils.isTure(StrUtil.isBlank(createDTO.getMaterialNo())).throwMessage("物料编码不能为空");
|
||||
//子级物料编码不能为空
|
||||
VUtils.isTure(CollUtil.isEmpty(createDTO.getDatas())).throwMessage("子级不能为空");
|
||||
List<BomNewEBomImportExcelDTO> noMaterialList = createDTO.getDatas().stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noMaterialList)).throwMessage("子级存在物料编码为空的数据");
|
||||
bomNewEbomParentService.createBom(createDTO);
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
// @PostMapping("createBom")
|
||||
// @ApiOperation("创建BOM")
|
||||
// public ResultVO<Boolean> createBom(@RequestBody BomNewEBomCreateDTO createDTO) {
|
||||
// VUtils.isTure(StrUtil.isBlank(createDTO.getMaterialNo())).throwMessage("物料编码不能为空");
|
||||
// //子级物料编码不能为空
|
||||
// VUtils.isTure(CollUtil.isEmpty(createDTO.getDatas())).throwMessage("子级不能为空");
|
||||
// List<BomNewEBomImportExcelDTO> noMaterialList = createDTO.getDatas().stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
// VUtils.isTure(CollUtil.isNotEmpty(noMaterialList)).throwMessage("子级存在物料编码为空的数据");
|
||||
// bomNewEbomParentService.createBom(createDTO);
|
||||
// return ResultVO.success(true);
|
||||
// }
|
||||
|
||||
|
||||
@PostMapping("revertDesign")
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
|
|||
|
||||
void updateBomState(@Param("status") Integer status ,@Param("rowIds") List<Long> rowIds);
|
||||
|
||||
void updateRevertBom(@Param("status") Integer status ,@Param("editStatus") Integer editStatus ,@Param("rowIds") List<Long> rowIds);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新是否根节点状态
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -906,24 +906,57 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 描述:此删除功能是整个BOM结构的删除;
|
||||
* 2. 规则:
|
||||
* 1. 物料没有被“设计复核”;
|
||||
* 2. 选中的物料必须为第一层(不存在父级编码);
|
||||
* 3. 删除逻辑:
|
||||
* 1. 如果数据不是从原始BOM导入的情况下(包含用户新增和通过变更添加的),直接删除即可。
|
||||
* 2. 如果数据是在原始Bom中导入的,需要删除EBom的数据,并且还要将原始Bom的数据状态改为“待处理”(如果数据已经在Ebom中进行了处理,原始Bom不需要处理,用户下次将数据导入过来的时候需要再一次修改)。
|
||||
* 3. 如果是借用件的节点不能删除。
|
||||
* 4. 如果存在其它用户创建的节点不可以删除。
|
||||
* 5. 如果是工艺岗位角色的时候,只能删除自己在EBOM中创建的数据。
|
||||
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
|
||||
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
|
||||
|
||||
VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确");
|
||||
|
||||
|
||||
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
|
||||
|
||||
//设计人员只能删自己
|
||||
if (userRoleService.designer()) {
|
||||
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
|
||||
}
|
||||
|
||||
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
|
||||
List<BomNewEbomParentVO> delBom = null;
|
||||
if (userRoleService.designer()) {
|
||||
|
||||
//设计 工艺,删录入 excel导入
|
||||
delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0
|
||||
&& u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|
||||
&& EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))
|
||||
&& (u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|
||||
|| EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
|
||||
//借用件不能删除,原始bom转换只能自己
|
||||
List<BomNewEbomParentVO> obomList=null;
|
||||
if (userRoleService.designer()) {
|
||||
obomList=bomTree.stream().filter(u -> u.getBomRowId() > 0
|
||||
&& (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue())
|
||||
&&u.getCreatedBy().equals(SessionUtil.getUserCode())
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if(CollectionUtil.isNotEmpty(obomList)){
|
||||
delBom.addAll(obomList);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(delBom)) {
|
||||
|
|
@ -939,6 +972,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
//恢复原始bom状态
|
||||
if(CollectionUtil.isNotEmpty(obomList)){
|
||||
List<Long> rowIds=obomList.stream().map(BomNewEbomParentVO::getSourceRowId).collect(Collectors.toList());
|
||||
SpringUtil.getBean(BomNewOriginalParentService.class).revertBom(rowIds);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -962,13 +1001,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
|
||||
}
|
||||
if (dto.getParent() != null) {
|
||||
if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {
|
||||
if (CollUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
|
||||
}
|
||||
if (dto.getParent() != null) {
|
||||
deleteBomChild(dto.getDelDatas());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -1017,19 +1053,46 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
if (dto.getParent() != null) {
|
||||
if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|
||||
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {
|
||||
|
||||
if (CollUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
|
||||
}
|
||||
}
|
||||
deleteBomChild(dto.getDelDatas());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1. 编辑页面的删除只是删除BOM的关联关系;
|
||||
* 2. 删除规则:
|
||||
* 1. 从原始Bom导入的数据,数据没有异常的情况下,用户不可以删除
|
||||
* 2. 用户可以直接删除,用户单击暂存或是提交时才会保存至数据库。
|
||||
*/
|
||||
private void deleteBomChild(List<BomNewEbomParentVO> delList){
|
||||
|
||||
List<BomNewEbomParentVO> delTagList=new ArrayList<>();
|
||||
//原始bom不正常
|
||||
List<BomNewEbomParentVO> s1List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_BOM.getValue(),u.getSource())
|
||||
&&!Objects.equals(u.getExceptionStatus(),EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
|
||||
if(CollectionUtil.isNotEmpty(s1List)){
|
||||
delTagList.addAll(s1List);
|
||||
}
|
||||
|
||||
//手动创建
|
||||
List<BomNewEbomParentVO> s2List= delList.stream().filter(u->Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(),u.getSource() )
|
||||
|| Objects.equals(EBomSourceEnum.FROM_MDM.getValue(),u.getSource())).collect(Collectors.toList());
|
||||
|
||||
if(CollectionUtil.isNotEmpty(s2List)){
|
||||
delTagList.addAll(s2List);
|
||||
}
|
||||
|
||||
if(CollectionUtil.isNotEmpty(delTagList)){
|
||||
List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId()!=null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
|
@ -204,6 +205,23 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
*/
|
||||
public void revertBom(List<Long> sourceIds){
|
||||
|
||||
if(CollectionUtil.isEmpty(sourceIds)){
|
||||
return;
|
||||
}
|
||||
|
||||
this.getBaseMapper().updateRevertBom(OriginalStatusEnum.UN_CONVERT.getValue(),
|
||||
OriginalEditStatusEnum.HANDLER_CREATED.getValue(),
|
||||
sourceIds);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取整颗BOM树
|
||||
*
|
||||
|
|
|
|||
|
|
@ -110,6 +110,26 @@
|
|||
</foreach>;
|
||||
</delete>
|
||||
|
||||
<update id="updateRevertBom">
|
||||
|
||||
update t_bom_new_original_parent set status = #{status},edit_status=#{editStatus} where
|
||||
row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>;
|
||||
|
||||
update t_bom_new_original_child set status = #{status},edit_status=#{editStatus} where
|
||||
parent_row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>;
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<update id="updateBomState">
|
||||
update t_bom_new_original_parent set status = #{status},convert_to_ebom_time=now() where
|
||||
row_id in
|
||||
|
|
|
|||
Loading…
Reference in New Issue