Merge branch 'dev-comp-price' into test
# Conflicts: # src/main/java/com/yem/wm/im/clientdemand/utils/ClientUtils.java
This commit is contained in:
commit
3d344212fc
@ -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();
|
||||||
@ -284,6 +287,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
countCalculationAmt();
|
countCalculationAmt();
|
||||||
ClientUtils.changeRate(model, "yem_es_materialinfo");
|
ClientUtils.changeRate(model, "yem_es_materialinfo");
|
||||||
ClientUtils.clearSalePrice(this.getModel());
|
ClientUtils.clearSalePrice(this.getModel());
|
||||||
|
ClientUtils.calculateSalesFCAStandardQingdaoUnitPrice(model, rowIndex);//销售FCA标配青岛单价
|
||||||
break;
|
break;
|
||||||
case "yem_qty":
|
case "yem_qty":
|
||||||
setRandomDataTools();
|
setRandomDataTools();
|
||||||
@ -300,6 +304,8 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
syncDeductionGifts(model, rowIndex);
|
syncDeductionGifts(model, rowIndex);
|
||||||
ClientUtils.addSaAmountTkZJ(model, rowIndex);//整机合同整机非赠品行销售单价(价格条款)
|
ClientUtils.addSaAmountTkZJ(model, rowIndex);//整机合同整机非赠品行销售单价(价格条款)
|
||||||
ClientUtils.countRealCatAmountZJ(model, rowIndex);//整机合同整机非赠品行实际整车金额
|
ClientUtils.countRealCatAmountZJ(model, rowIndex);//整机合同整机非赠品行实际整车金额
|
||||||
|
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");//销售金额(价格条款)汇总表头 金额价格条款
|
||||||
@ -310,6 +316,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
case "yem_standardprice"://标配FOB(青岛价)
|
case "yem_standardprice"://标配FOB(青岛价)
|
||||||
ClientUtils.fobPriceAdd(model, materialInfo);//FOB单价
|
ClientUtils.fobPriceAdd(model, materialInfo);//FOB单价
|
||||||
ClientUtils.countFobAmtSale(model, rowIndex);//销售FOB标配青岛单价
|
ClientUtils.countFobAmtSale(model, rowIndex);//销售FOB标配青岛单价
|
||||||
|
ClientUtils.calculateSalesFCAStandardQingdaoUnitPrice(model, rowIndex);//销售FCA标配青岛单价
|
||||||
break;
|
break;
|
||||||
case "yem_truecarpriceba":
|
case "yem_truecarpriceba":
|
||||||
ClientUtils.countRealCatAmountRMB(model, rowIndex);
|
ClientUtils.countRealCatAmountRMB(model, rowIndex);
|
||||||
@ -357,6 +364,7 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
break;
|
break;
|
||||||
case "yem_unitsetamount"://单台加价金额
|
case "yem_unitsetamount"://单台加价金额
|
||||||
ClientUtils.addSaPrice(model, materialInfo);//销售FOB单价(结算币别)
|
ClientUtils.addSaPrice(model, materialInfo);//销售FOB单价(结算币别)
|
||||||
|
ClientUtils.calculateSalesFOBUnitPrice(model, -1);//计算销售FOB单价
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "yem_sapricepriceclause"://销售单价(价格条款)结算币别
|
case "yem_sapricepriceclause"://销售单价(价格条款)结算币别
|
||||||
@ -409,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":
|
||||||
@ -507,6 +516,22 @@ public class SalesOrderZJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
|||||||
case "yem_interestdays":
|
case "yem_interestdays":
|
||||||
ClientUtils.calculateBankInterestCharges(-1, model);//银行利息费
|
ClientUtils.calculateBankInterestCharges(-1, model);//银行利息费
|
||||||
break;
|
break;
|
||||||
|
case "yem_sastandardfcaprice":
|
||||||
|
ClientUtils.calculateSalesFCAStandardQingdaoUnitAmount(model, rowIndex);//销售FCA标配青岛金额
|
||||||
|
ClientUtils.calculateSalesFOBUnitPrice(model, rowIndex);//计算销售FOB单价
|
||||||
|
break;
|
||||||
|
case "yem_fobsubfcaamt":
|
||||||
|
ClientUtils.calculateSalesFOBUnitPrice(model, rowIndex);//计算销售FOB单价
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,19 +192,25 @@ public class ClientUtils {
|
|||||||
* 获取标准价中 计算fob价(整机分录行)
|
* 获取标准价中 计算fob价(整机分录行)
|
||||||
*/
|
*/
|
||||||
public static void fobPriceAdd(DynamicObjectCollection dy, BigDecimal yem_exrate, int rowInfo, DynamicObject dynamicObject, IDataModel models) {
|
public static void fobPriceAdd(DynamicObjectCollection dy, BigDecimal yem_exrate, int rowInfo, DynamicObject dynamicObject, IDataModel models) {
|
||||||
|
//计算多功能配置页签 标准销售价价计算总额
|
||||||
|
DynamicObject currEntry = dy.get(rowInfo);
|
||||||
//fob单价计算
|
//fob单价计算
|
||||||
DynamicObject dataEntity = models.getDataEntity(true);
|
DynamicObject dataEntity = models.getDataEntity(true);
|
||||||
String yembilltype = dataEntity.getString("yem_billtype.number");
|
String yembilltype = dataEntity.getString("yem_billtype.number");
|
||||||
BigDecimal pricefob = BigDecimal.ZERO;
|
BigDecimal pricefob = BigDecimal.ZERO;
|
||||||
|
if (!isFCAPriceItem(currEntry)) {
|
||||||
if ("yem_im_inclientdeman_zj".equals(yembilltype) || "yem_es_salesorder_nmzj".equals(yembilltype) || "yem_es_xsalesorder_nmzj".equals(yembilltype)) {
|
if ("yem_im_inclientdeman_zj".equals(yembilltype) || "yem_es_salesorder_nmzj".equals(yembilltype) || "yem_es_xsalesorder_nmzj".equals(yembilltype)) {
|
||||||
pricefob = dynamicObject.getBigDecimal("yem_foreigntradeprice");
|
pricefob = dynamicObject.getBigDecimal("yem_foreigntradeprice");
|
||||||
}
|
}
|
||||||
if ("yem_im_clientdeman_zj".equals(yembilltype) || "yem_es_salesorder_ZJ".equals(yembilltype) || "yem_es_xsalesorder_zj".equals(yembilltype)) {
|
if ("yem_im_clientdeman_zj".equals(yembilltype) || "yem_es_salesorder_ZJ".equals(yembilltype) || "yem_es_xsalesorder_zj".equals(yembilltype)) {
|
||||||
pricefob = dynamicObject.getBigDecimal("yem_pricefob");
|
pricefob = dynamicObject.getBigDecimal("yem_pricefob");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pricefob = dynamicObject.getBigDecimal("yem_fcafactoryprice");//FCA工厂价
|
||||||
|
}
|
||||||
|
BigDecimal fobsubfcaamt = dynamicObject.getBigDecimal("yem_fobsubfcaamt");//FOB与FCA费用差额
|
||||||
|
models.setValue("yem_fobsubfcaamt", fobsubfcaamt, rowInfo);//FOB与FCA费用差额
|
||||||
|
|
||||||
//计算多功能配置页签 标准销售价价计算总额
|
|
||||||
DynamicObject currEntry = dy.get(rowInfo);
|
|
||||||
if (currEntry != null) {
|
if (currEntry != null) {
|
||||||
BigDecimal fobPrice = BigDecimal.ZERO;
|
BigDecimal fobPrice = BigDecimal.ZERO;
|
||||||
DynamicObjectCollection dc = currEntry.getDynamicObjectCollection("yem_multiconfig");
|
DynamicObjectCollection dc = currEntry.getDynamicObjectCollection("yem_multiconfig");
|
||||||
@ -377,11 +383,14 @@ public class ClientUtils {
|
|||||||
models.setValue("yem_exwrmbprice", dm.getBigDecimal("yem_standsalesprice"), rowInfo);
|
models.setValue("yem_exwrmbprice", dm.getBigDecimal("yem_standsalesprice"), rowInfo);
|
||||||
}
|
}
|
||||||
if (yem_exrate.compareTo(BigDecimal.ZERO) != 0) {
|
if (yem_exrate.compareTo(BigDecimal.ZERO) != 0) {
|
||||||
|
DynamicObjectCollection coll = getTypeColl(models);
|
||||||
|
if (!isFCAPriceItem(coll, rowInfo)) {
|
||||||
models.setValue("yem_safobprice", roundUpNew(dm.getBigDecimal("yem_standsalesprice").divide(yem_exrate, RoundingMode.HALF_UP)), rowInfo);
|
models.setValue("yem_safobprice", roundUpNew(dm.getBigDecimal("yem_standsalesprice").divide(yem_exrate, RoundingMode.HALF_UP)), rowInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
info.append("明细信息 第" + (rowInfo + 1) + "行未获取到标准价,请及时询价!\r\n");
|
info.append("明细信息 第" + (rowInfo + 1) + "行未获取到标准价,请及时询价!\r\n");
|
||||||
}
|
}
|
||||||
@ -469,8 +478,11 @@ public class ClientUtils {
|
|||||||
// }else {
|
// }else {
|
||||||
// }
|
// }
|
||||||
if ("Z".equals(businesssort)) {
|
if ("Z".equals(businesssort)) {
|
||||||
|
DynamicObjectCollection coll = getTypeColl(model);
|
||||||
|
if (!isFCAPriceItem(coll, rowNow)) {
|
||||||
model.setValue("yem_safobprice", fobPrice.add(sastandardprice), rowNow);
|
model.setValue("yem_safobprice", fobPrice.add(sastandardprice), rowNow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rowNow++;
|
rowNow++;
|
||||||
@ -1793,6 +1805,297 @@ public class ClientUtils {
|
|||||||
model.endInit();
|
model.endInit();
|
||||||
view.updateView("yem_frontrateentry", idx);
|
view.updateView("yem_frontrateentry", idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFCAPriceItem(DynamicObjectCollection collection, int idx) {
|
||||||
|
String propKey = "yem_priceitemsp";
|
||||||
|
DynamicObject d = collection.get(idx);
|
||||||
|
if (d.containsProperty(propKey)) {
|
||||||
|
DynamicObject priceItem = d.getDynamicObject(propKey);
|
||||||
|
if (YEM.isNotEmpty(priceItem)) {
|
||||||
|
String name = priceItem.getString("name");
|
||||||
|
return "FCA".equals(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFCAPriceItem(DynamicObject d) {
|
||||||
|
DynamicObjectCollection collection = new DynamicObjectCollection();
|
||||||
|
collection.add(d);
|
||||||
|
return isFCAPriceItem(collection, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFCAPriceItem(IDataModel model, int idx) {
|
||||||
|
DynamicObject priceitemsp = (DynamicObject) model.getValue("yem_priceitemsp", idx);
|
||||||
|
if (YEM.isNotEmpty(priceitemsp)) {
|
||||||
|
String name = priceitemsp.getString("name");
|
||||||
|
return "FCA".equals(name);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算销售FCA标配青岛单价
|
||||||
|
*
|
||||||
|
* 销售FCA标配青岛单价 = 标配FOB(青岛)价 / 汇率,向上取整,保留整数,业务存在手动调整
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @param idx
|
||||||
|
*/
|
||||||
|
public static void calculateSalesFCAStandardQingdaoUnitPrice(IDataModel model, int idx) {
|
||||||
|
if (isFCAPriceItem(model, idx)) {
|
||||||
|
BigDecimal standardprice = (BigDecimal) model.getValue("yem_standardprice", idx);//标配FOB(青岛)价
|
||||||
|
BigDecimal exrate = (BigDecimal) model.getValue("yem_exrate");//汇率
|
||||||
|
BigDecimal calc = BigDecimalUtils.div(standardprice, exrate, 10);
|
||||||
|
calc = calc.setScale(0, RoundingMode.UP);
|
||||||
|
model.setValue("yem_sastandardfcaprice", calc, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销售FCA标配青岛金额
|
||||||
|
*
|
||||||
|
* 销售FCA标配青岛金额=销售FCA标配青岛单价*数量
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @param idx
|
||||||
|
*/
|
||||||
|
public static void calculateSalesFCAStandardQingdaoUnitAmount(IDataModel model, int idx) {
|
||||||
|
BigDecimal sastandardfcaprice = (BigDecimal) model.getValue("yem_sastandardfcaprice", idx);
|
||||||
|
BigDecimal qty = (BigDecimal) model.getValue("yem_qty", idx);
|
||||||
|
BigDecimal calc = sastandardfcaprice.multiply(qty);
|
||||||
|
model.setValue("yem_sastandardfcaamt", calc, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算销售FOB单价
|
||||||
|
*
|
||||||
|
* 销售FOB单价=商品明细对应多功能配置中 单台加价金额(结算币别)合计值 + 销售FCA标配青岛单价+FOB与FCA费用差额
|
||||||
|
*/
|
||||||
|
public static void calculateSalesFOBUnitPrice(IDataModel model, int idx) {
|
||||||
|
if (!isFCAPriceItem(model, idx)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicObject dataEntity = model.getDataEntity(true);
|
||||||
|
DynamicObjectCollection c = dataEntity.getDynamicObjectCollection("yem_es_materialinfo");
|
||||||
|
|
||||||
|
if (idx != -1) {
|
||||||
|
DynamicObject d = c.get(idx);
|
||||||
|
DynamicObjectCollection subC = d.getDynamicObjectCollection("yem_multiconfig");
|
||||||
|
BigDecimal sumAmt = BigDecimal.ZERO;
|
||||||
|
for (DynamicObject sub : subC) {
|
||||||
|
BigDecimal decimal = sub.getBigDecimal("yem_unitsetamount");
|
||||||
|
sumAmt = sumAmt.add(decimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal sastandardfcaprice = (BigDecimal) model.getValue("yem_sastandardfcaprice", idx);//销售FCA标配青岛单价
|
||||||
|
BigDecimal fobsubfcaamt = (BigDecimal) model.getValue("yem_fobsubfcaamt", idx);//FOB与FCA费用差额
|
||||||
|
BigDecimal calc = sumAmt.add(sastandardfcaprice).add(fobsubfcaamt);
|
||||||
|
model.setValue("yem_safobprice", calc, idx);
|
||||||
|
} else {
|
||||||
|
int rowCount = model.getEntryRowCount("yem_es_materialinfo");
|
||||||
|
for (int i = 0; i < rowCount; i++) {
|
||||||
|
DynamicObject d = c.get(i);
|
||||||
|
DynamicObjectCollection subC = d.getDynamicObjectCollection("yem_multiconfig");
|
||||||
|
BigDecimal sumAmt = BigDecimal.ZERO;
|
||||||
|
for (DynamicObject sub : subC) {
|
||||||
|
BigDecimal decimal = sub.getBigDecimal("yem_unitsetamount");
|
||||||
|
sumAmt = sumAmt.add(decimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal sastandardfcaprice = (BigDecimal) model.getValue("yem_sastandardfcaprice", i);//销售FCA标配青岛单价
|
||||||
|
BigDecimal fobsubfcaamt = (BigDecimal) model.getValue("yem_fobsubfcaamt", i);//FOB与FCA费用差额
|
||||||
|
BigDecimal calc = sumAmt.add(sastandardfcaprice).add(fobsubfcaamt);
|
||||||
|
model.setValue("yem_safobprice", calc, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询物流价格核算表
|
||||||
|
*
|
||||||
|
* @param transportStyle 运输方式
|
||||||
|
* @param port 港口
|
||||||
|
* @param billingMethod 计费方式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BigDecimal queryLogisticsCosts(long transportStyle, long port, long billingMethod) {
|
||||||
|
QFilter qFilter = new QFilter("status", "=", "C");
|
||||||
|
qFilter.and("yem_entryentity.yem_shippingmethod.id", "=", transportStyle);
|
||||||
|
qFilter.and("yem_entryentity.yem_port.id", "=", port);
|
||||||
|
qFilter.and("yem_entryentity.yem_billingmethod.id", "=", billingMethod);
|
||||||
|
DynamicObject single = BusinessDataServiceHelper.loadSingle("yem_materialpriceing", qFilter.toArray());
|
||||||
|
DynamicObjectCollection entry = single.getDynamicObjectCollection("yem_entryentity");
|
||||||
|
for (DynamicObject d : entry) {
|
||||||
|
long e_transportStyle = d.getLong("yem_shippingmethod");
|
||||||
|
long e_port = d.getLong("yem_port");
|
||||||
|
long e_billingMethod = d.getLong("yem_billingmethod");
|
||||||
|
|
||||||
|
if (e_transportStyle == transportStyle && e_port == port && e_billingMethod == billingMethod) {
|
||||||
|
return d.getBigDecimal("yem_price");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 到【物流价格核算表】中查询到费用项目为【港杂费】的基础资料,根据合同的运输方式+明细.港口+费用信息.港杂费分录.计费方式 匹配 上述基础资料中的 运输方式+港口+计费方式
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @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");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据重量物流价格核算表.明细信息.重量核算价格 查询价格
|
||||||
|
* @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