| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | import com.zy.asrs.entity.result.OrderDetlVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.model.DetlDto; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | @RequestMapping(value = "/order/detl/all/auth") |
| | | @ManagerAuth |
| | | public R head(@RequestParam Long orderId){ |
| | | return R.ok().add(orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_id", orderId))); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_id", orderId)); |
| | | List<OrderDetl> orderDetls1 = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : orderDetls){ |
| | | double v = orderDetl.getAnfme() - orderDetl.getWorkQty(); |
| | | double v1 = new BigDecimal(v).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | if (v1!=0.0){ |
| | | orderDetls1.add(orderDetl); |
| | | } |
| | | } |
| | | return R.ok().add(orderDetls1); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/form/add/auth") |
| | | @ManagerAuth(memo = "手动添加订单") |
| | | @Transactional |
| | | public R formAdd(@RequestBody OrderDomainParam param){ |
| | | int payment = 0; |
| | | String prefix = ""; |
| | | DocType docType = docTypeService.selectById(param.getDocType()); |
| | | if(!Cools.isEmpty(docType)){ |
| | | prefix = docType.getPakin() == 1 ? "RK" : "CK"; |
| | | } |
| | | if (prefix.equals("CK")){ |
| | | payment = 1; |
| | | } |
| | | if(Cools.isEmpty(param.getOrderNo())){ |
| | | param.setOrderNo(prefix + snowflakeIdWorker.nextId()); |
| | |
| | | DateUtils.convert(now), // 单据日期 |
| | | param.getDocType(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | param.getItemName(), // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | null, // 联系方式 |
| | | param.getNumber(), // 票据号 |
| | | param.getCstmr(), // 客户编号 |
| | | param.getCstmrName(), // 客户 |
| | | param.getTel(), // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | |
| | | } |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | if (Cools.isEmpty(orderDetl.getOwner())){ |
| | | throw new CoolException("保存订单明细档失败,请输入货主编号"); |
| | | }else { |
| | | LocOwner locOwner = locOwnerService.selectById(orderDetl.getOwner()); |
| | | if (Cools.isEmpty(locOwner)){ |
| | | throw new CoolException("保存订单明细档失败,请输入存在的货主编号(整数)"); |
| | | } |
| | | } |
| | | |
| | | if (orderDetl.getBatch() == null) { |
| | | orderDetl.setBatch(""); |
| | | } |
| | |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | orderDetl.setPayment(payment); |
| | | orderDetl.setUuid(String.valueOf(System.currentTimeMillis())); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | // 修改主档 |
| | | if (!param.getDocType().equals(order.getDocType())) { |
| | | if (!param.getDocType().equals(order.getDocType()) || param.getCstmrName() != order.getCstmrName() || !Cools.eq(param.getItemName(),order.getItemName())) { |
| | | order.setDocType(param.getDocType()); |
| | | order.setUpdateBy(userId); |
| | | order.setCstmr(param.getCstmr()); |
| | | order.setCstmrName(param.getCstmrName()); |
| | | order.setTel(param.getTel()); |
| | | order.setNumber(param.getNumber()); |
| | | order.setItemName(param.getItemName()); |
| | | order.setUpdateTime(now); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("修改订单类型失败"); |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderQuery/auth") |
| | | @ManagerAuth |
| | | // @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<Order> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("id", condition); |
| | | wrapper.like("order_no", condition); |
| | | wrapper.le("settle",3); |
| | | Page<Order> page = orderService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Order order : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", order.getId()); |
| | | map.put("value", order.getOrderNo()); |
| | | map.put("customer",order.getCstmrName()); |
| | | map.put("phone",order.getTel()); |
| | | map.put("addr",order.getNumber()); |
| | | map.put("allocate",order.getItemName()); |
| | | map.put("type","order"); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/printExport/auth") |
| | | // @ManagerAuth(memo = "盘点单导出") |
| | | public void export(HttpServletResponse response, @RequestParam String orderNo) throws IOException { |
| | | //从数据库查询数据 |
| | | EntityWrapper<OrderDetl> locCheckEntityWrapper = new EntityWrapper<>(); |
| | | locCheckEntityWrapper.eq("order_no",orderNo); |
| | | List<OrderDetl> list = orderDetlService.selectList(locCheckEntityWrapper); |
| | | List<OrderDetlVo> orderDetlVos=new ArrayList<>(); |
| | | OrderDetlVo orderDetlVo=new OrderDetlVo(); |
| | | for (OrderDetl o: |
| | | list) { |
| | | orderDetlVo.setOrderNo(o.getOrderNo()); |
| | | orderDetlVo.setMatnr(o.getMatnr()); |
| | | orderDetlVo.setMaktx(o.getMaktx()); |
| | | orderDetlVo.setSpecs(o.getSpecs()); |
| | | orderDetlVo.setOwner(o.getOwner$()); |
| | | orderDetlVo.setPayment(o.getPayment$()); |
| | | orderDetlVo.setAnfme(o.getAnfme()); |
| | | orderDetlVo.setQty(o.getQty()); |
| | | orderDetlVo.setWorkQty(o.getWorkQty()); |
| | | orderDetlVo.setWeight(o.getWeight()); |
| | | orderDetlVos.add(orderDetlVo); |
| | | } |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("单据", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName+ orderNo + ".xlsx"); |
| | | Set<String> includeColumnFiledNames = new HashSet<String>(); |
| | | includeColumnFiledNames.add("orderNo"); |
| | | includeColumnFiledNames.add("matnr"); |
| | | includeColumnFiledNames.add("maktx"); |
| | | includeColumnFiledNames.add("specs"); |
| | | includeColumnFiledNames.add("owner"); |
| | | includeColumnFiledNames.add("payment"); |
| | | includeColumnFiledNames.add("anfme"); |
| | | includeColumnFiledNames.add("qty"); |
| | | includeColumnFiledNames.add("workQty"); |
| | | includeColumnFiledNames.add("weight"); |
| | | EasyExcel.write(response.getOutputStream(), OrderDetlVo.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .includeColumnFiledNames(includeColumnFiledNames) |
| | | .sheet("表1") |
| | | .doWrite(orderDetlVos); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/list/all") |
| | | public R orderList() { |
| | | |
| | | return R.ok(orderService.selectAllorderNo()); |
| | | } |
| | | |
| | | //订单组托2 |
| | | @RequestMapping(value = "/order/list/orderNo") |
| | | public R orderListorderNo(@RequestParam String orderNo) { |
| | | //数量修改成为完成数量 |
| | | List<OrderDetl> orderDetl1=orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no",orderNo)); |
| | | List<OrderDetl> orderDetls= new ArrayList<OrderDetl>(); |
| | | for (OrderDetl o: orderDetl1) { |
| | | o.setAnfme(o.getAnfme()-o.getWorkQty()); |
| | | BigDecimal c1 = new BigDecimal(o.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | o.setAnfme(c1.doubleValue()); |
| | | orderDetls.add(o); |
| | | } |
| | | return R.ok(orderDetls); |
| | | } |
| | | |
| | | |
| | | |
| | | } |