Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom
This commit is contained in:
commit
a33ff76c24
|
|
@ -64,7 +64,7 @@ public class EbomApi extends BaseApi {
|
||||||
|
|
||||||
@PostMapping("workDetailsListByPage")
|
@PostMapping("workDetailsListByPage")
|
||||||
@ApiOperation("Ebom-工作明细列表")
|
@ApiOperation("Ebom-工作明细列表")
|
||||||
public ResultVO<Page<TreeNode<BomNewEbomParentVO>>> workDetailsListByPage(@RequestBody BomNewEbomParentQuery query) {
|
public ResultVO<Page<BomNewEbomParentVO>> workDetailsListByPage(@RequestBody BomNewEbomParentQuery query) {
|
||||||
return ResultVO.success(bomNewEbomParentService.workDetailsListByPage(query));
|
return ResultVO.success(bomNewEbomParentService.workDetailsListByPage(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,6 +104,17 @@ public class EbomApi extends BaseApi {
|
||||||
return ResultVO.success(true);
|
return ResultVO.success(true);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("convertToPBom")
|
||||||
|
@ApiOperation("转PBom")
|
||||||
|
public ResultVO<Boolean> convertToPBom(@RequestBody VirtualPackageParamDto paramDto) {
|
||||||
|
VUtils.isTure(CollUtil.isEmpty(paramDto.getVirtualPackageValue())).throwMessage("请选择要生成的虚拟包");
|
||||||
|
bomNewEbomParentService.generateVirtualPackage(paramDto);
|
||||||
|
VUtils.isTure(true).throwMessage("请选择30开头的或200401类型的物料");
|
||||||
|
return ResultVO.success(true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("exportBom")
|
@PostMapping("exportBom")
|
||||||
|
|
|
||||||
|
|
@ -53,5 +53,5 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
|
||||||
|
|
||||||
List<BomNewEbomParentVO> getParentForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList);
|
List<BomNewEbomParentVO> getParentForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList);
|
||||||
|
|
||||||
List<BomNewEbomParentVO> getChildForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList);
|
List<BomNewEbomParentVO> getChildForMaterialNoSeach(@Param("materialNoList") List<String> materialNoList,@Param("materialNo") String materialNo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import lombok.experimental.Accessors;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_ebom_parent
|
* t_bom_new_ebom_parent
|
||||||
|
|
@ -271,5 +273,7 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
||||||
@ApiModelProperty(value = "修改时间")
|
@ApiModelProperty(value = "修改时间")
|
||||||
private LocalDateTime modifyTime;
|
private LocalDateTime modifyTime;
|
||||||
|
|
||||||
|
private List<BomNewEbomParentVO> childNodes = Collections.emptyList();
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
* @param query
|
* @param query
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Page<TreeNode<BomNewEbomParentVO>> workDetailsListByPage(BomNewEbomParentQuery query) {
|
public Page<BomNewEbomParentVO> workDetailsListByPage(BomNewEbomParentQuery query) {
|
||||||
|
|
||||||
Page<TreeNode<BomNewEbomParentVO>> returnResult = new Page<>();
|
Page<BomNewEbomParentVO>returnResult = new Page<>();
|
||||||
//物料编码搜索或图号搜索
|
//物料编码搜索或图号搜索
|
||||||
if(StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
if(StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||||
String materialNo=query.getMaterialNo();
|
String materialNo=query.getMaterialNo();
|
||||||
|
|
@ -95,24 +95,24 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician());
|
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo, !userRoleService.technician());
|
||||||
if(CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
if(CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
||||||
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
List<BomNewEbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(parentMaterialByMaterialNo);
|
||||||
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo);
|
List<BomNewEbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(parentMaterialByMaterialNo, materialNo);
|
||||||
|
|
||||||
returnResult = handSeachToTree(parents, childs);
|
returnResult = handSeachToTree(parents, childs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
Page<BomNewEbomParentVO> result = this.getBaseMapper().getEBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode());
|
Page<BomNewEbomParentVO> result = this.getBaseMapper().getEBomListPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode());
|
||||||
|
returnResult=result;
|
||||||
materialMainService.intiMaterialInfo(result.getRecords());
|
// materialMainService.intiMaterialInfo(result.getRecords());
|
||||||
Page<TreeNode<BomNewEbomParentVO>> resutlData = new Page<>();
|
// Page<TreeNode<BomNewEbomParentVO>> resutlData = new Page<>();
|
||||||
BeanUtil.copyProperties(result, resutlData);
|
// BeanUtil.copyProperties(result, resutlData);
|
||||||
resutlData.setRecords(handNodeToTree(result.getRecords()));
|
// //resutlData.setRecords(handNodeToTree(result.getRecords()));
|
||||||
returnResult= resutlData;
|
// returnResult= resutlData;
|
||||||
}
|
}
|
||||||
return returnResult;
|
return returnResult;
|
||||||
}
|
}
|
||||||
private Page<TreeNode<BomNewEbomParentVO>> handSeachToTree(List<BomNewEbomParentVO> parents, List<BomNewEbomParentVO> childs){
|
private Page<BomNewEbomParentVO> handSeachToTree(List<BomNewEbomParentVO> parents, List<BomNewEbomParentVO> childs){
|
||||||
Page<TreeNode<BomNewEbomParentVO>> resutlData = new Page<>();
|
Page<BomNewEbomParentVO> resutlData = new Page<>();
|
||||||
Set<String> parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
Set<String> parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||||
Set<String> childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
Set<String> childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
|
||||||
Set<String> difference = Sets.difference(parentSet, childSet);
|
Set<String> difference = Sets.difference(parentSet, childSet);
|
||||||
|
|
@ -124,23 +124,24 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
List<BomNewEbomParentVO> all=new ArrayList<>();
|
List<BomNewEbomParentVO> all=new ArrayList<>();
|
||||||
all.addAll(parents);
|
all.addAll(parents);
|
||||||
all.addAll(childs);
|
all.addAll(childs);
|
||||||
List<TreeNode<BomNewEbomParentVO>> result=new ArrayList<>();
|
List<BomNewEbomParentVO> result=new ArrayList<>();
|
||||||
for (BomNewEbomParentVO vo : resultParents) {
|
for (BomNewEbomParentVO vo : resultParents) {
|
||||||
result.addAll( TreeUtils.toTree(vo.getRowId(), all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
|
vo.setParentRowId(0L);
|
||||||
|
result.addAll( CTreeUtils.toTree(0L, all, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
|
||||||
}
|
}
|
||||||
resutlData.setRecords(result);
|
resutlData.setRecords(result);
|
||||||
return resutlData;
|
return resutlData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TreeNode<BomNewEbomParentVO>> handNodeToTree(List<BomNewEbomParentVO> list){
|
// private List<BomNewEbomParentVO> handNodeToTree(List<BomNewEbomParentVO> list){
|
||||||
List<TreeNode<BomNewEbomParentVO>> result=new ArrayList<>();
|
// List<TreeNode<BomNewEbomParentVO>> result=new ArrayList<>();
|
||||||
for (BomNewEbomParentVO vo : list) {
|
// for (BomNewEbomParentVO vo : list) {
|
||||||
TreeNode<BomNewEbomParentVO> treeData= new TreeNode<>();
|
// TreeNode<BomNewEbomParentVO> treeData= new TreeNode<>();
|
||||||
treeData.setData(vo);
|
// treeData.setData(vo);
|
||||||
result.add(treeData);
|
// result.add(treeData);
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.product.bomnew.util;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
|
public class CTreeNode<T> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private List<T> childNodes = Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
package com.nflg.product.bomnew.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||||
|
|
||||||
|
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 CTreeUtils {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param dataList 数据
|
||||||
|
* @param keyFun id
|
||||||
|
* @param parentKeyFun 父级id
|
||||||
|
* @param rootKey 顶层的 id 值 ,比如部门树的顶层id是0
|
||||||
|
*/
|
||||||
|
public static <T, K> List<BomNewEbomParentVO> toTree(K rootKey,
|
||||||
|
Collection<T> dataList,
|
||||||
|
@NotNull Function<T, K> parentKeyFun,
|
||||||
|
@NotNull Function<T, K> keyFun) {
|
||||||
|
return toFilterTree(rootKey, dataList, parentKeyFun, keyFun, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param rootKey 顶层的 id 值 ,比如部门树的顶层id是0
|
||||||
|
* @param dataList 数据列
|
||||||
|
* @param parentKeyFun 取父级id的方法引用
|
||||||
|
* @param keyFun 取子级id的方法引用
|
||||||
|
* @param filterNoDataFun 存在这种场景,选人的时候,某个子部门以及父部门下没有下挂任何人员,那么这两个部门直接隐藏,避免对用户造成干扰,
|
||||||
|
* 这个参数表示部门实体类,人员字段的方法引用
|
||||||
|
*/
|
||||||
|
public static <T, K, D> List<BomNewEbomParentVO> 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<BomNewEbomParentVO> 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<BomNewEbomParentVO> nodes = new ArrayList<>();
|
||||||
|
for (T t : rootNodes) {
|
||||||
|
List<T> childNodesData = groupParentKeyMap.getOrDefault(keyFun.apply(t), Collections.emptyList());
|
||||||
|
BomNewEbomParentVO node =new BomNewEbomParentVO();
|
||||||
|
BeanUtil.copyProperties(t,node);
|
||||||
|
|
||||||
|
List<BomNewEbomParentVO> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -105,15 +105,16 @@
|
||||||
</select>
|
</select>
|
||||||
<!--物料编码搜索-子级-->
|
<!--物料编码搜索-子级-->
|
||||||
<select id="getChildForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
|
<select id="getChildForMaterialNoSeach" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
|
||||||
select if(c.status=4,99,c.status) as status ,c.current_version c.created_by as bomCreatedBy ,c.devise_name,c.devise_user_code,c.dept_name ,
|
select if(c.status=4,99,c.status) as status ,c.current_version , c.created_by as bomCreatedBy
|
||||||
c.source, c.row_id as bomRowId, c.row_id as childBomRowId, b.*
|
,c.devise_name,c.devise_user_code,c.dept_name ,
|
||||||
from t_bom_new_ebom_parent a
|
c.source, c.row_id as bomRowId, c.row_id as childBomRowId, b.*
|
||||||
join t_bom_new_ebom_child b on a.row_id =b.parent_row_id
|
from t_bom_new_ebom_parent a
|
||||||
left join t_bom_new_ebom_parent c on b.material_no=c.material_no and c.last_version_is=1
|
join t_bom_new_ebom_child b on a.row_id =b.parent_row_id
|
||||||
where a.last_version_is=1 and a.material_no in
|
left join t_bom_new_ebom_parent c on b.material_no=c.material_no and c.last_version_is=1
|
||||||
|
where a.last_version_is=1 and ( b.material_no in
|
||||||
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
|
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach> or b.material_no=#{materialNo})
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--BOM-正式工作表-->
|
<!--BOM-正式工作表-->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue