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
3fa79da3
Commit
3fa79da3
authored
Apr 11, 2019
by
qiankunpingtai
Browse files
去除外键之产品类型表jsh_materialcategory相关修改
parent
a184aabd
Changes
7
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/materials/materialcategory.html
View file @
3fa79da3
...
@@ -196,11 +196,21 @@
...
@@ -196,11 +196,21 @@
ids
:
ids
ids
:
ids
}),
}),
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
code
!=
200
){
if
(
res
&&
res
.
code
===
200
)
{
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
error
'
);
$
(
'
#tt
'
).
tree
(
'
reload
'
);
return
;
}
else
{
if
(
res
&&
res
.
code
==
601
){
var
jsondata
=
{};
jsondata
.
ids
=
ids
;
jsondata
.
deleteType
=
'
2
'
;
var
type
=
'
batch
'
;
batDeleteMaterialCategoryForceConfirm
(
res
,
"
/materialCategory/batchDeleteMaterialCategory
"
,
jsondata
,
type
);
}
else
if
(
res
&&
res
.
code
==
600
){
$
.
messager
.
alert
(
'
删除提示
'
,
res
.
msg
,
'
error
'
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品信息异常,请稍后再试!
'
,
'
error
'
);
}
}
}
$
(
'
#tt
'
).
tree
(
'
reload
'
);
},
},
//此处添加错误处理
//此处添加错误处理
error
:
function
()
{
error
:
function
()
{
...
@@ -212,6 +222,35 @@
...
@@ -212,6 +222,35 @@
});
});
}
}
}
}
/**
* 确认强制删除
* */
function
batDeleteMaterialCategoryForceConfirm
(
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
)
{
$
(
'
#tt
'
).
tree
(
'
reload
'
);
}
else
if
(
res
&&
res
.
code
==
600
){
$
.
messager
.
alert
(
'
删除提示
'
,
res
.
msg
,
'
error
'
);
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品类别信息异常,请稍后再试!
'
,
'
error
'
);
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除商品类别信息异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
});
}
//保存信息
//保存信息
$
(
"
#saveMaterialCategory
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
$
(
"
#saveMaterialCategory
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
...
...
src/main/java/com/jsh/erp/controller/MaterialCategoryController.java
View file @
3fa79da3
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.MaterialCategory
;
import
com.jsh.erp.datasource.entities.MaterialCategory
;
import
com.jsh.erp.datasource.entities.SerialNumberEx
;
import
com.jsh.erp.datasource.entities.SerialNumberEx
;
...
@@ -151,9 +152,20 @@ public class MaterialCategoryController {
...
@@ -151,9 +152,20 @@ public class MaterialCategoryController {
* @return java.lang.Object
* @return java.lang.Object
*/
*/
@RequestMapping
(
value
=
"/batchDeleteMaterialCategory"
)
@RequestMapping
(
value
=
"/batchDeleteMaterialCategory"
)
public
Object
batchDeleteMaterialCategory
(
@RequestParam
(
"ids"
)
String
ids
)
throws
Exception
{
public
Object
batchDeleteMaterialCategory
(
@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
=
materialCategoryService
.
batchDeleteMaterialCategoryByIds
(
ids
);
int
i
=
0
;
if
(
BusinessConstants
.
DELETE_TYPE_NORMAL
.
equals
(
deleteType
)){
i
=
materialCategoryService
.
batchDeleteMaterialCategoryByIdsNormal
(
ids
);
}
else
if
(
BusinessConstants
.
DELETE_TYPE_FORCE
.
equals
(
deleteType
)){
i
=
materialCategoryService
.
batchDeleteMaterialCategoryByIds
(
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
){
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_DELETE_FAILED_CODE
,
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_DELETE_FAILED_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_DELETE_FAILED_MSG
);
ExceptionConstants
.
MATERIAL_CATEGORY_DELETE_FAILED_MSG
);
...
...
src/main/java/com/jsh/erp/datasource/mappers/MaterialCategoryMapperEx.java
View file @
3fa79da3
...
@@ -35,4 +35,6 @@ public interface MaterialCategoryMapperEx {
...
@@ -35,4 +35,6 @@ public interface MaterialCategoryMapperEx {
int
editMaterialCategory
(
MaterialCategory
mc
);
int
editMaterialCategory
(
MaterialCategory
mc
);
List
<
MaterialCategory
>
getMaterialCategoryBySerialNo
(
@Param
(
"serialNo"
)
String
serialNo
);
List
<
MaterialCategory
>
getMaterialCategoryBySerialNo
(
@Param
(
"serialNo"
)
String
serialNo
);
List
<
MaterialCategory
>
getMaterialCategoryListByCategoryIds
(
@Param
(
"parentIds"
)
String
[]
categoryIds
);
}
}
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java
View file @
3fa79da3
package
com.jsh.erp.datasource.mappers
;
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.AccountHead
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -57,4 +58,6 @@ public interface MaterialMapperEx {
...
@@ -57,4 +58,6 @@ public interface MaterialMapperEx {
List
<
Material
>
getMaterialEnableSerialNumberList
(
Map
<
String
,
Object
>
parameterMap
);
List
<
Material
>
getMaterialEnableSerialNumberList
(
Map
<
String
,
Object
>
parameterMap
);
int
batchDeleteMaterialByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
int
batchDeleteMaterialByIds
(
@Param
(
"updateTime"
)
Date
updateTime
,
@Param
(
"updater"
)
Long
updater
,
@Param
(
"ids"
)
String
ids
[]);
List
<
Material
>
getMaterialListByCategoryIds
(
@Param
(
"categoryIds"
)
String
[]
categoryIds
);
}
}
src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java
View file @
3fa79da3
package
com.jsh.erp.service.materialCategory
;
package
com.jsh.erp.service.materialCategory
;
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.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.MaterialCategory
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.entities.MaterialCategoryExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.MaterialCategoryMapper
;
import
com.jsh.erp.datasource.mappers.MaterialCategoryMapper
;
import
com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx
;
import
com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx
;
import
com.jsh.erp.datasource.mappers.MaterialMapperEx
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.log.LogService
;
...
@@ -37,6 +37,8 @@ public class MaterialCategoryService {
...
@@ -37,6 +37,8 @@ public class MaterialCategoryService {
private
UserService
userService
;
private
UserService
userService
;
@Resource
@Resource
private
LogService
logService
;
private
LogService
logService
;
@Resource
private
MaterialMapperEx
materialMapperEx
;
public
MaterialCategory
getMaterialCategory
(
long
id
)
{
public
MaterialCategory
getMaterialCategory
(
long
id
)
{
return
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
return
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
...
@@ -216,5 +218,52 @@ public class MaterialCategoryService {
...
@@ -216,5 +218,52 @@ public class MaterialCategoryService {
}
}
}
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* create time: 2019/4/11 9:26
* @Param: ids
* @return int
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialCategoryByIdsNormal
(
String
ids
)
throws
Exception
{
/**
* 校验
* 1、产品表 jsh_material
* 2、产品类型表 jsh_materialcategory
* 是否有相关数据
* */
int
deleteTotal
=
0
;
if
(
StringUtils
.
isEmpty
(
ids
)){
return
deleteTotal
;
}
String
[]
idArray
=
ids
.
split
(
","
);
/**
* 校验产品表 jsh_material
* */
List
<
Material
>
materialList
=
materialMapperEx
.
getMaterialListByCategoryIds
(
idArray
);
if
(
materialList
!=
null
&&
materialList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,CategoryIds[{}]"
,
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_materialcategory
* */
List
<
MaterialCategory
>
materialCategoryList
=
materialCategoryMapperEx
.
getMaterialCategoryListByCategoryIds
(
idArray
);
if
(
materialCategoryList
!=
null
&&
materialCategoryList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,CategoryIds[{}]"
,
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
=
batchDeleteMaterialCategoryByIds
(
ids
);
return
deleteTotal
;
}
}
}
src/main/resources/mapper_xml/MaterialCategoryMapperEx.xml
View file @
3fa79da3
...
@@ -107,5 +107,17 @@
...
@@ -107,5 +107,17 @@
and serial_no=#{serialNo}
and serial_no=#{serialNo}
and ifnull(status,'0') !='2'
and ifnull(status,'0') !='2'
</select>
</select>
<select
id=
"getMaterialCategoryListByCategoryIds"
resultMap=
"com.jsh.erp.datasource.mappers.MaterialCategoryMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.MaterialCategoryMapper.Base_Column_List"
/>
from jsh_materialcategory
where 1=1
and parentId in (
<foreach
collection=
"parentIds"
item=
"parentId"
separator=
","
>
#{parentId}
</foreach>
)
and ifnull(status,'0') !='2'
</select>
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/mapper_xml/MaterialMapperEx.xml
View file @
3fa79da3
...
@@ -149,6 +149,18 @@
...
@@ -149,6 +149,18 @@
</foreach>
</foreach>
)
)
</update>
</update>
<select
id=
"getMaterialListByCategoryIds"
resultMap=
"com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap"
>
select
<include
refid=
"com.jsh.erp.datasource.mappers.MaterialMapper.Base_Column_List"
/>
from jsh_material
where 1=1
and categoryId in (
<foreach
collection=
"categoryIds"
item=
"categoryId"
separator=
","
>
#{categoryId}
</foreach>
)
and ifnull(delete_Flag,'0') !='1'
</select>
</mapper>
</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