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
d188dcb2
Commit
d188dcb2
authored
Apr 19, 2019
by
qiankunpingtai
Browse files
异常封装之商品类型信息后台修改
parent
ff9a0de5
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/MaterialCategoryController.java
View file @
d188dcb2
...
...
@@ -35,7 +35,7 @@ public class MaterialCategoryController {
private
MaterialCategoryService
materialCategoryService
;
@GetMapping
(
value
=
"/getAllList"
)
public
BaseResponseInfo
getAllList
(
@RequestParam
(
"parentId"
)
Long
parentId
,
HttpServletRequest
request
)
{
public
BaseResponseInfo
getAllList
(
@RequestParam
(
"parentId"
)
Long
parentId
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
List
<
MaterialCategory
>
materialCategoryList
=
materialCategoryService
.
getAllList
(
parentId
);
...
...
@@ -56,7 +56,7 @@ public class MaterialCategoryController {
* @return
*/
@RequestMapping
(
value
=
"/findById"
)
public
BaseResponseInfo
findById
(
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
{
public
BaseResponseInfo
findById
(
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
List
<
MaterialCategory
>
dataList
=
materialCategoryService
.
findById
(
id
);
...
...
src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java
View file @
d188dcb2
...
...
@@ -21,16 +21,16 @@ public class MaterialCategoryComponent implements ICommonQuery {
private
MaterialCategoryService
materialCategoryService
;
@Override
public
Object
selectOne
(
String
condition
)
{
public
Object
selectOne
(
String
condition
)
throws
Exception
{
return
null
;
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
{
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMaterialCategoryList
(
map
);
}
private
List
<?>
getMaterialCategoryList
(
Map
<
String
,
String
>
map
)
{
private
List
<?>
getMaterialCategoryList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
Integer
parentId
=
StringUtil
.
parseInteger
(
StringUtil
.
getInfo
(
search
,
"parentId"
));
...
...
@@ -39,7 +39,7 @@ public class MaterialCategoryComponent implements ICommonQuery {
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
{
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
Integer
parentId
=
StringUtil
.
parseInteger
(
StringUtil
.
getInfo
(
search
,
"parentId"
));
...
...
@@ -47,27 +47,27 @@ public class MaterialCategoryComponent implements ICommonQuery {
}
@Override
public
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
return
materialCategoryService
.
insertMaterialCategory
(
beanJson
,
request
);
}
@Override
public
int
update
(
String
beanJson
,
Long
id
)
{
public
int
update
(
String
beanJson
,
Long
id
)
throws
Exception
{
return
materialCategoryService
.
updateMaterialCategory
(
beanJson
,
id
);
}
@Override
public
int
delete
(
Long
id
)
{
public
int
delete
(
Long
id
)
throws
Exception
{
return
materialCategoryService
.
deleteMaterialCategory
(
id
);
}
@Override
public
int
batchDelete
(
String
ids
)
{
public
int
batchDelete
(
String
ids
)
throws
Exception
{
return
materialCategoryService
.
batchDeleteMaterialCategory
(
ids
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
materialCategoryService
.
checkIsNameExist
(
id
,
name
);
}
...
...
src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java
View file @
d188dcb2
...
...
@@ -40,64 +40,154 @@ public class MaterialCategoryService {
@Resource
private
MaterialMapperEx
materialMapperEx
;
public
MaterialCategory
getMaterialCategory
(
long
id
)
{
return
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
public
MaterialCategory
getMaterialCategory
(
long
id
)
throws
Exception
{
MaterialCategory
result
=
null
;
try
{
result
=
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
result
;
}
public
List
<
MaterialCategory
>
getMaterialCategory
()
{
public
List
<
MaterialCategory
>
getMaterialCategory
()
throws
Exception
{
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
return
materialCategoryMapper
.
selectByExample
(
example
);
List
<
MaterialCategory
>
list
=
null
;
try
{
list
=
materialCategoryMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
list
;
}
public
List
<
MaterialCategory
>
getAllList
(
Long
parentId
)
{
public
List
<
MaterialCategory
>
getAllList
(
Long
parentId
)
throws
Exception
{
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andParentidEqualTo
(
parentId
).
andIdNotEqualTo
(
1
l
);
example
.
setOrderByClause
(
"id"
);
return
materialCategoryMapper
.
selectByExample
(
example
);
List
<
MaterialCategory
>
list
=
null
;
try
{
list
=
materialCategoryMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
list
;
}
public
List
<
MaterialCategory
>
select
(
String
name
,
Integer
parentId
,
int
offset
,
int
rows
)
{
return
materialCategoryMapperEx
.
selectByConditionMaterialCategory
(
name
,
parentId
,
offset
,
rows
);
public
List
<
MaterialCategory
>
select
(
String
name
,
Integer
parentId
,
int
offset
,
int
rows
)
throws
Exception
{
List
<
MaterialCategory
>
list
=
null
;
try
{
list
=
materialCategoryMapperEx
.
selectByConditionMaterialCategory
(
name
,
parentId
,
offset
,
rows
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
list
;
}
public
Long
countMaterialCategory
(
String
name
,
Integer
parentId
)
{
return
materialCategoryMapperEx
.
countsByMaterialCategory
(
name
,
parentId
);
public
Long
countMaterialCategory
(
String
name
,
Integer
parentId
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
materialCategoryMapperEx
.
countsByMaterialCategory
(
name
,
parentId
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterialCategory
(
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insertMaterialCategory
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
MaterialCategory
materialCategory
=
JSONObject
.
parseObject
(
beanJson
,
MaterialCategory
.
class
);
return
materialCategoryMapper
.
insertSelective
(
materialCategory
);
int
result
=
0
;
try
{
result
=
materialCategoryMapper
.
insertSelective
(
materialCategory
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterialCategory
(
String
beanJson
,
Long
id
)
{
public
int
updateMaterialCategory
(
String
beanJson
,
Long
id
)
throws
Exception
{
MaterialCategory
materialCategory
=
JSONObject
.
parseObject
(
beanJson
,
MaterialCategory
.
class
);
materialCategory
.
setId
(
id
);
return
materialCategoryMapper
.
updateByPrimaryKeySelective
(
materialCategory
);
int
result
=
0
;
try
{
result
=
materialCategoryMapper
.
updateByPrimaryKeySelective
(
materialCategory
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteMaterialCategory
(
Long
id
)
{
return
materialCategoryMapper
.
deleteByPrimaryKey
(
id
);
public
int
deleteMaterialCategory
(
Long
id
)
throws
Exception
{
int
result
=
0
;
try
{
result
=
materialCategoryMapper
.
deleteByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialCategory
(
String
ids
)
{
public
int
batchDeleteMaterialCategory
(
String
ids
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
return
materialCategoryMapper
.
deleteByExample
(
example
);
int
result
=
0
;
try
{
result
=
materialCategoryMapper
.
deleteByExample
(
example
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
0
;
}
public
List
<
MaterialCategory
>
findById
(
Long
id
)
{
public
List
<
MaterialCategory
>
findById
(
Long
id
)
throws
Exception
{
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andIdEqualTo
(
id
);
return
materialCategoryMapper
.
selectByExample
(
example
);
List
<
MaterialCategory
>
list
=
null
;
try
{
list
=
materialCategoryMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
list
;
}
/**
* create by: cjl
...
...
@@ -108,7 +198,16 @@ public class MaterialCategoryService {
* @return java.util.List<com.jsh.erp.datasource.vo.TreeNode>
*/
public
List
<
TreeNode
>
getMaterialCategoryTree
(
Long
id
)
throws
Exception
{
return
materialCategoryMapperEx
.
getNodeTree
(
id
);
List
<
TreeNode
>
list
=
null
;
try
{
list
=
materialCategoryMapperEx
.
getNodeTree
(
id
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
list
;
}
/**
* create by: cjl
...
...
@@ -144,7 +243,16 @@ public class MaterialCategoryService {
mc
.
setUpdateTime
(
date
);
//更新人
mc
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
return
materialCategoryMapperEx
.
addMaterialCategory
(
mc
);
int
result
=
0
;
try
{
result
=
materialCategoryMapperEx
.
addMaterialCategory
(
mc
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialCategoryByIds
(
String
ids
)
throws
Exception
{
...
...
@@ -160,8 +268,16 @@ public class MaterialCategoryService {
if
(
strArray
.
length
<
1
){
return
0
;
}
return
materialCategoryMapperEx
.
batchDeleteMaterialCategoryByIds
(
updateDate
,
updater
,
strArray
);
int
result
=
0
;
try
{
result
=
materialCategoryMapperEx
.
batchDeleteMaterialCategoryByIds
(
updateDate
,
updater
,
strArray
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
editMaterialCategory
(
MaterialCategory
mc
)
throws
Exception
{
...
...
@@ -180,12 +296,21 @@ public class MaterialCategoryService {
//更新人
User
userInfo
=
userService
.
getCurrentUser
();
mc
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
return
materialCategoryMapperEx
.
editMaterialCategory
(
mc
);
int
result
=
0
;
try
{
result
=
materialCategoryMapperEx
.
editMaterialCategory
(
mc
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
/**
* 根据商品类别编号判断商品类别是否已存在
* */
public
void
checkMaterialCategorySerialNo
(
MaterialCategory
mc
)
{
public
void
checkMaterialCategorySerialNo
(
MaterialCategory
mc
)
throws
Exception
{
if
(
mc
==
null
){
return
;
}
...
...
@@ -193,7 +318,15 @@ public class MaterialCategoryService {
return
;
}
//根据商品类别编号查询商品类别
List
<
MaterialCategory
>
mList
=
materialCategoryMapperEx
.
getMaterialCategoryBySerialNo
(
mc
.
getSerialNo
());
List
<
MaterialCategory
>
mList
=
null
;
try
{
mList
=
materialCategoryMapperEx
.
getMaterialCategoryBySerialNo
(
mc
.
getSerialNo
());
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
if
(
mList
==
null
||
mList
.
size
()<
1
){
//未查询到对应数据,编号可用
return
;
...
...
@@ -243,7 +376,15 @@ public class MaterialCategoryService {
/**
* 校验产品表 jsh_material
* */
List
<
Material
>
materialList
=
materialMapperEx
.
getMaterialListByCategoryIds
(
idArray
);
List
<
Material
>
materialList
=
null
;
try
{
materialList
=
materialMapperEx
.
getMaterialListByCategoryIds
(
idArray
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
if
(
materialList
!=
null
&&
materialList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,CategoryIds[{}]"
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
,
ids
);
...
...
@@ -253,7 +394,15 @@ public class MaterialCategoryService {
/**
* 校验产品类型表 jsh_materialcategory
* */
List
<
MaterialCategory
>
materialCategoryList
=
materialCategoryMapperEx
.
getMaterialCategoryListByCategoryIds
(
idArray
);
List
<
MaterialCategory
>
materialCategoryList
=
null
;
try
{
materialCategoryList
=
materialCategoryMapperEx
.
getMaterialCategoryListByCategoryIds
(
idArray
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
if
(
materialCategoryList
!=
null
&&
materialCategoryList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,CategoryIds[{}]"
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_CODE
,
ExceptionConstants
.
DELETE_FORCE_CONFIRM_MSG
,
ids
);
...
...
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