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

This commit is contained in:
曹鹏飞 2024-04-28 18:00:07 +08:00
commit 7deeff6c0f
18 changed files with 155 additions and 132 deletions

View File

@ -212,7 +212,7 @@ public class DQBomApi extends BaseApi {
*/
@PostMapping("importToSAP")
@ApiOperation("导入到SAP")
public ResultVO<Boolean> 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条");
return dQBomService.importToSAP(rootBomRowIds.get(0));
}

View File

@ -15,6 +15,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomEditDetailVO;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.util.EecExcelUtil;
import com.nflg.product.bomnew.util.VUtils;
@ -459,7 +460,7 @@ public class EbomApi extends BaseApi {
*/
@PostMapping("importToSAP")
@ApiOperation("导入到SAP")
public ResultVO<Boolean> 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条");
return bomNewEbomParentService.importToSAP(rootBomRowIds.get(0));
}

View File

@ -1,23 +1,22 @@
package com.nflg.product.bomnew.api.user;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.FactoryCodeEnum;
import com.nflg.product.bomnew.constant.MBomConstantEnum;
import com.nflg.product.bomnew.constant.ValueEnum;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO;
import com.nflg.product.bomnew.pojo.dto.BomNewMbomApplyBackMaterialDTO;
import com.nflg.product.bomnew.pojo.dto.BomNewMbomDetailDTO;
import com.nflg.product.bomnew.pojo.dto.BomNewMbomSuperStatusDTO;
import com.nflg.product.bomnew.pojo.query.BomNewMbomBackMaterialQuery;
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewMbomBackMaterialVO;
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.OperationErrorMsgVO;
import com.nflg.product.bomnew.service.BomNewMbomBackMaterialService;
import com.nflg.product.bomnew.service.BomNewMbomDetailService;
import com.nflg.product.bomnew.service.BomNewMbomParentService;
@ -225,15 +224,11 @@ public class MBomApi extends BaseApi {
@ApiOperation("导入sap")
@LogRecord(success = "Mbom-导入sap,操作结果:{{#_ret}}", bizNo = "",
extra = "{{#rowId}}" ,type = "Mbom-导入sap")
public ResultVO<Boolean > importSap(@ApiParam("行Id") @RequestParam("rowId") Long rowId) {
if(Objects.isNull(rowId)){
throw new NflgBusinessException(STATE.Error, "选择行操作" );
public ResultVO<List<OperationErrorMsgVO>> importSap(@ApiParam("行Id") @RequestParam("rowId") Long rowId) {
if (Objects.isNull(rowId)) {
throw new NflgBusinessException(STATE.Error, "选择行操作");
}
return bomNewMbomParentService.importSap(rowId) ;
return bomNewMbomParentService.importSap(rowId);
}

View File

@ -3,20 +3,19 @@ package com.nflg.product.bomnew.api.user;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.MD5;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.OptionalBomConstant;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.OptionalMbomMaterialAddDTO;
import com.nflg.product.bomnew.pojo.query.OptionalEbomConfigListQuery;
import com.nflg.product.bomnew.pojo.query.OptionalEbomMainListQuery;
import com.nflg.product.bomnew.pojo.query.OptionalMbomMaterialListQuery;
import com.nflg.product.bomnew.pojo.query.OptionalMbomMaterialQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigVO;
import com.nflg.product.bomnew.pojo.vo.OptionalMbomMaterialListVO;
import com.nflg.product.bomnew.service.OptionalEbomConfigService;
import com.nflg.product.bomnew.service.OptionalEbomImportChildService;
import com.nflg.product.bomnew.service.OptionalEbomMainService;
@ -30,7 +29,6 @@ import nflg.product.common.vo.ResultVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@ -161,16 +159,12 @@ public class OptionalMbomApi extends BaseApi {
@ApiOperation("导入sap")
@LogRecord(success = "移动破-导入sap,操作结果:{{#_ret}}", bizNo = "",
extra = "{{#rowId}}" ,type = "移动破-导入sap")
public ResultVO<Boolean > importSap(@ApiParam("行Id") @RequestParam("rowId") Long rowId) {
public ResultVO<List<OperationErrorMsgVO>> importSap(@ApiParam("行Id") @RequestParam("rowId") Long rowId) {
if(Objects.isNull(rowId)){
throw new NflgBusinessException(STATE.Error, "选择行操作" );
}
return optionalMbomMaterialService.importSap(rowId);
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
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.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.service.SapOpUtilService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -31,7 +32,7 @@ public class TestApi {
@GetMapping("sap")
@ApiOperation("sap接口测试")
public ResultVO<Boolean> workDetailsListByPage() {
public ResultVO<List<OperationErrorMsgVO>> workDetailsListByPage() {
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
ImportSapParamDTO sapDto = new ImportSapParamDTO();
sapDto.setZID(RandomUtil.randomNumbers(5));

View File

@ -11,9 +11,11 @@ public class MBomConstantEnum {
@Getter
public enum MBomStatusEnum implements ValueEnum<Integer> {
//1待发布sap3=已发布
UNPUB_SAP(1, "未发布"),
PUB_SAP(3, "已导入");
UNPUB_SAP(1, "未导入"),
PUB_RUNNING(2, "导入中"),
PUB_SAP(3, "已导入"),
PUB_ERROR(4, "部分导入失败"),
PUB_ERROR_ALL(5, "全部导入失败");
private final Integer value;
private final String description;

View File

@ -77,11 +77,11 @@ public class BomNewDQbomChildEntity extends BomNewDQbomBaseEntity {
// private String materialNo;
/**
* 物料名称
* 物料描述
*/
@TableField(value = "material_name")
@ApiModelProperty(value = "物料名称")
private String materialName;
@TableField(value = "material_desc")
@ApiModelProperty(value = "物料描述")
private String materialDesc;
// /**
// * 材质

View File

@ -49,11 +49,11 @@ public class BomNewDQbomParentEntity extends BomNewDQbomBaseEntity {
// private String materialNo;
/**
* 物料名称
* 物料描述
*/
@TableField(value = "material_name")
@ApiModelProperty(value = "物料名称")
private String materialName;
@TableField(value = "material_desc")
@ApiModelProperty(value = "物料描述")
private String materialDesc;
// /**
// * 材质

View File

@ -39,10 +39,10 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
private Long materialRowId;
/**
* 物料信息表中的物料名称
* 物料信息表中的物料描述
*/
@ApiModelProperty(value = "物料名称(系统)")
private String systemMaterialName;
@ApiModelProperty(value = "物料描述(系统)")
private String systemMaterialDesc;
/**
* 物料类别

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.nflg.product.bomnew.constant.BomConstant;
@ -125,7 +126,7 @@ public class BomNewDQbomExceptionCheckService {
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
if (parent.getRootIs() == 1 || parent.getUserRootIs() == 1) {
if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, parent.getProjectType())) {
if (StrUtil.isBlank(parent.getMaterialName())) {
if (StrUtil.isBlank(parent.getMaterialDesc())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
}
} else {
@ -137,9 +138,9 @@ public class BomNewDQbomExceptionCheckService {
status = EBomExceptionStatusEnum.EXCEPT_NO_7;
} else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_2;
} else if (!materialVO.getMaterialDesc().equals(parent.getMaterialName())) {
} else if (!materialVO.getMaterialDesc().equals(parent.getMaterialDesc())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_15;
} else if (Objects.isNull(parent.getNum()) || parent.getNum().equals(BigDecimal.ZERO)) {
} else if (Objects.isNull(parent.getNum()) || NumberUtil.equals(parent.getNum(), BigDecimal.ZERO)) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
} else if (!Objects.equals(materialVO.getMaterialUnit(), parent.getMaterialUnit())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_16;
@ -166,7 +167,7 @@ public class BomNewDQbomExceptionCheckService {
if (StrUtil.isBlank(child.getProjectType())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_8;
} else if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, child.getProjectType())) {
if (StrUtil.isBlank(child.getMaterialName())) {
if (StrUtil.isBlank(child.getMaterialDesc())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
}
} else {
@ -177,9 +178,9 @@ public class BomNewDQbomExceptionCheckService {
status = EBomExceptionStatusEnum.EXCEPT_NO_7;
} else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_2;
} else if (!materialVO.getMaterialDesc().equals(child.getMaterialName())) {
} else if (!materialVO.getMaterialDesc().equals(child.getMaterialDesc())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_15;
} else if (Objects.isNull(child.getNum()) || child.getNum().equals(BigDecimal.ZERO)) {
} else if (Objects.isNull(child.getNum()) || NumberUtil.equals(child.getNum(), BigDecimal.ZERO)) {
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
} else if (!Objects.equals(materialVO.getMaterialUnit(), child.getMaterialUnit())) {
status = EBomExceptionStatusEnum.EXCEPT_NO_16;

View File

@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.*;
import cn.hutool.extra.spring.SpringUtil;
@ -929,7 +928,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
public ResultVO<Boolean> importToSAP(Long bomRowId) {
public ResultVO<List<OperationErrorMsgVO>> importToSAP(Long bomRowId) {
BomNewEbomParentEntity root = this.getById(bomRowId);
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点");
@ -941,15 +940,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<T1DTO> t1s = new ArrayList<>();
buildChildrenForSap(root, t1s);
sapDto.setT1(t1s);
ResultVO<Boolean> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
if (resultVO.getState().equals(STATE.Success.getState())) {
BomNewEbomParentEntity parentEntity = new BomNewEbomParentEntity();
parentEntity.setRowId(bomRowId);
parentEntity.setSapState(MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue());
parentEntity.setSapTime(LocalDateTimeUtil.now());
updateById(parentEntity);
}
return resultVO;
ResultVO<List<OperationErrorMsgVO>> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
boolean update = lambdaUpdate().eq(BomNewEbomParentEntity::getRowId, bomRowId)
.set(BomNewEbomParentEntity::getSapTime, LocalDateTime.now())
.set(Objects.equals(resultVO.getState(), STATE.Success.getState())
, BomNewEbomParentEntity::getSapState, MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue())
.set(!Objects.equals(resultVO.getState(), STATE.Success.getState()) && t1s.size() == resultVO.getData().size()
, BomNewEbomParentEntity::getSapState, MBomConstantEnum.MBomStatusEnum.PUB_ERROR_ALL.getValue())
.set(!Objects.equals(resultVO.getState(), STATE.Success.getState()) && t1s.size() != resultVO.getData().size()
, BomNewEbomParentEntity::getSapState, MBomConstantEnum.MBomStatusEnum.PUB_ERROR.getValue())
.update();
return update ? resultVO : ResultVO.error("更新数据失败");
}
private void buildChildrenForSap(BomNewEbomParentEntity parent, List<T1DTO> t1s) {
@ -966,6 +967,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
t1.setMEINS(c.getMaterialUnit());
t1.setMENGE(c.getNum().toString());
t1.setPOSTP(c.getProjectType());
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(c.getProjectType())) {
t1.setIDNRK("");
t1.setPOTX1(c.getMaterialName());
}
t1.setDATUM(dateYMD);
t1s.add(t1);
BomNewEbomParentEntity cp = lambdaQuery()

View File

@ -3,7 +3,6 @@ package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
@ -11,7 +10,6 @@ import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.EBomSuperMaterialStatusEnum;
@ -22,16 +20,15 @@ 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.BomNewMbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewMbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewMbomIndexVO;
import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.service.domain.MBom.IndexListTree;
import com.nflg.product.bomnew.util.VUtils;
import io.swagger.annotations.ApiParam;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -197,8 +194,7 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
}
public ResultVO<Boolean> importSap(Long rowId){
public ResultVO<List<OperationErrorMsgVO>> importSap(Long rowId) {
BomNewMbomMiddleVO parentVO= getParentById(rowId);
@ -303,21 +299,29 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
}
}
ResultVO<Boolean> resultVO= SpringUtil.getBean(SapOpUtilService.class).importToSapV2(result,null);
ResultVO<List<OperationErrorMsgVO>> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(result, null);
//上传成功更新状态
if(resultVO.getState().equals( STATE.Success.getState())){
BomNewMbomParentEntity parentEntity=new BomNewMbomParentEntity();
parentEntity.setRowId(parentVO.getRowId());
parentEntity.setStatus(MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue());
parentEntity.setSysnSapUserName(SessionUtil.getUserName());
parentEntity.setSysnSapTime(LocalDateTimeUtil.now());
parentEntity.setModifyTime(LocalDateTimeUtil.now());
this.updateById(parentEntity);
}
// if(resultVO.getState().equals( STATE.Success.getState())){
// BomNewMbomParentEntity parentEntity=new BomNewMbomParentEntity();
// parentEntity.setRowId(parentVO.getRowId());
// parentEntity.setStatus(MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue());
// parentEntity.setSysnSapUserName(SessionUtil.getUserName());
// parentEntity.setSysnSapTime(LocalDateTimeUtil.now());
// parentEntity.setModifyTime(LocalDateTimeUtil.now());
// this.updateById(parentEntity);
// }
return resultVO;
// return null;
boolean update = lambdaUpdate().eq(BomNewMbomParentEntity::getRowId, parentVO.getRowId())
.set(BomNewMbomParentEntity::getSysnSapTime, LocalDateTime.now())
.set(Objects.equals(resultVO.getState(), STATE.Success.getState())
, BomNewMbomParentEntity::getStatus, MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue())
.set(!Objects.equals(resultVO.getState(), STATE.Success.getState()) && result.getT1().size() == resultVO.getData().size()
, BomNewMbomParentEntity::getStatus, MBomConstantEnum.MBomStatusEnum.PUB_ERROR_ALL.getValue())
.set(!Objects.equals(resultVO.getState(), STATE.Success.getState()) && result.getT1().size() != resultVO.getData().size()
, BomNewMbomParentEntity::getStatus, MBomConstantEnum.MBomStatusEnum.PUB_ERROR.getValue())
.update();
return update ? resultVO : ResultVO.error("更新数据失败");
}

View File

@ -292,7 +292,7 @@ public class DQBomImportService {
parent.setLevel(data.getLevel());
parent.setDrawingNo(data.getDrawingNo());
parent.setMaterialNo(data.getMaterialNo());
parent.setMaterialName(data.getMaterialName());
parent.setMaterialDesc(data.getMaterialName());
parent.setMaterialTexture(data.getMaterialTexture());
parent.setMaterialUnit(data.getMaterialUnit());
parent.setUnitWeight(data.getUnitWeight());
@ -334,7 +334,7 @@ public class DQBomImportService {
child.setParentRowId(parentRowIdMap.getOrDefault(data.getLevel() - 1, 0L));
child.setIdentityNo(child.getParentRowId() + "_" + child.getRowId());
child.setLevel(data.getLevel());
child.setMaterialName(data.getMaterialName());
child.setMaterialDesc(data.getMaterialName());
child.setMaterialTexture(data.getMaterialTexture());
child.setMaterialUnit(data.getMaterialUnit());
child.setUnitWeight(data.getUnitWeight());

View File

@ -3,7 +3,6 @@ package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
@ -78,7 +77,7 @@ public class DQBomService {
List<BomNewDQbomVO> roots = result.getRecords().stream()
.filter(r -> StrUtil.equals(r.getMaterialNo(), query.getMaterialNo())
|| StrUtil.equals(r.getDrawingNo(), query.getDrawingNo())
|| r.getMaterialName().contains(query.getMaterialName()))
|| r.getMaterialDesc().contains(query.getMaterialName()))
.collect(Collectors.toList());
roots.forEach(this::buildChildren);
//从子级开始查找
@ -184,7 +183,7 @@ public class DQBomService {
BaseMaterialVO bm = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(d.getMaterialNo())).findFirst().orElse(null);
if (bm != null) {
d.setMaterialState(bm.getMaterialState());
d.setSystemMaterialName(bm.getMaterialDesc());
d.setSystemMaterialDesc(bm.getMaterialDesc());
d.setSystemMaterialCategoryName(bm.getCategoryName());
d.setSystemMaterialUnit(bm.getMaterialUnit());
d.setMaterialRowId(bm.getMaterialRowId());
@ -289,7 +288,7 @@ public class DQBomService {
.eq(BomNewDQbomParentEntity::getStatus, DQBomStatusEnum.WAIT_CONVERT.getValue())
.one();
if (!Objects.isNull(cp)) {
cp.setMaterialName(c.getMaterialName());
cp.setMaterialDesc(c.getMaterialDesc());
cp.setUnitWeight(c.getUnitWeight());
cp.setTotalWeight(BomUtil.calculateTotalWeight(cp.getNum(), cp.getUnitWeight()));
cp.setModifyTime(LocalDateTime.now());
@ -379,14 +378,19 @@ public class DQBomService {
}
}
public ResultVO<Boolean> importToSAP(Long rootBomRowId) {
public ResultVO<List<OperationErrorMsgVO>> importToSAP(Long rootBomRowId) {
BomNewDQbomParentEntity root = dQBomParentService.getById(rootBomRowId);
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
VUtils.isTure(root.getRootIs() == 0).throwMessage("请选择根节点");
VUtils.isTure(root.getSapState() == 3).throwMessage("已导入过了,请勿重复操作");
VUtils.isTure(Objects.equals(root.getSapState(), MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue()))
.throwMessage("已导入过了,请勿重复操作");
VUtils.isTure(Objects.equals(root.getSapState(), MBomConstantEnum.MBomStatusEnum.PUB_RUNNING.getValue()))
.throwMessage("正在导入中,请等待操作完成");
List<BomNewDQbomVO> datas = getAll(rootBomRowId);
datas.remove(0);
List<String> materialNos = datas.stream().map(BomNewDQbomVO::getMaterialNo).collect(Collectors.toList());
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
ImportSapParamDTO sapDto = new ImportSapParamDTO();
sapDto.setZID(RandomUtil.randomNumbers(5));
sapDto.setI_WERKS("1");
@ -397,28 +401,47 @@ public class DQBomService {
T1DTO t1 = new T1DTO();
t1.setID(RandomUtil.randomNumbers(5));
t1.setMATNR(d.getParentMaterialNo());
t1.setMEINS(d.getMaterialUnit());
t1.setMENGE(d.getNum().toString());
t1.setPOSTP(d.getProjectType());
t1.setDATUM(dateYMD);
t1.setMEINS(d.getMaterialUnit());
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(d.getProjectType())) {
t1.setIDNRK("");
t1.setPOTX1(d.getMaterialName());
t1.setPOTX1(d.getMaterialDesc());
} else {
t1.setIDNRK(d.getMaterialNo());
BaseMaterialVO bm = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(d.getMaterialNo())).findFirst().orElse(null);
if (!Objects.isNull(bm)) {
t1.setMEINS(bm.getMaterialUnit());
}
}
t1.setDATUM(dateYMD);
t1s.add(t1);
});
sapDto.setT1(t1s);
ResultVO<Boolean> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
Set<Long> bomRowIds = datas.stream().map(BomNewDQbomVO::getBomRowId).collect(Collectors.toSet());
bomRowIds.add(rootBomRowId);
updateSapState(bomRowIds, MBomConstantEnum.MBomStatusEnum.PUB_RUNNING);
ResultVO<List<OperationErrorMsgVO>> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
MBomConstantEnum.MBomStatusEnum sapState;
if (resultVO.getState().equals(STATE.Success.getState())) {
BomNewDQbomParentEntity parentEntity = new BomNewDQbomParentEntity();
parentEntity.setRowId(rootBomRowId);
parentEntity.setSapState(MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue());
parentEntity.setSapTime(LocalDateTimeUtil.now());
dQBomParentService.updateById(parentEntity);
sapState = MBomConstantEnum.MBomStatusEnum.PUB_SAP;
} else if (t1s.size() == resultVO.getData().size()) {
sapState = MBomConstantEnum.MBomStatusEnum.PUB_ERROR_ALL;
} else {
sapState = MBomConstantEnum.MBomStatusEnum.PUB_ERROR;
}
return resultVO;
boolean update = updateSapState(bomRowIds, sapState);
return update ? resultVO : ResultVO.error(STATE.Error, "更新失败");
}
private boolean updateSapState(Set<Long> bomRowIds, MBomConstantEnum.MBomStatusEnum sapState) {
return dQBomParentService.lambdaUpdate()
.in(BomNewDQbomParentEntity::getRowId, bomRowIds)
.set(BomNewDQbomParentEntity::getSapTime, LocalDateTime.now())
.set(BomNewDQbomParentEntity::getSapState, sapState.getValue())
.update();
}
public BomDQbomEditDetailVO editDetail(Long rowId, Long bomRowId) {
@ -451,27 +474,10 @@ public class DQBomService {
public List<BomNewDQbomVO> changeMaterial(BomNewDQbomQuery query) {
VUtils.isTure(Objects.isNull(query.getParent())).throwMessage("父级节点不能为空");
if (CollUtil.isNotEmpty(query.getDatas())) return query.getDatas();
List<String> materialNos = query.getDatas().stream()
.map(BomNewDQbomVO::getMaterialNo)
.filter(StrUtil::isNotBlank)
.distinct()
.collect(Collectors.toList());
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
query.getDatas().forEach(c -> {
BaseMaterialVO vo = materialBaseInfos.stream()
.filter(m -> m.getMaterialNo().equals(c.getMaterialNo()))
.findFirst()
.orElse(null);
if (vo != null) {
c.setUnitWeight(vo.getMaterialWeight());
c.setTotalWeight(BomUtil.calculateTotalWeight(c.getNum(), c.getUnitWeight()));
c.setMaterialName(vo.getMaterialName());
c.setMaterialUnit(vo.getMaterialUnit());
c.setMaterialTexture(vo.getMaterialTexture());
}
});
if (CollUtil.isEmpty(query.getDatas())) return query.getDatas();
initMaterialInfo(query.getDatas());
return query.getDatas();
}
@ -498,6 +504,7 @@ public class DQBomService {
savePbomChildren(children, parents);
CompletableFuture.runAsync(() -> {
bomNewPbomParentService.getBaseMapper().updatePBomMaterialUse();
importToSAP(root.getRowId());
});
}
@ -537,6 +544,22 @@ public class DQBomService {
private void savePbomParents(List<BomNewDQbomParentEntity> parents) {
List<BomNewPbomParentEntity> pparents = Convert.toList(BomNewPbomParentEntity.class, parents);
pparents.forEach(p -> {
if (Objects.equals(p.getRootIs(), 1)) {
//如果pbom中该物料是待发布的子节点则设置该物料不是根节点
Set<Long> pcParentIds = bomNewPbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getParentRowId)
.eq(BomNewPbomChildEntity::getMaterialNo, p.getMaterialNo())
.list()
.stream()
.map(BomNewPbomChildEntity::getParentRowId)
.collect(Collectors.toSet());
if (!pcParentIds.isEmpty() && bomNewPbomParentService.lambdaQuery()
.in(BomNewPbomParentEntity::getMaterialNo, pcParentIds)
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.WAIT_PUBLISH.getValue())
.exists()) {
p.setRootIs(0);
}
}
p.setCreatedTime(LocalDateTime.now());
p.setModifyTime(null);
p.setEditStatus(PBomEditStatusEnum.HANDLER_FINISHED.getValue());
@ -643,5 +666,4 @@ public class DQBomService {
}
return datas;
}
}

View File

@ -28,6 +28,7 @@ import com.nflg.product.bomnew.pojo.entity.OptionalEbomConfigEntity;
import com.nflg.product.bomnew.pojo.entity.OptionalMbomMaterialEntity;
import com.nflg.product.bomnew.pojo.query.OptionalMbomMaterialListQuery;
import com.nflg.product.bomnew.pojo.query.OptionalMbomMaterialQuery;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.pojo.vo.OptionalMbomMaterialListVO;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
@ -119,9 +120,7 @@ public class OptionalMbomMaterialService extends ServiceImpl<OptionalMbomMateria
}
public ResultVO<Boolean> importSap(Long rowId){
public ResultVO<List<OperationErrorMsgVO>> importSap(Long rowId) {
OptionalMbomMaterialEntity entity= getById(rowId);
List<OptionalMbomMaterialListVO> list=this.baseMapper.getByRootIdList(entity.getRootRowId());
@ -164,8 +163,7 @@ public ResultVO<Boolean> importSap(Long rowId){
log.info(JSON.toJSONString(result));
ResultVO<Boolean> resultVO= SpringUtil.getBean(SapOpUtilService.class).importToSapV2(result,null);
ResultVO<List<OperationErrorMsgVO>> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(result, null);
if(resultVO.getState().equals( STATE.Success.getState())){
OptionalEbomConfigEntity configEntity=new OptionalEbomConfigEntity();

View File

@ -137,8 +137,7 @@ public class SapOpUtilService {
}
public ResultVO<Boolean> importToSapV2(ImportSapParamDTO impartSapParamDTO,List<T1DTO> backList) {
public ResultVO<List<OperationErrorMsgVO>> importToSapV2(ImportSapParamDTO impartSapParamDTO, List<T1DTO> backList) {
if (CollUtil.isEmpty(impartSapParamDTO.getT1())) {
return ResultVO.error("同步SAP 参数错误");
}
@ -201,7 +200,8 @@ public class SapOpUtilService {
}
if (errCount.get() > 0) {
//throw new Exception(errBuf.toString());
throw new ErrorMsgException(STATE.Success, "导入到SAP出错", liError);
//throw new ErrorMsgException(STATE.Success, "导入到SAP出错", liError);
return ResultVO.error(STATE.BusinessError, "导入到SAP出错", liError);
}
}else{
throw new Exception("获取sap返回数据转换异常");

View File

@ -4,7 +4,7 @@
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity">
<id column="row_id" jdbcType="BIGINT" property="rowId"/>
<result column="material_no" jdbcType="VARCHAR" property="materialNo"/>
<result column="material_name" jdbcType="VARCHAR" property="materialName"/>
<result column="material_desc" jdbcType="VARCHAR" property="materialDesc"/>
<result column="unit_weight" jdbcType="DECIMAL" property="unitWeight"/>
<result column="material_unit" jdbcType="VARCHAR" property="materialUnit"/>
<result column="material_texture" jdbcType="VARCHAR" property="materialTexture"/>
@ -47,7 +47,7 @@
AND p.material_no = #{query.materialNo}
</if>
<if test="query.materialName != null and query.materialName!=''">
AND c.project_type='T' AND p.material_name like concat('%', #{query.materialName}, '%')
AND c.project_type='T' AND p.material_desc like concat('%', #{query.materialName}, '%')
</if>
<if test="query.startDate != null and query.startDate!=''">
AND p.created_time <![CDATA[ >= ]]> #{query.startDate}
@ -65,7 +65,7 @@
if(c.exception_status = 1, ifnull(p.exception_status, 1), c.exception_status) exception_status,
ifnull(p.exception_tag, c.exception_tag) exception_tag,
ifnull(p.bom_exist, 0) bom_exist,
ifnull(p.sap_state, 1) sap_state,
p2.sap_state,
ifnull(p.current_version, if(c.status = 1, 'A00', p2.current_version)) current_version,
c.*
FROM t_bom_new_dqbom_child c
@ -93,7 +93,7 @@
c.level,
c.material_no,
c.drawing_no,
c.material_name,
c.material_desc,
c.material_texture,
c.num,
ifnull(p.material_unit, c.material_unit) material_unit,
@ -125,7 +125,7 @@
AND c.material_no = #{materialNo}
</if>
<if test="materialName != null and materialName!=''">
AND c.project_type='T' AND c.material_name like concat('%', #{materialName}, '%')
AND c.project_type='T' AND c.material_desc like concat('%', #{materialName}, '%')
</if>
</select>

View File

@ -70,8 +70,8 @@ public class ResultVO<T> implements Serializable {
return error(msg ,STATE.PassportErr.getState());
}
public static ResultVO error(STATE state, String msg, Object value) {
ResultVO vo = new ResultVO<>();
public static <T> ResultVO<T> error(STATE state, String msg, T value) {
ResultVO<T> vo = new ResultVO<T>();
vo.data = value;
vo.state = state.getState();
vo.msg = msg;