89bf371f sonin

安全环保费用 模块

1 个父辈 aec197c9
1 package com.skua.modules.safe.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
12 import cn.hutool.core.bean.BeanUtil;
13 import com.skua.core.api.vo.Result;
14 import com.skua.core.aspect.annotation.AutoLog;
15 import com.skua.core.context.BaseContextHandler;
16 import com.skua.core.query.QueryGenerator;
17 import com.skua.core.service.ISequenceService;
18 import com.skua.core.util.ConvertUtils;
19 import com.skua.modules.biz.IBusinessService;
20 import com.skua.modules.safe.dto.SafetyEnvironmentFeeDTO;
21 import com.skua.modules.safe.entity.SafetyEnvironmentFee;
22 import com.skua.modules.safe.service.ISafetyEnvironmentFeeService;
23
24 import java.util.Date;
25 import java.util.stream.Collectors;
26
27 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
28 import com.baomidou.mybatisplus.core.metadata.IPage;
29 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
30 import lombok.extern.slf4j.Slf4j;
31
32 import org.apache.commons.lang3.StringUtils;
33 import org.jeecgframework.poi.excel.ExcelImportUtil;
34 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
35 import org.jeecgframework.poi.excel.entity.ExportParams;
36 import org.jeecgframework.poi.excel.entity.ImportParams;
37 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
38
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.web.bind.annotation.*;
41 import org.springframework.web.multipart.MultipartFile;
42 import org.springframework.web.multipart.MultipartHttpServletRequest;
43 import org.springframework.web.servlet.ModelAndView;
44 import com.alibaba.fastjson.JSON;
45 import io.swagger.annotations.Api;
46 import io.swagger.annotations.ApiOperation;
47
48 /**
49 * <pre>
50 * 安全环保费用
51 * </pre>
52 *
53 * @author 开发者姓名
54 * @version V0.1, 开发时间
55 */
56 @Slf4j
57 @Api(tags = "安全环保费用")
58 @RestController
59 @RequestMapping("/safe/safetyEnvironmentFee")
60 public class SafetyEnvironmentFeeController {
61 @Autowired
62 private ISafetyEnvironmentFeeService safetyEnvironmentFeeService;
63 @Autowired
64 private IBusinessService businessService;
65
66 /**
67 * <pre>
68 * 分页列表查询
69 * </pre>
70 *
71 * @param safetyEnvironmentFee
72 * @param pageNo
73 * @param pageSize
74 * @param req
75 * @return
76 * @author 开发者姓名, 开发时间
77 * @Description: TODO(这里描述这个方法的需求变更情况)
78 */
79
80 @AutoLog(value = "安全环保费用-分页列表查询")
81 @ApiOperation(value = "安全环保费用-分页列表查询", notes = "安全环保费用-分页列表查询")
82 @GetMapping(value = "/list")
83 public Result<IPage<SafetyEnvironmentFee>> queryPageList(SafetyEnvironmentFee safetyEnvironmentFee,
84 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
85 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
86 HttpServletRequest req) {
87 Result<IPage<SafetyEnvironmentFee>> result = new Result<IPage<SafetyEnvironmentFee>>();
88 QueryWrapper<SafetyEnvironmentFee> queryWrapper = QueryGenerator.initQueryWrapper(safetyEnvironmentFee, req.getParameterMap());
89 Page<SafetyEnvironmentFee> page = new Page<SafetyEnvironmentFee>(pageNo, pageSize);
90 IPage<SafetyEnvironmentFee> pageList = safetyEnvironmentFeeService.page(page, queryWrapper);
91 result.setSuccess(true);
92 result.setResult(pageList);
93 return result;
94 }
95
96 @GetMapping(value = "/query/{type}")
97 public Result<Object> queryTypeCtrl(@PathVariable String type, SafetyEnvironmentFeeDTO safetyEnvironmentFeeDTO) {
98 Result<Object> result = new Result<>();
99 // 请求参数
100 String departId = safetyEnvironmentFeeDTO.getDepartId();
101 String feeDict = safetyEnvironmentFeeDTO.getFeeDict();
102 String feeType = safetyEnvironmentFeeDTO.getFeeType();
103 String startTime = safetyEnvironmentFeeDTO.getStartTime();
104 String endTime = safetyEnvironmentFeeDTO.getEndTime();
105 Long pageNo = safetyEnvironmentFeeDTO.getPageNo();
106 Long pageSize = safetyEnvironmentFeeDTO.getPageSize();
107 if (StringUtils.isEmpty(feeDict)) {
108 return Result.error("费用字典不能为空");
109 }
110 // 查询条件
111 QueryWrapper<SafetyEnvironmentFee> queryWrapper0 = new QueryWrapper<>();
112 queryWrapper0.eq(StringUtils.isNotEmpty(departId), "depart_id", departId)
113 .eq("fee_dict", feeDict)
114 .eq(StringUtils.isNotEmpty(feeType), "fee_type", feeType)
115 .ge(StringUtils.isNotEmpty(startTime), "fee_time", startTime)
116 .le(StringUtils.isNotEmpty(endTime), "fee_time", endTime);
117 if ("page".equals(type)) {
118 IPage<SafetyEnvironmentFee> safetyEnvironmentFeeIPage = safetyEnvironmentFeeService.page(new Page<>(pageNo, pageSize), queryWrapper0);
119 // 翻译
120 Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", null);
121 Map<String, String> safetyEnvironmentProtectionFeeDictMap = businessService.dictMap("safety_environment_protection_fee", null);
122 Map<String, String> energyEnvironmentProtectionFeeDictMap = businessService.dictMap("energy_environment_protection_fee", null);
123 // 封装结果
124 IPage<Map<String, Object>> mapIPage = new Page<>(pageNo, pageSize);
125 mapIPage.setTotal(safetyEnvironmentFeeIPage.getTotal());
126 mapIPage.setRecords(safetyEnvironmentFeeIPage.getRecords().stream().map(item -> {
127 Map<String, Object> entityMap = BeanUtil.beanToMap(item);
128 entityMap.put("departName", sysDepartDictMap.get(item.getDepartId()));
129 // 安全环保费
130 if ("1".equals(feeDict)) {
131 entityMap.put("feeType_dictText", safetyEnvironmentProtectionFeeDictMap.get(item.getFeeType()));
132 } else if ("2".equals(feeDict)) {
133 // 节能环保费
134 entityMap.put("feeType_dictText", energyEnvironmentProtectionFeeDictMap.get(item.getFeeType()));
135 }
136 return entityMap;
137 }).collect(Collectors.toList()));
138 result.setResult(mapIPage);
139 } else if ("statistics".equals(type)) {
140 queryWrapper0.select("sum(fee_value) as feeValueSum");
141 Map<String, Object> queryMap0 = safetyEnvironmentFeeService.getMap(queryWrapper0);
142 result.setResult(queryMap0);
143 }
144 return result;
145 }
146
147 /**
148 * <pre>
149 * 添加
150 * </pre>
151 *
152 * @param safetyEnvironmentFee
153 * @return
154 * @author 开发者姓名, 开发时间
155 * @Description: TODO(这里描述这个方法的需求变更情况)
156 */
157 @AutoLog(value = "安全环保费用-添加")
158 @ApiOperation(value = "安全环保费用-添加", notes = "安全环保费用-添加")
159 @PostMapping(value = "/add")
160 public Result<SafetyEnvironmentFee> add(@RequestBody SafetyEnvironmentFee safetyEnvironmentFee) {
161 Result<SafetyEnvironmentFee> result = new Result<SafetyEnvironmentFee>();
162 try {
163 safetyEnvironmentFeeService.save(safetyEnvironmentFee);
164 result.success("添加成功!");
165 } catch (Exception e) {
166 log.error(e.getMessage(), e);
167 result.error500("操作失败");
168 }
169 return result;
170 }
171
172 /**
173 * <pre>
174 * 编辑
175 * </pre>
176 *
177 * @param safetyEnvironmentFee
178 * @return
179 * @author 开发者姓名, 开发时间
180 * @Description: TODO(这里描述这个方法的需求变更情况)
181 */
182 @AutoLog(value = "安全环保费用-编辑")
183 @ApiOperation(value = "安全环保费用-编辑", notes = "安全环保费用-编辑")
184 @PutMapping(value = "/edit")
185 public Result<SafetyEnvironmentFee> edit(@RequestBody SafetyEnvironmentFee safetyEnvironmentFee) {
186 Result<SafetyEnvironmentFee> result = new Result<SafetyEnvironmentFee>();
187 SafetyEnvironmentFee safetyEnvironmentFeeEntity = safetyEnvironmentFeeService.getById(safetyEnvironmentFee.getId());
188 if (safetyEnvironmentFeeEntity == null) {
189 result.error500("未找到对应实体");
190 } else {
191 boolean ok = safetyEnvironmentFeeService.updateById(safetyEnvironmentFee);
192 //TODO 返回false说明什么?
193 if (ok) {
194 result.success("修改成功!");
195 }
196 }
197
198 return result;
199 }
200
201 /**
202 * <pre>
203 * 通过id删除
204 * </pre>
205 *
206 * @param id
207 * @return
208 * @author 开发者姓名, 开发时间
209 * @Description: TODO(这里描述这个方法的需求变更情况)
210 */
211 @AutoLog(value = "安全环保费用-通过id删除")
212 @ApiOperation(value = "安全环保费用-通过id删除", notes = "安全环保费用-通过id删除")
213 @DeleteMapping(value = "/delete")
214 public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
215 try {
216 safetyEnvironmentFeeService.removeById(id);
217 } catch (Exception e) {
218 log.error("删除失败", e.getMessage());
219 return Result.error("删除失败!");
220 }
221 return Result.ok("删除成功!");
222 }
223
224 /**
225 * <pre>
226 * 批量删除
227 * </pre>
228 *
229 * @param ids
230 * @return
231 * @author 开发者姓名, 开发时间
232 * @Description: TODO(这里描述这个方法的需求变更情况)
233 */
234 @AutoLog(value = "安全环保费用-批量删除")
235 @ApiOperation(value = "安全环保费用-批量删除", notes = "安全环保费用-批量删除")
236 @DeleteMapping(value = "/deleteBatch")
237 public Result<SafetyEnvironmentFee> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
238 Result<SafetyEnvironmentFee> result = new Result<SafetyEnvironmentFee>();
239 if (ids == null || "".equals(ids.trim())) {
240 result.error500("参数不识别!");
241 } else {
242 this.safetyEnvironmentFeeService.removeByIds(Arrays.asList(ids.split(",")));
243 result.success("删除成功!");
244 }
245 return result;
246 }
247
248 /**
249 * <pre>
250 * 通过id查询
251 * </pre>
252 *
253 * @param id
254 * @return
255 * @author 开发者姓名, 开发时间
256 * @Description: TODO(这里描述这个方法的需求变更情况)
257 */
258 @AutoLog(value = "安全环保费用-通过id查询")
259 @ApiOperation(value = "安全环保费用-通过id查询", notes = "安全环保费用-通过id查询")
260 @GetMapping(value = "/queryById")
261 public Result<SafetyEnvironmentFee> queryById(@RequestParam(name = "id", required = true) String id) {
262 Result<SafetyEnvironmentFee> result = new Result<SafetyEnvironmentFee>();
263 SafetyEnvironmentFee safetyEnvironmentFee = safetyEnvironmentFeeService.getById(id);
264 if (safetyEnvironmentFee == null) {
265 result.error500("未找到对应实体");
266 } else {
267 result.setResult(safetyEnvironmentFee);
268 result.setSuccess(true);
269 }
270 return result;
271 }
272
273 /**
274 * <pre>
275 * 导出excel
276 * </pre>
277 *
278 * @param request
279 * @param response
280 * @return
281 * @author 开发者姓名, 开发时间
282 * @Description: TODO(这里描述这个方法的需求变更情况)
283 */
284
285 @RequestMapping(value = "/exportXls")
286 public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
287 // Step.1 组装查询条件
288 QueryWrapper<SafetyEnvironmentFee> queryWrapper = null;
289 try {
290 String paramsStr = request.getParameter("paramsStr");
291 if (ConvertUtils.isNotEmpty(paramsStr)) {
292 String deString = URLDecoder.decode(paramsStr, "UTF-8");
293 SafetyEnvironmentFee safetyEnvironmentFee = JSON.parseObject(deString, SafetyEnvironmentFee.class);
294 queryWrapper = QueryGenerator.initQueryWrapper(safetyEnvironmentFee, request.getParameterMap());
295 }
296 } catch (UnsupportedEncodingException e) {
297 e.printStackTrace();
298 }
299
300 //Step.2 AutoPoi 导出Excel
301 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
302 List<SafetyEnvironmentFee> pageList = safetyEnvironmentFeeService.list(queryWrapper);
303 //导出文件名称
304 mv.addObject(NormalExcelConstants.FILE_NAME, "安全环保费用列表");
305 mv.addObject(NormalExcelConstants.CLASS, SafetyEnvironmentFee.class);
306 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("安全环保费用列表数据", "导出人:Jeecg", "导出信息"));
307 mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
308 return mv;
309 }
310
311 /**
312 * <pre>
313 * 通过excel导入数据
314 * </pre>
315 *
316 * @param request
317 * @param response
318 * @return
319 * @author 开发者姓名, 开发时间
320 * @Description: TODO(这里描述这个方法的需求变更情况)
321 */
322 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
323 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
324 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
325 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
326 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
327 MultipartFile file = entity.getValue();// 获取上传文件对象
328 ImportParams params = new ImportParams();
329 params.setTitleRows(2);
330 params.setHeadRows(1);
331 params.setNeedSave(true);
332 try {
333 List<SafetyEnvironmentFee> listSafetyEnvironmentFees = ExcelImportUtil.importExcel(file.getInputStream(), SafetyEnvironmentFee.class, params);
334 safetyEnvironmentFeeService.saveBatch(listSafetyEnvironmentFees);
335 return Result.ok("文件导入成功!数据行数:" + listSafetyEnvironmentFees.size());
336 } catch (Exception e) {
337 log.error(e.getMessage(), e);
338 return Result.error("文件导入失败:" + e.getMessage());
339 } finally {
340 try {
341 file.getInputStream().close();
342 } catch (IOException e) {
343 e.printStackTrace();
344 }
345 }
346 }
347 return Result.ok("文件导入失败!");
348 }
349
350 }
1 package com.skua.modules.safe.dto;
2
3 import com.skua.modules.safe.entity.SafetyEnvironmentFee;
4 import lombok.Data;
5
6 /**
7 * @Author:sonin
8 * @Date:2025/4/7 11:12
9 */
10 @Data
11 public class SafetyEnvironmentFeeDTO extends SafetyEnvironmentFee {
12
13 private Long pageNo = 1L;
14
15 private Long pageSize = 10L;
16
17 private String startTime;
18
19 private String endTime;
20 }
1 package com.skua.modules.safe.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("safety_environment_fee")
22 @EqualsAndHashCode(callSuper = false)
23 @Accessors(chain = true)
24 @ApiModel(value = "safety_environment_fee对象", description = "安全环保费用")
25 public class SafetyEnvironmentFee {
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 departId;
39 /**
40 * 费用字典(安全环保费:1、节能环保费:2)
41 */
42 @Excel(name = "费用字典(安全环保费:1、节能环保费:2)", width = 15)
43 @ApiModelProperty(value = "费用字典(安全环保费:1、节能环保费:2)")
44 private String feeDict;
45 /**
46 * 费用类别属性
47 */
48 @Excel(name = "费用类别属性", width = 15)
49 @ApiModelProperty(value = "费用类别属性")
50 private String feeType;
51 /**
52 * 费用名称
53 */
54 @Excel(name = "费用名称", width = 15)
55 @ApiModelProperty(value = "费用名称")
56 private String feeName;
57 /**
58 * 时间(日)
59 */
60 @Excel(name = "时间(日)", width = 15)
61 @ApiModelProperty(value = "时间(日)")
62 private String feeTime;
63 /**
64 * 费用(元)
65 */
66 @Excel(name = "费用(元)", width = 15)
67 @ApiModelProperty(value = "费用(元)")
68 private String feeValue;
69 /**
70 * 是否预算内(是、否)
71 */
72 @Excel(name = "是否预算内(是、否)", width = 15)
73 @ApiModelProperty(value = "是否预算内(是、否)")
74 private String budgetFlag;
75 /**
76 * 用途
77 */
78 @Excel(name = "用途", width = 15)
79 @ApiModelProperty(value = "用途")
80 private String feeUsage;
81 /**
82 * 使用部门
83 */
84 @Excel(name = "使用部门", width = 15)
85 @ApiModelProperty(value = "使用部门")
86 private String useDepartment;
87 /**
88 * 备注
89 */
90 @Excel(name = "备注", width = 15)
91 @ApiModelProperty(value = "备注")
92 private String remark;
93 /**
94 * 创建人
95 */
96 @Excel(name = "创建人", width = 15)
97 @ApiModelProperty(value = "创建人")
98 private String createBy;
99 /**
100 * 创建日期
101 */
102 @Excel(name = "创建日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
103 @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
104 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
105 @ApiModelProperty(value = "创建日期")
106 private Date createTime;
107 /**
108 * 更新人
109 */
110 @Excel(name = "更新人", width = 15)
111 @ApiModelProperty(value = "更新人")
112 private String updateBy;
113 /**
114 * 更新日期
115 */
116 @Excel(name = "更新日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
117 @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
118 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
119 @ApiModelProperty(value = "更新日期")
120 private Date updateTime;
121 /**
122 * 排序字段
123 */
124 @Excel(name = "排序字段", width = 15)
125 @ApiModelProperty(value = "排序字段")
126 private Integer orderNum;
127 /**
128 * 删除状态(0正常;1已删除)
129 */
130 @Excel(name = "删除状态(0正常;1已删除)", width = 15)
131 @ApiModelProperty(value = "删除状态(0正常;1已删除)")
132 private String delFlag;
133 }
1 package com.skua.modules.safe.mapper;
2
3 import com.skua.modules.safe.entity.SafetyEnvironmentFee;
4 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
6 /**
7 * 安全环保费用
8 */
9 public interface SafetyEnvironmentFeeMapper extends BaseMapper<SafetyEnvironmentFee> {
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.safe.mapper.SafetyEnvironmentFeeMapper">
4
5 </mapper>
...\ No newline at end of file ...\ No newline at end of file
1 package com.skua.modules.safe.service;
2
3 import com.skua.modules.safe.entity.SafetyEnvironmentFee;
4 import com.baomidou.mybatisplus.extension.service.IService;
5
6 /**
7 * 安全环保费用
8 */
9 public interface ISafetyEnvironmentFeeService extends IService<SafetyEnvironmentFee> {
10
11 }
1 package com.skua.modules.safe.service.impl;
2
3 import com.skua.modules.safe.entity.SafetyEnvironmentFee;
4 import com.skua.modules.safe.mapper.SafetyEnvironmentFeeMapper;
5 import com.skua.modules.safe.service.ISafetyEnvironmentFeeService;
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 SafetyEnvironmentFeeServiceImpl extends ServiceImpl<SafetyEnvironmentFeeMapper, SafetyEnvironmentFee> implements ISafetyEnvironmentFeeService {
15
16 }
...@@ -170,6 +170,7 @@ public class MybatisInterceptor implements Interceptor { ...@@ -170,6 +170,7 @@ public class MybatisInterceptor implements Interceptor {
170 || "com.skua.modules.safe.mapper.DangerLevelManageShareMapper.selectPage".equals(sqlId) 170 || "com.skua.modules.safe.mapper.DangerLevelManageShareMapper.selectPage".equals(sqlId)
171 || "com.skua.modules.edu.mapper.QuestionMapper.selectQuestionList".equals(sqlId)//试题列表 171 || "com.skua.modules.edu.mapper.QuestionMapper.selectQuestionList".equals(sqlId)//试题列表
172 || "com.skua.modules.edu.mapper.QuestionMapper.queryPageList".equals(sqlId)//试题分页 172 || "com.skua.modules.edu.mapper.QuestionMapper.queryPageList".equals(sqlId)//试题分页
173 || "com.skua.modules.safe.mapper.SafetyEnvironmentFeeMapper.selectPage".equals(sqlId)//安全环保费
173 ) { 174 ) {
174 log.debug("************************------sqlId------**************************" + sqlId); 175 log.debug("************************------sqlId------**************************" + sqlId);
175 return invocation.proceed(); 176 return invocation.proceed();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!