| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.constant.UserOperation; |
| | | import com.whyc.dto.FIleSilkLock; |
| | |
| | | import com.whyc.mapper.ProductHistoryMapper; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.ImageDiff; |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.ClientAnchor; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private AttachLockMapper attachLockMapper; |
| | | |
| | | @Autowired |
| | | private MaterialService materialService; |
| | | |
| | | //根据子件名称和母料型号查询历史版本记录 |
| | | public Response getBomHistoryByPModelAndSName(String pmodel, String sname) { |
| | |
| | | List<ProductBom> diffList = new LinkedList<>(); |
| | | List<ProductBom> addList = new LinkedList<>(); |
| | | List<ProductBom> deleteList = new LinkedList<>(); |
| | | //新增差异对比-图纸差异 |
| | | List<ProductBom> diffDwgList = new LinkedList<>(); |
| | | |
| | | //查找到基准产品 |
| | | if(baseProduct == null){ //查找上传的现有产品表内未锁定的版本 |
| | |
| | | deleteList.add(bom); |
| | | } |
| | | }); |
| | | //图纸差异对比逻辑 |
| | | //1.先找出所有需要对比的图纸 |
| | | List<ProductBom> bomListWithDwg = bomList.stream().filter(bom -> !StringUtils.isEmpty(bom.getDwgUrl())).collect(Collectors.toList()); |
| | | //2.从数据库中找到物料对应的图纸 |
| | | if(bomListWithDwg.size()!=0) { |
| | | List<Material> materialListInDB = materialService.getListByCodeAndModelList3(bomListWithDwg); |
| | | if (materialListInDB.size() != 0) { |
| | | //对比图纸 |
| | | for (int i = 0; i < materialListInDB.size(); i++) { |
| | | Material materialInDB = materialListInDB.get(i); |
| | | String materialStrInDB = materialInDB.getSubCode() + "/" + materialInDB.getSubModel(); |
| | | for (int j = 0; j < bomListWithDwg.size(); j++) { |
| | | ProductBom material = bomListWithDwg.get(j); |
| | | String materialStr = material.getSubCode() + "/" + material.getSubModel(); |
| | | if (materialStrInDB.equals(materialStr)) { |
| | | //如果物料一致,则进行对比 |
| | | String dwgUrlInDB = materialInDB.getDwgUrl(); |
| | | String dwgUrl = material.getDwgUrl(); |
| | | //物料图纸转化为png图片进行对比(弃用) |
| | | String dwgFileStr = CommonUtil.getProjectDir() + File.separator + dwgUrlInDB; |
| | | String dwgFileStr2 = CommonUtil.getProjectDir() + File.separator + dwgUrl; |
| | | |
| | | /*String absoluteDwgPngPath = dwgFileStr.substring(0, dwgFileStr.lastIndexOf(".")) + "-dwg.png"; |
| | | String absoluteDwgPngPath2 = dwgFileStr2.substring(0, dwgFileStr2.lastIndexOf(".")) + "-dwg.png"; |
| | | |
| | | if (!new File(absoluteDwgPngPath).exists()) { |
| | | DwgToPngUtil.dwg2png(new File(dwgFileStr)); |
| | | } |
| | | if (!new File(absoluteDwgPngPath2).exists()) { |
| | | DwgToPngUtil.dwg2png(new File(dwgFileStr2)); |
| | | }*/ |
| | | boolean sameImage = ImageDiff.compareImagesCheck(dwgFileStr, dwgFileStr2); |
| | | if (!sameImage) { //图纸不同 |
| | | //material.setNotes(absoluteDwgPngPath.replace(CommonUtil.getProjectDir()+ File.separator, "") + separator + absoluteDwgPngPath2.replace(CommonUtil.getProjectDir()+ File.separator, "")); |
| | | //克隆一个新的对象material |
| | | ProductBom materialDiff = new ProductBom(); |
| | | BeanUtils.copyProperties(material, materialDiff); |
| | | materialDiff.setNotes(dwgUrlInDB); |
| | | diffDwgList.add(materialDiff); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | compareMap.put("diffList",diffList); |
| | | compareMap.put("addList",addList); |
| | | compareMap.put("deleteList",deleteList); |
| | | compareMap.put("diffDwgList",diffDwgList); |
| | | return compareMap; |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | //根据产品母料型号,定制单号,版本下载原始压缩包文件 |
| | | public Response getOriginalZip(String parentModel, String customCode, int version) { |
| | | public Response getOriginalZip(String parentCode,String parentModel, String customCode, int version) { |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String withOutDwg=fileDirName+File.separator+"doc_file"+File.separator+"product"+File.separator+parentModel; |
| | | if(customCode!=null&&!customCode.isEmpty()){ |
| | |
| | | String[] filePath = file.list();//获取该文件夹下的所有文件以及目录的名字 |
| | | if(filePath!=null&&filePath.length>0){ |
| | | for (String tmp:filePath) { |
| | | if(tmp.contains(parentModel)&&tmp.contains(".zip")){ |
| | | if((tmp.contains(parentCode)||tmp.contains(parentModel))&&tmp.contains(".zip")){ |
| | | bl=true; |
| | | withOutDwg=withOutDwg+File.separator+tmp; |
| | | break; |