|
@@ -1,41 +1,27 @@
|
|
|
package cn.com.ctop.reimburse.mondule.controller;
|
|
package cn.com.ctop.reimburse.mondule.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 org.jeecg.common.api.vo.Result;
|
|
|
|
|
-import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
|
|
import cn.com.ctop.reimburse.mondule.entity.ReimburseProject;
|
|
import cn.com.ctop.reimburse.mondule.entity.ReimburseProject;
|
|
|
import cn.com.ctop.reimburse.mondule.service.IReimburseProjectService;
|
|
import cn.com.ctop.reimburse.mondule.service.IReimburseProjectService;
|
|
|
-
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
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.jeecg.common.api.vo.Result;
|
|
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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;
|
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 报销申请项目表
|
|
* 报销申请项目表
|
|
@@ -47,21 +33,14 @@ import io.swagger.annotations.ApiOperation;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Api(tags = "报销申请项目表")
|
|
@Api(tags = "报销申请项目表")
|
|
|
@RestController
|
|
@RestController
|
|
|
-@RequestMapping("/reimburse.mondule/reimburseProject")
|
|
|
|
|
|
|
+@RequestMapping("/reimburse/project")
|
|
|
public class ReimburseProjectController {
|
|
public class ReimburseProjectController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IReimburseProjectService reimburseProjectService;
|
|
private IReimburseProjectService reimburseProjectService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 分页列表查询
|
|
* 分页列表查询
|
|
|
- *
|
|
|
|
|
- * @param reimburseProject
|
|
|
|
|
- * @param pageNo
|
|
|
|
|
- * @param pageSize
|
|
|
|
|
- * @param req
|
|
|
|
|
- * @return
|
|
|
|
|
*/
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请项目表-分页列表查询", notes = "报销申请项目表-分页列表查询")
|
|
|
|
|
@GetMapping(value = "/list")
|
|
@GetMapping(value = "/list")
|
|
|
public Result<IPage<ReimburseProject>> queryPageList(ReimburseProject reimburseProject,
|
|
public Result<IPage<ReimburseProject>> queryPageList(ReimburseProject reimburseProject,
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
@@ -78,11 +57,7 @@ public class ReimburseProjectController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 添加
|
|
* 添加
|
|
|
- *
|
|
|
|
|
- * @param reimburseProject
|
|
|
|
|
- * @return
|
|
|
|
|
*/
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请项目表-添加", notes = "报销申请项目表-添加")
|
|
|
|
|
@PostMapping(value = "/add")
|
|
@PostMapping(value = "/add")
|
|
|
public Result<ReimburseProject> add(@RequestBody ReimburseProject reimburseProject) {
|
|
public Result<ReimburseProject> add(@RequestBody ReimburseProject reimburseProject) {
|
|
|
Result<ReimburseProject> result = new Result<>();
|
|
Result<ReimburseProject> result = new Result<>();
|
|
@@ -98,12 +73,8 @@ public class ReimburseProjectController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 编辑
|
|
* 编辑
|
|
|
- *
|
|
|
|
|
- * @param reimburseProject
|
|
|
|
|
- * @return
|
|
|
|
|
*/
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请项目表-编辑", notes = "报销申请项目表-编辑")
|
|
|
|
|
- @PutMapping(value = "/edit")
|
|
|
|
|
|
|
+ @PostMapping(value = "/edit")
|
|
|
public Result<ReimburseProject> edit(@RequestBody ReimburseProject reimburseProject) {
|
|
public Result<ReimburseProject> edit(@RequestBody ReimburseProject reimburseProject) {
|
|
|
Result<ReimburseProject> result = new Result<ReimburseProject>();
|
|
Result<ReimburseProject> result = new Result<ReimburseProject>();
|
|
|
ReimburseProject reimburseProjectEntity = reimburseProjectService.getById(reimburseProject.getId());
|
|
ReimburseProject reimburseProjectEntity = reimburseProjectService.getById(reimburseProject.getId());
|
|
@@ -121,12 +92,8 @@ public class ReimburseProjectController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 通过id删除
|
|
* 通过id删除
|
|
|
- *
|
|
|
|
|
- * @param id
|
|
|
|
|
- * @return
|
|
|
|
|
*/
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请项目表-通过id删除", notes = "报销申请项目表-通过id删除")
|
|
|
|
|
- @DeleteMapping(value = "/delete")
|
|
|
|
|
|
|
+ @GetMapping(value = "/delete")
|
|
|
public Result<?> delete(@RequestParam(name = "id") String id) {
|
|
public Result<?> delete(@RequestParam(name = "id") String id) {
|
|
|
try {
|
|
try {
|
|
|
reimburseProjectService.removeById(id);
|
|
reimburseProjectService.removeById(id);
|
|
@@ -139,12 +106,8 @@ public class ReimburseProjectController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 批量删除
|
|
* 批量删除
|
|
|
- *
|
|
|
|
|
- * @param ids
|
|
|
|
|
- * @return
|
|
|
|
|
*/
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请项目表-批量删除", notes = "报销申请项目表-批量删除")
|
|
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
|
|
|
|
+ @GetMapping(value = "/deleteBatch")
|
|
|
public Result<ReimburseProject> deleteBatch(@RequestParam(name = "ids") String ids) {
|
|
public Result<ReimburseProject> deleteBatch(@RequestParam(name = "ids") String ids) {
|
|
|
Result<ReimburseProject> result = new Result<>();
|
|
Result<ReimburseProject> result = new Result<>();
|
|
|
if (ids == null || "".equals(ids.trim())) {
|
|
if (ids == null || "".equals(ids.trim())) {
|
|
@@ -158,11 +121,7 @@ public class ReimburseProjectController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 通过id查询
|
|
* 通过id查询
|
|
|
- *
|
|
|
|
|
- * @param id
|
|
|
|
|
- * @return
|
|
|
|
|
*/
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请项目表-通过id查询", notes = "报销申请项目表-通过id查询")
|
|
|
|
|
@GetMapping(value = "/queryById")
|
|
@GetMapping(value = "/queryById")
|
|
|
public Result<ReimburseProject> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
public Result<ReimburseProject> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
Result<ReimburseProject> result = new Result<>();
|
|
Result<ReimburseProject> result = new Result<>();
|
|
@@ -177,70 +136,13 @@ public class ReimburseProjectController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 导出excel
|
|
|
|
|
- *
|
|
|
|
|
- * @param request
|
|
|
|
|
- * @param response
|
|
|
|
|
- */
|
|
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
- // Step.1 组装查询条件
|
|
|
|
|
- QueryWrapper<ReimburseProject> queryWrapper = null;
|
|
|
|
|
- try {
|
|
|
|
|
- String paramsStr = request.getParameter("paramsStr");
|
|
|
|
|
- if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
|
|
|
- String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
|
|
|
- ReimburseProject reimburseProject = JSON.parseObject(deString, ReimburseProject.class);
|
|
|
|
|
- queryWrapper = QueryGenerator.initQueryWrapper(reimburseProject, request.getParameterMap());
|
|
|
|
|
- }
|
|
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //Step.2 AutoPoi 导出Excel
|
|
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
|
|
- List<ReimburseProject> pageList = reimburseProjectService.list(queryWrapper);
|
|
|
|
|
- //导出文件名称
|
|
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "报销申请项目表列表");
|
|
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, ReimburseProject.class);
|
|
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("报销申请项目表列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
|
|
- return mv;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 通过excel导入数据
|
|
|
|
|
- *
|
|
|
|
|
- * @param request
|
|
|
|
|
- * @param response
|
|
|
|
|
- * @return
|
|
|
|
|
|
|
+ * 通过id查询
|
|
|
*/
|
|
*/
|
|
|
- @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<ReimburseProject> listReimburseProjects = ExcelImportUtil.importExcel(file.getInputStream(), ReimburseProject.class, params);
|
|
|
|
|
- reimburseProjectService.saveBatch(listReimburseProjects);
|
|
|
|
|
- return Result.ok("文件导入成功!数据行数:" + listReimburseProjects.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("文件导入失败!");
|
|
|
|
|
|
|
+ @PostMapping(value = "/queryByIds")
|
|
|
|
|
+ public Result<Object> queryByIds(@RequestBody JSONArray data) {
|
|
|
|
|
+ List<String> ids = JSONObject.parseArray(data.toJSONString(), String.class);
|
|
|
|
|
+ List<ReimburseProject> list = reimburseProjectService.getByIds(ids);
|
|
|
|
|
+ return Result.ok(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|