Merge branch 'refs/heads/feature/DM/nflg-bom-dq' into feature/DM/nflg-bom
This commit is contained in:
commit
638af508b4
|
|
@ -1,12 +1,15 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.nflg.product.bomnew.mapper.master.BomNewDQbomChildMapper;
|
import com.nflg.product.bomnew.mapper.master.BomNewDQbomChildMapper;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -16,8 +19,16 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class DQBomChildService extends ServiceImpl<BomNewDQbomChildMapper, BomNewDQbomChildEntity> {
|
public class DQBomChildService extends ServiceImpl<BomNewDQbomChildMapper, BomNewDQbomChildEntity> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DQBomParentService dQBomParentService;
|
||||||
|
|
||||||
public void deleteAllChildren(Long parentRowId) {
|
public void deleteAllChildren(Long parentRowId) {
|
||||||
this.getBaseMapper().deleteAllChildren(parentRowId);
|
this.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewDQbomChildEntity.class)
|
||||||
|
.eq(BomNewDQbomChildEntity::getParentRowId, parentRowId));
|
||||||
|
dQBomParentService.lambdaUpdate()
|
||||||
|
.set(BomNewDQbomParentEntity::getBomExist, 0)
|
||||||
|
.eq(BomNewDQbomParentEntity::getRowId, parentRowId)
|
||||||
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BomNewDQbomChildEntity> getByParentRowId(Long parentRowId) {
|
public List<BomNewDQbomChildEntity> getByParentRowId(Long parentRowId) {
|
||||||
|
|
|
||||||
|
|
@ -247,13 +247,15 @@ public class DQBomImportService {
|
||||||
.map(d -> OperationErrorMsgVO.create("第" + d.getRowNum() + "行", "编号和图号都为空"))
|
.map(d -> OperationErrorMsgVO.create("第" + d.getRowNum() + "行", "编号和图号都为空"))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
List<BaseMaterialVO> materialBaseInfos;
|
||||||
//如果编号不为空,则图号使用主物料图号
|
//如果编号不为空,则图号使用主物料图号
|
||||||
List<String> materialNos = datas.stream()
|
List<String> materialNos = datas.stream()
|
||||||
.map(DQbomExcelVO::getMaterialNo)
|
.map(DQbomExcelVO::getMaterialNo)
|
||||||
.filter(StrUtil::isNotBlank)
|
.filter(StrUtil::isNotBlank)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
|
if (CollUtil.isNotEmpty(materialNos)) {
|
||||||
|
materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
|
||||||
for (DQbomExcelVO d : datas) {
|
for (DQbomExcelVO d : datas) {
|
||||||
BaseMaterialVO vo = materialBaseInfos.stream()
|
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||||
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
|
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
|
||||||
|
|
@ -263,6 +265,7 @@ public class DQBomImportService {
|
||||||
d.setDrawingNo(vo.getDrawingNo());
|
d.setDrawingNo(vo.getDrawingNo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//如果编号为空,图号不为空,则编号使用主物料编号
|
//如果编号为空,图号不为空,则编号使用主物料编号
|
||||||
List<String> drawingNos = datas.stream()
|
List<String> drawingNos = datas.stream()
|
||||||
|
|
@ -270,6 +273,7 @@ public class DQBomImportService {
|
||||||
.map(DQbomExcelVO::getDrawingNo)
|
.map(DQbomExcelVO::getDrawingNo)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(drawingNos)) {
|
||||||
materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos);
|
materialBaseInfos = SpringUtil.getBean(MaterialMainMapper.class).getMaterialByDrawingNo(drawingNos);
|
||||||
for (DQbomExcelVO d : datas) {
|
for (DQbomExcelVO d : datas) {
|
||||||
if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) {
|
if (StrUtil.isNotBlank(d.getDrawingNo()) && StrUtil.isBlank(d.getMaterialNo())) {
|
||||||
|
|
@ -284,6 +288,7 @@ public class DQBomImportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return errorMsg;
|
return errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,10 @@ public class DQBomService {
|
||||||
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);
|
||||||
dQBomParentService.save(parent);
|
dQBomParentService.save(parent);
|
||||||
query.getParent().setBomRowId(parent.getRowId());
|
BomNewDQbomVO pvo = Convert.convert(BomNewDQbomVO.class, parent);
|
||||||
|
pvo.setBomRowId(parent.getRowId());
|
||||||
|
query.setParent(pvo);
|
||||||
|
//query.getParent().setBomRowId(parent.getRowId());
|
||||||
} else {
|
} else {
|
||||||
//删除所有子级关系
|
//删除所有子级关系
|
||||||
dQBomChildService.deleteAllChildren(query.getParent().getBomRowId());
|
dQBomChildService.deleteAllChildren(query.getParent().getBomRowId());
|
||||||
|
|
@ -590,13 +593,6 @@ public class DQBomService {
|
||||||
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());
|
|
||||||
cc.forEach(c -> {
|
|
||||||
c.setStatus(2);
|
|
||||||
c.setEditStatus(2);
|
|
||||||
c.setModifyTime(LocalDateTime.now());
|
|
||||||
});
|
|
||||||
children.addAll(cc);
|
|
||||||
|
|
||||||
BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||||
.orderByDesc(BomNewPbomParentEntity::getRowId)
|
.orderByDesc(BomNewPbomParentEntity::getRowId)
|
||||||
|
|
@ -608,20 +604,9 @@ public class DQBomService {
|
||||||
, parent.getCurrentVersion(), pp.getCurrentVersion()));
|
, parent.getCurrentVersion(), pp.getCurrentVersion()));
|
||||||
} else {
|
} else {
|
||||||
if (pp.getStatus() >= 4) {
|
if (pp.getStatus() >= 4) {
|
||||||
// List<BomNewDQbomVO> dqChildren = getChild(parent.getRowId());
|
|
||||||
// Set<String> pChildren = bomNewPbomChildService.lambdaQuery()
|
|
||||||
// .select(BomNewPbomChildEntity::getMaterialNo)
|
|
||||||
// .eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId())
|
|
||||||
// .list()
|
|
||||||
// .stream()
|
|
||||||
// .map(BomNewPbomChildEntity::getMaterialNo)
|
|
||||||
// .collect(Collectors.toSet());
|
|
||||||
// if (dqChildren.size() != pChildren.size()
|
|
||||||
// || !Sets.difference(dqChildren.stream().map(BomNewDQbomVO::getMaterialNo).collect(Collectors.toSet()), pChildren).isEmpty()) {
|
|
||||||
parent.setCurrentVersion(VersionUtil.getNextVersion(pp.getCurrentVersion()));
|
parent.setCurrentVersion(VersionUtil.getNextVersion(pp.getCurrentVersion()));
|
||||||
pp.setLastVersionIs(0);
|
pp.setLastVersionIs(0);
|
||||||
bomNewPbomParentService.updateById(pp);
|
bomNewPbomParentService.updateById(pp);
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
parent.setCurrentVersion(pp.getCurrentVersion());
|
parent.setCurrentVersion(pp.getCurrentVersion());
|
||||||
bomNewPbomParentService.getBaseMapper().deleteById(pp.getRowId());
|
bomNewPbomParentService.getBaseMapper().deleteById(pp.getRowId());
|
||||||
|
|
@ -633,12 +618,21 @@ public class DQBomService {
|
||||||
parent.setCurrentVersion(VersionUtil.getNextVersion(""));
|
parent.setCurrentVersion(VersionUtil.getNextVersion(""));
|
||||||
}
|
}
|
||||||
//处理子级
|
//处理子级
|
||||||
|
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
|
||||||
|
if (CollUtil.isNotEmpty(cc)) {
|
||||||
|
cc.forEach(c -> {
|
||||||
|
c.setStatus(2);
|
||||||
|
c.setEditStatus(2);
|
||||||
|
c.setModifyTime(LocalDateTime.now());
|
||||||
|
});
|
||||||
|
children.addAll(cc);
|
||||||
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()))
|
||||||
.eq(BomNewDQbomParentEntity::getStatus, 1)
|
.eq(BomNewDQbomParentEntity::getStatus, 1)
|
||||||
.list()
|
.list()
|
||||||
.forEach(p -> buildTree(p, parents, children));
|
.forEach(p -> buildTree(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;
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomNewDQbomChildMapper">
|
<mapper namespace="com.nflg.product.bomnew.mapper.master.BomNewDQbomChildMapper">
|
||||||
<delete id="deleteAllChildren">
|
|
||||||
DELETE
|
|
||||||
FROM t_bom_new_dqbom_child
|
|
||||||
WHERE parent_row_id = #{parentRowId};
|
|
||||||
UPDATE t_bom_new_dqbom_parent
|
|
||||||
SET bom_exist=0
|
|
||||||
WHERE row_id = #{parentRowId};
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<select id="getBomsByParentRowId" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
<select id="getBomsByParentRowId" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
||||||
SELECT c.*, p.row_id AS bomRowId, p.created_by AS bomCreateBy
|
SELECT c.*, p.row_id AS bomRowId, p.created_by AS bomCreateBy
|
||||||
FROM t_bom_new_dqbom_child c
|
FROM t_bom_new_dqbom_child c
|
||||||
LEFT JOIN t_bom_new_dqbom_parent p ON p.material_no = c.material_no
|
LEFT JOIN t_bom_new_dqbom_parent p ON p.material_no = c.material_no
|
||||||
WHERE c.parent_row_id = #{rowId}
|
WHERE c.parent_row_id = #{rowId};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getBom" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
<select id="getBom" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
||||||
|
|
@ -22,6 +13,6 @@
|
||||||
FROM t_bom_new_dqbom_child c
|
FROM t_bom_new_dqbom_child c
|
||||||
LEFT JOIN t_bom_new_dqbom_parent p ON p.material_no = c.material_no AND c.status = p.status
|
LEFT JOIN t_bom_new_dqbom_parent p ON p.material_no = c.material_no AND c.status = p.status
|
||||||
WHERE c.parent_row_id = #{parentRowId}
|
WHERE c.parent_row_id = #{parentRowId}
|
||||||
AND c.material_no = #{materialNo}
|
AND c.material_no = #{materialNo};
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue