| 
					
				 | 
			
			
				@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.shiro.SecurityUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.jeecg.common.system.vo.LoginUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.jeecg.common.util.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.jeecg.modules.geke.shift.mapper.ShiftMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.jeecg.modules.geke.userShift.entity.UserDept; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.jeecg.modules.geke.userShift.entity.UserShift; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.jeecg.modules.geke.userShift.entity.UserShiftVo; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -33,6 +34,9 @@ public class UserShiftServiceImpl extends ServiceImpl<UserShiftMapper, UserShift 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private  UserShiftMapper userShiftMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ShiftMapper shiftMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -118,41 +122,169 @@ public class UserShiftServiceImpl extends ServiceImpl<UserShiftMapper, UserShift 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public IPage<Map<String, Object>> mothUserShift(String date,Integer pageNo,Integer pageSize,List<String>deptids,List<String> userid,String type) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public IPage<Map<String, Object>> mothUserShift(String date,Integer pageNo,Integer pageSize,String type) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Page<Map<String, Object>> page = new Page<Map<String, Object>>(pageNo, pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String>userids=new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<String> mySubDepIdsByDepId=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        IPage<Map<String, Object>> users = getUsers(page,deptids,userid,type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        IPage<Map<String, Object>> users= getUsers(page); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Calendar calendar = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         calendar.setTime(sdf.parse(date)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int year = calendar.get(Calendar.YEAR);//年份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int month = calendar.get(calendar.MONTH) + 1;//月份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//获取前端传过来的时间获取月份的总天数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (type.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (users.getRecords()!=null&&users.getRecords().size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                users.getRecords().forEach(str -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userids.add(str.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (userids != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String, String> dep = getDepNamesByUserIds(userids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                users.getRecords().forEach(st -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    st.put("deptName", dep.get(st.get("id").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(int i=1;i<=actualMaximum;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (Map user:users.getRecords()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String shiftid=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String  shiftname=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                List<Map<String, Object>> id = userShiftMapper.getOneUserShift(user.get("id").toString(), year +"-"+ month+"-" + i, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               if (id.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                   if (id.get(0).get("id").equals("0")||id.get(0).get("id")=="0"){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       shiftname="休息"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                   }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       shiftname=id.get(0).get("name").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                       shiftid=id.get(0).get("id").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                user.put("a" + i, shiftname); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                user.put("shfitid",shiftid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (int i = 1; i <= actualMaximum; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (Map user : users.getRecords()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!user.get("type").equals("1") && !user.get("type").equals("3")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String shiftname = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        List<Map<String, Object>> id = userShiftMapper.getOneUserShift(user.get("id").toString(), year + "-" + month + "-" + i, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (id.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (id.get(0).get("id").equals("0") || id.get(0).get("id") == "0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                shiftname = "休息"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                shiftname = id.get(0).get("name").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        user.put("a" + i, shiftname); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String[] workDays = user.get("workDay").toString().split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String d = year + "-" + month + "-" + i + " :00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Date dates = DateUtils.str2Date(d, sdf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String is = "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String ts = String.valueOf(dates.getDay()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (String ws : workDays) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (String.valueOf(dates.getDay()).equals(ws)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                is = "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (is.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            user.put("a" + i, "班"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            user.put("a" + i, "休"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if (type.equals("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (users.getRecords()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                users.getRecords().forEach(s->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userids.add(s.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            users = getUserNot(page, userids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    users.getRecords().forEach(str->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        userids.add(str.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Map<String, String> dep = getDepNamesByUserIds(userids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    users.getRecords().forEach(st -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        st.put("deptName", dep.get(st.get("id").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return users; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public IPage<Map<String, Object>> getUsers(Page<Map<String, Object>> page,List<String> deptids,List<String> userid,String type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return page.setRecords(userShiftMapper.getUsers(page,deptids,userid,type)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<Map<String, Object>> mothUserShifts(String date, String type, String userid) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String>userids=new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> mySubDepIdsByDepId=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Calendar calendar = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        calendar.setTime(sdf.parse(date)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int year = calendar.get(Calendar.YEAR);//年份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int month = calendar.get(calendar.MONTH) + 1;//月份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//获取前端传过来的时间获取月份的总天数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> userByids = userShiftMapper.getUserByids(Arrays.asList(userid.split(","))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!type.equals("2")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (userByids!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (int i = 1; i <= actualMaximum; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    int ts=i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userByids.forEach(st->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        st.put("a"+ts,""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        st.put("shiftid"+ts,""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (userByids!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (int i = 1; i <= actualMaximum; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    int ts=i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userByids.forEach(st->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String shiftname = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String sid = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        List<Map<String, Object>> id = userShiftMapper.getOneUserShift(st.get("id").toString(), year + "-" + month + "-" + ts, ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (id.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (id.get(0).get("id").equals("0") || id.get(0).get("id") == "0") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                shiftname = "休息"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                sid="0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                shiftname = id.get(0).get("name").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                sid=id.get(0).get("id").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        st.put("a" + ts, shiftname); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        st.put("shiftid"+ts,sid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return userByids; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public IPage<Map<String, Object>> getUserNot(Page<Map<String, Object>> page, List<String> userids) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return page.setRecords(userShiftMapper.getUserNot(page,userids)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public IPage<Map<String, Object>> getUsers(Page<Map<String, Object>> page) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return page.setRecords(userShiftMapper.getUsers(page)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<Map<String, Object>> mothUserByCount(String date) throws ParseException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,Object>mt=new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mt.put("id","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mt.put("name","休息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> query = shiftMapper.query(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        query.add(mt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Calendar calendar = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        calendar.setTime(sdf.parse(date)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int year = calendar.get(Calendar.YEAR);//年份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int month = calendar.get(calendar.MONTH) + 1;//月份 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//获取前端传过来的时间获取月份的总天数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       if (query.size()>0&&query!=null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           for (int i = 1; i <= actualMaximum; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               int c=i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               query.forEach(str->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   String cout="0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   String d = year + "-" + month + "-" + c; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   Map<String, Object> maps = userShiftMapper.ShiftCount(str.get("id").toString(),d); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   if (maps!=null&&maps.get("count")!=null&&!maps.get("count").equals("")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       cout=maps.get("count").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   str.put("b" + c, cout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+               }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return query; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |