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/BomNewEbomParentService.java
This commit is contained in:
曹鹏飞 2024-05-26 11:19:28 +08:00
commit bed6402a50
10 changed files with 172 additions and 17 deletions

View File

@ -35,6 +35,7 @@ import javax.validation.Valid;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -149,7 +150,7 @@ public class EbomApi extends BaseApi {
@ApiOperation("转PBom") @ApiOperation("转PBom")
@LogRecord(success = "转PBom物料编码{{#CToPbom.materialNo}} 版本:{{#CToPbom.currentVersion}},操作结果:{{#_ret}}", @LogRecord(success = "转PBom物料编码{{#CToPbom.materialNo}} 版本:{{#CToPbom.currentVersion}},操作结果:{{#_ret}}",
bizNo = "{{#paramDto.bomRowIds.toString()}}", type = "转PBom") 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.getBomRowIds())).throwMessage("请选择要转换的物料");
VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂"); VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂");
bomNewEbomParentService.convertToPBom(paramDto); bomNewEbomParentService.convertToPBom(paramDto);
@ -159,9 +160,13 @@ public class EbomApi extends BaseApi {
bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse(); 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") @PostMapping("upgradeChanges")
@ -427,7 +432,7 @@ public class EbomApi extends BaseApi {
@ApiOperation("导入到SAP") @ApiOperation("导入到SAP")
public ResultVO<List<OperationErrorMsgVO>> importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) { public ResultVO<List<OperationErrorMsgVO>> importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
VUtils.isTure(rootBomRowIds.size() > 1).throwMessage("每次只能导入1条"); 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) { public ResultVO<List<BaseMaterialVO>> queryMaterials(@Valid @RequestBody @NotEmpty List<QueryMaterialsQuery> query) {
return ResultVO.success(bomNewEbomParentService.queryMaterials(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));
}
} }

View File

@ -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> {
}

View File

@ -1,7 +1,6 @@
package com.nflg.product.bomnew.pojo.dto; package com.nflg.product.bomnew.pojo.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum; import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -24,7 +23,7 @@ public class BomNewEBomImportExcelDTO {
private String projectType; private String projectType;
@ExcelColumn(value = "物料编码") @ExcelColumn(value = "物料编码*")
private String materialNo; private String materialNo;
@ -36,7 +35,7 @@ public class BomNewEBomImportExcelDTO {
private String materialDesc; private String materialDesc;
@ExcelColumn(value = "数量") @ExcelColumn(value = "数量*")
private BigDecimal num; private BigDecimal num;

View File

@ -15,7 +15,7 @@ public class EbomExcelDTO extends BaseImportExcelDTO {
/** /**
* 父级物料编号 * 父级物料编号
*/ */
@ExcelColumn("抬头物料") @ExcelColumn("抬头物料*")
private String parentMaterialNo; private String parentMaterialNo;
/** /**
@ -33,7 +33,7 @@ public class EbomExcelDTO extends BaseImportExcelDTO {
/** /**
* 物料编号 * 物料编号
*/ */
@ExcelColumn("项目物料") @ExcelColumn("项目物料*")
private String materialNo; private String materialNo;
/** /**
@ -45,7 +45,7 @@ public class EbomExcelDTO extends BaseImportExcelDTO {
/** /**
* 数量 * 数量
*/ */
@ExcelColumn("数量") @ExcelColumn("数量*")
private BigDecimal num; private BigDecimal num;
/** /**

View File

@ -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-ebom1-pbom2-mbom3-电气bom
*/
@TableField(value = "type")
@ApiModelProperty(value = "类别0-ebom1-pbom2-mbom3-电气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;
}

View File

@ -8,9 +8,11 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.*; import cn.hutool.core.util.*;
import cn.hutool.extra.spring.SpringUtil; 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.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -107,6 +109,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Resource @Resource
private BomNewOriginalChildService originalChildService; private BomNewOriginalChildService originalChildService;
@Resource
private BomNewSapErrorMsgService bomNewSapErrorMsgService;
/** /**
* 获取列表 * 获取列表
* *
@ -942,7 +947,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); BomNewEbomParentEntity root = this.getById(rootBomRowId);
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在"); VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点"); VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点");
@ -967,10 +972,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} else if (sapDto.getT1().size() != liErrMsg.size()) { } else if (sapDto.getT1().size() != liErrMsg.size()) {
state = SapStatusEnum.PUB_ERROR; 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 { } finally {
updateSapState(rootBomRowId, state); updateSapState(rootBomRowId, state);
} }
return ResultVO.success(liErrMsg); return liErrMsg;
} }
private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) { private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) {
@ -2453,4 +2470,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
return Collections.emptyList(); return Collections.emptyList();
} }
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);
}
} }

View File

@ -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> {
}

View File

@ -25,7 +25,8 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service @Service
@Slf4j @Slf4j
@ -34,6 +35,7 @@ public class SapOpUtilService {
@Resource @Resource
SapService sapService; SapService sapService;
private final static Pattern PATTERN = Pattern.compile("\\b\\d{10}\\b");
/** /**
* sap 创建 * sap 创建
@ -186,10 +188,21 @@ public class SapOpUtilService {
backList.addAll(list); backList.addAll(list);
} }
//"FLAG": "1" -- 0 失败1 成功 //"FLAG": "1" -- 0 失败1 成功
return list.stream() List<OperationErrorMsgVO> errorMsgVOS = new ArrayList<>();
list.stream()
.filter(f -> f.getFLAG().equals("0")) .filter(f -> f.getFLAG().equals("0"))
.map(item -> OperationErrorMsgVO.create(buildErrCol1(item), item.getSTATUS())) .forEach(it -> {
.collect(Collectors.toList()); 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) { private String buildErrCol1(T1DTO item) {

View File

@ -50,7 +50,8 @@ public class UserRoleService {
*/ */
public Integer getUserJob(){ public Integer getUserJob(){
// return 1; // return 1;
return technician()? UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue(); // return technician()? UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue();
return UserJobEnum.ENGINEER.getValue();
} }
/** /**

View File

@ -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>