ysh 3 anni fa
parent
commit
622d9237dc

+ 40 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java

@@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import io.netty.util.internal.StringUtil;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.jeecg.common.api.vo.Result;
@@ -19,12 +20,10 @@ import org.jeecg.common.util.ImportExcelUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.entity.SysUserRole;
 import org.jeecg.modules.system.model.DepartIdModel;
 import org.jeecg.modules.system.model.SysDepartTreeModel;
-import org.jeecg.modules.system.service.ISysDepartService;
-import org.jeecg.modules.system.service.ISysPositionService;
-import org.jeecg.modules.system.service.ISysUserDepartService;
-import org.jeecg.modules.system.service.ISysUserService;
+import org.jeecg.modules.system.service.*;
 import org.jeecg.modules.system.util.FindsDepartsChildrenUtil;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -65,6 +64,9 @@ public class SysDepartController {
 	private ISysUserService sysUserService;
 	@Autowired
 	private ISysUserDepartService sysUserDepartService;
+	@Autowired
+	private ISysUserRoleService iSysUserRoleService;
+
 	/**
 	 * 查询数据 查出我的部门,并以树结构数据格式响应给前端
 	 *
@@ -125,16 +127,46 @@ public class SysDepartController {
 		Result<List<SysDepartTreeModel>> result = new Result<>();
 		try {
 			LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+			List<SysUserRole> userRole = iSysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId()));
+			String orgId = null;
+			String orgCode = null;
 
-			if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
-				List<SysDepartTreeModel> list = sysDepartService.queryTreeList2(viewDate);
+			if(userRole.size() > 0){
+				String roleId = userRole.get(0).getRoleId();
+				if(roleId.equals("1462659329857978370")){//部门负责人
+					String dept = user.getDepartIds();
+					if(!StringUtil.isNullOrEmpty(dept)){
+						String[] deptArr = dept.split(",");
+						if(deptArr.length > 0){
+							orgId = deptArr[0];
+							orgCode = user.getOrgCode();
+						}
+					}
+
+				}else if(roleId.equals("1473241527673765890")){//普通用户
+					result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
+					result.setSuccess(true);
+					return result;
+				}
+
+				List<SysDepartTreeModel> list = sysDepartService.queryTreeList2(viewDate, orgId, orgCode);
 				result.setResult(list);
 				result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
-				result.setSuccess(true);
+
 			}else{
 				result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
-				result.setSuccess(true);
 			}
+			result.setSuccess(true);
+
+//			if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
+//				List<SysDepartTreeModel> list = sysDepartService.queryTreeList2(viewDate,user.getOrgCode());
+//				result.setResult(list);
+//				result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
+//				result.setSuccess(true);
+//			}else{
+//				result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
+//				result.setSuccess(true);
+//			}
 
 		} catch (Exception e) {
 			log.error(e.getMessage(),e);

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysDepartService.java

@@ -34,7 +34,7 @@ public interface ISysDepartService extends IService<SysDepart>{
      * 勤信息使用(部门下增加人员)
      * @return
      */
-    List<SysDepartTreeModel> queryTreeList2(String viewDate);
+    List<SysDepartTreeModel> queryTreeList2(String viewDate,String orgId,String deptCode);
 
     /**
      * 查询所有部门DepartId信息,并分节点进行显示

+ 31 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java

@@ -100,23 +100,50 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
 		return listResult;
 	}
 
+
 	/**
 	 * 考勤信息使用(部门下增加人员)
 	 * @return
 	 */
 	@Override
-	public List<SysDepartTreeModel> queryTreeList2(String viewDate) {
+	public List<SysDepartTreeModel> queryTreeList2(String viewDate,String orgId,String deptCode) {
 		LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
 		query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
+		if(!StringUtil.isNullOrEmpty(deptCode)){
+
+			if(deptCode.length() == 6){
+				String four = deptCode.substring(0,4);
+				String two = deptCode.substring(0,2);
+				query.apply("org_code"+" like {0}", deptCode+"%").or().eq(SysDepart::getOrgCode,four).or()
+						.eq(SysDepart::getOrgCode,two).or().eq(SysDepart::getId,1);
+
+			}else if(deptCode.length() == 4){
+				String two = deptCode.substring(0,2);
+				query.apply("org_code"+" like {0}", deptCode+"%").or()
+						.eq(SysDepart::getOrgCode,two).or().eq(SysDepart::getId,1);
+
+			}else if(deptCode.length() == 2){
+				query.apply("org_code"+" like {0}", deptCode+"%")
+						.or().eq(SysDepart::getId,1);
+
+			}else if(deptCode.equals("0")){
+				//公司总负责人,不做限制
+			}else{
+				query.eq(SysDepart::getId,"无权访问");
+
+			}
+
+		}
 		query.orderByAsc(SysDepart::getDepartOrder);
 		List<SysDepart> list = this.list(query);
+
 		if(StringUtil.isNullOrEmpty(viewDate)){
 			viewDate = DateUtils.getNYTime();
 		}else if(viewDate.equals("1")){
 			viewDate = DateUtils.getNYTime();
 		}
 
-		List<Map<String ,Object>> map = viewClockInMapper1.selectErrorNum(viewDate);
+		List<Map<String ,Object>> map = viewClockInMapper1.selectErrorNum(viewDate,orgId);
 
 		for(SysDepart o:list){
 
@@ -143,7 +170,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
 		}
 		//获取人员类型
 		List<SysDictItem> dictList = sysDictItemMapper.selectItemsByMainCode("category");
-		List<Map<String ,Object>> userMap = viewClockInMapper1.selectUserError(viewDate);
+		List<Map<String ,Object>> userMap = viewClockInMapper1.selectUserError(viewDate,orgId);
 
 //		LambdaQueryWrapper<SysUser> query1 = new LambdaQueryWrapper<SysUser>();
 //		query1.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
@@ -181,6 +208,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
 		list.addAll(list3);
 		// 调用wrapTreeDataToTreeList方法生成树状数据
 		List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list);
+		System.out.println();
 		return listResult;
 	}
 

+ 24 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/controller/bdClockinMonthController.java

@@ -54,6 +54,23 @@ public class bdClockinMonthController extends JeecgController<bdClockinMonth, Ib
 	@Autowired
 	private IbdClockinMonthService bdClockinMonthService;
 
+
+	 /**
+	  * 获取已关账日期
+	  * @return
+	  */
+	@RequestMapping(value = "getCloseDate",method = RequestMethod.GET)
+	public String getCloseDate(){
+
+		//查询所有数据
+		List<BdClose> list = bdClockinMonthService.selectClose();
+		if(list.size() > 0){
+			return list.get(0).getCloseDate();
+		}
+		return "未关账";
+	}
+
+
 	 /**
 	  * 系统关账功能
 	  * @param jsonObject
@@ -207,4 +224,11 @@ public class bdClockinMonthController extends JeecgController<bdClockinMonth, Ib
       return super.importExcel(request, response, bdClockinMonth.class);
   }
 
+	 public static void main(String[] args) {
+		 String aa = "102030";
+		 System.out.println(aa.length());
+		 System.out.println(aa.substring(0,4));
+		 System.out.println(aa.substring(0,2));
+
+	 }
 }

+ 82 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/controller/viewClockInController.java

@@ -76,6 +76,76 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 	 @Autowired
 	 private IStatutoryLeaveService statutoryLeaveService;
 
+
+	 /**
+	  * 批量人员考勤页面,1付薪,2累计调休,3忽略
+	  * @param jsonObject
+	  * @return
+	  * @throws ParseException
+	  */
+	 @RequestMapping(value = "/handleInfo", method = RequestMethod.PUT)
+	 public Result<?> handleInfo(@RequestBody JSONObject jsonObject) throws ParseException {
+		String viewDates = jsonObject.getString("viewDate");
+		String username = jsonObject.getString("username");
+		String st = jsonObject.getString("st");
+		String[] viewDateArr = viewDates.split(",");
+		if(StringUtil.isNullOrEmpty(viewDates)){
+			return Result.error("您没有选择任何数据");
+		}
+		if(StringUtil.isNullOrEmpty(username)){
+			return Result.error("您没有选择任何数据");
+		}
+		if(viewDateArr.length < 1){
+			return Result.error("您没有选择任何数据");
+		}
+		if(!bdClockinMonthService.ifClose(viewDateArr[0])){
+			return Result.error("当前月份已关账,无法此操作");
+		}
+		SysUser sysUser = iSysUserService.getUserByName(username);
+		 if(sysUser != null){
+			 //正式工 101 实习生 103 劳务工	104 劳务外包5+2 105  劳务外包6+1 106  顾问 102
+			 //员工为正式,实习,劳务加班付薪时,如果没匹配到工资倍数,则默认两倍;匹配到工资倍数则按照倍数算薪;其他员工除非能匹配到工资倍数,否则不能付薪只能调休
+			 int userType = sysUser.getCategory();
+			 if(userType != 101 && userType != 103 && userType != 104){
+				 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+				 List<StatutoryLeave> list = statutoryLeaveService.list();
+				 for(String a:viewDateArr){
+
+					 for(StatutoryLeave o:list){
+						 if(o.getType().equals("1")){//假期管理 班
+							 Date begin = o.getStartDate();
+							 Date end = o.getEndDate();
+							 if(!isEffectiveDate(sdf.parse(a),begin,end) ){
+								 return Result.error("当前用户的加班,只能用于累计调休");
+							 }
+						 }
+					 }
+
+				 }
+
+			 }else{
+				 if(st.equals("1")){
+					 st = "付薪";
+				 }else if(st.equals("2")){
+					 st = "累计调休";
+				 }else{
+					 st = "忽略";
+				 }
+				 for(String a:viewDateArr){
+
+					 viewClockInService.fuXinInfo(st,username,a,sysUser.getUsername());
+
+				 }
+
+			 }
+
+		 }
+
+		 return Result.OK("OK");
+	 }
+
+
 	 /**
 	  * 人员考勤页面,1付薪,2累计调休,3忽略
 	  * @param jsonObject
@@ -90,13 +160,8 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 		 String userId = jsonObject.get("userId").toString();
 		 SysUser sysUser = iSysUserService.getUserByName(userId);
 		 if(sysUser != null){
-		 	//正式工	101
-			//实习生	103
-//			 劳务工	104
-//			 劳务外包5+2	105
-//			 劳务外包6+1	106
-//			 顾问	102
-			// 员工为正式,实习,劳务加班付薪时,如果没匹配到工资倍数,则默认两倍;匹配到工资倍数则按照倍数算薪;其他员工除非能匹配到工资倍数,否则不能付薪只能调休
+			//正式工 101 实习生 103 劳务工	104 劳务外包5+2 105  劳务外包6+1 106  顾问 102
+			 //员工为正式,实习,劳务加班付薪时,如果没匹配到工资倍数,则默认两倍;匹配到工资倍数则按照倍数算薪;其他员工除非能匹配到工资倍数,否则不能付薪只能调休
 		 	int userType = sysUser.getCategory();
 		 	if(userType != 101 && userType != 103 && userType != 104){
 				DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@@ -466,12 +531,22 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 			query.eq(ViewClockIn::getHeadMonth,mDate);//月份
 		}
 
+		if(viewClockIn.getDuration() != null && viewClockIn.getDuration() != ""){
+			query.isNotNull(ViewClockIn::getDuration);//加班信息
+		}
+		if(viewClockIn.getShowState() != null && viewClockIn.getShowState() != ""){
+			query.like(ViewClockIn::getShowState,viewClockIn.getShowState());//异常状态
+		}
 		if(viewClockIn.getRealname() != null && viewClockIn.getRealname() != ""){
 			query.like(ViewClockIn::getRealname,viewClockIn.getRealname());//姓名
 		}
 		if(viewClockIn.getDepartNames() != null && viewClockIn.getDepartNames() != ""){
 			query.like(ViewClockIn::getDepartNames,viewClockIn.getDepartNames());//部门
 		}
+		if(viewClockIn.getDepartIds() != null && viewClockIn.getDepartIds() != ""){
+//			query.apply("org_code"+" like {0}", viewClockIn.getDepartIds()+"%");
+			query.apply("FIND_IN_SET({0},depart_ids)", viewClockIn.getDepartIds());
+		}
 		if(viewClockIn.getWorkNo() != null && viewClockIn.getWorkNo() != ""){
 			query.eq(ViewClockIn::getWorkNo,viewClockIn.getWorkNo());//工号
 		}

+ 9 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/entity/ViewClockIn.java

@@ -32,6 +32,7 @@ public class ViewClockIn {
 	private String ifwork;//固定班次是否需要考勤 (0不需要,其他需要)
 	private String jzTime;//最后校准时间
 	private String jzBy;//最后校准人
+	private String showState;//前台所展示的异常状态 (1异常,2加感叹号,0正常)
 
 	private String lastDept;//用户末级部门
 	private String oneDept;//一级
@@ -55,20 +56,22 @@ public class ViewClockIn {
 	@Excel(name = "班次名称", width = 15)
     @ApiModelProperty(value = "班次名称")
 	private String name;
-	/**shiftTimeS*/
+
+	/**班次中具体上班时间(含日期,时分)*/
 	@Excel(name = "上班时间", width = 15)
     @ApiModelProperty(value = "shiftTimeS")
 	private String shiftTimeS;
 	/**
-	 * 班次中的上班时间
+	 * 班次中的上班时间(不含日期,仅时分)
 	 */
 	private String shiftRealTimeS;
-	/**shiftTimeX*/
+
+	/**班次中具体下班时间(含日期,时分)*/
 	@Excel(name = "下班时间", width = 15)
     @ApiModelProperty(value = "shiftTimeX")
 	private String shiftTimeX;
 	/**
-	 * 班次中的下班时间
+	 * 班次中的下班时间(不含日期,仅时分)
 	 */
 	private String shiftRealTimeX;
 
@@ -103,11 +106,11 @@ public class ViewClockIn {
 	private String weekDate;
 
 	/**gotoTime*/
-	@Excel(name = "上班打卡时间", width = 15)
+	@Excel(name = "员工主动上班打卡时间", width = 15)
     @ApiModelProperty(value = "gotoTime")
 	private String gotoTime;
 	/**closingTime*/
-	@Excel(name = "下班打卡时间", width = 15)
+	@Excel(name = "员工主动下班打卡时间", width = 15)
     @ApiModelProperty(value = "closingTime")
 	private String closingTime;
 	/**gotoState*/

+ 3 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/mapper/viewClockInMapper.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.viewClockIn.mapper;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.viewClockIn.entity.NumEntity;
 import org.jeecg.modules.viewClockIn.entity.ViewClockIn;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -20,9 +21,9 @@ public interface viewClockInMapper extends BaseMapper<ViewClockIn> {
 
     int updateOvertime(String st,String id,String username);
 
-    List<Map<String,Object>> selectErrorNum(String viewDate);
+    List<Map<String,Object>> selectErrorNum(@Param("viewDate") String viewDate, @Param("deptCode")String deptCode);
 
-    List<Map<String,Object>> selectUserError(String viewDate);
+    List<Map<String,Object>> selectUserError(@Param("viewDate") String viewDate, @Param("deptCode")String deptCode);
 
     List<ViewClockIn> selectPage(Page<ViewClockIn> page);
 }

+ 29 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/viewClockIn/mapper/xml/viewClockInMapper.xml

@@ -45,25 +45,36 @@
 
     <select id="selectErrorNum"  resultType="Map">
 
-        select a.depart_name departname,a.usernum,c.errornum from view_user_num A
+        select a.depart_name departname,a.usernum,c.errornum,c.id from view_user_num A
         left join (
-        select A.depart_name,count(b.username) errornum from sys_depart A left join (
+        select A.depart_name,count(b.username) errornum ,A.id from sys_depart A left join (
         select b.username,b.depart_names from view_clock_in_1 b
         where DATE_FORMAT(b.view_date,'%Y-%m') = #{viewDate}
-        and (
+        <!--and (
                 b.lateTime_s &lt; 0 or b.lateTime_x > 0
                 || (b.ifwork !=0 and attendance_Count &lt; 2 and b.name is not null)
                 || ((b.ifwork is null or b.ifwork !=0) and b.name is not null and b.name != '' and (b.goto_time is null || b.goto_time = '' ||  b.goto_time = null))
                 || b.duration is not null
           and (b.set_info > 0 ) and (b.error_State != 0 or b.error_State is null)
-            )
+            )-->
+       and (b.latetime_s &lt; 0 or b.latetime_x > 0 <!-- 是否迟到早退-->
+        or (b.rule_type = 1 and b.ifwork > 0 and b.attendance_count &lt; 2 and b.shift_real_time_s is not null) <!-- 固定班,需要打卡(固定班时休息日),打卡次数不足,当天有排班-->
+        or (b.rule_type = 1 and b.ifwork > 0 and b.shift_real_time_s is not null and b.goto_time is null) <!-- 固定班,需要打卡,当天有排班,没有打卡记录-->
+        or (b.rule_type = 2 and b.attendance_count &lt; 2 and b.shift_real_time_s is not null) <!-- 班次上下班,需要打卡(固定班时休息日),打卡次数不足,当天有排班-->
+        or (b.rule_type = 2 and b.shift_real_time_s is not null and b.goto_time is null) <!-- 班次上下班,需要打卡,当天有排班,没有打卡记录-->
+        or (b.duration is not null and b.work_overtime > 0) <!-- 有加班信息,打卡时间早于加班申请时间-->
+        and b.set_info > 0 and b.error_state is not null
+           )
 
         group by b.username,b.depart_names
 
         ) B on find_in_set(A.depart_name , B.depart_names)
-        group by A.depart_name
+        group by A.depart_name,A.id
         ) C on A.depart_name = C.depart_name
 
+        <if test="deptCode != null and deptCode != ''">
+            where c.id=#{deptCode}
+        </if>
 
     </select>
 
@@ -73,18 +84,29 @@
         select a.username,a.realname,a.depart_ids departids,a.category,b.errornum from sys_user A left join (
         select b.user_id,count(1) as errornum from view_clock_in_1 b
         where DATE_FORMAT(b.view_date,'%Y-%m') = #{viewDate}
-        and (
+        <!--and (
             b.lateTime_s &lt; 0 or b.lateTime_x > 0
             || (b.ifwork !=0 and attendance_Count &lt; 2 and b.name is not null)
             || ((b.ifwork is null or b.ifwork !=0) and b.name is not null and b.name != '' and (b.goto_time is null || b.goto_time = '' ||  b.goto_time = null))
             || b.duration is not null
           and (b.set_info > 0 ) and (b.error_State != 0 or b.error_State is null)
             )
+-->
+        and (b.latetime_s &lt; 0 or b.latetime_x > 0 <!-- 是否迟到早退-->
+        or (b.rule_type = 1 and b.ifwork > 0 and b.attendance_count &lt; 2 and b.shift_real_time_s is not null) <!-- 固定班,需要打卡(固定班时休息日),打卡次数不足,当天有排班-->
+        or (b.rule_type = 1 and b.ifwork > 0 and b.shift_real_time_s is not null and b.goto_time is null) <!-- 固定班,需要打卡,当天有排班,没有打卡记录-->
+        or (b.rule_type = 2 and b.attendance_count &lt; 2 and b.shift_real_time_s is not null) <!-- 班次上下班,需要打卡(固定班时休息日),打卡次数不足,当天有排班-->
+        or (b.rule_type = 2 and b.shift_real_time_s is not null and b.goto_time is null) <!-- 班次上下班,需要打卡,当天有排班,没有打卡记录-->
+        or (b.duration is not null and b.work_overtime > 0) <!-- 有加班信息,打卡时间早于加班申请时间-->
+        and b.set_info > 0 and b.error_state is not null
+        )
 
         group by b.username
         ) B
         on a.id = b.user_id
-
+        <if test="deptCode != null and deptCode != ''">
+            where find_in_set(#{deptCode} , a.depart_ids)
+        </if>
 
     </select>
 </mapper>