From 02ff92b78b641fe7402e0343c43ecf59cb70b149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=B6=E4=B8=9C?= <1654135867@qq.com> Date: Fri, 1 Nov 2024 11:25:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E8=B5=84=E8=B4=A8bug?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DepadminlxController.java | 13 ++++++---- .../controller/DepsbnczController.java | 24 +++++++++++++++---- .../demo/depsbncz/entity/Depsbncz.java | 6 +++++ .../src/views/depsbncz/Depsbncz.data.ts | 5 ++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depadminlx/controller/DepadminlxController.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depadminlx/controller/DepadminlxController.java index 74a0703..4ef2655 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depadminlx/controller/DepadminlxController.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depadminlx/controller/DepadminlxController.java @@ -90,11 +90,16 @@ public class DepadminlxController extends JeecgController add(@RequestBody Depadminlx depadminlx) { LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal(); - depadminlx.setUserid(user.getId()); String depiid = depadminlxService.getdepid(user.getId()); - depadminlx.setDepid(depiid); - depadminlxService.save(depadminlx); - return Result.OK("添加成功!"); + List depadminlxes = depadminlxService.query().eq("depid",depiid).list(); + if (depadminlxes.size()>0){ + return Result.error("已经添加过了!"); + }else { + depadminlx.setUserid(user.getId()); + depadminlx.setDepid(depiid); + depadminlxService.save(depadminlx); + return Result.OK("添加成功!"); + } } /** diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/controller/DepsbnczController.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/controller/DepsbnczController.java index fb903ae..129f6c0 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/controller/DepsbnczController.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/controller/DepsbnczController.java @@ -1,5 +1,6 @@ package org.jeecg.modules.demo.depsbncz.controller; +import java.time.LocalDate; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -17,6 +18,8 @@ import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.query.QueryRuleEnum; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.demo.annual.entity.Annual; +import org.jeecg.modules.demo.annual.service.IAnnualService; import org.jeecg.modules.demo.depadminlx.service.IDepadminlxService; import org.jeecg.modules.demo.depsbncz.entity.Depsbncz; import org.jeecg.modules.demo.depsbncz.service.IDepsbnczService; @@ -58,6 +61,8 @@ public class DepsbnczController extends JeecgController add(@RequestBody Depsbncz depsbncz) { - LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal(); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); depsbncz.setUserid(user.getId()); String depiid = depadminlxService.getdepid(user.getId()); - depsbncz.setDepid(depiid); - depsbnczService.save(depsbncz); - return Result.OK("添加成功!"); + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 获取当前年份并直接转换为字符串 + String currentYearString = String.valueOf(currentDate.getYear()); + Annual annual = annualService.query().eq("annual_name",currentYearString).one(); + List depsbnczs=depsbnczService.query().eq("annualid",annual.getId()).eq("depid",depiid).list(); + if (depsbnczs.size()>0){ + return Result.error("本年度已经添加过了"); + }else { + depsbncz.setAnnualid(annual.getId()); + depsbncz.setDepid(depiid); + depsbnczService.save(depsbncz); + return Result.OK("添加成功!"); + } } /** diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/entity/Depsbncz.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/entity/Depsbncz.java index f3ca560..b89b3b7 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/entity/Depsbncz.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/depsbncz/entity/Depsbncz.java @@ -107,4 +107,10 @@ public class Depsbncz implements Serializable { @Excel(name = "用户id", width = 15) @ApiModelProperty(value = "用户id") private java.lang.String userid; + + /**年度*/ + @Excel(name = "年度", width = 15, dictTable = "annual", dicText = "annual_name", dicCode = "id") + @Dict(dictTable = "annual", dicText = "annual_name", dicCode = "id") + @ApiModelProperty(value = "年度") + private java.lang.String annualid; } diff --git a/jeecgboot-vue3/src/views/depsbncz/Depsbncz.data.ts b/jeecgboot-vue3/src/views/depsbncz/Depsbncz.data.ts index 5e3d946..0b6d892 100644 --- a/jeecgboot-vue3/src/views/depsbncz/Depsbncz.data.ts +++ b/jeecgboot-vue3/src/views/depsbncz/Depsbncz.data.ts @@ -60,6 +60,11 @@ export const columns: BasicColumn[] = [ align: "center", dataIndex: 'nsze' }, + { + title: '年度', + align: "center", + dataIndex: 'annualid_dictText' + }, ]; // 高级查询数据