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("分工厂-保存") @ApiOperation("分工厂-保存")
@LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存") @LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody List<SaveAllocationFactoryDTO> params){ public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody List<SaveAllocationFactoryDTO> params){
return ResultVO.success();
return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params)); //return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params));
} }
@PostMapping("saveAllocationFactoryNew") @PostMapping("saveAllocationFactoryNew")
@ApiOperation("分工厂-批量保存保存") @ApiOperation("分工厂-批量保存保存")
@LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存") @LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody AllocationFactoryParam params){ public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody AllocationFactoryParam params){
return ResultVO.success(bomNewPbomParentService.saveAllocationFactoryNew(params)); return ResultVO.success(bomNewPbomParentService.saveAllocationFactoryNew(params));
} }

View File

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

View File

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

View File

@ -1,44 +1,40 @@
package com.nflg.product.bomnew.pojo.vo; 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.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; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* t_bom_new_pbom_parent * t_bom_new_pbom_parent
*
*
* @author makejava * @author makejava
* @since 2024-01-01 10:39:59 * @since 2024-01-01 10:39:59
*/ */
@Data @Data
@Accessors(chain = true) @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 { public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
/** /**
* 主键行ID-雪花 * 主键行ID-雪花
*/ */
@ApiModelProperty(value = "主键行ID-雪花") @ApiModelProperty(value = "主键行ID-雪花")
private Long rowId=0L; private Long rowId = 0L;
@ApiModelProperty("Bom行ID") @ApiModelProperty("Bom行ID")
private Long bomRowId=0L; private Long bomRowId = 0L;
@ApiModelProperty("父级行id") @ApiModelProperty("父级行id")
private Long parentRowId=0L; private Long parentRowId = 0L;
/** /**
* 批号-来自plm-临时 * 批号-来自plm-临时
*/ */
@ -46,7 +42,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String batchNo; private String batchNo;
/** /**
* 工厂编码 * 工厂编码
*/ */
@ -54,7 +49,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String facCode; private String facCode;
/** /**
* 排序号 * 排序号
*/ */
@ -62,8 +56,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private String orderNumber; private String orderNumber;
/** /**
* 单重 * 单重
*/ */
@ -89,7 +81,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private BigDecimal num; private BigDecimal num;
/** /**
* 是否跟节点 0- 1- * 是否跟节点 0- 1-
*/ */
@ -112,7 +103,7 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
* 是否有BOM: 0- 1- * 是否有BOM: 0- 1-
*/ */
@ApiModelProperty(value = "是否有BOM: 0-否 1-是") @ApiModelProperty(value = "是否有BOM: 0-否 1-是")
private Integer bomExist=0; private Integer bomExist = 0;
/** /**
* 是否最新版0- 1- * 是否最新版0- 1-
@ -212,7 +203,7 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
private LocalDateTime expireEndTime; private LocalDateTime expireEndTime;
public LocalDateTime getExpireEndTime() { 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; private String levelNo;
// @ApiModelProperty("物料一级分类编码") // @ApiModelProperty("物料一级分类编码")
// private String relCategoryCode; // private String relCategoryCode;
@ApiModelProperty("子级") @ApiModelProperty("子级")
List<BomNewPbomParentVO> childNodes; 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.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.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;
@ -26,4 +27,12 @@ public class BomNewPbomChildService extends ServiceImpl<BomNewPbomChildMapper, B
public void setParentRowId(List<Long> rowIds, Long parentRowId) { public void setParentRowId(List<Long> rowIds, Long parentRowId) {
this.getBaseMapper().setParentRowId(rowIds, 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
* @param countLevelNum 是否标记层级 0- 1- * @param countLevelNum 是否标记层级 0- 1-
* @return * @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); List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
AtomicInteger levelNum = new AtomicInteger(1); AtomicInteger levelNum = new AtomicInteger(1);
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum); 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); 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); List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); 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); List<BomNewPbomParentVO> allBom = getAllBom(param.getBomRowId(), 1);
materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); materialMainService.intiMaterialInfo(allBom, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return allBom; return allBom;
@ -676,25 +687,28 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public Boolean saveAllocationFactoryNew(AllocationFactoryParam params) { public Boolean saveAllocationFactoryNew(AllocationFactoryParam params) {
VUtils.isTure(CollUtil.isEmpty(params.getData())).throwMessage("分配工厂数据为空"); 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) ){ if( params.getSetSubNode().equals(0) ){
return saveAllocationFactory(params.getData()); return saveAllocationFactory(params.getData());
}else { }else {
params.getData().forEach(k->{ params.getData().forEach(k -> {
try { AllocationFactoryBomQuery query = new AllocationFactoryBomQuery();
AllocationFactoryBomQuery query=new AllocationFactoryBomQuery(); query.setBomRowId(k.getBomRowId());
query.setBomRowId(k.getBomRowId());
List<BomNewPbomParentVO> allBom = this.getAllocationFactoryBom(query); List<BomNewPbomParentVO> allBom = this.getAllocationFactoryBom(query);
List<Long> rowIds =new ArrayList<>(); List<Long> rowIds = new ArrayList<>();
rowIds.add(k.getRowId()); rowIds.add(k.getRowId());
rowIds.addAll(allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList())); rowIds.addAll(allBom.stream().map(BomNewPbomParentVO::getRowId).collect(Collectors.toList()));
if(CollUtil.isNotEmpty(rowIds)) { if (CollUtil.isNotEmpty(rowIds)) {
pbomChildService.getBaseMapper().setProductionFactoryCode(k.getProductionFactoryCode(), rowIds); pbomChildService.getBaseMapper().setProductionFactoryCode(k.getProductionFactoryCode(), rowIds);
} }
} catch (ExecutionException e) {
e.printStackTrace(); if (k.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) {
} catch (InterruptedException e) { //设置所有父级节点为1010
e.printStackTrace(); pbomChildService.setParentFactoryCode1010(k.getAllParentRowIds());
} }
}); });
} }