Explorar el Código

bug修复及经销商电商任务导入功能

hxh hace 4 meses
padre
commit
bdd0c473b2

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

@@ -7012,6 +7012,14 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20251227165303 {
+        public static class v1 {
+        }
+    }
+    public static class ID20251227165403 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 420 - 0
src/custom/restcontroller/webmanage/sale/agentssales/ExportExcel.java

@@ -0,0 +1,420 @@
+package restcontroller.webmanage.sale.agentssales;
+
+
+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);
+        sheet.setColumnWidth((short) 3, (short) 5000);
+        sheet.setColumnWidth((short) 4, (short) 5000);
+        sheet.setColumnWidth((short) 5, (short) 5000);
+        sheet.setColumnWidth((short) 6, (short) 5000);
+        sheet.setColumnWidth((short) 7, (short) 5000);
+        sheet.setColumnWidth((short) 8, (short) 5000);
+        sheet.setColumnWidth((short) 9, (short) 5000);
+        sheet.setColumnWidth((short) 10, (short) 5000);
+        sheet.setColumnWidth((short) 11, (short) 5000);
+        sheet.setColumnWidth((short) 12, (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);
+        sheet.setColumnWidth((short) 4, (short) 5000);
+        sheet.setColumnWidth((short) 5, (short) 5000);
+        sheet.setColumnWidth((short) 6, (short) 5000);
+        sheet.setColumnWidth((short) 7, (short) 5000);
+        sheet.setColumnWidth((short) 8, (short) 5000);
+        sheet.setColumnWidth((short) 9, (short) 5000);
+        sheet.setColumnWidth((short) 10, (short) 5000);
+        sheet.setColumnWidth((short) 11, (short) 5000);
+        sheet.setColumnWidth((short) 12, (short) 5000);
+        sheet.setColumnWidth((short) 13, (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.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        cellStyle2.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+        cellStyle3.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle4.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 14));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("经销商电商任务导入");
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 14));
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        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("1月");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("2月");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("3月");
+
+        cell = row.createCell(6);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("4月");
+
+        cell = row.createCell(7);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("5月");
+
+        cell = row.createCell(8);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("6月");
+
+        cell = row.createCell(9);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("7月");
+
+        cell = row.createCell(10);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("8月");
+
+        cell = row.createCell(11);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("9月");
+
+        cell = row.createCell(12);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("10月");
+
+        cell = row.createCell(13);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("11月");
+
+        cell = row.createCell(14);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("12月");
+
+
+
+        /*第四行塞值*/
+        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("2026");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(6);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(7);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(8);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(9);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(10);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(11);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(12);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(13);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+        cell = row.createCell(14);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("0");
+
+    }
+
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFWorkbook workbook) {
+
+        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, 15));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("经销商电商任务导入");
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 15));
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        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("1月");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("2月");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("3月");
+
+        cell = row.createCell(6);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("4月");
+
+        cell = row.createCell(7);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("5月");
+
+        cell = row.createCell(8);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("6月");
+
+        cell = row.createCell(9);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("7月");
+
+        cell = row.createCell(10);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("8月");
+
+        cell = row.createCell(11);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("9月");
+
+        cell = row.createCell(12);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("10月");
+
+        cell = row.createCell(13);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("11月");
+
+        cell = row.createCell(14);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("12月");
+
+        cell = row.createCell(15);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("错误信息");
+
+    }
+}

+ 373 - 2
src/custom/restcontroller/webmanage/sale/agentssales/agentssales.java

@@ -10,11 +10,20 @@ 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.stockbill.ExportExcelSpecial;
+import restcontroller.webmanage.sale.stockbill.stockbill;
+import restcontroller.webmanage.sale.stockbill.stockbillitems;
+import restcontroller.webmanage.sale.stockbill.stockbillitemssku;
 
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 
 @API(title = "电商销售额表")
 public class agentssales  extends Controller {
@@ -68,7 +77,7 @@ public class agentssales  extends Controller {
             insertSQL.setValue("m12", m12);
             sqlList.add(insertSQL.getSQL());
             sqlList.add(
-                    DataContrlLog.createLog(this, "sa_agents_sales", sa_agents_salesid, "新增", "电商销售额信息新增成功").getSQL());
+                    DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "新增", "电商销售额信息新增成功").getSQL());
         } else {
             Rows rows = dbConnect.runSqlQuery(
                     "SELECT 1 from sa_agents_sales WHERE sa_agents_salesid = "
@@ -93,7 +102,7 @@ public class agentssales  extends Controller {
                 updateSQL.setValue("m11", m11);
                 updateSQL.setValue("m12", m12);
                 sqlList.add(updateSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sa_agents_sales", sa_agents_salesid, "更新", "电商销售额信息更新成功")
+                sqlList.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "更新", "电商销售额信息更新成功")
                         .getSQL());
 
             } else {
@@ -154,5 +163,367 @@ public class agentssales  extends Controller {
 
     }
 
+    /**
+     * 下载经销商电商任务导入模板
+     *
+     * @return
+     */
+    @API(title = "下载经销商电商任务导入模板", apiversion = R.ID20251227165303.v1.class)
+    public String downloadAgentsSalesExcel() throws YosException {
+        ExcelFactory excelFactory = new ExcelFactory("ImportTemplateForAgentsSales");
+
+        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 <= 16; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        ExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle4 = ExportExcel.createBodyCellStyle4(xssfFWorkbook);
+        ExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
+                xssfFWorkbook);// 写入标题
+
+        Rows aa = saveToExcelAttachment(excelFactory);
+        String url = "";
+        if (!aa.isEmpty()) {
+            url = aa.get(0).getString("url");
+        }
+        return getSucReturnObject().setData(url).toString();
+
+    }
+
+    @API(title = "导入经销商电商任务", apiversion = R.ID20251227165403.v1.class)
+    @CACHEING_CLEAN(apiClass = {agentssales.class })
+    public String uploadstockbillByExcel() throws YosException {
+        ArrayList<String> sqlList = new ArrayList<>();
+        ExcelFactory e;
+        try {
+
+            if (content.getLongValue("attachmentid") > 0) {
+                e = getExcelAttachment(content.getLongValue("attachmentid"));
+                // 本地
+                //e = getPostExcelFactory();
+            } else {
+                e = getPostExcel();
+                // 本地
+                //e = getPostExcelFactory();
+            }
+
+            ArrayList<String> keys = new ArrayList<>();
+            keys.add("agentnum");
+            keys.add("abbreviation");
+            keys.add("year");
+            keys.add("month1");
+            keys.add("month2");
+            keys.add("month3");
+            keys.add("month4");
+            keys.add("month5");
+            keys.add("month6");
+            keys.add("month7");
+            keys.add("month8");
+            keys.add("month9");
+            keys.add("month10");
+            keys.add("month11");
+            keys.add("month12");
+
+            Rows rows = e.getSheetRows(0, keys, 3);
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+
+            QuerySQL agentquerySQL = SQLFactory.createQuerySQL(this, "sa_agents", "sa_agentsid","agentnum", "sys_enterpriseid");
+            agentquerySQL.setTableAlias("t1");
+            agentquerySQL.setSiteid(siteid);
+            agentquerySQL.setWhere("t1.agentnum", rows.toArrayList("agentnum"));
+            Rows agentsRows = agentquerySQL.query();
+            RowsMap agentsRowsMap = agentsRows.toRowsMap("agentnum");
+
+
+            for (Row row : rows) {
+                iserr = false;
+                if (StringUtils.isBlank(row.getString("year"))
+                        || StringUtils.isBlank(row.getString("agentnum"))) {
+                    iserr = true;
+                    row.put("msg", "错误信息:经销商编码/年份不能为空");
+                    rowserr.add(row);
+                    continue;
+                }
+                if (!agentsRowsMap.containsKey(row.getString("agentnum"))) {
+                    iserr = true;
+                    row.put("msg", "错误信息:经销商编号不存在");
+                    rowserr.add(row);
+                    continue;
+                }
+                for (int i=1;i<=12;i++){
+                    if (!StringUtils.isBlank(row.getString("month"+i))){
+                        if (!isNumeric(row.getString("month"+i))) {
+                            iserr = true;
+                            row.put("msg", i+"月份不为数字格式,请检查");
+                            rowserr.add(row);
+                            break;
+                        }
+                    }
+                }
+                if(!iserr){
+                    row.put("sa_agentsid",agentsRowsMap.get(row.getString("agentnum")).get(0).getLong("sa_agentsid"));
+                    rowssuc.add(row);
+                }
+
+            }
+
+            Rows agentsSalesRows = dbConnect.runSqlQuery("select * from sa_agents_sales where siteid='"+siteid+"'");
+            RowsMap agentsSalesRowsMap = agentsSalesRows.toRowsMap("sa_agentsid");
+            if (!rowssuc.isEmpty()) {
+                boolean isInsert =true;
+                long sa_agents_salesid=0;
+                for (Row row : rowssuc) {
+                    if(agentsSalesRowsMap.containsKey(row.getString("sa_agentsid"))){
+                        if(agentsSalesRowsMap.get(row.getString("sa_agentsid")).toRowsMap("year").containsKey(row.getString("year"))){
+                            isInsert=false;
+                            sa_agents_salesid=agentsSalesRowsMap.get(row.getString("sa_agentsid")).toRowsMap("year").get(row.getString("year")).get(0).getLong("sa_agents_salesid");
+                        }else{
+                            isInsert=true;
+                        }
+                    }else{
+                        isInsert=true;
+                    }
+
+                    if(isInsert){
+                        sa_agents_salesid = createTableID("sa_agents_sales");
+                        InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_agents_sales");
+                        insertSQL.setUniqueid(sa_agents_salesid);
+                        insertSQL.setSiteid(siteid);
+                        insertSQL.setValue("sa_agentsid", row.getLong("sa_agentsid"));
+                        insertSQL.setValue("type", "电商款");
+                        insertSQL.setValue("year",row.getLong("year"));
+                        insertSQL.setValue("m1", StringUtils.isBlank(row.getString("month1"))?0:row.getString("month1"));
+                        insertSQL.setValue("m2", StringUtils.isBlank(row.getString("month2"))?0:row.getString("month2"));
+                        insertSQL.setValue("m3", StringUtils.isBlank(row.getString("month3"))?0:row.getString("month3"));
+                        insertSQL.setValue("m4", StringUtils.isBlank(row.getString("month4"))?0:row.getString("month4"));
+                        insertSQL.setValue("m5", StringUtils.isBlank(row.getString("month5"))?0:row.getString("month5"));
+                        insertSQL.setValue("m6", StringUtils.isBlank(row.getString("month6"))?0:row.getString("month6"));
+                        insertSQL.setValue("m7", StringUtils.isBlank(row.getString("month7"))?0:row.getString("month7"));
+                        insertSQL.setValue("m8", StringUtils.isBlank(row.getString("month8"))?0:row.getString("month8"));
+                        insertSQL.setValue("m9", StringUtils.isBlank(row.getString("month9"))?0:row.getString("month9"));
+                        insertSQL.setValue("m10", StringUtils.isBlank(row.getString("month10"))?0:row.getString("month10"));
+                        insertSQL.setValue("m11", StringUtils.isBlank(row.getString("month11"))?0:row.getString("month11"));
+                        insertSQL.setValue("m12", StringUtils.isBlank(row.getString("month12"))?0:row.getString("month12"));
+                        sqlList.add(insertSQL.getSQL());
+                        sqlList.add(
+                                DataContrlLog.createLog(this, "sa_agentss", row.getLong("sa_agentsid"), "新增", "电商销售额信息新增成功").getSQL());
+                    }else{
+                        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_agents_sales");
+                        updateSQL.setUniqueid(sa_agents_salesid);
+                        updateSQL.setSiteid(siteid);
+                        updateSQL.setValue("sa_agentsid", row.getLong("sa_agentsid"));
+                        updateSQL.setValue("type", "电商款");
+                        updateSQL.setValue("year",row.getLong("year"));
+                        if(StringUtils.isNotBlank(row.getString("month1"))){
+                            if(row.getDouble("month1")!=0){
+                                updateSQL.setValue("m1", row.getString("month1"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month2"))){
+                            if(row.getDouble("month2")!=0){
+                                updateSQL.setValue("m2", row.getString("month2"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month3"))){
+                            if(row.getDouble("month3")!=0){
+                                updateSQL.setValue("m3", row.getString("month3"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month4"))){
+                            if(row.getDouble("month4")!=0){
+                                updateSQL.setValue("m4", row.getString("month4"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month5"))){
+                            if(row.getDouble("month5")!=0){
+                                updateSQL.setValue("m5", row.getString("month5"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month6"))){
+                            if(row.getDouble("month6")!=0){
+                                updateSQL.setValue("m6", row.getString("month6"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month7"))){
+                            if(row.getDouble("month7")!=0){
+                                updateSQL.setValue("m7", row.getString("month7"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month8"))){
+                            if(row.getDouble("month8")!=0){
+                                updateSQL.setValue("m8", row.getString("month8"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month9"))){
+                            if(row.getDouble("month9")!=0){
+                                updateSQL.setValue("m9", row.getString("month9"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month10"))){
+                            if(row.getDouble("month10")!=0){
+                                updateSQL.setValue("m10", row.getString("month10"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month11"))){
+                            if(row.getDouble("month11")!=0){
+                                updateSQL.setValue("m11", row.getString("month11"));
+                            }
+                        }
+                        if(StringUtils.isNotBlank(row.getString("month12"))){
+                            if(row.getDouble("month12")!=0){
+                                updateSQL.setValue("m12", row.getString("month12"));
+                            }
+                        }
+                        sqlList.add(updateSQL.getSQL());
+                        sqlList.add(DataContrlLog.createLog(this, "sa_agents", row.getLong("sa_agentsid"), "更新", "电商销售额信息更新成功")
+                                .getSQL());
+                    }
+                }
+            }
+            if (!sqlList.isEmpty()) {
+                dbConnect.runSqlUpdate(sqlList);
+            }
+            if (rowserr.size()>0) {
+                ExcelFactory excelFactory = new ExcelFactory("经销商电商任务导入错误信息");
+                HashMap<String, String> map = new HashMap<String, String>();
+                map.put("agentnum","经销商编号");
+                map.put("abbreviation","经销商简称");
+                map.put("year","年份");
+                map.put("month1","1月");
+                map.put("month2","2月");
+                map.put("month3","3月");
+                map.put("month4","4月");
+                map.put("month5","5月");
+                map.put("month6","6月");
+                map.put("month7","7月");
+                map.put("month8","8月");
+                map.put("month9","9月");
+                map.put("month10","10月");
+                map.put("month11","11月");
+                map.put("month12","12月");
+                map.put("msg", "错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("agentnum");
+                colNameList.add("abbreviation");
+                colNameList.add("year");
+                colNameList.add("month1");
+                colNameList.add("month2");
+                colNameList.add("month3");
+                colNameList.add("month4");
+                colNameList.add("month5");
+                colNameList.add("month6");
+                colNameList.add("month7");
+                colNameList.add("month8");
+                colNameList.add("month9");
+                colNameList.add("month10");
+                colNameList.add("month11");
+                colNameList.add("month12");
+                colNameList.add("msg");
+
+                keytypemap.put("agentnum", String.class);
+                keytypemap.put("abbreviation", String.class);
+                keytypemap.put("year", String.class);
+                keytypemap.put("month1", String.class);
+                keytypemap.put("month2", String.class);
+                keytypemap.put("month3", String.class);
+                keytypemap.put("month4", String.class);
+                keytypemap.put("month5", String.class);
+                keytypemap.put("month6", String.class);
+                keytypemap.put("month7", String.class);
+                keytypemap.put("month8", String.class);
+                keytypemap.put("month9", String.class);
+                keytypemap.put("month10", String.class);
+                keytypemap.put("month11", String.class);
+                keytypemap.put("month12", String.class);
+                keytypemap.put("msg", String.class);
+                rowserr.setFieldList(colNameList);
+                rowserr.setFieldTypeMap(keytypemap);
+                addSheet(excelFactory, "Sheet1", rowserr, map);
+
+                Rows aa = saveToExcelAttachment(excelFactory);
+                String url = "";
+                if (!aa.isEmpty()) {
+                    url = aa.get(0).getString("url");
+                }
+                return getSucReturnObject().setData(url).toString();
+            }
+        } 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 <= 15; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        ExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = 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 == 15) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
+
+    public static boolean isNumeric(String strNum) {
+        if (strNum == null) {
+            return false;
+        }
+        return strNum.matches("-?\\d+(\\.\\d+)?");
+    }
 
 }

+ 3 - 0
src/custom/restcontroller/webmanage/sale/sendrepair/sendrepair.java

@@ -649,6 +649,8 @@ public class sendrepair extends Controller {
                     cashbillEntity.setType("维修费");
                     JSONObject cashbillPay = Accountbalance.createCashbillPay(this, row.getLong("sys_enterpriseid"), sa_accountclassid, cashbillEntity, true);
                     sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
+                    sqlList.add("update sa_sendrepair_detail set practicalamount=ifnull(practicalamount,0)+"+totalamount+" where sa_sendrepairid="+sa_sendrepairid);
+
                 } else {
                     CashbillEntity cashbillEntity = new CashbillEntity();
                     cashbillEntity.setAmount(totalamount.negate());
@@ -660,6 +662,7 @@ public class sendrepair extends Controller {
                     cashbillEntity.setType("维修费");
                     JSONObject cashbillPay = Accountbalance.createCashbillPay(this, row.getLong("sys_enterpriseid"), sa_accountclassid, cashbillEntity, true);
                     sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
+                    sqlList.add("update sa_sendrepair_detail set practicalamount=ifnull(practicalamount,0)-"+totalamount+" where sa_sendrepairid="+sa_sendrepairid);
                 }
             }
         }