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
07259995
Commit
07259995
authored
Apr 07, 2018
by
AlanGao
Browse files
update
parent
458409b4
Changes
205
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/service/materials/AccountItemService.java
View file @
07259995
package
com.jsh.service.materials
;
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.BaseService
;
import
com.jsh.base.Log
;
import
com.jsh.util.AssetConstants
;
import
com.jsh.dao.materials.AccountItemIDAO
;
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.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"
)
@SuppressWarnings
(
"unused"
)
private
AccountItemIDAO
accoumtItemDao
;
private
AccountItemIDAO
accoumtItemDao
;
...
@@ -29,8 +15,7 @@ public class AccountItemService extends BaseService<AccountItem> implements Acco
...
@@ -29,8 +15,7 @@ public class AccountItemService extends BaseService<AccountItem> implements Acco
@Override
@Override
protected
Class
<
AccountItem
>
getEntityClass
()
protected
Class
<
AccountItem
>
getEntityClass
()
{
{
return
AccountItem
.
class
;
return
AccountItem
.
class
;
}
}
...
...
src/main/java/com/jsh/service/materials/DepotHeadIService.java
View file @
07259995
package
com.jsh.service.materials
;
package
com.jsh.service.materials
;
import
com.jsh.base.BaseIService
;
import
com.jsh.base.BaseIService
;
import
com.jsh.util.JshException
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.model.po.DepotHead
;
import
com.jsh.
model.po.UserBusiness
;
import
com.jsh.
util.JshException
;
import
com.jsh.util.PageUtil
;
import
com.jsh.util.PageUtil
;
public
interface
DepotHeadIService
extends
BaseIService
<
DepotHead
>
public
interface
DepotHeadIService
extends
BaseIService
<
DepotHead
>
{
{
/*
/*
* 获取MaxId
* 获取MaxId
*/
*/
void
find
(
PageUtil
<
DepotHead
>
depotHead
,
String
maxid
)
throws
JshException
;
void
find
(
PageUtil
<
DepotHead
>
depotHead
,
String
maxid
)
throws
JshException
;
void
findAllMoney
(
PageUtil
<
DepotHead
>
depotHead
,
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
)
throws
JshException
;
void
findAllMoney
(
PageUtil
<
DepotHead
>
depotHead
,
Integer
supplierId
,
String
type
,
String
subType
,
String
mode
)
throws
JshException
;
void
batchSetStatus
(
Boolean
status
,
String
depotHeadIDs
);
void
batchSetStatus
(
Boolean
status
,
String
depotHeadIDs
);
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
;
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
;
void
findMaterialsListByHeaderId
(
PageUtil
pageUtil
,
Long
headerId
)
throws
JshException
;
void
findMaterialsListByHeaderId
(
PageUtil
pageUtil
,
Long
headerId
)
throws
JshException
;
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
;
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/DepotItemIService.java
View file @
07259995
package
com.jsh.service.materials
;
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.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.model.po.DepotItem
;
import
com.jsh.util.JshException
;
import
com.jsh.util.PageUtil
;
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
findByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
depotItem
,
String
type
,
Long
MId
)
throws
JshException
;
{
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
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
*
*/
* @return
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
;
*/
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
;
}
}
src/main/java/com/jsh/service/materials/DepotItemService.java
View file @
07259995
package
com.jsh.service.materials
;
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.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.text.DecimalFormat
;
import
java.util.List
;
import
java.util.Map
;
import
net.sf.json.JSONArray
;
public
class
DepotItemService
extends
BaseService
<
DepotItem
>
implements
DepotItemIService
{
import
net.sf.json.JSONObject
;
@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
;
public
void
setDepotItemDao
(
DepotItemIDAO
depotItemDao
)
{
import
com.jsh.base.Log
;
this
.
depotItemDao
=
depotItemDao
;
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
class
DepotItemService
extends
BaseService
<
DepotItem
>
implements
DepotItemIService
{
@SuppressWarnings
(
"unused"
)
private
DepotItemIDAO
depotItemDao
;
@Override
public
void
setDepotItemDao
(
DepotItemIDAO
depotItemDao
)
{
protected
Class
<
DepotItem
>
getEntityClass
()
{
this
.
depotItemDao
=
depotItemDao
;
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
@Override
public
void
findByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
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
);
depotItemDao
.
findByType
(
pageUtil
,
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
}
}
@Override
@Override
public
void
findByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Long
MId
)
throws
JshException
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
);
depotItemDao
.
findByTypeAndMaterialId
(
pageUtil
,
type
,
MId
);
}
}
@Override
@Override
public
void
findDetailByTypeAndMaterialId
(
PageUtil
<
DepotItem
>
pageUtil
,
Long
MId
)
throws
JshException
public
void
findGiftByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
subType
,
Integer
ProjectId
,
Long
MId
,
String
type
)
throws
JshException
{
{
depotItemDao
.
findGiftByType
(
pageUtil
,
subType
,
ProjectId
,
MId
,
type
);
depotItemDao
.
findDetailByTypeAndMaterialId
(
pageUtil
,
MId
);
}
}
@Override
/**
public
void
findPriceByType
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
Integer
ProjectId
,
Long
MId
,
String
MonthTime
,
Boolean
isPrev
)
throws
JshException
* 导出Excel表格
{
*/
depotItemDao
.
findPriceByType
(
pageUtil
,
type
,
ProjectId
,
MId
,
MonthTime
,
isPrev
);
}
@Override
@Override
public
void
buyOrSale
(
PageUtil
<
DepotItem
>
pageUtil
,
String
type
,
String
subType
,
Long
MId
,
String
MonthTime
,
String
sumType
)
throws
JshException
public
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
{
{
try
{
depotItemDao
.
buyOrSale
(
pageUtil
,
type
,
subType
,
MId
,
MonthTime
,
sumType
);
//将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
* 生成excel表格
{
*
depotItemDao
.
findGiftByType
(
pageUtil
,
subType
,
ProjectId
,
MId
,
type
);
* @param os
}
*/
@SuppressWarnings
(
"deprecation"
)
/**
private
void
putDataOnOutputStream
(
OutputStream
os
,
JSONArray
dataArray
)
{
* 导出Excel表格
WritableWorkbook
workbook
=
null
;
*/
try
{
@Override
workbook
=
Workbook
.
createWorkbook
(
os
);
public
InputStream
exmportExcel
(
String
isAllPage
,
JSONArray
dataArray
)
throws
JshException
WritableSheet
sheet
=
workbook
.
createSheet
(
"进销存报表"
,
0
);
{
//增加列头
try
int
[]
colunmWidth
=
{
10
,
10
,
10
,
10
,
10
,
10
,
15
,
15
,
15
,
15
,
15
};
{
String
[]
colunmName
=
{
"名称"
,
"型号"
,
"规格"
,
"颜色"
,
"单位"
,
"单价"
,
"上月结存数量"
,
"入库数量"
,
"出库数量"
,
"本月结存数量"
,
"结存金额"
};
//将OutputStream转化为InputStream
for
(
int
i
=
0
;
i
<
colunmWidth
.
length
;
i
++)
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
sheet
.
setColumnView
(
i
,
colunmWidth
[
i
]);
putDataOnOutputStream
(
out
,
dataArray
);
sheet
.
addCell
(
new
Label
(
i
,
0
,
colunmName
[
i
]));
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
}
}
if
(
null
!=
dataArray
&&
dataArray
.
size
()
>
0
)
{
catch
(
Exception
e
)
for
(
int
j
=
0
;
j
<
dataArray
.
size
();
j
++)
{
{
JSONObject
jo
=
JSONObject
.
fromObject
(
dataArray
.
get
(
j
));
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常"
,
e
);
sheet
.
addCell
(
new
Label
(
0
,
j
+
1
,
jo
.
getString
(
"MaterialName"
)));
throw
new
JshException
(
"export asset info to excel exception"
,
e
);
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"
)));
* 生成excel表格
sheet
.
addCell
(
new
Label
(
6
,
j
+
1
,
jo
.
getString
(
"prevSum"
)));
* @param os
sheet
.
addCell
(
new
Label
(
7
,
j
+
1
,
jo
.
getString
(
"InSum"
)));
*/
sheet
.
addCell
(
new
Label
(
8
,
j
+
1
,
jo
.
getString
(
"OutSum"
)));
@SuppressWarnings
(
"deprecation"
)
sheet
.
addCell
(
new
Label
(
9
,
j
+
1
,
jo
.
getString
(
"thisSum"
)));
private
void
putDataOnOutputStream
(
OutputStream
os
,
JSONArray
dataArray
)
double
d
=
Double
.
parseDouble
(
jo
.
getString
(
"thisAllPrice"
).
toString
());
{
String
s1
=
String
.
format
(
"%.2f"
,
d
);
WritableWorkbook
workbook
=
null
;
sheet
.
addCell
(
new
Label
(
10
,
j
+
1
,
s1
));
try
}
{
}
workbook
=
Workbook
.
createWorkbook
(
os
);
workbook
.
write
();
WritableSheet
sheet
=
workbook
.
createSheet
(
"进销存报表"
,
0
);
workbook
.
close
();
//增加列头
}
catch
(
Exception
e
)
{
int
[]
colunmWidth
=
{
10
,
10
,
10
,
10
,
10
,
10
,
15
,
15
,
15
,
15
,
15
};
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常"
,
e
);
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 @
07259995
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseIService
;
import
com.jsh.base.BaseIService
;
import
com.jsh.model.po.MaterialCategory
;
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 @
07259995
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
import
com.jsh.dao.materials.MaterialCategoryIDAO
;
import
com.jsh.dao.materials.MaterialCategoryIDAO
;
import
com.jsh.model.po.MaterialCategory
;
import
com.jsh.model.po.MaterialCategory
;
public
class
MaterialCategoryService
extends
BaseService
<
MaterialCategory
>
implements
MaterialCategoryIService
public
class
MaterialCategoryService
extends
BaseService
<
MaterialCategory
>
implements
MaterialCategoryIService
{
{
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
MaterialCategoryIDAO
materialCategoryDao
;
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 @
07259995
...
@@ -8,13 +8,12 @@ import com.jsh.util.PageUtil;
...
@@ -8,13 +8,12 @@ import com.jsh.util.PageUtil;
import
java.io.File
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStream
;
public
interface
MaterialIService
extends
BaseIService
<
Material
>
public
interface
MaterialIService
extends
BaseIService
<
Material
>
{
{
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
);
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 @
07259995
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseIService
;
import
com.jsh.base.BaseIService
;
import
com.jsh.model.po.MaterialProperty
;
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 @
07259995
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
import
com.jsh.dao.materials.MaterialPropertyIDAO
;
import
com.jsh.dao.materials.MaterialPropertyIDAO
;
import
com.jsh.model.po.MaterialProperty
;
import
com.jsh.model.po.MaterialProperty
;
public
class
MaterialPropertyService
extends
BaseService
<
MaterialProperty
>
implements
MaterialPropertyIService
public
class
MaterialPropertyService
extends
BaseService
<
MaterialProperty
>
implements
MaterialPropertyIService
{
{
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
MaterialPropertyIDAO
materialPropertyDao
;
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 @
07259995
...
@@ -21,305 +21,284 @@ import java.io.*;
...
@@ -21,305 +21,284 @@ import java.io.*;
import
java.lang.Boolean
;
import
java.lang.Boolean
;
import
java.util.*
;
import
java.util.*
;
public
class
MaterialService
extends
BaseService
<
Material
>
implements
MaterialIService
public
class
MaterialService
extends
BaseService
<
Material
>
implements
MaterialIService
{
{
/**
@SuppressWarnings
(
"unused"
)
* 初始化加载所有系统基础数据
private
MaterialIDAO
materialDao
;
*/
@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
)
{
public
void
setMaterialDao
(
MaterialIDAO
materialDao
)
{
this
.
materialDao
=
materialDao
;
this
.
materialDao
=
materialDao
;
}
}
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
){
public
void
batchSetEnable
(
Boolean
enable
,
String
supplierIDs
)
{
materialDao
.
batchSetEnable
(
enable
,
supplierIDs
);
materialDao
.
batchSetEnable
(
enable
,
supplierIDs
);
}
}
@Override
public
void
findUnitName
(
PageUtil
<
Material
>
pageUtil
,
Long
mId
)
throws
JshException
{
materialDao
.
findUnitName
(
pageUtil
,
mId
);
}
@Override
@Override
public
void
findUnitName
(
PageUtil
<
Material
>
pageUtil
,
Long
mId
)
throws
JshException
protected
Class
<
Material
>
getEntityClass
()
{
{
return
Material
.
class
;
materialDao
.
findUnitName
(
pageUtil
,
mId
);
}
}
@Override
/**
protected
Class
<
Material
>
getEntityClass
()
* 导出Excel表格
{
*/
return
Material
.
class
;
@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表格
*/
*
@SuppressWarnings
({
"rawtypes"
})
* @param os
private
static
Map
<
String
,
List
>
mapData
=
new
HashMap
<
String
,
List
>();
*/
@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
);
}
}
/**
/**
* 错误的表格数据
* 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误
*/
*
private
static
List
<
Material
>
wrongData
=
new
ArrayList
<
Material
>();
* @param cellInfo
/**
* @param cellNum
* 导出Excel表格
* @param columnNum
*/
* @param value
@Override
* @return
public
InputStream
exmportExcel
(
String
isAllPage
,
PageUtil
<
Material
>
pageUtil
)
throws
JshException
*/
{
private
Label
getLabelInfo
(
Map
<
Integer
,
String
>
cellInfo
,
int
cellNum
,
int
columnNum
,
String
value
,
Material
material
)
{
try
Label
label
=
null
;
{
//将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表格
WritableCellFormat
cellFormat
=
new
WritableCellFormat
();
* @param os
try
{
*/
cellFormat
.
setBackground
(
Colour
.
RED
);
@SuppressWarnings
(
"deprecation"
)
}
catch
(
WriteException
e
)
{
private
void
putDataOnOutputStream
(
OutputStream
os
,
List
<
Material
>
dataList
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误"
,
e
);
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
);
}
}
/**
if
(
null
==
cellInfo
||
cellInfo
.
size
()
==
0
)
{
* 根据错误信息进行提示--excel表格背景设置为红色,表示导入信息有误
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
* @param cellInfo
}
else
{
* @param cellNum
//表示此单元格有错误
* @param columnNum
if
(
cellInfo
.
containsKey
(
cellNum
))
{
* @param value
if
(
cellNum
==
MaterialConstants
.
BusinessForExcel
.
EXCEL_SAFETY_STOCK
)
{
* @return
label
=
new
Label
(
cellNum
,
columnNum
,
material
.
getSafetyStockStr
(),
cellFormat
);
*/
}
private
Label
getLabelInfo
(
Map
<
Integer
,
String
>
cellInfo
,
int
cellNum
,
int
columnNum
,
String
value
,
Material
material
)
}
else
{
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
Label
label
=
null
;
}
}
return
label
;
}
//设置背景颜色
@Override
WritableCellFormat
cellFormat
=
new
WritableCellFormat
();
public
InputStream
importExcel
(
File
materialFile
)
throws
JshException
{
try
//全局变量--每次调用前需要清空数据
{
mapData
.
clear
();
cellFormat
.
setBackground
(
Colour
.
RED
);
//2、解析文件成资产数据
}
parseFile
(
materialFile
);
catch
(
WriteException
e
)
{
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误"
,
e
);
}
if
(
null
==
cellInfo
||
cellInfo
.
size
()
==
0
)
{
if
(
null
!=
wrongData
&&
wrongData
.
size
()
>
0
)
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
//将OutputStream转化为InputStream
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
else
{
putDataOnOutputStream
(
out
,
wrongData
);
//表示此单元格有错误
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
if
(
cellInfo
.
containsKey
(
cellNum
))
{
}
else
{
if
(
cellNum
==
MaterialConstants
.
BusinessForExcel
.
EXCEL_SAFETY_STOCK
)
{
return
null
;
label
=
new
Label
(
cellNum
,
columnNum
,
material
.
getSafetyStockStr
(),
cellFormat
);
}
}
}
}
else
{
label
=
new
Label
(
cellNum
,
columnNum
,
value
);
}
}
return
label
;
}
@Override
public
InputStream
importExcel
(
File
materialFile
)
throws
JshException
{
//全局变量--每次调用前需要清空数据
mapData
.
clear
();
//2、解析文件成资产数据
parseFile
(
materialFile
);
if
(
null
!=
wrongData
&&
wrongData
.
size
()>
0
)
{
/**
//将OutputStream转化为InputStream
* 解析excel表格
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
*
putDataOnOutputStream
(
out
,
wrongData
);
* @param assetFile
return
new
ByteArrayInputStream
(
out
.
toByteArray
());
*/
}
@SuppressWarnings
(
"unchecked"
)
else
{
private
void
parseFile
(
File
assetFile
)
{
return
null
;
//每次调用前清空
}
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表格内容 --每行数据读取,同时统计总共行数
* 解析excel表格
totalRow
++;
* @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 是表头
//获取excel表格的每格数据内容
int
rowNum
=
row
.
getRowNum
();
Iterator
<
Cell
>
it
=
row
.
cellIterator
();
/**
//资产子类型--添加了一些excel表格数据
* 表头跳过不读
Material
material
=
new
Material
();
*/
//保存每个单元格错误类型
if
(
MaterialConstants
.
BusinessForExcel
.
EXCEL_TABLE_HEAD
==
rowNum
)
Map
<
Integer
,
String
>
cellType
=
new
HashMap
<
Integer
,
String
>();
continue
;
//设置列号
material
.
setRowLineNum
(
rowNum
);
//开始处理excel表格内容 --每行数据读取,同时统计总共行数
Cell
cell
=
null
;
totalRow
++;
//判断列号--从零开始
int
cellIndex
=
0
;
while
(
it
.
hasNext
())
{
//获取每个单元格对象
cell
=
it
.
next
();
//获取列号
cellIndex
=
cell
.
getColumnIndex
();
//设置此单元格为字符串类型
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
//获取excel表格的每格数据内容
Log
.
infoFileSync
(
"==================excel表格中第"
+
totalRow
+
"行的第 "
+
cellIndex
+
"列的值为"
+
cell
.
getStringCellValue
());
Iterator
<
Cell
>
it
=
row
.
cellIterator
();
//资产子类型--添加了一些excel表格数据
Material
material
=
new
Material
();
//保存每个单元格错误类型
Map
<
Integer
,
String
>
cellType
=
new
HashMap
<
Integer
,
String
>();
//设置列号
material
.
setRowLineNum
(
rowNum
);
Cell
cell
=
null
;
//每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"
//判断列号--从零开始
switch
(
cellIndex
)
{
int
cellIndex
=
0
;
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_NAME
:
while
(
it
.
hasNext
())
{
String
materialName
=
cell
.
getStringCellValue
();
//获取每个单元格对象
if
(
null
==
materialName
||
""
.
equals
(
materialName
))
{
cell
=
it
.
next
();
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(品名)信息"
);
//获取列号
break
;
cellIndex
=
cell
.
getColumnIndex
();
}
//设置此单元格为字符串类型
material
.
setName
(
materialName
);
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
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
)
{
if
((
null
!=
cellType
&&
cellType
.
size
()
>
0
)
||
material
.
getName
()
==
null
)
{
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_NAME
:
wrongData
.
add
(
material
);
String
materialName
=
cell
.
getStringCellValue
();
}
else
{
if
(
null
==
materialName
||
""
.
equals
(
materialName
))
{
material
.
setEnabled
(
true
);
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(品名)信息"
);
materialDao
.
save
(
material
);
break
;
}
}
}
material
.
setName
(
materialName
);
}
catch
(
FileNotFoundException
e
)
{
break
;
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!"
,
e
);
case
MaterialConstants
.
BusinessForExcel
.
EXCEL_CATEGORY
:
}
catch
(
IOException
e
)
{
String
category
=
cell
.
getStringCellValue
();
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !"
,
e
);
if
(
null
==
category
||
""
.
equals
(
category
))
{
}
Log
.
errorFileSync
(
">>>>>>>>>>>>>>>>列表没有填写(类型)信息"
);
Log
.
infoFileSync
(
"===================excel表格总共有 "
+
totalRow
+
" 条记录!"
);
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
+
" 条记录!"
);
}
}
}
src/main/java/com/jsh/service/materials/PersonIService.java
View file @
07259995
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
...
@@ -3,7 +3,6 @@ package com.jsh.service.materials;
import
com.jsh.base.BaseIService
;
import
com.jsh.base.BaseIService
;
import
com.jsh.model.po.Person
;
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 @
07259995
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
...
@@ -4,21 +4,19 @@ import com.jsh.base.BaseService;
import
com.jsh.dao.materials.PersonIDAO
;
import
com.jsh.dao.materials.PersonIDAO
;
import
com.jsh.model.po.Person
;
import
com.jsh.model.po.Person
;
public
class
PersonService
extends
BaseService
<
Person
>
implements
PersonIService
public
class
PersonService
extends
BaseService
<
Person
>
implements
PersonIService
{
{
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
PersonIDAO
personDao
;
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 @
07259995
...
@@ -2,26 +2,26 @@ package com.jsh.util;
...
@@ -2,26 +2,26 @@ package com.jsh.util;
/**
/**
* 定义资产管理常量
* 定义资产管理常量
*
* @author jishenghua
* @author jishenghua
*/
*/
public
interface
AssetConstants
public
interface
AssetConstants
{
{
/**
/**
* 公共常量
* 公共常量
*
* @author jishenghua
* @author jishenghua
*/
*/
public
class
Common
public
class
Common
{
{
}
}
/**
/**
* 资产常量--导入导出excel表格业务相关
* 资产常量--导入导出excel表格业务相关
*
* @author jishenghua
* @author jishenghua
*/
*/
public
class
BusinessForExcel
public
class
BusinessForExcel
{
{
/**
/**
* 资产名称常量
* 资产名称常量
*/
*/
...
@@ -65,17 +65,17 @@ public interface AssetConstants
...
@@ -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
...
@@ -116,6 +116,6 @@ public interface AssetConstants
* action返回excel结果
* action返回excel结果
*/
*/
public
static
final
String
EXCEL
=
"excel"
;
public
static
final
String
EXCEL
=
"excel"
;
}
}
}
}
src/main/java/com/jsh/util/BeanFactoryUtil.java
View file @
07259995
package
com.jsh.util
;
package
com.jsh.util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.context.support.FileSystemXmlApplicationContext
;
import
org.springframework.context.support.FileSystemXmlApplicationContext
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
/**
* 获取spring配置中的bean对象,是单例,只会加载一次,请注意使用
* 获取spring配置中的bean对象,是单例,只会加载一次,请注意使用
* 注意:此工具类默认处理UI组件WEB-INF目录下的applicationContext.xml配置文件,请注意文件 名和路径
* 注意:此工具类默认处理UI组件WEB-INF目录下的applicationContext.xml配置文件,请注意文件 名和路径
*
@author jishenghua
*
* @
qq 7 5 2 7 1 8 9 2 0
* @
author jishenghua
* @version V1.0
* @version V1.0
* @qq 7 5 2 7 1 8 9 2 0
*/
*/
public
class
BeanFactoryUtil
public
class
BeanFactoryUtil
{
{
private
static
BeanFactoryUtil
defaultBeanFactory
;
private
static
BeanFactoryUtil
defaultBeanFactory
;
private
ApplicationContext
defaultAC
=
null
;
//private ApplicationContext autoLoadAC = null;
private
static
BeanFactoryUtil
specialBeanFactory
;
private
static
BeanFactoryUtil
specialBeanFactory
;
private
ApplicationContext
specialAC
=
null
;
//private ApplicationContext autoLoadAC = null;
private
static
Map
<
String
,
ApplicationContext
>
beanMap
=
new
HashMap
<
String
,
ApplicationContext
>();
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);
//private Logger log = Logger.getLogger(BeanFactoryUtil.class);
/**
/**
* 私有构造函数,默认为UI组件WEB-INF目录下的applicationContext.xml配置文件
* 私有构造函数,默认为UI组件WEB-INF目录下的applicationContext.xml配置文件
*/
*/
private
BeanFactoryUtil
()
private
BeanFactoryUtil
()
{
{
String
fileUrl
=
PathTool
.
getWebinfPath
();
String
fileUrl
=
PathTool
.
getWebinfPath
();
//这里只对UI组件WEB-INF目录下的applicationContext.xml配置文件
//这里只对UI组件WEB-INF目录下的applicationContext.xml配置文件
defaultAC
=
new
FileSystemXmlApplicationContext
(
new
defaultAC
=
new
FileSystemXmlApplicationContext
(
new
String
[]{
fileUrl
String
[]{
fileUrl
+
"spring/basic-applicationContext.xml"
,
+
"spring/basic-applicationContext.xml"
,
fileUrl
+
"spring/dao-applicationContext.xml"
});
fileUrl
+
"spring/dao-applicationContext.xml"
});
}
}
/**
/**
* 私有构造函数,带有文件的classpath路径,可能是非applicationContext.xml文件
* 私有构造函数,带有文件的classpath路径,可能是非applicationContext.xml文件
*/
*/
private
BeanFactoryUtil
(
String
fileClassPath
)
private
BeanFactoryUtil
(
String
fileClassPath
)
{
{
specialAC
=
new
ClassPathXmlApplicationContext
(
"classpath:"
specialAC
=
new
ClassPathXmlApplicationContext
(
"classpath:"
+
fileClassPath
);
+
fileClassPath
);
}
}
/**
/**
* 非web.xml方式加载spring配置文件方式的实体实例获取方式
* 非web.xml方式加载spring配置文件方式的实体实例获取方式
*
* @param fileClassPath
* @param fileClassPath
* @param beanName
* @param beanName
* @return
* @return
*/
*/
public
synchronized
static
Object
getBeanByClassPathAndBeanName
(
public
synchronized
static
Object
getBeanByClassPathAndBeanName
(
String
fileClassPath
,
String
beanName
)
String
fileClassPath
,
String
beanName
)
{
{
ApplicationContext
ac
=
beanMap
.
get
(
fileClassPath
);
ApplicationContext
ac
=
beanMap
.
get
(
fileClassPath
);
if
(
null
==
ac
)
if
(
null
==
ac
)
{
{
ac
=
new
ClassPathXmlApplicationContext
(
"classpath:"
ac
=
new
ClassPathXmlApplicationContext
(
"classpath:"
+
fileClassPath
);
+
fileClassPath
);
beanMap
.
put
(
fileClassPath
,
ac
);
beanMap
.
put
(
fileClassPath
,
ac
);
}
}
return
ac
.
getBean
(
beanName
);
return
ac
.
getBean
(
beanName
);
}
}
/**
/**
* 获取类实例
* 获取类实例
* 默认加载UI组件WEB-INF目录下的applicationContext.xml配置文件
* 默认加载UI组件WEB-INF目录下的applicationContext.xml配置文件
* @return
*
*
* @return
*/
*/
public
synchronized
static
BeanFactoryUtil
getInstance
()
public
synchronized
static
BeanFactoryUtil
getInstance
()
{
{
if
(
null
==
defaultBeanFactory
)
{
if
(
null
==
defaultBeanFactory
)
{
defaultBeanFactory
=
new
BeanFactoryUtil
();
defaultBeanFactory
=
new
BeanFactoryUtil
();
}
}
return
defaultBeanFactory
;
return
defaultBeanFactory
;
}
}
/**
/**
* 获取类实例,这种情况一定是在依赖其他组件时没有在applicationContext.xml加载器spring文件时使用
* 获取类实例,这种情况一定是在依赖其他组件时没有在applicationContext.xml加载器spring文件时使用
* 这种情况请少用
* 这种情况请少用
*
* @param fileClassPath
* @param fileClassPath
* @return
* @return
*/
*/
@Deprecated
@Deprecated
public
synchronized
static
BeanFactoryUtil
getInstance
(
String
fileClassPath
)
public
synchronized
static
BeanFactoryUtil
getInstance
(
String
fileClassPath
)
{
{
if
(
null
==
specialBeanFactory
)
{
if
(
null
==
specialBeanFactory
)
{
specialBeanFactory
=
new
BeanFactoryUtil
(
fileClassPath
);
specialBeanFactory
=
new
BeanFactoryUtil
(
fileClassPath
);
}
}
return
specialBeanFactory
;
return
specialBeanFactory
;
}
}
/**
/**
* 获取UI组件WEB-INF目录下的applicationContext.xml配置文件中配置的bean实例
* 获取UI组件WEB-INF目录下的applicationContext.xml配置文件中配置的bean实例
*
* @param beanName
* @param beanName
* @return
* @return
*/
*/
public
Object
getBean
(
String
beanName
)
public
Object
getBean
(
String
beanName
)
{
{
return
defaultAC
.
getBean
(
beanName
);
return
defaultAC
.
getBean
(
beanName
);
}
}
/**
/**
* 获取没有在applicationContext.xml配置文件中引入的spring配置文件,即没有用容器加载过的配置文件
* 获取没有在applicationContext.xml配置文件中引入的spring配置文件,即没有用容器加载过的配置文件
* 这里为特殊情况下使用,不推荐使用
* 这里为特殊情况下使用,不推荐使用
* 推荐在applicationContext.xml配置文件中引入需要使用的spring配置文件,然后使用BeanFactoryUtil.getInstance().getBean("")方法
* 推荐在applicationContext.xml配置文件中引入需要使用的spring配置文件,然后使用BeanFactoryUtil.getInstance().getBean("")方法
*
* @param beanName
* @param beanName
* @return
* @return
*/
*/
@Deprecated
@Deprecated
public
Object
getSpecialBean
(
String
beanName
)
public
Object
getSpecialBean
(
String
beanName
)
{
{
return
specialAC
.
getBean
(
beanName
);
return
specialAC
.
getBean
(
beanName
);
}
}
}
}
src/main/java/com/jsh/util/ExceptionCodeConstants.java
View file @
07259995
package
com.jsh.util
;
package
com.jsh.util
;
public
interface
ExceptionCodeConstants
public
interface
ExceptionCodeConstants
{
{
/**
/**
* 用户错误码定义
* 用户错误码定义
*/
*/
public
class
UserExceptionCode
public
class
UserExceptionCode
{
{
/**
/**
* 用户不存在
* 用户不存在
*/
*/
...
...
src/main/java/com/jsh/util/JshConstants.java
View file @
07259995
package
com.jsh.util
;
package
com.jsh.util
;
public
interface
JshConstants
public
interface
JshConstants
{
{
/**
/**
* 定义资产管理公共常量
* 定义资产管理公共常量
*
* @author jishenghua
* @author jishenghua
*/
*/
public
class
Common
public
class
Common
{
{
/**
/**
* Info级别日志前缀
* Info级别日志前缀
*/
*/
...
@@ -19,17 +18,17 @@ public interface JshConstants
...
@@ -19,17 +18,17 @@ public interface JshConstants
public
static
final
String
LOG_ERROR_PREFIX
=
">>>>>>>>>>"
;
public
static
final
String
LOG_ERROR_PREFIX
=
">>>>>>>>>>"
;
/**
/**
*
debug级别日志前缀
* debug级别日志前缀
*/
*/
public
static
final
String
LOG_DEBUG_PREFIX
=
"-----------"
;
public
static
final
String
LOG_DEBUG_PREFIX
=
"-----------"
;
/**
/**
*
fatal级别日志前缀
* fatal级别日志前缀
*/
*/
public
static
final
String
LOG_FATAL_PREFIX
=
"$$$$$$$$$$"
;
public
static
final
String
LOG_FATAL_PREFIX
=
"$$$$$$$$$$"
;
/**
/**
*
warn级别日志前缀
* warn级别日志前缀
*/
*/
public
static
final
String
LOG_WARN_PREFIX
=
"##########"
;
public
static
final
String
LOG_WARN_PREFIX
=
"##########"
;
}
}
...
...
src/main/java/com/jsh/util/JshException.java
View file @
07259995
package
com.jsh.util
;
package
com.jsh.util
;
/**
/**
* @title: 平台异常基类
* @description: 用于包装一些异常信息,打印日志等服务
* @author jishenghua
* @author jishenghua
* @title: 平台异常基类
* @description: 用于包装一些异常信息,打印日志等服务
* @qq 7 5 2 7 1 8 9 2 0
* @qq 7 5 2 7 1 8 9 2 0
* @since: 2014-02-24
* @since: 2014-02-24
*/
*/
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
JshException
extends
Exception
public
class
JshException
extends
Exception
{
{
public
long
errorCode
=
-
1
;
public
long
errorCode
=
-
1
;
public
String
message
;
public
String
message
;
public
JshException
()
public
JshException
()
{
{
super
();
super
();
}
}
public
JshException
(
String
message
)
public
JshException
(
String
message
)
{
{
super
(
message
);
super
(
message
);
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
JshException
(
String
message
,
Throwable
cause
)
public
JshException
(
String
message
,
Throwable
cause
)
{
{
super
(
message
,
cause
);
super
(
message
,
cause
);
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
JshException
(
Throwable
cause
)
public
JshException
(
Throwable
cause
)
{
{
super
(
cause
);
super
(
cause
);
}
}
public
JshException
(
long
errorCode
)
public
JshException
(
long
errorCode
)
{
{
super
();
super
();
this
.
errorCode
=
errorCode
;
this
.
errorCode
=
errorCode
;
}
}
public
JshException
(
String
message
,
long
errorCode
)
public
JshException
(
String
message
,
long
errorCode
)
{
{
super
(
message
);
super
(
message
);
this
.
errorCode
=
errorCode
;
this
.
errorCode
=
errorCode
;
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
JshException
(
String
message
,
long
errorCode
,
Throwable
cause
)
public
JshException
(
String
message
,
long
errorCode
,
Throwable
cause
)
{
{
super
(
message
,
cause
);
super
(
message
,
cause
);
this
.
errorCode
=
errorCode
;
this
.
errorCode
=
errorCode
;
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
JshException
(
long
errorCode
,
Throwable
cause
)
public
JshException
(
long
errorCode
,
Throwable
cause
)
{
{
super
(
cause
);
super
(
cause
);
this
.
errorCode
=
errorCode
;
this
.
errorCode
=
errorCode
;
}
}
public
long
getErrorCode
()
public
long
getErrorCode
()
{
{
return
errorCode
;
return
errorCode
;
}
}
public
String
getMessage
()
public
String
getMessage
()
{
{
return
message
;
return
message
;
}
}
}
}
src/main/java/com/jsh/util/MaterialConstants.java
View file @
07259995
...
@@ -2,25 +2,25 @@ package com.jsh.util;
...
@@ -2,25 +2,25 @@ package com.jsh.util;
/**
/**
* 定义商品信息常量
* 定义商品信息常量
*
* @author jishenghua
* @author jishenghua
*/
*/
public
interface
MaterialConstants
public
interface
MaterialConstants
{
{
/**
/**
* 公共常量
* 公共常量
*
* @author ji sheng hua
* @author ji sheng hua
*/
*/
public
class
Common
public
class
Common
{
{
}
}
/**
/**
* 常量--导入导出excel表格业务相关
* 常量--导入导出excel表格业务相关
*
* @author jishenghua
* @author jishenghua
*/
*/
public
class
BusinessForExcel
public
class
BusinessForExcel
{
{
/**
/**
* 名称
* 名称
*/
*/
...
...
src/main/java/com/jsh/util/OpenSessionInViewFilterExtend.java
View file @
07259995
...
@@ -6,19 +6,17 @@ import org.hibernate.SessionFactory;
...
@@ -6,19 +6,17 @@ import org.hibernate.SessionFactory;
import
org.springframework.dao.DataAccessResourceFailureException
;
import
org.springframework.dao.DataAccessResourceFailureException
;
import
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
;
import
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
;
public
class
OpenSessionInViewFilterExtend
extends
OpenSessionInViewFilter
public
class
OpenSessionInViewFilterExtend
extends
OpenSessionInViewFilter
{
{
@Override
@Override
protected
Session
getSession
(
SessionFactory
sessionFactory
)
protected
Session
getSession
(
SessionFactory
sessionFactory
)
throws
DataAccessResourceFailureException
{
throws
DataAccessResourceFailureException
this
.
setFlushMode
(
FlushMode
.
AUTO
);
{
return
super
.
getSession
(
sessionFactory
);
this
.
setFlushMode
(
FlushMode
.
AUTO
);
}
return
super
.
getSession
(
sessionFactory
);
}
@Override
@Override
protected
void
closeSession
(
Session
session
,
SessionFactory
sessionFactory
)
{
protected
void
closeSession
(
Session
session
,
SessionFactory
sessionFactory
)
session
.
flush
();
{
super
.
closeSession
(
session
,
sessionFactory
);
session
.
flush
();
}
super
.
closeSession
(
session
,
sessionFactory
);
}
}
}
src/main/java/com/jsh/util/PageUtil.java
View file @
07259995
...
@@ -5,195 +5,186 @@ import java.util.ArrayList;
...
@@ -5,195 +5,186 @@ import java.util.ArrayList;
import
java.util.Hashtable
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* 分页工具类,实现分页功能
* 分页工具类,实现分页功能
* @author jishenghua
*
* @author jishenghua
* @version [版本号version01, 2014-2-21]
* @qq 7 5 2 7 1 8 9 2 0
* @qq 7 5 2 7 1 8 9 2 0
* @version [版本号version01, 2014-2-21]
*/
*/
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
PageUtil
<
E
>
implements
Serializable
public
class
PageUtil
<
E
>
implements
Serializable
{
{
/**
/**
* 总页数,根据总数和单页显示个数进行计算
* 总页数,根据总数和单页显示个数进行计算
*/
*/
private
int
totalPage
=
0
;
private
int
totalPage
=
0
;
/**
/**
* 总个数
* 总个数
*/
*/
private
int
totalCount
=
0
;
private
int
totalCount
=
0
;
/**
/**
* 当前页码
* 当前页码
*/
*/
private
int
curPage
=
1
;
private
int
curPage
=
1
;
/**
/**
* 每页显示个数
* 每页显示个数
*/
*/
private
int
pageSize
=
10
;
private
int
pageSize
=
10
;
/**
/**
* 是否为第一页
* 是否为第一页
*/
*/
private
boolean
isFirstPage
=
false
;
private
boolean
isFirstPage
=
false
;
/**
/**
* 是否是最后一页
* 是否是最后一页
*/
*/
private
boolean
isLastPage
=
false
;
private
boolean
isLastPage
=
false
;
/**
/**
* 是否有上一页
* 是否有上一页
*/
*/
private
boolean
hasPrevious
=
false
;
private
boolean
hasPrevious
=
false
;
/**
/**
* 是否有下一页
* 是否有下一页
*/
*/
private
boolean
hasNext
=
false
;
private
boolean
hasNext
=
false
;
/**
/**
* 返回页面list数组
* 返回页面list数组
*/
*/
private
List
<
E
>
pageList
=
new
ArrayList
<
E
>();
private
List
<
E
>
pageList
=
new
ArrayList
<
E
>();
/**
/**
* 页面搜索条件,用map来实现
* 页面搜索条件,用map来实现
*/
*/
private
Map
<
String
,
Object
>
advSearch
=
new
Hashtable
<
String
,
Object
>();
private
Map
<
String
,
Object
>
advSearch
=
new
Hashtable
<
String
,
Object
>();
public
PageUtil
()
{
public
PageUtil
()
{
}
}
public
PageUtil
(
int
totalCount
,
int
pageSize
,
int
curPage
,
Map
<
String
,
Object
>
adv
)
{
init
(
totalCount
,
pageSize
,
curPage
,
adv
);
public
PageUtil
(
int
totalCount
,
int
pageSize
,
int
curPage
,
Map
<
String
,
Object
>
adv
)
}
{
init
(
totalCount
,
pageSize
,
curPage
,
adv
);
/**
}
* 初始化页面显示参数
/**
*
* 初始化页面显示参数
* @param totalCount 总数
* @param totalCount 总数
* @param pageSize 页面显示个数
* @param pageSize 页面显示个数
* @param curPage 当前页面
* @param curPage 当前页面
*/
*/
public
void
init
(
int
totalCount
,
int
pageSize
,
int
curPage
,
Map
<
String
,
Object
>
adv
)
{
public
void
init
(
int
totalCount
,
int
pageSize
,
int
curPage
,
Map
<
String
,
Object
>
adv
)
this
.
totalCount
=
totalCount
;
{
this
.
pageSize
=
pageSize
;
this
.
totalCount
=
totalCount
;
this
.
curPage
=
curPage
;
this
.
pageSize
=
pageSize
;
this
.
advSearch
=
adv
;
this
.
curPage
=
curPage
;
//计算总页数
this
.
advSearch
=
adv
;
if
(
pageSize
!=
0
)
{
//计算总页数
this
.
totalPage
=
(
totalCount
+
pageSize
-
1
)
/
pageSize
;
if
(
pageSize
!=
0
)
}
{
if
(
curPage
<
1
)
{
this
.
totalPage
=
(
totalCount
+
pageSize
-
1
)/
pageSize
;
this
.
curPage
=
1
;
}
}
if
(
curPage
<
1
)
if
(
curPage
>
this
.
totalPage
)
{
{
this
.
curPage
=
this
.
totalPage
;
this
.
curPage
=
1
;
}
}
if
(
curPage
>
0
&&
this
.
totalPage
!=
1
&&
curPage
<
this
.
totalPage
)
{
if
(
curPage
>
this
.
totalPage
)
this
.
hasNext
=
true
;
{
}
this
.
curPage
=
this
.
totalPage
;
if
(
curPage
>
0
&&
this
.
totalPage
!=
1
&&
curPage
>
1
&&
curPage
<=
this
.
totalPage
)
{
}
this
.
hasPrevious
=
true
;
if
(
curPage
>
0
&&
this
.
totalPage
!=
1
&&
curPage
<
this
.
totalPage
)
}
{
if
(
curPage
==
1
)
{
this
.
hasNext
=
true
;
this
.
isFirstPage
=
true
;
}
}
if
(
curPage
>
0
&&
this
.
totalPage
!=
1
&&
curPage
>
1
&&
curPage
<=
this
.
totalPage
)
if
(
curPage
==
this
.
totalPage
)
{
{
this
.
isLastPage
=
true
;
this
.
hasPrevious
=
true
;
}
}
}
if
(
curPage
==
1
)
{
public
int
getTotalPage
()
{
this
.
isFirstPage
=
true
;
return
totalPage
;
}
}
if
(
curPage
==
this
.
totalPage
)
{
public
void
setTotalPage
(
int
totalPage
)
{
this
.
isLastPage
=
true
;
this
.
totalPage
=
totalPage
;
}
}
}
public
int
getTotalPage
()
public
int
getTotalCount
()
{
{
return
totalCount
;
return
totalPage
;
}
}
public
void
setTotalPage
(
int
totalPage
)
public
void
setTotalCount
(
int
totalCount
)
{
{
this
.
totalCount
=
totalCount
;
this
.
totalPage
=
totalPage
;
}
}
public
int
getTotalCount
()
public
int
getCurPage
()
{
{
return
curPage
;
return
totalCount
;
}
}
public
void
setTotalCount
(
int
totalCount
)
public
void
setCurPage
(
int
curPage
)
{
{
this
.
curPage
=
curPage
;
this
.
totalCount
=
totalCount
;
}
}
public
int
getCurPage
()
public
int
getPageSize
()
{
{
return
pageSize
;
return
curPage
;
}
}
public
void
setCurPage
(
int
curPage
)
public
void
setPageSize
(
int
pageSize
)
{
{
this
.
pageSize
=
pageSize
;
this
.
curPage
=
curPage
;
}
}
public
int
getPageSize
()
public
boolean
isFirstPage
()
{
{
return
isFirstPage
;
return
pageSize
;
}
}
public
void
setPageSize
(
int
pageSize
)
public
void
setFirstPage
(
boolean
isFirstPage
)
{
{
this
.
isFirstPage
=
isFirstPage
;
this
.
pageSize
=
pageSize
;
}
}
public
boolean
isFirstPage
()
public
boolean
isLastPage
()
{
{
return
isLastPage
;
return
isFirstPage
;
}
}
public
void
setFirstPage
(
boolean
isFirstPage
)
public
void
setLastPage
(
boolean
isLastPage
)
{
{
this
.
isLastPage
=
isLastPage
;
this
.
isFirstPage
=
isFirstPage
;
}
}
public
boolean
isLastPage
()
public
boolean
isHasPrevious
()
{
{
return
hasPrevious
;
return
isLastPage
;
}
}
public
void
setLastPage
(
boolean
isLastPage
)
public
void
setHasPrevious
(
boolean
hasPrevious
)
{
{
this
.
hasPrevious
=
hasPrevious
;
this
.
isLastPage
=
isLastPage
;
}
}
public
boolean
isHasPrevious
()
public
boolean
isHasNext
()
{
{
return
hasNext
;
return
hasPrevious
;
}
}
public
void
setHasPrevious
(
boolean
hasPrevious
)
public
void
setHasNext
(
boolean
hasNext
)
{
{
this
.
hasNext
=
hasNext
;
this
.
hasPrevious
=
hasPrevious
;
}
}
public
boolean
isHasNext
()
public
List
<
E
>
getPageList
()
{
{
return
pageList
;
return
hasNext
;
}
}
public
void
setHasNext
(
boolean
hasNext
)
public
void
setPageList
(
List
<
E
>
pageList
)
{
{
this
.
pageList
=
pageList
;
this
.
hasNext
=
hasNext
;
}
}
public
Map
<
String
,
Object
>
getAdvSearch
()
{
public
List
<
E
>
getPageList
()
return
advSearch
;
{
}
return
pageList
;
}
public
void
setAdvSearch
(
Map
<
String
,
Object
>
advSearch
)
{
public
void
setPageList
(
List
<
E
>
pageList
)
this
.
advSearch
=
advSearch
;
{
}
this
.
pageList
=
pageList
;
}
public
Map
<
String
,
Object
>
getAdvSearch
()
{
return
advSearch
;
}
public
void
setAdvSearch
(
Map
<
String
,
Object
>
advSearch
)
{
this
.
advSearch
=
advSearch
;
}
}
}
Prev
1
…
6
7
8
9
10
11
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