feat(ebom): 过渡版31码生成虚拟包逻辑调整
This commit is contained in:
parent
bc2a737d54
commit
d04b48d43f
|
|
@ -7,7 +7,9 @@ import com.nflg.product.base.core.api.BaseApi;
|
||||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper;
|
import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper;
|
||||||
import com.nflg.product.bomnew.pojo.dto.EbomExcelDTO;
|
import com.nflg.product.bomnew.pojo.dto.EbomExcelDTO;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ImportOriginalBomVO;
|
import com.nflg.product.bomnew.pojo.vo.ImportOriginalBomVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.ListForGenerateVirtualPackageVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||||
|
|
@ -105,4 +107,27 @@ public class EbomV2Api extends BaseApi {
|
||||||
.addSheet(new ListSheet<>("sheet1", ImmutableList.of(new EbomExcelDTO())))
|
.addSheet(new ListSheet<>("sheet1", ImmutableList.of(new EbomExcelDTO())))
|
||||||
.writeTo(response.getOutputStream());
|
.writeTo(response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取物料列表以生成发货包(31编码专用)
|
||||||
|
* @param bomRowId bom的行id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("getListForGenerateVirtualPackage")
|
||||||
|
@ApiOperation("获取物料列表以生成发货包(31编码专用)")
|
||||||
|
public ResultVO<ListForGenerateVirtualPackageVO> getListForGenerateVirtualPackage(@RequestParam("bomRowId") Long bomRowId) {
|
||||||
|
return ResultVO.success(ebomParentService.getListForGenerateVirtualPackage(bomRowId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成发货包(31编码专用)
|
||||||
|
* @param query 请求数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("generateVirtualPackage")
|
||||||
|
@ApiOperation("生成发货包(31编码专用)")
|
||||||
|
public ResultVO<Boolean> generateVirtualPackage(@RequestBody GenerateVirtualPackageQuery query) {
|
||||||
|
ebomParentService.generateVirtualPackageV2(query);
|
||||||
|
return ResultVO.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.query;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 10:42:20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-material-pojo-query-GenerateVirtualPackageItem")
|
||||||
|
public class GenerateVirtualPackageItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "行id", required = true)
|
||||||
|
@NotNull
|
||||||
|
private Long rowId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否生成泉州工厂发货包 true-生成;false-不生成
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否生成泉州工厂发货包", required = true)
|
||||||
|
@NotNull
|
||||||
|
private boolean generate1010;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否生成仙桃工厂发货包 true-生成;false-不生成
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否生成仙桃工厂发货包", required = true)
|
||||||
|
@NotNull
|
||||||
|
private boolean generate1020;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.query;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 10:38:41
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-material-pojo-query-GenerateVirtualPackageQuery")
|
||||||
|
public class GenerateVirtualPackageQuery {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "父级物料行id", required = true)
|
||||||
|
@NotNull
|
||||||
|
private Long parentRowId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "子级物料列表", required = true)
|
||||||
|
@NotEmpty
|
||||||
|
private List<GenerateVirtualPackageItem> children;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 10:30:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-material-pojo-vo-ChildListForGenerateVirtualPackageVO")
|
||||||
|
public class ChildListForGenerateVirtualPackageVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键-雪花")
|
||||||
|
private Long rowId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序号
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "排序号")
|
||||||
|
private String orderNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目类别
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "项目类别")
|
||||||
|
private String projectType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料编码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "物料编码")
|
||||||
|
private String materialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图号
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "图号")
|
||||||
|
private String drawingNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料描述
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "物料描述")
|
||||||
|
private String materialDesc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 泉州工厂是否已生成发货包 true:已生成;false:未生成
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "泉州工厂是否已生成发货包")
|
||||||
|
private boolean hasGenerated1010;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仙桃工厂是否已生成发货包 true:已生成;false:未生成
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "仙桃工厂是否已生成发货包")
|
||||||
|
private boolean hasGenerated1020;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 10:27:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-material-pojo-vo-ListForGenerateVirtualPackageVO")
|
||||||
|
public class ListForGenerateVirtualPackageVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父级物料
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "父级物料")
|
||||||
|
private BomNewEbomParentVO parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子级物料
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "子级物料")
|
||||||
|
private List<ChildListForGenerateVirtualPackageVO> children;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 09:55:12
|
||||||
|
*/
|
||||||
|
public class BomNewEbomGenerateVirtualPackageServiceFor21Impl implements IBomNewEbomGenerateVirtualPackageService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(GenerateVirtualPackageQuery query) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,253 @@
|
||||||
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
|
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||||
|
import com.nflg.product.bomnew.constant.OriginalConstant;
|
||||||
|
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
||||||
|
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.AddVirtrualMaterialDTO;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.ChildListForGenerateVirtualPackageVO;
|
||||||
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 09:54:41
|
||||||
|
*/
|
||||||
|
public class BomNewEbomGenerateVirtualPackageServiceFor31Impl implements IBomNewEbomGenerateVirtualPackageService {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(BomNewEbomGenerateVirtualPackageServiceFor31Impl.class);
|
||||||
|
|
||||||
|
private final BomNewEbomParentService ebomParentService = SpringUtil.getBean(BomNewEbomParentService.class);
|
||||||
|
private final BomNewEbomChildService ebomChildService = SpringUtil.getBean(BomNewEbomChildService.class);
|
||||||
|
private final MaterialService materialService = SpringUtil.getBean(MaterialService.class);
|
||||||
|
|
||||||
|
private final List<BomNewEbomChildEntity> children = new ArrayList<>();
|
||||||
|
private final List<BomNewEbomParentEntity> parents = new ArrayList<>();
|
||||||
|
private final List<Long> childRowIdsForDel = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(GenerateVirtualPackageQuery query) {
|
||||||
|
BomNewEbomParentEntity root = ebomParentService.getById(query.getParentRowId());
|
||||||
|
VUtils.isTure(Objects.isNull(root)).throwMessage("无效的数据");
|
||||||
|
|
||||||
|
VUtils.isTure(root.getMaterialNo().startsWith("21")).throwMessage("21编码接口调用错误");
|
||||||
|
VUtils.isTure(!root.getMaterialNo().startsWith("31")).throwMessage("该编码的物料不能生成发货包:" + root.getMaterialNo());
|
||||||
|
|
||||||
|
List<ChildListForGenerateVirtualPackageVO> olds = ebomParentService.getChildListForGenerateVirtualPackage(root);
|
||||||
|
query.getChildren().forEach(it -> {
|
||||||
|
ChildListForGenerateVirtualPackageVO old = olds.stream().filter(f -> Objects.equals(f.getRowId(), it.getRowId())).findFirst().orElse(null);
|
||||||
|
VUtils.isTure(Objects.isNull(old)).throwMessage(it.getRowId() + "无效");
|
||||||
|
BomNewEbomChildEntity child = ebomChildService.getById(it.getRowId());
|
||||||
|
if (it.isGenerate1010() && it.isGenerate1020()) {
|
||||||
|
selectedAll(root, child, old);
|
||||||
|
} else if (!it.isGenerate1010() && !it.isGenerate1020()) {
|
||||||
|
cancelAll(root, child, old);
|
||||||
|
} else if (it.isGenerate1010()) {
|
||||||
|
selected1010Cancel1020(root, child, old);
|
||||||
|
} else {
|
||||||
|
selected1020Cancel1010(root, child, old);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<AddVirtrualMaterialDTO> addM = children.stream().filter(c -> StrUtil.isBlank(c.getMaterialNo())).map(c -> {
|
||||||
|
AddVirtrualMaterialDTO ent = new AddVirtrualMaterialDTO();
|
||||||
|
ent.setKey(c.getRowId().toString());
|
||||||
|
ent.setDrawingNo(c.getDrawingNo());
|
||||||
|
ent.setMaterialName(c.getMaterialName());
|
||||||
|
ent.setMaterialDesc(c.getMaterialDesc());
|
||||||
|
ent.setMaterialCategoryCode(c.getMaterialCategoryCode());
|
||||||
|
return ent;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
Map<String, AddVirtrualMaterialDTO> vMNosResult = materialService.batchAddMaterial(addM);
|
||||||
|
vMNosResult.forEach((k, v) -> {
|
||||||
|
children.stream().filter(c -> Objects.equals(c.getRowId(), Convert.toLong(k))).forEach(c -> {
|
||||||
|
c.setMaterialNo(v.getMaterialNo());
|
||||||
|
});
|
||||||
|
parents.stream().filter(c -> Objects.equals(c.getRowId(), Convert.toLong(k))).forEach(c -> {
|
||||||
|
c.setMaterialNo(v.getMaterialNo());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void save() {
|
||||||
|
if (CollUtil.isNotEmpty(childRowIdsForDel)) {
|
||||||
|
ebomChildService.getBaseMapper().deleteBatchIds(childRowIdsForDel);
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(children)) {
|
||||||
|
ebomChildService.saveOrUpdateBatch(children);
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(parents)) {
|
||||||
|
ebomParentService.saveOrUpdateBatch(parents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selected1020Cancel1010(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
||||||
|
if (old.isHasGenerated1010()) {
|
||||||
|
buildDelDeliveryVirtualPackage(root, child, false);
|
||||||
|
}
|
||||||
|
if (!old.isHasGenerated1020()) {
|
||||||
|
build1020VirtualPackage(root, true, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selected1010Cancel1020(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
||||||
|
if (old.isHasGenerated1020()) {
|
||||||
|
buildDelDeliveryVirtualPackage(root, child, true);
|
||||||
|
}
|
||||||
|
if (!old.isHasGenerated1010()) {
|
||||||
|
build1010VirtualPackage(root, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void build1010VirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child) {
|
||||||
|
//发货包
|
||||||
|
BomNewEbomChildEntity qc1 = buildVirtualPackage(false, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||||
|
BomNewEbomParentEntity qp1 = buildVirtualPackage(root, qc1);
|
||||||
|
//制作包
|
||||||
|
BomNewEbomChildEntity qc2 = buildVirtualPackage(false, qp1.getRowId(), root, child, VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
||||||
|
BomNewEbomParentEntity qp2 = buildVirtualPackage(qp1, qc2);
|
||||||
|
child.setParentRowId(qp2.getRowId());
|
||||||
|
child.setModifyTime(LocalDateTime.now());
|
||||||
|
children.add(child);
|
||||||
|
//直发包
|
||||||
|
buildVirtualPackage(false, qp1.getRowId(), root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void build1020VirtualPackage(BomNewEbomParentEntity root, boolean mount, BomNewEbomChildEntity child) {
|
||||||
|
//发货包
|
||||||
|
BomNewEbomChildEntity xc1 = buildVirtualPackage(true, root.getRowId(), root, child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, child.getOrderNumber());
|
||||||
|
BomNewEbomParentEntity xp1 = buildVirtualPackage(root, xc1);
|
||||||
|
//制作包
|
||||||
|
BomNewEbomChildEntity xc2 = buildVirtualPackage(true, xp1.getRowId(), root, child, VirtualPackageTypeEnum.MAKING_PACKAGE, "001");
|
||||||
|
if (mount) {
|
||||||
|
BomNewEbomParentEntity xp2 = buildVirtualPackage(xp1, xc2);
|
||||||
|
child.setParentRowId(xp2.getRowId());
|
||||||
|
child.setModifyTime(LocalDateTime.now());
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
//直发包
|
||||||
|
buildVirtualPackage(true, xp1.getRowId(), root, child, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, "002");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectedAll(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
||||||
|
if (old.isHasGenerated1010() && old.isHasGenerated1020()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!old.isHasGenerated1010()) {
|
||||||
|
build1010VirtualPackage(root, child);
|
||||||
|
}
|
||||||
|
if (!old.isHasGenerated1020()) {
|
||||||
|
build1020VirtualPackage(root, false, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelAll(BomNewEbomParentEntity root, BomNewEbomChildEntity child, ChildListForGenerateVirtualPackageVO old) {
|
||||||
|
child.setParentRowId(root.getRowId());
|
||||||
|
child.setModifyTime(LocalDateTime.now());
|
||||||
|
children.add(child);
|
||||||
|
if (old.isHasGenerated1010()) {
|
||||||
|
buildDelDeliveryVirtualPackage(root, child, false);
|
||||||
|
}
|
||||||
|
if (old.isHasGenerated1020()) {
|
||||||
|
buildDelDeliveryVirtualPackage(root, child, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除发货包
|
||||||
|
* @param root 根节点
|
||||||
|
* @param child 物料
|
||||||
|
* @param is1020Factory 是否是仙桃工厂
|
||||||
|
*/
|
||||||
|
private void buildDelDeliveryVirtualPackage(BomNewEbomParentEntity root, BomNewEbomChildEntity child, boolean is1020Factory) {
|
||||||
|
//发货包
|
||||||
|
String drawingNo = buildDrawingNo(root.getDrawingNo(), child.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, is1020Factory);
|
||||||
|
BomNewEbomChildEntity c = ebomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomChildEntity::getParentRowId, root.getRowId())
|
||||||
|
.eq(BomNewEbomChildEntity::getDrawingNo, drawingNo)
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(c)) {
|
||||||
|
LOGGER.error("{}应有发货包“{}”但未找到", root.getMaterialNo(), drawingNo);
|
||||||
|
} else {
|
||||||
|
childRowIdsForDel.add(c.getRowId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BomNewEbomParentEntity buildVirtualPackage(BomNewEbomParentEntity parent, BomNewEbomChildEntity child) {
|
||||||
|
BomNewEbomParentEntity p = ebomParentService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomParentEntity::getDrawingNo, child.getDrawingNo())
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(p)) {
|
||||||
|
p = Convert.convert(BomNewEbomParentEntity.class, child);
|
||||||
|
p.setCreatedBy(SessionUtil.getUserCode());
|
||||||
|
p.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||||
|
p.setVirtualPackageIs(1);
|
||||||
|
p.setRootIs(0);
|
||||||
|
p.setUserRootIs(0);
|
||||||
|
p.setDeviseName(SessionUtil.getRealName());
|
||||||
|
p.setDeviseUserCode(SessionUtil.getUserCode());
|
||||||
|
p.setDeptName(SessionUtil.getDepartName());
|
||||||
|
p.setRootIsForWaitReview(0);
|
||||||
|
p.setAuditTime(parent.getAuditTime());
|
||||||
|
p.setAuditUserName(parent.getAuditUserName());
|
||||||
|
p.setStatus(parent.getStatus());
|
||||||
|
p.setLastVersionIs(1);
|
||||||
|
p.setBatchNo("");
|
||||||
|
p.setLevelNum(parent.getLevelNum() + 1);
|
||||||
|
p.setBomExist(1);
|
||||||
|
parents.add(p);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BomNewEbomChildEntity buildVirtualPackage(boolean is1020Factory, Long parentRowId, BomNewEbomParentEntity root
|
||||||
|
, BomNewEbomChildEntity material, VirtualPackageTypeEnum type, String orderNo) {
|
||||||
|
BomNewEbomChildEntity child = new BomNewEbomChildEntity();
|
||||||
|
child.setRowId(IdWorker.getId());
|
||||||
|
child.setParentRowId(parentRowId);
|
||||||
|
child.setIdentityNo(parentRowId + "_" + child.getRowId());
|
||||||
|
child.setOrderNumber(orderNo);
|
||||||
|
child.setNum(new BigDecimal(1));
|
||||||
|
child.setEditStatus(root.getEditStatus());
|
||||||
|
child.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||||
|
child.setVirtualPartType(type.getValue());
|
||||||
|
child.setProjectType("L");
|
||||||
|
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||||
|
child.setMaterialUnit("PC");
|
||||||
|
child.setMaterialOriginalUnit("PC");
|
||||||
|
//child.setVirtualPartRootMaterialNo(rootMaterialNo);
|
||||||
|
child.setCreatedBy(SessionUtil.getUserCode());
|
||||||
|
child.setDrawingNo(buildDrawingNo(root.getDrawingNo(), material.getMaterialName(), type, is1020Factory));
|
||||||
|
child.setMaterialDesc(child.getDrawingNo());
|
||||||
|
child.setMaterialName(child.getDrawingNo());
|
||||||
|
child.setMaterialCategoryCode(type.getMaterialCategoryCode());
|
||||||
|
children.add(child);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildDrawingNo(String drawingNo, String materialName, VirtualPackageTypeEnum type, boolean is1020Factory) {
|
||||||
|
return StrUtil.format("({})({}{})({})", drawingNo, materialName, is1020Factory ? "仙桃" : "", type.getConMaterialName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,7 @@ import com.nflg.product.bomnew.pojo.entity.*;
|
||||||
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery;
|
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery;
|
||||||
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
|
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
|
||||||
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
|
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.*;
|
import com.nflg.product.bomnew.pojo.vo.*;
|
||||||
import com.nflg.product.bomnew.service.domain.EBom.*;
|
import com.nflg.product.bomnew.service.domain.EBom.*;
|
||||||
import com.nflg.product.bomnew.util.*;
|
import com.nflg.product.bomnew.util.*;
|
||||||
|
|
@ -2352,4 +2353,58 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
.set(BomNewEbomParentEntity::getModifyTime, LocalDateTime.now())
|
.set(BomNewEbomParentEntity::getModifyTime, LocalDateTime.now())
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void generateVirtualPackageV2(GenerateVirtualPackageQuery query) {
|
||||||
|
IBomNewEbomGenerateVirtualPackageService service = new BomNewEbomGenerateVirtualPackageServiceFor31Impl();
|
||||||
|
service.generate(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListForGenerateVirtualPackageVO getListForGenerateVirtualPackage(Long bomRowId) {
|
||||||
|
BomNewEbomParentEntity parent = getById(bomRowId);
|
||||||
|
VUtils.isTure(Objects.isNull(parent)).throwMessage("无效的数据");
|
||||||
|
|
||||||
|
ListForGenerateVirtualPackageVO vo = new ListForGenerateVirtualPackageVO();
|
||||||
|
vo.setParent(Convert.convert(BomNewEbomParentVO.class, parent));
|
||||||
|
|
||||||
|
vo.setChildren(getChildListForGenerateVirtualPackage(parent));
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChildListForGenerateVirtualPackageVO> getChildListForGenerateVirtualPackage(BomNewEbomParentEntity parent) {
|
||||||
|
List<BomNewEbomChildEntity> children = ebomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomChildEntity::getVirtualPartRootMaterialNo, parent.getMaterialNo())
|
||||||
|
.ne(BomNewEbomChildEntity::getProjectType, BomConstant.PROJECT_TYPE_TEMPORARY)
|
||||||
|
.orderByAsc(BomNewEbomChildEntity::getOrderNumber)
|
||||||
|
.list();
|
||||||
|
if (CollUtil.isNotEmpty(children)) {
|
||||||
|
List<ChildListForGenerateVirtualPackageVO> cvos = new ArrayList<>();
|
||||||
|
children.forEach(it -> {
|
||||||
|
ChildListForGenerateVirtualPackageVO cvo = Convert.convert(ChildListForGenerateVirtualPackageVO.class, it);
|
||||||
|
BomNewEbomParentEntity p = lambdaQuery().eq(BomNewEbomParentEntity::getRowId, it.getParentRowId()).one();
|
||||||
|
if (p.getVirtualPackageIs() == 1) {
|
||||||
|
if (p.getMaterialDesc().contains("仙桃")) {
|
||||||
|
//如果上级虚拟包名称包含仙桃,那说明选中了仙桃,没有选中泉州
|
||||||
|
cvo.setHasGenerated1020(true);
|
||||||
|
cvo.setHasGenerated1010(false);
|
||||||
|
} else {
|
||||||
|
cvo.setHasGenerated1010(true);
|
||||||
|
//如果上级虚拟包名称不包含仙桃,那说明选中了泉州,有没有选中仙桃,需要继续判断是否生成了仙桃的发货包
|
||||||
|
String virtualPackageDrawingNo = BomNewEbomGenerateVirtualPackageServiceFor31Impl.buildDrawingNo(
|
||||||
|
parent.getDrawingNo(), it.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE, true);
|
||||||
|
cvo.setHasGenerated1020(ebomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId())
|
||||||
|
.eq(BomNewEbomChildEntity::getDrawingNo, virtualPackageDrawingNo)
|
||||||
|
.exists());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//如果上级不是虚拟包,说明都没选中
|
||||||
|
cvo.setHasGenerated1010(false);
|
||||||
|
cvo.setHasGenerated1020(false);
|
||||||
|
}
|
||||||
|
cvos.add(cvo);
|
||||||
|
});
|
||||||
|
return cvos;
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,9 @@ public class EBomImportService {
|
||||||
child.setProjectType(projectType);
|
child.setProjectType(projectType);
|
||||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||||
child.setIdentityNo(child.getParentRowId() + "_" + child.getRowId());
|
child.setIdentityNo(child.getParentRowId() + "_" + child.getRowId());
|
||||||
|
if (p.getMaterialNo().startsWith("31")) {
|
||||||
|
child.setVirtualPartRootMaterialNo(p.getMaterialNo());
|
||||||
|
}
|
||||||
BaseMaterialVO vo = materialBaseInfos.stream()
|
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||||
.filter(m -> m.getMaterialNo().equals(child.getMaterialNo()))
|
.filter(m -> m.getMaterialNo().equals(child.getMaterialNo()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import com.nflg.product.bomnew.pojo.query.GenerateVirtualPackageQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/5/15 09:51:42
|
||||||
|
*/
|
||||||
|
public interface IBomNewEbomGenerateVirtualPackageService {
|
||||||
|
|
||||||
|
void generate(GenerateVirtualPackageQuery query);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue