Merge branch 'refs/heads/feature/excel-132' into dev

This commit is contained in:
曹鹏飞 2024-04-19 08:11:12 +08:00
commit 77b7b523eb
4 changed files with 198 additions and 1 deletions

View File

@ -72,7 +72,7 @@ public class EbomApi extends BaseApi {
@PostMapping("workDetailsListByPage") @PostMapping("workDetailsListByPage")
@ApiOperation("Ebom-工作明细列表") @ApiOperation("Ebom-工作明细列表")
public ResultVO<Page<BomNewEbomParentVO>> workDetailsListByPage(@RequestBody BomNewEbomParentQuery query) { public ResultVO<Page<BomNewEbomParentVO>> workDetailsListByPage(@RequestBody BomNewEbomParentQuery query) {
return ResultVO.success(bomNewEbomParentService.workDetailsListByPage(query)); return ResultVO.success(bomNewEbomParentService.workDetailsListByPageNew(query));
} }
@PostMapping("formalWorksheet") @PostMapping("formalWorksheet")

View File

@ -81,4 +81,12 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
List<BomNewEbomParentEntity> getEBomParentByMaterialNos(@Param("job") Integer job, @Param("createdBy")String createdBy, @Param("materialNos") List<String> materialNos); List<BomNewEbomParentEntity> getEBomParentByMaterialNos(@Param("job") Integer job, @Param("createdBy")String createdBy, @Param("materialNos") List<String> materialNos);
Page<BomNewEbomParentVO> workDetailsListByPageNew(Page<Object> objectPage, BomNewEbomParentQuery query, Integer userJob, String userCode);
List<BomNewEbomParentVO> getChildren(Long bomRowId, int type);
List<BomNewEbomParentVO> getBom(String materialNo, String drawingNo);
List<BomNewEbomParentVO> getVOById(Long parentRowId);
} }

View File

@ -2080,4 +2080,106 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
log.debug("resetAllBomExist"); log.debug("resetAllBomExist");
this.getBaseMapper().resetAllBomExist(); this.getBaseMapper().resetAllBomExist();
} }
public Page<BomNewEbomParentVO> workDetailsListByPageNew(BomNewEbomParentQuery query) {
if (StrUtil.isNotBlank(query.getMaterialNo()) || StrUtil.isNotBlank(query.getDrawingNo())) {
query.setPage(1L);
query.setPageSize(20L);
}
Page<BomNewEbomParentVO> result = this.getBaseMapper().workDetailsListByPageNew(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserJob(), SessionUtil.getUserCode());
if (StrUtil.isBlank(query.getMaterialNo()) && StrUtil.isBlank(query.getDrawingNo())) {
//列表搜索
return result;
}
//根据编号或图号搜索
//从顶级开始查找
List<BomNewEbomParentVO> roots = result.getRecords().stream()
.filter(r -> StrUtil.equals(r.getMaterialNo(), query.getMaterialNo()) || StrUtil.equals(r.getDrawingNo(), query.getDrawingNo()))
.collect(Collectors.toList());
roots.forEach(this::buildChildren);
//从子级开始查找
List<BomNewEbomParentVO> boms = this.getBaseMapper().getBom(query.getMaterialNo(), query.getDrawingNo());
boms.removeIf(c -> Objects.equals(c.getLastVersionIs(), 0));
boms.forEach(this::buildChildren);
roots.addAll(boms.stream().filter(b -> b.getRootIs() == 0 && b.getUserRootIs() == 0 && b.getRootIsForWaitReview() == 0).map(this::buildParent).flatMap(List::stream).collect(Collectors.toList()));
Map<String, List<BomNewEbomParentVO>> map = roots.stream().collect(Collectors.groupingBy(BaseMaterialVO::getMaterialNo));
List<BomNewEbomParentVO> results = new ArrayList<>();
map.forEach((k, v) -> {
if (v.size() == 1) {
results.add(v.get(0));
} else {
BomNewEbomParentVO f1 = v.get(0);
for (int i = 1; i < v.size(); i++) {
merge(f1, v.get(i));
}
results.add(f1);
}
});
results.sort((r1, r2) -> r1.getBomRowId() >= r2.getBomRowId() ? r1.getBomRowId() > r2.getBomRowId() ? 1 : 0 : -1);
Page<BomNewEbomParentVO> pageResult = new Page<>();
pageResult.setPages(1);
pageResult.setCurrent(1);
pageResult.setTotal(results.size());
pageResult.setRecords(results);
return pageResult;
}
private void merge(BomNewEbomParentVO v1, BomNewEbomParentVO v2) {
v1.getChildNodes().addAll(v2.getChildNodes());
}
private List<BomNewEbomParentVO> buildParent(BomNewEbomParentVO vo) {
List<BomNewEbomParentVO> parents = this.getBaseMapper().getVOById(vo.getParentRowId());
parents.removeIf(c -> 0 == c.getLastVersionIs());
if (parents.isEmpty()) {
return CollUtil.toList(vo);
} else {
List<BomNewEbomParentVO> datas = new ArrayList<>();
parents.forEach(p -> {
if (Objects.isNull(vo.getStatus())) {
vo.setStatus(p.getStatus());
vo.setCurrentVersion("A00");
vo.setDeptName(p.getDeptName());
vo.setDeviseName(p.getDeviseName());
}
if (Objects.equals(vo.getBomExist(), 0) && Objects.equals(vo.getShouldBomExist(), 1)) {
vo.setCurrentVersion("A-1");
}
p.setChildNodes(CollUtil.toList(vo));
datas.addAll(buildParent(p));
});
return datas;
}
}
private void buildChildren(BomNewEbomParentVO vo) {
if (Objects.isNull(vo.getLastVersionIs())) return;
List<BomNewEbomParentVO> children = this.getBaseMapper().getChildren(vo.getBomRowId(), 0);
//children.removeIf(c -> c.getLastVersionIs() != 1);
vo.setChildNodes(children);
children.forEach(c -> {
if (!Objects.equals(vo.getStatus(), EBomStatusEnum.PUBLISHED.getValue())
&& Objects.equals(c.getStatus(), EBomStatusEnum.PUBLISHED.getValue())) {
c.setStatus(EBomStatusEnum.BORROWED_PARTS.getValue());
}
if (Objects.isNull(c.getStatus())) {
c.setStatus(vo.getStatus());
c.setCurrentVersion("A00");
c.setDeptName(vo.getDeptName());
c.setDeviseName(vo.getDeviseName());
}
if (Objects.equals(c.getBomExist(), 0) && Objects.equals(c.getShouldBomExist(), 1)) {
c.setCurrentVersion("A-1");
}
if (c.getBomRowId() != 0 && c.getUserRootIs() == 0 && !Objects.equals(c.getStatus(), EBomStatusEnum.BORROWED_PARTS.getValue())) {
List<BomNewEbomParentVO> cc = this.getBaseMapper().getChildren(c.getBomRowId(), 0);
//cc.removeIf(ci -> ci.getLastVersionIs() != 1);
c.setChildNodes(cc);
cc.forEach(this::buildChildren);
}
});
}
} }

View File

@ -380,4 +380,91 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="workDetailsListByPageNew" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT *,row_id as bomRowId
FROM t_bom_new_ebom_parent
WHERE (root_is=1 OR ((user_root_is=1 OR root_is_for_wait_review=1) AND created_by=#{userCode}))
<if test="userJob==0">
AND status IN (1,3)
</if>
<if test="userJob==1 and query.dataType==0">
AND status=2
</if>
<if test="userJob==1 and query.dataType==1">
AND status=4
</if>
<if test="query.deviseName!=null and query.deviseName!=''">
AND devise_name=#{query.deviseName}
</if>
<if test="query.startDate!=null and query.startDate!=''">
AND created_time BETWEEN #{query.startDate} AND DATE_ADD(#{query.endDate}, INTERVAL 1 DAY)
</if>
order by row_id desc
</select>
<select id="getChildren" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT a.current_version
, a.devise_name
, a.devise_user_code
, a.dept_name
, a.source
, a.created_by
, IFNULL(a.last_version_is, 1) last_version_is
, IFNULL(a.user_root_is, 0) user_root_is
, IFNULL(a.row_id, 0) AS bomRowId
, b.*
FROM t_bom_new_ebom_child b
LEFT JOIN t_bom_new_ebom_parent a ON a.material_no = b.material_no
WHERE b.parent_row_id = #{bomRowId}
<if test="type==0">
and IFNULL(a.last_version_is, 1)!=0
</if>
<if test="type==1">
and a.status=4
</if>
ORDER BY b.order_number
</select>
<select id="getBom" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT a.current_version
, a.devise_name
, a.devise_user_code
, a.dept_name
, a.source
, a.created_by
, a.last_version_is
, IFNULL(a.user_root_is, 0) user_root_is
,ifnull(a.root_is,0) root_is
,ifnull(a.root_is_for_wait_review,0) root_is_for_wait_review
, IFNULL(a.row_id, 0) AS bomRowId
,a.`status`
, b.*
FROM t_bom_new_ebom_child b
LEFT JOIN t_bom_new_ebom_parent a ON a.material_no = b.material_no
<if test="materialNo!=null and materialNo!=''">
WHERE b.material_no = #{materialNo}
</if>
<if test="drawingNo!=null and drawingNo!=''">
WHERE b.drawingNo = #{drawingNo}
</if>
ORDER BY b.order_number
</select>
<select id="getVOById" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT IFNULL(b.exception_status, a.exception_status) exception_status
, IFNULL(b.created_by, a.created_by) created_by
, IFNULL(b.edit_status, a.edit_status) edit_status
, IFNULL(b.created_time, a.created_time) created_time
, b.exception_tag
, b.project_type
, IFNULL(b.num, a.num) num
, IFNULL(b.modify_time, a.modify_time) modify_time
, IFNULL(b.parent_row_id, 0) parent_row_id
, a.row_id bomRowId
, a.*
FROM t_bom_new_ebom_parent a
LEFT JOIN t_bom_new_ebom_child b ON a.material_no = b.material_no
WHERE a.row_id = #{parentRowId}
</select>
</mapper> </mapper>