fix: pbom正式表分工厂时,如果设置为1010工厂,则需要设置父级的工厂为1010
This commit is contained in:
parent
b4880ab912
commit
698e40c1c4
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,52 +1,47 @@
|
|||
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
|
||||
*
|
||||
*
|
||||
* 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-临时
|
||||
*/
|
||||
@ApiModelProperty(value = "批号-来自plm-临时")
|
||||
private String batchNo;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 工厂编码
|
||||
*/
|
||||
|
|
@ -54,7 +49,6 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
private String facCode;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
|
|
@ -62,100 +56,97 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
private String orderNumber;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 单重
|
||||
*/
|
||||
@ApiModelProperty(value = "单重")
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
@ApiModelProperty(value = "总重")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private String currentVersion;
|
||||
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 是否跟节点 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否跟节点 0-否 1-是")
|
||||
private Integer rootIs;
|
||||
|
||||
|
||||
/**
|
||||
* 是否应该有BOM 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否应该有BOM 0-否 1-是")
|
||||
private Integer shouldBomExist;
|
||||
|
||||
|
||||
/**
|
||||
* 超级物料 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "超级物料 0-否 1-是")
|
||||
private Integer superMaterialStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 是否有BOM: 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
|
||||
private Integer bomExist=0;
|
||||
|
||||
private Integer bomExist = 0;
|
||||
|
||||
/**
|
||||
* 是否最新版:0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否最新版:0-否 1-是")
|
||||
private Integer lastVersionIs;
|
||||
|
||||
|
||||
/**
|
||||
* 1=待处理、2=暂存 3=已处理
|
||||
*/
|
||||
@ApiModelProperty(value = "1=待处理、2=暂存 3=已处理")
|
||||
private Integer editStatus;
|
||||
|
||||
|
||||
/**
|
||||
* BOM状态:1=待发布 2=待分配工厂 3=已分配工厂 4=已发布
|
||||
*/
|
||||
@ApiModelProperty(value = "BOM状态:1=待发布 2-借用件 4=已发布 8=待分配工厂 16=已分配工厂")
|
||||
private Integer status;
|
||||
|
||||
|
||||
/**
|
||||
* 是否用户跟节点 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否用户跟节点 0-否 1-是")
|
||||
private Integer userRootIs;
|
||||
|
||||
|
||||
/**
|
||||
* 是否虚拟包 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否虚拟包 0-否 1-是")
|
||||
private Integer virtualPackageIs;
|
||||
|
||||
|
||||
/**
|
||||
* 来源行ID(EBOM中的行ID)
|
||||
*/
|
||||
@ApiModelProperty(value = "来源行ID(EBOM中的行ID)")
|
||||
private Long sourceRowId;
|
||||
|
||||
|
||||
/**
|
||||
* 设计人员编码
|
||||
*/
|
||||
@ApiModelProperty(value = "设计人员编码")
|
||||
private String deviseUserCode;
|
||||
|
||||
|
||||
/**
|
||||
* 设计人员名称
|
||||
*/
|
||||
|
|
@ -174,37 +165,37 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty(value = "工艺人员名称")
|
||||
private String technologyUserName;
|
||||
|
||||
|
||||
/**
|
||||
* 创建人编码
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人编码")
|
||||
private String createdBy;
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
|
||||
/**
|
||||
* 创建人员所属岗位 0-设计人员 1-工艺人员 2-其他
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他")
|
||||
private Integer createdJob;
|
||||
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@ApiModelProperty(value = "发布时间")
|
||||
private LocalDateTime releaseTime;
|
||||
|
||||
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
@ApiModelProperty(value = "发布人")
|
||||
private String releaseUserName;
|
||||
|
||||
|
||||
/**
|
||||
* 版本过期时间=下个版本的创建时间
|
||||
*/
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -220,37 +211,37 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 设计维护部门名称
|
||||
*/
|
||||
@ApiModelProperty(value = "设计维护部门名称")
|
||||
private String deptName;
|
||||
|
||||
|
||||
/**
|
||||
* bom树的高度
|
||||
*/
|
||||
@ApiModelProperty(value = "bom树的高度")
|
||||
private Integer levelNum;
|
||||
|
||||
|
||||
/**
|
||||
* 升版说明
|
||||
*/
|
||||
@ApiModelProperty(value = "升版说明")
|
||||
private String changeDesc;
|
||||
|
||||
|
||||
/**
|
||||
* 通知单号
|
||||
*/
|
||||
@ApiModelProperty(value = "通知单号")
|
||||
private String noticeNums;
|
||||
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@ApiModelProperty(value = "订单号")
|
||||
private String orderNo;
|
||||
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue