|
|
@@ -1,5 +1,7 @@
|
|
|
package cn.com.ctop.reimburse.mondule.controller;
|
|
|
|
|
|
+import cn.com.ctop.common.module.service.ISysUserService;
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.reimburse.mondule.entity.ReimburseExpress;
|
|
|
import cn.com.ctop.reimburse.mondule.service.IReimburseExpressService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -10,6 +12,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.entity.SysUser;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
@@ -26,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
@@ -55,6 +59,9 @@ public class ReimburseExpressController {
|
|
|
@Autowired
|
|
|
private IReimburseExpressService reimburseExpressService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
|
@@ -71,7 +78,17 @@ public class ReimburseExpressController {
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
Result<IPage<ReimburseExpress>> result = new Result<>();
|
|
|
+ String statDate = reimburseExpress.getStatDate();
|
|
|
+ String userId = reimburseExpress.getUserId();
|
|
|
+ reimburseExpress = new ReimburseExpress();
|
|
|
QueryWrapper<ReimburseExpress> queryWrapper = QueryGenerator.initQueryWrapper(reimburseExpress, req.getParameterMap());
|
|
|
+ if (!Check.isNull(statDate)) {
|
|
|
+ queryWrapper.likeLeft("stat_date", statDate);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(userId)) {
|
|
|
+ queryWrapper.likeLeft("user_id", userId);
|
|
|
+ }
|
|
|
+
|
|
|
Page<ReimburseExpress> page = new Page<ReimburseExpress>(pageNo, pageSize);
|
|
|
IPage<ReimburseExpress> pageList = reimburseExpressService.page(page, queryWrapper);
|
|
|
result.setSuccess(true);
|
|
|
@@ -81,15 +98,15 @@ public class ReimburseExpressController {
|
|
|
|
|
|
/**
|
|
|
* 添加
|
|
|
- *
|
|
|
- * @param reimburseExpress
|
|
|
- * @return
|
|
|
*/
|
|
|
- @ApiOperation(value = "报销申请——快递记录表-添加", notes = "报销申请——快递记录表-添加")
|
|
|
@PostMapping(value = "/add")
|
|
|
public Result<ReimburseExpress> add(@RequestBody ReimburseExpress reimburseExpress) {
|
|
|
Result<ReimburseExpress> result = new Result<>();
|
|
|
try {
|
|
|
+ SysUser user = sysUserService.getById(reimburseExpress.getUserId());
|
|
|
+ if (!Check.isNull(user)) {
|
|
|
+ reimburseExpress.setUserName(user.getRealname());
|
|
|
+ }
|
|
|
reimburseExpressService.save(reimburseExpress);
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
|
@@ -100,13 +117,31 @@ public class ReimburseExpressController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 导入EXCEL批量创建
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/importExcel")
|
|
|
+ @ResponseBody
|
|
|
+ public Result<Object> importExcel(HttpServletResponse response, @RequestParam("file") MultipartFile file) {
|
|
|
+ response.setHeader("Access-Control-Allow-Origin", "*");
|
|
|
+ try {
|
|
|
+ if (Check.isNull(file)) {
|
|
|
+ return Result.error("执行失败,请上传应用Excel文件");
|
|
|
+ }
|
|
|
+ return reimburseExpressService.importExcel(file);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return Result.error("导入EXCEL失败," + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 编辑
|
|
|
*
|
|
|
* @param reimburseExpress
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "报销申请——快递记录表-编辑", notes = "报销申请——快递记录表-编辑")
|
|
|
- @PutMapping(value = "/edit")
|
|
|
+ @PostMapping(value = "/edit")
|
|
|
public Result<ReimburseExpress> edit(@RequestBody ReimburseExpress reimburseExpress) {
|
|
|
Result<ReimburseExpress> result = new Result<ReimburseExpress>();
|
|
|
ReimburseExpress reimburseExpressEntity = reimburseExpressService.getById(reimburseExpress.getId());
|
|
|
@@ -129,7 +164,7 @@ public class ReimburseExpressController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "报销申请——快递记录表-通过id删除", notes = "报销申请——快递记录表-通过id删除")
|
|
|
- @DeleteMapping(value = "/delete")
|
|
|
+ @GetMapping(value = "/delete")
|
|
|
public Result<?> delete(@RequestParam(name = "id") String id) {
|
|
|
try {
|
|
|
reimburseExpressService.removeById(id);
|
|
|
@@ -140,24 +175,6 @@ public class ReimburseExpressController {
|
|
|
return Result.ok("删除成功!");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 批量删除
|
|
|
- *
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "报销申请——快递记录表-批量删除", notes = "报销申请——快递记录表-批量删除")
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<ReimburseExpress> deleteBatch(@RequestParam(name = "ids") String ids) {
|
|
|
- Result<ReimburseExpress> result = new Result<>();
|
|
|
- if (ids == null || "".equals(ids.trim())) {
|
|
|
- result.error500("参数不识别!");
|
|
|
- } else {
|
|
|
- this.reimburseExpressService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
- result.success("删除成功!");
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 通过id查询
|
|
|
@@ -178,72 +195,4 @@ public class ReimburseExpressController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- // Step.1 组装查询条件
|
|
|
- QueryWrapper<ReimburseExpress> queryWrapper = null;
|
|
|
- try {
|
|
|
- String paramsStr = request.getParameter("paramsStr");
|
|
|
- if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
|
- String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
|
- ReimburseExpress reimburseExpress = JSON.parseObject(deString, ReimburseExpress.class);
|
|
|
- queryWrapper = QueryGenerator.initQueryWrapper(reimburseExpress, request.getParameterMap());
|
|
|
- }
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- //Step.2 AutoPoi 导出Excel
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- List<ReimburseExpress> pageList = reimburseExpressService.list(queryWrapper);
|
|
|
- //导出文件名称
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "报销申请——快递记录表列表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, ReimburseExpress.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("报销申请——快递记录表列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @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<ReimburseExpress> listReimburseExpresss = ExcelImportUtil.importExcel(file.getInputStream(), ReimburseExpress.class, params);
|
|
|
- reimburseExpressService.saveBatch(listReimburseExpresss);
|
|
|
- return Result.ok("文件导入成功!数据行数:" + listReimburseExpresss.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("文件导入失败!");
|
|
|
- }
|
|
|
-
|
|
|
}
|