Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

This commit is contained in:
jing's 2024-03-03 15:07:33 +08:00
commit 26a9144da0
14 changed files with 298 additions and 21 deletions

View File

@ -53,7 +53,11 @@
<artifactId>eec</artifactId>
<version>${eec.version}</version>
</dependency>
<dependency>
<groupId>io.github.mouzt</groupId>
<artifactId>bizlog-sdk</artifactId>
<version>3.0.6</version>
</dependency>

View File

@ -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) {

View File

@ -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<Boolean> projectTypeInit(@RequestBody List<Long> 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<Boolean> 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<Boolean> 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<Boolean> upgradeChanges(@RequestBody EBomUpgradeChangesParamDTO param) {
VUtils.isTure(CollUtil.isEmpty(param.getBomRowIds())).throwMessage("请选择要发起变更的物料");
bomNewEbomParentService.upgradeChanges(param);
@ -165,6 +168,8 @@ public class EbomApi extends BaseApi {
@PostMapping("exportBom")
@ApiOperation("工作明细导出")
@LogRecord(success = "Ebom-工作明细导出,操作结果:{{#_ret}}", bizNo = "",
extra = "{{#bomRowIds.toString()}}" ,type = "Ebom-工作明细导出")
public void exportBom(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的物料行");
bomNewEbomParentService.exportBom(bomRowIds, response);
@ -172,6 +177,8 @@ public class EbomApi extends BaseApi {
@PostMapping("editExportBom")
@ApiOperation("编辑导出")
@LogRecord(success = "Ebom-编辑导出,操作结果:{{#_ret}}", bizNo = "",
extra = "{{#list.toString()}}" ,type = "Ebom-编辑导出")
public void editExportBom(@RequestBody List<BomNewEbomParentVO> list, HttpServletResponse response) throws IOException {
VUtils.isTure(CollectionUtil.isEmpty(list)).throwMessage("请选择要导出的物料行");
bomNewEbomParentService.editExportBom(list, response);
@ -242,6 +249,8 @@ public class EbomApi extends BaseApi {
@PostMapping("revertDesign")
@ApiOperation("退回到设计")
@LogRecord(success = "Ebom-退回到设计:{{#log}},操作结果:{{#_ret}}", bizNo = "",
extra = "{{#dto.rowIdList.toString()}}" ,type = "Ebom-退回到设计")
public ResultVO<Boolean> revertDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
return ResultVO.error(STATE.ParamErr, "请选择要退回的数据");
@ -256,6 +265,8 @@ public class EbomApi extends BaseApi {
@PostMapping("reviewDesign")
@ApiOperation("设计复核")
@LogRecord(success = "Ebom-设计复核:{{#log}},操作结果:{{#_ret}}", bizNo = "",
extra = "{{#dto.rowIdList.toString()}}" ,type = "Ebom-设计复核")
public ResultVO<Boolean> reviewDesign(@RequestBody BomNewEBomRevertDTO dto) throws ExecutionException, InterruptedException {
if (CollectionUtil.isEmpty(dto.getRowIdList())) {
return ResultVO.error(STATE.ParamErr, "请选择要复核的数据");
@ -283,6 +294,7 @@ public class EbomApi extends BaseApi {
@PostMapping("updateProjectType")
@ApiOperation("更新项目类型")
@LogRecord(success = "Ebom-更新项目类型,操作结果:{{#_ret}}", bizNo = "",type = "Ebom-更新项目类型")
public ResultVO<Boolean> updateProjectType(@RequestBody BomNewEbomProjectTypeDTO dto) {
VUtils.isTure(StrUtil.isEmpty(dto.getProjectType())).throwMessage("项目类型不能为空");
@ -308,6 +320,7 @@ public class EbomApi extends BaseApi {
@PostMapping("changeMaterial")
@ApiOperation("更新物料行")
@LogRecord(success = "Ebom-更新物料行,物料编码:{{#dto.parent.materialNo}}-版本:{{dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "",type = "Ebom-更新物料行")
public ResultVO<List<BomNewEbomParentVO>> changeMaterial(@RequestBody BomNewEBomChangeDTO dto) {
if ( dto.getParent() ==null || CollectionUtil.isEmpty(dto.getDatas()) ) {
return ResultVO.error(STATE.Error, "选择更新的数据");
@ -323,6 +336,7 @@ public class EbomApi extends BaseApi {
@GetMapping("delete")
@ApiOperation("删除物料")
@LogRecord(success = "Ebom-删除物料,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "Ebom-删除物料")
public ResultVO<Boolean> deleteBom(@RequestParam("bomRowId") Long bomRowId ) throws ExecutionException, InterruptedException{
bomNewEbomParentService.deleteBom(bomRowId);
@ -344,6 +358,7 @@ public class EbomApi extends BaseApi {
@PostMapping("submit")
@ApiOperation("提交")
@LogRecord(success = "Ebom-提交,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-提交")
public ResultVO<Boolean> submit(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException {
return ResultVO.success(bomNewEbomParentService.submit(dto));
}
@ -351,6 +366,7 @@ public class EbomApi extends BaseApi {
@PostMapping("intiException")
@ApiOperation("初始化错误类型")
@LogRecord(success = "Ebom-初始化错误类型,操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}",type = "Ebom-提交")
public ResultVO<Boolean> intiException(@RequestBody List<Long> bomRowIds) throws ExecutionException, InterruptedException {
bomNewEbomParentService.batchCheckAndSaveEBomException(bomRowIds );
@ -368,6 +384,16 @@ public class EbomApi extends BaseApi {
// }
@LogRecord(success = "luo下了一个订单,购买商品「{{#bom.currentVersion}}}」,测试变量「dsfsdf」,下单结果:{{#_ret}}",
bizNo = "sfsfsa" ,type = "dsfdsf")
@PostMapping("log")
@ApiOperation("测试日志")
public boolean createOrder() {
bomNewEbomParentService.createOrder();
return true;
}

View File

@ -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<Boolean> 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<Boolean> 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<List<ImportOriginalBomVO>> pullFromPlm() {
List<ImportOriginalBomVO> 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<Boolean> 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<Boolean> convertToEBom(@RequestBody List<Long> 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<List<ImportOriginalBomVO>> 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<ImportOriginalBomVO> result = originalParentService.importBom(file);
//计算层级

View File

@ -2,6 +2,8 @@ package com.nflg.product.bomnew.api.user;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.EBomConstant;
import com.nflg.product.bomnew.constant.PBomEditStatusEnum;
@ -31,6 +33,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
/**
@ -78,12 +81,14 @@ public class PBomApi extends BaseApi {
@PostMapping("exportWorkDetailsListByPage")
@ApiOperation("导出工作列表--导出")
@LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表")
public void exportWorkDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
bomNewPbomParentService.workDetailsExcel(query,response);
}
@PostMapping("releaseListDownLoad")
@ApiOperation("PBom已发布工作列表--导出")
@LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表")
public void releaseListDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
bomNewPbomParentService.releaseListExcel(query,response);
}
@ -96,6 +101,7 @@ public class PBomApi extends BaseApi {
@PostMapping("editStaging")
@ApiOperation("编辑-暂存")
@LogRecord(success = "PBom-编辑-暂存,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#param.bomRowId}}",type = "PBom-编辑-暂存")
public ResultVO<Boolean> editStaging(@Valid @RequestBody EditPBomParamDTO param){
bomNewPbomParentService.editSave(param,PBomEditStatusEnum.HANDLER_TEMP);
return ResultVO.success(true);
@ -103,6 +109,7 @@ public class PBomApi extends BaseApi {
@PostMapping("editSubmit")
@ApiOperation("编辑-提交")
@LogRecord(success = "PBom-编辑-提交,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#param.bomRowId}}",type = "PBom-编辑-提交")
public ResultVO<Boolean> editSubmit(@Valid @RequestBody EditPBomParamDTO param){
//检查物料编码是否存在
bomNewPbomParentService.checkMaterialNo(param.getChildList());
@ -115,6 +122,7 @@ public class PBomApi extends BaseApi {
@PostMapping("editDel")
@ApiOperation("编辑-删除")
@LogRecord(success = "PBom-编辑-删除,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#param.bomRowId}}",type = "PBom-编辑-删除")
public ResultVO<Boolean> editDel(@Valid @RequestBody EditPBomDelDTO param){
VUtils.isTure(CollUtil.isEmpty(param.getRowIdList())).throwMessage("请选择要删除的数据行");
bomNewPbomParentService.editDel(param);
@ -123,6 +131,7 @@ public class PBomApi extends BaseApi {
@PostMapping("setVirtualPart")
@ApiOperation("编辑-设置虚拟件")
@LogRecord(success = "PBom-编辑-设置虚拟件,操作结果:{{#_ret}}", bizNo = "{{#rowIdList.toString()}}",type = "PBom-编辑-设置虚拟件")
public ResultVO<Boolean> setVirtualPart(@RequestBody List<Long> rowIdList){
VUtils.isTure(CollUtil.isEmpty(rowIdList)).throwMessage("请选择要设置虚拟件的行");
@ -160,6 +169,7 @@ public class PBomApi extends BaseApi {
@PostMapping("createTechnologyPackage")
@ApiOperation("编辑-创建虚拟包")
@LogRecord(success = "PBom-编辑-创建虚拟包,物料编码:{{#packageParam.materialName}},图号:{{#packageParam.drawingNo}},操作结果:{{#_ret}}", bizNo = "{{#packageParam.bomRowId}}",type = "PBom-编辑-创建虚拟包")
public ResultVO<BaseMaterialVO> createTechnologyPackage(@Valid @RequestBody TechnologyPackageParam packageParam) throws IOException {
return ResultVO.success( bomNewPbomParentService.createTechnologyPackage(packageParam));
@ -195,6 +205,7 @@ public class PBomApi extends BaseApi {
@PostMapping("saveAllocationFactory")
@ApiOperation("分工厂-保存")
@LogRecord(success = "PBom-分工厂-保存。操作结果:{{#_ret}}", bizNo = "",type = "PBom-分工厂-保存")
public ResultVO<Boolean> saveAllocationFactory(@Valid @RequestBody List<SaveAllocationFactoryDTO> params){
return ResultVO.success(bomNewPbomParentService.saveAllocationFactory(params));
@ -202,15 +213,20 @@ public class PBomApi extends BaseApi {
@PostMapping("allocationFactoryForRel")
@ApiOperation("分工厂-规则匹配")
@LogRecord(success = "PBom-分工厂-规则匹配,物料编码:{{#bom.materialNo}}-版本:{{#bom.currentVersion}}-规则编码:{{#params.ruleGroupCode}} 操作结果:{{#_ret}}", bizNo = "{{#params.bomRowId}}",type = "PBom-分工厂-规则匹配")
public ResultVO<Boolean> allocationFactoryForRel(@Valid @RequestBody AllocationFactoryForRelDTO params) throws ExecutionException, InterruptedException {
BomNewPbomParentEntity bom = bomNewPbomParentService.getBaseMapper().selectById(params.getBomRowId());
LogRecordContext.putVariable("bom",bom);
return ResultVO.success(bomNewPbomParentService.allocationFactoryForRel(params));
}
@GetMapping("convertToMBom")
@ApiOperation("转MBom")
@LogRecord(success = "PBom-转MBom物料编码{{#bom.materialNo}}-版本:{{#bom.currentVersion}} 操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "PBom-转MBom")
public ResultVO<Boolean> convertToMBom(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException {
BomNewPbomParentEntity parent = bomNewPbomParentService.getById(bomRowId);
LogRecordContext.putVariable("bom",parent);
VUtils.isTure(!parent.getMaterialNo().startsWith("31")).throwMessage("只有31开头的物料才可以发布");
VUtils.isTure(parent.getStatus()< PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能生成MBom");
//
@ -221,6 +237,7 @@ public class PBomApi extends BaseApi {
@GetMapping("realesePbom")
@ApiOperation("发布Pbom")
@LogRecord(success = "发布PBom物料编码{{#bom.materialNo}}-版本:{{#bom.currentVersion}} 操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "发布PBom")
public ResultVO<Boolean> realesePbom(@RequestParam("bomRowId") Long bomRowId) {
return ResultVO.success(bomNewPbomParentService.realesePbom(bomRowId));
@ -237,6 +254,7 @@ public class PBomApi extends BaseApi {
@GetMapping("upgrade")
@ApiOperation("发起变更")
@LogRecord(success = "PBom发起变更物料编码{{#bom.materialNo}}-版本:{{#bom.currentVersion}} 操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "发起变更")
public ResultVO<Boolean> upgrade(@RequestParam("bomRowId") Long bomRowId) {
try {
bomNewPbomParentService.upgrade(bomRowId);

View File

@ -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<BomNewLogEntity> {
}

View File

@ -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;
}

View File

@ -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<BomNewEbomParentMapper,
for (Long bomRowId : bomRowIds) {
List<BomNewEbomParentVO> 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<BomNewEbomParentMapper,
BomNewEbomParentEntity root = this.getById(paramDto.getBomRowId());
LogRecordContext.putVariable("bom",root);
//初始化虚拟包-判断枚举不是手工生成虚拟包的情况
checkAndInitVirtualPackageEnum(paramDto,root);
Boolean flag = true;
@ -685,6 +688,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
for (Long bomRowId : paramDto.getBomRowIds()) {
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
LogRecordContext.putVariable("bom", parent);
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
parent.setBomRowId(parent.getRowId());
parent.setChildBomRowId(parent.getRowId());
@ -762,6 +766,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomChildEntity> childResult = new ArrayList<>();
for (Long bomRowId : paramDTO.getBomRowIds()) {
BomNewEbomParentEntity parent = this.getById(bomRowId);
LogRecordContext.putVariable("bom",parent);
List<BomNewEbomParentEntity> existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
//含发布前版本则无需升级
if (CollUtil.isEmpty(existEnt)) {
@ -1034,12 +1039,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentEntity> bomNewEbomParentEntityList = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, rowIds).eq(BomNewEbomParentEntity::getRootIs, 1).list();
if (CollUtil.isEmpty(bomNewEbomParentEntityList)) {
// throw new NflgBusinessException(STATE.BusinessError, "下级BOM无法进行退回");
VUtils.isTure(true).throwMessage("下级BOM无法进行退回");
}
Set<String> materialNoAndVersion = bomNewEbomParentEntityList.stream().map(u -> StrUtil.join("-", u.getMaterialNo(), u.getCurrentVersion())).collect(Collectors.toSet());
LogRecordContext.putVariable("log",materialNoAndVersion);
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
@ -1145,6 +1150,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// return ResultVO.error("下级BOM无法进行复核");
VUtils.isTure(true).throwMessage("下级BOM无法进行复核");
}
Set<String> materialNoAndVersion = bomNewEbomParentEntityList.stream().map(u -> StrUtil.join("-", u.getMaterialNo(), u.getCurrentVersion())).collect(Collectors.toSet());
LogRecordContext.putVariable("log",materialNoAndVersion);
if (rowIds.size() != bomNewEbomParentEntityList.size()) {
VUtils.isTure(true).throwMessage("数据中包含有下级BOM无法进行复核");
@ -1386,6 +1393,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public Boolean deleteBom(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
LogRecordContext.putVariable("bom",parentEntity);
VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确");
@ -1728,4 +1736,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
public void createOrder(){
BomNewEbomParentEntity ent=new BomNewEbomParentEntity();
ent.setDrawingNo("testDrawingNo");
ent.setCurrentVersion("V001");
LogRecordContext.putVariable("bom",ent);
}
}

View File

@ -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<BomNewLogMapper, BomNewLogEntity> {
}

View File

@ -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<BomNewOriginalParen
public Boolean del(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewOriginalParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
LogRecordContext.putVariable("ent",parentEntity);
VUtils.isTure(Objects.isNull(parentEntity)).throwMessage("该节点不存在,请检查参数是否正确");
VUtils.isTure(!parentEntity.getCreatedBy().equals(SessionUtil.getUserCode())).throwMessage("该节点不属于你,你无权删除");
List<BomOriginalListVO> bomTree = getBomTree(bomRowId);
@ -474,7 +476,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
//开始转换
for (BomNewOriginalParentEntity parent : bomNewOriginalParentEntities) {
LogRecordContext.putVariable("bom",parent);
Long ebomRowId = IdWorker.getId();
convertToEBomDo(parent, ebomRowId);

View File

@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
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.*;
@ -311,7 +312,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void editSave(EditPBomParamDTO paramDTO, PBomEditStatusEnum editStatus) {
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误该BOM不存在");
LogRecordContext.putVariable("bom",parent);
List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList());
childList.forEach(u -> {
u.setParentRowId(paramDTO.getBomRowId());
@ -354,7 +355,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数bomRowId错误该BOM不存在");
BomNewPbomParentVO parentVO = Convert.convert(BomNewPbomParentVO.class, parent);
LogRecordContext.putVariable("bom",parent);
materialMainService.intiMaterialInfo(ImmutableList.of(parentVO));
List<BomNewPbomChildEntity> childList = pbomChildService.getBaseMapper().selectBatchIds(paramDTO.getRowIdList());
@ -853,6 +854,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Transactional(rollbackFor = Exception.class)
public boolean realesePbom(Long bomRowId) {
BomNewPbomParentEntity parent = this.getById(bomRowId);
LogRecordContext.putVariable("bom",parent);
try {
List<BomNewPbomParentVO> allBom = getAllBom(bomRowId, 0);
@ -919,6 +921,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void upgrade(Long bomRowId) throws ExecutionException, InterruptedException {
BomNewPbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能发起变更");
LogRecordContext.putVariable("bom",parent);
PBomUpgrade upgrade = new PBomUpgrade(parent, getAllBom(bomRowId, 0));
upgrade.upgrade();
if (CollUtil.isNotEmpty(upgrade.getParentResult())) {

View File

@ -83,13 +83,13 @@ public class EBomToPBom {
check();
//bom 提层
liftingLayer();
List<BomNewEbomParentVO> parentList = result.stream().filter(u -> u.getBomRowId() > 0 && u.getStatus()<PBomStatusEnum.PUBLISH.getValue()).collect(Collectors.toList());
List<BomNewEbomParentVO> parentList = result.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
List<String> hasConvert=new ArrayList<>();
for (String facCode : facCodes) {
//buildPBomParent(parent, facCode);
for (BomNewEbomParentVO vo : parentList) {
String hasConvertKey=StrUtil.join(facCode,vo.getBomRowId());
String hasConvertKey=StrUtil.join("-",facCode,vo.getBomRowId());
if(hasConvert.contains(hasConvertKey)){
continue;
}
@ -157,7 +157,7 @@ public class EBomToPBom {
private BomNewPbomParentEntity buildPBomParent(BomNewEbomParentVO parentVo, String facCode) {
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, parentVo.getMaterialNo())
.eq(BomNewPbomParentEntity::getFacCode, facCode).eq(BomNewPbomParentEntity::getLastVersionIs,1).one();
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
// this.hasConvertEBomRowIds.add(parentVo.getRowId());
if (Objects.nonNull(oldParent) && !EBomStatusEnum.PUBLISHED.equalsValue(oldParent.getStatus())) {
@ -176,7 +176,7 @@ public class EBomToPBom {
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
pBomParent.setCurrentVersion(VersionUtil.getNextVersion(""));
if(Objects.nonNull(oldParent)){
parentVo.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
pBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
oldParent.setExpireEndTime(LocalDateTime.now());
oldParent.setLastVersionIs(0);
}

View File

@ -0,0 +1,44 @@
package com.nflg.product.bomnew.service.log;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.mzt.logapi.beans.LogRecord;
import com.mzt.logapi.service.ILogRecordService;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
import com.nflg.product.bomnew.service.BomNewLogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class DbLogRecordServiceImpl implements ILogRecordService {
@Resource
BomNewLogService logService;
@Override
public void record(LogRecord logRecord) {
BomNewLogEntity logEnt=new BomNewLogEntity();
logEnt.setRowId(IdWorker.getId());
logEnt.setOpBizNo(logRecord.getBizNo());
logEnt.setOpAction(logRecord.getType());
logEnt.setOpContent(logRecord.getAction());
logEnt.setOpContentExt(logRecord.getExtra());
logEnt.setOpUserJobNo(SessionUtil.getUserCode());
logEnt.setOpUserName(SessionUtil.getUserName());
logEnt.setOpTime(LocalDateTime.now());
logService.save(logEnt);
}
@Override
public List<LogRecord> queryLog(String bizNo, String type) {
return null;
}
@Override
public List<LogRecord> queryLogByBizNo(String bizNo, String type, String subType) {
return null;
}
}

View File

@ -0,0 +1,22 @@
<?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.BomNewLogMapper">
<resultMap id="BaseResultMap" type="com.nflg.product.bomnew.pojo.entity.BomNewLogEntity">
<!--@mbg.generated-->
<!--@Table t_bom_new_log -->
<id column="row_id" property="rowId" jdbcType="BIGINT"/>
<result column="op_biz_no" property="opBizNo" jdbcType="BIGINT"/>
<result column="op_action" property="opAction" jdbcType="VARCHAR"/>
<result column="op_content" property="opContent" jdbcType="VARCHAR"/>
<result column="op_content_ext" property="opContentExt" jdbcType="VARCHAR"/>
<result column="op_user_job_no" property="opUserJobNo" jdbcType="VARCHAR"/>
<result column="op_user_name" property="opUserName" jdbcType="VARCHAR"/>
<result column="op_time" property="opTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
row_id, op_biz_no, op_action, op_content, op_content_ext, op_user_job_no, op_user_name, op_time </sql>
</mapper>