This commit is contained in:
parent
881e3d61a6
commit
ce05126a7e
|
|
@ -4,6 +4,8 @@ package com.nflg.product.bomnew.api.user;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.ReverseReportVO;
|
||||
import com.nflg.product.bomnew.service.ReverseReportService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
|
|
@ -12,16 +14,20 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "BOM-报表接口")
|
||||
@RestController
|
||||
@RequestMapping("bom/new/report")
|
||||
public class BomReportApi {
|
||||
|
||||
|
||||
@Resource
|
||||
ReverseReportService reverseReportService;
|
||||
|
||||
@PostMapping("reverseReport")
|
||||
@ApiOperation("bom-反查")
|
||||
public ResultVO<Page<BomNewEbomParentVO>> reverseReport(@RequestBody ReverseReportQuery query) {
|
||||
public ResultVO<Page<ReverseReportVO>> reverseReport(@RequestBody ReverseReportQuery query) {
|
||||
return ResultVO.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public class MBomApi extends BaseApi {
|
|||
@ApiOperation("redis 测试")
|
||||
public ResultVO<Set<String>> redisTest() {
|
||||
|
||||
return ResultVO.success(redisService.test());
|
||||
return ResultVO.success();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import javax.validation.constraints.NotNull;
|
|||
public class ReverseReportQuery {
|
||||
|
||||
@ApiModelProperty("BOM 类型 0-原始BOM 1-EBom 2-PBom 3-MBom")
|
||||
@NotNull(message = "BOM类型不能为空")
|
||||
private Integer bomType;
|
||||
|
||||
@ApiModelProperty("图号")
|
||||
|
|
@ -25,6 +26,7 @@ public class ReverseReportQuery {
|
|||
private String facCode;
|
||||
|
||||
@ApiModelProperty("查询方式 0-单层 1-多层 2-汇总")
|
||||
@NotNull(message = "查询方式不能为空")
|
||||
private Integer queryType;
|
||||
|
||||
@ApiModelProperty("版本策略 0-最新版 1-全部版本")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* BOM-反查结果表
|
||||
*/
|
||||
@Data
|
||||
public class ReverseReportVO {
|
||||
|
||||
@ApiModelProperty("层级")
|
||||
private String orderNumber;
|
||||
|
||||
@ApiModelProperty("物料编码")
|
||||
private String materialNo;
|
||||
|
||||
@ApiModelProperty("版本号")
|
||||
private String currentVersion;
|
||||
|
||||
@ApiModelProperty("项目类别")
|
||||
private String projectType;
|
||||
|
||||
@ApiModelProperty("物料类别名称")
|
||||
private String materialCategoryName;
|
||||
|
||||
@ApiModelProperty("物料描述")
|
||||
private String materialDesc;
|
||||
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
@ApiModelProperty("单位")
|
||||
private String materialUnit;
|
||||
|
||||
@ApiModelProperty(value = "创建人编码")
|
||||
private String createdBy;
|
||||
|
||||
@ApiModelProperty(value = "创建时间-有效开始时间")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
|
||||
private LocalDateTime expireEndTime;
|
||||
|
||||
|
||||
public LocalDateTime getExpireEndTime(){
|
||||
return Objects.isNull(expireEndTime)? LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")):expireEndTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* BOM-反查数据处理
|
||||
*/
|
||||
@Service
|
||||
public class ReverseReportService {
|
||||
|
||||
private static String eBomIndexPrefix="EBom";
|
||||
|
||||
private static String pBomIndexPrefix="PBom";
|
||||
|
||||
Joiner joiner = Joiner.on("-").skipNulls();
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* Ebom反查索引建立 (存Redis中)
|
||||
* @param parent
|
||||
* @param bomDetail
|
||||
* key: Ebom+物料编码+bom版本 value:子级物料+子级物料BOM版本 (Set)
|
||||
*/
|
||||
public void eBomToRedis(BomNewEbomParentVO parent , List<BomNewEbomParentVO> bomDetail){
|
||||
createEBomIndex(parent,bomDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* PBom反查索引建立 (存Redis中)
|
||||
* @param parent
|
||||
* @param bomDetail
|
||||
* key: Ebom+物料编码+bom版本 value:子级物料+子级物料BOM版本 (Set)
|
||||
*/
|
||||
public void pBomToRedis(BomNewEbomParentVO parent , List<BomNewEbomParentVO> bomDetail){
|
||||
createEBomIndex(parent,bomDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bom-反查查询
|
||||
* @param queryParam
|
||||
*/
|
||||
public void query(ReverseReportQuery queryParam){
|
||||
String[] bomType={"","EBom","PBom",""};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建-EBom反查索引
|
||||
* @param parent
|
||||
* @param bomDetail
|
||||
*/
|
||||
private void createEBomIndex(BomNewEbomParentVO parent , List<BomNewEbomParentVO> bomDetail){
|
||||
List<BomNewEbomParentVO> bomParents = bomDetail.stream().filter(u -> u.getBomRowId()>0).collect(Collectors.toList());
|
||||
bomParents.add(parent);
|
||||
for (BomNewEbomParentVO parentEnt :bomParents) {
|
||||
List<BomNewEbomParentVO> parentEntChild = bomDetail.stream().filter(u -> u.getParentRowId().equals(parentEnt.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO child :parentEntChild) {
|
||||
String key= joiner.join(eBomIndexPrefix, child.getMaterialNo(),child.getCurrentVersion());
|
||||
String value=joiner.join(eBomIndexPrefix , parentEnt.getMaterialNo(),parentEnt.getCurrentVersion());
|
||||
redisService.addSet(key,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Pbom-反查索引
|
||||
* @param parent
|
||||
* @param bomDetail
|
||||
*/
|
||||
private void createPBomIndex(BomNewPbomParentVO parent , List<BomNewPbomParentVO> bomDetail){
|
||||
List<BomNewPbomParentVO> bomParents = bomDetail.stream().filter(u -> u.getBomRowId()>0).collect(Collectors.toList());
|
||||
bomParents.add(parent);
|
||||
for (BomNewPbomParentVO parentEnt :bomParents) {
|
||||
List<BomNewPbomParentVO> parentEntChild = bomDetail.stream().filter(u -> u.getParentRowId().equals(parentEnt.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO child :parentEntChild) {
|
||||
String key= joiner.join(pBomIndexPrefix, child.getMaterialNo(),child.getCurrentVersion());
|
||||
String value=joiner.join(pBomIndexPrefix , parentEnt.getMaterialNo(),parentEnt.getCurrentVersion());
|
||||
redisService.addSet(key,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue