|  | @@ -1,20 +1,22 @@
 | 
	
		
			
				|  |  |  package org.jeecg.modules.viewClockIn.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.text.DateFormat;
 | 
	
		
			
				|  |  |  import java.text.ParseException;
 | 
	
		
			
				|  |  |  import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | -import java.util.Arrays;
 | 
	
		
			
				|  |  | -import java.util.Date;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  |  import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.baomidou.dynamic.datasource.annotation.DS;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  | +import io.netty.util.internal.StringUtil;
 | 
	
		
			
				|  |  | +import org.apache.shiro.SecurityUtils;
 | 
	
		
			
				|  |  |  import org.jeecg.common.api.vo.Result;
 | 
	
		
			
				|  |  |  import org.jeecg.common.system.query.QueryGenerator;
 | 
	
		
			
				|  |  |  import org.jeecg.common.aspect.annotation.AutoLog;
 | 
	
		
			
				|  |  | +import org.jeecg.common.system.vo.LoginUser;
 | 
	
		
			
				|  |  |  import org.jeecg.common.util.DateUtils;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.geke.attendance.entity.Attendance;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.geke.attendance.service.IAttendanceService;
 | 
	
	
		
			
				|  | @@ -85,60 +87,151 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	 @RequestMapping(value = "/jiaozhun", method = RequestMethod.PUT)
 | 
	
		
			
				|  |  | -	 public String jiaozhun(@RequestBody JSONObject jsonObject) throws ParseException {
 | 
	
		
			
				|  |  | +	 public Result<?> jiaozhun(@RequestBody JSONObject jsonObject) throws ParseException {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	 	if(jsonObject.get("shiftTimeS") == null || jsonObject.get("shiftTimeX") == null){
 | 
	
		
			
				|  |  | -			return "没有排班,无需校准打卡时间";
 | 
	
		
			
				|  |  | +//			return "没有排班,无需校准打卡时间";
 | 
	
		
			
				|  |  | +			return Result.error("没有排班,无需校准打卡时间!");
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		 DateFormat sdf = new SimpleDateFormat("YYYY-DD-MM mm:dd:ss");
 | 
	
		
			
				|  |  | +		 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 | 
	
		
			
				|  |  | +		 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |  		 Attendance attendance = new Attendance();
 | 
	
		
			
				|  |  |  		 String shiftTimeS = jsonObject.get("shiftTimeS").toString();
 | 
	
		
			
				|  |  | +		 String shiftTimeX = jsonObject.get("shiftTimeX").toString();
 | 
	
		
			
				|  |  |  		 String username = jsonObject.get("username").toString();
 | 
	
		
			
				|  |  |  		 attendance.setUserId(username);
 | 
	
		
			
				|  |  | +		 attendance.setNotes("手工校准"+user.getRealname());
 | 
	
		
			
				|  |  |  		 attendance.setUserDate(sdf.parse(shiftTimeS));
 | 
	
		
			
				|  |  |  		 attendance.setCheckinType("上班打卡");
 | 
	
		
			
				|  |  |  		 attendance.setExceptionType("正常");
 | 
	
		
			
				|  |  | +//		 if(jsonObject.get("setInfo") != null){
 | 
	
		
			
				|  |  | +//			 attendance.setSetInfo(jsonObject.get("setInfo").toString());
 | 
	
		
			
				|  |  | +//		 }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		 attendanceService.save(attendance);
 | 
	
		
			
				|  |  |  		 Attendance attendance2 = new Attendance();
 | 
	
		
			
				|  |  | +//		 if(jsonObject.get("setInfo") != null){
 | 
	
		
			
				|  |  | +//		 	attendance2.setSetInfo(jsonObject.get("setInfo").toString());
 | 
	
		
			
				|  |  | +//		 }
 | 
	
		
			
				|  |  | +		 attendance2.setNotes("手工校准"+user.getRealname());
 | 
	
		
			
				|  |  |  		 attendance2.setUserId(username);
 | 
	
		
			
				|  |  | -		 attendance2.setUserDate(sdf.parse(shiftTimeS));
 | 
	
		
			
				|  |  | +		 attendance2.setUserDate(sdf.parse(shiftTimeX));
 | 
	
		
			
				|  |  |  		 attendance2.setCheckinType("下班打卡");
 | 
	
		
			
				|  |  |  		 attendance2.setExceptionType("正常");
 | 
	
		
			
				|  |  |  		 attendanceService.save(attendance2);
 | 
	
		
			
				|  |  | -		 return "校准成功";
 | 
	
		
			
				|  |  | +		 return Result.OK("校准成功!");
 | 
	
		
			
				|  |  | +//		 return "校准成功";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	 public static void main(String[] args) throws ParseException {
 | 
	
		
			
				|  |  | -		 DateFormat sdf = new SimpleDateFormat("YYYY-DD-MM mm:dd:ss");
 | 
	
		
			
				|  |  | -		 System.out.println(sdf.parse("2021-12-12 20:12:12"));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	 	String st = "sdfsdfsddf";
 | 
	
		
			
				|  |  | +	 	String[] s = st.split("(");
 | 
	
		
			
				|  |  | +		 System.out.println(DateUtils.getNYTime());
 | 
	
		
			
				|  |  | +//		 DateFormat sdf = new SimpleDateFormat("YYYY-DD-MM HH:dd:ss");
 | 
	
		
			
				|  |  | +//		 System.out.println(sdf.parse("2021-12-12 20:12:12"));
 | 
	
		
			
				|  |  | +	 }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	 @RequestMapping(value = "/syMonthReport", method = RequestMethod.PUT)
 | 
	
		
			
				|  |  | +	 public Result<?> syMonthReport(@RequestBody JSONObject jsonObject) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		 String viewDate = jsonObject.getString("viewDate");
 | 
	
		
			
				|  |  | +		 String ids = jsonObject.getString("ids");
 | 
	
		
			
				|  |  | +		 String[] userId = ids.split(",");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//		 List<bdClockinMonth> list = bdClockinMonthService.selectAllByMonth(viewDate,userId);
 | 
	
		
			
				|  |  | +		 	try {
 | 
	
		
			
				|  |  | +				String err = bdClockinMonthService.reportIntoU8Job(viewDate,userId);
 | 
	
		
			
				|  |  | +				if(StringUtil.isNullOrEmpty(err)){
 | 
	
		
			
				|  |  | +					return Result.error(err);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}catch (Exception e){
 | 
	
		
			
				|  |  | +				return Result.error(e.getMessage());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		 return Result.OK("true");
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	 @RequestMapping(value = "/monthReport", method = RequestMethod.PUT)
 | 
	
		
			
				|  |  | -	 public String monthReport(@RequestBody JSONObject jsonObject) {
 | 
	
		
			
				|  |  | +	 public Result<?> monthReport(@RequestBody JSONObject jsonObject) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		 try {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +		 	 Map<String,String> map = new HashMap<>();
 | 
	
		
			
				|  |  |  			 String nowDate = jsonObject.getString("nowDate");
 | 
	
		
			
				|  |  | +			 String[] date = nowDate.split("-");
 | 
	
		
			
				|  |  | +			 String userIds = jsonObject.getString("userIds");
 | 
	
		
			
				|  |  | +			 List<String> userList = new ArrayList<>();
 | 
	
		
			
				|  |  | +			 if(!StringUtil.isNullOrEmpty(userIds)){
 | 
	
		
			
				|  |  | +				 String[] userId = userIds.split(",");
 | 
	
		
			
				|  |  | +				 for(String o:userId){
 | 
	
		
			
				|  |  | +					String[] arr = o.split("&");
 | 
	
		
			
				|  |  | +					if(arr.length > 0){
 | 
	
		
			
				|  |  | +						if(map.containsKey(arr[0])){
 | 
	
		
			
				|  |  | +							continue;
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +						userList.add(arr[0]);
 | 
	
		
			
				|  |  | +						map.put(arr[0],"");
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				 }
 | 
	
		
			
				|  |  | +			 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			 List<bdClockinMonth> list = bdClockinMonthService.selectByMonth(nowDate);
 | 
	
		
			
				|  |  | +			 List<bdClockinMonth> list = bdClockinMonthService.selectByMonth(nowDate,userList);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			 if(list.size() == 0){
 | 
	
		
			
				|  |  | -				 return "当前月份没有考勤数据,无法生成月报";
 | 
	
		
			
				|  |  | +				 return Result.error("当前月份没有考勤数据,无法生成月报!");
 | 
	
		
			
				|  |  |  			 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			 bdClockinMonthService.deleteByMonth(nowDate);
 | 
	
		
			
				|  |  | +			 bdClockinMonthService.deleteByMonth(nowDate,userList);
 | 
	
		
			
				|  |  |  			 for(bdClockinMonth o:list){
 | 
	
		
			
				|  |  | +			 	o.setMonthTime(nowDate);
 | 
	
		
			
				|  |  | +			 	o.setYears(date[0]);
 | 
	
		
			
				|  |  | +			 	o.setMonths(date[1]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				o.setWorkDay("21.75");
 | 
	
		
			
				|  |  | +				//是否免打卡 1免打卡
 | 
	
		
			
				|  |  | +				if(StringUtil.isNullOrEmpty(o.getIsAttendance()) && o.getIsAttendance().equals("1")){
 | 
	
		
			
				|  |  | +					 o.setWorkDayReal("21.75");//真实考勤天数
 | 
	
		
			
				|  |  | +				}else{
 | 
	
		
			
				|  |  | +					BigDecimal workDay = new BigDecimal("21.75");
 | 
	
		
			
				|  |  | +					if(!StringUtil.isNullOrEmpty(o.getHolidayTimeBj()) && !o.getHolidayTimeBj().equals("0")){
 | 
	
		
			
				|  |  | +						workDay = workDay.subtract(new BigDecimal(o.getHolidayTimeBj()));
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					if(!StringUtil.isNullOrEmpty(o.getHolidayTimeSj()) && !o.getHolidayTimeSj().equals("0")){
 | 
	
		
			
				|  |  | +						workDay = workDay.subtract(new BigDecimal(o.getHolidayTimeSj()));
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					o.setWorkDayReal(workDay.toString());//真实考勤天数
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  				 bdClockinMonthService.save(o);
 | 
	
		
			
				|  |  |  			 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		 } catch (Exception e) {
 | 
	
		
			
				|  |  |  			 log.error(e.getMessage(), e);
 | 
	
		
			
				|  |  | -			 return "月报生成失败,请稍后再试";
 | 
	
		
			
				|  |  | +			 return Result.error("月报生成失败,请稍后再试!");
 | 
	
		
			
				|  |  |  		 }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	 	return "true";
 | 
	
		
			
				|  |  | +		 return Result.OK("true");
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//	 @RequestMapping(value = "/list1111111", method = RequestMethod.GET)
 | 
	
		
			
				|  |  | +//	 public Result<Page<ViewClockIn>> queryPageList(ViewClockIn sysAnnouncement,
 | 
	
		
			
				|  |  | +//														@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 | 
	
		
			
				|  |  | +//														@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
 | 
	
		
			
				|  |  | +//														HttpServletRequest req) {
 | 
	
		
			
				|  |  | +//		 Result<Page<ViewClockIn>> result = new Result<Page<ViewClockIn>>();
 | 
	
		
			
				|  |  | +//		 Page<ViewClockIn> pageList = new Page<ViewClockIn>(pageNo,pageSize);
 | 
	
		
			
				|  |  | +//		 pageList = viewClockInService.selectPage(pageList);//
 | 
	
		
			
				|  |  | +//		 log.info("查询当前页:"+pageList.getCurrent());
 | 
	
		
			
				|  |  | +//		 log.info("查询当前页数量:"+pageList.getSize());
 | 
	
		
			
				|  |  | +//		 log.info("查询结果数量:"+pageList.getRecords().size());
 | 
	
		
			
				|  |  | +//		 log.info("数据总数:"+pageList.getTotal());
 | 
	
		
			
				|  |  | +//		 result.setSuccess(true);
 | 
	
		
			
				|  |  | +//		 result.setResult(pageList);
 | 
	
		
			
				|  |  | +//		 return result;
 | 
	
		
			
				|  |  | +//	 }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * 分页列表查询
 | 
	
		
			
				|  |  |  	 *
 | 
	
	
		
			
				|  | @@ -162,7 +255,8 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 | 
	
		
			
				|  |  |  		LambdaQueryWrapper<ViewClockIn> query = new LambdaQueryWrapper<ViewClockIn>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if(userName != null && userName != ""){
 | 
	
		
			
				|  |  | -			query.eq(ViewClockIn::getRealname,userName);//姓名
 | 
	
		
			
				|  |  | +			String[] s = userName.split("(");
 | 
	
		
			
				|  |  | +			query.eq(ViewClockIn::getRealname,s[0]);//姓名
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		if(mDate != null && mDate != ""){
 | 
	
		
			
				|  |  |  			query.eq(ViewClockIn::getHeadMonth,mDate);//月份
 | 
	
	
		
			
				|  | @@ -186,7 +280,10 @@ public class viewClockInController extends JeecgController<ViewClockIn, IviewClo
 | 
	
		
			
				|  |  |  		if(beginViewDate != null && beginViewDate != "" && !beginViewDate.equals("1")){
 | 
	
		
			
				|  |  |  			query.between(ViewClockIn::getViewDate,beginViewDate,endViewDate);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		query.orderByDesc(ViewClockIn::getViewDate);
 | 
	
		
			
				|  |  | +		if(beginViewDate.equals("1") && mDate == null && viewClockIn.getViewDate() == null){
 | 
	
		
			
				|  |  | +			query.eq(ViewClockIn::getHeadMonth,DateUtils.getNYTime());//月份
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		query.orderByAsc(ViewClockIn::getViewDate);
 | 
	
		
			
				|  |  |  		Page<ViewClockIn> page = new Page<ViewClockIn>(pageNo, pageSize);
 | 
	
		
			
				|  |  |  		IPage<ViewClockIn> pageList = viewClockInService.page(page, query);
 | 
	
		
			
				|  |  |  		return Result.OK(pageList);
 |