a11f1f6b 张雷

Merge remote-tracking branch 'origin/master' into master

2 个父辈 af409b3c 4ee7bc3e
...@@ -20,4 +20,6 @@ public interface BusinessConstant { ...@@ -20,4 +20,6 @@ public interface BusinessConstant {
20 20
21 String sumSuffix = "Sum"; 21 String sumSuffix = "Sum";
22 22
23 String dictText = "_dictText";
24
23 } 25 }
......
1 package com.skua.modules.joinclass.controller;
2
3 import cn.hutool.core.bean.BeanUtil;
4 import com.alibaba.fastjson.JSON;
5 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6 import com.baomidou.mybatisplus.core.metadata.IPage;
7 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8 import com.skua.common.constant.BusinessConstant;
9 import com.skua.core.api.vo.Result;
10 import com.skua.core.aspect.annotation.AutoLog;
11 import com.skua.core.query.QueryGenerator;
12 import com.skua.core.util.ConvertUtils;
13 import com.skua.modules.biz.IBusinessService;
14 import com.skua.modules.joinclass.entity.JoinClassInfo;
15 import com.skua.modules.joinclass.service.IJoinClassInfoService;
16 import io.swagger.annotations.Api;
17 import io.swagger.annotations.ApiOperation;
18 import lombok.extern.slf4j.Slf4j;
19 import org.apache.commons.lang3.StringUtils;
20 import org.jeecgframework.poi.excel.ExcelImportUtil;
21 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
22 import org.jeecgframework.poi.excel.entity.ExportParams;
23 import org.jeecgframework.poi.excel.entity.ImportParams;
24 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.web.bind.annotation.*;
27 import org.springframework.web.multipart.MultipartFile;
28 import org.springframework.web.multipart.MultipartHttpServletRequest;
29 import org.springframework.web.servlet.ModelAndView;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import java.io.IOException;
34 import java.io.UnsupportedEncodingException;
35 import java.net.URLDecoder;
36 import java.util.Arrays;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.stream.Collectors;
40
41 /**
42 * <pre>
43 * 交接班信息
44 * </pre>
45 *
46 * @author 开发者姓名
47 * @version V0.1, 开发时间
48 */
49 @Slf4j
50 @Api(tags = "交接班信息 ")
51 @RestController
52 @RequestMapping("/joinclass/joinClassInfo")
53 public class JoinClassInfoController {
54 @Autowired
55 private IJoinClassInfoService joinClassInfoService;
56 @Autowired
57 private IBusinessService businessService;
58
59 /**
60 * <pre>
61 * 分页列表查询
62 * </pre>
63 *
64 * @param joinClassInfo
65 * @param pageNo
66 * @param pageSize
67 * @param req
68 * @return
69 * @author 开发者姓名, 开发时间
70 * @Description: TODO(这里描述这个方法的需求变更情况)
71 */
72
73 @AutoLog(value = "交接班信息 -分页列表查询")
74 @ApiOperation(value = "交接班信息 -分页列表查询", notes = "交接班信息 -分页列表查询")
75 @GetMapping(value = "/list")
76 public Result<Object> queryPageList(JoinClassInfo joinClassInfo,
77 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
78 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
79 @RequestParam(name = "startTime", defaultValue = "") String startTime,
80 @RequestParam(name = "endTime", defaultValue = "") String endTime,
81 HttpServletRequest req) {
82 Result<Object> result = new Result<>();
83 QueryWrapper<JoinClassInfo> queryWrapper = QueryGenerator.initQueryWrapper(joinClassInfo, req.getParameterMap());
84 queryWrapper.ge(StringUtils.isNotEmpty(startTime), "data_time", startTime)
85 .le(StringUtils.isNotEmpty(endTime), "data_time", endTime);
86 Page<JoinClassInfo> page = new Page<>(pageNo, pageSize);
87 IPage<JoinClassInfo> pageList = joinClassInfoService.page(page, queryWrapper);
88 // 翻译
89 Map<String, String> classTypeDictMap = businessService.dictMap("JoinClassInfo_class_type", null);
90 Map<String, String> sysUserDictMap = businessService.dictMap("sys_user", null);
91 // 封装结果集
92 IPage<Map<String, Object>> mapIPage = new Page<>(pageNo, pageSize);
93 mapIPage.setTotal(pageList.getTotal());
94 mapIPage.setRecords(pageList.getRecords().stream().map(item -> {
95 Map<String, Object> entityMap = BeanUtil.beanToMap(item);
96 entityMap.put("classType" + BusinessConstant.dictText, classTypeDictMap.get(item.getClassType()));
97 entityMap.put("onDutyUser" + BusinessConstant.dictText, sysUserDictMap.get(item.getOnDutyUser()));
98 entityMap.put("handOverUser" + BusinessConstant.dictText, sysUserDictMap.get(item.getHandOverUser()));
99 entityMap.put("takeOverUser" + BusinessConstant.dictText, sysUserDictMap.get(item.getTakeOverUser()));
100 return entityMap;
101 }).collect(Collectors.toList()));
102 result.setSuccess(true);
103 result.setResult(mapIPage);
104 return result;
105 }
106
107 /**
108 * <pre>
109 * 添加
110 * </pre>
111 *
112 * @param joinClassInfo
113 * @return
114 * @author 开发者姓名, 开发时间
115 * @Description: TODO(这里描述这个方法的需求变更情况)
116 */
117 @AutoLog(value = "交接班信息 -添加")
118 @ApiOperation(value = "交接班信息 -添加", notes = "交接班信息 -添加")
119 @PostMapping(value = "/add")
120 public Result<JoinClassInfo> add(@RequestBody JoinClassInfo joinClassInfo) {
121 Result<JoinClassInfo> result = new Result<>();
122 try {
123 joinClassInfoService.save(joinClassInfo);
124 result.success("添加成功!");
125 } catch (Exception e) {
126 log.error(e.getMessage(), e);
127 result.error500("操作失败");
128 }
129 return result;
130 }
131
132 /**
133 * <pre>
134 * 编辑
135 * </pre>
136 *
137 * @param joinClassInfo
138 * @return
139 * @author 开发者姓名, 开发时间
140 * @Description: TODO(这里描述这个方法的需求变更情况)
141 */
142 @AutoLog(value = "交接班信息 -编辑")
143 @ApiOperation(value = "交接班信息 -编辑", notes = "交接班信息 -编辑")
144 @PutMapping(value = "/edit")
145 public Result<JoinClassInfo> edit(@RequestBody JoinClassInfo joinClassInfo) {
146 Result<JoinClassInfo> result = new Result<>();
147 JoinClassInfo joinClassInfoEntity = joinClassInfoService.getById(joinClassInfo.getId());
148 if (joinClassInfoEntity == null) {
149 result.error500("未找到对应实体");
150 } else {
151 boolean ok = joinClassInfoService.updateById(joinClassInfo);
152 //TODO 返回false说明什么?
153 if (ok) {
154 result.success("修改成功!");
155 }
156 }
157
158 return result;
159 }
160
161 /**
162 * <pre>
163 * 通过id删除
164 * </pre>
165 *
166 * @param id
167 * @return
168 * @author 开发者姓名, 开发时间
169 * @Description: TODO(这里描述这个方法的需求变更情况)
170 */
171 @AutoLog(value = "交接班信息 -通过id删除")
172 @ApiOperation(value = "交接班信息 -通过id删除", notes = "交接班信息 -通过id删除")
173 @DeleteMapping(value = "/delete")
174 public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
175 try {
176 joinClassInfoService.removeById(id);
177 } catch (Exception e) {
178 log.error("删除失败", e.getMessage());
179 return Result.error("删除失败!");
180 }
181 return Result.ok("删除成功!");
182 }
183
184 /**
185 * <pre>
186 * 批量删除
187 * </pre>
188 *
189 * @param ids
190 * @return
191 * @author 开发者姓名, 开发时间
192 * @Description: TODO(这里描述这个方法的需求变更情况)
193 */
194 @AutoLog(value = "交接班信息 -批量删除")
195 @ApiOperation(value = "交接班信息 -批量删除", notes = "交接班信息 -批量删除")
196 @DeleteMapping(value = "/deleteBatch")
197 public Result<JoinClassInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
198 Result<JoinClassInfo> result = new Result<JoinClassInfo>();
199 if (ids == null || "".equals(ids.trim())) {
200 result.error500("参数不识别!");
201 } else {
202 this.joinClassInfoService.removeByIds(Arrays.asList(ids.split(",")));
203 result.success("删除成功!");
204 }
205 return result;
206 }
207
208 /**
209 * <pre>
210 * 通过id查询
211 * </pre>
212 *
213 * @param id
214 * @return
215 * @author 开发者姓名, 开发时间
216 * @Description: TODO(这里描述这个方法的需求变更情况)
217 */
218 @AutoLog(value = "交接班信息 -通过id查询")
219 @ApiOperation(value = "交接班信息 -通过id查询", notes = "交接班信息 -通过id查询")
220 @GetMapping(value = "/queryById")
221 public Result<JoinClassInfo> queryById(@RequestParam(name = "id", required = true) String id) {
222 Result<JoinClassInfo> result = new Result<JoinClassInfo>();
223 JoinClassInfo joinClassInfo = joinClassInfoService.getById(id);
224 if (joinClassInfo == null) {
225 result.error500("未找到对应实体");
226 } else {
227 result.setResult(joinClassInfo);
228 result.setSuccess(true);
229 }
230 return result;
231 }
232
233 /**
234 * <pre>
235 * 导出excel
236 * </pre>
237 *
238 * @param request
239 * @param response
240 * @return
241 * @author 开发者姓名, 开发时间
242 * @Description: TODO(这里描述这个方法的需求变更情况)
243 */
244
245 @RequestMapping(value = "/exportXls")
246 public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
247 // Step.1 组装查询条件
248 QueryWrapper<JoinClassInfo> queryWrapper = null;
249 try {
250 String paramsStr = request.getParameter("paramsStr");
251 if (ConvertUtils.isNotEmpty(paramsStr)) {
252 String deString = URLDecoder.decode(paramsStr, "UTF-8");
253 JoinClassInfo joinClassInfo = JSON.parseObject(deString, JoinClassInfo.class);
254 queryWrapper = QueryGenerator.initQueryWrapper(joinClassInfo, request.getParameterMap());
255 }
256 } catch (UnsupportedEncodingException e) {
257 e.printStackTrace();
258 }
259
260 //Step.2 AutoPoi 导出Excel
261 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
262 List<JoinClassInfo> pageList = joinClassInfoService.list(queryWrapper);
263 //导出文件名称
264 mv.addObject(NormalExcelConstants.FILE_NAME, "交接班信息 列表");
265 mv.addObject(NormalExcelConstants.CLASS, JoinClassInfo.class);
266 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("交接班信息 列表数据", "导出人:Jeecg", "导出信息"));
267 mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
268 return mv;
269 }
270
271 /**
272 * <pre>
273 * 通过excel导入数据
274 * </pre>
275 *
276 * @param request
277 * @param response
278 * @return
279 * @author 开发者姓名, 开发时间
280 * @Description: TODO(这里描述这个方法的需求变更情况)
281 */
282 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
283 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
284 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
285 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
286 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
287 MultipartFile file = entity.getValue();// 获取上传文件对象
288 ImportParams params = new ImportParams();
289 params.setTitleRows(2);
290 params.setHeadRows(1);
291 params.setNeedSave(true);
292 try {
293 List<JoinClassInfo> listJoinClassInfos = ExcelImportUtil.importExcel(file.getInputStream(), JoinClassInfo.class, params);
294 joinClassInfoService.saveBatch(listJoinClassInfos);
295 return Result.ok("文件导入成功!数据行数:" + listJoinClassInfos.size());
296 } catch (Exception e) {
297 log.error(e.getMessage(), e);
298 return Result.error("文件导入失败:" + e.getMessage());
299 } finally {
300 try {
301 file.getInputStream().close();
302 } catch (IOException e) {
303 e.printStackTrace();
304 }
305 }
306 }
307 return Result.ok("文件导入失败!");
308 }
309
310 }
1 package com.skua.modules.joinclass.entity;
2
3 import java.util.Date;
4
5 import com.baomidou.mybatisplus.annotation.IdType;
6 import com.baomidou.mybatisplus.annotation.TableId;
7 import com.baomidou.mybatisplus.annotation.TableName;
8 import io.swagger.annotations.ApiModel;
9 import io.swagger.annotations.ApiModelProperty;
10 import lombok.Data;
11 import lombok.EqualsAndHashCode;
12 import lombok.experimental.Accessors;
13 import com.fasterxml.jackson.annotation.JsonFormat;
14 import org.springframework.format.annotation.DateTimeFormat;
15 import org.jeecgframework.poi.excel.annotation.Excel;
16
17 /**
18 * 交接班信息
19 */
20 @Data
21 @TableName("join_class_info")
22 @EqualsAndHashCode(callSuper = false)
23 @Accessors(chain = true)
24 @ApiModel(value = "join_class_info对象", description = "交接班信息 ")
25 public class JoinClassInfo {
26
27 /**
28 * 主键
29 */
30 @TableId(type = IdType.ID_WORKER_STR)
31 @ApiModelProperty(value = "主键")
32 private String id;
33 /**
34 * 值班人员
35 */
36 @Excel(name = "值班人员", width = 15)
37 @ApiModelProperty(value = "值班人员")
38 private String onDutyUser;
39 /**
40 * 时间
41 */
42 @Excel(name = "时间", width = 15)
43 @ApiModelProperty(value = "时间")
44 private String dataTime;
45 /**
46 * 班次类型(白班1;夜班2)
47 */
48 @Excel(name = "班次类型(白班1;夜班2)", width = 15)
49 @ApiModelProperty(value = "班次类型(白班1;夜班2)")
50 private String classType;
51 /**
52 * 值班记录
53 */
54 @Excel(name = "值班记录", width = 15)
55 @ApiModelProperty(value = "值班记录")
56 private String onDutyRecord;
57 /**
58 * 运行异常描述
59 */
60 @Excel(name = "运行异常描述", width = 15)
61 @ApiModelProperty(value = "运行异常描述")
62 private String runExceptionDesc;
63 /**
64 * 交接物品
65 */
66 @Excel(name = "交接物品", width = 15)
67 @ApiModelProperty(value = "交接物品")
68 private String handOverGoods;
69 /**
70 * 注意事项
71 */
72 @Excel(name = "注意事项", width = 15)
73 @ApiModelProperty(value = "注意事项")
74 private String attentionNote;
75 /**
76 * 交班人
77 */
78 @Excel(name = "交班人", width = 15)
79 @ApiModelProperty(value = "交班人")
80 private String handOverUser;
81 /**
82 * 接班人
83 */
84 @Excel(name = "接班人", width = 15)
85 @ApiModelProperty(value = "接班人")
86 private String takeOverUser;
87 /**
88 * 创建人
89 */
90 @Excel(name = "创建人", width = 15)
91 @ApiModelProperty(value = "创建人")
92 private String createBy;
93 /**
94 * 创建日期
95 */
96 @Excel(name = "创建日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
97 @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
98 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
99 @ApiModelProperty(value = "创建日期")
100 private Date createTime;
101 /**
102 * 更新人
103 */
104 @Excel(name = "更新人", width = 15)
105 @ApiModelProperty(value = "更新人")
106 private String updateBy;
107 /**
108 * 更新日期
109 */
110 @Excel(name = "更新日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
111 @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
112 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
113 @ApiModelProperty(value = "更新日期")
114 private Date updateTime;
115 /**
116 * 排序字段
117 */
118 @Excel(name = "排序字段", width = 15)
119 @ApiModelProperty(value = "排序字段")
120 private Integer orderNum;
121 /**
122 * 删除状态(0正常;1已删除)
123 */
124 @Excel(name = "删除状态(0正常;1已删除)", width = 15)
125 @ApiModelProperty(value = "删除状态(0正常;1已删除)")
126 private String delFlag;
127
128 }
1 package com.skua.modules.joinclass.mapper;
2
3 import com.skua.modules.joinclass.entity.JoinClassInfo;
4 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
6 /**
7 * 交接班信息
8 */
9 public interface JoinClassInfoMapper extends BaseMapper<JoinClassInfo> {
10
11 }
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="com.skua.modules.joinclass.mapper.JoinClassInfoMapper">
4
5 </mapper>
...\ No newline at end of file ...\ No newline at end of file
1 package com.skua.modules.joinclass.service;
2
3 import com.skua.modules.joinclass.entity.JoinClassInfo;
4 import com.baomidou.mybatisplus.extension.service.IService;
5
6 /**
7 * 交接班信息
8 */
9 public interface IJoinClassInfoService extends IService<JoinClassInfo> {
10
11 }
1 package com.skua.modules.joinclass.service.impl;
2
3 import com.skua.modules.joinclass.entity.JoinClassInfo;
4 import com.skua.modules.joinclass.mapper.JoinClassInfoMapper;
5 import com.skua.modules.joinclass.service.IJoinClassInfoService;
6 import org.springframework.stereotype.Service;
7
8 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
10 /**
11 * 交接班信息
12 */
13 @Service
14 public class JoinClassInfoServiceImpl extends ServiceImpl<JoinClassInfoMapper, JoinClassInfo> implements IJoinClassInfoService {
15
16 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!