feat:整机价格
This commit is contained in:
parent
e04dd91174
commit
788f9a2aa8
@ -42,6 +42,8 @@ import java.math.RoundingMode;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.yem.wm.im.clientdemand.utils.ClientUtils.bringProductModelTons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 外销合同 表单插件
|
* 外销合同 表单插件
|
||||||
*/
|
*/
|
||||||
@ -244,6 +246,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
FunctionalCommon.multiConfig(model, rowIndex);
|
FunctionalCommon.multiConfig(model, rowIndex);
|
||||||
setGiftGiving();
|
setGiftGiving();
|
||||||
bringAssemblyAmount(rowIndex, model, "yem_es_materialinfo");
|
bringAssemblyAmount(rowIndex, model, "yem_es_materialinfo");
|
||||||
|
bringProductModelTons(model, rowIndex);
|
||||||
break;
|
break;
|
||||||
case "yem_isnewagent":
|
case "yem_isnewagent":
|
||||||
setGiftGiving();
|
setGiftGiving();
|
||||||
@ -302,6 +305,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
ClientUtils.addSaAmountTkZJ(model, rowIndex);//整机合同整机非赠品行销售单价(价格条款)
|
ClientUtils.addSaAmountTkZJ(model, rowIndex);//整机合同整机非赠品行销售单价(价格条款)
|
||||||
ClientUtils.countRealCatAmountZJ(model, rowIndex);//整机合同整机非赠品行实际整车金额
|
ClientUtils.countRealCatAmountZJ(model, rowIndex);//整机合同整机非赠品行实际整车金额
|
||||||
ClientUtils.calculateSalesFCAStandardQingdaoUnitAmount(model, rowIndex);//销售FCA标配青岛金额
|
ClientUtils.calculateSalesFCAStandardQingdaoUnitAmount(model, rowIndex);//销售FCA标配青岛金额
|
||||||
|
ClientUtils.calculatePortAmt(model, rowIndex);//计算港杂费
|
||||||
break;
|
break;
|
||||||
case "yem_saamtpriceclause"://销售金额(价格条款)
|
case "yem_saamtpriceclause"://销售金额(价格条款)
|
||||||
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额(价格条款)汇总表头 金额价格条款
|
ClientUtils.totalSaFobAmount(model, "yem_es_materialinfo", "yem_ifgift", "yem_saamtpriceclause", "yem_offeramount");//销售金额(价格条款)汇总表头 金额价格条款
|
||||||
@ -413,6 +417,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
break;
|
break;
|
||||||
case "yem_transportstyle":
|
case "yem_transportstyle":
|
||||||
// setInsuranceFeeRate();
|
// setInsuranceFeeRate();
|
||||||
|
ClientUtils.calcInlandTransportationAmt(model, rowIndex);//计算内陆运费
|
||||||
break;
|
break;
|
||||||
case "yem_clientcountry":
|
case "yem_clientcountry":
|
||||||
case "yem_rapstyle":
|
case "yem_rapstyle":
|
||||||
@ -516,6 +521,15 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
case "yem_fobsubfcaamt":
|
case "yem_fobsubfcaamt":
|
||||||
ClientUtils.calculateSalesFOBUnitPrice(model, rowIndex);//计算销售FOB单价
|
ClientUtils.calculateSalesFOBUnitPrice(model, rowIndex);//计算销售FOB单价
|
||||||
break;
|
break;
|
||||||
|
case "yem_tonsqty":
|
||||||
|
case "yem_port":
|
||||||
|
case "yem_padexpense":
|
||||||
|
ClientUtils.calcInlandTransportationAmt(model, rowIndex);//计算内陆运费
|
||||||
|
ClientUtils.calculatePortAmt(model, rowIndex);//计算港杂费
|
||||||
|
break;
|
||||||
|
case "yem_squareqty":
|
||||||
|
ClientUtils.calculatePortAmt(model, rowIndex);//计算港杂费
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.yem.wm.im.clientdemand.utils;
|
package com.yem.wm.im.clientdemand.utils;
|
||||||
|
|
||||||
import com.sun.tools.doclets.formats.html.resources.standard;
|
|
||||||
import com.yem.tws.common1.BigDecimalUtils;
|
import com.yem.tws.common1.BigDecimalUtils;
|
||||||
import com.yem.wm.utils.DynamicObjectUtil;
|
|
||||||
import com.yem.wm.utils.YEM;
|
import com.yem.wm.utils.YEM;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
@ -12,7 +10,6 @@ import kd.bos.form.IFormView;
|
|||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.bos.servicehelper.QueryServiceHelper;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@ -1905,17 +1902,163 @@ public class ClientUtils {
|
|||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal queryLogisticsCosts(IDataModel model, int idx) {
|
/**
|
||||||
return queryLogisticsCosts(model.getDataEntity(true), idx);
|
* 到【物流价格核算表】中查询到费用项目为【港杂费】的基础资料,根据合同的运输方式+明细.港口+费用信息.港杂费分录.计费方式 匹配 上述基础资料中的 运输方式+港口+计费方式
|
||||||
}
|
*
|
||||||
|
* @param model
|
||||||
private static BigDecimal queryLogisticsCosts(DynamicObject dataEntity, int idx) {
|
* @param idx
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> queryLogistics(IDataModel model, int idx, String expenseItemNo) {
|
||||||
|
DynamicObject dataEntity = model.getDataEntity(true);
|
||||||
|
DynamicObject transportstyle = dataEntity.getDynamicObject("yem_transportstyle");
|
||||||
DynamicObjectCollection materialinfo = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
|
DynamicObjectCollection materialinfo = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
|
||||||
for (DynamicObject d : materialinfo) {
|
DynamicObject d = materialinfo.get(idx);
|
||||||
|
DynamicObjectCollection ports = d.getDynamicObjectCollection("yem_port");
|
||||||
|
if (ports.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
DynamicObject port = ports.get(0).getDynamicObject("fbasedataid");
|
||||||
|
|
||||||
|
long billingMethod = queryBillingMethod(dataEntity, expenseItemNo);
|
||||||
|
|
||||||
|
if (YEM.isNotEmpty(transportstyle) && YEM.isNotEmpty(port) && YEM.isNotEmpty(billingMethod)) {
|
||||||
|
long transportsty = transportstyle.getLong("id");
|
||||||
|
long portId = port.getLong("id");
|
||||||
|
QFilter qFilter = new QFilter("yem_expenseitems.number", "=", expenseItemNo);
|
||||||
|
qFilter.and("yem_entryentity.yem_shippingmethod.id", "=", transportsty);
|
||||||
|
qFilter.and("yem_entryentity.yem_port.id", "=", portId);
|
||||||
|
qFilter.and("yem_entryentity.yem_billingmethod.id", "=", billingMethod);
|
||||||
|
DynamicObject logistics = BusinessDataServiceHelper.loadSingle("yem_materialpriceing", qFilter.toArray());
|
||||||
|
if (YEM.isNotEmpty(logistics)) {
|
||||||
|
DynamicObjectCollection c = logistics.getDynamicObjectCollection("yem_entryentity");
|
||||||
|
for (DynamicObject cd : c) {
|
||||||
|
int i = c.indexOf(cd);
|
||||||
|
long cd_shippingmethod = cd.getLong("yem_shippingmethod.id");//运输方式
|
||||||
|
long cd_port = cd.getLong("yem_port.id");//港口
|
||||||
|
long cd_billingmethod = cd.getLong("yem_billingmethod.id");//计费方式
|
||||||
|
if (cd_shippingmethod == transportsty && portId == cd_port && billingMethod == cd_billingmethod) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("idx", i);
|
||||||
|
map.put("obj", logistics);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据重量物流价格核算表.明细信息.重量核算价格 查询价格
|
||||||
|
* @param entry 重量核算价格
|
||||||
|
* @param weight 重量
|
||||||
|
* @return 单价
|
||||||
|
*/
|
||||||
|
public static BigDecimal queryIntervalPrice(DynamicObjectCollection entry, BigDecimal weight) {
|
||||||
|
for (DynamicObject d : entry) {
|
||||||
|
BigDecimal from = d.getBigDecimal("yem_from");
|
||||||
|
BigDecimal reach = d.getBigDecimal("yem_reach");
|
||||||
|
if (weight.compareTo(from) >= 0 && weight.compareTo(reach) < 0) {
|
||||||
|
return d.getBigDecimal("yem_unitprice");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算港杂费
|
||||||
|
* <p>
|
||||||
|
* ①按方
|
||||||
|
* ②按台
|
||||||
|
* <p>
|
||||||
|
* ①港杂费=单价*方数*数量
|
||||||
|
* ②港杂费=单价*数量
|
||||||
|
*
|
||||||
|
* @param model 外销合同
|
||||||
|
* @param idx 明细行
|
||||||
|
*/
|
||||||
|
public static void calculatePortAmt(IDataModel model, int idx) {
|
||||||
|
BigDecimal qty = (BigDecimal) model.getValue("yem_qty", idx);
|
||||||
|
BigDecimal calc = BigDecimal.ZERO;
|
||||||
|
Map<String, Object> logistics = queryLogistics(model, idx, "FYXM0023.6");
|
||||||
|
if (YEM.isNotEmpty(logistics)) {
|
||||||
|
DynamicObject logisticsObj = (DynamicObject) logistics.get("obj");
|
||||||
|
int entryIdx = (int) logistics.get("idx");
|
||||||
|
DynamicObject entry = logisticsObj.getDynamicObjectCollection("yem_entryentity").get(entryIdx);
|
||||||
|
BigDecimal price = entry.getBigDecimal("yem_price");
|
||||||
|
BigDecimal squareqty = (BigDecimal) model.getValue("yem_squareqty", idx);
|
||||||
|
if (squareqty.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
calc = qty.multiply(price).multiply(squareqty);
|
||||||
|
} else {
|
||||||
|
calc = qty.multiply(price);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.setValue("yem_portamt", calc, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算内陆运费
|
||||||
|
* <p>
|
||||||
|
* ①内陆运输=费用信息.区间单价*吨数
|
||||||
|
*
|
||||||
|
* @param model 外销合同
|
||||||
|
* @param idx 明细行
|
||||||
|
*/
|
||||||
|
public static void calcInlandTransportationAmt(IDataModel model, int idx) {
|
||||||
|
BigDecimal tonsqty = (BigDecimal) model.getValue("yem_tonsqty", idx);
|
||||||
|
BigDecimal price = BigDecimal.ZERO;
|
||||||
|
Map<String, Object> logistics = queryLogistics(model, idx, "FYXM0023.11");//内陆运费
|
||||||
|
if (YEM.isNotEmpty(logistics)) {
|
||||||
|
DynamicObject logisticsObj = (DynamicObject) logistics.get("obj");
|
||||||
|
int entryIdx = (int) logistics.get("idx");
|
||||||
|
DynamicObject entryObj = logisticsObj.getDynamicObjectCollection("yem_entryentity").get(entryIdx);
|
||||||
|
DynamicObjectCollection subC = entryObj.getDynamicObjectCollection("yem_subentryentity");
|
||||||
|
price = queryIntervalPrice(subC, tonsqty);
|
||||||
|
}
|
||||||
|
BigDecimal calc = price.multiply(tonsqty);
|
||||||
|
model.setValue("yem_inlandfreight", calc, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选择基础机型、携带基础机型中产品机型的吨数
|
||||||
|
* @param model 外销合同
|
||||||
|
* @param idx 明细行
|
||||||
|
*/
|
||||||
|
public static void bringProductModelTons(IDataModel model, int idx) {
|
||||||
|
DynamicObject productmodel = (DynamicObject) model.getValue("yem_productmodel", idx);
|
||||||
|
if (YEM.isNotEmpty(productmodel)) {
|
||||||
|
DynamicObject products = productmodel.getDynamicObject("yem_products");
|
||||||
|
if (YEM.isNotEmpty(products)) {
|
||||||
|
products = BusinessDataServiceHelper.loadSingle(products.getPkValue(), products.getDynamicObjectType().getName());
|
||||||
|
BigDecimal tons = products.getBigDecimal("yem_tons");
|
||||||
|
model.setValue("yem_tonsqty", tons, idx);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
model.setValue("yem_tonsqty", BigDecimal.ZERO, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询费用项目对应的计费方式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Long queryBillingMethod(DynamicObject dataEntity, String expenseItemNo) {
|
||||||
|
DynamicObjectCollection costinfor = dataEntity.getDynamicObjectCollection("yem_costinfor");
|
||||||
|
for (DynamicObject d : costinfor) {
|
||||||
|
DynamicObject padexpense = d.getDynamicObject("yem_padexpense");
|
||||||
|
if (YEM.isNotEmpty(padexpense)) {
|
||||||
|
String number = padexpense.getString("number");
|
||||||
|
if (expenseItemNo.equals(number)) {
|
||||||
|
DynamicObject chargemode = d.getDynamicObject("yem_bd_chargemode");
|
||||||
|
if (YEM.isNotEmpty(chargemode)) {
|
||||||
|
return chargemode.getLong("id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user