Browse Source

新增字典顺序值校验,签卡结果同步统计表

yangyue 1 year ago
parent
commit
759249a5e6

+ 6 - 0
duty-service/src/main/java/cn/com/taiji/duty/controller/DutyDictDataController.java

@@ -100,6 +100,12 @@ public class DutyDictDataController {
         if (one != null) {
             return AjaxResult.error("字典值:"+dict.getDictValue()+"已存在!");
         }
+        List<DutyDictData> list = dictDataService.list(new LambdaQueryWrapper<DutyDictData>()
+                .eq(DutyDictData::getDictType, dict.getDictType())
+                .eq(DutyDictData::getDictSort, dict.getDictSort()));
+        if (list != null && list.size() > 0) {
+            return AjaxResult.error("顺序值:"+dict.getDictSort()+"已存在!");
+        }
         // dict.setCreateBy(getUsername());
         return dictDataService.insertDictData(dict) > 0 ? AjaxResult.success() : AjaxResult.error();
     }

+ 22 - 13
duty-service/src/main/java/cn/com/taiji/duty/service/impl/DutySignInRecordServiceImpl.java

@@ -1,14 +1,8 @@
 package cn.com.taiji.duty.service.impl;
 
-import cn.com.taiji.duty.model.DutyAccount;
-import cn.com.taiji.duty.model.DutyOperLog;
-import cn.com.taiji.duty.model.DutySignInRecord;
+import cn.com.taiji.duty.model.*;
 import cn.com.taiji.duty.mapper.DutySignInRecordMapper;
-import cn.com.taiji.duty.model.DutySignInRecordVo;
-import cn.com.taiji.duty.service.IDutyAccountService;
-import cn.com.taiji.duty.service.IDutyConfigService;
-import cn.com.taiji.duty.service.IDutyOperLogService;
-import cn.com.taiji.duty.service.IDutySignInRecordService;
+import cn.com.taiji.duty.service.*;
 import cn.com.taiji.duty.utils.JwtUtils;
 import cn.com.taiji.duty.utils.StringUtils;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -57,6 +51,9 @@ public class DutySignInRecordServiceImpl extends ServiceImpl<DutySignInRecordMap
     @Autowired
     private IDutyOperLogService operLogService;
 
+    @Autowired
+    private IDutyStatisticsService statisticsService;
+
     @Override
     public DutySignInRecord search(Long deptId) {
         return signInRecordMapper.search(deptId);
@@ -107,6 +104,8 @@ public class DutySignInRecordServiceImpl extends ServiceImpl<DutySignInRecordMap
         //     signInRecord.setId(signOut.getId());
         //     return this.updateById(signInRecord);
         // }
+        DutySignInRecord signOut = signInRecordMapper.queryByAccountId(signInRecord.getDeptId(),2,new Date());
+        DutySignInRecord sign = signInRecordMapper.queryByAccountId(signInRecord.getDeptId(),1,new Date());
 
         // 创建指定的时间
         LocalTime time = LocalTime.of(12, 0, 0);
@@ -118,7 +117,6 @@ public class DutySignInRecordServiceImpl extends ServiceImpl<DutySignInRecordMap
         String date = df.format(localDate);
         boolean before = nowTime.isAfter(time);
         if (before) {
-            DutySignInRecord signOut = signInRecordMapper.queryByAccountId(signInRecord.getDeptId(),2,new Date());
             signInRecord.setType("2");
             String signEndTime = configService.selectConfigByKey("sign.end.time");
             LocalTime localTime = LocalTime.parse(signEndTime, formatter);
@@ -132,7 +130,6 @@ public class DutySignInRecordServiceImpl extends ServiceImpl<DutySignInRecordMap
                 signInRecord.setId(signOut.getId());
             }
         } else {
-            DutySignInRecord sign = signInRecordMapper.queryByAccountId(signInRecord.getDeptId(),1,new Date());
             String signBeginTime = configService.selectConfigByKey("sign.begin.time");
             LocalTime localTime = LocalTime.parse(signBeginTime, formatter);
             boolean after = nowTime.isAfter(localTime);
@@ -153,7 +150,6 @@ public class DutySignInRecordServiceImpl extends ServiceImpl<DutySignInRecordMap
                     }
                     signInRecord.setId(sign.getId());
                 } else {
-                    DutySignInRecord signOut = signInRecordMapper.queryByAccountId(signInRecord.getDeptId(), 2, new Date());
                     signInRecord.setType("2");
                     String signEndTime = configService.selectConfigByKey("sign.end.time");
                     LocalTime localEndTime = LocalTime.parse(signEndTime, formatter);
@@ -178,10 +174,23 @@ public class DutySignInRecordServiceImpl extends ServiceImpl<DutySignInRecordMap
             operLog.setOperType("7");
         }
         operLogService.saveOperLog(operLog);
+        boolean boo;
         if (StringUtils.isNull(signInRecord.getId())) {
-            return this.save(signInRecord);
+            boo = this.save(signInRecord);
+        } else {
+            boo = this.updateById(signInRecord);
+        }
+        if (boo) {
+            if ("2".equals(signInRecord.getType()) && "1".equals(signInRecord.getStatus()) && sign != null && "1".equals(sign.getStatus())) {
+                DutyStatistics statistics = new DutyStatistics();
+                statistics.setStatus("1");
+                statisticsService.update(statistics, new LambdaQueryWrapper<DutyStatistics>()
+                        .eq(DutyStatistics::getDeptId,signInRecord.getDeptId())
+                        .eq(DutyStatistics::getTime,df.format(LocalDate.now()))
+                        .eq(DutyStatistics::getType,"1"));
+            }
         }
-        return this.updateById(signInRecord);
+        return boo;
     }
 
     @Override