diff --git a/erp_web/pages/reports/in_out_stock_report.html b/erp_web/pages/reports/in_out_stock_report.html
index 1051655d..8ac4ba3d 100644
--- a/erp_web/pages/reports/in_out_stock_report.html
+++ b/erp_web/pages/reports/in_out_stock_report.html
@@ -218,22 +218,13 @@
{title: '名称', field: 'MaterialName', width: 60},
{title: '型号', field: 'MaterialModel', width: 80},
{title: '扩展信息', field: 'MaterialOther', width: 150},
- {title: '单位', field: 'MaterialUnit', width: 80},
- {
- title: '单价', field: 'UnitPrice', width: 60, formatter: function (value, row, index) {
- return value.toFixed(2);
- }
- },
+ {title: '单位', field: 'unitName', width: 80},
+ {title: '单价', field: 'UnitPrice', width: 60},
{title: '上月结存数量', field: 'prevSum', width: 80},
{title: '入库数量', field: 'InSum', width: 60},
{title: '出库数量', field: 'OutSum', width: 60},
{title: '本月结存数量', field: 'thisSum', width: 80},
- {
- title: '结存金额', field: 'thisAllPrice', width: 60,
- formatter: function (value, row, index) {
- return value.toFixed(2);
- }
- }
+ {title: '结存金额', field: 'thisAllPrice', width: 60}
]],
onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
diff --git a/src/main/java/com/jsh/erp/controller/DepotItemController.java b/src/main/java/com/jsh/erp/controller/DepotItemController.java
index a8108447..1c2e083c 100644
--- a/src/main/java/com/jsh/erp/controller/DepotItemController.java
+++ b/src/main/java/com/jsh/erp/controller/DepotItemController.java
@@ -336,31 +336,20 @@ public class DepotItemController {
BigDecimal prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true).subtract(sumNumber("出库", pid, diEx.getMId(), monthTime, true));
BigDecimal InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false);
BigDecimal OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false);
- BigDecimal prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true).subtract(sumPrice("出库", pid, diEx.getMId(), monthTime, true));
- BigDecimal InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
- BigDecimal OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
item.put("MaterialName", diEx.getMName());
item.put("MaterialModel", diEx.getMModel());
//扩展信息
String materialOther = getOtherInfo(mpArr, diEx);
item.put("MaterialOther", materialOther);
item.put("MaterialColor", diEx.getMColor());
- item.put("MaterialUnit", diEx.getMaterialUnit());
- BigDecimal unitPrice = BigDecimal.ZERO;
- if ((prevSum .add(InSum).subtract(OutSum)).compareTo(BigDecimal.ZERO)!= 0) {
- unitPrice = (prevPrice.add(InPrice).subtract(OutPrice)).divide(prevSum.add(InSum).subtract(OutSum),2, BigDecimal.ROUND_HALF_UP);
- /**
- * 2019-01-15通过除法算出金额后,保留两位小数
- * */
- DecimalFormat df = new DecimalFormat("#.00");
- unitPrice= new BigDecimal(df.format(unitPrice));
- }
- item.put("UnitPrice", unitPrice);
+ item.put("unitName", getUName(diEx.getMaterialUnit(), diEx.getUName()));
+ item.put("UnitPrice", getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy()));
item.put("prevSum", prevSum);
item.put("InSum", InSum);
item.put("OutSum", OutSum);
- item.put("thisSum", prevSum.add(InSum).subtract(OutSum));
- item.put("thisAllPrice", prevPrice.add(InPrice).subtract(OutPrice));
+ BigDecimal thisSum = prevSum.add(InSum).subtract(OutSum);
+ item.put("thisSum", thisSum);
+ item.put("thisAllPrice", thisSum.multiply(getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy())));
dataArray.add(item);
}
}
@@ -690,6 +679,47 @@ public class DepotItemController {
}
return sumPrice;
}
+
+ /**
+ * 获取单位
+ * @param materialUnit
+ * @param uName
+ * @return
+ */
+ public String getUName(String materialUnit, String uName) {
+ String unitName = null;
+ if(!StringUtil.isEmpty(materialUnit)) {
+ unitName = materialUnit;
+ } else if(!StringUtil.isEmpty(uName)) {
+ unitName = uName.substring(0,uName.indexOf(","));
+ }
+ return unitName;
+ }
+
+ /**
+ * 获取单价
+ * @param presetPriceOne
+ * @param priceStrategy
+ * @return
+ */
+ public BigDecimal getUnitPrice(BigDecimal presetPriceOne, String priceStrategy) {
+ BigDecimal unitPrice = BigDecimal.ZERO;
+ if(presetPriceOne != null) {
+ DecimalFormat df = new DecimalFormat("#.00");
+ unitPrice = new BigDecimal(df.format(presetPriceOne));
+ } else {
+ JSONArray priceArr = JSONArray.parseArray(priceStrategy);
+ if(priceArr!=null && priceArr.get(0)!=null) {
+ JSONObject priceObj = JSONObject.parseObject(priceArr.get(0).toString());
+ BigDecimal basicPresetPriceOne = priceObj.getJSONObject("basic").getBigDecimal("PresetPriceOne");
+ if(basicPresetPriceOne!=null) {
+ unitPrice = basicPresetPriceOne;
+ }
+ }
+ }
+ return unitPrice;
+ }
+
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
diff --git a/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java b/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
index 60e49fff..36710de2 100644
--- a/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
+++ b/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
@@ -1,5 +1,7 @@
package com.jsh.erp.datasource.entities;
+import java.math.BigDecimal;
+
public class DepotItemVo4WithInfoEx extends DepotItem{
private Long MId;
@@ -30,6 +32,10 @@ public class DepotItemVo4WithInfoEx extends DepotItem{
private String UName;
+ private BigDecimal presetPriceOne;
+
+ private String priceStrategy;
+
public Long getMId() {
return MId;
}
@@ -141,4 +147,20 @@ public class DepotItemVo4WithInfoEx extends DepotItem{
public void setUName(String UName) {
this.UName = UName;
}
+
+ public BigDecimal getPresetPriceOne() {
+ return presetPriceOne;
+ }
+
+ public void setPresetPriceOne(BigDecimal presetPriceOne) {
+ this.presetPriceOne = presetPriceOne;
+ }
+
+ public String getPriceStrategy() {
+ return priceStrategy;
+ }
+
+ public void setPriceStrategy(String priceStrategy) {
+ this.priceStrategy = priceStrategy;
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/mapper_xml/DepotItemMapperEx.xml b/src/main/resources/mapper_xml/DepotItemMapperEx.xml
index 4418acba..4b5fb633 100644
--- a/src/main/resources/mapper_xml/DepotItemMapperEx.xml
+++ b/src/main/resources/mapper_xml/DepotItemMapperEx.xml
@@ -35,7 +35,10 @@
+
+
+
@@ -180,9 +183,11 @@