郭齐峰 il y a 3 ans
Parent
commit
ca89308239

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

@@ -4721,6 +4721,16 @@ public class R {
         }
     }
 
+    public static class ID20230510153404 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230510153504 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 342 - 0
src/custom/restcontroller/webmanage/sale/promotion/ExportExcel.java

@@ -0,0 +1,342 @@
+package restcontroller.webmanage.sale.promotion;
+
+
+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 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 createTitleCellStyle2(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.LEFT); // 居左
+        return cellStyle;
+    }
+
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    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;
+    }
+
+    /**
+     * 设置正文单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createBodyCellStyle(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.LEFT); // 居左
+        return cellStyle;
+    }
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(导入模板)
+     **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5500);
+        sheet.setColumnWidth((short) 1, (short) 5500);
+        sheet.setColumnWidth((short) 2, (short) 5500);
+        sheet.setColumnWidth((short) 3, (short) 5500);
+        sheet.setColumnWidth((short) 4, (short) 5500);
+        sheet.setColumnWidth((short) 5, (short) 5500);
+        sheet.setColumnWidth((short) 6, (short) 5500);
+        sheet.setColumnWidth((short) 7, (short) 5500);
+        sheet.setColumnWidth((short) 8, (short) 5500);
+    }
+
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(返回错误Excel的样式)
+     **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5500);
+        sheet.setColumnWidth((short) 1, (short) 5500);
+        sheet.setColumnWidth((short) 2, (short) 5500);
+        sheet.setColumnWidth((short) 3, (short) 5500);
+        sheet.setColumnWidth((short) 4, (short) 5500);
+        sheet.setColumnWidth((short) 5, (short) 5500);
+        sheet.setColumnWidth((short) 6, (short) 5500);
+        sheet.setColumnWidth((short) 7, (short) 5500);
+        sheet.setColumnWidth((short) 8, (short) 5500);
+        sheet.setColumnWidth((short) 9, (short) 5500);
+    }
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFCellStyle cellStyle4, 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);
+
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("促销商品导入");
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));
+        /*第二行塞值*/
+        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(cellStyle2);
+        cell.setCellValue("产品编码(必填)");
+
+        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("限购数");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格一活动价");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格二活动价");
+
+        cell = row.createCell(6);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格三活动价");
+
+        cell = row.createCell(7);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格四活动价");
+
+        cell = row.createCell(8);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格五活动价");
+
+
+
+        /*第四行塞值*/
+        row = sheet.createRow(3);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("12345");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(6);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(7);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+        cell = row.createCell(8);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("0");
+
+    }
+
+
+    /**
+     * 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, 9));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("促销商品导入");
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));
+        /*第二行塞值*/
+        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(cellStyle2);
+        cell.setCellValue("产品编码(必填)");
+
+        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("限购数");
+
+        cell = row.createCell(4);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格一活动价");
+
+        cell = row.createCell(5);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格二活动价");
+
+        cell = row.createCell(6);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格三活动价");
+
+        cell = row.createCell(7);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格四活动价");
+
+        cell = row.createCell(8);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("价格五活动价");
+
+        cell = row.createCell(9);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("错误信息");
+
+    }
+}

+ 23 - 21
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案参与授权范围查询.sql

@@ -1,21 +1,23 @@
-SELECT
-    t1.sa_promotion_authid,
-	t1.sa_promotionid,
-	t1.sys_enterpriseid,
-	t1.islimit,
-	t1.limitamount,
-	t1.limitgroupqty,
-	t1.limitordercount,
-	t1.saledamount,
-	t1.saledordercount,
-	t1.saledgroupqty,
-	t1.createby,
-	t1.createdate,
-	t2.enterprisename,
-	t2.abbreviation,
-	t2.phonenumber 
-FROM
-	sa_promotion_auth t1
-	LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid 
-	AND t1.siteid = t2.siteid
-	where t1.siteid=$siteid$ and t1.sa_promotionid=$sa_promotionid$ and $where$
+SELECT t1.sa_promotion_authid,
+       t1.sa_promotionid,
+       t1.sys_enterpriseid,
+       t1.islimit,
+       t1.limitamount,
+       t1.limitgroupqty,
+       t1.limitordercount,
+       t1.saledamount,
+       t1.saledordercount,
+       t1.saledgroupqty,
+       t1.createby,
+       t1.createdate,
+       t2.enterprisename,
+       t2.abbreviation,
+       t2.phonenumber,
+       t3.agentnum
+FROM sa_promotion_auth t1
+         LEFT JOIN sys_enterprise t2 ON t1.sys_enterpriseid = t2.sys_enterpriseid
+         left join sa_agents t3 on t1.siteid = t3.siteid and t1.sys_enterpriseid = t3.sys_enterpriseid
+    AND t1.siteid = t2.siteid
+where t1.siteid = $siteid$
+  and t1.sa_promotionid = $sa_promotionid$
+  and $where$

+ 37 - 21
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案商品查询.sql

@@ -1,21 +1,37 @@
-SELECT
-    t1.sa_promotion_itemsid,
-	t1.sa_promotionid,
-	t1.sa_promotion_itemgroupid,
-	t1.groupqty,
-	t1.orderaddqty,
-	t1.orderminqty,
-	t1.saledqty,
-	t1.islimit,
-	t1.isonsale,
-	t1.itemid,
-	t2.itemno,
-	t2.itemname,
-	t2.spec,
-	t2.model,
-	t3.unitname
-FROM
-	sa_promotion_items t1
-	left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid
-	left join plm_unit t3 on t2.unitid=t3.unitid and t2.siteid=t3.siteid
-	where t1.siteid=$siteid$ and t1.sa_promotionid=$sa_promotionid$  and t1.sa_promotion_itemgroupid = $sa_promotion_itemgroupid$ and $where$
+SELECT t1.sa_promotion_itemsid,
+       t1.sa_promotionid,
+       t1.sa_promotion_itemgroupid,
+       t1.groupqty,
+       t1.orderaddqty,
+       t1.orderminqty,
+       t1.saledqty,
+       t1.islimit,
+       t1.isonsale,
+       t1.itemid,
+       t2.itemno,
+       t2.itemname,
+       t2.spec,
+       t2.model,
+       t3.unitname,
+       ifnull(t4.price, 0) price1,
+       ifnull(t4.sa_promotion_itempriceid, 0) sa_promotion_itempriceid1,
+       ifnull(t5.price, 0) price2,
+       ifnull(t5.sa_promotion_itempriceid, 0) sa_promotion_itempriceid2,
+       ifnull(t6.price, 0) price3,
+       ifnull(t6.sa_promotion_itempriceid, 0) sa_promotion_itempriceid3,
+       ifnull(t7.price, 0) price4,
+       ifnull(t7.sa_promotion_itempriceid, 0) sa_promotion_itempriceid4,
+       ifnull(t8.price, 0) price5,
+       ifnull(t8.sa_promotion_itempriceid, 0) sa_promotion_itempriceid5
+FROM sa_promotion_items t1
+         left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
+         left join plm_unit t3 on t2.unitid = t3.unitid and t2.siteid = t3.siteid
+         left join sa_promotion_itemprice t4 on t1.itemid = t4.itemid and t1.siteid = t4.siteid and t4.pricegrade = 1
+         left join sa_promotion_itemprice t5 on t1.itemid = t5.itemid and t1.siteid = t5.siteid and t5.pricegrade = 2
+         left join sa_promotion_itemprice t6 on t1.itemid = t6.itemid and t1.siteid = t6.siteid and t6.pricegrade = 3
+         left join sa_promotion_itemprice t7 on t1.itemid = t7.itemid and t1.siteid = t7.siteid and t7.pricegrade = 4
+         left join sa_promotion_itemprice t8 on t1.itemid = t8.itemid and t1.siteid = t8.siteid and t8.pricegrade = 5
+where t1.siteid = $siteid$
+  and t1.sa_promotionid = $sa_promotionid$
+  and t1.sa_promotion_itemgroupid = $sa_promotion_itemgroupid$
+  and $where$

+ 17 - 0
src/custom/restcontroller/webmanage/sale/promotion/SQL/商品等级价格查询.sql

@@ -0,0 +1,17 @@
+select t1.itemid,
+       t1.itemno,
+       t1.orderminqty,
+       t1.orderaddqty,
+       ifnull(t2.price, 0) price1,
+       ifnull(t3.price, 0) price2,
+       ifnull(t4.price, 0) price3,
+       ifnull(t5.price, 0) price4,
+       ifnull(t6.price, 0) price5
+from plm_item t1
+         left join sa_itemprice t2 on t1.siteid = t2.siteid and t1.itemid = t2.itemid and t2.pricegrade = 1
+         left join sa_itemprice t3 on t1.siteid = t3.siteid and t1.itemid = t3.itemid and t3.pricegrade = 2
+         left join sa_itemprice t4 on t1.siteid = t4.siteid and t1.itemid = t4.itemid and t4.pricegrade = 3
+         left join sa_itemprice t5 on t1.siteid = t5.siteid and t1.itemid = t5.itemid and t5.pricegrade = 4
+         left join sa_itemprice t6 on t1.siteid = t6.siteid and t1.itemid = t6.itemid and t6.pricegrade = 5
+where t1.siteid = $siteid$
+  and t1.itemno in $itemno$

+ 10 - 5
src/custom/restcontroller/webmanage/sale/promotion/promotion.java

@@ -58,12 +58,14 @@ public class promotion extends Controller {
             sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "新增", "促销方案新增成功").getSQL());
         } else {
             Rows rows = dbConnect
-                    .runSqlQuery("SELECT status from sa_promotion WHERE sa_promotionid = " + sa_promotionid);
+                    .runSqlQuery("SELECT status,authmethod from sa_promotion WHERE sa_promotionid = " + sa_promotionid);
             if (rows.isNotEmpty()) {
                 if (rows.get(0).getString("status").equals("新建")) {
                     sqlFactory = new SQLFactory(this, "促销方案更新");
-                    sqlList.add(
-                            DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "更新", "促销方案更新成功").getSQL());
+                    sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "更新", "促销方案更新成功").getSQL());
+                    if (rows.get(0).getLong("authmethod") != authmethod) {
+                        sqlList.add("delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
+                    }
                 } else {
                     return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
                 }
@@ -344,11 +346,14 @@ public class promotion extends Controller {
         if (!rows.get(0).getString("status").equals("新建")) {
             return getErrReturnObject().setErrMsg("非新建状态不能修改授权方式").toString();
         }
+        ArrayList<String> sqlList = new ArrayList<>();
+        sqlList.add("delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
         if (rows.get(0).getLong("authmethod") == 0) {
-            dbConnect.runSqlUpdate("update sa_promotion set authmethod=1 where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
+            sqlList.add("update sa_promotion set authmethod=1 where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
         } else {
-            dbConnect.runSqlUpdate("update sa_promotion set authmethod=0 where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
+            sqlList.add("update sa_promotion set authmethod=0 where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
         }
+        dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
     }
 }

+ 4 - 3
src/custom/restcontroller/webmanage/sale/promotion/promotionAuth.java

@@ -113,9 +113,10 @@ public class promotionAuth extends Controller {
             JSONObject whereObject = content.getJSONObject("where");
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
                 where.append(" and(");
-                where.append("t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("t2.enterprisename like '%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.phonenumber like '%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t3.agentnum like '%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.abbreviation like '%").append(whereObject.getString("condition")).append("%' ");
                 where.append(")");
             }
         }

+ 101 - 92
src/custom/restcontroller/webmanage/sale/promotion/promotionItemPrice.java

@@ -17,97 +17,106 @@ import common.data.RowsMap;
 import common.data.SQLFactory;
 import restcontroller.R;
 
-public class promotionItemPrice  extends Controller{
-
-	public promotionItemPrice(JSONObject content) throws YosException {
-		super(content);
-		// TODO Auto-generated constructor stub
-	}
-	
-	@API(title = "促销方案商品价格更新", apiversion = R.ID20230102163003.v1.class)
-	@CACHEING_CLEAN(apiversions = { R.ID20230102163103.v1.class })
-	public String modify_promotionItemPrice() throws YosException {
-		Long sa_promotionid = content.getLong("sa_promotionid");
-		Long sa_promotion_itempriceid = content.getLong("sa_promotion_itempriceid");
-		BigDecimal price=content.getBigDecimal("price");
-		ArrayList<String> sqlList = new ArrayList<>();
-		Rows rowscount = dbConnect
-				.runSqlQuery("select status,sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid);
-
-		Rows itempricerows = dbConnect
-				.runSqlQuery(" select pricegrade,price,itemid from sa_itemprice where siteid='" + siteid + "'");
-		RowsMap itempricerowsMap = itempricerows.toRowsMap("itemid");
-		if (!rowscount.isEmpty()) {
-			if (!rowscount.get(0).getString("status").equals("新建")) {
-				return getErrReturnObject().setErrMsg("非新建状态的促销方案无法新增修改").toString();
-			}
-		}
-
-			if (sa_promotion_itempriceid > 0 && dbConnect
-					.runSqlQuery("select sa_promotion_itempriceid,sa_promotion_itemsid from sa_promotion_itemprice where sa_promotion_itempriceid="
-							+sa_promotion_itempriceid)
-				.isNotEmpty()) {
-			SQLFactory saleFactory = new SQLFactory(this, "促销方案商品价格更新");
-			saleFactory.addParameter("sa_promotion_itempriceid", sa_promotion_itempriceid);
-			saleFactory.addParameter("price", price);
-			// saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
-			saleFactory.addParameter("siteid", siteid);
-			sqlList.add(saleFactory.getSQL());
-			content.put("sa_promotion_itemsid", dbConnect
-					.runSqlQuery("select sa_promotion_itempriceid,sa_promotion_itemsid from sa_promotion_itemprice where sa_promotion_itempriceid="
-							+sa_promotion_itempriceid).get(0).getLong("sa_promotion_itemsid"));
-		}
-		dbConnect.runSqlUpdate(sqlList);
-		
-		return queryPromotionItemPriceList();
-	}
-	
-	@API(title = "促销方案商品价格列表", apiversion = R.ID20230102163103.v1.class)
-	@CACHEING
-	public String queryPromotionItemPriceList() throws YosException {
-		/*
-		 * 过滤条件设置
-		 */
-		StringBuffer where = new StringBuffer(" 1=1 ");
-		if (content.containsKey("where")) {
-			JSONObject whereObject = content.getJSONObject("where");
-			if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-				where.append(" and(");
-				where.append("t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
-				where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
-				where.append("or t2.model like'%").append(whereObject.getString("condition")).append("%' ");
-				where.append(")");
-			}
-		}
-		Long sa_promotionid = content.getLong("sa_promotionid");
-		Long sa_promotion_itemsid = content.getLong("sa_promotion_itemsid");
-		SQLFactory sqlFactory = new SQLFactory(this, "促销方案商品价格查询", pageSize, pageNumber, pageSorting);
-		sqlFactory.addParameter_SQL("where", where);
-		sqlFactory.addParameter("sa_promotionid", sa_promotionid);
-		sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsid);
-		sqlFactory.addParameter("siteid", siteid);
-		Rows rows = dbConnect.runSqlQuery(sqlFactory);
-
-		return getSucReturnObject().setData(rows).toString();
-	}
-	
-	@API(title = "快速折扣设置", apiversion = R.ID20230102163203.v1.class)
-	@CACHEING_CLEAN(apiversions = { R.ID20230102163103.v1.class })
-	public String updatePromotionItemsPrice() throws YosException {
-		
-		Long sa_promotionid = content.getLong("sa_promotionid");
-		BigDecimal discountrate = content.getBigDecimal("discountrate");
-		Rows rowscount = dbConnect
-				.runSqlQuery("select status,sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid);
-		if (!rowscount.isEmpty()) {
-			if (!rowscount.get(0).getString("status").equals("新建")) {
-				return getErrReturnObject().setErrMsg("非新建状态的促销方案无法进行快速折扣设置").toString();
-			}
-		}
-		dbConnect.runSqlUpdate("update sa_promotion_itemprice set price=price*"+discountrate+" where sa_promotionid="+sa_promotionid);
-		return getSucReturnObject().toString();
-		
-		
-	}
+public class promotionItemPrice extends Controller {
+
+    public promotionItemPrice(JSONObject content) throws YosException {
+        super(content);
+        // TODO Auto-generated constructor stub
+    }
+
+    @API(title = "促销方案商品价格更新", apiversion = R.ID20230102163003.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20230102163103.v1.class})
+    public String modify_promotionItemPrice() throws YosException {
+        Long sa_promotionid = content.getLong("sa_promotionid");
+        Long sa_promotion_itempriceid = content.getLong("sa_promotion_itempriceid");
+        BigDecimal price = content.getBigDecimal("price");
+        ArrayList<String> sqlList = new ArrayList<>();
+        Rows rowscount = dbConnect
+                .runSqlQuery("select status,sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid);
+
+        Rows itempricerows = dbConnect
+                .runSqlQuery(" select pricegrade,price,itemid from sa_itemprice where siteid='" + siteid + "'");
+        RowsMap itempricerowsMap = itempricerows.toRowsMap("itemid");
+        if (!rowscount.isEmpty()) {
+            if (!rowscount.get(0).getString("status").equals("新建")) {
+                return getErrReturnObject().setErrMsg("非新建状态的促销方案无法新增修改").toString();
+            }
+        }
+
+        if (sa_promotion_itempriceid > 0 && dbConnect
+                .runSqlQuery("select sa_promotion_itempriceid,sa_promotion_itemsid from sa_promotion_itemprice where sa_promotion_itempriceid="
+                        + sa_promotion_itempriceid)
+                .isNotEmpty()) {
+            SQLFactory saleFactory = new SQLFactory(this, "促销方案商品价格更新");
+            saleFactory.addParameter("sa_promotion_itempriceid", sa_promotion_itempriceid);
+            saleFactory.addParameter("price", price);
+            // saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
+            saleFactory.addParameter("siteid", siteid);
+            sqlList.add(saleFactory.getSQL());
+            content.put("sa_promotion_itemsid", dbConnect
+                    .runSqlQuery("select sa_promotion_itempriceid,sa_promotion_itemsid from sa_promotion_itemprice where sa_promotion_itempriceid="
+                            + sa_promotion_itempriceid).get(0).getLong("sa_promotion_itemsid"));
+        }
+        dbConnect.runSqlUpdate(sqlList);
+
+        return queryPromotionItemPriceList();
+    }
+
+    @API(title = "促销方案商品价格列表", apiversion = R.ID20230102163103.v1.class)
+    @CACHEING
+    public String queryPromotionItemPriceList() throws YosException {
+        /*
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.model like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        Long sa_promotionid = content.getLong("sa_promotionid");
+        Long sa_promotion_itemsid = content.getLong("sa_promotion_itemsid");
+        SQLFactory sqlFactory = new SQLFactory(this, "促销方案商品价格查询", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("sa_promotionid", sa_promotionid);
+        sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsid);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "快速折扣设置", apiversion = R.ID20230102163203.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20230102163103.v1.class})
+    public String updatePromotionItemsPrice() throws YosException {
+
+        Long sa_promotionid = content.getLong("sa_promotionid");
+        JSONArray itmeids = content.getJSONArray("itmeids");
+        BigDecimal discountrate = content.getBigDecimal("discountrate");
+        Rows rowscount = dbConnect
+                .runSqlQuery("select status,sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid);
+        if (!rowscount.isEmpty()) {
+            if (!rowscount.get(0).getString("status").equals("新建")) {
+                return getErrReturnObject().setErrMsg("非新建状态的促销方案无法进行快速折扣设置").toString();
+            }
+        }
+        String sql = "update sa_promotion_itemprice set price=price*" + discountrate + " where sa_promotionid=" + sa_promotionid;
+        if (itmeids.isEmpty()) {
+            dbConnect.runSqlUpdate(sql);
+        }else {
+            sql=sql+" and itemid in "+itmeids;
+            sql = sql.replace("[","(").replace("]",")");
+            dbConnect.runSqlUpdate(sql);
+        }
+
+        return getSucReturnObject().toString();
+
+
+    }
 
 }

+ 297 - 24
src/custom/restcontroller/webmanage/sale/promotion/promotionItems.java

@@ -2,6 +2,7 @@ package restcontroller.webmanage.sale.promotion;
 
 import beans.brand.Brand;
 import beans.data.BatchDeleteErr;
+import beans.datacontrllog.DataContrlLog;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
@@ -9,15 +10,16 @@ import common.YosException;
 import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
+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 java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 
 public class promotionItems extends Controller {
 
@@ -43,14 +45,14 @@ public class promotionItems extends Controller {
             }
 
             if (whereObject.containsKey("tradefield") && !whereObject.getJSONArray("tradefield").isEmpty()) {
-                String where2 =" 1=1 ";
-                if ( whereObject.getJSONArray("tradefield").size() > 0) {
-                    for (Object object:whereObject.getJSONArray("tradefield")) {
+                String where2 = " 1=1 ";
+                if (whereObject.getJSONArray("tradefield").size() > 0) {
+                    for (Object object : whereObject.getJSONArray("tradefield")) {
                         String str = String.valueOf(object);
-                        where2=where2 +" or tradefield ='"+str+"' ";
+                        where2 = where2 + " or tradefield ='" + str + "' ";
                     }
                 }
-                where=where+("and t1.itemid in (SELECT itemid from plm_item_tradefield WHERE ("+where2+") and siteid = '"+siteid+"')");
+                where = where + ("and t1.itemid in (SELECT itemid from plm_item_tradefield WHERE (" + where2 + ") and siteid = '" + siteid + "')");
             }
 
         }
@@ -58,20 +60,20 @@ public class promotionItems extends Controller {
         if (itemclassids.size() > 0) {
             String sql = " and t1.itemid in ( SELECT itemid from sa_itemsaleclass WHERE itemclassid IN " + itemclassids + "  and siteid='" + siteid + "')";
             sql = sql.replace("[", "(").replace("]", ")");
-            where=where+sql;
+            where = where + sql;
         }
         Long sa_promotionid = content.getLong("sa_promotionid");
-        Rows tradefieldrows =dbConnect.runSqlQuery("select tradefield from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid);
-        JSONArray tradefield=new JSONArray();
-        if(!tradefieldrows.isEmpty()){
+        Rows tradefieldrows = dbConnect.runSqlQuery("select tradefield from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
+        JSONArray tradefield = new JSONArray();
+        if (!tradefieldrows.isEmpty()) {
             if (!StringUtils.isBlank(tradefieldrows.get(0).getString("tradefield"))) {
-                tradefield=JSONArray.parseArray(tradefieldrows.get(0).getString("tradefield"));
+                tradefield = JSONArray.parseArray(tradefieldrows.get(0).getString("tradefield"));
             }
         }
-        if(tradefield!=null && !tradefield.isEmpty()){
-            for (Object object:tradefield) {
+        if (tradefield != null && !tradefield.isEmpty()) {
+            for (Object object : tradefield) {
                 String str = String.valueOf(object);
-                where1=where1 +" or tradefield ='"+str+"' ";
+                where1 = where1 + " or tradefield ='" + str + "' ";
             }
         }
 
@@ -81,7 +83,7 @@ public class promotionItems extends Controller {
         sqlFactory.addParameter_SQL("where1", where1);
         sqlFactory.addParameter("sa_promotionid", sa_promotionid);
         sqlFactory.addParameter("siteid", siteid);
-         System.out.println(sqlFactory.getSQL());
+        System.out.println(sqlFactory.getSQL());
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
 
         // 附件
@@ -124,7 +126,7 @@ public class promotionItems extends Controller {
         long[] sa_promotion_itemsid = createTableID("sa_promotion_items", iteminfos.size());
         for (Object obj : iteminfos) {
             JSONObject iteminfo = (JSONObject) obj;
-            Rows itemrows = dbConnect.runSqlQuery("select itemid,orderminqty,orderaddqty from plm_item where siteid='"+siteid+"'");
+            Rows itemrows = dbConnect.runSqlQuery("select itemid,orderminqty,orderaddqty from plm_item where siteid='" + siteid + "'");
             RowsMap itemrowsMap = itemrows.toRowsMap("itemid");
             if (iteminfo.getLong("sa_promotion_itemsid") <= 0 || dbConnect
                     .runSqlQuery("select sa_promotion_itemsid from sa_promotion_items where sa_promotion_itemsid="
@@ -137,15 +139,15 @@ public class promotionItems extends Controller {
                 saleFactory.addParameter("sa_promotion_itemgroupid", sa_promotion_itemgroupid);
                 saleFactory.addParameter("groupqty", iteminfo.getLong("groupqty"));
                 saleFactory.addParameter("itemid", iteminfo.getLong("itemid"));
-                if(itemrowsMap.containsKey(iteminfo.getString("itemid"))){
+                if (itemrowsMap.containsKey(iteminfo.getString("itemid"))) {
                     saleFactory.addParameter("orderaddqty", itemrowsMap.get(iteminfo.getString("itemid")).get(0).getBigDecimal("orderaddqty"));
-                    if(itemrowsMap.get(iteminfo.getString("itemid")).get(0).getBigDecimal("packageqty").compareTo(BigDecimal.ZERO)>0){
+                    if (itemrowsMap.get(iteminfo.getString("itemid")).get(0).getBigDecimal("packageqty").compareTo(BigDecimal.ZERO) > 0) {
                         saleFactory.addParameter("orderminqty", itemrowsMap.get(iteminfo.getString("itemid")).get(0).getBigDecimal("packageqty"));
-                    }else {
+                    } else {
                         saleFactory.addParameter("orderminqty", itemrowsMap.get(iteminfo.getString("itemid")).get(0).getBigDecimal("orderminqty"));
                     }
 
-                }else {
+                } else {
                     saleFactory.addParameter("orderaddqty", 1);
                     saleFactory.addParameter("orderminqty", 1);
                 }
@@ -211,7 +213,7 @@ public class promotionItems extends Controller {
         sqlFactory.addParameter("sa_promotionid", sa_promotionid);
         sqlFactory.addParameter("sa_promotion_itemgroupid", sa_promotion_itemgroupid);
         sqlFactory.addParameter("siteid", siteid);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
 
         ArrayList ids = rows.toArrayList("itemid", new ArrayList<>());
         // 附件
@@ -252,4 +254,275 @@ public class promotionItems extends Controller {
         }
         return batchDeleteErr.getReturnObject().toString();
     }
+
+    @API(title = "促销活动商品导入模板",apiversion = R.ID20230510153404.v1.class)
+    public String downloadPromotionExcel() throws YosException {
+        ExcelFactory excelFactory = new ExcelFactory("促销活动商品导入");
+
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        // 设置为文本格式,防止身份证号变成科学计数法
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        sheet.setDefaultColumnStyle(0, style);
+        ExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = ExportExcel.createBodyCellStyle(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle4 = ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        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 = "促销活动商品导入",apiversion = R.ID20230510153504.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20230102142503.v1.class, R.ID20230102144603.v1.class,R.ID20230102163103.v1.class})
+    public String uploadPromotionItems() throws YosException {
+
+        Long sa_promotionid = content.getLong("sa_promotionid");
+        Rows promotion = dbConnect.runSqlQuery("select status from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
+        if (promotion.isEmpty()) {
+            return getErrReturnObject().setErrMsg("无效促销活动").toString();
+        } else if (!promotion.get(0).getString("status").equals("新建")) {
+            return getErrReturnObject().setErrMsg("非新建状态促销活动无法导入").toString();
+        }
+
+        ExcelFactory e;
+        try {
+
+            // 华为云
+            e = getPostExcelFactory(content.getLong("attachmentid"));
+            // 本地
+            //e = getPostExcelFactory();
+
+            ArrayList<String> keys = new ArrayList<>();
+            ArrayList<String> sqllist = new ArrayList<>();
+            keys.add("itemno");
+            keys.add("orderminqty");
+            keys.add("orderaddqty");
+            keys.add("groupqty");
+            keys.add("price1");
+            keys.add("price2");
+            keys.add("price3");
+            keys.add("price4");
+            keys.add("price5");
+
+            int i = 0;
+            int a = 0;
+            Rows rows = e.getSheetRows(0, keys, 3);
+
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+            ArrayList<String> itemnoList = rows.toArrayList("itemno");
+            SQLFactory sqlFactory = new SQLFactory(this, "商品等级价格查询");
+            sqlFactory.addParameter("siteid", siteid);
+            sqlFactory.addParameter_in("itemno", itemnoList);
+            RowsMap itemRowsMap = dbConnect.runSqlQuery(sqlFactory.getSQL()).toRowsMap("itemno");
+            ArrayList<String> inItemnoList = dbConnect.runSqlQuery("select itemno from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid).toArrayList("itemno");
+            for (Row row : rows) {
+                String itemno = row.getString("itemno");
+                String orderminqty = row.getString("orderminqty");
+                String orderaddqty = row.getString("orderaddqty");
+                String groupqty = row.getString("groupqty");
+                String price1 = row.getString("price1");
+                String price2 = row.getString("price2");
+                String price3 = row.getString("price3");
+                String price4 = row.getString("price4");
+                String price5 = row.getString("price5");
+                if (StringUtils.isEmpty(itemno)) {
+                    iserr = true;
+                    row.put("msg", "产品编码不能为空");
+                    rowserr.add(row);
+                    continue;
+                }
+                if (!itemRowsMap.containsKey(itemno)) {
+                    iserr = true;
+                    row.put("msg", "产品不存在");
+                    rowserr.add(row);
+                    continue;
+                }
+                if(inItemnoList.contains(itemno)){
+                    iserr = true;
+                    row.put("msg", "产品已存在促销活动");
+                    rowserr.add(row);
+                    continue;
+                }
+                Row item = itemRowsMap.get(itemno).get(0);
+                row.put("itemid", item.getLong("itemid"));
+                if (StringUtils.isEmpty(orderminqty) || orderminqty.equals("0")) {
+                    row.put("orderminqty", item.getBigDecimal("orderminqty"));
+                }
+                if (StringUtils.isEmpty(orderaddqty) || orderaddqty.equals("0")) {
+                    row.put("orderaddqty", item.getBigDecimal("orderaddqty"));
+                }
+                if (StringUtils.isEmpty(groupqty) || groupqty.equals("0")) {
+                    row.put("groupqty", "0");
+                    row.put("islimit", "0");
+                }else {
+                    row.put("islimit", "1");
+                }
+                if (StringUtils.isEmpty(price1) || price1.equals("0")) {
+                    row.put("price1", item.getBigDecimal("price1"));
+                }
+                if (StringUtils.isEmpty(price2) || price2.equals("0")) {
+                    row.put("price2", item.getBigDecimal("price2"));
+                }
+                if (StringUtils.isEmpty(price3) || price3.equals("0")) {
+                    row.put("price3", item.getBigDecimal("price3"));
+                }
+                if (StringUtils.isEmpty(price4) || price4.equals("0")) {
+                    row.put("price4", item.getBigDecimal("price4"));
+                }
+                if (StringUtils.isEmpty(price5) || price5.equals("0")) {
+                    row.put("price5", item.getBigDecimal("price5"));
+                }
+                row.put("oldprice1", item.getBigDecimal("price1"));
+                row.put("oldprice2", item.getBigDecimal("price2"));
+                row.put("oldprice3", item.getBigDecimal("price3"));
+                row.put("oldprice4", item.getBigDecimal("price4"));
+                row.put("oldprice5", item.getBigDecimal("price5"));
+                rowssuc.add(row);
+            }
+            if (iserr) {
+                ExcelFactory excelFactory = new ExcelFactory("促销活动导入错误信息");
+                HashMap<String, String> map = new HashMap<String, String>();
+                map.put("itemno", "产品编码");
+                map.put("orderminqty", "起订量");
+                map.put("orderaddqty", "增量");
+                map.put("groupqty", "限购数");
+                map.put("price1", "价格一活动价");
+                map.put("price2", "价格二活动价");
+                map.put("price3", "价格三活动价");
+                map.put("price4", "价格四活动价");
+                map.put("price5", "价格五活动价");
+                map.put("msg", "错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("itemno");
+                colNameList.add("orderminqty");
+                colNameList.add("orderaddqty");
+                colNameList.add("groupqty");
+                colNameList.add("price1");
+                colNameList.add("price2");
+                colNameList.add("price3");
+                colNameList.add("price4");
+                colNameList.add("price5");
+                colNameList.add("msg");
+                keytypemap.put("itemno", String.class);
+                keytypemap.put("orderminqty", String.class);
+                keytypemap.put("orderaddqty", String.class);
+                keytypemap.put("groupqty", String.class);
+                keytypemap.put("price1", String.class);
+                keytypemap.put("price2", String.class);
+                keytypemap.put("price3", String.class);
+                keytypemap.put("price4", String.class);
+                keytypemap.put("price5", 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();
+            }
+            long[] sa_promotion_itemsids = createTableID("sa_promotion_items", rowssuc.size());
+            long[] sa_promotion_itempriceids = createTableID("sa_promotion_itemprice", rowssuc.size() * 5);
+            if (!rowssuc.isEmpty()) {
+                for (Row row : rowssuc) {
+                    long sa_promotion_itemsid = sa_promotion_itemsids[i];
+                    sqlFactory = new SQLFactory(this, "促销方案商品新增");
+                    sqlFactory.addParameter("siteid", siteid);
+                    sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsid);
+                    sqlFactory.addParameter("sa_promotionid", sa_promotionid);
+                    sqlFactory.addParameter("sa_promotion_itemgroupid", 0);
+                    sqlFactory.addParameter("groupqty", row.getString("groupqty"));
+                    sqlFactory.addParameter("itemid", row.getString("itemid"));
+                    sqlFactory.addParameter("orderaddqty", row.getString("orderaddqty"));
+                    sqlFactory.addParameter("orderminqty", row.getString("orderminqty"));
+                    sqlFactory.addParameter("islimit", row.getString("islimit"));
+                    sqllist.add(sqlFactory.getSQL());
+                    for (int o = 1; o <= 5; o++) {
+                        long sa_promotion_itempriceid = sa_promotion_itempriceids[a];
+                        sqlFactory = new SQLFactory(this, "促销方案商品价格新增");
+                        sqlFactory.addParameter("siteid", siteid);
+                        sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsid);
+                        sqlFactory.addParameter("sa_promotion_itempriceid", sa_promotion_itempriceid);
+                        sqlFactory.addParameter("sa_promotionid", sa_promotionid);
+                        sqlFactory.addParameter("itemid", row.getString("itemid"));
+                        sqlFactory.addParameter("pricegrade", o);
+                        sqlFactory.addParameter("oldprice", row.getBigDecimal("oldprice" + o));
+                        sqlFactory.addParameter("price", row.getString("price" + o));
+                        sqllist.add(sqlFactory.getSQL());
+                        a++;
+                    }
+                    i++;
+                }
+            }
+            if (!sqllist.isEmpty()) {
+                sqllist.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "导入", "促销活动商品导入成功").getSQL());
+                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);
+
+        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)).intValue());
+                } 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 == 9) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
 }