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
f89d8f2a
Commit
f89d8f2a
authored
Nov 26, 2021
by
季圣华
Browse files
优化进销存统计接口
parent
3b3805ee
Changes
1
Show whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
f89d8f2a
...
...
@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.*;
import
com.jsh.erp.datasource.vo.DepotItemStockWarningCount
;
import
com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.depot.DepotService
;
import
com.jsh.erp.service.materialExtend.MaterialExtendService
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.material.MaterialService
;
...
...
@@ -53,6 +54,9 @@ public class DepotItemController {
@Resource
private
UnitService
unitService
;
@Resource
private
DepotService
depotService
;
@Resource
private
RedisService
redisService
;
...
...
@@ -277,7 +281,7 @@ public class DepotItemController {
* 查找所有的明细
* @param currentPage
* @param pageSize
* @param depotId
* @param depotId
s
* @param monthTime
* @param materialParam
* @param mpList
...
...
@@ -289,16 +293,27 @@ public class DepotItemController {
@ApiOperation
(
value
=
"查找所有的明细"
)
public
BaseResponseInfo
findByAll
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
value
=
"depotId"
,
required
=
false
)
Lo
ng
depotId
,
@RequestParam
(
value
=
"depotId
s
"
,
required
=
false
)
Stri
ng
depotId
s
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"materialParam"
)
String
materialParam
,
@RequestParam
(
"mpList"
)
String
mpList
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
String
timeA
=
Tools
.
firstDayOfMonth
(
monthTime
)
+
BusinessConstants
.
DAY_FIRST_TIME
;
String
timeB
=
Tools
.
lastDayOfMonth
(
monthTime
)
+
BusinessConstants
.
DAY_LAST_TIME
;
try
{
List
<
Long
>
depotList
=
new
ArrayList
<>();
if
(
StringUtil
.
isNotEmpty
(
depotIds
))
{
depotList
=
StringUtil
.
strToLongList
(
depotIds
);
}
else
{
//未选择仓库时默认为当前用户有权限的仓库
JSONArray
depotArr
=
depotService
.
findDepotByCurrentUser
();
for
(
Object
obj:
depotArr
)
{
JSONObject
object
=
JSONObject
.
parseObject
(
obj
.
toString
());
depotList
.
add
(
object
.
getLong
(
"id"
));
}
}
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
StringUtil
.
toNull
(
materialParam
),
timeB
,(
currentPage
-
1
)*
pageSize
,
pageSize
);
String
[]
mpArr
=
mpList
.
split
(
","
);
...
...
@@ -324,11 +339,23 @@ public class DepotItemController {
item
.
put
(
"materialOther"
,
materialOther
);
item
.
put
(
"materialColor"
,
diEx
.
getMColor
());
item
.
put
(
"unitName"
,
diEx
.
getMaterialUnit
());
item
.
put
(
"prevSum"
,
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
timeA
));
item
.
put
(
"inSum"
,
depotItemService
.
getInNumByParam
(
depotId
,
mId
,
timeA
,
timeB
));
item
.
put
(
"outSum"
,
depotItemService
.
getOutNumByParam
(
depotId
,
mId
,
timeA
,
timeB
));
BigDecimal
thisSum
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
timeB
);
BigDecimal
prevSum
=
BigDecimal
.
ZERO
;
BigDecimal
inSum
=
BigDecimal
.
ZERO
;
BigDecimal
outSum
=
BigDecimal
.
ZERO
;
BigDecimal
thisSum
=
BigDecimal
.
ZERO
;
for
(
Long
depotId:
depotList
)
{
BigDecimal
prevSumStock
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
timeA
);
BigDecimal
inSumStock
=
depotItemService
.
getInNumByParam
(
depotId
,
mId
,
timeA
,
timeB
);
BigDecimal
outSumStock
=
depotItemService
.
getOutNumByParam
(
depotId
,
mId
,
timeA
,
timeB
);
BigDecimal
thisSumStock
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
timeB
);
prevSum
=
prevSum
.
add
(
prevSumStock
);
inSum
=
inSum
.
add
(
inSumStock
);
outSum
=
outSum
.
add
(
outSumStock
);
thisSum
=
thisSum
.
add
(
thisSumStock
);
}
item
.
put
(
"prevSum"
,
prevSum
);
item
.
put
(
"inSum"
,
inSum
);
item
.
put
(
"outSum"
,
outSum
);
item
.
put
(
"thisSum"
,
thisSum
);
for
(
MaterialExtend
me:
meList
)
{
if
(
me
.
getMaterialId
().
longValue
()
==
diEx
.
getMId
().
longValue
())
{
...
...
@@ -354,7 +381,7 @@ public class DepotItemController {
/**
* 统计总计金额
* @param depotId
* @param depotId
s
* @param monthTime
* @param materialParam
* @param request
...
...
@@ -362,21 +389,36 @@ public class DepotItemController {
*/
@GetMapping
(
value
=
"/totalCountMoney"
)
@ApiOperation
(
value
=
"统计总计金额"
)
public
BaseResponseInfo
totalCountMoney
(
@RequestParam
(
value
=
"depotId"
,
required
=
false
)
Lo
ng
depotId
,
public
BaseResponseInfo
totalCountMoney
(
@RequestParam
(
value
=
"depotId
s
"
,
required
=
false
)
Stri
ng
depotId
s
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"materialParam"
)
String
materialParam
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
endTime
=
Tools
.
lastDayOfMonth
(
monthTime
)
+
BusinessConstants
.
DAY_LAST_TIME
;
try
{
String
endTime
=
Tools
.
lastDayOfMonth
(
monthTime
)
+
BusinessConstants
.
DAY_LAST_TIME
;
List
<
Long
>
depotList
=
new
ArrayList
<>();
if
(
StringUtil
.
isNotEmpty
(
depotIds
))
{
depotList
=
StringUtil
.
strToLongList
(
depotIds
);
}
else
{
//未选择仓库时默认为当前用户有权限的仓库
JSONArray
depotArr
=
depotService
.
findDepotByCurrentUser
();
for
(
Object
obj:
depotArr
)
{
JSONObject
object
=
JSONObject
.
parseObject
(
obj
.
toString
());
depotList
.
add
(
object
.
getLong
(
"id"
));
}
}
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
StringUtil
.
toNull
(
materialParam
),
endTime
,
null
,
null
);
BigDecimal
thisAllPrice
=
BigDecimal
.
ZERO
;
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
Long
mId
=
diEx
.
getMId
();
BigDecimal
thisSum
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
endTime
);
BigDecimal
thisSum
=
BigDecimal
.
ZERO
;
for
(
Long
depotId:
depotList
)
{
BigDecimal
thisSumStock
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
endTime
);
thisSum
=
thisSum
.
add
(
thisSumStock
);
}
BigDecimal
unitPrice
=
diEx
.
getPurchaseDecimal
();
if
(
unitPrice
==
null
)
{
unitPrice
=
BigDecimal
.
ZERO
;
...
...
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