Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom
# Conflicts: # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java
This commit is contained in:
commit
f7f631796d
|
|
@ -35,6 +35,7 @@ import javax.validation.Valid;
|
|||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
@ -149,7 +150,7 @@ public class EbomApi extends BaseApi {
|
|||
@ApiOperation("转PBom")
|
||||
@LogRecord(success = "转PBom:物料编码:{{#CToPbom.materialNo}} 版本:{{#CToPbom.currentVersion}},操作结果:{{#_ret}}",
|
||||
bizNo = "{{#paramDto.bomRowIds.toString()}}", type = "转PBom")
|
||||
public ResultVO<Boolean> convertToPBom(@RequestBody EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
|
||||
public ResultVO<List<OperationErrorMsgVO>> convertToPBom(@RequestBody EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
|
||||
VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料");
|
||||
VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂");
|
||||
bomNewEbomParentService.convertToPBom(paramDto);
|
||||
|
|
@ -159,9 +160,13 @@ public class EbomApi extends BaseApi {
|
|||
bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse();
|
||||
});
|
||||
|
||||
return ResultVO.success(true);
|
||||
|
||||
//导入到sap
|
||||
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
||||
paramDto.getBomRowIds().forEach(rootRowId -> {
|
||||
errorMsgVOS.addAll(bomNewEbomParentService.importToSAP(rootRowId));
|
||||
});
|
||||
|
||||
return ResultVO.success(errorMsgVOS);
|
||||
}
|
||||
|
||||
@PostMapping("upgradeChanges")
|
||||
|
|
@ -427,7 +432,7 @@ public class EbomApi extends BaseApi {
|
|||
@ApiOperation("导入到SAP")
|
||||
public ResultVO<List<OperationErrorMsgVO>> importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
||||
VUtils.isTure(rootBomRowIds.size() > 1).throwMessage("每次只能导入1条");
|
||||
return bomNewEbomParentService.importToSAP(rootBomRowIds.get(0));
|
||||
return ResultVO.success(bomNewEbomParentService.importToSAP(rootBomRowIds.get(0)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -462,4 +467,24 @@ public class EbomApi extends BaseApi {
|
|||
public ResultVO<List<BaseMaterialVO>> queryMaterials(@Valid @RequestBody @NotEmpty List<QueryMaterialsQuery> query) {
|
||||
return ResultVO.success(bomNewEbomParentService.queryMaterials(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入sap失败的bom数量
|
||||
* @return 导入sap失败的bom数量
|
||||
*/
|
||||
@GetMapping("getSapErrorNum")
|
||||
@ApiOperation("获取导入sap失败的bom数量")
|
||||
public ResultVO<Integer> getSapErrorNum() {
|
||||
return ResultVO.success(bomNewEbomParentService.getSapErrorNum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入sap失败的bom
|
||||
* @return 导入sap失败的bom
|
||||
*/
|
||||
@GetMapping("getSapError")
|
||||
@ApiOperation("获取导入sap失败错误信息")
|
||||
public ResultVO<List<OperationErrorMsgVO>> getSapError(@Valid @RequestParam("rowId") @NotNull Long rowId) {
|
||||
return ResultVO.success(bomNewEbomParentService.getSapError(rowId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.nflg.product.bomnew.mapper.master;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
|
||||
|
||||
/**
|
||||
* @author 曹鹏飞
|
||||
* @date 2024/5/26 10:25:25
|
||||
*/
|
||||
public interface BomNewSapErrorMsgMapper extends BaseMapper<BomNewSapErrorMsgEntity> {
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.nflg.product.bomnew.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author 曹鹏飞
|
||||
* @date 2024/5/26 10:22:27
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewSapErrorMsgEntity")
|
||||
@TableName(value = "t_bom_new_sap_error_msg")
|
||||
public class BomNewSapErrorMsgEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键行ID-雪花
|
||||
*/
|
||||
@TableId(value = "target_row_id", type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键行ID-雪花")
|
||||
private Long targetRowId;
|
||||
|
||||
/**
|
||||
* 类别,0-ebom;1-pbom;2-mbom;3-电气bom
|
||||
*/
|
||||
@TableField(value = "type")
|
||||
@ApiModelProperty(value = "类别,0-ebom;1-pbom;2-mbom;3-电气bom")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 错误信息,json格式
|
||||
*/
|
||||
@TableField(value = "data")
|
||||
@ApiModelProperty(value = "错误信息,json格式")
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value = "created_name")
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createdName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "created_time")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createdTime;
|
||||
}
|
||||
|
|
@ -8,9 +8,11 @@ import cn.hutool.core.date.DateUtil;
|
|||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
|
@ -106,6 +108,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
@Resource
|
||||
private BomNewOriginalChildService originalChildService;
|
||||
|
||||
@Resource
|
||||
private BomNewSapErrorMsgService bomNewSapErrorMsgService;
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
|
|
@ -800,12 +805,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.throwMessage("异常状态下不允许生成虚拟包");
|
||||
LogRecordContext.putVariable("gvbom", root);
|
||||
|
||||
// Boolean flag = true;
|
||||
// for (Integer f : paramDto.getVirtualPackageValue()) {
|
||||
// flag = flag & ((root.getVirtrualPackageEnum() & f) == f);
|
||||
// }
|
||||
// VUtils.isTure(flag).throwMessage("已生成虚拟包,无需重复生成");
|
||||
|
||||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, root);
|
||||
materialMainService.intiMaterialInfo(ImmutableList.of(parent), BomNewEbomParentVO::getMaterialNo);
|
||||
if (parent.getMaterialCategoryCode().startsWith("30") || ImmutableList.of("200601", "200401").contains(parent.getMaterialCategoryCode())) {
|
||||
|
|
@ -949,7 +948,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
}
|
||||
|
||||
public ResultVO<List<OperationErrorMsgVO>> importToSAP(Long rootBomRowId) {
|
||||
public List<OperationErrorMsgVO> importToSAP(Long rootBomRowId) {
|
||||
BomNewEbomParentEntity root = this.getById(rootBomRowId);
|
||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||
VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点");
|
||||
|
|
@ -974,10 +973,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
} else if (sapDto.getT1().size() != liErrMsg.size()) {
|
||||
state = SapStatusEnum.PUB_ERROR;
|
||||
}
|
||||
if (CollUtil.isNotEmpty(liErrMsg)) {
|
||||
bomNewSapErrorMsgService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewSapErrorMsgEntity.class)
|
||||
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
|
||||
} else {
|
||||
BomNewSapErrorMsgEntity sapErrorMsgEntity = new BomNewSapErrorMsgEntity();
|
||||
sapErrorMsgEntity.setTargetRowId(rootBomRowId);
|
||||
sapErrorMsgEntity.setType(0);
|
||||
sapErrorMsgEntity.setData(JSON.toJSONString(liErrMsg));
|
||||
sapErrorMsgEntity.setCreatedName(SessionUtil.getRealName());
|
||||
sapErrorMsgEntity.setCreatedTime(LocalDateTime.now());
|
||||
bomNewSapErrorMsgService.saveOrUpdate(sapErrorMsgEntity);
|
||||
}
|
||||
} finally {
|
||||
updateSapState(rootBomRowId, state);
|
||||
}
|
||||
return ResultVO.success(liErrMsg);
|
||||
return liErrMsg;
|
||||
}
|
||||
|
||||
private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) {
|
||||
|
|
@ -2372,6 +2383,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
return datas;
|
||||
}
|
||||
|
||||
public Integer getSapErrorNum() {
|
||||
return bomNewSapErrorMsgService.lambdaQuery().eq(BomNewSapErrorMsgEntity::getType, 0).count();
|
||||
}
|
||||
|
||||
public List<OperationErrorMsgVO> getSapError(Long rowId) {
|
||||
BomNewSapErrorMsgEntity sapErrorMsgEntity = bomNewSapErrorMsgService.lambdaQuery()
|
||||
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rowId)
|
||||
.one();
|
||||
if (Objects.isNull(sapErrorMsgEntity)) return Collections.emptyList();
|
||||
return JSON.parseArray(sapErrorMsgEntity.getData(), OperationErrorMsgVO.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ebom发布时将历史正式版-移到正式表
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewSapErrorMsgMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 曹鹏飞
|
||||
* @date 2024/5/26 10:24:35
|
||||
*/
|
||||
@Service
|
||||
public class BomNewSapErrorMsgService extends ServiceImpl<BomNewSapErrorMsgMapper, BomNewSapErrorMsgEntity> {
|
||||
}
|
||||
|
|
@ -25,7 +25,8 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -34,6 +35,7 @@ public class SapOpUtilService {
|
|||
@Resource
|
||||
SapService sapService;
|
||||
|
||||
private final static Pattern PATTERN = Pattern.compile("\\b\\d{10}\\b");
|
||||
|
||||
/**
|
||||
* sap 创建
|
||||
|
|
@ -186,10 +188,21 @@ public class SapOpUtilService {
|
|||
backList.addAll(list);
|
||||
}
|
||||
//"FLAG": "1" -- 0 失败;1 成功
|
||||
return list.stream()
|
||||
List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
|
||||
list.stream()
|
||||
.filter(f -> f.getFLAG().equals("0"))
|
||||
.map(item -> OperationErrorMsgVO.create(buildErrCol1(item), item.getSTATUS()))
|
||||
.collect(Collectors.toList());
|
||||
.forEach(it -> {
|
||||
Matcher matcher = PATTERN.matcher(it.getSTATUS());
|
||||
if (matcher.find()) {
|
||||
if (errorMsgVOS.stream().noneMatch(f -> StrUtil.equals(f.getPrimaryKey(), matcher.group()))) {
|
||||
errorMsgVOS.add(OperationErrorMsgVO.create(matcher.group(), it.getSTATUS()));
|
||||
}
|
||||
} else {
|
||||
OperationErrorMsgVO.create(buildErrCol1(it), it.getSTATUS());
|
||||
}
|
||||
});
|
||||
|
||||
return errorMsgVOS;
|
||||
}
|
||||
|
||||
private String buildErrCol1(T1DTO item) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomNewSapErrorMsgMapper">
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue