Merge remote-tracking branch 'origin/master-xiantao-lhj1025'

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java
This commit is contained in:
10001392 2024-11-12 09:41:43 +08:00
commit 5949729eef
13 changed files with 506 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
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.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets;
@ -13,8 +14,13 @@ import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.PBomEditStatusEnum;
import com.nflg.product.bomnew.constant.PBomOaStatusEnum;
import com.nflg.product.bomnew.constant.PBomStatusEnum;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomAuditEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewTechnologyPackageTypeEntity;
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery;
@ -35,6 +41,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
@ -70,6 +77,9 @@ public class PBomApi extends BaseApi {
@Resource
private MaterialMainService materialMainService;
@Resource
private BomNewPbomAuditService bomNewPbomAuditService;
@Resource
SapService sapService;
@ -500,4 +510,29 @@ public class PBomApi extends BaseApi {
bomNewPbomParentService.lock(paramDTO);
return ResultVO.success(true);
}
@GetMapping("expand1020")
@ApiOperation("扩充1020编码")
public ResultVO<Void> expand1020(@Valid @RequestParam("bomRowId") @NotNull Long bomRowId){
bomNewPbomParentService.expand1020(bomRowId);
return ResultVO.success();
}
@GetMapping("updateByOaInstId")
@ApiOperation("根据OA InstId 来更新状态")
public ResultVO<Void> updateByOaInstId(@Valid @RequestParam("instId") @NotBlank String instId,
@Valid @RequestParam("status") @NotNull Integer status){
bomNewPbomParentService.updateByOaInstId(instId,status);
return ResultVO.success();
}
@GetMapping("auditList")
@ApiOperation("审批中的物料")
public ResultVO<String> auditList(@Valid @RequestParam("bomRowId") @NotNull Long bomRowId){
List<BomNewPbomAuditEntity> auditEntityList = bomNewPbomAuditService.list(Wrappers.<BomNewPbomAuditEntity>lambdaQuery()
.eq(BomNewPbomAuditEntity::getPbomParentRowId,bomRowId)
.eq(BomNewPbomAuditEntity::getOaStatus, PBomOaStatusEnum.IN_REVIEW.getValue()));
return ResultVO.success(auditEntityList.stream().map(BomNewPbomAuditEntity::getMaterialNos).collect(Collectors.joining(",")));
}
}

View File

@ -108,6 +108,9 @@ public class NacosConfig {
@Value("${oa.bom.noticeNum.url}")
private String bomNoticeUrl;
@Value("${oa.createXtsj.url:http://10.20.10.39:8080/jeecg-boot/OAWebService/OaMaster/createSJXT}")
private String oaCreateXtsjUrl;
public static NacosConfig getNacosConfig(){
return SpringContextUtils.getBean(NacosConfig.class);
}

View File

@ -0,0 +1,18 @@
package com.nflg.product.bomnew.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum PBomOaStatusEnum implements ValueEnum<Integer>{
WAIT_SUBMIT(1,"待提交"),
IN_REVIEW(2, "审核中"),
APPROVE(3,"已通过"),
REJECT(4,"已驳回");
private final Integer value;
private final String description;
}

View File

@ -0,0 +1,18 @@
package com.nflg.product.bomnew.mapper.master;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomAuditEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 10002327
* @description 针对表t_bom_new_pbom_audit(pbom_OA审批)的数据库操作Mapper
* @createDate 2024-10-30 10:50:02
* @Entity com.nflg.product.bomnew.pojo.entity.BomNewPbomAuditEntity
*/
public interface BomNewPbomAuditMapper extends BaseMapper<BomNewPbomAuditEntity> {
}

View File

@ -0,0 +1,74 @@
package com.nflg.product.bomnew.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
* pbom_OA审批
* @TableName t_bom_new_pbom_audit
*/
@TableName(value ="t_bom_new_pbom_audit")
@Data
public class BomNewPbomAuditEntity implements Serializable {
/**
* 行ID
*/
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
private Long rowId;
/**
* pbom_parent_id
*/
@TableField(value = "pbom_parent_row_id")
private Long pbomParentRowId;
/**
* 申请1020物料编码集合
*/
@TableField(value = "material_nos")
private String materialNos;
/**
* OA流程id
*/
@TableField(value = "oa_inst_id")
private String oaInstId;
/**
* OA流程状态1待提交2审核中3已通过4已驳回
*/
@TableField(value = "oa_status")
private Integer oaStatus;
/**
* 创建人编码
*/
@TableField(value = "created_by")
private String createdBy;
/**
* 创建时间
*/
@TableField(value = "created_time")
private LocalDateTime createdTime;
/**
* 修改人编码
*/
@TableField(value = "update_by")
private String updateBy;
/**
* 修改时间
*/
@TableField(value = "update_time")
private LocalDateTime updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,109 @@
package com.nflg.product.bomnew.pojo.param;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* packageName com.nflg.product.bomnew.pojo.param
*
* @author luohj
* @className OaXtsjParam
* @date 2024/10/25 0025
* @description OA仙桃收集流程参数 明细
*/
@Data
@Accessors(chain = true)
public class OaXtsjDetailParam implements Serializable {
@ApiModelProperty(value = "物料号")
@JSONField(name = "MATNR")
private String MATNR;
@ApiModelProperty(value = "物料描述")
@JSONField(name = "MAKTX")
private String MAKTX;
@ApiModelProperty(value = "物料组")
@JSONField(name = "MATKL")
private String MATKL;
@ApiModelProperty(value = "名称")
@JSONField(name = "MNAME")
private String MNAME;
@ApiModelProperty(value = "图号")
@JSONField(name = "MNUMB")
private String MNUMB;
@ApiModelProperty(value = "规格")
@JSONField(name = "MSPEC")
private String MSPEC;
@ApiModelProperty(value = "材质")
@JSONField(name = "MTEXT")
private String MTEXT;
@ApiModelProperty(value = "制作商")
@JSONField(name = "MMANU")
private String MMANU;
@ApiModelProperty(value = "细分类代码")
@JSONField(name = "ThinTypeCode")
private String ThinTypeCode;
@ApiModelProperty(value = "细分类描述")
@JSONField(name = "ThinTypeDes")
private String ThinTypeDes;
@ApiModelProperty(value = "小类代码")
@JSONField(name = "SmallTypeCode")
private String SmallTypeCode;
@ApiModelProperty(value = "小类描述")
@JSONField(name = "SmallTypeDes")
private String SmallTypeDes;
@ApiModelProperty(value = "中类代码")
@JSONField(name = "MiddleTypeCode")
private String MiddleTypeCode;
@ApiModelProperty(value = "中类描述")
@JSONField(name = "MiddleTypeDes")
private String MiddleTypeDes;
@ApiModelProperty(value = "基本记录单位")
@JSONField(name = "MEINS")
private String MEINS;
@ApiModelProperty(value = "采购类型")
@JSONField(name = "BESKZ")
private String BESKZ;
@ApiModelProperty(value = "特殊采购类型")
@JSONField(name = "SOBSL")
private String SOBSL;
@ApiModelProperty(value = "MRP控制者")
@JSONField(name = "DISPO")
private String DISPO;
@ApiModelProperty(value = "MRP类型")
@JSONField(name = "DISMM")
private String DISMM;
@ApiModelProperty(value = "ABC标识")
@JSONField(name = "MAABC")
private String MAABC;
@ApiModelProperty(value = "批量大小")
@JSONField(name = "DISLS")
private String DISLS;
@ApiModelProperty(value = "最小批量大小")
@JSONField(name = "BSTMI")
private String BSTMI;
}

View File

@ -0,0 +1,32 @@
package com.nflg.product.bomnew.pojo.param;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* packageName com.nflg.product.bomnew.pojo.param
*
* @author luohj
* @className OaXtsjParam
* @date 2024/10/25 0025
* @description OA仙桃收集流程参数
*/
@Data
@Accessors(chain = true)
public class OaXtsjParam implements Serializable {
@ApiModelProperty(value = "用户工号")
private String userid;
@ApiModelProperty(value = "来源默认:主数据平台发起")
private String summary = "主数据平台发起";
@ApiModelProperty(value = "明细")
@JSONField(name = "List")
private List<OaXtsjDetailParam> List;
}

View File

@ -1189,7 +1189,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
});
for (Long bomRowId : paramDto.getBomRowIds()) {
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在" + bomRowId.toString());
VUtils.isTure(Objects.isNull(parent)).throwMessage("请选择父级BOM进行操作~");
LogRecordContext.putVariable("CToPbom", parent);
List<BomNewEbomParentVO> bomTree = getFormalBomTree(bomRowId);
VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下级无需转换" + bomRowId.toString());

View File

@ -0,0 +1,21 @@
package com.nflg.product.bomnew.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.bomnew.mapper.master.BomNewOriginalParentMapper;
import com.nflg.product.bomnew.mapper.master.BomNewPbomAuditMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomAuditEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author 10002327
* @description 针对表t_bom_new_pbom_audit(pbom_OA审批)的数据库操作Service
* @createDate 2024-10-30 10:50:02
*/
@Service
@Slf4j
public class BomNewPbomAuditService extends ServiceImpl<BomNewPbomAuditMapper, BomNewPbomAuditEntity> {
}

View File

@ -1,4 +1,7 @@
package com.nflg.product.bomnew.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import cn.hutool.core.bean.BeanUtil;
@ -14,6 +17,7 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -21,9 +25,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.*;
import com.google.common.reflect.TypeToken;
import com.mysql.cj.xdevapi.JsonArray;
import com.mzt.logapi.context.LogRecordContext;
import com.nflg.product.base.core.config.MybatisPlusHandler;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.config.NacosConfig;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
import com.nflg.product.bomnew.pojo.dto.*;
@ -32,6 +40,8 @@ import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.param.OaXtsjDetailParam;
import com.nflg.product.bomnew.pojo.param.OaXtsjParam;
import com.nflg.product.bomnew.pojo.query.*;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.EBom.CheckPBomException;
@ -43,16 +53,21 @@ import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.ttzero.excel.entity.ListSheet;
import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
@ -80,6 +95,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource
MaterialMainService materialMainService;
@Resource
MaterialCategoryService materialCategoryService;
@Resource
BomNewPbomChildService pbomChildService;
@ -126,9 +144,15 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource
private BomNewNoticeNumDetail2Service bomNewNoticeNumDetail2Service;
@Resource
private BomNewPbomAuditService bomNewPbomAuditService;
@Resource
SapService sapService;
@Value("${oa.timeout}")
private int timeout;
/**
* pbom-工作列表
*
@ -154,8 +178,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
//String queryFac= StrUtil.isBlank(query.getFacCode())? userRoleService.getUserFactory():query.getFacCode();
String queryFac= "";
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo,"");
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo,"");
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo,"20000041");//SessionUtil.getUserCode()
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo,"20000041");
List<BomNewPbomParentVO> data = new ArrayList<>();
data.addAll(parents);
data.addAll(childs);
@ -497,7 +521,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
if (type == 0 && child.getStatus() >= EBomStatusEnum.PUBLISHED.getValue()) {
if (type == 0 && child.getStatus() != null && child.getStatus() >= EBomStatusEnum.PUBLISHED.getValue()) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
}
}
@ -2448,4 +2472,128 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void lock(LockParamDTO paramDTO){
this.getBaseMapper().lock(paramDTO,SessionUtil.getRealName());
}
/**
* 扩充1020 编码
* @param bomRowId
* @return
*/
public void expand1020(Long bomRowId){
BomNewPbomParentEntity pbomParent = this.getById(bomRowId);
VUtils.isTure(pbomParent == null).throwMessage("该BOM不存在" + bomRowId);
List<BomNewPbomAuditEntity> auditList = bomNewPbomAuditService.list(Wrappers.<BomNewPbomAuditEntity>lambdaQuery().eq(BomNewPbomAuditEntity::getPbomParentRowId,bomRowId));
List<Integer> errList = Lists.newArrayList(SapStatusEnum.PUB_ERROR.getValue(),SapStatusEnum.PUB_ERROR_ALL.getValue());
VUtils.isTure(!errList.contains(pbomParent.getSapState())).throwMessage("只有Sap导入失败的BOM才需要扩充1020编码");
List<BomNewPbomAuditEntity> inReviewList = auditList.stream().filter(audit -> Objects.equals(audit.getOaStatus(),PBomOaStatusEnum.IN_REVIEW.getValue())).collect(Collectors.toList());
VUtils.isTure(!inReviewList.isEmpty()).throwMessage("OA流程审核中请勿重复提交~");
BomNewSapErrorMsgEntity sapErrorMsgEntity = bomNewSapErrorMsgService.getById(bomRowId);
VUtils.isTure(sapErrorMsgEntity == null).throwMessage("不存在sap导入异常信息");
List<Map<String,String>> sapErrorList = JSON.parseObject(sapErrorMsgEntity.getData(),new TypeReference<List<Map<String,String>>>(){});
//"msg": "修改失败物料1100000531在工厂1020中未被维护", msg过滤出在工厂1020中未被维护的物料
List<String> materialNoList = sapErrorList.stream().filter(m -> StrUtil.contains(m.get("msg"),"在工厂1020中未被维护"))
.map(m -> ReUtil.get("(\\d{10})",m.get("msg"),1)).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());
VUtils.isTure(materialNoList.isEmpty()).throwMessage("没有物料需要扩充1020~");
List<MaterialMainEntity> materialList = materialMainService.list(Wrappers.<MaterialMainEntity>lambdaQuery().in(MaterialMainEntity::getMaterialNo,materialNoList));
VUtils.isTure(materialList.isEmpty()).throwMessage("没有物料需要扩充1020");
List<String> codeList = materialList.stream().map(m -> {
List<String> cList = Lists.newArrayList();
String code = m.getMaterialCategoryCode();
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= code.length(); i++) {
sb.append(code.charAt(i-1));
if(i % 2 == 0){
cList.add(sb.toString());
}
}
return cList;
}).filter(CollUtil::isNotEmpty).flatMap(List::stream).distinct().collect(Collectors.toList());
List<MaterialCategoryEntity> categoryList = materialCategoryService.list(Wrappers.<MaterialCategoryEntity>lambdaQuery().in(MaterialCategoryEntity::getCategoryCode,codeList));
Map<String,String> categoryMap = categoryList.stream().collect(Collectors.toMap(MaterialCategoryEntity::getCategoryCode,MaterialCategoryEntity::getCategoryName,(k1,k2) -> k1));
OaXtsjParam oaXtsjParam = new OaXtsjParam();
oaXtsjParam.setUserid(SessionUtil.getUserCode());
List<OaXtsjDetailParam> list = Lists.newArrayList();
materialList.forEach(m -> {
OaXtsjDetailParam detail = new OaXtsjDetailParam();
detail.setMATNR(m.getMaterialNo());
detail.setMAKTX(m.getMaterialDesc());
String code = m.getMaterialCategoryCode();
String code4 = ""; //物料分类前4位
String code6 = ""; //物料分类前6位
String code8 = ""; //物料分类前8位
StringBuilder sb = new StringBuilder();
for (int i = 0; i < code.length(); i++) {
sb.append(code.charAt(i));
if(i == 3){
code4 = sb.toString();
}
if(i == 5){
code6 = sb.toString();
}
if(i == 7){
code8 = sb.toString();
}
}
detail.setMATKL(code6);
detail.setMNAME(m.getMaterialName());
detail.setMNUMB(m.getDrawingNo());
detail.setMSPEC(m.getMaterialSpecifications());
detail.setMTEXT(m.getMaterialTexture());
detail.setMMANU(m.getMaterialBrand());
detail.setThinTypeCode(code8);
detail.setThinTypeDes(categoryMap.get(code8));
detail.setSmallTypeCode(code6);
detail.setSmallTypeDes(categoryMap.get(code6));
detail.setMiddleTypeCode(code4);
detail.setMiddleTypeDes(categoryMap.get(code4));
detail.setMEINS(m.getMaterialUnit());
detail.setBESKZ(m.getProcureType());
list.add(detail);
});
oaXtsjParam.setList(list);
HttpUtils httpUtils = new HttpUtils(timeout);
try {
log.info("扩充1020OA请求参数{}",JSON.toJSONString(oaXtsjParam));
String result = httpUtils.doPost(NacosConfig.getNacosConfig().getOaCreateXtsjUrl(),JSON.toJSONString(oaXtsjParam));
JSONObject jb = JSON.parseObject(result);
if(jb.getBoolean("success")){
String instId = Optional.ofNullable(jb.getJSONArray("data")).map(arr -> arr.getJSONObject(0))
.map(jo -> jo.getString("instId")).orElse("");
if(StrUtil.isNotBlank(instId)){
BomNewPbomAuditEntity auditEntity = new BomNewPbomAuditEntity();
auditEntity.setPbomParentRowId(bomRowId);
auditEntity.setMaterialNos(materialList.stream().map(MaterialMainEntity::getMaterialNo).collect(Collectors.joining(",")));
auditEntity.setOaInstId(instId);
auditEntity.setCreatedBy(SessionUtil.getUserCode());
auditEntity.setOaStatus(PBomOaStatusEnum.IN_REVIEW.getValue());
bomNewPbomAuditService.save(auditEntity);
}
}
log.info("OA返回信息{}",result);
} catch (IOException e) {
throw new NflgBusinessException(STATE.BusinessError, "同步OA出错".concat(e.getMessage()));
}
}
/**
* 根据OA流程ID更新状态
* @param instId OA流程id
* @param status 状态 3已通过4已驳回
*/
public void updateByOaInstId(@Valid @RequestParam("instId") @NotBlank String instId,
@Valid @RequestParam("status") @NotNull Integer status){
List<Integer> oaStatusList = Lists.newArrayList(PBomOaStatusEnum.APPROVE.getValue(),PBomOaStatusEnum.REJECT.getValue());
VUtils.isTure(!oaStatusList.contains(status)).throwMessage("OA状态异常");
BomNewPbomAuditEntity auditEntity = bomNewPbomAuditService.getOne(Wrappers.<BomNewPbomAuditEntity>lambdaQuery().eq(BomNewPbomAuditEntity::getOaInstId,instId),false);
VUtils.isTure(auditEntity == null).throwMessage("OA流程id不存在~");
VUtils.isTure(!Objects.equals(PBomOaStatusEnum.IN_REVIEW.getValue(),auditEntity.getOaStatus())).throwMessage("只有审核中的状态采可以更新~");
auditEntity.setOaStatus(status);
bomNewPbomAuditService.updateById(auditEntity);
}
}

View File

@ -0,0 +1,24 @@
<?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.nflg.product.bomnew.mapper.master.BomNewPbomAuditMapper">
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomNewPbomAuditEntity">
<id property="rowId" column="row_id" jdbcType="BIGINT"/>
<result property="pbomParentRowId" column="pbom_parent_row_id" jdbcType="BIGINT"/>
<result property="materialNos" column="material_nos" jdbcType="VARCHAR"/>
<result property="oaInstId" column="oa_inst_id" jdbcType="VARCHAR"/>
<result property="oaStatus" column="oa_status" jdbcType="TINYINT"/>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
row_id,pbom_parent_row_id,material_nos,
oa_inst_id,oa_status,created_by,
created_time,update_by,update_time
</sql>
</mapper>

View File

@ -2,10 +2,13 @@ package com.nflg.product.gateway.filter;
import com.google.common.collect.Lists;
import nflg.product.common.constant.STATE;
import nflg.product.common.util.JwtUtil;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
@ -15,7 +18,10 @@ import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl;
@ -27,6 +33,7 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.a
* @Date 2022-05-06
*/
@Component
@RefreshScope
public class LoginTokenFilter implements GlobalFilter, Ordered {
private static final String AUTHORIZE_TOKEN="authorization";
@ -36,6 +43,10 @@ public class LoginTokenFilter implements GlobalFilter, Ordered {
public final static String X_GATEWAY_BASE_PATH = "X_GATEWAY_BASE_PATH";
@Value("${auth.ignore.urls:/bom-new/pbom/updateByOaInstId}")
public String authIgnoreUrls;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
@ -43,6 +54,11 @@ public class LoginTokenFilter implements GlobalFilter, Ordered {
String tokenHeader=headers.getFirst(AUTHORIZE_TOKEN);
String path = request.getURI().getPath();
//白名单地址不做校验认证
if(Arrays.stream(authIgnoreUrls.split(",")).collect(Collectors.toList()).contains(path)){
return chain.filter(exchange);
}
//排除登入接口需检查token
if(!path.endsWith("user/login") && (StringUtils.isBlank(tokenHeader)) ){
return redirectToAuthrizeFail(exchange,chain, ResultVO.error(STATE.PassportErr,""));

View File

@ -15,6 +15,10 @@ spring.cloud.nacos.config.group=${spring.profiles.active}
spring.cloud.nacos.config.extension-configs[0].data-id=application-${spring.profiles.active}.properties
spring.cloud.nacos.config.extension-configs[0].group=${spring.profiles.active}
spring.cloud.nacos.config.extension-configs[1].data-id=gateway-${spring.profiles.active}.properties
spring.cloud.nacos.config.extension-configs[1].group=${spring.profiles.active}
spring.cloud.nacos.config.extension-configs[1].refresh=true
#discovery
spring.cloud.nacos.discovery.server-addr=${nacos.server-addr}
spring.cloud.nacos.discovery.group=${spring.profiles.active}