| | |
| | | package com.zy.asrs.wms.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.common.domain.entity.MatExcel; |
| | | import com.zy.asrs.common.domain.entity.WaitPakinExcel; |
| | | import com.zy.asrs.common.utils.MatExcelListener; |
| | | import com.zy.asrs.common.utils.WaitPakingExcelListener; |
| | | import com.zy.asrs.common.wms.entity.Mat; |
| | | import com.zy.asrs.common.wms.entity.WaitPakin; |
| | | import com.zy.asrs.common.wms.entity.WrkMast; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | /*************************************** 数据相关 ***********************************************/ |
| | | |
| | | /** |
| | | * excel导入模板下载 |
| | | */ |
| | | @RequestMapping(value = "/waitPakin/excel/import/mould") |
| | | public void matExcelImportMould(HttpServletResponse response) throws IOException { |
| | | List<WaitPakinExcel> excels = new ArrayList<>(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("入库通知档Excel导入模板", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), WaitPakinExcel.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet("sheet1") |
| | | .doWrite(excels); |
| | | } |
| | | |
| | | // // excel导入-------判断是否有重复物料 |
| | | // @PostMapping(value = "/mat/excel/import/check/auth") |
| | | // @ManagerAuth(memo = "商品档案数据导入") |
| | | // @Transactional |
| | | // public R matExcelImportCheck(MultipartFile file) throws IOException { |
| | | // MatExcelListener listener = new MatExcelListener(getUserId(), getHostId()); |
| | | // EasyExcel.read(file.getInputStream(), MatExcel.class, listener).sheet().doRead(); |
| | | // return R.ok("成功同步"+listener.getTotal()+"条商品数据"); |
| | | // } |
| | | |
| | | // excel导入 |
| | | @PostMapping(value = "/waitPakin/excel/import/auth") |
| | | @ManagerAuth(memo = "入库通知档档案数据导入") |
| | | @Transactional |
| | | public R matExcelImport(MultipartFile file) throws IOException { |
| | | WaitPakingExcelListener listener = new WaitPakingExcelListener(getUserId(), getHostId()); |
| | | EasyExcel.read(file.getInputStream(), WaitPakinExcel.class, listener).sheet().doRead(); |
| | | return R.ok("成功同步"+listener.getTotal()+"条商品数据"); |
| | | } |
| | | |
| | | } |