From 4f06c88888261715198f7bd19e835f298a0ed54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Fri, 1 Mar 2024 18:47:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nflg_project_dev/nflg-bom-new/pom.xml | 6 +- .../main/java/com/nflg/BomnewApplication.java | 2 + .../nflg/product/bomnew/api/user/EbomApi.java | 36 +++++--- .../bomnew/api/user/OriginalBomApi.java | 22 +++++ .../bomnew/mapper/master/BomNewLogMapper.java | 15 ++++ .../bomnew/pojo/entity/BomNewLogEntity.java | 84 +++++++++++++++++++ .../service/BomNewEbomParentService.java | 5 ++ .../bomnew/service/BomNewLogService.java | 19 +++++ .../service/BomNewOriginalParentService.java | 4 +- .../service/log/DbLogRecordServiceImpl.java | 44 ++++++++++ .../mapper/master/BomNewLogMapper.xml | 22 +++++ 11 files changed, 246 insertions(+), 13 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewLogMapper.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewLogEntity.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewLogService.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/log/DbLogRecordServiceImpl.java create mode 100644 nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewLogMapper.xml diff --git a/nflg_project_dev/nflg-bom-new/pom.xml b/nflg_project_dev/nflg-bom-new/pom.xml index 011f55f4..cd61d50b 100644 --- a/nflg_project_dev/nflg-bom-new/pom.xml +++ b/nflg_project_dev/nflg-bom-new/pom.xml @@ -53,7 +53,11 @@ eec ${eec.version} - + + io.github.mouzt + bizlog-sdk + 3.0.6 + diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/BomnewApplication.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/BomnewApplication.java index 30ab5bc9..ab7f98c6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/BomnewApplication.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/BomnewApplication.java @@ -1,5 +1,6 @@ package com.nflg; +import com.mzt.logapi.starter.annotation.EnableLogRecord; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @@ -20,6 +21,7 @@ import java.util.TimeZone; @EnableDiscoveryClient @EnableScheduling @EnableFeignClients +@EnableLogRecord(tenant = "com.nflg") public class BomnewApplication { public static void main(String[] args) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index f0d03b43..e2fc9a85 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -2,24 +2,21 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.ImmutableList; +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.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.pojo.dto.*; -import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery; -import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; -import com.nflg.product.bomnew.pojo.vo.*; +import com.nflg.product.bomnew.pojo.vo.BomNewEbomEditDetailVO; +import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; +import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO; import com.nflg.product.bomnew.service.*; -import com.nflg.product.bomnew.service.cache.MaterialMateCache; -import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase; -import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31; import com.nflg.product.bomnew.util.EecExcelUtil; -import com.nflg.product.bomnew.util.TreeNode; import com.nflg.product.bomnew.util.VUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,12 +31,9 @@ import org.ttzero.excel.entity.Workbook; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.sql.Struct; import java.util.List; import java.util.Objects; import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; /** @@ -116,8 +110,11 @@ public class EbomApi extends BaseApi { @PostMapping("projectTypeInit") @ApiOperation("项目类别自动赋值") + @LogRecord(success = "项目类别自动赋值:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", + bizNo = "{{#bomRowIds.toString()}}" ,type = "项目类别自动赋值") public ResultVO projectTypeInit(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要自动赋值的行"); + bomNewEbomParentService.projectTypeInit(bomRowIds); return ResultVO.success(true); @@ -125,6 +122,8 @@ public class EbomApi extends BaseApi { @PostMapping("generateVirtualPackage") @ApiOperation("生成虚拟包") + @LogRecord(success = "生成虚拟包:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", + bizNo = "{{#paramDto.bomRowId}}" ,type = "生成虚拟包") public ResultVO generateVirtualPackage(@RequestBody VirtualPackageParamDto paramDto) { VUtils.isTure(CollUtil.isEmpty(paramDto.getVirtualPackageValue())).throwMessage("请选择要生成的虚拟包"); @@ -141,6 +140,8 @@ public class EbomApi extends BaseApi { @PostMapping("convertToPBom") @ApiOperation("转PBom") + @LogRecord(success = "转PBom:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", + bizNo = "{{#paramDto.bomRowIds.toString()}}" ,type = "转PBom") public ResultVO convertToPBom(@RequestBody EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException { VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料"); VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂"); @@ -155,6 +156,8 @@ public class EbomApi extends BaseApi { @PostMapping("upgradeChanges") @ApiOperation("发起变更") + @LogRecord(success = "发起变更:物料编码:{{#bom.materialNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", + bizNo = "{{#param.bomRowIds.toString()}}" ,type = "发起变更") public ResultVO upgradeChanges(@RequestBody EBomUpgradeChangesParamDTO param) { VUtils.isTure(CollUtil.isEmpty(param.getBomRowIds())).throwMessage("请选择要发起变更的物料"); bomNewEbomParentService.upgradeChanges(param); @@ -368,6 +371,17 @@ public class EbomApi extends BaseApi { // } + @LogRecord(success = "luo下了一个订单,购买商品「{{#name.toString()}}}」,测试变量「dsfsdf」,下单结果:{{#_ret}}", + bizNo = "sfsfsa" ,type = "dsfdsf") + @PostMapping("log") + @ApiOperation("测试日志") + public boolean createOrder() { + LogRecordContext.putVariable("name","罗里面"); + + return true; + } + + diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java index 13e06db6..3517f1aa 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/OriginalBomApi.java @@ -3,12 +3,15 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.ImmutableList; +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.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.mapper.master.BomNewEbomChildMapper; import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO; import com.nflg.product.bomnew.pojo.dto.OriginalSaveBomDTO; +import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO; import com.nflg.product.bomnew.pojo.vo.ImportOriginalBomVO; @@ -84,19 +87,31 @@ public class OriginalBomApi extends BaseApi { @PostMapping("saveBom") @ApiOperation("编辑时-暂存") + @LogRecord(success = "编辑物料明细-图号-{{#drawingNo}},操作结果:{{#_ret}}", + bizNo = "{{#bom.parentRowId}}" ,type = "编辑时-暂存") public ResultVO saveBom(@Valid @RequestBody OriginalSaveBomDTO bom) { + BomNewOriginalParentEntity parentEntity = originalParentService.getBaseMapper().selectById(bom.getParentRowId()); + LogRecordContext.putVariable("drawingNo",parentEntity.getDrawingNo()); + return ResultVO.success(originalParentService.saveBom(bom, false)); } @PostMapping("saveSubmit") @ApiOperation("编辑时-提交") + @LogRecord(success = "编辑物料明细-图号-{{#drawingNo}},操作结果:{{#_ret}}", + bizNo = "{{#bom.parentRowId}}" ,type = "编辑时-提交") public ResultVO saveSubmit(@Valid @RequestBody OriginalSaveBomDTO bom) { + BomNewOriginalParentEntity parentEntity = originalParentService.getBaseMapper().selectById(bom.getParentRowId()); + LogRecordContext.putVariable("drawingNo",parentEntity.getDrawingNo()); + return ResultVO.success(originalParentService.saveSubmit(bom)); } @PostMapping("pullFromCad") @ApiOperation("从CAD获取BOM数据") //去除参数 @RequestBody OriginalBomFromPlmQuery dto @Transactional(rollbackFor = Exception.class) + @LogRecord(success = "从cad获取bom到原始BOM,操作结果:{{#_ret}}", + bizNo = "" ,type = "从CAD获取BOM数据") public ResultVO> pullFromPlm() { List result = originalParentService.pullFromPlm(SessionUtil.getUserCode()); @@ -111,6 +126,8 @@ public class OriginalBomApi extends BaseApi { @GetMapping("del") @ApiOperation("删除BOM") + @LogRecord(success = "删除BOM-图号:{{#ent.drawingNo}} 版本:{{#ent.currentVersion}},操作结果:{{#_ret}}", + bizNo = "{{#bomRowId}}" ,type = "删除BOM") public ResultVO del(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException { originalParentService.del(bomRowId); originalParentService.computeLevelNumAndRootState(); @@ -135,6 +152,8 @@ public class OriginalBomApi extends BaseApi { */ @PostMapping("convertToEBom") @ApiOperation("原始BOM转Ebom") + @LogRecord(success = "删除BOM-图号:{{#bom.drawingNo}} 版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", + bizNo = "{{#bomRowIds.toString()}}" ,type = "原始BOM转Ebom") @Transactional(rollbackFor = Exception.class) public ResultVO convertToEBom(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { @@ -163,10 +182,13 @@ public class OriginalBomApi extends BaseApi { @ApiOperation("导入") @PostMapping("importBom") @Transactional(rollbackFor = Exception.class) + @LogRecord(success = "原始BOM-导入:文件名:{{#fileNme}},操作结果:{{#_ret}}", + bizNo = "" ,type = "原始BOM导入") public ResultVO> importBom(@RequestParam(value = "file") MultipartFile file) throws IOException { if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) { return ResultVO.error("请上传Excel文件"); } + LogRecordContext.putVariable("fileNme", file.getOriginalFilename()); List result = originalParentService.importBom(file); //计算层级 diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewLogMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewLogMapper.java new file mode 100644 index 00000000..27f5c6b7 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewLogMapper.java @@ -0,0 +1,15 @@ +package com.nflg.product.bomnew.mapper.master; + +import org.apache.ibatis.annotations.Mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity; + +/** + * t_bom_new_log 表数据库访问层 + * + * + * @author makejava + * @since 2024-03-01 17:10:57 + */ +public interface BomNewLogMapper extends BaseMapper { +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewLogEntity.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewLogEntity.java new file mode 100644 index 00000000..90c0497d --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewLogEntity.java @@ -0,0 +1,84 @@ +package com.nflg.product.bomnew.pojo.entity; + +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.experimental.Accessors; +import java.time.LocalDateTime; +import java.time.LocalDate; + +/** + * t_bom_new_log + * + * + * @author makejava + * @since 2024-03-01 17:10:57 + */ +@Data +@Accessors(chain = true) +@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewLogEntity") +@TableName(value = "t_bom_new_log") +public class BomNewLogEntity implements Serializable { + + /** + * 主键行id + */ + @TableId(value = "row_id", type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键行id") + private Long rowId; + + /** + * 操作行ID + */ + @TableField(value = "op_biz_no") + @ApiModelProperty(value = "操作行标识") + private String opBizNo; + + /** + * 操作动作 + */ + @TableField(value = "op_action") + @ApiModelProperty(value = "操作动作") + private String opAction; + + /** + * 操作内容-简写 + */ + @TableField(value = "op_content") + @ApiModelProperty(value = "操作内容-简写") + private String opContent; + + /** + * 操作内容详情 + */ + @TableField(value = "op_content_ext") + @ApiModelProperty(value = "操作内容详情") + private String opContentExt; + + /** + * 操作人工号 + */ + @TableField(value = "op_user_job_no") + @ApiModelProperty(value = "操作人工号") + private String opUserJobNo; + + /** + * 操作人名称 + */ + @TableField(value = "op_user_name") + @ApiModelProperty(value = "操作人名称") + private String opUserName; + + /** + * 操作时间 + */ + @TableField(value = "op_time") + @ApiModelProperty(value = "操作时间") + private LocalDateTime opTime; + + private static final long serialVersionUID = -52831510327211450L; + +} 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 5111b4a9..fc4ce2b8 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 @@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; +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.constant.*; @@ -428,6 +429,7 @@ public class BomNewEbomParentService extends ServiceImpl data = getBomTree(bomRowId); BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId)); + LogRecordContext.putVariable("bom",parent); //初始化物料信息 materialMainService.intiMaterialInfo(data); productTypeInitDo(parent, data); @@ -639,6 +641,7 @@ public class BomNewEbomParentService extends ServiceImpl bomTree = getBomTree(bomRowId); parent.setBomRowId(parent.getRowId()); parent.setChildBomRowId(parent.getRowId()); @@ -762,6 +766,7 @@ public class BomNewEbomParentService extends ServiceImpl childResult = new ArrayList<>(); for (Long bomRowId : paramDTO.getBomRowIds()) { BomNewEbomParentEntity parent = this.getById(bomRowId); + LogRecordContext.putVariable("bom",parent); List existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); //含发布前版本则无需升级 if (CollUtil.isEmpty(existEnt)) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewLogService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewLogService.java new file mode 100644 index 00000000..89ac3469 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewLogService.java @@ -0,0 +1,19 @@ +package com.nflg.product.bomnew.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.nflg.product.bomnew.mapper.master.BomNewLogMapper; +import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity; +import org.springframework.stereotype.Service; + + +/** + * t_bom_new_log 表服务实现类 + * + * + * @author makejava + * @since 2024-03-01 17:10:57 + */ +@Service +public class BomNewLogService extends ServiceImpl { + +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java index 0a5ccc56..8a726401 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Sets; +import com.mzt.logapi.context.LogRecordContext; import com.nflg.product.base.core.config.SpringContextUtils; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.exception.NflgBusinessException; @@ -440,6 +441,7 @@ public class BomNewOriginalParentService extends ServiceImpl bomTree = getBomTree(bomRowId); @@ -474,7 +476,7 @@ public class BomNewOriginalParentService extends ServiceImpl queryLog(String bizNo, String type) { + return null; + } + + @Override + public List queryLogByBizNo(String bizNo, String type, String subType) { + return null; + } +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewLogMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewLogMapper.xml new file mode 100644 index 00000000..25a95416 --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewLogMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + row_id, op_biz_no, op_action, op_content, op_content_ext, op_user_job_no, op_user_name, op_time + +