| | |
| | | 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.WaitPakinLog; |
| | | import com.zy.asrs.common.wms.entity.WrkMast; |
| | | import com.zy.asrs.common.wms.service.OrderDetlService; |
| | | import com.zy.asrs.common.wms.service.WaitPakinService; |
| | |
| | | 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 |
| | |
| | | @RequestParam Map<String, Object> param) { |
| | | QueryWrapper<WaitPakin> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("host_id", getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like("id", condition); |
| | | } |
| | | convert(param,wrapper); |
| | | if (!Cools.isEmpty(timeRange)) { |
| | | String[] range = timeRange.split(RANGE_TIME_LINK); |
| | |
| | | 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()+"条商品数据"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/waitPakin/export/auth") |
| | | @ManagerAuth(memo = "库位明细导出") |
| | | public synchronized R export(@RequestBody JSONObject param){ |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | QueryWrapper<WaitPakin> wrapper = new QueryWrapper<>(); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("waitPakin")); |
| | | String row = ""; |
| | | if (map.get("row") != null) { |
| | | String chooseRow = (String) map.get("row"); |
| | | if (chooseRow.length() == 1) { |
| | | row = "0" + chooseRow; |
| | | map.remove("row"); |
| | | }else { |
| | | row = chooseRow; |
| | | map.remove("row"); |
| | | } |
| | | } |
| | | convert(map, wrapper); |
| | | // if (!row.equals("")){ |
| | | // wrapper.and() |
| | | // .where("loc_no like '" +row +"%'"); |
| | | // } |
| | | List<WaitPakin> list = waitPakinService.list(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | } |