24282 %!s(int64=2) %!d(string=hai) anos
pai
achega
790b8b2800
Modificáronse 19 ficheiros con 715 adicións e 9 borrados
  1. 3 3
      hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java
  2. 7 0
      hx-mes/pom.xml
  3. 86 0
      hx-mes/src/main/java/com/fjhx/mes/controller/bom/BomInfoController.java
  4. 36 0
      hx-mes/src/main/java/com/fjhx/mes/entity/bom/dto/BomInfoDto.java
  5. 22 0
      hx-mes/src/main/java/com/fjhx/mes/entity/bom/dto/BomInfoSelectDto.java
  6. 47 0
      hx-mes/src/main/java/com/fjhx/mes/entity/bom/po/BomDetail.java
  7. 44 0
      hx-mes/src/main/java/com/fjhx/mes/entity/bom/po/BomInfo.java
  8. 33 0
      hx-mes/src/main/java/com/fjhx/mes/entity/bom/vo/BomDetailVo.java
  9. 44 0
      hx-mes/src/main/java/com/fjhx/mes/entity/bom/vo/BomInfoVo.java
  10. 17 0
      hx-mes/src/main/java/com/fjhx/mes/mapper/bom/BomDetailMapper.java
  11. 26 0
      hx-mes/src/main/java/com/fjhx/mes/mapper/bom/BomInfoMapper.java
  12. 17 0
      hx-mes/src/main/java/com/fjhx/mes/service/bom/BomDetailService.java
  13. 53 0
      hx-mes/src/main/java/com/fjhx/mes/service/bom/BomInfoService.java
  14. 21 0
      hx-mes/src/main/java/com/fjhx/mes/service/bom/impl/BomDetailServiceImpl.java
  15. 230 0
      hx-mes/src/main/java/com/fjhx/mes/service/bom/impl/BomInfoServiceImpl.java
  16. 3 3
      hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProductionProcessesServiceImpl.java
  17. 3 3
      hx-mes/src/main/java/com/fjhx/mes/service/technology/impl/TechnologyServiceImpl.java
  18. 4 0
      hx-mes/src/main/resources/mapper/bom/BomDetailMapper.xml
  19. 19 0
      hx-mes/src/main/resources/mapper/bom/BomInfoMapper.xml

+ 3 - 3
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -54,7 +54,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         return result;
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void add(ProductInfoDto productInfoDto) {
         // 赋值产品编号
@@ -65,7 +65,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId());
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void edit(ProductInfoDto productInfoDto) {
         // 禁止产品编号修改
@@ -76,7 +76,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void delete(Long id) {
         this.removeById(id);

+ 7 - 0
hx-mes/pom.xml

@@ -12,6 +12,7 @@
 
     <artifactId>hx-mes</artifactId>
     <dependencies>
+
         <dependency>
             <groupId>com.fjhx</groupId>
             <artifactId>hx-base</artifactId>
@@ -25,6 +26,12 @@
             <groupId>com.fjhx</groupId>
             <artifactId>hx-item</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>hx-item</artifactId>
+        </dependency>
+
     </dependencies>
 
 

+ 86 - 0
hx-mes/src/main/java/com/fjhx/mes/controller/bom/BomInfoController.java

@@ -0,0 +1,86 @@
+package com.fjhx.mes.controller.bom;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.mes.entity.bom.dto.BomInfoDto;
+import com.fjhx.mes.entity.bom.dto.BomInfoSelectDto;
+import com.fjhx.mes.entity.bom.po.BomInfo;
+import com.fjhx.mes.entity.bom.vo.BomInfoVo;
+import com.fjhx.mes.service.bom.BomInfoService;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * bom 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@DS(SourceConstant.MES)
+@RestController
+@RequestMapping("/bomInfo")
+public class BomInfoController {
+
+    @Autowired
+    private BomInfoService bomInfoService;
+
+    /**
+     * bom分页
+     */
+    @PostMapping("/page")
+    public Page<BomInfoVo> page(@RequestBody BomInfoSelectDto dto) {
+        return bomInfoService.getPage(dto);
+    }
+
+    /**
+     * bom明细
+     */
+    @PostMapping("/detail")
+    public BomInfoVo detail(@RequestBody BaseSelectDto dto) {
+        return bomInfoService.detail(dto.getId());
+    }
+
+    /**
+     * bom新增
+     */
+    @PostMapping("/add")
+    public void add(@Validated @RequestBody BomInfoDto bomInfoDto) {
+        bomInfoService.add(bomInfoDto);
+    }
+
+    /**
+     * bom编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody BomInfoDto bomInfoDto) {
+        bomInfoService.edit(bomInfoDto);
+    }
+
+    /**
+     * 获取bom版本
+     */
+    @PostMapping("/getVersion")
+    public List<BomInfo> getVersion(@RequestBody BomInfo bomInfo) {
+        return bomInfoService.getVersion(bomInfo.getProductId());
+    }
+
+    /**
+     * 切换版本
+     */
+    @PostMapping("/editVersion")
+    public void editVersion(@RequestBody BomInfo bomInfo) {
+        bomInfoService.editVersion(bomInfo);
+    }
+
+}

+ 36 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/bom/dto/BomInfoDto.java

@@ -0,0 +1,36 @@
+package com.fjhx.mes.entity.bom.dto;
+
+import com.fjhx.mes.entity.bom.po.BomDetail;
+import com.fjhx.mes.entity.bom.po.BomInfo;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * bom新增编辑入参实体
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@Getter
+@Setter
+public class BomInfoDto extends BomInfo {
+
+    /**
+     * bom明细列表
+     */
+    @Valid
+    private List<BomDetail> bomDetailList;
+
+    /**
+     * 新增类型
+     * 1: 新建bom
+     * 2: 新建bom版本
+     */
+    @NotNull(message = "新增类型不能为空")
+    private Integer addType;
+
+}

+ 22 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/bom/dto/BomInfoSelectDto.java

@@ -0,0 +1,22 @@
+package com.fjhx.mes.entity.bom.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * bom列表查询入参实体
+ *
+ * @author 
+ * @since 2023-03-29
+ */
+@Getter
+@Setter
+public class BomInfoSelectDto extends BaseSelectDto {
+
+    /**
+     * 产品类型
+     */
+    private Integer productType;
+
+}

+ 47 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/bom/po/BomDetail.java

@@ -0,0 +1,47 @@
+package com.fjhx.mes.entity.bom.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * bom明细
+ * </p>
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@Getter
+@Setter
+@TableName("bom_detail")
+public class BomDetail extends BasePo {
+
+    /**
+     * bom id
+     */
+    private Long bomInfoId;
+
+    /**
+     * 产品id item模块product_info表id
+     */
+    @NotNull(message = "物料id不能为空")
+    private Long productId;
+
+    /**
+     * 数量
+     */
+    @NotNull(message = "物料数量不能为空")
+    private BigDecimal quantity;
+
+    /**
+     * 成本
+     */
+    @NotNull(message = "物料成本不能为空")
+    private BigDecimal cost;
+
+}

+ 44 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/bom/po/BomInfo.java

@@ -0,0 +1,44 @@
+package com.fjhx.mes.entity.bom.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * <p>
+ * bom
+ * </p>
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@Getter
+@Setter
+@TableName("bom_info")
+public class BomInfo extends BasePo {
+
+    /**
+     * 产品id item模块product_info表id
+     */
+    @NotNull(message = "产品id不能为空")
+    private Long productId;
+
+    /**
+     * 状态 1启用 0禁用
+     */
+    private Integer status;
+
+    /**
+     * 版本号
+     */
+    private Integer versionNumber;
+
+    /**
+     * 是否当前版本 1是 0否
+     */
+    private Integer currentVersion;
+
+}

+ 33 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/bom/vo/BomDetailVo.java

@@ -0,0 +1,33 @@
+package com.fjhx.mes.entity.bom.vo;
+
+import com.fjhx.mes.entity.bom.po.BomDetail;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * bom明细列表查询返回值实体
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@Getter
+@Setter
+public class BomDetailVo extends BomDetail {
+
+    /**
+     * 产品编码
+     */
+    private String productCode;
+
+    /**
+     * 产品名称
+     */
+    private String productName;
+
+    /**
+     * 产品单位
+     */
+    private String productUnit;
+
+
+}

+ 44 - 0
hx-mes/src/main/java/com/fjhx/mes/entity/bom/vo/BomInfoVo.java

@@ -0,0 +1,44 @@
+package com.fjhx.mes.entity.bom.vo;
+
+import com.fjhx.mes.entity.bom.po.BomInfo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * bom列表查询返回值实体
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@Getter
+@Setter
+public class BomInfoVo extends BomInfo {
+
+    /**
+     * 最近维护人
+     */
+    private String updateUserName;
+
+    /**
+     * 产品类型
+     */
+    private Integer productType;
+
+    /**
+     * 产品编码
+     */
+    private String productCode;
+
+    /**
+     * 产品名称
+     */
+    private String productName;
+
+    /**
+     * bom明细列表
+     */
+    private List<BomDetailVo> bomDetailVoList;
+
+}

+ 17 - 0
hx-mes/src/main/java/com/fjhx/mes/mapper/bom/BomDetailMapper.java

@@ -0,0 +1,17 @@
+package com.fjhx.mes.mapper.bom;
+
+import com.fjhx.mes.entity.bom.po.BomDetail;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+
+/**
+ * <p>
+ * bom明细 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-29
+ */
+public interface BomDetailMapper extends BaseMapper<BomDetail> {
+
+}

+ 26 - 0
hx-mes/src/main/java/com/fjhx/mes/mapper/bom/BomInfoMapper.java

@@ -0,0 +1,26 @@
+package com.fjhx.mes.mapper.bom;
+
+import com.fjhx.mes.entity.bom.po.BomInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.mes.entity.bom.vo.BomInfoVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Param;
+
+
+/**
+ * <p>
+ * bom Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-29
+ */
+public interface BomInfoMapper extends BaseMapper<BomInfo> {
+
+    /**
+     * bom分页
+     */
+    Page<BomInfoVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<BomInfo> wrapper);
+
+}

+ 17 - 0
hx-mes/src/main/java/com/fjhx/mes/service/bom/BomDetailService.java

@@ -0,0 +1,17 @@
+package com.fjhx.mes.service.bom;
+
+import com.fjhx.mes.entity.bom.po.BomDetail;
+import com.ruoyi.common.core.service.BaseService;
+
+
+/**
+ * <p>
+ * bom明细 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-29
+ */
+public interface BomDetailService extends BaseService<BomDetail> {
+
+}

+ 53 - 0
hx-mes/src/main/java/com/fjhx/mes/service/bom/BomInfoService.java

@@ -0,0 +1,53 @@
+package com.fjhx.mes.service.bom;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.mes.entity.bom.dto.BomInfoDto;
+import com.fjhx.mes.entity.bom.dto.BomInfoSelectDto;
+import com.fjhx.mes.entity.bom.po.BomInfo;
+import com.fjhx.mes.entity.bom.vo.BomInfoVo;
+import com.ruoyi.common.core.service.BaseService;
+
+import java.util.List;
+
+
+/**
+ * <p>
+ * bom 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-03-29
+ */
+public interface BomInfoService extends BaseService<BomInfo> {
+
+    /**
+     * bom分页
+     */
+    Page<BomInfoVo> getPage(BomInfoSelectDto dto);
+
+    /**
+     * bom明细
+     */
+    BomInfoVo detail(Long id);
+
+    /**
+     * bom新增
+     */
+    void add(BomInfoDto bomInfoDto);
+
+    /**
+     * bom编辑
+     */
+    void edit(BomInfoDto bomInfoDto);
+
+    /**
+     * 获取bom版本号
+     */
+    List<BomInfo> getVersion(Long productId);
+
+    /**
+     * 切换版本
+     */
+    void editVersion(BomInfo bomInfo);
+
+}

+ 21 - 0
hx-mes/src/main/java/com/fjhx/mes/service/bom/impl/BomDetailServiceImpl.java

@@ -0,0 +1,21 @@
+package com.fjhx.mes.service.bom.impl;
+
+import com.fjhx.mes.entity.bom.po.BomDetail;
+import com.fjhx.mes.mapper.bom.BomDetailMapper;
+import com.fjhx.mes.service.bom.BomDetailService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * <p>
+ * bom明细 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-29
+ */
+@Service
+public class BomDetailServiceImpl extends ServiceImpl<BomDetailMapper, BomDetail> implements BomDetailService {
+
+}

+ 230 - 0
hx-mes/src/main/java/com/fjhx/mes/service/bom/impl/BomInfoServiceImpl.java

@@ -0,0 +1,230 @@
+package com.fjhx.mes.service.bom.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.item.entity.product.po.ProductInfo;
+import com.fjhx.item.service.product.ProductInfoService;
+import com.fjhx.mes.entity.bom.dto.BomInfoDto;
+import com.fjhx.mes.entity.bom.dto.BomInfoSelectDto;
+import com.fjhx.mes.entity.bom.po.BomDetail;
+import com.fjhx.mes.entity.bom.po.BomInfo;
+import com.fjhx.mes.entity.bom.vo.BomDetailVo;
+import com.fjhx.mes.entity.bom.vo.BomInfoVo;
+import com.fjhx.mes.mapper.bom.BomInfoMapper;
+import com.fjhx.mes.service.bom.BomDetailService;
+import com.fjhx.mes.service.bom.BomInfoService;
+import com.ruoyi.common.constant.StatusConstant;
+import com.ruoyi.common.core.domain.BaseIdPo;
+import com.ruoyi.common.core.domain.BasePo;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.common.utils.wrapper.SqlField;
+import com.ruoyi.system.utils.UserUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+
+/**
+ * <p>
+ * bom 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-03-29
+ */
+@Service
+public class BomInfoServiceImpl extends ServiceImpl<BomInfoMapper, BomInfo> implements BomInfoService {
+
+    @Autowired
+    private ProductInfoService productInfoService;
+
+    @Autowired
+    private BomDetailService bomDetailService;
+
+    @Override
+    public Page<BomInfoVo> getPage(BomInfoSelectDto dto) {
+
+        Integer productType = dto.getProductType();
+        String keyword = dto.getKeyword();
+
+        Map<Long, ProductInfo> productInfoMap = new HashMap<>();
+        if (!ObjectUtil.isAllEmpty(productType, keyword)) {
+            DynamicDataSourceContextHolder.push(SourceConstant.ITEM);
+            List<ProductInfo> list = productInfoService.list(IWrapper.<ProductInfo>getWrapper()
+                    .eq(ProductInfo::getType, productType)
+                    .keyword(keyword, new SqlField(ProductInfo::getName), new SqlField(ProductInfo::getCode)));
+
+            if (list.size() == 0) {
+                DynamicDataSourceContextHolder.clear();
+                return new Page<>();
+            }
+
+            productInfoMap = list.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
+            DynamicDataSourceContextHolder.clear();
+            DynamicDataSourceContextHolder.push(SourceConstant.MES);
+        }
+
+        IWrapper<BomInfo> wrapper = getWrapper()
+                .in("bi", BomInfo::getProductId, productInfoMap.keySet())
+                .eq("bi", BomInfo::getCurrentVersion, StatusConstant.YES)
+                .orderByDesc("bi", BomInfo::getId);
+
+        Page<BomInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<BomInfoVo> records = page.getRecords();
+
+        if (records.size() == 0) {
+            return page;
+        }
+
+        // 赋值最近维护人
+        UserUtil.assignmentNickName(records, BasePo::getUpdateUser, BomInfoVo::setUpdateUserName);
+
+        if (productInfoMap.size() > 0) {
+            for (BomInfoVo item : records) {
+                ProductInfo productInfo = productInfoMap.get(item.getProductId());
+                item.setProductType(productInfo.getType());
+                item.setProductCode(productInfo.getCode());
+                item.setProductName(productInfo.getName());
+            }
+        } else {
+            DynamicDataSourceContextHolder.push(SourceConstant.ITEM);
+            productInfoService.attributeAssign(records, BomInfo::getProductId, (item, productInfo) -> {
+                item.setProductType(productInfo.getType());
+                item.setProductCode(productInfo.getCode());
+                item.setProductName(productInfo.getName());
+            });
+            DynamicDataSourceContextHolder.clear();
+        }
+
+        return page;
+    }
+
+    @Override
+    public BomInfoVo detail(Long id) {
+        BomInfo BomInfo = this.getById(id);
+        BomInfoVo result = BeanUtil.toBean(BomInfo, BomInfoVo.class);
+
+        List<BomDetail> bomDetailList = bomDetailService.list(q -> q.eq(BomDetail::getBomInfoId, id));
+        List<BomDetailVo> bomDetailVoList = BeanUtil.copyToList(bomDetailList, BomDetailVo.class);
+
+        DynamicDataSourceContextHolder.push(SourceConstant.ITEM);
+        productInfoService.attributeAssign(bomDetailVoList, BomDetailVo::getProductId, (item, productInfo) -> {
+            item.setProductCode(productInfo.getCode());
+            item.setProductName(productInfo.getName());
+            item.setProductUnit(productInfo.getUnit());
+        });
+        DynamicDataSourceContextHolder.clear();
+
+        result.setBomDetailVoList(bomDetailVoList);
+        return result;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void add(BomInfoDto bomInfoDto) {
+
+        // 新建bom
+        if (bomInfoDto.getAddType().equals(1)) {
+            nameDuplication(BomInfo::getProductId, bomInfoDto.getProductId(), "该产品已存在 BOM,请新建版本或进行修改操作");
+            bomInfoDto.setVersionNumber(1);
+            bomInfoDto.setCurrentVersion(StatusConstant.YES);
+        }
+        // 新建bom版本
+        else {
+            long count = count(q -> q.eq(BomInfo::getProductId, bomInfoDto.getProductId()));
+            bomInfoDto.setVersionNumber(Convert.toInt(count + 1));
+            bomInfoDto.setCurrentVersion(StatusConstant.NO);
+        }
+
+        bomInfoDto.setStatus(StatusConstant.ENABLE);
+        this.save(bomInfoDto);
+
+        // 添加bom明细
+        List<BomDetail> bomDetailList = bomInfoDto.getBomDetailList();
+        if (ObjectUtil.isNotEmpty(bomDetailList)) {
+            for (BomDetail bomDetail : bomDetailList) {
+                bomDetail.setBomInfoId(bomInfoDto.getId());
+            }
+            bomDetailService.saveBatch(bomDetailList);
+        }
+
+    }
+
+    @Override
+    public void edit(BomInfoDto bomInfoDto) {
+        Long bomInfoId = bomInfoDto.getId();
+        if (ObjectUtil.isEmpty(bomInfoId)) {
+            throw new ServiceException("bomId不能为空");
+        }
+
+        bomInfoDto.setCurrentVersion(null);
+        bomInfoDto.setVersionNumber(null);
+
+        this.updateById(bomInfoDto);
+
+        // 更新bom明细
+        List<BomDetail> bomDetailList = bomInfoDto.getBomDetailList();
+        if (ObjectUtil.isNotEmpty(bomDetailList)) {
+
+            List<Long> bomDetailIdList = bomDetailList.stream()
+                    .peek(item -> item.setBomInfoId(bomInfoId))
+                    .map(BaseIdPo::getId)
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toList());
+
+            bomDetailService.remove(q -> q
+                    .eq(BomDetail::getBomInfoId, bomInfoId)
+                    .notIn(ObjectUtil.isNotEmpty(bomDetailIdList), BaseIdPo::getId, bomDetailIdList));
+
+            bomDetailService.saveOrUpdateBatch(bomDetailList);
+        }
+
+    }
+
+    @Override
+    public List<BomInfo> getVersion(Long productId) {
+        if (ObjectUtil.isEmpty(productId)) {
+            throw new ServiceException("产品id不能为空");
+        }
+        return list(q -> q.eq(BomInfo::getProductId, productId));
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void editVersion(BomInfo bomInfo) {
+        Long productId = bomInfo.getProductId();
+        Integer versionNumber = bomInfo.getVersionNumber();
+
+        if (ObjectUtil.isEmpty(productId)) {
+            throw new ServiceException("产品id不能为空");
+        }
+        if (ObjectUtil.isEmpty(versionNumber)) {
+            throw new ServiceException("切换版本号不能为空");
+        }
+
+        update(q -> q
+                .eq(BomInfo::getProductId, productId)
+                .ne(BomInfo::getVersionNumber, versionNumber)
+                .set(BomInfo::getCurrentVersion, StatusConstant.NO));
+
+        update(q -> q
+                .eq(BomInfo::getProductId, productId)
+                .eq(BomInfo::getVersionNumber, versionNumber)
+                .set(BomInfo::getCurrentVersion, StatusConstant.YES));
+
+    }
+
+}

+ 3 - 3
hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProductionProcessesServiceImpl.java

@@ -57,7 +57,7 @@ public class ProductionProcessesServiceImpl extends ServiceImpl<ProductionProces
         return result;
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void add(ProductionProcessesDto productionProcessesDto) {
         ObsFile obsFile = productionProcessesDto.getFileList().get(0);
@@ -66,7 +66,7 @@ public class ProductionProcessesServiceImpl extends ServiceImpl<ProductionProces
         ObsFileUtil.saveFile(productionProcessesDto.getFileList(), productionProcessesDto.getId());
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void edit(ProductionProcessesDto productionProcessesDto) {
         ObsFile obsFile = productionProcessesDto.getFileList().get(0);
@@ -75,7 +75,7 @@ public class ProductionProcessesServiceImpl extends ServiceImpl<ProductionProces
         ObsFileUtil.editFile(productionProcessesDto.getFileList(), productionProcessesDto.getId());
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void delete(Long id) {
         this.removeById(id);

+ 3 - 3
hx-mes/src/main/java/com/fjhx/mes/service/technology/impl/TechnologyServiceImpl.java

@@ -133,7 +133,7 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
         return result;
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void add(TechnologyDto technologyDto) {
         this.save(technologyDto);
@@ -144,7 +144,7 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
         applicableProductsService.saveBatch(productList);
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void edit(TechnologyDto technologyDto) {
         this.updateById(technologyDto);
@@ -156,7 +156,7 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
         applicableProductsService.saveBatch(productList);
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public void delete(Long id) {
         this.removeById(id);

+ 4 - 0
hx-mes/src/main/resources/mapper/bom/BomDetailMapper.xml

@@ -0,0 +1,4 @@
+<?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.fjhx.mes.mapper.bom.BomDetailMapper">
+</mapper>

+ 19 - 0
hx-mes/src/main/resources/mapper/bom/BomInfoMapper.xml

@@ -0,0 +1,19 @@
+<?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.fjhx.mes.mapper.bom.BomInfoMapper">
+    <select id="getPage" resultType="com.fjhx.mes.entity.bom.vo.BomInfoVo">
+        select
+            bi.id,
+            bi.product_id,
+            bi.status,
+            bi.version_number,
+            bi.current_version,
+            bi.create_user,
+            bi.create_time,
+            bi.update_user,
+            bi.update_time
+        from bom_info bi
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>