| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.metadata.fill.FillConfig; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.sun.org.apache.xpath.internal.operations.Or; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | import com.zy.asrs.entity.result.LocDetlAll; |
| | | import com.zy.asrs.entity.result.OrderDetlVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.config.AdminInterceptor; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.utils.BarcodeUtils; |
| | | import com.zy.common.utils.QrCode; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | |
| | | private LocOwnerService locOwnerService; |
| | | @Autowired |
| | | private OrderLogService orderLogService; |
| | | |
| | | @RequestMapping(value = "/order/all") |
| | | @ManagerAuth |
| | | public R statis2(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param) { |
| | | |
| | | |
| | | |
| | | Page<Order> stockStatis = orderService.getOrderAll(toPage(curr, limit, param, Order.class)); |
| | | |
| | | return R.ok().add(stockStatis); |
| | | } |
| | | // @RequestMapping(value = "/order/export") |
| | | // @ManagerAuth |
| | | // public void orderExport(HttpServletResponse response,OrderExport orderExport) throws IOException { |
| | | // List<OrderDetl> orderNo = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderExport.getOrderNo())); |
| | | // |
| | | // response.setContentType("application/vnd.ms-excel"); |
| | | // response.setCharacterEncoding("utf-8"); |
| | | // String templateFileName = |
| | | // this.getClass().getClassLoader().getResource("ru.xlsx").getPath();; |
| | | // |
| | | // String fileName = "complexFill" + System.currentTimeMillis() + ".xlsx"; |
| | | // |
| | | // response.setHeader("Content-disposition", "attachment;filename=" + fileName); |
| | | // ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build(); |
| | | // WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
| | | // // 这里注意 入参用了forceNewRow 代表在写入list的时候不管list下面有没有空行 都会创建一行,然后下面的数据往后移动。默认 是false,会直接使用下一行,如果没有则创建。 |
| | | // // forceNewRow 如果设置了true,有个缺点 就是他会把所有的数据都放到内存了,所以慎用 |
| | | // // 简单的说 如果你的模板有list,且list不是最后一行,下面还有数据需要填充 就必须设置 forceNewRow=true 但是这个就会把所有数据放到内存 会很耗内存 |
| | | // // 如果数据量大 list不是最后一行 参照下一个 |
| | | // FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
| | | // excelWriter.fill(orderNo, fillConfig, writeSheet); |
| | | //// excelWriter.fill(orderNo, fillConfig, writeSheet); |
| | | // Map<String, Object> map = new HashMap<String, Object>(); |
| | | // map.put("date", "2019年10月9日13:28:28"); |
| | | // map.put("total", 1000); |
| | | // excelWriter.fill(map, writeSheet); |
| | | // excelWriter.finish(); |
| | | // |
| | | // |
| | | // } |
| | | |
| | | @RequestMapping("/download_excel") |
| | | public void downloadExcel(HttpServletResponse response,@RequestParam String orderNo) throws IOException { |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = "Order " + orderNo + ".xlsx"; |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName); |
| | | |
| | | OutputStream outputStream = response.getOutputStream(); |
| | | orderExport(outputStream, orderNo); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | } |
| | | |
| | | public void orderExport(OutputStream outputStream, String orderNo) throws IOException { |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderNo)); |
| | | |
| | | String templateFileName = this.getClass().getClassLoader().getResource("ru.xlsx").getPath(); |
| | | |
| | | ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(templateFileName).build(); |
| | | WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
| | | FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
| | | excelWriter.fill(orderDetls, fillConfig, writeSheet); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("date", "2019年10月9日13:28:28"); |
| | | map.put("orderNo", orderNo); |
| | | excelWriter.fill(map, writeSheet); |
| | | excelWriter.finish(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/nav/list/auth") |
| | | @ManagerAuth |
| | |
| | | } |
| | | if (orderLog != null) { |
| | | return R.error("单据编号在历史档中已存在"); |
| | | } |
| | | OrderDetl orderDetl1 = new OrderDetl(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | if (orderDetl1.getId() == null){ |
| | | orderDetl1.sync(orderDetl); |
| | | } |
| | | if (orderDetl1.getOwner() != orderDetl.getOwner()){ |
| | | return R.error("同个单据中只能存在一个货主代码"); |
| | | } |
| | | } |
| | | Date now = new Date(); |
| | | order = new Order( |
| | |
| | | if (order == null || order.getStatus() == 0) { |
| | | return R.error("订单不存在"); |
| | | } |
| | | |
| | | OrderDetl orderDetl1 = new OrderDetl(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | if (orderDetl1.getId() == null){ |
| | | orderDetl1.sync(orderDetl); |
| | | } |
| | | if (orderDetl1.getOwner() != orderDetl.getOwner()){ |
| | | return R.error("同个单据中只能存在一个货主代码"); |
| | | } |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | // 修改主档 |
| | |
| | | locCheckEntityWrapper.eq("order_no",orderNo); |
| | | List<OrderDetl> list = orderDetlService.selectList(locCheckEntityWrapper); |
| | | List<OrderDetlVo> orderDetlVos=new ArrayList<>(); |
| | | OrderDetlVo orderDetlVo=new OrderDetlVo(); |
| | | for (OrderDetl o: |
| | | list) { |
| | | for (OrderDetl o:list) { |
| | | OrderDetlVo orderDetlVo=new OrderDetlVo(); |
| | | orderDetlVo.setOrderNo(o.getOrderNo()); |
| | | orderDetlVo.setMatnr(o.getMatnr()); |
| | | orderDetlVo.setMaktx(o.getMaktx()); |
| | |
| | | return R.ok(orderService.selectAllorderNo()); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/list/AllCu") |
| | | @ManagerAuth |
| | | public R orderCuList(@RequestParam(required = false) String orderNo){ |
| | | EntityWrapper<Order> wrapper = new EntityWrapper<>(); |
| | | if (!Cools.isEmpty(orderNo)) { |
| | | wrapper.like("order_no", orderNo); |
| | | } |
| | | wrapper.le("settle", 2).eq("status", 1); |
| | | wrapper.orderBy("create_time", false); |
| | | List<Order> orders = orderService.selectList(wrapper); |
| | | // 保留出库单 |
| | | if (!Cools.isEmpty(orders)) { |
| | | Iterator<Order> iterator = orders.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Order order = iterator.next(); |
| | | if (order.getDocType() != null) { |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (docType != null) { |
| | | if (docType.getPakout() == 1) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.ok().add(orders); |
| | | } |
| | | |
| | | //订单组托2 |
| | | @RequestMapping(value = "/order/list/orderNo") |
| | | public R orderListorderNo(@RequestParam String orderNo) { |
| | |
| | | return R.ok(orderDetls); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/print2/auth") |
| | | @ManagerAuth(memo = "订单编码打印") |
| | | public R manPakOutPrint(@RequestParam(value = "param[]") String[] param) { |
| | | if(Cools.isEmpty(param)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | | } |
| | | List<OrderDetl> res = new ArrayList<>(); |
| | | for (String orderNo : param){ |
| | | res = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderNo)); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | @RequestMapping(value = "/order/code/auth") |
| | | // @ManagerAuth(memo = "物料编码条形码获取(type:1(条形码);2(二维码)") |
| | | public R manPakOutCodeBarcode(@RequestParam(defaultValue = "2") Integer type |
| | | , @RequestParam String param |
| | | , HttpServletResponse response) throws Exception { |
| | | AdminInterceptor.cors(response); |
| | | if (Cools.isEmpty(param)){ |
| | | return R.parse(BaseRes.EMPTY); |
| | | } |
| | | BufferedImage img; |
| | | if (type == 1) { |
| | | img = BarcodeUtils.encode(param); |
| | | } else { |
| | | img = QrCode.createImg(param); |
| | | } |
| | | if (!ImageIO.write(img, "jpg", response.getOutputStream())) { |
| | | throw new IOException("Could not write an image of format jpg"); |
| | | } |
| | | response.getOutputStream().flush(); |
| | | response.getOutputStream().close(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |