mbom 工作列表 明细
This commit is contained in:
parent
f2ed0fb5ca
commit
6ddbda06fc
|
|
@ -2,13 +2,16 @@ package com.nflg.product.bomnew.api.user;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.product.base.core.api.BaseApi;
|
import com.nflg.product.base.core.api.BaseApi;
|
||||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.bomnew.constant.FactoryCodeEnum;
|
import com.nflg.product.bomnew.constant.FactoryCodeEnum;
|
||||||
import com.nflg.product.bomnew.constant.MBomConstantEnum;
|
import com.nflg.product.bomnew.constant.MBomConstantEnum;
|
||||||
import com.nflg.product.bomnew.constant.ValueEnum;
|
import com.nflg.product.bomnew.constant.ValueEnum;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO;
|
||||||
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
|
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewMbomDetailVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewMbomDetailVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewMbomParentVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewMbomParentVO;
|
||||||
import com.nflg.product.bomnew.service.BomNewMbomDetailService;
|
import com.nflg.product.bomnew.service.BomNewMbomDetailService;
|
||||||
import com.nflg.product.bomnew.service.BomNewMbomParentService;
|
import com.nflg.product.bomnew.service.BomNewMbomParentService;
|
||||||
|
|
@ -52,12 +55,32 @@ public class MBomApi extends BaseApi {
|
||||||
* @param query Query 查询实体
|
* @param query Query 查询实体
|
||||||
* @return 所有数据
|
* @return 所有数据
|
||||||
*/
|
*/
|
||||||
@PostMapping("selectBomNewMbomParentEntityPageByCondition")
|
@PostMapping("workListPage")
|
||||||
@ApiOperation("auto-按字段条件分页查询")
|
@ApiOperation("工作明细表")
|
||||||
public ResultVO<IPage<BomNewMbomParentVO>> selectBomNewMbomParentEntityPageByCondition(@RequestBody BomNewMbomParentQuery query) {
|
public ResultVO<Page<BomNewMbomMiddleVO>> workListPage(@RequestBody BomNewMbomParentQuery query) {
|
||||||
return ResultVO.success();
|
return ResultVO.success(bomNewMbomParentService.workListPage(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("sapFormalListPage")
|
||||||
|
@ApiOperation("Sap明细表")
|
||||||
|
public ResultVO<Page<BomNewMbomMiddleVO>> sapFormalListPage(@RequestBody BomNewMbomParentQuery query) {
|
||||||
|
return ResultVO.success(bomNewMbomParentService.formalListPage(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("getChild")
|
||||||
|
@ApiOperation("获取下级")
|
||||||
|
public ResultVO<List<BomNewMbomMiddleVO>> getChild(@RequestBody BomNewMBomChildDTO dto) {
|
||||||
|
if(Objects.isNull(dto.getBomRowId())){
|
||||||
|
throw new NflgBusinessException(STATE.ParamErr,"bomRowId 不能为空");
|
||||||
|
}
|
||||||
|
if(Objects.isNull(dto.getRowId())){
|
||||||
|
throw new NflgBusinessException(STATE.ParamErr,"rowId 不能为空");
|
||||||
|
}
|
||||||
|
return ResultVO.success(bomNewMbomParentService.getChild(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("factoryList")
|
@GetMapping("factoryList")
|
||||||
@ApiOperation("工厂列表")
|
@ApiOperation("工厂列表")
|
||||||
|
|
@ -81,6 +104,14 @@ public class MBomApi extends BaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("superSaterialStatus")
|
@PostMapping("superSaterialStatus")
|
||||||
@ApiOperation("设置超级物料")
|
@ApiOperation("设置超级物料")
|
||||||
public ResultVO<Boolean> superSaterialStatus(@ApiParam("超级物料 0-否 1-是") @RequestParam(value = "status") Integer status, @RequestParam(value = "rowId") Long rowId ) {
|
public ResultVO<Boolean> superSaterialStatus(@ApiParam("超级物料 0-否 1-是") @RequestParam(value = "status") Integer status, @RequestParam(value = "rowId") Long rowId ) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,15 @@ public interface BomNewMbomParentMapper extends BaseMapper<BomNewMbomParentEntit
|
||||||
*/
|
*/
|
||||||
List<BomNewMbomMiddleVO> searchList(@Param("rowId") Long rowId );
|
List<BomNewMbomMiddleVO> searchList(@Param("rowId") Long rowId );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下级
|
||||||
|
* @param rowId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BomNewMbomMiddleVO> getParentChild(@Param("rowId") Long rowId );
|
||||||
|
|
||||||
|
BomNewMbomMiddleVO getParentById(@Param("rowId") Long rowId );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="com-nflg-product-bomnew-pojo-new-dto-BomNewMBomChildDTO")
|
||||||
|
public class BomNewMBomChildDTO {
|
||||||
|
/**
|
||||||
|
* 主键行ID-雪花
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "主键行ID")
|
||||||
|
private Long rowId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "bomRowId")
|
||||||
|
private Long bomRowId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -215,9 +215,6 @@ public class BomNewMbomMiddleVO extends BaseMaterialVO implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private List<BomNewMbomMiddleVO> childNodes = Collections.emptyList();
|
private List<BomNewMbomMiddleVO> childNodes = Collections.emptyList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,25 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nflg.product.bomnew.constant.MBomConstantEnum;
|
||||||
import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper;
|
import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
|
||||||
|
import com.nflg.product.bomnew.service.domain.MBom.IndexListTree;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_mbom_parent 表服务实现类
|
* t_bom_new_mbom_parent 表服务实现类
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* @author makejava
|
* @author makejava
|
||||||
* @since 2024-01-01 10:53:24
|
* @since 2024-01-01 10:53:24
|
||||||
|
|
@ -16,4 +27,79 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper, BomNewMbomParentEntity> {
|
public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper, BomNewMbomParentEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作明细
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Page<BomNewMbomMiddleVO> workListPage(BomNewMbomParentQuery query) {
|
||||||
|
|
||||||
|
query.setStatus(MBomConstantEnum.MBomStatusEnum.UNPUB_SAP.getValue());
|
||||||
|
|
||||||
|
return listPage(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Page<BomNewMbomMiddleVO> listPage(BomNewMbomParentQuery query) {
|
||||||
|
Page<BomNewMbomMiddleVO> page = null;
|
||||||
|
if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||||
|
page = this.getBaseMapper().indexListPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||||
|
if (CollectionUtil.isNotEmpty(page.getRecords())) {
|
||||||
|
List<BomNewMbomMiddleVO> indexList = page.getRecords().stream().collect(Collectors.toList());
|
||||||
|
;
|
||||||
|
page.getRecords().clear();
|
||||||
|
for (BomNewMbomMiddleVO item :
|
||||||
|
indexList) {
|
||||||
|
BomNewMbomMiddleVO parent = this.getBaseMapper().getParentById(item.getBomRowId());
|
||||||
|
parent.setParentRowId(0l);
|
||||||
|
parent.setBomRowId(parent.getRowId());
|
||||||
|
|
||||||
|
List<BomNewMbomMiddleVO> childList = this.getBaseMapper().searchList(item.getRowId());
|
||||||
|
IndexListTree.listToTree(parent, childList);
|
||||||
|
page.getRecords().add(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//不是通过物料或图号搜索
|
||||||
|
page = this.getBaseMapper().getMBomListPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Page<BomNewMbomMiddleVO> formalListPage(BomNewMbomParentQuery query) {
|
||||||
|
query.setStatus(MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue());
|
||||||
|
return listPage(query);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<BomNewMbomMiddleVO> getChild(BomNewMBomChildDTO dto) {
|
||||||
|
BomNewMbomMiddleVO parent = this.getBaseMapper().getParentById(dto.getBomRowId() );
|
||||||
|
if (parent != null) {
|
||||||
|
parent.setParentRowId(0l);
|
||||||
|
parent.setBomRowId(parent.getRowId());
|
||||||
|
|
||||||
|
}
|
||||||
|
Long _rowId = dto.getRowId();
|
||||||
|
if (Objects.equals(dto.getRowId(), dto.getBomRowId())) {
|
||||||
|
_rowId = 0l;
|
||||||
|
}
|
||||||
|
List<BomNewMbomMiddleVO> listChild = this.getBaseMapper().getParentChild(_rowId);
|
||||||
|
if (CollectionUtil.isNotEmpty(listChild)) {
|
||||||
|
listChild.forEach(child -> {
|
||||||
|
IndexListTree.sysnParentParam(parent, child);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return listChild;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.nflg.product.bomnew.service.domain.MBom;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class IndexListTree {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream分组
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static List<BomNewMbomMiddleVO> listToTree(BomNewMbomMiddleVO parent,List<BomNewMbomMiddleVO> childs) {
|
||||||
|
|
||||||
|
if(CollectionUtil.isEmpty(childs)){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, List<BomNewMbomMiddleVO>> groupMap = childs.stream().collect(Collectors.groupingBy(BomNewMbomMiddleVO::getParentRowId));
|
||||||
|
childs.forEach(child -> {
|
||||||
|
|
||||||
|
child.setChildNodes(groupMap.get(child.getRowId()));
|
||||||
|
|
||||||
|
sysnParentParam(parent,child);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//筛选出根
|
||||||
|
List<BomNewMbomMiddleVO> collect = childs.stream().filter(item -> Objects.isNull(item.getParentRowId()) || item.getParentRowId().equals(0L)).collect(Collectors.toList());
|
||||||
|
parent.setChildNodes(collect);
|
||||||
|
return collect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sysnParentParam(BomNewMbomMiddleVO parent,BomNewMbomMiddleVO child){
|
||||||
|
child.setOrderNo(parent.getOrderNo());
|
||||||
|
child.setStatus(parent.getStatus());
|
||||||
|
child.setSysnSapTime(parent.getSysnSapTime());
|
||||||
|
child.setSysnSapUserName(parent.getSysnSapUserName()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -94,27 +94,47 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="getMBomSapListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
<!-- <select id="getMBomSapListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">-->
|
||||||
select * from t_bom_new_mbom_parent
|
<!-- select t1.*,(SELECT count(1) from t_bom_new_mbom_detail where bom_row_id=t1.row_id) as bomExist from t_bom_new_mbom_parent as t1-->
|
||||||
where `status`=#{query.status}
|
<!-- where `status`=#{query.status}-->
|
||||||
<include refid="whrMore"/>
|
<!-- <include refid="whrMore"/>-->
|
||||||
|
|
||||||
<if test="query.startDate!=null and query.startDate!='' and query.endDate!=null and query.endDate!=''">
|
<!-- <if test="query.startDate!=null and query.startDate!='' and query.endDate!=null and query.endDate!=''">-->
|
||||||
<![CDATA[ and sysn_sap_time >= #{query.startDate} and sysn_sap_time <=#{query.endDate}]]>
|
<!-- <![CDATA[ and sysn_sap_time >= #{query.startDate} and sysn_sap_time <=#{query.endDate}]]>-->
|
||||||
</if>
|
<!-- </if>-->
|
||||||
|
<!-- </select>-->
|
||||||
|
|
||||||
|
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
||||||
|
select t1.*,(SELECT count(1) from t_bom_new_mbom_detail where parent_row_id=t1.row_id) as bom_exist
|
||||||
|
from t_bom_new_mbom_detail as t1
|
||||||
|
where t1.parent_row_id = #{rowId}
|
||||||
|
order by t1.order_number
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getParentById" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
||||||
|
select t1.*,(SELECT count(1) from t_bom_new_mbom_detail where parent_row_id=t1.row_id) as bom_exist
|
||||||
|
from t_bom_new_mbom_parent as t1
|
||||||
|
where t1.row_id = #{rowId}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="indexListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
<select id="indexListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
||||||
SELECT max(row_id) row_id ,bom_row_id from t_bom_new_mbom_detail GROUP BY bom_row_id
|
SELECT max(row_id) row_id ,bom_row_id from t_bom_new_mbom_detail GROUP BY bom_row_id
|
||||||
where `status`=#{status}
|
where `status`=#{query.status}
|
||||||
<include refid="whr"/>
|
<if test="query.drawingNo!=null and query.drawingNo!=''">
|
||||||
|
and drawing_no=#{query.drawingNo}
|
||||||
|
</if>
|
||||||
|
<if test="query.materialNo!=null and query.materialNo!=''">
|
||||||
|
and material_no=#{query.materialNo}
|
||||||
|
</if>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="searchList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
<select id="searchList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SELECT t2.*,(SELECT count(1) from t_bom_new_mbom_detail where parent_id=t2.row_id) as bomExist
|
SELECT t2.*,(SELECT count(1) from t_bom_new_mbom_detail where parent_id=t2.row_id) as bom_exist
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue