fix: pbom正式表分工厂时,如果设置为1010工厂,则需要设置父级的工厂为1010

This commit is contained in:
曹鹏飞 2024-04-16 10:27:32 +08:00
parent b4880ab912
commit 698e40c1c4
6 changed files with 100 additions and 79 deletions

View File

@ -246,15 +246,14 @@ public class PBomApi extends BaseApi {
@ApiOperation("分工厂-保存")
@LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody List<SaveAllocationFactoryDTO> params){
return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params));
return ResultVO.success();
//return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params));
}
@PostMapping("saveAllocationFactoryNew")
@ApiOperation("分工厂-批量保存保存")
@LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody AllocationFactoryParam params){
return ResultVO.success(bomNewPbomParentService.saveAllocationFactoryNew(params));
}

View File

@ -1,9 +1,10 @@
package com.nflg.product.bomnew.pojo.dto;
import com.nflg.product.bomnew.service.BomNewLogService;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@ -12,8 +13,10 @@ import java.util.List;
@Data
public class AllocationFactoryParam {
@NotEmpty
List<SaveAllocationFactoryDTO> data;
@ApiModelProperty("是否设置下级 0-否 1-是")
@NotNull
private Integer setSubNode;
}

View File

@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 保存分工厂参数
@ -21,4 +22,7 @@ public class SaveAllocationFactoryDTO {
@ApiModelProperty("生产工厂")
@NotNull(message = "生产工厂不能为空")
private String productionFactoryCode;
@ApiModelProperty("所有父级的rowId")
private List<Long> allParentRowIds;
}

View File

@ -1,44 +1,40 @@
package com.nflg.product.bomnew.pojo.vo;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* t_bom_new_pbom_parent
*
*
* @author makejava
* @since 2024-01-01 10:39:59
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-new-vo-BomNewPbomParentEntityVO")
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-vo-BomNewPbomParentEntityVO")
public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
/**
* 主键行ID-雪花
*/
@ApiModelProperty(value = "主键行ID-雪花")
private Long rowId=0L;
private Long rowId = 0L;
@ApiModelProperty("Bom行ID")
private Long bomRowId=0L;
private Long bomRowId = 0L;
@ApiModelProperty("父级行id")
private Long parentRowId=0L;
private Long parentRowId = 0L;
/**
* 批号-来自plm-临时
*/
@ -46,7 +42,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String batchNo;
/**
* 工厂编码
*/
@ -54,7 +49,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String facCode;
/**
* 排序号
*/
@ -62,8 +56,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String orderNumber;
/**
* 单重
*/
@ -89,7 +81,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private BigDecimal num;
/**
* 是否跟节点 0- 1-
*/
@ -112,7 +103,7 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
* 是否有BOM: 0- 1-
*/
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
private Integer bomExist=0;
private Integer bomExist = 0;
/**
* 是否最新版0- 1-
@ -212,7 +203,7 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private LocalDateTime expireEndTime;
public LocalDateTime getExpireEndTime() {
return expireEndTime==null? LocalDateTime.of(9999,12,31,23,59,59):expireEndTime;
return expireEndTime == null ? LocalDateTime.of(9999, 12, 31, 23, 59, 59) : expireEndTime;
}
/**
@ -275,14 +266,15 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String levelNo;
// @ApiModelProperty("物料一级分类编码")
// private String relCategoryCode;
// @ApiModelProperty("物料一级分类编码")
// private String relCategoryCode;
@ApiModelProperty("子级")
List<BomNewPbomParentVO> childNodes;
@ApiModelProperty("所有父级的rowId")
private Set<Long> allParentRowIds = new HashSet<>();
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
}

View File

@ -2,6 +2,7 @@ package com.nflg.product.bomnew.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.mapper.master.BomNewPbomChildMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
import org.springframework.stereotype.Service;
@ -26,4 +27,12 @@ public class BomNewPbomChildService extends ServiceImpl<BomNewPbomChildMapper, B
public void setParentRowId(List<Long> rowIds, Long parentRowId) {
this.getBaseMapper().setParentRowId(rowIds, parentRowId);
}
public boolean setParentFactoryCode1010(List<Long> allParentRowIds) {
return this.lambdaUpdate()
.in(BomNewPbomChildEntity::getRowId, allParentRowIds)
.set(BomNewPbomChildEntity::getProductionFactoryCode, EBomConstant.MAIN_FACTORY_CODE_1010)
.set(BomNewPbomChildEntity::getProductionFactoryCodeInputType, 2)
.update();
}
}

View File

@ -595,10 +595,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
* @param
* @param countLevelNum 是否标记层级 0- 1-
* @return
* @throws ExecutionException
* @throws InterruptedException
*/
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) {
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
AtomicInteger levelNum = new AtomicInteger(1);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
@ -645,13 +643,26 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return CTreePBomUtils.toTree(bomRowId, allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
}
public List<BomNewPbomParentVO> getAllocationFactoryBomTree(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
public List<BomNewPbomParentVO> getAllocationFactoryBomTree(AllocationFactoryBomQuery param) {
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
List<BomNewPbomParentVO> tree = CTreePBomUtils.toTree(param.getBomRowId(), allBom, BomNewPbomParentVO::getParentRowId, BomNewPbomParentVO::getBomRowId);
initParentRowIds(null, tree);
return tree;
}
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) throws ExecutionException, InterruptedException {
private void initParentRowIds(BomNewPbomParentVO parent, List<BomNewPbomParentVO> children) {
if (CollUtil.isEmpty(children)) return;
children.forEach(c -> {
if (parent != null) {
c.setAllParentRowIds(Sets.newHashSet(parent.getAllParentRowIds()));
c.getAllParentRowIds().add(parent.getRowId());
}
initParentRowIds(c, c.getChildNodes());
});
}
public List<BomNewPbomParentVO> getAllocationFactoryBom(AllocationFactoryBomQuery param) {
List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return allBom;
@ -676,25 +687,28 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public Boolean saveAllocationFactoryNew(AllocationFactoryParam params) {
VUtils.isTure(CollUtil.isEmpty(params.getData())).throwMessage("分配工厂数据为空");
//按分配的工厂分组
VUtils.isTure(params.getSetSubNode().equals(0)
&& params.getData().stream().anyMatch(u -> u.getProductionFactoryCode().equals(EBomConstant.XIAN_TAO_FACTORY_CODE_1020)))
.throwMessage("仙桃工厂(1020)下的子级必须也是仙桃");
if( params.getSetSubNode().equals(0) ){
return saveAllocationFactory(params.getData());
}else {
params.getData().forEach(k->{
try {
AllocationFactoryBomQuery query=new AllocationFactoryBomQuery();
query.setBomRowId(k.getBomRowId());
params.getData().forEach(k -> {
AllocationFactoryBomQuery query = new AllocationFactoryBomQuery();
query.setBomRowId(k.getBomRowId());
List<BomNewPbomParentVO> allBom = this.getAllocationFactoryBom(query);
List<Long> rowIds =new ArrayList<>();
rowIds.add(k.getRowId());
rowIds.addAll(allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList()));
if(CollUtil.isNotEmpty(rowIds)) {
pbomChildService.getBaseMapper().setProductionFactoryCode(k.getProductionFactoryCode(), rowIds);
}
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
List<BomNewPbomParentVO> allBom = this.getAllocationFactoryBom(query);
List<Long> rowIds = new ArrayList<>();
rowIds.add(k.getRowId());
rowIds.addAll(allBom.stream().map(BomNewPbomParentVO::getRowId).collect(Collectors.toList()));
if (CollUtil.isNotEmpty(rowIds)) {
pbomChildService.getBaseMapper().setProductionFactoryCode(k.getProductionFactoryCode(), rowIds);
}
if (k.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) {
//设置所有父级节点为1010
pbomChildService.setParentFactoryCode1010(k.getAllParentRowIds());
}
});
}