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
f4ef5aa0
Commit
f4ef5aa0
authored
Apr 07, 2021
by
季圣华
Browse files
vue版本上线
parent
76a0033a
Changes
242
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 242+
files are displayed.
Plain diff
Email patch
jshERP-boot/src/main/java/com/jsh/erp/service/log/LogComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.log
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.utils.Constants
;
import
com.jsh.erp.utils.QueryUtils
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"log_component"
)
@LogResource
public
class
LogComponent
implements
ICommonQuery
{
@Resource
private
LogService
logService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
logService
.
getLog
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getLogList
(
map
);
}
private
List
<?>
getLogList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
operation
=
StringUtil
.
getInfo
(
search
,
"operation"
);
Integer
userId
=
StringUtil
.
parseInteger
(
StringUtil
.
getInfo
(
search
,
"userId"
));
String
clientIp
=
StringUtil
.
getInfo
(
search
,
"clientIp"
);
Integer
status
=
StringUtil
.
parseInteger
(
StringUtil
.
getInfo
(
search
,
"status"
));
String
beginTime
=
StringUtil
.
getInfo
(
search
,
"beginTime"
);
String
endTime
=
StringUtil
.
getInfo
(
search
,
"endTime"
);
String
content
=
StringUtil
.
getInfo
(
search
,
"content"
);
return
logService
.
select
(
operation
,
userId
,
clientIp
,
status
,
beginTime
,
endTime
,
content
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
operation
=
StringUtil
.
getInfo
(
search
,
"operation"
);
Integer
userId
=
StringUtil
.
parseInteger
(
StringUtil
.
getInfo
(
search
,
"userId"
));
String
clientIp
=
StringUtil
.
getInfo
(
search
,
"clientIp"
);
Integer
status
=
StringUtil
.
parseInteger
(
StringUtil
.
getInfo
(
search
,
"status"
));
String
beginTime
=
StringUtil
.
getInfo
(
search
,
"beginTime"
);
String
endTime
=
StringUtil
.
getInfo
(
search
,
"endTime"
);
String
content
=
StringUtil
.
getInfo
(
search
,
"content"
);
return
logService
.
countLog
(
operation
,
userId
,
clientIp
,
status
,
beginTime
,
endTime
,
content
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
logService
.
insertLog
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
logService
.
updateLog
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
logService
.
deleteLog
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
logService
.
batchDeleteLog
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
0
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/log/LogResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.log
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"log"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
LogResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/log/LogService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.log
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.Log
;
import
com.jsh.erp.datasource.entities.LogExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.LogMapper
;
import
com.jsh.erp.datasource.mappers.LogMapperEx
;
import
com.jsh.erp.datasource.vo.LogVo4List
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.redis.RedisService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.Tools
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.List
;
import
static
com
.
jsh
.
erp
.
utils
.
Tools
.
getLocalIp
;
@Service
public
class
LogService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
LogService
.
class
);
@Resource
private
LogMapper
logMapper
;
@Resource
private
LogMapperEx
logMapperEx
;
@Resource
private
UserService
userService
;
@Resource
private
RedisService
redisService
;
public
Log
getLog
(
long
id
)
throws
Exception
{
Log
result
=
null
;
try
{
result
=
logMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
Log
>
getLog
()
throws
Exception
{
LogExample
example
=
new
LogExample
();
List
<
Log
>
list
=
null
;
try
{
list
=
logMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
LogVo4List
>
select
(
String
operation
,
Integer
userId
,
String
clientIp
,
Integer
status
,
String
beginTime
,
String
endTime
,
String
content
,
int
offset
,
int
rows
)
throws
Exception
{
List
<
LogVo4List
>
list
=
null
;
try
{
list
=
logMapperEx
.
selectByConditionLog
(
operation
,
userId
,
clientIp
,
status
,
beginTime
,
endTime
,
content
,
offset
,
rows
);
if
(
null
!=
list
)
{
for
(
LogVo4List
log
:
list
)
{
log
.
setCreateTimeStr
(
Tools
.
getCenternTime
(
log
.
getCreateTime
()));
}
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
Long
countLog
(
String
operation
,
Integer
userId
,
String
clientIp
,
Integer
status
,
String
beginTime
,
String
endTime
,
String
content
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
logMapperEx
.
countsByLog
(
operation
,
userId
,
clientIp
,
status
,
beginTime
,
endTime
,
content
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertLog
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Log
log
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Log
.
class
);
int
result
=
0
;
try
{
result
=
logMapper
.
insertSelective
(
log
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateLog
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Log
log
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Log
.
class
);
int
result
=
0
;
try
{
result
=
logMapper
.
updateByPrimaryKeySelective
(
log
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteLog
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
int
result
=
0
;
try
{
result
=
logMapper
.
deleteByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteLog
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
LogExample
example
=
new
LogExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
int
result
=
0
;
try
{
result
=
logMapper
.
deleteByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
void
insertLog
(
String
moduleName
,
String
content
,
HttpServletRequest
request
)
throws
Exception
{
try
{
Long
userId
=
userService
.
getUserId
(
request
);
if
(
userId
!=
null
)
{
Log
log
=
new
Log
();
log
.
setUserId
(
userId
);
log
.
setOperation
(
moduleName
);
log
.
setClientIp
(
getLocalIp
(
request
));
log
.
setCreateTime
(
new
Date
());
Byte
status
=
0
;
log
.
setStatus
(
status
);
log
.
setContent
(
content
);
logMapper
.
insertSelective
(
log
);
}
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
}
public
void
insertLogWithUserId
(
Long
userId
,
Long
tenantId
,
String
moduleName
,
String
content
,
HttpServletRequest
request
)
throws
Exception
{
try
{
if
(
userId
!=
null
)
{
Log
log
=
new
Log
();
log
.
setUserId
(
userId
);
log
.
setOperation
(
moduleName
);
log
.
setClientIp
(
getLocalIp
(
request
));
log
.
setCreateTime
(
new
Date
());
Byte
status
=
0
;
log
.
setStatus
(
status
);
log
.
setContent
(
content
);
log
.
setTenantId
(
tenantId
);
logMapper
.
insertSelective
(
log
);
}
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.material
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.service.depot.DepotResource
;
import
com.jsh.erp.service.depot.DepotService
;
import
com.jsh.erp.utils.Constants
;
import
com.jsh.erp.utils.QueryUtils
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"material_component"
)
@MaterialResource
public
class
MaterialComponent
implements
ICommonQuery
{
@Resource
private
MaterialService
materialService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
materialService
.
getMaterial
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMaterialList
(
map
);
}
private
List
<?>
getMaterialList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
categoryId
=
StringUtil
.
getInfo
(
search
,
"categoryId"
);
String
barCode
=
StringUtil
.
getInfo
(
search
,
"barCode"
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
standard
=
StringUtil
.
getInfo
(
search
,
"standard"
);
String
model
=
StringUtil
.
getInfo
(
search
,
"model"
);
String
mpList
=
StringUtil
.
getInfo
(
search
,
"mpList"
);
return
materialService
.
select
(
barCode
,
name
,
standard
,
model
,
categoryId
,
mpList
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
categoryId
=
StringUtil
.
getInfo
(
search
,
"categoryId"
);
String
barCode
=
StringUtil
.
getInfo
(
search
,
"barCode"
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
standard
=
StringUtil
.
getInfo
(
search
,
"standard"
);
String
model
=
StringUtil
.
getInfo
(
search
,
"model"
);
String
mpList
=
StringUtil
.
getInfo
(
search
,
"mpList"
);
return
materialService
.
countMaterial
(
barCode
,
name
,
standard
,
model
,
categoryId
,
mpList
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialService
.
insertMaterial
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialService
.
updateMaterial
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
materialService
.
deleteMaterial
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
materialService
.
batchDeleteMaterial
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
materialService
.
checkIsNameExist
(
id
,
name
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.material
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"material"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MaterialResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.material
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
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.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.materialExtend.MaterialExtendService
;
import
com.jsh.erp.service.depot.DepotService
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.materialCategory.MaterialCategoryService
;
import
com.jsh.erp.service.unit.UnitService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.ExcelUtils
;
import
com.jsh.erp.utils.StringUtil
;
import
jxl.Sheet
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigDecimal
;
import
java.util.*
;
@Service
public
class
MaterialService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialService
.
class
);
@Resource
private
MaterialMapper
materialMapper
;
@Resource
private
MaterialExtendMapper
materialExtendMapper
;
@Resource
private
MaterialMapperEx
materialMapperEx
;
@Resource
private
MaterialCategoryMapperEx
materialCategoryMapperEx
;
@Resource
private
MaterialExtendMapperEx
materialExtendMapperEx
;
@Resource
private
LogService
logService
;
@Resource
private
UserService
userService
;
@Resource
private
DepotItemMapperEx
depotItemMapperEx
;
@Resource
private
DepotItemService
depotItemService
;
@Resource
private
MaterialCategoryService
materialCategoryService
;
@Resource
private
UnitService
unitService
;
@Resource
private
MaterialInitialStockMapper
materialInitialStockMapper
;
@Resource
private
MaterialCurrentStockMapper
materialCurrentStockMapper
;
@Resource
private
DepotService
depotService
;
@Resource
private
MaterialExtendService
materialExtendService
;
public
Material
getMaterial
(
long
id
)
throws
Exception
{
Material
result
=
null
;
try
{
result
=
materialMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
Material
>
getMaterialListByIds
(
String
ids
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
List
<
Material
>
list
=
new
ArrayList
<>();
try
{
MaterialExample
example
=
new
MaterialExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
list
=
materialMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
Material
>
getMaterial
()
throws
Exception
{
MaterialExample
example
=
new
MaterialExample
();
example
.
createCriteria
().
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Material
>
list
=
null
;
try
{
list
=
materialMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialVo4Unit
>
select
(
String
barCode
,
String
name
,
String
standard
,
String
model
,
String
categoryId
,
String
mpList
,
int
offset
,
int
rows
)
throws
Exception
{
String
[]
mpArr
=
new
String
[]{};
if
(
StringUtil
.
isNotEmpty
(
mpList
)){
mpArr
=
mpList
.
split
(
","
);
}
List
<
MaterialVo4Unit
>
resList
=
new
ArrayList
<>();
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
StringUtil
.
isNotEmpty
(
categoryId
)){
idList
=
getListByParentId
(
Long
.
parseLong
(
categoryId
));
}
list
=
materialMapperEx
.
selectByConditionMaterial
(
barCode
,
name
,
standard
,
model
,
idList
,
mpList
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
null
!=
list
)
{
for
(
MaterialVo4Unit
m
:
list
)
{
//扩展信息
String
materialOther
=
""
;
for
(
int
i
=
0
;
i
<
mpArr
.
length
;
i
++)
{
if
(
mpArr
[
i
].
equals
(
"制造商"
))
{
materialOther
=
materialOther
+
((
m
.
getMfrs
()
==
null
||
m
.
getMfrs
().
equals
(
""
))
?
""
:
"("
+
m
.
getMfrs
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义1"
))
{
materialOther
=
materialOther
+
((
m
.
getOtherField1
()
==
null
||
m
.
getOtherField1
().
equals
(
""
))
?
""
:
"("
+
m
.
getOtherField1
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义2"
))
{
materialOther
=
materialOther
+
((
m
.
getOtherField2
()
==
null
||
m
.
getOtherField2
().
equals
(
""
))
?
""
:
"("
+
m
.
getOtherField2
()
+
")"
);
}
if
(
mpArr
[
i
].
equals
(
"自定义3"
))
{
materialOther
=
materialOther
+
((
m
.
getOtherField3
()
==
null
||
m
.
getOtherField3
().
equals
(
""
))
?
""
:
"("
+
m
.
getOtherField3
()
+
")"
);
}
}
m
.
setMaterialOther
(
materialOther
);
Long
tenantId
=
m
.
getTenantId
();
m
.
setStock
(
depotItemService
.
getStockByParam
(
null
,
m
.
getId
(),
null
,
null
,
tenantId
));
resList
.
add
(
m
);
}
}
return
resList
;
}
public
Long
countMaterial
(
String
barCode
,
String
name
,
String
standard
,
String
model
,
String
categoryId
,
String
mpList
)
throws
Exception
{
Long
result
=
null
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
StringUtil
.
isNotEmpty
(
categoryId
)){
idList
=
getListByParentId
(
Long
.
parseLong
(
categoryId
));
}
result
=
materialMapperEx
.
countsByMaterial
(
barCode
,
name
,
standard
,
model
,
idList
,
mpList
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterial
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Material
m
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Material
.
class
);
m
.
setEnabled
(
true
);
try
{
Long
mId
=
null
;
materialMapper
.
insertSelective
(
m
);
List
<
Material
>
materials
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getMfrs
(),
m
.
getUnit
(),
m
.
getUnitId
());
if
(
materials
!=
null
&&
materials
.
size
()>
0
)
{
mId
=
materials
.
get
(
0
).
getId
();
}
materialExtendService
.
saveDetials
(
obj
,
obj
.
getString
(
"sortList"
),
mId
);
if
(
obj
.
get
(
"stock"
)!=
null
)
{
JSONArray
stockArr
=
obj
.
getJSONArray
(
"stock"
);
for
(
int
i
=
0
;
i
<
stockArr
.
size
();
i
++)
{
JSONObject
jsonObj
=
stockArr
.
getJSONObject
(
i
);
if
(
jsonObj
.
get
(
"id"
)!=
null
&&
jsonObj
.
get
(
"initStock"
)!=
null
)
{
String
number
=
jsonObj
.
getString
(
"initStock"
);
Long
depotId
=
jsonObj
.
getLong
(
"id"
);
if
(
StringUtil
.
isNotEmpty
(
number
)
&&
Double
.
valueOf
(
number
)>
0
)
{
insertStockByMaterialAndDepot
(
depotId
,
mId
,
parseBigDecimalEx
(
number
));
}
}
}
}
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
).
append
(
m
.
getName
()).
toString
(),
request
);
return
1
;
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
return
0
;
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterial
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Material
material
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Material
.
class
);
try
{
materialMapper
.
updateByPrimaryKeySelective
(
material
);
if
(
material
.
getUnitId
()
==
null
)
{
materialMapperEx
.
setUnitIdToNull
(
material
.
getId
());
}
materialExtendService
.
saveDetials
(
obj
,
obj
.
getString
(
"sortList"
),
material
.
getId
());
if
(
obj
.
get
(
"stock"
)!=
null
)
{
JSONArray
stockArr
=
obj
.
getJSONArray
(
"stock"
);
for
(
int
i
=
0
;
i
<
stockArr
.
size
();
i
++)
{
JSONObject
jsonObj
=
stockArr
.
getJSONObject
(
i
);
if
(
jsonObj
.
get
(
"id"
)
!=
null
&&
jsonObj
.
get
(
"initStock"
)
!=
null
)
{
String
number
=
jsonObj
.
getString
(
"initStock"
);
Long
depotId
=
jsonObj
.
getLong
(
"id"
);
//先清除再插入
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
material
.
getId
()).
andDepotIdEqualTo
(
depotId
);
materialInitialStockMapper
.
deleteByExample
(
example
);
if
(
StringUtil
.
isNotEmpty
(
number
)
&&
Double
.
valueOf
(
number
)
>
0
)
{
insertStockByMaterialAndDepot
(
depotId
,
material
.
getId
(),
parseBigDecimalEx
(
number
));
}
}
}
}
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
material
.
getName
()).
toString
(),
request
);
return
1
;
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
return
0
;
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteMaterial
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteMaterialByIds
(
id
.
toString
());
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterial
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteMaterialByIds
(
ids
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialByIds
(
String
ids
)
throws
Exception
{
String
[]
idArray
=
ids
.
split
(
","
);
//校验单据子表 jsh_depot_item
List
<
DepotItem
>
depotItemList
=
null
;
try
{
depotItemList
=
depotItemMapperEx
.
getDepotItemListListByMaterialIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
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
);
}
//记录日志
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
);
List
<
Material
>
list
=
getMaterialListByIds
(
ids
);
for
(
Material
material:
list
){
sb
.
append
(
"["
).
append
(
material
.
getName
()).
append
(
"]"
);
}
logService
.
insertLog
(
"商品"
,
sb
.
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
User
userInfo
=
userService
.
getCurrentUser
();
//校验通过执行删除操作
try
{
//逻辑删除商品
materialMapperEx
.
batchDeleteMaterialByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
//逻辑删除商品价格扩展
materialExtendMapperEx
.
batchDeleteMaterialExtendByMIds
(
idArray
);
return
1
;
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
return
0
;
}
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
MaterialExample
example
=
new
MaterialExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andNameEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Material
>
list
=
null
;
try
{
list
=
materialMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
==
null
?
0
:
list
.
size
();
}
public
int
checkIsExist
(
Long
id
,
String
name
,
String
model
,
String
color
,
String
standard
,
String
mfrs
,
String
otherField1
,
String
otherField2
,
String
otherField3
,
String
unit
,
Long
unitId
)
throws
Exception
{
MaterialExample
example
=
new
MaterialExample
();
MaterialExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andNameEqualTo
(
name
).
andModelEqualTo
(
model
).
andColorEqualTo
(
color
)
.
andStandardEqualTo
(
standard
).
andMfrsEqualTo
(
mfrs
)
.
andOtherField1EqualTo
(
otherField1
).
andOtherField2EqualTo
(
otherField2
).
andOtherField2EqualTo
(
otherField3
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
if
(
id
>
0
)
{
criteria
.
andIdNotEqualTo
(
id
);
}
if
(!
StringUtil
.
isEmpty
(
unit
))
{
criteria
.
andUnitEqualTo
(
unit
);
}
if
(
unitId
!=
null
)
{
criteria
.
andUnitIdEqualTo
(
unitId
);
}
List
<
Material
>
list
=
null
;
try
{
list
=
materialMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
==
null
?
0
:
list
.
size
();
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchSetStatus
(
Boolean
status
,
String
ids
)
throws
Exception
{
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
List
<
Long
>
materialIds
=
StringUtil
.
strToLongList
(
ids
);
Material
material
=
new
Material
();
material
.
setEnabled
(
status
);
MaterialExample
example
=
new
MaterialExample
();
example
.
createCriteria
().
andIdIn
(
materialIds
);
int
result
=
0
;
try
{
result
=
materialMapper
.
updateByExampleSelective
(
material
,
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
Unit
findUnit
(
Long
mId
)
throws
Exception
{
Unit
unit
=
new
Unit
();
try
{
List
<
Unit
>
list
=
materialMapperEx
.
findUnitList
(
mId
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
unit
=
list
.
get
(
0
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
unit
;
}
public
List
<
MaterialVo4Unit
>
findById
(
Long
id
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
list
=
materialMapperEx
.
findById
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialVo4Unit
>
findByIdWithBarCode
(
Long
meId
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
list
=
materialMapperEx
.
findByIdWithBarCode
(
meId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
Long
>
getListByParentId
(
Long
parentId
)
{
List
<
Long
>
idList
=
new
ArrayList
<
Long
>();
List
<
MaterialCategory
>
list
=
materialCategoryMapperEx
.
getListByParentId
(
parentId
);
idList
.
add
(
parentId
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
getIdListByParentId
(
idList
,
parentId
);
}
return
idList
;
}
public
List
<
Long
>
getIdListByParentId
(
List
<
Long
>
idList
,
Long
parentId
){
List
<
MaterialCategory
>
list
=
materialCategoryMapperEx
.
getListByParentId
(
parentId
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
for
(
MaterialCategory
mc
:
list
){
idList
.
add
(
mc
.
getId
());
getIdListByParentId
(
idList
,
mc
.
getId
());
}
}
return
idList
;
}
public
List
<
MaterialVo4Unit
>
findBySelectWithBarCode
(
Long
categoryId
,
String
q
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
categoryId
!=
null
){
Long
parentId
=
categoryId
;
idList
=
getListByParentId
(
parentId
);
}
if
(
StringUtil
.
isNotEmpty
(
q
))
{
q
=
q
.
replace
(
"'"
,
""
);
}
list
=
materialMapperEx
.
findBySelectWithBarCode
(
idList
,
q
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
findBySelectWithBarCodeCount
(
Long
categoryId
,
String
q
)
throws
Exception
{
int
result
=
0
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
categoryId
!=
null
){
Long
parentId
=
categoryId
;
idList
=
getListByParentId
(
parentId
);
}
if
(
StringUtil
.
isNotEmpty
(
q
))
{
q
=
q
.
replace
(
"'"
,
""
);
}
result
=
materialMapperEx
.
findBySelectWithBarCodeCount
(
idList
,
q
);
}
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
<
MaterialVo4Unit
>
findByAll
(
String
barCode
,
String
name
,
String
standard
,
String
model
,
String
categoryId
)
throws
Exception
{
List
<
MaterialVo4Unit
>
resList
=
new
ArrayList
<>();
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
List
<
Long
>
idList
=
new
ArrayList
<>();
if
(
StringUtil
.
isNotEmpty
(
categoryId
)){
idList
=
getListByParentId
(
Long
.
parseLong
(
categoryId
));
}
list
=
materialMapperEx
.
findByAll
(
barCode
,
name
,
standard
,
model
,
idList
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
null
!=
list
)
{
for
(
MaterialVo4Unit
m
:
list
)
{
resList
.
add
(
m
);
}
}
return
resList
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
BaseResponseInfo
importExcel
(
Sheet
src
)
throws
Exception
{
List
<
Depot
>
depotList
=
depotService
.
getDepot
();
int
depotCount
=
depotList
.
size
();
List
<
MaterialWithInitStock
>
mList
=
new
ArrayList
<>();
for
(
int
i
=
2
;
i
<
src
.
getRows
();
i
++)
{
String
name
=
ExcelUtils
.
getContent
(
src
,
i
,
0
);
//名称
String
standard
=
ExcelUtils
.
getContent
(
src
,
i
,
1
);
//规格
String
model
=
ExcelUtils
.
getContent
(
src
,
i
,
2
);
//型号
String
color
=
ExcelUtils
.
getContent
(
src
,
i
,
3
);
//颜色
String
categoryName
=
ExcelUtils
.
getContent
(
src
,
i
,
4
);
//类别
String
safetyStock
=
ExcelUtils
.
getContent
(
src
,
i
,
5
);
//安全存量
String
unit
=
ExcelUtils
.
getContent
(
src
,
i
,
6
);
//基础单位
//校验名称、型号、单位是否为空
if
(
StringUtil
.
isNotEmpty
(
name
)
&&
StringUtil
.
isNotEmpty
(
model
)
&&
StringUtil
.
isNotEmpty
(
unit
))
{
MaterialWithInitStock
m
=
new
MaterialWithInitStock
();
m
.
setName
(
name
);
m
.
setStandard
(
standard
);
m
.
setModel
(
model
);
m
.
setColor
(
color
);
Long
categoryId
=
materialCategoryService
.
getCategoryIdByName
(
categoryName
);
m
.
setCategoryId
(
categoryId
);
m
.
setSafetyStock
(
parseBigDecimalEx
(
safetyStock
));
String
manyUnit
=
ExcelUtils
.
getContent
(
src
,
i
,
7
);
//副单位
String
barCode
=
ExcelUtils
.
getContent
(
src
,
i
,
8
);
//基础条码
String
manyBarCode
=
ExcelUtils
.
getContent
(
src
,
i
,
9
);
//副条码
String
ratio
=
ExcelUtils
.
getContent
(
src
,
i
,
10
);
//比例
String
purchaseDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
11
);
//采购价
String
commodityDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
12
);
//零售价
String
wholesaleDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
13
);
//销售价
String
lowDecimal
=
ExcelUtils
.
getContent
(
src
,
i
,
14
);
//最低售价
JSONObject
materialExObj
=
new
JSONObject
();
JSONObject
basicObj
=
new
JSONObject
();
basicObj
.
put
(
"barCode"
,
barCode
);
basicObj
.
put
(
"commodityUnit"
,
unit
);
basicObj
.
put
(
"purchaseDecimal"
,
purchaseDecimal
);
basicObj
.
put
(
"commodityDecimal"
,
commodityDecimal
);
basicObj
.
put
(
"wholesaleDecimal"
,
wholesaleDecimal
);
basicObj
.
put
(
"lowDecimal"
,
lowDecimal
);
materialExObj
.
put
(
"basic"
,
basicObj
);
if
(
StringUtil
.
isNotEmpty
(
manyUnit
.
trim
())){
//多单位
String
manyUnitAll
=
unit
+
","
+
manyUnit
+
"(1:"
+
ratio
+
")"
;
Long
unitId
=
unitService
.
getUnitIdByName
(
manyUnitAll
);
m
.
setUnitId
(
unitId
);
JSONObject
otherObj
=
new
JSONObject
();
otherObj
.
put
(
"barCode"
,
manyBarCode
);
otherObj
.
put
(
"commodityUnit"
,
manyUnit
);
otherObj
.
put
(
"purchaseDecimal"
,
parsePrice
(
purchaseDecimal
,
ratio
));
otherObj
.
put
(
"commodityDecimal"
,
parsePrice
(
commodityDecimal
,
ratio
));
otherObj
.
put
(
"wholesaleDecimal"
,
parsePrice
(
wholesaleDecimal
,
ratio
));
otherObj
.
put
(
"lowDecimal"
,
parsePrice
(
lowDecimal
,
ratio
));
materialExObj
.
put
(
"other"
,
otherObj
);
}
else
{
m
.
setUnit
(
unit
);
}
m
.
setMaterialExObj
(
materialExObj
);
String
enabled
=
ExcelUtils
.
getContent
(
src
,
i
,
15
);
//状态
m
.
setEnabled
(
enabled
.
equals
(
"1"
)?
true
:
false
);
//缓存各个仓库的库存信息
Map
<
Long
,
BigDecimal
>
stockMap
=
new
HashMap
<
Long
,
BigDecimal
>();
for
(
int
j
=
1
;
j
<=
depotCount
;
j
++)
{
int
col
=
15
+
j
;
if
(
col
<
src
.
getColumns
()){
String
depotName
=
ExcelUtils
.
getContent
(
src
,
1
,
col
);
//获取仓库名称
Long
depotId
=
depotService
.
getIdByName
(
depotName
);
if
(
depotId
!=
0L
){
String
stockStr
=
ExcelUtils
.
getContent
(
src
,
i
,
col
);
if
(
StringUtil
.
isNotEmpty
(
stockStr
))
{
stockMap
.
put
(
depotId
,
parseBigDecimalEx
(
stockStr
));
}
}
}
}
m
.
setStockMap
(
stockMap
);
mList
.
add
(
m
);
}
}
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
BaseResponseInfo
info
=
new
BaseResponseInfo
();
try
{
Long
mId
=
0L
;
for
(
MaterialWithInitStock
m:
mList
)
{
//判断该商品是否存在,如果不存在就新增,如果存在就更新
List
<
Material
>
materials
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getMfrs
(),
m
.
getUnit
(),
m
.
getUnitId
());
if
(
materials
.
size
()<=
0
)
{
materialMapper
.
insertSelective
(
m
);
List
<
Material
>
newList
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getMfrs
(),
m
.
getUnit
(),
m
.
getUnitId
());
if
(
newList
!=
null
&&
newList
.
size
()>
0
)
{
mId
=
newList
.
get
(
0
).
getId
();
}
}
else
{
mId
=
materials
.
get
(
0
).
getId
();
String
materialJson
=
JSON
.
toJSONString
(
m
);
Material
material
=
JSONObject
.
parseObject
(
materialJson
,
Material
.
class
);
material
.
setId
(
mId
);
materialMapper
.
updateByPrimaryKeySelective
(
material
);
}
//给商品新增条码与价格相关信息
User
user
=
userService
.
getCurrentUser
();
JSONObject
materialExObj
=
m
.
getMaterialExObj
();
if
(
StringUtil
.
isExist
(
materialExObj
.
get
(
"basic"
))){
String
basicStr
=
materialExObj
.
getString
(
"basic"
);
MaterialExtend
basicMaterialExtend
=
JSONObject
.
parseObject
(
basicStr
,
MaterialExtend
.
class
);
basicMaterialExtend
.
setMaterialId
(
mId
);
basicMaterialExtend
.
setDefaultFlag
(
"1"
);
basicMaterialExtend
.
setCreateTime
(
new
Date
());
basicMaterialExtend
.
setUpdateTime
(
System
.
currentTimeMillis
());
basicMaterialExtend
.
setCreateSerial
(
user
.
getLoginName
());
basicMaterialExtend
.
setUpdateSerial
(
user
.
getLoginName
());
Long
meId
=
materialExtendService
.
selectIdByMaterialIdAndDefaultFlag
(
mId
,
"1"
);
if
(
meId
==
0L
){
materialExtendMapper
.
insertSelective
(
basicMaterialExtend
);
}
else
{
basicMaterialExtend
.
setId
(
meId
);
materialExtendMapper
.
updateByPrimaryKeySelective
(
basicMaterialExtend
);
}
}
if
(
StringUtil
.
isExist
(
materialExObj
.
get
(
"other"
)))
{
String
otherStr
=
materialExObj
.
getString
(
"other"
);
MaterialExtend
otherMaterialExtend
=
JSONObject
.
parseObject
(
otherStr
,
MaterialExtend
.
class
);
otherMaterialExtend
.
setMaterialId
(
mId
);
otherMaterialExtend
.
setDefaultFlag
(
"0"
);
otherMaterialExtend
.
setCreateTime
(
new
Date
());
otherMaterialExtend
.
setUpdateTime
(
System
.
currentTimeMillis
());
otherMaterialExtend
.
setCreateSerial
(
user
.
getLoginName
());
otherMaterialExtend
.
setUpdateSerial
(
user
.
getLoginName
());
Long
meId
=
materialExtendService
.
selectIdByMaterialIdAndDefaultFlag
(
mId
,
"0"
);
if
(
meId
==
0L
){
materialExtendMapper
.
insertSelective
(
otherMaterialExtend
);
}
else
{
otherMaterialExtend
.
setId
(
meId
);
materialExtendMapper
.
updateByPrimaryKeySelective
(
otherMaterialExtend
);
}
}
//给商品初始化库存getAllListWithStock
Map
<
Long
,
BigDecimal
>
stockMap
=
m
.
getStockMap
();
Long
depotId
=
null
;
for
(
Depot
depot:
depotList
){
BigDecimal
stock
=
stockMap
.
get
(
depot
.
getId
());
//先清除再插入
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
mId
).
andDepotIdEqualTo
(
depot
.
getId
());
materialInitialStockMapper
.
deleteByExample
(
example
);
if
(
stock
!=
null
&&
stock
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
)
{
depotId
=
depot
.
getId
();
insertStockByMaterialAndDepot
(
depotId
,
mId
,
stock
);
}
}
}
info
.
code
=
200
;
info
.
data
=
"导入成功"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
info
.
code
=
500
;
info
.
data
=
"导入失败"
;
}
return
info
;
}
/**
* 根据条件返回产品列表
* @param name
* @param model
* @param color
* @param standard
* @param mfrs
* @param unit
* @param unitId
* @return
*/
private
List
<
Material
>
getMaterialListByParam
(
String
name
,
String
model
,
String
color
,
String
standard
,
String
mfrs
,
String
unit
,
Long
unitId
)
{
MaterialExample
example
=
new
MaterialExample
();
MaterialExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andNameEqualTo
(
name
);
if
(
StringUtil
.
isNotEmpty
(
model
))
{
criteria
.
andModelEqualTo
(
model
);
}
if
(
StringUtil
.
isNotEmpty
(
color
))
{
criteria
.
andColorEqualTo
(
color
);
}
if
(
StringUtil
.
isNotEmpty
(
standard
))
{
criteria
.
andStandardEqualTo
(
standard
);
}
if
(
StringUtil
.
isNotEmpty
(
mfrs
))
{
criteria
.
andMfrsEqualTo
(
mfrs
);
}
if
(
StringUtil
.
isNotEmpty
(
unit
))
{
criteria
.
andUnitEqualTo
(
unit
);
}
if
(
unitId
!=
null
)
{
criteria
.
andUnitIdEqualTo
(
unitId
);
}
criteria
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Material
>
list
=
materialMapper
.
selectByExample
(
example
);
return
list
;
}
/**
* 写入初始库存
* @param depotId
* @param mId
* @param stock
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
insertStockByMaterialAndDepot
(
Long
depotId
,
Long
mId
,
BigDecimal
stock
){
MaterialInitialStock
materialInitialStock
=
new
MaterialInitialStock
();
materialInitialStock
.
setDepotId
(
depotId
);
materialInitialStock
.
setMaterialId
(
mId
);
materialInitialStock
.
setNumber
(
stock
);
materialInitialStockMapper
.
insertSelective
(
materialInitialStock
);
//存入初始库存
}
public
List
<
MaterialVo4Unit
>
getMaterialEnableSerialNumberList
(
String
q
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
list
=
materialMapperEx
.
getMaterialEnableSerialNumberList
(
q
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
Long
getMaterialEnableSerialNumberCount
(
String
q
)
throws
Exception
{
Long
count
=
null
;
try
{
count
=
materialMapperEx
.
getMaterialEnableSerialNumberCount
(
q
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
count
;
}
public
BigDecimal
parseBigDecimalEx
(
String
str
)
throws
Exception
{
if
(!
StringUtil
.
isEmpty
(
str
))
{
return
new
BigDecimal
(
str
);
}
else
{
return
null
;
}
}
public
BigDecimal
parsePrice
(
String
price
,
String
ratio
)
throws
Exception
{
if
(
StringUtil
.
isEmpty
(
price
)
||
StringUtil
.
isEmpty
(
ratio
))
{
return
BigDecimal
.
ZERO
;
}
else
{
BigDecimal
pr
=
new
BigDecimal
(
price
);
BigDecimal
r
=
new
BigDecimal
(
ratio
);
return
pr
.
multiply
(
r
);
}
}
/**
* 根据商品获取初始库存,仓库为空的时候查全部库存
* @param materialId
* @return
*/
public
BigDecimal
getInitStockByMid
(
Long
depotId
,
Long
materialId
)
{
BigDecimal
stock
=
BigDecimal
.
ZERO
;
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
if
(
depotId
!=
null
)
{
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDepotIdEqualTo
(
depotId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
{
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
List
<
MaterialInitialStock
>
list
=
materialInitialStockMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
for
(
MaterialInitialStock
ms:
list
)
{
if
(
ms
!=
null
)
{
stock
=
stock
.
add
(
ms
.
getNumber
());
}
}
}
return
stock
;
}
/**
* 根据商品和仓库获取初始库存
* @param materialId
* @param depotId
* @return
*/
public
BigDecimal
getInitStock
(
Long
materialId
,
Long
depotId
)
{
BigDecimal
stock
=
BigDecimal
.
ZERO
;
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDepotIdEqualTo
(
depotId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialInitialStock
>
list
=
materialInitialStockMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
stock
=
list
.
get
(
0
).
getNumber
();
}
return
stock
;
}
/**
* 根据商品和仓库获取当前库存
* @param materialId
* @param depotId
* @return
*/
public
BigDecimal
getCurrentStock
(
Long
materialId
,
Long
depotId
)
{
BigDecimal
stock
=
BigDecimal
.
ZERO
;
MaterialCurrentStockExample
example
=
new
MaterialCurrentStockExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDepotIdEqualTo
(
depotId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialCurrentStock
>
list
=
materialCurrentStockMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
stock
=
list
.
get
(
0
).
getCurrentNumber
();
}
else
{
stock
=
getInitStock
(
materialId
,
depotId
);
}
return
stock
;
}
public
List
<
MaterialVo4Unit
>
getMaterialByMeId
(
Long
meId
)
{
List
<
MaterialVo4Unit
>
result
=
new
ArrayList
<
MaterialVo4Unit
>();
try
{
if
(
meId
!=
null
)
{
result
=
materialMapperEx
.
getMaterialByMeId
(
meId
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
String
getMaxBarCode
()
{
String
maxBarCodeOld
=
materialMapperEx
.
getMaxBarCode
();
return
Long
.
parseLong
(
maxBarCodeOld
)+
""
;
}
public
List
<
String
>
getMaterialNameList
()
{
return
materialMapperEx
.
getMaterialNameList
();
}
public
List
<
MaterialVo4Unit
>
getMaterialByBarCode
(
String
barCode
)
{
return
materialMapperEx
.
getMaterialByBarCode
(
barCode
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialCategory
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.service.materialProperty.MaterialPropertyResource
;
import
com.jsh.erp.service.materialProperty.MaterialPropertyService
;
import
com.jsh.erp.utils.Constants
;
import
com.jsh.erp.utils.QueryUtils
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"materialCategory_component"
)
@MaterialCategoryResource
public
class
MaterialCategoryComponent
implements
ICommonQuery
{
@Resource
private
MaterialCategoryService
materialCategoryService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
materialCategoryService
.
getMaterialCategory
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMaterialCategoryList
(
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"
));
String
order
=
QueryUtils
.
order
(
map
);
return
materialCategoryService
.
select
(
name
,
parentId
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
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"
));
return
materialCategoryService
.
countMaterialCategory
(
name
,
parentId
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialCategoryService
.
insertMaterialCategory
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialCategoryService
.
updateMaterialCategory
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
materialCategoryService
.
deleteMaterialCategory
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
materialCategoryService
.
batchDeleteMaterialCategory
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
materialCategoryService
.
checkIsNameExist
(
id
,
name
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialCategory
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"materialCategory"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MaterialCategoryResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialCategory
;
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.MaterialCategoryMapper
;
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.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
MaterialCategoryService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialCategoryService
.
class
);
@Resource
private
MaterialCategoryMapper
materialCategoryMapper
;
@Resource
private
MaterialCategoryMapperEx
materialCategoryMapperEx
;
@Resource
private
UserService
userService
;
@Resource
private
LogService
logService
;
@Resource
private
MaterialMapperEx
materialMapperEx
;
public
MaterialCategory
getMaterialCategory
(
long
id
)
throws
Exception
{
MaterialCategory
result
=
null
;
try
{
result
=
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
MaterialCategory
>
getMaterialCategoryListByIds
(
String
ids
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
List
<
MaterialCategory
>
list
=
new
ArrayList
<>();
try
{
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
list
=
materialCategoryMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialCategory
>
getMaterialCategory
()
throws
Exception
{
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
List
<
MaterialCategory
>
list
=
null
;
try
{
list
=
materialCategoryMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialCategory
>
getAllList
(
Long
parentId
)
throws
Exception
{
List
<
MaterialCategory
>
list
=
null
;
try
{
list
=
getMCList
(
parentId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialCategory
>
getMCList
(
Long
parentId
)
throws
Exception
{
List
<
MaterialCategory
>
res
=
new
ArrayList
<
MaterialCategory
>();
List
<
MaterialCategory
>
list
=
null
;
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andParentIdEqualTo
(
parentId
).
andIdNotEqualTo
(
1L
);
example
.
setOrderByClause
(
"id"
);
list
=
materialCategoryMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
res
.
addAll
(
list
);
for
(
MaterialCategory
mc
:
list
)
{
List
<
MaterialCategory
>
mcList
=
getMCList
(
mc
.
getId
());
if
(
mcList
!=
null
&&
mcList
.
size
()>
0
)
{
res
.
addAll
(
mcList
);
}
}
}
return
res
;
}
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
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
Long
countMaterialCategory
(
String
name
,
Integer
parentId
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
materialCategoryMapperEx
.
countsByMaterialCategory
(
name
,
parentId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterialCategory
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
MaterialCategory
materialCategory
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
MaterialCategory
.
class
);
materialCategory
.
setCreateTime
(
new
Date
());
materialCategory
.
setUpdateTime
(
new
Date
());
int
result
=
0
;
try
{
result
=
materialCategoryMapper
.
insertSelective
(
materialCategory
);
logService
.
insertLog
(
"商品类型"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
).
append
(
materialCategory
.
getName
()).
toString
(),
request
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterialCategory
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
MaterialCategory
materialCategory
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
MaterialCategory
.
class
);
materialCategory
.
setUpdateTime
(
new
Date
());
int
result
=
0
;
try
{
result
=
materialCategoryMapper
.
updateByPrimaryKeySelective
(
materialCategory
);
logService
.
insertLog
(
"商品类型"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
materialCategory
.
getName
()).
toString
(),
request
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteMaterialCategory
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteMaterialCategoryByIds
(
id
.
toString
());
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialCategory
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteMaterialCategoryByIds
(
ids
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialCategoryByIds
(
String
ids
)
throws
Exception
{
int
result
=
0
;
String
[]
idArray
=
ids
.
split
(
","
);
//校验产品表 jsh_material
List
<
Material
>
materialList
=
null
;
try
{
materialList
=
materialMapperEx
.
getMaterialListByCategoryIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
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_material_category
List
<
MaterialCategory
>
materialCategoryList
=
null
;
try
{
materialCategoryList
=
materialCategoryMapperEx
.
getMaterialCategoryListByCategoryIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
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
);
}
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
);
List
<
MaterialCategory
>
list
=
getMaterialCategoryListByIds
(
ids
);
for
(
MaterialCategory
materialCategory:
list
){
sb
.
append
(
"["
).
append
(
materialCategory
.
getName
()).
append
(
"]"
);
}
logService
.
insertLog
(
"商品类型"
,
sb
.
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//更新时间
Date
updateDate
=
new
Date
();
//更新人
User
userInfo
=
userService
.
getCurrentUser
();
Long
updater
=
userInfo
==
null
?
null
:
userInfo
.
getId
();
String
strArray
[]=
ids
.
split
(
","
);
if
(
strArray
.
length
<
1
){
return
0
;
}
try
{
result
=
materialCategoryMapperEx
.
batchDeleteMaterialCategoryByIds
(
updateDate
,
updater
,
strArray
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
0
;
}
public
List
<
MaterialCategory
>
findById
(
Long
id
)
throws
Exception
{
List
<
MaterialCategory
>
list
=
null
;
if
(
id
!=
null
)
{
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andIdEqualTo
(
id
);
try
{
list
=
materialCategoryMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
}
return
list
;
}
/**
* create by: cjl
* description:
*获取商品类别树数据
* create time: 2019/2/19 14:30
* @Param:
* @return java.util.List<com.jsh.erp.datasource.vo.TreeNode>
*/
public
List
<
TreeNode
>
getMaterialCategoryTree
(
Long
id
)
throws
Exception
{
List
<
TreeNode
>
list
=
null
;
try
{
list
=
materialCategoryMapperEx
.
getNodeTree
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
/**
* create by: cjl
* description:
* 新增商品类别信息
* create time: 2019/2/19 16:30
* @Param: mc
* @return void
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
addMaterialCategory
(
MaterialCategory
mc
)
throws
Exception
{
logService
.
insertLog
(
"商品类型"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
).
append
(
mc
.
getName
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
mc
==
null
){
return
0
;
}
if
(
mc
.
getParentId
()==
null
){
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
mc
.
setParentId
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_PARENT_ID
);
}
//检查商品类型编号是否已存在
checkMaterialCategorySerialNo
(
mc
);
//数据状态新增时默认设置为启用
Date
date
=
new
Date
();
User
userInfo
=
userService
.
getCurrentUser
();
//创建时间
mc
.
setCreateTime
(
date
);
//更新时间
mc
.
setUpdateTime
(
date
);
int
result
=
0
;
try
{
result
=
materialCategoryMapperEx
.
addMaterialCategory
(
mc
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
editMaterialCategory
(
MaterialCategory
mc
)
throws
Exception
{
logService
.
insertLog
(
"商品类型"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
mc
.
getName
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
mc
.
getParentId
()==
null
){
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
mc
.
setParentId
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_PARENT_ID
);
}
//检查商品类型编号是否已存在
checkMaterialCategorySerialNo
(
mc
);
//更新时间
mc
.
setUpdateTime
(
new
Date
());
//更新人
User
userInfo
=
userService
.
getCurrentUser
();
int
result
=
0
;
try
{
result
=
materialCategoryMapperEx
.
editMaterialCategory
(
mc
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
/**
* 根据商品类别编号判断商品类别是否已存在
* */
public
void
checkMaterialCategorySerialNo
(
MaterialCategory
mc
)
throws
Exception
{
if
(
mc
==
null
){
return
;
}
if
(
StringUtil
.
isEmpty
(
mc
.
getSerialNo
())){
return
;
}
//根据商品类别编号查询商品类别
List
<
MaterialCategory
>
mList
=
null
;
try
{
mList
=
materialCategoryMapperEx
.
getMaterialCategoryBySerialNo
(
mc
.
getSerialNo
(),
mc
.
getId
());
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
mList
==
null
||
mList
.
size
()<
1
){
//未查询到对应数据,编号可用
return
;
}
if
(
mList
.
size
()>
1
){
//查询到的数据条数大于1,编号已存在
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG
);
}
if
(
mc
.
getId
()==
null
){
//新增时,编号已存在
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG
);
}
/**
* 包装类型用equals来比较
* */
if
(
mc
.
getId
().
equals
(
mList
.
get
(
0
).
getId
())){
//修改时,相同编号,id不同
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG
);
}
}
/**
* 根据名称获取类型
* @param name
*/
public
Long
getCategoryIdByName
(
String
name
){
Long
categoryId
=
0L
;
MaterialCategoryExample
example
=
new
MaterialCategoryExample
();
example
.
createCriteria
().
andNameEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialCategory
>
list
=
materialCategoryMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
categoryId
=
list
.
get
(
0
).
getId
();
}
return
categoryId
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialExtend
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"material_extend"
)
@MaterialExtendResource
public
class
MaterialExtendComponent
implements
ICommonQuery
{
@Resource
private
MaterialExtendService
materialExtendService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
materialExtendService
.
getMaterialExtend
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMaterialList
(
map
);
}
private
List
<?>
getMaterialList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
null
;
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
0L
;
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
insertMaterialExtend
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
updateMaterialExtend
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
deleteMaterialExtend
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
materialExtendService
.
batchDeleteMaterialExtendByIds
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
materialExtendService
.
checkIsExist
(
id
,
name
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialExtend
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"materialExtend"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MaterialExtendResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialExtend
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.MaterialExtend
;
import
com.jsh.erp.datasource.entities.MaterialExtendExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.MaterialExtendMapper
;
import
com.jsh.erp.datasource.mappers.MaterialExtendMapperEx
;
import
com.jsh.erp.datasource.vo.MaterialExtendVo4List
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.redis.RedisService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
MaterialExtendService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialExtendService
.
class
);
@Resource
private
MaterialExtendMapper
materialExtendMapper
;
@Resource
private
MaterialExtendMapperEx
materialExtendMapperEx
;
@Resource
private
LogService
logService
;
@Resource
private
UserService
userService
;
@Resource
private
RedisService
redisService
;
public
MaterialExtend
getMaterialExtend
(
long
id
)
throws
Exception
{
MaterialExtend
result
=
null
;
try
{
result
=
materialExtendMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
MaterialExtendVo4List
>
getDetailList
(
Long
materialId
)
{
List
<
MaterialExtendVo4List
>
list
=
null
;
try
{
list
=
materialExtendMapperEx
.
getDetailList
(
materialId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialExtend
>
getListByMIds
(
List
<
Long
>
idList
)
{
List
<
MaterialExtend
>
meList
=
null
;
try
{
Long
[]
idArray
=
StringUtil
.
listToLongArray
(
idList
);
if
(
idArray
!=
null
&&
idArray
.
length
>
0
)
{
meList
=
materialExtendMapperEx
.
getListByMId
(
idArray
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
meList
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
saveDetials
(
JSONObject
obj
,
String
sortList
,
Long
materialId
)
throws
Exception
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
JSONArray
meArr
=
obj
.
getJSONArray
(
"meList"
);
JSONArray
insertedJson
=
new
JSONArray
();
JSONArray
updatedJson
=
new
JSONArray
();
JSONArray
deletedJson
=
new
JSONArray
();
List
<
String
>
barCodeList
=
new
ArrayList
<>();
if
(
null
!=
meArr
)
{
for
(
int
i
=
0
;
i
<
meArr
.
size
();
i
++)
{
JSONObject
tempJson
=
meArr
.
getJSONObject
(
i
);
String
barCode
=
tempJson
.
getString
(
"barCode"
);
barCodeList
.
add
(
barCode
);
MaterialExtend
materialExtend
=
getInfoByBarCode
(
barCode
);
if
(
materialExtend
.
getBarCode
()
==
null
){
insertedJson
.
add
(
tempJson
);
}
else
{
updatedJson
.
add
(
tempJson
);
}
}
List
<
MaterialExtend
>
materialExtendList
=
getMeListByBarCodeAndMid
(
barCodeList
,
materialId
);
for
(
MaterialExtend
meObj:
materialExtendList
)
{
JSONObject
deleteObj
=
new
JSONObject
();
deleteObj
.
put
(
"id"
,
meObj
.
getId
());
deletedJson
.
add
(
deleteObj
);
}
}
JSONArray
sortJson
=
JSONArray
.
parseArray
(
sortList
);
if
(
null
!=
insertedJson
)
{
for
(
int
i
=
0
;
i
<
insertedJson
.
size
();
i
++)
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
JSONObject
tempInsertedJson
=
JSONObject
.
parseObject
(
insertedJson
.
getString
(
i
));
materialExtend
.
setMaterialId
(
materialId
);
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"barCode"
)))
{
materialExtend
.
setBarCode
(
tempInsertedJson
.
getString
(
"barCode"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"commodityUnit"
)))
{
materialExtend
.
setCommodityUnit
(
tempInsertedJson
.
getString
(
"commodityUnit"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"purchaseDecimal"
)))
{
materialExtend
.
setPurchaseDecimal
(
tempInsertedJson
.
getBigDecimal
(
"purchaseDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"commodityDecimal"
)))
{
materialExtend
.
setCommodityDecimal
(
tempInsertedJson
.
getBigDecimal
(
"commodityDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"wholesaleDecimal"
)))
{
materialExtend
.
setWholesaleDecimal
(
tempInsertedJson
.
getBigDecimal
(
"wholesaleDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"lowDecimal"
)))
{
materialExtend
.
setLowDecimal
(
tempInsertedJson
.
getBigDecimal
(
"lowDecimal"
));
}
this
.
insertMaterialExtend
(
materialExtend
);
}
}
if
(
null
!=
deletedJson
)
{
StringBuffer
bf
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
deletedJson
.
size
();
i
++)
{
JSONObject
tempDeletedJson
=
JSONObject
.
parseObject
(
deletedJson
.
getString
(
i
));
bf
.
append
(
tempDeletedJson
.
getLong
(
"id"
));
if
(
i
<(
deletedJson
.
size
()-
1
)){
bf
.
append
(
","
);
}
}
this
.
batchDeleteMaterialExtendByIds
(
bf
.
toString
(),
request
);
}
if
(
null
!=
updatedJson
)
{
for
(
int
i
=
0
;
i
<
updatedJson
.
size
();
i
++)
{
JSONObject
tempUpdatedJson
=
JSONObject
.
parseObject
(
updatedJson
.
getString
(
i
));
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setId
(
tempUpdatedJson
.
getLong
(
"id"
));
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"barCode"
)))
{
materialExtend
.
setBarCode
(
tempUpdatedJson
.
getString
(
"barCode"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"commodityUnit"
)))
{
materialExtend
.
setCommodityUnit
(
tempUpdatedJson
.
getString
(
"commodityUnit"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"purchaseDecimal"
)))
{
materialExtend
.
setPurchaseDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"purchaseDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"commodityDecimal"
)))
{
materialExtend
.
setCommodityDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"commodityDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"wholesaleDecimal"
)))
{
materialExtend
.
setWholesaleDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"wholesaleDecimal"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempUpdatedJson
.
getString
(
"lowDecimal"
)))
{
materialExtend
.
setLowDecimal
(
tempUpdatedJson
.
getBigDecimal
(
"lowDecimal"
));
}
this
.
updateMaterialExtend
(
materialExtend
);
}
}
//处理条码的排序,基础单位排第一个
if
(
null
!=
sortJson
&&
sortJson
.
size
()>
0
)
{
//此处为更新的逻辑
for
(
int
i
=
0
;
i
<
sortJson
.
size
();
i
++)
{
JSONObject
tempSortJson
=
JSONObject
.
parseObject
(
sortJson
.
getString
(
i
));
MaterialExtend
materialExtend
=
new
MaterialExtend
();
if
(
StringUtil
.
isExist
(
tempSortJson
.
get
(
"id"
)))
{
materialExtend
.
setId
(
tempSortJson
.
getLong
(
"id"
));
}
if
(
StringUtil
.
isExist
(
tempSortJson
.
get
(
"defaultFlag"
)))
{
materialExtend
.
setDefaultFlag
(
tempSortJson
.
getString
(
"defaultFlag"
));
}
this
.
updateMaterialExtend
(
materialExtend
);
}
}
else
{
//新增的时候将第一条记录设置为默认基础单位
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialExtend
>
meList
=
materialExtendMapper
.
selectByExample
(
example
);
if
(
meList
!=
null
)
{
for
(
int
i
=
0
;
i
<
meList
.
size
();
i
++)
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setId
(
meList
.
get
(
i
).
getId
());
if
(
i
==
0
)
{
materialExtend
.
setDefaultFlag
(
"1"
);
//默认
}
else
{
materialExtend
.
setDefaultFlag
(
"0"
);
//非默认
}
this
.
updateMaterialExtend
(
materialExtend
);
}
}
}
return
null
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterialExtend
(
MaterialExtend
materialExtend
)
throws
Exception
{
User
user
=
userService
.
getCurrentUser
();
materialExtend
.
setDeleteFlag
(
BusinessConstants
.
DELETE_FLAG_EXISTS
);
materialExtend
.
setCreateTime
(
new
Date
());
materialExtend
.
setUpdateTime
(
new
Date
().
getTime
());
materialExtend
.
setCreateSerial
(
user
.
getLoginName
());
materialExtend
.
setUpdateSerial
(
user
.
getLoginName
());
int
result
=
0
;
try
{
result
=
materialExtendMapper
.
insertSelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterialExtend
(
MaterialExtend
MaterialExtend
)
throws
Exception
{
User
user
=
userService
.
getCurrentUser
();
MaterialExtend
.
setUpdateTime
(
System
.
currentTimeMillis
());
MaterialExtend
.
setUpdateSerial
(
user
.
getLoginName
());
int
res
=
0
;
try
{
res
=
materialExtendMapper
.
updateByPrimaryKeySelective
(
MaterialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
res
;
}
public
int
checkIsExist
(
Long
id
,
String
MaterialExtendName
)
throws
Exception
{
MaterialExtendExample
example
=
new
MaterialExtendExample
();
MaterialExtendExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andBarCodeEqualTo
(
MaterialExtendName
);
if
(
id
>
0
)
{
criteria
.
andIdNotEqualTo
(
id
);
}
List
<
MaterialExtend
>
list
=
null
;
try
{
list
=
materialExtendMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
==
null
?
0
:
list
.
size
();
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteMaterialExtend
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
int
result
=
0
;
MaterialExtend
materialExtend
=
new
MaterialExtend
();
materialExtend
.
setId
(
id
);
materialExtend
.
setDeleteFlag
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
Long
userId
=
Long
.
parseLong
(
redisService
.
getObjectFromSessionByKey
(
request
,
"userId"
).
toString
());
User
user
=
userService
.
getUser
(
userId
);
materialExtend
.
setUpdateTime
(
new
Date
().
getTime
());
materialExtend
.
setUpdateSerial
(
user
.
getLoginName
());
try
{
result
=
materialExtendMapper
.
updateByPrimaryKeySelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialExtendByIds
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
String
[]
idArray
=
ids
.
split
(
","
);
int
result
=
0
;
try
{
result
=
materialExtendMapperEx
.
batchDeleteMaterialExtendByIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
int
insertMaterialExtend
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
MaterialExtend
materialExtend
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
MaterialExtend
.
class
);
int
result
=
0
;
try
{
result
=
materialExtendMapper
.
insertSelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
int
updateMaterialExtend
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
MaterialExtend
materialExtend
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
MaterialExtend
.
class
);
int
result
=
0
;
try
{
result
=
materialExtendMapper
.
insertSelective
(
materialExtend
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
MaterialExtend
>
getMaterialExtendByTenantAndTime
(
Long
tenantId
,
Long
lastTime
,
Long
syncNum
)
throws
Exception
{
List
<
MaterialExtend
>
list
=
new
ArrayList
<
MaterialExtend
>();
try
{
//先获取最大的时间戳,再查两个时间戳之间的数据,这样同步能够防止丢失数据(应为时间戳有重复)
Long
maxTime
=
materialExtendMapperEx
.
getMaxTimeByTenantAndTime
(
tenantId
,
lastTime
,
syncNum
);
if
(
tenantId
!=
null
&&
lastTime
!=
null
&&
maxTime
!=
null
)
{
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andTenantIdEqualTo
(
tenantId
)
.
andUpdateTimeGreaterThan
(
lastTime
)
.
andUpdateTimeLessThanOrEqualTo
(
maxTime
);
list
=
materialExtendMapper
.
selectByExample
(
example
);
}
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
Long
selectIdByMaterialIdAndDefaultFlag
(
Long
materialId
,
String
defaultFlag
)
throws
Exception
{
Long
id
=
0L
;
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
materialId
).
andDefaultFlagEqualTo
(
defaultFlag
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialExtend
>
list
=
materialExtendMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
id
=
list
.
get
(
0
).
getId
();
}
return
id
;
}
public
MaterialExtend
getInfoByBarCode
(
String
barCode
)
throws
Exception
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andBarCodeEqualTo
(
barCode
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialExtend
>
list
=
materialExtendMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
materialExtend
=
list
.
get
(
0
);
}
return
materialExtend
;
}
/**
* 查询某个商品里面被清除的条码信息
* @param barCodeList
* @param mId
* @return
* @throws Exception
*/
public
List
<
MaterialExtend
>
getMeListByBarCodeAndMid
(
List
<
String
>
barCodeList
,
Long
mId
)
throws
Exception
{
MaterialExtend
materialExtend
=
new
MaterialExtend
();
MaterialExtendExample
example
=
new
MaterialExtendExample
();
example
.
createCriteria
().
andBarCodeNotIn
(
barCodeList
).
andMaterialIdEqualTo
(
mId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialExtend
>
list
=
materialExtendMapper
.
selectByExample
(
example
);
return
list
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialProperty
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.utils.Constants
;
import
com.jsh.erp.utils.QueryUtils
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"materialProperty_component"
)
@MaterialPropertyResource
public
class
MaterialPropertyComponent
implements
ICommonQuery
{
@Resource
private
MaterialPropertyService
materialPropertyService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
materialPropertyService
.
getMaterialProperty
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMaterialPropertyList
(
map
);
}
private
List
<?>
getMaterialPropertyList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
order
=
QueryUtils
.
order
(
map
);
return
materialPropertyService
.
select
(
name
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
return
materialPropertyService
.
countMaterialProperty
(
name
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialPropertyService
.
insertMaterialProperty
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
materialPropertyService
.
updateMaterialProperty
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
materialPropertyService
.
deleteMaterialProperty
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
materialPropertyService
.
batchDeleteMaterialProperty
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
materialPropertyService
.
checkIsNameExist
(
id
,
name
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialProperty
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"materialProperty"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MaterialPropertyResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.materialProperty
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.MaterialProperty
;
import
com.jsh.erp.datasource.entities.MaterialPropertyExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.MaterialPropertyMapper
;
import
com.jsh.erp.datasource.mappers.MaterialPropertyMapperEx
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.List
;
@Service
public
class
MaterialPropertyService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialPropertyService
.
class
);
@Resource
private
MaterialPropertyMapper
materialPropertyMapper
;
@Resource
private
MaterialPropertyMapperEx
materialPropertyMapperEx
;
@Resource
private
UserService
userService
;
@Resource
private
LogService
logService
;
public
MaterialProperty
getMaterialProperty
(
long
id
)
throws
Exception
{
MaterialProperty
result
=
null
;
try
{
result
=
materialPropertyMapper
.
selectByPrimaryKey
(
id
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
public
List
<
MaterialProperty
>
getMaterialProperty
()
throws
Exception
{
MaterialPropertyExample
example
=
new
MaterialPropertyExample
();
example
.
createCriteria
().
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialProperty
>
list
=
null
;
try
{
list
=
materialPropertyMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
MaterialProperty
>
select
(
String
name
,
int
offset
,
int
rows
)
throws
Exception
{
List
<
MaterialProperty
>
list
=
null
;
try
{
list
=
materialPropertyMapperEx
.
selectByConditionMaterialProperty
(
name
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
Long
countMaterialProperty
(
String
name
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
materialPropertyMapperEx
.
countsByMaterialProperty
(
name
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertMaterialProperty
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
MaterialProperty
materialProperty
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
MaterialProperty
.
class
);
int
result
=
0
;
try
{
result
=
materialPropertyMapper
.
insertSelective
(
materialProperty
);
logService
.
insertLog
(
"商品属性"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
).
append
(
materialProperty
.
getNativeName
()).
toString
(),
request
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateMaterialProperty
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
MaterialProperty
materialProperty
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
MaterialProperty
.
class
);
int
result
=
0
;
try
{
result
=
materialPropertyMapper
.
updateByPrimaryKeySelective
(
materialProperty
);
logService
.
insertLog
(
"商品属性"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
materialProperty
.
getNativeName
()).
toString
(),
request
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteMaterialProperty
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteMaterialPropertyByIds
(
id
.
toString
());
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialProperty
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteMaterialPropertyByIds
(
ids
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialPropertyByIds
(
String
ids
)
throws
Exception
{
logService
.
insertLog
(
"商品属性"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
User
userInfo
=
userService
.
getCurrentUser
();
String
[]
idArray
=
ids
.
split
(
","
);
int
result
=
0
;
try
{
result
=
materialPropertyMapperEx
.
batchDeleteMaterialPropertyByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
0
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/msg/MsgComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.msg
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.utils.Constants
;
import
com.jsh.erp.utils.QueryUtils
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
@Service
(
value
=
"msg_component"
)
@MsgResource
public
class
MsgComponent
implements
ICommonQuery
{
@Resource
private
MsgService
msgService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
msgService
.
getMsg
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getMsgList
(
map
);
}
private
List
<?>
getMsgList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
order
=
QueryUtils
.
order
(
map
);
String
filter
=
QueryUtils
.
filter
(
map
);
return
msgService
.
select
(
name
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
return
msgService
.
countMsg
(
name
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
msgService
.
insertMsg
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
msgService
.
updateMsg
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
msgService
.
deleteMsg
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
msgService
.
batchDeleteMsg
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
msgService
.
checkIsNameExist
(
id
,
name
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/msg/MsgResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.msg
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2019-9-7 22:52:35
*/
@ResourceInfo
(
value
=
"msg"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
MsgResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/msg/MsgService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.msg
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.Msg
;
import
com.jsh.erp.datasource.entities.MsgExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.MsgMapper
;
import
com.jsh.erp.datasource.mappers.MsgMapperEx
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.depotHead.DepotHeadService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Service
public
class
MsgService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MsgService
.
class
);
@Resource
private
MsgMapper
msgMapper
;
@Resource
private
MsgMapperEx
msgMapperEx
;
@Resource
private
DepotHeadService
depotHeadService
;
@Resource
private
UserService
userService
;
@Resource
private
LogService
logService
;
public
Msg
getMsg
(
long
id
)
throws
Exception
{
Msg
result
=
null
;
try
{
result
=
msgMapper
.
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
<
Msg
>
getMsg
()
throws
Exception
{
MsgExample
example
=
new
MsgExample
();
example
.
createCriteria
().
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Msg
>
list
=
null
;
try
{
list
=
msgMapper
.
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
<
Msg
>
select
(
String
name
,
int
offset
,
int
rows
)
throws
Exception
{
List
<
Msg
>
list
=
null
;
try
{
list
=
msgMapperEx
.
selectByConditionMsg
(
name
,
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
countMsg
(
String
name
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
msgMapperEx
.
countsByMsg
(
name
);
}
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
insertMsg
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Msg
msg
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Msg
.
class
);
int
result
=
0
;
try
{
result
=
msgMapper
.
insertSelective
(
msg
);
logService
.
insertLog
(
"消息"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
).
append
(
msg
.
getMsgTitle
()).
toString
(),
request
);
}
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
updateMsg
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Msg
msg
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Msg
.
class
);
int
result
=
0
;
try
{
result
=
msgMapper
.
updateByPrimaryKeySelective
(
msg
);
logService
.
insertLog
(
"消息"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
msg
.
getMsgTitle
()).
toString
(),
request
);
}
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
deleteMsg
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
int
result
=
0
;
try
{
result
=
msgMapper
.
deleteByPrimaryKey
(
id
);
logService
.
insertLog
(
"消息"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
id
).
toString
(),
request
);
}
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
batchDeleteMsg
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
MsgExample
example
=
new
MsgExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
int
result
=
0
;
try
{
result
=
msgMapper
.
deleteByExample
(
example
);
logService
.
insertLog
(
"消息"
,
"批量删除,id集:"
+
ids
,
request
);
}
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
)
throws
Exception
{
MsgExample
example
=
new
MsgExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andMsgTitleEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Msg
>
list
=
null
;
try
{
list
=
msgMapper
.
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
==
null
?
0
:
list
.
size
();
}
/**
* create by: qiankunpingtai
* 逻辑删除角色信息
* create time: 2019/3/28 15:44
* @Param: ids
* @return int
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMsgByIds
(
String
ids
)
throws
Exception
{
logService
.
insertLog
(
"序列号"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
String
[]
idArray
=
ids
.
split
(
","
);
int
result
=
0
;
try
{
result
=
msgMapperEx
.
batchDeleteMsgByIds
(
idArray
);
}
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
List
<
Msg
>
getMsgByStatus
(
String
status
)
throws
Exception
{
MsgExample
example
=
new
MsgExample
();
example
.
createCriteria
().
andStatusEqualTo
(
status
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Msg
>
list
=
null
;
try
{
list
=
msgMapper
.
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
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
batchUpdateStatus
(
String
ids
,
String
status
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
Msg
msg
=
new
Msg
();
msg
.
setStatus
(
status
);
MsgExample
example
=
new
MsgExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
try
{
msgMapper
.
updateByExampleSelective
(
msg
,
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
);
}
}
public
Long
getMsgCountByStatus
(
String
status
)
throws
Exception
{
Long
result
=
null
;
try
{
User
userInfo
=
userService
.
getCurrentUser
();
result
=
msgMapperEx
.
getMsgCountByStatus
(
status
,
userInfo
.
getId
());
}
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.orgaUserRel
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.service.organization.OrganizationResource
;
import
com.jsh.erp.service.organization.OrganizationService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/11 18:10
*/
@Service
(
value
=
"orgaUserRel_component"
)
@OrgaUserRelResource
public
class
OrgaUserRelComponent
implements
ICommonQuery
{
@Resource
private
OrgaUserRelService
orgaUserRelService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
orgaUserRelService
.
getOrgaUserRel
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
parameterMap
)
throws
Exception
{
return
getOrgaUserRelList
(
parameterMap
);
}
private
List
<?>
getOrgaUserRelList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
null
;
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
parameterMap
)
throws
Exception
{
return
null
;
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
orgaUserRelService
.
insertOrgaUserRel
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
orgaUserRelService
.
updateOrgaUserRel
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
orgaUserRelService
.
deleteOrgaUserRel
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
orgaUserRelService
.
batchDeleteOrgaUserRel
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
0
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.orgaUserRel
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* Description
* 机构用户关系
* @Author: cjl
* @Date: 2019/3/11 18:11
*/
@ResourceInfo
(
value
=
"orgaUserRel"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
OrgaUserRelResource
{
}
Prev
1
…
8
9
10
11
12
13
Next
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