Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

yusm 1 год назад
Родитель
Сommit
5a21a0add6

+ 0 - 27
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserWithBeisenController.java

@@ -122,33 +122,6 @@ public class UserWithBeisenController {
         return httpRespMsg;
     }
 
-    @RequestMapping("/getSwipingCardsTest")
-    public HttpRespMsg getSwipingCardsTest(String createDate){
-        HttpRespMsg httpRespMsg=new HttpRespMsg();
-        JSONArray swipingCards = BeiSenUtils.getSwipingCards(createDate,"97BF1F7DF8314F268D91E09C12772CAD","D52BE666683C408087063B422275C289DE09488E28D64B7FB4E5190C43F8AA66",1,300);
-        System.out.println("获取到的打卡数据====>"+swipingCards.toJSONString());
-        httpRespMsg.setData(swipingCards);
-        return httpRespMsg;
-    }
-
-    @RequestMapping("/getOverTimeListTest")
-    public HttpRespMsg getOverTimeListTest(String createDate){
-        HttpRespMsg httpRespMsg=new HttpRespMsg();
-        JSONArray swipingCards = BeiSenUtils.getOverTimeList(createDate,"97BF1F7DF8314F268D91E09C12772CAD","D52BE666683C408087063B422275C289DE09488E28D64B7FB4E5190C43F8AA66",1,100);
-        System.out.println("获取到的加班那数据====>"+swipingCards.toJSONString());
-        httpRespMsg.setData(swipingCards);
-        return httpRespMsg;
-    }
-
-    @RequestMapping("/getAttendanceStatisticsTest")
-    public HttpRespMsg getAttendanceStatisticsTest(String startDate,String endDate){
-        HttpRespMsg httpRespMsg=new HttpRespMsg();
-        JSONArray swipingCards = BeiSenUtils.getAttendanceStatistics(startDate,endDate,"97BF1F7DF8314F268D91E09C12772CAD","D52BE666683C408087063B422275C289DE09488E28D64B7FB4E5190C43F8AA66",1,100);
-        System.out.println("获取到的考勤数据====>"+swipingCards.toJSONString());
-        httpRespMsg.setData(swipingCards);
-        return httpRespMsg;
-    }
-
 
     @RequestMapping("/syncAttendanceFromBeisen")
     @Transactional(rollbackFor = Exception.class)

+ 15 - 23
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -4204,6 +4204,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
         Integer companyId = user.getCompanyId();
+        Company company = companyMapper.selectById(companyId);
         //String[] weekDayCHN = {"周一","周二","周三","周四","周五","周六","周日"};
         String[] weekDayCHN = {MessageUtils.message("week.Monday"),MessageUtils.message("week.Tuesday"),MessageUtils.message("week.Wednesday"),MessageUtils.message("week.Thursday"),MessageUtils.message("week.Friday"),MessageUtils.message("week.Saturday"),MessageUtils.message("week.Sunday")};
         HttpRespMsg msg = new HttpRespMsg();
@@ -4304,9 +4305,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         //对于全部的用户已填日报,对比请假的数据,进行填充
         TimeType timeType = timeTypeMapper.selectById(companyId);
-        //获取钉钉的请假日期
+        //获取请假数据(本系统内的、钉钉和泛微同步的)
         List<LeaveSheet> leaveSheets = null;
-        if (timeType.getSyncDingding() == 1||timeType.getSyncFanwei()==1) {
+        if (timeType.getSyncDingding() == 1||timeType.getSyncFanwei()==1 || company.getPackageOa() == 1) {
             List<String> userIds = new ArrayList<>();
             for (UserMonthWork work : userMonthWorks) {
                 userIds.add(work.userId);
@@ -4326,6 +4327,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
             }
 
+            //处理企业微信的请假数据
             curUserCorpTime.forEach(corpTime->{
                 java.sql.Date leaveDate = (java.sql.Date)corpTime.get("create_date");
                 String leaveDateStr = sdf.format(leaveDate);
@@ -4344,7 +4346,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
             });
             //钉钉请假的数据
-            if ((timeType.getSyncDingding() == 1 || timeType.getSyncFanwei()==1)&& leaveSheets != null && leaveSheets.size() > 0) {
+            if ((timeType.getSyncDingding() == 1 || timeType.getSyncFanwei()==1 || company.getPackageOa() == 1)&& leaveSheets != null && leaveSheets.size() > 0) {
                 List<LeaveSheet> curUserLeaveList = leaveSheets.stream().filter(leave -> leave.getOwnerId().equals(userMonthWork.userId)).collect(Collectors.toList());
                 curUserLeaveList.forEach(leave->{
                     LocalDate startDate1 = leave.getStartDate();
@@ -4364,11 +4366,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                                 find.get().put("workingTime", newStr);
                             }
                         } else {
-                            //没有对应的打卡记录,直接加上当天请假
-                            Map<String, Object> leaveMap = new HashMap<>();
-                            leaveMap.put("createDate", leaveDateStr);
-                            leaveMap.put("workingTime", MessageUtils.message("leave.leaveOfDay"));
-                            worktimeList.add(leaveMap);
+                            //没有对应的打卡记录,直接加上当天请假,该日为工作日的情况下,标记为请假
+                            if (WorkDayCalculateUtils.isWorkDay(workDate)) {
+                                Map<String, Object> leaveMap = new HashMap<>();
+                                leaveMap.put("createDate", leaveDateStr);
+                                leaveMap.put("workingTime", MessageUtils.message("leave.leaveOfDay"));
+                                worktimeList.add(leaveMap);
+                            }
                         }
 
                         if (workDate.isEqual(endDate1)) {
@@ -4412,17 +4416,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         List<UserMonthWork> userMonthWorks = (List<UserMonthWork>) map.get("list");
         List<List<String>> dataList = new ArrayList<>();
         List<String> titleList = new ArrayList<>();
-//        titleList.add("序号");
-//        titleList.add("姓名");
-//        titleList.add("部门");
-        titleList.add(MessageUtils.message("entry.serialNo"));
-        titleList.add(MessageUtils.message("entry.name"));
-        titleList.add(MessageUtils.message("excel.department"));
+        titleList.add(MessageUtils.message("entry.serialNo"));//序号
+        titleList.add(MessageUtils.message("entry.name"));//姓名
+        titleList.add(MessageUtils.message("excel.department"));//部门
         days.forEach(d->{
-//            String dateStr = (String)d.get("date");
-//            LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-//            String chn = weekDayCHN[date.getDayOfWeek().getValue()-1];
-//            String m = ""+date.getMonthValue();
             titleList.add((String)d.get("label"));
         });
         dataList.add(titleList);
@@ -4432,7 +4429,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             dataItem.add(""+(i+1));
 
             List<Map<String, Object>> worktimeList = userMonthWork.worktimeList;
-            //dataItem.add(userMonthWork.name+(worktimeList.size()==0?"(未填)":""));
             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                 dataItem.add("$userName="+(userMonthWork.corpwxUserId==null?"":userMonthWork.corpwxUserId)+"$"+(worktimeList.size()==0?"("+MessageUtils.message("entry.noFill")+")":""));
                 dataItem.add("$departmentName="+(userMonthWork.departmentName==null?"":userMonthWork.departmentName)+"$");
@@ -4443,10 +4439,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             DecimalFormat decimalFormat = new DecimalFormat("0.0");
             //找到那一天的工作时间
             days.forEach(d->{
-//                String dateStr = startDate;
-//                LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-//                //计算当前遍历到的那一天
-//                date = date.plusDays(d-1);
                 final String fDateStr = (String)d.get("date");
                 Optional<Map<String, Object>> op = worktimeList.stream().filter(m -> ((String) m.get("createDate")).equals(fDateStr)).findFirst();
                 if (op.isPresent()) {

+ 110 - 20
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -52,6 +52,7 @@ import java.util.*;
 import java.util.concurrent.*;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
+import java.util.stream.Stream;
 
 import static org.apache.logging.log4j.message.ParameterizedMessage.format;
 
@@ -1997,36 +1998,125 @@ public class TimingTask {
     //每天凌晨  2:30 获取前一天时间增量的人员数据  BeiSenHR---->工时管家  针对威派格
     @Scheduled(cron = "0 30 2 ? * *")
     public void getByTimeWindow(){
+        if(isDev){
+            return;
+        }
         List<UserWithBeisen> allBeisenList = userWithBeisenService.list(new LambdaQueryWrapper<UserWithBeisen>().eq(UserWithBeisen::getCompanyId, 936));
         List<UserWithBeisen> userWithBeisenList=new ArrayList<>();
         LocalDate now=LocalDate.now();
         DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
         String time=df.format(now.plusDays(1));
-        BeisenConfig beisenConfig = beisenConfigMapper.selectById(936);
-        if(beisenConfig!=null){
-            List<JSONArray> byTimeWindow = BeiSenUtils.getByTimeWindow("",time,time,beisenConfig.getAppKey(),beisenConfig.getAppSecret());
-            for (JSONArray array : byTimeWindow) {
-                for (int i = 0; i < array.size(); i++) {
-                    UserWithBeisen userWithBeisen=new UserWithBeisen();
-                    JSONObject targetItem = array.getJSONObject(i);
-                    JSONObject employeeInfo = targetItem.getJSONObject("employeeInfo");
-                    JSONObject recordInfo = targetItem.getJSONObject("recordInfo");
-                    userWithBeisen.setCompanyId(936);
-                    userWithBeisen.setJobNumber(recordInfo.getString("jobNumber"));
-                    userWithBeisen.setMobilePhone(employeeInfo.getString("mobilePhone"));
-                    userWithBeisen.setName(employeeInfo.getString("name"));
-                    userWithBeisen.setUserId(employeeInfo.getString("userID"));
-                    Optional<UserWithBeisen> first = allBeisenList.stream().filter(a -> a.getUserId().equals(employeeInfo.getString("userID"))).findFirst();
-                    if(first.isPresent()){
-                        userWithBeisen.setId(first.get().getId());
+        List<BeisenConfig> beisenConfigs = beisenConfigMapper.selectList(null);
+        for (BeisenConfig beisenConfig : beisenConfigs) {
+            if(beisenConfig!=null){
+                List<JSONArray> byTimeWindow = BeiSenUtils.getByTimeWindow("",time,time,beisenConfig.getAppKey(),beisenConfig.getAppSecret());
+                for (JSONArray array : byTimeWindow) {
+                    for (int i = 0; i < array.size(); i++) {
+                        UserWithBeisen userWithBeisen=new UserWithBeisen();
+                        JSONObject targetItem = array.getJSONObject(i);
+                        JSONObject employeeInfo = targetItem.getJSONObject("employeeInfo");
+                        JSONObject recordInfo = targetItem.getJSONObject("recordInfo");
+                        userWithBeisen.setCompanyId(beisenConfig.getCompanyId());
+                        userWithBeisen.setJobNumber(recordInfo.getString("jobNumber"));
+                        userWithBeisen.setMobilePhone(employeeInfo.getString("mobilePhone"));
+                        userWithBeisen.setName(employeeInfo.getString("name"));
+                        userWithBeisen.setUserId(employeeInfo.getString("userID"));
+                        Optional<UserWithBeisen> first = allBeisenList.stream().filter(a -> a.getUserId().equals(employeeInfo.getString("userID"))).findFirst();
+                        if(first.isPresent()){
+                            userWithBeisen.setId(first.get().getId());
+                        }
+                        userWithBeisenList.add(userWithBeisen);
                     }
-                    userWithBeisenList.add(userWithBeisen);
+                }
+                if(userWithBeisenList.size()>0){
+                    userWithBeisenService.saveOrUpdateBatch(userWithBeisenList);
                 }
             }
-            if(userWithBeisenList.size()>0){
-                userWithBeisenService.saveOrUpdateBatch(userWithBeisenList);
+        }
+    }
+
+    /**
+     * 每天凌晨2:50同步前一天的北森考勤数据 暂时固定公司id(5978)针对景昱
+     * */
+    @Scheduled(cron ="0 50 2 ? * *")
+    public void syncAttendanceFromBeisen(){
+        if(isDev){
+            return;
+        }
+        DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter df1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        DateTimeFormatter df2=DateTimeFormatter.ofPattern("HH:mm");
+        String startDate=LocalDate.now().plusDays(1).format(df);
+        String endDate=LocalDate.now().plusDays(1).format(df);
+        List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, 5978));
+        List<UserWithBeisen> userWithBeisenList = userWithBeisenService.list(new LambdaQueryWrapper<UserWithBeisen>().eq(UserWithBeisen::getCompanyId, 5978));
+        BeisenConfig beisenConfig = beisenConfigMapper.selectById(5978);
+        if(beisenConfig==null){
+            return;
+        }
+        //todo 获取到指定日期的考勤数据
+        JSONArray attendanceStatistics = BeiSenUtils.getAttendanceStatistics(startDate, endDate, beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
+        //todo 获取到指定日期的加班数据
+        List<LocalDate> workDaysListInRange = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 1);
+        JSONArray allOverTimeList=new JSONArray();
+        List<UserFvTime> userFvTimeList=new ArrayList<>();
+        for (LocalDate localDate : workDaysListInRange) {
+            JSONArray overTimeList = BeiSenUtils.getOverTimeList(df.format(localDate), beisenConfig.getAppKey(), beisenConfig.getAppSecret(), 1, 100);
+            allOverTimeList.addAll(overTimeList);
+        }
+        for (LocalDate localDate : workDaysListInRange) {
+            Stream<JSONObject> swipingCardsStream = attendanceStatistics.stream().map(item -> (JSONObject) item);
+            //todo: 获取当天的考勤数据
+            List<JSONObject> swipingCardDateList = swipingCardsStream.filter(i -> LocalDateTime.parse(i.getString("SwipingCardDate"),df1).toLocalDate().equals(localDate)).collect(Collectors.toList());
+            for (JSONObject item : swipingCardDateList) {
+                //获取当前数据下的人员工号对应到工时管家
+                String cardNumber = item.getString("CardNumber");
+                Optional<User> first = userList.stream().filter(f -> f.getJobNumber().equals(cardNumber)).findFirst();
+                //todo: 获取考勤打卡时间集合
+                JSONArray times = item.getJSONArray("Times");
+                Stream<JSONObject> timeStream = times.stream().map(time -> (JSONObject) time);
+                Stream<JSONObject> timeStream1 = times.stream().map(time -> (JSONObject) time);
+                //获取最早上班打卡时间
+                List<LocalTime> minLocalTimeList = timeStream.filter(t -> t.getIntValue("Type") == 1).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
+                Optional<LocalTime> min = minLocalTimeList.stream().min(LocalTime::compareTo);
+                //获取最早上班打卡时间
+                List<LocalTime> maxLocalTimeList = timeStream1.filter(t -> t.getIntValue("Type") == 9).map(i -> LocalDateTime.parse(i.getString("ActualTime"),df1).toLocalTime()).collect(Collectors.toList());
+                Optional<LocalTime> max = maxLocalTimeList.stream().max(LocalTime::compareTo);
+                //获取最晚下班时间
+                if(first.isPresent()){
+                    boolean workDay = WorkDayCalculateUtils.isWorkDay(localDate);
+                    //todo:针对景昱 工作日默认以8小时工作制度加上加班时长 非工作日以加班时长为准
+                    Double workTime=8.0;
+                    Stream<JSONObject> overTimeStream = allOverTimeList.stream().map(elment -> (JSONObject) elment);
+                    Optional<UserWithBeisen> beisen = userWithBeisenList.stream().filter(u -> u.getJobNumber() != null && u.getJobNumber().equals(first.get().getJobNumber())).findFirst();
+                    List<JSONObject> overTimeList = overTimeStream.filter(a -> a.getString("StaffId").equals(beisen.get().getUserId())
+                            && a.getIntValue("ApproveStatus") == 2).collect(Collectors.toList());
+                    if(overTimeList.size()>0){
+                        double actualOverTimeDuration = overTimeList.stream().mapToDouble(i -> i.getDouble("ActualOverTimeDuration")).sum();
+                        if(workDay){
+                            workTime= workTime+actualOverTimeDuration;
+                        }else {
+                            workTime= actualOverTimeDuration;
+                        }
+                    }
+                    UserFvTime userFvTime=new UserFvTime();
+                    userFvTime.setWorkDate(localDate);
+                    userFvTime.setStartTime(min.isPresent()?df2.format(min.get()):"08:30");
+                    userFvTime.setEndTime(max.isPresent()?df2.format(max.get()):"17:30");
+                    userFvTime.setUserId(first.get().getId());
+                    userFvTime.setCompanyId(5978);
+                    userFvTime.setWorkHours(workTime.floatValue());
+                    UserFvTime one = userFvTimeService.getOne(new LambdaQueryWrapper<UserFvTime>().eq(UserFvTime::getCompanyId, 5978).eq(UserFvTime::getUserId, first.get().getId()).eq(UserFvTime::getWorkDate, localDate));
+                    if(one!=null){
+                        userFvTime.setId(one.getId());
+                    }
+                    userFvTimeList.add(userFvTime);
+                }
             }
         }
+        if(userFvTimeList.size()>0){
+            userFvTimeService.saveOrUpdateBatch(userFvTimeList);
+        }
     }
 
 

+ 0 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -5385,7 +5385,6 @@
                 param.stateKey = this.stateKey
                 // param.departmentId = this.user.departmentId
                 console.log(param, '《=== 导出传的参数')
-                return
                 this.http.post( this.port.report.export, param,
                 res => {
                     this.exportingData = false;

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet_deploy/auto_deploy.sh

@@ -0,0 +1 @@
+sh bkup.sh;sh copyFiles.sh

+ 2 - 0
fhKeeper/formulahousekeeper/timesheet_deploy/bkup.sh

@@ -0,0 +1,2 @@
+mysqldump -h10.1.10.33 -uroot -pMld2022@# -B man_mld > ./man_mld.sql
+echo 'db backup successful'

+ 41 - 0
fhKeeper/formulahousekeeper/timesheet_deploy/bkup_script_win.bat

@@ -0,0 +1,41 @@
+@echo 开始备份数据库。 
+set "ymd=%date:~,4%%date:~5,2%%date:~8,2%"
+ 
+@备份数据库目录 
+set "bak_path=D:\data_xxxx"
+ 
+@数据库安装目录
+set "mysql_dump_path=D:\xxxxx\mysql-winx64\bin"
+ 
+@数据库账号
+set "dbuser=xxxxxx"
+ 
+@数据库密码
+set "dbpwd=xxxxxx"
+ 
+@数据库IP地址
+set "dbip=xxx.xxx.xx.xxx"
+ 
+@数据库端口
+set "dbport=xxxx"
+ 
+@备份保存时间,单位: 天
+set "dateoutday=x"
+ 
+@备份数据库名称,如果是all则是所有的数据
+set "dbname=all"
+ 
+if "%dbname%" == "all" (
+  
+@连接数据库及要备份的库u账号、p密码、h账号IP
+"%mysql_dump_path%"\mysqldump -u%dbuser% -p%dbpwd% -h%dbip% -P%dbport% --all-databases  --set-gtid-purged=OFF --triggers --routines --events > %bak_path%\qkbf_bak%ymd%.sql  
+)else (
+  echo "++++++++++++++++++++++"%dbname%"+++++++++++++++++++++++"
+ 
+@连接数据库及要备份的库u账号、p密码、h账号IP
+"%mysql_dump_path%"\mysqldump -u%dbuser% -p%dbpwd% -h%dbip% -P%dbport% --databases %dbname% > %bak_path%\%dbname%_bak%ymd%.sql 
+)
+ 
+@echo 删除3天前备份的文件。
+forfiles /p "%bak_path%" /s /m *.sql /d -%dateoutday% /c "cmd /c del @path"
+@echo 数据库备份完成,3秒后程序退出

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet_deploy/copyFiles.sh

@@ -1,2 +1,2 @@
 \cp timesheet-3.4.0.jar /www/webapps/worktime/;\cp -rf static_pc/dist/* /www/staticproject/timesheet/;\cp -rf static_h5/dist/* /www/staticproject/timesheet_h5/;
-echo 'all files are copied successful, if there is db script, you should run sh import_sql.sh; then you can restart server with command: sh /www/webapps/worktime/restart.sh'
+echo 'all files are copied successful, if there is db script, you should run sh import_sql.sh; then you can cd /www/webapps/worktime/ and restart server with command: sh restart.sh'

+ 2 - 0
fhKeeper/formulahousekeeper/timesheet_deploy/custom_db_bk.sh

@@ -0,0 +1,2 @@
+# 替换$HOST_IP, $PASSWORD, $DB_NAME
+mysqldump -h$HOST_IP -uroot -p$PASSWORD -B $DB_NAME > $DB_NAME.sql

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet_deploy/import_sql.sh

@@ -0,0 +1 @@
+mysql -uroot -pMld2022@# man_mld < update_script.sql

BIN
fhKeeper/formulahousekeeper/timesheet_deploy/windows创建备份任务计划.docx