excel 导入调整
This commit is contained in:
parent
852ebe63b3
commit
5ac9665214
|
|
@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class BomNewEbomImportDTO {
|
||||
|
||||
|
|
@ -16,9 +18,26 @@ public class BomNewEbomImportDTO {
|
|||
@ApiModelProperty("操作类型(1:删除 2:追加)")
|
||||
private Integer opType;
|
||||
|
||||
@ApiModelProperty("忽略")
|
||||
|
||||
private Integer source= EBomSourceEnum.FROM_EXCE.getValue();
|
||||
|
||||
public boolean isDel(){
|
||||
if (Objects.nonNull(opType)){
|
||||
if(opType==1){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isAppend(){
|
||||
if (Objects.nonNull(opType)){
|
||||
if(opType==2){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -620,13 +620,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
List<String> materialNos = result.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
|
||||
CheckEBomException.checkMaterialNoInMain1(materialNos));
|
||||
CheckEBomException.checkMaterialNoInMain1(materialNos);
|
||||
EBomImportExcelCheck eBomImportExcelCheck=new EBomImportExcelCheck();
|
||||
eBomImportExcelCheck.validData(result);
|
||||
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
|
||||
}, result);
|
||||
|
||||
materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo);
|
||||
|
||||
|
||||
|
||||
materialMainService.intiMaterialInfo(datas, "projectType",
|
||||
"materialUnit");
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
|
||||
BomNewEBomParentEditDTO bomNewEBomParentEditDTO = new BomNewEBomParentEditDTO();
|
||||
bomNewEBomParentEditDTO.setParent(dto.getParent());
|
||||
|
|
@ -634,12 +638,32 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
eBomEdit.temporary(bomNewEBomParentEditDTO);
|
||||
|
||||
|
||||
|
||||
|
||||
int orderNo=1;
|
||||
if(dto.isDel()){
|
||||
if (dto.getParent().getBomRowId() > 0 && (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|
||||
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue()))) {
|
||||
|
||||
deleteBom(dto.getParent().getBomRowId());
|
||||
|
||||
}
|
||||
}else {
|
||||
QueryWrapper<BomNewEbomChildEntity > queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId,dto.getParent().getBomRowId()).last("limit 1");
|
||||
queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber);
|
||||
|
||||
BomNewEbomChildEntity entity= ebomChildService.getOne(queryWrapper);
|
||||
if(entity!=null && StrUtil.isNotEmpty(entity.getOrderNumber())){
|
||||
orderNo= Integer.parseInt(entity.getOrderNumber()) ;
|
||||
orderNo++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(BomNewEbomChildEntity childEntities:eBomEdit.childEntities){
|
||||
childEntities.setOrderNumber(OrderNoUtil.orderNo2Str(orderNo));
|
||||
orderNo++;
|
||||
}
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities);
|
||||
|
|
@ -931,15 +955,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
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<>();
|
||||
// if (CollectionUtil.isNotEmpty(bomRowIdList)) {
|
||||
// UpdateWrapper<BomNewEbomParentEntity> parentUpdate = new UpdateWrapper<>();
|
||||
// parentUpdate.lambda()
|
||||
// .set(BomNewEbomParentEntity::getProjectType, dto.getProjectType())
|
||||
// .set(BomNewEbomParentEntity::getModifyTime, LocalDateTime.now())
|
||||
// .set(BomNewEbomParentEntity::getProjectTypeInputType, ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue())
|
||||
// .in(BomNewEbomParentEntity::getRowId, bomRowIdList);
|
||||
this.update(parentUpdate);
|
||||
}
|
||||
// this.update(parentUpdate);
|
||||
// }
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(rowIdList)) {
|
||||
|
|
|
|||
|
|
@ -245,15 +245,15 @@ public class EBomEdit {
|
|||
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
|
||||
}
|
||||
|
||||
// if(StrUtil.isNotEmpty(parent.getProjectType()) && StrUtil.containsAny(parent.getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
|
||||
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
|
||||
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
|
||||
// }
|
||||
if(StrUtil.isNotEmpty(dto.getParent().getProjectType()) && StrUtil.containsAny(dto.getParent().getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
|
||||
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
|
||||
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
|
||||
}
|
||||
|
||||
// if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
|
||||
// child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
|
||||
// }
|
||||
// }
|
||||
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
|
||||
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomImportExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomChildVO;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EBomImportExcelCheck {
|
||||
|
||||
|
||||
public void validData(List<BomNewEBomImportExcelDTO> list) {
|
||||
if(CollectionUtil.isNotEmpty(list)){
|
||||
return;
|
||||
}
|
||||
int count=1;
|
||||
StringBuffer error=new StringBuffer();
|
||||
List<String> projectTypeList= ProjectTypeInputTypeEnum.ProjectTypeEnum.getAllValue();
|
||||
for(BomNewEBomImportExcelDTO dto:list){
|
||||
|
||||
if(Objects.isNull(dto.getProjectType())){
|
||||
error.append(StrUtil.format("第%行,项目类别不能为空",count));
|
||||
}else {
|
||||
if(!projectTypeList.contains(dto.getProjectType())){
|
||||
error.append(StrUtil.format("第%行,项目类别填写错误",count));
|
||||
}
|
||||
}
|
||||
|
||||
if(Objects.isNull(dto.getMaterialNo())){
|
||||
error.append(StrUtil.format("第%行,物料编码不能为空",count));
|
||||
}
|
||||
|
||||
if(Objects.isNull(dto.getNum())){
|
||||
error.append(StrUtil.format("第%行,数量不能为空",count));
|
||||
}
|
||||
|
||||
|
||||
if(Objects.isNull(dto.getNum())){
|
||||
error.append(StrUtil.format("第%行,单重不能为空",count));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(StrUtil.isNotEmpty(error.toString())){
|
||||
throw new NflgBusinessException(STATE.Error,error.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class OrderNoUtil {
|
||||
|
||||
public static String orderNo2Str(int no){
|
||||
if(no<10){
|
||||
return StrUtil.format("00{}",no);
|
||||
}
|
||||
if(no <100){
|
||||
return StrUtil.format("0{}",no);
|
||||
}
|
||||
|
||||
return StrUtil.format("{}",no);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue