| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.system.dto.TSysOrderDto; |
| | | import com.ruoyi.system.dto.TSysOrderNextDto; |
| | | import com.ruoyi.system.mapper.*; |
| | |
| | | tErpClinicOutbound.setOutboundType(7); |
| | | tErpClinicOutbound.setOrderNumber(tSysOrder.getOrderNumber()); |
| | | tErpClinicOutbound.setTotalMoney(dto.getTotalMoney()); |
| | | tErpClinicOutbound.setOutboundNumber("G"+System.currentTimeMillis()); |
| | | |
| | | TErpClinicOutbound last = erpClinicOutboundMapper.selectOne(new LambdaQueryWrapper<TErpClinicOutbound>().orderByDesc(BaseModel::getCreateTime).orderByDesc(TErpClinicOutbound::getOutboundNumber).last("limit 1")); |
| | | if (last == null) { |
| | | tErpClinicOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow() + "00001"); |
| | | } else { |
| | | String lastProcurementCode = last.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpClinicOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpClinicOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | tErpClinicOutbound.setCreateBy(name); |
| | | tErpClinicOutbound.setCreateId(userId); |
| | | tErpClinicOutbound.setTypeNum(goodsIds.size()); |