浏览代码

研发打卡修改

anderx 2 年之前
父节点
当前提交
5ffb1b974b

+ 6 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -78,8 +78,9 @@ public class ProjectTaskController extends BaseController {
     public AjaxResult addRecord( @RequestBody ProjectStaffRecord in){
         Long userId = SecurityUtils.getUserId();
         in.setAid(userId);
-        if (projectStaffRecordService.addCheckMaxDuration(in)){
-            return AjaxResult.error("每天工时超出最大限制");
+        AjaxResult ajaxResult = projectStaffRecordService.addCheckMaxDuration(in);
+        if (ajaxResult.isError()){
+            return ajaxResult;
         }
         return projectStaffRecordService.add(in);
     }
@@ -94,8 +95,9 @@ public class ProjectTaskController extends BaseController {
     public AjaxResult updateRecord( @RequestBody ProjectStaffRecord in){
         Long userId = SecurityUtils.getUserId();
         in.setAid(userId);
-        if (projectStaffRecordService.updateCheckMaxDuration(in)){
-            return AjaxResult.error("每天工时超出最大限制");
+        AjaxResult ajaxResult = projectStaffRecordService.updateCheckMaxDuration(in);
+        if (ajaxResult.isError()){
+            return ajaxResult;
         }
         return projectStaffRecordService.update(in);
     }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectStaffRecordService.java

@@ -20,9 +20,9 @@ public interface ProjectStaffRecordService {
 
     AjaxResult myDuration(Long id);
 
-    boolean addCheckMaxDuration(ProjectStaffRecord in);
+    AjaxResult addCheckMaxDuration(ProjectStaffRecord in);
 
-    boolean updateCheckMaxDuration(ProjectStaffRecord in);
+    AjaxResult updateCheckMaxDuration(ProjectStaffRecord in);
 
     AjaxResult myDurationMonth(Long id);
 }

+ 12 - 9
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -87,7 +87,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     }
 
     @Override
-    public boolean addCheckMaxDuration(ProjectStaffRecord in) {
+    public AjaxResult addCheckMaxDuration(ProjectStaffRecord in) {
         BigDecimal maxDuration= new BigDecimal(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
         String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
         Boolean maxflag = Boolean.parseBoolean(maxDurationProjectFlag);
@@ -100,14 +100,15 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         BigDecimal mySum = new BigDecimal(myDuration).add(new BigDecimal(in.getDuration()));
 
         if (mySum.compareTo(maxDuration)==1){
-            log.debug(String.format("超出最大额.max=%s,my=%s",maxDuration,mySum));
-            return true;
+            String errorStr=String.format("每天工时超出最大限制,最大额[%s],当前总额[%s]",maxDuration,mySum);
+            log.debug(errorStr);
+            return AjaxResult.error(errorStr);
         }
-        return false;
+        return AjaxResult.success();
     }
 
     @Override
-    public boolean updateCheckMaxDuration(ProjectStaffRecord in) {
+    public AjaxResult updateCheckMaxDuration(ProjectStaffRecord in) {
         BigDecimal maxDuration= new BigDecimal(SecurityUtils.getLoginUser().getUser().getDept().getMaxDuration());
         String maxDurationProjectFlag = configService.selectConfigByKey("maxDurationProject");
         AtomicReference<Double> aDouble = new AtomicReference<>(0d);
@@ -132,10 +133,12 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         aDouble.updateAndGet(v -> v + in.getDuration());
         BigDecimal mySum= new BigDecimal(aDouble.toString());
         if (mySum.compareTo(maxDuration)==1){
-            log.debug(String.format("超出最大额.max=%s,my=%s",maxDuration,mySum));
-            return true;
-        }
-        return false;
+                String errorStr=String.format("每天工时超出最大限制,最大额[%s],当前总额[%s]",maxDuration,mySum);
+                log.debug(errorStr);
+                return AjaxResult.error(errorStr);
+            }
+            return AjaxResult.success();
+
     }
 
     @Override