Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
f8781f36
Commit
f8781f36
authored
Aug 13, 2019
by
季圣华
Browse files
解决商品库存报表的单价为负数的问题
parent
0a0f3469
Changes
4
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/reports/in_out_stock_report.html
View file @
f8781f36
...
...
@@ -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
'
);
...
...
src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
f8781f36
...
...
@@ -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
...
...
src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
View file @
f8781f36
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
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
f8781f36
...
...
@@ -35,7 +35,10 @@
<result
column=
"MName"
jdbcType=
"VARCHAR"
property=
"MName"
/>
<result
column=
"MModel"
jdbcType=
"VARCHAR"
property=
"MModel"
/>
<result
column=
"MaterialUnit"
jdbcType=
"VARCHAR"
property=
"MaterialUnit"
/>
<result
column=
"UName"
jdbcType=
"VARCHAR"
property=
"UName"
/>
<result
column=
"MColor"
jdbcType=
"VARCHAR"
property=
"MColor"
/>
<result
column=
"PresetPriceOne"
jdbcType=
"DECIMAL"
property=
"presetPriceOne"
/>
<result
column=
"PriceStrategy"
jdbcType=
"VARCHAR"
property=
"priceStrategy"
/>
</resultMap>
<resultMap
id=
"ResultStockWarningCount"
type=
"com.jsh.erp.datasource.vo.DepotItemStockWarningCount"
>
<result
column=
"MaterialName"
jdbcType=
"VARCHAR"
property=
"MaterialName"
/>
...
...
@@ -180,9 +183,11 @@
</select>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultByMaterial"
>
select m.id MId, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor
select m.id MId, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor,
m.PresetPriceOne, m.PriceStrategy, u.UName UName
from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1'
where 1=1
<if
test=
"headIds != null"
>
and di.HeaderId in (${headIds})
...
...
@@ -191,7 +196,7 @@
and di.MaterialId in (${materialIds})
</if>
and ifnull(di.delete_Flag,'0') !='1'
group by m.id,m.Name, m.Model, m.Unit, m.Color
group by m.id,m.Name, m.Model, m.Unit, m.Color
, m.PresetPriceOne, m.PriceStrategy, u.UName
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
</if>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment