|
@@ -0,0 +1,314 @@
|
|
|
+package org.jeecg.modules.splt.controller;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.spapl.entity.SyPreAssembledPackingList;
|
|
|
+import org.jeecg.modules.spapl.entity.SyPreAssembledPackingListItem;
|
|
|
+import org.jeecg.modules.spapl.service.ISyPreAssembledPackingListItemService;
|
|
|
+import org.jeecg.modules.spapl.service.ISyPreAssembledPackingListService;
|
|
|
+import org.jeecg.modules.spapl.vo.SyPreAssembledPackingListVo;
|
|
|
+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.jeecg.modules.splt.entity.SyPackingListTailoringItem;
|
|
|
+import org.jeecg.modules.splt.entity.SyPackingListTailoring;
|
|
|
+import org.jeecg.modules.splt.vo.SyPackingListTailoringPage;
|
|
|
+import org.jeecg.modules.splt.service.ISyPackingListTailoringService;
|
|
|
+import org.jeecg.modules.splt.service.ISyPackingListTailoringItemService;
|
|
|
+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 io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 装箱单主表
|
|
|
+ * @Author: jeecg-boot
|
|
|
+ * @Date: 2022-06-29
|
|
|
+ * @Version: V1.0
|
|
|
+ */
|
|
|
+@Api(tags="装箱单主表")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/splt/syPackingListTailoring")
|
|
|
+@Slf4j
|
|
|
+public class SyPackingListTailoringController {
|
|
|
+ @Autowired
|
|
|
+ private ISyPreAssembledPackingListService syPreAssembledPackingListService;//预装箱单主表
|
|
|
+ @Autowired
|
|
|
+ private ISyPackingListTailoringService syPackingListTailoringService;
|
|
|
+ @Autowired
|
|
|
+ private ISyPackingListTailoringItemService syPackingListTailoringItemService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param syPackingListTailoring
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "装箱单主表-分页列表查询")
|
|
|
+ @ApiOperation(value="装箱单主表-分页列表查询", notes="装箱单主表-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<?> queryPageList(SyPackingListTailoring syPackingListTailoring,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<SyPackingListTailoring> queryWrapper = QueryGenerator.initQueryWrapper(syPackingListTailoring, req.getParameterMap());
|
|
|
+ Page<SyPackingListTailoring> page = new Page<SyPackingListTailoring>(pageNo, pageSize);
|
|
|
+ IPage<SyPackingListTailoring> pageList = syPackingListTailoringService.page(page, queryWrapper);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "根据预装箱单-id获取数据")
|
|
|
+ @ApiOperation(value="根据预装箱单-id获取数据", notes="根据预装箱单-id获取数据")
|
|
|
+ @GetMapping(value = "/querySpaplId")
|
|
|
+ public Result<SyPackingListTailoring> querySpaplId(String id) {
|
|
|
+ Result<SyPackingListTailoring> result=new Result<>();
|
|
|
+ if(oConvertUtils.isEmpty(id)){
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage("未获取到id的信息");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.setResult(syPackingListTailoringService.querySpaplId(id));
|
|
|
+ result.setMessage("查询成功!");
|
|
|
+ result.setSuccess(true);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param syPreAssembledPackingListVo
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "参照预装箱单")
|
|
|
+ @ApiOperation(value="参照预装箱单", notes="参照预装箱单")
|
|
|
+ @GetMapping(value = "/getSpaplData")
|
|
|
+ public Result<IPage<SyPreAssembledPackingListVo>> queryPageList2(SyPreAssembledPackingListVo syPreAssembledPackingListVo,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ //System.out.println("当前登录用户:"+((LoginUser)SecurityUtils.getSubject().getPrincipal()).getRealname());
|
|
|
+ QueryWrapper<SyPreAssembledPackingListVo> queryWrapper =new QueryWrapper<>();//初始化
|
|
|
+ queryWrapper.eq("a.del_flag","0");//默认查询未删除
|
|
|
+ if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getId())){//查询id
|
|
|
+ queryWrapper.eq("a.id",syPreAssembledPackingListVo.getId());
|
|
|
+ }
|
|
|
+ if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getOrderNumber())){
|
|
|
+ queryWrapper.eq("a.order_number",syPreAssembledPackingListVo.getOrderNumber());//订单号
|
|
|
+ }
|
|
|
+ if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getItemNumber())){
|
|
|
+ queryWrapper.eq("a.item_number",syPreAssembledPackingListVo.getItemNumber());//款号
|
|
|
+ }
|
|
|
+ if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getProductName())){
|
|
|
+ queryWrapper.eq("a.product_Name",syPreAssembledPackingListVo.getProductName());//品名
|
|
|
+ }
|
|
|
+ Page<SyPreAssembledPackingListVo> page = new Page<SyPreAssembledPackingListVo>(pageNo, pageSize);
|
|
|
+ IPage<SyPreAssembledPackingListVo> pageList = syPreAssembledPackingListService.selectPage(page, queryWrapper);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param syPackingListTailoring
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "装箱单主表-添加")
|
|
|
+ @ApiOperation(value="装箱单主表-添加", notes="装箱单主表-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<?> add(@RequestBody SyPackingListTailoring syPackingListTailoring) {
|
|
|
+ syPackingListTailoringService.saveMain2(syPackingListTailoring);
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param syPackingListTailoringPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "装箱单主表-编辑")
|
|
|
+ @ApiOperation(value="装箱单主表-编辑", notes="装箱单主表-编辑")
|
|
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<?> edit(@RequestBody SyPackingListTailoringPage syPackingListTailoringPage) {
|
|
|
+ SyPackingListTailoring syPackingListTailoring = new SyPackingListTailoring();
|
|
|
+ BeanUtils.copyProperties(syPackingListTailoringPage, syPackingListTailoring);
|
|
|
+ syPackingListTailoringService.updateMain(syPackingListTailoring, syPackingListTailoringPage.getSyPackingListTailoringItemList());
|
|
|
+ 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) {
|
|
|
+ syPackingListTailoringService.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.syPackingListTailoringService.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<SyPackingListTailoring> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Result<SyPackingListTailoring> result=new Result<SyPackingListTailoring>();
|
|
|
+ if(oConvertUtils.isEmpty(id)){
|
|
|
+ result.setMessage("id为空");
|
|
|
+ result.setSuccess(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ SyPackingListTailoring syPackingListTailoring = syPackingListTailoringService.queryId(id);
|
|
|
+ if(syPackingListTailoring==null){
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage("未找到该id");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.setMessage("查询成功!");
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(syPackingListTailoring);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+/* *//**
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ *//*
|
|
|
+ @AutoLog(value = "装箱单子表-通过主表ID查询")
|
|
|
+ @ApiOperation(value="装箱单子表-通过主表ID查询", notes="装箱单主表-通过主表ID查询")
|
|
|
+ @GetMapping(value = "/querysyPackingListTailoringItemByMainId")
|
|
|
+ public Result<?> querysyPackingListTailoringItemListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
+ List<SyPackingListTailoringItem> syPackingListTailoringItemList = syPackingListTailoringItemService.selectByMainId(id);
|
|
|
+ return Result.OK(syPackingListTailoringItemList);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param syPackingListTailoring
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, SyPackingListTailoring syPackingListTailoring) {
|
|
|
+ // Step.1 组装查询条件
|
|
|
+ QueryWrapper<SyPackingListTailoring> queryWrapper = QueryGenerator.initQueryWrapper(syPackingListTailoring, request.getParameterMap());
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+ //Step.2 获取导出数据
|
|
|
+ List<SyPackingListTailoringPage> pageList = new ArrayList<SyPackingListTailoringPage>();
|
|
|
+ List<SyPackingListTailoring> syPackingListTailoringList = syPackingListTailoringService.list(queryWrapper);
|
|
|
+ for (SyPackingListTailoring temp : syPackingListTailoringList) {
|
|
|
+ SyPackingListTailoringPage vo = new SyPackingListTailoringPage();
|
|
|
+ BeanUtils.copyProperties(temp, vo);
|
|
|
+ List<SyPackingListTailoringItem> syPackingListTailoringItemList = syPackingListTailoringItemService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyPackingListTailoringItemList(syPackingListTailoringItemList);
|
|
|
+ pageList.add(vo);
|
|
|
+ }
|
|
|
+ //Step.3 调用AutoPoi导出Excel
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "装箱单主表");
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, SyPackingListTailoringPage.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<SyPackingListTailoringPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyPackingListTailoringPage.class, params);
|
|
|
+ for (SyPackingListTailoringPage page : list) {
|
|
|
+ SyPackingListTailoring po = new SyPackingListTailoring();
|
|
|
+ BeanUtils.copyProperties(page, po);
|
|
|
+ syPackingListTailoringService.saveMain(po, page.getSyPackingListTailoringItemList());
|
|
|
+ }
|
|
|
+ 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("文件导入失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|