feat: pbom删除工艺包时,将其下子级提层
This commit is contained in:
parent
a50007a526
commit
f1f44b01bd
|
|
@ -155,13 +155,17 @@ public class PBomApi extends BaseApi {
|
||||||
return ResultVO.success(true);
|
return ResultVO.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param param 包含删除BOM所需信息的DTO(数据传输对象)
|
||||||
|
* @return data字段表示删除的bom中是否包含工艺包,包含工艺包时需要刷新列表数据(true为包含,false为不包含)
|
||||||
|
*/
|
||||||
@PostMapping("editDel")
|
@PostMapping("editDel")
|
||||||
@ApiOperation("编辑-删除")
|
@ApiOperation("编辑-删除")
|
||||||
@LogRecord(success = "PBom-编辑-删除,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#param.bomRowId}}",type = "PBom-编辑-删除")
|
@LogRecord(success = "PBom-编辑-删除,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#param.bomRowId}}",type = "PBom-编辑-删除")
|
||||||
public ResultVO<Boolean> editDel(@Valid @RequestBody EditPBomDelDTO param){
|
public ResultVO<Boolean> editDel(@Valid @RequestBody EditPBomDelDTO param){
|
||||||
VUtils.isTure(CollUtil.isEmpty(param.getRowIdList())).throwMessage("请选择要删除的数据行");
|
VUtils.isTure(CollUtil.isEmpty(param.getRowIdList())).throwMessage("请选择要删除的数据行");
|
||||||
bomNewPbomParentService.editDel(param);
|
return ResultVO.success(bomNewPbomParentService.editDel(param));
|
||||||
return ResultVO.success(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("setVirtualPart")
|
@PostMapping("setVirtualPart")
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,8 @@ public class MaterialMainConstant {
|
||||||
|
|
||||||
public static final String MaterialNo_31="31";
|
public static final String MaterialNo_31="31";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 工艺包类别编号
|
||||||
|
*/
|
||||||
|
public static final String CATEGORYCODE_TECHNOLOGYPACKAGE = "201201";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,8 @@ public interface BomNewPbomChildMapper extends BaseMapper<BomNewPbomChildEntity>
|
||||||
void delByParentRowId(@Param("parentRowId") Long parentRowId);
|
void delByParentRowId(@Param("parentRowId") Long parentRowId);
|
||||||
|
|
||||||
void setProductionFactoryCode(@Param("productionFactoryCode")String productionFactoryCode, @Param("rowIds") List<Long> rowIds);
|
void setProductionFactoryCode(@Param("productionFactoryCode")String productionFactoryCode, @Param("rowIds") List<Long> rowIds);
|
||||||
|
|
||||||
|
List<BomNewPbomChildEntity> getChildrenByChildRowId(Long rowId);
|
||||||
|
|
||||||
|
void setParentRowId(List<Long> rowIds, Long parentRowId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
package com.nflg.product.bomnew.pojo.entity;
|
package com.nflg.product.bomnew.pojo.entity;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import java.time.LocalDateTime;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_pbom_child
|
* t_bom_new_pbom_child
|
||||||
|
|
@ -148,6 +146,7 @@ public class BomNewPbomChildEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产工厂设置方式 0-默认 1-规则匹配 2-手工
|
* 生产工厂设置方式 0-默认 1-规则匹配 2-手工
|
||||||
|
* @see com.nflg.product.bomnew.constant.ProductionFactoryCodeInputTypeEnum
|
||||||
*/
|
*/
|
||||||
@TableField(value = "production_factory_code_input_type")
|
@TableField(value = "production_factory_code_input_type")
|
||||||
@ApiModelProperty("生产工厂设置方式 0-默认 1-规则匹配 2-手工")
|
@ApiModelProperty("生产工厂设置方式 0-默认 1-规则匹配 2-手工")
|
||||||
|
|
@ -218,6 +217,7 @@ public class BomNewPbomChildEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包
|
* 0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包
|
||||||
|
* @see com.nflg.product.bomnew.constant.VirtualPackageTypeEnum
|
||||||
*/
|
*/
|
||||||
@TableField(value = "virtual_part_type")
|
@TableField(value = "virtual_part_type")
|
||||||
@ApiModelProperty(value = "0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
|
@ApiModelProperty(value = "0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
package com.nflg.product.bomnew.pojo.entity;
|
package com.nflg.product.bomnew.pojo.entity;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import java.time.LocalDateTime;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_pbom_parent
|
* t_bom_new_pbom_parent
|
||||||
|
|
@ -169,6 +167,7 @@ public class BomNewPbomParentEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1=待处理、2=暂存 3=已处理
|
* 1=待处理、2=暂存 3=已处理
|
||||||
|
* @see com.nflg.product.bomnew.constant.PBomEditStatusEnum
|
||||||
*/
|
*/
|
||||||
@TableField(value = "edit_status")
|
@TableField(value = "edit_status")
|
||||||
@ApiModelProperty(value = "1=待处理、2=暂存 3=已处理")
|
@ApiModelProperty(value = "1=待处理、2=暂存 3=已处理")
|
||||||
|
|
@ -176,6 +175,7 @@ public class BomNewPbomParentEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BOM状态:1=待发布 2=待分配工厂 3=已分配工厂 4=已发布
|
* BOM状态:1=待发布 2=待分配工厂 3=已分配工厂 4=已发布
|
||||||
|
* @see com.nflg.product.bomnew.constant.PBomStatusEnum
|
||||||
*/
|
*/
|
||||||
@TableField(value = "status")
|
@TableField(value = "status")
|
||||||
@ApiModelProperty(value = "BOM状态:1=待发布 4=已发布 8=待分配工厂 16=已分配工厂")
|
@ApiModelProperty(value = "BOM状态:1=待发布 4=已发布 8=待分配工厂 16=已分配工厂")
|
||||||
|
|
@ -247,6 +247,7 @@ public class BomNewPbomParentEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人员所属岗位 0-设计人员 1-工艺人员 2-其他
|
* 创建人员所属岗位 0-设计人员 1-工艺人员 2-其他
|
||||||
|
* @see com.nflg.product.bomnew.constant.UserJobEnum
|
||||||
*/
|
*/
|
||||||
@TableField(value = "created_job")
|
@TableField(value = "created_job")
|
||||||
@ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他")
|
@ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import com.nflg.product.bomnew.mapper.master.BomNewPbomChildMapper;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_pbom_child 表服务实现类
|
* t_bom_new_pbom_child 表服务实现类
|
||||||
|
|
@ -17,4 +19,11 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class BomNewPbomChildService extends ServiceImpl<BomNewPbomChildMapper, BomNewPbomChildEntity> {
|
public class BomNewPbomChildService extends ServiceImpl<BomNewPbomChildMapper, BomNewPbomChildEntity> {
|
||||||
|
|
||||||
|
public List<BomNewPbomChildEntity> getChildrenByChildRowId(Long rowId) {
|
||||||
|
return this.getBaseMapper().getChildrenByChildRowId(rowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentRowId(List<Long> rowIds, Long parentRowId) {
|
||||||
|
this.getBaseMapper().setParentRowId(rowIds, parentRowId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -366,28 +366,51 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
* @param paramDTO
|
* @param paramDTO
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void editDel(EditPBomDelDTO paramDTO) {
|
public boolean editDel(EditPBomDelDTO paramDTO) {
|
||||||
|
boolean hasTechnologypackage = false;
|
||||||
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
|
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
|
||||||
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数bomRowId错误,该BOM不存在");
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数bomRowId错误,该BOM不存在");
|
||||||
BomNewPbomParentVO parentVO = Convert.convert(BomNewPbomParentVO.class, parent);
|
BomNewPbomParentVO parentVO = Convert.convert(BomNewPbomParentVO.class, parent);
|
||||||
LogRecordContext.putVariable("bom",parent);
|
LogRecordContext.putVariable("bom",parent);
|
||||||
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
|
|
||||||
|
|
||||||
List<BomNewPbomChildEntity> childList = pbomChildService.getBaseMapper().selectBatchIds(paramDTO.getRowIdList());
|
List<BomNewPbomChildEntity> childList = pbomChildService.getBaseMapper().selectBatchIds(paramDTO.getRowIdList());
|
||||||
List<BomNewPbomParentVO> childListVO = Convert.toList(BomNewPbomParentVO.class, childList);
|
List<BomNewPbomParentVO> childListVO = Convert.toList(BomNewPbomParentVO.class, childList);
|
||||||
|
|
||||||
materialMainService.intiMaterialInfo(childListVO);
|
materialMainService.intiMaterialInfo(childListVO);
|
||||||
|
|
||||||
|
// 判断是否是工艺包
|
||||||
|
List<BomNewPbomParentVO> technologypackages = childListVO.stream()
|
||||||
|
.filter(c -> MaterialMainConstant.CATEGORYCODE_TECHNOLOGYPACKAGE.equals(c.getMaterialCategoryCode()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(technologypackages)) {
|
||||||
|
//将工艺包子级提层
|
||||||
|
for (BomNewPbomParentVO t : technologypackages) {
|
||||||
|
//找出所有子级
|
||||||
|
List<BomNewPbomChildEntity> cc = pbomChildService.getChildrenByChildRowId(t.getRowId());
|
||||||
|
if (!cc.isEmpty()) {
|
||||||
|
hasTechnologypackage = true;
|
||||||
|
//将子级的父级id设置为工艺包的父级id
|
||||||
|
pbomChildService.setParentRowId(cc.stream().map(BomNewPbomChildEntity::getRowId).collect(Collectors.toList()),
|
||||||
|
t.getParentRowId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
|
||||||
|
|
||||||
// 机加工件 的子级可直接删除
|
// 机加工件 的子级可直接删除
|
||||||
if (parentVO.getMaterialCategoryCode().startsWith("200301")) {
|
if (parentVO.getMaterialCategoryCode().startsWith("200301")) {
|
||||||
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
|
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
|
||||||
return;
|
return hasTechnologypackage;
|
||||||
}
|
}
|
||||||
//删除辅助物料
|
//删除辅助物料
|
||||||
List<BomNewPbomParentVO> noDelList = childListVO.stream().filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021")).collect(Collectors.toList());
|
List<BomNewPbomParentVO> noDelList = childListVO.stream()
|
||||||
|
.filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
noDelList.removeAll(technologypackages);
|
||||||
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
|
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
|
||||||
|
|
||||||
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
|
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
|
||||||
|
return hasTechnologypackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -68,4 +68,22 @@
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="getChildrenByChildRowId" resultMap="BaseResultMap">
|
||||||
|
SELECT c.*
|
||||||
|
FROM t_bom_new_pbom_child c
|
||||||
|
JOIN t_bom_new_pbom_parent p ON p.row_id = c.parent_row_id
|
||||||
|
JOIN t_bom_new_pbom_child c1 ON p.material_no = c1.material_no AND p.last_version_is = 1
|
||||||
|
WHERE c1.row_id = #{rowId}
|
||||||
|
ORDER BY c.row_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="setParentRowId">
|
||||||
|
UPDATE t_bom_new_pbom_child
|
||||||
|
SET parent_row_id=#{parentRowId},modify_time=now()
|
||||||
|
WHERE row_id IN
|
||||||
|
<foreach collection="rowIds" item="item" index="index" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue