Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
fmboot
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
f744d3f8
由
张雷
编写于
2023-02-15 14:21:47 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
设备台账自定义功能开发
1 个父辈
f6c10862
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
495 行增加
和
0 行删除
fm-product/src/main/java/com/skua/modules/equip/controller/FmEquipInfoController.java
fm-product/src/main/java/com/skua/modules/equip/controller/SysEquipFieldController.java
fm-product/src/main/java/com/skua/modules/equip/entity/SysEquipField.java
fm-product/src/main/java/com/skua/modules/equip/mapper/FmEquipInfoMapper.java
fm-product/src/main/java/com/skua/modules/equip/mapper/SysEquipFieldMapper.java
fm-product/src/main/java/com/skua/modules/equip/mapper/xml/FmEquipInfoMapper.xml
fm-product/src/main/java/com/skua/modules/equip/mapper/xml/SysEquipFieldMapper.xml
fm-product/src/main/java/com/skua/modules/equip/service/IFmEquipInfoService.java
fm-product/src/main/java/com/skua/modules/equip/service/ISysEquipFieldService.java
fm-product/src/main/java/com/skua/modules/equip/service/impl/FmEquipInfoServiceImpl.java
fm-product/src/main/java/com/skua/modules/equip/service/impl/SysEquipFieldServiceImpl.java
fm-product/src/main/java/com/skua/modules/equip/controller/FmEquipInfoController.java
查看文件 @
f744d3f
...
...
@@ -2,6 +2,7 @@ package com.skua.modules.equip.controller;
import
com.skua.core.api.vo.Result
;
import
com.skua.core.aspect.annotation.AutoLog
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.skua.modules.equip.service.IFmEquipInfoService
;
import
com.skua.modules.equip.vo.FmEquipResult
;
import
io.swagger.annotations.Api
;
...
...
@@ -54,4 +55,21 @@ public class FmEquipInfoController {
return
result
;
}
/**
* 添加设备字段
* @param equipField
* @return
*/
@AutoLog
(
value
=
"添加设备字段"
)
@ApiOperation
(
value
=
"添加设备字段"
,
notes
=
"添加设备字段"
)
@PostMapping
(
value
=
"/fieldAdd"
)
public
Result
<?>
planAdd
(
@RequestBody
SysEquipField
equipField
)
{
boolean
ok
=
fmEquipInfoService
.
equipFieldAdd
(
equipField
);
if
(
ok
){
return
Result
.
ok
(
"添加成功!"
);
}
else
{
return
Result
.
error
(
"添加失败!"
);
}
}
}
...
...
fm-product/src/main/java/com/skua/modules/equip/controller/SysEquipFieldController.java
0 → 100644
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
controller
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.skua.core.aspect.annotation.AutoLog
;
import
com.skua.core.api.vo.Result
;
import
com.skua.core.query.QueryGenerator
;
import
com.skua.core.util.ConvertUtils
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.skua.modules.equip.service.ISysEquipFieldService
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
lombok.extern.slf4j.Slf4j
;
import
org.jeecgframework.poi.excel.ExcelImportUtil
;
import
org.jeecgframework.poi.excel.def.NormalExcelConstants
;
import
org.jeecgframework.poi.excel.entity.ExportParams
;
import
org.jeecgframework.poi.excel.entity.ImportParams
;
import
org.jeecgframework.poi.excel.view.JeecgEntityExcelView
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.alibaba.fastjson.JSON
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/**
* 自定义设备字段
*/
@Slf4j
@Api
(
tags
=
"自定义设备字段"
)
@RestController
@RequestMapping
(
"/equip/sysEquipField"
)
public
class
SysEquipFieldController
{
@Autowired
private
ISysEquipFieldService
sysEquipFieldService
;
/**
* 分页列表查询
* @param sysEquipField
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog
(
value
=
"自定义设备字段-分页列表查询"
)
@ApiOperation
(
value
=
"自定义设备字段-分页列表查询"
,
notes
=
"自定义设备字段-分页列表查询"
)
@GetMapping
(
value
=
"/list"
)
public
Result
<
IPage
<
SysEquipField
>>
queryPageList
(
SysEquipField
sysEquipField
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
HttpServletRequest
req
)
{
Result
<
IPage
<
SysEquipField
>>
result
=
new
Result
<
IPage
<
SysEquipField
>>();
QueryWrapper
<
SysEquipField
>
queryWrapper
=
QueryGenerator
.
initQueryWrapper
(
sysEquipField
,
req
.
getParameterMap
());
Page
<
SysEquipField
>
page
=
new
Page
<
SysEquipField
>(
pageNo
,
pageSize
);
IPage
<
SysEquipField
>
pageList
=
sysEquipFieldService
.
page
(
page
,
queryWrapper
);
result
.
setSuccess
(
true
);
result
.
setResult
(
pageList
);
return
result
;
}
/**
* 添加
* @param sysEquipField
* @return
*/
@AutoLog
(
value
=
"自定义设备字段-添加"
)
@ApiOperation
(
value
=
"自定义设备字段-添加"
,
notes
=
"自定义设备字段-添加"
)
@PostMapping
(
value
=
"/add"
)
public
Result
<
SysEquipField
>
add
(
@RequestBody
SysEquipField
sysEquipField
)
{
Result
<
SysEquipField
>
result
=
new
Result
<
SysEquipField
>();
try
{
sysEquipFieldService
.
save
(
sysEquipField
);
result
.
success
(
"添加成功!"
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
result
.
error500
(
"操作失败"
);
}
return
result
;
}
/**
* 编辑
* @param sysEquipField
* @return
*/
@AutoLog
(
value
=
"自定义设备字段-编辑"
)
@ApiOperation
(
value
=
"自定义设备字段-编辑"
,
notes
=
"自定义设备字段-编辑"
)
@PutMapping
(
value
=
"/edit"
)
public
Result
<
SysEquipField
>
edit
(
@RequestBody
SysEquipField
sysEquipField
)
{
Result
<
SysEquipField
>
result
=
new
Result
<
SysEquipField
>();
SysEquipField
sysEquipFieldEntity
=
sysEquipFieldService
.
getById
(
sysEquipField
.
getId
());
if
(
sysEquipFieldEntity
==
null
)
{
result
.
error500
(
"未找到对应实体"
);
}
else
{
boolean
ok
=
sysEquipFieldService
.
updateById
(
sysEquipField
);
//TODO 返回false说明什么?
if
(
ok
)
{
result
.
success
(
"修改成功!"
);
}
}
return
result
;
}
/**
* 通过id删除
* @param id
* @return
*/
@AutoLog
(
value
=
"自定义设备字段-通过id删除"
)
@ApiOperation
(
value
=
"自定义设备字段-通过id删除"
,
notes
=
"自定义设备字段-通过id删除"
)
@DeleteMapping
(
value
=
"/delete"
)
public
Result
<?>
delete
(
@RequestParam
(
name
=
"id"
,
required
=
true
)
String
id
)
{
try
{
sysEquipFieldService
.
removeById
(
id
);
}
catch
(
Exception
e
)
{
log
.
error
(
"删除失败"
,
e
.
getMessage
());
return
Result
.
error
(
"删除失败!"
);
}
return
Result
.
ok
(
"删除成功!"
);
}
/**
* 批量删除
* @param ids
* @return
*/
@AutoLog
(
value
=
"自定义设备字段-批量删除"
)
@ApiOperation
(
value
=
"自定义设备字段-批量删除"
,
notes
=
"自定义设备字段-批量删除"
)
@DeleteMapping
(
value
=
"/deleteBatch"
)
public
Result
<
SysEquipField
>
deleteBatch
(
@RequestParam
(
name
=
"ids"
,
required
=
true
)
String
ids
)
{
Result
<
SysEquipField
>
result
=
new
Result
<
SysEquipField
>();
if
(
ids
==
null
||
""
.
equals
(
ids
.
trim
()))
{
result
.
error500
(
"参数不识别!"
);
}
else
{
this
.
sysEquipFieldService
.
removeByIds
(
Arrays
.
asList
(
ids
.
split
(
","
)));
result
.
success
(
"删除成功!"
);
}
return
result
;
}
/**
* 通过id查询
* @param id
* @return
*/
@AutoLog
(
value
=
"自定义设备字段-通过id查询"
)
@ApiOperation
(
value
=
"自定义设备字段-通过id查询"
,
notes
=
"自定义设备字段-通过id查询"
)
@GetMapping
(
value
=
"/queryById"
)
public
Result
<
SysEquipField
>
queryById
(
@RequestParam
(
name
=
"id"
,
required
=
true
)
String
id
)
{
Result
<
SysEquipField
>
result
=
new
Result
<
SysEquipField
>();
SysEquipField
sysEquipField
=
sysEquipFieldService
.
getById
(
id
);
if
(
sysEquipField
==
null
)
{
result
.
error500
(
"未找到对应实体"
);
}
else
{
result
.
setResult
(
sysEquipField
);
result
.
setSuccess
(
true
);
}
return
result
;
}
/**
* 导出excel
*
* @param request
* @param response
*/
@RequestMapping
(
value
=
"/exportXls"
)
public
ModelAndView
exportXls
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
// Step.1 组装查询条件
QueryWrapper
<
SysEquipField
>
queryWrapper
=
null
;
try
{
String
paramsStr
=
request
.
getParameter
(
"paramsStr"
);
if
(
ConvertUtils
.
isNotEmpty
(
paramsStr
))
{
String
deString
=
URLDecoder
.
decode
(
paramsStr
,
"UTF-8"
);
SysEquipField
sysEquipField
=
JSON
.
parseObject
(
deString
,
SysEquipField
.
class
);
queryWrapper
=
QueryGenerator
.
initQueryWrapper
(
sysEquipField
,
request
.
getParameterMap
());
}
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
//Step.2 AutoPoi 导出Excel
ModelAndView
mv
=
new
ModelAndView
(
new
JeecgEntityExcelView
());
List
<
SysEquipField
>
pageList
=
sysEquipFieldService
.
list
(
queryWrapper
);
//导出文件名称
mv
.
addObject
(
NormalExcelConstants
.
FILE_NAME
,
"自定义设备字段列表"
);
mv
.
addObject
(
NormalExcelConstants
.
CLASS
,
SysEquipField
.
class
);
mv
.
addObject
(
NormalExcelConstants
.
PARAMS
,
new
ExportParams
(
"自定义设备字段列表数据"
,
"导出人:Jeecg"
,
"导出信息"
));
mv
.
addObject
(
NormalExcelConstants
.
DATA_LIST
,
pageList
);
return
mv
;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping
(
value
=
"/importExcel"
,
method
=
RequestMethod
.
POST
)
public
Result
<?>
importExcel
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
MultipartHttpServletRequest
multipartRequest
=
(
MultipartHttpServletRequest
)
request
;
Map
<
String
,
MultipartFile
>
fileMap
=
multipartRequest
.
getFileMap
();
for
(
Map
.
Entry
<
String
,
MultipartFile
>
entity
:
fileMap
.
entrySet
())
{
MultipartFile
file
=
entity
.
getValue
();
// 获取上传文件对象
ImportParams
params
=
new
ImportParams
();
params
.
setTitleRows
(
2
);
params
.
setHeadRows
(
1
);
params
.
setNeedSave
(
true
);
try
{
List
<
SysEquipField
>
listSysEquipFields
=
ExcelImportUtil
.
importExcel
(
file
.
getInputStream
(),
SysEquipField
.
class
,
params
);
sysEquipFieldService
.
saveBatch
(
listSysEquipFields
);
return
Result
.
ok
(
"文件导入成功!数据行数:"
+
listSysEquipFields
.
size
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
Result
.
error
(
"文件导入失败:"
+
e
.
getMessage
());
}
finally
{
try
{
file
.
getInputStream
().
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
return
Result
.
ok
(
"文件导入失败!"
);
}
}
fm-product/src/main/java/com/skua/modules/equip/entity/SysEquipField.java
0 → 100644
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
entity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.jeecgframework.poi.excel.annotation.Excel
;
/**
* 自定义设备字段
*/
@Data
@TableName
(
"sys_equip_field"
)
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"sys_equip_field对象"
,
description
=
"自定义设备字段"
)
public
class
SysEquipField
{
/**主键id*/
@TableId
(
type
=
IdType
.
UUID
)
@ApiModelProperty
(
value
=
"主键id"
)
private
java
.
lang
.
String
id
;
/**数据项别名*/
@Excel
(
name
=
"数据项别名"
,
width
=
15
)
@ApiModelProperty
(
value
=
"数据项别名"
)
private
java
.
lang
.
String
itemAlias
;
/**数据项名称*/
@Excel
(
name
=
"数据项名称"
,
width
=
15
)
@ApiModelProperty
(
value
=
"数据项名称"
)
private
java
.
lang
.
String
itemCode
;
/**数据项单位*/
@Excel
(
name
=
"数据项单位"
,
width
=
15
)
@ApiModelProperty
(
value
=
"数据项单位"
)
private
java
.
lang
.
String
itemUnit
;
/**文本框类型*/
@Excel
(
name
=
"文本框类型"
,
width
=
15
)
@ApiModelProperty
(
value
=
"文本框类型"
)
private
java
.
lang
.
String
textType
;
/**字典CODE/时间格式/正则*/
@Excel
(
name
=
"字典CODE/时间格式/正则"
,
width
=
15
)
@ApiModelProperty
(
value
=
"字典CODE/时间格式/正则"
)
private
java
.
lang
.
String
typeInit
;
/**是否必填项*/
@Excel
(
name
=
"是否必填项"
,
width
=
15
)
@ApiModelProperty
(
value
=
"是否必填项"
)
private
java
.
lang
.
String
isMust
;
/**备注*/
@Excel
(
name
=
"备注"
,
width
=
15
)
@ApiModelProperty
(
value
=
"备注"
)
private
java
.
lang
.
String
remark
;
/**排序序号*/
@Excel
(
name
=
"排序序号"
,
width
=
15
)
@ApiModelProperty
(
value
=
"排序序号"
)
private
java
.
lang
.
Integer
sortNum
;
/**所属项目*/
@Excel
(
name
=
"所属项目"
,
width
=
15
)
@ApiModelProperty
(
value
=
"所属项目"
)
private
java
.
lang
.
String
projectId
;
/**创建人Id*/
@Excel
(
name
=
"创建人Id"
,
width
=
15
)
@ApiModelProperty
(
value
=
"创建人Id"
)
private
java
.
lang
.
String
createBy
;
/**创建时间*/
@Excel
(
name
=
"创建时间"
,
width
=
20
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
java
.
util
.
Date
createTime
;
/**修改人Id*/
@Excel
(
name
=
"修改人Id"
,
width
=
15
)
@ApiModelProperty
(
value
=
"修改人Id"
)
private
java
.
lang
.
String
updateBy
;
/**修改时间*/
@Excel
(
name
=
"修改时间"
,
width
=
20
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
value
=
"修改时间"
)
private
java
.
util
.
Date
updateTime
;
/**所属部门*/
@Excel
(
name
=
"所属部门"
,
width
=
15
)
@ApiModelProperty
(
value
=
"所属部门"
)
private
java
.
lang
.
String
createDept
;
/**所属公司*/
@Excel
(
name
=
"所属公司"
,
width
=
15
)
@ApiModelProperty
(
value
=
"所属公司"
)
private
java
.
lang
.
String
createCmpy
;
/**删除标识*/
@Excel
(
name
=
"删除标识"
,
width
=
15
)
@ApiModelProperty
(
value
=
"删除标识"
)
private
java
.
lang
.
Integer
delFlag
;
}
fm-product/src/main/java/com/skua/modules/equip/mapper/FmEquipInfoMapper.java
查看文件 @
f744d3f
...
...
@@ -13,4 +13,8 @@ public interface FmEquipInfoMapper {
List
<
FmEquipResult
>
queryListForView
(
@Param
(
"projectId"
)
String
projectId
);
FmEquipResult
getDataById
(
@Param
(
"equipId"
)
String
equipId
);
void
createView
(
@Param
(
"createViewSql"
)
String
createViewSql
,
@Param
(
"viewName"
)
String
viewName
);
void
deleteView
(
@Param
(
"viewName"
)
String
viewName
);
}
...
...
fm-product/src/main/java/com/skua/modules/equip/mapper/SysEquipFieldMapper.java
0 → 100644
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
mapper
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* 自定义设备字段
*/
public
interface
SysEquipFieldMapper
extends
BaseMapper
<
SysEquipField
>
{
}
fm-product/src/main/java/com/skua/modules/equip/mapper/xml/FmEquipInfoMapper.xml
查看文件 @
f744d3f
...
...
@@ -10,4 +10,13 @@
select * from view_equipment where equip_id = #{equipId} limit 1
</select>
<!-- 删除视图 -->
<select
id=
"deleteView"
>
drop view if exists ${viewName}
</select>
<!-- 创建视图 -->
<select
id=
"createView"
>
create view ${viewName} as ${createViewSql}
</select>
</mapper>
\ No newline at end of file
...
...
fm-product/src/main/java/com/skua/modules/equip/mapper/xml/SysEquipFieldMapper.xml
0 → 100644
查看文件 @
f744d3f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.skua.modules.equip.mapper.SysEquipFieldMapper"
>
</mapper>
\ No newline at end of file
fm-product/src/main/java/com/skua/modules/equip/service/IFmEquipInfoService.java
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
service
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.skua.modules.equip.vo.FmEquipResult
;
import
java.util.List
;
...
...
@@ -12,4 +13,6 @@ public interface IFmEquipInfoService {
List
<
FmEquipResult
>
queryList
(
String
projectId
);
FmEquipResult
getDataById
(
String
equipId
);
boolean
equipFieldAdd
(
SysEquipField
equipField
);
}
...
...
fm-product/src/main/java/com/skua/modules/equip/service/ISysEquipFieldService.java
0 → 100644
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
service
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* 自定义设备字段
*/
public
interface
ISysEquipFieldService
extends
IService
<
SysEquipField
>
{
}
fm-product/src/main/java/com/skua/modules/equip/service/impl/FmEquipInfoServiceImpl.java
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.skua.modules.equip.mapper.FmEquipInfoMapper
;
import
com.skua.modules.equip.service.IFmEquipInfoService
;
import
com.skua.modules.equip.service.ISysEquipFieldService
;
import
com.skua.modules.equip.vo.FmEquipResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.beans.BeanInfo
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 设备管理
...
...
@@ -16,6 +25,8 @@ public class FmEquipInfoServiceImpl implements IFmEquipInfoService {
@Autowired
private
FmEquipInfoMapper
fmEquipInfoMapper
;
@Autowired
private
ISysEquipFieldService
sysEquipFieldService
;
@Override
public
List
<
FmEquipResult
>
queryList
(
String
projectId
)
{
...
...
@@ -27,4 +38,67 @@ public class FmEquipInfoServiceImpl implements IFmEquipInfoService {
public
FmEquipResult
getDataById
(
String
equipId
)
{
return
fmEquipInfoMapper
.
getDataById
(
equipId
);
}
@Override
public
boolean
equipFieldAdd
(
SysEquipField
equipField
)
{
QueryWrapper
<
SysEquipField
>
queryWrapper
=
new
QueryWrapper
<
SysEquipField
>();
queryWrapper
.
eq
(
"project_id"
,
equipField
.
getProjectId
());
queryWrapper
.
eq
(
"item_code"
,
equipField
.
getItemCode
());
List
<
SysEquipField
>
list
=
sysEquipFieldService
.
list
(
queryWrapper
);
if
(
list
.
size
()>
0
){
return
false
;
}
else
{
boolean
ok
=
sysEquipFieldService
.
save
(
equipField
);
if
(
ok
){
//获取所有设备信息字段
QueryWrapper
<
SysEquipField
>
newQueryWrapper
=
new
QueryWrapper
<
SysEquipField
>();
newQueryWrapper
.
eq
(
"project_id"
,
equipField
.
getProjectId
());
List
<
SysEquipField
>
newList
=
sysEquipFieldService
.
list
(
newQueryWrapper
);
//修改设备自定义字段的视图
updateEquipView
(
newList
,
equipField
.
getProjectId
());
return
true
;
}
else
{
return
false
;
}
}
}
/**
* 修改设备自定义字段的视图
* @param list
*/
private
void
updateEquipView
(
List
<
SysEquipField
>
list
,
String
projectId
)
{
StringBuffer
sb
=
new
StringBuffer
();
fmEquipInfoMapper
.
deleteView
(
"view_equip_"
+
projectId
);
//删除旧视图
sb
.
append
(
"SELECT "
);
for
(
SysEquipField
equipField
:
list
)
{
sb
.
append
(
" MAX( CASE a.item_code WHEN '"
+
equipField
.
getItemCode
()+
"' THEN a.item_value ELSE '' END ) AS '"
+
equipField
.
getItemCode
()+
"', "
);
}
sb
.
append
(
" a.data_id "
+
" FROM "
+
" view_equip_field a "
+
" WHERE a.project_id = '"
+
projectId
+
"' "
+
" GROUP BY a.data_id"
);
//创建自定义设备属性视图
fmEquipInfoMapper
.
createView
(
sb
.
toString
(),
"view_equip_"
+
projectId
);
}
public
static
Map
<
String
,
Object
>
entityToMap
(
Object
bean
)
throws
Exception
{
Class
type
=
bean
.
getClass
();
Map
<
String
,
Object
>
returnMap
=
new
HashMap
<>();
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
type
);
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
descriptor
:
propertyDescriptors
)
{
String
propertyName
=
descriptor
.
getName
();
//name
if
(!
propertyName
.
equals
(
"class"
))
{
Method
readMethod
=
descriptor
.
getReadMethod
();
Object
result
=
readMethod
.
invoke
(
bean
);
//value
String
typeName
=
descriptor
.
getPropertyType
().
getName
();
//type
}
}
return
returnMap
;
}
}
...
...
fm-product/src/main/java/com/skua/modules/equip/service/impl/SysEquipFieldServiceImpl.java
0 → 100644
查看文件 @
f744d3f
package
com
.
skua
.
modules
.
equip
.
service
.
impl
;
import
com.skua.modules.equip.entity.SysEquipField
;
import
com.skua.modules.equip.mapper.SysEquipFieldMapper
;
import
com.skua.modules.equip.service.ISysEquipFieldService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
/**
* 自定义设备字段
*/
@Service
public
class
SysEquipFieldServiceImpl
extends
ServiceImpl
<
SysEquipFieldMapper
,
SysEquipField
>
implements
ISysEquipFieldService
{
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论