|
@@ -1,16 +1,17 @@
|
|
|
package org.jeecg.modules.purCode.controller;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
+import org.jeecg.modules.baseCode.entity.BaseExchangeRate;
|
|
|
+import org.jeecg.modules.baseCode.service.IBaseExchangeRateService;
|
|
|
import org.jeecg.modules.baseCode.service.ISerialPatternService;
|
|
|
import org.jeecg.modules.purCode.entity.*;
|
|
|
import org.jeecg.modules.purCode.service.*;
|
|
@@ -71,6 +72,9 @@ public class PurPurchaseQuotationController {
|
|
|
private IPurQuotationSelectionService purQuotationSelectionService;
|
|
|
@Autowired
|
|
|
private IPurOrderService purOrderService;
|
|
|
+ @Autowired
|
|
|
+ private IBaseExchangeRateService baseExchangeRateService;
|
|
|
+
|
|
|
|
|
|
|
|
|
* 分页列表查询
|
|
@@ -128,9 +132,108 @@ public class PurPurchaseQuotationController {
|
|
|
|
|
|
queryWrapper.orderByDesc("product_code");
|
|
|
IPage<SupplierQuotationDetails> pageList = purPurchaseInquiryProductService.supplierQuotationDetails(page, queryWrapper);
|
|
|
+
|
|
|
+ Map<String,BigDecimal> map = new HashMap<>();
|
|
|
+
|
|
|
+ for (SupplierQuotationDetails o : pageList.getRecords()) {
|
|
|
+
|
|
|
+ String currency = o.getCurrency();
|
|
|
+ Date billDate = o.getBillDate();
|
|
|
+
|
|
|
+ BigDecimal taxPrice = o.getTaxPrice();
|
|
|
+ BigDecimal taxAmount = o.getTaxAmount();
|
|
|
+ BigDecimal rate = BigDecimal.ONE;
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(currency)) {
|
|
|
+
|
|
|
+ if(map.containsKey(currency)){
|
|
|
+ rate = map.get(currency);
|
|
|
+ }else{
|
|
|
+ rate = this.getRateByUsd(billDate, currency);
|
|
|
+ map.put(currency, rate);
|
|
|
+ }
|
|
|
+
|
|
|
+ o.setTaxPriceUsd(taxPrice.multiply(rate));
|
|
|
+ o.setTaxAmountUsd(taxAmount.multiply(rate));
|
|
|
+ o.setExchangeRateUsd(rate);
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ o.setTaxPriceUsd(taxPrice.multiply(rate));
|
|
|
+ o.setTaxAmountUsd(taxAmount.multiply(rate));
|
|
|
+ o.setExchangeRateUsd(BigDecimal.ONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ int year = date.getYear() + 1900;
|
|
|
+ int month = date.getMonth() + 1;
|
|
|
+ int day = date.getDate();
|
|
|
+
|
|
|
+ System.out.println("年:" + year);
|
|
|
+ System.out.println("月:" + month);
|
|
|
+ System.out.println("日:" + day);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 获取币种
|
|
|
+ *
|
|
|
+ * @param currency
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal getRateByUsd(Date yearMonth, String currency) {
|
|
|
+
|
|
|
+ String year = String.valueOf(yearMonth.getYear() + 1900);
|
|
|
+ String month = String.valueOf(yearMonth.getMonth() + 1);
|
|
|
+
|
|
|
+ QueryWrapper<BaseExchangeRate> exchangeRateQuery = new QueryWrapper<BaseExchangeRate>();
|
|
|
+ exchangeRateQuery.eq("del_flag", 0);
|
|
|
+ exchangeRateQuery.eq("year", year);
|
|
|
+ if (StringUtils.isNotBlank(month)) {
|
|
|
+ exchangeRateQuery.eq("month", month);
|
|
|
+ }
|
|
|
+ exchangeRateQuery.eq("currency", currency);
|
|
|
+ exchangeRateQuery.orderByDesc("month");
|
|
|
+
|
|
|
+ Double exchangeRate = 1.0;
|
|
|
+
|
|
|
+ List<BaseExchangeRate> list = baseExchangeRateService.list(exchangeRateQuery);
|
|
|
+ if (list.size() > 0) {
|
|
|
+
|
|
|
+ exchangeRate = list.get(0).getExchangeRate();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ QueryWrapper<BaseExchangeRate> exchangeRateQuery2 = new QueryWrapper<BaseExchangeRate>();
|
|
|
+ exchangeRateQuery2.eq("del_flag", "0");
|
|
|
+ exchangeRateQuery2.eq("year", year);
|
|
|
+ exchangeRateQuery2.eq("month", "");
|
|
|
+ exchangeRateQuery2.eq("currency", currency);
|
|
|
+ exchangeRateQuery2.orderByDesc("month");
|
|
|
+ List<BaseExchangeRate> list2 = baseExchangeRateService.list(exchangeRateQuery2);
|
|
|
+
|
|
|
+ if (list2.size() > 0) {
|
|
|
+ exchangeRate = list2.get(0).getExchangeRate();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ return BigDecimal.ONE;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal bd = BigDecimal.valueOf(exchangeRate);
|
|
|
+
|
|
|
+ return bd;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* 供应商报价明细弹框
|
|
|
*
|
|
@@ -186,6 +289,37 @@ public class PurPurchaseQuotationController {
|
|
|
}
|
|
|
|
|
|
IPage<SupplierQuotationDetails> pageList = purPurchaseInquiryProductService.supplierQuotationTotal(page, queryWrapper);
|
|
|
+
|
|
|
+ Map<String,BigDecimal> map = new HashMap<>();
|
|
|
+
|
|
|
+ for (SupplierQuotationDetails o : pageList.getRecords()) {
|
|
|
+
|
|
|
+ String currency = o.getCurrency();
|
|
|
+ Date billDate = o.getBillDate();
|
|
|
+
|
|
|
+ BigDecimal taxAmount = o.getTaxAmount();
|
|
|
+ BigDecimal rate = BigDecimal.ONE;
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(currency)) {
|
|
|
+
|
|
|
+ if(map.containsKey(currency)){
|
|
|
+ rate = map.get(currency);
|
|
|
+ }else{
|
|
|
+ rate = this.getRateByUsd(billDate, currency);
|
|
|
+ map.put(currency, rate);
|
|
|
+ }
|
|
|
+
|
|
|
+ o.setTaxAmountUsd(taxAmount.multiply(rate));
|
|
|
+ o.setExchangeRateUsd(rate);
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ o.setTaxAmountUsd(taxAmount.multiply(rate));
|
|
|
+ o.setExchangeRateUsd(BigDecimal.ONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
|