Merge remote-tracking branch 'origin/feature/DM/nflg-bom-transition' into feature/DM/nflg-bom-transition
This commit is contained in:
commit
472a899bee
|
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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-ebom;1-pbom;2-mbom;3-电气bom")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "类别名称")
|
||||
private String typeName;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -38,6 +38,7 @@ public class BomNewEbomExportToSAP {
|
|||
|
||||
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||
private final List<T1ExtDTO> children = new ArrayList<>();
|
||||
private final Set<Long> liPIds = new HashSet<>();
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(BomNewEbomExportToSAP.class);
|
||||
|
||||
|
|
@ -133,6 +134,14 @@ public class BomNewEbomExportToSAP {
|
|||
sapErrorMsgEntity.setCreatedTime(LocalDateTime.now());
|
||||
bomNewSapErrorMsgService.saveOrUpdate(sapErrorMsgEntity);
|
||||
}
|
||||
|
||||
if (CollUtil.isEmpty(liErrMsg) && CollUtil.isNotEmpty(liPIds)) {
|
||||
bomNewEbomParentService.lambdaUpdate()
|
||||
.in(BomNewEbomParentEntity::getRowId, liPIds)
|
||||
.set(BomNewEbomParentEntity::getSapTime, LocalDateTime.now())
|
||||
.set(BomNewEbomParentEntity::getSapState, SapStatusEnum.PUB_SUCCESS.getValue())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
private void addToT1(T1ExtDTO dto) {
|
||||
|
|
@ -173,8 +182,8 @@ public class BomNewEbomExportToSAP {
|
|||
.orderByDesc(BomNewEbomParentEntity::getCurrentVersion)
|
||||
.last(" limit 1")
|
||||
.one();
|
||||
if (Objects.nonNull(p)) {
|
||||
LOGGER.debug("BomNewEbomParentEntity:" + JSON.toJSONString(p));
|
||||
if (Objects.nonNull(p) && p.getSapState() >= SapStatusEnum.PUB_ERROR.getValue()) {
|
||||
liPIds.add(p.getRowId());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
|||
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||
private final Map<Long, List<T1ExtDTO>> cmap = new HashMap<>();
|
||||
private final List<T1ExtDTO> children = new ArrayList<>();
|
||||
private final Set<Long> liPIds = new HashSet<>();
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(BomNewPbomExportToSAPImpl.class);
|
||||
|
||||
|
|
@ -166,11 +167,19 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
|||
sapErrorMsgEntity.setCreatedTime(LocalDateTime.now());
|
||||
bomNewSapErrorMsgService.saveOrUpdate(sapErrorMsgEntity);
|
||||
}
|
||||
|
||||
if (CollUtil.isEmpty(liErrMsg) && CollUtil.isNotEmpty(liPIds)) {
|
||||
bomNewPbomParentService.lambdaUpdate()
|
||||
.in(BomNewPbomParentEntity::getRowId, liPIds)
|
||||
.set(BomNewPbomParentEntity::getSapTime, LocalDateTime.now())
|
||||
.set(BomNewPbomParentEntity::getSapState, SapStatusEnum.PUB_SUCCESS.getValue())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) {
|
||||
bomNewPbomParentService.lambdaUpdate()
|
||||
.in(BomNewPbomParentEntity::getRowId, rootBomRowId)
|
||||
.eq(BomNewPbomParentEntity::getRowId, rootBomRowId)
|
||||
.set(BomNewPbomParentEntity::getSapTime, LocalDateTime.now())
|
||||
.set(BomNewPbomParentEntity::getSapState, sapState.getValue())
|
||||
.update();
|
||||
|
|
@ -278,7 +287,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
|||
}
|
||||
|
||||
private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) {
|
||||
return bomNewPbomParentService.lambdaQuery()
|
||||
BomNewPbomParentEntity parent = bomNewPbomParentService.lambdaQuery()
|
||||
.eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
|
||||
.ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, child.getFacCode())
|
||||
|
|
@ -286,6 +295,10 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
|||
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
|
||||
.last(" limit 1")
|
||||
.one();
|
||||
if (Objects.nonNull(parent) && parent.getSapState() >= SapStatusEnum.PUB_ERROR.getValue()) {
|
||||
liPIds.add(parent.getRowId());
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -284,7 +284,6 @@
|
|||
SELECT *, row_id AS bomRowId
|
||||
FROM t_bom_new_pbom_parent
|
||||
WHERE status >= 4
|
||||
AND (root_is = 1 OR user_root_is = 1 OR root_state = 1)
|
||||
AND sap_state > 3
|
||||
AND created_by = #{userCode}
|
||||
ORDER BY release_time DESC
|
||||
|
|
|
|||
Loading…
Reference in New Issue