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
bce05cf0
Commit
bce05cf0
authored
Apr 10, 2019
by
qiankunpingtai
Browse files
去除外键之产品表jsh_material相关修改
parent
9fa082f2
Changes
6
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/materials/material.html
View file @
bce05cf0
...
@@ -780,7 +780,17 @@
...
@@ -780,7 +780,17 @@
if
(
res
&&
res
.
code
==
200
)
{
if
(
res
&&
res
.
code
==
200
)
{
$
(
"
#searchBtn
"
).
click
();
$
(
"
#searchBtn
"
).
click
();
}
else
{
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息失败,请稍后再试!
'
,
'
error
'
);
if
(
res
&&
res
.
code
==
601
){
var
jsondata
=
{};
jsondata
.
ids
=
materialID
;
jsondata
.
deleteType
=
'
2
'
;
var
type
=
'
single
'
;
batDeleteMaterialForceConfirm
(
res
,
"
/material/batchDeleteMaterialByIds
"
,
jsondata
,
type
);
}
else
if
(
res
&&
res
.
code
==
600
){
$
.
messager
.
alert
(
'
删除提示
'
,
res
.
msg
,
'
error
'
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息异常,请稍后再试!
'
,
'
error
'
);
}
}
}
},
},
//此处添加错误处理
//此处添加错误处理
...
@@ -825,7 +835,17 @@
...
@@ -825,7 +835,17 @@
$
(
"
#searchBtn
"
).
click
();
$
(
"
#searchBtn
"
).
click
();
$
(
"
:checkbox
"
).
attr
(
"
checked
"
,
false
);
$
(
"
:checkbox
"
).
attr
(
"
checked
"
,
false
);
}
else
{
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息失败,请稍后再试!
'
,
'
error
'
);
if
(
res
&&
res
.
code
==
601
){
var
jsondata
=
{};
jsondata
.
ids
=
ids
;
jsondata
.
deleteType
=
'
2
'
;
var
type
=
'
batch
'
;
batDeleteMaterialForceConfirm
(
res
,
"
/material/batchDeleteMaterialByIds
"
,
jsondata
,
type
);
}
else
if
(
res
&&
res
.
code
==
600
){
$
.
messager
.
alert
(
'
删除提示
'
,
res
.
msg
,
'
error
'
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息异常,请稍后再试!
'
,
'
error
'
);
}
}
}
},
},
//此处添加错误处理
//此处添加错误处理
...
@@ -838,6 +858,38 @@
...
@@ -838,6 +858,38 @@
});
});
}
}
}
}
/**
* 确认强制删除
* */
function
batDeleteMaterialForceConfirm
(
res
,
url
,
jsondata
,
type
)
{
$
.
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
();
if
(
type
==
'
batch
'
){
$
(
"
:checkbox
"
).
attr
(
"
checked
"
,
false
);
}
}
else
if
(
res
&&
res
.
code
==
600
){
$
.
messager
.
alert
(
'
删除提示
'
,
res
.
msg
,
'
error
'
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息异常,请稍后再试!
'
,
'
error
'
);
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
});
}
//批量启用
//批量启用
function
setEnableFun
()
{
function
setEnableFun
()
{
...
...
erp_web/pages/materials/person.html
View file @
bce05cf0
...
@@ -315,7 +315,7 @@
...
@@ -315,7 +315,7 @@
}
else
{
}
else
{
if
(
res
&&
res
.
code
==
601
){
if
(
res
&&
res
.
code
==
601
){
var
jsondata
=
{};
var
jsondata
=
{};
jsondata
.
ids
=
personID
;
jsondata
.
ids
=
ids
;
jsondata
.
deleteType
=
'
2
'
;
jsondata
.
deleteType
=
'
2
'
;
var
type
=
'
batch
'
;
var
type
=
'
batch
'
;
batDeletePersonForceConfirm
(
res
,
"
/person/batchDeletePersonByIds
"
,
jsondata
,
type
);
batDeletePersonForceConfirm
(
res
,
"
/person/batchDeletePersonByIds
"
,
jsondata
,
type
);
...
...
src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
bce05cf0
...
@@ -353,9 +353,20 @@ public class MaterialController {
...
@@ -353,9 +353,20 @@ public class MaterialController {
* @return java.lang.Object
* @return java.lang.Object
*/
*/
@RequestMapping
(
value
=
"/batchDeleteMaterialByIds"
)
@RequestMapping
(
value
=
"/batchDeleteMaterialByIds"
)
public
Object
batchDeleteMaterialByIds
(
@RequestParam
(
"ids"
)
String
ids
)
throws
Exception
{
public
Object
batchDeleteMaterialByIds
(
@RequestParam
(
"ids"
)
String
ids
,
@RequestParam
(
value
=
"deleteType"
,
required
=
false
,
defaultValue
=
BusinessConstants
.
DELETE_TYPE_NORMAL
)
String
deleteType
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
int
i
=
materialService
.
batchDeleteMaterialByIds
(
ids
);
int
i
=
0
;
if
(
BusinessConstants
.
DELETE_TYPE_NORMAL
.
equals
(
deleteType
)){
i
=
materialService
.
batchDeleteMaterialByIdsNormal
(
ids
);
}
else
if
(
BusinessConstants
.
DELETE_TYPE_FORCE
.
equals
(
deleteType
)){
i
=
materialService
.
batchDeleteMaterialByIds
(
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
){
if
(
i
<
1
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,ids[{}]"
,
logger
.
error
(
"异常码[{}],异常提示[{}],参数,ids[{}]"
,
ExceptionConstants
.
MATERIAL_DELETE_FAILED_CODE
,
ExceptionConstants
.
MATERIAL_DELETE_FAILED_MSG
,
ids
);
ExceptionConstants
.
MATERIAL_DELETE_FAILED_CODE
,
ExceptionConstants
.
MATERIAL_DELETE_FAILED_MSG
,
ids
);
...
...
src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
bce05cf0
...
@@ -170,4 +170,6 @@ public interface DepotItemMapperEx {
...
@@ -170,4 +170,6 @@ public interface DepotItemMapperEx {
int
batchDeleteDepotItemByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
int
batchDeleteDepotItemByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
List
<
DepotItem
>
getDepotItemListListByDepotIds
(
@Param
(
"depotIds"
)
String
[]
depotIds
);
List
<
DepotItem
>
getDepotItemListListByDepotIds
(
@Param
(
"depotIds"
)
String
[]
depotIds
);
List
<
DepotItem
>
getDepotItemListListByMaterialIds
(
@Param
(
"materialIds"
)
String
[]
materialIds
);
}
}
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
bce05cf0
package
com.jsh.erp.service.material
;
package
com.jsh.erp.service.material
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.mappers.DepotItemMapperEx
;
import
com.jsh.erp.datasource.mappers.MaterialMapper
;
import
com.jsh.erp.datasource.mappers.MaterialMapper
;
import
com.jsh.erp.datasource.mappers.MaterialMapperEx
;
import
com.jsh.erp.datasource.mappers.MaterialMapperEx
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.BaseResponseInfo
;
...
@@ -32,6 +36,8 @@ public class MaterialService {
...
@@ -32,6 +36,8 @@ public class MaterialService {
private
LogService
logService
;
private
LogService
logService
;
@Resource
@Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
private
DepotItemMapperEx
depotItemMapperEx
;
public
Material
getMaterial
(
long
id
)
{
public
Material
getMaterial
(
long
id
)
{
return
materialMapper
.
selectByPrimaryKey
(
id
);
return
materialMapper
.
selectByPrimaryKey
(
id
);
...
@@ -217,4 +223,43 @@ public class MaterialService {
...
@@ -217,4 +223,43 @@ public class MaterialService {
String
[]
idArray
=
ids
.
split
(
","
);
String
[]
idArray
=
ids
.
split
(
","
);
return
materialMapperEx
.
batchDeleteMaterialByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
return
materialMapperEx
.
batchDeleteMaterialByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
}
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* create time: 2019/4/10 18:00
* @Param: ids
* @return int
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialByIdsNormal
(
String
ids
)
throws
Exception
{
/**
* 校验
* 1、单据子表 jsh_depotitem
* 是否有相关数据
* */
int
deleteTotal
=
0
;
if
(
StringUtils
.
isEmpty
(
ids
)){
return
deleteTotal
;
}
String
[]
idArray
=
ids
.
split
(
","
);
/**
* 校验单据子表 jsh_depotitem
* */
List
<
DepotItem
>
depotItemList
=
depotItemMapperEx
.
getDepotItemListListByMaterialIds
(
idArray
);
if
(
depotItemList
!=
null
&&
depotItemList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,MaterialIds[{}]"
,
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
=
batchDeleteMaterialByIds
(
ids
);
return
deleteTotal
;
}
}
}
src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
bce05cf0
...
@@ -423,6 +423,18 @@
...
@@ -423,6 +423,18 @@
)
)
and ifnull(delete_Flag,'0') !='1'
and ifnull(delete_Flag,'0') !='1'
</select>
</select>
<select
id=
"getDepotItemListListByMaterialIds"
resultMap=
"com.jsh.erp.datasource.mappers.DepotItemMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.DepotItemMapper.Base_Column_List"
/>
from jsh_depotitem
where 1=1
and materialId in (
<foreach
collection=
"materialIds"
item=
"materialId"
separator=
","
>
#{materialId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
...
...
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