临时转原始BOM
This commit is contained in:
parent
55e534b834
commit
3b88dab1f2
|
|
@ -1,10 +1,14 @@
|
|||
package com.nflg.product.bomnew.api.user;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.pojo.dto.OriginalSaveBomDTO;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomFromPlmQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.util.TreeNode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Getter;
|
||||
|
|
@ -14,7 +18,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* 大米
|
||||
|
|
@ -30,28 +36,52 @@ public class OriginalBomApi extends BaseApi {
|
|||
|
||||
@PostMapping("bomPage")
|
||||
@ApiOperation("原始BOM-列表")
|
||||
public ResultVO<List<BomOriginalListVO>> bomPage(@RequestBody OriginalBomQuery query) {
|
||||
public ResultVO<Page<BomOriginalListVO>> bomPage(@RequestBody OriginalBomQuery query) {
|
||||
return ResultVO.success(originalParentService.getOriginalBomListPage(query));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("getChild")
|
||||
@ApiOperation("获取子级")
|
||||
public ResultVO<List<BomOriginalListVO>> getChild(@RequestParam("rowId") Long rowId) {
|
||||
return ResultVO.success(originalParentService.getChild(rowId));
|
||||
}
|
||||
|
||||
@GetMapping("getChildTree")
|
||||
@ApiOperation("获取子级整颗树(测试用)")
|
||||
public ResultVO<List<TreeNode<BomOriginalListVO>>> getChildTree(@RequestParam("rowId") Long rowId) throws ExecutionException, InterruptedException {
|
||||
return ResultVO.success(originalParentService.getChildTree(rowId));
|
||||
}
|
||||
@PostMapping("saveBom")
|
||||
@ApiOperation("编辑时-暂存")
|
||||
public ResultVO<Boolean> saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) {
|
||||
return ResultVO.success(originalParentService.saveBom(bom));
|
||||
}
|
||||
|
||||
@PostMapping("saveSubmit")
|
||||
@ApiOperation("编辑时-提交")
|
||||
public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) {
|
||||
return ResultVO.success(originalParentService.saveSubmit(bom));
|
||||
}
|
||||
|
||||
@PostMapping("pullFromPlm")
|
||||
@ApiOperation("手动从PLM获取BOM数据") //去除参数 @RequestBody OriginalBomFromPlmQuery dto
|
||||
@ApiOperation("从PLM获取BOM数据") //去除参数 @RequestBody OriginalBomFromPlmQuery dto
|
||||
|
||||
public ResultVO<Boolean> pullFromPlm(@RequestParam("userCode") String userCode) {
|
||||
public ResultVO<Boolean> pullFromPlm() {
|
||||
// if ((dto.getStartDate() == null && dto.getEndDate() == null) && StringUtils.isEmpty(dto.getDrawingNo())) {
|
||||
// return ResultVO.error(STATE.ParamErr, "请选择日期或图号");
|
||||
// }
|
||||
|
||||
originalParentService.pullFromPlm(userCode);
|
||||
originalParentService.pullFromPlm(SessionUtil.getUserCode());
|
||||
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("del")
|
||||
@ApiOperation("删除BOM")
|
||||
public ResultVO<Boolean> del(@RequestParam("parentRowId") Long parentRowId) throws ExecutionException, InterruptedException {
|
||||
return ResultVO.success(originalParentService.del(parentRowId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
||||
/**
|
||||
* 主数据源配置
|
||||
|
|
@ -134,4 +135,10 @@ public class MasterDataSourceConfig {
|
|||
}
|
||||
|
||||
|
||||
@Bean("getBomDetailPool")
|
||||
public ForkJoinPool getBomNewDetailPool() {
|
||||
return new ForkJoinPool();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MaterialGetEnum implements ValueEnum<Integer> {
|
||||
|
||||
// 制作物料获取类型:1=自制、2=外协、3=采购
|
||||
|
||||
developing(1, "自制"),
|
||||
outsource(2, "外协"),
|
||||
purchase(3, "采购");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package com.nflg.product.bomnew.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -17,7 +19,12 @@ import java.util.List;
|
|||
public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalParentEntity> {
|
||||
|
||||
|
||||
List<BomOriginalListVO> getOriginalBomListPage();
|
||||
Page<BomOriginalListVO> getOriginalBomListPage(Page<BomOriginalListVO> page, @Param("query")OriginalBomQuery query);
|
||||
|
||||
List<BomOriginalListVO> getParentChild(@Param("rowId") Long rowId);
|
||||
|
||||
|
||||
List<BomOriginalListVO> getParentChildBatch(@Param("rowIds") List<Long> rowIds);
|
||||
|
||||
void delBatch(@Param("rowIds") List<Long> rowIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OriginalSaveBomDTO {
|
||||
|
||||
@ApiModelProperty("父级行ID")
|
||||
@NotNull(message = "父级行ID不能为空")
|
||||
private Long parentRowId;
|
||||
|
||||
@ApiModelProperty("子级列表")
|
||||
List<BomOriginalListVO> bomList;
|
||||
}
|
||||
|
|
@ -6,14 +6,17 @@ import cn.hutool.core.util.NumberUtil;
|
|||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* t_bom_new_original_child
|
||||
* t_bom_new_original_child
|
||||
* 原始bom-内容
|
||||
*
|
||||
* @author makejava
|
||||
|
|
@ -21,84 +24,88 @@ import java.time.LocalDate;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewOriginalChildEntity")
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewOriginalChildEntity")
|
||||
@TableName(value = "t_bom_new_original_child")
|
||||
public class BomNewOriginalChildEntity implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 雪花ID
|
||||
*/
|
||||
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "雪花ID")
|
||||
private Long rowId;
|
||||
|
||||
|
||||
/**
|
||||
* 父级行ID
|
||||
*/
|
||||
@TableField(value = "parent_row_id")
|
||||
@ApiModelProperty(value = "父级行ID")
|
||||
@TableField(value = "parent_row_id")
|
||||
@ApiModelProperty(value = "父级行ID")
|
||||
private Long parentRowId;
|
||||
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
@TableField(value = "order_number")
|
||||
@ApiModelProperty(value = "序号")
|
||||
@TableField(value = "order_number")
|
||||
@ApiModelProperty(value = "序号")
|
||||
private String orderNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
@TableField(value = "drawing_no")
|
||||
@ApiModelProperty(value = "图号")
|
||||
@TableField(value = "drawing_no")
|
||||
@ApiModelProperty(value = "图号")
|
||||
private String drawingNo;
|
||||
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@TableField(value = "material_no")
|
||||
@ApiModelProperty(value = "物料编码")
|
||||
@TableField(value = "material_no")
|
||||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@TableField(value = "material_name")
|
||||
@ApiModelProperty(value = "物料名称")
|
||||
@TableField(value = "material_name")
|
||||
@ApiModelProperty(value = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
@TableField(value = "material_desc")
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
@TableField(value = "material_desc")
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String materialDesc;
|
||||
|
||||
|
||||
/**
|
||||
* 单重
|
||||
*/
|
||||
@TableField(value = "unit_weight")
|
||||
@ApiModelProperty(value = "单重")
|
||||
@TableField(value = "unit_weight")
|
||||
@ApiModelProperty(value = "单重")
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@TableField(value = "num")
|
||||
@ApiModelProperty(value = "数量")
|
||||
@TableField(value = "num")
|
||||
@ApiModelProperty(value = "数量")
|
||||
private Integer num;
|
||||
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
@TableField(value = "total_weight")
|
||||
@ApiModelProperty(value = "重量")
|
||||
@TableField(value = "total_weight")
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
@TableField(value = "remark")
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
public BigDecimal getTotalWeight() {
|
||||
return NumberUtil.mul(this.getUnitWeight(),this.num);
|
||||
return NumberUtil.mul(this.getUnitWeight(), this.num);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -61829104329368344L;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,6 +222,10 @@ public class BomNewOriginalParentEntity implements Serializable {
|
|||
@ApiModelProperty("版本失效时间")
|
||||
private LocalDateTime expireEndTime;
|
||||
|
||||
@TableField(value = "level_num")
|
||||
@ApiModelProperty("bom树的高度")
|
||||
private Integer levelNum;
|
||||
|
||||
private static final long serialVersionUID = 157916241261695597L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ public class BaseMaterialVO {
|
|||
@ApiModelProperty("物料分类编码")
|
||||
private String materialCategoryCode;
|
||||
|
||||
@ApiModelProperty("制作物料获取类型:1=自制、2=外协、3=采购")
|
||||
private Integer materialGetType;
|
||||
|
||||
@ApiModelProperty("项目类别(F、Q、L)")
|
||||
private String projectType;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.bomnew.pojo.vo;
|
|||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -9,6 +10,7 @@ import java.time.LocalDateTime;
|
|||
/**
|
||||
* 原始BOM-列表
|
||||
*/
|
||||
@Data
|
||||
public class BomOriginalListVO extends BaseMaterialVO {
|
||||
|
||||
/**
|
||||
|
|
@ -17,36 +19,20 @@ public class BomOriginalListVO extends BaseMaterialVO {
|
|||
@ApiModelProperty(value = "雪花ID")
|
||||
private Long rowId;
|
||||
|
||||
|
||||
@ApiModelProperty("父级行ID")
|
||||
private Long parentRowId;
|
||||
|
||||
@ApiModelProperty("子级BOM行ID")
|
||||
private Long childBomRowId;
|
||||
|
||||
|
||||
/**
|
||||
* 批号来源cad原始bom
|
||||
*/
|
||||
@ApiModelProperty(value = "批号来源cad原始bom")
|
||||
private String batchNo;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
@ApiModelProperty(value = "图号")
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@ApiModelProperty(value = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String materialDesc;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
|
|
@ -173,6 +159,12 @@ public class BomOriginalListVO extends BaseMaterialVO {
|
|||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
@ApiModelProperty("序号")
|
||||
private String orderNumber;
|
||||
|
||||
@ApiModelProperty("bom树的高度")
|
||||
private Integer levelNum;
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,37 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewOriginalParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.OriginalSaveBomDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomOriginalPlmParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomDetailTask;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.PlmBomToOriginalConvert;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.TreeNode;
|
||||
import com.nflg.product.bomnew.util.TreeUtils;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -29,15 +49,56 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
|
||||
@Resource
|
||||
BomNewOriginalChildService originalChildService;
|
||||
|
||||
@Resource
|
||||
@Qualifier(value = "getBomDetailPool")
|
||||
private ForkJoinPool bomDetailPool;
|
||||
/**
|
||||
* 获取原始BOM列表
|
||||
* @param query 查询条件
|
||||
* @return 原始BOM列表
|
||||
*/
|
||||
public List<BomOriginalListVO> getOriginalBomListPage(OriginalBomQuery query){
|
||||
return this.getBaseMapper().getOriginalBomListPage();
|
||||
public Page<BomOriginalListVO> getOriginalBomListPage(OriginalBomQuery query){
|
||||
return this.getBaseMapper().getOriginalBomListPage(new Page<>(query.getPage(),query.getPageSize()), query);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑时-暂存
|
||||
* @param bom
|
||||
* @return
|
||||
*/
|
||||
public Boolean saveBom(OriginalSaveBomDTO bom){
|
||||
List<BomNewOriginalChildEntity> childEntities= Convert.toList(BomNewOriginalChildEntity.class, bom.getBomList());
|
||||
// originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId()));
|
||||
childEntities.forEach(u->{
|
||||
u.setParentRowId(bom.getParentRowId());
|
||||
});
|
||||
if(CollUtil.isNotEmpty(childEntities)) {
|
||||
originalChildService.saveOrUpdateBatch(childEntities);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑时-提交
|
||||
* @param bom
|
||||
* @return
|
||||
*/
|
||||
public Boolean saveSubmit(OriginalSaveBomDTO bom){
|
||||
saveBom(bom);
|
||||
//将状态变为已处理
|
||||
BomNewOriginalParentEntity parentEntity =new BomNewOriginalParentEntity();
|
||||
parentEntity.setRowId(bom.getParentRowId());
|
||||
parentEntity.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
this.updateById(parentEntity);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取子级
|
||||
* @param rowId
|
||||
|
|
@ -46,13 +107,52 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
public List<BomOriginalListVO> getChild(Long rowId){
|
||||
List<BomOriginalListVO> parentChild = this.getBaseMapper().getParentChild(rowId);
|
||||
|
||||
for (BomOriginalListVO child : parentChild) {
|
||||
|
||||
List<String> drawingNos = parentChild.stream().map(u -> u.getDrawingNo()).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(drawingNos)) {
|
||||
List<BomNewOriginalParentEntity> list = this.lambdaQuery().in(BomNewOriginalParentEntity::getDrawingNo, drawingNos)
|
||||
.eq(BomNewOriginalParentEntity::getLastVersionIs, 1).list();
|
||||
Map<String, BomNewOriginalParentEntity> bomListMap = ListCommonUtil.listToMap(list, BomNewOriginalParentEntity::getDrawingNo);
|
||||
for (BomOriginalListVO child : parentChild) {
|
||||
if (bomListMap.containsKey(child.getDrawingNo())) {
|
||||
BomNewOriginalParentEntity parentEntity = bomListMap.get(child.getDrawingNo());
|
||||
child.setCurrentVersion(parentEntity.getCurrentVersion());
|
||||
child.setStatus(parentEntity.getStatus());
|
||||
child.setEditStatus(parentEntity.getEditStatus());
|
||||
child.setDeviseName(parentEntity.getDeviseName());
|
||||
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
|
||||
child.setCreatedBy(parentEntity.getCreatedBy());
|
||||
child.setCreatedTime(parentEntity.getCreatedTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
return parentChild;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<TreeNode<BomOriginalListVO>> getChildTree(Long rowId) throws ExecutionException, InterruptedException {
|
||||
|
||||
List<BomOriginalListVO> bomTree = getBomTree(rowId);
|
||||
return TreeUtils.toTree(rowId, bomTree, BomOriginalListVO::getParentRowId, BomOriginalListVO::getChildBomRowId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取整颗BOM树
|
||||
* @param rowId
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private List<BomOriginalListVO> getBomTree(Long rowId) throws ExecutionException, InterruptedException {
|
||||
List<BomOriginalListVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
||||
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
|
||||
ForkJoinTask<List<BomOriginalListVO>> submit = bomDetailPool.submit(detailTask);
|
||||
return submit.get();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 从plm 转原始BOM
|
||||
* @param
|
||||
|
|
@ -75,6 +175,30 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除BOM
|
||||
* @param parentRowId
|
||||
*/
|
||||
public Boolean del(Long parentRowId) throws ExecutionException, InterruptedException {
|
||||
|
||||
List<BomOriginalListVO> bomTree = getBomTree(parentRowId);
|
||||
List<Long> parentDel=new ArrayList<>();
|
||||
|
||||
List<Long> delParentRowId = bomTree.stream().filter(u -> u.getCreatedBy().equals(SessionUtil.getUserCode()) && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).map(u -> u.getParentRowId()).collect(Collectors.toList());
|
||||
|
||||
if(CollUtil.isNotEmpty(delParentRowId)){
|
||||
this.getBaseMapper().delBatch(delParentRowId);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalSourceEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
|
|
@ -117,6 +115,8 @@ public abstract class BaseConvert {
|
|||
* @param material
|
||||
*/
|
||||
protected BomNewOriginalParentEntity buildParentEntity(BomOriginalPlmBomVO material ,String preVersion) {
|
||||
|
||||
|
||||
BomNewOriginalParentEntity parentEntity = new BomNewOriginalParentEntity();
|
||||
parentEntity.setRowId(IdWorker.getId());
|
||||
parentEntity.setBatchNo(material.getBatchNo());
|
||||
|
|
@ -126,8 +126,8 @@ public abstract class BaseConvert {
|
|||
parentEntity.setMaterialDesc(material.getMaterialDesc());
|
||||
parentEntity.setCurrentVersion(VersionUtil.getNextVersion(preVersion));
|
||||
parentEntity.setNum(material.getQty());
|
||||
parentEntity.setBomExist(0);
|
||||
parentEntity.setShouldBomExist(1);
|
||||
parentEntity.setBomExist(childs.size()>0?1:0);
|
||||
parentEntity.setShouldBomExist(0);
|
||||
parentEntity.setLastVersionIs(1);
|
||||
parentEntity.setMaterialTexture(material.getMaterial());
|
||||
parentEntity.setUnitWeight(material.getWeight());
|
||||
|
|
@ -140,6 +140,12 @@ public abstract class BaseConvert {
|
|||
parentEntity.setSource(OriginalSourceEnum.PLM_PUSH.getValue());
|
||||
parentEntity.setCreatedBy(material.getCreatedBy());
|
||||
parentEntity.setCreatedTime(LocalDateTime.now());
|
||||
|
||||
if (StrUtil.isNotBlank(material.getMaterialCategoryCode()) &&(material.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE) || material.getMaterialCategoryCode().startsWith("30") ||
|
||||
( material.getMaterialCategoryCode().startsWith("20") && material.getMaterialGetType().equals(MaterialGetEnum.developing.getValue())))){
|
||||
parentEntity.setShouldBomExist(1);
|
||||
|
||||
}
|
||||
this.resultParent.add(parentEntity);
|
||||
return parentEntity;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
package com.nflg.product.bomnew.service.domain.OriginalBom;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.RecursiveTask;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 大米
|
||||
* @descreption
|
||||
* @date 2023/7/8 9:18
|
||||
*/
|
||||
public class OriginalBomDetailTask extends RecursiveTask<List<BomOriginalListVO>> {
|
||||
|
||||
private List<BomOriginalListVO> bomDetail;
|
||||
|
||||
|
||||
|
||||
|
||||
List<BomOriginalListVO> result = new ArrayList<>();
|
||||
|
||||
|
||||
public OriginalBomDetailTask(List<BomOriginalListVO> inBomDetail) {
|
||||
bomDetail = inBomDetail;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理BOM明细中未选择Bom版本的明细;使用最新版
|
||||
*/
|
||||
public void handlerChildBomVersionDetail() {
|
||||
List<String> drawingNos = bomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getDrawingNo()) ).map(BomOriginalListVO::getDrawingNo).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(drawingNos)) {
|
||||
|
||||
List<BomNewOriginalParentEntity> childBomlist = SpringUtil.getBean(BomNewOriginalParentService.class).lambdaQuery().in(BomNewOriginalParentEntity::getDrawingNo, drawingNos).eq(BomNewOriginalParentEntity::getLastVersionIs, 1).list();
|
||||
Map<String, BomNewOriginalParentEntity> stringBomNewOriginalParentEntityMap = ListCommonUtil.listToMap(childBomlist, BomNewOriginalParentEntity::getDrawingNo);
|
||||
for (BomOriginalListVO detailVO : bomDetail) {
|
||||
if (stringBomNewOriginalParentEntityMap.containsKey(detailVO.getDrawingNo())) {
|
||||
BomNewOriginalParentEntity bomNewOriginalParentEntity = stringBomNewOriginalParentEntityMap.get(detailVO.getDrawingNo());
|
||||
detailVO.setChildBomRowId(bomNewOriginalParentEntity.getRowId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归调用零部件BOM
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected List<BomOriginalListVO> compute() {
|
||||
|
||||
handlerChildBomVersionDetail();
|
||||
// 最新 BOM 版本
|
||||
|
||||
result.addAll(bomDetail);
|
||||
|
||||
if (CollUtil.isNotEmpty(bomDetail)) {
|
||||
List<Long> childBowIds = bomDetail.stream().filter(u-> u.getChildBomRowId()!=null && u.getChildBomRowId() > 0).map(u->u.getChildBomRowId()).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(childBowIds)) {
|
||||
List<BomOriginalListVO> bom = SpringUtil.getBean(BomNewOriginalParentService.class).getBaseMapper().getParentChildBatch(childBowIds);
|
||||
|
||||
OriginalBomDetailTask task = new OriginalBomDetailTask(bom);
|
||||
task.fork();
|
||||
bomDetail.addAll(task.join());
|
||||
return bomDetail;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||
import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.MaterialGetEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalConstant;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.MaterialMainMapper;
|
||||
|
|
@ -55,6 +56,9 @@ public class PlmBomToOriginalConvert extends BaseConvert {
|
|||
*/
|
||||
private void handlerBom() {
|
||||
|
||||
//检查BOM
|
||||
checkBom();
|
||||
|
||||
//有子级
|
||||
if(CollUtil.isNotEmpty(childs)) {
|
||||
//获取原始BOM
|
||||
|
|
@ -129,6 +133,7 @@ public class PlmBomToOriginalConvert extends BaseConvert {
|
|||
BomNewOriginalParentEntity originalBomForMaterial = getOriginalBomForMaterial(childVo.getChartNo());
|
||||
List<BomNewOriginalParentEntity> parentResultOne = this.resultParent.stream().filter(u -> u.getDrawingNo().equals(childVo.getChartNo())).collect(Collectors.toList());
|
||||
if (Objects.isNull(originalBomForMaterial) && CollUtil.isEmpty(parentResultOne) ) {
|
||||
childVo.setCreatedBy(parentEntity.getCreatedBy());
|
||||
BomNewOriginalParentEntity parentEntity1 = buildParentEntity(childVo, "");
|
||||
handlerCommonMaterial(parentEntity1);
|
||||
}
|
||||
|
|
@ -188,5 +193,20 @@ public class PlmBomToOriginalConvert extends BaseConvert {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 哪些物料不能有BOm 但确有了BOM
|
||||
*/
|
||||
private void checkBom(){
|
||||
//禁止创建BOM
|
||||
if(StrUtil.isNotBlank(parent.getMaterialCategoryCode()) && ( parent.getMaterialCategoryCode().startsWith("10") ||
|
||||
parent.getMaterialCategoryCode().startsWith("40") || parent.getMaterialCategoryCode().startsWith("50")||
|
||||
parent.getMaterialCategoryCode().startsWith("7001") || parent.getMaterialCategoryCode().startsWith("7002"))){
|
||||
|
||||
VUtils.isTure(true).throwMessage(parent.getChartNo()+"禁止创建BOM");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
|
||||
import com.github.xiaoymin.knife4j.core.util.StrUtil;
|
||||
import com.nflg.product.bomnew.constant.MaterialGetEnum;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 判断物料是否应该有BOM
|
||||
* @author 大米
|
||||
|
|
@ -9,4 +15,15 @@ package com.nflg.product.bomnew.util;
|
|||
public class MaterialshouldBomExistUtil {
|
||||
|
||||
|
||||
public static void initShouldBomExist(List<BaseMaterialVO> materialVOList){
|
||||
for (BaseMaterialVO material: materialVOList) {
|
||||
if(StrUtil.isNotBlank(material.getMaterialCategoryCode()) &&
|
||||
(material.getMaterialCategoryCode().startsWith("30") ||
|
||||
( material.getMaterialCategoryCode().startsWith("20") && material.getMaterialGetType().equals(MaterialGetEnum.developing.getValue())))){
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TreeNode<T> {
|
||||
|
||||
private T data;
|
||||
|
||||
private List<TreeNode<T>> childNodes = Collections.emptyList();
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 大米
|
||||
* @date 2023/11/18 16:19
|
||||
*/
|
||||
public class TreeUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 示例{@link com.linsy.product.kernel.flow.service.FlowCategoryService#queryCategoryTree(Integer, Integer)}
|
||||
*
|
||||
* @param dataList 数据
|
||||
* @param keyFun id
|
||||
* @param parentKeyFun 父级id
|
||||
* @param rootKey 顶层的 id 值 ,比如部门树的顶层id是0
|
||||
*/
|
||||
public static <T, K> List<TreeNode<T>> toTree(K rootKey,
|
||||
Collection<T> dataList,
|
||||
@NotNull Function<T, K> parentKeyFun,
|
||||
@NotNull Function<T, K> keyFun) {
|
||||
return toFilterTree(rootKey, dataList, parentKeyFun, keyFun, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 示例{@link com.linsy.product.kernel.flow.service.FlowCategoryService#queryCategoryTree(Integer, Integer)}
|
||||
*
|
||||
* @param rootKey 顶层的 id 值 ,比如部门树的顶层id是0
|
||||
* @param dataList 数据列
|
||||
* @param parentKeyFun 取父级id的方法引用
|
||||
* @param keyFun 取子级id的方法引用
|
||||
* @param filterNoDataFun 存在这种场景,选人的时候,某个子部门以及父部门下没有下挂任何人员,那么这两个部门直接隐藏,避免对用户造成干扰,
|
||||
* 这个参数表示部门实体类,人员字段的方法引用
|
||||
*/
|
||||
public static <T, K, D> List<TreeNode<T>> toFilterTree(K rootKey,
|
||||
Collection<T> dataList,
|
||||
@NotNull Function<T, K> parentKeyFun,
|
||||
@NotNull Function<T, K> keyFun,
|
||||
Function<T, D> filterNoDataFun) {
|
||||
if (CollUtil.isEmpty(dataList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 根据父节点,对列表进行分组
|
||||
Map<K, List<T>> groupParentKeyMap = dataList.stream().filter(t -> parentKeyFun.apply(t) != null).collect(Collectors.groupingBy(parentKeyFun));
|
||||
List<T> rootNodes;
|
||||
if (rootKey == null) {
|
||||
rootNodes = dataList.stream().filter(t -> parentKeyFun.apply(t) == null).collect(Collectors.toList());
|
||||
} else {
|
||||
rootNodes = groupParentKeyMap.getOrDefault(rootKey, Collections.emptyList());
|
||||
}
|
||||
|
||||
return handlerChildTree(rootNodes, groupParentKeyMap, keyFun, filterNoDataFun);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表转树
|
||||
*/
|
||||
private static <T, K, D> List<TreeNode<T>> handlerChildTree(Collection<T> rootNodes, Map<K, List<T>> groupParentKeyMap,
|
||||
Function<T, K> keyFun, Function<T, D> filterNoDataFun) {
|
||||
if (CollUtil.isEmpty(rootNodes)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TreeNode<T>> nodes = new ArrayList<>();
|
||||
for (T t : rootNodes) {
|
||||
List<T> childNodesData = groupParentKeyMap.getOrDefault(keyFun.apply(t), Collections.emptyList());
|
||||
TreeNode<T> node = new TreeNode<>();
|
||||
node.setData(t);
|
||||
List<TreeNode<T>> treeNodes = handlerChildTree(childNodesData, groupParentKeyMap, keyFun, filterNoDataFun);
|
||||
if (filterNoDataFun != null && CollUtil.isEmpty(treeNodes)) {
|
||||
if (skipNoDataNode(filterNoDataFun, t)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
nodes.add(node);
|
||||
node.setChildNodes(treeNodes);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为空数据,如果没有数据则隐藏
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static <T, D> boolean skipNoDataNode(Function<T, D> filterNoDataFun, T t) {
|
||||
D filterData = filterNoDataFun.apply(t);
|
||||
if (filterData == null) {
|
||||
return true;
|
||||
}
|
||||
if (filterData instanceof Collection) {
|
||||
Collection filterDataList = (Collection) filterData;
|
||||
return CollUtil.isEmpty(filterDataList);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 树转list
|
||||
*/
|
||||
public static <T> List<T> toList(List<TreeNode<T>> treeNodeList) {
|
||||
List<T> resultList = new ArrayList<>();
|
||||
for (TreeNode<T> treeNode : treeNodeList) {
|
||||
if (treeNode == null || treeNode.getData() == null) {
|
||||
continue;
|
||||
}
|
||||
resultList.add(treeNode.getData());
|
||||
if (CollUtil.isNotEmpty(treeNode.getChildNodes())) {
|
||||
resultList.addAll(toList(treeNode.getChildNodes()));
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ public class VersionUtil {
|
|||
|
||||
public static String getNextVersion(String preVersion) {
|
||||
if (StrUtil.isBlank(preVersion)) {
|
||||
return versionPrefix + "-1";
|
||||
return versionPrefix + "00";
|
||||
}
|
||||
|
||||
Integer versionNum = Convert.toInt(StrUtil.replace(preVersion, "A", "")) + 1;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<result column="unit_weight" property="unitWeight" jdbcType="DECIMAL"/>
|
||||
<result column="num" property="num" jdbcType="INTEGER"/>
|
||||
<result column="total_weight" property="totalWeight" jdbcType="DECIMAL"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
|
||||
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="expire_end_time" property="expireEndTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="level_num" property="levelNum" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
|
|
@ -41,13 +42,20 @@
|
|||
devise_user_code, devise_name, status, edit_status, convert_to_ebom_time, dept_row_id, dept_name, source,
|
||||
remark, created_by, created_time,expire_end_time
|
||||
</sql>
|
||||
|
||||
<sql id="whr">
|
||||
<if test="query.status!= null">
|
||||
<if test="query.status==2">
|
||||
and status=2 and a.created_time> DATE_ADD(now(), INTERVAL -3 DAY)
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!--获取原始bom列表-->
|
||||
<select id="getOriginalBomListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO">
|
||||
select *
|
||||
from t_bom_new_original_parent
|
||||
where (user_root_is | user_root_is) = 1
|
||||
where (root_is | user_root_is) = 1
|
||||
<include refid="whr"/>
|
||||
order by user_root_is desc
|
||||
</select>
|
||||
|
||||
|
|
@ -58,4 +66,27 @@
|
|||
where parent_row_id = #{rowId}
|
||||
order by order_number
|
||||
</select>
|
||||
|
||||
<select id="getParentChildBatch" resultType="com.nflg.product.bomnew.pojo.vo.BomOriginalListVO">
|
||||
select *
|
||||
from t_bom_new_original_child
|
||||
where parent_row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<delete id="delBatch">
|
||||
delete from t_bom_new_original_parent where row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>;
|
||||
delete from t_bom_new_original_child where parent_row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>;
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
|
||||
<select id="getMaterialBaseInfo" resultType="com.nflg.product.bomnew.pojo.vo.BaseMaterialVO">
|
||||
select material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no,material_category_code
|
||||
select material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no,material_category_code ,material_get_type
|
||||
from t_material_main
|
||||
where material_no in
|
||||
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
|
||||
|
|
|
|||
Loading…
Reference in New Issue