|
|
@@ -56,37 +56,36 @@ public class databoard extends Controller {
|
|
|
String enddate2 = "";
|
|
|
|
|
|
|
|
|
-
|
|
|
switch (datetype) {
|
|
|
case "月":
|
|
|
begindate = getMonthFirstDay();
|
|
|
- begindate1=caluteDate(Calendar.MONTH,begindate);
|
|
|
- begindate2=caluteDate(Calendar.YEAR,begindate);
|
|
|
+ begindate1 = caluteDate(Calendar.MONTH, begindate);
|
|
|
+ begindate2 = caluteDate(Calendar.YEAR, begindate);
|
|
|
enddate = getMonthLastDay();
|
|
|
- enddate1= caluteDate(Calendar.MONTH,enddate);
|
|
|
- enddate2= caluteDate(Calendar.YEAR,enddate);
|
|
|
+ enddate1 = caluteDate(Calendar.MONTH, enddate);
|
|
|
+ enddate2 = caluteDate(Calendar.YEAR, enddate);
|
|
|
|
|
|
break;
|
|
|
case "年":
|
|
|
begindate = new SimpleDateFormat("yyyy").format(new Date()) + "-01-01";
|
|
|
- begindate1=caluteDate(Calendar.YEAR,begindate);
|
|
|
+ begindate1 = caluteDate(Calendar.YEAR, begindate);
|
|
|
enddate = new SimpleDateFormat("yyyy").format(new Date()) + "-12-31";
|
|
|
- enddate1= caluteDate(Calendar.YEAR,enddate);
|
|
|
+ enddate1 = caluteDate(Calendar.YEAR, enddate);
|
|
|
break;
|
|
|
case "日":
|
|
|
begindate = sdf.format(new Date().getTime());
|
|
|
- begindate1=caluteDate(Calendar.DAY_OF_MONTH,begindate);
|
|
|
+ begindate1 = caluteDate(Calendar.DAY_OF_MONTH, begindate);
|
|
|
enddate = sdf.format(new Date().getTime());
|
|
|
- enddate1= caluteDate(Calendar.DAY_OF_MONTH,enddate);
|
|
|
+ enddate1 = caluteDate(Calendar.DAY_OF_MONTH, enddate);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
- StringBuffer where = new StringBuffer(" 1=1 and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
- StringBuffer whereLast1 = new StringBuffer(" 1=1 and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
- StringBuffer whereLast2 = new StringBuffer(" 1=1 and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
+ StringBuffer whereLast1 = new StringBuffer(" 1=1 and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
+ StringBuffer whereLast2 = new StringBuffer(" 1=1 and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
|
|
|
if (begindate != "") {
|
|
|
where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >='").append(begindate).append("' ");
|
|
|
@@ -126,20 +125,20 @@ public class databoard extends Controller {
|
|
|
factoryLast2.addParameter_SQL("where", whereLast2);
|
|
|
Rows rowsLast2 = dbConnect.runSqlQuery(factoryLast2.getSQL(false));
|
|
|
|
|
|
- BigDecimal typestatistics =rows.get(0).getBigDecimal("typestatistics");
|
|
|
- BigDecimal typestatistics1 =rowsLast1.get(0).getBigDecimal("typestatistics");
|
|
|
- BigDecimal typestatistics2 =rowsLast2.get(0).getBigDecimal("typestatistics");
|
|
|
- BigDecimal huanbirate=BigDecimal.ZERO;
|
|
|
- BigDecimal tongbirate=BigDecimal.ZERO;
|
|
|
- if(typestatistics1.compareTo(BigDecimal.ZERO)>0){
|
|
|
- huanbirate=(typestatistics.subtract(typestatistics1)).divide(typestatistics1, 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal typestatistics = rows.get(0).getBigDecimal("typestatistics");
|
|
|
+ BigDecimal typestatistics1 = rowsLast1.get(0).getBigDecimal("typestatistics");
|
|
|
+ BigDecimal typestatistics2 = rowsLast2.get(0).getBigDecimal("typestatistics");
|
|
|
+ BigDecimal huanbirate = BigDecimal.ZERO;
|
|
|
+ BigDecimal tongbirate = BigDecimal.ZERO;
|
|
|
+ if (typestatistics1.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ huanbirate = (typestatistics.subtract(typestatistics1)).divide(typestatistics1, 4, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
- if(typestatistics2.compareTo(BigDecimal.ZERO)>0){
|
|
|
- tongbirate=(typestatistics.subtract(typestatistics2)).divide(typestatistics2, 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if (typestatistics2.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ tongbirate = (typestatistics.subtract(typestatistics2)).divide(typestatistics2, 4, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
|
|
|
jsonObject = new JSONObject();
|
|
|
- jsonObject.put("typestatistics",typestatistics);
|
|
|
+ jsonObject.put("typestatistics", typestatistics);
|
|
|
jsonObject.put("huanbirate", huanbirate);
|
|
|
jsonObject.put("tongbirate", tongbirate);
|
|
|
jsonArray.add(jsonObject);
|
|
|
@@ -159,13 +158,14 @@ public class databoard extends Controller {
|
|
|
|
|
|
|
|
|
//账户余额
|
|
|
- SQLFactory balancefactory= new SQLFactory(this, "账户余额_经销商");
|
|
|
+ SQLFactory balancefactory = new SQLFactory(this, "账户余额_经销商");
|
|
|
balancefactory.addParameter("siteid", siteid);
|
|
|
balancefactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
Rows balanceRows = dbConnect.runSqlQuery(balancefactory.getSQL(false));
|
|
|
|
|
|
return getSucReturnObject().setData(balanceRows).toString();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 订货额类别占比分析
|
|
|
*
|
|
|
@@ -341,8 +341,8 @@ public class databoard extends Controller {
|
|
|
|
|
|
String datatype = content.getString("datatype");
|
|
|
String where = " 1=1 ";
|
|
|
- if(sys_enterpriseid>0){
|
|
|
- where=where+" and t1.sys_enterpriseid="+sys_enterpriseid;
|
|
|
+ if (sys_enterpriseid > 0) {
|
|
|
+ where = where + " and t1.sys_enterpriseid=" + sys_enterpriseid;
|
|
|
}
|
|
|
/*
|
|
|
* 过滤条件设置
|
|
|
@@ -384,7 +384,7 @@ public class databoard extends Controller {
|
|
|
}
|
|
|
list = supplementDate(Integer.parseInt(year), list);
|
|
|
list = supplementDate(Integer.parseInt(lastyear), list);
|
|
|
- list.sort(Comparator.comparingLong(o -> Long.parseLong(StringUtils.isBlank(o.getMonth())?"9999":o.getMonth())));
|
|
|
+ list.sort(Comparator.comparingLong(o -> Long.parseLong(StringUtils.isBlank(o.getMonth()) ? "9999" : o.getMonth())));
|
|
|
return getSucReturnObject().setData(list).toString();
|
|
|
}
|
|
|
|
|
|
@@ -525,8 +525,8 @@ public class databoard extends Controller {
|
|
|
whereLastYear.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(sdf.format(cal.getTime())).append("' ");
|
|
|
}
|
|
|
|
|
|
- if(sys_enterpriseid>0){
|
|
|
- where.append(" and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
+ if (sys_enterpriseid > 0) {
|
|
|
+ where.append(" and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
}
|
|
|
|
|
|
if (datatype.equals("标准")) {
|
|
|
@@ -554,7 +554,7 @@ public class databoard extends Controller {
|
|
|
factoryLastYear.addParameter("siteid", siteid);
|
|
|
factoryLastYear.addParameter_SQL("where", whereLastYear);
|
|
|
Rows rowsLastYear = dbConnect.runSqlQuery(factoryLastYear.getSQL(false));
|
|
|
- RowsMap rowsLastYearMap =rowsLastYear.toRowsMap("marketingcategory");
|
|
|
+ RowsMap rowsLastYearMap = rowsLastYear.toRowsMap("marketingcategory");
|
|
|
|
|
|
for (Row row : rows) {
|
|
|
if (rows.isNotEmpty()) {
|
|
|
@@ -562,13 +562,13 @@ public class databoard extends Controller {
|
|
|
} else {
|
|
|
row.put("amount", BigDecimal.ZERO);
|
|
|
}
|
|
|
- if(rowsLastYearMap.containsKey(row.getString("marketingcategory"))){
|
|
|
- if(rowsLastYearMap.get(row.getString("marketingcategory")).isNotEmpty()){
|
|
|
+ if (rowsLastYearMap.containsKey(row.getString("marketingcategory"))) {
|
|
|
+ if (rowsLastYearMap.get(row.getString("marketingcategory")).isNotEmpty()) {
|
|
|
row.put("lastyearamount", rowsLastYearMap.get(row.getString("marketingcategory")).get(0).getBigDecimal("typestatistics"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
row.put("lastyearamount", BigDecimal.ZERO);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
row.put("lastyearamount", BigDecimal.ZERO);
|
|
|
}
|
|
|
if (row.getBigDecimal("lastyearamount").compareTo(BigDecimal.ZERO) == 0) {
|
|
|
@@ -585,7 +585,7 @@ public class databoard extends Controller {
|
|
|
row.put("proportion", row.getBigDecimal("amount").divide(sumamount, 4, BigDecimal.ROUND_HALF_UP));
|
|
|
}
|
|
|
}
|
|
|
- rows.sort(Comparator.comparingDouble(o ->o.getDouble("amount")));
|
|
|
+ rows.sort(Comparator.comparingDouble(o -> o.getDouble("amount")));
|
|
|
Collections.reverse(rows);
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
@@ -696,7 +696,7 @@ public class databoard extends Controller {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- list.sort(Comparator.comparingLong(o -> Long.parseLong(StringUtils.isBlank(o.getMonth())?"9999":o.getMonth())));
|
|
|
+ list.sort(Comparator.comparingLong(o -> Long.parseLong(StringUtils.isBlank(o.getMonth()) ? "9999" : o.getMonth())));
|
|
|
return getSucReturnObject().setData(list).toString();
|
|
|
}
|
|
|
|
|
|
@@ -888,31 +888,33 @@ public class databoard extends Controller {
|
|
|
* 过滤条件设置
|
|
|
*/
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
- if(sys_enterpriseid>0){
|
|
|
- where.append(" and t2.sys_enterpriseid="+sys_enterpriseid);
|
|
|
+ StringBuffer where2 = new StringBuffer(" 1=1 ");
|
|
|
+ if (sys_enterpriseid > 0) {
|
|
|
+ where.append(" and t2.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
+ where2.append(" and t3.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
}
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
- where.append(" and DATE_FORMAT(t2.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
- }
|
|
|
+ where.append(" and DATE_FORMAT(t2.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
+ }
|
|
|
if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
where.append(" and DATE_FORMAT(t2.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
SQLFactory factory = new SQLFactory(this, "工厂待发明细查询");
|
|
|
factory.addParameter("siteid", siteid);
|
|
|
factory.addParameter_SQL("where", where);
|
|
|
+ factory.addParameter_SQL("where2", where2);
|
|
|
Rows rows = dbConnect.runSqlQuery(factory.getSQL(false));
|
|
|
|
|
|
SQLFactory sumfactory = new SQLFactory(this, "工厂待发合计金额及数量查询");
|
|
|
sumfactory.addParameter("siteid", siteid);
|
|
|
sumfactory.addParameter_SQL("where", where);
|
|
|
+ sumfactory.addParameter_SQL("where2", where2);
|
|
|
Rows sumrows = dbConnect.runSqlQuery(sumfactory.getSQL(false));
|
|
|
- if(rows.isNotEmpty()){
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
rows.get(0).put("sumrows", sumrows);
|
|
|
}
|
|
|
|
|
|
@@ -1124,7 +1126,7 @@ public class databoard extends Controller {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public String caluteDate(int datetype,String selectdate) throws Exception {
|
|
|
+ public String caluteDate(int datetype, String selectdate) throws Exception {
|
|
|
Date date = sdf.parse(selectdate);
|
|
|
//创建Calendar实例
|
|
|
Calendar cal = Calendar.getInstance();
|