From 369d38887176f7737ebdf51d10c76dd2fbe8b5b7 Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期二, 19 十二月 2023 18:25:22 +0800 Subject: [PATCH] 代码提交 --- ruoyi-project/src/main/java/com/ruoyi/project/service/impl/BaseOnlyvalueServiceImpl.java | 39 +++++++++++++++++++++++++++++---------- ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BaseOnlyValController.java | 6 +++--- ruoyi-project/src/main/java/com/ruoyi/project/service/IBaseOnlyvalueService.java | 2 +- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BaseOnlyValController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BaseOnlyValController.java index 9e227b7..e058111 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BaseOnlyValController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/BaseOnlyValController.java @@ -39,10 +39,10 @@ */ @ApiOperation("鑾峰彇鍞竴缂栧彿") @GetMapping("/getOnlyCode") - public AjaxResult getOnlyCode(@RequestParam("businessType") String businessType) { - log.info("鏌ヨ鍞竴缂栧彿绫诲瀷 锛歿}锛�" , businessType); + public AjaxResult getOnlyCode(@RequestParam("businessType") String businessType, @RequestParam("datequery") Boolean datequery) { + log.info("鏌ヨ鍞竴缂栧彿绫诲瀷 锛歿}锛�", businessType); startPage(); - BaseOnlyvalue baseOnlyvalue = baseOnlyvalueService.getOnlyCode(businessType); + BaseOnlyvalue baseOnlyvalue = baseOnlyvalueService.getOnlyCode(businessType, datequery); return AjaxResult.success(baseOnlyvalue); } diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/IBaseOnlyvalueService.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/IBaseOnlyvalueService.java index 81a18e0..77e130e 100644 --- a/ruoyi-project/src/main/java/com/ruoyi/project/service/IBaseOnlyvalueService.java +++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/IBaseOnlyvalueService.java @@ -27,5 +27,5 @@ * @param businessType * @return */ - public BaseOnlyvalue getOnlyCode(String businessType); + public BaseOnlyvalue getOnlyCode(String businessType, Boolean datequery); } diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/BaseOnlyvalueServiceImpl.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/BaseOnlyvalueServiceImpl.java index 4f45220..a87095f 100644 --- a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/BaseOnlyvalueServiceImpl.java +++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/BaseOnlyvalueServiceImpl.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.project.domain.BaseOnlyvalue; import com.ruoyi.project.mapper.BaseOnlyvalueMapper; @@ -49,7 +50,7 @@ @Override - public BaseOnlyvalue getOnlyCode(String businessType) { + public BaseOnlyvalue getOnlyCode(String businessType, Boolean datequery) { LocalDate currentDate = LocalDate.now(); int year = currentDate.getYear(); int month = currentDate.getMonthValue(); @@ -57,7 +58,9 @@ //閫氳繃骞存湀鏃ユ湡鍘绘煡璇㈣鏈堜唤鏄惁瀛樺湪 String data = String.valueOf(year) + String.valueOf(month); BaseOnlyvalue baseOnlyvalue = new BaseOnlyvalue(); - baseOnlyvalue.setAppentvalue(data); + if (datequery) { + baseOnlyvalue.setAppentvalue(data); + } baseOnlyvalue.setBusinesstype(businessType); List<BaseOnlyvalue> baseOnlyvalues = queryList(baseOnlyvalue); @@ -68,16 +71,32 @@ baseOnlyvalue.setBusinesstype(businessType); save(baseOnlyvalue); -// return "OPO-" + data + "1"; - return baseOnlyvalue; + return baseOnlyvalue; } else { - //鍒欏皢currentValue+1,閲嶆柊璧嬪�� - BaseOnlyvalue baseOnlyvalue1 = baseOnlyvalues.get(0); - long newCurrentvalue = baseOnlyvalue1.getCurrentvalue() + 1; - baseOnlyvalue1.setCurrentvalue(newCurrentvalue); - updateById(baseOnlyvalue1); + for (BaseOnlyvalue baseOnlyvalue1 : baseOnlyvalues) { + if (datequery) { + //璇存槑鏄渶瑕佸皢甯︽棩鏈熺殑鍔�1 + if (!StringUtils.isEmpty(baseOnlyvalue1.getAppentvalue())) { + long newCurrentvalue = baseOnlyvalue1.getCurrentvalue() + 1; + baseOnlyvalue1.setCurrentvalue(newCurrentvalue); + updateById(baseOnlyvalue1); + } else { + continue; + } + } else { + //璇存槑鏄渶瑕佸皢涓嶅甫鏃ユ湡鐨勫姞1 + if (StringUtils.isEmpty(baseOnlyvalue1.getAppentvalue())) { + long newCurrentvalue = baseOnlyvalue1.getCurrentvalue() + 1; + baseOnlyvalue1.setCurrentvalue(newCurrentvalue); + updateById(baseOnlyvalue1); + } else { + continue; + } + } + baseOnlyvalue = baseOnlyvalue1; + } - return baseOnlyvalue1; + return baseOnlyvalue; } } -- Gitblit v1.9.3