|
@@ -0,0 +1,245 @@
|
|
|
+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 javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+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.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.oa.entity.SyCottonYarnB;
|
|
|
+import org.jeecg.modules.oa.entity.SyCottonYarn;
|
|
|
+import org.jeecg.modules.oa.vo.SyCottonYarnPage;
|
|
|
+import org.jeecg.modules.oa.service.ISyCottonYarnService;
|
|
|
+import org.jeecg.modules.oa.service.ISyCottonYarnBService;
|
|
|
+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;
|
|
|
+
|
|
|
+
|
|
|
+ * @Description: 搬运装卸费用-棉纱-主表
|
|
|
+ * @Author: jeecg-boot
|
|
|
+ * @Date: 2023-01-10
|
|
|
+ * @Version: V1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/oa/syCottonYarn")
|
|
|
+@Slf4j
|
|
|
+public class SyCottonYarnController {
|
|
|
+ @Autowired
|
|
|
+ private ISyCottonYarnService syCottonYarnService;
|
|
|
+ @Autowired
|
|
|
+ private ISyCottonYarnBService syCottonYarnBService;
|
|
|
+
|
|
|
+
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param syCottonYarn
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<?> queryPageList(SyCottonYarn syCottonYarn,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<SyCottonYarn> queryWrapper = QueryGenerator.initQueryWrapper(syCottonYarn, req.getParameterMap());
|
|
|
+ Page<SyCottonYarn> page = new Page<SyCottonYarn>(pageNo, pageSize);
|
|
|
+ IPage<SyCottonYarn> pageList = syCottonYarnService.page(page, queryWrapper);
|
|
|
+ return Result.ok(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param syCottonYarnPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<?> add(@RequestBody SyCottonYarnPage syCottonYarnPage) {
|
|
|
+ SyCottonYarn syCottonYarn = new SyCottonYarn();
|
|
|
+ BeanUtils.copyProperties(syCottonYarnPage, syCottonYarn);
|
|
|
+ syCottonYarnService.saveMain(syCottonYarn, syCottonYarnPage.getSyCottonYarnBList());
|
|
|
+ return Result.ok("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param syCottonYarnPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PutMapping(value = "/edit")
|
|
|
+ public Result<?> edit(@RequestBody SyCottonYarnPage syCottonYarnPage) {
|
|
|
+ SyCottonYarn syCottonYarn = new SyCottonYarn();
|
|
|
+ BeanUtils.copyProperties(syCottonYarnPage, syCottonYarn);
|
|
|
+ syCottonYarnService.updateMain(syCottonYarn, syCottonYarnPage.getSyCottonYarnBList());
|
|
|
+ return Result.ok("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id删除
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ syCottonYarnService.delMain(id);
|
|
|
+ return Result.ok("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
+ this.syCottonYarnService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.ok("批量删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ SyCottonYarn syCottonYarn = syCottonYarnService.getById(id);
|
|
|
+ return Result.ok(syCottonYarn);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 通过id查询
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/querySyCottonYarnBByMainId")
|
|
|
+ public Result<?> querySyCottonYarnBListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
+ List<SyCottonYarnB> syCottonYarnBList = syCottonYarnBService.selectByMainId(id);
|
|
|
+ return Result.ok(syCottonYarnBList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param syCottonYarn
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, SyCottonYarn syCottonYarn) {
|
|
|
+
|
|
|
+ QueryWrapper<SyCottonYarn> queryWrapper = QueryGenerator.initQueryWrapper(syCottonYarn, request.getParameterMap());
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+
|
|
|
+
|
|
|
+ List<SyCottonYarnPage> pageList = new ArrayList<SyCottonYarnPage>();
|
|
|
+ List<SyCottonYarn> syCottonYarnList = syCottonYarnService.list(queryWrapper);
|
|
|
+ for (SyCottonYarn temp : syCottonYarnList) {
|
|
|
+ SyCottonYarnPage vo = new SyCottonYarnPage();
|
|
|
+ BeanUtils.copyProperties(temp, vo);
|
|
|
+ List<SyCottonYarnB> syCottonYarnBList = syCottonYarnBService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyCottonYarnBList(syCottonYarnBList);
|
|
|
+ pageList.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "搬运装卸费用-棉纱-主表");
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, SyCottonYarnPage.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<SyCottonYarnPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyCottonYarnPage.class, params);
|
|
|
+ for (SyCottonYarnPage page : list) {
|
|
|
+ SyCottonYarn po = new SyCottonYarn();
|
|
|
+ BeanUtils.copyProperties(page, po);
|
|
|
+ syCottonYarnService.saveMain(po, page.getSyCottonYarnBList());
|
|
|
+ }
|
|
|
+ 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("文件导入失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 计划员批量签名
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/commitBatch")
|
|
|
+ public Result<?> commitBatch(@RequestParam(name="ids",required=true) String ids,@RequestParam(name="state",required=true) String state) {
|
|
|
+ String res = this.syCottonYarnService.commitBatch(Arrays.asList(ids.split(",")),state);
|
|
|
+ return Result.ok(res);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 计划员签名
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/signPlan")
|
|
|
+ public Result<?> signPlan(@RequestParam(name="id",required=true) String id) {
|
|
|
+ String res = syCottonYarnService.signPlan(id);
|
|
|
+ return Result.ok(res);
|
|
|
+ }
|
|
|
+}
|