Prechádzať zdrojové kódy

售后BOM管理(导入及复制)

hu 2 mesiacov pred
rodič
commit
f1e089f46c

+ 25 - 0
src/custom/restcontroller/R.java

@@ -6162,6 +6162,31 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025071414200903 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025071414202103 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025071414400503 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025071415152103 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025071415153103 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 263 - 0
src/custom/restcontroller/webmanage/sale/aftersalesbom/ExportExcel.java

@@ -0,0 +1,263 @@
+package restcontroller.webmanage.sale.aftersalesbom;
+
+
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.awt.*;
+
+public class ExportExcel {
+    /**
+     * 设置标题单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle1(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.RED.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居中
+        return cellStyle;
+    }
+
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle2(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.RED.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorGrey = new XSSFColor(new Color(217, 225, 242));
+        cellStyle.setFillForegroundColor(colorGrey);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    }
+
+    /**
+     * 设置正文单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createBodyCellStyle4(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setFontName("微软雅黑");// 设置标题字体
+        // font.setFontName(HSSFFont.FONT_ARIAL);// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        return cellStyle;
+    }
+
+    public static XSSFCellStyle createTitleCellStyle3(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.WHITE.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居中
+        return cellStyle;
+    }
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(导入模板)
+     **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5000);
+        sheet.setColumnWidth((short) 1, (short) 5000);
+        sheet.setColumnWidth((short) 2, (short) 5000);
+    }
+
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(返回错误Excel的样式)
+     **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5000);
+        sheet.setColumnWidth((short) 1, (short) 5000);
+        sheet.setColumnWidth((short) 2, (short) 5000);
+        sheet.setColumnWidth((short) 3, (short) 5000);
+    }
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFCellStyle cellStyle4, XSSFWorkbook xssfFWorkbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+        cellStyle1.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle2.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle3.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle4.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("售后bom产品清单导入");
+
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 2));
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("注意:①请按照以下示例填写信息;②最多不超过5000行;③导入前,请记得删除示例行!");
+        /*第三行塞值*/
+        row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("品号(必填)");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("品名");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("型号规格");
+
+        /*第四行塞值*/
+        row = sheet.createRow(3);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("测试品号");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("测试品名");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("测试型号规格");
+
+    }
+
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 3));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("售后bom产品清单导入");
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 3));
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("注意:①请按照以下示例填写信息;②最多不超过5000行;③导入前,请记得删除示例行!");
+        /*第三行塞值*/
+        row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("品号(必填)");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("品名");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("型号规格");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("错误信息");
+
+    }
+}

+ 308 - 0
src/custom/restcontroller/webmanage/sale/aftersalesbom/ExportExcel_pj.java

@@ -0,0 +1,308 @@
+package restcontroller.webmanage.sale.aftersalesbom;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.YosException;
+import common.data.Rows;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.awt.*;
+import java.util.Objects;
+
+public class ExportExcel_pj {
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(导入模板)
+     **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        short width = 3500;
+        sheet.setColumnWidth((short) 0, 4000);
+        sheet.setColumnWidth((short) 1, 4000);
+        for (int i = 1; i < 20; i++) {
+            sheet.setColumnWidth((short) i, width);
+        }
+
+    }
+
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(返回错误Excel的样式)
+     **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        short width = 3000;
+        sheet.setColumnWidth((short) 0, 4000);
+        sheet.setColumnWidth((short) 1, 4000);
+        for (int i = 1; i < 18; i++) {
+            sheet.setColumnWidth((short) i, width);
+        }
+        sheet.setColumnWidth((short) 20, width * 2);
+
+    }
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFWorkbook workbook, Rows rows) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+
+        cellStyle1.setDataFormat(workbook.createDataFormat().getFormat("TEXT"));
+        cellStyle2.setDataFormat(workbook.createDataFormat().getFormat("TEXT"));
+        cellStyle3.setDataFormat(workbook.createDataFormat().getFormat("TEXT"));
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 18));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("注意:①;最多不超过5000行;②导入前,请记得删除示例行!");
+
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("bom名称");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("层级");
+
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("层级");
+
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("层级");
+        int j=0;
+        for (int i = 1; i < 6; i++) {
+            cell = row.createCell( 4+j);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue("物料号"+i);
+
+            cell = row.createCell( 5+j);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue("启用时间"+i);
+
+            cell = row.createCell( 6+j);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue("停用时间"+i);
+            j=j+3;
+        }
+        int a=2;
+        for(common.data.Row bom : rows){
+            String bomname = bom.getString("bomname");
+            String module = bom.getString("module");
+            String component = bom.getString("component");
+            String accessorie = bom.getString("accessorie");
+            /*第三行塞值*/
+            row = sheet.createRow(a);
+
+            cell = row.createCell(0);
+            //cell.setCellStyle(cellStyle3);
+            cell.setCellValue(bomname);
+
+            cell = row.createCell(1);
+            //cell.setCellStyle(cellStyle3);
+            cell.setCellValue(module);
+
+            cell = row.createCell(2);
+           //cell.setCellStyle(cellStyle3);
+            cell.setCellValue(component);
+
+            cell = row.createCell(3);
+            //cell.setCellStyle(cellStyle3);
+            cell.setCellValue(accessorie);
+            a++;
+        }
+        //按范围合并单元格
+        for(int i = 0; i < 4; i++){
+            mergeSameCellContentColumn(sheet, 2, i);
+        }
+
+
+
+//        for (int i = 1; i < 18; i++) {
+//            cell = row.createCell(i);
+//            cell.setCellStyle(cellStyle3);
+//            cell.setCellValue("0");
+//
+//        }
+
+
+    }
+
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 19));//2.提示信息
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("注意:①最多不超过5000行;②导入前,请记得删除示例行!");
+
+
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("bom名称");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("层级");
+
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("层级");
+
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("层级");
+        int j=0;
+        for (int i = 1; i < 6; i++) {
+            cell = row.createCell( 4+j);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue("物料号"+i);
+
+            cell = row.createCell( 5+j);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue("启用时间"+i);
+
+            cell = row.createCell( 6+j);
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue("停用时间"+i);
+            j=j+3;
+        }
+
+        cell = row.createCell(19);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("错误信息");
+
+        //按范围合并单元格
+        for(int i = 0; i < 4; i++){
+            mergeSameCellContentColumn(sheet, 2, i);
+        }
+
+
+    }
+
+    public static void setBatchDetailSheetColumn3(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 700);
+        short width = 3500;
+        sheet.setColumnWidth((short) 0, 4000);
+        sheet.setColumnWidth((short) 1, 4000);
+        for (int i = 1; i < 20; i++) {
+            sheet.setColumnWidth((short) i, width);
+        }
+
+    }
+
+    /**
+     * 合并指定Excel sheet页、指定列中连续相同内容的单元格
+     *
+     * @param sheet    Excel sheet
+     * @param startRow 从第几行开始, startRow的值从1开始
+     * @param column   指定列
+     */
+    public static void mergeSameCellContentColumn(Sheet sheet, int startRow, int column) {
+        int totalRows = sheet.getLastRowNum();
+        int firstRow = 0;
+        int lastRow = 0;
+        // 上一次比较是否相同
+        boolean isPrevCompareSame = false;
+        String prevMergeAddress = null;
+        String currentMergeAddress;
+        // 从第几开始判断是否相同
+        if (totalRows >= startRow) {
+            for (int i = startRow; i <= totalRows; i++) {
+                String lastRowCellContent = sheet.getRow(i - 1).getCell(column).getStringCellValue();
+                String curRowCellContent = sheet.getRow(i).getCell(column).getStringCellValue();
+                if (curRowCellContent.equals(lastRowCellContent)) {
+                    if (!isPrevCompareSame) {
+                        firstRow = i - 1;
+                    }
+                    lastRow = i;
+                    isPrevCompareSame = true;
+                } else {
+                    isPrevCompareSame = false;
+                    currentMergeAddress = firstRow + lastRow + column + column + "";
+                    if (lastRow > firstRow && !Objects.equals(currentMergeAddress, prevMergeAddress)) {
+                        sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, column, column));
+                        prevMergeAddress = currentMergeAddress;
+                    }
+                }
+                // 最后一行时判断是否有需要合并的行
+                if ((i == totalRows) && (lastRow > firstRow)) {
+                    currentMergeAddress = firstRow + lastRow + column + column + "";
+                    if (!Objects.equals(currentMergeAddress, prevMergeAddress)) {
+                        sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, column, column));
+                    }
+                }
+            }
+        }
+    }
+
+
+}

+ 58 - 1
src/custom/restcontroller/webmanage/sale/aftersalesbom/aftersalesbom.java

@@ -10,7 +10,9 @@ import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.data.*;
+import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
+import restcontroller.webmanage.sale.promotion.*;
 import restcontroller.webmanage.sale.supplier.supplier;
 
 import java.util.ArrayList;
@@ -177,7 +179,7 @@ public class aftersalesbom extends Controller {
     }
 
     @API(title = "审核反审核", apiversion = R.ID2025071409541703.v1.class)
-    @CACHEING_CLEAN( apiClass = {supplier.class})
+    @CACHEING_CLEAN( apiClass = {aftersalesbom.class})
     public String check() throws YosException {
         Long sa_aftersalesbomid = content.getLong("sa_aftersalesbomid");
         boolean ischeck = content.getBooleanValue("ischeck");
@@ -247,4 +249,59 @@ public class aftersalesbom extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+
+    @API(title = "一键复制售后bom", apiversion = R.ID2025071414400503.v1.class)
+    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_pjs.class})
+    public String copyAftersalesbom() throws YosException {
+
+        Long sa_aftersalesbomid = content.getLong("sa_aftersalesbomid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        Rows rows = dbConnect.runSqlQuery("SELECT * from sa_aftersalesbom  WHERE sa_aftersalesbomid = " + sa_aftersalesbomid + " and siteid = '" + siteid + "'");
+
+        if (rows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("售后bom不存在").toString();
+        }
+        Row row = rows.get(0);
+
+        Long sa_aftersalesbom_copy = createTableID("sa_aftersalesbom");
+        InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_aftersalesbom");
+        insertSQL.setUniqueid(sa_aftersalesbom_copy);
+        insertSQL.setSiteid(siteid);
+        insertSQL.setValue("name",  row.getString("name")+"复制");
+        insertSQL.setValue("productcategories",  row.getString("productcategories"));
+        insertSQL.setValue("billno", createBillCode("aftersalesbom"));
+        insertSQL.setValue("createby", username);
+        insertSQL.setDateValue("createdate");
+        insertSQL.setValue("changeby", username);
+        insertSQL.setDateValue("changedate");
+        insertSQL.setValue("status", "新建");
+        sqlList.add(insertSQL.getSQL());
+
+        //复制商品
+        Rows aftersalesbompjsRows = dbConnect.runSqlQuery("SELECT * from sa_aftersalesbom_pjs WHERE sa_aftersalesbomid = " + sa_aftersalesbomid + " and siteid = '" + siteid + "'");
+
+        for (Row aftersalesbompj : aftersalesbompjsRows) {
+
+            InsertSQL insertSQL1 = SQLFactory.createInsertSQL(this, "sa_aftersalesbom_pjs");
+            insertSQL1.setUniqueid(createTableID("sa_aftersalesbom_pjs"));
+            insertSQL1.setSiteid(siteid);
+            insertSQL1.setValue("sa_aftersalesbomid", sa_aftersalesbom_copy);
+            insertSQL1.setValue("module", aftersalesbompj.getString("module"));
+            insertSQL1.setValue("component", aftersalesbompj.getString("component"));
+            insertSQL1.setValue("accessorie", aftersalesbompj.getString("accessorie"));
+            insertSQL1.setValue("itemid", aftersalesbompj.getString("itemid"));
+            insertSQL1.setValue("itemname", aftersalesbompj.getString("itemname"));
+            insertSQL1.setValue("itemno", aftersalesbompj.getString("itemno"));
+            insertSQL1.setValue("begindate", StringUtils.isBlank(aftersalesbompj.getString("begindate")) ?"null":aftersalesbompj.getString("begindate"));
+            insertSQL1.setValue("enddate", StringUtils.isBlank(aftersalesbompj.getString("enddate")) ?"null":aftersalesbompj.getString("enddate"));
+            sqlList.add(insertSQL1.getSQL());
+        }
+        dbConnect.runSqlUpdate(sqlList);
+        content.put("sa_aftersalesbomid", sa_aftersalesbom_copy);
+
+        return queryaftersalesbomMain();
+    }
+
 }

+ 211 - 0
src/custom/restcontroller/webmanage/sale/aftersalesbom/aftersalesbom_items.java

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.sale.aftersalesbom;
 
 import beans.data.BatchDeleteErr;
+import beans.itemprice.ItemPrice;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
@@ -9,10 +10,19 @@ import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.data.*;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.xssf.usermodel.*;
 import restcontroller.R;
 import restcontroller.webmanage.sale.aftersalesbom.aftersalesbom;
+import restcontroller.webmanage.sale.aftersalesbom.ExportExcel;
+import utility.tools.Math;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.HashMap;
 
 @API(title = "售后bom产品清单")
 public class aftersalesbom_items extends Controller {
@@ -170,4 +180,205 @@ public class aftersalesbom_items extends Controller {
 
         return batchDeleteErr.getReturnObject().toString();
     }
+
+    @API(title = "下载导入模板", apiversion = R.ID2025071414200903.v1.class)
+    public String downloadExcel() throws YosException {
+        ExcelFactory excelFactory = new ExcelFactory("售后bom产品清单导入模板");
+
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        for (int i = 0; i <= 2; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        // 设置工作薄列宽
+        restcontroller.webmanage.sale.aftersalesbom.ExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle4 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createBodyCellStyle4(xssfFWorkbook);
+
+        restcontroller.webmanage.sale.aftersalesbom.ExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4, xssfFWorkbook);
+
+        Rows aa = uploadExcelToObs(excelFactory);
+        String url = "";
+        if (!aa.isEmpty()) {
+            url = aa.get(0).getString("url");
+        }
+        return getSucReturnObject().setData(url).toString();
+    }
+
+
+    @API(title = "售后bom产品清单导入", apiversion = R.ID2025071414202103.v1.class)
+    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_items.class})
+    public String importItems() throws YosException {
+        Long sa_aftersalesbomid = content.getLong("sa_aftersalesbomid");
+        Rows aftersalesbom = dbConnect.runSqlQuery("select status from sa_aftersalesbom where siteid='" + siteid + "' and sa_aftersalesbomid=" + sa_aftersalesbomid);
+        if (aftersalesbom.isEmpty()) {
+            return getErrReturnObject().setErrMsg("该售后bom不存在").toString();
+        }
+        if (!aftersalesbom.get(0).getString("status").equals("新建")) {
+            return getErrReturnObject().setErrMsg("非新建状态不能导入").toString();
+        }
+        ArrayList<String> sqlList = new ArrayList<>();
+        ExcelFactory e;
+        try {
+
+            // 华为云
+            e = getPostExcelFactory(content.getLong("attachmentid"));
+            // 本地
+            //e = getPostExcelFactory();
+
+            ArrayList<String> keys = new ArrayList<>();
+            keys.add("itemno");
+            keys.add("itemname");
+            keys.add("spec");
+
+            Rows rows = e.getSheetRows(0, keys, 3);
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+
+            RowsMap itemRowsMap = dbConnect.runSqlQuery("select itemid,itemno from plm_item where siteid='" + siteid + "' and isonsale=1").toRowsMap("itemno");
+            ArrayList<Long> itemidList = dbConnect.runSqlQuery("select itemid from sa_aftersalesbom_items t1 inner join sa_aftersalesbom t2 on t1.siteid=t2.siteid and t1.sa_aftersalesbomid=t2.sa_aftersalesbomid").toArrayList("itemid", new ArrayList<>());
+
+            RowsMap imtitemRowsMap = rows.toRowsMap("itemno");
+            for (Row row : rows) {
+                String itemno = row.getString("itemno");
+                String itemname = row.getString("itemname");
+                String spec = row.getString("spec");
+                if (StringUtils.isEmpty(itemno)) {
+                    iserr = true;
+                    row.put("msg", "错误信息:品号不能为空");
+                    rowserr.add(row);
+                    continue;
+                }
+                if (imtitemRowsMap.get(itemno).size() > 1) {
+                    iserr = true;
+                    row.put("msg", "错误信息:本次导入存在重复商品");
+                    rowserr.add(row);
+                    continue;
+                }
+                if (!itemRowsMap.containsKey(itemno)) {
+                    iserr = true;
+                    row.put("msg", "错误信息:商品不存在");
+                    rowserr.add(row);
+                    continue;
+                } else {
+                    row.put("itemid", itemRowsMap.get(itemno).get(0).getLong("itemid"));
+                }
+                if (itemidList.contains(row.getLong("itemid"))) {
+                    iserr = true;
+                    row.put("msg", "错误信息:商品已存在其余售后bom中");
+                    rowserr.add(row);
+                    continue;
+                }
+                rowssuc.add(row);
+            }
+            if (iserr) {
+                ExcelFactory excelFactory = new ExcelFactory("商品明细导入错误信息");
+                HashMap<String, String> map = new HashMap<String, String>();
+                map.put("itemno", "品号");
+                map.put("itemname", "品名");
+                map.put("spce", "型号规格");
+                map.put("msg", "错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("itemno");
+                colNameList.add("itemname");
+                colNameList.add("spce");
+                colNameList.add("msg");
+                keytypemap.put("itemno", String.class);
+                keytypemap.put("itemname", String.class);
+                keytypemap.put("spce", String.class);
+                keytypemap.put("msg", String.class);
+                rowserr.setFieldList(colNameList);
+                rowserr.setFieldTypeMap(keytypemap);
+                addSheet(excelFactory, "Sheet1", rowserr, map);
+
+                Rows aa = uploadExcelToObs(excelFactory);
+                String url = "";
+                if (!aa.isEmpty()) {
+                    url = aa.get(0).getString("url");
+                }
+                return getSucReturnObject().setData(url).toString();
+            }
+
+            if (!rowssuc.isEmpty()) {
+                for (Row row : rowssuc) {
+                    InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_aftersalesbom_items");
+                    insertSQL.setUniqueid(createTableID("sa_aftersalesbom_items"));
+                    insertSQL.setSiteid(siteid);
+                    insertSQL.setValue("sa_aftersalesbomid", sa_aftersalesbomid);
+                    insertSQL.setValue("itemid", row.getString("itemid"));
+                    insertSQL.setValue("itemname", row.getString("itemname"));
+                    insertSQL.setValue("itemno", row.getString("itemno"));
+                    insertSQL.setValue("spec", row.getString("spec"));
+                    sqlList.add(insertSQL.getSQL());
+                }
+            }
+
+            if (!sqlList.isEmpty()) {
+                dbConnect.runSqlUpdate(sqlList);
+            }
+        } catch (Exception e1) {
+            e1.printStackTrace();
+            return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
+        }
+        return getSucReturnObject().toString();
+    }
+
+    public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows,
+                              HashMap<String, String> titlemap) {
+        ArrayList<String> keylist = datarows.getFieldList();
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
+        XSSFFont font = xssfFWorkbook.createFont();
+
+        font.setColor((short) 0xa);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        xssfCellStyle1.setFont(font);
+
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        for (int i = 0; i <= 3; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        restcontroller.webmanage.sale.aftersalesbom.ExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        ExportExcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
+
+        for (int n = 0; n < datarows.size(); n++) {
+            Row row = datarows.get(n);
+            XSSFRow datarow = sheet.createRow(n + 3);
+            for (int i1 = 0; i1 < keylist.size(); i1++) {
+                Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
+                if (fieldclazztype == Integer.class) {
+                    datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)));
+                } else if (fieldclazztype == Long.class) {
+                    datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
+                } else if (fieldclazztype == Float.class) {
+                    datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
+                } else if (fieldclazztype == Double.class) {
+                    datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
+                } else {
+                    datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
+                }
+                if (i1 == 3) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
 }

+ 287 - 2
src/custom/restcontroller/webmanage/sale/aftersalesbom/aftersalesbom_pjs.java

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.sale.aftersalesbom;
 
 import beans.data.BatchDeleteErr;
+import camundajar.impl.fastparse.internal.Msgs;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
@@ -10,10 +11,15 @@ import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.data.*;
 import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.xssf.usermodel.*;
 import restcontroller.R;
 import restcontroller.webmanage.sale.aftersalesbom.aftersalesbom;
+import restcontroller.webmanage.sale.aftersalesbom.ExportExcel;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 
 public class aftersalesbom_pjs extends Controller {
     public aftersalesbom_pjs(JSONObject content) throws YosException {
@@ -53,7 +59,7 @@ public class aftersalesbom_pjs extends Controller {
 
 
     @API(title = "售后bom配件明细新增更新", apiversion = R.ID2025071411252903.v1.class)
-    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_items.class})
+    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_pjs.class})
     public String insertormodify_aftersalesbompjs() throws YosException {
         Long sa_aftersalesbomid = content.getLong("sa_aftersalesbomid");
         JSONArray iteminfos = content.getJSONArray("iteminfos");
@@ -155,7 +161,7 @@ public class aftersalesbom_pjs extends Controller {
     }
 
     @API(title = "删除配件明细", apiversion = R.ID2025071411255003.v1.class)
-    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_items.class})
+    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_pjs.class})
     public String deletemx() throws YosException {
 
         JSONArray sa_aftersalesbom_pjsids = content.getJSONArray("sa_aftersalesbom_pjsids");
@@ -180,4 +186,283 @@ public class aftersalesbom_pjs extends Controller {
 
         return batchDeleteErr.getReturnObject().toString();
     }
+
+    @API(title = "下载导入模板", apiversion = R.ID2025071415152103.v1.class)
+    public String downloadExcel() throws YosException {
+        ExcelFactory excelFactory = new ExcelFactory("售后bom产品清单导入模板");
+
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+        CellStyle style = xssfFWorkbook.createCellStyle();
+
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        for (int i = 0; i <= 20; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        // 设置工作薄列宽
+        restcontroller.webmanage.sale.aftersalesbom.ExportExcel_pj.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle4 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createBodyCellStyle4(xssfFWorkbook);
+
+        String productcategories= content.getStringValue("productcategories");
+        if(StringUtils.isBlank(productcategories)){
+            return getErrReturnObject().setErrMsg("产品大类为空,无法下载导入模板").toString();
+        }
+        Rows rows = dbConnect.runSqlQuery("select t1.bomname,t2.bomname module,t3.bomname component,t4.bomname accessorie from plm_bom t1 left join plm_bom t2 on t1.plm_bomid=t2.parentid and t1.siteid=t2.siteid left join plm_bom t3 on t2.plm_bomid=t3.parentid and t2.siteid=t3.siteid left join plm_bom t4 on t3.plm_bomid=t4.parentid and t3.siteid=t4.siteid  where t1.bomname='"+productcategories+"' order by t2.bomname,t3.bomname,t4.bomname");
+        if(rows.isEmpty()){
+            return getErrReturnObject().setErrMsg("产品大类下不存在bom数据,无法下载导入模板").toString();
+        }
+        restcontroller.webmanage.sale.aftersalesbom.ExportExcel_pj.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook,rows);
+
+        Rows aa = uploadExcelToObs(excelFactory);
+        String url = "";
+        if (!aa.isEmpty()) {
+            url = aa.get(0).getString("url");
+        }
+        return getSucReturnObject().setData(url).toString();
+    }
+
+
+
+    @API(title = "售后bom配件导入", apiversion = R.ID2025071415153103.v1.class)
+    @CACHEING_CLEAN(apiClass = {aftersalesbom.class, aftersalesbom_items.class})
+    public String importItems() throws YosException {
+        Long sa_aftersalesbomid = content.getLong("sa_aftersalesbomid");
+        Rows aftersalesbom = dbConnect.runSqlQuery("select status,productcategories from sa_aftersalesbom where siteid='" + siteid + "' and sa_aftersalesbomid=" + sa_aftersalesbomid);
+        if (aftersalesbom.isEmpty()) {
+            return getErrReturnObject().setErrMsg("该售后bom不存在").toString();
+        }
+        if (!aftersalesbom.get(0).getString("status").equals("新建")) {
+            return getErrReturnObject().setErrMsg("非新建状态不能导入").toString();
+        }
+        Rows bomrows = dbConnect.runSqlQuery("select t1.bomname,t2.bomname module,t3.bomname component,t4.bomname accessorie from plm_bom t1 left join plm_bom t2 on t1.plm_bomid=t2.parentid and t1.siteid=t2.siteid left join plm_bom t3 on t2.plm_bomid=t3.parentid and t2.siteid=t3.siteid left join plm_bom t4 on t3.plm_bomid=t4.parentid and t3.siteid=t4.siteid  where t1.bomname='"+aftersalesbom.get(0).getString("productcategories")+"' order by t2.bomname,t3.bomname,t4.bomname");
+        ArrayList<String> sqlList = new ArrayList<>();
+        ExcelFactory e;
+        try {
+
+            // 华为云
+            e = getPostExcelFactory(content.getLong("attachmentid"));
+            // 本地
+            //e = getPostExcelFactory();
+
+            ArrayList<String> keys = new ArrayList<>();
+            keys.add("bomname");
+            keys.add("module");
+            keys.add("component");
+            keys.add("accessorie");
+            keys.add("itemno1");
+            keys.add("begindate1");
+            keys.add("enddate1");
+            keys.add("itemno2");
+            keys.add("begindate2");
+            keys.add("enddate2");
+            keys.add("itemno3");
+            keys.add("begindate3");
+            keys.add("enddate3");
+            keys.add("itemno4");
+            keys.add("begindate4");
+            keys.add("enddate4");
+            keys.add("itemno5");
+            keys.add("begindate5");
+            keys.add("enddate5");
+
+
+            Rows rows = e.getSheetRows(0, keys, 3);
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+
+            RowsMap itemRowsMap = dbConnect.runSqlQuery("select itemid,itemno,itemname from plm_item where siteid='" + siteid + "'").toRowsMap("itemno");
+            ArrayList<Long> itemidList = dbConnect.runSqlQuery("select itemid from sa_aftersalesbom_items t1 inner join sa_aftersalesbom t2 on t1.siteid=t2.siteid and t1.sa_aftersalesbomid=t2.sa_aftersalesbomid").toArrayList("itemid", new ArrayList<>());
+
+            for (Row row : rows) {
+                String msg="错误信息:";
+                for (int i = 1; i < 6; i++) {
+                    if(!StringUtils.isBlank(row.getString("itemno"+i))){
+                        if (!itemRowsMap.containsKey(row.getString("itemno"+i))) {
+                            msg = msg +row.getString("itemno"+i)+"商品不存在;";
+                        } else {
+                            row.put("itemid"+i, itemRowsMap.get(row.getString("itemno"+i)).get(0).getLong("itemid"));
+                            row.put("itemname"+i, itemRowsMap.get(row.getString("itemno"+i)).get(0).getString("itemname"));
+                        }
+                    }
+
+                }
+                if(msg.contains("商品不存在")){
+                    iserr=true;
+                    row.put("msg", msg);
+                    rowserr.add(row);
+                }else{
+                    rowssuc.add(row);
+                }
+
+            }
+            if (iserr) {
+                ExcelFactory excelFactory = new ExcelFactory("商品明细导入错误信息");
+                HashMap<String, String> map = new HashMap<String, String>();
+                map.put("bomname","bom名称");
+                map.put("module","层级");
+                map.put("component","层级");
+                map.put("accessorie","层级");
+                map.put("itemno1","物料号1");
+                map.put("begindate1","启用时间1");
+                map.put("enddate1","停用时间1");
+                map.put("itemno2","物料号2");
+                map.put("begindate2","启用时间2");
+                map.put("enddate2","停用时间2");
+                map.put("itemno3","物料号3");
+                map.put("begindate3","启用时间3");
+                map.put("enddate3","停用时间3");
+                map.put("itemno4","物料号4");
+                map.put("begindate4","启用时间4");
+                map.put("enddate4","停用时间4");
+                map.put("itemno5","物料号5");
+                map.put("begindate5","启用时间5");
+                map.put("enddate5","停用时间5");
+                map.put("msg", "错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("bomname");
+                colNameList.add("module");
+                colNameList.add("component");
+                colNameList.add("accessorie");
+                colNameList.add("itemno1");
+                colNameList.add("begindate1");
+                colNameList.add("enddate1");
+                colNameList.add("itemno2");
+                colNameList.add("begindate2");
+                colNameList.add("enddate2");
+                colNameList.add("itemno3");
+                colNameList.add("begindate3");
+                colNameList.add("enddate3");
+                colNameList.add("itemno4");
+                colNameList.add("begindate4");
+                colNameList.add("enddate4");
+                colNameList.add("itemno5");
+                colNameList.add("begindate5");
+                colNameList.add("enddate5");
+                colNameList.add("msg");
+                keytypemap.put("bomname",String.class);
+                keytypemap.put("module",String.class);
+                keytypemap.put("component",String.class);
+                keytypemap.put("accessorie",String.class);
+                keytypemap.put("itemno1",String.class);
+                keytypemap.put("begindate1",String.class);
+                keytypemap.put("enddate1",String.class);
+                keytypemap.put("itemno2",String.class);
+                keytypemap.put("begindate2",String.class);
+                keytypemap.put("enddate2",String.class);
+                keytypemap.put("itemno3",String.class);
+                keytypemap.put("begindate3",String.class);
+                keytypemap.put("enddate3",String.class);
+                keytypemap.put("itemno4",String.class);
+                keytypemap.put("begindate4",String.class);
+                keytypemap.put("enddate4",String.class);
+                keytypemap.put("itemno5",String.class);
+                keytypemap.put("begindate5",String.class);
+                keytypemap.put("enddate5",String.class);
+                keytypemap.put("msg",  String.class);
+                keytypemap.put("msg", String.class);
+                rowserr.setFieldList(colNameList);
+                rowserr.setFieldTypeMap(keytypemap);
+                addSheet(excelFactory, "Sheet1", rowserr, map);
+
+                Rows aa = uploadExcelToObs(excelFactory);
+                String url = "";
+                if (!aa.isEmpty()) {
+                    url = aa.get(0).getString("url");
+                }
+                return getSucReturnObject().setData(url).toString();
+            }
+
+            dbConnect.runSqlUpdate("delete from sa_aftersalesbom_pjs where sa_aftersalesbomid="+sa_aftersalesbomid);
+
+            if (!rowssuc.isEmpty()) {
+                for (Row row : rowssuc) {
+                    for (int i = 1; i < 6; i++) {
+                        if(row.containsKey("itemid"+i)){
+                            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_aftersalesbom_pjs");
+                            insertSQL.setUniqueid(createTableID("sa_aftersalesbom_pjs"));
+                            insertSQL.setSiteid(siteid);
+                            insertSQL.setValue("sa_aftersalesbomid", sa_aftersalesbomid);
+                            insertSQL.setValue("module", row.getString("module"));
+                            insertSQL.setValue("component", row.getString("component"));
+                            insertSQL.setValue("accessorie", row.getString("accessorie"));
+                            insertSQL.setValue("itemid", row.getString("itemid"+i));
+                            insertSQL.setValue("itemname", row.getString("itemname"+i));
+                            insertSQL.setValue("itemno", row.getString("itemno"+i));
+                            insertSQL.setValue("begindate", StringUtils.isBlank(row.getString("begindate"+i)) ?"null":row.getString("begindate"+i));
+                            insertSQL.setValue("enddate", StringUtils.isBlank(row.getString("enddate"+i)) ?"null":row.getString("enddate"+i));
+                            sqlList.add(insertSQL.getSQL());
+                        }
+
+                    }
+
+                }
+            }
+
+            if (!sqlList.isEmpty()) {
+                dbConnect.runSqlUpdate(sqlList);
+            }
+        } catch (Exception e1) {
+            e1.printStackTrace();
+            return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
+        }
+        return getSucReturnObject().toString();
+    }
+
+    public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows,
+                              HashMap<String, String> titlemap) {
+        ArrayList<String> keylist = datarows.getFieldList();
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
+        XSSFFont font = xssfFWorkbook.createFont();
+
+        font.setColor((short) 0xa);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        xssfCellStyle1.setFont(font);
+
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        for (int i = 0; i <= 3; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        restcontroller.webmanage.sale.aftersalesbom.ExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = restcontroller.webmanage.sale.aftersalesbom.ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        ExportExcel_pj.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, xssfFWorkbook);// 写入标题
+
+        for (int n = 0; n < datarows.size(); n++) {
+            Row row = datarows.get(n);
+            XSSFRow datarow = sheet.createRow(n + 3);
+            for (int i1 = 0; i1 < keylist.size(); i1++) {
+                Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
+                if (fieldclazztype == Integer.class) {
+                    datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)));
+                } else if (fieldclazztype == Long.class) {
+                    datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
+                } else if (fieldclazztype == Float.class) {
+                    datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
+                } else if (fieldclazztype == Double.class) {
+                    datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
+                } else {
+                    datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
+                }
+                if (i1 == 19) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
 }