This commit is contained in:
2026-08-24 18:03:30 +08:00
parent 19949d102a
commit 172098bb59
2 changed files with 13 additions and 1 deletions
@@ -1,7 +1,10 @@
/** BladeX Commercial License Agreement */
package org.springblade.transport.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springblade.transport.pojo.entity.MasterOrder;
/**
@@ -10,4 +13,9 @@ import org.springblade.transport.pojo.entity.MasterOrder;
* @author Chill
*/
public interface MasterOrderMapper extends BaseMapper<MasterOrder> {
@InterceptorIgnore(tenantLine = "true")
@Select("SELECT COALESCE(MAX(CAST(SUBSTRING_INDEX(master_no, '-', -1) AS UNSIGNED)), 0) " +
"FROM blade_master_order WHERE master_no LIKE CONCAT(#{prefix}, '%')")
int selectMaxSerial(@Param("prefix") String prefix);
}
@@ -517,5 +517,9 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
private LocalDate date(Map<String, Object> values, String key) { String value = string(values, key); if (Func.isEmpty(value)) return null; try { return LocalDate.parse(value.substring(0, 10)); } catch (Exception exception) { throw new ServiceException("日期格式不正确"); } }
private String string(Map<String, Object> values, String key) { return string(values, key, null); }
private String string(Map<String, Object> values, String key, String fallback) { Object value = values.get(key); return value == null ? fallback : String.valueOf(value); }
private synchronized String nextCode() { String prefix = "DL-" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "-"; long count = count(new LambdaQueryWrapper<MasterOrder>().likeRight(MasterOrder::getMasterNo, prefix)); return prefix + String.format("%04d", count + 1); }
private synchronized String nextCode() {
String prefix = "DL-" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "-";
int serial = baseMapper.selectMaxSerial(prefix) + 1;
return prefix + String.format("%04d", serial);
}
}