Merge remote-tracking branch 'origin/master'
# Conflicts:
# inspect-server/src/main/java/com/yuanchu/mom/mapper/RawInspectMapper.java
# inspect-server/src/main/resources/mapper/InspectUnacceptedMapper.xml
| | |
| | | <groupId>com.auth0</groupId> |
| | | <artifactId>java-jwt</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | </dependency> |
| | | <!--poi--> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.github.whvcse</groupId> |
| | | <artifactId>easy-captcha</artifactId> |
| | | <version>1.6.2</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </project> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.exception; |
| | | |
| | | import com.yuanchu.mom.utils.easyexcel.ResponseResultEnum; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * excelå
¨å±å¼å¸¸ |
| | | * @auther Zou, Yu |
| | | * @create 2023-9-24 |
| | | */ |
| | | @Getter |
| | | public class ExcelException extends RuntimeException { |
| | | |
| | | private Integer status; |
| | | |
| | | public ExcelException(ResponseResultEnum resultEnum) { |
| | | super(resultEnum.getMessage()); |
| | | this.status = resultEnum.getStatus(); |
| | | } |
| | | |
| | | public ExcelException(Integer status, String message) { |
| | | super(message); |
| | | this.status = status; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel; |
| | | |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.CellData; |
| | | import com.alibaba.excel.metadata.Head; |
| | | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| | | import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | *@author: Zou, Yu |
| | | *@description: |
| | | *@date: 2023/9/24 0024 12:56 |
| | | **/ |
| | | public class CustemHandler extends AbstractColumnWidthStyleStrategy { |
| | | |
| | | private static final int MAX_COLUMN_WIDTH = 255; |
| | | //å 为å¨èªå¨å宽çè¿ç¨ä¸ï¼æäºè®¾ç½®å°æ¹è®©å宽æ¾å¾ç´§åï¼æä»¥ååºäºä¸ªå¤æ |
| | | private static final int COLUMN_WIDTH = 20; |
| | | private Map<Integer, Map<Integer, Integer>> CACHE = new HashMap(8); |
| | | |
| | | public CustemHandler() { |
| | | } |
| | | |
| | | @Override |
| | | protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { |
| | | boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList); |
| | | if (needSetWidth) { |
| | | Map<Integer, Integer> maxColumnWidthMap = (Map) CACHE.get(writeSheetHolder.getSheetNo()); |
| | | if (maxColumnWidthMap == null) { |
| | | maxColumnWidthMap = new HashMap(16); |
| | | CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); |
| | | } |
| | | |
| | | Integer columnWidth = this.dataLength(cellDataList, cell, isHead); |
| | | if (columnWidth >= 0) { |
| | | if (columnWidth > MAX_COLUMN_WIDTH) { |
| | | columnWidth = MAX_COLUMN_WIDTH; |
| | | } else { |
| | | if (columnWidth < COLUMN_WIDTH) { |
| | | columnWidth = columnWidth * 2; |
| | | } |
| | | } |
| | | |
| | | Integer maxColumnWidth = (Integer) ((Map) maxColumnWidthMap).get(cell.getColumnIndex()); |
| | | if (maxColumnWidth == null || columnWidth > maxColumnWidth) { |
| | | ((Map) maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth); |
| | | writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Integer dataLength(List<CellData> cellDataList, Cell cell, Boolean isHead) { |
| | | if (isHead) { |
| | | return cell.getStringCellValue().getBytes().length; |
| | | } else { |
| | | CellData cellData = (CellData) cellDataList.get(0); |
| | | CellDataTypeEnum type = cellData.getType(); |
| | | if (type == null) { |
| | | return -1; |
| | | } else { |
| | | switch (type) { |
| | | case STRING: |
| | | return cellData.getStringValue().getBytes().length; |
| | | case BOOLEAN: |
| | | return cellData.getBooleanValue().toString().getBytes().length; |
| | | case NUMBER: |
| | | return cellData.getNumberValue().toString().getBytes().length; |
| | | default: |
| | | return -1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel; |
| | | |
| | | |
| | | import com.alibaba.excel.EasyExcelFactory; |
| | | import com.alibaba.excel.ExcelReader; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.metadata.Font; |
| | | import com.alibaba.excel.metadata.Sheet; |
| | | import com.alibaba.excel.metadata.Table; |
| | | import com.alibaba.excel.metadata.TableStyle; |
| | | import com.alibaba.excel.metadata.*; |
| | | import com.alibaba.excel.support.ExcelTypeEnum; |
| | | import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
| | | import com.alibaba.excel.write.metadata.style.WriteFont; |
| | | import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
| | | import com.yuanchu.mom.exception.ExcelException; |
| | | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.*; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | *@author: Zou, Yu |
| | | *@description: |
| | | *@date: 2023/9/24 0024 13:18 |
| | | **/ |
| | | public class EasyExcelUtils { |
| | | |
| | | |
| | | public static HorizontalCellStyleStrategy getStyleStrategy() { |
| | | // 头ççç¥ |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | // èæ¯è®¾ç½®ä¸ºç°è² |
| | | headWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontHeightInPoints((short) 12); |
| | | // å使 ·å¼ |
| | | headWriteFont.setFontName("Frozen"); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); |
| | | // èªå¨æ¢è¡ |
| | | headWriteCellStyle.setWrapped(false); |
| | | // æ°´å¹³å¯¹é½æ¹å¼ |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
| | | // åç´å¯¹é½æ¹å¼ |
| | | headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | |
| | | // å
容ççç¥ |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | // è¿ééè¦æå® FillPatternType 为FillPatternType.SOLID_FOREGROUND ä¸ç¶æ æ³æ¾ç¤ºèæ¯é¢è².头é»è®¤äº FillPatternTypeæä»¥å¯ä»¥ä¸æå® |
| | | // contentWriteCellStyle.setFillPatternType(FillPatternType.SQUARES); |
| | | // èæ¯ç½è² |
| | | contentWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex()); |
| | | WriteFont contentWriteFont = new WriteFont(); |
| | | // åä½å¤§å° |
| | | contentWriteFont.setFontHeightInPoints((short) 12); |
| | | // å使 ·å¼ |
| | | contentWriteFont.setFontName("Calibri"); |
| | | contentWriteCellStyle.setWriteFont(contentWriteFont); |
| | | // å
å®¹å·¦å¯¹é½ |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT); |
| | | // è¿ä¸ªçç¥æ¯ 头æ¯å¤´çæ ·å¼ å
容æ¯å
å®¹çæ ·å¼ å
¶ä»ççç¥å¯ä»¥èªå·±å®ç° |
| | | return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); |
| | | } |
| | | |
| | | public static HorizontalCellStyleStrategy getStyleFixedStrategy() { |
| | | // 头ççç¥ |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | // èæ¯è®¾ç½®ä¸ºç°è² |
| | | headWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontHeightInPoints((short) 12); |
| | | // å使 ·å¼ |
| | | headWriteFont.setFontName("Calibri"); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); |
| | | // èªå¨æ¢è¡ |
| | | headWriteCellStyle.setWrapped(false); |
| | | // æ°´å¹³å¯¹é½æ¹å¼ |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT); |
| | | // åç´å¯¹é½æ¹å¼ |
| | | headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // å
容ççç¥ |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | // è¿ééè¦æå® FillPatternType 为FillPatternType.SOLID_FOREGROUND ä¸ç¶æ æ³æ¾ç¤ºèæ¯é¢è².头é»è®¤äº FillPatternTypeæä»¥å¯ä»¥ä¸æå® |
| | | // contentWriteCellStyle.setFillPatternType(FillPatternType.SQUARES); |
| | | // èæ¯ç½è² |
| | | contentWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex()); |
| | | WriteFont contentWriteFont = new WriteFont(); |
| | | // åä½å¤§å° |
| | | contentWriteFont.setFontHeightInPoints((short) 10); |
| | | // å使 ·å¼ |
| | | contentWriteFont.setFontName("Calibri"); |
| | | contentWriteCellStyle.setWriteFont(contentWriteFont); |
| | | // å
å®¹å·¦å¯¹é½ |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT); |
| | | // è¿ä¸ªçç¥æ¯ 头æ¯å¤´çæ ·å¼ å
容æ¯å
å®¹çæ ·å¼ å
¶ä»ççç¥å¯ä»¥èªå·±å®ç° |
| | | return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); |
| | | } |
| | | |
| | | public static HorizontalCellStyleStrategy getArveStyleStrategy() { |
| | | // 头ççç¥ |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | // èæ¯è®¾ç½®ä¸º |
| | | headWriteCellStyle.setFillForegroundColor(IndexedColors.BLACK.getIndex()); |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontHeightInPoints((short) 12); |
| | | // å使 ·å¼ |
| | | headWriteFont.setFontName("Calibri"); |
| | | headWriteFont.setColor(IndexedColors.WHITE.getIndex()); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); |
| | | |
| | | headWriteCellStyle.setBorderBottom(BorderStyle.MEDIUM); |
| | | headWriteCellStyle.setLeftBorderColor(IndexedColors.WHITE.getIndex()); |
| | | headWriteCellStyle.setRightBorderColor(IndexedColors.WHITE.getIndex()); |
| | | // èªå¨æ¢è¡ |
| | | headWriteCellStyle.setWrapped(true); |
| | | // æ°´å¹³å¯¹é½æ¹å¼ |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT); |
| | | // åç´å¯¹é½æ¹å¼ |
| | | headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | // å
容ççç¥ |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | // è¿ééè¦æå® FillPatternType 为FillPatternType.SOLID_FOREGROUND ä¸ç¶æ æ³æ¾ç¤ºèæ¯é¢è².头é»è®¤äº FillPatternTypeæä»¥å¯ä»¥ä¸æå® |
| | | // contentWriteCellStyle.setFillPatternType(FillPatternType.SQUARES); |
| | | // èæ¯ç½è² |
| | | contentWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex()); |
| | | WriteFont contentWriteFont = new WriteFont(); |
| | | // åä½å¤§å° |
| | | contentWriteFont.setFontHeightInPoints((short) 10); |
| | | // å使 ·å¼ |
| | | contentWriteFont.setFontName("Calibri"); |
| | | contentWriteCellStyle.setWriteFont(contentWriteFont); |
| | | // è¿ä¸ªçç¥æ¯ 头æ¯å¤´çæ ·å¼ å
容æ¯å
å®¹çæ ·å¼ å
¶ä»ççç¥å¯ä»¥èªå·±å®ç° |
| | | return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle); |
| | | } |
| | | |
| | | /** |
| | | * excelæä»¶è¯»å |
| | | * |
| | | * @param clazz modelç±»åClass对象 |
| | | * @param excel excelæä»¶å¯¹è±¡ |
| | | * @param <T> modelç±»åæ³å |
| | | * @return modelç±»åæ°æ®éå |
| | | * @throws IOException IOå¼å¸¸ |
| | | */ |
| | | public static <T extends BaseRowModel> List<T> readModelExcel(Class<T> clazz, MultipartFile excel) throws IOException { |
| | | ExcelListener<T> excelListener = new ExcelListener<>(); |
| | | ExcelReader reader = getReader(excel, excelListener); |
| | | try { |
| | | reader.getSheets().forEach(sheet -> { |
| | | sheet.setClazz(clazz); |
| | | reader.read(sheet); |
| | | }); |
| | | } catch (Exception e) { |
| | | throw new IOException("è¯·æ£æ¥å¯¼å
¥æ¨¡æ¿ï¼"); |
| | | } |
| | | return excelListener.getDataList(); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param clazz modelç±»åClass对象 |
| | | * @param excel excelæä»¶å¯¹è±¡ |
| | | * @param sheetNumber æå®sheet页 |
| | | * @param <T> modelç±»åæ³å |
| | | * @return modelç±»åæ°æ®éå |
| | | * @throws IOException |
| | | */ |
| | | public static <T extends BaseRowModel> List<T> readModelSheetExcel(Class<T> clazz, MultipartFile excel, int sheetNumber) throws IOException { |
| | | ExcelListener<T> excelListener = new ExcelListener<>(); |
| | | ExcelReader reader = getReader(excel, excelListener); |
| | | try { |
| | | Sheet sheet = reader.getSheets().get(sheetNumber); |
| | | sheet.setClazz(clazz); |
| | | reader.read(sheet); |
| | | } catch (Exception e) { |
| | | throw new IOException("è¯·æ£æ¥å¯¼å
¥æ¨¡æ¿ï¼"); |
| | | } |
| | | return excelListener.getDataList(); |
| | | } |
| | | |
| | | /** |
| | | * è·åexcelæä»¶è¯»å对象 |
| | | * |
| | | * @param excel excelæä»¶å¯¹è±¡ |
| | | * @param excelListener exceläºä»¶å¤ç |
| | | * @return excel 读å对象 |
| | | * @throws IOException IOå¼å¸¸ |
| | | */ |
| | | private static ExcelReader getReader(MultipartFile excel, ExcelListener excelListener) throws IOException { |
| | | String filename = excel.getOriginalFilename(); |
| | | if (filename == null || (!filename.toLowerCase().endsWith(".xls") && !filename.toLowerCase().endsWith(".xlsx") && !filename.toLowerCase().endsWith(".xltm") && !filename.toLowerCase().endsWith(".xlsm"))) { |
| | | throw new ExcelException(ResponseResultEnum.EXCEL_FILE_EXT_ERROR); |
| | | } |
| | | InputStream inputStream = new BufferedInputStream(excel.getInputStream()); |
| | | return new ExcelReader(inputStream, null, excelListener, false); |
| | | } |
| | | |
| | | /** |
| | | * åå
¥æ°æ®å°å¯¼åºæä»¶ |
| | | * |
| | | * @param clazz modelç±»åClass对象 |
| | | * @param sheetNo sheetåºå· |
| | | * @param headLineMun headè¡æ° |
| | | * @param startRow å¼å§åå
¥è¡æ° |
| | | * @param tableNo tableåºå· |
| | | * @param modelList modelæ°æ®éå |
| | | * @param temp ä¸´æ¶æä»¶å¯¹è±¡ |
| | | * @param export å¯¼åºæä»¶å¯¹è±¡ |
| | | * @param <T> modelæ³å |
| | | */ |
| | | public static <T extends BaseRowModel> void writeModelExport(Class<T> clazz, Integer sheetNo, Integer headLineMun, Integer startRow, Integer tableNo, List<T> modelList, File temp, File export) { |
| | | try { |
| | | InputStream inputStream = new FileInputStream(temp); |
| | | FileOutputStream OutputStream = new FileOutputStream(export); |
| | | ExcelWriter writer = EasyExcelFactory.getWriterWithTemp(inputStream, OutputStream, ExcelTypeEnum.XLSX, false); |
| | | writer.write(modelList, initSheet(sheetNo, headLineMun, startRow), initTable(tableNo, clazz)); |
| | | writer.finish(); |
| | | OutputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Sheetåå§å |
| | | * |
| | | * @param sheetNo sheetåºå· |
| | | * @param headLineMun headè¡æ° |
| | | * @param startRow å¼å§åå
¥è¡æ° |
| | | * @return Sheet对象 |
| | | */ |
| | | public static Sheet initSheet(Integer sheetNo, Integer headLineMun, Integer startRow) { |
| | | Sheet sheet = new Sheet(sheetNo, headLineMun); |
| | | sheet.setStartRow(startRow); |
| | | return sheet; |
| | | } |
| | | |
| | | /** |
| | | * Tableåå§å |
| | | * |
| | | * @param tableNo tableåºå· |
| | | * @param clazz modelç±»åClass对象 |
| | | * @param <T> modelæ³å |
| | | * @return Table对象 |
| | | */ |
| | | public static <T extends BaseRowModel> Table initTable(Integer tableNo, Class<T> clazz) { |
| | | Table table = new Table(tableNo); |
| | | table.setClazz(clazz); |
| | | TableStyle tableStyle = new TableStyle(); |
| | | tableStyle.setTableContentBackGroundColor(IndexedColors.WHITE); |
| | | tableStyle.setTableHeadBackGroundColor(IndexedColors.WHITE); |
| | | Font font = new Font(); |
| | | font.setBold(false); |
| | | font.setFontName("å®ä½"); |
| | | font.setFontHeightInPoints((short) 11); |
| | | tableStyle.setTableContentFont(font); |
| | | table.setTableStyle(tableStyle); |
| | | return table; |
| | | } |
| | | |
| | | /** |
| | | * æ¿æ¢æ¨¡æ¿æ è®° |
| | | * |
| | | * @param export å¯¼åºæä»¶å¯¹è±¡ |
| | | * @param index sheetåºå· |
| | | * @param rows åå
æ ¼è¡åº |
| | | * @param columns åå
æ ¼ååº |
| | | * @param replaceMap å¤ä¸ªæ è®°éå |
| | | */ |
| | | public static void editModelWorkBook(File export, Integer index, Integer rows, Integer columns, Map<String, String> replaceMap) { |
| | | try { |
| | | XSSFWorkbook workBook = new XSSFWorkbook(export); |
| | | // editModelWorkBook(workBook,index,0,0,replaceMap); |
| | | editModelWorkBook(workBook, index, rows, columns, replaceMap); |
| | | workBook.close(); |
| | | } catch (IOException | InvalidFormatException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¿æ¢æ¨¡æ¿æ è®° |
| | | * |
| | | * @param workBook excelå·¥ä½å对象 |
| | | * @param index sheetåºå· |
| | | * @param rows åå
æ ¼è¡åº |
| | | * @param columns åå
æ ¼ååº |
| | | * @param replaceMap å¤ä¸ªæ è®°éå |
| | | */ |
| | | public static void editModelWorkBook(XSSFWorkbook workBook, Integer index, Integer rows, Integer columns, Map<String, String> replaceMap) { |
| | | XSSFSheet sheet = workBook.getSheetAt(index); |
| | | Row row = sheet.getRow(rows); |
| | | Cell cell = row.getCell(columns); |
| | | String replaceString = cell.toString(); |
| | | for (Map.Entry<String, String> entry : replaceMap.entrySet()) { |
| | | replaceString = replaceString.replace(entry.getKey(), entry.getValue()); |
| | | } |
| | | cell.setCellValue(replaceString); |
| | | workBook.setSheetName(index, replaceString.replace(":", "")); |
| | | } |
| | | |
| | | /** |
| | | * 模æ¿sheetå
éåå½å |
| | | * |
| | | * @param temp ä¸´æ¶æä»¶å¯¹è±¡ |
| | | * @param export å¯¼åºæä»¶å¯¹è±¡ |
| | | * @param cloneSheetNo å
ésheetåºå |
| | | * @param rows åå
æ ¼è¡åº |
| | | * @param columns åå
æ ¼ååº |
| | | * @param replaceMapList å¤ä¸ªæ è®°éå |
| | | */ |
| | | public static void writeModelCloneSheet(File temp, File export, Integer cloneSheetNo, Integer rows, Integer columns, List<Map<String, String>> replaceMapList) { |
| | | try { |
| | | XSSFWorkbook workBook = new XSSFWorkbook(temp); |
| | | OutputStream outputStream = new FileOutputStream(export); |
| | | /** å¦æä½ éè¦6份ç¸å模æ¿çsheet é£ä¹ä½ åªéè¦å
é5份å³å¯*/ |
| | | for (int index = 0; index < replaceMapList.size() - 1; index++) { |
| | | /** å
鿍¡æ¿æä»¶ */ |
| | | XSSFSheet sheet = workBook.cloneSheet(cloneSheetNo); |
| | | } |
| | | for (int index = 0; index < replaceMapList.size(); index++) { |
| | | editModelWorkBook(workBook, index, rows, columns, replaceMapList.get(index)); |
| | | } |
| | | workBook.write(outputStream); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | workBook.close(); |
| | | } catch (IOException | InvalidFormatException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä¸´æ¶æä»¶åå
¥å¯¼åºæä»¶ |
| | | * |
| | | * @param temp ä¸´æ¶æä»¶å¯¹è±¡ |
| | | * @param export å¯¼åºæä»¶å¯¹è±¡ |
| | | * @param index sheetåºå· |
| | | * @param rows åå
æ ¼è¡åº |
| | | * @param columns åå
æ ¼ååº |
| | | * @param isTime æ¯å¦ææ¶é´æ è®° |
| | | */ |
| | | public static void writeModelWorkBook(File temp, File export, Integer index, Integer rows, Integer columns, Boolean isTime) { |
| | | try { |
| | | XSSFWorkbook workBook = new XSSFWorkbook(temp); |
| | | OutputStream outputStream = new FileOutputStream(export); |
| | | if (isTime) { |
| | | writeModelWorkBook(workBook, index, rows, columns); |
| | | } |
| | | workBook.write(outputStream); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | workBook.close(); |
| | | } catch (IOException | InvalidFormatException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¿æ¢æ¶é´æ è®°ï¼year,month,dayï¼ |
| | | * |
| | | * @param workBook excelå·¥ä½å对象 |
| | | * @param index sheetåºå· |
| | | * @param rows åå
æ ¼è¡åº |
| | | * @param columns åå
æ ¼ååº |
| | | */ |
| | | public static void writeModelWorkBook(XSSFWorkbook workBook, Integer index, Integer rows, Integer columns) { |
| | | XSSFSheet xssfSheet = workBook.getSheetAt(index); |
| | | Row row = xssfSheet.getRow(rows); |
| | | Cell cell = row.getCell(columns); |
| | | String cellString = cell.toString(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | String yearString = cellString.replace("year", String.valueOf(year)); |
| | | String monthString = yearString.replace("month", String.valueOf(month)); |
| | | String dayString = monthString.replace("day", String.valueOf(day)); |
| | | cell.setCellValue(dayString); |
| | | } |
| | | |
| | | /** |
| | | * é对UserModelå¯¼åºæ¹æ³ |
| | | * |
| | | * @param temp |
| | | * @param export |
| | | * @param isTime |
| | | */ |
| | | public static void writeModelWorkBook(File temp, File export, Boolean isTime) { |
| | | writeModelWorkBook(temp, export, 0, 1, 9, isTime); |
| | | } |
| | | |
| | | |
| | | public static void writeModelCloneSheet(File temp, File export, List<Map<String, String>> replaceMapList) { |
| | | writeModelCloneSheet(temp, export, 0, 0, 0, replaceMapList); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel; |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * excelæ°æ®å¯¼å
¥æ°æ®å¤ç |
| | | * |
| | | * @param <T> |
| | | * @author Zou, Yu |
| | | */ |
| | | @Slf4j |
| | | @Getter |
| | | @Setter |
| | | public class ExcelListener<T> extends AnalysisEventListener<T> { |
| | | |
| | | private List<T> dataList = new ArrayList<>(); |
| | | |
| | | @Override |
| | | public void invoke(T classType, AnalysisContext analysisContext) { |
| | | dataList.add(classType); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | } |
| | | |
| | | @Override |
| | | public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { |
| | | String templateHead = ""; |
| | | |
| | | List<String> headList = new ArrayList<>(); |
| | | for (Integer i : headMap.keySet()) { |
| | | headList.add(headMap.get(i)); |
| | | } |
| | | String importHead = headMap.values().toString(); |
| | | log.info("importHead:{}", importHead); |
| | | String templateName = context.getCurrentSheet().getClazz().getSimpleName(); |
| | | log.info("templateName:", templateName); |
| | | // if ("CostModel".equals(templateName)) { |
| | | // templateHead = templateHeadCost; |
| | | // } else if ("StaffInfoTemplate".equals(templateName)) { |
| | | // templateHead = templateHeadStaff; |
| | | // } else if ("OrganizationTemplate".equals(templateName)) { |
| | | // templateHead = templateHeadOrganization; |
| | | // }else if ("StaffDictionaryTemplate".equals(templateName)) { |
| | | // templateHead = templateHeadDictionary; |
| | | // }else if ("StaffCtfTemplate".equals(templateName)){ |
| | | // templateHead = templateHeadCtf; |
| | | // }else if ("IndustryLineTemplate".equals(templateName)){ |
| | | // templateHead = templateHeadIndustryLine; |
| | | // }else if ("SubServiceLineTemplate".equals(templateName)){ |
| | | // templateHead = templateHeadSubServiceLine; |
| | | // }else if ("StaffHealthTemplate".equals(templateName)){ |
| | | // templateHead = templateHeadHealth; |
| | | // }else if ("AccountDataTemplate".equals(templateName)){ |
| | | // templateHead = templateAccountData; |
| | | // }else if ("PlInfoTemplate".equals(templateName)){ |
| | | // templateHead = templatePlInfo; |
| | | // }else if ("CodeDataTemplate".equals(templateName)){ |
| | | // templateHead = templateCodeData; |
| | | // }else if ("CodeTbdDataTemplate".equals(templateName)){ |
| | | // templateHead = templateCodeTbdData; |
| | | // } |
| | | |
| | | if (!templateHead.equals(importHead)) { |
| | | throw new RuntimeException(ResponseResultEnum.EXCEL_MODEL_ERROR.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.CellData; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | *@author: Zou, Yu |
| | | *@description: |
| | | *@date: 2023/9/24 0024 13:18 |
| | | **/ |
| | | @Component |
| | | public class LocalDateConverter implements Converter<LocalDate> { |
| | | |
| | | @Override |
| | | public Class<LocalDate> supportJavaTypeKey() { |
| | | return LocalDate.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return CellDataTypeEnum.STRING; |
| | | } |
| | | |
| | | @Override |
| | | public LocalDate convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, |
| | | GlobalConfiguration globalConfiguration) { |
| | | return LocalDate.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | |
| | | @Override |
| | | public CellData<String> convertToExcelData(LocalDate value, ExcelContentProperty contentProperty, |
| | | GlobalConfiguration globalConfiguration) { |
| | | return new CellData<>(value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å¼å¸¸ä¿¡æ¯æä¸¾ |
| | | * @auther Zou, Yu |
| | | * @create 2023-09-24 |
| | | */ |
| | | @Getter |
| | | public enum ResponseResultEnum { |
| | | EXCEL_FILE_EXT_ERROR(1000,"æä»¶æ ¼å¼é误"), |
| | | EXCEL_FILE_READ_FAIL(1001,"excelæä»¶è¯»å失败,è¯·æ£æ¥æ¨¡æ¿!"), |
| | | EXCEL_FILE_IS_EMPTY(1002,"excelæä»¶ä¸ºç©º"), |
| | | MODEL_FILE_NOT_EXIT(1003,"模çæä»¶ä¸åå¨"), |
| | | EXCEL_ACTIVE_DATE_ERROR(1004,"çææ¶é´é误"), |
| | | EXCEL_MODEL_ERROR(1005,"导å
¥æ¨¡æ¿æè¯¯ï¼è¯·æ£æ¥ï¼"), |
| | | EXCEL_FILE_EXCESS(1006,"æ¹é导å
¥æ°æ®éä¸å¯è¶
è¿500æ¡"); |
| | | |
| | | private Integer status; |
| | | private String message; |
| | | |
| | | ResponseResultEnum(Integer status, String message) { |
| | | this.status = status; |
| | | this.message = message; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel.converter; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.CellData; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** 订åç¶æè½¬æ¢ |
| | | * @Author: Zou, Yu |
| | | * @DATE: 2023/9/24 0024 14:21 |
| | | */ |
| | | @Component |
| | | public class SaleTypeConverter implements Converter<String> { |
| | | |
| | | @Override |
| | | public Class<String> supportJavaTypeKey() { |
| | | return String.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return CellDataTypeEnum.STRING; |
| | | } |
| | | |
| | | @Override |
| | | public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | if("éè¿".equals(cellData.getStringValue())){ |
| | | return "1"; |
| | | }else if("ä¸éè¿".equals(cellData.getStringValue())){ |
| | | return "0"; |
| | | }else{ |
| | | return "2"; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public CellData convertToExcelData(String str, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | if("1".equals(str)){ |
| | | return new CellData<>("éè¿"); |
| | | }else if("0".equals(str)){ |
| | | return new CellData<>("ä¸éè¿"); |
| | | }else{ |
| | | return new CellData<>("æªå®¡æ ¸"); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils.easyexcel.template; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.metadata.BaseRowModel; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.yuanchu.mom.utils.easyexcel.converter.SaleTypeConverter; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Author: Zou, Yu |
| | | * @DATE: 2023/9/24 0024 11:21 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class ExportSaleTemplate extends BaseRowModel implements Serializable { |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="åºå·", index = 0) |
| | | private Integer id; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="订åç¼å·", index = 1) |
| | | @JsonSerialize |
| | | private String orderNumber; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="订åç±»å", index = 2) |
| | | @JsonSerialize |
| | | private String orderType; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="ååç¼å·", index = 3) |
| | | @JsonSerialize |
| | | private String code; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="å·¥ç¨åç§°", index = 4) |
| | | @JsonSerialize |
| | | private String name; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="客æ·åç§°", index = 5) |
| | | @JsonSerialize |
| | | private String proname; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="äº¤è´§æ¥æ", index = 6) |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date delTime; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="夿³¨", index = 7) |
| | | @JsonSerialize |
| | | private String note; |
| | | |
| | | @ColumnWidth(26) |
| | | @ExcelProperty(value="ç¶æ", index = 8 ,converter = SaleTypeConverter.class) |
| | | @JsonSerialize |
| | | private String type; |
| | | |
| | | } |
| | |
| | | |
| | | @ApiOperation(value = "䏿¥(æ´æ°æ£éªç¶æ)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true) |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "number", value = "ä¸åæ ¼æ°é", dataTypeClass = Integer.class) |
| | | }) |
| | | @PostMapping("/updateFinishInspectsById") |
| | | public Result updateFinishInspectsById(@RequestHeader("token") String token, Integer id) throws Exception { |
| | | public Result updateFinishInspectsById(@RequestHeader("token") String token, Integer id,Integer number) throws Exception { |
| | | //妿已ç»ä¸æ¥äºä¸è½å䏿¬¡ä¸æ¥ |
| | | FinishedInspect finishedInspect = finishedInspectService.getById(id); |
| | | if (ObjectUtils.isNotEmpty(finishedInspect.getResult())) { |
| | | return Result.fail("å·²ç»ä¸æ¥è¿äº,ä¸è½åæ¬¡ä¸æ¥!"); |
| | | } |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | return Result.success(finishedInspectService.updateFinishInspectsById(data.get("name").replaceAll("\"", ""), id)); |
| | | return Result.success(finishedInspectService.updateFinishInspectsById(data.get("name").replaceAll("\"", ""), id,number)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ ¹æ®æ£éªåidæ¥è¯¢æåæ£éªå详æ
") |
| | |
| | | |
| | | @ApiOperation(value = "䏿¥(æ´æ°æ£éªç¶æ)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true) |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "number", value = "ä¸åæ ¼æ°é", dataTypeClass = Integer.class) |
| | | }) |
| | | @PostMapping("/updateProcessInspectsById") |
| | | public Result updateProcessInspectsById(Integer id) { |
| | | public Result updateProcessInspectsById(Integer id,Integer number) { |
| | | //妿已ç»ä¸æ¥äºä¸è½å䏿¬¡ä¸æ¥ |
| | | ProcessInspect processInspect = processInspectService.getById(id); |
| | | if (ObjectUtils.isNotEmpty(processInspect.getResult())) { |
| | | return Result.fail("å·²ç»ä¸æ¥è¿äº,ä¸è½åæ¬¡ä¸æ¥!"); |
| | | } |
| | | return Result.success(processInspectService.updateProcessInspectsById(id)); |
| | | return Result.success(processInspectService.updateProcessInspectsById(id,number)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ ¹æ®æ£éªåidæ¥è¯¢è¿ç¨æ£éªå详æ
") |
| | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @ApiOperation(value = "æ°å¢åæææ£éªå-->æ ¹æ®åææç¼ç å¾å°ifsä¸çæ¥æ£æ°æ®") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "code", value = "åææç¼ç ", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @PostMapping("/chooseIFS") |
| | | public Result chooseIFS(String code){ |
| | | return Result.success(rawInspectService.chooseIFS(code)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°å¢åæææ£éªå") |
| | | @PostMapping("/addRawInspects") |
| | |
| | | |
| | | @ApiOperation(value = "䏿¥(æ´æ°æ£éªç¶æ)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true) |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "number", value = "ä¸åæ ¼æ°é", dataTypeClass = Integer.class) |
| | | }) |
| | | @PostMapping("/updateRawInspectsById/{id}") |
| | | public Result updateRawInspectsById(@PathVariable Integer id) { |
| | | public Result updateRawInspectsById(@PathVariable Integer id,Integer number) { |
| | | //妿已ç»ä¸æ¥äºä¸è½å䏿¬¡ä¸æ¥ |
| | | RawInspect rawInspect = rawInspectService.getById(id); |
| | | if (rawInspect.getInsState() == 1) { |
| | | return Result.fail("å·²ç»ä¸æ¥è¿äº,ä¸è½åæ¬¡ä¸æ¥!"); |
| | | } |
| | | return Result.success(rawInspectService.updateRawInspectsById(id)); |
| | | return Result.success(rawInspectService.updateRawInspectsById(id,number)); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | //æ ¹æ®åæææ£éªåidæ¥ç详æ
|
| | | Map<String, Object> selectRawInspectsListById(Integer id); |
| | | |
| | | //æ ¹æ®åææç¼ç æ¥è¯¢æè¿ä¸æ¡æ°æ® |
| | | RawInspect selOneByCode(String code); |
| | | } |
| | | |
| | | |
| | |
| | | private String reason; |
| | | |
| | | /** |
| | | * æ°é |
| | | **/ |
| | | private Integer number; |
| | | |
| | | /** |
| | | * å¤çç¶æ 0ï¼å¾
å¤çï¼1ï¼å·²å¤ç |
| | | **/ |
| | | private Integer dealState; |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | /** |
| | | * æ¥ææ¥æ |
| | | */ |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date formTime; |
| | | |
| | | @TableField(exist = false) |
| | |
| | | package com.yuanchu.mom.pojo.vo; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | * æ¥ææ¥æ |
| | | */ |
| | | @NotNull(message = "æ¥ææ¥æä¸è½ä¸ºç©º!") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private Date formTime; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private DateTime formTime; |
| | | |
| | | /** |
| | | * åå·è§æ ¼ |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | String updateFinishInspectsById(String username,Integer id); |
| | | String updateFinishInspectsById(String username,Integer id,Integer number); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢æåæ£éªåå表 |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | String updateProcessInspectsById(Integer id); |
| | | String updateProcessInspectsById(Integer id,Integer number); |
| | | |
| | | /** |
| | | * æ ¹æ®æ£éªåidæ¥è¯¢è¿ç¨æ£éªå详æ
|
| | |
| | | public interface RawInspectService extends IService<RawInspect> { |
| | | |
| | | /** |
| | | *æ°å¢åæææ£éªå-->æ ¹æ®åææç¼ç å¾å°ifsä¸çæ¥æ£æ°æ® |
| | | * @param code |
| | | * @return |
| | | */ |
| | | RawInspectVo chooseIFS(String code); |
| | | |
| | | /** |
| | | * æ°å¢åæææ£éªå |
| | | * @param userName |
| | | * @param rawInspectVo |
| | |
| | | * æ´æ°æ£éªç¶æ |
| | | * @param id |
| | | */ |
| | | String updateRawInspectsById(Integer id); |
| | | String updateRawInspectsById(Integer id,Integer number); |
| | | |
| | | |
| | | } |
| | |
| | | //䏿¥(æ´æ°æ£éªç¶æ) |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String updateFinishInspectsById(String username, Integer id) { |
| | | public String updateFinishInspectsById(String username, Integer id,Integer number) { |
| | | /*æ´æ°æ£éªåéé¢çæ£éªç»è®º*/ |
| | | //å
夿æ£éªç»æ |
| | | List<Integer> results = inspectionItemMapper.getResult(id, 2); |
| | |
| | | if (finishedInspect.getResult() == 0) { |
| | | InspectUnaccepted finishUnaccepted = InspectUnaccepted.builder() |
| | | .reason(finishedInspect.getMaterial() + "ä¸åæ ¼") //æä¸å®ä¹ä¸ºäº§ååç§°ä¸åæ ¼ |
| | | .number(number) |
| | | .rawInspectId(id) |
| | | .type(1) //ç±»å为æåæ£éª |
| | | .build(); |
| | |
| | | //䏿¥(æ´æ°æ£éªç¶æ) |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String updateProcessInspectsById(Integer id) { |
| | | public String updateProcessInspectsById(Integer id,Integer number) { |
| | | /*æ´æ°æ£éªåéé¢çæ£éªç»è®º*/ |
| | | //å
夿æ£éªç»æ |
| | | List<Integer> results = inspectionItemMapper.getResult(id, 1); |
| | |
| | | if (processInspect.getResult() == 0) { |
| | | InspectUnaccepted processUnaccepted = InspectUnaccepted.builder() |
| | | .reason(processInspect.getMaterial() + processInspect.getTechname() + "ä¸åæ ¼") //æä¸å®ä¹ä¸ºäº§ååç§°+å·¥èºä¸åæ ¼ |
| | | .number(number) |
| | | .rawInspectId(id) |
| | | .type(2) //ç±»å为è¿ç¨æ£éª |
| | | .build(); |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.Task.SyncOrder; |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | | import com.yuanchu.mom.pojo.vo.RawInsProductVo; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Resource |
| | | UserMapper userMapper; |
| | | |
| | | //æ°å¢åæææ£éªå-->æ ¹æ®åææç¼ç å¾å°ifsä¸çæ¥æ£æ°æ® |
| | | @Override |
| | | public RawInspectVo chooseIFS(String code) { |
| | | RawInspectVo rawInspectVo = new RawInspectVo(); |
| | | List<Map<String, Object>> mapList = SyncOrder.ifsInterfaces(); |
| | | for (Map<String, Object> map : mapList) { |
| | | //todo: åç»éè¦å°ç¶ææ¹æå¾
æ£éª |
| | | if (map.get("STATE").equals("å·²æ¥æ¶")) { |
| | | if (map.get("PART_NO").toString().equals(code)) { |
| | | rawInspectVo.setCode(map.get("PART_NO").toString()); //åææç¼ç |
| | | String[] split = map.get("PART_DESC").toString().split("ï¼"); |
| | | rawInspectVo.setName(split[0]); //åææåç§° |
| | | rawInspectVo.setSpecifications(split[1]); //åå·è§æ ¼ |
| | | rawInspectVo.setUnit(map.get("BUY_UNIT_MEAS").toString()); //åä½ |
| | | rawInspectVo.setNumber(Integer.parseInt(String.valueOf(map.get("QTY_TO_INSPECT")))); //æ°é |
| | | rawInspectVo.setFormTime(DateUtil.parse(map.get("APPROVED_DATE").toString())); //æ¥ææ¥æ |
| | | rawInspectVo.setSupplier(map.get("SUPPLIER_NAME").toString()); //ä¾åºå |
| | | } |
| | | } |
| | | } |
| | | //æ¥è¯¢è¯¥åæææ¯å¦ææ£éªé¡¹ç®è®°å½ |
| | | RawInspect rawInspect = rawInspectMapper.selOneByCode(code); |
| | | if (ObjectUtils.isNotEmpty(rawInspect)){ |
| | | List<RawInsProduct> rawInsProductList = rawInsProductMapper.selectList(Wrappers.<RawInsProduct>query().eq("raw_inspect_id", rawInspect.getId())); |
| | | List<RawInsProductVo> rawInsProductVos = rawInsProductList.stream().map(rawInsProduct -> { |
| | | RawInsProductVo rawInsProductVo = new RawInsProductVo(); |
| | | rawInsProductVo.setName(rawInsProduct.getName()); |
| | | rawInsProductVo.setUnit(rawInsProduct.getUnit()); |
| | | rawInsProductVo.setRequired(rawInsProduct.getRequired()); |
| | | rawInsProductVo.setInternal(rawInsProduct.getInternal()); |
| | | return rawInsProductVo; |
| | | }).collect(Collectors.toList()); |
| | | rawInspectVo.setRawInsProducts(rawInsProductVos); |
| | | } |
| | | return rawInspectVo; |
| | | } |
| | | |
| | | //æ°å¢åæææ£éªå |
| | | @Override |
| | |
| | | //æ´æ°æ£éªç¶æ(䏿¥) |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String updateRawInspectsById(Integer id) { |
| | | public String updateRawInspectsById(Integer id,Integer number) { |
| | | /*æ´æ°æ£éªåéé¢çæ£éªç»è®º*/ |
| | | //å
夿æ£éªç»æ |
| | | List<Integer> results = rawInsProductMapper.getresult(id); |
| | |
| | | if (rawInspect.getJudgeState() == 0) { |
| | | InspectUnaccepted rawUnaccepted = InspectUnaccepted.builder() |
| | | .reason(rawInspectMapper.selectById(id).getName() + "ä¸åæ ¼") //æä¸å®ä¹ä¸ºåææä¸åæ ¼ |
| | | .number(number) |
| | | .rawInspectId(id) |
| | | .dealReasult(1) |
| | | .type(0) //ç±»åä¸ºåææ |
| | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //妿æ¯> , < ,=çæä½ |
| | | private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | boolean isStandardValueSatisfied = isValueSatisfied(standardValueStr, detectionValueStr); |
| | |
| | | <?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.yuanchu.mom.mapper.InspectUnacceptedMapper"> |
| | | |
| | | |
| | | <!--ä¸åæ ¼ç®¡ç--> |
| | | <select id="selectInsList" resultType="java.util.Map"> |
| | | SELECT ru.id, |
| | |
| | | fi.project_name, |
| | | fi.specifications_model, |
| | | fi.unit, |
| | | fi.quantity, |
| | | number quantity, |
| | | DATE_FORMAT(fi.inspectionDate, '%Y-%m-%d') inspectionDate, |
| | | DATE_FORMAT(fi.processingDate, '%Y-%m-%d') processingDate |
| | | FROM mom_ocean.inspect_unaccepted ru, mom_ocean.`user` u, ( |
| | |
| | | r.`name`, |
| | | r.`specifications`, |
| | | r.`unit`, |
| | | r.`number`, |
| | | i.number, |
| | | DATE_FORMAT(r.`create_time`,'%Y-%m-%d') inspectionDate, |
| | | r.`user_name`, |
| | | DATE_FORMAT(r.`ins_time`,'%Y-%m-%d') processingDate, |
| | |
| | | |
| | | <!--ä¸åæ ¼å¤ç½®--> |
| | | <select id="selectDisposal" resultType="map"> |
| | | SELECT i.`id`, s.`type`, s.name productName, s.`specifications`, s.number, i.`tell` description, |
| | | SELECT i.`id`, s.`type`, s.name productName, s.`specifications`, i.number, i.`tell` description, |
| | | i.`tell` opinions, s.user_name, DATE_FORMAT(i.`create_time`, '%Y-%m-%d') `date`, i.`deal_state`, i.way, i.faulty_materials, i.opinion_tell |
| | | FROM mom_ocean.inspect_unaccepted i |
| | | LEFT JOIN |
| | |
| | | SELECT 0 AS `type`, r.`name`, r.`specifications`, r.`number`, r.`id`, r.`user_name` |
| | | FROM mom_ocean.raw_inspect r |
| | | WHERE r.state = 1 |
| | | <if test="specificationModel != null and specificationModel != ''">AND r.`specifications` LIKE CONCAT('%', |
| | | <if test="specificationModel != null and specificationModel != ''"> |
| | | AND r.`specifications` LIKE CONCAT('%', |
| | | #{specificationModel}, '%') |
| | | </if> |
| | | <if test=" |
| | | productName != null and productName != ''">AND r.`name` LIKE CONCAT('%', #{productName}, '%') |
| | | productName != null and productName != ''"> |
| | | AND r.`name` LIKE CONCAT('%', #{productName}, '%') |
| | | </if> |
| | | UNION ALL |
| | | -- åæå |
| | | SELECT 1 AS `type`, f.`project_name` `name`, f.`specifications_model` specifications, f.`quantity` `number`, f.`id`, u.name user_name |
| | | -- æå |
| | | SELECT 1 AS `type`, f.`project_name` `name`, f.`specifications_model` specifications, f.`quantity` `number`, |
| | | f.`id`, u.name user_name |
| | | FROM mom_ocean.finished_inspect f, mom_ocean.`user` u |
| | | WHERE f.`state` = 1 |
| | | AND u.id = f.user_id |
| | |
| | | AND f.`project_name` LIKE CONCAT('%', #{productName}, '%') |
| | | </if> |
| | | UNION ALL |
| | | -- å¨å¶å |
| | | SELECT 2 AS `type`, p.`material` `name`, p.`specifications_model` specifications, p.`quantity` `number`, p.`id`, u.name user_name |
| | | -- åæå |
| | | SELECT 2 AS `type`, p.`material` `name`, p.`specifications_model` specifications, p.`quantity` `number`, p.`id`, |
| | | u.name user_name |
| | | FROM mom_ocean.process_inspect p, mom_ocean.`user` u |
| | | WHERE p.state = 1 |
| | | AND u.id = p.user_id |
| | |
| | | and rp.state = 1 |
| | | and r.id = #{id} |
| | | </select> |
| | | |
| | | <!--æ ¹æ®åææç¼ç æ¥è¯¢æè¿ä¸æ¡æ°æ®--> |
| | | <select id="selOneByCode" resultType="com.yuanchu.mom.pojo.RawInspect"> |
| | | select * |
| | | from mom_ocean.raw_inspect |
| | | where state = 1 |
| | | and code = #{code} |
| | | order by id desc |
| | | limit 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | private static final String DOWN_LOAD = "http://192.168.18.16:9999/order/otcService/download/"; |
| | | |
| | | private static final String IFS_URL="http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_POL_RECEIPT_STD&userId=mes_user&inAttr={\"ORDER_NO\":\"-2050314\"}"; |
| | | |
| | | private static final Map<String, String> GET_TOKEN_HEADER = new HashMap<>(2); |
| | | |
| | | private static final Map<String, Object> USER_INFO = new HashMap<>(4); |
| | |
| | | .execute().body(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * ifs |
| | | * @return |
| | | */ |
| | | public static List<Map<String, Object>>ifsInterfaces(){ |
| | | String result = HttpRequest.get(IFS_URL) |
| | | .header("Authorization", "Bearer " + getToken()) |
| | | .execute().body(); |
| | | Map<String, Object>map=JsonUtil.jsonToPojo(result,Map.class); |
| | | return JsonUtil.jsonToPojo(JsonUtil.jsonToString(map.get("LIST_INFO")),List.class); |
| | | } |
| | | } |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.support.ExcelTypeEnum; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.dto.ExportSaleDto; |
| | | import com.yuanchu.mom.utils.easyexcel.template.ExportSaleTemplate; |
| | | import com.yuanchu.mom.pojo.dto.SaleDto; |
| | | import com.yuanchu.mom.pojo.dto.SaleMaterialDto; |
| | | import com.yuanchu.mom.pojo.vo.SaleVo; |
| | | import com.yuanchu.mom.service.RepertoryService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.pojo.dto.SaleDto; |
| | | import com.yuanchu.mom.service.SaleService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.easyexcel.CustemHandler; |
| | | import com.yuanchu.mom.utils.easyexcel.EasyExcelUtils; |
| | | import com.yuanchu.mom.utils.easyexcel.LocalDateConverter; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | import springfox.documentation.spring.web.json.Json; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | return Result.success(saleService.download(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "éå®è®¢å导åº") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "orderNumber", value = "订åç¼å·", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "name", value = "产ååç§°", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "type", value = "ç¶æ(为空=å
¨é¨)", dataTypeClass = Integer.class), |
| | | @ApiImplicitParam(name = "delTime", value = "äº¤è´§æ¥æ", dataTypeClass = String.class) |
| | | }) |
| | | @PostMapping("/exportSale") |
| | | public void exportSale(@RequestBody ExportSaleDto dto, HttpServletResponse response){ |
| | | saleService.exportSale(dto,response); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.Sale; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.yuanchu.mom.utils.easyexcel.template.ExportSaleTemplate; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | //æ¹éå é¤ |
| | | void delAllSale(String ids); |
| | | |
| | | List<ExportSaleTemplate> selectSaleListByExport(String orderNumber, String name, Integer type, String delTime); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.pojo.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Author: Zou, Yu |
| | | * @DATE: 2023/9/24 0024 15:45 |
| | | */ |
| | | @Data |
| | | @JsonSerialize |
| | | public class ExportSaleDto { |
| | | |
| | | @JsonSerialize |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private String delTime; |
| | | |
| | | @JsonSerialize |
| | | private String name; |
| | | |
| | | @JsonSerialize |
| | | private Integer type; |
| | | |
| | | @JsonSerialize |
| | | private String orderNumber; |
| | | |
| | | } |
| | |
| | | import com.yuanchu.mom.pojo.Sale; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.yuanchu.mom.pojo.dto.ConsignmentDto1; |
| | | import com.yuanchu.mom.pojo.dto.ExportSaleDto; |
| | | import com.yuanchu.mom.pojo.dto.SaleDto; |
| | | import com.yuanchu.mom.pojo.vo.SaleVo; |
| | | import com.yuanchu.mom.utils.easyexcel.template.ExportSaleTemplate; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | * @return |
| | | */ |
| | | List<String> download(Integer id); |
| | | |
| | | /** |
| | | * 导åºéå®è®¢å |
| | | * @param dto |
| | | * @param response |
| | | */ |
| | | void exportSale(ExportSaleDto dto, HttpServletResponse response); |
| | | |
| | | } |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.support.ExcelTypeEnum; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.yuanchu.mom.pojo.Sale; |
| | | import com.yuanchu.mom.mapper.SaleMapper; |
| | | import com.yuanchu.mom.pojo.SaleMaterial; |
| | | import com.yuanchu.mom.pojo.dto.ConsignmentDto1; |
| | | import com.yuanchu.mom.pojo.dto.ConsignmentDto2; |
| | | import com.yuanchu.mom.pojo.dto.SaleDto; |
| | | import com.yuanchu.mom.pojo.dto.SaleMaterialDto; |
| | | import com.yuanchu.mom.pojo.dto.*; |
| | | import com.yuanchu.mom.pojo.vo.SaleVo; |
| | | import com.yuanchu.mom.service.SaleMaterialService; |
| | | import com.yuanchu.mom.service.SaleService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.utils.easyexcel.CustemHandler; |
| | | import com.yuanchu.mom.utils.easyexcel.EasyExcelUtils; |
| | | import com.yuanchu.mom.utils.easyexcel.LocalDateConverter; |
| | | import com.yuanchu.mom.utils.easyexcel.template.ExportSaleTemplate; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public void exportSale(ExportSaleDto dto, HttpServletResponse response) { |
| | | try{ |
| | | List<ExportSaleTemplate> exportSaleTemplates = saleMapper.selectSaleListByExport(dto.getOrderNumber(), dto.getName(), dto.getType(), dto.getDelTime()); |
| | | for (int i = 0; i < exportSaleTemplates.size(); i++) { |
| | | exportSaleTemplates.get(i).setId(i+1); |
| | | } |
| | | String fileName = String.valueOf(new StringBuilder() |
| | | .append("éå®è®¢å_") |
| | | .append(DateUtil.today()) |
| | | .append(ExcelTypeEnum.XLS.getValue())); |
| | | fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString()); |
| | | response.setContentType("application/octet-stream"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(ExportSaleTemplate.class) |
| | | .registerConverter(new LocalDateConverter()) |
| | | .autoCloseStream(true) |
| | | .excelType(ExcelTypeEnum.XLS) |
| | | .registerWriteHandler(new CustemHandler()) |
| | | .registerWriteHandler(EasyExcelUtils.getStyleStrategy()) |
| | | .sheet("Sheet1") |
| | | .doWrite(exportSaleTemplates); |
| | | }catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | response.getOutputStream().close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | </if> |
| | | order by id desc |
| | | </select> |
| | | |
| | | <select id="selectSaleListByExport" resultType="com.yuanchu.mom.utils.easyexcel.template.ExportSaleTemplate"> |
| | | select order_number AS orderNumber, |
| | | code, |
| | | name, |
| | | proname, |
| | | type, |
| | | DATE_FORMAT(delTime, '%Y-%m-%d') AS delTime, |
| | | note, |
| | | order_type AS orderType |
| | | from mom_ocean.sale |
| | | where state=1 |
| | | <if test="orderNumber!=null and orderNumber!=''"> |
| | | and order_number like concat('%',#{orderNumber},'%') |
| | | </if> |
| | | <if test="name!=null and name!=''"> |
| | | and name LIKE CONCAT('%',#{name},'%') |
| | | </if> |
| | | <if test="type!=null "> |
| | | and type=#{type} |
| | | </if> |
| | | <if test="delTime!=null and delTime!=''"> |
| | | and DATE_FORMAT(delTime, '%Y-%m-%d')=#{delTime} |
| | | </if> |
| | | order by id desc |
| | | </select> |
| | | <!--æ¥è¯¢è®¢åBOMå表--> |
| | | <select id="selectAllOrder" resultType="java.util.Map"> |
| | | select sm.id, |
| | |
| | | <feign-okhttp.version>11.0</feign-okhttp.version> |
| | | <shiro.version>1.5.3</shiro.version> |
| | | <hutool.version>5.8.16</hutool.version> |
| | | <easyexcel.version>2.2.10</easyexcel.version> |
| | | <poi.version>4.1.2</poi.version> |
| | | <!--æäº¤å--> |
| | | <!-- æå
å导åºçè·¯å¾ --> |
| | | <package.path>${project.build.directory}/BLOG</package.path> |
| | |
| | | |
| | | <dependencyManagement> |
| | | <dependencies> |
| | | <!--easyexcel--> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>${easyexcel.version}</version> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>${poi.version}</version> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>${poi.version}</version> |
| | | </dependency> |
| | | <!--log4j--> |
| | | <dependency> |
| | | <groupId>log4j</groupId> |
| | |
| | | package com.yuanchu.mom; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.yuanchu.mom.Task.SyncOrder; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.yuanchu.mom.pojo.Sale; |
| | | import com.yuanchu.mom.pojo.SaleMaterial; |
| | | import org.junit.jupiter.api.Test; |
| | |
| | | } |
| | | System.out.println(list); |
| | | } |
| | | |
| | | @Test |
| | | void bb() { |
| | | List<Map<String, Object>> mapList = SyncOrder.ifsInterfaces(); |
| | | List<RawInspect> rawInspectList = mapList.stream().map(map -> { |
| | | RawInspect rawInspect = new RawInspect(); |
| | | if (map.get("PART_NO").toString().equals("A0410008010700")) { |
| | | rawInspect.setCode(map.get("PART_NO").toString()); //åææç¼ç |
| | | String[] split = map.get("PART_DESC").toString().split("ï¼"); |
| | | rawInspect.setName(split[0]); //åææåç§° |
| | | rawInspect.setSpecifications(split[1]); //åå·è§æ ¼ |
| | | rawInspect.setUnit(map.get("BUY_UNIT_MEAS").toString()); //åä½ |
| | | rawInspect.setNumber(Integer.parseInt(String.valueOf(map.get("QTY_TO_INSPECT")))); //æ°é |
| | | rawInspect.setInsState(0); //æªæ£éª |
| | | rawInspect.setFormTime(DateUtil.parse(map.get("APPROVED_DATE").toString())); //æ¥ææ¥æ |
| | | rawInspect.setSupplier(map.get("SUPPLIER_NAME").toString()); //ä¾åºå |
| | | } |
| | | return rawInspect; |
| | | }).collect(Collectors.toList()); |
| | | System.out.println(rawInspectList); |
| | | } |
| | | |
| | | } |