longyvfengyun
2022-07-27 d90f0e1d65c60d5d8f382595cc2b51e36ba26546
src/main/java/com/whyc/service/ProductBomService.java
@@ -1,6 +1,7 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -9,14 +10,17 @@
import com.whyc.dto.ZipUtils;
import com.whyc.mapper.ProductBomMapper;
import com.whyc.pojo.ProductBom;
import com.whyc.pojo.ProductBomHistory;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@Service
@@ -70,10 +74,49 @@
        return new Response().setII(1,productBom!=null?true:false,productBom,"返回数据");
    }
    //获取产品的信息(不包含子料)
    /**获取产品的信息(不包含子料)*/
    public ProductBom getProduct(String parentModel){
        QueryWrapper<ProductBom> query = Wrappers.query();
        query.eq("parent_model",parentModel).last(" limit 1");
        return mapper.selectOne(query);
    }
    /** 删除旧的bom,增加新的bom*/
    @Transactional
    public void updateNewBom(List<ProductBomHistory> newBomHistoryList) {
        UpdateWrapper<ProductBom> update = Wrappers.update();
        update.eq("parent_model",newBomHistoryList.get(0).getParentModel());
        mapper.delete(update);
        List<ProductBom> newBomList = new LinkedList<>();
        newBomHistoryList.forEach(newBomHis->{
            ProductBom newBom = new ProductBom();
            newBom.setCategory(newBomHis.getCategory());
            newBom.setCreateDate(newBomHis.getCreateDate());
            newBom.setDwgUrl(newBomHis.getDwgUrl());
            newBom.setFileUrl(newBomHis.getFileUrl());
            newBom.setMaterial(newBomHis.getMaterial());
            newBom.setNotes(newBomHis.getNotes());
            newBom.setParentCode(newBomHis.getParentCode());
            newBom.setParentModel(newBomHis.getParentModel());
            newBom.setParentName(newBomHis.getParentName());
            newBom.setParentVersion(newBomHis.getParentVersion());
            newBom.setPictureUrl(newBomHis.getPictureUrl());
            newBom.setProducer(newBomHis.getProducer());
            newBom.setQuantity(newBomHis.getQuantity());
            newBom.setSubCode(newBomHis.getSubCode());
            newBom.setSubModel(newBomHis.getSubModel());
            newBom.setSubName(newBomHis.getSubName());
            newBom.setSurfaceDetail(newBomHis.getSurfaceDetail());
            newBom.setThickness(newBomHis.getThickness());
            newBom.setType(newBomHis.getType());
            newBom.setUnit(newBomHis.getUnit());
            newBom.setUpdateDate(newBomHis.getUpdateDate());
            newBom.setUpUser(newBomHis.getUpUser());
            newBom.setVersion(newBomHis.getEVersion());
            newBomList.add(newBom);
        });
        mapper.insertBatchSomeColumn(newBomList);
    }
}