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
d90771c7
Commit
d90771c7
authored
May 04, 2022
by
神话
Browse files
优化采购统计和销售统计报表的查询条件
parent
dd07b463
Changes
4
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
d90771c7
...
...
@@ -265,7 +265,7 @@ public class DepotItemController {
}
/**
*
查找所有的明细
*
进销存统计
* @param currentPage
* @param pageSize
* @param depotIds
...
...
@@ -351,7 +351,7 @@ public class DepotItemController {
}
/**
* 统计总计金额
*
进销存
统计总计金额
* @param depotIds
* @param monthTime
* @param materialParam
...
...
@@ -421,7 +421,8 @@ public class DepotItemController {
* 进货统计
* @param currentPage
* @param pageSize
* @param monthTime
* @param beginTime
* @param endTime
* @param materialParam
* @param mpList
* @param request
...
...
@@ -431,28 +432,30 @@ public class DepotItemController {
@ApiOperation
(
value
=
"进货统计"
)
public
BaseResponseInfo
buyIn
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"beginTime"
)
String
beginTime
,
@RequestParam
(
"endTime"
)
String
endTime
,
@RequestParam
(
"materialParam"
)
String
materialParam
,
@RequestParam
(
"mpList"
)
String
mpList
,
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
;
beginTime
=
Tools
.
parseDayToTime
(
beginTime
,
BusinessConstants
.
DAY_FIRST_TIME
);
endTime
=
Tools
.
parseDayToTime
(
endTime
,
BusinessConstants
.
DAY_LAST_TIME
);
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
StringUtil
.
toNull
(
materialParam
),
endTime
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
getListWithBugOrSale
(
StringUtil
.
toNull
(
materialParam
),
"buy"
,
beginTime
,
endTime
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
String
[]
mpArr
=
mpList
.
split
(
","
);
int
total
=
depotItemService
.
findByAll
Count
(
StringUtil
.
toNull
(
materialParam
),
endTime
);
int
total
=
depotItemService
.
getListWithBugOrSale
Count
(
StringUtil
.
toNull
(
materialParam
),
"buy"
,
beginTime
,
endTime
);
map
.
put
(
"total"
,
total
);
//存放数据json数组
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
BigDecimal
InSum
=
depotItemService
.
buyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
month
Time
,
"number"
);
BigDecimal
OutSum
=
depotItemService
.
buyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
month
Time
,
"number"
);
BigDecimal
InSumPrice
=
depotItemService
.
buyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
month
Time
,
"price"
);
BigDecimal
OutSumPrice
=
depotItemService
.
buyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
month
Time
,
"price"
);
BigDecimal
InSum
=
depotItemService
.
buyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"number"
);
BigDecimal
OutSum
=
depotItemService
.
buyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"number"
);
BigDecimal
InSumPrice
=
depotItemService
.
buyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"price"
);
BigDecimal
OutSumPrice
=
depotItemService
.
buyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"price"
);
BigDecimal
InOutSumPrice
=
InSumPrice
.
subtract
(
OutSumPrice
);
item
.
put
(
"barCode"
,
diEx
.
getBarCode
());
item
.
put
(
"materialName"
,
diEx
.
getMName
());
...
...
@@ -487,7 +490,8 @@ public class DepotItemController {
* 销售统计
* @param currentPage
* @param pageSize
* @param monthTime
* @param beginTime
* @param endTime
* @param materialParam
* @param mpList
* @param request
...
...
@@ -497,32 +501,34 @@ public class DepotItemController {
@ApiOperation
(
value
=
"销售统计"
)
public
BaseResponseInfo
saleOut
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"beginTime"
)
String
beginTime
,
@RequestParam
(
"endTime"
)
String
endTime
,
@RequestParam
(
"materialParam"
)
String
materialParam
,
@RequestParam
(
"mpList"
)
String
mpList
,
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
;
beginTime
=
Tools
.
parseDayToTime
(
beginTime
,
BusinessConstants
.
DAY_FIRST_TIME
);
endTime
=
Tools
.
parseDayToTime
(
endTime
,
BusinessConstants
.
DAY_LAST_TIME
);
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
StringUtil
.
toNull
(
materialParam
),
endTime
,(
currentPage
-
1
)*
pageSize
,
pageSize
);
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
getListWithBugOrSale
(
StringUtil
.
toNull
(
materialParam
),
"sale"
,
beginTime
,
endTime
,(
currentPage
-
1
)*
pageSize
,
pageSize
);
String
[]
mpArr
=
mpList
.
split
(
","
);
int
total
=
depotItemService
.
findByAll
Count
(
StringUtil
.
toNull
(
materialParam
),
endTime
);
int
total
=
depotItemService
.
getListWithBugOrSale
Count
(
StringUtil
.
toNull
(
materialParam
),
"sale"
,
beginTime
,
endTime
);
map
.
put
(
"total"
,
total
);
//存放数据json数组
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
BigDecimal
OutSumRetail
=
depotItemService
.
buyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
month
Time
,
"number"
);
BigDecimal
OutSum
=
depotItemService
.
buyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
month
Time
,
"number"
);
BigDecimal
InSumRetail
=
depotItemService
.
buyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
month
Time
,
"number"
);
BigDecimal
InSum
=
depotItemService
.
buyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
month
Time
,
"number"
);
BigDecimal
OutSumRetailPrice
=
depotItemService
.
buyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
month
Time
,
"price"
);
BigDecimal
OutSumPrice
=
depotItemService
.
buyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
month
Time
,
"price"
);
BigDecimal
InSumRetailPrice
=
depotItemService
.
buyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
month
Time
,
"price"
);
BigDecimal
InSumPrice
=
depotItemService
.
buyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
month
Time
,
"price"
);
BigDecimal
OutSumRetail
=
depotItemService
.
buyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"number"
);
BigDecimal
OutSum
=
depotItemService
.
buyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"number"
);
BigDecimal
InSumRetail
=
depotItemService
.
buyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"number"
);
BigDecimal
InSum
=
depotItemService
.
buyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"number"
);
BigDecimal
OutSumRetailPrice
=
depotItemService
.
buyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"price"
);
BigDecimal
OutSumPrice
=
depotItemService
.
buyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"price"
);
BigDecimal
InSumRetailPrice
=
depotItemService
.
buyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"price"
);
BigDecimal
InSumPrice
=
depotItemService
.
buyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
beginTime
,
end
Time
,
"price"
);
BigDecimal
OutInSumPrice
=
(
OutSumRetailPrice
.
add
(
OutSumPrice
)).
subtract
(
InSumRetailPrice
.
add
(
InSumPrice
));
item
.
put
(
"barCode"
,
diEx
.
getBarCode
());
item
.
put
(
"materialName"
,
diEx
.
getMName
());
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
d90771c7
...
...
@@ -50,6 +50,20 @@ public interface DepotItemMapperEx {
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"endTime"
)
String
endTime
);
List
<
DepotItemVo4WithInfoEx
>
getListWithBugOrSale
(
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"billType"
)
String
billType
,
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
int
getListWithBugOrSaleCount
(
@Param
(
"materialParam"
)
String
materialParam
,
@Param
(
"billType"
)
String
billType
,
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
);
BigDecimal
buyOrSaleNumber
(
@Param
(
"type"
)
String
type
,
@Param
(
"subType"
)
String
subType
,
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
d90771c7
...
...
@@ -259,11 +259,29 @@ public class DepotItemService {
return
result
;
}
public
BigDecimal
buyOrSale
(
String
type
,
String
subType
,
Long
MId
,
String
monthTime
,
String
sumType
)
throws
Exception
{
public
List
<
DepotItemVo4WithInfoEx
>
getListWithBugOrSale
(
String
materialParam
,
String
billType
,
String
beginTime
,
String
endTime
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
DepotItemVo4WithInfoEx
>
list
=
null
;
try
{
list
=
depotItemMapperEx
.
getListWithBugOrSale
(
materialParam
,
billType
,
beginTime
,
endTime
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
getListWithBugOrSaleCount
(
String
materialParam
,
String
billType
,
String
beginTime
,
String
endTime
)
throws
Exception
{
int
result
=
0
;
try
{
result
=
depotItemMapperEx
.
getListWithBugOrSaleCount
(
materialParam
,
billType
,
beginTime
,
endTime
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
BigDecimal
buyOrSale
(
String
type
,
String
subType
,
Long
MId
,
String
beginTime
,
String
endTime
,
String
sumType
)
throws
Exception
{
BigDecimal
result
=
BigDecimal
.
ZERO
;
try
{
String
beginTime
=
Tools
.
firstDayOfMonth
(
monthTime
)
+
BusinessConstants
.
DAY_FIRST_TIME
;
String
endTime
=
Tools
.
lastDayOfMonth
(
monthTime
)
+
BusinessConstants
.
DAY_LAST_TIME
;
if
(
SUM_TYPE
.
equals
(
sumType
))
{
result
=
depotItemMapperEx
.
buyOrSaleNumber
(
type
,
subType
,
MId
,
beginTime
,
endTime
,
sumType
);
}
else
{
...
...
jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
d90771c7
...
...
@@ -233,6 +233,67 @@
group by m.id) cc
</select>
<select
id=
"getListWithBugOrSale"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultByMaterial"
>
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, u.name unit_name
from jsh_material m
left join jsh_depot_item di on di.material_id=m.id and ifnull(di.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where 1=1
<if
test=
"materialParam != null and materialParam !=''"
>
<bind
name=
"bindKey"
value=
"'%'+materialParam+'%'"
/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if
test=
"billType =='buy'"
>
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
</if>
<if
test=
"billType =='sale'"
>
and (dh.sub_type = '销售' or dh.sub_type = '销售退货' or dh.sub_type = '零售' or dh.sub_type = '零售退货')
</if>
<if
test=
"beginTime != null"
>
and dh.oper_time >= #{beginTime}
</if>
<if
test=
"endTime != null"
>
and dh.oper_time
<
= #{endTime}
</if>
and ifnull(m.delete_flag,'0') !='1'
group by m.id
order by m.id desc
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
</if>
</select>
<select
id=
"getListWithBugOrSaleCount"
resultType=
"java.lang.Integer"
>
select count(1) from (select m.id
from jsh_material m
left join jsh_depot_item di on di.material_id=m.id and ifnull(m.delete_Flag,'0') !='1'
left join jsh_material_extend me on me.id=di.material_extend_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_depot_head dh on di.header_id=dh.id and ifnull(dh.delete_flag,'0') !='1'
where 1=1
<if
test=
"materialParam != null and materialParam !=''"
>
<bind
name=
"bindKey"
value=
"'%'+materialParam+'%'"
/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
</if>
<if
test=
"billType =='buy'"
>
and (dh.sub_type = '采购' or dh.sub_type = '采购退货')
</if>
<if
test=
"billType =='sale'"
>
and (dh.sub_type = '销售' or dh.sub_type = '销售退货' or dh.sub_type = '零售' or dh.sub_type = '零售退货')
</if>
<if
test=
"beginTime != null"
>
and dh.oper_time >= #{beginTime}
</if>
<if
test=
"endTime != null"
>
and dh.oper_time
<
= #{endTime}
</if>
and ifnull(di.delete_flag,'0') !='1'
group by m.id) cc
</select>
<select
id=
"buyOrSaleNumber"
resultType=
"java.math.BigDecimal"
>
select ifnull(sum(basic_number),0) as BasicNumber from jsh_depot_item di,jsh_depot_head dh
where di.header_id = dh.id
...
...
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