Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王夏晖
zhny
Commits
a95c4f3d
Commit
a95c4f3d
authored
May 31, 2018
by
王夏晖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备巡检功能修改完善
parent
785b568b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
122 additions
and
9 deletions
+122
-9
BusDeviceController.java
...usiness/device/assets/controller/BusDeviceController.java
+6
-0
BusDeviceRepository.java
...isoft/business/device/assets/dao/BusDeviceRepository.java
+2
-1
BusDeviceService.java
...soft/business/device/assets/service/BusDeviceService.java
+7
-0
BusDeviceServiceImpl.java
...ness/device/assets/service/impl/BusDeviceServiceImpl.java
+30
-0
InspectionController.java
...ss/device/inspection/controller/InspectionController.java
+65
-4
InspectionRepository.java
.../business/device/inspection/dao/InspectionRepository.java
+1
-1
InspectionService.java
...business/device/inspection/service/InspectionService.java
+1
-1
InspectionServiceImpl.java
...device/inspection/service/impl/InspectionServiceImpl.java
+9
-2
inspectionMapper.xml
...sources/mapper/sys/device/inspection/inspectionMapper.xml
+1
-0
No files found.
src/main/java/org/rcisoft/business/device/assets/controller/BusDeviceController.java
View file @
a95c4f3d
...
@@ -181,4 +181,10 @@ public class BusDeviceController extends PaginationController<BusDevice> {
...
@@ -181,4 +181,10 @@ public class BusDeviceController extends PaginationController<BusDevice> {
busDeviceServiceImpl
.
downloadExcel
(
response
,
list
);
busDeviceServiceImpl
.
downloadExcel
(
response
,
list
);
}
}
@ApiOperation
(
value
=
"生成设备二维码"
,
notes
=
"生成设备二维码"
)
@RequestMapping
(
"/generateCode"
)
public
Result
generateCode
(
@RequestParam
String
devNum
)
{
return
Result
.
builder
(
busDeviceServiceImpl
.
generateCode
(
devNum
));
}
}
}
src/main/java/org/rcisoft/business/device/assets/dao/BusDeviceRepository.java
View file @
a95c4f3d
...
@@ -25,7 +25,8 @@ public interface BusDeviceRepository extends BaseMapper<BusDevice> {
...
@@ -25,7 +25,8 @@ public interface BusDeviceRepository extends BaseMapper<BusDevice> {
" where 1=1"
+
" where 1=1"
+
"<if test='proId != null'> and a.pro_id = #{proId}</if>"
+
"<if test='proId != null'> and a.pro_id = #{proId}</if>"
+
"<if test='devTpId != null'> and a.dev_tp_id = #{devTpId}</if>"
+
"<if test='devTpId != null'> and a.dev_tp_id = #{devTpId}</if>"
+
"<if test='devNum != null'> and a.dev_num = #{devNum}</if>"
"<if test='devNum != null'> and a.dev_num = #{devNum}</if>"
+
"<if test='qrcodeUrl != null'> and a.qrcode_url is not null</if>"
+
"</script>"
)
+
"</script>"
)
List
<
Map
<
String
,
Object
>>
queryBusDevices
(
BusDevice
busDevice
);
List
<
Map
<
String
,
Object
>>
queryBusDevices
(
BusDevice
busDevice
);
...
...
src/main/java/org/rcisoft/business/device/assets/service/BusDeviceService.java
View file @
a95c4f3d
...
@@ -90,4 +90,11 @@ public interface BusDeviceService {
...
@@ -90,4 +90,11 @@ public interface BusDeviceService {
* @param response
* @param response
*/
*/
void
downloadExcel
(
HttpServletResponse
response
,
List
<
DeviceParamsVo
>
list
);
void
downloadExcel
(
HttpServletResponse
response
,
List
<
DeviceParamsVo
>
list
);
/**
* 生成设备二维码
* @param devNum 设备编号
* @return
*/
PersistModel
generateCode
(
String
devNum
);
}
}
src/main/java/org/rcisoft/business/device/assets/service/impl/BusDeviceServiceImpl.java
View file @
a95c4f3d
...
@@ -259,6 +259,36 @@ public class BusDeviceServiceImpl implements BusDeviceService {
...
@@ -259,6 +259,36 @@ public class BusDeviceServiceImpl implements BusDeviceService {
}
}
}
}
@Override
public
PersistModel
generateCode
(
String
devNum
)
{
int
line
=
1
;
String
message
=
""
;
boolean
flag
=
busDeviceRepository
.
queryDeviceByDevNum
(
devNum
)!=
null
&&
busDeviceRepository
.
queryDeviceByDevNum
(
devNum
).
size
()>
0
;
if
(!
flag
){
line
=
0
;
message
=
"设备编号不存在,生成失败"
;
}
else
{
// 保存二维码路径(配置的路径+项目编号)
String
path
=
qrcodePath
+
"/"
;
try
{
// 生成二维码(第一个参数(二维码数据):设备编号,第二个参数(保存的路径):保存的路径,第三个参数(文件名):设备id)
QRCodeUtils
.
createQRCodeFile
(
devNum
,
path
,
devNum
);
}
catch
(
WriterException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
Example
example
=
new
Example
(
BusDevice
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"devNum"
,
devNum
);
BusDevice
busDevice
=
new
BusDevice
();
busDevice
.
setDevNum
(
devNum
);
busDevice
.
setQrcodeUrl
(
"/"
+
devNum
+
".JPG"
);
line
=
busDeviceRepository
.
updateByExampleSelective
(
busDevice
,
example
);
}
return
new
PersistModel
(
line
,
message
);
}
private
byte
[]
createExcel
(
List
<
DeviceParamsVo
>
list
)
throws
IOException
{
private
byte
[]
createExcel
(
List
<
DeviceParamsVo
>
list
)
throws
IOException
{
HSSFWorkbook
workbook
=
null
;
HSSFWorkbook
workbook
=
null
;
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
...
...
src/main/java/org/rcisoft/business/device/inspection/controller/InspectionController.java
View file @
a95c4f3d
...
@@ -6,6 +6,8 @@ package org.rcisoft.business.device.inspection.controller;
...
@@ -6,6 +6,8 @@ package org.rcisoft.business.device.inspection.controller;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo
;
import
org.rcisoft.business.device.inspection.service.InspectionService
;
import
org.rcisoft.business.device.inspection.service.InspectionService
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.model.PersistModel
;
...
@@ -13,6 +15,16 @@ import org.rcisoft.core.result.Result;
...
@@ -13,6 +15,16 @@ import org.rcisoft.core.result.Result;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* Created by on 2018-4-18 15:41:54.
* Created by on 2018-4-18 15:41:54.
*/
*/
...
@@ -38,14 +50,63 @@ public class InspectionController {
...
@@ -38,14 +50,63 @@ public class InspectionController {
@ApiOperation
(
value
=
"查询该项目下某个设备的所有巡检记录"
)
@ApiOperation
(
value
=
"查询该项目下某个设备的所有巡检记录"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"varvhar"
),
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"varvhar"
),
@ApiImplicitParam
(
name
=
"devNum"
,
value
=
"设备编号"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"varvhar"
)
@ApiImplicitParam
(
name
=
"devNum"
,
value
=
"设备编号"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"varvhar"
),
@ApiImplicitParam
(
name
=
"mon"
,
value
=
"年月"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"varvhar"
)
})
})
@ResponseBody
@ResponseBody
@GetMapping
(
value
=
"/listAllInspection/{proId}/{devNum}"
)
@GetMapping
(
value
=
"/listAllInspection/{proId}/{devNum}
/{mon}
"
)
public
Result
listAllInspection
(
@PathVariable
(
"proId"
)
String
proId
,
@PathVariable
(
"devNum"
)
String
devNum
){
public
Result
listAllInspection
(
@PathVariable
(
"proId"
)
String
proId
,
@PathVariable
(
"devNum"
)
String
devNum
,
@PathVariable
(
"mon"
)
String
mon
){
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
inspectionService
.
listAllInspectionInfomatinByProIdAndDevNum
(
proId
,
devNum
));
inspectionService
.
listAllInspectionInfomatinByProIdAndDevNum
(
proId
,
devNum
,
mon
));
}
@ApiOperation
(
value
=
"导出单个设备的月巡检记录"
)
@ResponseBody
@RequestMapping
(
value
=
"/exportExcel"
,
method
=
RequestMethod
.
GET
)
public
void
exportExcel
(
HttpServletResponse
response
,
@RequestParam
String
proId
,
@RequestParam
(
"devNum"
)
String
devNum
,
@RequestParam
(
"mon"
)
String
mon
)
throws
UnsupportedEncodingException
{
List
<
Map
<
String
,
Object
>>
deviceList
=
new
ArrayList
<>();
//先获取数据库数据
deviceList
=
inspectionService
.
listAllInspectionInfomatinByProIdAndDevNum
(
proId
,
devNum
,
mon
);
//通过项目id获取对应的名称组拼成文件名
String
filename
=
devNum
+
"-"
+
mon
+
"巡检记录.xls"
;
//创建excel生成对象
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
HSSFSheet
sheet
=
workbook
.
createSheet
(
mon
+
"巡检记录表"
);
//表头内容
String
[]
headers
=
{
"时间"
,
"巡检人"
,
"巡检结果"
};
HSSFRow
row
=
sheet
.
createRow
(
0
);
//在excel表中添加表头
for
(
int
i
=
0
;
i
<
headers
.
length
;
i
++){
HSSFCell
cell
=
row
.
createCell
(
i
);
HSSFRichTextString
text
=
new
HSSFRichTextString
(
headers
[
i
]);
cell
.
setCellValue
(
text
);
}
//日期类型格式化
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
);
//在表中存放查询到的数据放入对应的列
int
rowNum
=
1
;
for
(
Map
<
String
,
Object
>
temp
:
deviceList
)
{
HSSFRow
rowTemp
=
sheet
.
createRow
(
rowNum
);
rowTemp
.
createCell
(
0
).
setCellValue
(
temp
.
get
(
"INSP_TM"
).
toString
());
rowTemp
.
createCell
(
1
).
setCellValue
(
temp
.
get
(
"USER_NICK_NAME"
).
toString
());
rowTemp
.
createCell
(
2
).
setCellValue
(
temp
.
get
(
"INSP_CONTENT"
).
toString
());
rowNum
++;
}
//设置响应头信息
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
filename
,
"utf-8"
));
try
{
OutputStream
outputStream
=
response
.
getOutputStream
();
workbook
.
write
(
outputStream
);
outputStream
.
flush
();
outputStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
src/main/java/org/rcisoft/business/device/inspection/dao/InspectionRepository.java
View file @
a95c4f3d
...
@@ -26,7 +26,7 @@ public interface InspectionRepository {
...
@@ -26,7 +26,7 @@ public interface InspectionRepository {
* @param devNum
* @param devNum
* @return
* @return
*/
*/
List
<
Map
<
String
,
Object
>>
listAllInspectionInfomatinByProIdAndDevNum
(
@Param
(
"proId"
)
String
proId
,
@Param
(
"devNum"
)
String
devNum
);
List
<
Map
<
String
,
Object
>>
listAllInspectionInfomatinByProIdAndDevNum
(
@Param
(
"proId"
)
String
proId
,
@Param
(
"devNum"
)
String
devNum
,
@Param
(
"mon"
)
String
mon
);
...
...
src/main/java/org/rcisoft/business/device/inspection/service/InspectionService.java
View file @
a95c4f3d
...
@@ -20,7 +20,7 @@ public interface InspectionService {
...
@@ -20,7 +20,7 @@ public interface InspectionService {
* @param devNum
* @param devNum
* @return
* @return
*/
*/
List
<
Map
<
String
,
Object
>>
listAllInspectionInfomatinByProIdAndDevNum
(
String
proId
,
String
devNum
);
List
<
Map
<
String
,
Object
>>
listAllInspectionInfomatinByProIdAndDevNum
(
String
proId
,
String
devNum
,
String
mon
);
...
...
src/main/java/org/rcisoft/business/device/inspection/service/impl/InspectionServiceImpl.java
View file @
a95c4f3d
package
org
.
rcisoft
.
business
.
device
.
inspection
.
service
.
impl
;
package
org
.
rcisoft
.
business
.
device
.
inspection
.
service
.
impl
;
import
freemarker.template.SimpleDate
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.business.device.inspection.dao.InspectionRepository
;
import
org.rcisoft.business.device.inspection.dao.InspectionRepository
;
import
org.rcisoft.business.device.inspection.service.InspectionService
;
import
org.rcisoft.business.device.inspection.service.InspectionService
;
...
@@ -9,6 +10,8 @@ import org.springframework.stereotype.Service;
...
@@ -9,6 +10,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -30,7 +33,11 @@ public class InspectionServiceImpl implements InspectionService {
...
@@ -30,7 +33,11 @@ public class InspectionServiceImpl implements InspectionService {
}
}
@Override
@Override
public
List
<
Map
<
String
,
Object
>>
listAllInspectionInfomatinByProIdAndDevNum
(
String
proId
,
String
devNum
)
{
public
List
<
Map
<
String
,
Object
>>
listAllInspectionInfomatinByProIdAndDevNum
(
String
proId
,
String
devNum
,
String
mon
)
{
return
inspectionRepository
.
listAllInspectionInfomatinByProIdAndDevNum
(
proId
,
devNum
);
if
(
mon
==
null
||
mon
.
equals
(
""
)){
SimpleDateFormat
simple
=
new
SimpleDateFormat
(
"yyyy-MM"
);
mon
=
simple
.
format
(
new
Date
());
}
return
inspectionRepository
.
listAllInspectionInfomatinByProIdAndDevNum
(
proId
,
devNum
,
mon
);
}
}
}
}
src/main/resources/mapper/sys/device/inspection/inspectionMapper.xml
View file @
a95c4f3d
...
@@ -36,5 +36,6 @@
...
@@ -36,5 +36,6 @@
LEFT JOIN sys_user su ON su.OPENID = bdi.INSPECTOR
LEFT JOIN sys_user su ON su.OPENID = bdi.INSPECTOR
WHERE
WHERE
bd.PRO_ID = #{proId} AND bd.DEV_NUM = #{devNum}
bd.PRO_ID = #{proId} AND bd.DEV_NUM = #{devNum}
AND DATE_FORMAT (bdi.INSP_TM,'%Y-%m') = #{mon}
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
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