From 648a4552c96129ac3728c92e4331673415d2177f Mon Sep 17 00:00:00 2001 From: 10002327 Date: Wed, 30 Oct 2024 13:43:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=80=E9=94=AE=E6=89=A9=E5=85=851020?= =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/PBomApi.java | 32 ++++ .../product/bomnew/config/NacosConfig.java | 3 + .../bomnew/constant/PBomOaStatusEnum.java | 18 +++ .../mapper/master/BomNewPbomAuditMapper.java | 18 +++ .../pojo/entity/BomNewPbomAuditEntity.java | 74 +++++++++ .../bomnew/pojo/param/OaXtsjDetailParam.java | 109 +++++++++++++ .../bomnew/pojo/param/OaXtsjParam.java | 32 ++++ .../service/BomNewPbomAuditService.java | 21 +++ .../service/BomNewPbomParentService.java | 146 ++++++++++++++++++ .../mapper/master/BomNewPbomAuditMapper.xml | 24 +++ .../gateway/filter/LoginTokenFilter.java | 16 ++ .../src/main/resources/bootstrap.properties | 4 + 12 files changed, 497 insertions(+) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PBomOaStatusEnum.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomAuditMapper.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomAuditEntity.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjDetailParam.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjParam.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomAuditService.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomAuditMapper.xml diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index b8cd7686..2bb4f535 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -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; @@ -14,9 +15,11 @@ import com.mzt.logapi.starter.annotation.LogRecord; import com.nflg.product.base.core.api.BaseApi; 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; @@ -37,6 +40,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; @@ -72,6 +76,9 @@ public class PBomApi extends BaseApi { @Resource private MaterialMainService materialMainService; + @Resource + private BomNewPbomAuditService bomNewPbomAuditService; + @Resource SapService sapService; @@ -491,4 +498,29 @@ public class PBomApi extends BaseApi { }; return ResultVO.success(true); } + + @GetMapping("expand1020") + @ApiOperation("扩充1020编码") + public ResultVO expand1020(@Valid @RequestParam("bomRowId") @NotNull Long bomRowId){ + bomNewPbomParentService.expand1020(bomRowId); + return ResultVO.success(); + } + + @GetMapping("updateByOaInstId") + @ApiOperation("根据OA InstId 来更新状态") + public ResultVO 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 auditList(@Valid @RequestParam("bomRowId") @NotNull Long bomRowId){ + List auditEntityList = bomNewPbomAuditService.list(Wrappers.lambdaQuery() + .eq(BomNewPbomAuditEntity::getPbomParentRowId,bomRowId) + .eq(BomNewPbomAuditEntity::getOaStatus, PBomOaStatusEnum.IN_REVIEW.getValue())); + return ResultVO.success(auditEntityList.stream().map(BomNewPbomAuditEntity::getMaterialNos).collect(Collectors.joining(","))); + } + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/NacosConfig.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/NacosConfig.java index 9f36c857..6d7c46b0 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/NacosConfig.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/config/NacosConfig.java @@ -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); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PBomOaStatusEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PBomOaStatusEnum.java new file mode 100644 index 00000000..ff1393b4 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PBomOaStatusEnum.java @@ -0,0 +1,18 @@ +package com.nflg.product.bomnew.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum PBomOaStatusEnum implements ValueEnum{ + + + WAIT_SUBMIT(1,"待提交"), + IN_REVIEW(2, "审核中"), + APPROVE(3,"已通过"), + REJECT(4,"已驳回"); + + private final Integer value; + private final String description; +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomAuditMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomAuditMapper.java new file mode 100644 index 00000000..3d2f38d0 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewPbomAuditMapper.java @@ -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 { + +} + + + + diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomAuditEntity.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomAuditEntity.java new file mode 100644 index 00000000..2f2ef0e4 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomAuditEntity.java @@ -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; +} \ No newline at end of file diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjDetailParam.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjDetailParam.java new file mode 100644 index 00000000..2b505306 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjDetailParam.java @@ -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; +} \ No newline at end of file diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjParam.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjParam.java new file mode 100644 index 00000000..0e6c5e20 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/param/OaXtsjParam.java @@ -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 List; +} \ No newline at end of file diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomAuditService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomAuditService.java new file mode 100644 index 00000000..b7ece5a2 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomAuditService.java @@ -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 { + +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 933c030b..b295b110 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -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,12 @@ 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.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 +39,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 +52,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 +94,9 @@ public class BomNewPbomParentService extends ServiceImpl auditList = bomNewPbomAuditService.list(Wrappers.lambdaQuery().eq(BomNewPbomAuditEntity::getPbomParentRowId,bomRowId)); + + List errList = Lists.newArrayList(SapStatusEnum.PUB_ERROR.getValue(),SapStatusEnum.PUB_ERROR_ALL.getValue()); + VUtils.isTure(!errList.contains(pbomParent.getSapState())).throwMessage("只有Sap导入失败的BOM,才需要扩充1020编码"); + + List 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> sapErrorList = JSON.parseObject(sapErrorMsgEntity.getData(),new TypeReference>>(){}); + //"msg": "修改失败物料1100000531在工厂1020中未被维护", msg过滤出在工厂1020中未被维护的物料 + List 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 materialList = materialMainService.list(Wrappers.lambdaQuery().in(MaterialMainEntity::getMaterialNo,materialNoList)); + VUtils.isTure(materialList.isEmpty()).throwMessage("没有物料需要扩充1020!"); + + List codeList = materialList.stream().map(m -> { + List 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 categoryList = materialCategoryService.list(Wrappers.lambdaQuery().in(MaterialCategoryEntity::getCategoryCode,codeList)); + Map categoryMap = categoryList.stream().collect(Collectors.toMap(MaterialCategoryEntity::getCategoryCode,MaterialCategoryEntity::getCategoryName,(k1,k2) -> k1)); + + OaXtsjParam oaXtsjParam = new OaXtsjParam(); + oaXtsjParam.setUserid(SessionUtil.getUserCode()); + List 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.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 oaStatusList = Lists.newArrayList(PBomOaStatusEnum.APPROVE.getValue(),PBomOaStatusEnum.REJECT.getValue()); + VUtils.isTure(!oaStatusList.contains(status)).throwMessage("OA状态异常"); + BomNewPbomAuditEntity auditEntity = bomNewPbomAuditService.getOne(Wrappers.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); + } + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomAuditMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomAuditMapper.xml new file mode 100644 index 00000000..393f2497 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomAuditMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + row_id,pbom_parent_row_id,material_nos, + oa_inst_id,oa_status,created_by, + created_time,update_by,update_time + + diff --git a/nflg_project_dev/nflg-cloud-gateway/src/main/java/com/nflg/product/gateway/filter/LoginTokenFilter.java b/nflg_project_dev/nflg-cloud-gateway/src/main/java/com/nflg/product/gateway/filter/LoginTokenFilter.java index 975d625e..62227a5f 100644 --- a/nflg_project_dev/nflg-cloud-gateway/src/main/java/com/nflg/product/gateway/filter/LoginTokenFilter.java +++ b/nflg_project_dev/nflg-cloud-gateway/src/main/java/com/nflg/product/gateway/filter/LoginTokenFilter.java @@ -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 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,"")); diff --git a/nflg_project_dev/nflg-cloud-gateway/src/main/resources/bootstrap.properties b/nflg_project_dev/nflg-cloud-gateway/src/main/resources/bootstrap.properties index 97e1f0f9..31689828 100644 --- a/nflg_project_dev/nflg-cloud-gateway/src/main/resources/bootstrap.properties +++ b/nflg_project_dev/nflg-cloud-gateway/src/main/resources/bootstrap.properties @@ -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} From ced7059846631f1c4a8fc58c0485df9055f8e48a Mon Sep 17 00:00:00 2001 From: 10002327 Date: Thu, 31 Oct 2024 10:40:55 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=80=E9=94=AE=E6=89=A9=E5=85=851020?= =?UTF-8?q?=E7=BC=96=E7=A0=812?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/service/BomNewPbomParentService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index b295b110..6edd7d1c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -28,6 +28,7 @@ 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; @@ -2540,6 +2541,7 @@ public class BomNewPbomParentService extends ServiceImpl Date: Thu, 31 Oct 2024 13:50:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?BOM=E5=AE=8C=E6=95=B4=E6=80=A7=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/service/BomNewPbomParentService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 6edd7d1c..a3d63c00 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -176,8 +176,8 @@ public class BomNewPbomParentService extends ServiceImpl parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo,SessionUtil.getUserCode()); - List childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo,SessionUtil.getUserCode()); + List parents = this.getBaseMapper().getParentForMaterialNoSeach(queryFac , parentMaterialByMaterialNo,"20000041");//SessionUtil.getUserCode() + List childs = this.getBaseMapper().getChildForMaterialNoSeach(queryFac , parentMaterialByMaterialNo, materialNo,"20000041"); List data = new ArrayList<>(); data.addAll(parents); data.addAll(childs); @@ -516,7 +516,7 @@ public class BomNewPbomParentService extends ServiceImpl= EBomStatusEnum.PUBLISHED.getValue()) { + if (type == 0 && child.getStatus() != null && child.getStatus() >= EBomStatusEnum.PUBLISHED.getValue()) { child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); } } From 1321fa003c74f5fac7cb7c95c5f3c7b20591ac2a Mon Sep 17 00:00:00 2001 From: 10002327 Date: Thu, 31 Oct 2024 17:17:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/service/BomNewEbomParentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 61b5fee7..eaba3102 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -1189,7 +1189,7 @@ public class BomNewEbomParentService extends ServiceImpl bomTree = getFormalBomTree(bomRowId); VUtils.isTure(CollUtil.isEmpty(bomTree)).throwMessage("该BOM不存在下级,无需转换:" + bomRowId.toString());