| | |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.sales.dto.*; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerArrivalMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerArrival; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | |
| | | private static final String LEDGER_TYPE_OIL = "卖油"; |
| | | /** 销售类型:代储(卖存储位置,走油库+储罐+手工合同金额) */ |
| | | private static final String LEDGER_TYPE_DEPOSIT = "代储"; |
| | | /** 发货状态:有到货记录即视为已发货(油品出库不再产发货单) */ |
| | | private static final String SHIPPING_STATUS_SHIPPED = "已发货"; |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final SalesLedgerArrivalMapper salesLedgerArrivalMapper; |
| | | private final CustomerMapper customerMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final SalesLedgerProductServiceImpl salesLedgerProductServiceImpl; |
| | |
| | | for (SalesLedgerProduct product : products) { |
| | | product.setRegister(SecurityUtils.getLoginUser().getUser().getNickName()); |
| | | product.setRegisterDate(LocalDateTime.now()); |
| | | // 发货信息 |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerProductId, product.getId()) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | // 发货状态:油品出库不再产发货单,改为「有到货记录即已发货」 |
| | | SalesLedgerArrival arrival = salesLedgerArrivalMapper.selectOne(new LambdaQueryWrapper<SalesLedgerArrival>() |
| | | .eq(SalesLedgerArrival::getSalesLedgerProductId, product.getId()) |
| | | .orderByDesc(SalesLedgerArrival::getArrivalDate) |
| | | .orderByDesc(SalesLedgerArrival::getId) |
| | | .last("limit 1")); |
| | | if (shippingInfo != null) { |
| | | product.setShippingStatus(shippingInfo.getStatus()); |
| | | if (arrival != null) { |
| | | product.setShippingStatus(SHIPPING_STATUS_SHIPPED); |
| | | } |
| | | } |
| | | |
| | |
| | | for (SalesLedgerProduct product : products) { |
| | | product.setRegister(SecurityUtils.getLoginUser().getUser().getNickName()); |
| | | product.setRegisterDate(LocalDateTime.now()); |
| | | // 发货信息 |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerProductId, product.getId()) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | // 发货信息:油品出库不再产发货单,改按最新一条到货记录回填 |
| | | SalesLedgerArrival arrival = salesLedgerArrivalMapper.selectOne(new LambdaQueryWrapper<SalesLedgerArrival>() |
| | | .eq(SalesLedgerArrival::getSalesLedgerProductId, product.getId()) |
| | | .orderByDesc(SalesLedgerArrival::getArrivalDate) |
| | | .orderByDesc(SalesLedgerArrival::getId) |
| | | .last("limit 1")); |
| | | product.setShippingCarNumber(shippingInfo.getShippingCarNumber()); |
| | | product.setShippingDate(shippingInfo.getShippingDate()); |
| | | if (shippingInfo != null) { |
| | | product.setShippingStatus(shippingInfo.getStatus()); |
| | | if (arrival != null) { |
| | | product.setShippingCarNumber(arrival.getTruckPlateNo()); |
| | | product.setShippingDate(arrival.getArrivalDate() == null ? null : java.sql.Date.valueOf(arrival.getArrivalDate())); |
| | | product.setShippingStatus(SHIPPING_STATUS_SHIPPED); |
| | | } |
| | | } |
| | | // 过滤只保留发货记录 |
| | |
| | | salesLedger.setOilDepotName(null); |
| | | salesLedger.setTankId(null); |
| | | salesLedger.setTankNo(null); |
| | | salesLedger.setTonnage(null); |
| | | // updateById 会跳过 null,对修改是空操作;新增时与改造前一致(本就为 null) |
| | | salesLedger.setContractAmount(null); |
| | | return; |