| | |
| | | convert(param, wrapper); |
| | | allLike(InventoryReserve.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | wrapper.orderBy("create_time", false); |
| | | return R.ok(inventoryReserveService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | |
| | | convert(param, wrapper); |
| | | allLike(InventoryReserveLog.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | wrapper.orderBy("create_time", false); |
| | | return R.ok(inventoryReserveLogService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.OrderDetlPakin; |
| | | import com.zy.asrs.service.OrderDetlPakinService; |
| | | import com.zy.common.web.BaseController; |
| | |
| | | @Autowired |
| | | private OrderDetlPakinService orderDetlService; |
| | | |
| | | @PostMapping("/orderDetl/list/pda/auth") |
| | | public R getPdaOrderDetl(@RequestBody Map<String,Object> map) { |
| | | EntityWrapper<OrderDetlPakin> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("order_no", map.get("orderNo")); |
| | | List<OrderDetlPakin> orderDetls = orderDetlService.selectList(wrapper); |
| | | return R.ok(orderDetls); |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderDetl/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | |
| | | @Autowired |
| | | private ClientService clientService; |
| | | |
| | | @RequestMapping(value = "/order/list/pda/page/auth") |
| | | @ManagerAuth |
| | | public R pdaPageList(@RequestParam(required = true)Long tagId, |
| | | @RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit){ |
| | | List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("pakin", 1)); |
| | | ArrayList<Integer> arrayList = new ArrayList<>(); |
| | | docTypes.forEach(docType -> { |
| | | arrayList.add(docType.getDocId().intValue()); |
| | | }); |
| | | EntityWrapper<OrderPakin> wrapper = new EntityWrapper<>(); |
| | | // wrapper.eq("tag_id", tagId); |
| | | wrapper.in("doc_type", arrayList); |
| | | wrapper.in("settle",1,2); |
| | | wrapper.orderBy("create_time", false); |
| | | Page<OrderPakin> orderPage = orderService.selectPage(new Page<>(curr, limit), wrapper); |
| | | return R.ok().add(orderPage); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/nav/list/auth") |
| | | @ManagerAuth |
| | | public R navList(@RequestParam(required = false) String orderNo) { |
| | |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private WrkMastLogService wrkMastLogService; |
| | | @Autowired |
| | | private ClientService clientService; |
| | | @Autowired |
| | | private InventoryReserveService inventoryReserveService; |
| | | |
| | | @RequestMapping(value = "/order/nav/list/auth") |
| | | @ManagerAuth |
| | |
| | | @RequestMapping(value = "/order/head/page/auth") |
| | | @ManagerAuth |
| | | public R head(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | EntityWrapper<OrderPakout> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | |
| | | return R.error("单据编号已存在"); |
| | | } |
| | | Client client = clientService.selectOne(new EntityWrapper<Client>().eq("name", param.getCstmrName())); |
| | | if (null == client){ |
| | | if (null == client) { |
| | | return R.error("客户不存在"); |
| | | } |
| | | Date now = new Date(); |
| | | order = new OrderPakout( |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | param.getOrderTime(), // 单据日期 |
| | | param.getDocType(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | client.getCode(), // 客户编号 |
| | | client.getName(), // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | | null, // 优惠金额 |
| | | null, // 销售或采购费用合计 |
| | | null, // 实付金额 |
| | | null, // 付款类型 |
| | | null, // 业务员 |
| | | null, // 结算天数 |
| | | null, // 邮费支付类型 |
| | | null, // 邮费 |
| | | null, // 付款时间 |
| | | null, // 发货时间 |
| | | null, // 物流名称 |
| | | null, // 物流单号 |
| | | 1L, // 订单状态 |
| | | 1, // 状态 |
| | | getUserId(), // 添加人员 |
| | | now, // 添加时间 |
| | | getUserId(), // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编号 |
| | | param.getOrderTime(), // 单据日期 |
| | | param.getDocType(), // 单据类型 |
| | | null, // 项目编号 |
| | | null, // |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | client.getCode(), // 客户编号 |
| | | client.getName(), // 客户 |
| | | 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("保存订单主档失败"); |
| | |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetlPakout item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(), |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | OrderDetlPakout item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), |
| | | orderDetl.getBatch(), orderDetl.getBrand(), |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | Client client = clientService.selectOne(new EntityWrapper<Client>().eq("name", param.getCstmrName())); |
| | | if (null == client){ |
| | | if (null == client) { |
| | | return R.error("客户不存在"); |
| | | } |
| | | order.setCstmr(client.getCode()); |
| | | order.setCstmrName(client.getName()); |
| | | // 修改主档 |
| | | if (!param.getDocType().equals(order.getDocType()) || !param.getOrderTime().equals(order.getOrderTime())) { |
| | | order.setCstmr(client.getCode()); |
| | | order.setCstmrName(client.getName()); |
| | | |
| | | order.setDocType(param.getDocType()); |
| | | order.setOrderTime(param.getOrderTime()); |
| | | order.setUpdateBy(userId); |
| | | order.setUpdateTime(now); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("修改订单类型失败"); |
| | | } |
| | | |
| | | } |
| | | order.setUpdateBy(userId); |
| | | order.setUpdateTime(now); |
| | | if (!orderService.updateById(order)) { |
| | | throw new CoolException("修改订单类型失败"); |
| | | } |
| | | |
| | | // 修改明细档 |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // 1.清空明细档 |
| | | if (!orderDetlService.delete(new EntityWrapper<OrderDetlPakout>().eq("order_id", order.getId()))) { |
| | | throw new CoolException("清空订单明细失败"); |
| | |
| | | orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetlPakout item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | OrderDetlPakout item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), |
| | | orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), |
| | | orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | |
| | | endQty = endQty + orderDetl.getQty(); |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued > 0.0) { |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getOrigin(), null); |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getOrigin(), null); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | issued = issued - locDetl.getAnfme(); |
| | |
| | | List<WrkTraceVo> wrkTraceVos = new ArrayList<>(); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectAndLogByOrderNoGroupByMatnrOfSum(order.getOrderNo()); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime())); |
| | | WrkMast wrkMast = wrkMastService.selectOne( |
| | | new EntityWrapper<WrkMast>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime())); |
| | | if (wrkMast == null) { |
| | | WrkMastLog wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime())); |
| | | WrkMastLog wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>() |
| | | .eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime())); |
| | | if (wrkMastLog.getIoType() == 103) { |
| | | wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime()).eq("io_type", 53)); |
| | | wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>() |
| | | .eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime()).eq("io_type", 53)); |
| | | } |
| | | if (wrkMastLog != null) { |
| | | wrkMast = new WrkMast(); |
| | |
| | | } |
| | | boolean exist = false; |
| | | for (WrkTraceVo vo : wrkTraceVos) { |
| | | if (vo.getWrkNo().equals(wrkMast.getWrkNo()) && vo.getIoTimeStr().equals(DateUtils.convert(wrkMast.getIoTime()))) { |
| | | if (vo.getWrkNo().equals(wrkMast.getWrkNo()) |
| | | && vo.getIoTimeStr().equals(DateUtils.convert(wrkMast.getIoTime()))) { |
| | | vo.getWrkDetls().add(wrkDetl); |
| | | exist = true; |
| | | } |
| | | } |
| | | if (!exist) { |
| | | WrkTraceVo vo = new WrkTraceVo(wrkMast.getWrkNo(), DateUtils.convert(wrkMast.getIoTime()), wrkMast, wrkDetl); |
| | | WrkTraceVo vo = new WrkTraceVo(wrkMast.getWrkNo(), DateUtils.convert(wrkMast.getIoTime()), wrkMast, |
| | | wrkDetl); |
| | | wrkTraceVos.add(vo); |
| | | } |
| | | } |
| | | if (!Cools.isEmpty(wrkTraceVos) && wrkTraceVos.size() > 1) { |
| | | wrkTraceVos.sort((o1, o2) -> (int) (o2.getWrkMast().getIoTime().getTime() - o1.getWrkMast().getIoTime().getTime())); |
| | | wrkTraceVos.sort( |
| | | (o1, o2) -> (int) (o2.getWrkMast().getIoTime().getTime() - o1.getWrkMast().getIoTime().getTime())); |
| | | } |
| | | return R.ok().add(Cools |
| | | .add("list", wrkTraceVos) |
| | |
| | | .add("totalQty", totalQty) |
| | | .add("wrkQty", wrkQty) |
| | | .add("lackQty", lackQty) |
| | | .add("endQty", endQty) |
| | | ); |
| | | .add("endQty", endQty)); |
| | | } |
| | | |
| | | |
| | | // ------------------------------------------------------------------------------------------------ |
| | | |
| | |
| | | @RequestMapping(value = "/order/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | EntityWrapper<OrderPakout> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | |
| | | 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())); |
| | | int pakinCount = waitPakinService |
| | | .selectCount(new EntityWrapper<WaitPakin>().eq("order_no", order.getOrderNo())); |
| | | if (wrkCount > 0 || pakinCount > 0) { |
| | | throw new CoolException("存在作业中数据,不能完结。请检查入库通知档和工作档"); |
| | | } |
| | |
| | | @Transactional |
| | | public R delete(@RequestParam Long orderId) { |
| | | 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); |
| | | // 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(); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/order/check/column/auth") |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<OrderPakout> wrapper = new EntityWrapper<OrderPakout>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | Wrapper<OrderPakout> wrapper = new EntityWrapper<OrderPakout>().eq(humpToLine(String.valueOf(param.get("key"))), |
| | | param.get("val")); |
| | | if (null != orderService.selectOne(wrapper)) { |
| | | return R.parse(BaseRes.REPEAT).add(getComment(OrderPakout.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/reserve/auth") |
| | | @ManagerAuth(memo = "订单库存预留") |
| | | @Transactional |
| | | public R reserve(@RequestParam Long orderId, |
| | | @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date expireTime) { |
| | | OrderPakout order = orderService.selectById(orderId); |
| | | if (order == null) { |
| | | return R.error("订单不存在"); |
| | | } |
| | | // 检查是否已存在该订单的预留记录 |
| | | int existCount = inventoryReserveService.selectCount( |
| | | new EntityWrapper<InventoryReserve>().eq("order_no", order.getOrderNo())); |
| | | if (existCount > 0) { |
| | | return R.error("该订单已存在预留记录,不能重复创建"); |
| | | } |
| | | // 查询订单明细 |
| | | List<OrderDetlPakout> orderDetls = orderDetlService.selectByOrderId(orderId); |
| | | if (Cools.isEmpty(orderDetls)) { |
| | | return R.error("订单明细为空"); |
| | | } |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | // 为每条明细创建库存预留记录 |
| | | for (OrderDetlPakout detl : orderDetls) { |
| | | InventoryReserve reserve = new InventoryReserve(); |
| | | reserve.setMatnr(detl.getMatnr()); |
| | | reserve.setMaktx(detl.getMaktx()); |
| | | reserve.setOrderNo(order.getOrderNo()); |
| | | reserve.setBatch(detl.getBatch()); |
| | | reserve.setQuantity(java.math.BigDecimal.valueOf(detl.getAnfme())); |
| | | reserve.setExpireTime(expireTime); |
| | | reserve.setCreateTime(now); |
| | | reserve.setCreateBy(userId); |
| | | reserve.setUpdateTime(now); |
| | | reserve.setUpdateBy(userId); |
| | | reserve.setBrand(detl.getBrand()); |
| | | reserve.setStandby1(detl.getStandby1()); |
| | | reserve.setStandby2(detl.getStandby2()); |
| | | reserve.setStandby3(detl.getStandby3()); |
| | | reserve.setBoxType1(detl.getBoxType1()); |
| | | reserve.setBoxType2(detl.getBoxType2()); |
| | | reserve.setBoxType3(detl.getBoxType3()); |
| | | inventoryReserveService.insert(reserve); |
| | | } |
| | | return R.ok("预留成功,共创建 " + orderDetls.size() + " 条预留记录"); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private OrderPakoutService orderPakOutService; |
| | | |
| | | @Autowired |
| | | private InventoryReserveService inventoryReserveService; |
| | | |
| | | |
| | | @PostMapping("/out/pakout/orderDetlIds/auth") |
| | |
| | | } |
| | | } else { |
| | | for (OrderDetlPakout orderDetl : orderDetlPakouts) { |
| | | |
| | | List<InventoryReserve> inventoryReserves = inventoryReserveService.selectList(new EntityWrapper<InventoryReserve>() |
| | | .eq("matnr", orderDetl.getMatnr()) |
| | | .eq("batch", orderDetl.getBatch()) |
| | | //如果订单号不为空,则查询订单号不为orderDetl.getOrderNo()的库存预留记录,否则查询所有库存预留记录 |
| | | .ne(!Cools.isEmpty(orderDetl.getOrderNo()), "order_no", orderDetl.getOrderNo()) |
| | | .eq(!Cools.isEmpty(orderDetl.getBrand()), "brand", orderDetl.getBrand()) |
| | | .eq(!Cools.isEmpty(orderDetl.getStandby1()), "standby1", orderDetl.getStandby1()) |
| | | .eq(!Cools.isEmpty(orderDetl.getStandby2()), "standby2", orderDetl.getStandby2()) |
| | | .eq(!Cools.isEmpty(orderDetl.getStandby3()), "standby3", orderDetl.getStandby3()) |
| | | .eq(!Cools.isEmpty(orderDetl.getBoxType1()), "box_type1", orderDetl.getBoxType1()) |
| | | .eq(!Cools.isEmpty(orderDetl.getBoxType2()), "box_type2", orderDetl.getBoxType2()) |
| | | .eq(!Cools.isEmpty(orderDetl.getBoxType3()), "box_type3", orderDetl.getBoxType3()) |
| | | |
| | | ); |
| | | // 如果库存预留记录不为空,使用steam将库存预留记录中的库存数量全部加起来,字段为quantity,类型为BigDecimal |
| | | BigDecimal inventoryReserveQuantity = inventoryReserves.stream().map(InventoryReserve::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //获取库存中的库存数量 |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | |
| | | // 使用steam将locDetls中的库存数量全部加起来,字段为quantity,Double类型 |
| | | BigDecimal locDetlQuantity = locDetls.stream().map(LocDetl::getAnfme).map(BigDecimal::valueOf).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | if (locDetlQuantity.subtract(new BigDecimal(orderDetl.getAnfme())).compareTo(inventoryReserveQuantity) < 0) { |
| | | return R.parse("库存预留数量大于库存数量"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.UserService; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | |
| | | @TableField("update_by") |
| | | private Long updateBy; |
| | | |
| | | @ApiModelProperty(value = "品牌") |
| | | private String brand; |
| | | |
| | | /** |
| | | * 备用1 |
| | | */ |
| | | @ApiModelProperty(value = "备用1") |
| | | private String standby1 = ""; |
| | | |
| | | /** |
| | | * 备用2 |
| | | */ |
| | | @ApiModelProperty(value = "备用2") |
| | | private String standby2 = ""; |
| | | |
| | | /** |
| | | * 备用3 |
| | | */ |
| | | @ApiModelProperty(value = "备用3") |
| | | private String standby3 = ""; |
| | | |
| | | /** |
| | | * 备用1 |
| | | */ |
| | | @ApiModelProperty(value = "备用1") |
| | | @TableField("box_type1") |
| | | private String boxType1 = "1"; |
| | | |
| | | /** |
| | | * 备用2 |
| | | */ |
| | | @ApiModelProperty(value = "备用2") |
| | | @TableField("box_type2") |
| | | private String boxType2 = "1"; |
| | | |
| | | /** |
| | | * 备用3 |
| | | */ |
| | | @ApiModelProperty(value = "备用3") |
| | | @TableField("box_type3") |
| | | private String boxType3 = "1"; |
| | | |
| | | public InventoryReserve() {} |
| | | |
| | | public InventoryReserve(String matnr,String maktx,String orderNo,String batch,BigDecimal quantity,Date expiceTime,Long deptId,Date createTime,Long createBy,Date updateTime,Long updateBy) { |
| | |
| | | // null // 更新人员 |
| | | // ); |
| | | |
| | | public String getExpiceTime$(){ |
| | | public String getExpireTime$(){ |
| | | if (Cools.isEmpty(this.expireTime)){ |
| | | return ""; |
| | | } |
| | |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | public String getCreateBy$() { |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.selectById(this.createBy); |
| | | if (!Cools.isEmpty(user)) { |
| | | return String.valueOf(user.getUsername()); |
| | | } |
| | | if (this.createBy == 9527){ |
| | | return "super"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getUpdateBy$() { |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.selectById(this.updateBy); |
| | | if (!Cools.isEmpty(user)) { |
| | | return String.valueOf(user.getUsername()); |
| | | } |
| | | if (this.createBy == 9527){ |
| | | return "super"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.UserService; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | |
| | | @TableField("update_by") |
| | | private Long updateBy; |
| | | |
| | | @ApiModelProperty(value = "品牌") |
| | | private String brand; |
| | | |
| | | /** |
| | | * 备用1 |
| | | */ |
| | | @ApiModelProperty(value = "备用1") |
| | | private String standby1 = ""; |
| | | |
| | | /** |
| | | * 备用2 |
| | | */ |
| | | @ApiModelProperty(value = "备用2") |
| | | private String standby2 = ""; |
| | | |
| | | /** |
| | | * 备用3 |
| | | */ |
| | | @ApiModelProperty(value = "备用3") |
| | | private String standby3 = ""; |
| | | |
| | | /** |
| | | * 备用1 |
| | | */ |
| | | @ApiModelProperty(value = "备用1") |
| | | @TableField("box_type1") |
| | | private String boxType1 = "1"; |
| | | |
| | | /** |
| | | * 备用2 |
| | | */ |
| | | @ApiModelProperty(value = "备用2") |
| | | @TableField("box_type2") |
| | | private String boxType2 = "1"; |
| | | |
| | | /** |
| | | * 备用3 |
| | | */ |
| | | @ApiModelProperty(value = "备用3") |
| | | @TableField("box_type3") |
| | | private String boxType3 = "1"; |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String memo; |
| | | |
| | | public InventoryReserveLog() {} |
| | | |
| | | public InventoryReserveLog(String matnr,String maktx,String orderNo,String batch,BigDecimal quantity,Date expiceTime,Long deptId,Date createTime,Long createBy,Date updateTime,Long updateBy) { |
| | |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | public String getCreateBy$() { |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.selectById(this.createBy); |
| | | if (!Cools.isEmpty(user)) { |
| | | return String.valueOf(user.getUsername()); |
| | | } |
| | | if (this.createBy == 9527){ |
| | | return "super"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getUpdateBy$() { |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.selectById(this.updateBy); |
| | | if (!Cools.isEmpty(user)) { |
| | | return String.valueOf(user.getUsername()); |
| | | } |
| | | if (this.createBy == 9527){ |
| | | return "super"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.task.handler; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.InventoryReserve; |
| | | import com.zy.asrs.entity.InventoryReserveLog; |
| | | import com.zy.asrs.entity.OrderPakout; |
| | | import com.zy.asrs.service.InventoryReserveLogService; |
| | | import com.zy.asrs.service.InventoryReserveService; |
| | | import com.zy.asrs.service.OrderPakoutService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | /** |
| | | * 预留库存过期处理器 |
| | | * 将过期的预留库存转移到日志表 |
| | | * 转历史条件: |
| | | * 1. 过期时间不为空且已过期 |
| | | * 2. 订单号不为空且订单状态为作业中(1)或已完成(2) |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | |
| | | @Autowired |
| | | private InventoryReserveLogService inventoryReserveLogService; |
| | | |
| | | @Autowired |
| | | private OrderPakoutService orderPakoutService; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ReturnT<String> start() { |
| | | // 查询过期的预留库存(过期时间不为空且小于当前时间) |
| | | Date now = new Date(); |
| | | List<InventoryReserve> expiredList = inventoryReserveService.selectList( |
| | | new EntityWrapper<InventoryReserve>() |
| | | .isNotNull("expire_time") |
| | | .lt("expire_time", now)); |
| | | |
| | | if (expiredList.isEmpty()) { |
| | | // 查询所有预留库存记录 |
| | | List<InventoryReserve> allReserves = inventoryReserveService.selectList(new EntityWrapper<>()); |
| | | |
| | | if (allReserves.isEmpty()) { |
| | | return SUCCESS; |
| | | } |
| | | |
| | | log.info("发现 {} 条过期的预留库存记录", expiredList.size()); |
| | | |
| | | for (InventoryReserve reserve : expiredList) { |
| | | int processedCount = 0; |
| | | for (InventoryReserve reserve : allReserves) { |
| | | try { |
| | | // 转移到日志表 |
| | | InventoryReserveLog logRecord = getInventoryReserveLog(reserve); |
| | | boolean shouldArchive = false; |
| | | String archiveReason = null; |
| | | |
| | | inventoryReserveLogService.insert(logRecord); |
| | | // 条件1:过期时间不为空且已过期 |
| | | if (reserve.getExpireTime() != null && reserve.getExpireTime().before(now)) { |
| | | shouldArchive = true; |
| | | archiveReason = "已过期"; |
| | | } |
| | | |
| | | // 删除原记录 |
| | | inventoryReserveService.deleteById(reserve.getId()); |
| | | // 条件2:订单号不为空且订单状态为作业中或已完成 |
| | | if (!shouldArchive && !Cools.isEmpty(reserve.getOrderNo())) { |
| | | OrderPakout order = orderPakoutService.selectOne( |
| | | new EntityWrapper<OrderPakout>().eq("order_no", reserve.getOrderNo())); |
| | | if (null != order) { |
| | | if (order.getSettle() != 1) { |
| | | shouldArchive = true; |
| | | archiveReason = "订单不为待处理状态"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | log.info("预留库存过期处理完成: id={}, matnr={}, batch={}", |
| | | reserve.getId(), reserve.getMatnr(), reserve.getBatch()); |
| | | if (shouldArchive) { |
| | | // 转移到日志表 |
| | | InventoryReserveLog logRecord = new InventoryReserveLog(); |
| | | BeanUtils.copyProperties(reserve, logRecord); |
| | | logRecord.setMemo(archiveReason); |
| | | inventoryReserveLogService.insert(logRecord); |
| | | |
| | | // 删除原记录 |
| | | inventoryReserveService.deleteById(reserve.getId()); |
| | | |
| | | log.info("预留库存转历史完成: id={}, matnr={}, batch={}, 原因={}", |
| | | reserve.getId(), reserve.getMatnr(), reserve.getBatch(), archiveReason); |
| | | processedCount++; |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("预留库存过期处理失败: id={}, error={}", reserve.getId(), e.getMessage()); |
| | | log.error("预留库存转历史失败: id={}, error={}", reserve.getId(), e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | return SUCCESS; |
| | | } |
| | | if (processedCount > 0) { |
| | | log.info("本次共处理 {} 条预留库存转历史记录", processedCount); |
| | | } |
| | | |
| | | private static InventoryReserveLog getInventoryReserveLog(InventoryReserve reserve) { |
| | | InventoryReserveLog logRecord = new InventoryReserveLog(); |
| | | logRecord.setMatnr(reserve.getMatnr()); |
| | | logRecord.setMaktx(reserve.getMaktx()); |
| | | logRecord.setOrderNo(reserve.getOrderNo()); |
| | | logRecord.setBatch(reserve.getBatch()); |
| | | logRecord.setQuantity(reserve.getQuantity()); |
| | | logRecord.setExpireTime(reserve.getExpireTime()); |
| | | logRecord.setDeptId(reserve.getDeptId()); |
| | | logRecord.setCreateTime(reserve.getCreateTime()); |
| | | logRecord.setCreateBy(reserve.getCreateBy()); |
| | | logRecord.setUpdateTime(new Date()); |
| | | return logRecord; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | // public static final String URI = "http://192.168.99.130:80"; |
| | | // 测试地址 |
| | | public static final String ERP_IP = "http://127.0.0.1:8080/yhfzwms/open/asrs"; |
| | | public static final String ERP_IP = "http://127.0.0.1:8080/wms/open/asrs"; |
| | | |
| | | /** |
| | | * 入库完成上报路径 |
| | |
| | | { field: 'orderNo', align: 'center', title: '订单号', width: 150 }, |
| | | { field: 'batch', align: 'center', title: '批次', width: 120 }, |
| | | { field: 'quantity', align: 'center', title: '数量', width: 100 }, |
| | | { field: 'expiceTime$', align: 'center', title: '过期时间', width: 180 }, |
| | | { field: 'createTime$', align: 'center', title: '创建时间', width: 180 }, |
| | | { field: 'expireTime$', align: 'center', title: '过期时间', width: 180 }, |
| | | { field: 'createTime$', align: 'center', title: '创建时间', width: 180 ,hide:true}, |
| | | { field: 'updateTime$', align: 'center', title: '更新时间', width: 180 }, |
| | | { field: 'createBy$', align: 'center', title: '创建人', width: 100 }, |
| | | { field: 'updateBy$', align: 'center', title: '更新人', width: 100 }, |
| | | { fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 150 } |
| | | ]], |
| | | request: { |
| | |
| | | |
| | | // 渲染日期选择器 |
| | | layDate.render({ |
| | | elem: '#expiceTime', |
| | | elem: '#expireTime', |
| | | type: 'datetime', |
| | | format: 'yyyy-MM-dd HH:mm:ss' |
| | | }); |
| | |
| | | { field: 'quantity', align: 'center', title: '数量', width: 100 }, |
| | | { field: 'expiceTime$', align: 'center', title: '过期时间', width: 180 }, |
| | | { field: 'createTime$', align: 'center', title: '原创建时间', width: 180 }, |
| | | { field: 'updateTime$', align: 'center', title: '转移时间', width: 180 } |
| | | { field: 'updateTime$', align: 'center', title: '转移时间', width: 180 }, |
| | | { field: 'memo', align: 'center', title: '过期原因', width: 180 } |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | |
| | | }); |
| | | } |
| | | }); |
| | | } else if (layEvent === 'reserve') { |
| | | showReserveDialog(data.id); |
| | | } |
| | | }); |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | // 预留弹窗 |
| | | function showReserveDialog(orderId) { |
| | | admin.open({ |
| | | type: 1, |
| | | title: '库存预留', |
| | | content: $('#reserveDialog').html(), |
| | | area: '400px', |
| | | success: function (layero, dIndex) { |
| | | // 初始化日期时间选择器 |
| | | layDate.render({ |
| | | elem: '#reserveExpireTime', |
| | | type: 'datetime', |
| | | format: 'yyyy-MM-dd HH:mm:ss', |
| | | min: 0 // 只能选择今天及以后 |
| | | }); |
| | | // 表单提交事件 |
| | | form.on('submit(reserveSubmit)', function (data) { |
| | | layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl + "/order/pakout/order/reserve/auth", |
| | | headers: { 'token': localStorage.getItem('token') }, |
| | | data: { |
| | | orderId: orderId, |
| | | expireTime: data.field.expireTime |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll('loading'); |
| | | if (res.code === 200) { |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, { icon: 1 }); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, { icon: 2 }); |
| | | } |
| | | } |
| | | }); |
| | | return false; |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | layDate.render({ |
| | | elem: '.layui-laydate-range' |
| | | , type: 'datetime' |
| | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">过期时间</label> |
| | | <div class="layui-input-block"> |
| | | <input id="expiceTime" name="expiceTime" placeholder="选择过期时间(可选)" class="layui-input" autocomplete="off"> |
| | | <input id="expireTime" name="expireTime" placeholder="选择过期时间(可选)" class="layui-input" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | |
| | | {{# if (d.settle == 2) { }} |
| | | <a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs btn-complete" lay-event="complete">完结</a> |
| | | {{# } }} |
| | | {{# if (d.settle == 1 || d.settle == 2) { }} |
| | | <a class="layui-btn layui-btn-warm layui-btn-xs btn-edit" lay-event="reserve">预留</a> |
| | | {{# } }} |
| | | </script> |
| | | <!-- 表格操作列 --> |
| | | <script type="text/html" id="tbLook"> |
| | |
| | | <option value="{{docId}}">{{docName}}</option> |
| | | {{/each}} |
| | | </script> |
| | | <!-- 预留时间选择弹窗 --> |
| | | <script type="text/html" id="reserveDialog"> |
| | | <form id="reserveForm" lay-filter="reserveForm" class="layui-form model-form"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">预留过期时间:</label> |
| | | <div class="layui-input-block"> |
| | | <input id="reserveExpireTime" name="expireTime" placeholder="选择预留过期时间(可选)" |
| | | type="text" class="layui-input" autocomplete="off" |
| | | lay-verType="tips"/> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | <button class="layui-btn" lay-filter="reserveSubmit" lay-submit>确认预留</button> |
| | | </div> |
| | | </form> |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |