Browse Source

[update]:BOM列表页一阶、多阶展示

dev
youjianchi 7 months ago
parent
commit
a71a3c0b71
  1. 19
      ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpBomController.java
  2. 3
      ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpBomMapper.java
  3. 2
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpBomService.java
  4. 39
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java
  5. 6
      ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml
  6. 158
      ruoyi-admin/src/main/resources/templates/erp/bom/bom.html

19
ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpBomController.java

@ -54,18 +54,29 @@ public class ErpBomController extends BaseController
}
/**
* 查询bom列表
* 查询bom一阶列表
*/
@RequiresPermissions("erp:bom:list")
@PostMapping("/subList")
@PostMapping("/oneLevelList")
@ResponseBody
public TableDataInfo subList(ErpBom erpBom)
public TableDataInfo oneLevelList(ErpBom erpBom)
{
startPage();
List<ErpBom> list = erpBomService.selectErpBomSubList(erpBom);
return getDataTable(list);
}
/**
* 查询bom所有阶列表
*/
@PostMapping("/allLevelList")
@ResponseBody
public TableDataInfo allLevelList(ErpBom erpBom)
{
startPage();
List<ErpBom> list = erpBomService.selectErpBomAllLevelList(erpBom);
return getDataTable(list);
}
/**
* 导出bom列表
*/

3
ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpBomMapper.java

@ -20,6 +20,9 @@ public interface ErpBomMapper
*/
public ErpBom selectErpBomById(Long id);
public ErpBom selectErpBomByOneMaterialNo(String materialNo);
/**
* 查询bom列表
*

2
ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpBomService.java

@ -30,6 +30,8 @@ public interface IErpBomService
List<ErpBom> selectErpBomSubList(ErpBom erpBom);
List<ErpBom> selectErpBomAllLevelList(ErpBom erpBom);
/**
* 新增bom
*

39
ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpBomServiceImpl.java

@ -15,7 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Collectors;
/**
* bomService业务层处理
@ -64,6 +67,42 @@ public class ErpBomServiceImpl implements IErpBomService
return erpBomMapper.selectErpBomSubList(erpBom);
}
@Override
public List<ErpBom> selectErpBomAllLevelList(ErpBom erpBom) {
List<ErpBom> resultList = new ArrayList<>();
// 一阶集合
List<ErpBom> oneLevelList = erpBomMapper.selectErpBomSubList(erpBom);
if(CollectionUtils.isNotEmpty(oneLevelList)){
for (ErpBom bom: oneLevelList) {
resultList.add(bom);
String materialNo = bom.getMaterialNo();
Long level = bom.getLevel();
recursionSubBom(resultList, materialNo, level);
}
}
return resultList;
}
private void recursionSubBom(List<ErpBom> resultList, String materialNo, Long level) {
ErpBom subBom = erpBomMapper.selectErpBomByOneMaterialNo(materialNo);
if(subBom!=null){
Long subId = subBom.getId();
ErpBom erpBom1 = new ErpBom();
erpBom1.setParentId(subId);
List<ErpBom> subLevelList = erpBomMapper.selectErpBomSubList(erpBom1);
if(CollectionUtils.isNotEmpty(subLevelList)){
for (ErpBom sub: subLevelList) {
Long level1 = level+1;
sub.setLevel(level1);
resultList.add(sub);
String materialNo1 = sub.getMaterialNo();
recursionSubBom(resultList,materialNo1,level1);
}
}
}
}
/**
* 新增bom
*

6
ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml

@ -270,4 +270,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from erp_bom where bom_no = #{bomNo}
</select>
<select id="selectErpBomByOneMaterialNo" parameterType="String" resultMap="ErpBomResult">
<include refid="selectErpBomVo"/>
where parent_id = 0
and material_no = #{materialNo}
</select>
</mapper>

158
ruoyi-admin/src/main/resources/templates/erp/bom/bom.html

@ -127,7 +127,13 @@
detailView: true,
//指定父id列
onExpandRow : function(index, row, $detail) {
initChildTable(index, row, $detail);
$detail.html('<h4>一阶</h4><table class="table-container" id="one_level_table_'+row.id+'"></table>' +
'<h4>多阶</h4><table class="table-container" id="all_level_table_'+row.id+'"></table>'
).find('table');
// 一阶
initOneLevelTable(index,row,$detail);
// 多阶
initAllLevelTable(index,row,$detail);
},
columns: [{
checkbox: true
@ -296,18 +302,156 @@
$.table.init(options);
});
initChildTable = function(index, row, $detail) {
var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
$(childTable).bootstrapTable({
url: prefix + "/subList",
initOneLevelTable = function(index, row, $detail) {
$("#"+"one_level_table_"+row.id).bootstrapTable({
url: prefix + "/oneLevelList",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
parentId: row.id
},
onExpandRow : function(index, row, $detail) {
initChildSonTable(index, row, $detail);
columns: [{
field: 'id',
title: '主键id'
},
{
field: 'level',
title: '层级',
formatter: function(value, row, index) {
return $.table.selectDictLabel(levelDatas, value);
}
},
{
field: 'bomNo',
title: 'bom号',
formatter:function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'photoUrl',
title: '图片',
formatter: function(value, row, index) {
return $.table.imageView(value);
}
},
{
field: 'materialNo',
title: '料号',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'materialName',
title: '物料名称',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'materialType',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
field: 'describe',
title: '描述',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'brand',
title: '品牌',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'unit',
title: '单位',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'useNum',
title: '用量',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'lossRate',
title: '损耗率',
formatter: function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
return value
}
}
},
{
field: 'processMethod',
title: '加工方式',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
field: 'parentId',
title: '父级id',
visible: false,
},
{
field: 'sortNo',
title: '排序',
visible: false
}]
});
};
initAllLevelTable = function(index, row, $detail) {
$("#"+"all_level_table_"+row.id).bootstrapTable({
url: prefix + "/allLevelList",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
parentId: row.id
},
columns: [{
field: 'id',

Loading…
Cancel
Save