|
@@ -1,366 +1,424 @@
|
|
|
package org.jeecg.modules.cost.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.jeecg.common.system.vo.LoginUser;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+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.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.cost.entity.*;
|
|
|
+import org.jeecg.modules.cost.service.*;
|
|
|
+import org.jeecg.modules.cost.vo.SyCostAllocationPage;
|
|
|
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.cost.entity.SyCostAllocationAccident;
|
|
|
-import org.jeecg.modules.cost.entity.SyCostAllocationCostpay;
|
|
|
-import org.jeecg.modules.cost.entity.SyCostAllocationFabric;
|
|
|
-import org.jeecg.modules.cost.entity.SyCostAllocationIngredient;
|
|
|
-import org.jeecg.modules.cost.entity.SyCostAllocationShipdetail;
|
|
|
-import org.jeecg.modules.cost.entity.SyCostAllocation;
|
|
|
-import org.jeecg.modules.cost.vo.SyCostAllocationPage;
|
|
|
-import org.jeecg.modules.cost.service.ISyCostAllocationService;
|
|
|
-import org.jeecg.modules.cost.service.ISyCostAllocationAccidentService;
|
|
|
-import org.jeecg.modules.cost.service.ISyCostAllocationCostpayService;
|
|
|
-import org.jeecg.modules.cost.service.ISyCostAllocationFabricService;
|
|
|
-import org.jeecg.modules.cost.service.ISyCostAllocationIngredientService;
|
|
|
-import org.jeecg.modules.cost.service.ISyCostAllocationShipdetailService;
|
|
|
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;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
- /**
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
* @Description: 成本分配主表
|
|
|
* @Author: jeecg-boot
|
|
|
- * @Date: 2022-06-21
|
|
|
+ * @Date: 2022-06-21
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
-@Api(tags="成本分配主表")
|
|
|
+@Api(tags = "成本分配主表")
|
|
|
@RestController
|
|
|
@RequestMapping("/cost/syCostAllocation")
|
|
|
@Slf4j
|
|
|
public class SyCostAllocationController {
|
|
|
- @Autowired
|
|
|
- private ISyCostAllocationService syCostAllocationService;
|
|
|
- @Autowired
|
|
|
- private ISyCostAllocationAccidentService syCostAllocationAccidentService;
|
|
|
- @Autowired
|
|
|
- private ISyCostAllocationCostpayService syCostAllocationCostpayService;
|
|
|
- @Autowired
|
|
|
- private ISyCostAllocationFabricService syCostAllocationFabricService;
|
|
|
- @Autowired
|
|
|
- private ISyCostAllocationIngredientService syCostAllocationIngredientService;
|
|
|
- @Autowired
|
|
|
- private ISyCostAllocationShipdetailService syCostAllocationShipdetailService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 分页列表查询
|
|
|
- *
|
|
|
- * @param syCostAllocation
|
|
|
- * @param pageNo
|
|
|
- * @param pageSize
|
|
|
- * @param req
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配主表-分页列表查询")
|
|
|
- @ApiOperation(value="成本分配主表-分页列表查询", notes="成本分配主表-分页列表查询")
|
|
|
- @GetMapping(value = "/list")
|
|
|
- public Result<?> queryPageList(SyCostAllocation syCostAllocation,
|
|
|
- @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
- @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
- HttpServletRequest req) {
|
|
|
- QueryWrapper<SyCostAllocation> queryWrapper = QueryGenerator.initQueryWrapper(syCostAllocation, req.getParameterMap());
|
|
|
- Page<SyCostAllocation> page = new Page<SyCostAllocation>(pageNo, pageSize);
|
|
|
- IPage<SyCostAllocation> pageList = syCostAllocationService.page(page, queryWrapper);
|
|
|
- List<SyCostAllocation> records = pageList.getRecords();
|
|
|
- List<String> collect = records.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
- //获取5子表数据并赋值
|
|
|
- if(collect!=null && !collect.isEmpty()) {
|
|
|
- //事故单
|
|
|
- QueryWrapper<SyCostAllocationAccident> list1QueryWrapper = new QueryWrapper<>();
|
|
|
- list1QueryWrapper.in("sy_cost_allocation_id", collect).eq("del_flag", 0);
|
|
|
- List<SyCostAllocationAccident> list1 = syCostAllocationAccidentService.list(list1QueryWrapper);
|
|
|
+ @Autowired
|
|
|
+ private ISyCostAllocationService syCostAllocationService;
|
|
|
+ @Autowired
|
|
|
+ private ISyCostAllocationAccidentService syCostAllocationAccidentService;
|
|
|
+ @Autowired
|
|
|
+ private ISyCostAllocationCostpayService syCostAllocationCostpayService;
|
|
|
+ @Autowired
|
|
|
+ private ISyCostAllocationFabricService syCostAllocationFabricService;
|
|
|
+ @Autowired
|
|
|
+ private ISyCostAllocationIngredientService syCostAllocationIngredientService;
|
|
|
+ @Autowired
|
|
|
+ private ISyCostAllocationShipdetailService syCostAllocationShipdetailService;
|
|
|
|
|
|
- //费用支出
|
|
|
- QueryWrapper<SyCostAllocationCostpay> list2QueryWrapper = new QueryWrapper<>();
|
|
|
- list2QueryWrapper.in("sy_cost_allocation_id", collect).eq("del_flag", 0);
|
|
|
- List<SyCostAllocationCostpay> list2 = syCostAllocationCostpayService.list(list2QueryWrapper);
|
|
|
-
|
|
|
- QueryWrapper<SyCostAllocationFabric> list3QueryWrapper = new QueryWrapper<>();
|
|
|
- list3QueryWrapper.in("sy_cost_allocation_id", collect).eq("del_flag", 0);
|
|
|
- List<SyCostAllocationFabric> list3 = syCostAllocationFabricService.list(list3QueryWrapper);
|
|
|
+ /**
|
|
|
+ * 分页列表查询
|
|
|
+ *
|
|
|
+ * @param syCostAllocation
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @param req
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-分页列表查询")
|
|
|
+ @ApiOperation(value = "成本分配主表-分页列表查询", notes = "成本分配主表-分页列表查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result<?> queryPageList(SyCostAllocation syCostAllocation,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+ QueryWrapper<SyCostAllocation> queryWrapper = QueryGenerator.initQueryWrapper(syCostAllocation, req.getParameterMap());
|
|
|
+ Page<SyCostAllocation> page = new Page<SyCostAllocation>(pageNo, pageSize);
|
|
|
+ IPage<SyCostAllocation> pageList = syCostAllocationService.page(page, queryWrapper);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
|
|
|
- QueryWrapper<SyCostAllocationIngredient> list4QueryWrapper = new QueryWrapper<>();
|
|
|
- list4QueryWrapper.in("sy_cost_allocation_id", collect).eq("del_flag", 0);
|
|
|
- List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientService.list(list4QueryWrapper);
|
|
|
+ /**
|
|
|
+ * 通过计划号-销售订单号查询
|
|
|
+ *
|
|
|
+ * @param plannum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-通过计划号-销售订单号查询")
|
|
|
+ @GetMapping(value = "/queryByPlanNum")
|
|
|
+ public Result<?> queryByPlanNum(@RequestParam(name = "plannum", required = true) String plannum) {
|
|
|
+ if (oConvertUtils.isEmpty(plannum)) {
|
|
|
+ throw new JeecgBootException("计划号不能为空!");
|
|
|
+ }
|
|
|
+ QueryWrapper<SyCostAllocation> listQueryWrapper = new QueryWrapper<>();
|
|
|
+ listQueryWrapper.eq("plan_num", plannum).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocation> list = syCostAllocationService.list(listQueryWrapper);
|
|
|
+ if (list.size() != 1) {
|
|
|
+ throw new JeecgBootException("数据查询有误,请联系管理员确认!");
|
|
|
+ }
|
|
|
+ SyCostAllocation sycostAllocation = list.get(0);
|
|
|
+ //事故单
|
|
|
+ QueryWrapper<SyCostAllocationAccident> list1QueryWrapper = new QueryWrapper<>();
|
|
|
+ list1QueryWrapper.in("sy_cost_allocation_id", sycostAllocation.getId()).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocationAccident> list1 = syCostAllocationAccidentService.list(list1QueryWrapper);
|
|
|
+ sycostAllocation.setSyCostAllocationAccidentList(list1);
|
|
|
+ //费用支出
|
|
|
+ QueryWrapper<SyCostAllocationCostpay> list2QueryWrapper = new QueryWrapper<>();
|
|
|
+ list2QueryWrapper.in("sy_cost_allocation_id", sycostAllocation.getId()).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocationCostpay> list2 = syCostAllocationCostpayService.list(list2QueryWrapper);
|
|
|
+ sycostAllocation.setSyCostAllocationCostpayList(list2);
|
|
|
+ //面料
|
|
|
+ QueryWrapper<SyCostAllocationFabric> list3QueryWrapper = new QueryWrapper<>();
|
|
|
+ list3QueryWrapper.in("sy_cost_allocation_id", sycostAllocation.getId()).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocationFabric> list3 = syCostAllocationFabricService.list(list3QueryWrapper);
|
|
|
+ sycostAllocation.setSyCostAllocationFabricList(list3);
|
|
|
+ //辅料
|
|
|
+ QueryWrapper<SyCostAllocationIngredient> list4QueryWrapper = new QueryWrapper<>();
|
|
|
+ list4QueryWrapper.in("sy_cost_allocation_id", sycostAllocation.getId()).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocationIngredient> list4 = syCostAllocationIngredientService.list(list4QueryWrapper);
|
|
|
+ sycostAllocation.setSyCostAllocationIngredientList(list4);
|
|
|
+ //发运明细
|
|
|
+ QueryWrapper<SyCostAllocationShipdetail> list5QueryWrapper = new QueryWrapper<>();
|
|
|
+ list5QueryWrapper.in("sy_cost_allocation_id", sycostAllocation.getId()).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocationShipdetail> list5 = syCostAllocationShipdetailService.list(list5QueryWrapper);
|
|
|
+ sycostAllocation.setSyCostAllocationShipdetailList(list5);
|
|
|
|
|
|
- QueryWrapper<SyCostAllocationShipdetail> list5QueryWrapper = new QueryWrapper<>();
|
|
|
- list5QueryWrapper.in("sy_cost_allocation_id", collect).eq("del_flag", 0);
|
|
|
- List<SyCostAllocationShipdetail> list5 = syCostAllocationShipdetailService.list(list5QueryWrapper);
|
|
|
- for (SyCostAllocation record : records) {
|
|
|
- String id = record.getId();
|
|
|
- List<SyCostAllocationAccident> collect1 = list1.stream().filter(i -> i.getSyCostAllocationId().equals(id)).collect(Collectors.toList());
|
|
|
- }
|
|
|
+ return Result.OK(list);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过计划号-销售订单号审批
|
|
|
+ *
|
|
|
+ * @param plannum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-通过计划号-销售订单号审批")
|
|
|
+ @GetMapping(value = "/approveByPlanNum")
|
|
|
+ public Result<?> approveByPlanNum(@RequestParam(name = "plannum", required = true) String plannum) {
|
|
|
+ if (oConvertUtils.isEmpty(plannum)) {
|
|
|
+ throw new JeecgBootException("计划号不能为空!");
|
|
|
+ }
|
|
|
+ QueryWrapper<SyCostAllocation> listQueryWrapper = new QueryWrapper<>();
|
|
|
+ listQueryWrapper.eq("plan_num", plannum).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocation> list = syCostAllocationService.list(listQueryWrapper);
|
|
|
+ if (list.size() != 1) {
|
|
|
+ throw new JeecgBootException("数据未保存,不能操作!");
|
|
|
+ }
|
|
|
+ if (list.get(0).getBillstatus().equals(2)) {
|
|
|
+ throw new JeecgBootException("单据已经是审批状态!");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ UpdateWrapper<SyCostAllocation> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("plan_num", plannum).eq("del_flag", 0);
|
|
|
+ updateWrapper.set("billstatus", 2);
|
|
|
+ syCostAllocationService.update(updateWrapper);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
+ Result.error("操作失败!");
|
|
|
+ }
|
|
|
+ return Result.OK("单据已审批!");
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过计划号-销售订单号弃审
|
|
|
+ *
|
|
|
+ * @param plannum
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-通过计划号-销售订单号弃审")
|
|
|
+ @GetMapping(value = "/dApproveByPlanNum")
|
|
|
+ public Result<?> dApproveByPlanNum(@RequestParam(name = "plannum", required = true) String plannum) {
|
|
|
+ if (oConvertUtils.isEmpty(plannum)) {
|
|
|
+ throw new JeecgBootException("计划号不能为空!");
|
|
|
+ }
|
|
|
+ QueryWrapper<SyCostAllocation> listQueryWrapper = new QueryWrapper<>();
|
|
|
+ listQueryWrapper.eq("plan_num", plannum).eq("del_flag", 0);
|
|
|
+ List<SyCostAllocation> list = syCostAllocationService.list(listQueryWrapper);
|
|
|
+ if (list.size() != 1) {
|
|
|
+ throw new JeecgBootException("数据未保存,不能操作!");
|
|
|
+ }
|
|
|
+ if (list.get(0).getBillstatus().equals(1)) {
|
|
|
+ throw new JeecgBootException("单据已经是保存状态!");
|
|
|
}
|
|
|
+ try {
|
|
|
+ UpdateWrapper<SyCostAllocation> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("plan_num", plannum).eq("del_flag", 0);
|
|
|
+ updateWrapper.set("billstatus", 1);
|
|
|
+ syCostAllocationService.update(updateWrapper);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
+ Result.error("操作失败!");
|
|
|
+ }
|
|
|
+ return Result.OK("单据已弃审!");
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param syCostAllocationPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-添加")
|
|
|
+ @ApiOperation(value = "成本分配主表-添加", notes = "成本分配主表-添加")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ public Result<?> add(@RequestBody SyCostAllocationPage syCostAllocationPage) {
|
|
|
+ SyCostAllocation syCostAllocation = new SyCostAllocation();
|
|
|
+ BeanUtils.copyProperties(syCostAllocationPage, syCostAllocation);
|
|
|
+ syCostAllocationService.saveMain(syCostAllocation, syCostAllocationPage.getSyCostAllocationAccidentList(), syCostAllocationPage.getSyCostAllocationCostpayList(), syCostAllocationPage.getSyCostAllocationFabricList(), syCostAllocationPage.getSyCostAllocationIngredientList(), syCostAllocationPage.getSyCostAllocationShipdetailList());
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param syCostAllocationPage
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-编辑")
|
|
|
+ @ApiOperation(value = "成本分配主表-编辑", notes = "成本分配主表-编辑")
|
|
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
|
|
+ public Result<?> edit(@RequestBody SyCostAllocationPage syCostAllocationPage) {
|
|
|
+ SyCostAllocation syCostAllocation = new SyCostAllocation();
|
|
|
+ BeanUtils.copyProperties(syCostAllocationPage, syCostAllocation);
|
|
|
+ syCostAllocationService.updateMain(syCostAllocation, syCostAllocationPage.getSyCostAllocationAccidentList(), syCostAllocationPage.getSyCostAllocationCostpayList(), syCostAllocationPage.getSyCostAllocationFabricList(), syCostAllocationPage.getSyCostAllocationIngredientList(), syCostAllocationPage.getSyCostAllocationShipdetailList());
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
|
|
|
- return Result.OK(pageList);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 通过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) {
|
|
|
+ syCostAllocationService.delMain(id);
|
|
|
+ return Result.OK("删除成功!");
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 通过计划号-销售订单号查询
|
|
|
- *
|
|
|
- * @param plannum
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配主表-通过id查询")
|
|
|
- @ApiOperation(value="成本分配主表-通过id查询", notes="成本分配主表-通过id查询")
|
|
|
- @GetMapping(value = "/queryByPlanNum")
|
|
|
- public Result<?> queryByPlanNum(@RequestParam(name="plannum",required=true) String plannum) {
|
|
|
- SyCostAllocation syCostAllocation = syCostAllocationService.getById(plannum);
|
|
|
- return Result.OK(syCostAllocation);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-批量删除")
|
|
|
+ @ApiOperation(value = "成本分配主表-批量删除", notes = "成本分配主表-批量删除")
|
|
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
+ public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
+ this.syCostAllocationService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
+ return Result.OK("批量删除成功!");
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 添加
|
|
|
- *
|
|
|
- * @param syCostAllocationPage
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配主表-添加")
|
|
|
- @ApiOperation(value="成本分配主表-添加", notes="成本分配主表-添加")
|
|
|
- @PostMapping(value = "/add")
|
|
|
- public Result<?> add(@RequestBody SyCostAllocationPage syCostAllocationPage) {
|
|
|
- SyCostAllocation syCostAllocation = new SyCostAllocation();
|
|
|
- BeanUtils.copyProperties(syCostAllocationPage, syCostAllocation);
|
|
|
- syCostAllocationService.saveMain(syCostAllocation, syCostAllocationPage.getSyCostAllocationAccidentList(),syCostAllocationPage.getSyCostAllocationCostpayList(),syCostAllocationPage.getSyCostAllocationFabricList(),syCostAllocationPage.getSyCostAllocationIngredientList(),syCostAllocationPage.getSyCostAllocationShipdetailList());
|
|
|
- return Result.OK("添加成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑
|
|
|
- *
|
|
|
- * @param syCostAllocationPage
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配主表-编辑")
|
|
|
- @ApiOperation(value="成本分配主表-编辑", notes="成本分配主表-编辑")
|
|
|
- @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
- public Result<?> edit(@RequestBody SyCostAllocationPage syCostAllocationPage) {
|
|
|
- SyCostAllocation syCostAllocation = new SyCostAllocation();
|
|
|
- BeanUtils.copyProperties(syCostAllocationPage, syCostAllocation);
|
|
|
- syCostAllocationService.updateMain(syCostAllocation, syCostAllocationPage.getSyCostAllocationAccidentList(),syCostAllocationPage.getSyCostAllocationCostpayList(),syCostAllocationPage.getSyCostAllocationFabricList(),syCostAllocationPage.getSyCostAllocationIngredientList(),syCostAllocationPage.getSyCostAllocationShipdetailList());
|
|
|
- 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) {
|
|
|
- syCostAllocationService.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.syCostAllocationService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
- return Result.OK("批量删除成功!");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
+ /**
|
|
|
+ * 通过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) {
|
|
|
- SyCostAllocation syCostAllocation = syCostAllocationService.getById(id);
|
|
|
- return Result.OK(syCostAllocation);
|
|
|
- }
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配主表-通过id查询")
|
|
|
+ @ApiOperation(value = "成本分配主表-通过id查询", notes = "成本分配主表-通过id查询")
|
|
|
+ @GetMapping(value = "/queryById")
|
|
|
+ public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ SyCostAllocation syCostAllocation = syCostAllocationService.getById(id);
|
|
|
+ return Result.OK(syCostAllocation);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
*
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配子表_事故单-通过主表ID查询")
|
|
|
- @ApiOperation(value="成本分配子表_事故单-通过主表ID查询", notes="成本分配主表-通过主表ID查询")
|
|
|
- @GetMapping(value = "/querySyCostAllocationAccidentByMainId")
|
|
|
- public Result<?> querySyCostAllocationAccidentListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
- List<SyCostAllocationAccident> syCostAllocationAccidentList = syCostAllocationAccidentService.selectByMainId(id);
|
|
|
- return Result.OK(syCostAllocationAccidentList);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配子表_事故单-通过主表ID查询")
|
|
|
+ @ApiOperation(value = "成本分配子表_事故单-通过主表ID查询", notes = "成本分配主表-通过主表ID查询")
|
|
|
+ @GetMapping(value = "/querySyCostAllocationAccidentByMainId")
|
|
|
+ public Result<?> querySyCostAllocationAccidentListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ List<SyCostAllocationAccident> syCostAllocationAccidentList = syCostAllocationAccidentService.selectByMainId(id);
|
|
|
+ return Result.OK(syCostAllocationAccidentList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
*
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配子表_费用支出-通过主表ID查询")
|
|
|
- @ApiOperation(value="成本分配子表_费用支出-通过主表ID查询", notes="成本分配主表-通过主表ID查询")
|
|
|
- @GetMapping(value = "/querySyCostAllocationCostpayByMainId")
|
|
|
- public Result<?> querySyCostAllocationCostpayListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
- List<SyCostAllocationCostpay> syCostAllocationCostpayList = syCostAllocationCostpayService.selectByMainId(id);
|
|
|
- return Result.OK(syCostAllocationCostpayList);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配子表_费用支出-通过主表ID查询")
|
|
|
+ @ApiOperation(value = "成本分配子表_费用支出-通过主表ID查询", notes = "成本分配主表-通过主表ID查询")
|
|
|
+ @GetMapping(value = "/querySyCostAllocationCostpayByMainId")
|
|
|
+ public Result<?> querySyCostAllocationCostpayListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ List<SyCostAllocationCostpay> syCostAllocationCostpayList = syCostAllocationCostpayService.selectByMainId(id);
|
|
|
+ return Result.OK(syCostAllocationCostpayList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
*
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配子表_面料-通过主表ID查询")
|
|
|
- @ApiOperation(value="成本分配子表_面料-通过主表ID查询", notes="成本分配主表-通过主表ID查询")
|
|
|
- @GetMapping(value = "/querySyCostAllocationFabricByMainId")
|
|
|
- public Result<?> querySyCostAllocationFabricListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
- List<SyCostAllocationFabric> syCostAllocationFabricList = syCostAllocationFabricService.selectByMainId(id);
|
|
|
- return Result.OK(syCostAllocationFabricList);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配子表_面料-通过主表ID查询")
|
|
|
+ @ApiOperation(value = "成本分配子表_面料-通过主表ID查询", notes = "成本分配主表-通过主表ID查询")
|
|
|
+ @GetMapping(value = "/querySyCostAllocationFabricByMainId")
|
|
|
+ public Result<?> querySyCostAllocationFabricListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ List<SyCostAllocationFabric> syCostAllocationFabricList = syCostAllocationFabricService.selectByMainId(id);
|
|
|
+ return Result.OK(syCostAllocationFabricList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
*
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配子表_辅料-通过主表ID查询")
|
|
|
- @ApiOperation(value="成本分配子表_辅料-通过主表ID查询", notes="成本分配主表-通过主表ID查询")
|
|
|
- @GetMapping(value = "/querySyCostAllocationIngredientByMainId")
|
|
|
- public Result<?> querySyCostAllocationIngredientListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
- List<SyCostAllocationIngredient> syCostAllocationIngredientList = syCostAllocationIngredientService.selectByMainId(id);
|
|
|
- return Result.OK(syCostAllocationIngredientList);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 通过id查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配子表_辅料-通过主表ID查询")
|
|
|
+ @ApiOperation(value = "成本分配子表_辅料-通过主表ID查询", notes = "成本分配主表-通过主表ID查询")
|
|
|
+ @GetMapping(value = "/querySyCostAllocationIngredientByMainId")
|
|
|
+ public Result<?> querySyCostAllocationIngredientListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ List<SyCostAllocationIngredient> syCostAllocationIngredientList = syCostAllocationIngredientService.selectByMainId(id);
|
|
|
+ return Result.OK(syCostAllocationIngredientList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询
|
|
|
*
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
- @AutoLog(value = "成本分配子表_发运明细-通过主表ID查询")
|
|
|
- @ApiOperation(value="成本分配子表_发运明细-通过主表ID查询", notes="成本分配主表-通过主表ID查询")
|
|
|
- @GetMapping(value = "/querySyCostAllocationShipdetailByMainId")
|
|
|
- public Result<?> querySyCostAllocationShipdetailListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
- List<SyCostAllocationShipdetail> syCostAllocationShipdetailList = syCostAllocationShipdetailService.selectByMainId(id);
|
|
|
- return Result.OK(syCostAllocationShipdetailList);
|
|
|
- }
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "成本分配子表_发运明细-通过主表ID查询")
|
|
|
+ @ApiOperation(value = "成本分配子表_发运明细-通过主表ID查询", notes = "成本分配主表-通过主表ID查询")
|
|
|
+ @GetMapping(value = "/querySyCostAllocationShipdetailByMainId")
|
|
|
+ public Result<?> querySyCostAllocationShipdetailListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
+ List<SyCostAllocationShipdetail> syCostAllocationShipdetailList = syCostAllocationShipdetailService.selectByMainId(id);
|
|
|
+ return Result.OK(syCostAllocationShipdetailList);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param syCostAllocation
|
|
|
- */
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, SyCostAllocation syCostAllocation) {
|
|
|
- // Step.1 组装查询条件
|
|
|
- QueryWrapper<SyCostAllocation> queryWrapper = QueryGenerator.initQueryWrapper(syCostAllocation, request.getParameterMap());
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param syCostAllocation
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, SyCostAllocation syCostAllocation) {
|
|
|
+ // Step.1 组装查询条件
|
|
|
+ QueryWrapper<SyCostAllocation> queryWrapper = QueryGenerator.initQueryWrapper(syCostAllocation, request.getParameterMap());
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
|
- //Step.2 获取导出数据
|
|
|
- List<SyCostAllocationPage> pageList = new ArrayList<SyCostAllocationPage>();
|
|
|
- List<SyCostAllocation> syCostAllocationList = syCostAllocationService.list(queryWrapper);
|
|
|
- for (SyCostAllocation temp : syCostAllocationList) {
|
|
|
- SyCostAllocationPage vo = new SyCostAllocationPage();
|
|
|
- BeanUtils.copyProperties(temp, vo);
|
|
|
- List<SyCostAllocationAccident> syCostAllocationAccidentList = syCostAllocationAccidentService.selectByMainId(temp.getId());
|
|
|
- vo.setSyCostAllocationAccidentList(syCostAllocationAccidentList);
|
|
|
- List<SyCostAllocationCostpay> syCostAllocationCostpayList = syCostAllocationCostpayService.selectByMainId(temp.getId());
|
|
|
- vo.setSyCostAllocationCostpayList(syCostAllocationCostpayList);
|
|
|
- List<SyCostAllocationFabric> syCostAllocationFabricList = syCostAllocationFabricService.selectByMainId(temp.getId());
|
|
|
- vo.setSyCostAllocationFabricList(syCostAllocationFabricList);
|
|
|
- List<SyCostAllocationIngredient> syCostAllocationIngredientList = syCostAllocationIngredientService.selectByMainId(temp.getId());
|
|
|
- vo.setSyCostAllocationIngredientList(syCostAllocationIngredientList);
|
|
|
- List<SyCostAllocationShipdetail> syCostAllocationShipdetailList = syCostAllocationShipdetailService.selectByMainId(temp.getId());
|
|
|
- vo.setSyCostAllocationShipdetailList(syCostAllocationShipdetailList);
|
|
|
- pageList.add(vo);
|
|
|
- }
|
|
|
- //Step.3 调用AutoPoi导出Excel
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "成本分配主表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, SyCostAllocationPage.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("成本分配主表数据", "导出人:"+sysUser.getRealname(), "成本分配主表"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
- }
|
|
|
+ //Step.2 获取导出数据
|
|
|
+ List<SyCostAllocationPage> pageList = new ArrayList<SyCostAllocationPage>();
|
|
|
+ List<SyCostAllocation> syCostAllocationList = syCostAllocationService.list(queryWrapper);
|
|
|
+ for (SyCostAllocation temp : syCostAllocationList) {
|
|
|
+ SyCostAllocationPage vo = new SyCostAllocationPage();
|
|
|
+ BeanUtils.copyProperties(temp, vo);
|
|
|
+ List<SyCostAllocationAccident> syCostAllocationAccidentList = syCostAllocationAccidentService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyCostAllocationAccidentList(syCostAllocationAccidentList);
|
|
|
+ List<SyCostAllocationCostpay> syCostAllocationCostpayList = syCostAllocationCostpayService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyCostAllocationCostpayList(syCostAllocationCostpayList);
|
|
|
+ List<SyCostAllocationFabric> syCostAllocationFabricList = syCostAllocationFabricService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyCostAllocationFabricList(syCostAllocationFabricList);
|
|
|
+ List<SyCostAllocationIngredient> syCostAllocationIngredientList = syCostAllocationIngredientService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyCostAllocationIngredientList(syCostAllocationIngredientList);
|
|
|
+ List<SyCostAllocationShipdetail> syCostAllocationShipdetailList = syCostAllocationShipdetailService.selectByMainId(temp.getId());
|
|
|
+ vo.setSyCostAllocationShipdetailList(syCostAllocationShipdetailList);
|
|
|
+ pageList.add(vo);
|
|
|
+ }
|
|
|
+ //Step.3 调用AutoPoi导出Excel
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "成本分配主表");
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, SyCostAllocationPage.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<SyCostAllocationPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyCostAllocationPage.class, params);
|
|
|
- for (SyCostAllocationPage page : list) {
|
|
|
- SyCostAllocation po = new SyCostAllocation();
|
|
|
- BeanUtils.copyProperties(page, po);
|
|
|
- syCostAllocationService.saveMain(po, page.getSyCostAllocationAccidentList(),page.getSyCostAllocationCostpayList(),page.getSyCostAllocationFabricList(),page.getSyCostAllocationIngredientList(),page.getSyCostAllocationShipdetailList());
|
|
|
- }
|
|
|
- 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("文件导入失败!");
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 通过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<SyCostAllocationPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyCostAllocationPage.class, params);
|
|
|
+ for (SyCostAllocationPage page : list) {
|
|
|
+ SyCostAllocation po = new SyCostAllocation();
|
|
|
+ BeanUtils.copyProperties(page, po);
|
|
|
+ syCostAllocationService.saveMain(po, page.getSyCostAllocationAccidentList(), page.getSyCostAllocationCostpayList(), page.getSyCostAllocationFabricList(), page.getSyCostAllocationIngredientList(), page.getSyCostAllocationShipdetailList());
|
|
|
+ }
|
|
|
+ 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("文件导入失败!");
|
|
|
+ }
|
|
|
|
|
|
}
|