| | |
| | | |
| | | 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.FileDirPath; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | |
| | | } |
| | | String excelFilePath = excelDir + File.separator + originalFilename.substring(0,originalFilename.lastIndexOf(".")) + "_" + dateUnion +originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String excelHttpUrl = excelFilePath.substring(excelDir.lastIndexOf("doc_file"+ File.separator + "ecr")); |
| | | multipartFile.transferTo(new File(excelFilePath)); |
| | | |
| | | Workbook workbook = null; |
| | | workbook = WorkbookFactory.create(inputStream); |
| | |
| | | if(proposeDateStr.equals("")){ |
| | | return new Response().set(1,false,"申请日期不能为空!"); |
| | | } |
| | | Date proposeDate = DateUtil.YYYY_MM_DD_UNION.parse(proposeDateStr); |
| | | |
| | | Date proposeDate; |
| | | try { |
| | | if(proposeDateStr.contains(".")){ |
| | | proposeDate = DateUtil.YYYY_MM_DD_UNION2.parse(proposeDateStr); |
| | | }else if(proposeDateStr.contains("-")){ |
| | | proposeDate = DateUtil.YYYY_MM_DD_UNION3.parse(proposeDateStr); |
| | | }else if(proposeDateStr.contains("/")){ |
| | | proposeDate = DateUtil.YYYY_MM_DD_UNION4.parse(proposeDateStr); |
| | | }else { |
| | | proposeDate = DateUtil.YYYY_MM_DD_UNION.parse(proposeDateStr); |
| | | } |
| | | }catch (ParseException e){ |
| | | return new Response().set(1,false,"申请日期格式错误!"); |
| | | } |
| | | Cell proposerCell = sheet.getRow(2).getCell(22); |
| | | if(proposerCell == null || !proposerCell.getStringCellValue().contains("申请人")){ |
| | | return new Response().set(1,false,"申请人不能为空或单元格格式不规范!"); |
| | |
| | | if(solutionCellValue.contains("■")){ |
| | | String solutionStr = solutionCellValue.split("■")[1]; |
| | | solution = solutionStr.split("\\.")[1]; |
| | | if(solution.contains("□")){ |
| | | solution = solution.split("□")[0]; |
| | | } |
| | | }else{ |
| | | return new Response().set(1,false,"处理方式必须选中一项!"); |
| | | } |
| | |
| | | ecrTemp.setSubModel(modelSplit[i]); |
| | | ecrList.add(ecrTemp); |
| | | } |
| | | //提交之前先校验流水号是否存在 |
| | | QueryWrapper<ECR> query = Wrappers.query(); |
| | | query.eq("number",ecrList.get(0).getNumber()).last(" limit 1"); |
| | | ECR ecrNumberObj = mapper.selectOne(query); |
| | | if(ecrNumberObj!= null) { |
| | | return new Response().set(1,false,"ecr编号已存在"); |
| | | } |
| | | //存储操作执行 |
| | | multipartFile.transferTo(new File(excelFilePath)); |
| | | mapper.insertBatchSomeColumn(ecrList); |
| | | |
| | | return new Response().set(1,true,"导入完成"); |
| | |
| | | ecrTemp.setSubCode(subCodeSplit[i]); |
| | | ecrTemp.setSubModel(subModelSplit[i]); |
| | | ecrList.add(ecrTemp); |
| | | } |
| | | //提交之前先校验流水号是否存在 |
| | | QueryWrapper<ECR> query = Wrappers.query(); |
| | | query.eq("number",ecrList.get(0).getNumber()).last(" limit 1"); |
| | | ECR ecrNumberObj = mapper.selectOne(query); |
| | | if(ecrNumberObj!= null) { |
| | | return new Response().set(1,false,"ecr编号已存在"); |
| | | } |
| | | mapper.insertBatchSomeColumn(ecrList); |
| | | return new Response().set(1,true,"导入完成"); |
| | |
| | | return list; |
| | | } |
| | | |
| | | public void exportExcel(HttpServletResponse response) { |
| | | //查询所有 |
| | | List<ECR> ecrList = mapper.selectList(null); |
| | | public void exportExcel(HttpServletResponse response, List<Integer> ids) { |
| | | List<ECR> ecrList; |
| | | if(ids == null) { |
| | | //查询所有 |
| | | ecrList = mapper.selectList(null); |
| | | }else{ |
| | | //查询ids的记录 |
| | | QueryWrapper<ECR> query = Wrappers.query(); |
| | | query.in("id",ids); |
| | | ecrList = mapper.selectList(query); |
| | | } |
| | | int size = ecrList.size(); |
| | | //ECR编号,申请日期,申请人,变更描述,变更料号,变更型号,变更所属型号,处理方式,创建时间 |
| | | String[] title = new String[]{"年份","ECR编号","申请日期","申请人","变更描述","变更料号","变更型号","变更所属型号","处理方式","创建时间"}; |
| | |
| | | values[i][8] = ecr.getSolution(); |
| | | values[i][9] = DateUtil.YYYY_MM_DD_HH_MM_SS.format(ecr.getCreateTime()); |
| | | } |
| | | String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS.format(new Date()); |
| | | String dateFormat = DateUtil.YYYY_MM_DD_HH_MM_SS2.format(new Date()); |
| | | ExcelUtil.exportExcel("变更记录清单_"+dateFormat,"清单",title,values,null,response); |
| | | } |
| | | //删除ECR记录 |
| | | public Response deleteEcr(int id, String filePath) { |
| | | if(!filePath.isEmpty()){ |
| | | public Response deleteEcr(String number, String filePath) { |
| | | if(!(filePath==null||filePath.isEmpty())){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | File file = new File(fileDirName+File.separator+filePath); |
| | | if(!file.isDirectory()){ |
| | |
| | | } |
| | | //删除表记录 |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("id",id); |
| | | wrapper.eq("number",number); |
| | | int delFlag=mapper.delete(wrapper); |
| | | return new Response().set(1,delFlag>0,"删除ECR"); |
| | | } |
| | | //反馈下拉查询ECR记录 |
| | | public Response searchEcrInFeedback() { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.select("distinct number"); |
| | | wrapper.orderByDesc("create_time"); |
| | | List list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list.size()>0,list,"查询ECR记录"); |
| | | } |
| | | } |