操作权限相关调整
This commit is contained in:
parent
2c2c4c2cf9
commit
7845437d5b
|
|
@ -231,8 +231,8 @@ public class EbomApi extends BaseApi {
|
|||
return ResultVO.error("清除原数据或追加行数据错误");
|
||||
}
|
||||
|
||||
bomNewEbomParentService.createBomImport(dto,file.getInputStream());
|
||||
return ResultVO.success(true);
|
||||
return bomNewEbomParentService.createBomImport(dto,file.getInputStream());
|
||||
|
||||
}
|
||||
|
||||
// @PostMapping("createBom")
|
||||
|
|
@ -355,6 +355,9 @@ public class EbomApi extends BaseApi {
|
|||
@ApiOperation("暂存")
|
||||
@LogRecord(success = "Ebom-暂存,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-暂存")
|
||||
public ResultVO<BomNewEbomParentVO> temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
|
||||
|
||||
bomNewEbomParentService.deleteBomChild(dto.getDelDatas());
|
||||
return ResultVO.success(bomNewEbomParentService.temporary(dto));
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +380,7 @@ public class EbomApi extends BaseApi {
|
|||
@ApiOperation("提交")
|
||||
@LogRecord(success = "Ebom-提交,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-提交")
|
||||
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
|
||||
bomNewEbomParentService.deleteBomChild(dto.getDelDatas());
|
||||
return ResultVO.success(bomNewEbomParentService.submit(dto));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author 大米
|
||||
* @date 2023/11/11 20:09
|
||||
|
|
@ -24,4 +27,20 @@ public class EBomConstant {
|
|||
public static final String XIAN_TAO_FACTORY_CODE_1020="1020";
|
||||
|
||||
public static final String XIAN_TAO_FACTORY_Name_1020="仙桃";
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EBomExcelImportEnum implements ValueEnum<Integer> {
|
||||
|
||||
// 1- 删除 2-追加
|
||||
IMPORT_TYPE_DEL(1, "删除"),
|
||||
IMPORT_TYPE_APPEND(2, "追加");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
import com.nflg.product.bomnew.constant.EBomConstant;
|
||||
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -29,7 +30,7 @@ public class BomNewEbomImportDTO {
|
|||
|
||||
public boolean isDel(){
|
||||
if (Objects.nonNull(opType)){
|
||||
if(opType==1){
|
||||
if(opType.equals(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_DEL.getValue())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +38,7 @@ public class BomNewEbomImportDTO {
|
|||
}
|
||||
public boolean isAppend(){
|
||||
if (Objects.nonNull(opType)){
|
||||
if(opType==2){
|
||||
if(opType.equals(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_APPEND.getValue())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import cn.hutool.core.lang.TypeReference;
|
|||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
|
@ -32,6 +33,7 @@ import com.nflg.product.bomnew.service.domain.EBom.*;
|
|||
import com.nflg.product.bomnew.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -915,7 +917,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException, ExecutionException, InterruptedException {
|
||||
public ResultVO<Boolean> createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException, ExecutionException, InterruptedException {
|
||||
|
||||
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
|
||||
|
||||
|
|
@ -941,6 +943,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
parentVO.setBomRowId(parentVO.getRowId());
|
||||
parentVO.setParentRowId(0l);
|
||||
|
||||
//原始bom强制追加
|
||||
if(ObjectUtil.equal(EBomSourceEnum.FROM_BOM.getValue(),parentVO.getSource())){
|
||||
dto.setOpType(EBomConstant.EBomExcelImportEnum.IMPORT_TYPE_APPEND.getValue());
|
||||
}
|
||||
|
||||
|
||||
materialMainService.intiMaterialInfo(datas, "projectType", "materialWeight",
|
||||
"material_texture");
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
|
||||
|
|
@ -954,7 +962,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
if (dto.isDel()) {
|
||||
if ((parentVO.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|
||||
|| parentVO.getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
|
||||
deleteBom(dto.getRowId());
|
||||
// deleteBom(dto.getRowId());
|
||||
//当前bom下列表数据
|
||||
QueryWrapper<BomNewEbomChildEntity > delWrapper=new QueryWrapper<>();
|
||||
delWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId());
|
||||
SpringUtil.getBean(BomNewEbomChildService.class).getBaseMapper().delete(delWrapper);
|
||||
|
||||
}
|
||||
} else {
|
||||
//最后一个序列号
|
||||
|
|
@ -994,13 +1007,35 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
this.saveOrUpdate(eBomEdit.getParentEntity());
|
||||
}
|
||||
|
||||
|
||||
List<String> sameList=null;
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) {
|
||||
|
||||
QueryWrapper<BomNewEbomChildEntity > queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getRowId());
|
||||
List<BomNewEbomChildEntity> oldChildList= SpringUtil.getBean(BomNewEbomChildService.class).list(queryWrapper);
|
||||
|
||||
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
|
||||
|
||||
if(CollUtil.isNotEmpty(oldChildList)) {
|
||||
//追加里包含相同
|
||||
List<String> appendList = eBomEdit.childEntities.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList());
|
||||
List<String> oldList = oldChildList.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList());
|
||||
sameList = appendList.stream()
|
||||
.filter(oldList::contains)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//不要异步
|
||||
computeLevelNumAndRootState();
|
||||
// ThreadUtil.execAsync(() -> computeLevelNumAndRootState());
|
||||
|
||||
if(CollUtil.isEmpty(sameList)){
|
||||
return ResultVO.success();
|
||||
}else{
|
||||
return ResultVO.error(StrUtil.format("包含相同物料 {}",StrUtil.join(",",sameList)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1068,31 +1103,23 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
/**
|
||||
* 退回设计
|
||||
* 退回设计,不用判断角色 工艺岗才能看见已复核数据
|
||||
* 1.已发布不能退
|
||||
* 2.被工艺岗位添加的物料,不可以退回。但是可以被删除(只能是当前工艺岗位的用户创建的物料)
|
||||
*
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void revertDesign(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
|
||||
|
||||
List<Long> rowIds = dto.getRowIdList();
|
||||
|
||||
|
||||
// List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.getBaseMapper().selectBatchIds(rowIds);
|
||||
|
||||
|
||||
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
|
||||
|
||||
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
|
||||
// throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
|
||||
VUtils.isTure(true).throwMessage("下级BOM无法进行退回");
|
||||
VUtils.isTure(true).throwMessage("下级BOM无法进行退回,请选择顶层");
|
||||
}
|
||||
Set<String> materialNoAndVersion = bomNewEbomParentEntityList.stream().map(u -> StrUtil.join("-", u.getMaterialNo(), u.getCurrentVersion())).collect(Collectors.toSet());
|
||||
LogRecordContext.putVariable("log", materialNoAndVersion);
|
||||
|
||||
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
|
||||
|
||||
|
||||
VUtils.isTure(true).throwMessage("选择数据中包含有下级BOM无法进行退回");
|
||||
}
|
||||
|
||||
|
|
@ -1100,40 +1127,25 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
List<Long> revertList = new ArrayList<>();
|
||||
for (Long bomRowId :
|
||||
rowIds) {
|
||||
|
||||
List<BomNewEbomParentVO> bomTreeList = buildBomTreeContainSelf(bomRowId);
|
||||
//
|
||||
//
|
||||
//
|
||||
// List<BomNewEbomParentEntity> waitList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.WAIT_CHECK.getValue())).collect(Collectors.toList());
|
||||
// List<BomNewEbomParentEntity> revertList = bomNewEbomParentEntityList.stream().filter(item -> item.getStatus().equals(EBomStatusEnum.RETURNED.getValue())).collect(Collectors.toList());
|
||||
|
||||
List<BomNewEbomParentVO> pbomList = bomTreeList.stream().filter(item -> EBomStatusEnum.PUBLISHED.getValue().equals(item.getStatus())).collect(Collectors.toList());
|
||||
// if (CollUtil.isNotEmpty(waitList)) {
|
||||
// List<String> materialNoList = waitList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
//
|
||||
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为待复核,无法退回设计", StrUtil.join(",", materialNoList)));
|
||||
// }
|
||||
// if (CollUtil.isNotEmpty(revertList)) {
|
||||
// List<String> materialNoList = revertList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
//
|
||||
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已退回,不需要退回设计", StrUtil.join(",", materialNoList)));
|
||||
// }
|
||||
|
||||
if (CollectionUtil.isNotEmpty(pbomList)) {
|
||||
List<String> materialNoList = pbomList.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
|
||||
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编号 {} 状态为已发布PBOM,无法退回设计", StrUtil.join(",", materialNoList)));
|
||||
|
||||
}
|
||||
|
||||
//忽略叶子节点 和 工艺人员
|
||||
//忽略叶子节点 和 工艺人员
|
||||
revertList.addAll(bomTreeList.stream()
|
||||
.filter(u -> u.getBomRowId() > 0 && !Objects.equals(UserJobEnum.ENGINEER.getValue(),u.getCreatedJob()))
|
||||
.map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(revertList)) {
|
||||
//parent表状态
|
||||
UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda()
|
||||
.set(BomNewEbomParentEntity::getRevertTime, LocalDateTime.now())
|
||||
|
|
@ -1142,41 +1154,31 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
|
||||
.in(BomNewEbomParentEntity::getRowId, revertList);
|
||||
|
||||
//child 表状态
|
||||
UpdateWrapper<BomNewEbomChildEntity> childWrapper = new UpdateWrapper<>();
|
||||
childWrapper.lambda()
|
||||
.set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now())
|
||||
|
||||
.set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_CREATED.getValue())
|
||||
.in(BomNewEbomChildEntity::getParentRowId, revertList);
|
||||
|
||||
if (!this.update(updateWrapper)) {
|
||||
this.update(updateWrapper );
|
||||
if (!ebomChildService.update(childWrapper)) {
|
||||
throw new NflgBusinessException(STATE.Error, "退回设计失败");
|
||||
}
|
||||
ebomChildService.update(childWrapper);
|
||||
|
||||
|
||||
} else {
|
||||
VUtils.isTure(true).throwMessage("没有需要退回设计的物料");
|
||||
}
|
||||
|
||||
//重新创建保存list 避免污染
|
||||
// List<BomNewEbomParentEntity> updateList = new ArrayList<>();
|
||||
// for (Long rowId : revertList) {
|
||||
// BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
|
||||
// entity.setRowId(rowId);
|
||||
// entity.setStatus(EBomStatusEnum.RETURNED.getValue());
|
||||
// entity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
// entity.setRevertTime(LocalDateTime.now());
|
||||
// entity.setRevertUserName(dto.getRevertUserName());
|
||||
// updateList.add(entity);
|
||||
// }
|
||||
//
|
||||
// if (!this.updateBatchById(updateList)) {
|
||||
// throw new NflgBusinessException(STATE.Error, "退回设计失败");
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设计复核
|
||||
*设计人员只可以复核自己的物料,如果存在引用其他用户创建的物料时,不可以改变被引用物料的审核状态。
|
||||
* 异常检查:
|
||||
* 1. 是否存在空物料编号、空数量的数据信息;
|
||||
* 2. 是否存在在主数据平台的物料信息没有的数据;
|
||||
* 3. 同一层级是否存在相同的物料编码数据;
|
||||
|
|
@ -1184,7 +1186,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
* 5. 项目类别是否填写正确(项目类别请参照“项目类别自动赋值”规则);
|
||||
* 6. 是否存在“已冻结/永久禁用”的物料;
|
||||
*/
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean designReview(BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
|
||||
|
||||
List<Long> rowIds = dto.getRowIdList();
|
||||
|
|
@ -1192,10 +1194,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
|
||||
|
||||
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
|
||||
|
||||
// return ResultVO.error("下级BOM无法进行复核");
|
||||
VUtils.isTure(true).throwMessage("下级BOM无法进行复核");
|
||||
VUtils.isTure(true).throwMessage("下级BOM无法进行复核,请选择顶层");
|
||||
}
|
||||
|
||||
//检查顶级bom是否是设计自己
|
||||
List<BomNewEbomParentEntity> checkList=bomNewEbomParentEntityList.stream().filter(u->!u.getCreatedBy().equals(SessionUtil.getUserCode())).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(checkList)) {
|
||||
String checkListMaterialNo=StrUtil.join(",",checkList.stream().map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList()));
|
||||
VUtils.isTure(true).throwMessage(StrUtil.format("{} 该节点不属于你,你无权复核",checkListMaterialNo));
|
||||
}
|
||||
|
||||
|
||||
Set<String> materialNoAndVersion = bomNewEbomParentEntityList.stream().map(u -> StrUtil.join("-", u.getMaterialNo(), u.getCurrentVersion())).collect(Collectors.toSet());
|
||||
LogRecordContext.putVariable("log", materialNoAndVersion);
|
||||
|
||||
|
|
@ -1204,6 +1214,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
// return ResultVO.error("数据中包含有下级BOM无法进行复核");
|
||||
}
|
||||
|
||||
//异常检查范围
|
||||
List<Integer> checkStatus = CollectionUtil.toList(new Integer[]{
|
||||
EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(),
|
||||
EBomExceptionStatusEnum.EXCEPT_NO_3.getValue(),
|
||||
|
|
@ -1224,7 +1235,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
checkEBomException.initException();
|
||||
//错误状态包含在checkStatus内有异常抛出
|
||||
checkEBomException.checkContainExcept(checkStatus);
|
||||
//筛选bomRowId()>0 说明有bom,更新只到parent这层,无bom不需要更新
|
||||
//筛选bomRowId()>0 说明有bom,更新到parent这层,无bom不需要更新
|
||||
//设计人员只可以复核自己的物料,如果存在引用其他用户创建的物料时,不可以改变被引用物料的审核状态。
|
||||
updateReviewIdList.addAll(checkEBomException.getAllBomDetail().stream()
|
||||
.filter(u -> u.getBomRowId() > 0
|
||||
|
|
@ -1234,8 +1245,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
//改变复核状态
|
||||
|
||||
if (CollectionUtil.isNotEmpty(updateReviewIdList)) {
|
||||
//parent表状态变更
|
||||
UpdateWrapper<BomNewEbomParentEntity> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda()
|
||||
.set(BomNewEbomParentEntity::getAuditTime, LocalDateTime.now())
|
||||
|
|
@ -1244,33 +1255,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.set(BomNewEbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
|
||||
.in(BomNewEbomParentEntity::getRowId, updateReviewIdList);
|
||||
|
||||
//child表状态变更
|
||||
UpdateWrapper<BomNewEbomChildEntity> childWrapper = new UpdateWrapper<>();
|
||||
childWrapper.lambda()
|
||||
.set(BomNewEbomChildEntity::getModifyTime, LocalDateTime.now())
|
||||
|
||||
.set(BomNewEbomChildEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
|
||||
.in(BomNewEbomChildEntity::getParentRowId, updateReviewIdList);
|
||||
|
||||
if (!this.update(updateWrapper)) {
|
||||
|
||||
this.update(updateWrapper);
|
||||
if (!ebomChildService.update(childWrapper)) {
|
||||
throw new NflgBusinessException(STATE.Error, "复核失败");
|
||||
}
|
||||
ebomChildService.update(childWrapper);
|
||||
|
||||
}
|
||||
// List<BomNewEbomParentEntity> updateReviewList = new ArrayList<>();
|
||||
// for (Long id : updateReviewIdList) {
|
||||
// BomNewEbomParentEntity entity = new BomNewEbomParentEntity();
|
||||
// entity.setRowId(id);
|
||||
// entity.setAuditTime(LocalDateTime.now());
|
||||
// entity.setAuditUserName(dto.getRevertUserName());
|
||||
// entity.setStatus(EBomStatusEnum.CHECKED.getValue());
|
||||
// entity.setEditStatus(EbomEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
// updateReviewList.add(entity);
|
||||
// }
|
||||
//
|
||||
// if (!this.updateBatchById(updateReviewList)) {
|
||||
// throw new NflgBusinessException(STATE.Error, "复核失败");
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1283,9 +1280,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto) {
|
||||
|
||||
|
||||
|
||||
List<Long> rowIdList = dto.getRowIdList().stream().map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getRowId).collect(Collectors.toList());
|
||||
List<Long> bomRowIdList = dto.getRowIdList().stream().filter(u -> u.getBomRowId() > 0).map(BomNewEbomProjectTypeDTO.BomNewEbomChangeProjectType::getBomRowId).collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
|
||||
// if (CollectionUtil.isNotEmpty(bomRowIdList)) {
|
||||
// UpdateWrapper<BomNewEbomParentEntity> parentUpdate = new UpdateWrapper<>();
|
||||
// parentUpdate.lambda()
|
||||
|
|
@ -1473,15 +1474,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
|
||||
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
|
||||
QueryWrapper<BomNewEbomParentEntity> queryWrapper=new QueryWrapper<>();
|
||||
|
||||
queryWrapper.lambda() .eq(BomNewEbomParentEntity::getRowId, bomRowId)
|
||||
.eq(BomNewEbomParentEntity::getRootIs, 1);
|
||||
|
||||
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectOne(queryWrapper);
|
||||
|
||||
LogRecordContext.putVariable("bom", parentEntity);
|
||||
|
||||
VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确");
|
||||
|
||||
//设计人员只能删自己
|
||||
if (userRoleService.designer()) {
|
||||
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
|
||||
}
|
||||
checkUserRoleAuth(parentEntity.getCreatedBy());
|
||||
// if (userRoleService.designer()) {
|
||||
// VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
|
||||
// }
|
||||
|
||||
EBomDel eBomDel = new EBomDel(bomRowId);
|
||||
eBomDel.classifyBom();
|
||||
|
|
@ -1538,6 +1546,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
void checkUserRoleAuth(String bomCreatedBy){
|
||||
//1.设计岗操作自己数据
|
||||
//2.工艺人员可以修改自己创建的或是已通过“设计复核”的数据,工艺岗能看见设计岗数据必定是已复核或双角色岗(设计+工艺)
|
||||
if(!SpringUtil.getBean(UserRoleService.class).technician()){
|
||||
if(!bomCreatedBy.equals(SessionUtil.getUserCode())){
|
||||
VUtils.isTure(true).throwMessage("该节点不属于你,你无权操作");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂存
|
||||
* <p>
|
||||
|
|
@ -1548,9 +1568,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
public BomNewEbomParentVO temporary(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
deleteBomChild(dto.getDelDatas());
|
||||
}
|
||||
checkUserRoleAuth(dto.getParent().getCreatedBy());
|
||||
|
||||
|
||||
|
||||
//暂存数据为空后面不处理
|
||||
if (CollUtil.isEmpty(dto.getDatas())) {
|
||||
|
|
@ -1563,11 +1583,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
eBomEdit.handleBom(dto);
|
||||
|
||||
|
||||
if (dto.getParent() != null) {
|
||||
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
deleteBomChild(dto.getDelDatas());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (eBomEdit.getParentEntity() != null) {
|
||||
this.saveOrUpdate(eBomEdit.getParentEntity());
|
||||
|
|
@ -1598,11 +1614,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean submit(BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
|
||||
checkUserRoleAuth(dto.getParent().getCreatedBy());
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(dto.getDelDatas())) {
|
||||
deleteBomChild(dto.getDelDatas());
|
||||
}
|
||||
|
||||
//无提交数据后面不处理
|
||||
if (CollUtil.isEmpty(dto.getDatas())) {
|
||||
|
|
@ -1666,46 +1680,69 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
* 从原始Bom导入的数据,数据没有异常的情况下,用户不可以删除;
|
||||
* 用户可以直接删除,用户单击暂存或是提交时才会保存至数据库。
|
||||
*/
|
||||
private void deleteBomChild(List<BomNewEbomParentVO> delList) {
|
||||
public void deleteBomChild(List<BomNewEbomParentVO> delList) {
|
||||
|
||||
if (CollectionUtil.isEmpty(delList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<BomNewEbomParentVO> delTagList = new ArrayList<>();
|
||||
QueryWrapper<BomNewEbomChildEntity> queryChildWrapper=new QueryWrapper<>();
|
||||
queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,delList.stream().map(BomNewEbomParentVO::getRowId));
|
||||
List<BomNewEbomChildEntity> delChildList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
|
||||
|
||||
List<BomNewEbomParentVO> okList = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
|
||||
|
||||
List<BomNewEbomChildEntity> delTagList = new ArrayList<>();
|
||||
|
||||
//检查原始bom里过来数据是否包含正常数据
|
||||
List<BomNewEbomChildEntity> check1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
&& Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(okList)) {
|
||||
throw new NflgBusinessException(STATE.Error, "从原始Bom导入的数据,数据没有异常的情况下,不可以删除");
|
||||
if (CollUtil.isNotEmpty(check1List)) {
|
||||
throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以删除 ",StrUtil.join(",", check1List.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()) )));
|
||||
}
|
||||
|
||||
//检查有bom数据关系是否可以删?
|
||||
// List<BomNewEbomParentVO> check2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
// && u.getBomRowId()>0).collect(Collectors.toList());
|
||||
//
|
||||
// if (CollUtil.isNotEmpty(check2List)) {
|
||||
// throw new NflgBusinessException(STATE.Error,StrUtil.format("原始Bom导入有Bom,{} 不可以删除,请退回重新处理 ",String.join(",", check2List.stream().map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList()) )));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//原始bom不正常
|
||||
List<BomNewEbomParentVO> s1List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
List<BomNewEbomChildEntity> s1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
&& !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(s1List)) {
|
||||
delTagList.addAll(s1List);
|
||||
}
|
||||
|
||||
//手动创建
|
||||
List<BomNewEbomParentVO> s2List = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource())
|
||||
List<BomNewEbomChildEntity> s2List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource())
|
||||
|| Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())).collect(Collectors.toList());
|
||||
|
||||
//工艺岗可以删自己的和设计岗(手动、excel),
|
||||
// 设计自己删除自己
|
||||
//工艺岗用户1 可以删工艺岗用户2 的数据?
|
||||
if (CollectionUtil.isNotEmpty(s2List)) {
|
||||
delTagList.addAll(s2List);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(delTagList)) {
|
||||
List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(rowIdList)) {
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
for (BomNewEbomChildEntity vo:
|
||||
s2List) {
|
||||
if( userRoleService.technician() ){ //工艺岗可删
|
||||
delTagList.add(vo);
|
||||
}else if ( userRoleService.designer() && vo.getCreatedBy().equals(SessionUtil.getUserCode())){ //自己的数据可删
|
||||
delTagList.add(vo);
|
||||
}else{
|
||||
throw new NflgBusinessException(STATE.Error,StrUtil.format("{}数据不是你的,无权删除",vo.getMaterialNo()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(delTagList)) {
|
||||
List<Long> rowIdList = delTagList.stream().filter(u -> u.getRowId() != null || u.getRowId().longValue() > 0).map(BomNewEbomChildEntity::getRowId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(rowIdList)) {
|
||||
ebomChildService.removeByIds(rowIdList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ public class CheckEBomException {
|
|||
allBomDetail) {
|
||||
//并集 寻找相同
|
||||
List<Integer> list = CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());
|
||||
;
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,10 @@ public class EBomDel {
|
|||
|
||||
|
||||
|
||||
//设计人员 自己创建的直接删除
|
||||
|
||||
//工艺岗位角色的时候,只能删除自己在EBOM中创建的数据
|
||||
//设计人员在Ebom中创建的数据 工艺人员可以删除?
|
||||
//设计人员: 自己创建的直接删除
|
||||
//工艺岗位,只能删除自己在EBOM中创建的数据
|
||||
// 原始bom导入过来的只能 设计人员自己删,工艺不能删
|
||||
//设计人员在Ebom中创建的数据 工艺人员可以删除?
|
||||
if(roleList.contains(EBomConstant.DESIGNER)){
|
||||
delEBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0
|
||||
&& u.getCreatedBy().equals(SessionUtil.getUserCode())
|
||||
|
|
@ -53,7 +52,7 @@ public class EBomDel {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//工艺 删除自己和设计人员的
|
||||
//工艺 删除自己和设计人员的数据只能是excel和手动录入
|
||||
if(roleList.contains(EBomConstant.TECHNICIAN)){
|
||||
delEBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0
|
||||
&&( u.getCreatedJob().equals(UserJobEnum.DESIGNER.getValue())||u.getCreatedBy().equals(SessionUtil.getUserCode()))
|
||||
|
|
@ -62,7 +61,7 @@ public class EBomDel {
|
|||
}
|
||||
|
||||
|
||||
//借用件不能删除,原始bom转换只能自己
|
||||
//借用件不能删除,原始bom转换只能删自己
|
||||
if(roleList.contains(EBomConstant.DESIGNER)){
|
||||
revertOBom = bomTreeAll.stream().filter(u -> u.getBomRowId() > 0
|
||||
&& (u.getSource().equals(EBomSourceEnum.FROM_BOM.getValue())
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
|
@ -19,14 +19,14 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
|||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomChildService;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.UserRoleService;
|
||||
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import lombok.Getter;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import org.ttzero.excel.reader.Col;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -68,7 +68,7 @@ public class EBomEdit {
|
|||
parent.setCurrentVersion("A00");
|
||||
parent.setDeviseName(SessionUtil.getRealName());
|
||||
parent.setDeptName(SessionUtil.getDepartName());
|
||||
parent.setSourceRowId(0l);
|
||||
parent.setSourceRowId(0L);
|
||||
parent.setSource(source);
|
||||
parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
parent.setNum(new BigDecimal(1));
|
||||
|
|
@ -178,7 +178,7 @@ public class EBomEdit {
|
|||
child.setSource(source);
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
child.setCreatedBy(SessionUtil.getUserCode());
|
||||
child.setSourceRowId(0l);
|
||||
child.setSourceRowId(0L);
|
||||
child.setParentRowId(parentEntity.getRowId());
|
||||
if(StrUtil.isEmpty(child.getOrderNumber())){
|
||||
child.setOrderNumber("00");
|
||||
|
|
@ -237,6 +237,37 @@ public class EBomEdit {
|
|||
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
|
||||
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料主数据中不存在");
|
||||
|
||||
|
||||
//检查数据是否可修改
|
||||
List<BomNewEbomParentVO> notNullRowIdList= dto.getDatas().stream().filter(u->u.getRowId()!=null && u.getRowId()>0).collect(Collectors.toList());
|
||||
Map<Long,BomNewEbomParentVO> mapList= ListCommonUtil.listToMap(notNullRowIdList,BomNewEbomParentVO::getRowId);
|
||||
|
||||
|
||||
QueryWrapper<BomNewEbomChildEntity> queryChildWrapper=new QueryWrapper<>();
|
||||
List<Long> rowIds=notNullRowIdList.stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
|
||||
queryChildWrapper.lambda().in(BomNewEbomChildEntity::getRowId,rowIds);
|
||||
List<BomNewEbomChildEntity> childList=SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
|
||||
|
||||
// 数据不存在异常的情况下,数据是不能被修改
|
||||
List<BomNewEbomChildEntity> check1List = childList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
|
||||
&& Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
|
||||
|
||||
for (BomNewEbomChildEntity childEntity:
|
||||
check1List ) {
|
||||
if(mapList.get(childEntity.getRowId()) ==null){
|
||||
continue;
|
||||
}
|
||||
//忽略物料编码空的
|
||||
if(ObjectUtil.isNull(childEntity.getMaterialNo())){
|
||||
continue;
|
||||
}
|
||||
|
||||
//检查物料id是否被修改,根据情况还可加入其他条件
|
||||
if(!mapList.get(childEntity.getRowId()).getMaterialNo().equals(childEntity.getMaterialNo())){
|
||||
throw new NflgBusinessException(STATE.Error,StrUtil.format("从原始Bom导入的数据,数据没有异常的情况下,{} 不可以修改 ", childEntity.getMaterialNo()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue