This commit is contained in:
parent
501ff022c3
commit
b9c463f5cb
|
|
@ -36,6 +36,7 @@ import java.io.IOException;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.sql.Struct;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -186,6 +187,14 @@ public class EbomApi extends BaseApi {
|
|||
@PostMapping("createBomImport")
|
||||
@ApiOperation("创建EBOM-导入")
|
||||
public ResultVO<Boolean> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException, ExecutionException, InterruptedException {
|
||||
|
||||
if (Objects.isNull(dto.getParent())) {
|
||||
return ResultVO.error(STATE.Error, "请先保存编辑BOM列表再导入数据");
|
||||
}
|
||||
if (Objects.isNull(dto.getOpType())) {
|
||||
return ResultVO.error(STATE.Error, "请选择清除原数据或追加行");
|
||||
}
|
||||
|
||||
if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
|
||||
return ResultVO.error("请上传Excel文件");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,4 +61,6 @@ public class BaseMaterialVO {
|
|||
@ApiModelProperty("单位")
|
||||
private String materialUnit;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,13 @@ import lombok.experimental.Accessors;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_parent
|
||||
|
|
@ -118,6 +122,14 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
|
||||
private Integer bomExist;
|
||||
|
||||
|
||||
public Integer getBomExist(){
|
||||
if(Objects.isNull(bomExist)){
|
||||
bomExist=0;
|
||||
}
|
||||
return bomExist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否最新版:0-否 1-是
|
||||
*/
|
||||
|
|
@ -226,6 +238,15 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
|
||||
private LocalDateTime expireEndTime;
|
||||
|
||||
|
||||
public LocalDateTime getExpireEndTime(){
|
||||
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("9999-12-31 23:59:59");
|
||||
|
||||
return LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换pbom时间
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import cn.hutool.core.date.DateUtil;
|
|||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
|
@ -278,6 +279,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
child.setStatus(parent.getStatus());
|
||||
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -621,9 +624,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException, ExecutionException, InterruptedException {
|
||||
if (dto.getParent() == null) {
|
||||
VUtils.isTure(true).throwMessage("没选择父级不能导入");
|
||||
}
|
||||
|
||||
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
|
||||
|
||||
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
|
||||
|
|
@ -1219,19 +1220,33 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
CheckEBomException.checkMaterialNoInMain(dto.getDatas());
|
||||
|
||||
List<BomNewEbomParentVO> parentChild = dto.getDatas();
|
||||
|
||||
// materialMainService.intiMaterialInfo(parentChild);
|
||||
|
||||
List<BomNewEbomParentVO> checkBom = new ArrayList<>();
|
||||
// checkBom.add(dto.getParent());
|
||||
checkBom.addAll(dto.getDatas());
|
||||
|
||||
List<BomNewEbomParentVO> tmp1=dto.getDatas().stream().filter(item->Objects.nonNull(item.getRowId()) && item.getRowId()>0).collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> tmp2=dto.getDatas().stream().filter(item->Objects.isNull(item.getRowId()) || item.getRowId()==0).collect(Collectors.toList());
|
||||
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2);
|
||||
|
||||
String[] ignore= new String[]{
|
||||
"projectType",
|
||||
"procureType",
|
||||
"materialUnit",
|
||||
"material",
|
||||
"materialTexture",
|
||||
"materialGetType"
|
||||
};
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp1,ignore);
|
||||
|
||||
checkBom.addAll(tmp1);
|
||||
checkBom.addAll(tmp2);
|
||||
|
||||
CheckEBomException checkEBomException = new CheckEBomException(checkBom);
|
||||
checkEBomException.initException();
|
||||
checkEBomException.checkException();
|
||||
if(CollectionUtil.isNotEmpty(dto.getDatas())){
|
||||
for (BomNewEbomParentVO vo:
|
||||
dto.getDatas()) {
|
||||
if(Objects.isNull(vo.getRowId())){
|
||||
if(Objects.isNull(vo.getRowId()) ||vo.getRowId()==0 ){
|
||||
vo.setDeviseUserCode(SessionUtil.getUserCode());
|
||||
vo.setDeviseName(SessionUtil.getRealName());
|
||||
vo.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
|
@ -1240,7 +1255,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return dto.getDatas();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue