ysh 3 роки тому
батько
коміт
c8f824fec8

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

@@ -387,7 +387,7 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 				 return Result.error("不能操作未发生的考勤月份");
 			 }
 
-			 String[] date = nowDate.split("-");
+//			 String[] date = nowDate.split("-");
 			 String userIds = jsonObject.getString("userIds");
 			 List<String> userList = new ArrayList<>();
 			 if(!StringUtil.isNullOrEmpty(userIds)){
@@ -404,90 +404,10 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 				 }
 			 }
 
-			 List<bdClockinMonth> list = bdClockinMonthService.selectByMonth(nowDate,userList);
-
-//			 List<bdClockinMonth> list2 = bdClockinMonthService.selectSyByMonth(nowDate,userList);
-
-			 if(list.size() == 0){
-				 return Result.error("当前月份没有考勤数据,无法生成月报!");
-			 }
-
-			 bdClockinMonthService.deleteByMonth(nowDate,userList);
-			 for(bdClockinMonth o:list){
-
-			 	if(o.getSyU8() != null && (o.getSyU8().equals(1) || o.getSyU8() == 1)){
-					System.out.println(o.getPersonName());
-			 		continue;
-				}
-
-			 	if(!StringUtil.isNullOrEmpty(o.getDepartId())){
-			 		String[] dept = o.getDepartId().split(",");
-			 		if(dept.length > 0){
-			 			o.setDepartId(dept[0]);
-					}
-				}
-
-			 	o.setMonthTime(nowDate);
-			 	o.setYears(date[0]);
-			 	o.setMonths(date[1]);
-
-				o.setWorkDay("21.75");
-
-
-				 //正式工	101
-				 //实习生	103
-//			 劳务工	104
-//			 劳务外包5+2	105
-//			 劳务外包6+1	106
-//			 顾问	102
-				 // 员工为正式,实习,劳务加班付薪时,如果没匹配到工资倍数,则默认两倍;匹配到工资倍数则按照倍数算薪;其他员工除非能匹配到工资倍数,否则不能付薪只能调休
-//				 String cate = o.getCategory();
-//				 if(!cate.equals("101") && !cate.equals("103") && !cate.equals("104")){
-//					 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-//					 String thisDate = null;
-//					 if(w.equals("1")){
-//						 thisDate = jsonObject.get("viewDate1").toString();
-//					 }else{
-//						 thisDate = jsonObject.get("viewDate").toString();
-//					 }
-//					 List<StatutoryLeave> list = statutoryLeaveService.list();
-//					 for(StatutoryLeave o:list){
-//						 if(o.getType().equals("1")){//班
-//							 Date begin = o.getStartDate();
-//							 Date end = o.getEndDate();
-//							 if(!isEffectiveDate(sdf.parse(thisDate),begin,end) ){
-//								 return Result.error("当前用户的加班,只能用于累计调休");
-//							 }
-//						 }
-//					 }
-//
-//				 }
-//
-
-				//是否免打卡 1免打卡
-				if(StringUtil.isNullOrEmpty(o.getIsAttendance()) && o.getIsAttendance().equals("1")){
-					 o.setWorkDayReal("21.75");//真实考勤天数
-				}else{
-					BigDecimal workDay = new BigDecimal("21.75").setScale(2,BigDecimal.ROUND_HALF_UP);;
-					if(!StringUtil.isNullOrEmpty(o.getHolidayTimeBj()) && !o.getHolidayTimeBj().equals("0")){
-						workDay = workDay.subtract(new BigDecimal(o.getHolidayTimeBj()));
-					}
-					if(!StringUtil.isNullOrEmpty(o.getHolidayTimeSj()) && !o.getHolidayTimeSj().equals("0")){
-						workDay = workDay.subtract(new BigDecimal(o.getHolidayTimeSj()));
-					}
-					if(!StringUtil.isNullOrEmpty(o.getMissingNum()) && !o.getMissingNum().equals("0")){
-						workDay = workDay.subtract(new BigDecimal(o.getMissingNum()));
-					}
-					o.setWorkDayReal(workDay.toString());//真实考勤天数
-
-				}
-
-				 bdClockinMonthService.save(o);
-			 }
-
+			 bdClockinMonthService.handleInfo(nowDate,userList);
 		 } catch (Exception e) {
 			 log.error(e.getMessage(), e);
-			 return Result.error("月报生成失败,请稍后再试!");
+			 return Result.error("月报生成失败!"+e.getMessage());
 		 }
 		 return Result.OK("true");
 	 }

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

@@ -37,6 +37,18 @@ public class ExportClockDay {
 	@Excel(name = "最迟打卡时间", width = 25)
 	private String closingTime;
 
+	@Excel(name = "上班1", width = 25)
+	private String oneTime;
+
+	@Excel(name = "下班1", width = 25)
+	private String twoTime;
+
+	@Excel(name = "上班2", width = 25)
+	private String threeTime;
+
+	@Excel(name = "下班2", width = 25)
+	private String fourTime;
+
 	@Excel(name = "打卡次数", width = 15)
 	private String attendanceCount;
 

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

@@ -53,12 +53,24 @@ public class ExportClockInfo {
 	@Excel(name = "状态", width = 15)
 	private String state;
 
-	@Excel(name = "最早打卡时间", width = 25)
+	@Excel(name = "最早", width = 25)
 	private String gotoTime;
 
-	@Excel(name = "最迟打卡时间", width = 25)
+	@Excel(name = "最", width = 25)
 	private String closingTime;
 
+	@Excel(name = "上班1", width = 25)
+	private String oneTime;
+
+	@Excel(name = "下班1", width = 25)
+	private String twoTime;
+
+	@Excel(name = "上班2", width = 25)
+	private String threeTime;
+
+	@Excel(name = "下班2", width = 25)
+	private String fourTime;
+
 	@Excel(name = "打卡次数", width = 15)
 	private String attendanceCount;
 

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

@@ -66,6 +66,10 @@ public class ViewClockIn {
 	 * 班次中的上班时间(不含日期,仅时分)
 	 */
 	private String shiftRealTimeS;
+	/**
+	 * 班次中的上班时间(不含日期,仅时分)
+	 */
+	private String shiftRealTime2S;
 
 	/**班次中具体下班时间(含日期,时分)*/
 	@Excel(name = "下班时间", width = 15)
@@ -75,6 +79,10 @@ public class ViewClockIn {
 	 * 班次中的下班时间(不含日期,仅时分)
 	 */
 	private String shiftRealTimeX;
+	/**
+	 * 班次中的下班时间(不含日期,仅时分)
+	 */
+	private String shiftRealTime2X;
 
 	/**latetimeS 实际上班打卡时间 与 要求上班时间相差的分钟数,为负数,则表示打卡时间比上班时间晚,正数则表示比上班时间早 */
 	@Excel(name = "迟到分钟数", width = 15)
@@ -107,11 +115,29 @@ public class ViewClockIn {
 	private String weekDate;
 
 	/**gotoTime*/
-	@Excel(name = "员工主动上班打卡时间", width = 15)
+	@Excel(name = "上班1", width = 15)
+	@ApiModelProperty(value = "oneTime")
+	private String oneTime;
+	/**gotoTime*/
+	@Excel(name = "下班1", width = 15)
+	@ApiModelProperty(value = "twoTime")
+	private String twoTime;
+	/**gotoTime*/
+	@Excel(name = "上班2", width = 15)
+	@ApiModelProperty(value = "threeTime")
+	private String threeTime;
+	/**gotoTime*/
+	@Excel(name = "下班2", width = 15)
+	@ApiModelProperty(value = "fourTime")
+	private String fourTime;
+
+
+	/**gotoTime*/
+	@Excel(name = "员工主动上班打卡时间(最早)", width = 15)
     @ApiModelProperty(value = "gotoTime")
 	private String gotoTime;
 	/**closingTime*/
-	@Excel(name = "员工主动下班打卡时间", width = 15)
+	@Excel(name = "员工主动下班打卡时间(最晚)", width = 15)
     @ApiModelProperty(value = "closingTime")
 	private String closingTime;
 	/**gotoState*/

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

@@ -5,6 +5,7 @@ import java.util.Map;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.geke.statutoryleave.entity.StatutoryLeave;
 import org.jeecg.modules.viewClockIn.entity.BdClose;
 import org.jeecg.modules.viewClockIn.entity.bdClockinMonth;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -91,4 +92,10 @@ public interface bdClockinMonthMapper extends BaseMapper<bdClockinMonth> {
      * @return
      */
     List<BdClose> selectClose();
+
+    /**
+     * 根据年月查询当月的法定假期
+     * @return
+     */
+    List<StatutoryLeave> getStatutoryLeave(String date);
 }

+ 8 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/mapper/xml/bdClockinMonthMapper.xml

@@ -25,7 +25,7 @@
         end lateTime_x,
         case when set_info ='付薪' then duration else 0 end
         duration,
-        case when shift_name is not null and (goto_time is null or goto_time = '') then 1 else 0 end missingNum,
+        case when shift_name is not null and (goto_time is null) then 1 else 0 end missingNum,
 
         TIMESTAMPDIFF(hour,holiday_start_date,holiday_end_date)/24 sj_time,
         holiday_type,holiday_start_date,holiday_end_date from view_clock_in_1
@@ -244,4 +244,11 @@
         select * from bd_close
     </select>
 
+    <select id="getStatutoryLeave" resultType="org.jeecg.modules.geke.statutoryleave.entity.StatutoryLeave">
+        select * from geke_statutory_leave where del_flag = '0'
+        <if test="date!=null and ''!=date">
+            and date_format(#{date},'%Y-%m') BETWEEN date_format(start_date,'%Y-%m') AND date_format(end_date,'%Y-%m')
+        </if>
+    </select>
+
 </mapper>

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

@@ -101,6 +101,7 @@
         or (b.rule_type = 2 and b.attendance_count &lt; 2 and b.shift_real_time_s is not null) <!-- 班次上下班,需要打卡(固定班时休息日),打卡次数不足,当天有排班-->
         or (b.rule_type = 2 and b.shift_real_time_s is not null and b.goto_time is null) <!-- 班次上下班,需要打卡,当天有排班,没有打卡记录-->
         or (duration is not null and (work_overtime > 0 or work_overtime is null))  <!-- 有加班信息,打卡时间早于加班申请时间-->
+        or (shift_type = 1 and (latetime1_s &lt; 0 or latetime1_x > 0 or latetime2_s &lt; 0 or latetime2_x > 0))  <!-- 分段打卡-->
         and b.set_info > 0 ) and b.error_state is null
 
 
@@ -137,6 +138,8 @@
                 or (b.rule_type = 2 and b.attendance_count &lt; 2 and b.shift_real_time_s is not null) <!-- 班次上下班,需要打卡(固定班时休息日),打卡次数不足,当天有排班-->
                 or (b.rule_type = 2 and b.shift_real_time_s is not null and b.goto_time is null) <!-- 班次上下班,需要打卡,当天有排班,没有打卡记录-->
                 or (duration is not null and (work_overtime > 0 or work_overtime is null))  <!-- 有加班信息,打卡时间早于加班申请时间-->
+                or (shift_type = 1 and (latetime1_s &lt; 0 or latetime1_x > 0 or latetime2_s &lt; 0 or latetime2_x > 0))  <!-- 分段打卡-->
+
                 and b.set_info > 0 ) and b.error_state is null
 
                 group by b.username

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/service/IbdClockinMonthService.java

@@ -17,6 +17,12 @@ import java.util.Map;
  */
 public interface IbdClockinMonthService extends IService<bdClockinMonth> {
 
+    /**
+     * 生成月报表
+     * @return
+     */
+    String handleInfo(String String,List<String> userList);
+
     List<bdClockinMonth> selectByMonth(String nowDate,List<String> userId);
 
     List<bdClockinMonth> selectAllByMonth(String nowDate,String[] userId);

+ 91 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/service/impl/bdClockinMonthServiceImpl.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.viewClockIn.service.impl;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import io.netty.util.internal.StringUtil;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.UUIDGenerator;
+import org.jeecg.modules.geke.statutoryleave.entity.StatutoryLeave;
 import org.jeecg.modules.viewClockIn.entity.BdClose;
 import org.jeecg.modules.viewClockIn.entity.ViewClockIn;
 import org.jeecg.modules.viewClockIn.entity.bdClockinMonth;
@@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.math.BigDecimal;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -32,6 +35,94 @@ public class bdClockinMonthServiceImpl extends ServiceImpl<bdClockinMonthMapper,
     @Autowired
     private bdClockinMonthMapper clockinMonthMapper;
 
+    /**
+     * 生成月报表
+     * @return
+     */
+    public String handleInfo(String nowDate,List<String> userList){
+        List<bdClockinMonth> list = clockinMonthMapper.selectByMonth(nowDate,userList);
+        if(list.size() == 0){
+            throw new RuntimeException("当前月份没有考勤数据,无法生成月报!");
+        }
+
+        String[] date = nowDate.split("-");
+        clockinMonthMapper.deleteByMonth(nowDate,userList);//删除之前生成的月报
+        List<StatutoryLeave>  leaveList = clockinMonthMapper.getStatutoryLeave(nowDate);
+        for(bdClockinMonth o:list){
+
+            if(o.getSyU8() != null && (o.getSyU8().equals(1) || o.getSyU8() == 1)){
+                System.out.println(o.getPersonName());
+                continue;
+            }
+
+            if(!StringUtil.isNullOrEmpty(o.getDepartId())){
+                String[] dept = o.getDepartId().split(",");
+                if(dept.length > 0){
+                    o.setDepartId(dept[0]);
+                }
+            }
+
+            o.setMonthTime(nowDate);
+            o.setYears(date[0]);
+            o.setMonths(date[1]);
+
+            o.setWorkDay("21.75");
+
+//				正式工		101
+//				实习生		103
+//			 	劳务工		104
+//			 	劳务外包5+2	105
+//			 	劳务外包6+1	106
+//			 	顾问			102
+// 				员工为正式,实习,劳务加班付薪时,如果没匹配到工资倍数,则默认两倍;匹配到工资倍数则按照倍数算薪;其他员工除非能匹配到工资倍数,否则不能付薪只能调休
+//				 String cate = o.getCategory();
+//				 if(!cate.equals("101") && !cate.equals("103") && !cate.equals("104")){
+//					 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//					 String thisDate = null;
+//					 if(w.equals("1")){
+//						 thisDate = jsonObject.get("viewDate1").toString();
+//					 }else{
+//						 thisDate = jsonObject.get("viewDate").toString();
+//					 }
+//					 List<StatutoryLeave> list = statutoryLeaveService.list();
+//					 for(StatutoryLeave o:list){
+//						 if(o.getType().equals("1")){//班
+//							 Date begin = o.getStartDate();
+//							 Date end = o.getEndDate();
+//							 if(!isEffectiveDate(sdf.parse(thisDate),begin,end) ){
+//								 return Result.error("当前用户的加班,只能用于累计调休");
+//							 }
+//						 }
+//					 }
+//
+//				 }
+            // 附加考勤天数(加班数据、节假日上班多倍工资)
+            BigDecimal addDays = new BigDecimal("0");
+
+            //是否免打卡 1免打卡
+            if(StringUtil.isNullOrEmpty(o.getIsAttendance()) && o.getIsAttendance().equals("1")){
+                o.setWorkDayReal("21.75");//真实考勤天数
+            }else{
+                BigDecimal workDay = new BigDecimal("21.75").setScale(2,BigDecimal.ROUND_HALF_UP);;
+                if(!StringUtil.isNullOrEmpty(o.getHolidayTimeBj()) && !o.getHolidayTimeBj().equals("0")){
+                    workDay = workDay.subtract(new BigDecimal(o.getHolidayTimeBj()));
+                }
+                if(!StringUtil.isNullOrEmpty(o.getHolidayTimeSj()) && !o.getHolidayTimeSj().equals("0")){
+                    workDay = workDay.subtract(new BigDecimal(o.getHolidayTimeSj()));
+                }
+                if(!StringUtil.isNullOrEmpty(o.getMissingNum()) && !o.getMissingNum().equals("0")){
+                    workDay = workDay.subtract(new BigDecimal(o.getMissingNum()));
+                }
+                o.setWorkDayReal(workDay.toString());//真实考勤天数
+
+            }
+            o.setId(UUIDGenerator.generate());
+            clockinMonthMapper.insert(o);
+        }
+
+        return "true";
+    }
+
     public List<bdClockinMonth> selectByMonth(String nowDate,List<String> userId){
         return clockinMonthMapper.selectByMonth(nowDate,userId);
     }