| | |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @RequestMapping(value = "/order/nav/list/auth") |
| | | @ManagerAuth |
| | |
| | | if (!Cools.isEmpty(orderNo)) { |
| | | wrapper.like("order_no", orderNo); |
| | | } |
| | | wrapper.le("settle", 2).eq("doc_type", 1).eq("status", 1); |
| | | 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() == 0) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.ok().add(orders); |
| | | } |
| | | |
| | |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else { |
| | | wrapper.orderBy("create_time", false); |
| | | wrapper.orderBy("settle").orderBy("create_time", false); |
| | | } |
| | | wrapper.eq("status", 1); |
| | | return R.ok(orderService.selectPage(new Page<>(curr, limit), wrapper)); |
| | |
| | | @ManagerAuth(memo = "手动添加订单") |
| | | @Transactional |
| | | public R formAdd(@RequestBody OrderDomainParam param){ |
| | | if(Cools.isEmpty(param.getOrderNo())){ |
| | | String prefix = ""; |
| | | DocType docType = docTypeService.selectById(param.getDocType()); |
| | | if(!Cools.isEmpty(docType)){ |
| | | prefix = docType.getPakin() == 1 ? "RK" : "CK"; |
| | | } |
| | | param.setOrderNo(prefix + snowflakeIdWorker.nextId()); |
| | | } |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (order != null) { |
| | | return R.error("单据编号已存在"); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // ------------------------------------------------------------------------------------------------ |
| | | |
| | | @RequestMapping(value = "/order/{id}/auth") |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/update/auth") |
| | | @ManagerAuth |
| | | public R update(Order order){ |
| | | if (Cools.isEmpty(order) || null == order.getId()){ |
| | | return R.error(); |
| | | } |
| | | |
| | | //订单完结前,判断是否存在作业中数据,存在则不能完结 |
| | | if(order.getSettle() == 4){ |
| | | int wrkCount = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("order_no",order.getOrderNo())); |
| | | int pakinCount = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("order_no",order.getOrderNo())); |
| | | if (wrkCount > 0 || pakinCount > 0) { |
| | | throw new CoolException("存在作业中数据,不能完结。请检查入库通知档和工作档"); |
| | | } |
| | | } |
| | | |
| | | order.setUpdateBy(getUserId()); |
| | | order.setUpdateTime(new Date()); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("修改订单失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/delete/auth") |
| | | @ManagerAuth(memo = "手动删除订单") |
| | | @Transactional |
| | | public R delete(@RequestParam Long orderId){ |
| | | Order order = orderService.selectById(orderId); |
| | | if (order != null) { |
| | | order.setStatus(0); |
| | | } |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("删除订单失败"); |
| | | } |
| | | orderDetlService.modifyStatus(orderId, 0); |
| | | orderService.remove(orderId); |
| | | // Order order = orderService.selectById(orderId); |
| | | // if (order != null) { |
| | | // order.setStatus(0); |
| | | // } |
| | | // if (!orderService.updateById(order)) { |
| | | // throw new CoolException("删除订单失败"); |
| | | // } |
| | | // orderDetlService.modifyStatus(orderId, 0); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/order/form/add/authtest") |
| | | @ManagerAuth(memo = "手动添加订单") |
| | | @Transactional |
| | | public R formAddTest(@RequestBody OrderDomainParam param){ |
| | | if(Cools.isEmpty(param.getOrderNo())){ |
| | | String prefix = ""; |
| | | DocType docType = docTypeService.selectById(param.getDocType()); |
| | | if(!Cools.isEmpty(docType)){ |
| | | prefix = docType.getPakin() == 1 ? "RK" : "CK"; |
| | | } |
| | | param.setOrderNo(prefix + snowflakeIdWorker.nextId()); |
| | | } |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (order != null) { |
| | | return R.error("单据编号已存在"); |
| | | } |
| | | Date now = new Date(); |
| | | order = new Order( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | DateUtils.convert(now), // 单据日期 |
| | | param.getDocType(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | null, // 客户编号 |
| | | null, // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | | null, // 优惠金额 |
| | | null, // 销售或采购费用合计 |
| | | null, // 实付金额 |
| | | null, // 付款类型 |
| | | null, // 业务员 |
| | | null, // 结算天数 |
| | | null, // 邮费支付类型 |
| | | null, // 邮费 |
| | | null, // 付款时间 |
| | | null, // 发货时间 |
| | | null, // 物流名称 |
| | | null, // 物流单号 |
| | | 1L, // 订单状态 |
| | | 1, // 状态 |
| | | getUserId(), // 添加人员 |
| | | now, // 添加时间 |
| | | getUserId(), // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("保存订单主档失败"); |
| | | } |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | } else { |
| | | list.add(dto); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setCreateBy(getUserId()); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(getUserId()); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | |
| | | //给添加子订单 |
| | | Set<String> exist = new HashSet<>(); |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | |
| | | |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok("订单添加成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |