Kaynağa Gözat

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

ggooalice 2 yıl önce
ebeveyn
işleme
7e3cbe4f79

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ExpenseTypeController.java

@@ -41,7 +41,7 @@ public class ExpenseTypeController {
     public HttpRespMsg getList() {
         User user = userMapper.selectById(request.getHeader("token"));
         HttpRespMsg msg = new HttpRespMsg();
-        msg.data=expenseTypeMapper.selectList(new QueryWrapper<ExpenseType>().eq("company_id",user.getCompanyId()).orderByDesc("mainType"));
+        msg.data=expenseTypeMapper.selectList(new QueryWrapper<ExpenseType>().eq("company_id",user.getCompanyId()).orderByDesc("main_type"));
         return msg;
     }
 

+ 19 - 11
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -5864,9 +5864,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public HttpRespMsg getUserReportTimelinessRate(HttpServletRequest request, String startDate, String endDate, Integer departmentId, String userId,Integer pageIndex,Integer pageSize) {
         HttpRespMsg msg=new HttpRespMsg();
         DecimalFormat dft =  new DecimalFormat("0%");
-        LocalDateTime sDate = LocalDate.parse(startDate).atTime(LocalTime.MIN);
-        LocalDateTime eDate = LocalDate.parse(endDate).atTime(LocalTime.MIN);
-        List<LocalDateTime> dateTimeList = getDays(sDate, eDate);
         User targetUser= userMapper.selectById(request.getHeader("token"));
         TimeType timeType = timeTypeMapper.selectById(targetUser.getCompanyId());
         Integer timeliness = timeType.getTimeliness();
@@ -5922,6 +5919,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<LeaveSheet> leaveSheetList = leaveSheetMapper.selectList(new QueryWrapper<LeaveSheet>().eq("company_id", targetUser.getCompanyId()));
         List<TimelinessRateVO> resultList=new ArrayList<>();
         for (User user : userList){
+            LocalDateTime sDate;
+            LocalDateTime eDate = LocalDate.parse(endDate).atTime(LocalTime.MIN);
+            LocalDate inductionDate = user.getInductionDate();
+            //每个人须填报天数按照入职日期过滤
+            if(inductionDate!=null){
+                if(inductionDate.isBefore(LocalDate.parse(startDate))){
+                    sDate = LocalDate.parse(startDate).atTime(LocalTime.MIN);
+                }else{
+                    sDate = inductionDate.atTime(LocalTime.MIN);
+                }
+            }else  sDate = LocalDate.parse(startDate).atTime(LocalTime.MIN);
+            List<LocalDateTime> dateTimeList=getDays(sDate, eDate);
             List<Map<String,Object>> dataList=new ArrayList<>();
             long days =dateTimeList.size();
             List<LeaveSheet> leaveSheets = leaveSheetList.stream().filter(ls -> ls.getOwnerId().equals(user.getId())
@@ -5964,7 +5973,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     }
                 }
             }
-            //去填未填日报非工作日
+            //去填未填日报非工作日
             for (LocalDateTime localDateTime : dateTimeList) {
                 if(mapList!=null){
                     if(!WorkDayCalculateUtils.isWorkDay(localDateTime.toLocalDate())&&!mapList.stream().anyMatch(ml->{
@@ -7864,16 +7873,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 Map<String,Object> itemMap=new HashMap<>();
                 List<String> weekList = SplitDateUtil.doDateByStatisticsType("week", sDate, eDate);
                 List<Map<String,Object>> itemList=new ArrayList<>();
-                int a=1;
                 for (int i1 = 0; i1 < weekList.size(); i1++) {
                     String sDate1 = weekList.get(i1);
                     String eDate1 = weekList.get(i1 + 1);
                     Map<String,Object> map=new HashMap<>();
                     map.put("startDate",sDate1);
                     map.put("endDate",eDate1);
-                    map.put("week",a);
+                    String weekValueByDate = SplitDateUtil.getWeekValueByDate(eDate1);
+                    map.put("week",weekValueByDate);
                     i1++;
-                    a++;
                     itemList.add(map);
                     System.out.println(sDate1+"-----"+eDate1);
                 }
@@ -7881,7 +7889,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 itemMap.put("data",itemList);
                 dataDetailList.add(itemMap);
             }
-        } catch (ParseException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         System.out.println(dataDetailList);
@@ -7892,10 +7900,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<String> titleString = new ArrayList<>(Arrays.asList(s));
         for (Map<String, Object> objectMap : dataDetailList) {
             List<Map<String,Object>> data = (List<Map<String, Object>>) objectMap.get("data");
-            Integer month = Integer.valueOf(String.valueOf(objectMap.get("month")));
             for (Map<String, Object> datum : data) {
-                Integer week =Integer.valueOf(String.valueOf( datum.get("week")));
-                titleString.add(month+"月份第"+week+"周及时率");
+                String week =String.valueOf( datum.get("week"));
+
+                titleString.add(week+"_"+String.valueOf(datum.get("startDate"))+"-"+ String.valueOf(datum.get("endDate"))+"及时率");
             }
         }
         List<List<String>> dataList=new ArrayList<>();

+ 78 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/SplitDateUtil.java

@@ -6,6 +6,9 @@ import org.ehcache.core.internal.util.CollectionUtil;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 
 public class SplitDateUtil {
@@ -56,6 +59,81 @@ public class SplitDateUtil {
         return listWeekOrMonth;
     }
 
+    /**
+     * 获取当前日期是本月的第几周(通过本月有几个周三来判断)
+     * @param dateStr 日期(格式:yyyy-MM-dd)
+     * @return  第n周
+     * @throws Exception
+     */
+    public static String  getWeekValueByDate(String dateStr) throws Exception {
+            String monthNoAndWeekNo;
+            //获取当月的第一天
+            //获取月第一个周一,从当月第一天开始找
+            DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDate sourceTime=LocalDate.parse(dateStr,df);
+            LocalDateTime firstMondayOfMonth = getFirstMonday(sourceTime.atTime(LocalTime.MIN));
+
+            //比较当月的第一个星期一 < = 参数时间
+            if (firstMondayOfMonth.isBefore(sourceTime.atTime(LocalTime.MIN)) || firstMondayOfMonth.isEqual(sourceTime.atTime(LocalTime.MIN))) {
+                //当月第一个周一在当前时间之前 firstMondayOfMonth<=sourceTime
+                //计算两个时间间隔天数
+                int dayOfMonthFirstMonday = firstMondayOfMonth.getDayOfMonth();
+                int dayOfMonthSourceTime = sourceTime.getDayOfMonth();
+
+                int diffDays = dayOfMonthSourceTime - dayOfMonthFirstMonday;
+                //第几周weekNo
+                int weekNo = (diffDays / 7) + 1;
+                //月份
+                int monthNo = sourceTime.getMonth().getValue();
+
+                monthNoAndWeekNo = monthNo + "月份" + "第" + weekNo + "周";
+            } else {
+                //如果当月的第一个周一大于参数时间,则要计算到上个月份去
+                //获取上一个月的第一个周一
+                LocalDateTime lastMontLocalDateTime = sourceTime.atTime(LocalTime.MIN).minusMonths(1);
+                //上个月的第一天
+                //从上个月的第一天开始找周一
+                LocalDateTime firstMondayOfMonthLast = getFirstMonday(lastMontLocalDateTime);
+
+                //  计算两个时间间隔天数 (上月第一个周一 减去 当前时间)
+                Duration duration = Duration.between(firstMondayOfMonthLast, sourceTime.atTime(LocalTime.MIN));
+                long diffDays = duration.toDays(); //相差的天数
+                //第几周weekNo
+                long weekNo = (diffDays / 7) + 1;
+                //月份
+                int monthNo = firstMondayOfMonthLast.getMonth().getValue();//汉字版月份
+
+                monthNoAndWeekNo = monthNo + "月份" + "第" + weekNo + "周";
+            }
+
+            return monthNoAndWeekNo;
+    }
+
+
+    /**
+     *获取当月第一天
+     */
+    public static LocalDateTime getFirstLocalDayOfMonth(LocalDateTime localDateTime) {
+        return localDateTime.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
+    }
+
+    /**
+     *获取当月第一周  以第一个周一为准
+     */
+    private static LocalDateTime getFirstMonday(LocalDateTime sourceTime) {
+        LocalDateTime firstMondayOfMonth = getFirstLocalDayOfMonth(sourceTime);
+        for (int i = 0; i < 6; i++) {
+            DayOfWeek dayOfWeekTemp = firstMondayOfMonth.getDayOfWeek();
+            if (dayOfWeekTemp.equals(DayOfWeek.MONDAY)) {
+                break;
+            }
+            //往后推一天
+            firstMondayOfMonth = firstMondayOfMonth.plusDays(1);
+        }
+        return firstMondayOfMonth;
+    }
+
+
     public static void main(String[] args) {
         try {
             List<String> list = doDateByStatisticsType("month", "2022-01-01", "2022-03-30");