Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java
This commit is contained in:
曹鹏飞 2024-06-18 09:59:40 +08:00
commit 44c714816a
4 changed files with 121 additions and 7 deletions

View File

@ -0,0 +1,63 @@
package com.nflg.product.bomnew.advice;
import cn.hutool.core.util.StrUtil;
import com.nflg.product.bomnew.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.util.JwtUtil;
import nflg.product.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
import java.lang.reflect.Type;
/**
* @author 曹鹏飞
* @date 2024/6/18 09:41:31
*/
@Slf4j
@ControllerAdvice
@RefreshScope
public class LoggingRequestBodyAdvice implements RequestBodyAdvice {
@Value("${logging.http.detailed:false}")
private Boolean enableHttpDetailed;
@Override
public boolean supports(MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
return enableHttpDetailed;
}
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
return httpInputMessage;
}
@Override
public Object afterBodyRead(Object o, HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
try {
log.info("请求参数: {}", JsonUtil.toJson(o));
log.info("请求头: {}", JsonUtil.toJson(httpInputMessage.getHeaders()));
String token = httpInputMessage.getHeaders().getFirst("Authorization");
if (StrUtil.isNotBlank(token)) {
ResultVO result = JwtUtil.parse(token);
if (result.getState().equals(STATE.Success.getState())) {
log.info("请求用户: {}", JsonUtil.toJson(result.getData()));
}
}
} catch (Exception ex) {
log.error("读取请求体出错", ex);
}
return o;
}
@Override
public Object handleEmptyBody(Object o, HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
return o;
}
}

View File

@ -0,0 +1,41 @@
package com.nflg.product.bomnew.advice;
import com.nflg.product.bomnew.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
/**
* @author 曹鹏飞
* @date 2024/6/18 09:42:06
*/
@Slf4j
@ControllerAdvice
@RefreshScope
public class LoggingResponseBodyAdvice implements ResponseBodyAdvice<Object> {
@Value("${logging.http.detailed:false}")
private Boolean enableHttpDetailed;
@Override
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
return enableHttpDetailed;
}
@Override
public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class<? extends HttpMessageConverter<?>> aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
try {
log.info("响应数据: {}", JsonUtil.toJson(o));
} catch (Exception ex) {
log.error("读取响应数据出错", ex);
}
return o;
}
}

View File

@ -1935,10 +1935,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
checkUserRoleAuth(dto.getParent().getCreatedBy());
//暂存数据为空后面不处理
if (CollUtil.isEmpty(dto.getDatas())) {
return dto.getParent();
}
// //暂存数据为空后面不处理
// if (CollUtil.isEmpty(dto.getDatas())) {
// return dto.getParent();
// }
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());

View File

@ -14,6 +14,7 @@ import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.service.BomNewEbomChildService;
@ -21,6 +22,7 @@ import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.service.UserRoleService;
import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.VersionUtil;
import lombok.Getter;
@ -75,6 +77,11 @@ public class EBomEdit {
parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
parent.setNum(new BigDecimal(1));
parent.setBomExist(1);
MaterialMainEntity materialMainEntity = SpringUtil.getBean(MaterialMainService.class).lambdaQuery()
.eq(MaterialMainEntity::getMaterialNo, parent.getMaterialNo())
.one();
parent.setShouldBomExist(MaterialshouldBomExistUtil.checkShouldBomExist(materialMainEntity.getMaterialCategoryCode()
, materialMainEntity.getMaterialGetType()) ? 1 : 0);
parent.setLastVersionIs(1);
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
@ -132,6 +139,7 @@ public class EBomEdit {
parentEntity.setRootIs(parentEntity.getMaterialNo().startsWith("31") ? 1 : 0);
parentEntity.setUserRootIs(1);
parentEntity.setDeptRowId(SessionUtil.getDepartRowId());
parentEntity.setBomExist(CollUtil.isEmpty(createDTO.getDatas()) ? 0 : 1);
createDTO.getDatas().forEach(k -> {
k.setParentRowId(parentEntity.getRowId());
@ -272,9 +280,10 @@ public class EBomEdit {
throw new NflgBusinessException(STATE.Error, "parent 数据不能为空");
}
if (CollUtil.isEmpty(dto.getDatas())) {
throw new NflgBusinessException(STATE.Error, "datas 数据不能为空");
}
// if (CollUtil.isEmpty(dto.getDatas())) {
// throw new NflgBusinessException(STATE.Error, "datas 数据不能为空");
// }
List<String> materialNos = dto.getDatas().stream()
.filter(f -> !StrUtil.equals(f.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY, true))
.map(BaseMaterialVO::getMaterialNo)
@ -356,6 +365,7 @@ public class EBomEdit {
parentEntity.setModifyTime(LocalDateTime.now());
}
parentEntity.setEditStatus(dto.getOpType());
parentEntity.setBomExist(CollUtil.isEmpty(dto.getDatas()) ? 0 : 1);
//提交
if (Objects.equals(dto.getOpType(), EbomEditStatusEnum.HANDLER_FINISHED.getValue())) {
//工艺人员