Merge pull request 'nflg-bom-transition-home-msg-lhj0812' (#7) from nflg-bom-transition-home-msg-lhj0812 into feature/DM/nflg-bom-transition

Reviewed-on: http://192.168.0.40:3000/root/nflg_project/pulls/7
This commit is contained in:
10002327 2024-08-19 08:15:31 +08:00
commit 5f35756d2a
6 changed files with 244 additions and 5 deletions

View File

@ -1,15 +1,17 @@
package com.nflg.product.material.api.user.material;
import cn.hutool.core.date.DateUtil;
import cn.hutool.db.Session;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.material.config.MaterialHomeBiConfig;
import com.nflg.product.material.config.NacosConfig;
import com.nflg.product.material.constant.MaterialProcessStateEnum;
import com.nflg.product.material.constant.MaterialUpdateBillStateEnum;
import com.nflg.product.material.pojo.entity.*;
import com.nflg.product.material.pojo.vo.MaterialHomeBiVO;
import com.nflg.product.material.pojo.vo.MaterialHomeMainVO;
import com.nflg.product.material.pojo.vo.StandardPartPickRuleHomeVO;
import com.nflg.product.material.service.*;
@ -23,10 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -68,6 +67,9 @@ public class MaterialHomeApi extends BaseApi {
@Value("${material.home.day:30}")
private Integer homeDay;
@Resource
private MaterialHomeBiConfig materialHomeBiConfig;
@GetMapping("materialManagement")
@ApiOperation("物料管理")
public ResultVO<Map<String,List<MaterialHomeMainVO>>> materialManagement(){
@ -155,4 +157,12 @@ public class MaterialHomeApi extends BaseApi {
return ResultVO.success(mp);
}
@GetMapping("getBiUrlList")
@ApiOperation("获取BI地址")
public ResultVO<List<MaterialHomeBiVO>> getBiUrlList(){
return ResultVO.success(Optional.ofNullable(materialHomeBiConfig)
.map(MaterialHomeBiConfig::getList)
.map(ls -> ls.stream().sorted(Comparator.comparing(MaterialHomeBiVO::getSort)).collect(Collectors.toList())).orElse(Lists.newArrayList()));
}
}

View File

@ -0,0 +1,29 @@
package com.nflg.product.material.config;
import com.nflg.product.material.pojo.vo.MaterialHomeBiVO;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* packageName com.nflg.product.material.config
*
* @author luohj
* @className MaterialHomeBiConfig
* @date 2024/8/13 0013
* @description TODO
*/
@Component
@Data
@RefreshScope
@ConfigurationProperties(prefix = "material.home.bi")
public class MaterialHomeBiConfig {
private List<MaterialHomeBiVO> list;
}

View File

@ -0,0 +1,34 @@
package com.nflg.product.material.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* packageName com.nflg.product.material.pojo.vo
*
* @author luohj
* @className MaterialHomeBiUrlVO
* @date 2024/8/13 0013
* @description TODO
*/
@Data
@Accessors(chain = true)
@ApiModel(value="首页bi链接配置")
public class MaterialHomeBiVO {
@ApiModelProperty(value = "1iframe,2跳转")
private String type;
@ApiModelProperty(value = "链接名称")
private String name;
@ApiModelProperty(value = "链接地址")
private String url;
@ApiModelProperty(value = "排序字段")
private Integer sort;
}

View File

@ -0,0 +1,108 @@
package com.nflg.product.bomnew.api.user;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Maps;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.SapErrorMsgTypeEnum;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
import com.nflg.product.bomnew.pojo.query.BomNewLogQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewSapErrorMsgVO;
import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.service.BomNewPbomParentService;
import com.nflg.product.bomnew.service.BomNewSapErrorMsgService;
import com.nflg.product.bomnew.util.EnumUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import nflg.product.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* packageName com.nflg.product.bomnew.api.user
*
* @author luohj
* @className BomHomeApi
* @date 2024/8/12 0012
* @description 首页接口
*/
@Api(tags = "首页")
@RestController
@RequestMapping("bomHome")
@RefreshScope
public class BomHomeApi extends BaseApi {
@Value("${material.home.day:30}")
private Integer homeDay;
@Resource
private BomNewSapErrorMsgService sapErrorMsgService;
@Resource
private BomNewEbomParentService ebomParentService;
@Resource
private BomNewPbomParentService pbomParentService;
@GetMapping("sapMsgList")
@ApiOperation("sap异常消息")
public ResultVO<List<BomNewSapErrorMsgVO>> sapMsgList() {
//仅取90天内的数据
Date date90 = DateUtil.offsetDay(new Date(),-homeDay);
int limitNums = 5;
List<BomNewSapErrorMsgEntity> msgList = sapErrorMsgService.list(Wrappers.<BomNewSapErrorMsgEntity>lambdaQuery()
.ge(BomNewSapErrorMsgEntity::getCreatedTime,date90)
.eq(BomNewSapErrorMsgEntity::getCreatedName,SessionUtil.getRealName())
.orderByAsc(BomNewSapErrorMsgEntity::getType)
.orderByDesc(BomNewSapErrorMsgEntity::getCreatedTime)
.last(String.format("limit %d",limitNums)));
List<BomNewSapErrorMsgVO> reList = Convert.toList(BomNewSapErrorMsgVO.class,msgList);
List<Long> eBomIdList = reList.stream().filter(re -> Objects.equals(re.getType(),SapErrorMsgTypeEnum.EBOM.getValue())).distinct()
.map(BomNewSapErrorMsgVO::getTargetRowId).collect(Collectors.toList());
Map<Long,BomNewEbomParentEntity> eBomMap = Maps.newHashMap();
if(!eBomIdList.isEmpty()){
List<BomNewEbomParentEntity> eBomList = ebomParentService.listByIds(eBomIdList);
eBomMap = eBomList.stream().collect(Collectors.toMap(BomNewEbomParentEntity::getRowId, Function.identity()));
}
List<Long> pBomIdList = reList.stream().filter(re -> Objects.equals(re.getType(),SapErrorMsgTypeEnum.PBOM.getValue())).distinct()
.map(BomNewSapErrorMsgVO::getTargetRowId).collect(Collectors.toList());
Map<Long,BomNewPbomParentEntity> pBomMap = Maps.newHashMap();
if(!pBomIdList.isEmpty()){
List<BomNewPbomParentEntity> pBomList = pbomParentService.listByIds(pBomIdList);
pBomMap = pBomList.stream().collect(Collectors.toMap(BomNewPbomParentEntity::getRowId,Function.identity()));
}
Map<Long, BomNewEbomParentEntity> finalEBomMap = eBomMap;
Map<Long, BomNewPbomParentEntity> finalPBomMap = pBomMap;
reList.forEach(re -> {
re.setTypeName(EnumUtils.getEnumDescription(SapErrorMsgTypeEnum.class,re.getType()));
if(Objects.equals(SapErrorMsgTypeEnum.EBOM.getValue(),re.getType())){
re.setMaterialNo(Optional.ofNullable(finalEBomMap
.get(re.getTargetRowId())).map(BomNewEbomParentEntity::getMaterialNo).orElse(""));
re.setMaterialDesc(Optional.ofNullable(finalEBomMap
.get(re.getTargetRowId())).map(BomNewEbomParentEntity::getMaterialDesc).orElse(""));
}
if(Objects.equals(SapErrorMsgTypeEnum.PBOM.getValue(),re.getType())){
re.setMaterialNo(Optional.ofNullable(finalPBomMap
.get(re.getTargetRowId())).map(BomNewPbomParentEntity::getMaterialNo).orElse(""));
re.setMaterialDesc(Optional.ofNullable(finalPBomMap
.get(re.getTargetRowId())).map(BomNewPbomParentEntity::getMaterialDesc).orElse(""));
}
});
return ResultVO.success(reList.stream().filter(re-> StrUtil.isNotBlank(re.getMaterialNo())).collect(Collectors.toList()));
}
}

View File

@ -0,0 +1,21 @@
package com.nflg.product.bomnew.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author 曹鹏飞
* @date 2024/6/27 09:25:44
*/
@AllArgsConstructor
@Getter
public enum SapErrorMsgTypeEnum implements ValueEnum<Integer> {
EBOM(0, "EBOM"),
PBOM(1, "PBOM"),
MBOM(2, "MBOM"),
DQBOM(3, "电气BOM");
private final Integer value;
private final String description;
}

View File

@ -0,0 +1,37 @@
package com.nflg.product.bomnew.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* packageName com.nflg.product.bomnew.pojo.vo
*
* @author luohj
* @className BomNewSapErrorMsgVO
* @date 2024/8/12 0012
* @description 首页 消息提醒 sap异常消息
*/
@Data
@Accessors(chain = true)
public class BomNewSapErrorMsgVO implements Serializable {
@ApiModelProperty(value = "主键行ID-雪花")
private Long targetRowId;
@ApiModelProperty(value = "物料编码")
private String materialNo;
@ApiModelProperty(value = "物料描述")
private String materialDesc;
@ApiModelProperty(value = "类别0-ebom1-pbom2-mbom3-电气bom")
private Integer type;
@ApiModelProperty(value = "类别名称")
private String typeName;
}