| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | if (locDetl == null || locDetl.getAnfme() < param.getCount()) { |
| | | return R.error(mat.getMaktx() + "库存不足"); |
| | | } |
| | | Date now = new Date(); |
| | | Cstmr cstmr = cstmrService.selectByName(param.getCstmr()); |
| | | // 生成订单 |
| | | Order order = new Order( |
| | | hostId, |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | "HM-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15), // 订单编号 |
| | | // null, // 订单编号 |
| | | DateUtils.convert(now, DateUtils.yyyyMMdd_F), // 单据日期 |
| | | null, // 单据类型 |
| | | null, // 项目编号 |
| | | null, // 项目名称 |
| | | null, // 调拨项目编号 |
| | | null, // 初始票据号 |
| | | null, // 票据号 |
| | | cstmr==null?null:cstmr.getId(), // 客户编号 |
| | | param.getCstmr(), // 客户 |
| | | null, // 联系方式 |
| | | null, // 操作人员 |
| | | null, // 合计金额 |
| | | null, // 优惠率 |
| | | null, // 优惠金额 |
| | | null, // 销售或采购费用合计 |
| | | null, // 实付金额 |
| | | null, // 付款类型 |
| | | null, // 业务员 |
| | | null, // 结算天数 |
| | | null, // 邮费支付类型 |
| | | null, // 邮费 |
| | | null, // 付款时间 |
| | | null, // 发货时间 |
| | | null, // 物流名称 |
| | | null, // 物流单号 |
| | | 4L, // 订单状态 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | now, // 添加时间 |
| | | userId, // 修改人员 |
| | | now, // 修改时间 |
| | | "直接出库" // 备注 |
| | | ); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成订单失败!"); |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.setHostId(hostId); |
| | | orderDetl.setOrderId(order.getId()); // 订单内码 |
| | | orderDetl.setAnfme(param.getCount()); // 数量 |
| | | orderDetl.setCreateBy(userId); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(userId); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | VersionUtils.setOrderDetl(orderDetl, mat); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("生成订单失败"); |
| | | } |
| | | |
| | | // 生成拣货单 |
| | | Pakout pakout = new Pakout( |
| | | hostId, |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 任务号[非空] |
| | |
| | | null, // 重量 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | new Date(), // 添加时间 |
| | | now, // 添加时间 |
| | | userId, // 修改人员 |
| | | new Date(), // 修改时间 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | VersionUtils.setPakout(pakout, mat); |