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
e9bcdb21
Commit
e9bcdb21
authored
Aug 22, 2021
by
季圣华
Browse files
解决批量删除单据bug
parent
56dbc071
Changes
1
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
e9bcdb21
...
...
@@ -3,10 +3,7 @@ package com.jsh.erp.service.depotHead;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.DepotHead
;
import
com.jsh.erp.datasource.entities.DepotHeadExample
;
import
com.jsh.erp.datasource.entities.DepotItem
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.mappers.DepotHeadMapper
;
import
com.jsh.erp.datasource.mappers.DepotHeadMapperEx
;
import
com.jsh.erp.datasource.mappers.DepotItemMapperEx
;
...
...
@@ -241,69 +238,73 @@ public class DepotHeadService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteDepotHead
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
int
result
=
0
;
try
{
//查询单据主表信息
DepotHead
depotHead
=
getDepotHead
(
id
);
//只有未审核的单据才能被删除
if
(
"0"
.
equals
(
depotHead
.
getStatus
()))
{
User
userInfo
=
userService
.
getCurrentUser
();
//删除出库数据回收序列号
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())
&&
!
BusinessConstants
.
SUB_TYPE_TRANSFER
.
equals
(
depotHead
.
getSubType
()))
{
//查询单据子表列表
List
<
DepotItem
>
depotItemList
=
null
;
try
{
depotItemList
=
depotItemMapperEx
.
findDepotItemListBydepotheadId
(
id
,
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
);
}
catch
(
Exception
e
)
{
JshException
.
readFail
(
logger
,
e
);
}
/**回收序列号*/
if
(
depotItemList
!=
null
&&
depotItemList
.
size
()
>
0
)
{
for
(
DepotItem
depotItem
:
depotItemList
)
{
//BasicNumber=OperNumber*ratio
serialNumberService
.
cancelSerialNumber
(
depotItem
.
getMaterialId
(),
depotItem
.
getHeaderId
(),
(
depotItem
.
getBasicNumber
()
==
null
?
0
:
depotItem
.
getBasicNumber
()).
intValue
(),
userInfo
);
}
}
}
//对于零售出库单据,更新会员的预收款信息
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())
&&
BusinessConstants
.
SUB_TYPE_RETAIL
.
equals
(
depotHead
.
getSubType
())){
if
(
BusinessConstants
.
PAY_TYPE_PREPAID
.
equals
(
depotHead
.
getPayType
()))
{
if
(
depotHead
.
getOrganId
()
!=
null
)
{
supplierService
.
updateAdvanceIn
(
depotHead
.
getOrganId
(),
depotHead
.
getTotalPrice
().
abs
());
}
}
}
/**删除单据子表数据*/
depotItemMapperEx
.
batchDeleteDepotItemByDepotHeadIds
(
new
Long
[]{
id
});
//更新当前库存
List
<
DepotItem
>
list
=
depotItemService
.
getListByHeaderId
(
id
);
for
(
DepotItem
depotItem
:
list
)
{
depotItemService
.
updateCurrentStock
(
depotItem
);
}
/**删除单据主表信息*/
batchDeleteDepotHeadByIds
(
id
.
toString
());
logService
.
insertLog
(
"单据"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
depotHead
.
getNumber
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
result
=
1
;
}
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
return
batchDeleteBillByIds
(
id
.
toString
());
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteDepotHead
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteBillByIds
(
ids
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteBillByIds
(
String
ids
)
throws
Exception
{
int
result
=
0
;
try
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
);
List
<
DepotHead
>
dhList
=
getDepotHeadListByIds
(
ids
);
for
(
DepotHead
depotHead:
dhList
){
sb
.
append
(
"["
).
append
(
depotHead
.
getNumber
()).
append
(
"]"
);
}
logService
.
insertLog
(
"单据"
,
sb
.
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
StringUtil
.
isNotEmpty
(
ids
)){
String
[]
headIds
=
ids
.
split
(
","
);
for
(
int
i
=
0
;
i
<
headIds
.
length
;
i
++){
deleteDepotHead
(
Long
.
valueOf
(
headIds
[
i
]),
request
);
Long
id
=
Long
.
parseLong
(
headIds
[
i
]);
//查询单据主表信息
DepotHead
depotHead
=
getDepotHead
(
id
);
//只有未审核的单据才能被删除
if
(
"0"
.
equals
(
depotHead
.
getStatus
()))
{
User
userInfo
=
userService
.
getCurrentUser
();
//删除出库数据回收序列号
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())
&&
!
BusinessConstants
.
SUB_TYPE_TRANSFER
.
equals
(
depotHead
.
getSubType
()))
{
//查询单据子表列表
List
<
DepotItem
>
depotItemList
=
null
;
try
{
depotItemList
=
depotItemMapperEx
.
findDepotItemListBydepotheadId
(
id
,
BusinessConstants
.
ENABLE_SERIAL_NUMBER_ENABLED
);
}
catch
(
Exception
e
)
{
JshException
.
readFail
(
logger
,
e
);
}
/**回收序列号*/
if
(
depotItemList
!=
null
&&
depotItemList
.
size
()
>
0
)
{
for
(
DepotItem
depotItem
:
depotItemList
)
{
//BasicNumber=OperNumber*ratio
serialNumberService
.
cancelSerialNumber
(
depotItem
.
getMaterialId
(),
depotItem
.
getHeaderId
(),
(
depotItem
.
getBasicNumber
()
==
null
?
0
:
depotItem
.
getBasicNumber
()).
intValue
(),
userInfo
);
}
}
}
//对于零售出库单据,更新会员的预收款信息
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())
&&
BusinessConstants
.
SUB_TYPE_RETAIL
.
equals
(
depotHead
.
getSubType
())){
if
(
BusinessConstants
.
PAY_TYPE_PREPAID
.
equals
(
depotHead
.
getPayType
()))
{
if
(
depotHead
.
getOrganId
()
!=
null
)
{
supplierService
.
updateAdvanceIn
(
depotHead
.
getOrganId
(),
depotHead
.
getTotalPrice
().
abs
());
}
}
}
/**删除单据子表数据*/
depotItemMapperEx
.
batchDeleteDepotItemByDepotHeadIds
(
new
Long
[]{
id
});
//更新当前库存
List
<
DepotItem
>
list
=
depotItemService
.
getListByHeaderId
(
id
);
for
(
DepotItem
depotItem
:
list
)
{
depotItemService
.
updateCurrentStock
(
depotItem
);
}
/**删除单据主表信息*/
batchDeleteDepotHeadByIds
(
id
.
toString
());
}
}
}
result
=
1
;
...
...
@@ -313,6 +314,12 @@ public class DepotHeadService {
return
result
;
}
/**
* 删除单据主表信息
* @param ids
* @return
* @throws Exception
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteDepotHeadByIds
(
String
ids
)
throws
Exception
{
User
userInfo
=
userService
.
getCurrentUser
();
...
...
@@ -326,6 +333,19 @@ public class DepotHeadService {
return
result
;
}
public
List
<
DepotHead
>
getDepotHeadListByIds
(
String
ids
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
List
<
DepotHead
>
list
=
new
ArrayList
<>();
try
{
DepotHeadExample
example
=
new
DepotHeadExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
list
=
depotHeadMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
DepotHeadExample
example
=
new
DepotHeadExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
...
...
@@ -625,7 +645,6 @@ public class DepotHeadService {
* 新增单据主表及单据子表信息
* @param beanJson
* @param rows
* @param tenantId
* @param request
* @throws Exception
*/
...
...
@@ -710,7 +729,6 @@ public class DepotHeadService {
* 更新单据主表及单据子表信息
* @param beanJson
* @param rows
* @param tenantId
* @param request
* @throws Exception
*/
...
...
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