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
40155c27
Commit
40155c27
authored
Jan 06, 2019
by
季圣华
Browse files
优化报表分组sql
parent
d6c43108
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
40155c27
...
@@ -580,14 +580,12 @@ public class DepotItemController {
...
@@ -580,14 +580,12 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
);
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
true
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getMaterialid
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMColor
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMColor
());
//扩展信息
//扩展信息
...
@@ -641,9 +639,9 @@ public class DepotItemController {
...
@@ -641,9 +639,9 @@ public class DepotItemController {
Double
thisAllPrice
=
0.0
;
Double
thisAllPrice
=
0.0
;
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
thisAllPrice
=
thisAllPrice
+
(
prevPrice
+
InPrice
-
OutPrice
);
thisAllPrice
=
thisAllPrice
+
(
prevPrice
+
InPrice
-
OutPrice
);
}
}
}
}
...
@@ -689,12 +687,10 @@ public class DepotItemController {
...
@@ -689,12 +687,10 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
//扩展信息
...
@@ -751,16 +747,14 @@ public class DepotItemController {
...
@@ -751,16 +747,14 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
OutSumRetail
=
sumNumberBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumRetail
=
sumNumberBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSum
=
sumNumberBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumRetail
=
sumNumberBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumRetail
=
sumNumberBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
);
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSum
=
sumNumberBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSumRetailPrice
=
sumPriceBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumRetailPrice
=
sumPriceBuyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
OutSumPrice
=
sumPriceBuyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumRetailPrice
=
sumPriceBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumRetailPrice
=
sumPriceBuyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMaterialid
(),
monthTime
);
Double
InSumPrice
=
sumPriceBuyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
//扩展信息
...
@@ -817,10 +811,8 @@ public class DepotItemController {
...
@@ -817,10 +811,8 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
JSONObject
item
=
new
JSONObject
();
Double
InSum
=
sumNumberGift
(
"礼品充值"
,
pid
,
diEx
.
getMaterialid
(),
"in"
);
Double
InSum
=
sumNumberGift
(
"礼品充值"
,
pid
,
diEx
.
getMId
(),
"in"
);
Double
OutSum
=
sumNumberGift
(
"礼品销售"
,
pid
,
diEx
.
getMaterialid
(),
"out"
);
Double
OutSum
=
sumNumberGift
(
"礼品销售"
,
pid
,
diEx
.
getMId
(),
"out"
);
item
.
put
(
"Id"
,
diEx
.
getId
());
item
.
put
(
"MaterialId"
,
diEx
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
//扩展信息
...
@@ -876,12 +868,12 @@ public class DepotItemController {
...
@@ -876,12 +868,12 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
String
[]
objs
=
new
String
[
9
];
String
[]
objs
=
new
String
[
9
];
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
);
Double
prevSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
)
-
sumNumber
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
InSum
=
sumNumber
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
OutSum
=
sumNumber
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
true
);
Double
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
)
-
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
true
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
ateriali
d
(),
monthTime
,
false
);
Double
OutPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getM
I
d
(),
monthTime
,
false
);
Double
unitPrice
=
0.0
;
Double
unitPrice
=
0.0
;
if
(
prevSum
+
InSum
-
OutSum
!=
0.0
)
{
if
(
prevSum
+
InSum
-
OutSum
!=
0.0
)
{
unitPrice
=
(
prevPrice
+
InPrice
-
OutPrice
)
/
(
prevSum
+
InSum
-
OutSum
);
unitPrice
=
(
prevPrice
+
InPrice
-
OutPrice
)
/
(
prevSum
+
InSum
-
OutSum
);
...
...
src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
View file @
40155c27
...
@@ -48,6 +48,8 @@ public class DepotItemVo4WithInfoEx {
...
@@ -48,6 +48,8 @@ public class DepotItemVo4WithInfoEx {
private
String
mtype
;
private
String
mtype
;
private
Long
MId
;
private
String
MName
;
private
String
MName
;
private
String
MModel
;
private
String
MModel
;
...
@@ -258,6 +260,14 @@ public class DepotItemVo4WithInfoEx {
...
@@ -258,6 +260,14 @@ public class DepotItemVo4WithInfoEx {
this
.
mtype
=
mtype
;
this
.
mtype
=
mtype
;
}
}
public
Long
getMId
()
{
return
MId
;
}
public
void
setMId
(
Long
MId
)
{
this
.
MId
=
MId
;
}
public
String
getMName
()
{
public
String
getMName
()
{
return
MName
;
return
MName
;
}
}
...
...
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
40155c27
...
@@ -33,6 +33,14 @@
...
@@ -33,6 +33,14 @@
<result
column=
"UName"
jdbcType=
"VARCHAR"
property=
"UName"
/>
<result
column=
"UName"
jdbcType=
"VARCHAR"
property=
"UName"
/>
</resultMap>
</resultMap>
<resultMap
extends=
"BaseResultMap"
id=
"ResultByMaterial"
type=
"com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx"
>
<result
column=
"MId"
jdbcType=
"VARCHAR"
property=
"MId"
/>
<result
column=
"MName"
jdbcType=
"VARCHAR"
property=
"MName"
/>
<result
column=
"MModel"
jdbcType=
"VARCHAR"
property=
"MModel"
/>
<result
column=
"MaterialUnit"
jdbcType=
"VARCHAR"
property=
"MaterialUnit"
/>
<result
column=
"MColor"
jdbcType=
"VARCHAR"
property=
"MColor"
/>
</resultMap>
<select
id=
"selectByConditionDepotItem"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByConditionDepotItem"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"BaseResultMap"
>
select *
select *
FROM jsh_depotitem
FROM jsh_depotitem
...
@@ -130,35 +138,35 @@
...
@@ -130,35 +138,35 @@
order by di.id asc
order by di.id asc
</select>
</select>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"Result
WithInfoExMap
"
>
<select
id=
"findByAll"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"Result
ByMaterial
"
>
select
di.*
, 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
from jsh_depotitem di
from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.id
inner join jsh_material m on di.MaterialId=m.id
where 1=1
where 1=1
<if
test=
"headIds != null"
>
<if
test=
"headIds != null"
>
and HeaderId in (${headIds})
and
di.
HeaderId in (${headIds})
</if>
</if>
<if
test=
"materialIds != null"
>
<if
test=
"materialIds != null"
>
and MaterialId in (${materialIds})
and
di.
MaterialId in (${materialIds})
</if>
</if>
group by
MaterialId
group by
m.id,m.Name, m.Model, m.Unit, m.Color
<if
test=
"offset != null and rows != null"
>
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
limit #{offset},#{rows}
</if>
</if>
</select>
</select>
<select
id=
"findByAllCount"
resultType=
"java.lang.Integer"
>
<select
id=
"findByAllCount"
resultType=
"java.lang.Integer"
>
select count(1) from (select
di.I
d
select count(1) from (select
m.i
d
from jsh_depotitem di
from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.id
inner join jsh_material m on di.MaterialId=m.id
where 1=1
where 1=1
<if
test=
"headIds != null"
>
<if
test=
"headIds != null"
>
and HeaderId in (${headIds})
and
di.
HeaderId in (${headIds})
</if>
</if>
<if
test=
"materialIds != null"
>
<if
test=
"materialIds != null"
>
and MaterialId in (${materialIds})
and
di.
MaterialId in (${materialIds})
</if>
</if>
group by
MaterialI
d) cc
group by
m.i
d) cc
</select>
</select>
<select
id=
"findByTypeInIsPrev"
resultType=
"java.lang.Double"
>
<select
id=
"findByTypeInIsPrev"
resultType=
"java.lang.Double"
>
...
...
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