KqglServiceImpl.java 59.1 KB
Newer Older
lal committed
1 2
package cn.timer.api.controller.kqgl.service;

lal committed
3
import java.math.BigDecimal;
lal committed
4
import java.text.ParseException;
lal committed
5
import java.text.SimpleDateFormat;
lal committed
6
import java.util.ArrayList;
lal committed
7
import java.util.Date;
lal committed
8
import java.util.List;
lal committed
9 10

import org.springframework.beans.factory.annotation.Autowired;
ilal committed
11
import org.springframework.beans.factory.annotation.Value;
lal committed
12 13
import org.springframework.stereotype.Service;

lal committed
14 15
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

lal committed
16 17
import cn.timer.api.bean.kqmk.KqglAssoBcsz;
import cn.timer.api.bean.kqmk.KqglAssoDkjl;
lal committed
18
import cn.timer.api.bean.kqmk.KqglAssoDkmx;
lal committed
19
import cn.timer.api.bean.kqmk.KqglAssoLeaveBalance;
lal committed
20
import cn.timer.api.bean.kqmk.KqglAssoLeaveEmployeeBalance;
lal committed
21
import cn.timer.api.bean.kqmk.KqglAssoLeaveRules;
lal committed
22
import cn.timer.api.bean.kqmk.KqglAssoLeaveRulesT;
lal committed
23 24
import cn.timer.api.bean.kqmk.KqglAssoOvertimeRange;
import cn.timer.api.bean.kqmk.KqglAssoOvertimeRules;
lal committed
25
import cn.timer.api.bean.kqmk.KqglAssoRelationSummary;
lal committed
26
import cn.timer.api.bean.kqmk.KqglAssoTeshu;
lal committed
27
import cn.timer.api.bean.kqmk.KqglAssoYhkqz;
lal committed
28
import cn.timer.api.bean.kqmk.KqglAssoZhoupaiban;
lal committed
29
import cn.timer.api.bean.kqmk.KqglMainKqz;
lal committed
30
import cn.timer.api.bean.yggl.YgglMainEmp;
lal committed
31
import cn.timer.api.config.exception.CustomException;
lal committed
32
import cn.timer.api.controller.kqgl.ClockInTool;
lal committed
33
import cn.timer.api.controller.kqgl.EmptyUtil;
lal committed
34
import cn.timer.api.dao.kqmk.KqglAssoLeaveBalanceMapper;
lal committed
35
import cn.timer.api.dao.kqmk.KqglAssoPbmxMapper;
ilal committed
36
import cn.timer.api.dao.kqmk.KqglAssoRelationSummaryMapper;
lal committed
37
import cn.timer.api.dao.kqmk.KqglMainKqzMapper;
lal committed
38
import cn.timer.api.dto.kqmk.AttEvectionApprovalDto;
lal committed
39
import cn.timer.api.dto.kqmk.AttLateLate;
lal committed
40 41 42
import cn.timer.api.dto.kqmk.AttLeaveApprovalDto;
import cn.timer.api.dto.kqmk.AttOvertimeApprovalDto;
import cn.timer.api.dto.kqmk.AttRepairApprovalDto;
lal committed
43 44
import cn.timer.api.dto.kqmk.AttSchedule;
import cn.timer.api.dto.kqmk.AttendanceCardListDto;
lal committed
45
import cn.timer.api.dto.kqmk.KqglAssoPbmxDto;
lal committed
46
import cn.timer.api.utils.DateUtil;
ilal committed
47
import cn.timer.api.utils.ResultUtil;
lal committed
48

lal committed
49 50 51 52
/**
 * @author lal
 *	记录用户假期审批流程  对应减去剩余余额
 */
lal committed
53 54 55
@Service
public class KqglServiceImpl implements KqglService {

lal committed
56 57 58
	@Autowired
	private KqglAssoLeaveBalanceMapper kqglassoleavebalancemapper;
	
lal committed
59 60 61 62 63
	/**
	 * 考勤请假审批
	 */
	@Override
	public boolean attleaveapproval(AttLeaveApprovalDto leaveappr) {
lal committed
64 65
		String startdate = new SimpleDateFormat("yyyy-MM-dd").format(leaveappr.getStarttime());
		String enddate = new SimpleDateFormat("yyyy-MM-dd").format(leaveappr.getEndtime());
lal committed
66
		String[] days=ClockInTool.listToString(ClockInTool.getDays(startdate,enddate)).split(",");
lal committed
67
		int i = 1;
lal committed
68 69 70
		for(String num : days) {
			//记入打卡月汇总关联表
			KqglAssoRelationSummary.builder().userId(leaveappr.getUserid()).appTime(num).approvalId(leaveappr.getLeaveid()).approvalType(2).duration(leaveappr.getDuration())
lal committed
71
				.leaveTypeId(leaveappr.getLeavetype()).startTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(leaveappr.getStarttime()))
lal committed
72 73
				.endTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(leaveappr.getEndtime())).orgCode(leaveappr.getOrgcode()).ordernum(i).totals(days.length).build().insert();
			i++;
lal committed
74
		}
lal committed
75
		YgglMainEmp emp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, leaveappr.getUserid()).eq(YgglMainEmp::getOrgCode, leaveappr.getOrgcode()));
lal committed
76
		
lal committed
77
		int modifynumber = 1;
lal committed
78
		KqglAssoLeaveBalance balan = kqglassoleavebalancemapper.selectOne(new QueryWrapper<KqglAssoLeaveBalance>().lambda().eq(KqglAssoLeaveBalance::getUserid, leaveappr.getUserid()).eq(KqglAssoLeaveBalance::getOrgCode, leaveappr.getOrgcode())
lal committed
79 80 81 82
				.orderByDesc(KqglAssoLeaveBalance :: getModifyNumber).last("LIMIT 1"));
		if(balan != null) {
			modifynumber = balan.getModifyNumber()+1;
		}
lal committed
83 84 85 86 87 88 89 90
		
		String mse = "考勤请假审批";
		KqglAssoLeaveRulesT rult = KqglAssoLeaveRulesT.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveRulesT>().lambda().eq(KqglAssoLeaveRulesT::getId, leaveappr.getLeavetype()));
		if(rult != null) {
			mse = "考勤"+rult.getName()+"审批";
		}
		
		
lal committed
91
		KqglAssoLeaveBalance.builder().leaveRulesId(leaveappr.getLeavetype()).userid(leaveappr.getUserid()).modifyAction(2).balanceDays("-"+leaveappr.getDuration())
lal committed
92
		.reason(mse).modifyUserid(emp.getEmpNum()).modifyTimer(new Date().getTime()).orgCode(emp.getOrgCode()).isAutomatic(1).modifyNumber(modifynumber).build().insert();//员工假期余额
lal committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
		
		
		//查询员工假期余额表中所对应的假期id
		KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, leaveappr.getLeavetype())
				.eq(KqglAssoLeaveEmployeeBalance::getUserid, leaveappr.getUserid()).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, leaveappr.getOrgcode()));
		
		//获取最后得到的最终余额
		double balance_days = kqglassoleavebalancemapper.Sumbalancedays(leaveappr.getUserid(), leaveappr.getOrgcode(),leaveappr.getLeavetype());
		if(emba != null && balance_days > 0) {
			if(emba.getBalanceDays() != -1) {//确认为限制余额的
				//修改最终的余额数
				KqglAssoLeaveEmployeeBalance.builder().id(emba.getId()).balanceDays(balance_days).build().updateById();
			}
		}
		
lal committed
108 109 110 111 112 113 114 115
		return true;
	}

	/**
	 * 考勤加班审批
	 */
	@Override
	public boolean attovertimeapproval(AttOvertimeApprovalDto overappr) {
lal committed
116 117
		String startdate = new SimpleDateFormat("yyyy-MM-dd").format(overappr.getStarttime());
		String enddate = new SimpleDateFormat("yyyy-MM-dd").format(overappr.getEndtime());
lal committed
118
		String[] days=ClockInTool.listToString(ClockInTool.getDays(startdate,enddate)).split(",");
lal committed
119
		int i = 1;
lal committed
120 121 122
		for(String num : days) {
			//记入打卡月汇总关联表
			KqglAssoRelationSummary.builder().userId(overappr.getUserid()).appTime(num).approvalId(overappr.getOvertimeid()).approvalType(1).duration(overappr.getDuration())
lal committed
123
				.overtimeTypeId(overappr.getOvertimetype()).compensateId(overappr.getCompensate()).startTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(overappr.getStarttime()))
lal committed
124 125
				.endTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(overappr.getEndtime())).ordernum(i).orgCode(overappr.getOrgcode()).totals(days.length).build().insert();
			i++;
lal committed
126
		}
lal committed
127
		
lal committed
128
		YgglMainEmp emp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, overappr.getUserid()).eq(YgglMainEmp::getOrgCode, overappr.getOrgcode()));
lal committed
129 130 131 132
		
		//查询当前公司调休的id
		KqglAssoLeaveRules learul = KqglAssoLeaveRules.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, emp.getOrgCode()).eq(KqglAssoLeaveRules::getRulesType, 2));
		
lal committed
133 134
		//
		if(overappr.getCompensate() == 1 || overappr.getCompensate() == 3) {
lal committed
135
			
lal committed
136 137
			double duration = 0l;//
			
lal committed
138
			int modifynumber = 1;
lal committed
139
			KqglAssoLeaveBalance balan = kqglassoleavebalancemapper.selectOne(new QueryWrapper<KqglAssoLeaveBalance>().lambda().eq(KqglAssoLeaveBalance::getUserid, overappr.getUserid()).eq(KqglAssoLeaveBalance::getOrgCode, overappr.getOrgcode())
lal committed
140 141 142 143 144
					.orderByDesc(KqglAssoLeaveBalance :: getModifyNumber).last("LIMIT 1"));
			if(balan != null) {
				modifynumber = balan.getModifyNumber()+1;
			}
			
lal committed
145
			
lal committed
146 147 148 149 150 151 152 153 154
			KqglAssoYhkqz yhd = KqglAssoYhkqz.builder().build().selectOne(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, overappr.getUserid()).eq(KqglAssoYhkqz::getQyid, overappr.getOrgcode()));
			if(yhd != null) {
				KqglAssoOvertimeRange timeran = KqglAssoOvertimeRange.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, yhd.getKqzid()));
				if(timeran != null) {
					KqglAssoOvertimeRules rul = KqglAssoOvertimeRules.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRules>().lambda().eq(KqglAssoOvertimeRules::getId, timeran.getOvertimeRulesId()));
					if(rul != null) {
						//1:工作日加班;2:休息日加班;3:节假日加班
						if(overappr.getOvertimetype() == 1) {
							if(rul.getIsWorkovertime() == 1) {
lal committed
155
								if(rul.getWork() == 1) {//1:调休  2:加班费  3:调休/加班费
lal committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
									duration = Double.valueOf(rul.getWorkOne()) * overappr.getDuration();
								}else if(rul.getWork() == 3) {
									duration = Double.valueOf(rul.getWorkThree()) * overappr.getDuration();
								}
							}
						}else if(overappr.getOvertimetype() == 2) {
							if(rul.getIsRestovertime() == 1) {
								if(rul.getRest() == 1) {
									duration = Double.valueOf(rul.getRestOne()) * overappr.getDuration();
								}else if(rul.getRest() == 3) {
									duration = Double.valueOf(rul.getRestThree()) * overappr.getDuration();
								}
							}
						}else {
							if(rul.getIsHolidays() == 1) {
								if(rul.getHolidays() == 1) {
									duration = Double.valueOf(rul.getHolidaysOne()) * overappr.getDuration();
								}else if(rul.getHolidays() == 3) {
									duration = Double.valueOf(rul.getHolidaysThree()) * overappr.getDuration();
								}
							}
						}
					}
				}
			}
lal committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
				
			//调休单位是“天”时    按照=》加班时长/班次的工作时长=调休天数
			if(learul.getCompany() == 1) {
				try {
					AttendanceCardListDto attdate = MethodCall(overappr.getOrgcode(),overappr.getUserid(),startdate);//获取当天打卡班次信息
					
					long starttime1 = 0,endtime1 = 0,starttime2 = 0,endtime2 = 0,starttime3 = 0,endtime3 = 0; 
					double time1 = 0,time2 = 0,time3 = 0;
					
					BigDecimal num0 = new BigDecimal(60);
					if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {//班次不为空
						List<AttSchedule> ash = attdate.getAttsch();//获取当天应打卡时间
						if(attdate.getAttsch().size() == 2 || attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
							 starttime1 = ash.get(0).getTime();
							 endtime1 = ash.get(1).getTime();
							 
							 BigDecimal num = new BigDecimal((endtime1 - starttime1)/1000/60);
							 time1 = num.divide(num0,2,BigDecimal.ROUND_HALF_UP).doubleValue();
						 }
					 	if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
					 		starttime2 = ash.get(2).getTime();
						    endtime2 = ash.get(3).getTime();
						    
						    BigDecimal num = new BigDecimal((endtime2 - starttime2)/1000/60);
							time2 = num.divide(num0,2,BigDecimal.ROUND_HALF_UP).doubleValue();
						}
					 	if(attdate.getAttsch().size() == 6) {
					 		starttime3 = ash.get(4).getTime();
							endtime3 = ash.get(5).getTime();
							
							BigDecimal num = new BigDecimal((endtime3 - starttime3)/1000/60);
							time3 = num.divide(num0,2,BigDecimal.ROUND_HALF_UP).doubleValue();
						 }
					}
					
					BigDecimal num1 = new BigDecimal(time1);
					BigDecimal num2 = new BigDecimal(time2);
					BigDecimal num3 = num1.add(num2);
					BigDecimal num4 = new BigDecimal(time3);
					double shift_duration = ClockInTool.round(num3.add(num4).doubleValue());//班次时长
					
lal committed
222 223 224
					if(shift_duration > 0) {
						BigDecimal num5 = new BigDecimal(duration);
						BigDecimal num6 = new BigDecimal(shift_duration);
lal committed
225

lal committed
226 227 228
						//加班时长/班次的工作时长=调休天数
						duration = num5.divide(num6,2,BigDecimal.ROUND_HALF_UP).doubleValue();
					}
lal committed
229 230 231 232 233 234
					
				} catch (ParseException e) {
					e.printStackTrace();
				}
				
			}
lal committed
235 236
			
			KqglAssoLeaveBalance.builder().leaveRulesId(learul.getId()).userid(overappr.getUserid()).modifyAction(2).balanceDays("+"+duration)
lal committed
237
			.reason("考勤加班审批").modifyUserid(emp.getEmpNum()).modifyTimer(overappr.getStarttime()).orgCode(emp.getOrgCode()).isAutomatic(1).modifyNumber(modifynumber).build().insert();//员工假期余额
lal committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
			
			
			//查询员工假期余额表中所对应的假期id
			KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, learul.getId())
					.eq(KqglAssoLeaveEmployeeBalance::getUserid, overappr.getUserid()).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, overappr.getOrgcode()));
			
			//获取最后得到的最终余额
			double balance_days = kqglassoleavebalancemapper.Sumbalancedays(overappr.getUserid(), overappr.getOrgcode(),learul.getId());
			if(emba != null && balance_days > 0) {
				if(emba.getBalanceDays() != -1) {//确认为限制余额的
					//修改最终的余额数
					KqglAssoLeaveEmployeeBalance.builder().id(emba.getId()).balanceDays(balance_days).build().updateById();
				}
			}
			
lal committed
253 254
		}
		
lal committed
255 256 257 258 259 260 261 262
		return true;
	}

	/**
	 * 考勤出差外出审批
	 */
	@Override
	public boolean attevectionapproval(AttEvectionApprovalDto evecappr) {
lal committed
263 264 265
		if(evecappr.getEvectiontype() == 1) {	//出差
			String startdate = new SimpleDateFormat("yyyy-MM-dd").format(evecappr.getStarttime());
			String enddate = new SimpleDateFormat("yyyy-MM-dd").format(evecappr.getEndtime());
lal committed
266
			String[] days=ClockInTool.listToString(ClockInTool.getDays(startdate,enddate)).split(",");
lal committed
267
			int i = 1;
lal committed
268 269
			for(String num : days) {
				//记入打卡月汇总关联表
lal committed
270
				KqglAssoRelationSummary.builder().userId(evecappr.getUserid()).appTime(num).approvalId(evecappr.getEvectionid()).approvalType(3).duration(evecappr.getDuration())
lal committed
271
					.startTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(evecappr.getStarttime())).endTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(evecappr.getEndtime()))
lal committed
272 273
					.orgCode(evecappr.getOrgcode()).ordernum(i).totals(days.length).build().insert();
				i++;
lal committed
274 275 276 277
			}
		}else {	//外出
			String startdate = new SimpleDateFormat("yyyy-MM-dd").format(evecappr.getStarttime());
			String enddate = new SimpleDateFormat("yyyy-MM-dd").format(evecappr.getEndtime());
lal committed
278
			String[] days=ClockInTool.listToString(ClockInTool.getDays(startdate,enddate)).split(",");
lal committed
279
			int i = 1;
lal committed
280 281
			for(String num : days) {
				//记入打卡月汇总关联表
lal committed
282
				KqglAssoRelationSummary.builder().userId(evecappr.getUserid()).appTime(num).approvalId(evecappr.getEvectionid()).approvalType(4).duration(evecappr.getDuration())
lal committed
283
					.startTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(evecappr.getStarttime())).endTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(evecappr.getEndtime()))
lal committed
284 285
					.orgCode(evecappr.getOrgcode()).ordernum(i).totals(days.length).build().insert();
				i++;
lal committed
286 287
			}
		}
lal committed
288 289 290
		return true;
	}

lal committed
291 292 293
	@Autowired
	private KqglMainKqzMapper kqglmainkqzmapper;
	
ilal committed
294 295 296
	@Autowired
	private KqglAssoRelationSummaryMapper kqglassorelationsummarymapper;
	
lal committed
297 298 299 300 301
	/**
	 * 考勤补卡审批
	 */
	@Override
	public boolean attrepairapproval(AttRepairApprovalDto repaappr) {
lal committed
302
		String cardrepltime = new SimpleDateFormat("yyyy-MM-dd").format(repaappr.getCardrepltime());//补卡时间
lal committed
303 304 305
		
		boolean isRange = true;
		
lal committed
306 307 308 309 310 311
		int atttype = 0;//类型(0:无排班打卡 1:上班 2:下班)
		int results = 0;//打卡结果
		int type = 0;
		long attime = 0l;//应打卡时间戳
		int dkmxid = 0;//打卡明细ID
		
lal committed
312 313 314 315 316 317 318 319 320
		Long start_time = null;
		Long end_time = null;
		try {
			start_time = DateUtil.getStartTime(0,DateUtil.getStringTime(cardrepltime,"yyyy-MM-dd")).getTime();
			end_time = DateUtil.getnowEndTime(23,DateUtil.getStringTime(cardrepltime,"yyyy-MM-dd")).getTime();
		} catch (ParseException e1) {
			e1.printStackTrace();
		}
		
lal committed
321
		//记入打卡月汇总关联表
lal committed
322 323
		KqglAssoRelationSummary.builder().userId(repaappr.getUserid()).appTime(cardrepltime).approvalId(repaappr.getRepairid()).approvalType(5).startTime(new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(repaappr.getCardrepltime())).orgCode(repaappr.getOrgcode()).build().insert();
		
lal committed
324
		int shifid = 0;
lal committed
325 326 327
		try {
			KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(repaappr.getUserid(),repaappr.getOrgcode()); //考勤组信息
			if(attgro != null) {
lal committed
328
				AttendanceCardListDto attdate = MethodCall(repaappr.getOrgcode(),repaappr.getUserid(),cardrepltime);//获取当天打卡班次信息
329 330 331
				//排班方式 // 考勤类型:1-固定排班、2-排班制、3-自由工时
				//自由工时无班次ID 另行逻辑
				if(attgro.getPbfs()<3 && EmptyUtil.isNotEmpty(attdate.getAttsch())) {//班次不为空
lal committed
332
					List<AttSchedule> ash = attdate.getAttsch();//获取当天应打卡时间
lal committed
333
					shifid = ash.get(0).getId();//班次id
lal committed
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
					long starttime1 = 0,starttime1ks = 0,starttime1js = 0,endtime1 = 0,endtime1ks = 0,endtime1js = 0,starttime2 = 0,starttime2ks = 0,starttime2js = 0,endtime2 = 0,endtime2ks = 0,endtime2js = 0,starttime3 = 0,starttime3ks = 0,starttime3js = 0,
							endtime3 = 0,endtime3ks = 0,endtime3js = 0; 
					if(attdate.getAttsch().size() == 2 || attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
						 starttime1 = ash.get(0).getTime();starttime1ks = ash.get(0).getStarttime();starttime1js = ash.get(0).getEndtime();
						 endtime1 = ash.get(1).getTime();endtime1ks = ash.get(1).getStarttime();endtime1js = ash.get(1).getEndtime();
					 }
				 	if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
				 		starttime2 = ash.get(2).getTime();starttime2ks = ash.get(2).getStarttime();starttime2js = ash.get(2).getEndtime();
					    endtime2 = ash.get(3).getTime();endtime2ks = ash.get(3).getStarttime();endtime2js = ash.get(3).getEndtime();
					}
				 	if(attdate.getAttsch().size() == 6) {
				 		starttime3 = ash.get(4).getTime();starttime3ks = ash.get(4).getStarttime();starttime3js = ash.get(4).getEndtime();
						endtime3 = ash.get(5).getTime();endtime3ks = ash.get(5).getStarttime();endtime3js = ash.get(5).getEndtime();
					 }
					
lal committed
349 350 351 352
		    		if(ash.get(0).getId() != 0) { //有排班  非休息
		    			
		    			KqglAssoBcsz shif = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, shifid));
		    			
lal committed
353 354 355
		    			KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, repaappr.getUserid()).eq(KqglAssoDkmx::getQyid, repaappr.getOrgcode())
								.ge(KqglAssoDkmx::getDksj, start_time).le(KqglAssoDkmx::getDksj, end_time));//获取补卡当天是否有打卡记录
		    			if(dkmc != null) {
lal committed
356
		    				dkmxid = dkmc.getId();
lal committed
357
		    				if(attdate.getAttsch().size() == 2) {//一套班次
lal committed
358
		    					if(repaappr.getCardreplperiod() == 1 && dkmc.getSbdk1() == null) {//上班
lal committed
359 360 361 362 363 364 365
		    						if(starttime1ks > 0 && starttime1js > 0) {
//		    							boolean sb1 = verification_range(starttime1ks,starttime1js,repaappr.getCardrepltime());
		    							 String staputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1ks);//应打卡开始时间
		    							 String entputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1js);//应打卡结束时间
		    							 String DKputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(repaappr.getCardrepltime());//打卡时间
		    							 boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"yyyy-MM-dd HH:mm");
		    							 if (!effectiveDate) {
ilal committed
366
		    								 Logoutput("当前打卡时间不在范围内");
lal committed
367 368 369
		    								 isRange = false;
		    							 }
		    						}
lal committed
370
		    						int sbdkjg = 0;
lal committed
371 372 373 374 375 376 377 378 379 380 381
		    						if(isRange) {
			    						Long time = (repaappr.getCardrepltime() - starttime1)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 
										 Double gzsctime = null;//工作时长
										 if(dkmc.getXbdk1() != null){
											 Long time1 = (repaappr.getCardrepltime() - dkmc.getXbdk1())/1000/60;
											 gzsctime = Math.abs(Double.valueOf(time1.toString()));//只打一次卡时计算工作时长
										 }
lal committed
382
		    							KqglAssoDkmx.builder().id(dkmc.getId()).sbdk1(repaappr.getCardrepltime()).sbdk1jg(sbdkjg).dktj1(1).gzsc(gzsctime).build().updateById();
lal committed
383 384
		    						}
		    						
lal committed
385 386 387 388
		    						atttype = 1;
		    						results = sbdkjg;
		    						attime = starttime1;
		    					}else if(repaappr.getCardreplperiod() == 2 && dkmc.getXbdk1() == null) {//下班
lal committed
389 390 391 392 393 394
		    						if(endtime1ks > 0 && endtime1js > 0) {
		    							 String staputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1ks);//应打卡开始时间
		    							 String entputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1js);//应打卡结束时间
		    							 String DKputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(repaappr.getCardrepltime());//打卡时间
		    							 boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"yyyy-MM-dd HH:mm");
		    							 if (!effectiveDate) {
ilal committed
395
		    								 Logoutput("当前打卡时间不在范围内");
lal committed
396 397 398
		    								 isRange = false;
		    							 }
		    						}
lal committed
399
		    						int xbdk1jg = 0;
lal committed
400
		    						if(isRange) {
lal committed
401
		    							
lal committed
402 403 404 405 406 407 408 409 410
		    							Long time = (repaappr.getCardrepltime() - endtime1)/1000/60;
										 if(time > 0){}else{
											 xbdk1jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长
										 if(dkmc.getSbdk1() != null) {
											 Long time1 = (repaappr.getCardrepltime() - dkmc.getSbdk1())/1000/60;
											 gzsctime = Math.abs(Double.valueOf(time1.toString()));
										 }
lal committed
411
										 KqglAssoDkmx.builder().id(dkmc.getId()).xbdk1(repaappr.getCardrepltime()).xbdk1jg(xbdk1jg).dktj2(1).gzsc(gzsctime).build().updateById();
lal committed
412
		    						}
lal committed
413 414 415 416
		    						
		    						atttype = 2;
		    						results = xbdk1jg;
		    						attime = endtime1;
lal committed
417 418 419 420
		    					}
		    				}else if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
		    					if(repaappr.getCardreplperiod() == 1) {
		    						boolean sb1 = verification_range(starttime1ks,starttime1js,repaappr.getCardrepltime());
lal committed
421
		    						if(sb1 && dkmc.getSbdk1() == null) {
lal committed
422
		    							int sbdkjg = 0;
lal committed
423 424 425 426 427 428
			    						Long time = (repaappr.getCardrepltime() - starttime1)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长

lal committed
429
		    							KqglAssoDkmx.builder().id(dkmc.getId()).sbdk1(repaappr.getCardrepltime()).sbdk1jg(sbdkjg).dktj1(1).gzsc(gzsctime).build().updateById();
lal committed
430 431 432 433
		    							
		    							atttype = 1;
		    							results = sbdkjg;
		    							attime = starttime1;
lal committed
434 435 436
		    						}
		    						
		    						boolean sb2 = verification_range(starttime2ks,starttime2js,repaappr.getCardrepltime());
lal committed
437
		    						if(sb2 && dkmc.getSbdk2() == null) {
lal committed
438
		    							int sbdkjg = 0;
lal committed
439 440 441 442 443 444
			    						Long time = (repaappr.getCardrepltime() - starttime2)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长

lal committed
445
		    							KqglAssoDkmx.builder().id(dkmc.getId()).sbdk2(repaappr.getCardrepltime()).sbdk2jg(sbdkjg).dktj3(1).gzsc(gzsctime).build().updateById();
lal committed
446 447 448 449
		    							
		    							atttype = 3;
		    							results = sbdkjg;
		    							attime = starttime2;
lal committed
450 451 452 453
		    						}
		    						
		    					}else if(repaappr.getCardreplperiod() == 2) {
		    						boolean xb1 = verification_range(endtime1ks,endtime1js,repaappr.getCardrepltime());
lal committed
454
		    						if(xb1 && dkmc.getXbdk1() == null) {
lal committed
455
		    							int xbdk1jg = 0;
lal committed
456 457 458 459 460 461
		    							Long time = (repaappr.getCardrepltime() - endtime1)/1000/60;
										 if(time > 0){}else{
											 xbdk1jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长

lal committed
462
										 KqglAssoDkmx.builder().id(dkmc.getId()).xbdk1(repaappr.getCardrepltime()).xbdk1jg(xbdk1jg).dktj2(1).gzsc(gzsctime).build().updateById();
lal committed
463 464 465 466
										 
										 atttype = 2;
										 results = xbdk1jg;
										 attime = endtime1;
lal committed
467 468 469
		    						}
		    						
		    						boolean xb2 = verification_range(endtime2ks,endtime2js,repaappr.getCardrepltime());
lal committed
470
		    						if(xb2 && dkmc.getXbdk2() == null) {
lal committed
471
		    							int xbdk2jg = 0;
lal committed
472 473 474 475 476 477
		    							Long time = (repaappr.getCardrepltime() - endtime2)/1000/60;
										 if(time > 0){}else{
											 xbdk2jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长

lal committed
478
										 KqglAssoDkmx.builder().id(dkmc.getId()).xbdk2(repaappr.getCardrepltime()).xbdk2jg(xbdk2jg).dktj4(1).gzsc(gzsctime).build().updateById();
lal committed
479 480 481 482
										 
										 atttype = 4;
										 results = xbdk2jg;
										 attime = endtime2;
lal committed
483 484 485 486 487 488
		    						}
		    						
		    					}
		    				}else if(attdate.getAttsch().size() == 6) {
		    					if(repaappr.getCardreplperiod() == 1) {
		    						boolean sb3 = verification_range(starttime3ks,starttime3js,repaappr.getCardrepltime());
lal committed
489
		    						if(sb3 && dkmc.getSbdk3() == null) {
lal committed
490
		    							int sbdkjg = 0;
lal committed
491 492 493 494 495 496
			    						Long time = (repaappr.getCardrepltime() - starttime3)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长

lal committed
497
		    							KqglAssoDkmx.builder().id(dkmc.getId()).sbdk3(repaappr.getCardrepltime()).sbdk3jg(sbdkjg).dktj5(1).gzsc(gzsctime).build().updateById();
lal committed
498 499 500
		    							 atttype = 5;
		    							 results = sbdkjg;
		    							 attime = starttime3;
lal committed
501 502 503 504
		    						}
		    						
		    					}else if(repaappr.getCardreplperiod() == 2) {
		    						boolean xb3 = verification_range(endtime3ks,endtime3js,repaappr.getCardrepltime());
lal committed
505
		    						if(xb3 && dkmc.getXbdk3() == null) {
lal committed
506
		    							int xbdk3jg = 0;
lal committed
507 508 509 510 511 512
		    							Long time = (repaappr.getCardrepltime() - endtime3)/1000/60;
										 if(time > 0){}else{
											 xbdk3jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 Double gzsctime = null;//工作时长

lal committed
513
										 KqglAssoDkmx.builder().id(dkmc.getId()).xbdk3(repaappr.getCardrepltime()).xbdk3jg(xbdk3jg).dktj6(1).gzsc(gzsctime).build().updateById();
lal committed
514 515 516
										 atttype = 6;
										 results = xbdk3jg;
										 attime = endtime3;
lal committed
517 518 519 520 521
		    						}
		    						
		    					}
		    				}
		    				
lal committed
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
		    			}else {//补卡当天无打卡记录时
		    				
		    				KqglAssoDkmx pcd = KqglAssoDkmx.builder().userid(repaappr.getUserid()).data(cardrepltime).qyid(repaappr.getOrgcode()).dksj(start_time).ydkcs(shif.getSxbcs()*2)
		    						.gzsc(0d).build();
		    				
//		    				int yzcd = shif.getYzcdfzs();//严重迟到分钟数
//							int kgcdfzs  = shif.getKgcdfzs();//旷工迟到分钟数 
		    				
		    				if(attdate.getAttsch().size() == 2) {//一套班次
		    					if(repaappr.getCardreplperiod() == 1) {//上班
		    						if(starttime1ks > 0 && starttime1js > 0) {
		    							 String staputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1ks);//应打卡开始时间
		    							 String entputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1js);//应打卡结束时间
		    							 String DKputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(repaappr.getCardrepltime());//打卡时间
		    							 boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"yyyy-MM-dd HH:mm");
		    							 if (!effectiveDate) {
ilal committed
538
		    								 Logoutput("当前打卡时间不在范围内");
lal committed
539 540 541
		    								 isRange = false;
		    							 }
		    						}
lal committed
542
		    						int sbdkjg = 0;
lal committed
543 544 545 546 547 548 549 550
		    						if(isRange) {
			    						Long time = (repaappr.getCardrepltime() - starttime1)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 
										 pcd.setSbdk1(repaappr.getCardrepltime());
										 pcd.setSbdk1jg(sbdkjg);
lal committed
551 552
										 pcd.setDktj1(1);
										 
lal committed
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
		    						}
		    						
		    						atttype = 1;
		    						results = sbdkjg;
		    						attime = starttime1;
		    					}else if(repaappr.getCardreplperiod() == 2) {//下班
		    						if(endtime1ks > 0 && endtime1js > 0) {
		    							 String staputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1ks);//应打卡开始时间
		    							 String entputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1js);//应打卡结束时间
		    							 String DKputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(repaappr.getCardrepltime());//打卡时间
		    							 boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"yyyy-MM-dd HH:mm");
		    							 if (!effectiveDate) {
ilal committed
569
		    								 Logoutput("当前打卡时间不在范围内");
lal committed
570 571 572
		    								 isRange = false;
		    							 }
		    						}
lal committed
573
		    						int xbdk1jg = 0;
lal committed
574 575 576 577 578 579 580 581 582
		    						if(isRange) {
		    							
		    							Long time = (repaappr.getCardrepltime() - endtime1)/1000/60;
										 if(time > 0){}else{
											 xbdk1jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 
										 pcd.setXbdk1(repaappr.getCardrepltime());
										 pcd.setXbdk1jg(xbdk1jg);
lal committed
583
										 pcd.setDktj2(1);
lal committed
584 585 586 587 588 589 590 591 592 593 594 595 596 597
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
		    						}
		    						
		    						atttype = 2;
		    						results = xbdk1jg;
		    						attime = endtime1;
		    					}
		    				}else if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
		    					if(repaappr.getCardreplperiod() == 1) {
		    						boolean sb1 = verification_range(starttime1ks,starttime1js,repaappr.getCardrepltime());
		    						if(sb1) {
lal committed
598
		    							int sbdkjg = 0;
lal committed
599 600 601 602 603 604 605
			    						Long time = (repaappr.getCardrepltime() - starttime1)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }

										 pcd.setSbdk1(repaappr.getCardrepltime());
										 pcd.setSbdk1jg(sbdkjg);
lal committed
606
										 pcd.setDktj1(1);
lal committed
607 608 609 610 611 612 613 614 615 616 617 618
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
		    							
		    							atttype = 1;
		    							results = sbdkjg;
		    							attime = starttime1;
		    						}
		    						
		    						boolean sb2 = verification_range(starttime2ks,starttime2js,repaappr.getCardrepltime());
		    						if(sb2) {
lal committed
619
		    							int sbdkjg = 0;
lal committed
620 621 622 623 624 625 626
			    						Long time = (repaappr.getCardrepltime() - starttime2)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }

										 pcd.setSbdk2(repaappr.getCardrepltime());
										 pcd.setSbdk2jg(sbdkjg);
lal committed
627
										 pcd.setDktj3(1);
lal committed
628 629 630 631 632 633 634 635 636 637 638 639 640
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
		    							
		    							atttype = 3;
		    							results = sbdkjg;
		    							attime = starttime2;
		    						}
		    						
		    					}else if(repaappr.getCardreplperiod() == 2) {
		    						boolean xb1 = verification_range(endtime1ks,endtime1js,repaappr.getCardrepltime());
		    						if(xb1) {
lal committed
641
		    							int xbdk1jg = 0;
lal committed
642 643 644 645 646 647 648
		    							Long time = (repaappr.getCardrepltime() - endtime1)/1000/60;
										 if(time > 0){}else{
											 xbdk1jg = Math.abs(Integer.valueOf(time.toString()));
										 }

										 pcd.setXbdk1(repaappr.getCardrepltime());
										 pcd.setXbdk1jg(xbdk1jg);
lal committed
649
										 pcd.setDktj2(1);
lal committed
650 651 652 653 654 655 656 657 658 659 660 661
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
										 
										 atttype = 2;
										 results = xbdk1jg;
										 attime = endtime1;
		    						}
		    						
		    						boolean xb2 = verification_range(endtime2ks,endtime2js,repaappr.getCardrepltime());
		    						if(xb2) {
lal committed
662
		    							int xbdk2jg = 0;
lal committed
663 664 665 666 667 668
		    							Long time = (repaappr.getCardrepltime() - endtime2)/1000/60;
										 if(time > 0){}else{
											 xbdk2jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 pcd.setXbdk2(repaappr.getCardrepltime());
										 pcd.setXbdk2jg(xbdk2jg);
lal committed
669
										 pcd.setDktj4(1);
lal committed
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
										 
										 atttype = 4;
										 results = xbdk2jg;
										 attime = endtime2;
		    						}
		    						
		    					}
		    				}else if(attdate.getAttsch().size() == 6) {
		    					if(repaappr.getCardreplperiod() == 1) {
		    						boolean sb3 = verification_range(starttime3ks,starttime3js,repaappr.getCardrepltime());
		    						if(sb3) {
lal committed
685
		    							int sbdkjg = 0;
lal committed
686 687 688 689 690 691 692
			    						Long time = (repaappr.getCardrepltime() - starttime3)/1000/60;
										 if(time > 0){//上班1打卡结果
											 sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										 }
										
										 pcd.setSbdk3(repaappr.getCardrepltime());
										 pcd.setSbdk3jg(sbdkjg);
lal committed
693
										 pcd.setDktj5(1);
lal committed
694 695 696 697 698 699 700 701 702 703 704 705 706
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
										 
		    							 atttype = 5;
		    							 results = sbdkjg;
		    							 attime = starttime3;
		    						}
		    						
		    					}else if(repaappr.getCardreplperiod() == 2) {
		    						boolean xb3 = verification_range(endtime3ks,endtime3js,repaappr.getCardrepltime());
		    						if(xb3) {
lal committed
707
		    							int xbdk3jg = 0;
lal committed
708 709 710 711 712 713 714 715
		    							Long time = (repaappr.getCardrepltime() - endtime3)/1000/60;
										 if(time > 0){}else{
											 xbdk3jg = Math.abs(Integer.valueOf(time.toString()));
										 }
										 
										 
										 pcd.setXbdk3(repaappr.getCardrepltime());
										 pcd.setXbdk3jg(xbdk3jg);
lal committed
716
										 pcd.setDktj6(1);
lal committed
717 718 719 720 721 722 723 724 725 726 727 728
										 
										 if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										 }
										 
										 atttype = 6;
										 results = xbdk3jg;
										 attime = endtime3;
		    						}
		    						
		    					}
		    				}
ilal committed
729 730 731 732 733
		    				if(isRange) {
		    					dkmxid = pcd.getId();
		    				}else {
		    					throw new CustomException("当前时间,没有考勤异常无需补卡");
		    				}
lal committed
734 735 736
		    				
		    			}
		    			
lal committed
737 738 739 740
		    			//0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休 
		    			//9:管理员改为正常 10:管理员改为迟到 11:管理员改为早退  12:补卡通过/正常 13:补卡通过/迟到 14:补卡通过/早退
		    			int status = 2;
		    			
lal committed
741 742
		    			if((atttype)%2 > 0){
		    				type = 1;
lal committed
743 744 745 746 747 748
		    				
		    				if(results == 0) {
		    					status = 12;
		    				}else {
		    					status = 13;
		    				}
lal committed
749 750
		    			}else {
		    				type = 2;
lal committed
751 752 753 754 755 756
		    				
		    				if(results == 0) {
		    					status = 12;
		    				}else {
		    					status = 14;
		    				}
lal committed
757 758
		    			}
		    			
lal committed
759 760 761 762 763
		    			Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(cardrepltime,"yyyy-MM-dd")).getTime();
		    			String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(startDate));//转换打卡时间格式
		    			
		    			//attime  应打卡时间
		    			
ilal committed
764 765 766
		    			double gzsc = 0;
		    			
		    			long rest_time = 0;
ilal committed
767
		    			if(shif.getStartTime() != null && !("").equals(shif.getStartTime()) && shif.getEndTime() != null && !("").equals(shif.getEndTime())) {
ilal committed
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
		    				long kaishixiuxi = Long.valueOf(ClockInTool.dateToStamp(cardrepltime + " " +shif.getStartTime()+":00"));
		    			    long jieshuxiuxi = Long.valueOf(ClockInTool.dateToStamp(cardrepltime + " " +shif.getEndTime()+":00"));
		    			    rest_time = (jieshuxiuxi - kaishixiuxi)/1000/60;//休息时间
		    			}
		    			
		    			//请假时长
		    			KqglAssoRelationSummary qjsc = kqglassorelationsummarymapper.Businessdayclockin(repaappr.getUserid(), 2, cardrepltime, repaappr.getOrgcode());
		    			
		    			//计算工作时长
		    			KqglAssoDkmx dkgzsc = KqglAssoDkmx.builder().id(dkmxid).build().selectById();
		    			if(dkgzsc.getYdkcs() == 2 || dkgzsc.getYdkcs() == 4 || dkgzsc.getYdkcs() == 6) {
		    				if(dkgzsc.getSbdk1() != null && dkgzsc.getXbdk1() != null) {
		    					gzsc = gzsc + (dkgzsc.getXbdk1() - dkgzsc.getSbdk1())/1000/60;
		    				}
		    			}
		    			if(dkgzsc.getYdkcs() == 4 || dkgzsc.getYdkcs() == 6) {
		    				if(dkgzsc.getSbdk2() != null && dkgzsc.getXbdk2() != null) {
		    					gzsc = gzsc + (dkgzsc.getXbdk2() - dkgzsc.getSbdk2())/1000/60;
		    				}
		    			}
		    			if(dkgzsc.getYdkcs() == 6) {
		    				if(dkgzsc.getSbdk3() != null && dkgzsc.getXbdk3() != null) {
		    					gzsc = gzsc + (dkgzsc.getXbdk3() - dkgzsc.getSbdk3())/1000/60;
		    				}
		    			}
		    			gzsc = gzsc - rest_time - qjsc.getDuration();
		    			
		    			KqglAssoDkmx.builder().id(dkmxid).gzsc(gzsc).build().updateById();
		    			
		    			
		    			
lal committed
799
		    			KqglAssoDkjl pre = KqglAssoDkjl.builder().dktime(repaappr.getCardrepltime()).results(results).userId(repaappr.getUserid()).type(type).status(status).sort(atttype)
lal committed
800 801 802 803 804 805 806 807
								.cardType(0).qyid(repaappr.getOrgcode()).attdate(attdate_+" "+ClockInTool.dateToWeek2(cardrepltime)).attime(attime).dkmxid(dkmxid).bcid(shifid).remarks("审批补卡通过打卡").punchmode(0)
								.punchequipment("").commentary("成功打卡").build();
						
						if (!pre.insert()) {
							throw new CustomException("打卡记录-新增异常-2");
						 }
		    			
		    			
lal committed
808 809
		    		}
				}
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
				if(attgro.getPbfs() == 3){
					long starttime1 = 0,starttime1ks = 0,starttime1js = 0,endtime1 = 0,endtime1ks = 0,endtime1js = 0,starttime2 = 0,starttime2ks = 0,starttime2js = 0,endtime2 = 0,endtime2ks = 0,endtime2js = 0,starttime3 = 0,starttime3ks = 0,starttime3js = 0,
							endtime3 = 0,endtime3ks = 0,endtime3js = 0;

						KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, repaappr.getUserid()).eq(KqglAssoDkmx::getQyid, repaappr.getOrgcode())
								.ge(KqglAssoDkmx::getDksj, start_time).le(KqglAssoDkmx::getDksj, end_time));//获取补卡当天是否有打卡记录
						if(dkmc != null) {
							dkmxid = dkmc.getId();
								if(repaappr.getCardreplperiod() == 1 && dkmc.getSbdk1() == null) {//上班
									int sbdkjg = 0;
									if(isRange) {
										Long time = (repaappr.getCardrepltime() - starttime1)/1000/60;
										if(time > 0){//上班1打卡结果
											sbdkjg = Math.abs(Integer.valueOf(time.toString()));
										}

										Double gzsctime = null;//工作时长
										if(dkmc.getXbdk1() != null){
											Long time1 = (repaappr.getCardrepltime() - dkmc.getXbdk1())/1000/60;
											gzsctime = Math.abs(Double.valueOf(time1.toString()));//只打一次卡时计算工作时长
										}
										KqglAssoDkmx.builder().id(dkmc.getId()).sbdk1(repaappr.getCardrepltime()).sbdk1jg(sbdkjg).dktj1(1).gzsc(gzsctime).build().updateById();
									}

									atttype = 1;
									results = sbdkjg;
								}else if(repaappr.getCardreplperiod() == 2 && dkmc.getXbdk1() == null) {//下班
									int xbdk1jg = 0;
									if(isRange) {

										Long time = (repaappr.getCardrepltime() - endtime1)/1000/60;
										if(time > 0){}else{
											xbdk1jg = Math.abs(Integer.valueOf(time.toString()));
										}
										Double gzsctime = null;//工作时长
										if(dkmc.getSbdk1() != null) {
											Long time1 = (repaappr.getCardrepltime() - dkmc.getSbdk1())/1000/60;
											gzsctime = Math.abs(Double.valueOf(time1.toString()));
										}
										KqglAssoDkmx.builder().id(dkmc.getId()).xbdk1(repaappr.getCardrepltime()).xbdk1jg(xbdk1jg).dktj2(1).gzsc(gzsctime).build().updateById();
									}

									atttype = 2;
									results = xbdk1jg;
								}

						}else {//补卡当天无打卡记录时

							KqglAssoDkmx pcd = KqglAssoDkmx.builder().userid(repaappr.getUserid()).data(cardrepltime).qyid(repaappr.getOrgcode()).dksj(start_time).ydkcs(2)
									.gzsc(0d).build();
								if(repaappr.getCardreplperiod() == 1) {//上班
									int sbdkjg = 0;
									if(isRange) {
										pcd.setSbdk1(repaappr.getCardrepltime());
										pcd.setSbdk1jg(sbdkjg);
										pcd.setDktj1(1);


										if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										}
									}

									atttype = 1;
								}else if(repaappr.getCardreplperiod() == 2) {//下班
									int xbdk1jg = 0;
									if(isRange) {

										pcd.setXbdk1(repaappr.getCardrepltime());
										pcd.setXbdk1jg(xbdk1jg);
										pcd.setDktj2(1);

										if (!pcd.insert()) {
											throw new CustomException("打卡明细-新增异常-1");
										}
									}
									atttype = 2;
								}
							if(isRange) {
								dkmxid = pcd.getId();
							}else {
								throw new CustomException("当前时间,没有考勤异常无需补卡");
							}

						}

						//0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休
						//9:管理员改为正常 10:管理员改为迟到 11:管理员改为早退  12:补卡通过/正常 13:补卡通过/迟到 14:补卡通过/早退
						int status = 2;

						if((atttype)%2 > 0){
							type = 1;

							if(results == 0) {
								status = 12;
							}else {
								status = 13;
							}
						}else {
							type = 2;

							if(results == 0) {
								status = 12;
							}else {
								status = 14;
							}
						}

						Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(cardrepltime,"yyyy-MM-dd")).getTime();
						String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(startDate));//转换打卡时间格式

						//attime  应打卡时间

						double gzsc = 0;

						//long rest_time = 0;
						/*if(shif.getStartTime() != null && !("").equals(shif.getStartTime()) && shif.getEndTime() != null && !("").equals(shif.getEndTime())) {
							long kaishixiuxi = Long.valueOf(ClockInTool.dateToStamp(cardrepltime + " " +shif.getStartTime()+":00"));
							long jieshuxiuxi = Long.valueOf(ClockInTool.dateToStamp(cardrepltime + " " +shif.getEndTime()+":00"));
							rest_time = (jieshuxiuxi - kaishixiuxi)/1000/60;//休息时间
						}*/

						//请假时长
						//KqglAssoRelationSummary qjsc = kqglassorelationsummarymapper.Businessdayclockin(repaappr.getUserid(), 2, cardrepltime, repaappr.getOrgcode());

						//计算工作时长
						KqglAssoDkmx dkgzsc = KqglAssoDkmx.builder().id(dkmxid).build().selectById();
						if(dkgzsc.getYdkcs() == 2 || dkgzsc.getYdkcs() == 4 || dkgzsc.getYdkcs() == 6) {
							if(dkgzsc.getSbdk1() != null && dkgzsc.getXbdk1() != null) {
								gzsc = gzsc + (dkgzsc.getXbdk1() - dkgzsc.getSbdk1())/1000/60;
							}
						}
						if(dkgzsc.getYdkcs() == 4 || dkgzsc.getYdkcs() == 6) {
							if(dkgzsc.getSbdk2() != null && dkgzsc.getXbdk2() != null) {
								gzsc = gzsc + (dkgzsc.getXbdk2() - dkgzsc.getSbdk2())/1000/60;
							}
						}
						if(dkgzsc.getYdkcs() == 6) {
							if(dkgzsc.getSbdk3() != null && dkgzsc.getXbdk3() != null) {
								gzsc = gzsc + (dkgzsc.getXbdk3() - dkgzsc.getSbdk3())/1000/60;
							}
						}
						//gzsc = gzsc - rest_time - qjsc.getDuration();

						KqglAssoDkmx.builder().id(dkmxid).gzsc(gzsc).build().updateById();



						KqglAssoDkjl pre = KqglAssoDkjl.builder().dktime(repaappr.getCardrepltime()).results(results).userId(repaappr.getUserid()).type(type).status(status).sort(atttype)
								.cardType(0).qyid(repaappr.getOrgcode()).attdate(attdate_+" "+ClockInTool.dateToWeek2(cardrepltime)).attime(repaappr.getCardrepltime()).dkmxid(dkmxid).bcid(shifid).remarks("审批补卡通过打卡").punchmode(0)
								.punchequipment("").commentary("成功打卡").build();

						if (!pre.insert()) {
							throw new CustomException("打卡记录-新增异常-2");
						}


					}
				//}
lal committed
969 970 971 972 973 974
			}
			
			
		} catch (ParseException e) {
			e.printStackTrace();
		}
lal committed
975 976
		
		
lal committed
977 978
		return true;
	}
lal committed
979 980 981 982 983 984 985 986 987
	
	
	public boolean verification_range(long punchstart,long punchend,long time_) {
		 boolean isRange = true;
		 String staputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(punchstart);//应打卡开始时间
		 String entputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(punchend);//应打卡结束时间
		 String DKputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_);//打卡时间
		 boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"yyyy-MM-dd HH:mm");
		 if (!effectiveDate) {
ilal committed
988
			 Logoutput("当前打卡时间不在范围内");
lal committed
989 990 991 992 993
			 isRange = false;
		 }
		 
		 return isRange;
	}
lal committed
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
	
	@Autowired
	private KqglAssoPbmxMapper kqglassopbmxmapper;
	
	public AttendanceCardListDto MethodCall(int qyid,int userid,String date) throws ParseException {
		 
		AttendanceCardListDto attcar = new AttendanceCardListDto();
		 String str = null;
		 if(!("").equals(date)){
			 str = date;
		 }else{
			 Date d = new Date();
			 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			 str = sdf.format(d);
		 }
//		 Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(str,"yyyy-MM-dd")).getTime();
//	     Long endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(str,"yyyy-MM-dd")).getTime();
		 
	     KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
	     
	     //pbfs:排班方式 1:固定排班;2:自由排班;3:自由工时
		 if(attgro != null){//判断当前用户是否加入到考勤组
			 //排班制
			 KqglAssoPbmxDto jrpb = kqglassopbmxmapper.getScheduleSpecificAttendance(attgro.getId(),userid,str);
		     //固定排班
		     int week = Integer.valueOf(ClockInTool.dateToWeek(str));//4
		     
		     KqglAssoZhoupaiban atwek = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
		    		 .eq(KqglAssoZhoupaiban::getType, week).ne(KqglAssoZhoupaiban::getBcid, 0));
			 
		    if(attgro.getPbfs() == 1){//固定排班
		    	if(atwek != null){//有固定周排班
		    		KqglAssoTeshu rest = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId())
		    				.eq(KqglAssoTeshu::getTsrq, str).eq(KqglAssoTeshu::getBcid, 0));
		    		if(rest != null){//今天休息  Sort返回0【特殊日期--休息】
		    			List<AttSchedule> atts = new ArrayList<AttSchedule>();
			    		AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
			    		atts.add(as);
			    		attcar.setAttsch(atts);
		    		}else{//今天上班
			    		KqglAssoBcsz bcz = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));
			    		
			    		if(bcz != null){
			    			Getshiftinformationbatch(bcz,attcar,str);
			    		}
		    		}
		    	}else{//必须打卡
		    		KqglAssoTeshu tsri = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId())
		    				.eq(KqglAssoTeshu::getTsrq, str).ne(KqglAssoTeshu::getBcid, 0));
		    		if(tsri != null){
		    			KqglAssoBcsz tsrq = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, tsri.getBcid()));
		    			if(tsrq!=null){
		    				Getshiftinformationbatch(tsrq,attcar,str);
		    			}
		    		}else{//休息
		    			List<AttSchedule> atts = new ArrayList<AttSchedule>();
			    		AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
			    		atts.add(as);
			    		attcar.setAttsch(atts);
		    		}
		    	}
			}else if(attgro.getPbfs() == 2){//自由排班
				//未排班时,员工可选择班次打卡
lal committed
1057 1058 1059 1060 1061
//			    if(attgro.getIsXzbcdk() == 1){
//			    	attcar.setOptscheduling(true);	
//			    }else{
//			    	attcar.setOptscheduling(false);
//			    }
lal committed
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
				if(jrpb != null){
					if(jrpb.getBcid() != 0){//有班次时("Bcid"不为0时)
						KqglAssoBcsz tsrq = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, jrpb.getBcid()));
						/**已简化**/
						Getshiftinformationbatch(tsrq,attcar,str);
					}else{//当天排班为休息
						List<AttSchedule> atts1 = new ArrayList<AttSchedule>();
			    		AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
			    		atts1.add(as);
			    		attcar.setAttsch(atts1);
					}
				}
			}else{//自由工时
				KqglAssoZhoupaiban wekz = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
						.eq(KqglAssoZhoupaiban::getBcid, 0).eq(KqglAssoZhoupaiban::getType, week));
				
				if(wekz != null){//
					String dada = str+" "+attgro.getKqkssjTime()+":00";
					attcar.setStapclotime(Long.valueOf(ClockInTool.dateToStamp(dada)));
				}
				
				if(!("").equals(attgro.getJbzdsc())){
					attcar.setCanpunchworkdate(Double.valueOf(attgro.getJbzdsc()));//上班打卡后多久大下班卡
				}
			}
		    if(jrpb != null || atwek != null){
		    	KqglAssoBcsz shif = KqglAssoBcsz.builder().build();
		    	if(attgro.getPbfs() == 1){
		    		shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));
		    	}else if(attgro.getPbfs() == 2){
		    		shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, jrpb.getBcid()));
		    	}
		    	
		    	if(shif != null){
		    		if(shif.getIsXbdk() == 1){
		    			attcar.setNoclockout(true);// 下班不用打卡
		    		}else{
		    			attcar.setNoclockout(false);// 下班不用打卡
		    		}
		    		attcar.setAllowlate(shif.getYxcdfzs());// 允许迟到分钟数
		    		attcar.setSeriouslate(shif.getYzcdfzs());// 严重迟到分钟数
		    		attcar.setAbsenteeismlate(shif.getKgcdfzs());// 旷工迟到分钟数
		    		if(shif.getIsWzwd() == 1){
		    			attcar.setIslatelate(true);// 晚走晚到
		    			List<AttLateLate> atwzwd = new ArrayList<AttLateLate>();
		    			int p = 0;
		    			if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1())){p = 2;}
		    			if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1()) && !("").equals(shif.getXbwz2()) && !("").equals(shif.getSbwd2())){p = 4;}
		    			if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1()) && !("").equals(shif.getXbwz2()) && !("").equals(shif.getSbwd2()) && !("").equals(shif.getXbwz3()) && !("").equals(shif.getSbwd3())){p = 6;}
		    			AttLateLate ala = AttLateLate.builder().build();
		    			ala.setLatewalk(shif.getXbwz1());
		    			ala.setArrivelate(shif.getSbwd1());
		    			atwzwd.add(ala);
		    			if(p == 4 || p == 6){
		    				AttLateLate alat = AttLateLate.builder().build();
		    				alat.setLatewalk(shif.getXbwz2());
		    				alat.setArrivelate(shif.getSbwd2());
		    				atwzwd.add(alat);
		    			}
		    			if(p == 6){
		    				AttLateLate alas = AttLateLate.builder().build();
		    				alas.setLatewalk(shif.getXbwz3());
		    				alas.setArrivelate(shif.getSbwd3());
		    				atwzwd.add(alas);
		    			}
		    			attcar.setAttlat(atwzwd);
		    		}else{
		    			attcar.setIslatelate(false);// 晚走晚到
		    		}
		    	}
		    }
		    attcar.setAttgrouptype(attgro.getPbfs());//1:固定排班;2:自由排班;3:自由工时
		 }else{
			 attcar.setAttgrouptype(0);//1:固定排班;2:自由排班;3:自由工时
		 }
		 return attcar;
	 }
	
	
	public void Getshiftinformationbatch(KqglAssoBcsz shiftm,AttendanceCardListDto attcar,String str){
		int isXbdk1Cr = shiftm.getIsXbdk1Cr();//下班1是否次日(0:否;1:是)
		int isSbdk2Cr = shiftm.getIsSbdk2Cr();//上班2是否次日(0:否;1:是)
		int isXbdk2Cr = shiftm.getIsXbdk2Cr();//下班2是否次日(0:否;1:是)
		int isSbdk3Cr = shiftm.getIsSbdk3Cr();//上班3是否次日(0:否;1:是)
		int isXbdk3Cr = shiftm.getIsXbdk3Cr();//下班3是否次日(0:否;1:是)
		
		//次日专用
		String next_day = ClockInTool.requires_extra_times(str,1,2,1);
		
		 List<AttSchedule> atts = new ArrayList<AttSchedule>();
	    	if(shiftm.getSxbcs() == 1 || shiftm.getSxbcs() == 2 || shiftm.getSxbcs() == 3){//1次上下班
	    		for(int o=0;o<2;o++){
	    			if(o==0){
			    		AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(1).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbdk1()+":00").replaceAll("\r|\n", ""))))
			    				.starttime(("").equals(shiftm.getSbqjks1()) || shiftm.getSbqjks1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjks1()+":00").replaceAll("\r|\n", ""))))
			    				.endtime(("").equals(shiftm.getSbqjjs1()) || shiftm.getSbqjjs1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjjs1()+":00").replaceAll("\r|\n", ""))))
			    				.nextday(0).build();
			    		
			    		atts.add(as);
	    			}else{
	    				//次日
	    				if(isXbdk1Cr > 0) {
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(2).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbdk1()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getXbqjks1()) || shiftm.getXbqjks1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjks1()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getXbqjjs1()) || shiftm.getXbqjjs1() ==null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjjs1()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(1).build();
				    		atts.add(as);
	    				}else {
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(2).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbdk1()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getXbqjks1()) || shiftm.getXbqjks1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjks1()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getXbqjjs1()) || shiftm.getXbqjjs1() ==null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjjs1()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(0).build();
				    		atts.add(as);
	    				}
			    		
	    			}
	    		}
	    		attcar.setAttsch(atts);
	    	}
	    	if(shiftm.getSxbcs() == 2 || shiftm.getSxbcs() == 3){//2次上下班
	    		for(int o=0;o<2;o++){
	    			if(o==0){
	    				if(isSbdk2Cr > 0) {//次日
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(3).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbdk2()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getSbqjks2())|| shiftm.getSbqjks2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjks2()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getSbqjjs2()) || shiftm.getSbqjjs2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjjs2()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(1).build();
				    		atts.add(as);
	    				}else {
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(3).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbdk2()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getSbqjks2())|| shiftm.getSbqjks2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjks2()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getSbqjjs2()) || shiftm.getSbqjjs2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjjs2()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(0).build();
				    		atts.add(as);
	    				}
			    		
	    			}else{
	    				if(isXbdk2Cr > 0) {//次日
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(4).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbdk2()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getXbqjks2()) || shiftm.getXbqjks2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjks2()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getXbqjjs2()) || shiftm.getXbqjjs2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjjs2()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(1).build();
				    		atts.add(as);
	    				}else {
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(4).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbdk2()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getXbqjks2()) || shiftm.getXbqjks2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjks2()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getXbqjjs2()) || shiftm.getXbqjjs2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjjs2()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(0).build();
				    		atts.add(as);
	    				}
			    		
	    			}
	    		}
	    		attcar.setAttsch(atts);
	    	}
	    	if(shiftm.getSxbcs() == 3){//3次上下班
	    		for(int o=0;o<2;o++){
	    			if(o==0){
	    				if(isSbdk3Cr > 0) {//次日
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(5).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbdk3()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getSbqjks3()) || shiftm.getSbqjks3() == null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjks3()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getSbqjjs3()) || shiftm.getSbqjjs3() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjjs3()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(1).build();
				    		atts.add(as);
	    				}else {
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(5).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbdk3()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getSbqjks3()) || shiftm.getSbqjks3() == null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjks3()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getSbqjjs3()) || shiftm.getSbqjjs3() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjjs3()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(0).build();
				    		atts.add(as);
	    				}
			    		
	    			}else{
	    				if(isXbdk3Cr > 0) {//次日
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(6).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbdk3()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getXbqjks3()) || shiftm.getXbqjks3()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjks3()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getXbqjjs3()) || shiftm.getXbqjjs3() ==null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjjs3()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(1).build();
				    		atts.add(as);
	    				}else {
	    					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(6).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbdk3()+":00").replaceAll("\r|\n", ""))))
				    				.starttime(("").equals(shiftm.getXbqjks3()) || shiftm.getXbqjks3()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjks3()+":00").replaceAll("\r|\n", ""))))
				    				.endtime(("").equals(shiftm.getXbqjjs3()) || shiftm.getXbqjjs3() ==null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjjs3()+":00").replaceAll("\r|\n", ""))))
				    				.nextday(0).build();
				    		atts.add(as);
	    				}
			    		
	    			}
	    		}
	    		attcar.setAttsch(atts);
	    	}
	 }
lal committed
1254

ilal committed
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267
	@Value("${config-8timer.environmental-science}")
	public String environmental_science;
	
	public void Logoutput(String science) {
		
		if(!("pro").equals(environmental_science)) {
			
			System.out.println(science);
		}else {
			System.out.println("");
		}
		
	}
lal committed
1268
}