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
ee839055
"jetbrains:/idea/checkout/git" did not exist on "e8f2f849b4c70a6a4870741f175b50922914b40e"
Commit
ee839055
authored
Oct 12, 2019
by
季圣华
Browse files
优化库存计算方式
parent
26bd6235
Changes
10
Show whitespace changes
Inline
Side-by-side
erp_web/js/pages/materials/in_out.js
View file @
ee839055
...
...
@@ -603,17 +603,14 @@
type
:
"
get
"
,
url
:
'
/depotItem/findStockNumById
'
,
data
:{
projectId
:
depotId
,
materialId
:
mId
,
monthTime
:
monthTime
,
currentPage
:
1
,
pageSize
:
10
depotId
:
depotId
,
mId
:
mId
},
dataType
:
"
json
"
,
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
)
{
if
(
res
.
data
&&
res
.
data
.
page
&&
res
.
data
.
page
[
0
]
)
{
var
thisStock
=
res
.
data
.
page
[
0
].
thisSum
;
if
(
res
.
data
)
{
var
thisStock
=
res
.
data
.
stock
;
if
(
type
==
"
select
"
)
{
//选择下拉框的时候
if
(
ratio
!=
undefined
&&
ratio
!=
1
)
{
loadRatio
=
ratio
;
...
...
erp_web/pages/reports/in_out_stock_report.html
View file @
ee839055
...
...
@@ -71,14 +71,9 @@
//导出EXCEL
function
exportExcel
()
{
$
(
"
#exprotBtn
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
if
(
!
$
(
"
#searchPanel .total-count
"
).
text
())
{
$
.
messager
.
alert
(
'
导出提示
'
,
'
请先选择月份再进行查询!
'
,
'
error
'
);
}
else
{
showEachDetails
(
1
,
3000
);
//此处直接去做get请求,用下面的查询每月统计的方法,去获取list,参数长度虽长,但还是可以用get
//window.location.href = "/depotItem/exportExcel.action?browserType=" + getOs();
}
});
}
...
...
@@ -314,7 +309,7 @@
var
mIds
=
res
.
data
.
mIds
;
if
(
mIds
)
{
if
(
pageSize
===
3000
)
{
window
.
location
.
href
=
"
/depotItem/exportExcel?browserType=
"
+
getOs
()
+
"
¤tPage=
"
+
pageNo
+
"
&pageSize=
"
+
pageSize
+
"
&
projec
tId=
"
+
$
.
trim
(
$
(
"
#searchProjectId
"
).
val
())
+
"
&monthTime=
"
+
$
(
"
#searchMonth
"
).
val
()
+
"
&headIds=
"
+
HeadIds
+
"
&materialIds=
"
+
mIds
;
window
.
location
.
href
=
"
/depotItem/exportExcel?browserType=
"
+
getOs
()
+
"
¤tPage=
"
+
pageNo
+
"
&pageSize=
"
+
pageSize
+
"
&
depo
tId=
"
+
$
.
trim
(
$
(
"
#searchProjectId
"
).
val
())
+
"
&monthTime=
"
+
$
(
"
#searchMonth
"
).
val
()
+
"
&headIds=
"
+
HeadIds
+
"
&materialIds=
"
+
mIds
;
}
else
{
$
.
ajax
({
...
...
@@ -324,7 +319,7 @@
data
:
({
currentPage
:
pageNo
,
pageSize
:
pageSize
,
projec
tId
:
$
.
trim
(
$
(
"
#searchProjectId
"
).
val
()),
depo
tId
:
$
.
trim
(
$
(
"
#searchProjectId
"
).
val
()),
monthTime
:
$
(
"
#searchMonth
"
).
val
(),
headIds
:
HeadIds
,
materialIds
:
mIds
,
...
...
@@ -348,7 +343,7 @@
url
:
"
/depotItem/totalCountMoney
"
,
dataType
:
"
json
"
,
data
:
({
projec
tId
:
$
.
trim
(
$
(
"
#searchProjectId
"
).
val
()),
depo
tId
:
$
.
trim
(
$
(
"
#searchProjectId
"
).
val
()),
monthTime
:
$
(
"
#searchMonth
"
).
val
(),
headIds
:
HeadIds
,
materialIds
:
mIds
...
...
@@ -360,7 +355,7 @@
if
(
count
.
lastIndexOf
(
'
.
'
)
>
-
1
)
{
count
=
count
.
substring
(
0
,
count
.
lastIndexOf
(
'
.
'
)
+
3
);
}
$
(
"
#search
Panel
.total-count
"
).
text
(
"
本月合计金额:
"
+
count
+
"
元
"
);
//本月合计金额
$
(
"
#search
Table
.total-count
"
).
text
(
"
本月合计金额:
"
+
count
+
"
元
"
);
//本月合计金额
}
}
},
...
...
src/main/java/com/jsh/erp/config/TenantConfig.java
View file @
ee839055
...
...
@@ -61,9 +61,8 @@ public class TenantConfig {
return
true
;
}
else
{
// 这里可以判断是否过滤表
if
(
"databasechangelog"
.
equals
(
tableName
)
||
"databasechangeloglock"
.
equals
(
tableName
)
||
"jsh_materialproperty"
.
equals
(
tableName
)
||
"tbl_sequence"
.
equals
(
tableName
)
||
"jsh_userbusiness"
.
equals
(
tableName
)
||
"jsh_app"
.
equals
(
tableName
)
||
"jsh_functions"
.
equals
(
tableName
)
if
(
"jsh_materialproperty"
.
equals
(
tableName
)
||
"tbl_sequence"
.
equals
(
tableName
)
||
"jsh_userbusiness"
.
equals
(
tableName
)
||
"jsh_functions"
.
equals
(
tableName
)
||
"jsh_tenant"
.
equals
(
tableName
))
{
return
true
;
}
else
{
...
...
@@ -83,7 +82,8 @@ public class TenantConfig {
public
boolean
doFilter
(
MetaObject
metaObject
)
{
MappedStatement
ms
=
SqlParserHelper
.
getMappedStatement
(
metaObject
);
// 过滤自定义查询此时无租户信息约束出现
if
(
"com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName"
.
equals
(
ms
.
getId
()))
{
if
(
"com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName"
.
equals
(
ms
.
getId
())||
"com.jsh.erp.datasource.mappers.DepotItemMapperEx.getStockByParam"
.
equals
(
ms
.
getId
()))
{
return
true
;
}
return
false
;
...
...
@@ -108,10 +108,10 @@ public class TenantConfig {
/**
* 性能分析拦截器,不建议生产使用
*/
//
@Bean
//
public PerformanceInterceptor performanceInterceptor(){
//
return new PerformanceInterceptor();
//
}
@Bean
public
PerformanceInterceptor
performanceInterceptor
(){
return
new
PerformanceInterceptor
();
}
}
src/main/java/com/jsh/erp/controller/DepotHeadController.java
View file @
ee839055
...
...
@@ -398,12 +398,13 @@ public class DepotHeadController {
@RequestParam
(
"updated"
)
String
updated
,
HttpServletRequest
request
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
Long
billsNumLimit
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"billsNumLimit"
).
toString
());
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
Long
count
=
depotHeadService
.
countDepotHead
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
if
(
count
>=
billsNumLimit
)
{
throw
new
BusinessParamCheckingException
(
ExceptionConstants
.
DEPOT_HEAD_OVER_LIMIT_FAILED_CODE
,
ExceptionConstants
.
DEPOT_HEAD_OVER_LIMIT_FAILED_MSG
);
}
else
{
depotHeadService
.
addDepotHeadAndDetail
(
beanJson
,
inserted
,
deleted
,
updated
);
depotHeadService
.
addDepotHeadAndDetail
(
beanJson
,
inserted
,
deleted
,
updated
,
tenantId
);
}
return
result
;
}
...
...
@@ -421,12 +422,16 @@ public class DepotHeadController {
* @return java.lang.Object
*/
@RequestMapping
(
value
=
"/updateDepotHeadAndDetail"
)
public
Object
updateDepotHeadAndDetail
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"info"
)
String
beanJson
,
@RequestParam
(
"inserted"
)
String
inserted
,
public
Object
updateDepotHeadAndDetail
(
@RequestParam
(
"id"
)
Long
id
,
@RequestParam
(
"info"
)
String
beanJson
,
@RequestParam
(
"inserted"
)
String
inserted
,
@RequestParam
(
"deleted"
)
String
deleted
,
@RequestParam
(
"updated"
)
String
updated
,
@RequestParam
(
"preTotalPrice"
)
BigDecimal
preTotalPrice
)
throws
Exception
{
@RequestParam
(
"updated"
)
String
updated
,
@RequestParam
(
"preTotalPrice"
)
BigDecimal
preTotalPrice
,
HttpServletRequest
request
)
throws
Exception
{
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
depotHeadService
.
updateDepotHeadAndDetail
(
id
,
beanJson
,
inserted
,
deleted
,
updated
,
preTotalPrice
);
depotHeadService
.
updateDepotHeadAndDetail
(
id
,
beanJson
,
inserted
,
deleted
,
updated
,
preTotalPrice
,
tenantId
);
return
result
;
}
/**
...
...
src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
ee839055
...
...
@@ -89,93 +89,30 @@ public class DepotItemController {
/**
* 根据商品id和仓库id查询库存数量
* @param pageSize
* @param currentPage
* @param depotId
* @param mId
* @param request
* @return
* @throws Exception
*/
@GetMapping
(
value
=
"/findStockNumById"
)
public
String
findStockNumById
(
@RequestParam
(
value
=
Constants
.
PAGE_SIZE
,
required
=
false
)
Integer
pageSize
,
@RequestParam
(
value
=
Constants
.
CURRENT_PAGE
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
"projectId"
)
Integer
pid
,
@RequestParam
(
"materialId"
)
String
mId
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
String
>
parameterMap
=
ParamUtils
.
requestToMap
(
request
);
parameterMap
.
put
(
"mId"
,
mId
);
parameterMap
.
put
(
"monthTime"
,
monthTime
);
PageQueryInfo
queryInfo
=
new
PageQueryInfo
();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
if
(
pageSize
!=
null
&&
pageSize
<=
0
)
{
pageSize
=
10
;
}
String
offset
=
ParamUtils
.
getPageOffset
(
currentPage
,
pageSize
);
if
(
StringUtil
.
isNotEmpty
(
offset
))
{
parameterMap
.
put
(
Constants
.
OFFSET
,
offset
);
}
List
<
DepotItemVo4Material
>
list
=
depotItemService
.
findStockNumByMaterialIdList
(
parameterMap
);
//存放数据json数组
Long
materialId
=
Long
.
parseLong
(
mId
);
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
list
)
{
for
(
DepotItemVo4Material
di
:
list
)
{
JSONObject
item
=
new
JSONObject
();
BigDecimal
prevSum
=
sumNumber
(
"入库"
,
pid
,
materialId
,
monthTime
,
true
).
subtract
(
sumNumber
(
"出库"
,
pid
,
materialId
,
monthTime
,
true
));
BigDecimal
InSum
=
sumNumber
(
"入库"
,
pid
,
materialId
,
monthTime
,
false
);
BigDecimal
OutSum
=
sumNumber
(
"出库"
,
pid
,
materialId
,
monthTime
,
false
);
// +组装(组合件)-组装(普通子件)+拆卸(普通子件)-拆卸(组合件)
BigDecimal
prevAssembleSum
=
assembleNumber
(
"组装单"
,
"组合件"
,
pid
,
materialId
,
monthTime
,
true
)
.
subtract
(
assembleNumber
(
"组装单"
,
"普通子件"
,
pid
,
materialId
,
monthTime
,
true
))
.
add
(
assembleNumber
(
"拆卸单"
,
"普通子件"
,
pid
,
materialId
,
monthTime
,
true
))
.
subtract
(
assembleNumber
(
"拆卸单"
,
"组合件"
,
pid
,
materialId
,
monthTime
,
true
));
BigDecimal
notPrevAssembleSum
=
assembleNumber
(
"组装单"
,
"组合件"
,
pid
,
materialId
,
monthTime
,
false
)
.
subtract
(
assembleNumber
(
"组装单"
,
"普通子件"
,
pid
,
materialId
,
monthTime
,
false
))
.
add
(
assembleNumber
(
"拆卸单"
,
"普通子件"
,
pid
,
materialId
,
monthTime
,
false
))
.
subtract
(
assembleNumber
(
"拆卸单"
,
"组合件"
,
pid
,
materialId
,
monthTime
,
false
));
item
.
put
(
"MaterialId"
,
di
.
getMaterialid
()
==
null
?
""
:
di
.
getMaterialid
());
item
.
put
(
"MaterialName"
,
di
.
getMname
());
item
.
put
(
"MaterialModel"
,
di
.
getMmodel
());
item
.
put
(
"thisSum"
,
prevSum
.
add
(
InSum
).
subtract
(
OutSum
).
add
(
prevAssembleSum
).
add
(
notPrevAssembleSum
));
dataArray
.
add
(
item
);
}
}
objectMap
.
put
(
"page"
,
dataArray
);
if
(
list
==
null
)
{
queryInfo
.
setRows
(
new
ArrayList
<
Object
>());
queryInfo
.
setTotal
(
BusinessConstants
.
DEFAULT_LIST_NULL_NUMBER
);
return
returnJson
(
objectMap
,
"查找不到数据"
,
ErpInfo
.
OK
.
code
);
}
queryInfo
.
setRows
(
list
);
queryInfo
.
setTotal
(
depotItemService
.
findStockNumByMaterialIdCounts
(
parameterMap
));
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
/**
* 保存明细
* @param inserted
* @param deleted
* @param updated
* @param headerId
* @param request
* @return
*/
@PostMapping
(
value
=
"/saveDetials"
)
public
String
saveDetials
(
@RequestParam
(
"inserted"
)
String
inserted
,
@RequestParam
(
"deleted"
)
String
deleted
,
@RequestParam
(
"updated"
)
String
updated
,
@RequestParam
(
"headerId"
)
Long
headerId
,
public
BaseResponseInfo
findStockNumById
(
@RequestParam
(
"depotId"
)
Long
depotId
,
@RequestParam
(
"mId"
)
Long
mId
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
depotItemService
.
saveDetials
(
inserted
,
deleted
,
updated
,
headerId
);
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
catch
(
DataAccessException
e
)
{
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
map
.
put
(
"stock"
,
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
null
,
tenantId
));
res
.
code
=
200
;
res
.
data
=
map
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
error
(
">>>>>>>>>>>>>>>>>>>保存明细信息异常"
,
e
)
;
re
turn
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
)
;
res
.
code
=
500
;
re
s
.
data
=
"获取数据失败"
;
}
return
res
;
}
/**
...
...
@@ -205,6 +142,7 @@ public class DepotItemController {
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
new
ArrayList
<
DepotItemVo4WithInfoEx
>();
if
(
headerId
!=
0
)
{
...
...
@@ -233,9 +171,7 @@ public class DepotItemController {
String
materialOther
=
getOtherInfo
(
mpArr
,
diEx
);
MaterialName
=
MaterialName
+
materialOther
+
((
diEx
.
getUName
()
==
null
||
diEx
.
getUName
().
equals
(
""
))
?
""
:
"("
+
diEx
.
getUName
()
+
")"
)
+
ratio
;
item
.
put
(
"MaterialName"
,
MaterialName
==
null
?
""
:
MaterialName
);
int
inSum
=
depotItemService
.
findByTypeAndMaterialIdAndDepotId
(
"入库"
,
diEx
.
getMaterialid
(),
diEx
.
getDepotid
());
int
outSum
=
depotItemService
.
findByTypeAndMaterialIdAndDepotId
(
"出库"
,
diEx
.
getMaterialid
(),
diEx
.
getDepotid
());
item
.
put
(
"Stock"
,
inSum
-
outSum
);
item
.
put
(
"Stock"
,
depotItemService
.
getStockByParam
(
diEx
.
getDepotid
(),
diEx
.
getMaterialid
(),
null
,
null
,
tenantId
));
item
.
put
(
"Unit"
,
diEx
.
getMunit
());
item
.
put
(
"OperNumber"
,
diEx
.
getOpernumber
());
item
.
put
(
"BasicNumber"
,
diEx
.
getBasicnumber
());
...
...
@@ -320,7 +256,7 @@ public class DepotItemController {
@PostMapping
(
value
=
"/findByAll"
)
public
BaseResponseInfo
findByAll
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"
projectId"
)
Integer
projec
tId
,
@RequestParam
(
"
depotId"
)
Long
depo
tId
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"headIds"
)
String
headIds
,
@RequestParam
(
"materialIds"
)
String
materialIds
,
...
...
@@ -328,20 +264,20 @@ public class DepotItemController {
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
headIds
,
materialIds
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
String
[]
mpArr
=
mpList
.
split
(
","
);
int
total
=
depotItemService
.
findByAllCount
(
headIds
,
materialIds
);
map
.
put
(
"total"
,
total
);
//存放数据json数组
Integer
pid
=
projectId
;
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
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
)
;
Long
mId
=
diEx
.
getMId
(
);
String
timeA
=
monthTime
+
"-01 00:00:00"
;
String
timeB
=
monthTime
+
"-31 23:59:59"
;
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
...
...
@@ -350,10 +286,10 @@ public class DepotItemController {
item
.
put
(
"MaterialColor"
,
diEx
.
getMColor
());
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"
,
Out
S
um
);
BigDecimal
thisSum
=
prevSum
.
add
(
InSum
).
subtract
(
OutSum
);
item
.
put
(
"prevSum"
,
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
timeA
,
tenantId
)
);
item
.
put
(
"InSum"
,
depotItemService
.
getInNumByParam
(
depotId
,
mId
,
timeA
,
timeB
,
tenantId
)
);
item
.
put
(
"OutSum"
,
depotItemService
.
get
Out
N
um
ByParam
(
depotId
,
mId
,
timeA
,
timeB
,
tenantId
)
);
BigDecimal
thisSum
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
null
,
tenantId
);
item
.
put
(
"thisSum"
,
thisSum
);
item
.
put
(
"thisAllPrice"
,
thisSum
.
multiply
(
getUnitPrice
(
diEx
.
getPresetPriceOne
(),
diEx
.
getPriceStrategy
())));
dataArray
.
add
(
item
);
...
...
@@ -370,6 +306,60 @@ public class DepotItemController {
return
res
;
}
/**
* 导出excel表格
* @param currentPage
* @param pageSize
* @param projectId
* @param monthTime
* @param headIds
* @param materialIds
* @param request
* @param response
* @return
*/
@GetMapping
(
value
=
"/exportExcel"
)
public
void
exportExcel
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"depotId"
)
Long
depotId
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"headIds"
)
String
headIds
,
@RequestParam
(
"materialIds"
)
String
materialIds
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
headIds
,
materialIds
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
//存放数据json数组
String
[]
names
=
{
"名称"
,
"型号"
,
"单位"
,
"单价"
,
"上月结存数量"
,
"入库数量"
,
"出库数量"
,
"本月结存数量"
,
"结存金额"
};
String
title
=
"库存报表"
;
List
<
String
[]>
objects
=
new
ArrayList
<
String
[]>();
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
Long
mId
=
diEx
.
getMId
();
String
timeA
=
monthTime
+
"-01 00:00:00"
;
String
timeB
=
monthTime
+
"-31 23:59:59"
;
String
[]
objs
=
new
String
[
9
];
objs
[
0
]
=
diEx
.
getMName
().
toString
();
objs
[
1
]
=
diEx
.
getMModel
().
toString
();
objs
[
2
]
=
diEx
.
getMaterialUnit
().
toString
();
objs
[
3
]
=
getUnitPrice
(
diEx
.
getPresetPriceOne
(),
diEx
.
getPriceStrategy
()).
toString
();
objs
[
4
]
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
timeA
,
tenantId
).
toString
();
objs
[
5
]
=
depotItemService
.
getInNumByParam
(
depotId
,
mId
,
timeA
,
timeB
,
tenantId
).
toString
();
objs
[
6
]
=
depotItemService
.
getOutNumByParam
(
depotId
,
mId
,
timeA
,
timeB
,
tenantId
).
toString
();
BigDecimal
thisSum
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
null
,
tenantId
);
objs
[
7
]
=
thisSum
.
toString
();
objs
[
8
]
=
thisSum
.
multiply
(
getUnitPrice
(
diEx
.
getPresetPriceOne
(),
diEx
.
getPriceStrategy
())).
toString
();
objects
.
add
(
objs
);
}
}
File
file
=
ExcelUtils
.
exportObjectsWithoutTitle
(
title
,
names
,
title
,
objects
);
ExportExecUtil
.
showExec
(
file
,
file
.
getName
()
+
"-"
+
monthTime
,
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 统计总计金额
* @param pid
...
...
@@ -380,22 +370,23 @@ public class DepotItemController {
* @return
*/
@PostMapping
(
value
=
"/totalCountMoney"
)
public
BaseResponseInfo
totalCountMoney
(
@RequestParam
(
"
projectId"
)
Integer
pi
d
,
public
BaseResponseInfo
totalCountMoney
(
@RequestParam
(
"
depotId"
)
Long
depotI
d
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"headIds"
)
String
headIds
,
@RequestParam
(
"materialIds"
)
String
materialIds
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Long
tenantId
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"tenantId"
).
toString
());
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
headIds
,
materialIds
,
null
,
null
);
BigDecimal
thisAllPrice
=
BigDecimal
.
ZERO
;
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
BigDecimal
prevPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
).
subtract
(
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
true
)
);
BigDecimal
InPrice
=
sumPrice
(
"入库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
BigDecimal
O
utPrice
=
sumPrice
(
"出库"
,
pid
,
diEx
.
getMId
(),
monthTime
,
false
);
thisAllPrice
=
thisAllPrice
.
add
(
prevPrice
.
add
(
InPrice
).
subtract
(
Ou
tPrice
));
Long
mId
=
diEx
.
getMId
(
);
BigDecimal
thisSum
=
depotItemService
.
getStockByParam
(
depotId
,
mId
,
null
,
null
,
tenantId
);
BigDecimal
u
ni
tPrice
=
getUnitPrice
(
diEx
.
getPresetPriceOne
(),
diEx
.
getPriceStrategy
()
);
thisAllPrice
=
thisAllPrice
.
add
(
thisSum
.
multiply
(
uni
tPrice
));
}
}
map
.
put
(
"totalCount"
,
thisAllPrice
);
...
...
@@ -440,10 +431,10 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
BigDecimal
InSum
=
sumNumberB
uyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
OutSum
=
sumNumberB
uyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
InSumPrice
=
sumPr
ice
B
uyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
OutSumPrice
=
sumPr
ice
B
uyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
InSum
=
depotItemService
.
b
uyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
,
"number"
);
BigDecimal
OutSum
=
depotItemService
.
b
uyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
,
"number"
);
BigDecimal
InSumPrice
=
depotItemServ
ice
.
b
uyOrSale
(
"入库"
,
"采购"
,
diEx
.
getMId
(),
monthTime
,
"price"
);
BigDecimal
OutSumPrice
=
depotItemServ
ice
.
b
uyOrSale
(
"出库"
,
"采购退货"
,
diEx
.
getMId
(),
monthTime
,
"price"
);
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
//扩展信息
...
...
@@ -501,14 +492,14 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
BigDecimal
OutSumRetail
=
sumNumberB
uyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
OutSum
=
sumNumberB
uyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
InSumRetail
=
sumNumberB
uyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
InSum
=
sumNumberB
uyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
OutSumRetailPrice
=
sumPr
ice
B
uyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
OutSumPrice
=
sumPr
ice
B
uyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
InSumRetailPrice
=
sumPr
ice
B
uyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
InSumPrice
=
sumPr
ice
B
uyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
);
BigDecimal
OutSumRetail
=
depotItemService
.
b
uyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
,
"number"
);
BigDecimal
OutSum
=
depotItemService
.
b
uyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
,
"number"
);
BigDecimal
InSumRetail
=
depotItemService
.
b
uyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
,
"number"
);
BigDecimal
InSum
=
depotItemService
.
b
uyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
,
"number"
);
BigDecimal
OutSumRetailPrice
=
depotItemServ
ice
.
b
uyOrSale
(
"出库"
,
"零售"
,
diEx
.
getMId
(),
monthTime
,
"price"
);
BigDecimal
OutSumPrice
=
depotItemServ
ice
.
b
uyOrSale
(
"出库"
,
"销售"
,
diEx
.
getMId
(),
monthTime
,
"price"
);
BigDecimal
InSumRetailPrice
=
depotItemServ
ice
.
b
uyOrSale
(
"入库"
,
"零售退货"
,
diEx
.
getMId
(),
monthTime
,
"price"
);
BigDecimal
InSumPrice
=
depotItemServ
ice
.
b
uyOrSale
(
"入库"
,
"销售退货"
,
diEx
.
getMId
(),
monthTime
,
"price"
);
BigDecimal
OutInSumPrice
=
(
OutSumRetailPrice
.
add
(
OutSumPrice
)).
subtract
(
InSumRetailPrice
.
add
(
InSumPrice
));
item
.
put
(
"MaterialName"
,
diEx
.
getMName
());
item
.
put
(
"MaterialModel"
,
diEx
.
getMModel
());
...
...
@@ -537,157 +528,6 @@ public class DepotItemController {
return
res
;
}
/**
* 导出excel表格
* @param currentPage
* @param pageSize
* @param projectId
* @param monthTime
* @param headIds
* @param materialIds
* @param request
* @param response
* @return
*/
@GetMapping
(
value
=
"/exportExcel"
)
public
void
exportExcel
(
@RequestParam
(
"currentPage"
)
Integer
currentPage
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"projectId"
)
Integer
projectId
,
@RequestParam
(
"monthTime"
)
String
monthTime
,
@RequestParam
(
"headIds"
)
String
headIds
,
@RequestParam
(
"materialIds"
)
String
materialIds
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
List
<
DepotItemVo4WithInfoEx
>
dataList
=
depotItemService
.
findByAll
(
headIds
,
materialIds
,
(
currentPage
-
1
)*
pageSize
,
pageSize
);
//存放数据json数组
Integer
pid
=
projectId
;
String
[]
names
=
{
"名称"
,
"型号"
,
"单位"
,
"单价"
,
"上月结存数量"
,
"入库数量"
,
"出库数量"
,
"本月结存数量"
,
"结存金额"
};
String
title
=
"库存报表"
;
List
<
String
[]>
objects
=
new
ArrayList
<
String
[]>();
if
(
null
!=
dataList
)
{
for
(
DepotItemVo4WithInfoEx
diEx
:
dataList
)
{
String
[]
objs
=
new
String
[
9
];
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
);
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
));
}
BigDecimal
thisSum
=
prevSum
.
add
(
InSum
).
subtract
(
OutSum
);
BigDecimal
thisAllPrice
=
prevPrice
.
add
(
InPrice
).
subtract
(
OutPrice
);
objs
[
0
]
=
diEx
.
getMName
().
toString
();
objs
[
1
]
=
diEx
.
getMModel
().
toString
();
objs
[
2
]
=
diEx
.
getMaterialUnit
().
toString
();
objs
[
3
]
=
unitPrice
.
toString
();
objs
[
4
]
=
prevSum
.
toString
();
objs
[
5
]
=
InSum
.
toString
();
objs
[
6
]
=
OutSum
.
toString
();
objs
[
7
]
=
thisSum
.
toString
();
objs
[
8
]
=
thisAllPrice
.
toString
();
objects
.
add
(
objs
);
}
}
File
file
=
ExcelUtils
.
exportObjectsWithoutTitle
(
title
,
names
,
title
,
objects
);
ExportExecUtil
.
showExec
(
file
,
file
.
getName
()
+
"-"
+
monthTime
,
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 数量合计
*
* @param type
* @param MId
* @param MonthTime
* @param isPrev
* @return
*/
public
BigDecimal
sumNumber
(
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
Exception
{
BigDecimal
sumNumber
=
BigDecimal
.
ZERO
;
try
{
BigDecimal
sum
=
depotItemService
.
findByType
(
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
if
(
sum
!=
null
)
{
sumNumber
=
sum
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
sumNumber
;
}
public
BigDecimal
assembleNumber
(
String
subType
,
String
mType
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
Exception
{
BigDecimal
assembleNumber
=
BigDecimal
.
ZERO
;
try
{
BigDecimal
sum
=
depotItemService
.
findAssembleByType
(
subType
,
mType
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
if
(
sum
!=
null
)
{
assembleNumber
=
sum
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
assembleNumber
;
}
/**
* 价格合计
*
* @param type
* @param MId
* @param MonthTime
* @param isPrev
* @return
*/
public
BigDecimal
sumPrice
(
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
Exception
{
BigDecimal
sumPrice
=
BigDecimal
.
ZERO
;
try
{
BigDecimal
sum
=
depotItemService
.
findPriceByType
(
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
if
(
sum
!=
null
)
{
sumPrice
=
sum
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
sumPrice
;
}
public
BigDecimal
sumNumberBuyOrSale
(
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
)
throws
Exception
{
BigDecimal
sumNumber
=
BigDecimal
.
ZERO
;
String
sumType
=
"Number"
;
try
{
BigDecimal
sum
=
depotItemService
.
buyOrSale
(
type
,
subType
,
MId
,
MonthTime
,
sumType
);
if
(
sum
!=
null
)
{
sumNumber
=
sum
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
sumNumber
;
}
public
BigDecimal
sumPriceBuyOrSale
(
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
)
throws
Exception
{
BigDecimal
sumPrice
=
BigDecimal
.
ZERO
;
String
sumType
=
"Price"
;
try
{
BigDecimal
sum
=
depotItemService
.
buyOrSale
(
type
,
subType
,
MId
,
MonthTime
,
sumType
);
if
(
sum
!=
null
)
{
sumPrice
=
sum
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
sumPrice
;
}
/**
* 获取单位
* @param materialUnit
...
...
@@ -803,7 +643,6 @@ public class DepotItemController {
if
(
null
!=
dataList
)
{
for
(
DepotItemStockWarningCount
diEx
:
dataList
)
{
String
[]
objs
=
new
String
[
9
];
objs
[
0
]
=
diEx
.
getMaterialName
().
toString
();
objs
[
1
]
=
diEx
.
getMaterialModel
().
toString
();
objs
[
2
]
=
diEx
.
getMaterialOther
().
toString
();
...
...
src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
ee839055
...
...
@@ -2,6 +2,7 @@ package com.jsh.erp.datasource.mappers;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.vo.DepotItemStockWarningCount
;
import
com.jsh.erp.datasource.vo.DepotItemVo4Stock
;
import
org.apache.ibatis.annotations.Param
;
import
java.math.BigDecimal
;
...
...
@@ -35,30 +36,12 @@ public interface DepotItemMapperEx {
Long
findDetailByTypeAndMaterialIdCounts
(
@Param
(
"mId"
)
Long
mId
);
List
<
DepotItemVo4Material
>
findStockNumByMaterialIdList
(
@Param
(
"mId"
)
Long
mId
,
@Param
(
"monthTime"
)
String
monthTime
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"rows"
)
Integer
rows
);
Long
findStockNumByMaterialIdCounts
(
@Param
(
"mId"
)
Long
mId
,
@Param
(
"monthTime"
)
String
monthTime
);
Long
findByTypeAndMaterialIdIn
(
@Param
(
"mId"
)
Long
mId
);
Long
findByTypeAndMaterialIdOut
(
@Param
(
"mId"
)
Long
mId
);
int
findByTypeAndDepotIdAndMaterialIdIn
(
@Param
(
"depotId"
)
Long
depotId
,
@Param
(
"mId"
)
Long
mId
);
int
findByTypeAndDepotIdAndMaterialIdOut
(
@Param
(
"depotId"
)
Long
depotId
,
@Param
(
"mId"
)
Long
mId
);
List
<
DepotItemVo4WithInfoEx
>
getDetailList
(
@Param
(
"headerId"
)
Long
headerId
);
...
...
@@ -72,62 +55,6 @@ public interface DepotItemMapperEx {
@Param
(
"headIds"
)
String
headIds
,
@Param
(
"materialIds"
)
String
materialIds
);
BigDecimal
findByTypeInIsPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findByTypeInIsNotPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findByTypeOutIsPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findByTypeOutIsNotPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findPriceByTypeInIsPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findPriceByTypeInIsNotPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findPriceByTypeOutIsPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findPriceByTypeOutIsNotPrev
(
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findAssembleIsPrev
(
@Param
(
"subType"
)
String
subType
,
@Param
(
"mType"
)
String
mType
,
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
findAssembleIsNotPrev
(
@Param
(
"subType"
)
String
subType
,
@Param
(
"mType"
)
String
mType
,
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
,
@Param
(
"MonthTime"
)
String
MonthTime
);
BigDecimal
buyOrSaleNumber
(
@Param
(
"type"
)
String
type
,
@Param
(
"subType"
)
String
subType
,
...
...
@@ -142,15 +69,13 @@ public interface DepotItemMapperEx {
@Param
(
"MonthTime"
)
String
MonthTime
,
@Param
(
"sumType"
)
String
sumType
);
BigDecimal
findGiftByTypeIn
(
@Param
(
"subType"
)
String
subType
,
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
);
DepotItemVo4Stock
getStockByParam
(
@Param
(
"depotId"
)
Long
depotId
,
@Param
(
"mId"
)
Long
mId
,
@Param
(
"beginTime"
)
String
beginTime
,
@Param
(
"endTime"
)
String
endTime
,
@Param
(
"tenantId"
)
Long
tenantId
);
BigDecimal
findGiftByTypeOut
(
@Param
(
"subType"
)
String
subType
,
@Param
(
"ProjectId"
)
Integer
ProjectId
,
@Param
(
"MId"
)
Long
MId
);
/**
* create by: cjl
* description:
...
...
src/main/java/com/jsh/erp/datasource/vo/DepotItemVo4Stock.java
0 → 100644
View file @
ee839055
package
com.jsh.erp.datasource.vo
;
import
java.math.BigDecimal
;
public
class
DepotItemVo4Stock
{
private
BigDecimal
inNum
;
private
BigDecimal
outNum
;
public
BigDecimal
getInNum
()
{
return
inNum
;
}
public
void
setInNum
(
BigDecimal
inNum
)
{
this
.
inNum
=
inNum
;
}
public
BigDecimal
getOutNum
()
{
return
outNum
;
}
public
void
setOutNum
(
BigDecimal
outNum
)
{
this
.
outNum
=
outNum
;
}
}
src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
ee839055
...
...
@@ -469,7 +469,7 @@ public class DepotHeadService {
* @return java.lang.String
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
addDepotHeadAndDetail
(
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
)
throws
Exception
{
public
void
addDepotHeadAndDetail
(
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
,
Long
tenantId
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
...
...
@@ -494,7 +494,7 @@ public class DepotHeadService {
}
}
/**入库和出库处理单据子表信息*/
depotItemService
.
saveDetials
(
inserted
,
deleted
,
updated
,
depotHead
.
getId
());
depotItemService
.
saveDetials
(
inserted
,
deleted
,
updated
,
depotHead
.
getId
()
,
tenantId
);
/**如果关联单据号非空则更新订单的状态为2 */
if
(
depotHead
.
getLinknumber
()!=
null
)
{
DepotHead
depotHeadOrders
=
new
DepotHead
();
...
...
@@ -522,7 +522,8 @@ public class DepotHeadService {
* @return java.lang.Object
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
updateDepotHeadAndDetail
(
Long
id
,
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
,
BigDecimal
preTotalPrice
)
throws
Exception
{
public
void
updateDepotHeadAndDetail
(
Long
id
,
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
,
BigDecimal
preTotalPrice
,
Long
tenantId
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
id
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
...
...
@@ -545,7 +546,7 @@ public class DepotHeadService {
}
}
/**入库和出库处理单据子表信息*/
depotItemService
.
saveDetials
(
inserted
,
deleted
,
updated
,
depotHead
.
getId
());
depotItemService
.
saveDetials
(
inserted
,
deleted
,
updated
,
depotHead
.
getId
()
,
tenantId
);
}
/**
...
...
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
ee839055
...
...
@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapper;
import
com.jsh.erp.datasource.mappers.DepotItemMapperEx
;
import
com.jsh.erp.datasource.mappers.SerialNumberMapperEx
;
import
com.jsh.erp.datasource.vo.DepotItemStockWarningCount
;
import
com.jsh.erp.datasource.vo.DepotItemVo4Stock
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.log.LogService
;
...
...
@@ -192,38 +193,6 @@ public class DepotItemService {
return
result
;
}
public
List
<
DepotItemVo4Material
>
findStockNumByMaterialIdList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
mIdStr
=
map
.
get
(
"mId"
);
Long
mId
=
null
;
if
(!
StringUtil
.
isEmpty
(
mIdStr
))
{
mId
=
Long
.
parseLong
(
mIdStr
);
}
String
monthTime
=
map
.
get
(
"monthTime"
);
List
<
DepotItemVo4Material
>
list
=
null
;
try
{
list
=
depotItemMapperEx
.
findStockNumByMaterialIdList
(
mId
,
monthTime
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
Long
findStockNumByMaterialIdCounts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
mIdStr
=
map
.
get
(
"mId"
);
Long
mId
=
null
;
if
(!
StringUtil
.
isEmpty
(
mIdStr
))
{
mId
=
Long
.
parseLong
(
mIdStr
);
}
String
monthTime
=
map
.
get
(
"monthTime"
);
Long
result
=
null
;
try
{
result
=
depotItemMapperEx
.
findStockNumByMaterialIdCounts
(
mId
,
monthTime
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertDepotItemWithObj
(
DepotItem
depotItem
)
throws
Exception
{
int
result
=
0
;
...
...
@@ -260,14 +229,6 @@ public class DepotItemService {
return
result
;
}
public
int
findByTypeAndMaterialIdAndDepotId
(
String
type
,
Long
mId
,
Long
depotId
)
{
if
(
type
.
equals
(
TYPE
))
{
return
depotItemMapperEx
.
findByTypeAndDepotIdAndMaterialIdIn
(
depotId
,
mId
);
}
else
{
return
depotItemMapperEx
.
findByTypeAndDepotIdAndMaterialIdOut
(
depotId
,
mId
);
}
}
public
List
<
DepotItemVo4WithInfoEx
>
getDetailList
(
Long
headerId
)
throws
Exception
{
List
<
DepotItemVo4WithInfoEx
>
list
=
null
;
try
{
...
...
@@ -298,69 +259,8 @@ public class DepotItemService {
return
result
;
}
public
BigDecimal
findByType
(
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
Exception
{
BigDecimal
result
=
null
;
try
{
if
(
TYPE
.
equals
(
type
))
{
if
(
isPrev
)
{
result
=
depotItemMapperEx
.
findByTypeInIsPrev
(
ProjectId
,
MId
,
MonthTime
);
}
else
{
result
=
depotItemMapperEx
.
findByTypeInIsNotPrev
(
ProjectId
,
MId
,
MonthTime
);
}
}
else
{
if
(
isPrev
)
{
result
=
depotItemMapperEx
.
findByTypeOutIsPrev
(
ProjectId
,
MId
,
MonthTime
);
}
else
{
result
=
depotItemMapperEx
.
findByTypeOutIsNotPrev
(
ProjectId
,
MId
,
MonthTime
);
}
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
BigDecimal
findPriceByType
(
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
Exception
{
BigDecimal
result
=
null
;
try
{
if
(
TYPE
.
equals
(
type
))
{
if
(
isPrev
)
{
result
=
depotItemMapperEx
.
findPriceByTypeInIsPrev
(
ProjectId
,
MId
,
MonthTime
);
}
else
{
result
=
depotItemMapperEx
.
findPriceByTypeInIsNotPrev
(
ProjectId
,
MId
,
MonthTime
);
}
}
else
{
if
(
isPrev
)
{
result
=
depotItemMapperEx
.
findPriceByTypeOutIsPrev
(
ProjectId
,
MId
,
MonthTime
);
}
else
{
result
=
depotItemMapperEx
.
findPriceByTypeOutIsNotPrev
(
ProjectId
,
MId
,
MonthTime
);
}
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
BigDecimal
findAssembleByType
(
String
subType
,
String
mType
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
Exception
{
BigDecimal
result
=
null
;
try
{
if
(
isPrev
)
{
result
=
depotItemMapperEx
.
findAssembleIsPrev
(
subType
,
mType
,
ProjectId
,
MId
,
MonthTime
);
}
else
{
result
=
depotItemMapperEx
.
findAssembleIsNotPrev
(
subType
,
mType
,
ProjectId
,
MId
,
MonthTime
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
BigDecimal
buyOrSale
(
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
,
String
sumType
)
throws
Exception
{
BigDecimal
result
=
null
;
BigDecimal
result
=
BigDecimal
.
ZERO
;
try
{
if
(
SUM_TYPE
.
equals
(
sumType
))
{
result
=
depotItemMapperEx
.
buyOrSaleNumber
(
type
,
subType
,
MId
,
MonthTime
,
sumType
);
...
...
@@ -380,7 +280,7 @@ public class DepotItemService {
* 这里重点重申一下:BasicNumber=OperNumber*ratio
* */
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
)
throws
Exception
{
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
,
Long
tenantId
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_ITEM
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
...
...
@@ -525,7 +425,9 @@ public class DepotItemService {
if
(
material
==
null
){
continue
;
}
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
(),
depotItem
.
getDepotid
())<(
depotItem
.
getBasicnumber
()==
null
?
0
:
depotItem
.
getBasicnumber
()).
intValue
()){
BigDecimal
stock
=
getStockByParam
(
depotItem
.
getDepotid
(),
depotItem
.
getMaterialid
(),
null
,
null
,
tenantId
);
BigDecimal
thisBasicNumber
=
depotItem
.
getBasicnumber
()==
null
?
BigDecimal
.
ZERO
:
depotItem
.
getBasicnumber
();
if
(
stock
.
compareTo
(
thisBasicNumber
)<
0
){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
...
...
@@ -648,7 +550,9 @@ public class DepotItemService {
}
/**出库时处理序列号*/
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
(),
depotItem
.
getDepotid
())<(
depotItem
.
getBasicnumber
()==
null
?
0
:
depotItem
.
getBasicnumber
()).
intValue
()){
BigDecimal
stock
=
getStockByParam
(
depotItem
.
getDepotid
(),
depotItem
.
getMaterialid
(),
null
,
null
,
tenantId
);
BigDecimal
thisBasicNumber
=
depotItem
.
getBasicnumber
()==
null
?
BigDecimal
.
ZERO
:
depotItem
.
getBasicnumber
();
if
(
stock
.
compareTo
(
thisBasicNumber
)<
0
){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_CODE
,
String
.
format
(
ExceptionConstants
.
MATERIAL_STOCK_NOT_ENOUGH_MSG
,
material
==
null
?
""
:
material
.
getName
()));
}
...
...
@@ -687,17 +591,7 @@ public class DepotItemService {
}
return
unitName
;
}
/**
* 查询商品当前库存数量是否充足,
*
* */
public
int
getCurrentInStock
(
Long
materialId
,
Long
depotId
){
//入库数量
int
inSum
=
findByTypeAndMaterialIdAndDepotId
(
BusinessConstants
.
DEPOTHEAD_TYPE_STORAGE
,
materialId
,
depotId
);
//出库数量
int
outSum
=
findByTypeAndMaterialIdAndDepotId
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
,
materialId
,
depotId
);
return
(
inSum
-
outSum
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteDepotItemByIds
(
String
ids
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_ITEM
,
...
...
@@ -749,4 +643,45 @@ public class DepotItemService {
BigDecimal
count
=
depotItemMapperEx
.
getFinishNumber
(
mid
,
linkNumber
);
return
count
;
}
/**
* 库存统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public
BigDecimal
getStockByParam
(
Long
depotId
,
Long
mId
,
String
beginTime
,
String
endTime
,
Long
tenantId
){
DepotItemVo4Stock
stockObj
=
depotItemMapperEx
.
getStockByParam
(
depotId
,
mId
,
beginTime
,
endTime
,
tenantId
);
BigDecimal
intNum
=
stockObj
.
getInNum
();
BigDecimal
outNum
=
stockObj
.
getOutNum
();
return
intNum
.
subtract
(
outNum
);
}
/**
* 入库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public
BigDecimal
getInNumByParam
(
Long
depotId
,
Long
mId
,
String
beginTime
,
String
endTime
,
Long
tenantId
){
DepotItemVo4Stock
stockObj
=
depotItemMapperEx
.
getStockByParam
(
depotId
,
mId
,
beginTime
,
endTime
,
tenantId
);
return
stockObj
.
getInNum
();
}
/**
* 出库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public
BigDecimal
getOutNumByParam
(
Long
depotId
,
Long
mId
,
String
beginTime
,
String
endTime
,
Long
tenantId
){
DepotItemVo4Stock
stockObj
=
depotItemMapperEx
.
getStockByParam
(
depotId
,
mId
,
beginTime
,
endTime
,
tenantId
);
return
stockObj
.
getOutNum
();
}
}
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
ee839055
...
...
@@ -53,6 +53,11 @@
<result
column=
"BasicLinjieNumber"
jdbcType=
"DECIMAL"
property=
"BasicLinjieNumber"
/>
</resultMap>
<resultMap
id=
"StockMap"
type=
"com.jsh.erp.datasource.vo.DepotItemVo4Stock"
>
<result
column=
"in_stock"
jdbcType=
"DECIMAL"
property=
"inNum"
/>
<result
column=
"out_stock"
jdbcType=
"DECIMAL"
property=
"outNum"
/>
</resultMap>
<select
id=
"selectByConditionDepotItem"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap"
>
select *
FROM jsh_depotitem
...
...
@@ -113,27 +118,6 @@
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"findStockNumByMaterialIdList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultAndMaterialMap"
>
select di.*,m.Name mName,m.Model mModel from jsh_depotitem di
inner join jsh_material m on di.MaterialId=m.Id and ifnull(m.delete_Flag,'0') !='1'
where 1=1
<if
test=
"mId != null"
>
and di.MaterialId=${mId}
</if>
and ifnull(di.delete_Flag,'0') !='1'
<if
test=
"offset != null and rows != null"
>
limit #{offset},#{rows}
</if>
</select>
<select
id=
"findStockNumByMaterialIdCounts"
resultType=
"java.lang.Long"
>
select count(*) from jsh_depotitem where 1=1
<if
test=
"mId != null"
>
and MaterialId=${mId}
</if>
and ifnull(delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeAndMaterialIdIn"
resultType=
"java.lang.Long"
>
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
...
...
@@ -151,23 +135,6 @@
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeAndDepotIdAndMaterialIdIn"
resultType=
"java.lang.Integer"
>
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type='入库'
and di.MaterialId = ${mId} and di.DepotId = ${depotId}
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeAndDepotIdAndMaterialIdOut"
resultType=
"java.lang.Integer"
>
select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depothead dh
INNER JOIN jsh_depotitem di on dh.id=di.HeaderId and ifnull(di.delete_Flag,'0') !='1'
where dh.type='出库'
and dh.SubType!='调拨'
and di.MaterialId = ${mId} and di.DepotId = ${depotId}
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select
id=
"getDetailList"
parameterType=
"com.jsh.erp.datasource.entities.DepotItemExample"
resultMap=
"ResultWithInfoExMap"
>
select di.*,m.Name MName,m.Model MModel,m.Unit MaterialUnit,m.Color MColor,m.Standard MStandard,m.Mfrs MMfrs,
m.OtherField1 MOtherField1,m.OtherField2 MOtherField2,m.OtherField3 MOtherField3,
...
...
@@ -217,129 +184,6 @@
group by m.id) cc
</select>
<select
id=
"findByTypeInIsPrev"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId}
and dh.OperTime
<
'${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeInIsNotPrev"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId} and dh.OperTime
>
= '${MonthTime}-01 00:00:00'
and dh.OperTime
<
= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeOutIsPrev"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime
<
'${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findByTypeOutIsNotPrev"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime
>
= '${MonthTime}-01 00:00:00'
and dh.OperTime
<
= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findPriceByTypeInIsPrev"
resultType=
"java.math.BigDecimal"
>
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId}
and dh.OperTime
<
'${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findPriceByTypeInIsNotPrev"
resultType=
"java.math.BigDecimal"
>
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and
((dh.type='入库' and di.DepotId=${ProjectId})
or
(dh.SubType='调拨' and di.AnotherDepotId=${ProjectId})
or
(di.AnotherDepotId=${ProjectId}))
and di.MaterialId = ${MId} and dh.OperTime
>
= '${MonthTime}-01 00:00:00'
and dh.OperTime
<
= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findPriceByTypeOutIsPrev"
resultType=
"java.math.BigDecimal"
>
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime
<
'${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findPriceByTypeOutIsNotPrev"
resultType=
"java.math.BigDecimal"
>
select sum(AllPrice) as AllPrice from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id and dh.type='出库'
and di.DepotId= ${ProjectId}
and di.MaterialId = ${MId}
and dh.OperTime
>
= '${MonthTime}-01 00:00:00'
and dh.OperTime
<
= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findAssembleIsPrev"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.SubType= '${subType}'
and di.MType= '${mType}'
and di.MaterialId = ${MId}
and dh.OperTime
<
'${MonthTime}-01 00:00:00'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findAssembleIsNotPrev"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.SubType= '${subType}'
and di.MType= '${mType}'
and di.MaterialId = ${MId}
and dh.OperTime
>
= '${MonthTime}-01 00:00:00'
and dh.OperTime
<
= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"buyOrSaleNumber"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
...
...
@@ -362,24 +206,33 @@
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findGiftByTypeIn"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.SubType='${subType}'
and di.AnotherDepotId=${ProjectId}
and di.MaterialId =${MId}
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select
id=
"findGiftByTypeOut"
resultType=
"java.math.BigDecimal"
>
select sum(BasicNumber) as BasicNumber from jsh_depotitem di,jsh_depothead dh
where di.HeaderId = dh.id
and dh.SubType='${subType}'
and di.DepotId=${ProjectId}
and di.MaterialId =${MId}
<select
id=
"getStockByParam"
resultMap=
"StockMap"
>
select ifnull((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal),0) as in_stock,
ifnull((curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal),0) out_stock
from
(select sum(if(dh.type='入库'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
, di.BasicNumber,0)) as inTotal,
sum(if(dh.SubType='调拨'
<if
test=
"depotId != null"
>
and di.AnotherDepotId=#{depotId}
</if>
,di.BasicNumber,0)) as transfInTotal,
sum(if(dh.SubType='调拨'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
,di.BasicNumber,0)) as transfOutTotal,
sum(if(dh.type='出库' and dh.SubType!='调拨'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
,di.BasicNumber,0)) as outTotal,
sum(if(dh.SubType='组装单' and di.MType='组合件'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
,di.BasicNumber,0)) as assemInTotal,
sum(if(dh.SubType='组装单' and di.MType='普通子件'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
,di.BasicNumber,0)) as assemOutTotal,
sum(if(dh.SubType='拆卸单' and di.MType='普通子件'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
,di.BasicNumber,0)) as disAssemInTotal,
sum(if(dh.SubType='拆卸单' and di.MType='组合件'
<if
test=
"depotId != null"
>
and di.DepotId=#{depotId}
</if>
,di.BasicNumber,0)) as disAssemOutTotal
from
jsh_depothead dh,jsh_depotitem di
where 1=1
and dh.id=di.HeaderId
and di.MaterialId=#{mId}
<if
test=
"beginTime != null"
>
and dh.OperTime
>
= '${beginTime}'
</if>
<if
test=
"endTime != null"
>
and dh.OperTime
<
= '${endTime}'
</if>
and dh.tenant_id=#{tenantId}
and di.tenant_id=#{tenantId}
and ifnull(dh.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
and ifnull(di.delete_Flag,'0') !='1'
) as curep
</select>
<select
id=
"findDepotItemListBydepotheadId"
resultType=
"com.jsh.erp.datasource.entities.DepotItem"
>
...
...
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