|
|
|
|
@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
|
|
|
|
import com.nflg.product.bomnew.constant.EBomConstant;
|
|
|
|
|
import com.nflg.product.bomnew.constant.MBomConstantEnum;
|
|
|
|
|
import com.nflg.product.bomnew.mapper.master.BomNewMbomDetailMapper;
|
|
|
|
|
import com.nflg.product.bomnew.pojo.entity.BomNewMbomDetailEntity;
|
|
|
|
|
@ -19,6 +20,7 @@ import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO;
|
|
|
|
|
import nflg.product.common.constant.STATE;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@ -61,6 +63,8 @@ public class BomNewMbomDetailService extends ServiceImpl<BomNewMbomDetailMapper,
|
|
|
|
|
List<BomNewMbomMiddleVO> voList = Convert.convert(new TypeReference<List<BomNewMbomMiddleVO>>() {
|
|
|
|
|
}, list);
|
|
|
|
|
|
|
|
|
|
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(voList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
|
|
|
|
|
|
|
|
|
|
return voList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -74,6 +78,7 @@ public class BomNewMbomDetailService extends ServiceImpl<BomNewMbomDetailMapper,
|
|
|
|
|
*
|
|
|
|
|
* @param rowId
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void superSaterialStatusTag(Long rowId, Integer status) {
|
|
|
|
|
|
|
|
|
|
BomNewMbomDetailEntity entity = getById(rowId);
|
|
|
|
|
@ -90,52 +95,61 @@ public class BomNewMbomDetailService extends ServiceImpl<BomNewMbomDetailMapper,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//取消超级物料标签
|
|
|
|
|
if (Objects.equals(status, MBomConstantEnum.MBomSuperMaterialStatusEnum.UN_SUPER.getValue())) {
|
|
|
|
|
BomNewMbomDetailEntity uppdateBomNewMbomDetailEntity = new BomNewMbomDetailEntity();
|
|
|
|
|
uppdateBomNewMbomDetailEntity.setSuperMaterialStatus(MBomConstantEnum.MBomSuperMaterialStatusEnum.UN_SUPER.getValue());
|
|
|
|
|
uppdateBomNewMbomDetailEntity.setModifyTime(LocalDateTime.now());
|
|
|
|
|
uppdateBomNewMbomDetailEntity.setRowId(rowId);
|
|
|
|
|
updateById(uppdateBomNewMbomDetailEntity);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// if (Objects.equals(status, MBomConstantEnum.MBomSuperMaterialStatusEnum.UN_SUPER.getValue())) {
|
|
|
|
|
// BomNewMbomDetailEntity uppdateBomNewMbomDetailEntity = new BomNewMbomDetailEntity();
|
|
|
|
|
// uppdateBomNewMbomDetailEntity.setSuperMaterialStatus(MBomConstantEnum.MBomSuperMaterialStatusEnum.UN_SUPER.getValue());
|
|
|
|
|
// uppdateBomNewMbomDetailEntity.setModifyTime(LocalDateTime.now());
|
|
|
|
|
// uppdateBomNewMbomDetailEntity.setRowId(rowId);
|
|
|
|
|
// updateById(uppdateBomNewMbomDetailEntity);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//当前数据已是超级物料
|
|
|
|
|
if (Objects.equals(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue(), entity.getSuperMaterialStatus())) {
|
|
|
|
|
throw new NflgBusinessException(STATE.Error, StrUtil.format("选择行物料{}已为超级物料", entity.getMaterialNo()));
|
|
|
|
|
}
|
|
|
|
|
// //当前数据已是超级物料
|
|
|
|
|
// if (Objects.equals(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue(), entity.getSuperMaterialStatus())) {
|
|
|
|
|
// throw new NflgBusinessException(STATE.Error, StrUtil.format("选择行物料{}已为超级物料", entity.getMaterialNo()));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //parentRowId 空情况
|
|
|
|
|
// if (Objects.isNull(entity.getParentRowId()) || entity.getParentRowId().longValue() == 0) {
|
|
|
|
|
// QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
// queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, 0l)
|
|
|
|
|
// .eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue());
|
|
|
|
|
// List<BomNewMbomDetailEntity> list = this.list(queryWrapper);
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
// throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料");
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// //check 父级为超级物料 子级才能为超级物料
|
|
|
|
|
// QueryWrapper<BomNewMbomDetailEntity> queryParentWrapper = new QueryWrapper<>();
|
|
|
|
|
// queryParentWrapper.lambda().eq(BomNewMbomDetailEntity::getRowId, entity.getParentRowId());
|
|
|
|
|
// BomNewMbomDetailEntity parentDetail = this.getOne(queryParentWrapper);
|
|
|
|
|
// if (parentDetail == null) {
|
|
|
|
|
// throw new NflgBusinessException(STATE.Error, "数据异常联系管理员");
|
|
|
|
|
// }
|
|
|
|
|
// if (!Objects.equals(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue(), parentDetail.getSuperMaterialStatus())) {
|
|
|
|
|
// throw new NflgBusinessException(STATE.Error, "父级不为超级物料,子级不能设置为超级物料");
|
|
|
|
|
// }
|
|
|
|
|
// //check 同级不能多个超级物料
|
|
|
|
|
// QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
// queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, entity.getParentRowId())
|
|
|
|
|
// .eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue());
|
|
|
|
|
// List<BomNewMbomDetailEntity> list = this.list(queryWrapper);
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
// throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//parentRowId 空情况
|
|
|
|
|
if (Objects.isNull(entity.getParentRowId()) || entity.getParentRowId().longValue() == 0) {
|
|
|
|
|
QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, 0l)
|
|
|
|
|
.eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue());
|
|
|
|
|
List<BomNewMbomDetailEntity> list = this.list(queryWrapper);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//check 父级为超级物料 子级才能为超级物料
|
|
|
|
|
QueryWrapper<BomNewMbomDetailEntity> queryParentWrapper = new QueryWrapper<>();
|
|
|
|
|
queryParentWrapper.lambda().eq(BomNewMbomDetailEntity::getRowId, entity.getParentRowId());
|
|
|
|
|
BomNewMbomDetailEntity parentDetail = this.getOne(queryParentWrapper);
|
|
|
|
|
if (parentDetail == null) {
|
|
|
|
|
throw new NflgBusinessException(STATE.Error, "数据异常联系管理员");
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.equals(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue(), parentDetail.getSuperMaterialStatus())) {
|
|
|
|
|
throw new NflgBusinessException(STATE.Error, "父级不为超级物料,子级不能设置为超级物料");
|
|
|
|
|
}
|
|
|
|
|
//check 同级不能多个超级物料
|
|
|
|
|
QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, entity.getParentRowId())
|
|
|
|
|
.eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue());
|
|
|
|
|
List<BomNewMbomDetailEntity> list = this.list(queryWrapper);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料");
|
|
|
|
|
}
|
|
|
|
|
//取消
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateWrapper<BomNewMbomDetailEntity> updateWrapper=new UpdateWrapper<>();
|
|
|
|
|
updateWrapper.lambda().set(BomNewMbomDetailEntity::getModifyTime,LocalDateTime.now());
|
|
|
|
|
updateWrapper.lambda().set(BomNewMbomDetailEntity::getSuperMaterialStatus,MBomConstantEnum.MBomSuperMaterialStatusEnum.UN_SUPER.getValue());
|
|
|
|
|
updateWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId ,entity.getParentRowId());
|
|
|
|
|
update(updateWrapper);
|
|
|
|
|
|
|
|
|
|
BomNewMbomDetailEntity uppdateBomNewMbomDetailEntity = new BomNewMbomDetailEntity();
|
|
|
|
|
uppdateBomNewMbomDetailEntity.setSuperMaterialStatus(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue());
|
|
|
|
|
uppdateBomNewMbomDetailEntity.setModifyTime(LocalDateTime.now());
|
|
|
|
|
|