|
@@ -5,9 +5,7 @@ import com.uas.platform.b2b.openapi.model.CustTrading;
|
|
|
import com.uas.platform.b2b.openapi.model.RecentOfMonth;
|
|
import com.uas.platform.b2b.openapi.model.RecentOfMonth;
|
|
|
import com.uas.platform.b2b.openapi.model.RecentOfYear;
|
|
import com.uas.platform.b2b.openapi.model.RecentOfYear;
|
|
|
import com.uas.platform.b2b.openapi.service.TradingDataService;
|
|
import com.uas.platform.b2b.openapi.service.TradingDataService;
|
|
|
-import com.uas.platform.b2b.openapi.support.ErpRate;
|
|
|
|
|
-import com.uas.platform.b2b.openapi.support.NumFormat;
|
|
|
|
|
-import com.uas.platform.b2b.openapi.support.TimeStauts;
|
|
|
|
|
|
|
+import com.uas.platform.b2b.openapi.support.*;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -46,7 +44,7 @@ public class TradingDataServiceImpl implements TradingDataService {
|
|
|
Double apBillSum = getApBillSum(enUU);
|
|
Double apBillSum = getApBillSum(enUU);
|
|
|
// 获取历史退货率
|
|
// 获取历史退货率
|
|
|
Double orderSum = getOrderSum(enUU);
|
|
Double orderSum = getOrderSum(enUU);
|
|
|
- Double historyReturn = NumFormat.getPercent(orderSum == 0.0 ? 0.0 : returnSum / orderSum);
|
|
|
|
|
|
|
+ Double historyReturn = NumFormat.getPercent(NumDefaultUtil.DOUBLE.equals(orderSum) ? NumDefaultUtil.DOUBLE : returnSum / orderSum);
|
|
|
map.put("timeSum", timeSum);
|
|
map.put("timeSum", timeSum);
|
|
|
map.put("acceptSum", acceptSum);
|
|
map.put("acceptSum", acceptSum);
|
|
|
map.put("returnSum", returnSum);
|
|
map.put("returnSum", returnSum);
|
|
@@ -64,23 +62,24 @@ public class TradingDataServiceImpl implements TradingDataService {
|
|
|
Double sum = getAcceptSum(enUU, null) - getReturnSum(enUU, null);
|
|
Double sum = getAcceptSum(enUU, null) - getReturnSum(enUU, null);
|
|
|
Integer sumNum = getAcceptNum(enUU, null) - getReturnNum(enUU, null);
|
|
Integer sumNum = getAcceptNum(enUU, null) - getReturnNum(enUU, null);
|
|
|
if (CollectionUtils.isNotEmpty(datas)) {
|
|
if (CollectionUtils.isNotEmpty(datas)) {
|
|
|
- for (CustTrading custTrading : datas) {
|
|
|
|
|
|
|
+ System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "100");
|
|
|
|
|
+ datas.parallelStream().forEach(custTrading -> {
|
|
|
Double acceptSum = getAcceptSum(enUU, custTrading.getCustUU());
|
|
Double acceptSum = getAcceptSum(enUU, custTrading.getCustUU());
|
|
|
Double returnSum = getReturnSum(enUU, custTrading.getCustUU());
|
|
Double returnSum = getReturnSum(enUU, custTrading.getCustUU());
|
|
|
custTrading.setRealAccept(NumFormat.getTwo(acceptSum - returnSum));
|
|
custTrading.setRealAccept(NumFormat.getTwo(acceptSum - returnSum));
|
|
|
- if (StringUtils.isEmpty(acceptSum) || acceptSum == 0.0) {
|
|
|
|
|
- custTrading.setAcceptPercent(0.00);
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(acceptSum) || NumDefaultUtil.DOUBLE.equals(acceptSum)) {
|
|
|
|
|
+ custTrading.setAcceptPercent(NumDefaultUtil.DOUBLE);
|
|
|
} else {
|
|
} else {
|
|
|
- custTrading.setAcceptPercent(NumFormat.getPercent(sum == 0.0 ? 0.0 : (acceptSum - returnSum) / sum));
|
|
|
|
|
|
|
+ custTrading.setAcceptPercent(NumFormat.getPercent(NumDefaultUtil.DOUBLE.equals(sum) ? NumDefaultUtil.DOUBLE : (acceptSum - returnSum) / sum));
|
|
|
}
|
|
}
|
|
|
Integer acceptNum = getAcceptNum(enUU, custTrading.getCustUU());
|
|
Integer acceptNum = getAcceptNum(enUU, custTrading.getCustUU());
|
|
|
Integer realNum = acceptNum - getReturnNum(enUU, custTrading.getCustUU());
|
|
Integer realNum = acceptNum - getReturnNum(enUU, custTrading.getCustUU());
|
|
|
custTrading.setRealNum(realNum);
|
|
custTrading.setRealNum(realNum);
|
|
|
- if (0 != acceptNum) {
|
|
|
|
|
- custTrading.setNumPercent(NumFormat.getPercent(sumNum == 0 ? 0 : (double) realNum / sumNum));
|
|
|
|
|
|
|
+ if (!NumDefaultUtil.INTEGER.equals(acceptNum)) {
|
|
|
|
|
+ custTrading.setNumPercent(NumFormat.getPercent(NumDefaultUtil.INTEGER.equals(sumNum) ? NumDefaultUtil.INTEGER : (double) realNum / sumNum));
|
|
|
}
|
|
}
|
|
|
custTrading.setTimeSum(NumFormat.getOne(getTimeSum(enUU, custTrading.getCustUU())));
|
|
custTrading.setTimeSum(NumFormat.getOne(getTimeSum(enUU, custTrading.getCustUU())));
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
map.put("data", datas);
|
|
map.put("data", datas);
|
|
|
return map;
|
|
return map;
|
|
@@ -365,7 +364,7 @@ public class TradingDataServiceImpl implements TradingDataService {
|
|
|
private Double getApBillSum(Long enUU) {
|
|
private Double getApBillSum(Long enUU) {
|
|
|
StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
|
|
StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
|
|
|
+ "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
|
|
+ "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
|
|
|
- + "FROM (SELECT SUM(pab_paymount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU
|
|
|
|
|
|
|
+ + "FROM (SELECT SUM(pab_apamount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU
|
|
|
+ " GROUP BY pab_currency) a");
|
|
+ " GROUP BY pab_currency) a");
|
|
|
Double result = commonDao.queryForObject(sql.toString(), Double.class);
|
|
Double result = commonDao.queryForObject(sql.toString(), Double.class);
|
|
|
return NumFormat.getTwo(NumFormat.getTenThousand(result));
|
|
return NumFormat.getTwo(NumFormat.getTenThousand(result));
|
|
@@ -543,7 +542,7 @@ public class TradingDataServiceImpl implements TradingDataService {
|
|
|
private Double getApBillSumTime(Long enUU, Date startTime, Date endTime) {
|
|
private Double getApBillSumTime(Long enUU, Date startTime, Date endTime) {
|
|
|
StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
|
|
StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
|
|
|
+ "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
|
|
+ "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
|
|
|
- + "FROM (SELECT SUM(pab_paymount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU
|
|
|
|
|
|
|
+ + "FROM (SELECT SUM(pab_apamount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU
|
|
|
+ " and pab_date >= '" + startTime + "' and pab_date < '" + endTime + "' GROUP BY pab_currency) a");
|
|
+ " and pab_date >= '" + startTime + "' and pab_date < '" + endTime + "' GROUP BY pab_currency) a");
|
|
|
Double result = commonDao.queryForObject(sql.toString(), Double.class);
|
|
Double result = commonDao.queryForObject(sql.toString(), Double.class);
|
|
|
return NumFormat.getTwo(result);
|
|
return NumFormat.getTwo(result);
|
|
@@ -571,22 +570,14 @@ public class TradingDataServiceImpl implements TradingDataService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public Double getTimeSum(Long enUU, Long custUU) {
|
|
public Double getTimeSum(Long enUU, Long custUU) {
|
|
|
- StringBuffer last = new StringBuffer("SELECT ifnull((SELECT pu_date from purc$orders "
|
|
|
|
|
- + "WHERE pu_venduu = " + enUU + " and pu_date is not null ");
|
|
|
|
|
|
|
+ StringBuffer sql = new StringBuffer("SELECT TIMESTAMPDIFF(MONTH,min(pu_date),max(pu_date)) from purc$orders WHERE pu_venduu = " + enUU);
|
|
|
if (!StringUtils.isEmpty(custUU)) {
|
|
if (!StringUtils.isEmpty(custUU)) {
|
|
|
- last.append("and pu_enuu = " + custUU + "");
|
|
|
|
|
|
|
+ sql.append(" and pu_enuu = " + custUU);
|
|
|
}
|
|
}
|
|
|
- last.append(" ORDER BY pu_date desc limit 1),now()) pu_date");
|
|
|
|
|
- StringBuffer first = new StringBuffer("SELECT ifnull((SELECT pu_date from purc$orders "
|
|
|
|
|
- + "WHERE pu_venduu = " + enUU + " and pu_date is not null ");
|
|
|
|
|
- if (!StringUtils.isEmpty(custUU)) {
|
|
|
|
|
- first.append("and pu_enuu = " + custUU + "");
|
|
|
|
|
|
|
+ Double result = commonDao.queryForObject(sql.toString(), Double.class);
|
|
|
|
|
+ if (StringUtils.isEmpty(result)) {
|
|
|
|
|
+ result = NumDefaultUtil.DOUBLE;
|
|
|
}
|
|
}
|
|
|
- first.append(" ORDER BY pu_date asc limit 1),now()) pu_date");
|
|
|
|
|
- Date lastTime = commonDao.queryForObject(last.toString(), Date.class);
|
|
|
|
|
- Date firstTime = commonDao.queryForObject(first.toString(), Date.class);
|
|
|
|
|
- StringBuffer result = new StringBuffer("SELECT TIMESTAMPDIFF(MONTH,'" + firstTime + "','" + lastTime + "')");
|
|
|
|
|
- Double resultTime = commonDao.queryForObject(result.toString(), Double.class) / TimeStauts.TYEAR.value();
|
|
|
|
|
- return NumFormat.getOne(resultTime);
|
|
|
|
|
|
|
+ return NumFormat.getOne(result / TimeStauts.TYEAR.value());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|