feat: 电气专用bom功能
This commit is contained in:
parent
f8ede45454
commit
b1c757938b
|
|
@ -1,5 +1,7 @@
|
||||||
package com.nflg.product.bomnew.api.user;
|
package com.nflg.product.bomnew.api.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.mzt.logapi.context.LogRecordContext;
|
import com.mzt.logapi.context.LogRecordContext;
|
||||||
|
|
@ -29,6 +31,7 @@ import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -99,6 +102,12 @@ public class DQBomApi extends BaseApi {
|
||||||
@PostMapping("getPageList")
|
@PostMapping("getPageList")
|
||||||
@ApiOperation("分页查询数据")
|
@ApiOperation("分页查询数据")
|
||||||
public ResultVO<Page<BomNewDQbomVO>> getPageList(@Valid @RequestBody @NotNull BomNewDQbomPageQuery query) {
|
public ResultVO<Page<BomNewDQbomVO>> getPageList(@Valid @RequestBody @NotNull BomNewDQbomPageQuery query) {
|
||||||
|
if (query.getStatus() == 2) {
|
||||||
|
if (StrUtil.isBlank(query.getStartDate()) && StrUtil.isBlank(query.getEndDate())) {
|
||||||
|
query.setStartDate(LocalDateTimeUtil.format(LocalDateTime.now().plusDays(-2), "yyyy-MM-dd"));
|
||||||
|
query.setEndDate(LocalDateTimeUtil.format(LocalDateTime.now().plusDays(1), "yyyy-MM-dd"));
|
||||||
|
}
|
||||||
|
}
|
||||||
return ResultVO.success(dQBomService.getPageList(query));
|
return ResultVO.success(dQBomService.getPageList(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,10 +165,9 @@ public class DQBomApi extends BaseApi {
|
||||||
*/
|
*/
|
||||||
@PostMapping("exportBom")
|
@PostMapping("exportBom")
|
||||||
@ApiOperation("导出bom")
|
@ApiOperation("导出bom")
|
||||||
public ResultVO exportBom(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) throws IOException {
|
public void exportBom(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds, HttpServletResponse response) throws IOException {
|
||||||
List<DQbomExcelVO> data = dQBomService.exportBom(rootBomRowIds.get(0));
|
List<DQbomExcelVO> data = dQBomService.exportBom(rootBomRowIds.get(0));
|
||||||
EecExcelUtil.export(response, data, DQbomExcelVO.class, "专用bom正式表");
|
EecExcelUtil.export(response, data, DQbomExcelVO.class, "电气专用bom");
|
||||||
return ResultVO.success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -205,9 +213,8 @@ public class DQBomApi extends BaseApi {
|
||||||
*/
|
*/
|
||||||
@PostMapping("importToSAP")
|
@PostMapping("importToSAP")
|
||||||
@ApiOperation("导入到SAP")
|
@ApiOperation("导入到SAP")
|
||||||
public ResultVO importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
public ResultVO<Boolean> importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
||||||
dQBomService.importToSAP(rootBomRowIds.get(0));
|
return dQBomService.importToSAP(rootBomRowIds.get(0));
|
||||||
return ResultVO.success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.nflg.product.bomnew.pojo.vo;
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -93,14 +92,18 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
||||||
/**
|
/**
|
||||||
* 是否有子节点: 0-否 1-是
|
* 是否有子节点: 0-否 1-是
|
||||||
*/
|
*/
|
||||||
@TableField(value = "bom_exist")
|
|
||||||
@ApiModelProperty(value = "是否有子节点")
|
@ApiModelProperty(value = "是否有子节点")
|
||||||
private Integer bomExist;
|
private Integer bomExist;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否最新版:0-否 1-是
|
* 是否最新版:0-否 1-是
|
||||||
*/
|
*/
|
||||||
@TableField(value = "last_version_is")
|
|
||||||
@ApiModelProperty(value = "是否最新版")
|
@ApiModelProperty(value = "是否最新版")
|
||||||
private Integer lastVersionIs = 1;
|
private Integer lastVersionIs = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入SAP状态,1-未导入;3-已导入
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "导入SAP状态,1-未导入;3-已导入")
|
||||||
|
private Integer sapState;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -256,9 +256,11 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList());
|
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(materialNos)) {
|
if (CollUtil.isNotEmpty(materialNos)) {
|
||||||
List<BomNewPbomParentEntity> list = this.lambdaQuery().in(BomNewPbomParentEntity::getMaterialNo, materialNos)
|
List<BomNewPbomParentEntity> list = this.lambdaQuery().in(BomNewPbomParentEntity::getMaterialNo, materialNos)
|
||||||
.eq(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()), BomNewPbomParentEntity::getLastVersionIs, 1)
|
// .eq(PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()), BomNewPbomParentEntity::getLastVersionIs, 1)
|
||||||
.lt(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus,PBomStatusEnum.PUBLISH.getValue())
|
// .lt(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus,PBomStatusEnum.PUBLISH.getValue())
|
||||||
.eq(PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
// .eq(PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()),BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||||
|
.eq(PBomStatusEnum.PUBLISH.getValue() > parent.getStatus(), BomNewPbomParentEntity::getLastVersionIs, 1)
|
||||||
|
.gt(PBomStatusEnum.PUBLISH.getValue() <= parent.getStatus(), BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
Map<String, BomNewPbomParentEntity> bomListMap= list.parallelStream()
|
Map<String, BomNewPbomParentEntity> bomListMap= list.parallelStream()
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,10 @@ public class DQBomImportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkData(List<DQbomExcelVO> datas) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>> pcs = BOMMAP.get(SessionUtil.getUserCode());
|
Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>> pcs = BOMMAP.get(SessionUtil.getUserCode());
|
||||||
VUtils.isTure(pcs == null).throwMessage("数据已丢失,请重新导入");
|
VUtils.isTure(pcs == null).throwMessage("数据已丢失,请重新导入");
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -223,11 +224,8 @@ public class DQBomService {
|
||||||
public void save(BomNewDQbomSaveQuery query) {
|
public void save(BomNewDQbomSaveQuery query) {
|
||||||
BomNewDQbomParentEntity parent = new BomNewDQbomParentEntity();
|
BomNewDQbomParentEntity parent = new BomNewDQbomParentEntity();
|
||||||
BeanUtil.copyProperties(query.getParent(), parent);
|
BeanUtil.copyProperties(query.getParent(), parent);
|
||||||
//BomNewDQbomChildEntity child;
|
|
||||||
|
|
||||||
List<BomNewDQbomParentEntity> liParents = new ArrayList<>();
|
if (Objects.isNull(parent.getRowId()) || parent.getRowId() == 0) {
|
||||||
|
|
||||||
if (Objects.isNull(parent.getRowId())) {
|
|
||||||
//新增父级节点
|
//新增父级节点
|
||||||
BomNewDQbomParentEntity oldParent = dQBomParentService.lambdaQuery().eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
BomNewDQbomParentEntity oldParent = dQBomParentService.lambdaQuery().eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||||
.eq(BomNewDQbomParentEntity::getLastVersionIs, 1)
|
.eq(BomNewDQbomParentEntity::getLastVersionIs, 1)
|
||||||
|
|
@ -247,7 +245,7 @@ public class DQBomService {
|
||||||
parent.setCreatedName(SessionUtil.getRealName());
|
parent.setCreatedName(SessionUtil.getRealName());
|
||||||
parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||||
parent.setSource(2);
|
parent.setSource(2);
|
||||||
liParents.add(parent);
|
dQBomParentService.save(parent);
|
||||||
} else {
|
} else {
|
||||||
//修改数据
|
//修改数据
|
||||||
VUtils.isTure(!SessionUtil.getUserCode().equals(parent.getCreatedBy())).throwMessage("不能修改他人的数据");
|
VUtils.isTure(!SessionUtil.getUserCode().equals(parent.getCreatedBy())).throwMessage("不能修改他人的数据");
|
||||||
|
|
@ -257,16 +255,10 @@ public class DQBomService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//删除
|
//删除
|
||||||
// dQBomChildService.deleteNotIn(parent.getRowId(),
|
|
||||||
// query.getChildren().stream()
|
|
||||||
// .map(BomNewDQbomSaveVO::getRowId)
|
|
||||||
// .filter(d -> ObjectUtil.isNotNull(d) && d > 0L)
|
|
||||||
// .collect(Collectors.toList()));
|
|
||||||
dQBomChildService.deleteAllChildren(parent.getRowId());
|
dQBomChildService.deleteAllChildren(parent.getRowId());
|
||||||
parent.setBomExist(1);
|
parent.setBomExist(1);
|
||||||
parent.setModifyTime(LocalDateTime.now());
|
parent.setModifyTime(LocalDateTime.now());
|
||||||
|
dQBomParentService.updateById(parent);
|
||||||
//child = dQBomChildService.getById(query.getParent().getBomChildRowId());
|
|
||||||
}
|
}
|
||||||
//处理child
|
//处理child
|
||||||
List<BomNewDQbomChildEntity> children = Convert.toList(BomNewDQbomChildEntity.class, query.getChildren());
|
List<BomNewDQbomChildEntity> children = Convert.toList(BomNewDQbomChildEntity.class, query.getChildren());
|
||||||
|
|
@ -383,7 +375,7 @@ public class DQBomService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importToSAP(Long rootBomRowId) {
|
public ResultVO<Boolean> importToSAP(Long rootBomRowId) {
|
||||||
BomNewDQbomParentEntity root = dQBomParentService.getById(rootBomRowId);
|
BomNewDQbomParentEntity root = dQBomParentService.getById(rootBomRowId);
|
||||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||||
VUtils.isTure(root.getRootIs() == 0).throwMessage("请选择根节点");
|
VUtils.isTure(root.getRootIs() == 0).throwMessage("请选择根节点");
|
||||||
|
|
@ -416,6 +408,7 @@ public class DQBomService {
|
||||||
parentEntity.setSapTime(LocalDateTimeUtil.now());
|
parentEntity.setSapTime(LocalDateTimeUtil.now());
|
||||||
dQBomParentService.updateById(parentEntity);
|
dQBomParentService.updateById(parentEntity);
|
||||||
}
|
}
|
||||||
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BomDQbomEditDetailVO editDetail(Long rowId, Long bomRowId) {
|
public BomDQbomEditDetailVO editDetail(Long rowId, Long bomRowId) {
|
||||||
|
|
@ -475,7 +468,10 @@ public class DQBomService {
|
||||||
dQBomChildService.updateBatchById(children);
|
dQBomChildService.updateBatchById(children);
|
||||||
savePbomParents(parents);
|
savePbomParents(parents);
|
||||||
savePbomChildren(children, parents);
|
savePbomChildren(children, parents);
|
||||||
|
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
importToSAP(root.getRowId());
|
importToSAP(root.getRowId());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void savePbomChildren(List<BomNewDQbomChildEntity> children, List<BomNewDQbomParentEntity> parents) {
|
private void savePbomChildren(List<BomNewDQbomChildEntity> children, List<BomNewDQbomParentEntity> parents) {
|
||||||
|
|
@ -513,6 +509,8 @@ public class DQBomService {
|
||||||
p.setFacCode(FactoryCodeEnum.FACTORY_1010.getValue());
|
p.setFacCode(FactoryCodeEnum.FACTORY_1010.getValue());
|
||||||
p.setSourceRowId(p.getRowId());
|
p.setSourceRowId(p.getRowId());
|
||||||
p.setLevelNum(parents.stream().filter(ps -> Objects.equals(ps.getRowId(), p.getRowId())).findFirst().get().getLevel());
|
p.setLevelNum(parents.stream().filter(ps -> Objects.equals(ps.getRowId(), p.getRowId())).findFirst().get().getLevel());
|
||||||
|
p.setReleaseTime(LocalDateTime.now());
|
||||||
|
p.setReleaseUserName(SessionUtil.getUserName());
|
||||||
});
|
});
|
||||||
bomNewPbomParentService.saveBatch(pparents);
|
bomNewPbomParentService.saveBatch(pparents);
|
||||||
}
|
}
|
||||||
|
|
@ -520,12 +518,17 @@ public class DQBomService {
|
||||||
private void buildPbom(BomNewDQbomParentEntity parent, List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
private void buildPbom(BomNewDQbomParentEntity parent, List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||||
parent.setStatus(2);
|
parent.setStatus(2);
|
||||||
parent.setConvertToPbomTime(LocalDateTime.now());
|
parent.setConvertToPbomTime(LocalDateTime.now());
|
||||||
|
parent.setModifyTime(LocalDateTime.now());
|
||||||
parents.add(parent);
|
parents.add(parent);
|
||||||
LambdaQueryWrapper<BomNewDQbomParentEntity> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BomNewDQbomParentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo());
|
wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo());
|
||||||
wrapper.ne(BomNewDQbomParentEntity::getRowId, parent.getRowId());
|
wrapper.ne(BomNewDQbomParentEntity::getRowId, parent.getRowId());
|
||||||
dQBomParentService.getBaseMapper().delete(wrapper);
|
dQBomParentService.getBaseMapper().delete(wrapper);
|
||||||
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
|
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
|
||||||
|
cc.forEach(c -> {
|
||||||
|
c.setStatus(2);
|
||||||
|
c.setModifyTime(LocalDateTime.now());
|
||||||
|
});
|
||||||
children.addAll(cc);
|
children.addAll(cc);
|
||||||
|
|
||||||
BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||||
|
|
@ -557,6 +560,8 @@ public class DQBomService {
|
||||||
bomNewPbomChildService.getBaseMapper().delete(new LambdaQueryWrapper<BomNewPbomChildEntity>()
|
bomNewPbomChildService.getBaseMapper().delete(new LambdaQueryWrapper<BomNewPbomChildEntity>()
|
||||||
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId()));
|
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//处理子级
|
//处理子级
|
||||||
dQBomParentService.lambdaQuery()
|
dQBomParentService.lambdaQuery()
|
||||||
.in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList()))
|
.in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList()))
|
||||||
|
|
@ -564,8 +569,6 @@ public class DQBomService {
|
||||||
.list()
|
.list()
|
||||||
.forEach(p -> buildPbom(p, parents, children));
|
.forEach(p -> buildPbom(p, parents, children));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int versionCompare(String version1, String version2) {
|
private int versionCompare(String version1, String version2) {
|
||||||
if (StrUtil.isBlank(version1)) return 1;
|
if (StrUtil.isBlank(version1)) return 1;
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@
|
||||||
if(c.exception_status = 1, ifnull(p.exception_status, 1), c.exception_status) exception_status,
|
if(c.exception_status = 1, ifnull(p.exception_status, 1), c.exception_status) exception_status,
|
||||||
ifnull(p.exception_tag, c.exception_tag) exception_tag,
|
ifnull(p.exception_tag, c.exception_tag) exception_tag,
|
||||||
ifnull(p.bom_exist, 0) bom_exist,
|
ifnull(p.bom_exist, 0) bom_exist,
|
||||||
|
ifnull(p.sap_state, 1) sap_state,
|
||||||
c.*
|
c.*
|
||||||
FROM t_bom_new_dqbom_parent p
|
FROM t_bom_new_dqbom_parent p
|
||||||
RIGHT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no
|
RIGHT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue