| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.dto.FileUrlDTO; |
| | | 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.whyc.dto.Response; |
| | | import com.whyc.mapper.ComponentApprovingMapper; |
| | | import com.whyc.pojo.ComponentApproving; |
| | | import com.whyc.pojo.ComponentProductApproving; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.ProductBomApproving; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.FileUtil; |
| | | 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 java.io.*; |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | @Service |
| | | public class ComponentApprovingService { |
| | | |
| | | @Resource |
| | | private ComponentApprovingMapper mapper; |
| | | |
| | | /** |
| | | * |
| | |
| | | //遍历解压后的文件夹路径,解析excel |
| | | System.out.println(filePath); |
| | | List<String> fileList = new ArrayList<>(); |
| | | |
| | | fileList = FileUtil.getStaticFilePath(parentFile,fileList); |
| | | for (int i = 0; i < fileList.size(); i++) { |
| | | String fileTempUrl = fileList.get(i); |
| | | //查询到xls数据 |
| | |
| | | Row row3 = sheet.getRow(3); |
| | | String productVersion = row3.getCell(5).getStringCellValue(); |
| | | for (int l = 8; l < lastRowNum-1; l++) { |
| | | Cell cellTemp = sheet.getRow(l).getCell(1); |
| | | cellTemp.setCellType(Cell.CELL_TYPE_STRING); |
| | | if(cellTemp.getStringCellValue().equals("")){ |
| | | break; |
| | | } |
| | | ComponentApproving approving = new ComponentApproving(); |
| | | approving.setCreateDate(new Date()); |
| | | |
| | |
| | | int cellValueInt = 0; |
| | | Double cellValueDouble = null; |
| | | if(m == 3){ |
| | | cellValueDouble = cell.getNumericCellValue(); |
| | | DecimalFormat decimalFormat = new DecimalFormat("0"); |
| | | cellValue = decimalFormat.format(cellValueDouble); |
| | | //cellValueDouble = cell.getNumericCellValue(); |
| | | //DecimalFormat decimalFormat = new DecimalFormat("0"); |
| | | //cellValue = decimalFormat.format(cellValueDouble); |
| | | cell.setCellType(Cell.CELL_TYPE_STRING); |
| | | cellValue = cell.getStringCellValue(); |
| | | } |
| | | else if(m ==7){ |
| | | cellValueDouble = cell.getNumericCellValue(); |
| | |
| | | } |
| | | } |
| | | } |
| | | for (ComponentApproving componentApproving : list) { |
| | | if(componentApproving.getSubName()==null ||componentApproving.getSubName().equals("")){ |
| | | return response.set(1,false,"拒绝解析,excel文件中记录包含名称为空的记录"); |
| | | } |
| | | } |
| | | String nextTitle = originalFilename.substring(0,originalFilename.lastIndexOf(".")); |
| | | return response.setIII(1,true,list,nextTitle,"解析完成"); |
| | | } |
| | | |
| | | public void insert(List<ComponentApproving> cApprovingList) { |
| | | mapper.insertBatchSomeColumn(cApprovingList); |
| | | } |
| | | |
| | | public List<ComponentApproving> getListByStatus(int status) { |
| | | QueryWrapper<ComponentApproving> query = Wrappers.query(); |
| | | query.eq("status",status); |
| | | return mapper.selectList(query); |
| | | } |
| | | |
| | | public void endStatus(Integer mainId) { |
| | | UpdateWrapper<ComponentApproving> 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(); |
| | | 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"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | } |