| | |
| | | package org.jeecg.modules.spare.controller; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.base.entity.SysUpload; |
| | | import org.jeecg.common.system.base.entity.SysUploadRela; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.model.InspectionCycleVo; |
| | | import org.jeecg.modules.spare.entity.SparePart; |
| | | import org.jeecg.modules.spare.entity.SparesPartInventory; |
| | | import org.jeecg.modules.spare.service.ISparePartService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | 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.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.modules.spare.entity.SparePart; |
| | | import org.jeecg.modules.spare.entity.SparesPartInventory; |
| | | import org.jeecg.modules.spare.service.ISparePartService; |
| | | import org.jeecg.modules.spare.service.ISparesPartInventoryService; |
| | | import org.jeecg.modules.spare.vo.AuxiliaryUnitVo; |
| | | 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.base.controller.JeecgController; |
| | | 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.jeecg.common.aspect.annotation.AutoLog; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: mom_eam_spare_part |
| | |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "mom_eam_spare_part-分页列表查询") |
| | | @ApiOperation(value="mom_eam_spare_part-分页列表查询", notes="mom_eam_spare_part-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<SparePart>> queryPageList(SparePart sparePart, |
| | |
| | | */ |
| | | @AutoLog(value = "mom_eam_spare_part-添加") |
| | | @ApiOperation(value="mom_eam_spare_part-添加", notes="mom_eam_spare_part-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody SparePart sparePart) { |
| | | sparePartService.save(sparePart); |
| | |
| | | */ |
| | | @AutoLog(value = "mom_eam_spare_part-通过id删除") |
| | | @ApiOperation(value="mom_eam_spare_part-通过id删除", notes="mom_eam_spare_part-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | sparePartService.removeById(id); |
| | |
| | | */ |
| | | @AutoLog(value = "mom_eam_spare_part-批量删除") |
| | | @ApiOperation(value="mom_eam_spare_part-批量删除", notes="mom_eam_spare_part-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.sparePartService.removeByIds(Arrays.asList(ids.split(","))); |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "mom_eam_spare_part-通过id查询") |
| | | @ApiOperation(value="mom_eam_spare_part-通过id查询", notes="mom_eam_spare_part-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<SparePart> queryById(@RequestParam(name="id",required=true) String id) { |
| | |
| | | * @param request |
| | | * @param sparePart |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:mom_eam_spare_part:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, SparePart sparePart) { |
| | | return super.exportXls(request, sparePart, SparePart.class, "mom_eam_spare_part"); |
| | |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("mom_eam_spare_part:importExcel") |
| | | |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, SparePart.class); |
| | | 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<SparePart> list = ExcelImportUtil.importExcel(file.getInputStream(), SparePart.class, params); |
| | | long start = System.currentTimeMillis(); |
| | | sparePartService.saveBatch(list); |
| | | log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒"); |
| | | 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.error("文件导入失败!"); |
| | | } |
| | | |
| | | /** |