| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.utils.uuid.UUID; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | * @date : 2025/9/15 15:31 |
| | | */ |
| | | public class OrderUtils { |
| | | |
| | | /** |
| | | * List<Integer> 转换为 Long[] 数组 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | public static Long[] listIntegerToLongArray(List<Integer> ids) { |
| | | return ids.stream() |
| | | // 处理null值:如果元素为null,转换为0L(可根据业务调整,比如抛异常) |
| | | .map(id -> id != null ? id.longValue() : -1L) |
| | | // 将Stream<Long>转换为Long[]数组 |
| | | .toArray(Long[]::new); |
| | | } |
| | | |
| | | /** |
| | | * 判断目标id是否在逗号分隔的字符串中 |
| | | * @param targetId |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public boolean isStaffIdExist(Object targetId,String str) { |
| | | // 空值校验,避免空指针 |
| | | if (str == null || str.trim().isEmpty() || targetId == null) { |
| | | return false; |
| | | } |
| | | // 按逗号分割成数组 |
| | | String[] idArray = str.split(","); |
| | | // 遍历数组判断是否包含目标id |
| | | for (String id : idArray) { |
| | | // 去除空格(防止字符串中有多余空格,如"1, 121") |
| | | String cleanId = id.trim(); |
| | | // 转换为数字并比较 |
| | | try { |
| | | if (cleanId.equals(String.valueOf(targetId))) { |
| | | return true; |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | // 若存在非数字ID,直接返回false |
| | | return false; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | // 执行查询 |
| | | Long aLong = mapper.selectCount(queryWrapper); |
| | | // 拼接订单编号 preFix + 时间(yyyyMMdd) + 订单数量(001) |
| | | return preFix + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE).replaceAll("-", "") + String.format("%03d", (aLong + 1));} |
| | | return preFix + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE).replaceAll("-", "") + String.format("%03d", (aLong + 1)) + "-" + new Date().getTime(); |
| | | } |
| | | } |