|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|