src/main/java/com/whyc/mapper/ProductBomMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/ProductBomService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/WorksheetLinkService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/ProductBomMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/mapper/ProductBomMapper.java
@@ -1,10 +1,14 @@ package com.whyc.mapper; import com.whyc.pojo.ProductBom; import com.whyc.pojo.ProductBomApproving; import java.util.List; public interface ProductBomMapper extends CustomMapper<ProductBom>{ //图纸分类检索 List<ProductBom> searchCadDrawer(ProductBom productBom); void updateUrl(List<ProductBomApproving> fileBomApprovingList); } src/main/java/com/whyc/service/ProductBomService.java
@@ -10,6 +10,7 @@ import com.whyc.dto.ZipUtils; import com.whyc.mapper.ProductBomMapper; import com.whyc.pojo.ProductBom; import com.whyc.pojo.ProductBomApproving; import com.whyc.pojo.ProductBomHistory; import com.whyc.util.ActionUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -162,4 +163,8 @@ e.printStackTrace(); } } public void updateUrl(List<ProductBomApproving> fileBomApprovingList) { mapper.updateUrl(fileBomApprovingList); } } src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -5,11 +5,15 @@ import com.whyc.mapper.ProductBomApprovingMapper; import com.whyc.mapper.WorksheetLinkMapper; import com.whyc.pojo.*; import com.whyc.util.CommonUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.FileCopyUtils; import javax.annotation.Resource; import java.io.File; import java.io.IOException; import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -173,7 +177,35 @@ FileUtil.copyDir()*/ //将产品bom表的url修正,更新到正式表 TODO /*将产品bom表的url修正,更新到正式表*/ //审批完后,将本次的bom带url的全部复制到正式文件夹中 List<ProductBomApproving> fileBomApprovingList = approvingList.stream() .filter(productBomApproving -> productBomApproving.getPictureUrl() != null || productBomApproving.getDwgUrl() != null ).collect(Collectors.toList()); String projectDir = CommonUtil.getProjectDir(); fileBomApprovingList.forEach(fileBom->{ try { String pictureUrl = fileBom.getPictureUrl(); String dwgUrl = fileBom.getDwgUrl(); if(pictureUrl !=null){ String newPictureUrl ="doc_file"+File.separator+"product"+File.separator+fileBom.getParentModel()+File.separator+ pictureUrl.substring(pictureUrl.lastIndexOf(File.separator)+1); FileCopyUtils.copy(new File(projectDir+File.separator+ pictureUrl), new File(projectDir+File.separator+newPictureUrl)); fileBom.setPictureUrl(newPictureUrl); } if(dwgUrl !=null){ String newDwgUrl ="doc_file"+File.separator+"product"+File.separator+fileBom.getParentModel()+File.separator+ dwgUrl.substring(dwgUrl.lastIndexOf(File.separator)+1); FileCopyUtils.copy(new File(projectDir+File.separator+ dwgUrl), new File(projectDir+File.separator+newDwgUrl)); fileBom.setDwgUrl(newDwgUrl); } } catch (IOException e) { e.printStackTrace(); } }); //更新正式bom的对应url bomService.updateUrl(fileBomApprovingList); } } src/main/resources/mapper/ProductBomMapper.xml
@@ -1,6 +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.ProductBomMapper"> <update id="updateUrl"> <foreach collection="list" item="item" separator=";"> update db_doc.tb_product_bom set picture_url = #{item.pictureUrl},dwg_url = #{item.dwgUrl} where parent_model = #{item.parentModel} and sub_model = #{item.subModel} and id !=0; </foreach> </update> <select id="searchCadDrawer" resultType="ProductBom" parameterType="ProductBom">