Browse Source

Merge branch 'master' of http://47.100.37.243:10080/wutt/manHourHousekeeper

cs 2 years ago
parent
commit
d55d19f7e7

+ 24 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserCorpwxTimeController.java

@@ -9,6 +9,7 @@ import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.ReportService;
 import com.management.platform.service.ReportService;
+import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import com.management.platform.util.MessageUtils;
@@ -24,6 +25,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -67,6 +69,8 @@ public class UserCorpwxTimeController {
     WxCorpInfoMapper wxCorpInfoMapper;
     WxCorpInfoMapper wxCorpInfoMapper;
     @Resource
     @Resource
     ExcelExportService excelExportService;
     ExcelExportService excelExportService;
+    @Resource
+    WxCorpInfoService wxCorpInfoService;
 
 
     @RequestMapping("/getMyDeptMembsData")
     @RequestMapping("/getMyDeptMembsData")
     public HttpRespMsg getMyDeptMembsData(String startDate, String endDate) {
     public HttpRespMsg getMyDeptMembsData(String startDate, String endDate) {
@@ -303,5 +307,25 @@ public class UserCorpwxTimeController {
         fileName += MessageUtils.message("fileName.workHour",startDate,endDate);
         fileName += MessageUtils.message("fileName.workHour",startDate,endDate);
         return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, fileName, allData, path);
         return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, fileName, allData, path);
     }
     }
+
+    @RequestMapping("/getPunchRecordBySelf")
+    public HttpRespMsg getUserPunchRecord(String date){
+        HttpRespMsg msg=new HttpRespMsg();
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate localDate = LocalDate.parse(date, df);
+        LocalDateTime start = LocalDateTime.of(localDate, LocalTime.MIN);
+        LocalDateTime end = LocalDateTime.of(localDate, LocalTime.MAX).withSecond(0).withNano(0);
+        User user = userMapper.selectById(request.getHeader("token"));
+        wxCorpInfoService.getUserPunchRecord(user.getCompanyId(),user.getId(),start,end,false);
+        Map<String,Object> resultMap =new HashMap<>();
+        List<UserCorpwxTime> corpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+        if (corpwxTimes.size() > 0) {
+            UserCorpwxTime time = corpwxTimes.get(0);
+            resultMap.put("time", time);
+        }
+        msg.data=resultMap;
+        return msg;
+    }
 }
 }
 
 

+ 18 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -472,6 +472,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         String url = null;
         String url = null;
         try {
         try {
             startDateTime = startDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
             startDateTime = startDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
+            LocalDate date=startDateTime.toLocalDate();
             long startTime = startDateTime.toEpochSecond(ZoneOffset.of("+8"));
             long startTime = startDateTime.toEpochSecond(ZoneOffset.of("+8"));
             endDateTime = endDateTime.withHour(23).withMinute(59).withSecond(0).withNano(0);
             endDateTime = endDateTime.withHour(23).withMinute(59).withSecond(0).withNano(0);
             long endTime = endDateTime.toEpochSecond(ZoneOffset.of("+8"));
             long endTime = endDateTime.toEpochSecond(ZoneOffset.of("+8"));
@@ -500,7 +501,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                 int toIndex = (i + 1) * batchSize;
                 int toIndex = (i + 1) * batchSize;
                 if (toIndex > totalLength) toIndex = totalLength;
                 if (toIndex > totalLength) toIndex = totalLength;
                 Object[] objects = corpwxUserIds.subList(fromIndex, toIndex).toArray(new String[0]);
                 Object[] objects = corpwxUserIds.subList(fromIndex, toIndex).toArray(new String[0]);
-                reqPunchRecord(corpInfo, startTime, endTime, objects, showLog);
+                reqPunchRecord(corpInfo, startTime, endTime, objects, showLog,userId,date);
             }
             }
         } catch (Exception exception) {
         } catch (Exception exception) {
             exception.printStackTrace();
             exception.printStackTrace();
@@ -509,7 +510,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         return msg;
         return msg;
     }
     }
 
 
-    public void reqPunchRecord(WxCorpInfo corpInfo, long startTime, long endTime, Object[] objects, boolean showLog)throws Exception {
+    public void reqPunchRecord(WxCorpInfo corpInfo, long startTime, long endTime, Object[] objects, boolean showLog,String userId,LocalDate date)throws Exception {
         DateTimeFormatter mdFormat = DateTimeFormatter.ofPattern("yyyy/M/d");
         DateTimeFormatter mdFormat = DateTimeFormatter.ofPattern("yyyy/M/d");
         LocalDateTime needDataTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
         LocalDateTime needDataTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
         long dataTime = needDataTime.toEpochSecond(ZoneOffset.of("+8"));
         long dataTime = needDataTime.toEpochSecond(ZoneOffset.of("+8"));
@@ -585,16 +586,27 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm");
                     DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm");
                     userCorpwxTime.setStartTime(LocalTime.parse(minTime,df).plusHours(8).format(df));
                     userCorpwxTime.setStartTime(LocalTime.parse(minTime,df).plusHours(8).format(df));
                     userCorpwxTime.setEndTime(LocalTime.parse(maxTime,df).plusHours(8).format(df));
                     userCorpwxTime.setEndTime(LocalTime.parse(maxTime,df).plusHours(8).format(df));
-                    userCorpwxTime.setCreateDate(LocalDate.now());
                     userCorpwxTime.setWxCorpid(corpInfo.getCorpid());
                     userCorpwxTime.setWxCorpid(corpInfo.getCorpid());
-                    userCorpwxTime.setWeekDay(LocalDate.now().getDayOfWeek().getValue());
+                    if(userId!=null){
+                        userCorpwxTime.setCreateDate(date);
+                        userCorpwxTime.setWeekDay(date.getDayOfWeek().getValue());
+                    }else {
+                        userCorpwxTime.setCreateDate(LocalDate.now());
+                        userCorpwxTime.setWeekDay(LocalDate.now().getDayOfWeek().getValue());
+                    }
                     userCorpwxTime.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(userCorpwxTime.getWeekDay()));
                     userCorpwxTime.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(userCorpwxTime.getWeekDay()));
                     BigDecimal bigDecimal=new BigDecimal(Duration.between(LocalTime.parse(minTime,df).plusHours(8),LocalTime.parse(maxTime,df).plusHours(8)).toMinutes());
                     BigDecimal bigDecimal=new BigDecimal(Duration.between(LocalTime.parse(minTime,df).plusHours(8),LocalTime.parse(maxTime,df).plusHours(8)).toMinutes());
                     bigDecimal=bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(restTime));
                     bigDecimal=bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(restTime));
                     userCorpwxTime.setWorkHours(bigDecimal.doubleValue());
                     userCorpwxTime.setWorkHours(bigDecimal.doubleValue());
                     System.out.println(userCorpwxTime);
                     System.out.println(userCorpwxTime);
-                    UserCorpwxTime item = userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", (String) objects[i])
-                            .eq("create_date", LocalDate.now()));
+                    UserCorpwxTime item;
+                    if(userId!=null){
+                         item= userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", (String) objects[i])
+                                .eq("create_date", date));
+                    }else {
+                         item= userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", (String) objects[i])
+                                .eq("create_date", LocalDate.now()));
+                    }
                     if (item != null) {
                     if (item != null) {
                         userCorpwxTime.setId(item.getId());
                         userCorpwxTime.setId(item.getId());
                         //已存在记录,进行更新
                         //已存在记录,进行更新