Merge remote-tracking branch 'origin/feature/DM/rakor'

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java
This commit is contained in:
10001392 2024-10-17 17:45:47 +08:00
commit 9af6e14072
10 changed files with 214 additions and 20 deletions

View File

@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets;
import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi;
@ -18,7 +19,9 @@ import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewTechnologyPackageTypeEntity;
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.query.PBomExceptionQuery;
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.*;
@ -29,17 +32,16 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.compress.utils.Lists;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
@ -437,6 +439,28 @@ public class PBomApi extends BaseApi {
return ResultVO.success(bomNewPbomParentService.checkBomExist(bomRowId,type));
}
/**
* 获取节点异常状态
* @param query query
* @return 节点异常状态
*/
@PostMapping("getBomException")
@ApiOperation("获取节点异常状态")
public ResultVO<List<BomExceptionVO>> getBomException(@Valid @RequestBody @NotEmpty List<BomExceptionQuery> query) {
return ResultVO.success(bomNewPbomParentService.getBomException(query));
}
/**
* 获取单个节点异常状态
* @param query query
* @return 节点异常状态
*/
@PostMapping("getSingleBomException")
@ApiOperation("获取单个节点异常状态")
public ResultVO<BomExceptionVO> getSingleBomException(@Valid @RequestBody @NotEmpty PBomExceptionQuery query) {
return ResultVO.success(bomNewPbomParentService.getSingleBomException(query));
}
@PostMapping("checkBomExport")
@ApiOperation("BOM完整性检查结果导出")
public void checkBomExport(@Valid @RequestBody @NotNull List<CheckBomVO> messages
@ -458,6 +482,4 @@ public class PBomApi extends BaseApi {
};
return ResultVO.success(true);
}
}

View File

@ -0,0 +1,38 @@
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 java.io.Serializable;
/**
* @author 曹鹏飞
* @date 2024/9/25 17:38:14
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-query-PBomExceptionQuery")
public class PBomExceptionQuery implements Serializable {
/**
* materialNo 物料编号
*/
@ApiModelProperty(value = "物料编号")
protected String materialNo;
/**
* drawingNo 图号
*/
@ApiModelProperty(value = "图号")
protected String drawingNo;
/**
* facCode 工厂编号
*/
@ApiModelProperty(value = "工厂编号")
@NotEmpty(message = "工厂编号不能为空")
protected String facCode;
}

View File

@ -42,9 +42,15 @@ public class ReverseReportVO {
@ApiModelProperty(value = "数量")
private BigDecimal num;
@ApiModelProperty(value = "子级数量")
private BigDecimal childNum;
@ApiModelProperty("单位")
private String materialUnit;
@ApiModelProperty("子级单位")
private String childMaterialUnit;
@ApiModelProperty(value = "创建人编码")
private String createdBy;

View File

@ -8,6 +8,10 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import cn.hutool.core.util.*;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -26,9 +30,7 @@ import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query;
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
import com.nflg.product.bomnew.pojo.query.*;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.EBom.CheckPBomException;
import com.nflg.product.bomnew.service.domain.PBom.*;
@ -46,6 +48,8 @@ import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@ -2191,4 +2195,83 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
public List<BomExceptionVO> getBomException(@Valid @NotEmpty List<BomExceptionQuery> query) {
List<BomExceptionVO> datas = new ArrayList<>();
List<BaseMaterialVO> materialVOS = materialMainService.getMaterialBaseInfo(query.stream().map(BomExceptionQuery::getMaterialNo).collect(Collectors.toList()));
for (BomExceptionQuery bom : query) {
BomExceptionVO vo = new BomExceptionVO();
vo.setBomRowId(bom.getBomRowId());
vo.setRowId(bom.getRowId());
vo.setMaterialNo(bom.getMaterialNo());
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
BaseMaterialVO mv = materialVOS.stream().filter(f -> StrUtil.equals(f.getMaterialNo(), bom.getMaterialNo())).findFirst().orElse(null);
if (Objects.isNull(mv)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
} else if (!Objects.equals(mv.getMaterialState(), MateiralStateEnum.ACTIVE.getValue())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
List<String> materialNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, bom.getBomRowId())
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BaseMaterialVO> vos = materialMainService.initMaterialForAnyNo(materialNos);
if (CollUtil.isNotEmpty(vos)) {
if (vos.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
}
}
}
datas.add(vo);
}
Collections.reverse(datas);
return datas;
}
public BomExceptionVO getSingleBomException(@Valid @NotEmpty PBomExceptionQuery query) {
List<String> materialNosOrDrawingNos = Collections.singletonList(StrUtil.isNotBlank(query.getMaterialNo()) ? query.getMaterialNo() : query.getDrawingNo());
List<BaseMaterialVO> materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
BomExceptionVO vo = new BomExceptionVO();
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
BaseMaterialVO mVO = materialVOS.stream().findFirst().orElse(null);
if (Objects.nonNull(mVO)) {
vo.setMaterialNo(mVO.getMaterialNo());
if (!Objects.equals(mVO.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
BomNewPbomParentEntity p = this.lambdaQuery()
.select(BomNewPbomParentEntity::getRowId)
.eq(StrUtil.isNotBlank(query.getMaterialNo()), BomNewPbomParentEntity::getMaterialNo, query.getMaterialNo())
.eq(StrUtil.isNotBlank(query.getDrawingNo()), BomNewPbomParentEntity::getDrawingNo, query.getDrawingNo())
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode, query.getFacCode())
.list()
.stream()
.findFirst()
.orElse(null);
if (Objects.nonNull(p)) {
materialNosOrDrawingNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, p.getRowId())
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNosOrDrawingNos)) {
materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
if (CollUtil.isNotEmpty(materialVOS)) {
if (materialVOS.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
}
}
}
}
}
return vo;
}
}

View File

@ -16,7 +16,6 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ResultDTO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.VUtils;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
@ -142,7 +141,10 @@ public class SapOpUtilService {
public List<OperationErrorMsgVO> importToSapV2(ImportSapParamDTO impartSapParamDTO, List<T1DTO> backList) {
VUtils.isTure(CollUtil.isEmpty(impartSapParamDTO.getT1())).throwMessage("没有需要同步的数据");
if (CollUtil.isEmpty(impartSapParamDTO.getT1())) {
log.info("没有需要同步的数据");
return Collections.emptyList();
}
SapReqParams params = new SapReqParams();
// 接口名
params.setFunName("ZRFC_PP_005");

View File

@ -164,7 +164,17 @@ public class EBomQueryService {
&& Objects.equals(v.getNum(), it.getNum())
&& StrUtil.equals(v.getMaterialUnit(), it.getMaterialUnit())
&& StrUtil.equals(v.getCreatedBy(), it.getCreatedBy()))) {
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1)));
ReverseReportVO levelVO = null;
if (level > 1) {
for (int i = vos.size() - 1; i >= 0; i--) {
ReverseReportVO vo = vos.get(i);
if (Objects.equals(level - 1, vo.getLevelNum())) {
levelVO = vo;
break;
}
}
}
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1), pVO, levelVO));
}
bindData(it, level + 1, vos);
}
@ -175,7 +185,7 @@ public class EBomQueryService {
return ebomParentService.getReverseBoms(parentRowId);
}
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO) {
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO, BomNewPbomParentVO pVO, ReverseReportVO levelVO) {
ReverseReportVO vo = Convert.convert(ReverseReportVO.class, parentVO);
vo.setLevelNum(level);
if (Objects.isNull(lastVO)) {
@ -183,6 +193,13 @@ public class EBomQueryService {
} else {
vo.setBomVersion(level >= lastVO.getLevelNum() ? lastVO.getBomVersion() : String.valueOf(Integer.parseInt(lastVO.getBomVersion()) + 1));
}
if (Objects.nonNull(levelVO)) {
vo.setChildNum(levelVO.getNum());
vo.setChildMaterialUnit(levelVO.getMaterialUnit());
} else {
vo.setChildNum(pVO.getNum());
vo.setChildMaterialUnit(pVO.getMaterialUnit());
}
return vo;
}
}

View File

@ -158,7 +158,17 @@ public class PBomQueryService {
&& Objects.equals(v.getNum(), it.getNum())
&& StrUtil.equals(v.getMaterialUnit(), it.getMaterialUnit())
&& StrUtil.equals(v.getCreatedBy(), it.getCreatedBy()))) {
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1)));
ReverseReportVO levelVO = null;
if (level > 1) {
for (int i = vos.size() - 1; i >= 0; i--) {
ReverseReportVO vo = vos.get(i);
if (Objects.equals(level - 1, vo.getLevelNum())) {
levelVO = vo;
break;
}
}
}
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1), pVO, levelVO));
}
bindData(it, level + 1, vos);
}
@ -169,7 +179,7 @@ public class PBomQueryService {
return pbomParentService.getReverseBoms(parentRowId);
}
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO) {
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO, BomNewPbomParentVO pVO, ReverseReportVO levelVO) {
ReverseReportVO vo = Convert.convert(ReverseReportVO.class, parentVO);
vo.setLevelNum(level);
if (Objects.isNull(lastVO)) {
@ -177,6 +187,13 @@ public class PBomQueryService {
} else {
vo.setBomVersion(level >= lastVO.getLevelNum() ? lastVO.getBomVersion() : String.valueOf(Integer.parseInt(lastVO.getBomVersion()) + 1));
}
if (Objects.nonNull(levelVO)) {
vo.setChildNum(levelVO.getNum());
vo.setChildMaterialUnit(levelVO.getMaterialUnit());
} else {
vo.setChildNum(pVO.getNum());
vo.setChildMaterialUnit(pVO.getMaterialUnit());
}
return vo;
}
}

View File

@ -412,9 +412,9 @@
<!--ebom单层反查-->
<select id="eBomReverseReport" resultType="com.nflg.product.bomnew.pojo.vo.ReverseReportVO">
select b.* , a.drawing_no as childDrawingNo from t_bom_new_ebom_child_formal a
select b.* , a.drawing_no as childDrawingNo,a.num AS childNum,a.material_unit AS childMaterialUnit
from t_bom_new_ebom_child_formal a
join t_bom_new_ebom_parent_formal b on a.parent_row_id=b.row_id
where true
<if test="bomVersionRowId!=null and bomVersionRowId>0">
and a.bom_version_row_id=#{bomVersionRowId}
@ -427,7 +427,8 @@
<!--ebom单层反查-->
<select id="eBomReverseReportNewst" resultType="com.nflg.product.bomnew.pojo.vo.ReverseReportVO">
select b.* , a.drawing_no as childDrawingNo from t_bom_new_ebom_child a
select b.*, a.drawing_no as childDrawingNo, a.num AS childNum, a.material_unit AS childMaterialUnit
from t_bom_new_ebom_child a
join t_bom_new_ebom_parent b on a.parent_row_id=b.row_id
where a.material_no =#{materialNo} and b.status=4
</select>
@ -621,7 +622,11 @@
</foreach>;
</select>
<select id="getReverseBoms" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT IFNULL(c.num, p.num) AS num, c.project_type projectType, c.project_type, p1.row_id parentRowId, p.*
SELECT IFNULL(IFNULL(c.num, p.num), 1) AS num,
c.project_type projectType,
c.project_type,
p1.row_id parentRowId,
p.*
FROM t_bom_new_ebom_child c
RIGHT JOIN t_bom_new_ebom_parent p ON c.material_no = p.material_no
LEFT JOIN t_bom_new_ebom_parent p1 ON c.parent_row_id = p1.row_id AND p1.status = 4

View File

@ -78,8 +78,8 @@
<!--pbom单层反查-->
<select id="pBomSingleReverseReport" resultType="com.nflg.product.bomnew.pojo.vo.ReverseReportVO">
select IFNULL(a.num,1)*IFNULL(b.num,1) AS num,b.* , a.drawing_no as childDrawingNo from
t_bom_new_pbom_child_formal a
select b.* , a.drawing_no as childDrawingNo,a.num AS childNum,a.material_unit AS childMaterialUnit
from t_bom_new_pbom_child_formal a
join t_bom_new_pbom_parent_formal b on a.parent_row_id=b.row_id
where true

View File

@ -298,7 +298,11 @@
WHERE p.created_by = #{userCode}
</select>
<select id="getReverseBoms" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT IFNULL(c.num, p.num) AS num, c.project_type projectType, c.project_type, p1.row_id parentRowId, p.*
SELECT IFNULL(IFNULL(c.num, p.num), 1) AS num,
c.project_type projectType,
c.project_type,
p1.row_id parentRowId,
p.*
FROM t_bom_new_pbom_child c
RIGHT JOIN t_bom_new_pbom_parent p ON c.material_no = p.material_no AND c.fac_code = p.fac_code
LEFT JOIN t_bom_new_pbom_parent p1