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
"jetbrains:/idea/checkout/git" did not exist on "0d017bde7748568c68449794d9beed7db1bbd1aa"
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/datasource/vo/DepotItemStockWarningCount.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
import
java.math.BigDecimal
;
public
class
DepotItemStockWarningCount
{
private
Long
MId
;
private
String
MName
;
private
String
MModel
;
private
String
MaterialUnit
;
private
String
MColor
;
private
String
MStandard
;
private
String
MMfrs
;
private
String
unitName
;
private
String
MaterialOther
;
private
String
MOtherField1
;
private
String
MOtherField2
;
private
String
MOtherField3
;
private
BigDecimal
safetystock
;
//安全库存量
private
BigDecimal
currentNumber
;
//库存
private
BigDecimal
linjieNumber
;
//临界库存
public
Long
getMId
()
{
return
MId
;
}
public
void
setMId
(
Long
MId
)
{
this
.
MId
=
MId
;
}
public
String
getMName
()
{
return
MName
;
}
public
void
setMName
(
String
MName
)
{
this
.
MName
=
MName
;
}
public
String
getMModel
()
{
return
MModel
;
}
public
void
setMModel
(
String
MModel
)
{
this
.
MModel
=
MModel
;
}
public
String
getMaterialUnit
()
{
return
MaterialUnit
;
}
public
void
setMaterialUnit
(
String
materialUnit
)
{
MaterialUnit
=
materialUnit
;
}
public
String
getMColor
()
{
return
MColor
;
}
public
void
setMColor
(
String
MColor
)
{
this
.
MColor
=
MColor
;
}
public
String
getMStandard
()
{
return
MStandard
;
}
public
void
setMStandard
(
String
MStandard
)
{
this
.
MStandard
=
MStandard
;
}
public
String
getMMfrs
()
{
return
MMfrs
;
}
public
void
setMMfrs
(
String
MMfrs
)
{
this
.
MMfrs
=
MMfrs
;
}
public
String
getUnitName
()
{
return
unitName
;
}
public
void
setUnitName
(
String
unitName
)
{
this
.
unitName
=
unitName
;
}
public
String
getMaterialOther
()
{
return
MaterialOther
;
}
public
void
setMaterialOther
(
String
materialOther
)
{
MaterialOther
=
materialOther
;
}
public
String
getMOtherField1
()
{
return
MOtherField1
;
}
public
void
setMOtherField1
(
String
MOtherField1
)
{
this
.
MOtherField1
=
MOtherField1
;
}
public
String
getMOtherField2
()
{
return
MOtherField2
;
}
public
void
setMOtherField2
(
String
MOtherField2
)
{
this
.
MOtherField2
=
MOtherField2
;
}
public
String
getMOtherField3
()
{
return
MOtherField3
;
}
public
void
setMOtherField3
(
String
MOtherField3
)
{
this
.
MOtherField3
=
MOtherField3
;
}
public
BigDecimal
getSafetystock
()
{
return
safetystock
;
}
public
void
setSafetystock
(
BigDecimal
safetystock
)
{
this
.
safetystock
=
safetystock
;
}
public
BigDecimal
getCurrentNumber
()
{
return
currentNumber
;
}
public
void
setCurrentNumber
(
BigDecimal
currentNumber
)
{
this
.
currentNumber
=
currentNumber
;
}
public
BigDecimal
getLinjieNumber
()
{
return
linjieNumber
;
}
public
void
setLinjieNumber
(
BigDecimal
linjieNumber
)
{
this
.
linjieNumber
=
linjieNumber
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/DepotItemVo4Stock.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
import
java.math.BigDecimal
;
public
class
DepotItemVo4Stock
{
private
BigDecimal
inNum
;
private
BigDecimal
outNum
;
public
BigDecimal
getInNum
()
{
return
inNum
;
}
public
void
setInNum
(
BigDecimal
inNum
)
{
this
.
inNum
=
inNum
;
}
public
BigDecimal
getOutNum
()
{
return
outNum
;
}
public
void
setOutNum
(
BigDecimal
outNum
)
{
this
.
outNum
=
outNum
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/LogVo4List.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
import
com.jsh.erp.datasource.entities.Log
;
public
class
LogVo4List
extends
Log
{
private
String
userName
;
private
String
createTimeStr
;
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getCreateTimeStr
()
{
return
createTimeStr
;
}
public
void
setCreateTimeStr
(
String
createTimeStr
)
{
this
.
createTimeStr
=
createTimeStr
;
}
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/MaterialExtendVo4List.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
import
com.jsh.erp.datasource.entities.MaterialExtend
;
import
java.math.BigDecimal
;
public
class
MaterialExtendVo4List
extends
MaterialExtend
{
private
String
supplier
;
private
String
originPlace
;
private
String
unit
;
private
String
brandName
;
private
BigDecimal
guaranteePeriod
;
private
BigDecimal
memberDecimal
;
public
String
getSupplier
()
{
return
supplier
;
}
public
void
setSupplier
(
String
supplier
)
{
this
.
supplier
=
supplier
;
}
public
String
getOriginPlace
()
{
return
originPlace
;
}
public
void
setOriginPlace
(
String
originPlace
)
{
this
.
originPlace
=
originPlace
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
String
getBrandName
()
{
return
brandName
;
}
public
void
setBrandName
(
String
brandName
)
{
this
.
brandName
=
brandName
;
}
public
BigDecimal
getGuaranteePeriod
()
{
return
guaranteePeriod
;
}
public
void
setGuaranteePeriod
(
BigDecimal
guaranteePeriod
)
{
this
.
guaranteePeriod
=
guaranteePeriod
;
}
public
BigDecimal
getMemberDecimal
()
{
return
memberDecimal
;
}
public
void
setMemberDecimal
(
BigDecimal
memberDecimal
)
{
this
.
memberDecimal
=
memberDecimal
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/NodeAttributes.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
/**
* Description
*
* @Author: qiankunpingtai
* @Date: 2019/3/13 18:11
*/
public
class
NodeAttributes
{
//编号
private
String
no
;
//类型
private
Integer
type
;
public
String
getNo
()
{
return
no
;
}
public
void
setNo
(
String
no
)
{
this
.
no
=
no
;
}
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/TreeNode.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
import
java.util.List
;
/**
* Description
* 树形结构基本元素
* @Author: cjl
* @Date: 2019/2/19 11:27
*/
public
class
TreeNode
{
/**
* id主键
* */
private
Long
id
;
private
Long
key
;
private
Long
value
;
/**
* title显示的文本
* */
private
String
title
;
/**
*state节点状态,'open' 或 'closed',默认:'open'。如果为'closed'的时候,将不自动展开该节点。
* */
private
String
state
=
"open"
;
/**
*iconCls 节点图标id
* */
private
String
iconCls
;
/**
* checked 是否被选中
* */
private
boolean
checked
;
/**
*attributes 自定义属性
* */
private
String
attributes
;
/**
* children 子节点
* */
private
List
<
TreeNode
>
children
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getKey
()
{
return
key
;
}
public
void
setKey
(
Long
key
)
{
this
.
key
=
key
;
}
public
Long
getValue
()
{
return
value
;
}
public
void
setValue
(
Long
value
)
{
this
.
value
=
value
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getState
()
{
return
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
String
getIconCls
()
{
return
iconCls
;
}
public
void
setIconCls
(
String
iconCls
)
{
this
.
iconCls
=
iconCls
;
}
public
boolean
isChecked
()
{
return
checked
;
}
public
void
setChecked
(
boolean
checked
)
{
this
.
checked
=
checked
;
}
public
String
getAttributes
()
{
return
attributes
;
}
public
void
setAttributes
(
String
attributes
)
{
this
.
attributes
=
attributes
;
}
public
List
<
TreeNode
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
TreeNode
>
children
)
{
this
.
children
=
children
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/datasource/vo/TreeNodeEx.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.datasource.vo
;
import
java.util.List
;
/**
* Description
*
* @Author: qiankunpingtai
* @Date: 2019/3/13 18:10
*/
public
class
TreeNodeEx
{
/**
* id主键
* */
private
Long
id
;
/**
* text显示的文本
* */
private
String
text
;
/**
*state节点状态,'open' 或 'closed',默认:'open'。如果为'closed'的时候,将不自动展开该节点。
* */
private
String
state
=
"open"
;
/**
*iconCls 节点图标id
* */
private
String
iconCls
;
/**
* checked 是否被选中
* */
private
boolean
checked
;
/**
*attributes 自定义属性
* */
private
NodeAttributes
attributes
;
/**
* children 子节点
* */
private
List
<
TreeNode
>
children
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getText
()
{
return
text
;
}
public
void
setText
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getState
()
{
return
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
String
getIconCls
()
{
return
iconCls
;
}
public
void
setIconCls
(
String
iconCls
)
{
this
.
iconCls
=
iconCls
;
}
public
boolean
isChecked
()
{
return
checked
;
}
public
void
setChecked
(
boolean
checked
)
{
this
.
checked
=
checked
;
}
public
NodeAttributes
getAttributes
()
{
return
attributes
;
}
public
void
setAttributes
(
NodeAttributes
attributes
)
{
this
.
attributes
=
attributes
;
}
public
List
<
TreeNode
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
TreeNode
>
children
)
{
this
.
children
=
children
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/exception/BusinessParamCheckingException.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.exception
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
@Getter
public
class
BusinessParamCheckingException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1L
;
private
int
code
;
private
Map
<
String
,
Object
>
data
;
public
BusinessParamCheckingException
(
int
code
,
String
reason
)
{
super
(
reason
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
objectMap
.
put
(
"message"
,
reason
);
this
.
code
=
code
;
this
.
data
=
objectMap
;
}
public
BusinessParamCheckingException
(
int
code
,
String
reason
,
Throwable
throwable
)
{
super
(
reason
,
throwable
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
objectMap
.
put
(
"message"
,
reason
);
this
.
code
=
code
;
this
.
data
=
objectMap
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/exception/BusinessRunTimeException.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.exception
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
@Getter
public
class
BusinessRunTimeException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
private
int
code
;
private
Map
<
String
,
Object
>
data
;
public
BusinessRunTimeException
(
int
code
,
String
reason
)
{
super
(
reason
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
objectMap
.
put
(
"message"
,
reason
);
this
.
code
=
code
;
this
.
data
=
objectMap
;
}
public
BusinessRunTimeException
(
int
code
,
String
reason
,
Throwable
throwable
)
{
super
(
reason
,
throwable
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
objectMap
.
put
(
"message"
,
reason
);
this
.
code
=
code
;
this
.
data
=
objectMap
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.exception
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
javax.servlet.http.HttpServletRequest
;
@Slf4j
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
@ExceptionHandler
(
value
=
Exception
.
class
)
@ResponseBody
public
Object
handleException
(
Exception
e
,
HttpServletRequest
request
)
{
JSONObject
status
=
new
JSONObject
();
// 针对业务参数异常的处理
if
(
e
instanceof
BusinessParamCheckingException
)
{
status
.
put
(
ExceptionConstants
.
GLOBAL_RETURNS_CODE
,
((
BusinessParamCheckingException
)
e
).
getCode
());
status
.
put
(
ExceptionConstants
.
GLOBAL_RETURNS_DATA
,
((
BusinessParamCheckingException
)
e
).
getData
());
return
status
;
}
//针对业务运行时异常的处理
if
(
e
instanceof
BusinessRunTimeException
)
{
status
.
put
(
ExceptionConstants
.
GLOBAL_RETURNS_CODE
,
((
BusinessRunTimeException
)
e
).
getCode
());
status
.
put
(
ExceptionConstants
.
GLOBAL_RETURNS_DATA
,
((
BusinessRunTimeException
)
e
).
getData
());
return
status
;
}
status
.
put
(
ExceptionConstants
.
GLOBAL_RETURNS_CODE
,
ExceptionConstants
.
SERVICE_SYSTEM_ERROR_CODE
);
status
.
put
(
ExceptionConstants
.
GLOBAL_RETURNS_DATA
,
ExceptionConstants
.
SERVICE_SYSTEM_ERROR_MSG
);
log
.
error
(
"Global Exception Occured => url : {}, msg : {}"
,
request
.
getRequestURL
(),
e
.
getMessage
());
/**
* create by: qiankunpingtai
* create time: 2019/4/18 17:41
* 这里输出完整的堆栈信息,否则有些异常完全不知道哪里出错了。
*/
log
.
error
(
"Global Exception Occured => url : {}"
,
request
.
getRequestURL
(),
e
);
e
.
printStackTrace
();
return
status
;
}
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/exception/JshException.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.exception
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
org.slf4j.Logger
;
/**
* 封装日志打印,收集日志
* author: ji shenghua, qq 752718 920
*/
public
class
JshException
{
public
static
void
readFail
(
Logger
logger
,
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
);
}
public
static
void
writeFail
(
Logger
logger
,
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
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/filter/LogCostFilter.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.filter
;
import
com.jsh.erp.service.redis.RedisService
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.annotation.WebInitParam
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@WebFilter
(
filterName
=
"LogCostFilter"
,
urlPatterns
=
{
"/*"
},
initParams
=
{
@WebInitParam
(
name
=
"ignoredUrl"
,
value
=
".ico"
),
@WebInitParam
(
name
=
"filterPath"
,
value
=
"/jshERP-boot/user/login#/jshERP-boot/user/registerUser#/jshERP-boot/user/randomImage"
+
"#/jshERP-boot/platformConfig/getPlatformName#/jshERP-boot/v2/api-docs"
)})
public
class
LogCostFilter
implements
Filter
{
private
static
final
String
FILTER_PATH
=
"filterPath"
;
private
static
final
String
IGNORED_PATH
=
"ignoredUrl"
;
private
static
final
List
<
String
>
ignoredList
=
new
ArrayList
<>();
private
String
[]
allowUrls
;
private
String
[]
ignoredUrls
;
@Resource
private
RedisService
redisService
;
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
String
filterPath
=
filterConfig
.
getInitParameter
(
FILTER_PATH
);
if
(!
StringUtils
.
isEmpty
(
filterPath
))
{
allowUrls
=
filterPath
.
contains
(
"#"
)
?
filterPath
.
split
(
"#"
)
:
new
String
[]{
filterPath
};
}
String
ignoredPath
=
filterConfig
.
getInitParameter
(
IGNORED_PATH
);
if
(!
StringUtils
.
isEmpty
(
ignoredPath
))
{
ignoredUrls
=
ignoredPath
.
contains
(
"#"
)
?
ignoredPath
.
split
(
"#"
)
:
new
String
[]{
ignoredPath
};
for
(
String
ignoredUrl
:
ignoredUrls
)
{
ignoredList
.
add
(
ignoredUrl
);
}
}
}
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
HttpServletRequest
servletRequest
=
(
HttpServletRequest
)
request
;
HttpServletResponse
servletResponse
=
(
HttpServletResponse
)
response
;
String
requestUrl
=
servletRequest
.
getRequestURI
();
//具体,比如:处理若用户未登录,则跳转到登录页
Object
userId
=
redisService
.
getObjectFromSessionByKey
(
servletRequest
,
"userId"
);
if
(
userId
!=
null
)
{
//如果已登录,不阻止
chain
.
doFilter
(
request
,
response
);
return
;
}
if
(
requestUrl
!=
null
&&
(
requestUrl
.
contains
(
"/doc.html"
)
||
requestUrl
.
contains
(
"/register.html"
)
||
requestUrl
.
contains
(
"/login.html"
)))
{
chain
.
doFilter
(
request
,
response
);
return
;
}
if
(
verify
(
ignoredList
,
requestUrl
))
{
chain
.
doFilter
(
servletRequest
,
response
);
return
;
}
if
(
null
!=
allowUrls
&&
allowUrls
.
length
>
0
)
{
for
(
String
url
:
allowUrls
)
{
if
(
requestUrl
.
startsWith
(
url
))
{
chain
.
doFilter
(
request
,
response
);
return
;
}
}
}
servletResponse
.
sendRedirect
(
"/login.html"
);
}
private
static
String
regexPrefix
=
"^.*"
;
private
static
String
regexSuffix
=
".*$"
;
private
static
boolean
verify
(
List
<
String
>
ignoredList
,
String
url
)
{
for
(
String
regex
:
ignoredList
)
{
Pattern
pattern
=
Pattern
.
compile
(
regexPrefix
+
regex
+
regexSuffix
);
Matcher
matcher
=
pattern
.
matcher
(
url
);
if
(
matcher
.
matches
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
destroy
()
{
}
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/CommonQueryManager.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author jishenghua 752718920 2018-10-7 15:25:58
*/
@Service
public
class
CommonQueryManager
{
@Resource
private
InterfaceContainer
container
;
@Resource
private
LogService
logService
;
/**
* 查询单条
*
* @param apiName 接口名称
* @param id ID
*/
public
Object
selectOne
(
String
apiName
,
Long
id
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
)
&&
id
!=
null
)
{
return
container
.
getCommonQuery
(
apiName
).
selectOne
(
id
);
}
return
null
;
}
/**
* 查询
* @param apiName
* @param parameterMap
* @return
*/
public
List
<?>
select
(
String
apiName
,
Map
<
String
,
String
>
parameterMap
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
select
(
parameterMap
);
}
return
new
ArrayList
<
Object
>();
}
/**
* 计数
* @param apiName
* @param parameterMap
* @return
*/
public
Long
counts
(
String
apiName
,
Map
<
String
,
String
>
parameterMap
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
counts
(
parameterMap
);
}
return
BusinessConstants
.
DEFAULT_LIST_NULL_NUMBER
;
}
/**
* 插入
* @param apiName
* @param obj
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insert
(
String
apiName
,
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
insert
(
obj
,
request
);
}
return
0
;
}
/**
* 更新
* @param apiName
* @param obj
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
update
(
String
apiName
,
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
update
(
obj
,
request
);
}
return
0
;
}
/**
* 删除
* @param apiName
* @param id
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
delete
(
String
apiName
,
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
delete
(
id
,
request
);
}
return
0
;
}
/**
* 批量删除
* @param apiName
* @param ids
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteBatch
(
String
apiName
,
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
deleteBatch
(
ids
,
request
);
}
return
0
;
}
/**
* 判断是否存在
* @param apiName
* @param id
* @param name
* @return
*/
public
int
checkIsNameExist
(
String
apiName
,
Long
id
,
String
name
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
checkIsNameExist
(
id
,
name
);
}
return
0
;
}
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/ICommonQuery.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service
;
import
com.alibaba.fastjson.JSONObject
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
/**
* 通用查询接口
* 功能:1、单条查询 2、分页+搜索 3、查询数量
*
* @author jishenghua
* @version 1.0
*/
public
interface
ICommonQuery
{
/**
* 根据id查询明细。
*
* @param id 资源id
* @return 资源
*/
Object
selectOne
(
Long
id
)
throws
Exception
;
/**
* 自定义查询
*
* @param parameterMap 查询参数
* @return 查询结果
*/
List
<?>
select
(
Map
<
String
,
String
>
parameterMap
)
throws
Exception
;
/**
* 查询数量
*
* @param parameterMap 查询参数
* @return 查询结果
*/
Long
counts
(
Map
<
String
,
String
>
parameterMap
)
throws
Exception
;
/**
* 新增数据
*
* @param obj
* @return
*/
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
;
/**
* 更新数据
*
* @param obj
* @return
*/
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
;
/**
* 删除数据
*
* @param id
* @return
*/
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
;
/**
* 批量删除数据
*
* @param ids
* @return
*/
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
;
/**
* 查询名称是否存在
*
* @param id
* @return
*/
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
;
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/InterfaceContainer.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service
;
import
com.jsh.erp.utils.AnnotationUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author jishenghua 2018-10-7 15:25:09
*/
@Service
public
class
InterfaceContainer
{
private
final
Map
<
String
,
ICommonQuery
>
configComponentMap
=
new
HashMap
<>();
@Autowired
(
required
=
false
)
private
synchronized
void
init
(
ICommonQuery
[]
configComponents
)
{
for
(
ICommonQuery
configComponent
:
configComponents
)
{
ResourceInfo
info
=
AnnotationUtils
.
getAnnotation
(
configComponent
,
ResourceInfo
.
class
);
if
(
info
!=
null
)
{
configComponentMap
.
put
(
info
.
value
(),
configComponent
);
}
}
}
public
ICommonQuery
getCommonQuery
(
String
apiName
)
{
return
configComponentMap
.
get
(
apiName
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/ResourceInfo.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service
;
import
java.lang.annotation.*
;
/**
* @author jishenghua 2018-10-7 15:25:39
*/
@Target
({
ElementType
.
TYPE
,
ElementType
.
ANNOTATION_TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Inherited
@Documented
public
@interface
ResourceInfo
{
String
value
();
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.account
;
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
=
"account_component"
)
@AccountResource
public
class
AccountComponent
implements
ICommonQuery
{
@Resource
private
AccountService
accountService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
accountService
.
getAccount
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getAccountList
(
map
);
}
private
List
<?>
getAccountList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
serialNo
=
StringUtil
.
getInfo
(
search
,
"serialNo"
);
String
remark
=
StringUtil
.
getInfo
(
search
,
"remark"
);
String
order
=
QueryUtils
.
order
(
map
);
return
accountService
.
select
(
name
,
serialNo
,
remark
,
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"
);
String
serialNo
=
StringUtil
.
getInfo
(
search
,
"serialNo"
);
String
remark
=
StringUtil
.
getInfo
(
search
,
"remark"
);
return
accountService
.
countAccount
(
name
,
serialNo
,
remark
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
accountService
.
insertAccount
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
accountService
.
updateAccount
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
accountService
.
deleteAccount
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
accountService
.
batchDeleteAccount
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
accountService
.
checkIsNameExist
(
id
,
name
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountResource.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.account
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo
(
value
=
"account"
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
AccountResource
{
}
jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountService.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.account
;
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.datasource.vo.AccountVo4InOutList
;
import
com.jsh.erp.datasource.vo.AccountVo4List
;
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
com.jsh.erp.utils.Tools
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.dao.DataAccessException
;
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.text.DecimalFormat
;
import
java.util.*
;
@Service
public
class
AccountService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountService
.
class
);
@Resource
private
AccountMapper
accountMapper
;
@Resource
private
AccountMapperEx
accountMapperEx
;
@Resource
private
DepotHeadMapper
depotHeadMapper
;
@Resource
private
DepotHeadMapperEx
depotHeadMapperEx
;
@Resource
private
AccountHeadMapper
accountHeadMapper
;
@Resource
private
AccountHeadMapperEx
accountHeadMapperEx
;
@Resource
private
AccountItemMapper
accountItemMapper
;
@Resource
private
AccountItemMapperEx
accountItemMapperEx
;
@Resource
private
LogService
logService
;
@Resource
private
UserService
userService
;
public
Account
getAccount
(
long
id
)
throws
Exception
{
return
accountMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
Account
>
getAccountListByIds
(
String
ids
)
throws
Exception
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
List
<
Account
>
list
=
new
ArrayList
<>();
try
{
AccountExample
example
=
new
AccountExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
list
=
accountMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
Account
>
getAccount
()
throws
Exception
{
AccountExample
example
=
new
AccountExample
();
example
.
createCriteria
().
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Account
>
list
=
null
;
try
{
list
=
accountMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
Account
>
getAccountByParam
(
String
name
,
String
serialNo
)
throws
Exception
{
List
<
Account
>
list
=
null
;
try
{
list
=
accountMapperEx
.
getAccountByParam
(
name
,
serialNo
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
List
<
AccountVo4List
>
select
(
String
name
,
String
serialNo
,
String
remark
,
int
offset
,
int
rows
)
throws
Exception
{
List
<
AccountVo4List
>
resList
=
new
ArrayList
<
AccountVo4List
>();
List
<
AccountVo4List
>
list
=
null
;
try
{
list
=
accountMapperEx
.
selectByConditionAccount
(
name
,
serialNo
,
remark
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
String
timeStr
=
Tools
.
getCurrentMonth
();
if
(
null
!=
list
&&
null
!=
timeStr
)
{
for
(
AccountVo4List
al
:
list
)
{
DecimalFormat
df
=
new
DecimalFormat
(
".##"
);
BigDecimal
thisMonthAmount
=
getAccountSum
(
al
.
getId
(),
timeStr
,
"month"
).
add
(
getAccountSumByHead
(
al
.
getId
(),
timeStr
,
"month"
)).
add
(
getAccountSumByDetail
(
al
.
getId
(),
timeStr
,
"month"
)).
add
(
getManyAccountSum
(
al
.
getId
(),
timeStr
,
"month"
));
String
thisMonthAmountFmt
=
"0"
;
if
((
thisMonthAmount
.
compareTo
(
BigDecimal
.
ZERO
))!=
0
)
{
thisMonthAmountFmt
=
df
.
format
(
thisMonthAmount
);
}
al
.
setThisMonthAmount
(
thisMonthAmountFmt
);
//本月发生额
BigDecimal
currentAmount
=
getAccountSum
(
al
.
getId
(),
""
,
"month"
).
add
(
getAccountSumByHead
(
al
.
getId
(),
""
,
"month"
)).
add
(
getAccountSumByDetail
(
al
.
getId
(),
""
,
"month"
)).
add
(
getManyAccountSum
(
al
.
getId
(),
""
,
"month"
))
.
add
(
al
.
getInitialAmount
())
;
al
.
setCurrentAmount
(
currentAmount
);
resList
.
add
(
al
);
}
}
return
resList
;
}
public
Long
countAccount
(
String
name
,
String
serialNo
,
String
remark
)
throws
Exception
{
Long
result
=
null
;
try
{
result
=
accountMapperEx
.
countsByAccount
(
name
,
serialNo
,
remark
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertAccount
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Account
account
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Account
.
class
);
if
(
account
.
getInitialAmount
()
==
null
)
{
account
.
setInitialAmount
(
BigDecimal
.
ZERO
);
}
account
.
setIsDefault
(
false
);
int
result
=
0
;
try
{
result
=
accountMapper
.
insertSelective
(
account
);
logService
.
insertLog
(
"账户"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
).
append
(
account
.
getName
()).
toString
(),
request
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateAccount
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
Account
account
=
JSONObject
.
parseObject
(
obj
.
toJSONString
(),
Account
.
class
);
int
result
=
0
;
try
{
result
=
accountMapper
.
updateByPrimaryKeySelective
(
account
);
logService
.
insertLog
(
"账户"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
account
.
getName
()).
toString
(),
request
);
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteAccount
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteAccountByIds
(
id
.
toString
());
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteAccount
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
batchDeleteAccountByIds
(
ids
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteAccountByIds
(
String
ids
)
throws
Exception
{
int
result
=
0
;
String
[]
idArray
=
ids
.
split
(
","
);
//校验财务主表 jsh_accounthead
List
<
AccountHead
>
accountHeadList
=
null
;
try
{
accountHeadList
=
accountHeadMapperEx
.
getAccountHeadListByAccountIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
accountHeadList
!=
null
&&
accountHeadList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,AccountIds[{}]"
,
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_accountitem
List
<
AccountItem
>
accountItemList
=
null
;
try
{
accountItemList
=
accountItemMapperEx
.
getAccountItemListByAccountIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
accountItemList
!=
null
&&
accountItemList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,AccountIds[{}]"
,
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_depot_head
List
<
DepotHead
>
depotHeadList
=
null
;
try
{
depotHeadList
=
depotHeadMapperEx
.
getDepotHeadListByAccountIds
(
idArray
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
depotHeadList
!=
null
&&
depotHeadList
.
size
()>
0
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,AccountIds[{}]"
,
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
<
Account
>
list
=
getAccountListByIds
(
ids
);
for
(
Account
account:
list
){
sb
.
append
(
"["
).
append
(
account
.
getName
()).
append
(
"]"
);
}
logService
.
insertLog
(
"账户"
,
sb
.
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
User
userInfo
=
userService
.
getCurrentUser
();
//校验通过执行删除操作
try
{
result
=
accountMapperEx
.
batchDeleteAccountByIds
(
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
{
AccountExample
example
=
new
AccountExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andNameEqualTo
(
name
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
Account
>
list
=
null
;
try
{
list
=
accountMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
==
null
?
0
:
list
.
size
();
}
public
List
<
Account
>
findBySelect
()
throws
Exception
{
AccountExample
example
=
new
AccountExample
();
example
.
createCriteria
().
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
example
.
setOrderByClause
(
"id desc"
);
List
<
Account
>
list
=
null
;
try
{
list
=
accountMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
/**
* 单个账户的金额求和-入库和出库
*
* @param id
* @return
*/
public
BigDecimal
getAccountSum
(
Long
id
,
String
timeStr
,
String
type
)
throws
Exception
{
BigDecimal
accountSum
=
BigDecimal
.
ZERO
;
try
{
DepotHeadExample
example
=
new
DepotHeadExample
();
if
(!
timeStr
.
equals
(
""
))
{
Date
bTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
Date
eTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-31 00:00:00"
,
null
);
Date
mTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
if
(
type
.
equals
(
"month"
))
{
example
.
createCriteria
().
andAccountIdEqualTo
(
id
).
andPayTypeNotEqualTo
(
"预付款"
)
.
andOperTimeGreaterThanOrEqualTo
(
bTime
).
andOperTimeLessThanOrEqualTo
(
eTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
if
(
type
.
equals
(
"date"
))
{
example
.
createCriteria
().
andAccountIdEqualTo
(
id
).
andPayTypeNotEqualTo
(
"预付款"
)
.
andOperTimeLessThanOrEqualTo
(
mTime
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
}
else
{
example
.
createCriteria
().
andAccountIdEqualTo
(
id
).
andPayTypeNotEqualTo
(
"预付款"
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
List
<
DepotHead
>
dataList
=
null
;
try
{
dataList
=
depotHeadMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
dataList
!=
null
)
{
for
(
DepotHead
depotHead
:
dataList
)
{
if
(
depotHead
.
getChangeAmount
()!=
null
)
{
accountSum
=
accountSum
.
add
(
depotHead
.
getChangeAmount
())
;
}
}
}
}
catch
(
DataAccessException
e
)
{
logger
.
error
(
">>>>>>>>>查找进销存信息异常"
,
e
);
}
return
accountSum
;
}
/**
* 单个账户的金额求和-收入、支出、转账的单据表头的合计
*
* @param id
* @return
*/
public
BigDecimal
getAccountSumByHead
(
Long
id
,
String
timeStr
,
String
type
)
throws
Exception
{
BigDecimal
accountSum
=
BigDecimal
.
ZERO
;
try
{
AccountHeadExample
example
=
new
AccountHeadExample
();
if
(!
timeStr
.
equals
(
""
))
{
Date
bTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
Date
eTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-31 00:00:00"
,
null
);
Date
mTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
if
(
type
.
equals
(
"month"
))
{
example
.
createCriteria
().
andAccountIdEqualTo
(
id
)
.
andBillTimeGreaterThanOrEqualTo
(
bTime
).
andBillTimeLessThanOrEqualTo
(
eTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
if
(
type
.
equals
(
"date"
))
{
example
.
createCriteria
().
andAccountIdEqualTo
(
id
)
.
andBillTimeLessThanOrEqualTo
(
mTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
}
else
{
example
.
createCriteria
().
andAccountIdEqualTo
(
id
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
List
<
AccountHead
>
dataList
=
null
;
try
{
dataList
=
accountHeadMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
dataList
!=
null
)
{
for
(
AccountHead
accountHead
:
dataList
)
{
if
(
accountHead
.
getChangeAmount
()!=
null
)
{
accountSum
=
accountSum
.
add
(
accountHead
.
getChangeAmount
());
}
}
}
}
catch
(
DataAccessException
e
)
{
logger
.
error
(
">>>>>>>>>查找进销存信息异常"
,
e
);
}
return
accountSum
;
}
/**
* 单个账户的金额求和-收款、付款、转账、收预付款的单据明细的合计
*
* @param id
* @return
*/
public
BigDecimal
getAccountSumByDetail
(
Long
id
,
String
timeStr
,
String
type
)
throws
Exception
{
BigDecimal
accountSum
=
BigDecimal
.
ZERO
;
try
{
AccountHeadExample
example
=
new
AccountHeadExample
();
if
(!
timeStr
.
equals
(
""
))
{
Date
bTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
Date
eTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-31 00:00:00"
,
null
);
Date
mTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
if
(
type
.
equals
(
"month"
))
{
example
.
createCriteria
().
andBillTimeGreaterThanOrEqualTo
(
bTime
).
andBillTimeLessThanOrEqualTo
(
eTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
if
(
type
.
equals
(
"date"
))
{
example
.
createCriteria
().
andBillTimeLessThanOrEqualTo
(
mTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
}
List
<
AccountHead
>
dataList
=
null
;
try
{
dataList
=
accountHeadMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
dataList
!=
null
)
{
String
ids
=
""
;
for
(
AccountHead
accountHead
:
dataList
)
{
ids
=
ids
+
accountHead
.
getId
()
+
","
;
}
if
(!
ids
.
equals
(
""
))
{
ids
=
ids
.
substring
(
0
,
ids
.
length
()
-
1
);
}
AccountItemExample
exampleAi
=
new
AccountItemExample
();
if
(!
ids
.
equals
(
""
))
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
exampleAi
.
createCriteria
().
andAccountIdEqualTo
(
id
).
andHeaderIdIn
(
idList
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
AccountItem
>
dataListOne
=
accountItemMapper
.
selectByExample
(
exampleAi
);
if
(
dataListOne
!=
null
)
{
for
(
AccountItem
accountItem
:
dataListOne
)
{
if
(
accountItem
.
getEachAmount
()!=
null
)
{
accountSum
=
accountSum
.
add
(
accountItem
.
getEachAmount
());
}
}
}
}
}
}
catch
(
DataAccessException
e
)
{
logger
.
error
(
">>>>>>>>>查找进销存信息异常"
,
e
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>异常信息:"
,
e
);
}
return
accountSum
;
}
/**
* 单个账户的金额求和-多账户的明细合计
*
* @param id
* @return
*/
public
BigDecimal
getManyAccountSum
(
Long
id
,
String
timeStr
,
String
type
)
throws
Exception
{
BigDecimal
accountSum
=
BigDecimal
.
ZERO
;
try
{
DepotHeadExample
example
=
new
DepotHeadExample
();
if
(!
timeStr
.
equals
(
""
))
{
Date
bTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
Date
eTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-31 00:00:00"
,
null
);
Date
mTime
=
StringUtil
.
getDateByString
(
timeStr
+
"-01 00:00:00"
,
null
);
if
(
type
.
equals
(
"month"
))
{
example
.
createCriteria
().
andAccountIdListLike
(
"%"
+
id
.
toString
()
+
"%"
)
.
andOperTimeGreaterThanOrEqualTo
(
bTime
).
andOperTimeLessThanOrEqualTo
(
eTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
else
if
(
type
.
equals
(
"date"
))
{
example
.
createCriteria
().
andAccountIdListLike
(
"%"
+
id
.
toString
()
+
"%"
)
.
andOperTimeLessThanOrEqualTo
(
mTime
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
}
else
{
example
.
createCriteria
().
andAccountIdListLike
(
"%"
+
id
.
toString
()
+
"%"
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
}
List
<
DepotHead
>
dataList
=
null
;
try
{
dataList
=
depotHeadMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
if
(
dataList
!=
null
)
{
for
(
DepotHead
depotHead
:
dataList
)
{
String
accountIdList
=
depotHead
.
getAccountIdList
();
String
accountMoneyList
=
depotHead
.
getAccountMoneyList
();
if
(
StringUtil
.
isNotEmpty
(
accountIdList
)
&&
StringUtil
.
isNotEmpty
(
accountMoneyList
))
{
accountIdList
=
accountIdList
.
replace
(
"["
,
""
).
replace
(
"]"
,
""
).
replace
(
"\""
,
""
);
accountMoneyList
=
accountMoneyList
.
replace
(
"["
,
""
).
replace
(
"]"
,
""
).
replace
(
"\""
,
""
);
String
[]
aList
=
accountIdList
.
split
(
","
);
String
[]
amList
=
accountMoneyList
.
split
(
","
);
for
(
int
i
=
0
;
i
<
aList
.
length
;
i
++)
{
if
(
aList
[
i
].
toString
().
equals
(
id
.
toString
()))
{
if
(
amList
!=
null
&&
amList
.
length
>
0
)
{
accountSum
=
accountSum
.
add
(
new
BigDecimal
(
amList
[
i
]));
}
}
}
}
}
}
}
catch
(
DataAccessException
e
)
{
logger
.
error
(
">>>>>>>>>查找信息异常"
,
e
);
}
return
accountSum
;
}
public
List
<
AccountVo4InOutList
>
findAccountInOutList
(
Long
accountId
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
AccountVo4InOutList
>
list
=
null
;
try
{
list
=
accountMapperEx
.
findAccountInOutList
(
accountId
,
offset
,
rows
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
list
;
}
public
int
findAccountInOutListCount
(
Long
accountId
)
throws
Exception
{
int
result
=
0
;
try
{
result
=
accountMapperEx
.
findAccountInOutListCount
(
accountId
);
}
catch
(
Exception
e
){
JshException
.
readFail
(
logger
,
e
);
}
return
result
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateIsDefault
(
Long
accountId
)
throws
Exception
{
int
result
=
0
;
try
{
//全部取消默认
Account
allAccount
=
new
Account
();
allAccount
.
setIsDefault
(
false
);
AccountExample
allExample
=
new
AccountExample
();
allExample
.
createCriteria
();
accountMapper
.
updateByExampleSelective
(
allAccount
,
allExample
);
//给指定账户设为默认
Account
account
=
new
Account
();
account
.
setIsDefault
(
true
);
AccountExample
example
=
new
AccountExample
();
example
.
createCriteria
().
andIdEqualTo
(
accountId
);
accountMapper
.
updateByExampleSelective
(
account
,
example
);
logService
.
insertLog
(
"账户"
,
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
+
accountId
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
result
=
1
;
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
return
result
;
}
public
Map
<
String
,
Object
>
getStatistics
(
String
name
,
String
serialNo
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
try
{
List
<
Account
>
list
=
getAccountByParam
(
name
,
serialNo
);
String
timeStr
=
Tools
.
getCurrentMonth
();
BigDecimal
allMonthAmount
=
BigDecimal
.
ZERO
;
BigDecimal
allCurrentAmount
=
BigDecimal
.
ZERO
;
if
(
null
!=
list
&&
null
!=
timeStr
)
{
for
(
Account
a
:
list
)
{
BigDecimal
monthAmount
=
getAccountSum
(
a
.
getId
(),
timeStr
,
"month"
).
add
(
getAccountSumByHead
(
a
.
getId
(),
timeStr
,
"month"
))
.
add
(
getAccountSumByDetail
(
a
.
getId
(),
timeStr
,
"month"
)).
add
(
getManyAccountSum
(
a
.
getId
(),
timeStr
,
"month"
));
BigDecimal
currentAmount
=
getAccountSum
(
a
.
getId
(),
""
,
"month"
).
add
(
getAccountSumByHead
(
a
.
getId
(),
""
,
"month"
))
.
add
(
getAccountSumByDetail
(
a
.
getId
(),
""
,
"month"
)).
add
(
getManyAccountSum
(
a
.
getId
(),
""
,
"month"
)).
add
(
a
.
getInitialAmount
());
allMonthAmount
=
allMonthAmount
.
add
(
monthAmount
);
allCurrentAmount
=
allCurrentAmount
.
add
(
currentAmount
);
}
}
map
.
put
(
"allCurrentAmount"
,
priceFormat
(
allCurrentAmount
));
//当前总金额
map
.
put
(
"allMonthAmount"
,
priceFormat
(
allMonthAmount
));
//本月发生额
}
catch
(
Exception
e
)
{
JshException
.
readFail
(
logger
,
e
);
}
return
map
;
}
/**
* 价格格式化
* @param price
* @return
*/
private
String
priceFormat
(
BigDecimal
price
)
{
String
priceFmt
=
"0"
;
DecimalFormat
df
=
new
DecimalFormat
(
".##"
);
if
((
price
.
compareTo
(
BigDecimal
.
ZERO
))!=
0
)
{
priceFmt
=
df
.
format
(
price
);
}
return
priceFmt
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.service.accountHead
;
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
=
"accountHead_component"
)
@AccountHeadResource
public
class
AccountHeadComponent
implements
ICommonQuery
{
@Resource
private
AccountHeadService
accountHeadService
;
@Override
public
Object
selectOne
(
Long
id
)
throws
Exception
{
return
accountHeadService
.
getAccountHead
(
id
);
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getAccountHeadList
(
map
);
}
private
List
<?>
getAccountHeadList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
type
=
StringUtil
.
getInfo
(
search
,
"type"
);
String
roleType
=
StringUtil
.
getInfo
(
search
,
"roleType"
);
String
billNo
=
StringUtil
.
getInfo
(
search
,
"billNo"
);
String
beginTime
=
StringUtil
.
getInfo
(
search
,
"beginTime"
);
String
endTime
=
StringUtil
.
getInfo
(
search
,
"endTime"
);
String
order
=
QueryUtils
.
order
(
map
);
return
accountHeadService
.
select
(
type
,
roleType
,
billNo
,
beginTime
,
endTime
,
QueryUtils
.
offset
(
map
),
QueryUtils
.
rows
(
map
));
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
type
=
StringUtil
.
getInfo
(
search
,
"type"
);
String
roleType
=
StringUtil
.
getInfo
(
search
,
"roleType"
);
String
billNo
=
StringUtil
.
getInfo
(
search
,
"billNo"
);
String
beginTime
=
StringUtil
.
getInfo
(
search
,
"beginTime"
);
String
endTime
=
StringUtil
.
getInfo
(
search
,
"endTime"
);
return
accountHeadService
.
countAccountHead
(
type
,
roleType
,
billNo
,
beginTime
,
endTime
);
}
@Override
public
int
insert
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
accountHeadService
.
insertAccountHead
(
obj
,
request
);
}
@Override
public
int
update
(
JSONObject
obj
,
HttpServletRequest
request
)
throws
Exception
{
return
accountHeadService
.
updateAccountHead
(
obj
,
request
);
}
@Override
public
int
delete
(
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
return
accountHeadService
.
deleteAccountHead
(
id
,
request
);
}
@Override
public
int
deleteBatch
(
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
return
accountHeadService
.
batchDeleteAccountHead
(
ids
,
request
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
accountHeadService
.
checkIsNameExist
(
id
,
name
);
}
}
Prev
1
…
6
7
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