|
@@ -0,0 +1,466 @@
|
|
|
+package restcontroller.webmanage.sale.item;
|
|
|
+
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import beans.itemprice.ItemPrice;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+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 utility.tools.Math;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+@API(title = "季度价格系数")
|
|
|
+public class quarterpricenum extends Controller {
|
|
|
+ public quarterpricenum(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "季度价格系数新增修改", apiversion = R.ID2025020710433903.v1.class)
|
|
|
+ public String insertormodify_quarterpricenum() throws YosException {
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ String tableName = "sa_quarterpricenum";
|
|
|
+
|
|
|
+ Long sa_quarterpricenumid = content.getLongValue("sa_quarterpricenumid");
|
|
|
+ Long year = content.getLongValue("year");
|
|
|
+ Long sa_agentsid = content.getLongValue("sa_agentsid");
|
|
|
+ Long quarter = content.getLongValue("quarter");
|
|
|
+ BigDecimal pricerate = content.getBigDecimal("pricerate");
|
|
|
+ if (sa_quarterpricenumid <= 0 || dbConnect.runSqlQuery("select * from sa_quarterpricenum where sa_quarterpricenumid="+sa_quarterpricenumid).isEmpty()) {
|
|
|
+ sa_quarterpricenumid = createTableID(tableName);
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, tableName);
|
|
|
+ insertSQL.setUniqueid(sa_quarterpricenumid).setSiteid(siteid);
|
|
|
+ insertSQL.setValue("year", year);
|
|
|
+ insertSQL.setValue("sa_agentsid", sa_agentsid);
|
|
|
+ insertSQL.setValue("quarter", quarter);
|
|
|
+ insertSQL.setValue("pricerate", pricerate);
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setDateValue("operatedate");
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, tableName, sa_quarterpricenumid, "新增", "季度价格系数新增成功").getSQL());
|
|
|
+ } else{
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_quarterpricenum where sa_quarterpricenumid="+sa_quarterpricenumid);
|
|
|
+ if(rows.isNotEmpty() && rows.get(0).getString("status").equals("新建")){
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, tableName);
|
|
|
+ updateSQL.setUniqueid(sa_quarterpricenumid).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("year", year);
|
|
|
+ updateSQL.setValue("sa_agentsid", sa_agentsid);
|
|
|
+ updateSQL.setValue("pricerate", pricerate);
|
|
|
+ updateSQL.setValue("quarter", quarter);
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, tableName, sa_quarterpricenumid, "编辑", "季度价格系数编辑成功").getSQL());
|
|
|
+ }else{
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态的季度价格系数无法更新").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ content.put("sa_quarterpricenumid", sa_quarterpricenumid);
|
|
|
+
|
|
|
+ return queryquarterpricenumMain();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "季度价格系数列表", apiversion = R.ID2025020710553803.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryquarterpricenumList() 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("t1.year like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.quarter like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t3.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and t1.status='").append(whereObject.getString("status")).append("' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+// SQLFactory sqlFactory = new SQLFactory(this, "经销商列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+// sqlFactory.addParameter_SQL("where", where);
|
|
|
+// sqlFactory.addParameter("siteid", siteid);
|
|
|
+// Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_quarterpricenum");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sa_agents", "t2", "t1.siteid = t2.siteid and t1.sa_agentsid = t2.sa_agentsid","agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t3.siteid = t2.siteid and t3.sys_enterpriseid = t2.sys_enterpriseid","enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "季度价格系数详情", apiversion = R.ID2025020710554503.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryquarterpricenumMain() throws YosException {
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_quarterpricenum");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sa_agents", "t2", "t1.siteid = t2.siteid and t1.sa_agentsid = t2.sa_agentsid","agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t3.siteid = t2.siteid and t3.sys_enterpriseid = t2.sys_enterpriseid","enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sa_quarterpricenumid",content.getLongValue("sa_quarterpricenumid"));
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "检查", apiversion = R.ID2025020711080903.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {quarterpricenum.class})
|
|
|
+ public String check() throws YosException {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_quarterpricenum where status='新建' and siteid='"+siteid+"'");
|
|
|
+ Rows agentRows = dbConnect.runSqlQuery("select sa_agentsid,year,quarter,pricerate from sa_agents where siteid='"+siteid+"' and sa_agentsid in (select sa_agentsid from sa_quarterpricenum where status='新建' and siteid='"+siteid+"')");
|
|
|
+ RowsMap agentRowsMap = agentRows.toRowsMap("sa_agentsid");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ for(Row row :rows){
|
|
|
+ if(agentRowsMap.containsKey(row.getString("sa_agentsid"))){
|
|
|
+ if(row.getBigDecimal("pricerate").compareTo(BigDecimal.ZERO)<=0){
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("ischeck", true);
|
|
|
+ updateSQL.setValue("isright", false);
|
|
|
+ updateSQL.setValue("result", "价格系数不能小于0");
|
|
|
+ updateSQL.setValue("status", "已检验");
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ updateSQL.setDateValue("operatedate");
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }else{
|
|
|
+ if(agentRowsMap.get(row.getString("sa_agentsid")).get(0).getLong("year")==row.getLong("year") &&
|
|
|
+ agentRowsMap.get(row.getString("sa_agentsid")).get(0).getLong("quarter")==row.getLong("quarter") &&
|
|
|
+ agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate").compareTo(row.getBigDecimal("pricerate"))==0){
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("ischeck", true);
|
|
|
+ updateSQL.setValue("isright", false);
|
|
|
+ updateSQL.setValue("result", "原有系数:" + agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate")+ " , 待导入系数:" + row.getBigDecimal("pricerate"));
|
|
|
+ updateSQL.setValue("status", "已检验");
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ updateSQL.setDateValue("operatedate");
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }else{
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("ischeck", true);
|
|
|
+ updateSQL.setValue("isright", true);
|
|
|
+ updateSQL.setValue("result", "原有系数:" + agentRowsMap.get(row.getString("sa_agentsid")).get(0).getBigDecimal("pricerate")+ " , 待导入系数:" + row.getBigDecimal("pricerate"));
|
|
|
+ updateSQL.setValue("status", "已检验");
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ updateSQL.setDateValue("operatedate");
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_quarterpricenum");
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_quarterpricenumid")).setSiteid(siteid);
|
|
|
+ updateSQL.setValue("ischeck", true);
|
|
|
+ updateSQL.setValue("isright", false);
|
|
|
+ updateSQL.setValue("result", "该经销商不存在");
|
|
|
+ updateSQL.setValue("status", "已检验");
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ updateSQL.setDateValue("operatedate");
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "更新经销商季度价格系数", apiversion = R.ID2025020713110003.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {Item.class, restcontroller.sale.item.Item.class,quarterpricenum.class})
|
|
|
+ public String UpdateQuarterPriceNum() throws YosException {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_quarterpricenum where status='已检验' and ischeck=1 and isright=1 and siteid='"+siteid+"'");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ for(Row row :rows){
|
|
|
+ sqlList.add("update sa_agents set year="+row.getLong("year")+",quarter="+row.getLong("quarter")+",pricerate="+row.getBigDecimal("pricerate")+" where sa_agentsid="+row.getLong("sa_agentsid"));
|
|
|
+ sqlList.add("update sa_quarterpricenum set status='已更新' where sa_quarterpricenumid="+row.getLong("sa_quarterpricenumid"));
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "季度价格系数删除", apiversion = R.ID2025020711034703.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {quarterpricenum.class})
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray sa_quarterpricenumids = content.getJSONArray("sa_quarterpricenumids");
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_quarterpricenumids.size());
|
|
|
+ for (Object o : sa_quarterpricenumids) {
|
|
|
+ long sa_quarterpricenumid = Long.parseLong(o.toString());
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery(
|
|
|
+ "select status from sa_quarterpricenum where sa_quarterpricenumid='" + sa_quarterpricenumid + "'");
|
|
|
+
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
+ if (RowsStatus.get(0).getString("status").equals("已更新")) {
|
|
|
+ batchDeleteErr.addErr(sa_quarterpricenumid, "已更新状态的季度价格系数无法删除");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ list.add("delete from sa_quarterpricenum where siteid='" + siteid
|
|
|
+ + "' and sa_quarterpricenumid=" + sa_quarterpricenumid);
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(list);
|
|
|
+ }
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "下载导入模板", apiversion = R.ID2025020713403803.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {quarterpricenum.class})
|
|
|
+ public String downloadExcel() 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("@"));
|
|
|
+ // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
|
|
|
+ for (int i = 0; i <= 2; i++) {
|
|
|
+ sheet.setDefaultColumnStyle(i, style);
|
|
|
+ }
|
|
|
+ // 设置工作薄列宽
|
|
|
+ ExportpricePriceNumExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
|
|
|
+ XSSFCellStyle titleCellStyle1 = ExportpricePriceNumExcel.createTitleCellStyle1(xssfFWorkbook);
|
|
|
+ XSSFCellStyle titleCellStyle2 = ExportpricePriceNumExcel.createTitleCellStyle2(xssfFWorkbook);
|
|
|
+ XSSFCellStyle titleCellStyle3 = ExportpricePriceNumExcel.createTitleCellStyle3(xssfFWorkbook);
|
|
|
+ XSSFCellStyle titleCellStyle4 = ExportpricePriceNumExcel.createBodyCellStyle4(xssfFWorkbook);
|
|
|
+
|
|
|
+ ExportpricePriceNumExcel.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.ID2025020713405203.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {quarterpricenum.class})
|
|
|
+ public String importQuarterpricenum() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ ExcelFactory e;
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 华为云
|
|
|
+ //e = getPostExcelFactory(content.getLong("attachmentid"));
|
|
|
+ // 本地
|
|
|
+ e = getPostExcelFactory();
|
|
|
+
|
|
|
+ ArrayList<String> keys = new ArrayList<>();
|
|
|
+ keys.add("agentnum");
|
|
|
+ keys.add("year");
|
|
|
+ keys.add("quarter");
|
|
|
+ keys.add("pricerate");
|
|
|
+
|
|
|
+ Rows rows = e.getSheetRows(0, keys, 3);
|
|
|
+ boolean iserr = false;
|
|
|
+ Rows rowserr = new Rows();
|
|
|
+ Rows rowssuc = new Rows();
|
|
|
+
|
|
|
+ RowsMap agentRowsMap = dbConnect.runSqlQuery("select sa_agentsid,agentnum from sa_agents where siteid='" + siteid + "'").toRowsMap("agentnum");
|
|
|
+
|
|
|
+ RowsMap limitagentRowsMap = rows.toRowsMap("agentnum");
|
|
|
+ for (Row row : rows) {
|
|
|
+ String agentnum = row.getString("agentnum");
|
|
|
+ String year = row.getString("year");
|
|
|
+ String quarter = row.getString("quarter");
|
|
|
+ String pricerate = row.getString("pricerate");
|
|
|
+ if (StringUtils.isEmpty(agentnum)
|
|
|
+ || StringUtils.isEmpty(year)
|
|
|
+ || StringUtils.isEmpty(quarter) || StringUtils.isEmpty(pricerate)) {
|
|
|
+ iserr = true;
|
|
|
+ row.put("msg", "错误信息:经销商编号/年份/季度/价格系数不能为空");
|
|
|
+ rowserr.add(row);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!isNumeric(row.getString("year"))){
|
|
|
+ iserr = true;
|
|
|
+ row.put("msg", "年份不为数字格式,请检查");
|
|
|
+ rowserr.add(row);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!isNumeric(row.getString("quarter"))){
|
|
|
+ iserr = true;
|
|
|
+ row.put("msg", "季度不为数字格式,请检查");
|
|
|
+ rowserr.add(row);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!isNumeric(row.getString("pricerate"))){
|
|
|
+ iserr = true;
|
|
|
+ row.put("msg", "价格系数不为数字格式,请检查");
|
|
|
+ rowserr.add(row);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (limitagentRowsMap.get(agentnum).size() > 1) {
|
|
|
+ iserr = true;
|
|
|
+ row.put("msg", "错误信息:本次导入存在重复经销商");
|
|
|
+ rowserr.add(row);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!agentRowsMap.containsKey(agentnum)) {
|
|
|
+ iserr = true;
|
|
|
+ row.put("msg", "错误信息:经销商不存在");
|
|
|
+ rowserr.add(row);
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ row.put("sa_agentsid", agentRowsMap.get(agentnum).get(0).getLong("sa_agentsid"));
|
|
|
+ }
|
|
|
+ rowssuc.add(row);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!rowssuc.isEmpty()) {
|
|
|
+ for(Row row : rowssuc){
|
|
|
+ long sa_quarterpricenumid = createTableID("sa_quarterpricenum");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_quarterpricenum");
|
|
|
+ insertSQL.setUniqueid(sa_quarterpricenumid).setSiteid(siteid);
|
|
|
+ insertSQL.setValue("year", row.getString("year"));
|
|
|
+ insertSQL.setValue("sa_agentsid", row.getString("sa_agentsid"));
|
|
|
+ insertSQL.setValue("quarter", row.getString("quarter"));
|
|
|
+ insertSQL.setValue("pricerate", row.getString("pricerate"));
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ insertSQL.setDateValue("operatedate");
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!sqlList.isEmpty()) {
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ }
|
|
|
+ if (iserr) {
|
|
|
+ ExcelFactory excelFactory = new ExcelFactory("季度价格系数导入错误信息");
|
|
|
+ HashMap<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("agentnum", "经销商编码");
|
|
|
+ map.put("year", "年份");
|
|
|
+ map.put("quarter", "季度");
|
|
|
+ map.put("pricerate", "价格系数");
|
|
|
+ map.put("msg", "错误信息");
|
|
|
+ ArrayList<String> colNameList = new ArrayList<String>();
|
|
|
+ HashMap<String, Class> keytypemap = new HashMap<String, Class>();
|
|
|
+ colNameList.add("agentnum");
|
|
|
+ colNameList.add("year");
|
|
|
+ colNameList.add("quarter");
|
|
|
+ colNameList.add("pricerate");
|
|
|
+ colNameList.add("msg");
|
|
|
+ keytypemap.put("agentnum", String.class);
|
|
|
+ keytypemap.put("year", String.class);
|
|
|
+ keytypemap.put("quarter", String.class);
|
|
|
+ keytypemap.put("pricerate", 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();
|
|
|
+ }
|
|
|
+ } 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 <= 5; i++) {
|
|
|
+ sheet.setDefaultColumnStyle(i, style);
|
|
|
+ }
|
|
|
+ ExportpricePriceNumExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
|
|
|
+ XSSFCellStyle titleCellStyle1 = ExportpricePriceNumExcel.createTitleCellStyle1(xssfFWorkbook);
|
|
|
+ XSSFCellStyle titleCellStyle2 = ExportpricePriceNumExcel.createTitleCellStyle2(xssfFWorkbook);
|
|
|
+ XSSFCellStyle titleCellStyle3 = ExportpricePriceNumExcel.createTitleCellStyle3(xssfFWorkbook);
|
|
|
+ ExportpricePriceNumExcel.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 == 5) {
|
|
|
+ datarow.getCell(i1).setCellStyle(xssfCellStyle1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sheet;
|
|
|
+ }
|
|
|
+ public static boolean isNumeric(String strNum) {
|
|
|
+ if (strNum == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return strNum.matches("-?\\d+(\\.\\d+)?");
|
|
|
+ }
|
|
|
+}
|