若依进销存系统---采购入库单

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: 若依进销存系统---采购入库单

采购入库单


后端代码


controller层

package com.ruoyi.web.controller.gson.warehousemanagement;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.PathConstant;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.ErrCode;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.SwException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ValidUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.Do.CbpcDo;
import com.ruoyi.system.domain.dto.CbpcDto;
import com.ruoyi.system.domain.dto.CbpdDto;
import com.ruoyi.system.domain.vo.CbpcVo;
import com.ruoyi.system.domain.vo.IdVo;
import com.ruoyi.system.service.ISwJsPurchaseinboundService;
import com.ruoyi.web.controller.tool.Resubmit;
import com.ruoyi.web.utils.FileCopyUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.*;
import java.util.List;
import static io.lettuce.core.pubsub.PubSubOutput.Type.message;
/**
 * 采购入库单Controller
 *
 * @author lhy
 * @date  2022-06-26
 */
@Api(
        tags = {"采购入库单"}
)
@Slf4j
@RestController
@RequestMapping("/system/Purchaseinbound")
public class SwJsPurchaseinboundController extends BaseController {
    @Resource
    private ISwJsPurchaseinboundService swJsPurchaseinboundService;
    /**
     * 新增采购入库单
     */
    @ApiOperation(
            value ="新增采购入库单",
            notes = "新增采购入库单"
    )
    @PostMapping("/SwJsPurchaseinboundaddplus")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:add')")
    public AjaxResult swJsPurchaseinboundaddplus(@Valid @RequestBody CbpdDto cbpdDto, BindingResult bindingResult) {
        try {
            ValidUtils.bindvaild(bindingResult);
            swJsPurchaseinboundService.insertSwJsSkuBarcodesplus(cbpdDto);
            return AjaxResult.success();
        }catch (SwException e) {
            log.error("【新增采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【新增采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【新增采购入库单】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 新增采购入库单主表
     */
    @ApiOperation(
            value ="新增采购入库单主表",
            notes = "新增采购入库单主表"
    )
    @PostMapping("/SwJsPurchaseinboundadd")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:add')")
    public AjaxResult<IdVo> swJsPurchaseinboundadd(@Valid @RequestBody CbpdDto cbpdDto, BindingResult bindingResult) {
        IdVo res=null;
        try {
            ValidUtils.bindvaild(bindingResult);
          res=swJsPurchaseinboundService.insertSwJsSkuBarcodes(cbpdDto);
            return AjaxResult.success(res);
        }catch (SwException e) {
            log.error("【新增采购入库单主表】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【新增采购入库单主表】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【新增采购入库单主表】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库单修改1
     */
    @ApiOperation(
            value ="采购入库单修改1",
            notes = "采购入库单修改1"
    )
    @PostMapping("/SwJsPurchaseinboundeditone")
    public AjaxResult SwJsPurchaseinboundeditone(@Valid @RequestBody CbpdDto cbpdDto, BindingResult bindingResult) {
        try {
            ValidUtils.bindvaild(bindingResult);
         swJsPurchaseinboundService.SwJsPurchaseinboundeditone(cbpdDto);
            return AjaxResult.success();
        }catch (SwException e) {
            log.error("【采购入库单修改1】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【采购入库单修改1】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【采购入库单修改1】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 新增采购入库单扫码
     */
    @ApiOperation(
            value ="新增采购入库单扫码",
            notes = "新增采购入库单扫码"
    )
    //@Resubmit(delaySeconds = 2)
    @PostMapping("/SwJsPurchaseinboundaddsm")
    public AjaxResult swJsPurchaseinboundaddsm(@Valid @RequestBody Cbpe itemList, BindingResult bindingResult) {
        try {
            ValidUtils.bindvaild(bindingResult);
            return toAjax(swJsPurchaseinboundService.insertSwJsSkuBarcodesm(itemList));
        }catch (SwException e) {
            log.error("【新增采购入库单扫码】接口出现异常,参数${},异常${}$", JSON.toJSON(itemList), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【新增采购入库单扫码】接口出现异常,参数${},异常${}$", JSON.toJSON(itemList), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【新增采购入库单扫码】接口出现异常,参数${}$,异常${}$", JSON.toJSON(itemList), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 新增采购入库单明细表
     */
    @ApiOperation(
            value ="新增采购入库单明细表",
            notes = "新增采购入库单明细表"
    )
    @PostMapping("/SwJsPurchseinboundadds")
    public AjaxResult SwJsPurchseinboundadds(@Valid @RequestBody List<Cbpd> itemList, BindingResult bindingResult) {
        try {
            ValidUtils.bindvaild(bindingResult);
            return toAjax(swJsPurchaseinboundService.insertSwJsSkuBarcsodesm(itemList));
        }catch (SwException e) {
            log.error("【新增采购入库单明细表】接口出现异常,参数${},异常${}$", JSON.toJSON(itemList), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (ServiceException e) {
            log.error("【新增采购入库单明细表】接口出现异常,参数${},异常${}$", JSON.toJSON(itemList), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (Exception e) {
            log.error("【新增采购入库单明细表】接口出现异常,参数${}$,异常${}$", JSON.toJSON(itemList), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库单审核
     */
    @ApiOperation(
            value ="采购入库单审核",
            notes = "采购入库单审核"
    )
    @PostMapping("/SwJsPurchaseinboundsh")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:sh')")
    public AjaxResult swJsPurchaseinboundsh( @RequestBody CbpdDto cbpdDto) {
        try {
            return toAjax(swJsPurchaseinboundService.SwJsSkuBarcodeshs(cbpdDto));
        }catch (ServiceException e) {
            log.error("【采购入库单审核】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (SwException e) {
            log.error("【采购入库单审核】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【采购入库单审核】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库标记完成
     */
    @ApiOperation(
            value ="采购入库标记完成",
            notes = "采购入库标记完成"
    )
    @Resubmit(delaySeconds = 3)
    @PostMapping("/SwJsPurchaseinboundshss")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:bjwc')")
    public AjaxResult swJsPurchaseinboundshss( @RequestBody CbpdDto cbpdDto ) {
        try {
            return toAjax(swJsPurchaseinboundService.SwJsSkuBarcodeshsss(cbpdDto));
        }catch (ServiceException e) {
            log.error("【采购入库标记完成】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (SwException e) {
            log.error("【采购入库标记完成】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【采购入库标记完成】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库取消完成
     */
    @ApiOperation(
            value ="采购入库取消完成",
            notes = "采购入库取消完成"
    )
    @PostMapping("/SwJsPurchaseinbounds")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:qxwc')")
    public AjaxResult swJsPurchaseinbounds( @RequestBody CbpdDto cbpdDto) {
        try {
            return toAjax(swJsPurchaseinboundService.SwJsSkuBarcodesh(cbpdDto));
        }catch (ServiceException e) {
            log.error("【采购入库取消完成】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (SwException e) {
            log.error("【采购入库取消完成】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【采购入库取消完成】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库单反审
     */
    @ApiOperation(
            value ="采购入库单反审",
            notes = "采购入库单反审"
    )
    @PostMapping("/SwJsPurchaseinboundshs")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:fs')")
    public AjaxResult swJsPurchaseinboundshs( @RequestBody CbpdDto cbpdDto) {
        try {
            return toAjax(swJsPurchaseinboundService.SwJsSkuBarcodeshss(cbpdDto));
        }catch (ServiceException e) {
            log.error("【采购入库单反审】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (SwException e) {
            log.error("【采购入库单反审】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【采购入库单反审】接口出现异常,参数${}$,异常${}$",JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 删除采购入库单
     */
    @ApiOperation(
            value ="删除采购入库单",
            notes = "删除采购入库单"
    )
    @PostMapping("/SwJsPurchaseinboundremove")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:remove')")
    public AjaxResult swJsPurchaseinboundremove(@RequestBody CbpdDto cbpdDto) {
        try {
            return toAjax(swJsPurchaseinboundService.deleteSwJsSkuBarcodsById(cbpdDto));
        }catch (SwException e) {
            log.error("【删除采购入库单】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpdDto),ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【删除采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpdDto), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【删除采购入库单】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpdDto),ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 修改采购入库单
     */
    @ApiOperation(
            value ="修改采购入库单",
            notes = "修改采购入库单"
    )
    @PostMapping("/SwJsPurchaseinboundedit")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:edit')")
    public AjaxResult swJsPurchaseinboundedit(@RequestBody CbpcDo cbpcDo) {
        try {
            return toAjax(swJsPurchaseinboundService.updateSwJsSkuBarcodes(cbpcDo));
        }catch (SwException e) {
            log.error("【修改采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcDo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【修改采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcDo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【修改采购入库单】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpcDo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库单查询
     */
    @ApiOperation(
            value ="采购入库单查询",
            notes = "采购入库单查询"
    )
    @GetMapping("/SwJsSkuBarcodelist")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:list')")
    public AjaxResult<TableDataInfo> swJsGoodslist(CbpcVo cbpcVo) {
        try {
            startPage();
            List<CbpcVo> list = swJsPurchaseinboundService.selectSwJsTaskGoodsRelLists(cbpcVo);
            return AjaxResult.success(getDataTable(list));
        }catch (SwException e) {
            log.error("【采购入库单查询】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcVo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (ServiceException e) {
            log.error("【采购入库单查询】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcVo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (Exception e) {
            log.error("【采购入库单查询】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpcVo),ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库单详情
     */
    @ApiOperation(
            value ="采购入库单详情",
            notes = "采购入库单详情"
    )
    @GetMapping("/SwJsSkuBarcodelistss")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:detail')")
    public AjaxResult<TableDataInfo> swJsGoodslistss( CbpcVo cbpcVo) {
        try {
          //  startPage();
            List<CbpcVo> list = swJsPurchaseinboundService.selectSwJsTaskGoodsRelListsss(cbpcVo);
            return AjaxResult.success(getDataTable(list));
        }catch (SwException e) {
            log.error("【采购入库单详情】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcVo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (ServiceException e) {
            log.error("【采购入库单详情】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcVo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (Exception e) {
            log.error("【采购入库单详情】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpcVo),ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 采购入库单列表
     */
    @ApiOperation(
            value ="采购入库单列表",
            notes = "采购入库单列表"
    )
    @GetMapping("/SwJsSkuBarcodelists")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:list')")
    public AjaxResult<TableDataInfo> swJsGoodslists(CbpcVo cbpcVo) {
        try {
            startPage();
            List<CbpcVo> list = swJsPurchaseinboundService.selectSwJsTaskGoodsRelListss(cbpcVo);
            return AjaxResult.success(getDataTable(list));
        }catch (SwException e) {
            log.error("【采购入库单列表】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcVo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (ServiceException e) {
            log.error("【采购入库单列表】接口出现异常,参数${},异常${}$", JSON.toJSON(cbpcVo), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【采购入库单列表】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbpcVo),ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
    /**
     * 导出采购入库单
     */
    @ApiOperation(
            value ="导出采购入库单",
            notes = "导出采购入库单"
    )
    @PostMapping("/SwJsGoodsexport")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:export')")
    public void swJsGoodsexport(HttpServletResponse response, CbpcVo cbpcVo) {
        List<CbpcVo> list = swJsPurchaseinboundService.selectSwJsTaskGoodsRelLists(cbpcVo);
        ExcelUtil<CbpcVo> util = new ExcelUtil<>(CbpcVo.class);
        util.exportExcel(response, list, "商品数据");
    }
    /**
     * 导入采购入库单
     */
    @ApiOperation(
            value ="导入采购入库单",
            notes = "导入采购入库单"
    )
    @PostMapping("/importSwJsGoods")
    @PreAuthorize("@ss.hasPermi('system:purchaseinbound:import')")
    @ResponseBody
    public AjaxResult importSwJsGoods(MultipartFile file, boolean updateSupport) {
        try {
            ExcelUtil<CbpcDto> util = new ExcelUtil<>(CbpcDto.class);
            List<CbpcDto> swJsGoodsList = util.importExcel(file.getInputStream());
            //    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            String operName = SecurityUtils.getUsername();
            //String operName = loginUser.getUsername();
            String message = swJsPurchaseinboundService.importSwJsGoods(swJsGoodsList, updateSupport,operName);
            return AjaxResult.success(message);
        }catch (SwException e) {
            log.error("【导入采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(message), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (ServiceException e) {
            log.error("【导入采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(message), ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        }catch (Exception e) {
            log.error("【导入采购入库单】接口出现异常,参数${},异常${}$", JSON.toJSON(message),ExceptionUtils.getStackTrace(e));
            return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }
    }
/*
    *//**
     * 导入采购入库单下载模板
     *//*
    @ApiOperation(
            value ="导入采购入库单下载模板",
            notes = "导入采购入库单下载模板"
    )
    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response)
    {
        ExcelUtil<CbpcDto> util = new ExcelUtil<CbpcDto>(CbpcDto.class);
        util.importTemplateExcel(response,"导入客户下载模板");
    }*/
    /**
     * 导入采购入库单下载模板
     */
    @ApiOperation(
            value ="导入采购入库单下载模板",
            notes = "导入采购入库单下载模板"
    )
    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response) throws IOException {
        InputStream in = null;
        String excelPaht="";
        String excelPaht2="";
        String pdfPath="";
        XSSFWorkbook wb = null;
        try {
            long time = System.currentTimeMillis();
            excelPaht=   RuoYiConfig.getSwdataprofile()+"采购入库导入模板_"+time+".xlsx";
            excelPaht2 = RuoYiConfig.getSwprofile() + "模板采购入库导入_"  + time + ".xlsx";
            FileCopyUtils.copyFile(new File(RuoYiConfig.getSwprofile()+ PathConstant.BUY_ORDER_SCANSEWASTYY_EXCEL),new File(excelPaht2));
            File is = new File(excelPaht2);
            wb = new XSSFWorkbook(is);
        /*File file = new File("text.java");
        String filePath = file.getAbsolutePath();*/
            saveExcelToDisk(wb, excelPaht);
            //  saveExcelToDisk(wb, name);
            FileUtils.setAttachmentResponseHeader(response, "采购入库单导入模板_.xlsx");
            FileUtils.writeBytes(excelPaht, response.getOutputStream());
        } catch (SwException e) {
            log.error("【导入采购入库单下载模板】接口出现异常,参数${}$,异常${}$", ExceptionUtils.getStackTrace(e));
            // return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage());
        } catch (Exception e) {
            log.error("【导入采购入库单下载模板】接口出现异常,参数${}$,异常${}$",  ExceptionUtils.getStackTrace(e));
            // return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败");
        }finally {
            if(in!=null){
                in.close();
            }
            if(wb!=null){
                wb.close();
            }
            if(excelPaht!=null){
                FileUtils.deleteFile(excelPaht);
            }
            if(excelPaht2!=null){
                FileUtils.deleteFile(excelPaht2);
            }
        }
        // return AjaxResult.success();
    }
    private static void saveExcelToDisk(XSSFWorkbook wb, String filePath){
        File file = new File(filePath);
        OutputStream os=null;
        try {
            os = new FileOutputStream(file);
            wb.write(os);
            os.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {if(os!=null) {
                os.close();
            }
            } catch (IOException e) { log.error("error", e);}
        }
    }
}


封装的消息提醒

package com.ruoyi.common.core.domain;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils;
import java.io.Serializable;
import java.util.HashMap;
/**
 * 操作消息提醒
 *
 * @author ruoyi
 */
public class AjaxResult<T> extends HashMap<String, Object> implements Serializable
{
    private static final long serialVersionUID = 1L;
    /** 状态码 */
    public static final String CODE_TAG = "code";
    /** 返回内容 */
    public static final String MSG_TAG = "msg";
    /** 数据对象 */
    public static final String DATA_TAG = "data";
    /**
     * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
     */
    public AjaxResult()
    {
    }
    /**
     * 初始化一个新创建的 AjaxResult 对象
     *
     * @param code 状态码
     * @param msg 返回内容
     */
    public AjaxResult(int code, String msg)
    {
        super.put(CODE_TAG, code);
        super.put(MSG_TAG, msg);
    }
    /**
     * 初始化一个新创建的 AjaxResult 对象
     *
     * @param code 状态码
     * @param msg 返回内容
     * @param data 数据对象
     */
    public AjaxResult(int code, String msg, Object data)
    {
        super.put(CODE_TAG, code);
        super.put(MSG_TAG, msg);
        if (StringUtils.isNotNull(data))
        {
            super.put(DATA_TAG, data);
        }
    }
    /**
     * 返回成功消息
     *
     * @return 成功消息
     */
    public static AjaxResult success()
    {
        return AjaxResult.success("操作成功");
    }
    /**
     * 返回成功数据
     *
     * @return 成功消息
     */
    public static AjaxResult success(Object data)
    {
        return AjaxResult.success("操作成功", data);
    }
    /**
     * 返回成功消息
     *
     * @param msg 返回内容
     * @return 成功消息
     */
    public static AjaxResult success(String msg)
    {
        return AjaxResult.success(msg, null);
    }
    /**
     * 返回成功消息
     *
     * @param msg 返回内容
     * @param data 数据对象
     * @return 成功消息
     */
    public static AjaxResult success(String msg, Object data)
    {
        return new AjaxResult(HttpStatus.SUCCESS, msg, data);
    }
    /**
     * 返回错误消息
     *
     * @return
     */
    public static AjaxResult error()
    {
        return AjaxResult.error("操作失败");
    }
    /**
     * 返回错误消息
     *
     * @param msg 返回内容
     * @return 警告消息
     */
    public static AjaxResult error(String msg)
    {
        return AjaxResult.error(msg, null);
    }
    /**
     * 返回错误消息
     *
     * @param msg 返回内容
     * @param data 数据对象
     * @return 警告消息
     */
    public static AjaxResult error(String msg, Object data)
    {
        return new AjaxResult(HttpStatus.ERROR, msg, data);
    }
    /**
     * 返回错误消息
     *
     * @param code 状态码
     * @param msg 返回内容
     * @return 警告消息
     */
    public static AjaxResult error(int code, String msg)
    {
        return new AjaxResult(code, msg, null);
    }
    /**
     * 方便链式调用
     *
     * @param key 键
     * @param value 值
     * @return 数据对象
     */
    @Override
    public AjaxResult put(String key, Object value)
    {
        super.put(key, value);
        return this;
    }
    private Long errcode;
    private String errmsg;
    private T data;
    private String traceId;
    AjaxResult(final Long errcode, final String errmsg, final T data, final String traceId) {
        this.errcode = errcode;
        this.errmsg = errmsg;
        this.data = data;
        this.traceId = traceId;
    }
    public static class AjaxResultBuilder<T> {
        private Long errcode;
        private String errmsg;
        private T data;
        private String traceId;
        protected AjaxResultBuilder() {
        }
        public AjaxResultBuilder<T> errcode(final Long errcode) {
            this.errcode = errcode;
            return this;
        }
        public AjaxResultBuilder<T> errmsg(final String errmsg) {
            this.errmsg = errmsg;
            return this;
        }
        public AjaxResultBuilder<T> data(final T data) {
            this.data = data;
            return this;
        }
        public AjaxResultBuilder<T> traceId(final String traceId) {
            this.traceId = traceId;
            return this;
        }
        public AjaxResult<TableDataInfo> build() {
            return new AjaxResult(this.errcode, this.errmsg, this.data, this.traceId);
        }
        public AjaxResult<T> builds() {
            return new AjaxResult(this.errcode, this.errmsg, this.data, this.traceId);
        }
        public String toString() {
            return "ResponseResult.AjaxResultBuilder(errcode=" + this.errcode + ", errmsg=" + this.errmsg + ", data=" + this.data + ", traceId=" + this.traceId + ")";
        }
    }
    public static <T> AjaxResultBuilder<T> builder() {
        return new AjaxResultBuilder();
    }
}


Service层·

package com.ruoyi.system.service;
import com.ruoyi.system.domain.Cbpc;
import com.ruoyi.system.domain.Cbpd;
import com.ruoyi.system.domain.Cbpe;
import com.ruoyi.system.domain.Cbsc;
import com.ruoyi.system.domain.Do.CbpcDo;
import com.ruoyi.system.domain.dto.CbpcDto;
import com.ruoyi.system.domain.dto.CbpdDto;
import com.ruoyi.system.domain.vo.CbpcVo;
import com.ruoyi.system.domain.vo.IdVo;
import java.util.List;
public interface ISwJsPurchaseinboundService {
    /**
     * 新增采购入库单
     *
     * @param cbpdDto
     * @return 结果
     */
    IdVo insertSwJsSkuBarcodes(CbpdDto cbpdDto);
    int SwJsSkuBarcodeshs(CbpdDto cbpdDto);
    int deleteSwJsSkuBarcodsById(CbpdDto cbpdDto);
    int updateSwJsSkuBarcodes(CbpcDo cbpcDo);
    List<CbpcVo> selectSwJsTaskGoodsRelLists(CbpcVo cbpcVo);
    public List<Cbpc> selectCBPCList(Cbpc cbpc);
    String importSwJsGoods(List<CbpcDto> swJsGoodsList, boolean updateSupport, String operName);
    int SwJsSkuBarcodeshss(CbpdDto cbpdDto);
    int SwJsSkuBarcodeshsss(CbpdDto cbpdDto) throws InterruptedException;
    int SwJsSkuBarcodesh(CbpdDto cbpdDto);
    List<CbpcVo> selectSwJsTaskGoodsRelListss(CbpcVo cbpcVo);
    List<CbpcVo> selectSwJsTaskGoodsRelListsss(CbpcVo cbpcVo);
    int insertSwJsSkuBarcodesm(Cbpe itemList);
    int insertSwJsStores(List<CbpcDto> itemList);
    int insertSwJsSkuBarcsodesm(List<Cbpd> itemList);
    void SwJsPurchaseinboundeditone(CbpdDto cbpdDto);
    int insertSwJsSkuBarcodesplus(CbpdDto cbpdDto);
}


ServiceImpl层

package com.ruoyi.framework.web.service.impl;
import com.ruoyi.common.enums.*;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.SwException;
import com.ruoyi.common.utils.BeanCopyUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.Do.*;
import com.ruoyi.system.domain.dto.CbpcDto;
import com.ruoyi.system.domain.dto.CbpdDto;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.ISwJsPurchaseinboundService;
import com.ruoyi.system.service.gson.BaseCheckService;
import com.ruoyi.system.service.gson.OrderDistributionService;
import com.ruoyi.system.service.gson.TaskService;
import com.ruoyi.system.service.gson.impl.NumberGenerate;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
 * @author 15698
 */
@Slf4j
@Service
public class SwJsPurchaseinboundServiceImpl implements ISwJsPurchaseinboundService {
@Resource
private GsGoodsSnMapper gsGoodsSnMapper;
@Resource
private BaseCheckService baseCheckService;
@Resource
private GsGoodsSkuMapper gsGoodsSkuMapper;
    @Resource
    private CbpcMapper cbpcMapper;
    @Resource
    private CbpdMapper cbpdMapper;
    @Resource
    private CbsaMapper cbasMapper;
    @Resource
    private CbpeMapper cbpeMapper;
   @Resource
   private TaskService taskService;
   @Resource
   private CbsaMapper cbsaMapper;
   @Resource
   private CblaMapper cblaMapper;
   @Resource
   private CbwaMapper cbwaMapper;
   @Resource
   private CalaMapper calaMapper;
   @Resource
   private CbpbMapper cbpbMapper;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Resource
    private CbibMapper cbibMapper;
    @Resource
    private OrderDistributionService orderDistributionService;
@Resource
private NumberGenerate numberGenerate;
    @Autowired
    private SqlSessionFactory sqlSessionFactory;
    /**
     * 新增采购入库单
     *
     * @param cbpdDto 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public IdVo insertSwJsSkuBarcodes(CbpdDto cbpdDto) {
       // 检查供应商
        baseCheckService.checksupplier(cbpdDto.getCbpc09());
        //检查仓库
        baseCheckService.checkStore(cbpdDto.getCbpc10());
        //检查商品
     //  baseCheckService.checkGoods(cbpdDto.getCbpd08());
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc07EqualTo(cbpdDto.getCbpc07())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        List<Cbpc> cbpcs = cbpcMapper.selectByExample(example);
        //主表根据输入编号查不到数据,添加数据
            Long userid = SecurityUtils.getUserId();
            Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
            Date date = new Date();
            cbpc.setCbpc02(date);
            cbpc.setCbpc03(Math.toIntExact(userid));
            cbpc.setCbpc04(date);
            cbpc.setCbpc05(Math.toIntExact(userid));
            cbpc.setCbpc08(date);
            cbpc.setCbpc11(TaskStatus.mr.getCode());
            cbpc.setCbpc06(DeleteFlagEnum.NOT_DELETE.getCode());
            String purchaseinboundNo = numberGenerate.getPurchaseinboundNo(cbpdDto.getCbpc10());
            cbpc.setCbpc07(purchaseinboundNo);
            cbpc.setCbpc13(date);
            cbpc.setCbpc15(date);
            cbpc.setUserId(Math.toIntExact(userid));
            cbpcMapper.insertSelective(cbpc);
            CbpcCriteria example1 = new CbpcCriteria();
            example1.createCriteria().andCbpc07EqualTo(purchaseinboundNo)
                    .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
            List<Cbpc> cbpcs1 = cbpcMapper.selectByExample(example1);
        IdVo idVo = new IdVo();
        if(!CollectionUtils.isEmpty(cbpcs1)){
            idVo.setId(cbpcs1.get(0).getCbpc01());
        }
       // idVo.setId(cbpcs1.get(0).getCbpc01());
        List<Cbpd> goods = cbpdDto.getGoods();
        for(Cbpd cbpd : goods){
            cbpd.setCbpc01(idVo.getId());
        }
        this.insertSwJsSkuBarcsodesm(goods);
        return idVo;
    }
    /**
     * 新增采购入库单扫码
     *
     * @param itemList 审核信息
     * @return 结果
     */
   @Transactional
    @Override
    public int insertSwJsSkuBarcodesm(Cbpe itemList) {
       log.info("打印" + Thread.currentThread().getName() + "sn表");
       if (itemList == null) {
           throw new SwException("请选择要扫的商品");
       }
       if (itemList.getCbpc01() == null) {
           throw new SwException("采购订单主单id不能为空");
       }
if(itemList.getCbpe08()!=null) {
    Cbpb cbpb = cbpbMapper.selectByPrimaryKey(itemList.getCbpe08());
    if(cbpb!=null){
        if(Objects.equals(cbpb.getCbpb12(), itemList.getCbpe09())){
            throw new SwException("sn不正确");
        }
    }
}
       CbpcVo cbpcVo = new CbpcVo();
       cbpcVo.setCbpc01(itemList.getCbpc01());
       List<CbpcVo> cbpcVos = selectSwJsTaskGoodsRelListsss(cbpcVo);
       if(  cbpcVos.get(0).getSaoma()!=null){
           double v = cbpcVos.get(0).getSaoma().doubleValue();
           if( v==cbpcVos.get(0).getNums()){
               throw new SwException("该采购订单已扫描完成");
           }
       }
       Cbpc cbpcs = cbpcMapper.selectByPrimaryKey(itemList.getCbpc01());
       Integer storeid = cbpcs.getCbpc10();
       CbpdCriteria cas = new CbpdCriteria();
       cas.createCriteria().andCbpc01EqualTo(itemList.getCbpc01());
       List<Cbpd> cbphs = cbpdMapper.selectByExample(cas);
       if (cbphs.size() == 0) {
           throw new SwException("采购入库单明细为空");
       }
       Set<Integer> sio = cbphs.stream().map(Cbpd::getCbpd08).collect(Collectors.toSet());
       Date date = new Date();
       Long userid = SecurityUtils.getUserId();
           if (itemList.getCbpe09() == null) {
               throw new SwException("sn码不能为空");
           }
           String cbic10 = itemList.getCbpe09();
           String uuid = UUID.randomUUID().toString();
           Boolean lock = redisTemplate.opsForValue().setIfAbsent(cbic10, uuid, 3, TimeUnit.SECONDS);
           if (!lock) {
               throw new SwException("sn重复,请勿重复提交");
           }
           String s = redisTemplate.opsForValue().get(cbic10);
           GsGoodsSnDo gsGoodsSnDo;
           try {
               if (itemList.getCbpe08() == null) {
                   throw new SwException("商品id不能为空");
               }
               CbpeCriteria example = new CbpeCriteria();
                example.createCriteria().andCbpe08EqualTo(itemList.getCbpe08())
                          .andCbpc01EqualTo(itemList.getCbpc01());
                List<Cbpe> cbpess = cbpeMapper.selectByExample(example);
                if(cbpess.size()>0){
                CbpdCriteria example1 = new CbpdCriteria();
                example1.createCriteria().andCbpc01EqualTo(itemList.getCbpc01())
                        .andCbpd08EqualTo(itemList.getCbpe08());
                List<Cbpd> cbpds = cbpdMapper.selectByExample(example1);
                    if(cbpds.size()==0){
                        throw new SwException("该商品不在该采购入库单中");
                    }
                    if(cbpess.size()==cbpds.get(0).getCbpd09()){
                        throw new SwException("该商品已扫描完成");
                    }
                }
               if (!sio.contains(itemList.getCbpe08())) {
                   throw new SwException("该商品不在采购入货单明细中");
               }
               if (itemList.getCbpe10() == null) {
                   throw new SwException("库位id不能为空");
               }
               Cbla cblas = cblaMapper.selectByPrimaryKey(itemList.getCbpe10());
               if (cblas == null) {
                   throw new SwException("库位不存在");
               }
               if (!cblas.getCbla10().equals(storeid)) {
                   throw new SwException("库位不属于该仓库");
               }
               String sn = itemList.getCbpe09();
           /*  boolean redisKeyBoolean = redisTemplate.opsForValue().setIfAbsent("lock",sn, 5, TimeUnit.SECONDS);
           String lock = redisTemplate.opsForValue().get("lock");*/
/*
           while (!redisTemplate.opsForValue().setIfAbsent("lock",sn, 3, TimeUnit.SECONDS)) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace(); }
            }
           String lock = redisTemplate.opsForValue().get("lock");*/
               //校验sn码
               CbpeCriteria examples = new CbpeCriteria();
               examples.createCriteria().andCbpe09EqualTo(sn)
                       .andCbpc01EqualTo(itemList.getCbpc01());
               List<Cbpe> cbpes = cbpeMapper.selectByExample(examples);
               if (cbpes.size() > 0) {
                   throw new SwException("该sn已存在");
               }
               //校验库位
               Cbla cbla = baseCheckService.checkStoresku(itemList.getCbpe10());
               itemList.setCbpe03(date);
               itemList.setCbpe04(Math.toIntExact(userid));
               itemList.setCbpe05(date);
               itemList.setCbpe06(Math.toIntExact(userid));
               itemList.setCbpe07(DeleteFlagEnum.NOT_DELETE.getCode());
               itemList.setUserId(Math.toIntExact(userid));
               itemList.setCbpe11(ScanStatusEnum.YISAOMA.getCode());
               //如果查不到添加信息到库存表
               Cbpc cbpc = cbpcMapper.selectByPrimaryKey(itemList.getCbpc01());
               if (cbpc == null) {
                   throw new SwException("采购入库单不存在");
               }
CbpdCriteria example1 = new CbpdCriteria();
                example1.createCriteria().andCbpc01EqualTo(itemList.getCbpc01())
                          .andCbpd08EqualTo(itemList.getCbpe08());
                List<Cbpd> cbpds = cbpdMapper.selectByExample(example1);
               GsGoodsSnCriteria gsGoodsSnCriteria = new GsGoodsSnCriteria();
               gsGoodsSnCriteria.createCriteria().andSnEqualTo(sn);
               List<GsGoodsSn> gsGoodsSns = gsGoodsSnMapper.selectByExample(gsGoodsSnCriteria);
               if (gsGoodsSns.size() > 0) {
                   if(gsGoodsSns.get(0).getStatus().equals(TaskStatus.sh.getCode().byteValue())){
                       throw new SwException("该sn已存在库存sn表里入库状态");
                   }
                   else {
                       GsGoodsSn  gsGoodsSn = new GsGoodsSn();
                       gsGoodsSn.setStatus(GoodsType.yrk.getCode());
                       gsGoodsSn.setGroudStatus(GoodsType.yrk.getCode());
                       gsGoodsSn.setSn(itemList.getCbpe09());
                       gsGoodsSn.setCurrency(cbpc.getCbpc16());
                       gsGoodsSn.setLocationId(itemList.getCbpe10());
                       if(cbpds.size()>0){
                           gsGoodsSn.setPrice(cbpds.get(0).getCbpd11());
                       }
                       GsGoodsSnCriteria gsGoodsSnCriteria1 = new GsGoodsSnCriteria();
                          gsGoodsSnCriteria1.createCriteria().andSnEqualTo(sn);
                          gsGoodsSnMapper.updateByExampleSelective(gsGoodsSn,gsGoodsSnCriteria1);
                   }
               //    throw new SwException("该sn已存在库存sn表里");
               }
          else{
               GsGoodsSn  gsGoodsSn = new GsGoodsSn();
               gsGoodsSn.setCreateTime(date);
               gsGoodsSn.setUpdateTime(date);
               gsGoodsSn.setCreateBy(Math.toIntExact(userid));
               gsGoodsSn.setUpdateBy(Math.toIntExact(userid));
               gsGoodsSn.setDeleteFlag(DeleteFlagEnum1.NOT_DELETE.getCode());
               gsGoodsSn.setSn(itemList.getCbpe09());
               gsGoodsSn.setGoodsId(itemList.getCbpe08());
               gsGoodsSn.setWhId(cbpc.getCbpc10());
               gsGoodsSn.setLocationId(itemList.getCbpe10());
               gsGoodsSn.setStatus(GoodsType.yrk.getCode());
               gsGoodsSn.setCurrency(cbpc.getCbpc16());
               gsGoodsSn.setInTime(date);
               if(cbpds.size()>0){
                   gsGoodsSn.setPrice(cbpds.get(0).getCbpd11());
               }
               gsGoodsSn.setGroudStatus(Groudstatus.SJ.getCode());
              /* if(cbpdList!=null&&cbpdList.size()>0){
                   gsGoodsSn.setPrice(cbpdList.get(0).getCbpd11());
               }
*/
               gsGoodsSnMapper.insertSelective(gsGoodsSn);
          }
           } finally {
               String script = "if redis.call('get', KEYS[1]) == ARGV[1] " +
                       "then " +
                       "return redis.call('del', KEYS[1]) " +
                       "else " +
                       "return 0 " +
                       "end";
               this.redisTemplate.execute(new DefaultRedisScript<>(script, Boolean.class), Arrays.asList("lock"), uuid);
           }
           // this.redisTemplate.delete("lock");
           cbpeMapper.insertSelective(itemList);
          // taskService.addGsGoodsSns(gsGoodsSnDo);
           //  redisTemplate.delete("lock");
       return 1;
   }
    //导入新增
    @Transactional
    @Override
    public int insertSwJsStores(List<CbpcDto> itemList) {
        if(CollectionUtils.isEmpty(itemList)){
            throw new SwException("导入数据为空");
        }
        Date date = new Date();
        Long userid = SecurityUtils.getUserId();
        if(itemList.get(0).getStorename()==null){
            throw new SwException("仓库名称不能为空");
        }
        String storename = itemList.get(0).getStorename();
        CbwaCriteria cbwaCriteria = new CbwaCriteria();
        cbwaCriteria.createCriteria().andCbwa09EqualTo(storename);
        List<Cbwa> cbwas = cbwaMapper.selectByExample(cbwaCriteria);
        if(CollectionUtils.isEmpty(cbwas)){
            throw new SwException("仓库不存在");
        }
        if(Objects.isNull(itemList.get(0).getSuppierName())){
            throw new SwException("供应商名称不能为空");
        }
        CbsaCriteria cbsaCriteria = new CbsaCriteria();
        cbsaCriteria.createCriteria().andCbsa08EqualTo(itemList.get(0).getSuppierName());
        List<Cbsa> cbsas = cbsaMapper.selectByExample(cbsaCriteria);
        if(CollectionUtils.isEmpty(cbsas)){
            throw new SwException("供应商不存在");
        }
        if(Objects.isNull(itemList.get(0).getMoneytype())){
            throw new SwException("货币类形不能为空");
        }
         CalaCriteria calaCriteria = new CalaCriteria();
        calaCriteria.createCriteria()
                .andCala08EqualTo(itemList.get(0).getMoneytype())
                .andCala10EqualTo("币种");
        List<Cala> calas = calaMapper.selectByExample(calaCriteria);
        if(CollectionUtils.isEmpty(calas)){
                throw new SwException("货币类形不存在");
            }
        Integer cala01 = calas.get(0).getCala01();
        Integer cbsa01 = cbsas.get(0).getCbsa01();
        Integer cbwa01 = cbwas.get(0).getCbwa01();
        Date cbpc08 = itemList.get(0).getCbpc08();
        Integer cbpc09 = itemList.get(0).getCbpc09();
        Integer cbpc10 = itemList.get(0).getCbpc10();
        Integer cbpc16 = itemList.get(0).getCbpc16();
        String purchaseinboundNo = numberGenerate.getPurchaseinboundNo(cbwa01);
        Cbpc cbpc = new Cbpc();
        cbpc.setCbpc02(date);
        cbpc.setCbpc03(Math.toIntExact(userid));
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc06(DeleteFlagEnum.NOT_DELETE.getCode());
        cbpc.setCbpc07(purchaseinboundNo);
        cbpc.setCbpc08(date);
        cbpc.setCbpc09(cbsa01);
        cbpc.setCbpc10(cbwa01);
        cbpc.setCbpc11(TaskStatus.mr.getCode());
        cbpc.setCbpc16(cala01);
        cbpc.setCbpc06(DeleteFlagEnum.NOT_DELETE.getCode());
        cbpcMapper.insertSelective(cbpc);
CbpcCriteria cbpcCriteria = new CbpcCriteria();
        cbpcCriteria.createCriteria().andCbpc07EqualTo(purchaseinboundNo);
        List<Cbpc> cbpcs = cbpcMapper.selectByExample(cbpcCriteria);
        Integer cbpc01 = cbpcs.get(0).getCbpc01();
        SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
        CbpdMapper mapper = session.getMapper(CbpdMapper.class);
        for (int i = 0; i < itemList.size(); i++) {
            if(Objects.isNull(itemList.get(i).getGoodtype())){
                throw new SwException("商品型号不能为空");
            }
            CbpbCriteria cbpbCriteria = new CbpbCriteria();
            cbpbCriteria.createCriteria().andCbpb12EqualTo(itemList.get(i).getGoodtype());
            List<Cbpb> cbpbs = cbpbMapper.selectByExample(cbpbCriteria);
            if(cbpbs.size()==0){
                throw new SwException("商品不存在"+itemList.get(i).getGoodtype());
            }
            Integer cbpb01 = cbpbs.get(0).getCbpb01();
            itemList.get(i).setCbpd03(date);
            itemList.get(i).setCbpd04(Math.toIntExact(userid));
            itemList.get(i).setCbpd05(date);
            itemList.get(i).setCbpd06(Math.toIntExact(userid));
            itemList.get(i).setCbpd07(DeleteFlagEnum.NOT_DELETE.getCode());
            itemList.get(i).setUserId(Math.toIntExact(userid));
            itemList.get(i).setCbpd08(cbpb01);
            itemList.get(i).setCbpd09(itemList.get(i).getCbpd09());
            itemList.get(i).setCbpd11(itemList.get(i).getCbpd11());
            itemList.get(i).setCbpd12(itemList.get(i).getCbpd09()*itemList.get(i).getCbpd11());
            itemList.get(i).setCbpd13(itemList.get(i).getCbpd13());
            itemList.get(i).setCbpc01(cbpc01);
            mapper.insertSelective(itemList.get(i));
            if (i % 10 == 9) {//每10条提交一次
                session.commit();
                session.clearCache();
            }
        }
        session.commit();
        session.clearCache();
        return 1;
    }
    @Transactional
    @Override
    public int insertSwJsSkuBarcsodesm(List<Cbpd> itemList) {
        if(itemList.size()==0){
            throw new SwException("采购入库明细不能为空");
        }
        SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
        CbpdMapper mapper = session.getMapper(CbpdMapper.class);
        Date date = new Date();
        Long userid = SecurityUtils.getUserId();
        for (int i = 0; i < itemList.size(); i++) {
            if(Objects.isNull(itemList.get(i).getCbpc01())){
                throw new SwException("采购入库主表id不能为空");
            }
            if(Objects.isNull(itemList.get(i).getCbpd08())){
                throw new SwException("商品不能为空");
            }
            if(Objects.isNull(itemList.get(i).getCbpd09())){
                throw new SwException("数量不能为空");
            }
            if(Objects.isNull(itemList.get(i).getCbpd11())){
                throw new SwException("单价不能为空");
            }
            itemList.get(i).setCbpd03(date);
            itemList.get(i).setCbpd04(Math.toIntExact(userid));
            itemList.get(i).setCbpd05(date);
            itemList.get(i).setCbpd06(Math.toIntExact(userid));
            itemList.get(i).setCbpd07(DeleteFlagEnum.NOT_DELETE.getCode());
            itemList.get(i).setUserId(Math.toIntExact(userid));
            mapper.insertSelective(itemList.get(i));
            if (i % 10 == 9) {//每10条提交一次
                session.commit();
                session.clearCache();
            }
        }
        session.commit();
        session.clearCache();
 Cbpc cbpc = new Cbpc();
 if(itemList.get(0).getCbpc01()==null){
     throw new SwException("采购入库主表id不能为空");
 }
        cbpc.setCbpc01(itemList.get(0).getCbpc01());
        cbpc.setCbpc06(DeleteFlagEnum.NOT_DELETE.getCode());
        cbpcMapper.updateByPrimaryKeySelective(cbpc);
        return 1;
    }
    @Override
    public void SwJsPurchaseinboundeditone(CbpdDto cbpdDto) {
        if(cbpdDto.getCbpc01()==null){
            throw new SwException("采购订单id不能为空");
        }
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(!cbpc1.getCbpc11().equals(TaskStatus.mr.getCode())){
            throw new SwException("未审核状态才能修改");
        }
        List<Cbpd> goods = cbpdDto.getGoods();
        if(goods==null||goods.size()==0){
            throw new SwException("请至少添加一件货物");
        }
        Long userid = SecurityUtils.getUserId();
        Date date = new Date();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        cbpc.setCbpc01(cbpdDto.getCbpc01());
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpcMapper.updateByPrimaryKeySelective(cbpc);
        CbpdCriteria cbpdCriterisa = new CbpdCriteria();
        cbpdCriterisa.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01());
        int i = cbpdMapper.deleteByExample(cbpdCriterisa);
        Cbpd cbpd = null;
        for(Cbpd good:goods){
            cbpd = new Cbpd();
            if(good.getCbpd01()==null){
                throw new SwException("采购订单明细id不能为空");
            }
            cbpd.setCbpd01(null);
            cbpd.setCbpd05(date);
            cbpd.setCbpd06(Math.toIntExact(userid));
            cbpd.setCbpd07(DeleteFlagEnum.NOT_DELETE.getCode());
            cbpd.setCbpd08(good.getCbpd08());
            cbpd.setCbpd09(good.getCbpd09());
            cbpd.setCbpd10(good.getCbpd10());
            cbpd.setCbpd11(good.getCbpd11());
            cbpd.setCbpd12(good.getCbpd12());
            cbpd.setCbpd13(good.getCbpd13());
            cbpd.setCbpc01(cbpdDto.getCbpc01());
            CbpdCriteria cbpdCriteria = new CbpdCriteria();
            cbpdCriteria.createCriteria().andCbpd01EqualTo(good.getCbpd01());
            cbpdMapper.insertSelective(cbpd);
        }
        return;
    }
    @Override
    @Transactional
    public int insertSwJsSkuBarcodesplus(CbpdDto cbpdDto) {
        // 检查供应商
        baseCheckService.checksupplier(cbpdDto.getCbpc09());
        //检查仓库
        baseCheckService.checkStore(cbpdDto.getCbpc10());
        //检查商品
        //  baseCheckService.checkGoods(cbpdDto.getCbpd08());
        List<Cbpd> goods = cbpdDto.getGoods();
        if(goods==null||goods.size()==0){
            throw new SwException("请至少添加一件货物");
        }
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc07EqualTo(cbpdDto.getCbpc07())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        List<Cbpc> cbpcs = cbpcMapper.selectByExample(example);
        //主表根据输入编号查不到数据,添加数据
        Long userid = SecurityUtils.getUserId();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        Date date = new Date();
        cbpc.setCbpc02(date);
        cbpc.setCbpc03(Math.toIntExact(userid));
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc08(date);
        cbpc.setCbpc11(TaskStatus.mr.getCode());
        cbpc.setCbpc06(DeleteFlagEnum.NOT_DELETE.getCode());
        String purchaseinboundNo = numberGenerate.getPurchaseinboundNo(cbpdDto.getCbpc10());
        cbpc.setCbpc07(purchaseinboundNo);
        cbpc.setCbpc13(date);
        cbpc.setCbpc15(date);
        cbpc.setUserId(Math.toIntExact(userid));
        cbpcMapper.insertSelective(cbpc);
        CbpcCriteria example1 = new CbpcCriteria();
        example1.createCriteria().andCbpc07EqualTo(purchaseinboundNo)
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        List<Cbpc> cbpcs1 = cbpcMapper.selectByExample(example1);
        Cbpd cbpd = null;
        for(Cbpd good:goods){
            cbpd = new Cbpd();
            if(good.getCbpd01()==null){
                throw new SwException("采购订单明细id不能为空");
            }
            cbpd.setCbpd03(date);
            cbpd.setCbpd04(Math.toIntExact(userid));
            cbpd.setCbpd05(date);
            cbpd.setCbpd06(Math.toIntExact(userid));
            cbpd.setCbpd07(DeleteFlagEnum.NOT_DELETE.getCode());
            cbpd.setCbpd08(good.getCbpd08());
            cbpd.setCbpd09(good.getCbpd09());
            cbpd.setCbpd10(good.getCbpd10());
            cbpd.setCbpd11(good.getCbpd11());
            cbpd.setCbpd12(good.getCbpd12());
            cbpd.setCbpd13(good.getCbpd13());
            if(cbpcs1.size()>0){
                Cbpc cbpc1 = cbpcs1.get(0);
                cbpd.setCbpc01(cbpc1.getCbpc01());
            }
            cbpdMapper.insertSelective(cbpd);
        }
        return 1;
    }
    /**
     * 审核采购入库单
     *
     * @param cbpdDto 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public int SwJsSkuBarcodeshs(CbpdDto cbpdDto) {
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(!cbpc1.getCbpc11().equals(TaskStatus.mr.getCode())){
            throw new SwException("不是未审核状态");
        }
        Long userid = SecurityUtils.getUserId();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        Date date = new Date();
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc11(TaskStatus.sh.getCode());
        cbpc.setCbpc12(cbpdDto.getCbpc12());
        cbpc.setCbpc13(cbpdDto.getCbpc13());
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        return cbpcMapper.updateByExampleSelective(cbpc, example);
    }
    /**
     * 反审采购入库单
     *
     * @param cbpdDto 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public int SwJsSkuBarcodeshss(CbpdDto cbpdDto) {
        CbpeCriteria example1 = new CbpeCriteria();
        example1.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01());
        List<Cbpe> cbpes = cbpeMapper.selectByExample(example1);
        if(cbpes.size()>0 ){
            int size = cbpes.size();
            for(int i=0;i<size;i++){
                if(cbpes.get(i).getCbpe11().equals(ScanStatusEnum.YISAOMA.getCode())) {
                    throw new SwException("已扫码不能反审");
                }
            }
        }
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(!cbpc1.getCbpc11().equals(TaskStatus.sh.getCode())){
            throw new SwException("不是 审核状态");
        }
        Long userid = SecurityUtils.getUserId();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        Date date = new Date();
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc11(TaskStatus.mr.getCode());
        cbpc.setCbpc12(cbpdDto.getCbpc12());
        cbpc.setCbpc13(cbpdDto.getCbpc13());
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        return cbpcMapper.updateByExampleSelective(cbpc, example);
    }
    /**
     * 采购入库单标记完成
     *
     * @param cbpdDto 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public int SwJsSkuBarcodeshsss(CbpdDto cbpdDto) throws InterruptedException {
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(cbpc1.getCbpc11().equals(TaskStatus.sh.getCode())||cbpc1.getCbpc11().equals(TaskStatus.fsh.getCode())){}
        else {
            throw new SwException("不是审核状态或反审状态不能标记完成");
        }
        Long userid = SecurityUtils.getUserId();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        Date date = new Date();
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc11(TaskStatus.bjwc.getCode());
        cbpc.setCbpc12(cbpdDto.getCbpc12());
        cbpc.setCbpc13(cbpdDto.getCbpc13());
        Cbsa cbsa = cbasMapper.selectByPrimaryKey(cbpc1.getCbpc09());
        if(cbsa==null){
            throw new SwException("供应商不存在");
        }
        //
        CbwaCriteria exampse1 = new CbwaCriteria();
        exampse1.createCriteria().andCbwa12EqualTo("数量管理");
        List<Cbwa> cbwas = cbwaMapper.selectByExample(exampse1);
        List<Integer> goodsids = cbwas.stream().map(Cbwa::getCbwa01).collect(Collectors.toList());
        Set<Integer> sio = new HashSet<>(goodsids);
        //判断是哪个仓库  数量仓库
        if(sio.contains(cbpc1.getCbpc10())){
            //数量管理查找商品id和仓库id,没有就加入
            CbpdCriteria cbpdexample1=new CbpdCriteria();
            cbpdexample1.createCriteria()
                    .andCbpc01EqualTo(cbpdDto.getCbpc01());
            List<Cbpd> cbpds = cbpdMapper.selectByExample(cbpdexample1);
            //得到数量
            List<Double> collect2 = cbpds.stream().map(Cbpd::getCbpd09).collect(Collectors.toList());
            double[] doubles = collect2.stream().mapToDouble(Double::doubleValue).toArray();
            //得到商品id
            List<Integer> collect = cbpds.stream().map(Cbpd::getCbpd08).collect(Collectors.toList());
            int[] ints = collect.stream().mapToInt(Integer::intValue).toArray();
            if (ints.length == 0) {
                throw new SwException("采购入库明细没有商品id");
            }
            for(int i=0;i<ints.length;i++) {
                int goodsid = ints[i];
               // cbpds.get(i).getCbpd08();
               /* GsGoodsSkuCriteria example = new GsGoodsSkuCriteria();
                example.createCriteria()
                        .andGoodsIdEqualTo(goodsid)
                        .andWhIdEqualTo(cbpc1.getCbpc10());
                List<GsGoodsSku> gsGoodsSkus = gsGoodsSkuMapper.selectByExample(example);*/
                List<GsGoodsSku> gsGoodsSkus = gsGoodsSkuMapper.selectByGoodsIdAndWhId(goodsid, cbpc1.getCbpc10());
                double num = doubles[i];
                //对库存表的操作
                if (gsGoodsSkus.size() == 0) {
                    //新增数据
                    GsGoodsSku gsGoodsSku = new GsGoodsSku();
                    gsGoodsSku.setCreateTime(date);
                    gsGoodsSku.setUpdateTime(date);
                    gsGoodsSku.setCreateBy(Math.toIntExact(userid));
                    gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                    gsGoodsSku.setDeleteFlag(DeleteFlagEnum1.NOT_DELETE.getCode());
                    gsGoodsSku.setGoodsId(goodsid);
                    gsGoodsSku.setWhId(cbpc1.getCbpc10());
                    gsGoodsSku.setQty(num);
                    gsGoodsSkuMapper.insertSelective(gsGoodsSku);
                }
                else {
                    //更新数据
//                    List<Integer> collect1 = gsGoodsSkus.stream().map(GsGoodsSku::getId).collect(Collectors.toList());
//                    int[] ints1 = collect1.stream().mapToInt(Integer::intValue).toArray();
//                    int id = ints1[0];
                    Integer id = gsGoodsSkus.get(0).getId();
                    GsGoodsSku gsGoodsSku = baseCheckService.checkGoodsSkuForUpdate(id);
                    gsGoodsSku.setId(id);
                    gsGoodsSku.setQty(gsGoodsSku.getQty() + num);
                    gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                    gsGoodsSku.setUpdateTime(date);
                    gsGoodsSkuMapper.updateByPrimaryKeySelective(gsGoodsSku);
                }
            }
            //台账操作
            //调用台账方法,最后加
            CbpdCriteria example3 = new CbpdCriteria();
            example3.createCriteria()
                    .andCbpc01EqualTo(cbpdDto.getCbpc01());
            List<Cbpd> cbpds1 = cbpdMapper.selectByExample(example3);
            for(int j=0;j<cbpds1.size();j++) {
                CbibDo cbibDo = new CbibDo();
                cbibDo.setCbib02(cbpc1.getCbpc10());
                cbibDo.setCbib03(cbpc1.getCbpc07());
                cbibDo.setCbib05(String.valueOf(TaskType.cgrkd.getCode()));
                cbibDo.setCbib06(cbsa.getCbsa08());
                cbibDo.setCbib07(cbpc1.getCbpc01());
                cbibDo.setCbib08(cbpds1.get(j).getCbpd08());
                //本次入库数量
                cbibDo.setCbib11(cbpds1.get(j).getCbpd09());
                cbibDo.setCbib12(cbpds1.get(j).getCbpd12());
                cbibDo.setCbib17(TaskType.cgrkd.getMsg());
                cbibDo.setCbib19(cbpc1.getCbpc09());
                taskService.InsertCBIB(cbibDo);
            }
            }
        else {
            int sdw=0;
            CbpdCriteria hji = new CbpdCriteria();
            hji.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01());
            List<Cbpd> ser = cbpdMapper.selectByExample(hji);
            if(ser.size()==0){
                throw new SwException("没有明细不能标记完成");
            }
            for (Cbpd cbpd : ser) {
                Double cbpd09 = cbpd.getCbpd09();
                sdw+=cbpd09;
            }
            CbpeCriteria ehks = new CbpeCriteria();
            ehks.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01());
            List<Cbpe> aoc = cbpeMapper.selectByExample(ehks);
            if(aoc.size()<sdw){
                throw new SwException("扫码数量小于任务数量不能标记完成");
            }
            CbpdCriteria example2 = new CbpdCriteria();
            example2.createCriteria()
                    .andCbpc01EqualTo(cbpdDto.getCbpc01());
            List<Cbpd> cbpds = cbpdMapper.selectByExample(example2);
            List<Cbpe> cbpes = null;
            Double num= 0.0;
            Double nums= 0.0;
            UIOVo uioVo = new UIOVo();
            uioVo.setId(cbpdDto.getCbpc01());
            List<UIOVo> selectbyid = cbpeMapper.selectbyid(uioVo);
            if(selectbyid.size()>0){
                for(int k=0;k<selectbyid.size();k++){
                GsGoodsSkuCriteria example = new GsGoodsSkuCriteria();
                example.createCriteria()
                        .andGoodsIdEqualTo(selectbyid.get(k).getGoodsId())
                        .andWhIdEqualTo(cbpc1.getCbpc10())
                        .andLocationIdEqualTo(selectbyid.get(k).getStoreskuid());
                List<GsGoodsSku> gsGoodsSkus = gsGoodsSkuMapper.selectByExample(example);
                // double num = doubles[i];
                //对库存表的操作
                if (gsGoodsSkus.size() == 0) {
                    Cbla cbla = cblaMapper.selectByPrimaryKey(selectbyid.get(k).getStoreskuid());
                    Double cbla11 = cbla.getCbla11();
                    GsGoodsSkuCriteria example1 = new GsGoodsSkuCriteria();
                    example1.createCriteria()
                            .andLocationIdEqualTo(selectbyid.get(k).getStoreskuid());
                    List<GsGoodsSku> gsGoodsSkus1 = gsGoodsSkuMapper.selectByExample(example1);
                    if(gsGoodsSkus1.size()>0){
                        double sum = gsGoodsSkus1.stream().mapToDouble(GsGoodsSku::getQty).sum();
                        if(sum + selectbyid.get(k).getNums()>cbla11){
                            throw new SwException("库位容量不足");
                        }
                    }
                    if( selectbyid.get(k).getNums()>cbla11){
                        throw new SwException("库位容量不足");
                    }
                    //新增数据
                    GsGoodsSku gsGoodsSku = new GsGoodsSku();
                    gsGoodsSku.setCreateTime(date);
                    gsGoodsSku.setUpdateTime(date);
                    gsGoodsSku.setCreateBy(Math.toIntExact(userid));
                    gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                    gsGoodsSku.setDeleteFlag(DeleteFlagEnum1.NOT_DELETE.getCode());
                    gsGoodsSku.setGoodsId(selectbyid.get(k).getGoodsId());
                    gsGoodsSku.setWhId(cbpc1.getCbpc10());
                    gsGoodsSku.setQty((double) selectbyid.get(k).getNums());
                    gsGoodsSku.setLocationId(selectbyid.get(k).getStoreskuid());
                    gsGoodsSkuMapper.insertSelective(gsGoodsSku);
                }
                else {
                    Cbla cbla = cblaMapper.selectByPrimaryKey(selectbyid.get(k).getStoreskuid());
                    Double cbla11 = cbla.getCbla11();
                    //更新数据
//                    List<Integer> collect1 = gsGoodsSkus.stream().map(GsGoodsSku::getId).collect(Collectors.toList());
//                    int[] ints1 = collect1.stream().mapToInt(Integer::intValue).toArray();
//                    int id = ints1[0];
                    Integer id = gsGoodsSkus.get(0).getId();
                    GsGoodsSku gsGoodsSku = baseCheckService.checkGoodsSkuForUpdate(id);
                    gsGoodsSku.setId(id);
                    GsGoodsSkuCriteria example1 = new GsGoodsSkuCriteria();
                    example1.createCriteria()
                            .andLocationIdEqualTo(selectbyid.get(k).getStoreskuid());
                    List<GsGoodsSku> gsGoodsSkus1 = gsGoodsSkuMapper.selectByExample(example1);
                    if(gsGoodsSkus1.size()>0){
                        double sum = gsGoodsSkus1.stream().mapToDouble(GsGoodsSku::getQty).sum();
                        if(sum + selectbyid.get(k).getNums()>cbla11){
                            throw new SwException("库位容量不足");
                        }
                    }
                    if( selectbyid.get(k).getNums()>cbla11){
                        throw new SwException("库位容量不足");
                    }
                    gsGoodsSku.setQty(gsGoodsSku.getQty() + selectbyid.get(k).getNums());
                    gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                    gsGoodsSku.setUpdateTime(date);
                    gsGoodsSkuMapper.updateByPrimaryKeySelective(gsGoodsSku);
                }
            }}
            for (int j = 0; j < cbpds.size(); j++) {
                //判断是哪个仓库  扫码仓库
                CbpeCriteria example1 = new CbpeCriteria();
                example1.createCriteria()
                        .andCbpc01EqualTo(cbpdDto.getCbpc01())
                        .andCbpe08EqualTo(cbpds.get(j).getCbpd08());
                cbpes = cbpeMapper.selectByExample(example1);
                if (cbpes.size() == 0) {
                    throw new SwException("商品id为" + cbpds.get(j).getCbpd08() + "扫码数量为0条");
                }
                //按仓库分的数量
                nums = (double) cbpes.size();
                //库存操作
/*
                for (int i = 0; i < cbpes.size(); i++) {
                    Integer goodsid = cbpes.get(i).getCbpe08();
                    if (cbpes.get(i).getCbpe10() == null) {
                        throw new SwException("库位id不能为空");
                    }
                    Integer cbpe10 = cbpes.get(i).getCbpe10();
                    //库存操作
                    GsGoodsSkuCriteria example = new GsGoodsSkuCriteria();
                    example.createCriteria()
                            .andGoodsIdEqualTo(goodsid)
                            .andWhIdEqualTo(cbpc1.getCbpc10())
                            .andLocationIdEqualTo(cbpe10);
                    List<GsGoodsSku> gsGoodsSkus = gsGoodsSkuMapper.selectByExample(example);
                    // double num = doubles[i];
                    //对库存表的操作
                    if (gsGoodsSkus.size() == 0) {
                        //新增数据
                        GsGoodsSku gsGoodsSku = new GsGoodsSku();
                        gsGoodsSku.setCreateTime(date);
                        gsGoodsSku.setUpdateTime(date);
                        gsGoodsSku.setCreateBy(Math.toIntExact(userid));
                        gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                        gsGoodsSku.setDeleteFlag(DeleteFlagEnum1.NOT_DELETE.getCode());
                        gsGoodsSku.setGoodsId(goodsid);
                        gsGoodsSku.setWhId(cbpc1.getCbpc10());
                        gsGoodsSku.setQty(1.0);
                        gsGoodsSku.setLocationId(cbpe10);
                        gsGoodsSkuMapper.insertSelective(gsGoodsSku);
                    }
                    else {
                        Cbla cbla = cblaMapper.selectByPrimaryKey(cbpe10);
                        Double cbla11 = cbla.getCbla11();
                        //更新数据
//                    List<Integer> collect1 = gsGoodsSkus.stream().map(GsGoodsSku::getId).collect(Collectors.toList());
//                    int[] ints1 = collect1.stream().mapToInt(Integer::intValue).toArray();
//                    int id = ints1[0];
                        Integer id = gsGoodsSkus.get(0).getId();
                        GsGoodsSku gsGoodsSku = baseCheckService.checkGoodsSkuForUpdate(id);
                        gsGoodsSku.setId(id);
                        if(gsGoodsSku.getQty()>=cbla11){
                            throw new SwException("库位id为"+cbpe10+"的库位已满");
                        }
                        gsGoodsSku.setQty(gsGoodsSku.getQty() + 1);
                        gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                        gsGoodsSku.setUpdateTime(date);
                        gsGoodsSkuMapper.updateByPrimaryKeySelective(gsGoodsSku);
                    }
                }
*/
                //台账操作
                //调用台账方法,最后加
                CbpdCriteria example3 = new CbpdCriteria();
                example3.createCriteria()
                        .andCbpd07EqualTo(DeleteFlagEnum.NOT_DELETE.getCode())
                        .andCbpc01EqualTo(cbpdDto.getCbpc01());
                List<Cbpd> cbpds1 = cbpdMapper.selectByExample(example3);
                CbibDo cbibDo = new CbibDo();
                cbibDo.setCbib02(cbpc1.getCbpc10());
                cbibDo.setCbib03(cbpc1.getCbpc07());
                cbibDo.setCbib05(String.valueOf(TaskType.cgrkd.getCode()));
                cbibDo.setCbib06(cbsa.getCbsa08());
                cbibDo.setCbib07(cbpc1.getCbpc01());
                cbibDo.setCbib08(cbpes.get(0).getCbpe08());
                //本次入库数量
                cbibDo.setCbib11(nums);
                Double cbpd11 = cbpds1.get(0).getCbpd11();
                Double prices = cbpd11 * nums;
                cbibDo.setCbib12(prices);
                cbibDo.setCbib17(TaskType.cgrkd.getMsg());
                cbibDo.setCbib19(cbpc1.getCbpc09());
                taskService.InsertCBIB(cbibDo);
            }
        }
    /*    //扫码仓库
        else {
            CbpeCriteria example = new CbpeCriteria();
            example.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                    .andCbpe06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
            List<Cbpe> cbpes = cbpeMapper.selectByExample(example);
            for (int i = 0; i < cbpes.size(); i++) {
                //商品id
                Integer goodsid = cbpes.get(i).getCbpe08();
                //库位id
                Integer sku = cbpes.get(i).getCbpe10();
                //sn码
                String sn = cbpes.get(i).getCbpe09();
                GsGoodsSkuCriteria example1 = new GsGoodsSkuCriteria();
                //检查是否有数据存在
                example1.createCriteria()
                        .andGoodsIdEqualTo(goodsid)
                        .andLocationIdEqualTo(sku);
                List<GsGoodsSku> gsGoodsSkus = gsGoodsSkuMapper.selectByExample(example1);
                //对库存表的操作
                if (gsGoodsSkus.size() == 0) {
                    //新增数据
                    GsGoodsSku gsGoodsSku = new GsGoodsSku();
                    gsGoodsSku.setCreateTime(date);
                    gsGoodsSku.setUpdateTime(date);
                    gsGoodsSku.setCreateBy(Math.toIntExact(userid));
                    gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                    gsGoodsSku.setDeleteFlag(DeleteFlagEnum1.NOT_DELETE.getCode());
                    gsGoodsSku.setGoodsId(goodsid);
                    gsGoodsSku.setLocationId(sku);
                    gsGoodsSku.setQty(1.0);
                    gsGoodsSkuMapper.insertSelective(gsGoodsSku);
                } else {
                    //对库存进行更新操作
                    Integer id = gsGoodsSkus.get(i).getId();
                    GsGoodsSku gsGoodsSku = baseCheckService.checkGoodsSkuForUpdate(id);
                    gsGoodsSku.setQty(gsGoodsSku.getQty() + 1);
                    gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                    gsGoodsSku.setUpdateTime(date);
                    gsGoodsSkuMapper.updateByPrimaryKeySelective(gsGoodsSku);
                }
                //对货物sn表操作
                GsGoodsSnDo goodsSnDo = new GsGoodsSnDo();
                goodsSnDo.setSn(sn);
                goodsSnDo.setGoodsId(goodsid);
                goodsSnDo.setLocationId(sku);
                goodsSnDo.setStatus(GoodsType.yrk.getCode());
                goodsSnDo.setInTime(date);
                taskService.InsertGsGoodsn(goodsSnDo);
                //商品sn扫码交易表
                GsGoodsSnTransDo goodsSnTransDo = new GsGoodsSnTransDo();
                goodsSnTransDo.setSn(sn);
                goodsSnTransDo.setTransType(TaskType.cgrkd.getCode());
                goodsSnTransDo.setTransId(cbpdDto.getCbpc01());
                goodsSnTransDo.setTransLineId(cbpc1.getCbpc07());
                goodsSnTransDo.setGoodsId(goodsid);
                goodsSnTransDo.setLocationId(sku);
                taskService.InsertGsGoodsntrans(goodsSnTransDo);
                //调用台账方法,最后加
                CbpdCriteria example3 = new CbpdCriteria();
                example3.createCriteria()
                        .andCbpd06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode())
                        .andCbpc01EqualTo(cbpdDto.getCbpc01());
                List<Cbpd> cbpds = cbpdMapper.selectByExample(example3);
                CbibDo cbibDo = new CbibDo();
                cbibDo.setCbib02(cbpc1.getCbpc10());
                cbibDo.setCbib03(cbpc1.getCbpc07());
                cbibDo.setCbib05(String.valueOf(TaskType.cgrkd.getCode()));
                cbibDo.setCbib06(cbsa.getCbsa07());
                cbibDo.setCbib07(cbpc1.getCbpc01());
                cbibDo.setCbib08(goodsid);
                cbibDo.setCbib11(cbpds.get(i).getCbpd09());
                cbibDo.setCbib12(cbpds.get(i).getCbpd12());
                cbibDo.setCbib15(cbpds.get(i).getCbpd09());
                cbibDo.setCbib16(cbpds.get(i).getCbpd12());
                cbibDo.setCbib17(TaskType.cgrkd.getMsg());
                cbibDo.setCbib19(cbpc1.getCbpc09());
                taskService.InsertCBIB(cbibDo);
            }
            }*/
            CbpcCriteria example = new CbpcCriteria();
            example.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                    .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
             cbpcMapper.updateByExampleSelective(cbpc, example);
        return 1;
    }
    /**
     * 采购入库单取消完成
     *
     * @param cbpdDto 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public int SwJsSkuBarcodesh(CbpdDto cbpdDto) {
        Date date = new Date();
        Long userid = SecurityUtils.getUserId();
        if(cbpdDto.getCbpc01()==null){
            throw new SwException("采购入库单id不能为空");
        }
//数量仓库
        Cbpc cbpc2 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(cbpc2==null){
            throw new SwException("采购入库单不存在");
        }
        if(cbpc2.getCbpc10()==null){
            throw new SwException("采购入库单仓库不能为空");
        }
        Integer storeid = cbpc2.getCbpc10();
        Cbwa cbwa = cbwaMapper.selectByPrimaryKey(storeid);
        if(Objects.equals(cbwa.getCbwa12(), "数量管理")){
            CbpdCriteria exawple = new CbpdCriteria();
            exawple.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01());
            List<Cbpd> cbpds = cbpdMapper.selectByExample(exawple);
            if(cbpds.size()>0){
                for(int i=0;i< cbpds.size();i++){
                    Integer goodsid = cbpds.get(i).getCbpd08();
                    Double qty = cbpds.get(i).getCbpd09();
                    //对库存进行更新操作
                    GsGoodsSkuCriteria exoample = new GsGoodsSkuCriteria();
                    exoample.createCriteria().andGoodsIdEqualTo(goodsid)
                                               .andWhIdEqualTo(storeid);
                    List<GsGoodsSku> gsGoodsSkus = gsGoodsSkuMapper.selectByExample(exoample);
                    //检查是否有可用库存
                    CheckSkuDo checkSkuDo=new CheckSkuDo();
                    checkSkuDo.setGoodsId(goodsid);
                    checkSkuDo.setOrderClass(OrderTypeEnum.GUONEIDINGDAN.getCode());
                    QtyMsgVo qtyMsgVo = orderDistributionService.checkSku(checkSkuDo);
                    if(qtyMsgVo.getCanUseNum()<qty){
                       throw new SwException("商品库存不够,商品:" + cbpds.get(i).getCbpd12());
                    }
                    if(gsGoodsSkus.size()>0){
                        baseCheckService.checkGoodsSkuForUpdate(gsGoodsSkus.get(0).getId());
                        Integer id = gsGoodsSkus.get(0).getId();
                        GsGoodsSku gsGoodsSku = baseCheckService.checkGoodsSkuForUpdate(id);
                        if(gsGoodsSku.getQty()<qty){
                            throw new SwException("仓库id为"+storeid+"商品id为"+goodsid+"的商品库存不足");
                        }
                        gsGoodsSku.setId(id);
                        gsGoodsSku.setQty(gsGoodsSku.getQty() - qty);
                        gsGoodsSku.setUpdateBy(Math.toIntExact(userid));
                        gsGoodsSku.setUpdateTime(date);
                        gsGoodsSkuMapper.updateByPrimaryKeySelective(gsGoodsSku);
                    }
                }
                Cbsa cbsa = cbasMapper.selectByPrimaryKey(cbpc2.getCbpc09());
                if(cbsa==null){
                    throw new SwException("供应商不存在");
                }
                //台账操作
                //调用台账方法,最后加
                CbpdCriteria example3 = new CbpdCriteria();
                example3.createCriteria()
                        .andCbpc01EqualTo(cbpdDto.getCbpc01());
                List<Cbpd> cbpds1 = cbpdMapper.selectByExample(example3);
                for(int j=0;j<cbpds1.size();j++) {
                    CbibDo cbibDo = new CbibDo();
                    Cbib cbib = BeanCopyUtils.coypToClass(cbibDo, Cbib.class, null);
                    cbib.setCbib02(cbpc2.getCbpc10());
                    cbib.setCbib03(cbpc2.getCbpc07());
                    cbib.setCbib04(date);
                    cbib.setCbib05(String.valueOf(TaskType.cgrkd.getCode()));
                    cbib.setCbib06(cbsa.getCbsa07());
                    cbib.setCbib07(cbpc2.getCbpc01());
                    cbib.setCbib08(cbpds1.get(j).getCbpd08());
                    //本次入库数量
                    cbib.setCbib11(0.0);
                    cbib.setCbib12(0.0);
                    cbib.setCbib17("采购入库单取消完成");
                    cbib.setCbib19(cbpc2.getCbpc09());
                    Cbib cbib1 = cbibMapper.selectLastByGoodsIdAndStoreId(cbib.getCbib08(), cbib.getCbib02());
                    if(cbib1!=null){
                        cbib.setCbib09(cbib1.getCbib15());
                        cbib.setCbib10(cbib1.getCbib16());
                        cbib.setCbib13(cbpds1.get(j).getCbpd09());
                        cbib.setCbib14(cbpds1.get(j).getCbpd12());
                        cbib.setCbib15(cbib.getCbib09()-cbib.getCbib13());
                        cbib.setCbib16(cbib.getCbib10()-cbib.getCbib14());
                        cbib.setCbib18(cbib1.getCbib18()+1);
                    }
                    cbibMapper.insertSelective(cbib);
                }
            }
        }
        CbpeCriteria example1 = new CbpeCriteria();
        example1.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01());
        List<Cbpe> cbpes = cbpeMapper.selectByExample(example1);
        if(cbpes.size()>0 ){
            int size = cbpes.size();
            for(int i=0;i<size;i++){
                if(cbpes.get(i).getCbpe11().equals(ScanStatusEnum.YISAOMA.getCode())) {
                    throw new SwException("已扫码不能取消完成");
                }
            }
        }
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(!cbpc1.getCbpc11().equals(TaskStatus.bjwc.getCode())){
            throw new SwException("不是标记完成状态");
        }
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc11(TaskStatus.sh.getCode());
        cbpc.setCbpc12(Math.toIntExact(userid));
        cbpc.setCbpc13(date);
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
         cbpcMapper.updateByExampleSelective(cbpc, example);
        return 1;
    }
    @Override
    public List<CbpcVo> selectSwJsTaskGoodsRelListss(CbpcVo cbpcVo) {
        return  cbpdMapper.getInfosss(cbpcVo);
    }
    /**
     * 删除采购入库单
     *
     * @param cbpdDto 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteSwJsSkuBarcodsById(CbpdDto cbpdDto) {
        //标记完成不可删除
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpdDto.getCbpc01());
        if(!cbpc1.getCbpc11().equals(TaskStatus.mr.getCode())){
            throw new SwException("默认情况才能删除");
        }
        Integer storeid = cbpc1.getCbpc10();
        CbpdCriteria example1=new CbpdCriteria();
        example1.createCriteria().andCbpd08EqualTo(cbpdDto.getCbpc01())
                .andCbpd07EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        List<Cbpd> cbpds = cbpdMapper.selectByExample(example1);
        if(cbpds.size()>0) {
           Integer goodsid = cbpds.get(0).getCbpd08();
            //检查是否有库存
              baseCheckService.checkGoodsSku(goodsid,storeid);
        }
        Long userid = SecurityUtils.getUserId();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpdDto, Cbpc.class, null);
        Date date = new Date();
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc06(DeleteFlagEnum.DELETE.getCode());
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        Cbpd cbpd = BeanCopyUtils.coypToClass(cbpdDto, Cbpd.class, null);
        cbpd.setCbpd05(date);
        cbpd.setCbpd06(Math.toIntExact(userid));
        cbpd.setCbpd07(DeleteFlagEnum.DELETE.getCode());
        CbpdCriteria example2 = new CbpdCriteria();
        example2.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                .andCbpd07EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        cbpdMapper.updateByExampleSelective(cbpd,example2);
        return   cbpcMapper.updateByExampleSelective(cbpc, example);
    }
    /**
     * 修改采购入库单
     *
     * @param cbpcDo 审核信息
     * @return 结果
     */
    @Transactional
    @Override
    public int updateSwJsSkuBarcodes(CbpcDo cbpcDo) {
        //标记完成不可修改
        Cbpc cbpc1 = cbpcMapper.selectByPrimaryKey(cbpcDo.getCbpc01());
        if(cbpc1.getCbpc11().equals(TaskStatus.bjwc.getCode()) ||
                cbpc1.getCbpc11().equals(TaskStatus.qxwc.getCode()) ||
                cbpc1.getCbpc11().equals(TaskStatus.sh.getCode())  ){
            throw new SwException("非反审或默认不可修改");
        }
        if(cbpcDo.getCbpc07()!=null){
        CbpcCriteria example = new CbpcCriteria();
        example.createCriteria().andCbpc07EqualTo(cbpcDo.getCbpc07())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        List<Cbpc> cbpcs = cbpcMapper.selectByExample(example);
        if(cbpcs.size() >0 && !cbpcs.get(0).getCbpc01().equals(cbpcDo.getCbpc01())){
            throw new SwException("编号已存在");
        }
        }
        Long userid = SecurityUtils.getUserId();
        Cbpc cbpc = BeanCopyUtils.coypToClass(cbpcDo, Cbpc.class, null);
        Date date = new Date();
        cbpc.setCbpc04(date);
        cbpc.setCbpc05(Math.toIntExact(userid));
        cbpc.setCbpc07(cbpcDo.getCbpc07());
        cbpc.setCbpc08(cbpcDo.getCbpc08());
        cbpc.setCbpc09(cbpcDo.getCbpc09());
        cbpc.setCbpc10(cbpcDo.getCbpc10());
        cbpc.setCbpc11(cbpcDo.getCbpc11());
        cbpc.setCbpc12(cbpcDo.getCbpc12());
        cbpc.setCbpc13(cbpcDo.getCbpc13());
        cbpc.setCbpc14(cbpcDo.getCbpc14());
        cbpc.setCbpc15(cbpcDo.getCbpc15());
        cbpc.setCbpc16(cbpcDo.getCbpc16());
        cbpc.setCbpc17(cbpcDo.getCbpc17());
        CbpcCriteria example2 = new CbpcCriteria();
        example2.createCriteria().andCbpc01EqualTo(cbpcDo.getCbpc01())
                .andCbpc06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
      return  cbpcMapper.updateByExampleSelective(cbpc, example2);
       /* Cbpd cbpd = BeanCopyUtils.coypToClass(cbpdDto, Cbpd.class, null);
        cbpd.setCbpd05(date);
        cbpd.setCbpd06(Math.toIntExact(userid));
        cbpd.setCbpd08(cbpdDto.getCbpd08());
        cbpd.setCbpd09(cbpdDto.getCbpd09());
        cbpd.setCbpd10(cbpdDto.getCbpd10());
        cbpd.setCbpd11(cbpdDto.getCbpd11());
        cbpd.setCbpd12(cbpdDto.getCbpd12());
        CbpdCriteria example1 = new CbpdCriteria();
        example1.createCriteria().andCbpc01EqualTo(cbpdDto.getCbpc01())
                .andCbpd07EqualTo(DeleteFlagEnum.NOT_DELETE.getCode());
        return  cbpdMapper.updateByExampleSelective(cbpd, example1);*/
    }
    /**
     * 采购入库单查询
     * @param cbpcVo 审核信息
     * @return 结果
     */
    @Override
    public List<CbpcVo> selectSwJsTaskGoodsRelLists(CbpcVo cbpcVo) {
        return  cbpdMapper.getInfoss(cbpcVo);
    }
    public double m2(double f) {
        //#.00 表示两位小数
        BigDecimal bigDecimal = new BigDecimal(f).setScale(2, BigDecimal.ROUND_DOWN);
        double newDouble = bigDecimal.doubleValue();
        return  newDouble;
    }
    /**
     * 采购入库单详情
     * @param cbpcVo 审核信息
     * @return 结果
     */
    @Override
    public List<CbpcVo> selectSwJsTaskGoodsRelListsss(CbpcVo cbpcVo) {
        List<CbpcVo> infossss = cbpdMapper.getInfossss(cbpcVo);
        CbpcVo res = new CbpcVo();
        List<ScanVo> goods = res.getGoods();
        Integer cbpc01 = cbpcVo.getCbpc01();
        if (cbpc01 == null) {
            throw new SwException("采购入库单id不能为空");
        }
        CbpeCriteria example4 = new CbpeCriteria();
        example4.createCriteria().andCbpc01EqualTo(cbpc01);
        List<Cbpe> cbpess = cbpeMapper.selectByExample(example4);
        Double sum = 0.0;
        if(cbpess.size()>0){
            Integer saoma = 0;
        for (int i = 0; i < infossss.size(); i++) {
            CbpeCriteria example = new CbpeCriteria();
            example.createCriteria().andCbpc01EqualTo(cbpc01)
                    .andCbpe08EqualTo(infossss.get(i).getCbpd08());
            List<Cbpe> cbpes = cbpeMapper.selectByExample(example);
            int size = cbpes.size();
            if (size > 0) {
                for (int j = 0; j < size; j++) {
                    ScanVo scanVo = new ScanVo();
                    scanVo.setLx(infossss.get(i).getCbpa07());
                    scanVo.setPinpai(infossss.get(i).getCala08());
                    scanVo.setCbpb08(infossss.get(i).getCbpb08());
                    scanVo.setCbpb12(infossss.get(i).getCbpb12());
                    scanVo.setSn(cbpes.get(j).getCbpe09());
                    Cbla cbla = cblaMapper.selectByPrimaryKey(cbpes.get(j).getCbpe10());
                    if(cbla==null){
                        throw new SwException("没有改库位信息");
                    }
                    scanVo.setKwm(cbla.getCbla09());
                    scanVo.setCbpe03(cbpes.get(j).getCbpe03());
                    scanVo.setCbpb15(infossss.get(i).getCbpb15());
                    goods.add(scanVo);
                }
                infossss.get(i).setSaoma(size);
                 saoma += infossss.get(i).getSaoma();
            }
            infossss.get(0).setGoods(goods);
            // List<CbpcVo> list = new ArrayList<CbpcVo>(select);
        }
            infossss.get(0).setSaomanums(saoma);
        }
        if(infossss.size()>0) {
            for (int i = 0; i < infossss.size(); i++) {
                if(infossss.get(i).getCbpd09()==null){
                    throw new SwException("明细表数量为空");
                }
                sum += infossss.get(i).getCbpd09();
            }
            infossss.get(0).setNums(sum);
        }
        return infossss;
    }
    @Override
    public List<Cbpc> selectCBPCList(Cbpc cbpc) {
        return cbpdMapper.selectCBPCList(cbpc);
    }
    /**
     * 采购入库导入
     * @param swJsGoodsList
     * @return 结果
     */
    @Transactional
    @Override
    public String importSwJsGoods(List<CbpcDto> swJsGoodsList, boolean updateSupport, String operName) {
        if (StringUtils.isNull(swJsGoodsList) || swJsGoodsList.size() == 0)
        {
            throw new ServiceException("导入用户数据不能为空!");
        }
        int successNum = 0;
        int failureNum = 0;
        StringBuilder successMsg = new StringBuilder();
        StringBuilder failureMsg = new StringBuilder();
        this.insertSwJsStores(swJsGoodsList);
        if (failureNum > 0)
        {
            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
            throw new ServiceException(failureMsg.toString());
        }
        else
        {
            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + swJsGoodsList.size() + " 条,数据如下:");
        }
        return successMsg.toString();    }
    public int insertCBPC(Cbpc cbpc)
    {
        return cbpdMapper.insertCBPC(cbpc);
    }
    public int updateCBPC(Cbpc cbpc)
    {
        return cbpdMapper.updateCBPC(cbpc);
    }
}


Mapper层

package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.Cbpc;
import com.ruoyi.system.domain.CbpcCriteria;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface CbpcMapper {
    long countByExample(CbpcCriteria example);
    int deleteByExample(CbpcCriteria example);
    int deleteByPrimaryKey(Integer cbpc01);
    int insert(Cbpc record);
    int insertSelective(Cbpc record);
    List<Cbpc> selectByExample(CbpcCriteria example);
    Cbpc selectByPrimaryKey(Integer cbpc01);
    int updateByExampleSelective(@Param("record") Cbpc record, @Param("example") CbpcCriteria example);
    int updateByExample(@Param("record") Cbpc record, @Param("example") CbpcCriteria example);
    int updateByPrimaryKeySelective(Cbpc record);
    int updateByPrimaryKey(Cbpc record);
}


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.CbpcMapper">
  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.Cbpc">
    <id column="CBPC01" jdbcType="INTEGER" property="cbpc01" />
    <result column="CBPC02" jdbcType="TIMESTAMP" property="cbpc02" />
    <result column="CBPC03" jdbcType="INTEGER" property="cbpc03" />
    <result column="CBPC04" jdbcType="TIMESTAMP" property="cbpc04" />
    <result column="CBPC05" jdbcType="INTEGER" property="cbpc05" />
    <result column="CBPC06" jdbcType="INTEGER" property="cbpc06" />
    <result column="CBPC07" jdbcType="VARCHAR" property="cbpc07" />
    <result column="CBPC08" jdbcType="TIMESTAMP" property="cbpc08" />
    <result column="CBPC09" jdbcType="INTEGER" property="cbpc09" />
    <result column="CBPC10" jdbcType="INTEGER" property="cbpc10" />
    <result column="CBPC11" jdbcType="INTEGER" property="cbpc11" />
    <result column="CBPC12" jdbcType="INTEGER" property="cbpc12" />
    <result column="CBPC13" jdbcType="TIMESTAMP" property="cbpc13" />
    <result column="CBPC14" jdbcType="INTEGER" property="cbpc14" />
    <result column="CBPC15" jdbcType="TIMESTAMP" property="cbpc15" />
    <result column="CBPC16" jdbcType="INTEGER" property="cbpc16" />
    <result column="CBPC17" jdbcType="VARCHAR" property="cbpc17" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    CBPC01, CBPC02, CBPC03, CBPC04, CBPC05, CBPC06, CBPC07, CBPC08, CBPC09, CBPC10, CBPC11,
    CBPC12, CBPC13, CBPC14, CBPC15, CBPC16, CBPC17, user_id
  </sql>
  <select id="selectByExample" parameterType="com.ruoyi.system.domain.CbpcCriteria" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from `CBPC`
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from `CBPC`
    where CBPC01 = #{cbpc01,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from `CBPC`
    where CBPC01 = #{cbpc01,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.ruoyi.system.domain.CbpcCriteria">
    delete from `CBPC`
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.ruoyi.system.domain.Cbpc">
    insert into `CBPC` (CBPC01, CBPC02, CBPC03,
      CBPC04, CBPC05, CBPC06,
      CBPC07, CBPC08, CBPC09,
      CBPC10, CBPC11, CBPC12,
      CBPC13, CBPC14, CBPC15,
      CBPC16, CBPC17, user_id
      )
    values (#{cbpc01,jdbcType=INTEGER}, #{cbpc02,jdbcType=TIMESTAMP}, #{cbpc03,jdbcType=INTEGER},
      #{cbpc04,jdbcType=TIMESTAMP}, #{cbpc05,jdbcType=INTEGER}, #{cbpc06,jdbcType=INTEGER},
      #{cbpc07,jdbcType=VARCHAR}, #{cbpc08,jdbcType=TIMESTAMP}, #{cbpc09,jdbcType=INTEGER},
      #{cbpc10,jdbcType=INTEGER}, #{cbpc11,jdbcType=INTEGER}, #{cbpc12,jdbcType=INTEGER},
      #{cbpc13,jdbcType=TIMESTAMP}, #{cbpc14,jdbcType=INTEGER}, #{cbpc15,jdbcType=TIMESTAMP},
      #{cbpc16,jdbcType=INTEGER}, #{cbpc17,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.ruoyi.system.domain.Cbpc">
    insert into `CBPC`
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="cbpc01 != null">
        CBPC01,
      </if>
      <if test="cbpc02 != null">
        CBPC02,
      </if>
      <if test="cbpc03 != null">
        CBPC03,
      </if>
      <if test="cbpc04 != null">
        CBPC04,
      </if>
      <if test="cbpc05 != null">
        CBPC05,
      </if>
      <if test="cbpc06 != null">
        CBPC06,
      </if>
      <if test="cbpc07 != null">
        CBPC07,
      </if>
      <if test="cbpc08 != null">
        CBPC08,
      </if>
      <if test="cbpc09 != null">
        CBPC09,
      </if>
      <if test="cbpc10 != null">
        CBPC10,
      </if>
      <if test="cbpc11 != null">
        CBPC11,
      </if>
      <if test="cbpc12 != null">
        CBPC12,
      </if>
      <if test="cbpc13 != null">
        CBPC13,
      </if>
      <if test="cbpc14 != null">
        CBPC14,
      </if>
      <if test="cbpc15 != null">
        CBPC15,
      </if>
      <if test="cbpc16 != null">
        CBPC16,
      </if>
      <if test="cbpc17 != null">
        CBPC17,
      </if>
      <if test="userId != null">
        user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="cbpc01 != null">
        #{cbpc01,jdbcType=INTEGER},
      </if>
      <if test="cbpc02 != null">
        #{cbpc02,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc03 != null">
        #{cbpc03,jdbcType=INTEGER},
      </if>
      <if test="cbpc04 != null">
        #{cbpc04,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc05 != null">
        #{cbpc05,jdbcType=INTEGER},
      </if>
      <if test="cbpc06 != null">
        #{cbpc06,jdbcType=INTEGER},
      </if>
      <if test="cbpc07 != null">
        #{cbpc07,jdbcType=VARCHAR},
      </if>
      <if test="cbpc08 != null">
        #{cbpc08,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc09 != null">
        #{cbpc09,jdbcType=INTEGER},
      </if>
      <if test="cbpc10 != null">
        #{cbpc10,jdbcType=INTEGER},
      </if>
      <if test="cbpc11 != null">
        #{cbpc11,jdbcType=INTEGER},
      </if>
      <if test="cbpc12 != null">
        #{cbpc12,jdbcType=INTEGER},
      </if>
      <if test="cbpc13 != null">
        #{cbpc13,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc14 != null">
        #{cbpc14,jdbcType=INTEGER},
      </if>
      <if test="cbpc15 != null">
        #{cbpc15,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc16 != null">
        #{cbpc16,jdbcType=INTEGER},
      </if>
      <if test="cbpc17 != null">
        #{cbpc17,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.ruoyi.system.domain.CbpcCriteria" resultType="java.lang.Long">
    select count(*) from `CBPC`
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update `CBPC`
    <set>
      <if test="record.cbpc01 != null">
        CBPC01 = #{record.cbpc01,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc02 != null">
        CBPC02 = #{record.cbpc02,jdbcType=TIMESTAMP},
      </if>
      <if test="record.cbpc03 != null">
        CBPC03 = #{record.cbpc03,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc04 != null">
        CBPC04 = #{record.cbpc04,jdbcType=TIMESTAMP},
      </if>
      <if test="record.cbpc05 != null">
        CBPC05 = #{record.cbpc05,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc06 != null">
        CBPC06 = #{record.cbpc06,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc07 != null">
        CBPC07 = #{record.cbpc07,jdbcType=VARCHAR},
      </if>
      <if test="record.cbpc08 != null">
        CBPC08 = #{record.cbpc08,jdbcType=TIMESTAMP},
      </if>
      <if test="record.cbpc09 != null">
        CBPC09 = #{record.cbpc09,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc10 != null">
        CBPC10 = #{record.cbpc10,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc11 != null">
        CBPC11 = #{record.cbpc11,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc12 != null">
        CBPC12 = #{record.cbpc12,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc13 != null">
        CBPC13 = #{record.cbpc13,jdbcType=TIMESTAMP},
      </if>
      <if test="record.cbpc14 != null">
        CBPC14 = #{record.cbpc14,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc15 != null">
        CBPC15 = #{record.cbpc15,jdbcType=TIMESTAMP},
      </if>
      <if test="record.cbpc16 != null">
        CBPC16 = #{record.cbpc16,jdbcType=INTEGER},
      </if>
      <if test="record.cbpc17 != null">
        CBPC17 = #{record.cbpc17,jdbcType=VARCHAR},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update `CBPC`
    set CBPC01 = #{record.cbpc01,jdbcType=INTEGER},
      CBPC02 = #{record.cbpc02,jdbcType=TIMESTAMP},
      CBPC03 = #{record.cbpc03,jdbcType=INTEGER},
      CBPC04 = #{record.cbpc04,jdbcType=TIMESTAMP},
      CBPC05 = #{record.cbpc05,jdbcType=INTEGER},
      CBPC06 = #{record.cbpc06,jdbcType=INTEGER},
      CBPC07 = #{record.cbpc07,jdbcType=VARCHAR},
      CBPC08 = #{record.cbpc08,jdbcType=TIMESTAMP},
      CBPC09 = #{record.cbpc09,jdbcType=INTEGER},
      CBPC10 = #{record.cbpc10,jdbcType=INTEGER},
      CBPC11 = #{record.cbpc11,jdbcType=INTEGER},
      CBPC12 = #{record.cbpc12,jdbcType=INTEGER},
      CBPC13 = #{record.cbpc13,jdbcType=TIMESTAMP},
      CBPC14 = #{record.cbpc14,jdbcType=INTEGER},
      CBPC15 = #{record.cbpc15,jdbcType=TIMESTAMP},
      CBPC16 = #{record.cbpc16,jdbcType=INTEGER},
      CBPC17 = #{record.cbpc17,jdbcType=VARCHAR},
      user_id = #{record.userId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.Cbpc">
    update `CBPC`
    <set>
      <if test="cbpc02 != null">
        CBPC02 = #{cbpc02,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc03 != null">
        CBPC03 = #{cbpc03,jdbcType=INTEGER},
      </if>
      <if test="cbpc04 != null">
        CBPC04 = #{cbpc04,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc05 != null">
        CBPC05 = #{cbpc05,jdbcType=INTEGER},
      </if>
      <if test="cbpc06 != null">
        CBPC06 = #{cbpc06,jdbcType=INTEGER},
      </if>
      <if test="cbpc07 != null">
        CBPC07 = #{cbpc07,jdbcType=VARCHAR},
      </if>
      <if test="cbpc08 != null">
        CBPC08 = #{cbpc08,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc09 != null">
        CBPC09 = #{cbpc09,jdbcType=INTEGER},
      </if>
      <if test="cbpc10 != null">
        CBPC10 = #{cbpc10,jdbcType=INTEGER},
      </if>
      <if test="cbpc11 != null">
        CBPC11 = #{cbpc11,jdbcType=INTEGER},
      </if>
      <if test="cbpc12 != null">
        CBPC12 = #{cbpc12,jdbcType=INTEGER},
      </if>
      <if test="cbpc13 != null">
        CBPC13 = #{cbpc13,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc14 != null">
        CBPC14 = #{cbpc14,jdbcType=INTEGER},
      </if>
      <if test="cbpc15 != null">
        CBPC15 = #{cbpc15,jdbcType=TIMESTAMP},
      </if>
      <if test="cbpc16 != null">
        CBPC16 = #{cbpc16,jdbcType=INTEGER},
      </if>
      <if test="cbpc17 != null">
        CBPC17 = #{cbpc17,jdbcType=VARCHAR},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
    </set>
    where CBPC01 = #{cbpc01,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ruoyi.system.domain.Cbpc">
    update `CBPC`
    set CBPC02 = #{cbpc02,jdbcType=TIMESTAMP},
      CBPC03 = #{cbpc03,jdbcType=INTEGER},
      CBPC04 = #{cbpc04,jdbcType=TIMESTAMP},
      CBPC05 = #{cbpc05,jdbcType=INTEGER},
      CBPC06 = #{cbpc06,jdbcType=INTEGER},
      CBPC07 = #{cbpc07,jdbcType=VARCHAR},
      CBPC08 = #{cbpc08,jdbcType=TIMESTAMP},
      CBPC09 = #{cbpc09,jdbcType=INTEGER},
      CBPC10 = #{cbpc10,jdbcType=INTEGER},
      CBPC11 = #{cbpc11,jdbcType=INTEGER},
      CBPC12 = #{cbpc12,jdbcType=INTEGER},
      CBPC13 = #{cbpc13,jdbcType=TIMESTAMP},
      CBPC14 = #{cbpc14,jdbcType=INTEGER},
      CBPC15 = #{cbpc15,jdbcType=TIMESTAMP},
      CBPC16 = #{cbpc16,jdbcType=INTEGER},
      CBPC17 = #{cbpc17,jdbcType=VARCHAR},
      user_id = #{userId,jdbcType=INTEGER}
    where CBPC01 = #{cbpc01,jdbcType=INTEGER}
  </update>
</mapper>


前端代码


<template>
    <!--采购入库-->
    <div class="app-container">
        <el-row :gutter="20" style="margin:0;width: 100%;">
            <!--用户数据-->
            <el-col :span="20" :xs="24" class="tooltup"
                style="width:100%;display: flex;flex-direction: column;height: calc(93vh - 85px);padding:0;margin:0">
                <!-- 表头内容  -->
                <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                    label-width="68px" style="flex-grow: 0;height: auto;">
                    <el-form-item prop="cbpc07" label="编号">
                        <el-input v-model="queryParams.cbpc07" id="miaoshu" placeholder="请输入编号" clearable
                            style="width: 180px;" @keyup.enter.native="handleQuery" />
                    </el-form-item>
                    <el-form-item prop="cbsa08" label="供应商">
                        <el-input v-model="queryParams.cbsa08" id="miaoshu" placeholder="请输入供应商" clearable
                            style="width: 150px;" @keyup.enter.native="handleQuery" />
                    </el-form-item>
                    <el-form-item prop="cbwa09" label="仓库">
                        <el-input v-model="queryParams.cbwa09" id="miaoshu" placeholder="请输入仓库" clearable
                            style="width: 130px;" @keyup.enter.native="handleQuery" />
                    </el-form-item>
                    <el-form-item label="日期" style="margin-left:1%;">
                        <el-date-picker :size="mini" v-model="dateRange" type="daterange"
                            :picker-options="pickerOptions" popper-class="elDatePicker" value-format="yyyy-MM-dd"
                            range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" align="right">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button v-hasPermi="['system:purchaseinbound:list']" size="mini" class="biaoto-buttonchaxuen"
                            @click="handleQuery">查询</el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button v-hasPermi="['system:purchaseinbound:list']" class="biaoto-buttonchuangjian"
                            size="mini" @click="resetQuery">重置</el-button>
                    </el-form-item>
                    <el-form-item style="margin-left:0;">
                        <!--<el-button type="mini" @click="show()" class="biaoto-buttonfanshen">搜索</el-button>-->
                        <!-- <el-button size="mini" class="biaoto-buttonchuangjian" @click="handlechuangjiang">创建
                        </el-button> -->
                        <el-button size="mini" v-hasPermi="['system:purchaseinbound:add']"
                            class="biaoto-buttonchuangjian" @click="handleChuangJiangone">创建
                        </el-button>
                        <el-button type="mini" v-hasPermi="['system:purchaseinbound:remove']"
                            class="biaoto-buttonshanchu" :disabled="multiple" @click="handleDelete">
                            删除</el-button>
                        <el-button plain size="mini" v-hasPermi="['system:purchaseinbound:import']"
                                   class="biaoto-buttondaoru" @click="handleImport"
                            >导入</el-button>
                        <el-button size="mini" class="biaoto-buttonchaxuen" @click="handleExport">导出</el-button>
                        <!-- <el-button plain size="mini" class="biaoto-buttondaochu" :disabled="multiple"
                            @click="PurchaseinboundShenpi01" v-hasPermi="['system:user:export']">审核</el-button>
                        <el-button plain size="mini" class="biaoto-buttonfanshen" :disabled="multiple"
                            @click="PurchaseinboundFanShenpi01" v-hasPermi="['system:user:export']">反审
                        </el-button> -->
                        <!-- <el-button plain size="mini" class="biaoto-buttondaoru" @click="handleImport"
                            v-hasPermi="['system:user:import']">导入</el-button> -->
                        <el-button plain size="mini" class="biaoto-buttondaochu"
                            @click="PurchaseinboundBiaojiWancheng01" :disabled="multiple"
                            v-hasPermi="['system:purchaseinbound:bjwc']">标记完成
                        </el-button>
                        <el-button plain size="mini" class="biaoto-buttonfanshen"
                            @click="PurchaseinboundQuxiaoWangcheng01" :disabled="multiple"
                            v-hasPermi="['system:purchaseinbound:qxwc']">取消完成
                        </el-button>
                    </el-form-item>
                </el-form>
                <el-table border :header-cell-style="headClasspw" :row-style="{ height: '3px' }"
                    :cell-style="{ padding: '2px' }" v-loading="loading" :data="userList" height="500"
                    :default-sort="{ prop: 'name', order: 'descending' }" style="width:100%;height: 8%;flex-grow: 1;"
                    @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="50" align="center" />
                    <el-table-column label="编号" align="left" key="cbpc07" :show-overflow-tooltip="true" prop="cbpc07"
                        sortable />
                    <el-table-column label="日期" align="left" key="cbpc08" prop="cbpc08" :formatter="formatDate"
                        sortable>
                    </el-table-column>
                    <el-table-column label="供应商" align="left" key="cbsa08" prop="cbsa08" sortable />
                    <el-table-column label="仓库" align="left" key="cbwa09" prop="cbwa09" sortable width="80" />
                    <el-table-column label="结算货币" align="left" key="cala08" prop="cala08" width="100" sortable>
                        <!-- <template scope="scope">
                            <div>{{ scope.row.cala08 == 5 ? "USD" : scope.row.cala08 == 6 ?
                            "CNY" : "未确定状态"
                            }}
                            </div>
                        </template> -->
                    </el-table-column>
                    <el-table-column label="状态" align="center" key="cbpc11" prop="cbpc11" width="80" sortable>
                        <template scope="scope">
                            <div>{{ scope.row.cbpc11 == 0 ? "未审核" : scope.row.cbpc11 == 1 ?
                                    "已审核" : scope.row.cbpc11 == 4 ? "已完成" : "未确定状态"
                            }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center" width="240" class-name="small-padding fixed-width">
                        <template slot-scope="scope" style="margin-left:-10%;">
                            <el-button size="mini" type="text" icon="el-icon-edit"
                                class="button-caozuoxougai caozuoxiangqeng" @click="handlexiangqengSelect(scope.row)"
                                v-if="scope.row.cbpc11 == 0 | scope.row.cbpc11 == 2"
                                v-hasPermi="['system:purchaseinbound:edit']">
                                修改
                            </el-button>
                            <el-button size="mini" type="text" icon="el-icon-delete"
                                class="button-caozuoxougai caozuoxiangqeng" @click="handleDelete01(scope.row)"
                                v-if="scope.row.cbpc11 == 0 | scope.row.cbpc11 == ' '"
                                v-hasPermi="['system:purchaseinbound:remove']">删除</el-button>
                            <el-button size="mini" type="text" icon="el-icon-share" class="caozuoxiangqeng"
                                @click="handleAuthRole(scope.row)" v-if="scope.row.cbpc11 == 4 | scope.row.cbpc11 == 1"
                                v-hasPermi="['system:purchaseinbound:detail']">详情
                            </el-button>
                            <el-button size="mini" type="text" icon="el-icon-s-order" class="caozuoxiangqeng"
                                @click="PurchaseinboundShenpi(scope.row)" v-hasPermi="['system:purchaseinbound:sh']"
                                v-if="scope.row.cbpc11 == 0">审核</el-button>
                            <el-button size="mini" type="text" icon="el-icon-s-order" class="caozuoxiangqeng"
                                @click="PurchaseinboundFanShenpi(scope.row)" v-hasPermi="['system:purchaseinbound:fs']"
                                v-if="scope.row.cbpc11 == 1">反审</el-button>
                            <el-button size="mini" type="text" icon="el-icon-s-order" class="caozuoxiangqeng"
                                @click="PurchaseinboundQuxiaoWangcheng(scope.row)"
                                v-hasPermi="['system:purchaseinbound:qxwc']" v-if="scope.row.cbpc11 == 4">取消完成
                            </el-button>
                            <el-button size="mini" type="text" icon="el-icon-s-order" class="caozuoxiangqeng"
                                @click="PurchaseinboundBiaojiWancheng(scope.row)"
                                v-hasPermi="['system:purchaseinbound:bjwc']"
                                v-if="scope.row.cbpc11 == 1 | scope.row.cbpc11 == 1">标记完成</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize" @pagination="getList" :page-sizes="[10, 15, 20, 50, 500]"
                    class="pagintotal" />
            </el-col>
        </el-row>
        <!--修改-->
        <el-dialog :visible.sync="open">
            <div style="margin-top:-30px;">
                <span style="font-size:20px;">采购入库单</span>
                <hr />
            </div>
            <el-form ref="form" :model="form" label-width="30%" style="margin-left:-15%;margin-top:3%;">
                <el-row>
                    <el-col style="margin-top:1%;">
                        <el-form-item label="编号:" prop="cbpc07">
                            <el-input v-model="form.cbpc07" maxlength="30" style="width:50%;" :disabled="true" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col style="margin-top:1%;">
                        <el-form-item label="供料单位:" prop="cbsa08">
                            <el-popover placement="bottom-start" trigger="click">
                                <supplierMaintenance ref="supplierMaintenance" @selected="selected03"
                                    style="width:320px;" />
                                <el-select slot="reference" v-model="form.cbsa08" placeholder="" readonly
                                    style=" width: 50%;">
                                </el-select>
                            </el-popover>
                        </el-form-item>
                    </el-col>
                    <el-col style="margin-top:1%;">
                        <!-- <el-form-item label="结算货币:" prop="cala08">
                            <el-popover placement="bottom-start" trigger="click">
                                <ListLists ref="ListLists" @selected="selected005" style="width:320px;" />
                                <el-select slot="reference" v-model="form.cala08" placeholder="" readonly
                                    style="border:solid #eee thin; width:50%;">
                                </el-select>
                            </el-popover>
                        </el-form-item> -->
                        <!-- <el-form-item label="结算货币:" prop="cbpc16">
                            <el-select v-model="form.cbpc16" placeholder=""
                                style="width: 50%; ">
                                <el-option v-for="item in jiageLeixeng" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item> -->
                    </el-col>
                    <el-col style="margin-top:1%;">
                        <el-form-item label="仓库:" prop="cbwa09">
                            <el-popover placement="bottom-start" trigger="click">
                                <kuweixxweihu ref="kuweixxweihu" @selected="selected04" style="width:320px;" />
                                <el-select slot="reference" v-model="form.cbwa09" placeholder="" readonly
                                    style=" width: 50%;">
                                </el-select>
                            </el-popover>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="false">
                    <el-col>
                        <el-form-item label="供料单位id" prop="cbsa01">
                            <el-input v-model="form.cbsa01" maxlength="30" style="width:50%;" />
                        </el-form-item>
                        <!-- <el-form-item label="结算货币id" prop="cala01">
                            <el-input v-model="form.cala01" maxlength="30" style="width:50%;border:solid #eee thin;" />
                        </el-form-item> -->
                        <el-form-item label="仓库id" prop="cbwa01">
                            <el-input v-model="form.cbwa01" maxlength="30" style="width:50%;" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="handleUpdate">确 定</el-button>
                <el-button @click="cancells">取 消</el-button>
            </div>
        </el-dialog>
        <!-- 用户导入对话框 -->
        <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
            <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
                :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
                :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
                <div class="el-upload__tip text-center" slot="tip">
                    <div class="el-upload__tip" slot="tip">
                        <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
                    </div>
                    <span>仅允许导入xls、xlsx格式文件。</span>
                    <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
                        @click="importTemplate">下载模板</el-link>
                </div>
            </el-upload>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFileForm">确 定</el-button>
                <el-button @click="upload.open = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
// import { addUserSysPurchaseinbound, listUserPurchaseinbound, updateUserPurchaseinbound, removeSysPurchaseinbound, henUserSysPurchaseinbound, listUserGongyinShangs, listUserShangPxxweihus, listUserKuweisKus, listUsercangkuStore } from "@/api/Warehousemanagement/PurchaseWarehousing";
import { PurchaseinboundAdd, PurchaseinboundList, PurchaseinboundEdit, PurchaseinboundRemove, PurchaseinboundSH, PurchaseinboundShs, Purchaseinbounds, PurchaseinboundShss, SupplierList, GoodsList01, StoreList, StoreSkuList } from "@/api/Warehousemanagement/PurchaseWarehousing";
import * as req from "@/api/Warehousemanagement/PurchaseWarehousing";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
//仓库
import kuweixxweihu from "@/components/WarehouseInfoSku";
//供应商
import supplierMaintenance from "@/components/SupplierMaintenance";
//供应商
import ListLists from "@/components/ListMaintenance";
export default {
    name: "PurchaseWarehousing",
    dicts: ['sys_normal_disable', 'sw_js_store_type', 'sys_user_sex', 'sw_js_store_type_manage_mode'],
    components: { Treeselect, kuweixxweihu, supplierMaintenance, ListLists },
    data() {
        return {
            // 遮罩层
            loading: true,
            tianjiahang: [],
            // 选中数组
            ids: [],
            shenpiids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 用户表格数据
            userList: null,
            // 弹出层标题
            title: "",
            // 部门树选项
            deptOptions: undefined,
            // 是否显示弹出层
            open: false,
            open1: false,
            open2: false,
            // 部门名称
            deptName: undefined,
            // 默认密码
            initPassword: undefined,
            // 日期范围
            housingTime: [],
            // 供应商选项
            postOptions: [],
            //库位
            KuWeiOptions: [],
            //商品信息维护品牌
            shangponOptions: [],
            //商品信息维护的型号
            XinghaoOptions: [],
            //仓库信息维护
            //商品的品牌型号描述
            ponpaixenghaomiaoshu: [],
            // 日期范围
            dateRange: [],
            postCangKu: [],
            //修改下拉框首选值
            kucuenmiongxichu: {
                spuplierName: '翰合供应链公司',
                skuName: 'gwqww',
                brand: '华为',
                type: '条码管理',
                model: 'jwe',
                isQualified: '合格',
                orderType: '国内订单',
                scanStatus: '已扫码',
                warehusingStatus: '待入库'
                // name:'翰合供应链公司'
            },
            //仓库类型
            LeixingOptions: [{
                value: '1',
                label: '条码管理'
            }, {
                value: '2',
                label: '数量管理'
            }],
            value: '',
            //货币类型
            jiageLeixeng: [{
                value: '6',
                label: 'CNY'
            }, {
                value: '5',
                label: 'USD'
            }],
            value: '',
            //发票类别
            fapiaoleix: [{
                value: '1',
                label: '增值税专用发票'
            }, {
                value: '2',
                label: '增值税普通发票'
            }, {
                value: '3',
                label: '个人普通发票'
            }, {
                value: '4',
                label: '不开发票'
            }],
            value: '',
            //状态
            ZhuangTaivalue: [{
                value: '-1',
                label: '启用'
            }, {
                value: '1',
                label: '禁用'
            }],
            //合格状态
            hegezhuangtai: [{
                value: '-1',
                label: '合格'
            }, {
                value: '1',
                label: '不合格'
            }],
            value: '',
            //订单分类
            dingdanfelei: [{
                value: '1',
                label: '国内订单'
            }, {
                value: '2',
                label: '国际订单'
            }],
            value: '',
            //扫码状态
            saomazhuangtai: [{
                value: '-1',
                label: '已扫码'
            }, {
                value: '1',
                label: '未扫码'
            }],
            value: '',
            //入库状态
            rukuzhuangtai: [{
                value: '1',
                label: '待入库'
            }, {
                value: '2',
                label: '已入库'
            }],
            value: '',
            // 角色选项
            roleOptions: [],
            // 表单参数
            form: {
                cbpc08: "",
                cbsa08: "",
                cbwa09: "",
                cala08: "",
                invoiceNumber: "",
                invoicePhone: "",
                invoiceTaxpayerNumber: "",
                invoiceType: "",
                name: "",
                phone: "",
                skuSort: "",
                telPeople: "",
                cbpd09: "",
                cbpd11: "",
                cbpd12: "",
                cbpc166: "",
                cbpc16: "",
                cbpc167: ""
            },
            form1: {
                // classifyId: "",
                // brand: "",
                // model: "",
                // upc: "",
                // description: "",
                // ifEnabled: ""
            },
            form2: {
                cbpc07: "",
                cbpc08: "",
                cbsa08: "",
                cbwa09: "",
                cala08: "",
                cbpc100: "",
                cbpc099: "",
                cbpc166: "",
                cbpc10: "",
                cbpc09: "",
                cbpd09: "",
                cbpd11: "",
                cbpd12: "",
                cbpc16: "",
                cbpc12: "",
                cbpc14: "",
                cbpd08: "",
                cbpc167: ""
            },
            defaultProps: {
                children: "children",
                label: "label"
            },
            // 用户导入参数
            upload: {
                // 是否显示弹出层(用户导入)
                open: false,
                // 弹出层标题(用户导入)
                title: "",
                // 是否禁用上传
                isUploading: false,
                // 是否更新已经存在的用户数据
                updateSupport: 0,
                // 设置上传的请求头部
                headers: { Authorization: "Bearer " + getToken() },
                // 上传的地址/dev-api/stage-api/system/Purchaseinbound/importSwJsGoods
                url: process.env.VUE_APP_BASE_API + "/system/Purchaseinbound/importSwJsGoods"
            },
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 15,
                page: 1,
                size: 15,
                total: this.total,
                cbpc07: undefined,
                cbsa08: undefined,
                cbwa09: undefined,
                dateRange: undefined
            },
            // 列信息
            //  columns: [
            //   {
            //     title:'状态',
            //     dataIndex:'ifEnabled',
            //     scopedSlots: { customRender: 'ifEnabled' }
            //   }
            // ],
            //表单校验
            rules: {
                cbpc099: [
                    { required: true, message: "供料单位不能为空!", trigger: 'change' }
                ],
                cbpc100: [
                    { required: true, message: "仓库不能为空!", trigger: 'change' }
                ],
                cbpc07: [
                    { required: true, message: "品牌不能为空!", trigger: "blur" }
                ]
            },
            pickerOptions: {
                shortcuts: [{
                    text: '今日',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime());
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '昨日',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', [start, start]);
                    }
                }, {
                    text: '本周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        let day = start.getDay();
                        let date = start.getDate();
                        if (day != 0) {
                            start.setDate(date - (day - 1));
                        }
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '上周',
                    onClick(picker) {
                        var oDate = new Date()
                        oDate.setTime(oDate.getTime() - 3600 * 1000 * 24 * 7);
                        let day = oDate.getDay()
                        let start = new Date(),
                            end = new Date();
                        if (day == 0) {
                            start.setDate(oDate.getDate());
                            end.setDate(oDate.getDate() + 6);
                        } else {
                            start.setTime(oDate.getTime() - 3600 * 1000 * 24 * (day - 1));
                            end.setTime(oDate.getTime() + 3600 * 1000 * 24 * (7 - day));
                        }
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '本月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setDate(1);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '上月',
                    onClick(picker) {
                        var oDate = new Date()
                        let year = oDate.getFullYear();
                        let month = oDate.getMonth();
                        let start, end;
                        if (month == 0) {
                            year--
                            start = new Date(year, 11, 1)
                            end = new Date(year, 11, 31)
                        } else {
                            start = new Date(year, month - 1, 1)
                            end = new Date(year, month, 0);
                        }
                        picker.$emit('pick', [start, end]);
                    }
                },
                {
                    text: '本季度',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '上季度',
                    onClick(picker) {
                        var oDate = new Date()
                        let year = oDate.getFullYear();
                        let month = oDate.getMonth() + 1;
                        let n = Math.ceil(month / 3); // 季度,上一个季度则-1
                        let prevN = n - 1;
                        if (n == 1) {
                            year--
                            prevN = 4;
                        }
                        month = prevN * 3; // 月份
                        const start = new Date(year, month - 3, 1);
                        const end = new Date(year, month, 0);
                        picker.$emit('pick', [start, end]);
                    }
                },
                {
                    text: '本年',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setMonth(0);
                        start.setDate(1);
                        picker.$emit('pick', [start, end]);
                    }
                }
                ]
            },
            // value1: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
            daterange: ''
        };
    },
    watch: {
        // 根据名称筛选部门树
        deptName(val) {
            this.$refs.tree.filter(val);
        },
        '$route'() {
            this.getList();
        }
    },
    created() {
        //仓库明细初始化
        this.getList();
        //供应商
        this.getList01();
        //库位
        this.getList02();
        //商品信息维护
        this.getList03();
        //仓库
        this.getList04();
        this.getConfigKey("sys.user.initPassword").then(response => {
            // this.initPassword = response.msg;
        });
        this.getDicts("sw_js_store_type").then(response => {
            this.form.type = response.rows;
        });
        // this.form.type = this.dict[0].label;
        // this.userList.housingTime.substring(0, this.userList.housingTime.indexOf("T"));
        // console.log(this.userList,123456789);
        this.chen();
        this.form2.cbpd11 = "20"
        console.log(this.form.cbpc16, 123456);
    },
    methods: {
        //列表表头设置
        headClasspw() {
            return {
                'text-align': 'left',
                height: '30px',
                padding: '0'
            }
        },
        //父子传值
        sendParams(row) {
            this.$router.push({
                path: '/warehouer',
                name: 'index',
                query: {
                    name: '页面1',
                    // data: this.form2.cbpc01,
                    data: row.cbpc01,
                }
            })
        },
        chen() {
            this.form2.cbpd11 = "20"
            this.form2.cbpd12 = this.form2.cbpd11 * this.form2.cbpd09;
        },
        //添加模块-仓库
        selected01(name) {
            console.log(name, 123)
            console.log(name.substring(name.indexOf("-") + 1), 963);
            this.form2.cbpc100 = name.substring(0, name.indexOf("-"))
            this.form2.cbpc10 = name.substring(name.indexOf("-") + 1)
            // this.form2.icon = name;
        },
        //修改模块-仓库
        selected04(name) {
            console.log(name, 123)
            console.log(name.substring(name.indexOf("-") + 1), 963);
            this.form.cbwa09 = name.substring(0, name.indexOf("-"));
            this.form.cbwa01 = name.substring(name.indexOf("-") + 1)
            // this.form2.icon = name;
        },
        //修改模块-货币类型
        // selected005(name) {
        //     console.log(name, 123)
        //     console.log(name.substring(name.indexOf("-") + 1), 963);
        //     this.form.cala08 = name.substring(0, name.indexOf("-"));
        //     this.form.cala01 = name.substring(name.indexOf("-") + 1)
        //     // this.form2.icon = name;
        // },
        //添加模块-供应商
        selected02(name) {
            console.log(name, 123)
            console.log(name.substring(name.indexOf("-") + 1), 963);
            this.form2.cbpc099 = name.substring(0, name.indexOf("-"));
            this.form2.cbpc09 = name.substring(name.indexOf("-") + 1);
            this.form.cbsa08 = name.substring(0, name.indexOf("-"));
            // this.form2.icon = name;
        },
        //修改模块-供应商
        selected03(name) {
            console.log(name, 123)
            console.log(name.substring(name.indexOf("-") + 1), 963);
            this.form.cbsa01 = name.substring(name.indexOf("-") + 1);
            this.form.cbsa08 = name.substring(0, name.indexOf("-"));
            // this.form2.icon = name;
        },
        //添加行
        addData() {
            this.tianjiahang.push({
                tianjiaoname: '',
                tianjiaogender: '',
                tianjiaocontact: ''
            })
        },
        deletData(index) {
            this.tianjiahang.splice(index, 1);
        },
        /** 查询用户列表 */
        getList() {
            this.loading = true;
            PurchaseinboundList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
                this.userList = response.data.rows;
                this.total = response.data.total;
                // //供应商
                // this.postOptions = response.data.content;
                // console.log(this.userList, daterange3369);
                console.log(response, 339688);
                // this.deleteFlag = response.data.rows.deleteFlag;
                this.loading = false;
            }
            );
        },
        /** 详情列表 */
        // getList05() {
        //     this.loading = true;
        //     PurchaseinboundLists(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        //         this.userList = response.data.rows;
        //         this.total = response.data.total;
        //         console.log(response, 3396888952);
        //         this.loading = false;
        //     }
        //     );
        // },
        //供应商
        getList01() {
            SupplierList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
                this.postOptions = response.data.rows;
                // console.log(response.data.rows,551100);
            });
        },
        //库位
        getList02() {
            StoreList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
                this.KuWeiOptions = response.data.rows;
                // console.log(response.data.rows,663322);
            });
        },
        //商品信息维护
        getList03() {
            GoodsList01(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
                this.shangponOptions = response.data.rows;
                this.XinghaoOptions = response.data.rows;
                this.ponpaixenghaomiaoshu = response.data.rows;
                // console.log(response.data.rows, 1655);
            });
        },
        //仓库信息维护
        getList04() {
            StoreSkuList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
                this.postCangKu = response.data.rows;
                // this.XinghaoOptions = response.data.rows;
                // console.log(response.data.rows, 1655);
            });
        },
        // /** 查询部门下拉树结构 */
        // getTreeselect() {
        //     treeselectt().then(response => {
        //         response.data.forEach((res) => {
        //             res.code = res.label ? res.label.substring(res.label.indexOf("-") + 1) : ""
        //             res.label = res.label ? res.label.substring(0, res.label.indexOf("-")) : ""
        //             if (res.children) {
        //                 res.children.forEach((i) => {
        //                     i.code = i.label ? i.label.substring(i.label.indexOf("-") + 1) : ""
        //                     i.label = i.label ? i.label.substring(0, i.label.indexOf("-")) : ""
        //                 })
        //             }
        //         })
        //         this.deptOptions = response.data;
        //         // this.deptOptions = response.data[0].label.substring(0, response.data[0].label.indexOf("-"));
        //         // console.log(response.data[response.data.length].label.substring(0, response.data[response.data.length].label.indexOf("-")),123456789);
        //         // console.log(response.data.label);
        //         // console.log(JSON.stringify(Object.assign({}, response.data)));
        //         // var j = JSON.stringify(Object.assign({}, response.data))
        //         // for(var key in j)
        //         // {
        //         //   //  alert();
        //         //   // console.log(key);
        //         // }
        //         // console.log(response);
        //         // console.log(response.data);
        //     });
        // },
        // 筛选节点
        // filterNode(value, data) {
        //
        //   if (!value) return true;
        //   alert("ddd");
        //   return data.indexOf(value) !== -1;
        // },
        // 节点单击事件
        // handleNodeClick(data) {
        //     // console.log(data)
        //     // this.queryParams.deptId = data.id;
        //     // console.log(data.label,88888);
        //     // const v1=data.label.substring(0, data.label.indexOf("-"));
        //     this.form.classifyNum = "";
        //     for (let i = 0; i < (data.code.split("-")).length - 1; i++) {
        //         if (i != 0) {
        //             this.form.classifyNum += ("-" + (data.code.split("-"))[i])
        //         } else {
        //             this.form.classifyNum += (data.code.split("-"))[i]
        //         }
        //     }
        //     // this.form.classifyNum =  data.code ? data.code.substring(0,data.code.indexOf("-") ):""//data.label.substring(v1.length+1, data.label.length);
        //     this.form.classifyName = data.label
        //     this.form.id = (data.code.split("-"))[data.code.split("-").length - 1]
        //     // console.log(data.code ? data.code.substring(data.code.indexOf("-") + 1) : "");
        //     this.handleQuery();
        // },
        // 取消按钮
        cancel() {
            this.open2 = false;
        },
        //修改的取消按钮
        cancells() {
            this.open = false;
        },
        //添加的取消按钮
        cancel9() {
            this.open2 = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                classifyName: undefined,
                classifyNum: undefined
            };
            // this.resetForm("form");
        },
        // 表单重置
        reset01() {
            this.form2 = {
                brand: undefined,
                description: undefined,
                model: undefined,
                remark: undefined,
                skuName: undefined,
                sn: undefined,
                spuplierName: undefined,
                type: undefined
            };
            this.resetForm("form2");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            // var neirong = $('#miaoshu').val();
            // this.userList.cbpc07 = this.form.cbpc07;
            this.queryParams.pageNum = 1;
            this.getList();
            // this.queryParams.sn = "";
            // this.getList();
            //  this.queryParams.pageNum = this.form.classifyName;
            // console.log(this.queryParams);
            // this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection;
            this.idss = selection.map(item => item.cbpc07);
            this.shenpiids = selection;
            this.single = selection.length != 1;
            this.multiple = !selection.length;
        },
        // 更多操作触发
        handleCommand(command, row) {
            switch (command) {
                case "handleResetPwd":
                    this.handleResetPwd(row);
                    break;
                case "handleAuthRole":
                    this.handleAuthRole(row);
                    break;
                default:
                    break;
            }
        },
        handlechuangjiang() {
            this.open2 = true;
            this.form2.swJsStoreId01 = row.name;
        },
        //审批
        PurchaseinboundShenpi(row) {
            let cbpc01 = row.cbpc01
            let status = row.cbpc11
            this.$router.push("/system/user-auth/role/" + cbpc01 + status);
            //     this.$modal.confirm('是否要审批,编号为"' + row.cbpc07 + '"的数据项?').then(() => {
            //     console.log(row.cbpc01,8888);
            //     PurchaseinboundSH(row).then(response => {
            //      if (response.code == "200") {
            //         this.getList();
            //         // this.open = false;
            //         this.$message({ message: response.msg, type: 'success' });
            //     }else{
            //                 this.$message({ message: response.msg, type: 'error' });
            //           }
            //     });
            //   }).catch(() => { });
        },
        //审批上面内容
        PurchaseinboundShenpi01(row) {
            this.$modal.confirm('是否要审批,编号为"' + this.idss + '"的数据项?').then(() => {
                let userIds = this.shenpiids.length > 0 ? this.shenpiids : row
                // console.log(row.cbpc01, 8888);
                userIds.forEach((item) => {
                    req.PurchaseinboundSH(item).then((res) => {
                        if (res.code == "200") {
                            this.getList();
                            this.$modal.msgSuccess(res.msg);
                        } else {
                            // this.$message({ message: res.msg, type: 'error' });
                        }
                    }).catch((e) => {
                        // console.log(e, 456)
                    })
                });
            }).catch(() => { });
        },
        //反审
        PurchaseinboundFanShenpi(row) {
            let cbpc01 = row.cbpc01
            let status = row.cbpc11
            this.$router.push("/system/user-auth/role/" + cbpc01 + status);
            //     this.$modal.confirm('是否要反审,编号为"' + row.cbpc07 + '"的数据项?').then(() => {
            //     // console.log(row.cbpc01, 8888);
            //     PurchaseinboundShs(row).then(response => {
            //       if (response.code == "200") {
            //         this.getList();
            //         // this.open = false;
            //         this.$message({ message: response.msg, type: 'success' });
            //     }else{
            //                 this.$message({ message: response.msg, type: 'error' });
            //           }
            //     });
            //   }).catch(() => { });
        },
        //反审上面的
        PurchaseinboundFanShenpi01(row) {
            this.$modal.confirm('是否要反审,编号为"' + this.idss + '"的数据项?').then(() => {
                let userIds = this.shenpiids.length > 0 ? this.shenpiids : row
                // console.log(row.cbpc01, 8888);
                userIds.forEach((item) => {
                    req.PurchaseinboundShs(item).then((res) => {
                        if (res.code == "200") {
                            // console.log(res, 123)
                            this.getList();
                            this.$modal.msgSuccess(res.msg);
                        } else {
                            // this.$message({ message: res.msg, type: 'error' });
                        }
                    }).catch((e) => {
                        // console.log(e, 456)
                    })
                });
            }).catch(() => { });
        },
        //标记完成
        PurchaseinboundBiaojiWancheng(row) {
            this.$modal.confirm('是否要标记完成,编号为"' + row.cbpc07 + '"的数据项?').then(() => {
                // console.log(row.cbpc01, 8888);
                PurchaseinboundShss(row).then(response => {
                    if (response.code == "200") {
                        console.log(this.form.cbpc01, 789)
                        // this.submitShangpin();
                        this.getList();
                        // this.open = false;
                        this.$message({ message: response.msg, type: 'success' });
                    } else {
                        // this.$message({ message: response.msg, type: 'error' });
                    }
                });
            }).catch(() => { });
        },
        //标记完成上面的按钮
        PurchaseinboundBiaojiWancheng01(row) {
            this.$modal.confirm('是否要标记完成,编号为"' + this.idss + '"的数据项?').then(() => {
                let userIds = this.shenpiids.length > 0 ? this.shenpiids : row
                // console.log(row.cbpc01, 8888);
                userIds.forEach((item) => {
                    req.PurchaseinboundShss(item).then((res) => {
                        if (res.code == "200") {
                            // console.log(res, 123)
                            this.getList();
                            this.$modal.msgSuccess(res.msg);
                        } else {
                            // this.$message({ message: res.msg, type: 'error' });
                        }
                    }).catch((e) => {
                        // console.log(e, 456)
                    })
                });
            }).catch(() => { });
        },
        //取消标记
        PurchaseinboundQuxiaoWangcheng(row) {
            // console.log(row.cbpc01, 8888);
            this.$modal.confirm('是否要取消标记,编号为"' + row.cbpc07 + '"的数据项?').then(() => {
                Purchaseinbounds(row).then(response => {
                    if (response.code == "200") {
                        console.log(this.form.cbpc01, 789);
                        this.getList();
                        this.$message({ message: response.msg, type: 'success' });
                    } else {
                        // this.$message({ message: response.msg, type: 'error' });
                    }
                });
            }).catch(() => { });
        },
        //取消标记上面的
        PurchaseinboundQuxiaoWangcheng01(row) {
            this.$modal.confirm('是否要取消标记,编号为"' + this.idss + '"的数据项?').then(() => {
                let userIds = this.shenpiids.length > 0 ? this.shenpiids : row
                // console.log(row.cbpc01, 8888);
                userIds.forEach((item) => {
                    req.Purchaseinbounds(item).then((res) => {
                        if (res.code == "200") {
                            this.getList();
                            this.$modal.msgSuccess(res.msg);
                            console.log(res, 8956231);
                        } else {
                            // this.$message({ message: res.msg, type: 'error' });
                        }
                    }).catch((e) => { })
                });
            }).catch(() => { });
        },
        /** 修改按钮操作 */
        handleUpdate() {
            let row = {}
            row.cbpc07 = this.form.cbpc07;
            row.cbpc09 = this.form.cbsa01;
            row.cbpc10 = this.form.cbwa01;
            row.cala08 = this.form.cala08;
            row.cbpc01 = this.form.cbpc01;
            // row.cbpc16 = this.form.cala08;
            // console.log(this.form.id);
            PurchaseinboundEdit(JSON.stringify(row)).then(response => {
                if (response.code == "200") {
                    // console.log(this.form, 789)
                    this.getList();
                    this.open = false;
                    this.$message({ message: response.msg, type: 'success' });
                } else {
                    // this.$message({ message: response.msg, type: 'error' });
                }
            });
        },
        /** 详情按钮操作 */
        handlexiangqeng() {
            let row1 = {}
            row.cbpc07 = this.form1.cbpc07;
            row.cbsa08 = this.form1.cbsa08;
            row.cbwa09 = this.form1.cbwa09;
            row.cala08 = this.form1.cala08;
            row.cbpc01 = this.form1.cbpc01;
            // console.log(this.form.id);
            PurchaseinboundEdit(JSON.stringify(row)).then(response => {
                if (response.code == "200") {
                    // console.log(this.form, 789)
                    this.getList();
                    this.open = false;
                    this.$message({ message: response.msg, type: 'success' });
                } else {
                    // this.$message({ message: response.msg, type: 'error' });
                }
            });
        },
        /** 修改详情按钮操作**/
        handlexiangqengSelect(row) {
            // this.open = true;
            // // console.log(row, 7788521);
            // this.form = row;
            // this.form.cbpc16 = row.cala08;
            let id = row.cbpc01
            console.log(row, id)
            this.$router.push("/system/user-ckrkxg/role/" + id);
        },
        /** 数形列表的商品分类按钮**/
        submitShangpin() {
            this.reset();
        },
        //列表刷新
        liebiaoshuax() {
            this.getList();
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.$refs["form2"].validate((item) => {
                if (item) {
                    PurchaseinboundAdd(this.form2).then(response => {
                        if (response.code == "200") {
                            // console.log(response.posts, 12345678);
                            this.$message({ message: "添加成功", type: 'success', style: 'color:red;!important' });
                            this.submitShangpin();
                            this.getList();
                            this.open2 = false;
                            this.reset01();
                        } else {
                            // this.$message({ message: response.msg, type: 'error' });
                        }
                    });
                } else {
                    // this.$message.error('请注意规范');
                }
            })
        },
        /** 重置密码按钮操作 */
        handleResetPwd(row) {
            this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnClickModal: false,
                inputPattern: /^.{5,20}$/,
                inputErrorMessage: "用户密码长度必须介于 5 和 20 之间"
            }).then(({ value }) => {
                resetUserPwd(row.userId, value).then(response => {
                    this.$modal.msgSuccess("修改成功,新密码是:" + value);
                });
            }).catch(() => { });
        },
        /** 详情操作 */
        handleAuthRole: function (row) {
            // const cbpc01 = row.cbpc01;
            // console.log(row.cbpc01);
            // // this.$router.push("/system/user-auth/role/");
            // this.$router.push("/system/user-auth/role/" + cbpc01);
            let cbpc01 = row.cbpc01
            let status = 8
            this.$router.push("/system/user-auth/role/" + cbpc01 + status);
        },
        /** 创建操作 */
        handleChuangJiangone: function (row) {
            // this.$router.push("/system/user-auth/role/");
            this.$router.push("/system/user-cj/role/");
        },
        // /** 提交按钮 */
        // submitForm: function () {
        //     this.$refs["form"].validate(valid => {
        //         if (valid) {
        //             if (this.form.userId != undefined) {
        //                 updateUserStore(this.form).then(response => {
        //                     this.$modal.msgSuccess("修改成功");
        //                     this.open = false;
        //                     this.getList();
        //                 });
        //             } else {
        //                 addUser(this.form).then(response => {
        //                     this.$modal.msgSuccess("新增成功");
        //                     this.open = false;
        //                     this.getList();
        //                 });
        //             }
        //         }
        //     });
        // },
        /** 批量删除按钮操作 */
        handleDelete(row) {
            // row.classifyId = this.form.classifyId;
            // row.brand = this.form.brand;
            // row.model = this.form.model;
            // row.upc = this.form.upc;
            // row.description = this.form.description;
            // row.ifEnabled = this.form.ifEnabled;
            // row.id=this.form.id;
            let userIds = this.ids.length > 0 ? this.ids : row
            this.$modal.confirm('是否确认删除,编号为"' + JSON.stringify(this.idss) + '"的数据项?').then(() => {
                userIds.forEach((item) => {
                    req.PurchaseinboundRemove(JSON.stringify(item)).then((res) => {
                        if (res.code == "200") {
                            // console.log(res, 123)
                            this.submitShangpin();
                            this.getList();
                            this.$modal.msgSuccess("删除成功");
                        } else {
                            //   this.$message({ message: res.msg, type: 'error' });
                        }
                    }).catch((e) => {
                        // console.log(e, 456)
                    })
                })
            }).catch(() => { });
        },
        /** 导出按钮操作
         *
         * /dev-api/stage-api/system/Purchaseinbound/SwJsGoodsexport
        */
        handleExport() {
            this.download('/system/Purchaseinbound/SwJsGoodsexport', {
                ...this.queryParams
            }, `user_${new Date().getTime()}.xlsx`)
        },
        /** 普通删除按钮操作 */
        handleDelete01(row) {
            // row.classifyId = this.form.classifyId;
            // row.brand = this.form.brand;
            // row.model = this.form.model;
            // row.upc = this.form.upc;
            // row.description = this.form.description;
            // row.ifEnabled = this.form.ifEnabled;
            // row.id=this.form.id;
            // console.log(row, 2222);
            this.$modal.confirm('是否确认删除用户,编号为"' + row.cbpc07 + '"的数据项?').then(function () {
                return PurchaseinboundRemove(JSON.stringify(row));
            }).then((response) => {
                if (response.code == "200") {
                    this.submitShangpin();
                    this.getList();
                    this.$modal.msgSuccess("删除成功");
                } else {
                    // this.$message({ message: response.msg, type: 'error' });
                }
            }).catch(() => { });
        },
        /** 导入按钮操作 */
        handleImport() {
            this.upload.title = "采购入库单";
            this.upload.open = true;
        },
        /** 下载模板操作
         * /dev-api/stage-api/system/Purchaseinbound/importTemplate
        */
        importTemplate() {
            this.download('/system/Purchaseinbound/importTemplate', {
            }, `采购入库单模板_${new Date().getTime()}.xlsx`)
        },
        // 文件上传中处理
        handleFileUploadProgress(event, file, fileList) {
            this.upload.isUploading = true;
        },
        // 文件上传成功处理
        handleFileSuccess(response, file, fileList) {
            this.upload.open = false;
            this.upload.isUploading = false;
            this.$refs.upload.clearFiles();
            this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
            this.getList();
        },
        // 提交上传文件
        submitFileForm() {
            this.$refs.upload.submit();
        },
        //测试树状菜单
        // handleNodeClick(data) {
        //   console.log(data);
        // }
    },
};
</script>
<style src="./PurchaseWarehousingcss/index.css" scoped>
</style>
<style lang="scss" scoped>
::v-deep .pagination-container .el-pagination {
    position: inherit;
}
.pagintotal {
    flex-grow: 0;
    text-align: right;
    height: auto;
    padding: 20px 0 0 !important;
    margin: 0;
}
</style>
相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore &nbsp; &nbsp; ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库&nbsp;ECS 实例和一台目标数据库&nbsp;RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&amp;RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
8月前
|
供应链 监控
解密ERP系统的采购与物料管理模块
解密ERP系统的采购与物料管理模块
198 8
|
SQL 供应链 JavaScript
订单管理系统(OMS)搭建实战 - 低代码拖拽定制订单管理系统
订单管理系统是很多公司,特别是电商公司最常用的内部系统之一。订单管理系统的使用者通常是仓管或者运营人员,它常被用于管理用户订单,比如添加或者修改一条发货记录,与快递 API 集成以便自动更新订单号等场景。
1027 0
|
21天前
|
存储 供应链 数据可视化
2024年采购管理新趋势:最适合记录和更新采购清单的在线看板工具
在现代企业中,采购部门的任务高效协作与管理至关重要。本文介绍了六款适合采购部门的在线看板工具:板栗看板、Trello、Miro、Zoho Projects、Airtable和TeamGantt,分别从关键功能、优势、劣势及适用对象等方面进行了详细对比,帮助企业选择最合适的工具,提升采购效率和透明度。
2024年采购管理新趋势:最适合记录和更新采购清单的在线看板工具
|
8月前
|
前端开发
基于jeecgboot的ERP单据中增加编号的方法
基于jeecgboot的ERP单据中增加编号的方法
222 1
|
5月前
|
监控 数据可视化 ice
项目采购管理
项目采购管理
35 0
|
8月前
|
BI 数据库
基于Jeecgboot前后端分离的ERP系统开发系列--出库单(1)
基于Jeecgboot前后端分离的ERP系统开发系列--出库单(1)
94 1
|
8月前
|
JavaScript 前端开发
基于Jeecgboot前后端分离的ERP系统开发系列--出库单(2)
基于Jeecgboot前后端分离的ERP系统开发系列--出库单(2)
85 1
|
8月前
|
前端开发
基于Jeecgboot前后端分离的ERP系统开发系列--出库单(3)
基于Jeecgboot前后端分离的ERP系统开发系列--出库单(3)
97 0
|
8月前
|
搜索推荐 前端开发 Java
财务管理系统|基于Springboot开发实现公司财务管理系统
财务管理系统|基于Springboot开发实现公司财务管理系统
162 0
采购管理系统定制的好处
随着企业的不断发展,通用型的软件已经无法支持企业的需求和长期的业务运作,通用型的软件功能匹配不到企业的实际业务流程,就会影响企业整体的发展运作,所以就需要定制开发的采购软件。下面白码科技介绍下采购系统定制化的好处有哪些!