lxw
2022-08-19 5d9865a1b1d48cb3192ecce036f706ef582c1424
去掉所有的报错正常运行
10个文件已删除
4 文件已重命名
10个文件已添加
15个文件已修改
1089 ■■■■ 已修改文件
src/main/java/com/whyc/config/EnumWorksheetType.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ComponentController.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ComponentProductHistoryController.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/MaterialApprovingController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/MaterialController.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/MaterialProductHistoryController.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ProductBomController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ProductController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/WorksheetMainController.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/WorksheetMainDTO.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ComponentApprovingMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ComponentMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ComponentProductApprovingMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ComponentProductHistoryMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialApprovingMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialProductApprovingMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/MaterialProductHistoryMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ProductBomMapper.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/WorksheetMain.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ComponentProductApprovingService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ComponentProductHistoryService.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialApprovingService.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialProductApprovingService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialProductHistoryService.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/MaterialService.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomApprovingService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomHistoryService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomService.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/WorksheetLinkService.java 172 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/WorksheetMainService.java 90 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ComponentProductApprovingMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ComponentProductHistoryMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialMapper.xml 76 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialProductApprovingMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MaterialProductHistoryMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ProductBomMapper.xml 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/WorksheetLinkMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/WorksheetMainMapper.xml 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/config/EnumWorksheetType.java
@@ -2,8 +2,8 @@
public enum EnumWorksheetType {
    ProductBom(1,"产品Bom"),
    Component(2,"散装件"),
    ComponentProduct(3,"散装件-产品"),
    Material(2,"散装件"),
    MaterialProduct(3,"散装件-产品"),
    ProductSoftware(4,"产品软件");
    EnumWorksheetType(Integer type, String typeName) {
src/main/java/com/whyc/controller/ComponentController.java
File was deleted
src/main/java/com/whyc/controller/ComponentProductHistoryController.java
File was deleted
src/main/java/com/whyc/controller/MaterialApprovingController.java
File was renamed from src/main/java/com/whyc/controller/ComponentApprovingController.java
@@ -1,9 +1,7 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.ProductBomApproving;
import com.whyc.service.ComponentApprovingService;
import com.whyc.service.ProductBomApprovingService;
import com.whyc.service.MaterialApprovingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -12,18 +10,17 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
/**
 * 散装件解析
 */
@RestController
@RequestMapping("componentApproving")
@RequestMapping("materialApproving")
@Api(tags = "散装件审批解析")
public class ComponentApprovingController {
public class MaterialApprovingController {
    @Autowired
    private ComponentApprovingService service;
    private MaterialApprovingService service;
    @PostMapping("zipParse")
src/main/java/com/whyc/controller/MaterialController.java
New file
@@ -0,0 +1,41 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.service.MaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "物料管理")
@RestController
@RequestMapping("material")
public class MaterialController {
    @Autowired
    private MaterialService service;
    @ApiOperation(value = "查询所有的散装件信息分页(带上关联的子件信息,status状态不做处理))")
    @GetMapping("getAllMaterial")
    public Response getAllMaterial(@RequestParam(required = false) String category,@RequestParam(required = false) String subCode,@RequestParam(required = false) String subName, @RequestParam(required = false) String subModel,@RequestParam int pageCurr, @RequestParam int pageSize){
        return service.getAllMaterial(category,subCode,subName,subModel,pageCurr,pageSize);
    }
    @ApiOperation(tags = "产品管理",value = "查询所有的散装件信息不分页(不包含被最新版本关联的散装件,status=1可用)")
    @GetMapping("getMaterialWithoutSub")
    public Response getMaterialWithoutSub(@RequestParam String parentModel, @RequestParam String subName, @RequestParam int version){
        return service.getMaterialWithoutSub(parentModel,subName,version);
    }
    @ApiOperation(value = "删除散装件(将散装件标识为不可用)")
    @GetMapping("deleteMaterial")
    public Response deleteMaterial(@RequestParam int id){
        return service.deleteMaterial(id);
    }
    @ApiOperation(value = "查询所有物料(分页,模糊查询)",notes = "8.17修改后使用")
    @GetMapping("getMaterialLimit")
    public Response getMaterialLimit(@RequestParam(required = false) String subCode,@RequestParam(required = false) String subName, @RequestParam(required = false) String subModel,@RequestParam int pageCurr, @RequestParam int pageSize){
        return service.getMaterialLimit(subCode,subName,subModel,pageCurr,pageSize);
    }
}
src/main/java/com/whyc/controller/MaterialProductHistoryController.java
New file
@@ -0,0 +1,26 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.MaterialProductHistory;
import com.whyc.service.MaterialProductHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(tags = "散装件管理")
@RestController
@RequestMapping("materialProduct")
public class MaterialProductHistoryController {
    @Autowired
    private MaterialProductHistoryService service;
    @ApiOperation(value = "增加散装件和产品之间替换关系")
    @PostMapping("addMaterialConnectBom")
    public Response addMaterialConnectBom(@RequestBody List<MaterialProductHistory> list){
        return  service.addMaterialConnectBom(list);
    }
}
src/main/java/com/whyc/controller/ProductBomController.java
@@ -63,9 +63,9 @@
    }
    @ApiOperation(tags = "产品管理",value = "根据母料型号查询子件信息及有最新版本关联的散装件信息")
    @GetMapping("getSubByComponentProduct")
    public Response getSubByComponentProduct(@RequestParam String parentModel){
        return service.getSubByComponentProduct(parentModel);
    @GetMapping("getSubByMaterialProduct")
    public Response getSubByMaterialProduct(@RequestParam String parentModel){
        return service.getSubByMaterialProduct(parentModel);
    }
    @ApiOperation(tags = "产品管理",value = "产品打包下载")
@@ -74,9 +74,9 @@
         service.downloadBom(req,resp,parentModel);
    }
    @ApiOperation(tags = "散装件管理",value = "查询所有产品中没有与指定散装件关联的子件")
    @GetMapping("getAllSubWithOutComponent")
    public Response getAllSubWithOutComponent(@RequestParam int componentId){
        return  service.getAllSubWithOutComponent(componentId);
    @GetMapping("getAllSubWithOutMaterial")
    public Response getAllSubWithOutMaterial(@RequestParam int MaterialId){
        return  service.getAllSubWithOutMaterial(MaterialId);
    }
}
src/main/java/com/whyc/controller/ProductController.java
@@ -14,7 +14,7 @@
    private ProductService service;
    @ApiOperation(tags = "物料管理",value = "根据物料编码查询所有包含该物料的产品信息",notes = "8.17修改后使用")
    @GetMapping()
    @GetMapping("getProductByMaterial")
    public Response getProductByMaterial(@RequestParam String subCode){
        return service.getProductByMaterial(subCode);
    }
src/main/java/com/whyc/controller/WorksheetMainController.java
@@ -40,11 +40,11 @@
        }
    }
    @PostMapping("componentRelatedSubmit")
    @PostMapping("MaterialRelatedSubmit")
    @ApiOperation(value="散装件-产品审批提交")
    public Response componentProductSubmit(@RequestBody WorksheetMainDTO mainDTO){
    public Response MaterialProductSubmit(@RequestBody WorksheetMainDTO mainDTO){
        DocUser user = ActionUtil.getUser();
        boolean res = service.componentProductSubmit(mainDTO,user);
        boolean res = service.MaterialProductSubmit(mainDTO,user);
        if(res) {
            return new Response().set(1,true, "提交完成");
        }else{
@@ -52,12 +52,12 @@
        }
    }
    @PostMapping("componentSubmit")
    @PostMapping("MaterialSubmit")
    @ApiOperation(value="散装件审批提交")
    public Response componentSubmit(@RequestBody WorksheetMain main){
    public Response MaterialSubmit(@RequestBody WorksheetMain main){
        Response<Object> response = new Response<>();
        DocUser user = ActionUtil.getUser();
        Response res = service.componentSubmit(main,user);
        Response res = service.MaterialSubmit(main,user);
        if(res.getCode()==1) {
            response.set(1,true, "提交完成");
        }else if(res.getCode()==3){
@@ -65,11 +65,11 @@
        }else{
            //重复提交
            Object existCAList = res.getData();
            Object existComponentList = res.getData2();
            Object existMaterialList = res.getData2();
            response.setCode(1);
            response.setData(false);
            response.setData2(existCAList);
            response.setData3(existComponentList);
            response.setData3(existMaterialList);
            if(res.getCode()==21){
                response.setMsg("重复提交:现有散装件及正在进行审批的散装件中,存在当前提交上传的散装件");
            }else if(res.getCode()==22){
src/main/java/com/whyc/dto/WorksheetMainDTO.java
@@ -1,6 +1,6 @@
package com.whyc.dto;
import com.whyc.pojo.ComponentProductApproving;
import com.whyc.pojo.MaterialProductApproving;
import com.whyc.pojo.WorksheetMain;
import java.util.List;
@@ -11,9 +11,9 @@
public class WorksheetMainDTO {
    private WorksheetMain main;
    private List<ComponentProductApproving> addedList;
    private List<ComponentProductApproving> replacedList;
    private List<ComponentProductApproving> removedList;
    private List<MaterialProductApproving> addedList;
    private List<MaterialProductApproving> replacedList;
    private List<MaterialProductApproving> removedList;
    public WorksheetMain getMain() {
        return main;
@@ -23,27 +23,27 @@
        this.main = main;
    }
    public List<ComponentProductApproving> getAddedList() {
    public List<MaterialProductApproving> getAddedList() {
        return addedList;
    }
    public void setAddedList(List<ComponentProductApproving> addedList) {
    public void setAddedList(List<MaterialProductApproving> addedList) {
        this.addedList = addedList;
    }
    public List<ComponentProductApproving> getReplacedList() {
    public List<MaterialProductApproving> getReplacedList() {
        return replacedList;
    }
    public void setReplacedList(List<ComponentProductApproving> replacedList) {
    public void setReplacedList(List<MaterialProductApproving> replacedList) {
        this.replacedList = replacedList;
    }
    public List<ComponentProductApproving> getRemovedList() {
    public List<MaterialProductApproving> getRemovedList() {
        return removedList;
    }
    public void setRemovedList(List<ComponentProductApproving> removedList) {
    public void setRemovedList(List<MaterialProductApproving> removedList) {
        this.removedList = removedList;
    }
}
src/main/java/com/whyc/mapper/ComponentApprovingMapper.java
File was deleted
src/main/java/com/whyc/mapper/ComponentMapper.java
File was deleted
src/main/java/com/whyc/mapper/ComponentProductApprovingMapper.java
File was deleted
src/main/java/com/whyc/mapper/ComponentProductHistoryMapper.java
File was deleted
src/main/java/com/whyc/mapper/MaterialApprovingMapper.java
New file
@@ -0,0 +1,7 @@
package com.whyc.mapper;
import com.whyc.pojo.MaterialApproving;
public interface MaterialApprovingMapper extends CustomMapper<MaterialApproving>{
}
src/main/java/com/whyc/mapper/MaterialMapper.java
New file
@@ -0,0 +1,18 @@
package com.whyc.mapper;
import com.whyc.pojo.Material;
import com.whyc.pojo.ProductBom;
import com.whyc.pojo.ProductBomHistory;
import java.util.List;
public interface MaterialMapper extends CustomMapper<Material>{
    //查询所有的散装件信息不分页
    List<Material> getMaterialWithoutSub(String parentModel, String subName,int version);
    //查询所有的散装件信息加设置了替换关系的子件信息
    List<Material> getAllMaterial(String category,String subCode,String subName,String subModel);
    //查询出存在替换关系得散装件
    List<ProductBom> getReplaceMaterial(String parentModel);
    //历史版本下载查询出存在替换关系得散装件
    List<ProductBomHistory> getReplaceHisMaterial(String parentModel,int version);
}
src/main/java/com/whyc/mapper/MaterialProductApprovingMapper.java
New file
@@ -0,0 +1,12 @@
package com.whyc.mapper;
import com.whyc.pojo.MaterialProductApproving;
import com.whyc.pojo.MaterialProductHistory;
import java.util.List;
public interface MaterialProductApprovingMapper extends CustomMapper<MaterialProductApproving> {
    List<MaterialProductApproving> getLatestExistListByMaterialId(Integer MaterialId);
}
src/main/java/com/whyc/mapper/MaterialProductHistoryMapper.java
New file
@@ -0,0 +1,12 @@
package com.whyc.mapper;
import com.whyc.pojo.MaterialProductHistory;
import java.util.List;
public interface MaterialProductHistoryMapper extends CustomMapper<MaterialProductHistory>{
    void updateVersionBatch(List<MaterialProductHistory> cphList);
    List<MaterialProductHistory> getLatestExistListByMaterialId(Integer MaterialId);
}
src/main/java/com/whyc/mapper/ProductBomMapper.java
@@ -1,6 +1,6 @@
package com.whyc.mapper;
import com.whyc.pojo.Component;
import com.whyc.pojo.Material;
import com.whyc.pojo.ProductBom;
import com.whyc.pojo.ProductBomApproving;
@@ -13,10 +13,10 @@
    void updateUrl(List<ProductBomApproving> fileBomApprovingList);
    //查询所有产品中没有与指定散装件关联的子件
    List<ProductBom> getAllSubWithOutComponent(int componentId);
    List<ProductBom> getAllSubWithOutMaterial(int MaterialId);
    //根据母料型号查询子件信息及有关联的散装件信息
    List<ProductBom> getSubByComponentProduct(String parentModel);
    List<ProductBom> getSubByMaterialProduct(String parentModel);
    //查询出存在的旧的关联子件
    List<Component> getOldComponent(String oldSubName);
    List<Material> getOldMaterial(String oldSubName);
}
src/main/java/com/whyc/pojo/WorksheetMain.java
@@ -70,10 +70,10 @@
    @ApiModelProperty("待审批散装件")
    @TableField(exist = false)
    private List<ComponentApproving> cApprovingList;
    private List<MaterialApproving> cApprovingList;
    @TableField(exist = false)
    private List<ComponentProductApproving> cpApprovingList;
    private List<MaterialProductApproving> cpApprovingList;
    public Integer getId() {
        return id;
@@ -211,19 +211,19 @@
        this.type = type;
    }
    public List<ComponentApproving> getCApprovingList() {
   public List<MaterialApproving> getCApprovingList() {
        return cApprovingList;
    }
    public void setCApprovingList(List<ComponentApproving> cApprovingList) {
    public void setCApprovingList(List<MaterialApproving> cApprovingList) {
        this.cApprovingList = cApprovingList;
    }
    public List<ComponentProductApproving> getCpApprovingList() {
    public List<MaterialProductApproving> getCpApprovingList() {
        return cpApprovingList;
    }
    public void setCpApprovingList(List<ComponentProductApproving> cpApprovingList) {
    public void setCpApprovingList(List<MaterialProductApproving> cpApprovingList) {
        this.cpApprovingList = cpApprovingList;
    }
}
src/main/java/com/whyc/service/ComponentProductApprovingService.java
File was deleted
src/main/java/com/whyc/service/ComponentProductHistoryService.java
File was deleted
src/main/java/com/whyc/service/MaterialApprovingService.java
File was renamed from src/main/java/com/whyc/service/ComponentApprovingService.java
@@ -4,8 +4,8 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.mapper.ComponentApprovingMapper;
import com.whyc.pojo.ComponentApproving;
import com.whyc.mapper.MaterialApprovingMapper;
import com.whyc.pojo.MaterialApproving;
import com.whyc.pojo.DocUser;
import com.whyc.util.ActionUtil;
import com.whyc.util.CommonUtil;
@@ -13,14 +13,12 @@
import com.whyc.util.Zip4jUtil;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -28,10 +26,10 @@
import java.util.List;
@Service
public class ComponentApprovingService {
public class MaterialApprovingService {
    @Resource
    private ComponentApprovingMapper mapper;
    private MaterialApprovingMapper mapper;
    /**
     *
@@ -41,7 +39,7 @@
     * @throws InvalidFormatException
     */
    public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException {
        List<ComponentApproving> list = new LinkedList<>();
        List<MaterialApproving> list = new LinkedList<>();
        Response response = new Response();
        //检查是否为zip
        boolean isZip = Zip4jUtil.checkZipFileParam(file);
@@ -53,7 +51,7 @@
        DocUser user = ActionUtil.getUser();
        String dateFormat = new SimpleDateFormat("YYYY-MM").format(new Date());
        long timeStamp = System.currentTimeMillis();
        String filePath = rootFile + File.separator + "component_approving" + File.separator + user.getName() + File.separator + dateFormat+ File.separator + timeStamp;
        String filePath = rootFile + File.separator + "Material_approving" + File.separator + user.getName() + File.separator + dateFormat+ File.separator + timeStamp;
        File parentFile = new File(filePath);
        String originalFilename = file.getOriginalFilename();
        File zipFile = new File(filePath+File.separator+ originalFilename);
@@ -95,7 +93,7 @@
                    if(cellTemp.getStringCellValue().equals("")){
                        break;
                    }
                    ComponentApproving approving = new ComponentApproving();
                    MaterialApproving approving = new MaterialApproving();
                    approving.setCreateDate(new Date());
                    for (int m = 2; m < lastCellNum; m++) {
@@ -133,8 +131,8 @@
                }
            }
        }
        for (ComponentApproving componentApproving : list) {
            if(componentApproving.getSubName()==null ||componentApproving.getSubName().equals("")){
        for (MaterialApproving MaterialApproving : list) {
            if(MaterialApproving.getSubName()==null ||MaterialApproving.getSubName().equals("")){
                return response.set(1,false,"拒绝解析,excel文件中记录包含名称为空的记录");
            }
        }
@@ -142,31 +140,31 @@
        return response.setIII(1,true,list,nextTitle,"解析完成");
    }
    public void insert(List<ComponentApproving> cApprovingList) {
    public void insert(List<MaterialApproving> cApprovingList) {
        mapper.insertBatchSomeColumn(cApprovingList);
    }
    public List<ComponentApproving> getListByStatus(int status) {
        QueryWrapper<ComponentApproving> query = Wrappers.query();
    public List<MaterialApproving> getListByStatus(int status) {
        QueryWrapper<MaterialApproving> query = Wrappers.query();
        query.eq("status",status);
        return mapper.selectList(query);
    }
    public void endStatus(Integer mainId) {
        UpdateWrapper<ComponentApproving> update = Wrappers.update();
        UpdateWrapper<MaterialApproving> update = Wrappers.update();
        update.set("status",2).eq("main_id",mainId);
        mapper.update(null,update);
    }
    public List<ComponentApproving> getListByMainId(Integer mainId) {
        QueryWrapper<ComponentApproving> query = Wrappers.query();
    public List<MaterialApproving> getListByMainId(Integer mainId) {
        QueryWrapper<MaterialApproving> query = Wrappers.query();
        query.eq("main_id",mainId);
        return mapper.selectList(query);
    }
    public ComponentApproving getListByComponentId(Integer componentId) {
        QueryWrapper<ComponentApproving> query = Wrappers.query();
        query.eq("component_id",componentId).last(" limit 1");
    public MaterialApproving getListByMaterialId(Integer MaterialId) {
        QueryWrapper<MaterialApproving> query = Wrappers.query();
        query.eq("Material_id",MaterialId).last(" limit 1");
        return mapper.selectOne(query);
    }
}
src/main/java/com/whyc/service/MaterialProductApprovingService.java
New file
@@ -0,0 +1,31 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.mapper.MaterialProductApprovingMapper;
import com.whyc.pojo.MaterialProductApproving;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class MaterialProductApprovingService {
    @Resource
    private MaterialProductApprovingMapper mapper;
    public void insert(List<MaterialProductApproving> approvingList) {
        mapper.insertBatchSomeColumn(approvingList);
    }
    public List<MaterialProductApproving> getListByMainId(Integer mainId) {
        QueryWrapper<MaterialProductApproving> query = Wrappers.query();
        query.eq("main_id",mainId);
        return mapper.selectList(query);
    }
    public List<MaterialProductApproving> getLatestExistListByMaterialId(Integer MaterialId) {
        return mapper.getLatestExistListByMaterialId(MaterialId);
    }
}
src/main/java/com/whyc/service/MaterialProductHistoryService.java
New file
@@ -0,0 +1,40 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.mapper.MaterialProductHistoryMapper;
import com.whyc.pojo.MaterialProductHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MaterialProductHistoryService {
    @Autowired(required = false)
    private MaterialProductHistoryMapper mapper;
    //增加散装件和产品之间替换关系
    public Response addMaterialConnectBom(List<MaterialProductHistory> list) {
        int bl=mapper.insertBatchSomeColumn(list);
        return new Response().setII(1,true,bl,bl>0?"添加关联成功":"添加关联失败");
    }
    public List<MaterialProductHistory> getListByParentModel(String parentModel, int currentVersion) {
        QueryWrapper<MaterialProductHistory> query = Wrappers.query();
        query.eq("parent_model",parentModel).le("s_version",currentVersion).ge("e_version",currentVersion);
        return mapper.selectList(query);
    }
    public void updateVersionBatch(List<MaterialProductHistory> cphList) {
        mapper.updateVersionBatch(cphList);
    }
    public void insertBatch(List<MaterialProductHistory> newHistoryList) {
        mapper.insertBatchSomeColumn(newHistoryList);
    }
    public List<MaterialProductHistory> getLatestExistListByMaterialId(Integer MaterialId) {
        return mapper.getLatestExistListByMaterialId(MaterialId);
    }
}
src/main/java/com/whyc/service/MaterialService.java
File was renamed from src/main/java/com/whyc/service/ComponentService.java
@@ -2,38 +2,37 @@
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;
import com.whyc.dto.Response;
import com.whyc.mapper.ComponentMapper;
import com.whyc.pojo.Component;
import com.whyc.mapper.MaterialMapper;
import com.whyc.pojo.Material;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ComponentService {
public class MaterialService {
    @Autowired(required = false)
    private ComponentMapper mapper;
    private MaterialMapper mapper;
    //查询所有的散装件信息加设置了替换关系的子件信息
    public Response getAllComponent(String category,String subCode,String subName,String subModel,int pageCurr,int pageSize) {
    public Response getAllMaterial(String category,String subCode,String subName,String subModel,int pageCurr,int pageSize) {
        PageHelper.startPage(pageCurr,pageSize);
        /*QueryWrapper wrapper=new QueryWrapper();
        wrapper.orderByAsc("id");
        List<Component> list=mapper.selectList(wrapper);*/
        List<Component> list=mapper.getAllComponent(category,subCode,subName,subModel);
        List<Material> list=mapper.selectList(wrapper);*/
        List<Material> list=mapper.getAllMaterial(category,subCode,subName,subModel);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list.size()>0?true:false,pageInfo,"返回所有的散装件");
    }
    //查询所有的散装件信息不分页
    public Response getComponentWithoutSub(String parentModel, String subName,int version) {
        List<Component> list=mapper.getComponentWithoutSub(parentModel,subName,version);
    public Response getMaterialWithoutSub(String parentModel, String subName,int version) {
        List<Material> list=mapper.getMaterialWithoutSub(parentModel,subName,version);
        return new Response().setII(1,list.size()>0?true:false,list,"返回子件没有添加过联系的散装件");
    }
    //删除散装件(将散装件标识为不可用)
    public Response deleteComponent(int id) {
    public Response deleteMaterial(int id) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("status",0);
        wrapper.eq("id",id);
@@ -41,17 +40,17 @@
        return new Response().setII(1,bl>0?true:false,bl,"将散装件标识为不可用");
    }
    public List<Component> getList() {
    public List<Material> getList() {
        return mapper.selectList(null);
    }
    public void insertBatch(List<Component> componentList) {
        mapper.insertBatchSomeColumn(componentList);
    public void insertBatch(List<Material> MaterialList) {
        mapper.insertBatchSomeColumn(MaterialList);
    }
    /**mybatis-plus逻辑删除*/
    public void deleteBatch(List<Integer> componentIdList) {
        mapper.deleteBatchIds(componentIdList);
    public void deleteBatch(List<Integer> MaterialIdList) {
        mapper.deleteBatchIds(MaterialIdList);
    }
    //查询所有物料(分页,模糊查询)
@@ -67,7 +66,7 @@
        if(subModel!=null&&!subModel.isEmpty()){
            wrapper.like("sub_model",subModel);
        }
        List<Component> list=mapper.selectList(wrapper);
        List<Material> list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list.size()>0?true:false,pageInfo,"查询所有物料(分页,模糊查询)");
    }
src/main/java/com/whyc/service/ProductBomApprovingService.java
@@ -249,7 +249,8 @@
                for (int l = 9; l < lastRowNum-1; l++) {
                    ProductBomApproving bomApproving = new ProductBomApproving();
                    bomApproving.setParentModel(productModel);
                    bomApproving.setParentVersion(productVersion);
                    //lxw注释
                    //bomApproving.setParentVersion(productVersion);
                    bomApproving.setType(type);
                    bomApproving.setExcelName(fileTempUrl.substring(fileTempUrl.lastIndexOf(File.separator)+1));
@@ -417,7 +418,9 @@
        if(bomApproving==null){
            return -1;
        }else{
            return bomApproving.getRejectVersion();
            //lxw注释
            //return bomApproving.getRejectVersion();
            return  0;
        }
    }
}
src/main/java/com/whyc/service/ProductBomHistoryService.java
@@ -6,10 +6,9 @@
import com.whyc.dto.FileDirPath;
import com.whyc.dto.Response;
import com.whyc.dto.ZipUtils;
import com.whyc.mapper.ComponentMapper;
import com.whyc.mapper.MaterialMapper;
import com.whyc.mapper.ProductBomHistoryMapper;
import com.whyc.pojo.DocUser;
import com.whyc.pojo.ProductBom;
import com.whyc.pojo.ProductBomHistory;
import com.whyc.util.ActionUtil;
import org.apache.poi.hssf.usermodel.*;
@@ -31,7 +30,7 @@
    @Autowired(required = false)
    private ProductBomHistoryMapper mapper;
    @Autowired(required = false)
    private ComponentMapper cponentMapper;
    private MaterialMapper cponentMapper;
    @Autowired
    private DocLogService logService;
@@ -70,7 +69,7 @@
        wrapper.ge("e_version",version);
        List<ProductBomHistory> list=mapper.selectList(wrapper);
        //查询出存在替换关系得散装件
        List<ProductBomHistory> replaceBomHis=cponentMapper.getReplaceHisComponent(parentModel,version);
        List<ProductBomHistory> replaceBomHis=cponentMapper.getReplaceHisMaterial(parentModel,version);
        //两个集合合并才是最终的BOM
        if(list!=null&&list.size()>0){
            if(replaceBomHis!=null&&replaceBomHis.size()>0){
@@ -90,7 +89,7 @@
        wrapper.ge("e_version",version);
        List<ProductBomHistory> list=mapper.selectList(wrapper);
        //查询出存在替换关系得散装件
        List<ProductBomHistory> replaceBomHis=cponentMapper.getReplaceHisComponent(parentModel,version);
        List<ProductBomHistory> replaceBomHis=cponentMapper.getReplaceHisMaterial(parentModel,version);
        //两个集合合并才是最终的BOM
        if(list!=null&&list.size()>0){
            if(replaceBomHis!=null&&replaceBomHis.size()>0){
@@ -156,7 +155,7 @@
                ProductBomHistory bomHistory= (ProductBomHistory) list.get(i);
                String dwgUrl=bomHistory.getDwgUrl();
                if(i==0){
                    excelName=bomHistory.getParentCode()+"_"+bomHistory.getParentModel()+"_"+version;
                    //excelName=bomHistory.getParentCode()+"_"+bomHistory.getParentModel()+"_"+version;
                    rootFace=fileDirName+ File.separator+excelName;
                    File destfile = new File(rootFace);
                    if(!destfile.exists()) {
@@ -170,9 +169,9 @@
                Row row=sheet.createRow(rownum+i+1);
                //row.setHeight((short)(1500));
                sheet.getRow(rownum+i+1).createCell(1).setCellValue(i+1);
                sheet.getRow(rownum+i+1).createCell(2).setCellValue(bomHistory.getParentCode());
                sheet.getRow(rownum+i+1).createCell(3).setCellValue(bomHistory.getParentName());
                sheet.getRow(rownum+i+1).createCell(4).setCellValue(bomHistory.getParentModel());
                //sheet.getRow(rownum+i+1).createCell(2).setCellValue(bomHistory.getParentCode());
                //sheet.getRow(rownum+i+1).createCell(3).setCellValue(bomHistory.getParentName());
                //sheet.getRow(rownum+i+1).createCell(4).setCellValue(bomHistory.getParentModel());
                sheet.getRow(rownum+i+1).createCell(5).setCellValue(bomHistory.getCategory());
                sheet.getRow(rownum+i+1).createCell(6).setCellValue(bomHistory.getSubCode());
                if(bomHistory.getOldSubName()!=null&&!bomHistory.getOldSubName().isEmpty()){
src/main/java/com/whyc/service/ProductBomService.java
@@ -9,12 +9,11 @@
import com.whyc.dto.FileDirPath;
import com.whyc.dto.Response;
import com.whyc.dto.ZipUtils;
import com.whyc.mapper.ComponentMapper;
import com.whyc.mapper.MaterialMapper;
import com.whyc.mapper.ProductBomMapper;
import com.whyc.pojo.*;
import com.whyc.util.ActionUtil;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,8 +25,6 @@
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -39,7 +36,7 @@
    private ProductBomMapper mapper;
    @Autowired(required = false)
    private ComponentMapper cponentMapper;
    private MaterialMapper cponentMapper;
    @Autowired
    private DocLogService logService;
    //图纸分类检索
@@ -87,7 +84,8 @@
    @Transactional
    public void updateNewBom(List<ProductBomHistory> newBomHistoryList) {
        UpdateWrapper<ProductBom> update = Wrappers.update();
        update.eq("parent_model",newBomHistoryList.get(0).getParentModel());
        //lxw注释
        //update.eq("parent_model",newBomHistoryList.get(0).getParentModel());
        mapper.delete(update);
        List<ProductBom> newBomList = new LinkedList<>();
@@ -99,10 +97,10 @@
            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.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());
@@ -114,7 +112,7 @@
            newBom.setType(newBomHis.getType());
            newBom.setUnit(newBomHis.getUnit());
            newBom.setUpUserId(newBomHis.getUpUserId());
            newBom.setVersion(newBomHis.getEVersion());
            //newBom.setVersion(newBomHis.getEVersion());
            newBomList.add(newBom);
        });
@@ -195,7 +193,7 @@
        wrapper.eq("parent_model",parentModel);
        List<ProductBom> list=mapper.selectList(wrapper);
        //查询出存在替换关系得散装件
        List<ProductBom> replaceBoms=cponentMapper.getReplaceComponent(parentModel);
        List<ProductBom> replaceBoms=cponentMapper.getReplaceMaterial(parentModel);
        //两个集合合并才是最终的BOM
        if(list!=null&&list.size()>0){
            if(replaceBoms!=null&&replaceBoms.size()>0){
@@ -256,7 +254,7 @@
                ProductBom bom= (ProductBom) list.get(i);
                String dwgUrl=bom.getDwgUrl();
                if(i==0){
                    excelName=bom.getParentCode()+"_"+bom.getParentModel();
                    //excelName=bom.getParentCode()+"_"+bom.getParentModel();
                    String timeStr= ActionUtil.sdfwithFTP.format(new Date());
                    if(type.equals("pic")){
                        excelName=timeStr;
@@ -274,9 +272,9 @@
                Row row=sheet.createRow(rownum+i+1);
                //row.setHeight((short)(1500));
                sheet.getRow(rownum+i+1).createCell(1).setCellValue(i+1);
                sheet.getRow(rownum+i+1).createCell(2).setCellValue(bom.getParentCode());
                sheet.getRow(rownum+i+1).createCell(3).setCellValue(bom.getParentName());
                sheet.getRow(rownum+i+1).createCell(4).setCellValue(bom.getParentModel());
                //sheet.getRow(rownum+i+1).createCell(2).setCellValue(bom.getParentCode());
                //sheet.getRow(rownum+i+1).createCell(3).setCellValue(bom.getParentName());
                //sheet.getRow(rownum+i+1).createCell(4).setCellValue(bom.getParentModel());
                sheet.getRow(rownum+i+1).createCell(5).setCellValue(bom.getCategory());
                sheet.getRow(rownum+i+1).createCell(6).setCellValue(bom.getSubCode());
                if(bom.getOldSubName()!=null&&!bom.getOldSubName().isEmpty()){
@@ -361,15 +359,15 @@
        }
    }
    //查询所有产品中没有与指定散装件关联的子件
    public Response getAllSubWithOutComponent(int componentId) {
        List<ProductBom> list=mapper.getAllSubWithOutComponent(componentId);
    public Response getAllSubWithOutMaterial(int MaterialId) {
        List<ProductBom> list=mapper.getAllSubWithOutMaterial(MaterialId);
        return new Response().setII(1,list.size()>0?true:false,list,"返回数据");
    }
    //根据母料型号查询子件信息及有最新版本关联的散装件信息
    public Response getSubByComponentProduct(String parentModel) {
        List<ProductBom> list=mapper.getSubByComponentProduct(parentModel);
    public Response getSubByMaterialProduct(String parentModel) {
        List<ProductBom> list=mapper.getSubByMaterialProduct(parentModel);
        //查询出存在替换关系得散装件
        List<ProductBom> replaceBoms=cponentMapper.getReplaceComponent(parentModel);
        List<ProductBom> replaceBoms=cponentMapper.getReplaceMaterial(parentModel);
        if(replaceBoms!=null&&replaceBoms.size()>0){
            replaceBoms.stream().forEach(replaceBom->{
                        //如果存在替换关系,查询出原子件的关联关系(将原子件名称放在oldSubName中)
@@ -378,8 +376,8 @@
                            replaceBom.setReplaceStatus(1);
                            if (replaceBom.getOldSubName() != null && !replaceBom.getOldSubName().isEmpty()) {
                                //查询出存在的旧的关联子件,还要与原BOM版本一致
                                List<Component> oldCponent = mapper.getOldComponent(replaceBom.getOldSubName());
                                replaceBom.setComponents(oldCponent);
                                List<Material> oldCponent = mapper.getOldMaterial(replaceBom.getOldSubName());
                                replaceBom.setMaterials(oldCponent);
                            }
                        }
                        list.add(replaceBom);
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -16,7 +16,6 @@
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Service
@@ -27,8 +26,8 @@
    @Resource
    private WorksheetLinkMapper linkMapper;
    @Autowired
    //lxw修改
    @Autowired(required = false)
    private ProductBomApprovingMapper approvingMapper;
    @Autowired
@@ -38,16 +37,16 @@
    private ProductBomHistoryService historyService;
    @Autowired
    private ComponentProductHistoryService cphService;
    private MaterialProductHistoryService cphService;
    @Autowired
    private ComponentProductApprovingService cpAService;
    private MaterialProductApprovingService cpAService;
    @Autowired
    private ComponentApprovingService cAService;
    private MaterialApprovingService cAService;
    @Autowired
    private ComponentService cService;
    private MaterialService cService;
    @Transactional
    public void audit(WorksheetLink link) {
@@ -56,7 +55,7 @@
        linkMapper.updateById(link);
        if(link.getLinkStatus() == 2){ //驳回
            //查看是否为散装件审批,是则需要更新散装件审批表中的状态为完结
            if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Component.getType())){
            if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Material.getType())){
                cAService.endStatus(link.getMainId());
            }
            //项目经理驳回,驳回即终止
@@ -154,14 +153,15 @@
                    his.setCategory(approvingBom.getCategory());
                    his.setCreateDate(approvingBom.getCreateDate());
                    his.setDwgUrl(approvingBom.getDwgUrl());
                    his.setEVersion(nextVersion);
                    //lxw注释
                    //his.setEVersion(nextVersion);
                    his.setFileUrl(approvingBom.getFileUrl());
                    his.setMaterial(approvingBom.getMaterial());
                    his.setNotes(approvingBom.getNotes());
                    his.setParentCode(approvingBom.getParentCode());
                    his.setParentModel(approvingBom.getParentModel());
                    his.setParentName(approvingBom.getParentName());
                    his.setParentVersion(approvingBom.getParentVersion());
                    //his.setParentCode(approvingBom.getParentCode());
                    //his.setParentModel(approvingBom.getParentModel());
                    //his.setParentName(approvingBom.getParentName());
                    //his.setParentVersion(approvingBom.getParentVersion());
                    his.setPictureUrl(approvingBom.getPictureUrl());
                    his.setProducer(approvingBom.getProducer());
                    his.setQuantity(approvingBom.getQuantity());
@@ -169,7 +169,7 @@
                    his.setSubModel(approvingBom.getSubModel());
                    his.setSubName(approvingBom.getSubName());
                    his.setSurfaceDetail(approvingBom.getSurfaceDetail());
                    his.setSVersion(nextVersion);
                    //his.setSVersion(nextVersion);
                    his.setThickness(approvingBom.getThickness());
                    his.setType(approvingBom.getType());
                    his.setUnit(approvingBom.getUnit());
@@ -187,13 +187,14 @@
                        .filter(currentHistory -> !approvingUpdateSubNameList.contains(currentHistory.getSubName()))
                        .collect(Collectors.toList());
                newVersionCurrentHistoryList.forEach(history -> {
                    history.setEVersion(nextVersion);
                    //lxw修改
                    //history.setEVersion(nextVersion);
                });
                if (newVersionCurrentHistoryList.size() != 0) {
                    historyService.updateVersionBatch(newVersionCurrentHistoryList);
                }
                //更新散件表当前版本,更新eVersion
                List<ComponentProductHistory> cphList = cphService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion);
                List<MaterialProductHistory> cphList = cphService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion);
                if(cphList.size()!=0){cphService.updateVersionBatch(cphList);}
                /*更新到product_bom*/
@@ -243,40 +244,42 @@
                //更新正式bom的对应url
                bomService.updateUrl(fileBomApprovingList);
            }
            else if(type.intValue() == EnumWorksheetType.Component.getType()){ //散装件
                List<ComponentApproving> approvingList = cAService.getListByMainId(link.getMainId());
                List<Component> componentList = new LinkedList<>();
            else if(type.intValue() == EnumWorksheetType.Material.getType()){ //散装件
                List<MaterialApproving> approvingList = cAService.getListByMainId(link.getMainId());
                List<Material> MaterialList = new LinkedList<>();
                //区分是新增还是删除
                Integer componentId = approvingList.get(0).getComponentId();
                if(componentId==null) { //新增
                Integer MaterialId = approvingList.get(0).getMaterialId();
                if(MaterialId==null) { //新增
                    //将散装件从审批表中转移到正式表
                    approvingList.forEach(approve -> {
                        Component component = new Component();
                        component.setCategory(approve.getCategory());
                        component.setSubCode(approve.getSubCode());
                        component.setSubName(approve.getSubName());
                        component.setSubModel(approve.getSubModel());
                        component.setUnit(approve.getUnit());
                        component.setQuantity(approve.getQuantity());
                        component.setProducer(approve.getProducer());
                        component.setNotes(approve.getNotes());
                        component.setCreateDate(new Date());
                        component.setStatus(1);
                        componentList.add(component);
                        Material Material = new Material();
                        Material.setCategory(approve.getCategory());
                        Material.setSubCode(approve.getSubCode());
                        Material.setSubName(approve.getSubName());
                        Material.setSubModel(approve.getSubModel());
                        Material.setUnit(approve.getUnit());
                        Material.setQuantity(approve.getQuantity());
                        Material.setProducer(approve.getProducer());
                        Material.setNotes(approve.getNotes());
                        Material.setCreateDate(new Date());
                        Material.setStatus(1);
                        MaterialList.add(Material);
                    });
                    cService.insertBatch(componentList);
                    cService.insertBatch(MaterialList);
                }else{ //删除
                    List<Integer> componentIdList = approvingList.stream().map(ComponentApproving::getComponentId).collect(Collectors.toList());
                    cService.deleteBatch(componentIdList);
                    List<Integer> MaterialIdList = approvingList.stream().map(MaterialApproving::getMaterialId).collect(Collectors.toList());
                    cService.deleteBatch(MaterialIdList);
                }
                //更新散装件审批子表中type为完结
                cAService.endStatus(link.getMainId());
            }
            else if(type.intValue() == EnumWorksheetType.ComponentProduct.getType()){ //更新散装件-产品关系
            else if(type.intValue() == EnumWorksheetType.MaterialProduct.getType()){ //更新散装件-产品关系
                //查找到对应的散装件-产品关系数据
                List<ComponentProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
                List<MaterialProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
                //查询部件最新的版本号
                ProductBom product = bomService.getProduct(cpAList.get(0).getParentModel());
                //lxw修改
                //ProductBom product = bomService.getProduct(cpAList.get(0).getParentModel());
                ProductBom product=new ProductBom();
                int currentVersion = -1;
                if (product != null) {
                    currentVersion = product.getVersion();
@@ -284,10 +287,10 @@
                Integer nextVersion = currentVersion + 1;
                //关联/接触关联,更新版本
                //替换,更新版本,同时bom表历史中对应的subName 版本号不变(排除更新)
                Map<Integer, List<ComponentProductApproving>> linkTypeMap = cpAList.stream().collect(Collectors.groupingBy(ComponentProductApproving::getLinkType));
                List<ComponentProductApproving> addedList = new LinkedList<>();
                List<ComponentProductApproving> replacedList = new LinkedList<>();
                List<ComponentProductApproving> removedList = new LinkedList<>();
                Map<Integer, List<MaterialProductApproving>> linkTypeMap = cpAList.stream().collect(Collectors.groupingBy(MaterialProductApproving::getLinkType));
                List<MaterialProductApproving> addedList = new LinkedList<>();
                List<MaterialProductApproving> replacedList = new LinkedList<>();
                List<MaterialProductApproving> removedList = new LinkedList<>();
                linkTypeMap.forEach((linkType,list)->{
                    if(linkType == 1){
                        addedList.addAll(list);
@@ -297,12 +300,14 @@
                        removedList.addAll(list);
                    }
                });
                List<ComponentProductHistory> newHistoryList = new LinkedList<>();
                List<MaterialProductHistory> newHistoryList = new LinkedList<>();
                //查询最新版本生效的相关散装件
                List<ComponentProductHistory> nowHistoryList = cphService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
                //lxw注释
                //List<MaterialProductHistory> nowHistoryList = cphService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
                List<MaterialProductHistory> nowHistoryList =new ArrayList<>();
                //查询历史中最新版本生效的bom
                List<ProductBomHistory> nowBomHistoryList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
                //List<ProductBomHistory> nowBomHistoryList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
                List<ProductBomHistory> nowBomHistoryList = new ArrayList<>();
                /*
                对于关联的,判断当前版本中是否存在替换关系,存在,则直接下个版本插入关联;
                同时,其他当前版本的相关散装件-产品记录更新版本,排除存在的替换关系
@@ -319,19 +324,20 @@
                if(removedList.size()!=0){
                    removedList.forEach(remove -> {
                        /*nowHistoryList.forEach(nowHistory -> {
                            if (remove.getComponentId().intValue() == nowHistory.getComponentId()) {
                            if (remove.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                                nowHistoryList.remove(nowHistory);
                            }
                        });*/
                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                        Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
                        while (iterator.hasNext()){
                            ComponentProductHistory next = iterator.next();
                            if(remove.getComponentId().intValue() == next.getComponentId()
                            MaterialProductHistory next = iterator.next();
                            //lxw注释
                            /*if(remove.getMaterialId().intValue() == next.getMaterialId()
                                &&remove.getSubName().equals(next.getSubName())
                            ){
                                iterator.remove();
                                break;
                            }
                            }*/
                        }
                    });
                }
@@ -341,32 +347,34 @@
                    replacedList.forEach(replace -> {
                        //当前生效的散装件-产品列表
                        /*nowHistoryList.forEach(nowHistory -> {
                            if (replace.getComponentId().intValue() == nowHistory.getComponentId()) {
                            if (replace.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                                nowHistoryList.remove(nowHistory);
                            }
                        });*/
                        if(nowHistoryList.size()!=0) {
                            Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                            Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
                            while (iterator.hasNext()) {
                                ComponentProductHistory next = iterator.next();
                                if (replace.getComponentId().intValue() == next.getComponentId()
                                MaterialProductHistory next = iterator.next();
                                //lxw注释
                                /*if (replace.getMaterialId().intValue() == next.getMaterialId()
                                        && replace.getSubName().equals(next.getSubName())
                                ) {
                                    iterator.remove();
                                    break;
                                }
                                }*/
                            }
                        }
                        //下个版本新增替换的散装件-产品列表
                        ComponentProductHistory newHistory = new ComponentProductHistory();
                        newHistory.setComponentId(replace.getComponentId());
                        newHistory.setParentModel(replace.getParentModel());
                        newHistory.setSubName(replace.getSubName());
                        MaterialProductHistory newHistory = new MaterialProductHistory();
                        newHistory.setMaterialId(replace.getMaterialId());
                        //lxw注释
                        //newHistory.setParentModel(replace.getParentModel());
                        //newHistory.setSubName(replace.getSubName());
                        newHistory.setQuantity(replace.getQuantity());
                        newHistory.setCreateTime(new Date());
                        newHistory.setLinkType(2);
                        newHistory.setSVersion(nextVersion);
                        newHistory.setEVersion(nextVersion);
                        //newHistory.setSVersion(nextVersion);
                        //newHistory.setEVersion(nextVersion);
                        newHistoryList.add(newHistory);
                        //当前生效的bom列表
                        /*nowBomHistoryList.forEach(nowBomHistory->{
@@ -376,10 +384,11 @@
                        });*/
                        Iterator<ProductBomHistory> iterator1 = nowBomHistoryList.iterator();
                        while (iterator1.hasNext()){
                            if(replace.getSubName().equals(iterator1.next().getSubName())){
                            //lxw注释
                            /*if(replace.getSubName().equals(iterator1.next().getSubName())){
                                iterator1.remove();
                                break;
                            }
                            }*/
                        }
                    });
                }
@@ -387,47 +396,50 @@
                //处理关联
                addedList.forEach(add -> {
                    /*nowHistoryList.forEach(nowHistory -> {
                        if (add.getComponentId().intValue() == nowHistory.getComponentId()) {
                        if (add.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                            nowHistoryList.remove(nowHistory);
                        }
                    });*/
                    if(nowHistoryList.size()!=0) {
                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                        Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
                        while (iterator.hasNext()) {
                            ComponentProductHistory next = iterator.next();
                            if (add.getComponentId().intValue() == next.getComponentId()
                            MaterialProductHistory next = iterator.next();
                            //lxw注释
                            /*if (add.getMaterialId().intValue() == next.getMaterialId()
                                    && add.getSubName().equals(next.getSubName())
                            ) {
                                iterator.remove();
                                break;
                            }
                            }*/
                        }
                    }
                    ComponentProductHistory newHistory = new ComponentProductHistory();
                    newHistory.setComponentId(add.getComponentId());
                    newHistory.setParentModel(add.getParentModel());
                    newHistory.setSubName(add.getSubName());
                    MaterialProductHistory newHistory = new MaterialProductHistory();
                    newHistory.setMaterialId(add.getMaterialId());
                    //newHistory.setParentModel(add.getParentModel());
                    //newHistory.setSubName(add.getSubName());
                    newHistory.setQuantity(add.getQuantity());
                    newHistory.setCreateTime(new Date());
                    newHistory.setLinkType(1);
                    newHistory.setSVersion(nextVersion);
                    newHistory.setEVersion(nextVersion);
                    //newHistory.setSVersion(nextVersion);
                    //newHistory.setEVersion(nextVersion);
                    newHistoryList.add(newHistory);
                });
                //处理完成,进行表单数据更新,分为nowHistoryList,newHistoryList,nowBomHistoryList
                //nowHistoryList.forEach(nowHis->nowHis.setEVersion(nextVersion));
                if(newHistoryList.size()!=0){newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});}
                if(nowBomHistoryList.size()!=0){nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));}
                //lxw注释
                //if(newHistoryList.size()!=0){newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});}
                //if(nowBomHistoryList.size()!=0){nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));}
                if(nowHistoryList.size()!=0){cphService.updateVersionBatch(nowHistoryList);}
                if(newHistoryList.size()!=0){cphService.insertBatch(newHistoryList);}
                if(nowBomHistoryList.size()!=0){historyService.updateVersionBatch(nowBomHistoryList);}
                //更新ProductBom
                List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion);
                bomService.updateNewBom(newBomList);
                //lxw注释
                //List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion);
                //bomService.updateNewBom(newBomList);
            }
            else if(type.intValue() == EnumWorksheetType.ProductSoftware.getType()){
                //转移记录
src/main/java/com/whyc/service/WorksheetMainService.java
@@ -12,7 +12,6 @@
import com.whyc.mapper.WorksheetLinkMapper;
import com.whyc.mapper.WorksheetMainMapper;
import com.whyc.pojo.*;
import com.whyc.util.ActionUtil;
import com.whyc.util.CommonUtil;
import com.whyc.util.Zip4jUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,19 +48,19 @@
    private ProductBomApprovingService approvingService;
    @Autowired
    private ComponentProductApprovingService cpApprovingService;
    private MaterialProductApprovingService cpApprovingService;
    @Autowired
    private ComponentApprovingService cApprovingService;
    private MaterialApprovingService cApprovingService;
    @Autowired
    private ComponentService cService;
    private MaterialService cService;
    @Autowired
    private ProductBomService pbService;
    @Autowired
    private ComponentProductHistoryService cphService;
    private MaterialProductHistoryService cphService;
    @Autowired
    private ProductSoftwareApprovingService psaService;
@@ -127,7 +126,8 @@
        bomList.forEach(bom->{
            bom.setMainId(main.getId());
            bom.setUpUserId(user.getId());
            bom.setRejectVersion(nextRejectVersion);
            //lxw注释
            //bom.setRejectVersion(nextRejectVersion);
            bom.setCreateDate(new Date());
            if(bom.getDwgUrl()==null){
                bom.setDwgUrl("");
@@ -149,14 +149,14 @@
        return true;
    }
    public boolean componentProductSubmit(WorksheetMainDTO mainDTO, DocUser user) {
        List<ComponentProductApproving> approvingList = new LinkedList<>();
    public boolean MaterialProductSubmit(WorksheetMainDTO mainDTO, DocUser user) {
        List<MaterialProductApproving> approvingList = new LinkedList<>();
        WorksheetMain main = mainDTO.getMain();
        List<ComponentProductApproving> addedList = mainDTO.getAddedList();
        List<ComponentProductApproving> replacedList = mainDTO.getReplacedList();
        List<ComponentProductApproving> removedList = mainDTO.getRemovedList();
        List<MaterialProductApproving> addedList = mainDTO.getAddedList();
        List<MaterialProductApproving> replacedList = mainDTO.getReplacedList();
        List<MaterialProductApproving> removedList = mainDTO.getRemovedList();
        main.setType(EnumWorksheetType.ComponentProduct.getType());
        main.setType(EnumWorksheetType.MaterialProduct.getType());
        //提交主表
        main.setCreateUserId(user.getId());
        //提交人角色来判断工作流层级
@@ -227,33 +227,33 @@
        return true;
    }
    public Response componentSubmit(WorksheetMain main, DocUser user) {
    public Response MaterialSubmit(WorksheetMain main, DocUser user) {
        Response<Object> response = new Response<>();
        List<ComponentApproving> cApprovingList = main.getCApprovingList();
        List<MaterialApproving> cApprovingList = main.getCApprovingList();
        //判断是新增还是删除
        boolean isAdded = cApprovingList.get(0).getSubName()!=null;
        if(isAdded) { //新增
            //查询是否有 已生效或者已提交审批的 相同的散装件
            List<Component> existComponentList = new LinkedList<>();
            List<ComponentApproving> existCAList = new LinkedList<>();
            List<Material> existMaterialList = new LinkedList<>();
            List<MaterialApproving> existCAList = new LinkedList<>();
            List<Component> componentList = cService.getList();
            List<ComponentApproving> cAList = cApprovingService.getListByStatus(1);
            List<Material> MaterialList = cService.getList();
            List<MaterialApproving> cAList = cApprovingService.getListByStatus(1);
            for (int i = 0; i < cApprovingList.size(); i++) {
                ComponentApproving componentApproving = cApprovingList.get(i);
                for (int j = 0; j < componentList.size(); j++) {
                    if (componentApproving.getSubCode().equals(componentList.get(j).getSubCode())
                            && componentApproving.getSubName().equals(componentList.get(j).getSubName())
                            && componentApproving.getSubModel().equals(componentList.get(j).getSubModel())
                MaterialApproving MaterialApproving = cApprovingList.get(i);
                for (int j = 0; j < MaterialList.size(); j++) {
                    if (MaterialApproving.getSubCode().equals(MaterialList.get(j).getSubCode())
                            && MaterialApproving.getSubName().equals(MaterialList.get(j).getSubName())
                            && MaterialApproving.getSubModel().equals(MaterialList.get(j).getSubModel())
                    ) {
                        existComponentList.add(componentList.get(j));
                        existMaterialList.add(MaterialList.get(j));
                    }
                }
                for (int j = 0; j < cAList.size(); j++) {
                    if (componentApproving.getSubCode().equals(cAList.get(j).getSubCode())
                            && componentApproving.getSubName().equals(cAList.get(j).getSubName())
                            && componentApproving.getSubModel().equals(cAList.get(j).getSubModel())
                    if (MaterialApproving.getSubCode().equals(cAList.get(j).getSubCode())
                            && MaterialApproving.getSubName().equals(cAList.get(j).getSubName())
                            && MaterialApproving.getSubModel().equals(cAList.get(j).getSubModel())
                    ) {
                        existCAList.add(cAList.get(j));
                    }
@@ -261,31 +261,32 @@
            }
            int existCASize = existCAList.size();
            int existComponentSize = existComponentList.size();
            int existMaterialSize = existMaterialList.size();
            if (existCASize != 0) {
                if (existComponentSize != 0) {
                    response.setII(21, existCAList, existComponentList, "重复提交:现有散装件及正在进行审批的散装件中,存在当前提交上传的散装件");
                if (existMaterialSize != 0) {
                    response.setII(21, existCAList, existMaterialList, "重复提交:现有散装件及正在进行审批的散装件中,存在当前提交上传的散装件");
                } else {
                    response.set(22, existCAList, "重复提交:正在进行审批的散装件中,存在当前提交上传的散装件");
                }
                return response;
            } else {
                if (existComponentSize != 0) {
                    return response.setII(23, null, existComponentList, "重复提交:现有散装件中,存在当前提交上传的散装件");
                if (existMaterialSize != 0) {
                    return response.setII(23, null, existMaterialList, "重复提交:现有散装件中,存在当前提交上传的散装件");
                }
            }
        }else{ //删除
            //判断是否在散装件审批删除中,是否存在产品关联及关联审批
            ComponentApproving deleteApproving = new ComponentApproving();
            List<ComponentProductHistory> existComponentProducts = new LinkedList<>();
            List<ComponentProductApproving> existComponentProductApprovingList = new LinkedList<>();
            deleteApproving = cApprovingService.getListByComponentId(cApprovingList.get(0).getComponentId());
            MaterialApproving deleteApproving = new MaterialApproving();
            List<MaterialProductHistory> existMaterialProducts = new LinkedList<>();
            List<MaterialProductApproving> existMaterialProductApprovingList = new LinkedList<>();
            deleteApproving = cApprovingService.getListByMaterialId(cApprovingList.get(0).getMaterialId());
            //查看产品关联
            List<ComponentProductHistory> cphLatestExistList =  cphService.getLatestExistListByComponentId(cApprovingList.get(0).getComponentId());
            List<MaterialProductHistory> cphLatestExistList =  cphService.getLatestExistListByMaterialId(cApprovingList.get(0).getMaterialId());
            //查看产品关联审批
            List<ComponentProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByComponentId(cApprovingList.get(0).getComponentId());
            //lxw注释
            //List<MaterialProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByMaterialId(cApprovingList.get(0).getMaterialId());
            List<MaterialProductApproving> cpaLatestExistList =new ArrayList<>();
            if(deleteApproving!=null){
                return response.set(31,deleteApproving,"拒绝本次删除申请,当前散装件正在进行删除审批");
            }
@@ -302,7 +303,7 @@
            }
        }
        main.setType(EnumWorksheetType.Component.getType());
        main.setType(EnumWorksheetType.Material.getType());
        //提交主表
        main.setCreateUserId(user.getId());
        //提交人角色来判断工作流层级
@@ -588,10 +589,13 @@
        Integer type = getInfoById(id).getType();
        if(type.intValue() == EnumWorksheetType.ProductBom.getType()) {
            return mainMapper.getLinkList(id);
        }else if(type.intValue() == EnumWorksheetType.Component.getType()){
            return mainMapper.getLinkListWithComponents(id);
        }else if(type.intValue() == EnumWorksheetType.Material.getType()){
            //lxw注释
            //return mainMapper.getLinkListWithMaterials(id);
            return null;
        }else{ //散装件-产品
            return mainMapper.getLinkListWithComponentProducts(id);
            //return mainMapper.getLinkListWithMaterialProducts(id);
            return null;
        }
    }
src/main/resources/mapper/ComponentProductApprovingMapper.xml
File was deleted
src/main/resources/mapper/ComponentProductHistoryMapper.xml
File was deleted
src/main/resources/mapper/MaterialMapper.xml
File was renamed from src/main/resources/mapper/ComponentMapper.xml
@@ -1,18 +1,18 @@
<?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.whyc.mapper.ComponentMapper">
<mapper namespace="com.whyc.mapper.MaterialMapper">
    <select id="getComponentWithoutSub" resultType="com.whyc.pojo.Component">
        select * from  db_doc.tb_component  b
        where (select count(1) as num from  db_doc.tb_component_product_history  c
               where b.id= c.component_id   and c.sub_name=#{subName} and parent_model=#{parentModel}
    <select id="getMaterialWithoutSub" resultType="com.whyc.pojo.Material">
        select * from  db_doc.tb_Material  b
        where (select count(1) as num from  db_doc.tb_Material_product_history  c
               where b.id= c.Material_id   and c.sub_name=#{subName} and parent_model=#{parentModel}
               and c.e_version=#{version}
             ) = 0
        and b.status=1;
    </select>
    <resultMap id="productBomList" type="component">
    <resultMap id="productBomList" type="Material">
        <id property="id" column="id"></id>
        <result property="type" column="type"></result>
        <result property="category" column="category"></result>
@@ -32,12 +32,12 @@
        <result property="createDate" column="create_date"></result>
        <result property="updateDate" column="update_date"></result>
        <result property="dwgUrl" column="dwg_url"></result>
        <collection property="cProductHistorys" javaType="java.util.ArrayList" ofType="com.whyc.pojo.ComponentProductHistory" column="{id=id}" select="selectComponentProductHistory">
        <collection property="cProductHistorys" javaType="java.util.ArrayList" ofType="com.whyc.pojo.MaterialProductHistory" column="{id=id}" select="selectMaterialProductHistory">
        </collection>
    </resultMap>
    <select id="getAllComponent" resultMap="productBomList">
        select distinct * from  db_doc.tb_component
    <select id="getAllMaterial" resultMap="productBomList">
        select distinct * from  db_doc.tb_Material
        <where>
        1=1
            <if test="category!=null&amp;&amp;category!=''">
@@ -55,17 +55,17 @@
        </where>
        order by id asc
    </select>
    <select id="selectComponentProductHistory"  resultType="com.whyc.pojo.ComponentProductHistory">
        select DISTINCT tb_component_product_history.*  FROM db_doc.tb_product_bom,db_doc.tb_component_product_history
        where  tb_product_bom.version=tb_component_product_history.e_version
        and tb_product_bom.parent_model=tb_component_product_history.parent_model and tb_component_product_history.component_id=#{id}
    <select id="selectMaterialProductHistory"  resultType="com.whyc.pojo.MaterialProductHistory">
        select DISTINCT tb_Material_product_history.*  FROM db_doc.tb_product_bom,db_doc.tb_Material_product_history
        where  tb_product_bom.version=tb_Material_product_history.e_version
        and tb_product_bom.parent_model=tb_Material_product_history.parent_model and tb_Material_product_history.Material_id=#{id}
    </select>
    <resultMap id="replaceBom" type="productBom">
        <result property="parentCode" column="parent_code"></result>
       <!-- <result property="parentCode" column="parent_code"></result>
        <result property="parentModel" column="parent_model"></result>
        <result property="parentName" column="parent_name"></result>
        <result property="parentName" column="parent_name"></result>-->
        <result property="oldSubName" column="old_subName"></result>
        <result property="type" column="type"></result>
        <result property="category" column="category"></result>
@@ -83,26 +83,26 @@
        <result property="fileUrl" column="file_url"></result>
        <result property="upUserId" column="up_user_id"></result>
        <result property="createDate" column="create_date"></result>
        <result property="updateDate" column="update_date"></result>
        <!--<result property="updateDate" column="update_date"></result>-->
        <result property="dwgUrl" column="dwg_url"></result>
        <result property="version" column="version"></result>
        <result property="parentVersion" column="parent_version"></result>
        <!--<result property="parentVersion" column="parent_version"></result>-->
    </resultMap>
    <select id="getReplaceComponent" resultMap="replaceBom">
        select distinct tb_component.*,tb_component_product_history.sub_name as old_subName
    <select id="getReplaceMaterial" resultMap="replaceBom">
        select distinct tb_Material.*,tb_Material_product_history.sub_name as old_subName
             ,tb_product_bom.parent_model,tb_product_bom.parent_code,tb_product_bom.parent_name
        ,tb_component_product_history.e_version as version
        from db_doc.tb_component,db_doc.tb_component_product_history,tb_product_bom
        where tb_component.id=tb_component_product_history.component_id
        and tb_component_product_history.parent_model=tb_product_bom.parent_model
        and tb_product_bom.version=tb_component_product_history.e_version
        and tb_component_product_history.parent_model=#{parentModel}
        and tb_component_product_history.link_type=2
        ,tb_Material_product_history.e_version as version
        from db_doc.tb_Material,db_doc.tb_Material_product_history,tb_product_bom
        where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.parent_model=tb_product_bom.parent_model
        and tb_product_bom.version=tb_Material_product_history.e_version
        and tb_Material_product_history.parent_model=#{parentModel}
        and tb_Material_product_history.link_type=2
    </select>
    <resultMap id="replaceHisBom" type="productBomHistory">
        <result property="parentCode" column="parent_code"></result>
        <!--<result property="parentCode" column="parent_code"></result>
        <result property="parentModel" column="parent_model"></result>
        <result property="parentName" column="parent_name"></result>
        <result property="parentName" column="parent_name"></result>-->
        <result property="oldSubName" column="old_subName"></result>
        <result property="type" column="type"></result>
        <result property="category" column="category"></result>
@@ -121,17 +121,17 @@
        <result property="upUserId" column="up_user_id"></result>
        <result property="createDate" column="create_date"></result>
        <result property="dwgUrl" column="dwg_url"></result>
        <result property="parentVersion" column="parent_version"></result>
       <!-- <result property="parentVersion" column="parent_version"></result>-->
    </resultMap>
    <select id="getReplaceHisComponent" resultMap="replaceHisBom">
        select distinct tb_component.*,tb_component_product_history.sub_name as old_subName
    <select id="getReplaceHisMaterial" resultMap="replaceHisBom">
        select distinct tb_Material.*,tb_Material_product_history.sub_name as old_subName
                      ,tb_product_bom.parent_model,tb_product_bom.parent_code,tb_product_bom.parent_name
        from db_doc.tb_component,db_doc.tb_component_product_history,tb_product_bom
        where tb_component.id=tb_component_product_history.component_id
          and tb_component_product_history.parent_model=tb_product_bom.parent_model
          and tb_component_product_history.parent_model=#{parentModel}
          and tb_component_product_history.link_type=2
          and tb_component_product_history.s_version&lt;=#{version}
          and tb_component_product_history.e_version>=#{version}
        from db_doc.tb_Material,db_doc.tb_Material_product_history,tb_product_bom
        where tb_Material.id=tb_Material_product_history.Material_id
          and tb_Material_product_history.parent_model=tb_product_bom.parent_model
          and tb_Material_product_history.parent_model=#{parentModel}
          and tb_Material_product_history.link_type=2
          and tb_Material_product_history.s_version&lt;=#{version}
          and tb_Material_product_history.e_version>=#{version}
    </select>
</mapper>
src/main/resources/mapper/MaterialProductApprovingMapper.xml
New file
@@ -0,0 +1,12 @@
<?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.whyc.mapper.MaterialProductApprovingMapper" >
    <select id="getLatestExistListByMaterialId" resultType="com.whyc.pojo.MaterialProductApproving">
        SELECT a.* FROM db_doc.tb_Material_product_approving a,db_doc.tb_worksheet_main m
        where a.main_id = m.id
        and m.status not in(0,5)
        and Material_id = #{MaterialId}
    </select>
</mapper>
src/main/resources/mapper/MaterialProductHistoryMapper.xml
New 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.whyc.mapper.MaterialProductHistoryMapper">
    <update id="updateVersionBatch">
        <foreach collection="list" item="his" separator=";">
            update db_doc.tb_Material_product_history set e_version = e_version+1 where id = #{his.id}
        </foreach>
    </update>
    <select id="getLatestExistListByMaterialId" resultType="com.whyc.pojo.MaterialProductHistory">
        SELECT
        h.*
        FROM
        db_doc.tb_Material_product_history h,
        db_doc.tb_product_bom b
        WHERE
        h.parent_model = b.parent_model
        AND b.version = h.e_version
        AND h.Material_id = #{MaterialId}
    </select>
</mapper>
src/main/resources/mapper/ProductBomMapper.xml
@@ -53,19 +53,19 @@
        </where>
    </select>
    <select id="getAllSubWithOutComponent" resultType="com.whyc.pojo.ProductBom">
    <select id="getAllSubWithOutMaterial" resultType="com.whyc.pojo.ProductBom">
        select * from  db_doc.tb_product_bom  b
        where (select count(1) as num from  db_doc.tb_component_product_history  c
        where (select count(1) as num from  db_doc.tb_Material_product_history  c
               where b.parent_model= c.parent_model  and b.sub_name= c.sub_name  and b.version=c.e_version
                and c.component_id=#{componentId}
                and c.Material_id=#{MaterialId}
              ) = 0
    </select>
    <resultMap id="componentList" type="productBom">
    <resultMap id="MaterialList" type="productBom">
        <id property="id" column="id"></id>
        <result property="parentCode" column="parent_code"></result>
        <!--<result property="parentCode" column="parent_code"></result>
        <result property="parentName" column="parent_name"></result>
        <result property="parentModel" column="parent_model"></result>
        <result property="parentModel" column="parent_model"></result>-->
        <result property="type" column="type"></result>
        <result property="category" column="category"></result>
        <result property="subCode" column="sub_code"></result>
@@ -82,16 +82,16 @@
        <result property="fileUrl" column="file_url"></result>
        <result property="upUserId" column="up_user_id"></result>
        <result property="createDate" column="create_date"></result>
        <result property="updateDate" column="update_date"></result>
       <!-- <result property="updateDate" column="update_date"></result>-->
        <result property="version" column="version"></result>
        <result property="dwgUrl" column="dwg_url"></result>
        <result property="parentVersion" column="parent_version"></result>
        <!--<result property="parentVersion" column="parent_version"></result>-->
        <result property="replaceStatus" column="replaceStatus"></result>
        <collection property="components" javaType="java.util.ArrayList" ofType="com.whyc.pojo.Component" column="{subName=sub_name,parentModel=parent_model,eVersion=version}" select="selectComponent">
        <collection property="Materials" javaType="java.util.ArrayList" ofType="com.whyc.pojo.Material" column="{subName=sub_name,parentModel=parent_model,eVersion=version}" select="selectMaterial">
        </collection>
    </resultMap>
    <select id="getSubByComponentProduct" resultMap="componentList" parameterType="java.lang.String">
    <select id="getSubByMaterialProduct" resultMap="MaterialList" parameterType="java.lang.String">
        select distinct *,0 as replaceStatus from  db_doc.tb_product_bom
        <where>
            parent_model = #{parentModel}
@@ -99,18 +99,18 @@
        order by id asc
    </select>
    <select id="selectComponent"  resultType="com.whyc.pojo.Component">
        select DISTINCT tb_component.*  FROM db_doc.tb_component,db_doc.tb_component_product_history where tb_component.id=tb_component_product_history.component_id
        and tb_component_product_history.sub_name=#{subName} and tb_component_product_history.parent_model=#{parentModel}
        and tb_component_product_history.e_version=#{eVersion}
    <select id="selectMaterial"  resultType="com.whyc.pojo.Material">
        select DISTINCT tb_Material.*  FROM db_doc.tb_Material,db_doc.tb_Material_product_history where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.sub_name=#{subName} and tb_Material_product_history.parent_model=#{parentModel}
        and tb_Material_product_history.e_version=#{eVersion}
    </select>
    <select id="getOldComponent"  resultType="com.whyc.pojo.Component">
        select DISTINCT tb_component.*
        FROM db_doc.tb_component,db_doc.tb_component_product_history,tb_product_bom
        where tb_component.id=tb_component_product_history.component_id
        and tb_component_product_history.parent_model=tb_product_bom.parent_model
        and tb_component_product_history.sub_name=#{oldSubName} and tb_component_product_history.link_type=1
        and tb_component_product_history.e_version=tb_product_bom.version
    <select id="getOldMaterial"  resultType="com.whyc.pojo.Material">
        select DISTINCT tb_Material.*
        FROM db_doc.tb_Material,db_doc.tb_Material_product_history,tb_product_bom
        where tb_Material.id=tb_Material_product_history.Material_id
        and tb_Material_product_history.parent_model=tb_product_bom.parent_model
        and tb_Material_product_history.sub_name=#{oldSubName} and tb_Material_product_history.link_type=1
        and tb_Material_product_history.e_version=tb_product_bom.version
    </select>
</mapper>
src/main/resources/mapper/WorksheetLinkMapper.xml
@@ -23,9 +23,9 @@
            <result column="status" property="status"/>
            <result column="end_reason" property="endReason"/>
            <result column="create_user_id" property="createUserId"/>
            <association property="createUser" column="create_user_id" javaType="com.whyc.pojo.DocUser" select="getUser">
            <!--<association property="createUser" column="create_user_id" javaType="com.whyc.pojo.DocUser" select="getUser">
                <result column="name" property="name"/>
            </association>
            </association>-->
        </association>
    </resultMap>
    <select id="getInfoList" resultMap="Map_WorksheetLink">
src/main/resources/mapper/WorksheetMainMapper.xml
@@ -28,9 +28,9 @@
            <result column="enable_archive" property="enableArchive"/>
            <result column="create_time" property="createTime"/>
            <result column="deal_time" property="dealTime"/>
            <association property="dealUser" column="deal_user_id" javaType="com.whyc.pojo.DocUser" select="getUser">
            <!--<association property="dealUser" column="deal_user_id" javaType="com.whyc.pojo.DocUser" select="getUser">
                <result column="name" property="name"/>
            </association>
            </association>-->
        </collection>
    </resultMap>
    <resultMap id="Map_WorksheetMain2" type="WorksheetMain" extends="Map_WorksheetMain">
@@ -54,12 +54,12 @@
            <result column="file_url" property="fileUrl"/>
            <result column="dwg_url" property="dwgUrl"/>
            <result column="create_date" property="createDate"/>
            <result column="update_date" property="updateDate"/>
            <result column="parent_version" property="parentVersion"/>
            <!--<result column="update_date" property="updateDate"/>
            <result column="parent_version" property="parentVersion"/>-->
        </collection>
    </resultMap>
    <resultMap id="Map_WorksheetMain3" type="WorksheetMain" extends="Map_WorksheetMain">
        <collection property="cApprovingList" ofType="ComponentApproving">
        <collection property="cApprovingList" ofType="MaterialApproving">
            <result column="type" property="type"/>
            <result column="category" property="category"/>
            <result column="sub_code" property="subCode"/>
@@ -77,9 +77,9 @@
            <result column="dwg_url" property="dwgUrl"/>
            <result column="create_date" property="createDate"/>
            <result column="update_date" property="updateDate"/>
            <result column="operation_type" property="operationType"/>
            <result column="component_id" property="componentId"/>
            <association column="component_id" property="component" javaType="Component" select="getComponent">
           <!-- <result column="operation_type" property="operationType"/>
            <result column="Material_id" property="MaterialId"/>
            <association column="Material_id" property="Material" javaType="Material" select="getMaterial">
                <result column="category" property="category"/>
                <result column="sub_code" property="subCode"/>
                <result column="sub_name" property="subName"/>
@@ -88,16 +88,16 @@
                <result column="unit" property="unit"/>
                <result column="producer" property="producer"/>
                <result column="notes" property="notes"/>
            </association>
            </association>-->
        </collection>
    </resultMap>
    <resultMap id="Map_WorksheetMain4" type="WorksheetMain" extends="Map_WorksheetMain">
        <collection property="cpApprovingList" ofType="ComponentProductApproving">
            <result column="parent_model" property="parentModel" />
        <collection property="cpApprovingList" ofType="MaterialProductApproving">
           <!-- <result column="parent_model" property="parentModel" />
            <result column="sub_name" property="subName"/>
            <result column="link_type" property="linkType"/>
            <result column="component_id" property="componentId"/>
            <association column="component_id" property="component" javaType="Component" select="getComponent">
            <result column="Material_id" property="MaterialId"/>
            <association column="Material_id" property="Material" javaType="Material" select="getMaterial">
                <result column="category" property="category"/>
                <result column="sub_code" property="subCode"/>
                <result column="sub_name" property="subName"/>
@@ -106,7 +106,7 @@
                <result column="unit" property="unit"/>
                <result column="producer" property="producer"/>
                <result column="notes" property="notes"/>
            </association>
            </association>-->
        </collection>
    </resultMap>
@@ -128,10 +128,10 @@
    <select id="getUser" resultType="com.whyc.pojo.DocUser">
        select name from db_doc.tb_doc_user where id =#{user_id}
    </select>
    <select id="getComponent" resultType="Component">
        select category,sub_code,sub_name,sub_model,unit,quantity,producer,notes from db_doc.tb_component where id =#{component_id}
    <select id="getMaterial" resultType="Material">
        select category,sub_code,sub_name,sub_model,unit,quantity,producer,notes from db_doc.tb_Material where id =#{Material_id}
    </select>
    <select id="getLinkListWithComponents" resultMap="Map_WorksheetMain3">
    <select id="getLinkListWithMaterials" resultMap="Map_WorksheetMain3">
        SELECT
        m.id mid,m.title,m.description,m.file,m.create_user_id,m.begin_time,m.end_time,m.level,m.status,m.end_reason,m.type mType,
        l.id lid,l.parent_id,deal_user_id,deal_type,deal_desc,deal_reason,link_file,link_status,enable_archive,create_time,deal_time,
@@ -141,11 +141,11 @@
        LEFT JOIN
        tb_worksheet_link l ON m.id = l.main_id
        LEFT JOIN
        tb_component_approving c ON m.id = c.main_id
        tb_Material_approving c ON m.id = c.main_id
        WHERE
        m.id = #{id}
    </select>
    <select id="getLinkListWithComponentProducts" resultMap="Map_WorksheetMain4">
    <select id="getLinkListWithMaterialProducts" resultMap="Map_WorksheetMain4">
        SELECT
        m.id mid,m.title,m.description,m.file,m.create_user_id,m.begin_time,m.end_time,m.level,m.status,m.end_reason,m.type mType,
        l.id lid,l.parent_id,deal_user_id,deal_type,deal_desc,deal_reason,link_file,link_status,enable_archive,create_time,deal_time,
@@ -155,7 +155,7 @@
        LEFT JOIN
        tb_worksheet_link l ON m.id = l.main_id
        LEFT JOIN
        tb_component_product_approving cp ON m.id = cp.main_id
        tb_Material_product_approving cp ON m.id = cp.main_id
        WHERE
        m.id = #{id}
    </select>