Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skboot-zhongye
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
d6473e16
由
康伟
编写于
2024-09-18 18:16:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
kangwei: 事故案例库后端接口
1 个父辈
0cce2f66
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
438 行增加
和
0 行删除
sk-module-biz/src/main/java/com/skua/modules/safe/controller/AccidentCaseController.java
sk-module-biz/src/main/java/com/skua/modules/safe/entity/AccidentCase.java
sk-module-biz/src/main/java/com/skua/modules/safe/mapper/AccidentCaseMapper.java
sk-module-biz/src/main/java/com/skua/modules/safe/mapper/xml/AccidentCaseMapper.xml
sk-module-biz/src/main/java/com/skua/modules/safe/service/IAccidentCaseService.java
sk-module-biz/src/main/java/com/skua/modules/safe/service/impl/AccidentCaseServiceImpl.java
sk-module-biz/src/main/java/com/skua/modules/safe/controller/AccidentCaseController.java
0 → 100644
查看文件 @
d6473e1
package
com
.
skua
.
modules
.
safe
.
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.api.vo.Result
;
import
com.skua.core.aspect.annotation.AutoLog
;
import
com.skua.core.context.BaseContextHandler
;
import
com.skua.core.query.QueryGenerator
;
import
com.skua.core.service.ISequenceService
;
import
com.skua.core.util.ConvertUtils
;
import
com.skua.modules.safe.entity.AccidentCase
;
import
com.skua.modules.safe.service.IAccidentCaseService
;
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
;
/**
* <pre>
* 事故案例库
* </pre>
* @author 开发者姓名
* @version V0.1, 开发时间
*/
@Slf4j
@Api
(
tags
=
"事故案例库"
)
@RestController
(
"webAccidentCaseController"
)
@RequestMapping
(
"/web/safe/accidentCase"
)
public
class
AccidentCaseController
{
@Autowired
private
IAccidentCaseService
accidentCaseService
;
/**
* <pre>
* 分页列表查询
* </pre>
* @param accidentCase
* @param pageNo
* @param pageSize
* @param req
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog
(
value
=
"事故案例库-分页列表查询"
)
@ApiOperation
(
value
=
"事故案例库-分页列表查询"
,
notes
=
"事故案例库-分页列表查询"
)
@GetMapping
(
value
=
"/list"
)
public
Result
<
IPage
<
AccidentCase
>>
queryPageList
(
AccidentCase
accidentCase
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
HttpServletRequest
req
)
{
Result
<
IPage
<
AccidentCase
>>
result
=
new
Result
<
IPage
<
AccidentCase
>>();
QueryWrapper
<
AccidentCase
>
queryWrapper
=
QueryGenerator
.
initQueryWrapper
(
accidentCase
,
req
.
getParameterMap
());
Page
<
AccidentCase
>
page
=
new
Page
<
AccidentCase
>(
pageNo
,
pageSize
);
queryWrapper
.
orderByDesc
(
"create_time"
);
IPage
<
AccidentCase
>
pageList
=
accidentCaseService
.
page
(
page
,
queryWrapper
);
result
.
setSuccess
(
true
);
result
.
setResult
(
pageList
);
return
result
;
}
/**
* <pre>
* 添加
* </pre>
* @param accidentCase
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog
(
value
=
"事故案例库-添加"
)
@ApiOperation
(
value
=
"事故案例库-添加"
,
notes
=
"事故案例库-添加"
)
@PostMapping
(
value
=
"/add"
)
public
Result
<
AccidentCase
>
add
(
@RequestBody
AccidentCase
accidentCase
)
{
Result
<
AccidentCase
>
result
=
new
Result
<
AccidentCase
>();
try
{
accidentCaseService
.
save
(
accidentCase
);
result
.
success
(
"添加成功!"
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
result
.
error500
(
"操作失败"
);
}
return
result
;
}
/**
* <pre>
* 编辑
* </pre>
* @param accidentCase
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog
(
value
=
"事故案例库-编辑"
)
@ApiOperation
(
value
=
"事故案例库-编辑"
,
notes
=
"事故案例库-编辑"
)
@PutMapping
(
value
=
"/edit"
)
public
Result
<
AccidentCase
>
edit
(
@RequestBody
AccidentCase
accidentCase
)
{
Result
<
AccidentCase
>
result
=
new
Result
<
AccidentCase
>();
AccidentCase
accidentCaseEntity
=
accidentCaseService
.
getById
(
accidentCase
.
getId
());
if
(
accidentCaseEntity
==
null
)
{
result
.
error500
(
"未找到对应实体"
);
}
else
{
boolean
ok
=
accidentCaseService
.
updateById
(
accidentCase
);
//TODO 返回false说明什么?
if
(
ok
)
{
result
.
success
(
"修改成功!"
);
}
}
return
result
;
}
/**
* <pre>
* 通过id删除
* </pre>
* @param id
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog
(
value
=
"事故案例库-通过id删除"
)
@ApiOperation
(
value
=
"事故案例库-通过id删除"
,
notes
=
"事故案例库-通过id删除"
)
@DeleteMapping
(
value
=
"/delete"
)
public
Result
<?>
delete
(
@RequestParam
(
name
=
"id"
,
required
=
true
)
String
id
)
{
try
{
accidentCaseService
.
removeById
(
id
);
}
catch
(
Exception
e
)
{
log
.
error
(
"删除失败"
,
e
.
getMessage
());
return
Result
.
error
(
"删除失败!"
);
}
return
Result
.
ok
(
"删除成功!"
);
}
/**
* <pre>
* 批量删除
* </pre>
* @param ids
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog
(
value
=
"事故案例库-批量删除"
)
@ApiOperation
(
value
=
"事故案例库-批量删除"
,
notes
=
"事故案例库-批量删除"
)
@DeleteMapping
(
value
=
"/deleteBatch"
)
public
Result
<
AccidentCase
>
deleteBatch
(
@RequestParam
(
name
=
"ids"
,
required
=
true
)
String
ids
)
{
Result
<
AccidentCase
>
result
=
new
Result
<
AccidentCase
>();
if
(
ids
==
null
||
""
.
equals
(
ids
.
trim
()))
{
result
.
error500
(
"参数不识别!"
);
}
else
{
this
.
accidentCaseService
.
removeByIds
(
Arrays
.
asList
(
ids
.
split
(
","
)));
result
.
success
(
"删除成功!"
);
}
return
result
;
}
/**
* <pre>
* 通过id查询
* </pre>
* @param id
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog
(
value
=
"事故案例库-通过id查询"
)
@ApiOperation
(
value
=
"事故案例库-通过id查询"
,
notes
=
"事故案例库-通过id查询"
)
@GetMapping
(
value
=
"/queryById"
)
public
Result
<
AccidentCase
>
queryById
(
@RequestParam
(
name
=
"id"
,
required
=
true
)
String
id
)
{
Result
<
AccidentCase
>
result
=
new
Result
<
AccidentCase
>();
AccidentCase
accidentCase
=
accidentCaseService
.
getById
(
id
);
if
(
accidentCase
==
null
)
{
result
.
error500
(
"未找到对应实体"
);
}
else
{
result
.
setResult
(
accidentCase
);
result
.
setSuccess
(
true
);
}
return
result
;
}
/**
* <pre>
* 导出excel
* </pre>
* @param request
* @param response
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@RequestMapping
(
value
=
"/exportXls"
)
public
ModelAndView
exportXls
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
// Step.1 组装查询条件
QueryWrapper
<
AccidentCase
>
queryWrapper
=
null
;
try
{
String
paramsStr
=
request
.
getParameter
(
"paramsStr"
);
if
(
ConvertUtils
.
isNotEmpty
(
paramsStr
))
{
String
deString
=
URLDecoder
.
decode
(
paramsStr
,
"UTF-8"
);
AccidentCase
accidentCase
=
JSON
.
parseObject
(
deString
,
AccidentCase
.
class
);
queryWrapper
=
QueryGenerator
.
initQueryWrapper
(
accidentCase
,
request
.
getParameterMap
());
}
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
//Step.2 AutoPoi 导出Excel
ModelAndView
mv
=
new
ModelAndView
(
new
JeecgEntityExcelView
());
List
<
AccidentCase
>
pageList
=
accidentCaseService
.
list
(
queryWrapper
);
//导出文件名称
mv
.
addObject
(
NormalExcelConstants
.
FILE_NAME
,
"事故案例库列表"
);
mv
.
addObject
(
NormalExcelConstants
.
CLASS
,
AccidentCase
.
class
);
mv
.
addObject
(
NormalExcelConstants
.
PARAMS
,
new
ExportParams
(
"事故案例库列表数据"
,
"导出人:Jeecg"
,
"导出信息"
));
mv
.
addObject
(
NormalExcelConstants
.
DATA_LIST
,
pageList
);
return
mv
;
}
/**
* <pre>
* 通过excel导入数据
* </pre>
* @param request
* @param response
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@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
<
AccidentCase
>
listAccidentCases
=
ExcelImportUtil
.
importExcel
(
file
.
getInputStream
(),
AccidentCase
.
class
,
params
);
accidentCaseService
.
saveBatch
(
listAccidentCases
);
return
Result
.
ok
(
"文件导入成功!数据行数:"
+
listAccidentCases
.
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
(
"文件导入失败!"
);
}
}
sk-module-biz/src/main/java/com/skua/modules/safe/entity/AccidentCase.java
0 → 100644
查看文件 @
d6473e1
package
com
.
skua
.
modules
.
safe
.
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
com.skua.core.aspect.annotation.Dict
;
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
(
"safe_accident_case"
)
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"safe_accident_case对象"
,
description
=
"事故案例库"
)
public
class
AccidentCase
{
/**id*/
@TableId
(
type
=
IdType
.
ID_WORKER_STR
)
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
/**所属机构*/
@Excel
(
name
=
"所属机构"
,
width
=
15
)
@ApiModelProperty
(
value
=
"所属机构"
)
private
String
departId
;
/**事故名称*/
@Excel
(
name
=
"事故名称"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故名称"
)
private
String
accidentName
;
/**事故类型*/
@Excel
(
name
=
"事故类型"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故类型"
)
@Dict
(
dicCode
=
"safe_accident_type"
)
private
String
accidentType
;
/**发生时间*/
@Excel
(
name
=
"发生时间"
,
width
=
15
)
@ApiModelProperty
(
value
=
"发生时间"
)
private
String
accidentTime
;
/**发生地点*/
@Excel
(
name
=
"发生地点"
,
width
=
15
)
@ApiModelProperty
(
value
=
"发生地点"
)
private
String
accidentPlace
;
/**责任部门*/
@Excel
(
name
=
"责任部门"
,
width
=
15
)
@ApiModelProperty
(
value
=
"责任部门"
)
private
String
dutyDepart
;
/**责任人员(用户id)*/
@Excel
(
name
=
"责任人员(用户id)"
,
width
=
15
)
@ApiModelProperty
(
value
=
"责任人员(用户id)"
)
private
String
dutyUser
;
/**事故描述*/
@Excel
(
name
=
"事故描述"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故描述"
)
private
String
accidentDescription
;
/**事故后果*/
@Excel
(
name
=
"事故后果"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故后果"
)
private
String
accidentResult
;
/**应急措施*/
@Excel
(
name
=
"应急措施"
,
width
=
15
)
@ApiModelProperty
(
value
=
"应急措施"
)
private
String
measures
;
/**事故总结*/
@Excel
(
name
=
"事故总结"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故总结"
)
private
String
accidentSummary
;
/**事故照片*/
@Excel
(
name
=
"事故照片"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故照片"
)
private
String
accidentImg
;
/**事故报告文件*/
@Excel
(
name
=
"事故报告文件"
,
width
=
15
)
@ApiModelProperty
(
value
=
"事故报告文件"
)
private
String
accidentFile
;
/**备注*/
@Excel
(
name
=
"备注"
,
width
=
15
)
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
/**创建人Id*/
@Excel
(
name
=
"创建人Id"
,
width
=
15
)
@ApiModelProperty
(
value
=
"创建人Id"
)
private
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
Date
createTime
;
/**修改人Id*/
@Excel
(
name
=
"修改人Id"
,
width
=
15
)
@ApiModelProperty
(
value
=
"修改人Id"
)
private
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
Date
updateTime
;
/**删除标识,1有效,0删除*/
@Excel
(
name
=
"删除标识,1有效,0删除"
,
width
=
15
)
@ApiModelProperty
(
value
=
"删除标识,1有效,0删除"
)
private
Integer
delFlag
;
}
sk-module-biz/src/main/java/com/skua/modules/safe/mapper/AccidentCaseMapper.java
0 → 100644
查看文件 @
d6473e1
package
com
.
skua
.
modules
.
safe
.
mapper
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
com.skua.modules.safe.entity.AccidentCase
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* 事故案例库
*/
public
interface
AccidentCaseMapper
extends
BaseMapper
<
AccidentCase
>
{
}
sk-module-biz/src/main/java/com/skua/modules/safe/mapper/xml/AccidentCaseMapper.xml
0 → 100644
查看文件 @
d6473e1
<?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.safe.mapper.AccidentCaseMapper"
>
</mapper>
\ No newline at end of file
sk-module-biz/src/main/java/com/skua/modules/safe/service/IAccidentCaseService.java
0 → 100644
查看文件 @
d6473e1
package
com
.
skua
.
modules
.
safe
.
service
;
import
com.skua.modules.safe.entity.AccidentCase
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* 事故案例库
*/
public
interface
IAccidentCaseService
extends
IService
<
AccidentCase
>
{
}
sk-module-biz/src/main/java/com/skua/modules/safe/service/impl/AccidentCaseServiceImpl.java
0 → 100644
查看文件 @
d6473e1
package
com
.
skua
.
modules
.
safe
.
service
.
impl
;
import
com.skua.modules.safe.entity.AccidentCase
;
import
com.skua.modules.safe.mapper.AccidentCaseMapper
;
import
com.skua.modules.safe.service.IAccidentCaseService
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
/**
* 事故案例库
*/
@Service
public
class
AccidentCaseServiceImpl
extends
ServiceImpl
<
AccidentCaseMapper
,
AccidentCase
>
implements
IAccidentCaseService
{
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论