3487a53e 张雷

feat(report): 新增运营周报补充填报功能

- 添加了 WeekReportRemark 实体类
- 创建了 IWeekReportRemarkService 接口及其实现类 WeekReportRemarkServiceImpl
- 开发了 WeekReportRemarkController 控制器
- 设计了 WeekReportRemarkMapper 映射接口及其 XML 配置文件
- 实现了运营周报补充填报的增删改查和导出导入功能
1 个父辈 4bd23601
1 package com.skua.modules.report.controller;
2
3 import java.util.Arrays;
4 import java.util.List;
5 import java.util.Map;
6 import java.io.IOException;
7 import java.io.UnsupportedEncodingException;
8 import java.net.URLDecoder;
9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse;
11 import com.skua.core.api.vo.Result;
12 import com.skua.core.aspect.annotation.AutoLog;
13 import com.skua.core.context.BaseContextHandler;
14 import com.skua.core.query.QueryGenerator;
15 import com.skua.core.service.ISequenceService;
16 import com.skua.core.util.ConvertUtils;
17 import com.skua.modules.report.entity.WeekReportRemark;
18 import com.skua.modules.report.service.IWeekReportRemarkService;
19 import java.util.Date;
20 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
21 import com.baomidou.mybatisplus.core.metadata.IPage;
22 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
23 import lombok.extern.slf4j.Slf4j;
24
25 import org.jeecgframework.poi.excel.ExcelImportUtil;
26 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
27 import org.jeecgframework.poi.excel.entity.ExportParams;
28 import org.jeecgframework.poi.excel.entity.ImportParams;
29 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
30
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.web.bind.annotation.*;
33 import org.springframework.web.multipart.MultipartFile;
34 import org.springframework.web.multipart.MultipartHttpServletRequest;
35 import org.springframework.web.servlet.ModelAndView;
36 import com.alibaba.fastjson.JSON;
37 import io.swagger.annotations.Api;
38 import io.swagger.annotations.ApiOperation;
39
40 /**
41 * 运营周报补充填报
42 * @author 开发者姓名
43 * @version V0.1, 开发时间
44 */
45 @Slf4j
46 @Api(tags="运营周报补充填报")
47 @RestController
48 @RequestMapping("/report/weekReportRemark")
49 public class WeekReportRemarkController {
50 @Autowired
51 private IWeekReportRemarkService weekReportRemarkService;
52
53 /**
54 * <pre>
55 * 分页列表查询
56 * </pre>
57 * @param weekReportRemark
58 * @param pageNo
59 * @param pageSize
60 * @param req
61 * @return
62 * @author 开发者姓名, 开发时间
63 * @Description: TODO(这里描述这个方法的需求变更情况)
64 */
65
66 @AutoLog(value = "运营周报补充填报-分页列表查询")
67 @ApiOperation(value="运营周报补充填报-分页列表查询", notes="运营周报补充填报-分页列表查询")
68 @GetMapping(value = "/list")
69 public Result<IPage<WeekReportRemark>> queryPageList(WeekReportRemark weekReportRemark,
70 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
71 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
72 HttpServletRequest req) {
73 Result<IPage<WeekReportRemark>> result = new Result<IPage<WeekReportRemark>>();
74 QueryWrapper<WeekReportRemark> queryWrapper = QueryGenerator.initQueryWrapper(weekReportRemark, req.getParameterMap());
75 Page<WeekReportRemark> page = new Page<WeekReportRemark>(pageNo, pageSize);
76 IPage<WeekReportRemark> pageList = weekReportRemarkService.page(page, queryWrapper);
77 result.setSuccess(true);
78 result.setResult(pageList);
79 return result;
80 }
81
82 @AutoLog(value = "运营周报补充填报查询")
83 @ApiOperation(value="运营周报补充填报查询", notes="运营周报补充填报查询")
84 @GetMapping(value = "/getInfo")
85 public Result<WeekReportRemark> getInfo(WeekReportRemark weekReportRemark) {
86 Result<WeekReportRemark> result = new Result<WeekReportRemark>();
87 WeekReportRemark remark = weekReportRemarkService.getInfo(weekReportRemark);
88 result.setSuccess(true);
89 result.setResult(remark);
90 return result;
91 }
92
93 @AutoLog(value = "运营周报补充填报保存")
94 @ApiOperation(value="运营周报补充填报保存", notes="运营周报补充填报保存")
95 @PostMapping(value = "/save")
96 public Result<WeekReportRemark> save(@RequestBody WeekReportRemark weekReportRemark) {
97 Result<WeekReportRemark> result = new Result<WeekReportRemark>();
98 WeekReportRemark remark = weekReportRemarkService.getInfo(weekReportRemark);
99 if(remark!=null){
100 weekReportRemark.setId(remark.getId());
101 weekReportRemarkService.updateById(weekReportRemark);
102 }else{
103 weekReportRemarkService.save(weekReportRemark);
104 }
105 result.setSuccess(true);
106 result.setResult(weekReportRemark);
107 return result;
108 }
109
110 /**
111 * <pre>
112 * 添加
113 * </pre>
114 * @param weekReportRemark
115 * @return
116 * @author 开发者姓名, 开发时间
117 * @Description: TODO(这里描述这个方法的需求变更情况)
118 */
119 @AutoLog(value = "运营周报补充填报-添加")
120 @ApiOperation(value="运营周报补充填报-添加", notes="运营周报补充填报-添加")
121 @PostMapping(value = "/add")
122 public Result<WeekReportRemark> add(@RequestBody WeekReportRemark weekReportRemark) {
123 Result<WeekReportRemark> result = new Result<WeekReportRemark>();
124 try {
125 weekReportRemarkService.save(weekReportRemark);
126 result.success("添加成功!");
127 } catch (Exception e) {
128 log.error(e.getMessage(),e);
129 result.error500("操作失败");
130 }
131 return result;
132 }
133 /**
134 * <pre>
135 * 编辑
136 * </pre>
137 * @param weekReportRemark
138 * @return
139 * @author 开发者姓名, 开发时间
140 * @Description: TODO(这里描述这个方法的需求变更情况)
141 */
142 @AutoLog(value = "运营周报补充填报-编辑")
143 @ApiOperation(value="运营周报补充填报-编辑", notes="运营周报补充填报-编辑")
144 @PutMapping(value = "/edit")
145 public Result<WeekReportRemark> edit(@RequestBody WeekReportRemark weekReportRemark) {
146 Result<WeekReportRemark> result = new Result<WeekReportRemark>();
147 WeekReportRemark weekReportRemarkEntity = weekReportRemarkService.getById(weekReportRemark.getId());
148 if(weekReportRemarkEntity==null) {
149 result.error500("未找到对应实体");
150 }else {
151 boolean ok = weekReportRemarkService.updateById(weekReportRemark);
152 //TODO 返回false说明什么?
153 if(ok) {
154 result.success("修改成功!");
155 }
156 }
157
158 return result;
159 }
160 /**
161 * <pre>
162 * 通过id删除
163 * </pre>
164 * @param id
165 * @return
166 * @author 开发者姓名, 开发时间
167 * @Description: TODO(这里描述这个方法的需求变更情况)
168 */
169 @AutoLog(value = "运营周报补充填报-通过id删除")
170 @ApiOperation(value="运营周报补充填报-通过id删除", notes="运营周报补充填报-通过id删除")
171 @DeleteMapping(value = "/delete")
172 public Result<?> delete(@RequestParam(name="id",required=true) String id) {
173 try {
174 weekReportRemarkService.removeById(id);
175 } catch (Exception e) {
176 log.error("删除失败",e.getMessage());
177 return Result.error("删除失败!");
178 }
179 return Result.ok("删除成功!");
180 }
181
182 /**
183 * <pre>
184 * 批量删除
185 * </pre>
186 * @param ids
187 * @return
188 * @author 开发者姓名, 开发时间
189 * @Description: TODO(这里描述这个方法的需求变更情况)
190 */
191 @AutoLog(value = "运营周报补充填报-批量删除")
192 @ApiOperation(value="运营周报补充填报-批量删除", notes="运营周报补充填报-批量删除")
193 @DeleteMapping(value = "/deleteBatch")
194 public Result<WeekReportRemark> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
195 Result<WeekReportRemark> result = new Result<WeekReportRemark>();
196 if(ids==null || "".equals(ids.trim())) {
197 result.error500("参数不识别!");
198 }else {
199 this.weekReportRemarkService.removeByIds(Arrays.asList(ids.split(",")));
200 result.success("删除成功!");
201 }
202 return result;
203 }
204 /**
205 * <pre>
206 * 通过id查询
207 * </pre>
208 * @param id
209 * @return
210 * @author 开发者姓名, 开发时间
211 * @Description: TODO(这里描述这个方法的需求变更情况)
212 */
213 @AutoLog(value = "运营周报补充填报-通过id查询")
214 @ApiOperation(value="运营周报补充填报-通过id查询", notes="运营周报补充填报-通过id查询")
215 @GetMapping(value = "/queryById")
216 public Result<WeekReportRemark> queryById(@RequestParam(name="id",required=true) String id) {
217 Result<WeekReportRemark> result = new Result<WeekReportRemark>();
218 WeekReportRemark weekReportRemark = weekReportRemarkService.getById(id);
219 if(weekReportRemark==null) {
220 result.error500("未找到对应实体");
221 }else {
222 result.setResult(weekReportRemark);
223 result.setSuccess(true);
224 }
225 return result;
226 }
227
228 /**
229 * <pre>
230 * 导出excel
231 * </pre>
232 * @param request
233 * @param response
234 * @return
235 * @author 开发者姓名, 开发时间
236 * @Description: TODO(这里描述这个方法的需求变更情况)
237 */
238
239 @RequestMapping(value = "/exportXls")
240 public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
241 // Step.1 组装查询条件
242 QueryWrapper<WeekReportRemark> queryWrapper = null;
243 try {
244 String paramsStr = request.getParameter("paramsStr");
245 if (ConvertUtils.isNotEmpty(paramsStr)) {
246 String deString = URLDecoder.decode(paramsStr, "UTF-8");
247 WeekReportRemark weekReportRemark = JSON.parseObject(deString, WeekReportRemark.class);
248 queryWrapper = QueryGenerator.initQueryWrapper(weekReportRemark, request.getParameterMap());
249 }
250 } catch (UnsupportedEncodingException e) {
251 e.printStackTrace();
252 }
253
254 //Step.2 AutoPoi 导出Excel
255 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
256 List<WeekReportRemark> pageList = weekReportRemarkService.list(queryWrapper);
257 //导出文件名称
258 mv.addObject(NormalExcelConstants.FILE_NAME, "运营周报补充填报列表");
259 mv.addObject(NormalExcelConstants.CLASS, WeekReportRemark.class);
260 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("运营周报补充填报列表数据", "导出人:Jeecg", "导出信息"));
261 mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
262 return mv;
263 }
264
265 /**
266 * <pre>
267 * 通过excel导入数据
268 * </pre>
269 * @param request
270 * @param response
271 * @return
272 * @author 开发者姓名, 开发时间
273 * @Description: TODO(这里描述这个方法的需求变更情况)
274 */
275 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
276 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
277 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
278 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
279 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
280 MultipartFile file = entity.getValue();// 获取上传文件对象
281 ImportParams params = new ImportParams();
282 params.setTitleRows(2);
283 params.setHeadRows(1);
284 params.setNeedSave(true);
285 try {
286 List<WeekReportRemark> listWeekReportRemarks = ExcelImportUtil.importExcel(file.getInputStream(), WeekReportRemark.class, params);
287 weekReportRemarkService.saveBatch(listWeekReportRemarks);
288 return Result.ok("文件导入成功!数据行数:" + listWeekReportRemarks.size());
289 } catch (Exception e) {
290 log.error(e.getMessage(),e);
291 return Result.error("文件导入失败:"+e.getMessage());
292 } finally {
293 try {
294 file.getInputStream().close();
295 } catch (IOException e) {
296 e.printStackTrace();
297 }
298 }
299 }
300 return Result.ok("文件导入失败!");
301 }
302
303 }
1 package com.skua.modules.report.entity;
2
3 import java.io.Serializable;
4 import java.util.Date;
5 import com.baomidou.mybatisplus.annotation.IdType;
6 import com.baomidou.mybatisplus.annotation.TableId;
7 import com.baomidou.mybatisplus.annotation.TableName;
8 import com.baomidou.mybatisplus.annotation.TableField;
9 import io.swagger.annotations.ApiModel;
10 import io.swagger.annotations.ApiModelProperty;
11 import lombok.Data;
12 import lombok.EqualsAndHashCode;
13 import lombok.experimental.Accessors;
14 import com.fasterxml.jackson.annotation.JsonFormat;
15 import org.springframework.format.annotation.DateTimeFormat;
16 import org.jeecgframework.poi.excel.annotation.Excel;
17
18 /**
19 * 运营周报补充填报
20 */
21 @Data
22 @TableName("week_report_remark")
23 @EqualsAndHashCode(callSuper = false)
24 @Accessors(chain = true)
25 @ApiModel(value="week_report_remark对象", description="运营周报补充填报")
26 public class WeekReportRemark {
27
28 /**主键*/
29 @TableId(type = IdType.ID_WORKER_STR)
30 @ApiModelProperty(value = "主键")
31 private String id;
32 /**年月周*/
33 @Excel(name = "年月周", width = 15)
34 @ApiModelProperty(value = "年月周")
35 private String monthWeek;
36 /**工艺达标情况*/
37 @Excel(name = "工艺达标情况", width = 15)
38 @ApiModelProperty(value = "工艺达标情况")
39 private String craftRemark;
40 /**安全工作情况*/
41 @Excel(name = "安全工作情况", width = 15)
42 @ApiModelProperty(value = "安全工作情况")
43 private String safeRemark;
44 /**管理部工作*/
45 @Excel(name = "管理部工作", width = 15)
46 @ApiModelProperty(value = "管理部工作")
47 private String manageRemark;
48 /**所属*/
49 @Excel(name = "所属", width = 15)
50 @ApiModelProperty(value = "所属")
51 private String departId;
52 /**创建人*/
53 @Excel(name = "创建人", width = 15)
54 @ApiModelProperty(value = "创建人")
55 private String createBy;
56 /**创建时间*/
57 @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
58 @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
59 @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
60 @ApiModelProperty(value = "创建时间")
61 private Date createTime;
62 /**修改人*/
63 @Excel(name = "修改人", width = 15)
64 @ApiModelProperty(value = "修改人")
65 private String updateBy;
66 /**修改时间*/
67 @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
68 @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
69 @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
70 @ApiModelProperty(value = "修改时间")
71 private Date updateTime;
72 /**删除状态(0-正常,1-已删除*/
73 @Excel(name = "删除状态(0-正常,1-已删除", width = 15)
74 @ApiModelProperty(value = "删除状态(0-正常,1-已删除")
75 private Integer delFlag;
76 }
1 package com.skua.modules.report.mapper;
2
3 import java.util.List;
4
5 import org.apache.ibatis.annotations.Param;
6 import com.skua.modules.report.entity.WeekReportRemark;
7 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
8
9 /**
10 * 运营周报补充填报
11 */
12 public interface WeekReportRemarkMapper extends BaseMapper<WeekReportRemark> {
13
14 WeekReportRemark getInfo(@Param("monthWeek") String monthWeek);
15 }
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.report.mapper.WeekReportRemarkMapper">
4
5 <select id="getInfo" resultType="com.skua.modules.report.entity.WeekReportRemark">
6 select * from week_report_remark where month_week = #{monthWeek} limit 1
7 </select>
8
9 </mapper>
1 package com.skua.modules.report.service;
2
3 import com.skua.modules.report.entity.WeekReportRemark;
4 import com.baomidou.mybatisplus.extension.service.IService;
5
6 /**
7 * 运营周报补充填报
8 */
9 public interface IWeekReportRemarkService extends IService<WeekReportRemark> {
10
11 WeekReportRemark getInfo(WeekReportRemark weekReportRemark);
12 }
1 package com.skua.modules.report.service.impl;
2
3 import com.skua.modules.report.entity.WeekReportRemark;
4 import com.skua.modules.report.mapper.ReportTargetConfigSubMapper;
5 import com.skua.modules.report.mapper.WeekReportRemarkMapper;
6 import com.skua.modules.report.service.IWeekReportRemarkService;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Service;
9
10 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
12 /**
13 * 运营周报补充填报
14 */
15 @Service
16 public class WeekReportRemarkServiceImpl extends ServiceImpl<WeekReportRemarkMapper, WeekReportRemark> implements IWeekReportRemarkService {
17
18 @Autowired
19 WeekReportRemarkMapper weekReportRemarkMapper;
20
21 @Override
22 public WeekReportRemark getInfo(WeekReportRemark weekReportRemark) {
23 WeekReportRemark remark = new WeekReportRemark();
24 if(weekReportRemark.getMonthWeek()!=null){
25 remark = weekReportRemarkMapper.getInfo(weekReportRemark.getMonthWeek());
26 }
27 return remark;
28 }
29 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!