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
Commit
ee839055
authored
Oct 12, 2019
by
季圣华
Browse files
优化库存计算方式
parent
26bd6235
Changes
10
Expand all
Hide 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();
}
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
,
@RequestParam
(
"deleted"
)
String
deleted
,
@RequestParam
(
"updated"
)
String
updated
,
@RequestParam
(
"preTotalPrice"
)
BigDecimal
preTotalPrice
)
throws
Exception
{
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
,
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
This diff is collapsed.
Click to expand it.
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,12 +425,14 @@ 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
()));
}
/**出库时处理序列号*/
/**出库时处理序列号*/
if
(!
BusinessConstants
.
SUB_TYPE_TRANSFER
.
equals
(
depotHead
.
getSubtype
()))
{
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
...
...
@@ -648,14 +550,16 @@ 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
()));
}
if
(!
BusinessConstants
.
SUB_TYPE_TRANSFER
.
equals
(
depotHead
.
getSubtype
()))
{
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
if
(
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
.
equals
(
material
.
getEnableserialnumber
()))
{
//查询单据子表中开启序列号的数据列表
serialNumberService
.
checkAndUpdateSerialNumber
(
depotItem
,
userInfo
);
...
...
@@ -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