ysh преди 3 години
родител
ревизия
c27de76893

+ 36 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/controller/viewClockInController.java

@@ -35,6 +35,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.system.base.controller.JeecgController;
 
+import org.jeecg.modules.workOvertime.mapper.workOvertimeMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
@@ -60,6 +61,8 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 	 private IAttendanceService attendanceService;
 	 @Autowired
 	 private IShiftService shiftService;
+	 @Autowired
+	 private workOvertimeMapper overtimeMapper;
 
 //	 public List<Map> getMap(){
 //		 LambdaQueryWrapper<Shift> query = new LambdaQueryWrapper<Shift>();
@@ -96,11 +99,37 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 		 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 		 Attendance attendance = new Attendance();
-		 String shiftTimeS = jsonObject.get("shiftTimeS").toString();
+
+		 String shiftTimeS = jsonObject.get("shiftTimeS").toString();//校准后时间
 		 String shiftTimeX = jsonObject.get("shiftTimeX").toString();
+		 if(jsonObject.get("shiftTimeSYs") != null && jsonObject.get("shiftTimeSYs") != ""){
+			 String shiftTimeSYs = jsonObject.get("shiftTimeSYs").toString();//校准前时间
+		 	 //compareTo()方法的返回值,date1小于date2返回-1,date1大于date2返回1,相等返回0
+			 int compareTo = sdf.parse(shiftTimeS).compareTo(sdf.parse(shiftTimeSYs));
+			 if(compareTo != -1){
+				 return Result.error("最早打卡时间不能早于已有打卡时间");
+			 }
+		 }
+
+		 if(jsonObject.get("shiftTimeXYs") != null && jsonObject.get("shiftTimeXYs") != ""){
+			 String shiftTimeXYs = jsonObject.get("shiftTimeXYs").toString();
+		 	 //compareTo()方法的返回值,date1小于date2返回-1,date1大于date2返回1,相等返回0
+			 int compareTo = sdf.parse(shiftTimeX).compareTo(sdf.parse(shiftTimeXYs));
+			 if(compareTo != 1){
+				 return Result.error("最迟打卡时间不能晚于已有打卡时间");
+			 }
+		 }
+		 int compareTo1 = sdf.parse(shiftTimeS).compareTo(sdf.parse(shiftTimeX));
+		 if(compareTo1 == 0){
+			 return Result.error("最早和最迟打卡时间不能相同");
+		 }
+		 if(compareTo1 == 1){
+			 return Result.error("最早打卡时间不能晚于最迟打卡时间");
+		 }
+
 		 String username = jsonObject.get("username").toString();
 		 attendance.setUserId(username);
-		 attendance.setNotes("手工校准"+user.getRealname());
+		 attendance.setNotes("手工校准 "+user.getRealname());
 		 attendance.setUserDate(sdf.parse(shiftTimeS));
 		 attendance.setCheckinType("上班打卡");
 		 attendance.setExceptionType("正常");
@@ -113,13 +142,17 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 //		 if(jsonObject.get("setInfo") != null){
 //		 	attendance2.setSetInfo(jsonObject.get("setInfo").toString());
 //		 }
-		 attendance2.setNotes("手工校准"+user.getRealname());
+		 attendance2.setNotes("手工校准 "+user.getRealname());
 		 attendance2.setUserId(username);
 		 attendance2.setUserDate(sdf.parse(shiftTimeX));
 		 attendance2.setCheckinType("下班打卡");
 		 attendance2.setExceptionType("正常");
 		 attendanceService.save(attendance2);
+
+		 String viewDate = jsonObject.get("viewDate").toString();//校准后时间
+		 overtimeMapper.delAttendanceByUser(username,viewDate);
 		 return Result.OK("校准成功!");
+
 //		 return "校准成功";
 
 	 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/entity/ViewClockIn.java

@@ -30,6 +30,8 @@ public class ViewClockIn {
 	@TableField(exist = false)
 	private String allDate;//当月所有日期
 	private String ifwork;//固定班次是否需要考勤 (0不需要,其他需要)
+	private String jzTime;//最后校准时间
+	private String jzBy;//最后校准人
 
 	private String pkId;//临时主键 (例:100131&2021-12-01)
 	/**真实姓名*/

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/mapper/xml/viewClockInMapper.xml

@@ -48,7 +48,7 @@
         and (
                 b.lateTime_s &lt; 0 or b.lateTime_x > 0
                 || (b.ifwork !=0 and attendance_Count &lt; 2 and b.name is not null)
-                || (b.ifwork !=0 and b.name is not null and b.name != '' and (b.goto_time is null || b.goto_time = '' ||  b.goto_time = null))
+                || ((b.ifwork is null or b.ifwork !=0) and b.name is not null and b.name != '' and (b.goto_time is null || b.goto_time = '' ||  b.goto_time = null))
                 || b.duration is not null
             )
 
@@ -71,7 +71,7 @@
         and (
             b.lateTime_s &lt; 0 or b.lateTime_x > 0
             || (b.ifwork !=0 and attendance_Count &lt; 2 and b.name is not null)
-            || (b.ifwork !=0 and b.name is not null and b.name != '' and (b.goto_time is null || b.goto_time = '' ||  b.goto_time = null))
+            || ((b.ifwork is null or b.ifwork !=0) and b.name is not null and b.name != '' and (b.goto_time is null || b.goto_time = '' ||  b.goto_time = null))
             || b.duration is not null
 
             )

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/workOvertime/mapper/workOvertimeMapper.java

@@ -20,4 +20,11 @@ public interface workOvertimeMapper extends BaseMapper<workOvertime> {
 
     List<workOvertime>getworkList(Page<workOvertime> page,@Param("name")String name,@Param("code")String code,@Param("startDate")String startDate,@Param("endDate")String endDate);
 
+    /**
+     * 删除无效打卡信息
+     * @param userId
+     * @param viewDate
+     * @return
+     */
+    int delAttendanceByUser(@Param("userId")String userId,@Param("viewDate")String viewDate);
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/workOvertime/mapper/xml/workOvertimeMapper.xml

@@ -29,4 +29,10 @@
         </if>
 order by a.commit_date desc
     </select>
+
+    <update id="delAttendanceByUser">
+        update geke_attendance set del_flag='1'
+        where user_id = #{userId} and DATE_FORMAT(user_date,'%Y-%m-%d') = #{viewDate}
+        and exception_type = '未打卡'
+    </update>
 </mapper>