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
76034a12
Commit
76034a12
authored
Apr 10, 2019
by
qiankunpingtai
Browse files
去除外键之账户信息表jsh_account相关修改
parent
85bc297e
Changes
11
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/account.html
View file @
76034a12
...
...
@@ -234,7 +234,14 @@
if
(
res
&&
res
.
code
==
200
)
{
$
(
"
#searchBtn
"
).
click
();
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除结算账户失败,请稍后再试!
'
,
'
error
'
);
if
(
res
&&
res
.
code
==
601
){
var
jsondata
=
{};
jsondata
.
ids
=
accountTotalInfo
[
0
];
jsondata
.
deleteType
=
'
2
'
;
batDeleteAccountForceConfirm
(
res
,
"
/account/batchDeleteAccountByIds
"
,
jsondata
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除结算账户失败,请稍后再试!
'
,
'
error
'
);
}
}
},
//此处添加错误处理
...
...
@@ -278,7 +285,14 @@
$
(
"
#searchBtn
"
).
click
();
$
(
"
:checkbox
"
).
attr
(
"
checked
"
,
false
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除结算账户失败,请稍后再试!
'
,
'
error
'
);
if
(
res
&&
res
.
code
==
601
){
var
jsondata
=
{};
jsondata
.
ids
=
ids
;
jsondata
.
deleteType
=
'
2
'
;
batDeleteAccountForceConfirm
(
res
,
"
/account/batchDeleteAccountByIds
"
,
jsondata
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除结算账户失败,请稍后再试!
'
,
'
error
'
);
}
}
},
//此处添加错误处理
...
...
@@ -291,6 +305,33 @@
});
}
}
/**
* 确认强制删除
* */
function
batDeleteAccountForceConfirm
(
res
,
url
,
jsondata
)
{
$
.
messager
.
confirm
(
'
删除确认
'
,
res
.
msg
,
function
(
r
)
{
if
(
r
)
{
$
.
ajax
({
type
:
"
post
"
,
url
:
url
,
dataType
:
"
json
"
,
data
:
(
jsondata
),
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
==
200
)
{
$
(
"
#searchBtn
"
).
click
();
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除结算账户失败,请稍后再试!
'
,
'
error
'
);
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除结算账户异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
});
}
//增加结算账户
var
url
;
...
...
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
76034a12
...
...
@@ -200,6 +200,14 @@ public class BusinessConstants {
public
static
final
String
TYPE_NAME_ROLE_APP
=
"RoleAPP"
;
public
static
final
String
TYPE_NAME_ROLE_FUNCTIONS
=
"RoleFunctions"
;
/**
* 删除类型
* 1正常删除
* 2强制删除
* */
public
static
final
String
DELETE_TYPE_NORMAL
=
"1"
;
public
static
final
String
DELETE_TYPE_FORCE
=
"2"
;
...
...
src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
76034a12
...
...
@@ -23,6 +23,17 @@ public class ExceptionConstants {
**/
public
static
final
int
SERVICE_SYSTEM_ERROR_CODE
=
500
;
public
static
final
String
SERVICE_SYSTEM_ERROR_MSG
=
"未知异常"
;
/**
* 删除操作被拒绝,请联系管理员
**/
public
static
final
int
DELETE_REFUSED_CODE
=
600
;
public
static
final
String
DELETE_REFUSED_MSG
=
"删除操作被拒绝,请联系管理员"
;
/**
* 检测到存在依赖数据,是否强制删除?
**/
public
static
final
int
DELETE_FORCE_CONFIRM_CODE
=
601
;
public
static
final
String
DELETE_FORCE_CONFIRM_MSG
=
"检测到存在依赖数据,是否强制删除?"
;
/**
* 用户信息
* type = 5
...
...
src/main/java/com/jsh/erp/controller/AccountController.java
View file @
76034a12
package
com.jsh.erp.controller
;
import
com.alibaba.druid.util.StringUtils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.Account
;
import
com.jsh.erp.datasource.vo.AccountVo4InOutList
;
...
...
@@ -150,10 +152,28 @@ public class AccountController {
* @return java.lang.Object
*/
@RequestMapping
(
value
=
"/batchDeleteAccountByIds"
)
public
Object
batchDeleteAccountByIds
(
@RequestParam
(
"ids"
)
String
ids
)
throws
Exception
{
public
Object
batchDeleteAccountByIds
(
@RequestParam
(
"ids"
)
String
ids
,
@RequestParam
(
value
=
"deleteType"
,
required
=
false
,
defaultValue
=
BusinessConstants
.
DELETE_TYPE_NORMAL
)
String
deleteType
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
int
i
=
accountService
.
batchDeleteAccountByIds
(
ids
);
/**
* create by: qiankunpingtai
* create time: 2019/4/10 10:19
* website:https://qiankunpingtai.cn
* description:
* 出于兼容性考虑,没有传递删除类型时,默认为正常删除
*/
int
i
=
0
;
if
(
BusinessConstants
.
DELETE_TYPE_NORMAL
.
equals
(
deleteType
)){
i
=
accountService
.
batchDeleteAccountByIdsNormal
(
ids
);
}
else
if
(
BusinessConstants
.
DELETE_TYPE_FORCE
.
equals
(
deleteType
)){
i
=
accountService
.
batchDeleteAccountByIds
(
ids
);
}
else
{
logger
.
error
(
"异常码[{}],异常提示[{}],参数,ids[{}],deleteType[{}]"
,
ExceptionConstants
.
DELETE_REFUSED_CODE
,
ExceptionConstants
.
DELETE_REFUSED_MSG
,
ids
,
deleteType
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DELETE_REFUSED_CODE
,
ExceptionConstants
.
DELETE_REFUSED_MSG
);
}
if
(
i
<
1
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,ids[{}]"
,
ExceptionConstants
.
ACCOUNT_DELETE_FAILED_CODE
,
ExceptionConstants
.
ACCOUNT_DELETE_FAILED_MSG
,
ids
);
...
...
src/main/java/com/jsh/erp/datasource/mappers/AccountHeadMapperEx.java
View file @
76034a12
...
...
@@ -36,5 +36,7 @@ public interface AccountHeadMapperEx {
List
<
AccountHeadVo4ListEx
>
getDetailByNumber
(
@Param
(
"billNo"
)
String
billNo
);
int
batchDeleteAccountHeadByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
int
batchDeleteAccountHeadByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
[]
ids
);
List
<
AccountHead
>
getAccountHeadListByAccountIds
(
@Param
(
"accountIds"
)
String
[]
accountIds
);
}
\ No newline at end of file
src/main/java/com/jsh/erp/datasource/mappers/AccountItemMapperEx.java
View file @
76034a12
...
...
@@ -25,5 +25,7 @@ public interface AccountItemMapperEx {
List
<
AccountItemVo4List
>
getDetailList
(
@Param
(
"headerId"
)
Long
headerId
);
int
batchDeleteAccountItemByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
int
batchDeleteAccountItemByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
[]
ids
);
List
<
AccountItem
>
getAccountItemListByAccountIds
(
@Param
(
"accountIds"
)
String
[]
accountIds
);
}
\ No newline at end of file
src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapperEx.java
View file @
76034a12
...
...
@@ -115,4 +115,6 @@ public interface DepotHeadMapperEx {
Long
getBuildOnlyNumber
(
@Param
(
"seq_name"
)
String
seq_name
);
int
batchDeleteDepotHeadByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
List
<
DepotHead
>
getDepotHeadListByAccountIds
(
@Param
(
"accountIds"
)
String
[]
accountIds
);
}
src/main/java/com/jsh/erp/service/account/AccountService.java
View file @
76034a12
package
com.jsh.erp.service.account
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.mappers.*
;
import
com.jsh.erp.datasource.vo.AccountVo4InOutList
;
import
com.jsh.erp.datasource.vo.AccountVo4List
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
...
...
@@ -38,13 +41,19 @@ public class AccountService {
@Resource
private
DepotHeadMapper
depotHeadMapper
;
@Resource
private
DepotHeadMapperEx
depotHeadMapperEx
;
@Resource
private
AccountHeadMapper
accountHeadMapper
;
@Resource
private
AccountHeadMapperEx
accountHeadMapperEx
;
@Resource
private
AccountItemMapper
accountItemMapper
;
@Resource
private
AccountItemMapperEx
accountItemMapperEx
;
@Resource
private
LogService
logService
;
@Resource
private
UserService
userService
;
...
...
@@ -330,4 +339,64 @@ public class AccountService {
String
[]
idArray
=
ids
.
split
(
","
);
return
accountMapperEx
.
batchDeleteAccountByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* create time: 2019/4/10 10:31
* @Param: ids
* @return int
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteAccountByIdsNormal
(
String
ids
)
throws
Exception
{
/**
* 校验:
* 1、财务主表 jsh_accounthead
* 2、财务子表 jsh_accountitem
* 3、单据主表 jsh_depothead
* 是否有相关数据
* */
int
deleteTotal
=
0
;
if
(
StringUtils
.
isEmpty
(
ids
)){
return
deleteTotal
;
}
String
[]
idArray
=
ids
.
split
(
","
);
/**
* 校验财务主表 jsh_accounthead
* */
List
<
AccountHead
>
accountHeadList
=
accountHeadMapperEx
.
getAccountHeadListByAccountIds
(
idArray
);
if
(
accountHeadList
!=
null
&&
accountHeadList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,AccountIds[{}]"
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
,
ids
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
);
}
/**
* 校验财务子表 jsh_accountitem
* */
List
<
AccountItem
>
accountItemList
=
accountItemMapperEx
.
getAccountItemListByAccountIds
(
idArray
);
if
(
accountItemList
!=
null
&&
accountItemList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,AccountIds[{}]"
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
,
ids
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
);
}
/**
* 校验单据主表 jsh_depothead
* */
List
<
DepotHead
>
depotHeadList
=
depotHeadMapperEx
.
getDepotHeadListByAccountIds
(
idArray
);
if
(
depotHeadList
!=
null
&&
depotHeadList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,AccountIds[{}]"
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
,
ids
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
);
}
/**
* 校验通过执行删除操作
* */
deleteTotal
=
batchDeleteAccountByIds
(
ids
);
return
deleteTotal
;
}
}
src/main/resources/mapper_xml/AccountHeadMapperEx.xml
View file @
76034a12
...
...
@@ -88,4 +88,16 @@
</foreach>
)
</update>
<select
id=
"getAccountHeadListByAccountIds"
resultMap=
"com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List"
/>
from jsh_accounthead
where 1=1
and accountId in (
<foreach
collection=
"accountIds"
item=
"accountId"
separator=
","
>
#{accountId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper_xml/AccountItemMapperEx.xml
View file @
76034a12
...
...
@@ -60,4 +60,16 @@
</foreach>
)
</update>
<select
id=
"getAccountItemListByAccountIds"
resultMap=
"com.jsh.erp.datasource.mappers.AccountItemMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.AccountItemMapper.Base_Column_List"
/>
from jsh_accountitem
where 1=1
and accountId in (
<foreach
collection=
"accountIds"
item=
"accountId"
separator=
","
>
#{accountId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper_xml/DepotHeadMapperEx.xml
View file @
76034a12
...
...
@@ -438,5 +438,17 @@
</foreach>
)
</update>
<select
id=
"getDepotHeadListByAccountIds"
resultMap=
"com.jsh.erp.datasource.mappers.DepotHeadMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.DepotHeadMapper.Base_Column_List"
/>
from jsh_depothead
where 1=1
and accountId in (
<foreach
collection=
"accountIds"
item=
"accountId"
separator=
","
>
#{accountId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>
\ No newline at end of file
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