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
7a436d1c
Commit
7a436d1c
authored
Apr 22, 2018
by
季圣华
Browse files
!14 格式化代码,看着有点别扭
Merge pull request !14 from SmkfGao/master
parents
8f304964
6bc92ec9
Changes
230
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 230+
files are displayed.
Plain diff
Email patch
src/main/java/com/jsh/service/basic/UserService.java
View file @
7a436d1c
package
com.jsh.service.basic
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.jsh.base.BaseService
;
import
com.jsh.base.Log
;
import
com.jsh.util.ExceptionCodeConstants
;
import
com.jsh.dao.basic.UserBusinessIDAO
;
import
com.jsh.dao.basic.UserIDAO
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.Basicuser
;
import
com.jsh.util.ExceptionCodeConstants
;
import
com.jsh.util.JshException
;
import
com.jsh.util.PageUtil
;
public
class
UserService
extends
BaseService
<
Basicuser
>
implements
UserIService
{
private
PageUtil
<
Basicuser
>
pageUtil
=
new
PageUtil
<
Basicuser
>();
private
Map
<
String
,
Object
>
condition
=
new
HashMap
<
String
,
Object
>();
private
UserIDAO
userDao
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
UserService
extends
BaseService
<
Basicuser
>
implements
UserIService
{
private
PageUtil
<
Basicuser
>
pageUtil
=
new
PageUtil
<
Basicuser
>();
private
Map
<
String
,
Object
>
condition
=
new
HashMap
<
String
,
Object
>();
private
UserIDAO
userDao
;
@Override
public
int
validateUser
(
String
username
,
String
password
)
throws
JshException
{
try
{
//全局变量 每次使用前清除
condition
.
clear
();
/**默认是可以登录的*/
List
<
Basicuser
>
list
=
null
;
try
{
condition
.
put
(
"loginame_s_eq"
,
username
);
pageUtil
.
setAdvSearch
(
condition
);
userDao
.
find
(
pageUtil
);
list
=
pageUtil
.
getPageList
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>访问验证用户姓名是否存在后台信息异常"
,
e
);
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
@Override
public
int
validateUser
(
String
username
,
String
password
)
throws
JshException
{
try
{
//全局变量 每次使用前清除
condition
.
clear
();
/**默认是可以登录的*/
List
<
Basicuser
>
list
=
null
;
try
{
condition
.
put
(
"loginame_s_eq"
,
username
);
pageUtil
.
setAdvSearch
(
condition
);
userDao
.
find
(
pageUtil
);
list
=
pageUtil
.
getPageList
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>访问验证用户姓名是否存在后台信息异常"
,
e
);
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
if
(
null
!=
list
&&
list
.
size
()
==
0
)
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_NOT_EXIST
;
try
{
condition
.
put
(
"loginame_s_eq"
,
username
);
condition
.
put
(
"password_s_eq"
,
password
);
pageUtil
.
setAdvSearch
(
condition
);
userDao
.
find
(
pageUtil
);
list
=
pageUtil
.
getPageList
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>访问验证用户密码后台信息异常"
,
e
);
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
if
(
null
!=
list
&&
list
.
size
()
==
0
)
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_PASSWORD_ERROR
;
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_CONDITION_FIT
;
}
catch
(
Exception
e
)
{
throw
new
JshException
(
"unknown exception"
,
e
);
}
}
if
(
null
!=
list
&&
list
.
size
()
==
0
)
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_NOT_EXIST
;
@Override
public
Basicuser
getUser
(
String
username
)
throws
JshException
{
//全局变量 每次使用前清除
condition
.
clear
();
condition
.
put
(
"loginame_s_eq"
,
username
);
try
{
condition
.
put
(
"loginame_s_eq"
,
username
);
condition
.
put
(
"password_s_eq"
,
password
);
pageUtil
.
setAdvSearch
(
condition
);
userDao
.
find
(
pageUtil
);
list
=
pageUtil
.
getPageList
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>访问验证用户密码后台信息异常"
,
e
);
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
if
(
null
!=
list
&&
list
.
size
()
==
0
)
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_PASSWORD_ERROR
;
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_CONDITION_FIT
;
}
catch
(
Exception
e
)
{
throw
new
JshException
(
"unknown exception"
,
e
);
}
}
@Override
public
Basicuser
getUser
(
String
username
)
throws
JshException
{
//全局变量 每次使用前清除
condition
.
clear
();
condition
.
put
(
"loginame_s_eq"
,
username
);
pageUtil
.
setAdvSearch
(
condition
);
userDao
.
find
(
pageUtil
);
List
<
Basicuser
>
list
=
pageUtil
.
getPageList
();
if
(
null
!=
list
&&
list
.
size
()
>
0
)
return
list
.
get
(
0
);
else
throw
new
JshException
(
"no username exist"
);
}
@Override
public
Boolean
checkIsNameExist
(
String
field
,
String
username
,
Long
userID
)
throws
JshException
{
condition
.
clear
();
if
(
null
!=
list
&&
list
.
size
()
>
0
)
return
list
.
get
(
0
);
else
throw
new
JshException
(
"no username exist"
);
}
@Override
public
Boolean
checkIsNameExist
(
String
field
,
String
username
,
Long
userID
)
throws
JshException
{
condition
.
clear
();
condition
.
put
(
field
+
"_s_eq"
,
username
);
condition
.
put
(
"id_n_neq"
,
userID
);
pageUtil
.
setAdvSearch
(
condition
);
userDao
.
find
(
pageUtil
);
List
<
Basicuser
>
dataList
=
pageUtil
.
getPageList
();
if
(
null
!=
dataList
&&
dataList
.
size
()
>
0
)
if
(
null
!=
dataList
&&
dataList
.
size
()
>
0
)
return
true
;
return
false
;
}
//==============spring注入等公共方法,与业务无关=========================
public
void
setUserDao
(
UserIDAO
userDao
)
{
this
.
userDao
=
userDao
;
}
}
//==============spring注入等公共方法,与业务无关=========================
public
void
setUserDao
(
UserIDAO
userDao
)
{
this
.
userDao
=
userDao
;
}
@Override
protected
Class
<
Basicuser
>
getEntityClass
()
{
return
Basicuser
.
class
;
}
@Override
protected
Class
<
Basicuser
>
getEntityClass
()
{
return
Basicuser
.
class
;
}
}
src/main/java/com/jsh/service/materials/AccountHeadIService.java
View file @
7a436d1c
package
com.jsh.service.materials
;
import
com.jsh.base.BaseIService
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.AccountHead
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.model.po.UserBusiness
;
import
com.jsh.util.JshException
;
import
com.jsh.util.PageUtil
;
public
interface
AccountHeadIService
extends
BaseIService
<
AccountHead
>
{
public
interface
AccountHeadIService
extends
BaseIService
<
AccountHead
>
{
/*
* 获取MaxId
*/
void
find
(
PageUtil
<
AccountHead
>
accountHead
,
String
maxid
)
throws
JshException
;
void
findAllMoney
(
PageUtil
<
AccountHead
>
accountHead
,
Integer
supplierId
,
String
type
,
String
mode
)
throws
JshException
;
void
find
(
PageUtil
<
AccountHead
>
accountHead
,
String
maxid
)
throws
JshException
;
void
findAllMoney
(
PageUtil
<
AccountHead
>
accountHead
,
Integer
supplierId
,
String
type
,
String
mode
)
throws
JshException
;
}
src/main/java/com/jsh/service/materials/AccountHeadService.java
View file @
7a436d1c
...
...
@@ -2,14 +2,11 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseService
;
import
com.jsh.dao.materials.AccountHeadIDAO
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.AccountHead
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.model.po.UserBusiness
;
import
com.jsh.util.JshException
;
import
com.jsh.util.PageUtil
;
public
class
AccountHeadService
extends
BaseService
<
AccountHead
>
implements
AccountHeadIService
{
public
class
AccountHeadService
extends
BaseService
<
AccountHead
>
implements
AccountHeadIService
{
@SuppressWarnings
(
"unused"
)
private
AccountHeadIDAO
accountHeadDao
;
...
...
@@ -20,18 +17,15 @@ public class AccountHeadService extends BaseService<AccountHead> implements Acco
@Override
protected
Class
<
AccountHead
>
getEntityClass
()
{
protected
Class
<
AccountHead
>
getEntityClass
()
{
return
AccountHead
.
class
;
}
public
void
find
(
PageUtil
<
AccountHead
>
pageUtil
,
String
maxid
)
throws
JshException
{
public
void
find
(
PageUtil
<
AccountHead
>
pageUtil
,
String
maxid
)
throws
JshException
{
accountHeadDao
.
find
(
pageUtil
,
maxid
);
}
public
void
findAllMoney
(
PageUtil
<
AccountHead
>
pageUtil
,
Integer
supplierId
,
String
type
,
String
mode
)
throws
JshException
{
accountHeadDao
.
findAllMoney
(
pageUtil
,
supplierId
,
type
,
mode
);
public
void
findAllMoney
(
PageUtil
<
AccountHead
>
pageUtil
,
Integer
supplierId
,
String
type
,
String
mode
)
throws
JshException
{
accountHeadDao
.
findAllMoney
(
pageUtil
,
supplierId
,
type
,
mode
);
}
}
src/main/java/com/jsh/service/materials/AccountItemIService.java
View file @
7a436d1c
package
com.jsh.service.materials
;
import
java.io.InputStream
;
import
java.util.List
;
import
net.sf.json.JSONArray
;
import
com.jsh.base.BaseIService
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.Asset
;
import
com.jsh.model.po.AccountHead
;
import
com.jsh.model.po.AccountItem
;
import
com.jsh.util.PageUtil
;
public
interface
AccountItemIService
extends
BaseIService
<
AccountItem
>
{
public
interface
AccountItemIService
extends
BaseIService
<
AccountItem
>
{
}
src/main/java/com/jsh/service/materials/AccountItemService.java
View file @
7a436d1c
package
com.jsh.service.materials
;
import
java.util.List
;
import
java.util.Map
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
com.jsh.base.BaseService
;
import
com.jsh.base.Log
;
import
com.jsh.util.AssetConstants
;
import
com.jsh.dao.materials.AccountItemIDAO
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.Asset
;
import
com.jsh.model.po.AccountHead
;
import
com.jsh.model.po.AccountItem
;
import
com.jsh.util.PageUtil
;
import
com.jsh.util.Tools
;
public
class
AccountItemService
extends
BaseService
<
AccountItem
>
implements
AccountItemIService
{
public
class
AccountItemService
extends
BaseService
<
AccountItem
>
implements
AccountItemIService
{
@SuppressWarnings
(
"unused"
)
private
AccountItemIDAO
accoumtItemDao
;
...
...
@@ -29,8 +15,7 @@ public class AccountItemService extends BaseService<AccountItem> implements Acco
@Override
protected
Class
<
AccountItem
>
getEntityClass
()
{
protected
Class
<
AccountItem
>
getEntityClass
()
{
return
AccountItem
.
class
;
}
...
...
src/main/java/com/jsh/service/materials/DepotHeadIService.java
View file @
7a436d1c
package
com.jsh.service.materials
;
import
com.jsh.base.BaseIService
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.
model.po.UserBusiness
;
import
com.jsh.
util.JshException
;
import
com.jsh.util.PageUtil
;
public
interface
DepotHeadIService
extends
BaseIService
<
DepotHead
>
{
/*
* 获取MaxId
*/
void
find
(
PageUtil
<
DepotHead
>
depotHead
,
String
maxid
)
throws
JshException
;
void
findAllMoney
(
PageUtil
<
DepotHead
>
depotHead
,
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
)
throws
JshException
;
public
interface
DepotHeadIService
extends
BaseIService
<
DepotHead
>
{
/*
* 获取MaxId
*/
void
find
(
PageUtil
<
DepotHead
>
depotHead
,
String
maxid
)
throws
JshException
;
void
findAllMoney
(
PageUtil
<
DepotHead
>
depotHead
,
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
)
throws
JshException
;
public
void
batchSetStatus
(
Boolean
status
,
String
depotHeadIDs
);
void
batchSetStatus
(
Boolean
status
,
String
depotHeadIDs
);
public
void
findInDetail
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
;
void
findInDetail
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
;
public
void
findInOutMaterialCount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
;
void
findInOutMaterialCount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
;
public
void
findMaterialsListByHeaderId
(
PageUtil
pageUtil
,
Long
headerId
)
throws
JshException
;
void
findMaterialsListByHeaderId
(
PageUtil
pageUtil
,
Long
headerId
)
throws
JshException
;
public
void
findStatementAccount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
Long
organId
,
String
supType
)
throws
JshException
;
void
findStatementAccount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
Long
organId
,
String
supType
)
throws
JshException
;
public
void
getHeaderIdByMaterial
(
PageUtil
pageUtil
,
String
materialParam
,
String
depotIds
)
throws
JshException
;
void
getHeaderIdByMaterial
(
PageUtil
pageUtil
,
String
materialParam
,
String
depotIds
)
throws
JshException
;
}
src/main/java/com/jsh/service/materials/DepotHeadService.java
View file @
7a436d1c
...
...
@@ -2,59 +2,62 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseService
;
import
com.jsh.dao.materials.DepotHeadIDAO
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.
model.po.UserBusiness
;
import
com.jsh.
util.JshException
;
import
com.jsh.util.PageUtil
;
public
class
DepotHeadService
extends
BaseService
<
DepotHead
>
implements
DepotHeadIService
{
@SuppressWarnings
(
"unused"
)
private
DepotHeadIDAO
depotHeadDao
;
public
class
DepotHeadService
extends
BaseService
<
DepotHead
>
implements
DepotHeadIService
{
@SuppressWarnings
(
"unused"
)
private
DepotHeadIDAO
depotHeadDao
;
public
void
setDepotHeadDao
(
DepotHeadIDAO
depotHeadDao
)
{
this
.
depotHeadDao
=
depotHeadDao
;
}
public
void
setDepotHeadDao
(
DepotHeadIDAO
depotHeadDao
)
{
this
.
depotHeadDao
=
depotHeadDao
;
}
@Override
protected
Class
<
DepotHead
>
getEntityClass
()
{
return
DepotHead
.
class
;
}
public
void
find
(
PageUtil
<
DepotHead
>
pageUtil
,
String
maxid
)
throws
JshException
{
depotHeadDao
.
find
(
pageUtil
,
maxid
);
@Override
protected
Class
<
DepotHead
>
getEntityClass
()
{
return
DepotHead
.
class
;
}
public
void
findAllMoney
(
PageUtil
<
DepotHead
>
pageUtil
,
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
)
throws
JshException
{
depotHeadDao
.
find
AllMoney
(
pageUtil
,
supplierId
,
type
,
subType
,
mode
);
@Override
public
void
find
(
PageUtil
<
DepotHead
>
pageUtil
,
String
maxid
)
throws
JshException
{
depotHeadDao
.
find
(
pageUtil
,
maxid
);
}
public
void
batchSetStatus
(
Boolean
status
,
String
depotHeadIDs
){
depotHeadDao
.
batchSetStatus
(
status
,
depotHeadIDs
);
}
@Override
public
void
findAllMoney
(
PageUtil
<
DepotHead
>
pageUtil
,
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
)
throws
JshException
{
depotHeadDao
.
findAllMoney
(
pageUtil
,
supplierId
,
type
,
subType
,
mode
);
}
public
void
findInDetail
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
{
depotHeadDao
.
findInDetail
(
pageUtil
,
beginTime
,
endTime
,
type
,
pid
,
dids
,
oId
);
}
@Override
public
void
batchSetStatus
(
Boolean
status
,
String
depotHeadIDs
)
{
depotHeadDao
.
batchSetStatus
(
status
,
depotHeadIDs
);
}
public
void
findInOutMaterialCount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
{
depotHeadDao
.
findInOutMaterialCount
(
pageUtil
,
beginTime
,
endTime
,
type
,
pid
,
dids
,
oId
);
}
@Override
public
void
findInDetail
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
{
depotHeadDao
.
findInDetail
(
pageUtil
,
beginTime
,
endTime
,
type
,
pid
,
dids
,
oId
);
}
@Override
public
void
findInOutMaterialCount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
String
type
,
Long
pid
,
String
dids
,
Long
oId
)
throws
JshException
{
depotHeadDao
.
findInOutMaterialCount
(
pageUtil
,
beginTime
,
endTime
,
type
,
pid
,
dids
,
oId
);
}
public
void
findMaterialsListByHeaderId
(
PageUtil
pageUtil
,
Long
headerId
)
throws
JshException
{
depotHeadDao
.
findMaterialsListByHeaderId
(
pageUtil
,
headerId
);
}
@Override
public
void
findMaterialsListByHeaderId
(
PageUtil
pageUtil
,
Long
headerId
)
throws
JshException
{
depotHeadDao
.
findMaterialsListByHeaderId
(
pageUtil
,
headerId
);
}
public
void
findStatementAccount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
Long
organId
,
String
supType
)
throws
JshException
{
depotHeadDao
.
findStatementAccount
(
pageUtil
,
beginTime
,
endTime
,
organId
,
supType
);
}
@Override
public
void
findStatementAccount
(
PageUtil
pageUtil
,
String
beginTime
,
String
endTime
,
Long
organId
,
String
supType
)
throws
JshException
{
depotHeadDao
.
findStatementAccount
(
pageUtil
,
beginTime
,
endTime
,
organId
,
supType
);
}
public
void
getHeaderIdByMaterial
(
PageUtil
pageUtil
,
String
materialParam
,
String
depotIds
)
throws
JshException
{
depotHeadDao
.
getHeaderIdByMaterial
(
pageUtil
,
materialParam
,
depotIds
);
}
@Override
public
void
getHeaderIdByMaterial
(
PageUtil
pageUtil
,
String
materialParam
,
String
depotIds
)
throws
JshException
{
depotHeadDao
.
getHeaderIdByMaterial
(
pageUtil
,
materialParam
,
depotIds
);
}
}
src/main/java/com/jsh/service/materials/DepotItemIService.java
View file @
7a436d1c
package
com.jsh.service.materials
;
import
java.io.InputStream
;
import
java.util.List
;
import
net.sf.json.JSONArray
;
import
com.jsh.base.BaseIService
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.Asset
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.model.po.DepotItem
;
import
com.jsh.util.JshException
;
import
com.jsh.util.PageUtil
;
import
net.sf.json.JSONArray
;
import
java.io.InputStream
;
public
interface
DepotItemIService
extends
BaseIService
<
DepotItem
>
{
void
findByType
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
;
public
interface
DepotItemIService
extends
BaseIService
<
DepotItem
>
{
void
findByType
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
;
void
findByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Long
MId
)
throws
JshException
;
void
findByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Long
MId
)
throws
JshException
;
void
find
Detail
ByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
depotItem
,
Long
MId
)
throws
JshException
;
void
find
DetailByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
depotItem
,
Long
MId
)
throws
JshException
;
void
find
PriceByType
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
;
void
findPriceByType
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
;
void
buyOrSale
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
,
String
sumType
)
throws
JshException
;
void
buyOrSale
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
,
String
sumType
)
throws
JshException
;
void
findGiftByType
(
PageUtil
<
DepotItem
>
depotItem
,
String
subType
,
Integer
ProjectId
,
Long
MId
,
String
type
)
throws
JshException
;
void
findGiftByType
(
PageUtil
<
DepotItem
>
depotItem
,
String
subType
,
Integer
ProjectId
,
Long
MId
,
String
type
)
throws
JshException
;
/**
* 导出信息
* @return
*/
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
;
/**
* 导出信息
*
* @return
*/
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
;
}
src/main/java/com/jsh/service/materials/DepotItemService.java
View file @
7a436d1c
package
com.jsh.service.materials
;
import
com.jsh.base.BaseService
;
import
com.jsh.base.Log
;
import
com.jsh.dao.materials.DepotItemIDAO
;
import
com.jsh.model.po.DepotItem
;
import
com.jsh.util.JshException
;
import
com.jsh.util.PageUtil
;
import
jxl.Workbook
;
import
jxl.write.Label
;
import
jxl.write.WritableSheet
;
import
jxl.write.WritableWorkbook
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.text.DecimalFormat
;
import
java.util.List
;
import
java.util.Map
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
public
class
DepotItemService
extends
BaseService
<
DepotItem
>
implements
DepotItemIService
{
@SuppressWarnings
(
"unused"
)
private
DepotItemIDAO
depotItemDao
;
import
jxl.Workbook
;
import
jxl.write.Label
;
import
jxl.write.WritableSheet
;
import
jxl.write.WritableWorkbook
;
import
com.jsh.base.BaseService
;
import
com.jsh.base.Log
;
import
com.jsh.util.AssetConstants
;
import
com.jsh.dao.materials.DepotItemIDAO
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.Asset
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.model.po.DepotItem
;
import
com.jsh.util.PageUtil
;
import
com.jsh.util.Tools
;
public
void
setDepotItemDao
(
DepotItemIDAO
depotItemDao
)
{
this
.
depotItemDao
=
depotItemDao
;
}
public
class
DepotItemService
extends
BaseService
<
DepotItem
>
implements
DepotItemIService
{
@SuppressWarnings
(
"unused"
)
private
DepotItemIDAO
depotItemDao
;
public
void
setDepotItemDao
(
DepotItemIDAO
depotItemDao
)
{
this
.
depotItemDao
=
depotItemDao
;
}
@Override
protected
Class
<
DepotItem
>
getEntityClass
()
{
return
DepotItem
.
class
;
}
@Override
public
void
findByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
{
depotItemDao
.
findByType
(
pageUtil
,
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
}
@Override
public
void
findByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Long
MId
)
throws
JshException
{
depotItemDao
.
findByTypeAndMaterialId
(
pageUtil
,
type
,
MId
);
}
@Override
public
void
findDetailByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
pageUtil
,
Long
MId
)
throws
JshException
{
depotItemDao
.
findDetailByTypeAndMaterialId
(
pageUtil
,
MId
);
}
@Override
protected
Class
<
DepotItem
>
getEntityClass
()
{
return
DepotItem
.
class
;
}
@Override
public
void
findByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
{
depotItemDao
.
findByType
(
pageUtil
,
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
public
void
findPriceByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
{
depotItemDao
.
findPriceByType
(
pageUtil
,
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
}
@Override
public
void
findByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Long
MId
)
throws
JshException
{
depotItemDao
.
findByTypeAndMaterialId
(
pageUtil
,
type
,
MId
);
}
@Override
public
void
buyOrSale
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
,
String
sumType
)
throws
JshException
{
depotItemDao
.
buyOrSale
(
pageUtil
,
type
,
subType
,
MId
,
MonthTime
,
sumType
);
}
@Override
public
void
findDetailByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
pageUtil
,
Long
MId
)
throws
JshException
{
depotItemDao
.
findDetailByTypeAndMaterialId
(
pageUtil
,
MId
);
}
@Override
public
void
findGiftByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
subType
,
Integer
ProjectId
,
Long
MId
,
String
type
)
throws
JshException
{
depotItemDao
.
findGiftByType
(
pageUtil
,
subType
,
ProjectId
,
MId
,
type
);
}
@Override
public
void
findPriceByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
{
depotItemDao
.
findPriceByType
(
pageUtil
,
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
}
/**
* 导出Excel表格
*/
@Override
public
void
buyOrSale
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
,
String
sumType
)
throws
JshException
{
depotItemDao
.
buyOrSale
(
pageUtil
,
type
,
subType
,
MId
,
MonthTime
,
sumType
);
public
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
{
try
{
//将OutputStream转化为InputStream
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
putDataOnOutputStream
(
out
,
dataArray
);
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
throw
new
JshException
(
"export asset info to excel exception"
,
e
);
}
}
@Override
public
void
findGiftByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
subType
,
Integer
ProjectId
,
Long
MId
,
String
type
)
throws
JshException
{
depotItemDao
.
findGiftByType
(
pageUtil
,
subType
,
ProjectId
,
MId
,
type
);
}
/**
* 导出Excel表格
*/
@Override
public
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
{
try
{
//将OutputStream转化为InputStream
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
putDataOnOutputStream
(
out
,
dataArray
);
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
throw
new
JshException
(
"export asset info to excel exception"
,
e
);
}
}
/**
* 生成excel表格
* @param os
*/
@SuppressWarnings
(
"deprecation"
)
private
void
putDataOnOutputStream
(
OutputStream
os
,
JSONArray
dataArray
)
{
WritableWorkbook
workbook
=
null
;
try
{
workbook
=
Workbook
.
createWorkbook
(
os
);
WritableSheet
sheet
=
workbook
.
createSheet
(
"进销存报表"
,
0
);
//增加列头
int
[]
colunmWidth
=
{
10
,
10
,
10
,
10
,
10
,
10
,
15
,
15
,
15
,
15
,
15
};
String
[]
colunmName
=
{
"名称"
,
"型号"
,
"规格"
,
"颜色"
,
"单位"
,
"单价"
,
"上月结存数量"
,
"入库数量"
,
"出库数量"
,
"本月结存数量"
,
"结存金额"
};
for
(
int
i
=
0
;
i
<
colunmWidth
.
length
;
i
++)
{
sheet
.
setColumnView
(
i
,
colunmWidth
[
i
]);
sheet
.
addCell
(
new
Label
(
i
,
0
,
colunmName
[
i
]));
}
if
(
null
!=
dataArray
&&
dataArray
.
size
()
>
0
)
{
for
(
int
j
=
0
;
j
<
dataArray
.
size
();
j
++){
JSONObject
jo
=
JSONObject
.
fromObject
(
dataArray
.
get
(
j
));
sheet
.
addCell
(
new
Label
(
0
,
j
+
1
,
jo
.
getString
(
"MaterialName"
)));
sheet
.
addCell
(
new
Label
(
1
,
j
+
1
,
jo
.
getString
(
"MaterialModel"
)));
sheet
.
addCell
(
new
Label
(
2
,
j
+
1
,
jo
.
getString
(
"MaterialStandard"
)));
sheet
.
addCell
(
new
Label
(
3
,
j
+
1
,
jo
.
getString
(
"MaterialColor"
)));
sheet
.
addCell
(
new
Label
(
4
,
j
+
1
,
jo
.
getString
(
"MaterialUnit"
)));
sheet
.
addCell
(
new
Label
(
5
,
j
+
1
,
jo
.
getString
(
"UnitPrice"
)));
sheet
.
addCell
(
new
Label
(
6
,
j
+
1
,
jo
.
getString
(
"prevSum"
)));
sheet
.
addCell
(
new
Label
(
7
,
j
+
1
,
jo
.
getString
(
"InSum"
)));
sheet
.
addCell
(
new
Label
(
8
,
j
+
1
,
jo
.
getString
(
"OutSum"
)));
sheet
.
addCell
(
new
Label
(
9
,
j
+
1
,
jo
.
getString
(
"thisSum"
)));
double
d
=
Double
.
parseDouble
(
jo
.
getString
(
"thisAllPrice"
).
toString
());
String
s1
=
String
.
format
(
"%.2f"
,
d
);
sheet
.
addCell
(
new
Label
(
10
,
j
+
1
,
s1
));
}
}
workbook
.
write
();
workbook
.
close
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常"
,
e
);
}
}
/**
* 生成excel表格
*
* @param os
*/
@SuppressWarnings
(
"deprecation"
)
private
void
putDataOnOutputStream
(
OutputStream
os
,
JSONArray
dataArray
)
{
WritableWorkbook
workbook
=
null
;
try
{
workbook
=
Workbook
.
createWorkbook
(
os
);
WritableSheet
sheet
=
workbook
.
createSheet
(
"进销存报表"
,
0
);
//增加列头
int
[]
colunmWidth
=
{
10
,
10
,
10
,
10
,
10
,
10
,
15
,
15
,
15
,
15
,
15
};
String
[]
colunmName
=
{
"名称"
,
"型号"
,
"规格"
,
"颜色"
,
"单位"
,
"单价"
,
"上月结存数量"
,
"入库数量"
,
"出库数量"
,
"本月结存数量"
,
"结存金额"
};
for
(
int
i
=
0
;
i
<
colunmWidth
.
length
;
i
++)
{
sheet
.
setColumnView
(
i
,
colunmWidth
[
i
]);
sheet
.
addCell
(
new
Label
(
i
,
0
,
colunmName
[
i
]));
}
if
(
null
!=
dataArray
&&
dataArray
.
size
()
>
0
)
{
for
(
int
j
=
0
;
j
<
dataArray
.
size
();
j
++)
{
JSONObject
jo
=
JSONObject
.
fromObject
(
dataArray
.
get
(
j
));
sheet
.
addCell
(
new
Label
(
0
,
j
+
1
,
jo
.
getString
(
"MaterialName"
)));
sheet
.
addCell
(
new
Label
(
1
,
j
+
1
,
jo
.
getString
(
"MaterialModel"
)));
sheet
.
addCell
(
new
Label
(
2
,
j
+
1
,
jo
.
getString
(
"MaterialStandard"
)));
sheet
.
addCell
(
new
Label
(
3
,
j
+
1
,
jo
.
getString
(
"MaterialColor"
)));
sheet
.
addCell
(
new
Label
(
4
,
j
+
1
,
jo
.
getString
(
"MaterialUnit"
)));
sheet
.
addCell
(
new
Label
(
5
,
j
+
1
,
jo
.
getString
(
"UnitPrice"
)));
sheet
.
addCell
(
new
Label
(
6
,
j
+
1
,
jo
.
getString
(
"prevSum"
)));
sheet
.
addCell
(
new
Label
(
7
,
j
+
1
,
jo
.
getString
(
"InSum"
)));
sheet
.
addCell
(
new
Label
(
8
,
j
+
1
,
jo
.
getString
(
"OutSum"
)));
sheet
.
addCell
(
new
Label
(
9
,
j
+
1
,
jo
.
getString
(
"thisSum"
)));
double
d
=
Double
.
parseDouble
(
jo
.
getString
(
"thisAllPrice"
).
toString
());
String
s1
=
String
.
format
(
"%.2f"
,
d
);
sheet
.
addCell
(
new
Label
(
10
,
j
+
1
,
s1
));
}
}
workbook
.
write
();
workbook
.
close
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常"
,
e
);
}
}
}
src/main/java/com/jsh/service/materials/MaterialCategoryIService.java
View file @
7a436d1c
...
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseIService
;
import
com.jsh.model.po.MaterialCategory
;
public
interface
MaterialCategoryIService
extends
BaseIService
<
MaterialCategory
>
{
public
interface
MaterialCategoryIService
extends
BaseIService
<
MaterialCategory
>
{
}
src/main/java/com/jsh/service/materials/MaterialCategoryService.java
View file @
7a436d1c
...
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
import
com.jsh.dao.materials.MaterialCategoryIDAO
;
import
com.jsh.model.po.MaterialCategory
;
public
class
MaterialCategoryService
extends
BaseService
<
MaterialCategory
>
implements
MaterialCategoryIService
{
@SuppressWarnings
(
"unused"
)
private
MaterialCategoryIDAO
materialCategoryDao
;
public
class
MaterialCategoryService
extends
BaseService
<
MaterialCategory
>
implements
MaterialCategoryIService
{
@SuppressWarnings
(
"unused"
)
private
MaterialCategoryIDAO
materialCategoryDao
;
public
void
setMaterialCategoryDao
(
MaterialCategoryIDAO
materialCategoryDao
)
{
this
.
materialCategoryDao
=
materialCategoryDao
;
}
public
void
setMaterialCategoryDao
(
MaterialCategoryIDAO
materialCategoryDao
)
{
this
.
materialCategoryDao
=
materialCategoryDao
;
}
@Override
protected
Class
<
MaterialCategory
>
getEntityClass
()
{
return
MaterialCategory
.
class
;
}
@Override
protected
Class
<
MaterialCategory
>
getEntityClass
()
{
return
MaterialCategory
.
class
;
}
}
src/main/java/com/jsh/service/materials/MaterialIService.java
View file @
7a436d1c
...
...
@@ -8,13 +8,12 @@ import com.jsh.util.PageUtil;
import
java.io.File
;
import
java.io.InputStream
;
public
interface
MaterialIService
extends
BaseIService
<
Material
>
{
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
);
public
interface
MaterialIService
extends
BaseIService
<
Material
>
{
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
);
public
void
findUnitName
(
PageUtil
<
Material
>
material
,
Long
mId
)
throws
JshException
;
public
void
findUnitName
(
PageUtil
<
Material
>
material
,
Long
mId
)
throws
JshException
;
public
InputStream
exmportExcel
(
String
isAllPage
,
PageUtil
<
Material
>
pageUtil
)
throws
JshException
;
public
InputStream
exmportExcel
(
String
isAllPage
,
PageUtil
<
Material
>
pageUtil
)
throws
JshException
;
public
InputStream
importExcel
(
File
materialFile
)
throws
JshException
;
public
InputStream
importExcel
(
File
materialFile
)
throws
JshException
;
}
src/main/java/com/jsh/service/materials/MaterialPropertyIService.java
View file @
7a436d1c
...
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseIService
;
import
com.jsh.model.po.MaterialProperty
;
public
interface
MaterialPropertyIService
extends
BaseIService
<
MaterialProperty
>
{
public
interface
MaterialPropertyIService
extends
BaseIService
<
MaterialProperty
>
{
}
src/main/java/com/jsh/service/materials/MaterialPropertyService.java
View file @
7a436d1c
...
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
import
com.jsh.dao.materials.MaterialPropertyIDAO
;
import
com.jsh.model.po.MaterialProperty
;
public
class
MaterialPropertyService
extends
BaseService
<
MaterialProperty
>
implements
MaterialPropertyIService
{
@SuppressWarnings
(
"unused"
)
private
MaterialPropertyIDAO
materialPropertyDao
;
public
class
MaterialPropertyService
extends
BaseService
<
MaterialProperty
>
implements
MaterialPropertyIService
{
@SuppressWarnings
(
"unused"
)
private
MaterialPropertyIDAO
materialPropertyDao
;
public
void
setMaterialPropertyDao
(
MaterialPropertyIDAO
materialPropertyDao
)
{
this
.
materialPropertyDao
=
materialPropertyDao
;
}
public
void
setMaterialPropertyDao
(
MaterialPropertyIDAO
materialPropertyDao
)
{
this
.
materialPropertyDao
=
materialPropertyDao
;
}
@Override
protected
Class
<
MaterialProperty
>
getEntityClass
()
{
return
MaterialProperty
.
class
;
}
@Override
protected
Class
<
MaterialProperty
>
getEntityClass
()
{
return
MaterialProperty
.
class
;
}
}
src/main/java/com/jsh/service/materials/MaterialService.java
View file @
7a436d1c
...
...
@@ -21,305 +21,284 @@ import java.io.*;
import
java.lang.Boolean
;
import
java.util.*
;
public
class
MaterialService
extends
BaseService
<
Material
>
implements
MaterialIService
{
@SuppressWarnings
(
"unused"
)
private
MaterialIDAO
materialDao
;
public
class
MaterialService
extends
BaseService
<
Material
>
implements
MaterialIService
{
/**
* 初始化加载所有系统基础数据
*/
@SuppressWarnings
({
"rawtypes"
})
private
static
Map
<
String
,
List
>
mapData
=
new
HashMap
<
String
,
List
>();
/**
* 错误的表格数据
*/
private
static
List
<
Material
>
wrongData
=
new
ArrayList
<
Material
>();
@SuppressWarnings
(
"unused"
)
private
MaterialIDAO
materialDao
;
public
void
setMaterialDao
(
MaterialIDAO
materialDao
)
{
this
.
materialDao
=
materialDao
;
}
public
void
setMaterialDao
(
MaterialIDAO
materialDao
)
{
this
.
materialDao
=
materialDao
;
}
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
){
materialDao
.
batchSetEnable
(
enable
,
supplierIDs
);
}
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
)
{
materialDao
.
batchSetEnable
(
enable
,
supplierIDs
);
}
@Override
public
void
findUnitName
(
PageUtil
<
Material
>
pageUtil
,
Long
mId
)
throws
JshException
{
materialDao
.
findUnitName
(
pageUtil
,
mId
);
}
@Override
public
void
findUnitName
(
PageUtil
<
Material
>
pageUtil
,
Long
mId
)
throws
JshException
{
materialDao
.
findUnitName
(
pageUtil
,
mId
);
}
@Override
protected
Class
<
Material
>
getEntityClass
()
{
return
Material
.
class
;
}
@Override
protected
Class
<
Material
>
getEntityClass
()
{
return
Material
.
class
;
}
/**
* 导出Excel表格
*/
@Override
public
InputStream
exmportExcel
(
String
isAllPage
,
PageUtil
<
Material
>
pageUtil
)
throws
JshException
{
try
{
//将OutputStream转化为InputStream
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
putDataOnOutputStream
(
out
,
pageUtil
.
getPageList
());
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
throw
new
JshException
(
"导出信息为excel表格异常"
,
e
);
}
}
/**
* 初始化加载所有系统基础数据
*/
@SuppressWarnings
({
"rawtypes"
})
private
static
Map
<
String
,
List
>
mapData
=
new
HashMap
<
String
,
List
>();
/**
* 生成excel表格
*
* @param os
*/
@SuppressWarnings
(
"deprecation"
)
private
void
putDataOnOutputStream
(
OutputStream
os
,
List
<
Material
>
dataList
)
{
WritableWorkbook
workbook
=
null
;
try
{
workbook
=
Workbook
.
createWorkbook
(
os
);
WritableSheet
sheet
=
workbook
.
createSheet
(
"信息报表"
,
0
);
//增加列头
String
[]
colunmName
=
{
"品名"
,
"类型"
,
"型号"
,
"安全存量"
,
"单位"
,
"零售价"
,
"最低售价"
,
"预计采购价"
,
"批发价"
,
"备注"
,
"状态"
};
for
(
int
i
=
0
;
i
<
colunmName
.
length
;
i
++)
{
sheet
.
setColumnView
(
i
,
10
);
sheet
.
addCell
(
new
Label
(
i
,
0
,
colunmName
[
i
]));
}
if
(
null
!=
dataList
&&
dataList
.
size
()
>
0
)
{
int
i
=
1
;
for
(
Material
material
:
dataList
)
{
int
j
=
0
;
Map
<
Integer
,
String
>
cellInfo
=
material
.
getCellInfo
();
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getName
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getMaterialCategory
().
getName
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getModel
()
==
null
?
""
:
material
.
getModel
()));
sheet
.
addCell
(
getLabelInfo
(
cellInfo
,
j
++,
i
,
material
.
getSafetyStock
()
==
null
?
""
:
material
.
getSafetyStock
().
toString
(),
material
));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getUnit
()
==
null
?
""
:
material
.
getUnit
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getRetailPrice
()
==
null
?
""
:
material
.
getRetailPrice
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getLowPrice
()
==
null
?
""
:
material
.
getLowPrice
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getPresetPriceOne
()
==
null
?
""
:
material
.
getPresetPriceOne
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getPresetPriceTwo
()
==
null
?
""
:
material
.
getPresetPriceTwo
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getRemark
()
==
null
?
""
:
material
.
getRemark
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getEnabled
()
?
"启用"
:
"禁用"
));
i
++;
}
}
workbook
.
write
();
workbook
.
close
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
}
}
/**
* 错误的表格数据
*/
private
static
List
<
Material
>
wrongData
=
new
ArrayList
<
Material
>();
/**
* 导出Excel表格
*/
@Override
public
InputStream
exmportExcel
(
String
isAllPage
,
PageUtil
<
Material
>
pageUtil
)
throws
JshException
{
try
{
//将OutputStream转化为InputStream
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
putDataOnOutputStream
(
out
,
pageUtil
.
getPageList
());
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
throw
new
JshException
(
"导出信息为excel表格异常"
,
e
);
}
}
/**
* 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误
*
* @param cellInfo
* @param cellNum
* @param columnNum
* @param value
* @return
*/
private
Label
getLabelInfo
(
Map
<
Integer
,
String
>
cellInfo
,
int
cellNum
,
int
columnNum
,
String
value
,
Material
material
)
{
Label
label
=
null
;
/**
* 生成excel表格
* @param os
*/
@SuppressWarnings
(
"deprecation"
)
private
void
putDataOnOutputStream
(
OutputStream
os
,
List
<
Material
>
dataList
)
{
WritableWorkbook
workbook
=
null
;
try
{
workbook
=
Workbook
.
createWorkbook
(
os
);
WritableSheet
sheet
=
workbook
.
createSheet
(
"信息报表"
,
0
);
//增加列头
String
[]
colunmName
=
{
"品名"
,
"类型"
,
"型号"
,
"安全存量"
,
"单位"
,
"零售价"
,
"最低售价"
,
"预计采购价"
,
"批发价"
,
"备注"
,
"状态"
};
for
(
int
i
=
0
;
i
<
colunmName
.
length
;
i
++)
{
sheet
.
setColumnView
(
i
,
10
);
sheet
.
addCell
(
new
Label
(
i
,
0
,
colunmName
[
i
]));
}
if
(
null
!=
dataList
&&
dataList
.
size
()
>
0
)
{
int
i
=
1
;
for
(
Material
material:
dataList
){
int
j
=
0
;
Map
<
Integer
,
String
>
cellInfo
=
material
.
getCellInfo
();
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getName
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getMaterialCategory
().
getName
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getModel
()
==
null
?
""
:
material
.
getModel
()));
sheet
.
addCell
(
getLabelInfo
(
cellInfo
,
j
++,
i
,
material
.
getSafetyStock
()
==
null
?
""
:
material
.
getSafetyStock
().
toString
(),
material
));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getUnit
()
==
null
?
""
:
material
.
getUnit
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getRetailPrice
()
==
null
?
""
:
material
.
getRetailPrice
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getLowPrice
()
==
null
?
""
:
material
.
getLowPrice
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getPresetPriceOne
()
==
null
?
""
:
material
.
getPresetPriceOne
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getPresetPriceTwo
()
==
null
?
""
:
material
.
getPresetPriceTwo
().
toString
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getRemark
()
==
null
?
""
:
material
.
getRemark
()));
sheet
.
addCell
(
new
Label
(
j
++,
i
,
material
.
getEnabled
()?
"启用"
:
"禁用"
));
i
++;
}
}
workbook
.
write
();
workbook
.
close
();
}
catch
(
Exception
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
}
}
//设置背景颜色
WritableCellFormat
cellFormat
=
new
WritableCellFormat
();
try
{
cellFormat
.
setBackground
(
Colour
.
RED
);
}
catch
(
WriteException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误"
,
e
);
}
/**
* 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误
* @param cellInfo
* @param cellNum
* @param columnNum
* @param value
* @return
*/
private
Label
getLabelInfo
(
Map
<
Integer
,
String
>
cellInfo
,
int
cellNum
,
int
columnNum
,
String
value
,
Material
material
)
{
Label
label
=
null
;
if
(
null
==
cellInfo
||
cellInfo
.
size
()
==
0
)
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
}
else
{
//表示此单元格有错误
if
(
cellInfo
.
containsKey
(
cellNum
))
{
if
(
cellNum
==
MaterialConstants
.
BusinessForExcel
.
EXCEL_SAFETY_STOCK
)
{
label
=
new
Label
(
cellNum
,
columnNum
,
material
.
getSafetyStockStr
(),
cellFormat
);
}
}
else
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
}
}
return
label
;
}
//设置背景颜色
WritableCellFormat
cellFormat
=
new
WritableCellFormat
();
try
{
cellFormat
.
setBackground
(
Colour
.
RED
);
}
catch
(
WriteException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误"
,
e
);
}
@Override
public
InputStream
importExcel
(
File
materialFile
)
throws
JshException
{
//全局变量--每次调用前需要清空数据
mapData
.
clear
();
//2、解析文件成资产数据
parseFile
(
materialFile
);
if
(
null
==
cellInfo
||
cellInfo
.
size
()
==
0
)
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
}
else
{
//表示此单元格有错误
if
(
cellInfo
.
containsKey
(
cellNum
))
{
if
(
cellNum
==
MaterialConstants
.
BusinessForExcel
.
EXCEL_SAFETY_STOCK
)
{
label
=
new
Label
(
cellNum
,
columnNum
,
material
.
getSafetyStockStr
(),
cellFormat
);
}
}
else
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
}
}
return
label
;
}
if
(
null
!=
wrongData
&&
wrongData
.
size
()
>
0
)
{
//将OutputStream转化为InputStream
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
putDataOnOutputStream
(
out
,
wrongData
);
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
else
{
return
null
;
}
}
@Override
public
InputStream
importExcel
(
File
materialFile
)
throws
JshException
{
//全局变量--每次调用前需要清空数据
mapData
.
clear
();
//2、解析文件成资产数据
parseFile
(
materialFile
);
if
(
null
!=
wrongData
&&
wrongData
.
size
()>
0
)
{
//将OutputStream转化为InputStream
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
putDataOnOutputStream
(
out
,
wrongData
);
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
else
{
return
null
;
}
}
/**
* 解析excel表格
*
* @param assetFile
*/
@SuppressWarnings
(
"unchecked"
)
private
void
parseFile
(
File
assetFile
)
{
//每次调用前清空
wrongData
.
clear
();
int
totalRow
=
0
;
try
{
//创建对Excel工作簿文件的引用
HSSFWorkbook
workbook
=
new
HSSFWorkbook
(
new
FileInputStream
(
assetFile
));
//创建对工作表的引用,获取第一个工作表的内容
HSSFSheet
sheet
=
workbook
.
getSheetAt
(
0
);
/**
* =====================================
* 1、此处要增加文件的验证,如果不是资产文件需要进行特殊的处理,13列
* 2、文件内容为空处理
* 3、如果是修改过的文件内容
*/
Iterator
<
Row
>
itsheet
=
sheet
.
rowIterator
();
while
(
itsheet
.
hasNext
())
{
//获取当前行数据
Row
row
=
itsheet
.
next
();
//excel表格第几行数据 从1开始 0 是表头
int
rowNum
=
row
.
getRowNum
();
/**
* 表头跳过不读
*/
if
(
MaterialConstants
.
BusinessForExcel
.
EXCEL_TABLE_HEAD
==
rowNum
)
continue
;
/**
* 解析excel表格
* @param assetFile
*/
@SuppressWarnings
(
"unchecked"
)
private
void
parseFile
(
File
assetFile
)
{
//每次调用前清空
wrongData
.
clear
();
int
totalRow
=
0
;
try
{
//创建对Excel工作簿文件的引用
HSSFWorkbook
workbook
=
new
HSSFWorkbook
(
new
FileInputStream
(
assetFile
));
//创建对工作表的引用,获取第一个工作表的内容
HSSFSheet
sheet
=
workbook
.
getSheetAt
(
0
);
/**
* =====================================
* 1、此处要增加文件的验证,如果不是资产文件需要进行特殊的处理,13列
* 2、文件内容为空处理
* 3、如果是修改过的文件内容
*/
Iterator
<
Row
>
itsheet
=
sheet
.
rowIterator
();
while
(
itsheet
.
hasNext
())
{
//获取当前行数据
Row
row
=
itsheet
.
next
();
//开始处理excel表格内容 --每行数据读取,同时统计总共行数
totalRow
++;
//excel表格第几行数据 从1开始 0 是表头
int
rowNum
=
row
.
getRowNum
();
/**
* 表头跳过不读
*/
if
(
MaterialConstants
.
BusinessForExcel
.
EXCEL_TABLE_HEAD
==
rowNum
)
continue
;
//获取excel表格的每格数据内容
Iterator
<
Cell
>
it
=
row
.
cellIterator
();
//资产子类型--添加了一些excel表格数据
Material
material
=
new
Material
();
//保存每个单元格错误类型
Map
<
Integer
,
String
>
cellType
=
new
HashMap
<
Integer
,
String
>();
//设置列号
material
.
setRowLineNum
(
rowNum
);
//开始处理excel表格内容 --每行数据读取,同时统计总共行数
totalRow
++;
Cell
cell
=
null
;
//判断列号--从零开始
int
cellIndex
=
0
;
while
(
it
.
hasNext
())
{
//获取每个单元格对象
cell
=
it
.
next
();
//获取列号
cellIndex
=
cell
.
getColumnIndex
();
//设置此单元格为字符串类型
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
//获取excel表格的每格数据内容
Iterator
<
Cell
>
it
=
row
.
cellIterator
();
//资产子类型--添加了一些excel表格数据
Material
material
=
new
Material
();
//保存每个单元格错误类型
Map
<
Integer
,
String
>
cellType
=
new
HashMap
<
Integer
,
String
>();
//设置列号
material
.
setRowLineNum
(
rowNum
);
Log
.
infoFileSync
(
"==================excel表格中第"
+
totalRow
+
"行的第 "
+
cellIndex
+
"列的值为"
+
cell
.
getStringCellValue
());
Cell
cell
=
null
;
//判断列号--从零开始
int
cellIndex
=
0
;
while
(
it
.
hasNext
())
{
//获取每个单元格对象
cell
=
it
.
next
();
//获取列号
cellIndex
=
cell
.
getColumnIndex
();
//设置此单元格为字符串类型
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
//每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"
switch
(
cellIndex
)
{
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_NAME
:
String
materialName
=
cell
.
getStringCellValue
();
if
(
null
==
materialName
||
""
.
equals
(
materialName
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(品名)信息"
);
break
;
}
material
.
setName
(
materialName
);
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_CATEGORY
:
String
category
=
cell
.
getStringCellValue
();
if
(
null
==
category
||
""
.
equals
(
category
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(类型)信息"
);
break
;
}
material
.
setMaterialCategory
(
new
MaterialCategory
(
1
l
));
//根目录
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_MODEL
:
String
model
=
cell
.
getStringCellValue
();
if
(
null
==
model
||
""
.
equals
(
model
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(型号)信息"
);
break
;
}
material
.
setModel
(
model
);
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_SAFETY_STOCK
:
String
safetyStock
=
cell
.
getStringCellValue
();
if
(
null
==
safetyStock
||
""
.
equals
(
safetyStock
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(安全存量)信息"
);
break
;
}
if
(
Tools
.
checkStrIsNum
(
safetyStock
))
{
material
.
setSafetyStock
(
Double
.
parseDouble
(
safetyStock
));
}
else
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>(安全存量)不是数字格式"
);
cellType
.
put
(
cellIndex
,
"wrong"
);
material
.
setSafetyStock
(
0.00d
);
material
.
setSafetyStockStr
(
safetyStock
);
}
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_UNIT
:
String
unit
=
cell
.
getStringCellValue
();
if
(
null
==
unit
||
""
.
equals
(
unit
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(单位)信息"
);
break
;
}
material
.
setUnit
(
unit
);
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_REMARK
:
String
remark
=
cell
.
getStringCellValue
();
if
(
null
==
remark
||
""
.
equals
(
remark
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(备注)信息"
);
break
;
}
material
.
setRemark
(
remark
);
break
;
}
}
material
.
setCellInfo
(
cellType
);
Log
.
infoFileSync
(
"==================excel表格中第"
+
totalRow
+
"行
的第
"
+
cellIndex
+
"列
的值为"
+
cell
.
getStringCellValue
()
);
Log
.
infoFileSync
(
totalRow
+
"行
总共有
"
+
cellIndex
+
"列
"
);
//每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"
switch
(
cellIndex
)
{
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_NAME
:
String
materialName
=
cell
.
getStringCellValue
();
if
(
null
==
materialName
||
""
.
equals
(
materialName
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(品名)信息"
);
break
;
}
material
.
setName
(
materialName
);
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_CATEGORY
:
String
category
=
cell
.
getStringCellValue
();
if
(
null
==
category
||
""
.
equals
(
category
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(类型)信息"
);
break
;
}
material
.
setMaterialCategory
(
new
MaterialCategory
(
1
l
));
//根目录
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_MODEL
:
String
model
=
cell
.
getStringCellValue
();
if
(
null
==
model
||
""
.
equals
(
model
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(型号)信息"
);
break
;
}
material
.
setModel
(
model
);
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_SAFETY_STOCK
:
String
safetyStock
=
cell
.
getStringCellValue
();
if
(
null
==
safetyStock
||
""
.
equals
(
safetyStock
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(安全存量)信息"
);
break
;
}
if
(
Tools
.
checkStrIsNum
(
safetyStock
))
{
material
.
setSafetyStock
(
Double
.
parseDouble
(
safetyStock
));
}
else
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>(安全存量)不是数字格式"
);
cellType
.
put
(
cellIndex
,
"wrong"
);
material
.
setSafetyStock
(
0.00d
);
material
.
setSafetyStockStr
(
safetyStock
);
}
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_UNIT
:
String
unit
=
cell
.
getStringCellValue
();
if
(
null
==
unit
||
""
.
equals
(
unit
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(单位)信息"
);
break
;
}
material
.
setUnit
(
unit
);
break
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_REMARK
:
String
remark
=
cell
.
getStringCellValue
();
if
(
null
==
remark
||
""
.
equals
(
remark
))
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(备注)信息"
);
break
;
}
material
.
setRemark
(
remark
);
break
;
}
}
material
.
setCellInfo
(
cellType
);
Log
.
infoFileSync
(
totalRow
+
"行总共有"
+
cellIndex
+
"列"
);
//判断完成后增加数据
if
((
null
!=
cellType
&&
cellType
.
size
()
>
0
)
||
material
.
getName
()
==
null
)
{
wrongData
.
add
(
material
);
}
else
{
material
.
setEnabled
(
true
);
materialDao
.
save
(
material
);
}
}
}
catch
(
FileNotFoundException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!"
,
e
);
}
catch
(
IOException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !"
,
e
);
}
Log
.
infoFileSync
(
"===================excel表格总共有 "
+
totalRow
+
" 条记录!"
);
}
//判断完成后增加数据
if
((
null
!=
cellType
&&
cellType
.
size
()
>
0
)
||
material
.
getName
()
==
null
)
{
wrongData
.
add
(
material
);
}
else
{
material
.
setEnabled
(
true
);
materialDao
.
save
(
material
);
}
}
}
catch
(
FileNotFoundException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!"
,
e
);
}
catch
(
IOException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !"
,
e
);
}
Log
.
infoFileSync
(
"===================excel表格总共有 "
+
totalRow
+
" 条记录!"
);
}
}
src/main/java/com/jsh/service/materials/PersonIService.java
View file @
7a436d1c
...
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseIService
;
import
com.jsh.model.po.Person
;
public
interface
PersonIService
extends
BaseIService
<
Person
>
{
public
interface
PersonIService
extends
BaseIService
<
Person
>
{
}
src/main/java/com/jsh/service/materials/PersonService.java
View file @
7a436d1c
...
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
import
com.jsh.dao.materials.PersonIDAO
;
import
com.jsh.model.po.Person
;
public
class
PersonService
extends
BaseService
<
Person
>
implements
PersonIService
{
@SuppressWarnings
(
"unused"
)
private
PersonIDAO
personDao
;
public
class
PersonService
extends
BaseService
<
Person
>
implements
PersonIService
{
@SuppressWarnings
(
"unused"
)
private
PersonIDAO
personDao
;
public
void
setPersonDao
(
PersonIDAO
personDao
)
{
this
.
personDao
=
personDao
;
}
public
void
setPersonDao
(
PersonIDAO
personDao
)
{
this
.
personDao
=
personDao
;
}
@Override
protected
Class
<
Person
>
getEntityClass
()
{
return
Person
.
class
;
}
@Override
protected
Class
<
Person
>
getEntityClass
()
{
return
Person
.
class
;
}
}
src/main/java/com/jsh/util/AssetConstants.java
View file @
7a436d1c
...
...
@@ -2,26 +2,26 @@ package com.jsh.util;
/**
* 定义资产管理常量
*
* @author jishenghua
*/
public
interface
AssetConstants
{
public
interface
AssetConstants
{
/**
* 公共常量
*
* @author jishenghua
*/
public
class
Common
{
public
class
Common
{
}
/**
* 资产常量--导入导出excel表格业务相关
*
* @author jishenghua
*/
public
class
BusinessForExcel
{
public
class
BusinessForExcel
{
/**
* 资产名称常量
*/
...
...
@@ -65,17 +65,17 @@ public interface AssetConstants
/**
* 序列号
*/
public
static
final
int
EXCEL_SERIALNO
=
8
;
public
static
final
int
EXCEL_SERIALNO
=
8
;
/**
* 有效日期
*/
public
static
final
int
EXCEL_EXPIRATION_DATE
=
9
;
public
static
final
int
EXCEL_EXPIRATION_DATE
=
9
;
/**
* 保修日期
*/
public
static
final
int
EXCEL_WARRANTY_DATE
=
10
;
public
static
final
int
EXCEL_WARRANTY_DATE
=
10
;
/**
* 供应商
...
...
@@ -116,6 +116,6 @@ public interface AssetConstants
* action返回excel结果
*/
public
static
final
String
EXCEL
=
"excel"
;
}
}
src/main/java/com/jsh/util/BeanFactoryUtil.java
View file @
7a436d1c
package
com.jsh.util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.context.support.FileSystemXmlApplicationContext
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 获取spring配置中的bean对象,是单例,只会加载一次,请注意使用
* 注意:此工具类默认处理UI组件WEB-INF目录下的applicationContext.xml配置文件,请注意文件 名和路径
*
@author jishenghua
* @
qq 7 5 2 7 1 8 9 2 0
*
* @
author jishenghua
* @version V1.0
* @qq 7 5 2 7 1 8 9 2 0
*/
public
class
BeanFactoryUtil
{
public
class
BeanFactoryUtil
{
private
static
BeanFactoryUtil
defaultBeanFactory
;
private
ApplicationContext
defaultAC
=
null
;
//private ApplicationContext autoLoadAC = null;
private
static
BeanFactoryUtil
specialBeanFactory
;
private
ApplicationContext
specialAC
=
null
;
//private ApplicationContext autoLoadAC = null;
private
static
Map
<
String
,
ApplicationContext
>
beanMap
=
new
HashMap
<
String
,
ApplicationContext
>();
private
ApplicationContext
defaultAC
=
null
;
private
ApplicationContext
specialAC
=
null
;
//private Logger log = Logger.getLogger(BeanFactoryUtil.class);
/**
* 私有构造函数,默认为UI组件WEB-INF目录下的applicationContext.xml配置文件
*/
private
BeanFactoryUtil
()
{
private
BeanFactoryUtil
()
{
String
fileUrl
=
PathTool
.
getWebinfPath
();
//这里只对UI组件WEB-INF目录下的applicationContext.xml配置文件
defaultAC
=
new
FileSystemXmlApplicationContext
(
new
String
[]{
fileUrl
+
"spring/basic-applicationContext.xml"
,
fileUrl
+
"spring/dao-applicationContext.xml"
});
defaultAC
=
new
FileSystemXmlApplicationContext
(
new
String
[]{
fileUrl
+
"spring/basic-applicationContext.xml"
,
fileUrl
+
"spring/dao-applicationContext.xml"
});
}
/**
* 私有构造函数,带有文件的classpath路径,可能是非applicationContext.xml文件
*/
private
BeanFactoryUtil
(
String
fileClassPath
)
{
private
BeanFactoryUtil
(
String
fileClassPath
)
{
specialAC
=
new
ClassPathXmlApplicationContext
(
"classpath:"
+
fileClassPath
);
}
/**
* 非web.xml方式加载spring配置文件方式的实体实例获取方式
*
* @param fileClassPath
* @param beanName
* @return
* @return
*/
public
synchronized
static
Object
getBeanByClassPathAndBeanName
(
String
fileClassPath
,
String
beanName
)
{
String
fileClassPath
,
String
beanName
)
{
ApplicationContext
ac
=
beanMap
.
get
(
fileClassPath
);
if
(
null
==
ac
)
{
if
(
null
==
ac
)
{
ac
=
new
ClassPathXmlApplicationContext
(
"classpath:"
+
fileClassPath
);
beanMap
.
put
(
fileClassPath
,
ac
);
}
return
ac
.
getBean
(
beanName
);
}
/**
* 获取类实例
* 默认加载UI组件WEB-INF目录下的applicationContext.xml配置文件
* @return
*
* @return
*/
public
synchronized
static
BeanFactoryUtil
getInstance
()
{
if
(
null
==
defaultBeanFactory
)
{
public
synchronized
static
BeanFactoryUtil
getInstance
()
{
if
(
null
==
defaultBeanFactory
)
{
defaultBeanFactory
=
new
BeanFactoryUtil
();
}
return
defaultBeanFactory
;
}
/**
* 获取类实例,这种情况一定是在依赖其他组件时没有在applicationContext.xml加载器spring文件时使用
* 这种情况请少用
*
* @param fileClassPath
* @return
* @return
*/
@Deprecated
public
synchronized
static
BeanFactoryUtil
getInstance
(
String
fileClassPath
)
{
if
(
null
==
specialBeanFactory
)
{
public
synchronized
static
BeanFactoryUtil
getInstance
(
String
fileClassPath
)
{
if
(
null
==
specialBeanFactory
)
{
specialBeanFactory
=
new
BeanFactoryUtil
(
fileClassPath
);
}
return
specialBeanFactory
;
}
/**
* 获取UI组件WEB-INF目录下的applicationContext.xml配置文件中配置的bean实例
*
* @param beanName
* @return
* @return
*/
public
Object
getBean
(
String
beanName
)
{
public
Object
getBean
(
String
beanName
)
{
return
defaultAC
.
getBean
(
beanName
);
}
/**
* 获取没有在applicationContext.xml配置文件中引入的spring配置文件,即没有用容器加载过的配置文件
* 这里为特殊情况下使用,不推荐使用
* 推荐在applicationContext.xml配置文件中引入需要使用的spring配置文件,然后使用BeanFactoryUtil.getInstance().getBean("")方法
*
* @param beanName
* @return
* @return
*/
@Deprecated
public
Object
getSpecialBean
(
String
beanName
)
{
public
Object
getSpecialBean
(
String
beanName
)
{
return
specialAC
.
getBean
(
beanName
);
}
}
src/main/java/com/jsh/util/ExceptionCodeConstants.java
View file @
7a436d1c
package
com.jsh.util
;
public
interface
ExceptionCodeConstants
{
public
interface
ExceptionCodeConstants
{
/**
* 用户错误码定义
*/
public
class
UserExceptionCode
{
public
class
UserExceptionCode
{
/**
* 用户不存在
*/
...
...
Prev
1
…
6
7
8
9
10
11
12
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