Procházet zdrojové kódy

项目月打卡数据统计与用户导入修改

anderx před 2 roky
rodič
revize
d5fba4a823

+ 3 - 1
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -40,6 +40,8 @@ public class SysUser extends BaseEntity
     @Excel(name = "用户名称")
     private String nickName;
     @Excel(name = "职位",width = 8)
+    private String roleName;
+
     private String postName;
     /**
      *  0=兼职,1=全职
@@ -135,7 +137,7 @@ public class SysUser extends BaseEntity
 
     /** 角色ID */
     private Long roleId;
-    private String roleName;
+
 
     /**公司id*/
     private Long companyId;

+ 5 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -218,4 +218,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         System.out.println(lastDayOfMonth());
     }
 
+    public static int getWeeks(String dates) {
+        Calendar cal=Calendar.getInstance();
+        cal.setTime(parseDate(dates));
+        return cal.get(Calendar.DAY_OF_WEEK)-1;
+    }
 }

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/project/bo/MyMonthDays.java

@@ -3,11 +3,20 @@ package com.ruoyi.project.bo;
 public class MyMonthDays {
     private String dates;
     private String duration;
+    private Integer week;
     /**
      *  0 =未到时限 1=满工时,2=未打卡,3=未满工时
      */
     private Integer status;
 
+    public Integer getWeek() {
+        return week;
+    }
+
+    public void setWeek(Integer week) {
+        this.week = week;
+    }
+
     public String getDates() {
         return dates;
     }

+ 16 - 11
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -39,9 +39,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -160,6 +158,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         List<MyMonthDays> myMonthDays = projectStaffRecordMapper.myDurationMonth(id, aid, DateUtils.firsDayOfMonth(), DateUtils.lastDayOfMonth() + " 23:59:59");
         supplementMyMonthDays(myMonthDays);
         for (MyMonthDays myMonthDay : myMonthDays) {
+            DateUtils.getWeeks(myMonthDay.getDates());
 //            0 =未到时限 1=满工时,2=未打卡,3=未满工时
             if (compareTo(date,myMonthDay.getDates())){
                 myMonthDay.setStatus(0);
@@ -258,18 +257,20 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     }
 
     private void supplementMyMonthDays(List<MyMonthDays> myMonthDays) {
-        List<String> monthDays = getMonthDays();
-        for (String monthDay : monthDays) {
+        List<Map<String,Object>> monthDays = getMonthDays();
+        for ( Map<String,Object> map : monthDays) {
             boolean flag= true;
             for (MyMonthDays myMonthDay : myMonthDays) {
-                if (monthDay.equals(myMonthDay.getDates())){
+                if (map.get("days").equals(myMonthDay.getDates())){
                     flag=false;
+                    myMonthDay.setWeek((Integer) map.get("week"));
                     break;
                 }
             }
             if (flag){
                 MyMonthDays mmd=new MyMonthDays();
-                mmd.setDates(monthDay);
+                mmd.setDates((String) map.get("days"));
+                mmd.setWeek((Integer) map.get("week"));
                 mmd.setDuration("0");
                 mmd.setStatus(0);
                 myMonthDays.add(mmd);
@@ -277,21 +278,25 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         }
     }
 
-    private static List<String> getMonthDays() {
+    private static List<Map<String,Object>> getMonthDays() {
         String firsDayOfMonth = DateUtils.firsDayOfMonth();
         String lastDayOfMonth = DateUtils.lastDayOfMonth();
-        List<String> dates=new ArrayList<>();
+        List<Map<String,Object>> dates=new ArrayList<>();
 
         String str=firsDayOfMonth.substring(0,firsDayOfMonth.lastIndexOf("-"));
-        System.out.println(str);
+
         for (int i=1; i<32;i++){
+            Map<String,Object> map=new HashMap<>();
             String res;
             if (i<10){
                  res=str+"-0"+i;
+
             }else {
                 res=str+"-"+i;
             }
-            dates.add(res);
+            map.put("days",res);
+            map.put("week",DateUtils.getWeeks(res));
+            dates.add(map);
             if (res.equals(lastDayOfMonth)){
                 break;
             }

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -555,8 +555,8 @@ public class SysUserServiceImpl implements ISysUserService
                         }
                     }
                     userMapper.insertUser(user);
-                    if (user.getPostName()!=null){
-                        SysRole sysRole = roleMapper.selectByRoleName(user.getPostName());
+                    if (user.getRoleName()!=null){
+                        SysRole sysRole = roleMapper.selectByRoleName(user.getRoleName());
                         if (sysRole !=null){
                             List<SysUserRole> list=new ArrayList<>();
                             SysUserRole sur = new SysUserRole();