7 changed files with 226 additions and 0 deletions
-
30src/main/java/com/spring/modules/part/controller/CompleteWhereUsedController.java
-
23src/main/java/com/spring/modules/part/dto/CompleteWhereUsedQueryDto.java
-
16src/main/java/com/spring/modules/part/mapper/CompleteWhereUsedMapper.java
-
9src/main/java/com/spring/modules/part/service/CompleteWhereUsedService.java
-
38src/main/java/com/spring/modules/part/service/impl/CompleteWhereUsedServiceImpl.java
-
43src/main/java/com/spring/modules/part/vo/CompleteWhereUsedVo.java
-
67src/main/resources/mapper/part/CompleteWhereUsedMapper.xml
@ -0,0 +1,30 @@ |
|||
package com.spring.modules.part.controller; |
|||
|
|||
import com.spring.common.utils.PageUtils; |
|||
import com.spring.common.utils.R; |
|||
import com.spring.modules.part.dto.CompleteWhereUsedQueryDto; |
|||
import com.spring.modules.part.service.CompleteWhereUsedService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 完整反查:按子件或父件查询 BOM 组件引用关系 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("plm/completeWhereUsed") |
|||
public class CompleteWhereUsedController { |
|||
|
|||
@Autowired |
|||
private CompleteWhereUsedService completeWhereUsedService; |
|||
|
|||
@PostMapping("/search") |
|||
@ResponseBody |
|||
public R search(@RequestBody CompleteWhereUsedQueryDto query) { |
|||
PageUtils page = completeWhereUsedService.completeWhereUsedSearch(query); |
|||
return R.ok().put("page", page); |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.spring.modules.part.dto; |
|||
|
|||
import com.spring.common.utils.QueryPage; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 查询条件:完整反查(子件在哪些父件 BOM 中被引用) |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class CompleteWhereUsedQueryDto extends QueryPage { |
|||
|
|||
private String site; |
|||
/** 子件物料编码 */ |
|||
private String componentPart; |
|||
/** 子件描述 */ |
|||
private String componentPartDesc; |
|||
/** 子件零件类型 */ |
|||
private String componentPartType; |
|||
/** 子件零件状态 */ |
|||
private String componentPartStatus; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.spring.modules.part.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.spring.modules.part.dto.CompleteWhereUsedQueryDto; |
|||
import com.spring.modules.part.vo.CompleteWhereUsedVo; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
@Mapper |
|||
public interface CompleteWhereUsedMapper { |
|||
|
|||
IPage<CompleteWhereUsedVo> completeWhereUsedSearch( |
|||
Page<CompleteWhereUsedVo> page, |
|||
@Param("query") CompleteWhereUsedQueryDto query); |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
package com.spring.modules.part.service; |
|||
|
|||
import com.spring.common.utils.PageUtils; |
|||
import com.spring.modules.part.dto.CompleteWhereUsedQueryDto; |
|||
|
|||
public interface CompleteWhereUsedService { |
|||
|
|||
PageUtils completeWhereUsedSearch(CompleteWhereUsedQueryDto query); |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.spring.modules.part.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.spring.common.utils.PageUtils; |
|||
import com.spring.modules.part.dto.CompleteWhereUsedQueryDto; |
|||
import com.spring.modules.part.mapper.CompleteWhereUsedMapper; |
|||
import com.spring.modules.part.service.CompleteWhereUsedService; |
|||
import com.spring.modules.part.vo.CompleteWhereUsedVo; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class CompleteWhereUsedServiceImpl implements CompleteWhereUsedService { |
|||
|
|||
@Autowired |
|||
private CompleteWhereUsedMapper completeWhereUsedMapper; |
|||
|
|||
@Override |
|||
public PageUtils completeWhereUsedSearch(CompleteWhereUsedQueryDto query) { |
|||
if (query == null || StringUtils.isBlank(query.getSite())) { |
|||
throw new RuntimeException("工厂(site)不能为空"); |
|||
} |
|||
if (StringUtils.isAllBlank(query.getComponentPart(), query.getComponentPartDesc(), query.getComponentPartType(), query.getComponentPartStatus())) { |
|||
throw new RuntimeException("请至少填写一项查询条件"); |
|||
} |
|||
if (StringUtils.isNotBlank(query.getComponentPart())) { |
|||
query.setComponentPart(query.getComponentPart().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(query.getComponentPartDesc())) { |
|||
query.setComponentPartDesc(query.getComponentPartDesc().trim()); |
|||
} |
|||
IPage<CompleteWhereUsedVo> page = completeWhereUsedMapper.completeWhereUsedSearch( |
|||
new Page<>(query.getPage(), query.getLimit()), query); |
|||
return new PageUtils(page); |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.spring.modules.part.vo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 完整反查结果行,字段顺序与查询 SQL 列顺序一致。 |
|||
*/ |
|||
@Data |
|||
public class CompleteWhereUsedVo { |
|||
|
|||
private String site; |
|||
private String parentPartNo; |
|||
private String parentPartDesc; |
|||
private String parentPartType; |
|||
private String parentPartStatus; |
|||
private String parentPartStatusDesc; |
|||
private Integer engChgLevel; |
|||
private String alternativeNo; |
|||
/** plm_bom_detail.status */ |
|||
private String bomDetailStatus; |
|||
private Integer lineItemNo; |
|||
private Integer lineSequence; |
|||
private String componentPart; |
|||
private String componentPartDesc; |
|||
private String componentPartType; |
|||
private String issueType; |
|||
private String componentPartStatus; |
|||
private String componentPartStatusDesc; |
|||
private String bomType; |
|||
private Date effPhaseInDate; |
|||
private Date effPhaseOutDate; |
|||
private BigDecimal qtyPerAssembly; |
|||
private BigDecimal componentScrap; |
|||
private BigDecimal shrinkageFactor; |
|||
private Integer operationNo; |
|||
private String issueToLoc; |
|||
private String noteText; |
|||
private String consumptionItem; |
|||
private String printUnit; |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
<?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"> |
|||
<mapper namespace="com.spring.modules.part.mapper.CompleteWhereUsedMapper"> |
|||
|
|||
<select id="completeWhereUsedSearch" |
|||
parameterType="com.spring.modules.part.dto.CompleteWhereUsedQueryDto" |
|||
resultType="com.spring.modules.part.vo.CompleteWhereUsedVo"> |
|||
SELECT |
|||
pbc.site, |
|||
pbc.part_no AS parentPartNo, |
|||
p1.part_desc AS parentPartDesc, |
|||
p1.part_type AS parentPartType, |
|||
p1.part_status AS parentPartStatus, |
|||
dbo.get_part_status_name(p1.site, p1.part_status) AS parentPartStatusDesc, |
|||
pbc.eng_chg_level AS engChgLevel, |
|||
pbc.alternative_no AS alternativeNo, |
|||
pbd.status AS bomDetailStatus, |
|||
pbc.line_item_no AS lineItemNo, |
|||
pbc.line_sequence AS lineSequence, |
|||
pbc.component_part AS componentPart, |
|||
dbo.get_part_name(pbc.site, pbc.component_part) AS componentPartDesc, |
|||
p2.part_type AS componentPartType, |
|||
pbc.issue_type AS issueType, |
|||
p2.part_status AS componentPartStatus, |
|||
dbo.get_part_status_name(p2.site, p2.part_status) AS componentPartStatusDesc, |
|||
pbc.bom_type AS bomType, |
|||
pbh.EFF_PHASE_IN_DATE AS effPhaseInDate, |
|||
pbh.EFF_PHASE_OUT_DATE AS effPhaseOutDate, |
|||
pbc.qty_per_assembly AS qtyPerAssembly, |
|||
pbc.component_scrap AS componentScrap, |
|||
pbc.shrinkage_factor AS shrinkageFactor, |
|||
pbc.operation_no AS operationNo, |
|||
pbc.issue_to_loc AS issueToLoc, |
|||
pbc.note_text AS noteText, |
|||
pbc.consumption_item AS consumptionItem, |
|||
pbc.print_unit AS printUnit |
|||
FROM plm_bom_component AS pbc |
|||
LEFT JOIN part AS p1 ON pbc.site = p1.site AND pbc.part_no = p1.part_no |
|||
LEFT JOIN part AS p2 ON pbc.site = p2.site AND pbc.component_part = p2.part_no |
|||
LEFT JOIN plm_bom_detail AS pbd ON pbc.site = pbd.site AND pbc.part_no = pbd.part_no |
|||
AND pbc.eng_chg_level = pbd.eng_chg_level AND pbc.bom_type = pbd.bom_type |
|||
AND pbc.alternative_no = pbd.alternative_no |
|||
LEFT JOIN plm_bom_header AS pbh ON pbc.site = pbh.site AND pbc.part_no = pbh.part_no |
|||
AND pbc.eng_chg_level = pbh.eng_chg_level AND pbc.bom_type = pbh.bom_type |
|||
<where> |
|||
pbc.site = #{query.site} |
|||
<if test="query.componentPart != null and query.componentPart != ''"> |
|||
AND pbc.component_part = #{query.componentPart} |
|||
</if> |
|||
<if test="query.componentPartDesc != null and query.componentPartDesc != ''"> |
|||
AND dbo.get_part_name(pbc.site, pbc.component_part) LIKE #{query.componentPartDesc} |
|||
</if> |
|||
<if test="query.componentPartType != null and query.componentPartType != ''"> |
|||
AND p2.part_type = #{query.componentPartType} |
|||
</if> |
|||
<if test="query.componentPartStatus != null and query.componentPartStatus != ''"> |
|||
AND p2.part_status = #{query.componentPartStatus} |
|||
</if> |
|||
</where> |
|||
ORDER BY |
|||
pbc.part_no, |
|||
pbc.site, |
|||
pbc.eng_chg_level, |
|||
pbc.bom_type, |
|||
pbc.alternative_no |
|||
</select> |
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue