|
@@ -0,0 +1,372 @@
|
|
|
+package org.jeecg.modules.oa.controller;
|
|
|
+
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+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.system.vo.LoginUser;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.oa.entity.IncidentTicketChildren;
|
|
|
+import org.jeecg.modules.oa.entity.IncidentTicket;
|
|
|
+import org.jeecg.modules.oa.vo.IncidentTicketPage;
|
|
|
+import org.jeecg.modules.oa.service.IIncidentTicketService;
|
|
|
+import org.jeecg.modules.oa.service.IIncidentTicketChildrenService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 森_工厂质量事故单-主表
|
|
|
+ * @Author: jeecg-boot
|
|
|
+ * @Date: 2023-02-22
|
|
|
+ * @Version: V1.0
|
|
|
+ */
|
|
|
+@Api(tags="森_工厂质量事故单-主表")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/oa/incidentTicket")
|
|
|
+@Slf4j
|
|
|
+public class IncidentTicketController {
|
|
|
+ @Autowired
|
|
|
+ private IIncidentTicketService incidentTicketService;
|
|
|
+ @Autowired
|
|
|
+ private IIncidentTicketChildrenService incidentTicketChildrenService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param incidentTicket
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-主表-分页列表查询")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-主表-分页列表查询", notes="森_工厂质量事故单-主表-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<?> queryPageList(IncidentTicket incidentTicket,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<IncidentTicket> queryWrapper = QueryGenerator.initQueryWrapper(incidentTicket, req.getParameterMap());
|
|
|
+ Page<IncidentTicket> page = new Page<IncidentTicket>(pageNo, pageSize);
|
|
|
+ IPage<IncidentTicket> pageList = incidentTicketService.page(page, queryWrapper);
|
|
|
+ return Result.ok(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param incidentTicketPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-主表-添加")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-主表-添加", notes="森_工厂质量事故单-主表-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<?> add(@RequestBody IncidentTicketPage incidentTicketPage) {
|
|
|
+ IncidentTicket incidentTicket = new IncidentTicket();
|
|
|
+ BeanUtils.copyProperties(incidentTicketPage, incidentTicket);
|
|
|
+ incidentTicketService.saveMain(incidentTicket, incidentTicketPage.getIncidentTicketChildrenList());
|
|
|
+ return Result.ok("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param incidentTicketPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-主表-编辑")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-主表-编辑", notes="森_工厂质量事故单-主表-编辑")
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
+ public Result<?> edit(@RequestBody IncidentTicketPage incidentTicketPage) {
|
|
|
+ IncidentTicket incidentTicket = new IncidentTicket();
|
|
|
+ BeanUtils.copyProperties(incidentTicketPage, incidentTicket);
|
|
|
+ IncidentTicket incidentTicketEntity = incidentTicketService.getById(incidentTicket.getId());
|
|
|
+ if(incidentTicketEntity==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ incidentTicketService.updateMain(incidentTicket, incidentTicketPage.getIncidentTicketChildrenList());
|
|
|
+ return Result.ok("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-主表-通过id删除")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-主表-通过id删除", notes="森_工厂质量事故单-主表-通过id删除")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ incidentTicketService.delMain(id);
|
|
|
+ return Result.ok("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-主表-批量删除")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-主表-批量删除", notes="森_工厂质量事故单-主表-批量删除")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
+ this.incidentTicketService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.ok("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-主表-通过id查询")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-主表-通过id查询", notes="森_工厂质量事故单-主表-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ IncidentTicket incidentTicket = incidentTicketService.getById(id);
|
|
|
+ if(incidentTicket==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ return Result.ok(incidentTicket);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "森_工厂质量事故单-子表集合-通过id查询")
|
|
|
+ @ApiOperation(value="森_工厂质量事故单-子表集合-通过id查询", notes="森_工厂质量事故单-子表-通过id查询")
|
|
|
+ @GetMapping(value = "/queryIncidentTicketChildrenByMainId")
|
|
|
+ public Result<?> queryIncidentTicketChildrenListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
+ List<IncidentTicketChildren> incidentTicketChildrenList = incidentTicketChildrenService.selectByMainId(id);
|
|
|
+ return Result.ok(incidentTicketChildrenList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 方珂通知其他人员
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "方珂通知其他人员")
|
|
|
+ @ApiOperation(value="方珂通知其他人员", notes="方珂通知其他人员")
|
|
|
+ @GetMapping(value = "/noticeUser")
|
|
|
+ public Result<?> noticeUser(String ids,String headId,String code,String title) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(ids) || StringUtils.isBlank(headId)|| StringUtils.isBlank(code)|| StringUtils.isBlank(title)){
|
|
|
+ return Result.error("参数不完整");
|
|
|
+ }
|
|
|
+ String info = incidentTicketService.noticeUser(ids,headId,code,title);
|
|
|
+ if(info.equals("false")){
|
|
|
+ return Result.error("数据异常,请联系管理员");
|
|
|
+ }else{
|
|
|
+ return Result.ok(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他人员通知方珂
|
|
|
+ *
|
|
|
+ * @param headId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "其他人员通知方珂")
|
|
|
+ @ApiOperation(value="其他人员通知方珂", notes="其他人员通知方珂")
|
|
|
+ @GetMapping(value = "/noticeUserReturn")
|
|
|
+ public Result<?> noticeUserReturn(String headId,String code,String title) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(headId)|| StringUtils.isBlank(code)|| StringUtils.isBlank(title)){
|
|
|
+ return Result.error("参数不完整");
|
|
|
+ }
|
|
|
+ String info = incidentTicketService.noticeUserReturn(headId,code,title);
|
|
|
+ if(info.equals("false")){
|
|
|
+ return Result.error("数据异常,请联系管理员");
|
|
|
+ }else{
|
|
|
+ return Result.ok(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推送
|
|
|
+ *
|
|
|
+ * @param headId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "质量事故单-推送")
|
|
|
+ @ApiOperation(value="质量事故单-推送", notes="质量事故单-推送")
|
|
|
+ @GetMapping(value = "/propelling")
|
|
|
+ public Result<?> propelling(String headId) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(headId)){
|
|
|
+ return Result.error("参数不完整");
|
|
|
+ }
|
|
|
+
|
|
|
+ IncidentTicket incidentTicket = incidentTicketService.getById(headId);
|
|
|
+ if(incidentTicket==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(incidentTicket.getState().equals("3")){//1未处理 2已通知 3通知已反馈 4已推送 5已完结
|
|
|
+ incidentTicket.setState("4");
|
|
|
+ incidentTicketService.save(incidentTicket);
|
|
|
+ return Result.ok("已完结");
|
|
|
+ }else{
|
|
|
+ return Result.ok("此单据状态下无法推送");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 完结
|
|
|
+ *
|
|
|
+ * @param headId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "质量事故单-完结")
|
|
|
+ @ApiOperation(value="质量事故单-完结", notes="质量事故单-完结")
|
|
|
+ @GetMapping(value = "/endOrder")
|
|
|
+ public Result<?> endOrder(String headId) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(headId)){
|
|
|
+ return Result.error("参数不完整");
|
|
|
+ }
|
|
|
+ IncidentTicket incidentTicket = incidentTicketService.getById(headId);
|
|
|
+ if(incidentTicket==null) {
|
|
|
+ return Result.error("未找到对应数据");
|
|
|
+ }
|
|
|
+ //完结操作可跳过推送,直接完结
|
|
|
+ if(incidentTicket.getState().equals("3") || incidentTicket.getState().equals("4")){//1未处理 2已通知 3通知已反馈 4已推送 5已完结
|
|
|
+ incidentTicket.setState("5");
|
|
|
+ incidentTicketService.save(incidentTicket);
|
|
|
+ return Result.ok("已完结");
|
|
|
+ }else{
|
|
|
+ return Result.ok("此单据状态下无法完结");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param incidentTicket
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, IncidentTicket incidentTicket) {
|
|
|
+ // Step.1 组装查询条件查询数据
|
|
|
+ QueryWrapper<IncidentTicket> queryWrapper = QueryGenerator.initQueryWrapper(incidentTicket, request.getParameterMap());
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ //Step.2 获取导出数据
|
|
|
+ List<IncidentTicket> queryList = incidentTicketService.list(queryWrapper);
|
|
|
+ // 过滤选中数据
|
|
|
+ String selections = request.getParameter("selections");
|
|
|
+ List<IncidentTicket> incidentTicketList = new ArrayList<IncidentTicket>();
|
|
|
+ if(oConvertUtils.isEmpty(selections)) {
|
|
|
+ incidentTicketList = queryList;
|
|
|
+ }else {
|
|
|
+ List<String> selectionList = Arrays.asList(selections.split(","));
|
|
|
+ incidentTicketList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Step.3 组装pageList
|
|
|
+ List<IncidentTicketPage> pageList = new ArrayList<IncidentTicketPage>();
|
|
|
+ for (IncidentTicket main : incidentTicketList) {
|
|
|
+ IncidentTicketPage vo = new IncidentTicketPage();
|
|
|
+ BeanUtils.copyProperties(main, vo);
|
|
|
+ List<IncidentTicketChildren> incidentTicketChildrenList = incidentTicketChildrenService.selectByMainId(main.getId());
|
|
|
+ vo.setIncidentTicketChildrenList(incidentTicketChildrenList);
|
|
|
+ pageList.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Step.4 AutoPoi 导出Excel
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "森_工厂质量事故单-主表列表");
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, IncidentTicketPage.class);
|
|
|
+ mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("森_工厂质量事故单-主表数据", "导出人:"+sysUser.getRealname(), "森_工厂质量事故单-主表"));
|
|
|
+ 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<IncidentTicketPage> list = ExcelImportUtil.importExcel(file.getInputStream(), IncidentTicketPage.class, params);
|
|
|
+ for (IncidentTicketPage page : list) {
|
|
|
+ IncidentTicket po = new IncidentTicket();
|
|
|
+ BeanUtils.copyProperties(page, po);
|
|
|
+ incidentTicketService.saveMain(po, page.getIncidentTicketChildrenList());
|
|
|
+ }
|
|
|
+ return Result.ok("文件导入成功!数据行数:" + list.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("文件导入失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|