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
aa7dca67
"src/main/vscode:/vscode.git/clone" did not exist on "f23d238cf72d53506c92d976dbc7781be280b4e2"
Commit
aa7dca67
authored
Mar 26, 2019
by
乾坤平台
Committed by
季圣华
Mar 26, 2019
Browse files
!38 修改日志记录功能
Merge pull request !38 from 乾坤平台/master
parents
bd64a7e4
7e20ea9c
Changes
18
Show whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
aa7dca67
...
@@ -135,6 +135,67 @@ public class BusinessConstants {
...
@@ -135,6 +135,67 @@ public class BusinessConstants {
public
static
final
byte
USER_STATUS_NORMAL
=
0
;
public
static
final
byte
USER_STATUS_NORMAL
=
0
;
public
static
final
byte
USER_STATUS_DELETE
=
1
;
public
static
final
byte
USER_STATUS_DELETE
=
1
;
public
static
final
byte
USER_STATUS_BANNED
=
2
;
public
static
final
byte
USER_STATUS_BANNED
=
2
;
/**
* 日志操作
* 新增、修改、删除
* */
public
static
final
String
LOG_OPERATION_TYPE_ADD
=
"新增"
;
public
static
final
String
LOG_OPERATION_TYPE_BATCH_ADD
=
"批量新增"
;
public
static
final
String
LOG_OPERATION_TYPE_EDIT
=
"修改,id:"
;
public
static
final
String
LOG_OPERATION_TYPE_DELETE
=
"删除,id:"
;
public
static
final
String
LOG_OPERATION_TYPE_IMPORT
=
"导入"
;
/**
* 数据数量单位
* 条
* */
public
static
final
String
LOG_DATA_UNIT
=
"条"
;
/**
* 模块中文名称
* 模块对应的标识
* */
public
static
final
String
LOG_MODULE_NAME_USER
=
"用户"
;
public
static
final
String
LOG_INTERFACE_NAME_USER
=
"user"
;
public
static
final
String
LOG_MODULE_NAME_ROLE
=
"角色"
;
public
static
final
String
LOG_INTERFACE_NAME_ROLE
=
"role"
;
public
static
final
String
LOG_MODULE_NAME_APP
=
"应用"
;
public
static
final
String
LOG_INTERFACE_NAME_APP
=
"app"
;
public
static
final
String
LOG_MODULE_NAME_DEPOT
=
"仓库"
;
public
static
final
String
LOG_INTERFACE_NAME_DEPOT
=
"depot"
;
public
static
final
String
LOG_MODULE_NAME_FUNCTIONS
=
"功能"
;
public
static
final
String
LOG_INTERFACE_NAME_FUNCTIONS
=
"functions"
;
public
static
final
String
LOG_MODULE_NAME_IN_OUT_ITEM
=
"收支项目"
;
public
static
final
String
LOG_INTERFACE_NAME_IN_OUT_ITEM
=
"inOutItem"
;
public
static
final
String
LOG_MODULE_NAME_UNIT
=
"计量单位"
;
public
static
final
String
LOG_INTERFACE_NAME_UNIT
=
"unit"
;
public
static
final
String
LOG_MODULE_NAME_PERSON
=
"经手人"
;
public
static
final
String
LOG_INTERFACE_NAME_PERSON
=
"person"
;
public
static
final
String
LOG_MODULE_NAME_USER_BUSINESS
=
"关联关系"
;
public
static
final
String
LOG_INTERFACE_NAME_USER_BUSINESS
=
"userBusiness"
;
public
static
final
String
LOG_MODULE_NAME_SYSTEM_CONFIG
=
"系统配置"
;
public
static
final
String
LOG_INTERFACE_NAME_SYSTEM_CONFIG
=
"systemConfig"
;
public
static
final
String
LOG_MODULE_NAME_MATERIAL_PROPERTY
=
"商品属性"
;
public
static
final
String
LOG_INTERFACE_NAME_MATERIAL_PROPERTY
=
"materialProperty"
;
public
static
final
String
LOG_MODULE_NAME_ACCOUNT
=
"账户"
;
public
static
final
String
LOG_INTERFACE_NAME_ACCOUNT
=
"account"
;
public
static
final
String
LOG_MODULE_NAME_SUPPLIER
=
"商家"
;
public
static
final
String
LOG_INTERFACE_NAME_SUPPLIER
=
"supplier"
;
public
static
final
String
LOG_MODULE_NAME_MATERIAL_CATEGORY
=
"商品类型"
;
public
static
final
String
LOG_INTERFACE_NAME_MATERIAL_CATEGORY
=
"materialCategory"
;
public
static
final
String
LOG_MODULE_NAME_MATERIAL
=
"商品"
;
public
static
final
String
LOG_INTERFACE_NAME_MATERIAL
=
"material"
;
public
static
final
String
LOG_MODULE_NAME_DEPOT_HEAD
=
"单据"
;
public
static
final
String
LOG_INTERFACE_NAME_DEPOT_HEAD
=
"depotHead"
;
public
static
final
String
LOG_MODULE_NAME_DEPOT_ITEM
=
"单据明细"
;
public
static
final
String
LOG_INTERFACE_NAME_DEPOT_ITEM
=
"depotItem"
;
public
static
final
String
LOG_MODULE_NAME_ACCOUNT_HEAD
=
"财务"
;
public
static
final
String
LOG_INTERFACE_NAME_ACCOUNT_HEAD
=
"accountHead"
;
public
static
final
String
LOG_MODULE_NAME_ACCOUNT_ITEM
=
"财务明细"
;
public
static
final
String
LOG_INTERFACE_NAME_ACCOUNT_ITEM
=
"accountItem"
;
public
static
final
String
LOG_MODULE_NAME_SERIAL_NUMBER
=
"序列号"
;
public
static
final
String
LOG_INTERFACE_NAME_SERIAL_NUMBER
=
"serialNumber"
;
public
static
final
String
LOG_MODULE_NAME_ORGANIZATION
=
"机构"
;
public
static
final
String
LOG_INTERFACE_NAME_ORGANIZATION
=
"organization"
;
...
...
src/main/java/com/jsh/erp/controller/AccountItemController.java
View file @
aa7dca67
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.jsh.erp.datasource.entities.AccountItem
;
import
com.jsh.erp.datasource.entities.AccountItem
;
import
com.jsh.erp.datasource.vo.AccountItemVo4List
;
import
com.jsh.erp.datasource.vo.AccountItemVo4List
;
import
com.jsh.erp.service.accountItem.AccountItemService
;
import
com.jsh.erp.service.accountItem.AccountItemService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.*
;
import
com.jsh.erp.utils.*
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
...
src/main/java/com/jsh/erp/controller/DepotHeadController.java
View file @
aa7dca67
...
@@ -40,8 +40,6 @@ public class DepotHeadController {
...
@@ -40,8 +40,6 @@ public class DepotHeadController {
@Resource
@Resource
private
DepotHeadService
depotHeadService
;
private
DepotHeadService
depotHeadService
;
@Resource
private
LogService
logService
;
/**
/**
* 批量设置状态-审核或者反审核
* 批量设置状态-审核或者反审核
...
@@ -435,7 +433,7 @@ public class DepotHeadController {
...
@@ -435,7 +433,7 @@ public class DepotHeadController {
@RequestParam
(
"updated"
)
String
updated
,
HttpServletRequest
request
)
throws
Exception
{
@RequestParam
(
"updated"
)
String
updated
,
HttpServletRequest
request
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
depotHeadService
.
addDepotHeadAndDetail
(
beanJson
,
inserted
,
deleted
,
updated
);
depotHeadService
.
addDepotHeadAndDetail
(
beanJson
,
inserted
,
deleted
,
updated
);
logService
.
insertLog
(
"depotHead"
,
"新增"
,
request
);
return
result
;
return
result
;
}
}
/**
/**
...
...
src/main/java/com/jsh/erp/controller/SupplierController.java
View file @
aa7dca67
...
@@ -11,6 +11,7 @@ import jxl.Workbook;
...
@@ -11,6 +11,7 @@ import jxl.Workbook;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -375,8 +376,8 @@ public class SupplierController {
...
@@ -375,8 +376,8 @@ public class SupplierController {
importFun
(
supplierFile
);
importFun
(
supplierFile
);
response
.
sendRedirect
(
"../pages/manage/member.html"
);
response
.
sendRedirect
(
"../pages/manage/member.html"
);
}
}
public
String
importFun
(
MultipartFile
supplierFile
){
public
String
importFun
(
MultipartFile
supplierFile
){
BaseResponseInfo
info
=
new
BaseResponseInfo
();
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
String
message
=
"成功"
;
...
...
src/main/java/com/jsh/erp/service/CommonQueryManager.java
View file @
aa7dca67
...
@@ -78,7 +78,7 @@ public class CommonQueryManager {
...
@@ -78,7 +78,7 @@ public class CommonQueryManager {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insert
(
String
apiName
,
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insert
(
String
apiName
,
String
beanJson
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
"新增"
,
request
);
logService
.
insertLog
(
apiName
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
request
);
return
container
.
getCommonQuery
(
apiName
).
insert
(
beanJson
,
request
);
return
container
.
getCommonQuery
(
apiName
).
insert
(
beanJson
,
request
);
}
}
return
0
;
return
0
;
...
@@ -94,7 +94,8 @@ public class CommonQueryManager {
...
@@ -94,7 +94,8 @@ public class CommonQueryManager {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
update
(
String
apiName
,
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
{
public
int
update
(
String
apiName
,
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
"更新,id:"
+
id
,
request
);
logService
.
insertLog
(
apiName
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
id
).
toString
(),
request
);
return
container
.
getCommonQuery
(
apiName
).
update
(
beanJson
,
id
);
return
container
.
getCommonQuery
(
apiName
).
update
(
beanJson
,
id
);
}
}
return
0
;
return
0
;
...
@@ -109,7 +110,8 @@ public class CommonQueryManager {
...
@@ -109,7 +110,8 @@ public class CommonQueryManager {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
delete
(
String
apiName
,
Long
id
,
HttpServletRequest
request
)
{
public
int
delete
(
String
apiName
,
Long
id
,
HttpServletRequest
request
)
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
"删除,id:"
+
id
,
request
);
logService
.
insertLog
(
apiName
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
id
).
toString
(),
request
);
return
container
.
getCommonQuery
(
apiName
).
delete
(
id
);
return
container
.
getCommonQuery
(
apiName
).
delete
(
id
);
}
}
return
0
;
return
0
;
...
...
src/main/java/com/jsh/erp/service/account/AccountService.java
View file @
aa7dca67
package
com.jsh.erp.service.account
;
package
com.jsh.erp.service.account
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.mappers.*
;
import
com.jsh.erp.datasource.mappers.*
;
import
com.jsh.erp.datasource.vo.AccountVo4InOutList
;
import
com.jsh.erp.datasource.vo.AccountVo4InOutList
;
import
com.jsh.erp.datasource.vo.AccountVo4List
;
import
com.jsh.erp.datasource.vo.AccountVo4List
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.Tools
;
import
com.jsh.erp.utils.Tools
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -12,6 +14,8 @@ import org.slf4j.LoggerFactory;
...
@@ -12,6 +14,8 @@ import org.slf4j.LoggerFactory;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -39,6 +43,8 @@ public class AccountService {
...
@@ -39,6 +43,8 @@ public class AccountService {
@Resource
@Resource
private
AccountItemMapper
accountItemMapper
;
private
AccountItemMapper
accountItemMapper
;
@Resource
private
LogService
logService
;
public
Account
getAccount
(
long
id
)
{
public
Account
getAccount
(
long
id
)
{
return
accountMapper
.
selectByPrimaryKey
(
id
);
return
accountMapper
.
selectByPrimaryKey
(
id
);
...
@@ -303,6 +309,8 @@ public class AccountService {
...
@@ -303,6 +309,8 @@ public class AccountService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateAmountIsDefault
(
Boolean
isDefault
,
Long
accountId
)
{
public
int
updateAmountIsDefault
(
Boolean
isDefault
,
Long
accountId
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_ACCOUNT
,
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
+
accountId
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
Account
account
=
new
Account
();
Account
account
=
new
Account
();
account
.
setIsdefault
(
isDefault
);
account
.
setIsdefault
(
isDefault
);
AccountExample
example
=
new
AccountExample
();
AccountExample
example
=
new
AccountExample
();
...
...
src/main/java/com/jsh/erp/service/accountItem/AccountItemService.java
View file @
aa7dca67
...
@@ -2,11 +2,13 @@ package com.jsh.erp.service.accountItem;
...
@@ -2,11 +2,13 @@ package com.jsh.erp.service.accountItem;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.AccountItem
;
import
com.jsh.erp.datasource.entities.AccountItem
;
import
com.jsh.erp.datasource.entities.AccountItemExample
;
import
com.jsh.erp.datasource.entities.AccountItemExample
;
import
com.jsh.erp.datasource.mappers.AccountItemMapper
;
import
com.jsh.erp.datasource.mappers.AccountItemMapper
;
import
com.jsh.erp.datasource.mappers.AccountItemMapperEx
;
import
com.jsh.erp.datasource.mappers.AccountItemMapperEx
;
import
com.jsh.erp.datasource.vo.AccountItemVo4List
;
import
com.jsh.erp.datasource.vo.AccountItemVo4List
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.ErpInfo
;
import
com.jsh.erp.utils.ErpInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -14,6 +16,8 @@ import org.slf4j.LoggerFactory;
...
@@ -14,6 +16,8 @@ import org.slf4j.LoggerFactory;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -31,6 +35,8 @@ public class AccountItemService {
...
@@ -31,6 +35,8 @@ public class AccountItemService {
@Resource
@Resource
private
AccountItemMapperEx
accountItemMapperEx
;
private
AccountItemMapperEx
accountItemMapperEx
;
@Resource
private
LogService
logService
;
public
AccountItem
getAccountItem
(
long
id
)
{
public
AccountItem
getAccountItem
(
long
id
)
{
return
accountItemMapper
.
selectByPrimaryKey
(
id
);
return
accountItemMapper
.
selectByPrimaryKey
(
id
);
...
@@ -97,6 +103,9 @@ public class AccountItemService {
...
@@ -97,6 +103,9 @@ public class AccountItemService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
,
String
listType
)
throws
DataAccessException
{
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
,
String
listType
)
throws
DataAccessException
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_ACCOUNT_ITEM
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
",headerId:"
).
append
(
headerId
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//转为json
//转为json
JSONArray
insertedJson
=
JSONArray
.
parseArray
(
inserted
);
JSONArray
insertedJson
=
JSONArray
.
parseArray
(
inserted
);
JSONArray
deletedJson
=
JSONArray
.
parseArray
(
deleted
);
JSONArray
deletedJson
=
JSONArray
.
parseArray
(
deleted
);
...
...
src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
aa7dca67
...
@@ -14,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
...
@@ -14,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
import
com.jsh.erp.datasource.vo.DepotHeadVo4List
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4List
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount
;
import
com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.serialNumber.SerialNumberService
;
import
com.jsh.erp.service.serialNumber.SerialNumberService
;
import
com.jsh.erp.service.supplier.SupplierService
;
import
com.jsh.erp.service.supplier.SupplierService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
...
@@ -22,6 +23,8 @@ import org.slf4j.Logger;
...
@@ -22,6 +23,8 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -51,6 +54,8 @@ public class DepotHeadService {
...
@@ -51,6 +54,8 @@ public class DepotHeadService {
private
SerialNumberService
serialNumberService
;
private
SerialNumberService
serialNumberService
;
@Resource
@Resource
DepotItemMapperEx
depotItemMapperEx
;
DepotItemMapperEx
depotItemMapperEx
;
@Resource
private
LogService
logService
;
public
DepotHead
getDepotHead
(
long
id
)
{
public
DepotHead
getDepotHead
(
long
id
)
{
...
@@ -143,6 +148,9 @@ public class DepotHeadService {
...
@@ -143,6 +148,9 @@ public class DepotHeadService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchSetStatus
(
String
status
,
String
depotHeadIDs
)
{
public
int
batchSetStatus
(
String
status
,
String
depotHeadIDs
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
depotHeadIDs
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
depotHeadIDs
);
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
depotHeadIDs
);
DepotHead
depotHead
=
new
DepotHead
();
DepotHead
depotHead
=
new
DepotHead
();
depotHead
.
setStatus
(
status
);
depotHead
.
setStatus
(
status
);
...
@@ -269,6 +277,9 @@ public class DepotHeadService {
...
@@ -269,6 +277,9 @@ public class DepotHeadService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
addDepotHeadAndDetail
(
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
)
throws
Exception
{
public
void
addDepotHeadAndDetail
(
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
/**处理单据主表数据*/
/**处理单据主表数据*/
DepotHead
depotHead
=
JSONObject
.
parseObject
(
beanJson
,
DepotHead
.
class
);
DepotHead
depotHead
=
JSONObject
.
parseObject
(
beanJson
,
DepotHead
.
class
);
//判断用户是否已经登录过,登录过不再处理
//判断用户是否已经登录过,登录过不再处理
...
@@ -309,6 +320,9 @@ public class DepotHeadService {
...
@@ -309,6 +320,9 @@ public class DepotHeadService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
updateDepotHeadAndDetail
(
Long
id
,
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
,
BigDecimal
preTotalPrice
)
throws
Exception
{
public
void
updateDepotHeadAndDetail
(
Long
id
,
String
beanJson
,
String
inserted
,
String
deleted
,
String
updated
,
BigDecimal
preTotalPrice
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
id
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
/**更新单据主表信息*/
/**更新单据主表信息*/
DepotHead
depotHead
=
JSONObject
.
parseObject
(
beanJson
,
DepotHead
.
class
);
DepotHead
depotHead
=
JSONObject
.
parseObject
(
beanJson
,
DepotHead
.
class
);
//判断用户是否已经登录过,登录过不再处理
//判断用户是否已经登录过,登录过不再处理
...
@@ -337,6 +351,9 @@ public class DepotHeadService {
...
@@ -337,6 +351,9 @@ public class DepotHeadService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
deleteDepotHeadAndDetail
(
Long
id
)
throws
Exception
{
public
void
deleteDepotHeadAndDetail
(
Long
id
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
id
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//查询单据主表信息
//查询单据主表信息
DepotHead
depotHead
=
getDepotHead
(
id
);
DepotHead
depotHead
=
getDepotHead
(
id
);
User
userInfo
=
userService
.
getCurrentUser
();
User
userInfo
=
userService
.
getCurrentUser
();
...
@@ -368,6 +385,9 @@ public class DepotHeadService {
...
@@ -368,6 +385,9 @@ public class DepotHeadService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
batchDeleteDepotHeadAndDetail
(
String
ids
)
throws
Exception
{
public
void
batchDeleteDepotHeadAndDetail
(
String
ids
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
StringUtil
.
isNotEmpty
(
ids
)){
if
(
StringUtil
.
isNotEmpty
(
ids
)){
String
[]
headIds
=
ids
.
split
(
","
);
String
[]
headIds
=
ids
.
split
(
","
);
for
(
int
i
=
0
;
i
<
headIds
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
headIds
.
length
;
i
++){
...
...
src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
aa7dca67
...
@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapper;
...
@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapper;
import
com.jsh.erp.datasource.mappers.DepotItemMapperEx
;
import
com.jsh.erp.datasource.mappers.DepotItemMapperEx
;
import
com.jsh.erp.datasource.mappers.SerialNumberMapperEx
;
import
com.jsh.erp.datasource.mappers.SerialNumberMapperEx
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.service.serialNumber.SerialNumberService
;
import
com.jsh.erp.service.serialNumber.SerialNumberService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
...
@@ -21,6 +22,8 @@ import org.slf4j.LoggerFactory;
...
@@ -21,6 +22,8 @@ import org.slf4j.LoggerFactory;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -54,6 +57,8 @@ public class DepotItemService {
...
@@ -54,6 +57,8 @@ public class DepotItemService {
SerialNumberService
serialNumberService
;
SerialNumberService
serialNumberService
;
@Resource
@Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
private
LogService
logService
;
public
DepotItem
getDepotItem
(
long
id
)
{
public
DepotItem
getDepotItem
(
long
id
)
{
return
depotItemMapper
.
selectByPrimaryKey
(
id
);
return
depotItemMapper
.
selectByPrimaryKey
(
id
);
...
@@ -224,6 +229,10 @@ public class DepotItemService {
...
@@ -224,6 +229,10 @@ public class DepotItemService {
* */
* */
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
)
throws
Exception
{
public
String
saveDetials
(
String
inserted
,
String
deleted
,
String
updated
,
Long
headerId
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_ITEM
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//查询单据主表信息
//查询单据主表信息
DepotHead
depotHead
=
depotHeadMapper
.
selectByPrimaryKey
(
headerId
);
DepotHead
depotHead
=
depotHeadMapper
.
selectByPrimaryKey
(
headerId
);
//获得当前操作人
//获得当前操作人
...
@@ -461,6 +470,20 @@ public class DepotItemService {
...
@@ -461,6 +470,20 @@ public class DepotItemService {
depotItem
.
setOtherfield4
(
tempUpdatedJson
.
getString
(
"OtherField4"
));
depotItem
.
setOtherfield4
(
tempUpdatedJson
.
getString
(
"OtherField4"
));
depotItem
.
setOtherfield5
(
tempUpdatedJson
.
getString
(
"OtherField5"
));
depotItem
.
setOtherfield5
(
tempUpdatedJson
.
getString
(
"OtherField5"
));
depotItem
.
setMtype
(
tempUpdatedJson
.
getString
(
"MType"
));
depotItem
.
setMtype
(
tempUpdatedJson
.
getString
(
"MType"
));
/**
* create by: qiankunpingtai
* create time: 2019/3/25 15:18
* website:http://39.105.146.63/symphony/
* description:
* 修改了商品类型时,库中的商品和页面传递的不同
* 这里需要重新获取页面传递的商品信息
*/
if
(!
material
.
getId
().
equals
(
depotItem
.
getMaterialid
())){
material
=
materialService
.
getMaterial
(
depotItem
.
getMaterialid
());
if
(
material
==
null
){
continue
;
}
}
/**出库时处理序列号*/
/**出库时处理序列号*/
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())){
if
(
BusinessConstants
.
DEPOTHEAD_TYPE_OUT
.
equals
(
depotHead
.
getType
())){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<
depotItem
.
getBasicnumber
().
intValue
()){
if
(
getCurrentInStock
(
depotItem
.
getMaterialid
())<
depotItem
.
getBasicnumber
().
intValue
()){
...
...
src/main/java/com/jsh/erp/service/log/LogService.java
View file @
aa7dca67
package
com.jsh.erp.service.log
;
package
com.jsh.erp.service.log
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.Log
;
import
com.jsh.erp.datasource.entities.Log
;
import
com.jsh.erp.datasource.entities.LogExample
;
import
com.jsh.erp.datasource.entities.LogExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
...
@@ -97,44 +98,48 @@ public class LogService {
...
@@ -97,44 +98,48 @@ public class LogService {
public
String
getModule
(
String
apiName
){
public
String
getModule
(
String
apiName
){
String
moduleName
=
null
;
String
moduleName
=
null
;
switch
(
apiName
)
{
switch
(
apiName
)
{
case
"user"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_USER
:
moduleName
=
"用户"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_USER
;
break
;
case
"role"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_ROLE
:
moduleName
=
"角色"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_ROLE
;
break
;
case
"app"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_APP
:
moduleName
=
"应用"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_APP
;
break
;
case
"depot"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT
:
moduleName
=
"仓库"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_DEPOT
;
break
;
case
"functions"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_FUNCTIONS
:
moduleName
=
"功能"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_FUNCTIONS
;
break
;
case
"inOutItem"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_IN_OUT_ITEM
:
moduleName
=
"收支项目"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_IN_OUT_ITEM
;
break
;
case
"unit"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_UNIT
:
moduleName
=
"计量单位"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_UNIT
;
break
;
case
"person"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_PERSON
:
moduleName
=
"经手人"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_PERSON
;
break
;
case
"userBusiness"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_USER_BUSINESS
:
moduleName
=
"关联关系"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_USER_BUSINESS
;
break
;
case
"systemConfig"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_SYSTEM_CONFIG
:
moduleName
=
"系统配置"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_SYSTEM_CONFIG
;
break
;
case
"materialProperty"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL_PROPERTY
:
moduleName
=
"商品属性"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_MATERIAL_PROPERTY
;
break
;
case
"account"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_ACCOUNT
:
moduleName
=
"账户"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_ACCOUNT
;
break
;
case
"supplier"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_SUPPLIER
:
moduleName
=
"商家"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_SUPPLIER
;
break
;
case
"materialCategory"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL_CATEGORY
:
moduleName
=
"商品类型"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_MATERIAL_CATEGORY
;
break
;
case
"material"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL
:
moduleName
=
"商品"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_MATERIAL
;
break
;
case
"depotHead"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_HEAD
:
moduleName
=
"单据"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_DEPOT_HEAD
;
break
;
case
"depotItem"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_DEPOT_ITEM
:
moduleName
=
"单据明细"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_DEPOT_ITEM
;
break
;
case
"accountHead"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_ACCOUNT_HEAD
:
moduleName
=
"财务"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_ACCOUNT_HEAD
;
break
;
case
"accountItem"
:
case
BusinessConstants
.
LOG_INTERFACE_NAME_ACCOUNT_ITEM
:
moduleName
=
"财务明细"
;
break
;
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_ACCOUNT_ITEM
;
break
;
case
BusinessConstants
.
LOG_INTERFACE_NAME_SERIAL_NUMBER
:
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_SERIAL_NUMBER
;
break
;
case
BusinessConstants
.
LOG_INTERFACE_NAME_ORGANIZATION
:
moduleName
=
BusinessConstants
.
LOG_MODULE_NAME_ORGANIZATION
;
break
;
}
}
return
moduleName
;
return
moduleName
;
}
}
...
...
src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
aa7dca67
package
com.jsh.erp.service.material
;
package
com.jsh.erp.service.material
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.DepotEx
;
import
com.jsh.erp.datasource.entities.DepotEx
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.Material
;
import
com.jsh.erp.datasource.entities.MaterialExample
;
import
com.jsh.erp.datasource.entities.MaterialExample
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.entities.MaterialVo4Unit
;
import
com.jsh.erp.datasource.mappers.MaterialMapper
;
import
com.jsh.erp.datasource.mappers.MaterialMapper
;
import
com.jsh.erp.datasource.mappers.MaterialMapperEx
;
import
com.jsh.erp.datasource.mappers.MaterialMapperEx
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -29,6 +33,8 @@ public class MaterialService {
...
@@ -29,6 +33,8 @@ public class MaterialService {
private
MaterialMapper
materialMapper
;
private
MaterialMapper
materialMapper
;
@Resource
@Resource
private
MaterialMapperEx
materialMapperEx
;
private
MaterialMapperEx
materialMapperEx
;
@Resource
private
LogService
logService
;
public
Material
getMaterial
(
long
id
)
{
public
Material
getMaterial
(
long
id
)
{
return
materialMapper
.
selectByPrimaryKey
(
id
);
return
materialMapper
.
selectByPrimaryKey
(
id
);
...
@@ -141,6 +147,9 @@ public class MaterialService {
...
@@ -141,6 +147,9 @@ public class MaterialService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchSetEnable
(
Boolean
enabled
,
String
materialIDs
)
{
public
int
batchSetEnable
(
Boolean
enabled
,
String
materialIDs
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
materialIDs
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
materialIDs
);
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
materialIDs
);
Material
material
=
new
Material
();
Material
material
=
new
Material
();
material
.
setEnabled
(
enabled
);
material
.
setEnabled
(
enabled
);
...
@@ -177,8 +186,11 @@ public class MaterialService {
...
@@ -177,8 +186,11 @@ public class MaterialService {
}
}
return
resList
;
return
resList
;
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
BaseResponseInfo
importExcel
(
List
<
Material
>
mList
)
throws
Exception
{
public
BaseResponseInfo
importExcel
(
List
<
Material
>
mList
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
BaseResponseInfo
info
=
new
BaseResponseInfo
();
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
try
{
try
{
...
...
src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java
View file @
aa7dca67
...
@@ -10,12 +10,15 @@ import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
...
@@ -10,12 +10,15 @@ import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
import
com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx
;
import
com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -32,6 +35,8 @@ public class MaterialCategoryService {
...
@@ -32,6 +35,8 @@ public class MaterialCategoryService {
private
MaterialCategoryMapperEx
materialCategoryMapperEx
;
private
MaterialCategoryMapperEx
materialCategoryMapperEx
;
@Resource
@Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
private
LogService
logService
;
public
MaterialCategory
getMaterialCategory
(
long
id
)
{
public
MaterialCategory
getMaterialCategory
(
long
id
)
{
return
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
return
materialCategoryMapper
.
selectByPrimaryKey
(
id
);
...
@@ -113,6 +118,9 @@ public class MaterialCategoryService {
...
@@ -113,6 +118,9 @@ public class MaterialCategoryService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
addMaterialCategory
(
MaterialCategory
mc
)
throws
Exception
{
public
int
addMaterialCategory
(
MaterialCategory
mc
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL_CATEGORY
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
mc
==
null
){
if
(
mc
==
null
){
return
0
;
return
0
;
}
}
...
@@ -138,7 +146,9 @@ public class MaterialCategoryService {
...
@@ -138,7 +146,9 @@ public class MaterialCategoryService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteMaterialCategoryByIds
(
String
ids
)
throws
Exception
{
public
int
batchDeleteMaterialCategoryByIds
(
String
ids
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL_CATEGORY
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//更新时间
//更新时间
Date
updateDate
=
new
Date
();
Date
updateDate
=
new
Date
();
//更新人
//更新人
...
@@ -153,6 +163,9 @@ public class MaterialCategoryService {
...
@@ -153,6 +163,9 @@ public class MaterialCategoryService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
editMaterialCategory
(
MaterialCategory
mc
)
{
public
int
editMaterialCategory
(
MaterialCategory
mc
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_MATERIAL_CATEGORY
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
mc
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
mc
.
getParentid
()==
null
){
if
(
mc
.
getParentid
()==
null
){
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
//没有给定父级目录的id,默认设置父级目录为根目录的父目录
mc
.
setParentid
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_PARENT_ID
);
mc
.
setParentid
(
BusinessConstants
.
MATERIAL_CATEGORY_ROOT_PARENT_ID
);
...
...
src/main/java/com/jsh/erp/service/organization/OrganizationService.java
View file @
aa7dca67
...
@@ -10,12 +10,15 @@ import com.jsh.erp.datasource.mappers.OrganizationMapper;
...
@@ -10,12 +10,15 @@ import com.jsh.erp.datasource.mappers.OrganizationMapper;
import
com.jsh.erp.datasource.mappers.OrganizationMapperEx
;
import
com.jsh.erp.datasource.mappers.OrganizationMapperEx
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -38,6 +41,8 @@ public class OrganizationService {
...
@@ -38,6 +41,8 @@ public class OrganizationService {
private
OrganizationMapperEx
organizationMapperEx
;
private
OrganizationMapperEx
organizationMapperEx
;
@Resource
@Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
private
LogService
logService
;
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertOrganization
(
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insertOrganization
(
String
beanJson
,
HttpServletRequest
request
)
{
Organization
organization
=
JSONObject
.
parseObject
(
beanJson
,
Organization
.
class
);
Organization
organization
=
JSONObject
.
parseObject
(
beanJson
,
Organization
.
class
);
...
@@ -62,6 +67,9 @@ public class OrganizationService {
...
@@ -62,6 +67,9 @@ public class OrganizationService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
addOrganization
(
Organization
org
)
throws
Exception
{
public
int
addOrganization
(
Organization
org
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_ORGANIZATION
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//新增时间
//新增时间
Date
date
=
new
Date
();
Date
date
=
new
Date
();
User
userInfo
=
userService
.
getCurrentUser
();
User
userInfo
=
userService
.
getCurrentUser
();
...
@@ -88,6 +96,9 @@ public class OrganizationService {
...
@@ -88,6 +96,9 @@ public class OrganizationService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
editOrganization
(
Organization
org
)
throws
Exception
{
public
int
editOrganization
(
Organization
org
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_ORGANIZATION
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
org
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//修改时间
//修改时间
org
.
setUpdateTime
(
new
Date
());
org
.
setUpdateTime
(
new
Date
());
User
userInfo
=
userService
.
getCurrentUser
();
User
userInfo
=
userService
.
getCurrentUser
();
...
@@ -161,6 +172,9 @@ public class OrganizationService {
...
@@ -161,6 +172,9 @@ public class OrganizationService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteOrganizationByIds
(
String
ids
)
throws
Exception
{
public
int
batchDeleteOrganizationByIds
(
String
ids
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_ORGANIZATION
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
User
userInfo
=
userService
.
getCurrentUser
();
User
userInfo
=
userService
.
getCurrentUser
();
String
[]
idArray
=
ids
.
split
(
","
);
String
[]
idArray
=
ids
.
split
(
","
);
return
organizationMapperEx
.
batchDeleteOrganizationByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
return
organizationMapperEx
.
batchDeleteOrganizationByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
...
...
src/main/java/com/jsh/erp/service/serialNumber/SerialNumberService.java
View file @
aa7dca67
...
@@ -7,6 +7,7 @@ import com.jsh.erp.datasource.entities.*;
...
@@ -7,6 +7,7 @@ import com.jsh.erp.datasource.entities.*;
import
com.jsh.erp.datasource.mappers.*
;
import
com.jsh.erp.datasource.mappers.*
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.depotItem.DepotItemService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.service.material.MaterialService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
...
@@ -14,6 +15,8 @@ import org.slf4j.Logger;
...
@@ -14,6 +15,8 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -40,11 +43,9 @@ public class SerialNumberService {
...
@@ -40,11 +43,9 @@ public class SerialNumberService {
@Resource
@Resource
private
MaterialMapper
materialMapper
;
private
MaterialMapper
materialMapper
;
@Resource
@Resource
private
DepotItemService
depotItemService
;
@Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
@Resource
private
DepotItemMapperEx
depotItemMapperEx
;
private
LogService
logService
;
public
SerialNumber
getSerialNumber
(
long
id
)
{
public
SerialNumber
getSerialNumber
(
long
id
)
{
...
@@ -68,6 +69,7 @@ public class SerialNumberService {
...
@@ -68,6 +69,7 @@ public class SerialNumberService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertSerialNumber
(
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insertSerialNumber
(
String
beanJson
,
HttpServletRequest
request
)
{
SerialNumber
serialNumber
=
JSONObject
.
parseObject
(
beanJson
,
SerialNumber
.
class
);
SerialNumber
serialNumber
=
JSONObject
.
parseObject
(
beanJson
,
SerialNumber
.
class
);
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SERIAL_NUMBER
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
request
);
return
serialNumberMapper
.
insertSelective
(
serialNumber
);
return
serialNumberMapper
.
insertSelective
(
serialNumber
);
}
}
...
@@ -168,6 +170,8 @@ public class SerialNumberService {
...
@@ -168,6 +170,8 @@ public class SerialNumberService {
* */
* */
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
SerialNumberEx
addSerialNumber
(
SerialNumberEx
serialNumberEx
)
{
public
SerialNumberEx
addSerialNumber
(
SerialNumberEx
serialNumberEx
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SERIAL_NUMBER
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
serialNumberEx
==
null
){
if
(
serialNumberEx
==
null
){
return
null
;
return
null
;
}
}
...
@@ -191,6 +195,9 @@ public class SerialNumberService {
...
@@ -191,6 +195,9 @@ public class SerialNumberService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
SerialNumberEx
updateSerialNumber
(
SerialNumberEx
serialNumberEx
)
{
public
SerialNumberEx
updateSerialNumber
(
SerialNumberEx
serialNumberEx
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SERIAL_NUMBER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
serialNumberEx
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
serialNumberEx
==
null
){
if
(
serialNumberEx
==
null
){
return
null
;
return
null
;
}
}
...
@@ -345,6 +352,9 @@ public class SerialNumberService {
...
@@ -345,6 +352,9 @@ public class SerialNumberService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
batAddSerialNumber
(
String
materialName
,
String
serialNumberPrefix
,
Integer
batAddTotal
,
String
remark
)
{
public
void
batAddSerialNumber
(
String
materialName
,
String
serialNumberPrefix
,
Integer
batAddTotal
,
String
remark
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SERIAL_NUMBER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_BATCH_ADD
).
append
(
batAddTotal
).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
StringUtil
.
isNotEmpty
(
materialName
)){
if
(
StringUtil
.
isNotEmpty
(
materialName
)){
//查询商品id
//查询商品id
Long
materialId
=
checkMaterialName
(
materialName
);
Long
materialId
=
checkMaterialName
(
materialName
);
...
...
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
View file @
aa7dca67
package
com.jsh.erp.service.supplier
;
package
com.jsh.erp.service.supplier
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.datasource.mappers.SupplierMapperEx
;
import
com.jsh.erp.datasource.mappers.SupplierMapperEx
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -28,6 +32,8 @@ public class SupplierService {
...
@@ -28,6 +32,8 @@ public class SupplierService {
@Resource
@Resource
private
SupplierMapperEx
supplierMapperEx
;
private
SupplierMapperEx
supplierMapperEx
;
@Resource
private
LogService
logService
;
public
Supplier
getSupplier
(
long
id
)
{
public
Supplier
getSupplier
(
long
id
)
{
return
supplierMapper
.
selectByPrimaryKey
(
id
);
return
supplierMapper
.
selectByPrimaryKey
(
id
);
...
@@ -81,6 +87,9 @@ public class SupplierService {
...
@@ -81,6 +87,9 @@ public class SupplierService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateAdvanceIn
(
Long
supplierId
,
BigDecimal
advanceIn
){
public
int
updateAdvanceIn
(
Long
supplierId
,
BigDecimal
advanceIn
){
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SUPPLIER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
supplierId
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
Supplier
supplier
=
supplierMapper
.
selectByPrimaryKey
(
supplierId
);
Supplier
supplier
=
supplierMapper
.
selectByPrimaryKey
(
supplierId
);
if
(
supplier
!=
null
){
if
(
supplier
!=
null
){
supplier
.
setAdvancein
(
supplier
.
getAdvancein
().
add
(
advanceIn
));
//增加预收款的金额,可能增加的是负值
supplier
.
setAdvancein
(
supplier
.
getAdvancein
().
add
(
advanceIn
));
//增加预收款的金额,可能增加的是负值
...
@@ -121,6 +130,9 @@ public class SupplierService {
...
@@ -121,6 +130,9 @@ public class SupplierService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchSetEnable
(
Boolean
enabled
,
String
supplierIDs
)
{
public
int
batchSetEnable
(
Boolean
enabled
,
String
supplierIDs
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SUPPLIER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
supplierIDs
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
supplierIDs
);
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
supplierIDs
);
Supplier
supplier
=
new
Supplier
();
Supplier
supplier
=
new
Supplier
();
supplier
.
setEnabled
(
enabled
);
supplier
.
setEnabled
(
enabled
);
...
@@ -140,8 +152,11 @@ public class SupplierService {
...
@@ -140,8 +152,11 @@ public class SupplierService {
public
List
<
Supplier
>
findByAll
(
String
supplier
,
String
type
,
String
phonenum
,
String
telephone
,
String
description
)
{
public
List
<
Supplier
>
findByAll
(
String
supplier
,
String
type
,
String
phonenum
,
String
telephone
,
String
description
)
{
return
supplierMapperEx
.
findByAll
(
supplier
,
type
,
phonenum
,
telephone
,
description
);
return
supplierMapperEx
.
findByAll
(
supplier
,
type
,
phonenum
,
telephone
,
description
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
BaseResponseInfo
importExcel
(
List
<
Supplier
>
mList
)
throws
Exception
{
public
BaseResponseInfo
importExcel
(
List
<
Supplier
>
mList
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_SUPPLIER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
BaseResponseInfo
info
=
new
BaseResponseInfo
();
BaseResponseInfo
info
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
try
{
try
{
...
...
src/main/java/com/jsh/erp/service/user/UserService.java
View file @
aa7dca67
...
@@ -13,6 +13,7 @@ import com.jsh.erp.datasource.mappers.UserMapperEx;
...
@@ -13,6 +13,7 @@ import com.jsh.erp.datasource.mappers.UserMapperEx;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.datasource.vo.TreeNode
;
import
com.jsh.erp.datasource.vo.TreeNodeEx
;
import
com.jsh.erp.datasource.vo.TreeNodeEx
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.orgaUserRel.OrgaUserRelService
;
import
com.jsh.erp.service.orgaUserRel.OrgaUserRelService
;
import
com.jsh.erp.utils.ExceptionCodeConstants
;
import
com.jsh.erp.utils.ExceptionCodeConstants
;
import
com.jsh.erp.utils.JshException
;
import
com.jsh.erp.utils.JshException
;
...
@@ -44,6 +45,8 @@ public class UserService {
...
@@ -44,6 +45,8 @@ public class UserService {
private
UserMapperEx
userMapperEx
;
private
UserMapperEx
userMapperEx
;
@Resource
@Resource
private
OrgaUserRelService
orgaUserRelService
;
private
OrgaUserRelService
orgaUserRelService
;
@Resource
private
LogService
logService
;
public
User
getUser
(
long
id
)
{
public
User
getUser
(
long
id
)
{
return
userMapper
.
selectByPrimaryKey
(
id
);
return
userMapper
.
selectByPrimaryKey
(
id
);
...
@@ -109,6 +112,9 @@ public class UserService {
...
@@ -109,6 +112,9 @@ public class UserService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateUserByObj
(
User
user
)
{
public
int
updateUserByObj
(
User
user
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_MODULE_NAME_USER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
user
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
}
}
/**
/**
...
@@ -122,6 +128,9 @@ public class UserService {
...
@@ -122,6 +128,9 @@ public class UserService {
*/
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
resetPwd
(
String
md5Pwd
,
Long
id
)
{
public
int
resetPwd
(
String
md5Pwd
,
Long
id
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_MODULE_NAME_USER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
id
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
User
user
=
new
User
();
User
user
=
new
User
();
user
.
setId
(
id
);
user
.
setId
(
id
);
user
.
setPassword
(
md5Pwd
);
user
.
setPassword
(
md5Pwd
);
...
@@ -208,6 +217,9 @@ public class UserService {
...
@@ -208,6 +217,9 @@ public class UserService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
addUserAndOrgUserRel
(
UserEx
ue
)
throws
Exception
{
public
void
addUserAndOrgUserRel
(
UserEx
ue
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_MODULE_NAME_USER
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//检查用户名和登录名
//检查用户名和登录名
checkUserNameAndLoginName
(
ue
);
checkUserNameAndLoginName
(
ue
);
//新增用户信息
//新增用户信息
...
@@ -262,6 +274,9 @@ public class UserService {
...
@@ -262,6 +274,9 @@ public class UserService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
updateUserAndOrgUserRel
(
UserEx
ue
)
throws
Exception
{
public
void
updateUserAndOrgUserRel
(
UserEx
ue
)
throws
Exception
{
logService
.
insertLog
(
BusinessConstants
.
LOG_MODULE_NAME_USER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
ue
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//检查用户名和登录名
//检查用户名和登录名
checkUserNameAndLoginName
(
ue
);
checkUserNameAndLoginName
(
ue
);
//更新用户信息
//更新用户信息
...
@@ -390,6 +405,9 @@ public class UserService {
...
@@ -390,6 +405,9 @@ public class UserService {
* */
* */
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
batDeleteUser
(
String
ids
)
{
public
void
batDeleteUser
(
String
ids
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_MODULE_NAME_USER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
ids
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
String
idsArray
[]=
ids
.
split
(
","
);
String
idsArray
[]=
ids
.
split
(
","
);
int
i
=
userMapperEx
.
batDeleteOrUpdateUser
(
idsArray
,
BusinessConstants
.
USER_STATUS_DELETE
);
int
i
=
userMapperEx
.
batDeleteOrUpdateUser
(
idsArray
,
BusinessConstants
.
USER_STATUS_DELETE
);
if
(
i
<
1
){
if
(
i
<
1
){
...
...
src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java
View file @
aa7dca67
package
com.jsh.erp.service.userBusiness
;
package
com.jsh.erp.service.userBusiness
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.UserBusinessExample
;
import
com.jsh.erp.datasource.entities.UserBusinessExample
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapper
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapper
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
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.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -20,6 +24,8 @@ public class UserBusinessService {
...
@@ -20,6 +24,8 @@ public class UserBusinessService {
@Resource
@Resource
private
UserBusinessMapper
userBusinessMapper
;
private
UserBusinessMapper
userBusinessMapper
;
@Resource
private
LogService
logService
;
public
UserBusiness
getUserBusiness
(
long
id
)
{
public
UserBusiness
getUserBusiness
(
long
id
)
{
return
userBusinessMapper
.
selectByPrimaryKey
(
id
);
return
userBusinessMapper
.
selectByPrimaryKey
(
id
);
...
@@ -96,6 +102,9 @@ public class UserBusinessService {
...
@@ -96,6 +102,9 @@ public class UserBusinessService {
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateBtnStr
(
Long
userBusinessId
,
String
btnStr
)
{
public
int
updateBtnStr
(
Long
userBusinessId
,
String
btnStr
)
{
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_USER_BUSINESS
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
userBusinessId
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
UserBusiness
userBusiness
=
new
UserBusiness
();
UserBusiness
userBusiness
=
new
UserBusiness
();
userBusiness
.
setBtnstr
(
btnStr
);
userBusiness
.
setBtnstr
(
btnStr
);
UserBusinessExample
example
=
new
UserBusinessExample
();
UserBusinessExample
example
=
new
UserBusinessExample
();
...
...
src/main/java/com/jsh/erp/utils/Tools.java
View file @
aa7dca67
...
@@ -290,7 +290,7 @@ public class Tools {
...
@@ -290,7 +290,7 @@ public class Tools {
* @return ip
* @return ip
*/
*/
public
static
String
getLocalIp
(
HttpServletRequest
request
)
{
public
static
String
getLocalIp
(
HttpServletRequest
request
)
{
String
remoteAddr
=
request
.
getRemoteAddr
(
);
String
remoteAddr
=
getIpAddr
(
request
);
String
forwarded
=
request
.
getHeader
(
"X-Forwarded-For"
);
String
forwarded
=
request
.
getHeader
(
"X-Forwarded-For"
);
String
realIp
=
request
.
getHeader
(
"X-Real-IP"
);
String
realIp
=
request
.
getHeader
(
"X-Real-IP"
);
...
@@ -313,6 +313,35 @@ public class Tools {
...
@@ -313,6 +313,35 @@ public class Tools {
}
}
return
ip
;
return
ip
;
}
}
/**
* 获取访问者IP
*
* 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。
*
* 本方法先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割),
* 如果还不存在则调用Request .getRemoteAddr()。
*
* @param request
* @return
*/
public
static
String
getIpAddr
(
HttpServletRequest
request
)
{
String
ip
=
request
.
getHeader
(
"X-Real-IP"
);
if
(!
StringUtils
.
isEmpty
(
ip
)
&&
!
"unknown"
.
equalsIgnoreCase
(
ip
))
{
return
ip
;
}
ip
=
request
.
getHeader
(
"X-Forwarded-For"
);
if
(!
StringUtils
.
isEmpty
(
ip
)
&&
!
"unknown"
.
equalsIgnoreCase
(
ip
))
{
// 多次反向代理后会有多个IP值,第一个为真实IP。
int
index
=
ip
.
indexOf
(
','
);
if
(
index
!=
-
1
)
{
return
ip
.
substring
(
0
,
index
);
}
else
{
return
ip
;
}
}
else
{
return
request
.
getRemoteAddr
();
}
}
/**
/**
* 转化前台批量传入的ID值
* 转化前台批量传入的ID值
...
...
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