From 8b801fb370a413e31e7b6163ff6f12d6ffe98465 Mon Sep 17 00:00:00 2001 From: memorylkf <312904636@qq.com> Date: Thu, 22 Jan 2026 16:48:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20[=E7=BC=96=E5=8F=B7=E7=94=9F=E6=88=90]?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E5=88=86=E8=A3=85=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hxhq/business/controller/PublicController.java | 9 +++++---- .../main/java/com/hxhq/business/service/ISnGenService.java | 9 +++++++++ .../com/hxhq/business/service/impl/SnGenServiceImpl.java | 12 +++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java index b216127..68d7540 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/PublicController.java @@ -70,17 +70,18 @@ public class PublicController extends BaseController { /** * 获取编号 - * + * @param count + * @param my 母液编号(分装用) * @return */ @GetMapping("/getSn") - public AjaxResult getSn(Integer count) { + public AjaxResult getSn(Integer count,String my) { if (count == null || count.intValue() <= 1) { - return AjaxResult.success("操作成功",snGenService.getNewSn(SnTypeEnum.wz.getValue())); + return AjaxResult.success("操作成功",snGenService.getNewSn(SnTypeEnum.wz.getValue(),my)); }else{ List list = new ArrayList<>(); for (int i = 0; i < count;i++){ - list.add(snGenService.getNewSn(SnTypeEnum.wz.getValue())); + list.add(snGenService.getNewSn(SnTypeEnum.wz.getValue(),my)); } return AjaxResult.success(list); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISnGenService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISnGenService.java index a3082d1..5591a01 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISnGenService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/ISnGenService.java @@ -14,6 +14,15 @@ public interface ISnGenService extends IService { /** * 获取新编号 + * @param type + * @param my 母液编号(分装用) + * @return + */ + String getNewSn(Integer type, String my); + + /** + * 获取新编号 + * @param type * @return */ String getNewSn(Integer type); diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SnGenServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SnGenServiceImpl.java index 9df468d..9f56c43 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SnGenServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SnGenServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hxhq.common.core.utils.DateUtils; import com.hxhq.common.core.utils.SpringUtils; +import com.hxhq.common.core.utils.StringUtils; import com.hxhq.common.redis.service.RedisService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -31,11 +32,11 @@ public class SnGenServiceImpl extends ServiceImpl implements private final Lock lock = new ReentrantLock(true); @Override - public String getNewSn(Integer type) { + public String getNewSn(Integer type, String my) { lock.lock(); try { Integer sort = 1; - String date = DateUtils.dateTimeNow("yyMMdd"); + String date = StringUtils.isBlank(my)? DateUtils.dateTimeNow("yyMMdd"):my; QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("date",date); queryWrapper.eq("type",type); @@ -49,7 +50,7 @@ public class SnGenServiceImpl extends ServiceImpl implements baseMapper.addSn(date,type); sort = getOne(queryWrapper,false).getSn(); } - return date+"-"+String.format("%03d", sort); + return (StringUtils.isBlank(my)?(date+"-"):"")+String.format("%03d", sort); } catch (Exception e) { log.error("getNewSn执行被中断", e); } finally { @@ -57,4 +58,9 @@ public class SnGenServiceImpl extends ServiceImpl implements } return null; } + + @Override + public String getNewSn(Integer type) { + return getNewSn(type,null); + } }