Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java
This commit is contained in:
jing's 2023-12-24 15:10:51 +08:00
commit cfc4280ba5
16 changed files with 342 additions and 118 deletions

View File

@ -14,10 +14,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.BomNewEbomParentService; import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.service.UserRoleService;
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase; import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase;
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31; import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31;
import com.nflg.product.bomnew.util.EecExcelUtil; import com.nflg.product.bomnew.util.EecExcelUtil;
@ -66,6 +63,9 @@ public class EbomApi extends BaseApi {
@Resource @Resource
private UserRoleService userRoleService; private UserRoleService userRoleService;
@Resource
private BomNewEbomUpgradeChangeService upgradeChangeService;
@PostMapping("workDetailsListByPage") @PostMapping("workDetailsListByPage")
@ApiOperation("Ebom-工作明细列表") @ApiOperation("Ebom-工作明细列表")
@ -81,10 +81,28 @@ public class EbomApi extends BaseApi {
@PostMapping("changeImpact") @PostMapping("changeImpact")
@ApiOperation("Ebom-变更影响") @ApiOperation("Ebom-变更影响")
public ResultVO<Page<BomNewEbomParentVO>> changeImpact(@RequestBody BomNewEbomParentQuery query) { public ResultVO<Page<BomNewEbomUpgradeChangeVO>> changeImpact(@RequestBody BomNewEbomParentQuery query) {
return ResultVO.success(bomNewEbomParentService.formalWorksheet(query)); return ResultVO.success(bomNewEbomParentService.getUpgradeChangeList(query));
} }
@PostMapping("delChangeImpact")
@ApiOperation("Ebom-删除变更影响")
public ResultVO<Boolean> delChangeImpact(@RequestBody List<Long> rowIds){
VUtils.isTure(CollUtil.isEmpty(rowIds)).throwMessage("请选择要删除的数据");
upgradeChangeService.delChangeImpact(rowIds);
return ResultVO.success(true);
}
@PostMapping("updateChangeImpactVersion")
@ApiOperation("Ebom-更新版本")
public ResultVO<Boolean> updateChangeImpactVersion(@RequestBody List<Long> rowIds){
VUtils.isTure(CollUtil.isEmpty(rowIds)).throwMessage("请选择要更新版本的数据");
upgradeChangeService.updateChangeImpactVersion(rowIds);
return ResultVO.success(true);
}
@GetMapping("getChild") @GetMapping("getChild")
@ApiOperation("获取子级") @ApiOperation("获取子级")
public ResultVO<List<BomNewEbomParentVO>> getChild(@RequestParam("bomRowId") Long bomRowId) { public ResultVO<List<BomNewEbomParentVO>> getChild(@RequestParam("bomRowId") Long bomRowId) {

View File

@ -47,7 +47,7 @@ import java.util.concurrent.ExecutionException;
@Api(tags = "原始BOM") @Api(tags = "原始BOM")
@RestController @RestController
@RequestMapping("bom/new/bomOriginal") @RequestMapping("bom/new/bomOriginal")
public class OriginalBomApi extends BaseApi { public class OriginalBomApi extends BaseApi {
@Resource @Resource
BomNewOriginalParentService originalParentService; BomNewOriginalParentService originalParentService;
@ -78,15 +78,16 @@ public class OriginalBomApi extends BaseApi {
public ResultVO<List<TreeNode<BomOriginalListVO>>> getChildTree(@RequestParam("rowId") Long rowId) throws ExecutionException, InterruptedException { public ResultVO<List<TreeNode<BomOriginalListVO>>> getChildTree(@RequestParam("rowId") Long rowId) throws ExecutionException, InterruptedException {
return ResultVO.success(originalParentService.getChildTree(rowId)); return ResultVO.success(originalParentService.getChildTree(rowId));
} }
@PostMapping("saveBom") @PostMapping("saveBom")
@ApiOperation("编辑时-暂存") @ApiOperation("编辑时-暂存")
public ResultVO<Boolean> saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) { public ResultVO<Boolean> saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) {
return ResultVO.success(originalParentService.saveBom(bom,false)); return ResultVO.success(originalParentService.saveBom(bom, false));
} }
@PostMapping("saveSubmit") @PostMapping("saveSubmit")
@ApiOperation("编辑时-提交") @ApiOperation("编辑时-提交")
public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) { public ResultVO<Boolean> saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) {
return ResultVO.success(originalParentService.saveSubmit(bom)); return ResultVO.success(originalParentService.saveSubmit(bom));
} }
@ -120,6 +121,7 @@ public class OriginalBomApi extends BaseApi {
/** /**
* 原始BOM转EBom * 原始BOM转EBom
*
* @return * @return
*/ */
@PostMapping("convertToEBom") @PostMapping("convertToEBom")
@ -128,7 +130,7 @@ public class OriginalBomApi extends BaseApi {
public ResultVO<Boolean> convertToEBom(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException { public ResultVO<Boolean> convertToEBom(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM"); VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要转换的BOM");
VUtils.isTure(bomRowIds.size()>20).throwMessage("你选择的BOM数据大于20"); VUtils.isTure(bomRowIds.size() > 20).throwMessage("你选择的BOM数据大于20");
originalParentService.convertToEBom(bomRowIds); originalParentService.convertToEBom(bomRowIds);
//更新物料使用 //更新物料使用
bomNewEbomChildMapper.updateEBomMaterialUse(); bomNewEbomChildMapper.updateEBomMaterialUse();
@ -152,7 +154,7 @@ public class OriginalBomApi extends BaseApi {
@ApiOperation("导入") @ApiOperation("导入")
@PostMapping("importBom") @PostMapping("importBom")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> importBom(@RequestParam(value = "file")MultipartFile file) throws IOException { public ResultVO<Boolean> importBom(@RequestParam(value = "file") MultipartFile file) throws IOException {
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) { if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
return ResultVO.error("请上传Excel文件"); return ResultVO.error("请上传Excel文件");
} }
@ -160,12 +162,7 @@ public class OriginalBomApi extends BaseApi {
//计算层级 //计算层级
originalParentService.computeLevelNumAndRootState(); originalParentService.computeLevelNumAndRootState();
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
// @Override
// public void afterCommit() {
// originalParentService.computeLevelNumAndRootState();
// }
// });
return ResultVO.success(true); return ResultVO.success(true);
} }
@ -174,18 +171,18 @@ public class OriginalBomApi extends BaseApi {
@ApiOperation("新增物料") @ApiOperation("新增物料")
@GetMapping("testaddMaterial") @GetMapping("testaddMaterial")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResultVO<String> testaddMaterial(@RequestParam(value = "drawingNo" ,required = false)String drawingNo, public ResultVO<String> testaddMaterial(@RequestParam(value = "drawingNo", required = false) String drawingNo,
@RequestParam(value = "materialName" ,required = false)String materialName, @RequestParam(value = "materialName", required = false) String materialName,
@RequestParam("materialCategoryCode")String materialCategoryCode) throws IOException { @RequestParam("materialCategoryCode") String materialCategoryCode) throws IOException {
materialService.addMaterial(drawingNo, materialName,materialCategoryCode); materialService.addMaterial(drawingNo, materialName, materialCategoryCode);
return ResultVO.success("true"); return ResultVO.success("true");
} }
@ApiOperation("获取sessionKey") @ApiOperation("获取sessionKey")
@GetMapping("getSessionKey") @GetMapping("getSessionKey")
public ResultVO<String> getSessionKey() { public ResultVO<String> getSessionKey() {
return ResultVO.success(SessionUtil.getSessionKey()); return ResultVO.success(SessionUtil.getSessionKey());
@ -196,19 +193,16 @@ public class OriginalBomApi extends BaseApi {
@PostMapping("testImportBom") @PostMapping("testImportBom")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResultVO<Boolean> testImportBom() throws IOException { public ResultVO<Boolean> testImportBom() throws IOException {
InputStream inputStream=new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx"); InputStream inputStream = new FileInputStream("C:\\Users\\01956\\Desktop\\西卡印尼烘干线总站BOM.xlsx");
originalParentService.importBomTest(inputStream); originalParentService.importBomTest(inputStream);
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override // originalParentService.computeLevelNumAndRootState();
public void afterCommit() {
originalParentService.computeLevelNumAndRootState(); originalParentService.computeLevelNumAndRootState();
}
});
return ResultVO.success(true); return ResultVO.success(true);
} }
} }

View File

@ -6,6 +6,7 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO;
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO; import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO; import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -38,6 +39,8 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
* @return * @return
*/ */
Page<BomNewEbomParentVO> formalWorksheet(Page<BomNewEbomParentVO> page, @Param("query") BomNewEbomParentQuery query); Page<BomNewEbomParentVO> formalWorksheet(Page<BomNewEbomParentVO> page, @Param("query") BomNewEbomParentQuery query);
Page<BomNewEbomUpgradeChangeVO> getUpgradeChangeList(Page<BomNewEbomUpgradeChangeVO> page, @Param("query") BomNewEbomParentQuery query);
/** /**
* 获取子级 * 获取子级
* @param rowId * @param rowId
@ -58,4 +61,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
void updateRootState(); void updateRootState();
void delBatch(@Param("rowIds") List<Long> rowIds); void delBatch(@Param("rowIds") List<Long> rowIds);
void updateStateBatchByRowIds(@Param("status") Integer status, @Param("list") List<Long> list );
} }

View File

@ -33,5 +33,8 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
/** /**
* 更新是否根节点状态 * 更新是否根节点状态
*/ */
void updateRootState(); void updateRootState_1();
void updateRootState_2();
void updateRootState_3();
} }

View File

@ -0,0 +1,96 @@
package com.nflg.product.bomnew.pojo.vo;
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;
/**
* t_bom_new_ebom_upgrade_change
* ebom-变更影响
*
* @author makejava
* @since 2023-12-23 16:10:19
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-new-vo-BomNewEbomUpgradeChangeEntityVO")
public class BomNewEbomUpgradeChangeVO implements Serializable {
/**
* 主键-行ID
*/
@ApiModelProperty(value = "主键-行ID")
private Long rowId;
/**
* 受影响的物料编码
*/
@ApiModelProperty(value = "受影响的物料编码")
private String materialNo;
/**
* 修订版()
*/
@ApiModelProperty(value = "修订版(旧)")
private String versionOld;
/**
* 修订版()
*/
@ApiModelProperty(value = "修订版(新)")
private String versionNew;
/**
* 名称
*/
@ApiModelProperty(value = "名称")
private String materialName;
/**
* 图号
*/
@ApiModelProperty(value = "图号")
private String drawingNo;
/**
* 设计人员
*/
@ApiModelProperty(value = "设计人员")
private String deviseName;
/**
* 设计人员部门
*/
@ApiModelProperty(value = "设计人员部门")
private String deptName;
/**
* 关联物料编码
*/
@ApiModelProperty(value = "关联物料编码")
private String relMaterialNo;
/**
* 关联物料描述
*/
@ApiModelProperty(value = "关联物料描述")
private String relMaterialDesc;
/**
* 状态0-未升级处理 1-已升级处理
*/
@ApiModelProperty(value = "状态0-未升级处理 1-已升级处理")
private Integer status;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private LocalDateTime updatedTime;
private static final long serialVersionUID = 1L;
}

View File

@ -201,6 +201,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/**
* 获取变更影响
* @param query
* @return
*/
public Page<BomNewEbomUpgradeChangeVO> getUpgradeChangeList(BomNewEbomParentQuery query) {
Page<BomNewEbomUpgradeChangeVO> result = this.getBaseMapper().getUpgradeChangeList(new Page<>(query.getPage(), query.getPageSize()), query);
return result;
}
/** /**
* 获取子级 * 获取子级
* *
@ -248,6 +262,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
} }
} }
//初始化错误
initBomException(parentChild);
return parentChild; return parentChild;
} }
@ -446,11 +462,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId)); BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId); List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
parent.setBomRowId(parent.getRowId());
EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes()); parent.setChildBomRowId(parent.getRowId());
parent.setParentRowId(0L);
bomTree.add(parent);
EBomToPBom eBomToPBom = new EBomToPBom(parent, bomTree, paramDto.getFacCodes(),0L);
eBomToPBom.convert(); eBomToPBom.convert();
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
pBomParentService.saveOrUpdateBatch(eBomToPBom.getPBomParentResult()); pBomParentService.saveOrUpdateBatch(eBomToPBom.getPBomParentResult());
} }
if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) { if (CollUtil.isNotEmpty(eBomToPBom.getPBomChildResult())) {
pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult()); pBomChildService.saveOrUpdateBatch(eBomToPBom.getPBomChildResult());
@ -461,6 +482,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())){ if(CollUtil.isNotEmpty(eBomToPBom.getUpgradeChangeResult())){
upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult()); upgradeChangeService.saveOrUpdateBatch(eBomToPBom.getUpgradeChangeResult());
}; };
if(CollUtil.isNotEmpty(eBomToPBom.getHasConvertEBomRowIds())){
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(),eBomToPBom.getHasConvertEBomRowIds());
}
} }

View File

@ -5,6 +5,8 @@ import com.nflg.product.bomnew.mapper.master.BomNewEbomUpgradeChangeMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* t_bom_new_ebom_upgrade_change 表服务实现类 * t_bom_new_ebom_upgrade_change 表服务实现类
@ -16,4 +18,25 @@ import org.springframework.stereotype.Service;
@Service @Service
public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgradeChangeMapper, BomNewEbomUpgradeChangeEntity> { public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgradeChangeMapper, BomNewEbomUpgradeChangeEntity> {
/**
* 删除
*/
public void delChangeImpact(List<Long> rowIds){
this.getBaseMapper().deleteBatchIds(rowIds);
}
/**
* 更新版本
*/
public void updateChangeImpactVersion(List<Long> rowIds){
List<BomNewEbomUpgradeChangeEntity> upList = this.getBaseMapper().selectBatchIds(rowIds);
//
}
} }

View File

@ -8,6 +8,7 @@ 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.nflg.product.base.core.config.SpringContextUtils; import com.nflg.product.base.core.config.SpringContextUtils;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.OriginalConstant; import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum; import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
import com.nflg.product.bomnew.constant.OriginalSourceEnum; import com.nflg.product.bomnew.constant.OriginalSourceEnum;
@ -99,22 +100,22 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
* @param bom * @param bom
* @return * @return
*/ */
public Boolean saveBom(OriginalSaveBomDTO bom ,Boolean submitIs) { public Boolean saveBom(OriginalSaveBomDTO bom, Boolean submitIs) {
List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList()); List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList());
List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts); List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts);
// originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId())); // originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId()));
childEntities.forEach(u -> { childEntities.forEach(u -> {
u.setParentRowId(bom.getParentRowId()); u.setParentRowId(bom.getParentRowId());
if(submitIs){ if (submitIs) {
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue()); u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
} }
}); });
if (CollUtil.isNotEmpty(childEntities)) { if (CollUtil.isNotEmpty(childEntities)) {
//删除行 //删除行
List<Long> delRowIds = bom.getBomList().stream().filter(u->u.getRowId()>0).map(u-> u.getRowId()).collect(Collectors.toList()); List<Long> delRowIds = bom.getBomList().stream().filter(u -> u.getRowId() > 0).map(u -> u.getRowId()).collect(Collectors.toList());
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds,bom.getParentRowId()); originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId());
originalChildService.saveOrUpdateBatch(childEntities); originalChildService.saveOrUpdateBatch(childEntities);
} }
return true; return true;
@ -128,7 +129,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
* @return * @return
*/ */
public Boolean saveSubmit(OriginalSaveBomDTO bom) { public Boolean saveSubmit(OriginalSaveBomDTO bom) {
saveBom(bom,true); saveBom(bom, true);
//将状态变为已处理 //将状态变为已处理
BomNewOriginalParentEntity parentEntity = new BomNewOriginalParentEntity(); BomNewOriginalParentEntity parentEntity = new BomNewOriginalParentEntity();
parentEntity.setRowId(bom.getParentRowId()); parentEntity.setRowId(bom.getParentRowId());
@ -161,13 +162,13 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
child.setStatus(parentEntity.getStatus()); child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName()); child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode()); child.setDeviseUserCode(parentEntity.getDeviseUserCode());
// child.setCreatedBy(parentEntity.getCreatedBy()); // child.setCreatedBy(parentEntity.getCreatedBy());
// child.setCreatedTime(parentEntity.getCreatedTime()); // child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId()); child.setBomRowId(parentEntity.getRowId());
child.setLevelNum(parentEntity.getLevelNum()); child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName()); child.setDeptName(parentEntity.getDeptName());
child.setSource(parentEntity.getSource()); child.setSource(parentEntity.getSource());
if(parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT)){ if (parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT)) {
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue()); child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
} }
//非本人则为借用件 //非本人则为借用件
@ -233,7 +234,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
for (BomNewOriginalParentEntity bom : list) { for (BomNewOriginalParentEntity bom : list) {
bom.setRootIs(1); // bom.setRootIs(1);
List<BomOriginalListVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId()); List<BomOriginalListVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId());
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail); OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
detailTask.setLevelNum(1); detailTask.setLevelNum(1);
@ -284,16 +285,18 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
* 计算层级数和根节点状态 * 计算层级数和根节点状态
*/ */
public void computeLevelNumAndRootState() { public void computeLevelNumAndRootState() {
//计算树的层级数
// CompletableFuture.runAsync(() -> {
try {
this.getBaseMapper().updateRootState();
this.compucteLevelNum();
} catch (Exception e) { try {
log.info("计算层级出错:"+e.getMessage()); this.getBaseMapper().updateRootState_1();
} this.getBaseMapper().updateRootState_2();
// }); this.getBaseMapper().updateRootState_3();
this.compucteLevelNum();
} catch (Exception e) {
log.info("计算层级出错:" + e.getMessage());
}
} }
@ -310,8 +313,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
List<BomOriginalListVO> bomTree = getBomTree(bomRowId); List<BomOriginalListVO> bomTree = getBomTree(bomRowId);
//需删除的BOM //需删除的BOM
List<BomOriginalListVO> delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList()); List<BomOriginalListVO> delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 && OriginalStatusEnum.UN_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList());
List<Long> delParentRowId=new ArrayList<>(); List<Long> delParentRowId = new ArrayList<>();
for ( BomOriginalListVO bom: delBom) { for (BomOriginalListVO bom : delBom) {
delParentRowId.add(bom.getBomRowId()); delParentRowId.add(bom.getBomRowId());
} }
delParentRowId.add(bomRowId); delParentRowId.add(bomRowId);
@ -333,7 +336,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
List<BomNewOriginalParentEntity> bomNewOriginalParentEntities = this.getBaseMapper().selectBatchIds(bomRowIds); List<BomNewOriginalParentEntity> bomNewOriginalParentEntities = this.getBaseMapper().selectBatchIds(bomRowIds);
List<BomNewOriginalParentEntity> convertedBom = bomNewOriginalParentEntities.stream().filter(u -> OriginalStatusEnum.OVER_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList()); List<BomNewOriginalParentEntity> convertedBom = bomNewOriginalParentEntities.stream().filter(u -> OriginalStatusEnum.OVER_CONVERT.equalsValue(u.getStatus())).collect(Collectors.toList());
// VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM"); // VUtils.isTure(CollUtil.isNotEmpty(convertedBom)).throwMessage("所选BOM中存在已转换的BOM");
//开始转换 //开始转换
for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) { for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) {
@ -385,17 +388,16 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
/** /**
* 原始BOM导入 * 原始BOM导入
*/ */
@Transactional(rollbackFor = Exception.class)
public void importBom(MultipartFile file) throws IOException { public void importBom(MultipartFile file) throws IOException {
rowNum.set(1); rowNum.set(1);
excelContextTL.set(new ArrayList<>()); excelContextTL.set(new ArrayList<>());
String uuid = IdUtil.simpleUUID(); String uuid = IdUtil.simpleUUID();
EecExcelUtil.handlerExcel(file.getInputStream(), BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow); EecExcelUtil.handlerExcel(file.getInputStream(), BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get(); List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList()); List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空"); VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList()); List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空"); VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
// List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList()); // List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList());
// VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空"); // VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空");
@ -410,7 +412,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert(); PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert();
List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList()); List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(chileds)) { if (CollUtil.isNotEmpty(chileds)) {
int i=1; int i = 1;
for (BomNewOriginalExcelDTO ch : chileds) { for (BomNewOriginalExcelDTO ch : chileds) {
ch.setOrderNo(i); ch.setOrderNo(i);
i++; i++;
@ -430,8 +432,8 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
public static void handlerExcelRow(BomNewOriginalExcelDTO data) { public static void handlerExcelRow(BomNewOriginalExcelDTO data) {
data.setRowNum(rowNum.get()); data.setRowNum(rowNum.get());
// data.setOrderNo(data.getLevelNo()); // data.setOrderNo(data.getLevelNo());
data.setChartNo(StrUtil.trim(data.getChartNo()).replace("","(").replace("",")").replace(" ","")); data.setChartNo(StrUtil.trim(data.getChartNo()).replace("", "(").replace("", ")").replace(" ", ""));
rowNum.set(rowNum.get() + 1); rowNum.set(rowNum.get() + 1);
excelContextTL.get().add(data); excelContextTL.get().add(data);
@ -446,12 +448,12 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
String uuid = IdUtil.simpleUUID(); String uuid = IdUtil.simpleUUID();
EecExcelUtil.handlerExcel(file, BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow); EecExcelUtil.handlerExcel(file, BomNewOriginalExcelDTO.class, BomNewOriginalParentService::handlerExcelRow);
List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get(); List<BomNewOriginalExcelDTO> excelContext = excelContextTL.get();
List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u->u.getRowNum()).collect(Collectors.toList()); List<Integer> noLevelNo = excelContext.stream().filter(u -> Objects.isNull(u.getLevelNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",",noLevelNo )+"层次为空"); VUtils.isTure(CollUtil.isNotEmpty(noLevelNo)).throwMessage(StrUtil.join(",", noLevelNo) + "层次为空");
List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u->u.getRowNum()).collect(Collectors.toList()); List<Integer> noDrawingNo = excelContext.stream().filter(u -> StrUtil.isBlank(u.getChartNo())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",",noDrawingNo )+"图号为空"); VUtils.isTure(CollUtil.isNotEmpty(noDrawingNo)).throwMessage(StrUtil.join(",", noDrawingNo) + "图号为空");
List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u->u.getRowNum()).collect(Collectors.toList()); List<Integer> noNum = excelContext.stream().filter(u -> Objects.isNull(u.getQty())).map(u -> u.getRowNum()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage( StrUtil.join(",",noNum )+"数量为空"); VUtils.isTure(CollUtil.isNotEmpty(noNum)).throwMessage(StrUtil.join(",", noNum) + "数量为空");
for (BomNewOriginalExcelDTO data : excelContext) { for (BomNewOriginalExcelDTO data : excelContext) {
List<BomNewOriginalExcelDTO> parentData = excelContext.stream().filter(u -> u.getLevelNo().equals(data.getLevelNo() - 1) && u.getRowNum() < data.getRowNum()) List<BomNewOriginalExcelDTO> parentData = excelContext.stream().filter(u -> u.getLevelNo().equals(data.getLevelNo() - 1) && u.getRowNum() < data.getRowNum())
@ -464,7 +466,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert(); PlmBomToOriginalConvert convert = new PlmBomToOriginalConvert();
List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList()); List<BomNewOriginalExcelDTO> chileds = excelContext.stream().filter(u -> u.getParentKey().equals(data.getLevelNo() + "-" + data.getRowNum())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(chileds)) { if (CollUtil.isNotEmpty(chileds)) {
int i=1; int i = 1;
for (BomNewOriginalExcelDTO ch : chileds) { for (BomNewOriginalExcelDTO ch : chileds) {
ch.setOrderNo(i); ch.setOrderNo(i);
i++; i++;

View File

@ -38,6 +38,7 @@ public class CheckEBomException {
List<BomNewEbomParentVO> allBomDetail ; List<BomNewEbomParentVO> allBomDetail ;
public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException { public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId); // allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
// BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId); // BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
// BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent); // BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
@ -46,6 +47,7 @@ public class CheckEBomException {
// allBomDetail.add(convert); // allBomDetail.add(convert);
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId); allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId);
} }
/** /**

View File

@ -60,7 +60,7 @@ public class EBomDetailTask extends RecursiveTask<List<BomNewEbomParentVO>> {
BomNewEbomParentEntity ebomParentEntity = stringBomNewOriginalParentEntityMap.get(detailVO.getMaterialNo()); BomNewEbomParentEntity ebomParentEntity = stringBomNewOriginalParentEntityMap.get(detailVO.getMaterialNo());
detailVO.setChildBomRowId(ebomParentEntity.getRowId()); detailVO.setChildBomRowId(ebomParentEntity.getRowId());
detailVO.setBomRowId(ebomParentEntity.getRowId()); detailVO.setBomRowId(ebomParentEntity.getRowId());
detailVO.setCurrentVersion(ebomParentEntity.getCurrentVersion());
} }
} }

View File

@ -24,6 +24,7 @@ import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.VersionUtil; import com.nflg.product.bomnew.util.VersionUtil;
import lombok.Getter; import lombok.Getter;
import org.bouncycastle.crypto.engines.EthereumIESEngine;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -58,17 +59,20 @@ public class EBomToPBom {
@Getter @Getter
private List<BomNewEbomUpgradeChangeEntity> upgradeChangeResult = new ArrayList<>(); private List<BomNewEbomUpgradeChangeEntity> upgradeChangeResult = new ArrayList<>();
@Getter
private List<Long> hasConvertEBomRowIds=new ArrayList<>();
private Map<String, String> generateDrawingNoMap = new HashMap<>(); private Map<String, String> generateDrawingNoMap = new HashMap<>();
private Set<String> upChangeMaterialSet=new HashSet<>(); private Set<String> upChangeMaterialSet = new HashSet<>();
public EBomToPBom(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes) { public EBomToPBom(BomNewEbomParentVO inParent, List<BomNewEbomParentVO> inAllBomDetail, List<String> inFacCodes, Long parentRowId) {
this.parent = inParent; this.parent = inParent;
this.allBomDetail = inAllBomDetail; this.allBomDetail = inAllBomDetail;
this.facCodes = inFacCodes; this.facCodes = inFacCodes;
generateDrawingNo(allBomDetail, inParent.getRowId(), ""); generateDrawingNo(allBomDetail, parentRowId, "");
} }
@ -83,6 +87,7 @@ public class EBomToPBom {
List<BomNewEbomParentVO> parentList = result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()); List<BomNewEbomParentVO> parentList = result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
for (String facCode : facCodes) { for (String facCode : facCodes) {
//buildPBomParent(parent, facCode);
for (BomNewEbomParentVO vo : parentList) { for (BomNewEbomParentVO vo : parentList) {
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode); BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode);
//子级 //子级
@ -94,6 +99,7 @@ public class EBomToPBom {
childEnt.setRowId(IdWorker.getId()); childEnt.setRowId(IdWorker.getId());
childEnt.setParentRowId(parentEnt.getRowId()); childEnt.setParentRowId(parentEnt.getRowId());
childEnt.setFacCode(facCode); childEnt.setFacCode(facCode);
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
this.pBomChildResult.add(childEnt); this.pBomChildResult.add(childEnt);
} }
} }
@ -121,6 +127,7 @@ public class EBomToPBom {
.eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo()) .eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo())
.eq(BomNewPbomParentEntity::getFacCode, facCode).one(); .eq(BomNewPbomParentEntity::getFacCode, facCode).one();
this.hasConvertEBomRowIds.add(parentVo.getRowId());
if (Objects.nonNull(oldParent) && !EBomStatusEnum.PUBLISHED.equalsValue(oldParent.getStatus())) { if (Objects.nonNull(oldParent) && !EBomStatusEnum.PUBLISHED.equalsValue(oldParent.getStatus())) {
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId())); SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
oldParent.setCurrentVersion(parentVo.getCurrentVersion()); oldParent.setCurrentVersion(parentVo.getCurrentVersion());
@ -128,7 +135,7 @@ public class EBomToPBom {
return oldParent; return oldParent;
} else { } else {
BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity(); BomNewPbomParentEntity pBomParent = new BomNewPbomParentEntity();
BeanUtil.copyProperties( parentVo,pBomParent); BeanUtil.copyProperties(parentVo, pBomParent);
pBomParent.setRowId(IdWorker.getId()); pBomParent.setRowId(IdWorker.getId());
pBomParent.setLastVersionIs(1); pBomParent.setLastVersionIs(1);
pBomParent.setFacCode(facCode); pBomParent.setFacCode(facCode);
@ -155,8 +162,7 @@ public class EBomToPBom {
vo.setSourceParentMaterialNo(getParentMaterialNo(vo.getBomRowId())); vo.setSourceParentMaterialNo(getParentMaterialNo(vo.getBomRowId()));
vo.setParentRowId(lastVirtualPackage.getBomRowId()); vo.setParentRowId(lastVirtualPackage.getBomRowId());
result.add(vo); result.add(vo);
} } else { //当没找到直发包时记录到变更影响
else { //当没找到直发包时记录到变更影响
buildUpgradeChange(vo); buildUpgradeChange(vo);
} }
continue; continue;
@ -169,8 +175,7 @@ public class EBomToPBom {
vo.setSourceParentMaterialNo(getParentMaterialNo(vo.getBomRowId())); vo.setSourceParentMaterialNo(getParentMaterialNo(vo.getBomRowId()));
vo.setParentRowId(lastVirtualPackage.getBomRowId()); vo.setParentRowId(lastVirtualPackage.getBomRowId());
result.add(vo); result.add(vo);
} } else { //当没找到直发包时记录到变更影响
else { //当没找到直发包时记录到变更影响
buildUpgradeChange(vo); buildUpgradeChange(vo);
} }
continue; continue;
@ -180,35 +185,35 @@ public class EBomToPBom {
} }
//变更记录 //变更记录
private void buildUpgradeChange(BomNewEbomParentVO vo){ private void buildUpgradeChange(BomNewEbomParentVO vo) {
List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList()); List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级"); VUtils.isTure(CollUtil.isNotEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级");
List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery() List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery()
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, voParent.get(0).getMaterialNo()).list(); .eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, voParent.get(0).getMaterialNo()).list();
if(CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
if(upChangeMaterialSet.contains(voParent.get(0).getMaterialNo())){ if (upChangeMaterialSet.contains(voParent.get(0).getMaterialNo())) {
return; return;
} }
Map<String, List<BomNewEbomVirtualPackageCompositionEntity>> vMaterialMap = ListCommonUtil.listGroupMap(list, BomNewEbomVirtualPackageCompositionEntity::getParentFullPathMaterialNo); Map<String, List<BomNewEbomVirtualPackageCompositionEntity>> vMaterialMap = ListCommonUtil.listGroupMap(list, BomNewEbomVirtualPackageCompositionEntity::getParentFullPathMaterialNo);
Set<String> oldMaterialNoAndNumSet=new HashSet<>(); Set<String> oldMaterialNoAndNumSet = new HashSet<>();
for (String key: vMaterialMap.keySet()) { for (String key : vMaterialMap.keySet()) {
oldMaterialNoAndNumSet=vMaterialMap.get(key).stream().map(u->StrUtil.join("-", u.getChildMaterialNo(),u.getNum())).collect(Collectors.toSet()); oldMaterialNoAndNumSet = vMaterialMap.get(key).stream().map(u -> StrUtil.join("-", u.getChildMaterialNo(), u.getNum())).collect(Collectors.toSet());
} }
Set<String> newSet = allBomDetail.stream().filter(u -> u.getParentRowId().equals(vo.getParentRowId()) && Objects.nonNull(u.getProjectType()) && vo.getProjectType().equals(u.getProjectType())).map(u -> StrUtil.join("-", u.getMaterialNo(), u.getNum())).collect(Collectors.toSet()); Set<String> newSet = allBomDetail.stream().filter(u -> u.getParentRowId().equals(vo.getParentRowId()) && Objects.nonNull(u.getProjectType()) && vo.getProjectType().equals(u.getProjectType())).map(u -> StrUtil.join("-", u.getMaterialNo(), u.getNum())).collect(Collectors.toSet());
//bom 发生了改变-影响了虚拟包 //bom 发生了改变-影响了虚拟包
if( CollUtil.isNotEmpty(Sets.difference(oldMaterialNoAndNumSet,newSet)) || CollUtil.isNotEmpty(Sets.difference(newSet,oldMaterialNoAndNumSet)) ){ if (CollUtil.isNotEmpty(Sets.difference(oldMaterialNoAndNumSet, newSet)) || CollUtil.isNotEmpty(Sets.difference(newSet, oldMaterialNoAndNumSet))) {
upChangeMaterialSet.add(parent.getMaterialNo()); upChangeMaterialSet.add(parent.getMaterialNo());
buildUpgradeChange(list, voParent.get(0)); buildUpgradeChange(list, voParent.get(0));
} }
} }
} }
private void buildUpgradeChange(List<BomNewEbomVirtualPackageCompositionEntity> changeList,BomNewEbomParentVO parent){ private void buildUpgradeChange(List<BomNewEbomVirtualPackageCompositionEntity> changeList, BomNewEbomParentVO parent) {
List<String> vmaterialNoList= changeList.stream().map(u -> u.getVirtualPackageMaterialNo()).distinct().collect(Collectors.toList()); List<String> vmaterialNoList = changeList.stream().map(u -> u.getVirtualPackageMaterialNo()).distinct().collect(Collectors.toList());
for (String vmaterialNo: vmaterialNoList) { for (String vmaterialNo : vmaterialNoList) {
BomNewEbomUpgradeChangeEntity changeEntity=new BomNewEbomUpgradeChangeEntity(); BomNewEbomUpgradeChangeEntity changeEntity = new BomNewEbomUpgradeChangeEntity();
changeEntity.setRowId(IdWorker.getId()); changeEntity.setRowId(IdWorker.getId());
changeEntity.setMaterialNo(vmaterialNo); changeEntity.setMaterialNo(vmaterialNo);
changeEntity.setVersionOld(parent.getCurrentVersion()); changeEntity.setVersionOld(parent.getCurrentVersion());
@ -224,7 +229,6 @@ public class EBomToPBom {
} }
/** /**
* 提层汇总数量 * 提层汇总数量
* *
@ -234,16 +238,16 @@ public class EBomToPBom {
private void liftingLayerSummary(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) { private void liftingLayerSummary(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) {
BigDecimal sum = vo.getNum(); BigDecimal sum = vo.getNum();
String parentLevelNo = vo.getLevelNo().substring(0, vo.getLevelNo().length() - 2); String parentLevelNo = vo.getLevelNo().substring(0, vo.getLevelNo().length() - 2);
List<String> parentFullPathMaterialNoList=new ArrayList<>(); List<String> parentFullPathMaterialNoList = new ArrayList<>();
while (parentLevelNo.length() >= lastVirtualPackage.getLevelNo().length()) { while (parentLevelNo.length() >= lastVirtualPackage.getLevelNo().length()) {
String pNo=parentLevelNo; String pNo = parentLevelNo;
List<BomNewEbomParentVO> parentList = allBomDetail.stream().filter(u -> u.getLevelNo().equals(pNo) && !u.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName()) && List<BomNewEbomParentVO> parentList = allBomDetail.stream().filter(u -> u.getLevelNo().equals(pNo) && !u.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName()) &&
!u.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName()) && !u.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) !u.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName()) && !u.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isNotEmpty(parentList)) { if (CollUtil.isNotEmpty(parentList)) {
sum = NumberUtil.mul(sum, parentList.get(0).getNum()); sum = NumberUtil.mul(sum, parentList.get(0).getNum());
parentFullPathMaterialNoList.add(parentList.get(0).getMaterialNo()); parentFullPathMaterialNoList.add(parentList.get(0).getMaterialNo());
}else { } else {
parentFullPathMaterialNoList.add(vo.getMaterialNo()); parentFullPathMaterialNoList.add(vo.getMaterialNo());
} }
parentLevelNo = parentLevelNo.substring(0, parentLevelNo.length() - 2); parentLevelNo = parentLevelNo.substring(0, parentLevelNo.length() - 2);
@ -251,32 +255,30 @@ public class EBomToPBom {
} }
vo.setNum(sum); vo.setNum(sum);
//构建虚拟包组成 //构建虚拟包组成
buildVirtualPackageComposition(lastVirtualPackage, vo,parentFullPathMaterialNoList); buildVirtualPackageComposition(lastVirtualPackage, vo, parentFullPathMaterialNoList);
} }
private void buildVirtualPackageComposition(BomNewEbomParentVO lastVirtualPackage,BomNewEbomParentVO vo, List<String> parentFullPathMaterialNoList){ private void buildVirtualPackageComposition(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo, List<String> parentFullPathMaterialNoList) {
Collections.reverse(parentFullPathMaterialNoList); Collections.reverse(parentFullPathMaterialNoList);
String fullPath= StrUtil.join("-", parentFullPathMaterialNoList); String fullPath = StrUtil.join("-", parentFullPathMaterialNoList);
List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery() List<BomNewEbomVirtualPackageCompositionEntity> list = SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).lambdaQuery()
.eq(BomNewEbomVirtualPackageCompositionEntity::getParentFullPathMaterialNo, fullPath) .eq(BomNewEbomVirtualPackageCompositionEntity::getParentFullPathMaterialNo, fullPath)
.eq(BomNewEbomVirtualPackageCompositionEntity::getVirtualPackageMaterialNo, lastVirtualPackage.getMaterialNo()).list(); .eq(BomNewEbomVirtualPackageCompositionEntity::getVirtualPackageMaterialNo, lastVirtualPackage.getMaterialNo()).list();
//删除旧的 //删除旧的
if(CollUtil.isNotEmpty(list)){ if (CollUtil.isNotEmpty(list)) {
List<Long> delRowIds = list.stream().map(u -> u.getRowId()).collect(Collectors.toList()); List<Long> delRowIds = list.stream().map(u -> u.getRowId()).collect(Collectors.toList());
SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).getBaseMapper().deleteBatchIds(delRowIds); SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class).getBaseMapper().deleteBatchIds(delRowIds);
} }
BomNewEbomVirtualPackageCompositionEntity packageCompositionEntity=new BomNewEbomVirtualPackageCompositionEntity(); BomNewEbomVirtualPackageCompositionEntity packageCompositionEntity = new BomNewEbomVirtualPackageCompositionEntity();
packageCompositionEntity.setRowId(IdWorker.getId()); packageCompositionEntity.setRowId(IdWorker.getId());
packageCompositionEntity.setVirtualPackageMaterialNo(lastVirtualPackage.getMaterialNo()); packageCompositionEntity.setVirtualPackageMaterialNo(lastVirtualPackage.getMaterialNo());
List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId()) ).collect(Collectors.toList()); List<BomNewEbomParentVO> voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList());
VUtils.isTure(CollUtil.isEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级"); VUtils.isTure(CollUtil.isEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级");
if(voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName()) && if (voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName()) &&
!voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName()) && !voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) !voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName()) && !voParent.get(0).getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) {
{
packageCompositionEntity.setParentMaterialNo(voParent.get(0).getMaterialNo()); packageCompositionEntity.setParentMaterialNo(voParent.get(0).getMaterialNo());
} } else {
else{
packageCompositionEntity.setParentMaterialNo(vo.getMaterialNo()); packageCompositionEntity.setParentMaterialNo(vo.getMaterialNo());
} }

View File

@ -133,7 +133,7 @@ public class EbomInitProjectType {
sameLevelChild = getChilds(child.getParentRowId()); sameLevelChild = getChilds(child.getParentRowId());
sResult = sameLevelChild.stream().filter(u -> u.getMaterialCategoryCode().startsWith("2005") || u.getMaterialCategoryCode().startsWith("2006")).collect(Collectors.toList()); sResult = sameLevelChild.stream().filter(u -> u.getMaterialCategoryCode().startsWith("2005") || u.getMaterialCategoryCode().startsWith("2006")).collect(Collectors.toList());
if (CollUtil.isNotEmpty(sResult)) { if (CollUtil.isNotEmpty(sResult)) {
List<String> projectType = sResult.stream().map(u -> u.getProjectType()).distinct().collect(Collectors.toList()); List<String> projectType = sResult.stream().filter(u->StrUtil.isNotBlank(u.getProjectType())).map(u -> u.getProjectType()).distinct().collect(Collectors.toList());
if (projectType.size() == 1 && projectType.get(0).equals("Q")) { if (projectType.size() == 1 && projectType.get(0).equals("Q")) {
child.setProjectType("Q"); child.setProjectType("Q");
} }

View File

@ -0,0 +1,22 @@
package com.nflg.product.bomnew.service.domain.EBom;
import io.swagger.annotations.ApiModelProperty;
/**
* 更新-变更影响版本
*/
public class UpdateChangeVersion {
@ApiModelProperty("变更行ID")
private Long upChangeRowId;
public UpdateChangeVersion (Long inUpChangeRowId){
this.upChangeRowId=inUpChangeRowId;
}
}

View File

@ -231,6 +231,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
eBomParent.setConvertToEbomTime(LocalDateTime.now()); eBomParent.setConvertToEbomTime(LocalDateTime.now());
eBomParent.setSourceRowId(parentEnt.getBomRowId()); eBomParent.setSourceRowId(parentEnt.getBomRowId());
eBomParent.setLastVersionIs(1); eBomParent.setLastVersionIs(1);
eBomParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
eBomParent.setModifyTime(LocalDateTime.now()); eBomParent.setModifyTime(LocalDateTime.now());
eBomParent.setBomExist(parentEnt.getBomRowId()>0?1:0); eBomParent.setBomExist(parentEnt.getBomRowId()>0?1:0);
//工艺岗直接到已复核 //工艺岗直接到已复核

View File

@ -82,12 +82,12 @@
<!--Ebom工作列表--> <!--Ebom工作列表-->
<select id="getEBomListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="getEBomListPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
<if test="job==0"> <if test="job==0">
select * ,row_id as bomRowId from t_bom_new_ebom_parent where status=1 and created_by=#{createdBy} and user_root_is=1 and select * ,row_id as bomRowId from t_bom_new_ebom_parent where created_by=#{createdBy} and user_root_is=1 and
(status=1 or status=3) (status=1 or status=3)
<include refid="whr"/> <include refid="whr"/>
</if> </if>
<if test="job==1"> <if test="job==1">
select * ,row_id as bomRowId from t_bom_new_ebom_parent where status=2 and user_root_is=1 and ( status=2 or status=4 ) select * ,row_id as bomRowId from t_bom_new_ebom_parent where user_root_is=1 and ( status=2 or status=4 )
<include refid="whr"/> <include refid="whr"/>
</if> </if>
</select> </select>
@ -119,10 +119,31 @@
<!--BOM-正式工作表--> <!--BOM-正式工作表-->
<select id="formalWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="formalWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
select row_id as bomRowId, * from t_bom_new_ebom_parent where status=4 select * , row_id as bomRowId from t_bom_new_ebom_parent where status=4
<include refid="whr"/> <include refid="whr"/>
</select> </select>
<sql id="getUpgradeChangeListWhr">
<if test="query.drawingNo!=null and query.drawingNo!=''">
and drawing_no=#{query.drawingNo}
</if>
<if test="query.materialNo!=null and query.materialNo!=''">
and material_no=#{query.materialNo}
</if>
<if test="query.deviseName!=null and query.deviseName!=''">
and devise_name=#{query.deviseName}
</if>
<if test="query.startDate!=null and query.startDate!=''">
and updated_time between #{query.startDate} and #{query.endDate}
</if>
</sql>
<!--BOM-变更影响-->
<select id="getUpgradeChangeList" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO">
select * from t_bom_new_ebom_upgrade_change where status=0
<include refid="getUpgradeChangeListWhr"/>
</select>
<!--获取子级--> <!--获取子级-->
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO"> <select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
select * select *
@ -186,6 +207,13 @@
</foreach>; </foreach>;
</delete> </delete>
<update id="updateStateBatchByRowIds">
update t_bom_new_ebom_parent set status=#{status} where row_id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper> </mapper>

View File

@ -48,7 +48,7 @@
and status=2 and status=2
<if test="query.startDate==null or query.startDate==''"> <if test="query.startDate==null or query.startDate==''">
and created_time> DATE_ADD(now(), INTERVAL -3 DAY) and convert_to_ebom_time> DATE_ADD(now(), INTERVAL -3 DAY)
</if> </if>
</if> </if>
<if test="query.status==1"> <if test="query.status==1">
@ -111,7 +111,7 @@
</delete> </delete>
<update id="updateBomState"> <update id="updateBomState">
update t_bom_new_original_parent set status = #{status} where update t_bom_new_original_parent set status = #{status},convert_to_ebom_time=now() where
row_id in row_id in
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")"> <foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
#{rowId} #{rowId}
@ -124,23 +124,27 @@
</foreach>; </foreach>;
</update> </update>
<update id="updateRootState"> <update id="updateRootState_1">
update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1; update t_bom_new_original_parent set root_is=0,user_root_is=0 where last_version_is=1
</update>
<update id="updateRootState_2">
update t_bom_new_original_parent a join ( update t_bom_new_original_parent a join (
select a.row_id from t_bom_new_original_parent a select a.row_id from t_bom_new_original_parent a
left join t_bom_new_original_child b left join t_bom_new_original_child b
on a.drawing_no=b.drawing_no on a.drawing_no=b.drawing_no
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1; where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.root_is=1
</update>
<update id="updateRootState_3">
update t_bom_new_original_parent a join ( update t_bom_new_original_parent a join (
select a.row_id from t_bom_new_original_parent a select a.row_id from t_bom_new_original_parent a
left join t_bom_new_original_child b left join t_bom_new_original_child b
on a.drawing_no=b.drawing_no and a.created_by=b.created_by on a.drawing_no=b.drawing_no and a.created_by=b.created_by
where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1; where a.last_version_is=1 and b.row_id is null ) t on a.row_id=t.row_id set a.user_root_is=1
</update> </update>
</mapper> </mapper>