TimeCardController.java 109 KB
Newer Older
ilal committed
1 2
package cn.timer.api.controller.kqgl;

ilal committed
3
import java.lang.reflect.InvocationTargetException;
ilal committed
4 5
import java.text.ParseException;
import java.text.SimpleDateFormat;
ilal committed
6
import java.util.ArrayList;
lal committed
7
import java.util.Calendar;
ilal committed
8
import java.util.Comparator;
ilal committed
9
import java.util.Date;
ilal committed
10
import java.util.List;
ilal committed
11
import java.util.Map;
ilal committed
12

ilal committed
13
import org.springframework.beans.factory.annotation.Autowired;
lal committed
14
import org.springframework.beans.factory.annotation.Value;
ilal committed
15 16 17
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
ilal committed
18
import org.springframework.transaction.annotation.Transactional;
ilal committed
19 20
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
ilal committed
21
import org.springframework.validation.annotation.Validated;
ilal committed
22
import org.springframework.web.bind.annotation.DeleteMapping;
ilal committed
23
import org.springframework.web.bind.annotation.GetMapping;
ilal committed
24 25 26 27
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
ilal committed
28 29
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
ilal committed
30
import org.springframework.web.client.RestClientException;
ilal committed
31
import org.springframework.web.client.RestTemplate;
ilal committed
32

ilal committed
33 34 35 36
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
ilal committed
37 38
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;

ilal committed
39 40
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Console;
lal committed
41
import cn.timer.api.bean.kqgl.KqglAssoKqjgly;
ilal committed
42 43
import cn.timer.api.bean.kqgl.PunchCardDetails;
import cn.timer.api.bean.kqgl.PunchRecord;
lal committed
44
import cn.timer.api.bean.kqgl.UserAttendanceRel;
ilal committed
45
import cn.timer.api.bean.kqgl.UserEquiRelation;
ilal committed
46 47
import cn.timer.api.bean.kqmk.KqglAssOvertimeVice;
import cn.timer.api.bean.kqmk.KqglAssoBcsz;
ilal committed
48
import cn.timer.api.bean.kqmk.KqglAssoDkdz;
ilal committed
49 50
import cn.timer.api.bean.kqmk.KqglAssoDkjl;
import cn.timer.api.bean.kqmk.KqglAssoDkmx;
ilal committed
51 52
import cn.timer.api.bean.kqmk.KqglAssoDkwx;
import cn.timer.api.bean.kqmk.KqglAssoKqj;
ilal committed
53
import cn.timer.api.bean.kqmk.KqglAssoKqzdkfs;
ilal committed
54
import cn.timer.api.bean.kqmk.KqglAssoLeaveBalance;
ilal committed
55 56
import cn.timer.api.bean.kqmk.KqglAssoLeaveRules;
import cn.timer.api.bean.kqmk.KqglAssoOvertimeBasics;
ilal committed
57
import cn.timer.api.bean.kqmk.KqglAssoOvertimeRange;
ilal committed
58
import cn.timer.api.bean.kqmk.KqglAssoOvertimeRules;
ilal committed
59
import cn.timer.api.bean.kqmk.KqglAssoPbmx;
ilal committed
60
import cn.timer.api.bean.kqmk.KqglAssoRulesVice;
ilal committed
61 62
import cn.timer.api.bean.kqmk.KqglAssoTeshu;
import cn.timer.api.bean.kqmk.KqglAssoYhkqz;
ilal committed
63
import cn.timer.api.bean.kqmk.KqglAssoYhsb;
ilal committed
64
import cn.timer.api.bean.kqmk.KqglAssoZhoupaiban;
ilal committed
65
import cn.timer.api.bean.kqmk.KqglMainKqz;
ilal committed
66
import cn.timer.api.bean.yggl.YgglMainEmp;
ilal committed
67 68
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
lal committed
69
import cn.timer.api.config.exception.CustomException;
ilal committed
70 71
import cn.timer.api.dao.kqgl.PunchCardDetailsMapper;
import cn.timer.api.dao.kqgl.PunchRecordMapper;
lal committed
72
import cn.timer.api.dao.kqgl.UserAttendanceRelMapper;
ilal committed
73
import cn.timer.api.dao.kqgl.UserEquiRelationMapper;
ilal committed
74 75
import cn.timer.api.dao.kqmk.KqglAssOvertimeViceMapper;
import cn.timer.api.dao.kqmk.KqglAssoBcszMapper;
ilal committed
76
import cn.timer.api.dao.kqmk.KqglAssoDkdzMapper;
ilal committed
77
import cn.timer.api.dao.kqmk.KqglAssoDkjlMapper;
lal committed
78
import cn.timer.api.dao.kqmk.KqglAssoDkmxMapper;
ilal committed
79 80
import cn.timer.api.dao.kqmk.KqglAssoDkwxMapper;
import cn.timer.api.dao.kqmk.KqglAssoKqjMapper;
ilal committed
81
import cn.timer.api.dao.kqmk.KqglAssoKqzdkfsMapper;
ilal committed
82
import cn.timer.api.dao.kqmk.KqglAssoLeaveBalanceMapper;
ilal committed
83
import cn.timer.api.dao.kqmk.KqglAssoLeaveRulesMapper;
lal committed
84
import cn.timer.api.dao.kqmk.KqglAssoMonthPunchSummaryMapper;
ilal committed
85
import cn.timer.api.dao.kqmk.KqglAssoOvertimeRangeMapper;
ilal committed
86
import cn.timer.api.dao.kqmk.KqglAssoOvertimeRulesMapper;
ilal committed
87
import cn.timer.api.dao.kqmk.KqglAssoPbmxMapper;
ilal committed
88
import cn.timer.api.dao.kqmk.KqglAssoRulesViceMapper;
ilal committed
89 90
import cn.timer.api.dao.kqmk.KqglAssoTeshuMapper;
import cn.timer.api.dao.kqmk.KqglAssoYhkqzMapper;
ilal committed
91
import cn.timer.api.dao.kqmk.KqglAssoYhsbMapper;
ilal committed
92
import cn.timer.api.dao.kqmk.KqglAssoZhoupaibanMapper;
ilal committed
93
import cn.timer.api.dao.kqmk.KqglMainKqzMapper;
lal committed
94
import cn.timer.api.dto.kqmk.AttMemberSettings;
ilal committed
95 96
import cn.timer.api.dto.kqmk.AttSchedulingDto;
import cn.timer.api.dto.kqmk.AttendanceAssistantDto;
lal committed
97
import cn.timer.api.dto.kqmk.AttendanceSummaryQueryDto;
ilal committed
98
import cn.timer.api.dto.kqmk.AttqueryCriteriaDto;
lal committed
99
import cn.timer.api.dto.kqmk.ChangePunchResultsDto;
ilal committed
100
import cn.timer.api.dto.kqmk.CompensateDto;
lal committed
101
import cn.timer.api.dto.kqmk.DailyDetailsDto;
ilal committed
102
import cn.timer.api.dto.kqmk.EmployeeLeaveBalanceDto;
ilal committed
103
import cn.timer.api.dto.kqmk.IndividualOvertimeRuleDto;
ilal committed
104
import cn.timer.api.dto.kqmk.KqglAssoLeaveRulesDto;
lal committed
105
import cn.timer.api.dto.kqmk.KqglAssoMonthPunchSummaryDto;
ilal committed
106
import cn.timer.api.dto.kqmk.KqglAssoOvertimeRulesDto;
ilal committed
107
import cn.timer.api.dto.kqmk.KqglAssoPbmxDto;
lal committed
108
import cn.timer.api.dto.kqmk.KqglAssoRulesViceDto;
ilal committed
109
import cn.timer.api.dto.kqmk.KqglMainKqzDto;
ilal committed
110
import cn.timer.api.dto.kqmk.KqzAttendanceGroupSearchDto;
ilal committed
111
import cn.timer.api.dto.kqmk.LeaveTypeDto;
ilal committed
112
import cn.timer.api.dto.kqmk.MachinememberDto;
lal committed
113
import cn.timer.api.dto.kqmk.ModifyEmployeeBalanceDto;
lal committed
114
import cn.timer.api.dto.kqmk.OriginalRecordDto;
ilal committed
115
import cn.timer.api.dto.kqmk.SetConditionsDto;
ilal committed
116
import cn.timer.api.dto.kqmk.StartTimeRestDto;
lal committed
117
import cn.timer.api.dto.kqmk.UserAttendanceRelDto;
ilal committed
118
import cn.timer.api.dto.kqmk.VacationInformationDto;
ilal committed
119
import cn.timer.api.utils.DateUtil;
ilal committed
120
import cn.timer.api.utils.ResponseResult;
ilal committed
121 122 123 124 125
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

ilal committed
126
@Api(tags = "3.0[1]考勤模块")
ilal committed
127 128 129 130
@RestController
@Transactional
@RequestMapping(value = "/kqmk", produces = { "application/json", "multipart/form-data" })
public class TimeCardController {
lal committed
131 132 133 134
	
	@Value("${config-8timer.machine8timerUrl}")
	public String mac_command; // 回调地址
	
ilal committed
135 136 137 138 139 140 141
	@Autowired
	private KqglAssoBcszMapper kqglassobcszmapper;
	@Autowired
	private KqglAssoOvertimeRulesMapper kqglassoovertimerulesmapper;
	@Autowired
	private KqglAssOvertimeViceMapper kqglassovertimevicemapper;
	
lal committed
142 143 144 145
	//用户和考勤组关系
	@Autowired
	private UserAttendanceRelMapper userattendancerelmapper;
	
ilal committed
146 147 148
	/**
	 * 查询列表-获取班次数据-分页
	 */
ilal committed
149
	@PostMapping(value = "/ShiftDataList")
ilal committed
150 151 152 153 154 155 156 157
	@ApiOperation(value = "1.获取班次数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 1)
	public Result<Object> selectShifts(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
			IPage<KqglAssoBcsz> page = new Page<KqglAssoBcsz>(
			 attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
			 attquerycriteriadto.getTotalPage() == null ? 10 : attquerycriteriadto.getTotalPage());
			attquerycriteriadto.setOrgCode(userBean.getOrgCode());
			attquerycriteriadto.setEmpNum(userBean.getEmpNum());
lal committed
158
			IPage<KqglAssoBcsz> pageAs = kqglassobcszmapper.selectPage(page, new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getQyid, userBean.getOrgCode()).orderByDesc(KqglAssoBcsz::getId));
ilal committed
159 160 161 162 163 164 165 166 167 168 169
			List<KqglAssoBcsz> listAs = pageAs.getRecords();
			return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
	/**
	 * 新增班次信息
	 */
	@PostMapping(value = "/Shif")
	@ApiOperation(value = "2:新增班次信息", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 2)
	public Result<KqglAssoBcsz> ShiftInformation(@CurrentUser UserBean userBean,@RequestBody KqglAssoBcsz shif) {
lal committed
170
			String sdf = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
ilal committed
171 172 173
			shif.setQyid(userBean.getOrgCode());
			shif.setLusjTime(new Date().getTime());
			shif.setLuryid(userBean.getEmpNum());//录入人员
lal committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
			
			boolean xbbydk = false;
			if(shif.getIsXbdk() == 1) {
				xbbydk = true;
			}
			
			if(shif.getSxbcs() == 1) {
				if(xbbydk) {
					shif.setXbdk1("");
					String asd = ClockInTool.addtime(sdf+" "+shif.getSbdk1()+":00", "1").substring(11, 16);
					shif.setXbdk1(asd);
				}
			}else if(shif.getSxbcs() == 2) {
				if(xbbydk) {
					shif.setXbdk2("");
					String asd = ClockInTool.addtime(sdf+" "+shif.getSbdk2()+":00", "1").substring(11, 16);
					shif.setXbdk2(asd);
				}
			}else {
				if(xbbydk) {
					shif.setXbdk3("");
					String asd = ClockInTool.addtime(sdf+" "+shif.getSbdk3()+":00", "1").substring(11, 16);
					shif.setXbdk3(asd);
				}
			}
			
ilal committed
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
			if(kqglassobcszmapper.insert(shif)>0){
				return ResultUtil.data(shif, "新增班次成功");
			}else{
				return ResultUtil.error("新增班次失败");
			}
	}
	
	/**
	 * 删除班次信息
	 */
	@DeleteMapping(value = "/Shif/{id}")
	@ApiOperation(value = "3:删除班次信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 3)
	public Result<Integer> deleteShiftInformation(@PathVariable("id") Integer id) {
		return KqglAssoBcsz.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
	
	/**
	 * 根据班次id获取班次信息
	 */
	@GetMapping(value="/Shifts/{id}")
	@ApiOperation(value = "4:获取班次信息-根据班次id", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 4)
	public Result<Object> getShiftCenter(@PathVariable("id") Integer id) {
		return ResultUtil.data(KqglAssoBcsz.builder().id(id).build().selectById(),"操作成功!");
	}
	
	/**
	 * 修改班次信息
	 */
	@PutMapping(value = "/Shif")
	@ApiOperation(value = "5:修改班次信息", httpMethod = "PUT", notes = "接口发布说明")
	@ApiOperationSupport(order = 5)
	public Result<KqglAssoBcsz> updateShiftInformation(@CurrentUser UserBean userBean,@RequestBody KqglAssoBcsz shif) {
			shif.setQyid(userBean.getOrgCode());//企业id
			if (kqglassobcszmapper.update(shif) > 0) {
				return ResultUtil.data(shif,"修改班次信息成功");
			}
			return ResultUtil.error("修改班次信息失败");
	}
	
	/**
	 * 查询列表-获取加班规则数据-分页
ilal committed
243 244
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
ilal committed
245 246 247 248
	 */
	@PostMapping(value = "/select_overtime_rules")
	@ApiOperation(value = "6.获取加班规则数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 6)
ilal committed
249
	public Result<Object> selectOvertimeRules(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) throws IllegalAccessException, InvocationTargetException {
ilal committed
250 251 252 253 254 255 256
			IPage<KqglAssoOvertimeRules> page = new Page<KqglAssoOvertimeRules>(
			 attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
			 attquerycriteriadto.getTotalPage() == null ? 10 : attquerycriteriadto.getTotalPage());
			attquerycriteriadto.setOrgCode(userBean.getOrgCode());
			attquerycriteriadto.setEmpNum(userBean.getEmpNum());
			IPage<KqglAssoOvertimeRules> pageAs = kqglassoovertimerulesmapper.selectPage(page, new QueryWrapper<KqglAssoOvertimeRules>().lambda().eq(KqglAssoOvertimeRules::getOrgCode, userBean.getOrgCode()));
			List<KqglAssoOvertimeRules> listAs = pageAs.getRecords();
ilal committed
257 258
			List<KqglAssoOvertimeRulesDto> rulesdto = new ArrayList<KqglAssoOvertimeRulesDto>();
			for (int i = 0, n = listAs.size(); i < n; i++) {
ilal committed
259
				String[] nary = null;
lal committed
260
				String[] naryid = null;
ilal committed
261 262
				if(listAs.get(i).getAppliedScope() == 0) {//全公司
					nary = new String[1];//用户名
lal committed
263
					naryid = new String[1];//用户名
ilal committed
264
					nary[0] = "全公司";
lal committed
265
					naryid[0] = "0";
ilal committed
266 267 268
				}else {
					List<KqglAssoOvertimeRange> overtim = kqglassoovertimerangemapper.selectList(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, listAs.get(i).getId()));
					nary = new String[overtim.size()];//用户名
lal committed
269
					naryid = new String[overtim.size()];//用户名
ilal committed
270 271 272
					for(int y = 0,l = overtim.size(); y < l ; y++) {
						KqglMainKqz kqzmc = kqglmainkqzmapper.selectOne(new QueryWrapper<KqglMainKqz>().lambda().eq(KqglMainKqz::getId, overtim.get(y).getAttgroupId()));
						nary[y] = kqzmc.getName();
lal committed
273
						naryid[y] = String.valueOf(kqzmc.getId());
ilal committed
274
					}
ilal committed
275
				}
lal committed
276 277 278 279 280 281 282 283 284 285 286 287 288
				
				
				List<KqglAssOvertimeVice> vice = kqglassovertimevicemapper.selectList(new QueryWrapper<KqglAssOvertimeVice>().lambda().eq(KqglAssOvertimeVice::getOvertimeRulesId, listAs.get(i).getId()));
				
				StartTimeRestDto[] starttime = new StartTimeRestDto[vice.size()];//用户名;
				
				for(int r = 0,t = vice.size(); r < t ; r++) {
					StartTimeRestDto startt = new StartTimeRestDto(vice.get(r).getBreakStartTime(),vice.get(r).getBreakEndTime(),vice.get(r).getOverType());
					starttime[r] = startt;
				}
				
				
				
ilal committed
289 290
				KqglAssoOvertimeRulesDto ruldto = KqglAssoOvertimeRulesDto.builder().build();
				ruldto.setApplyrange(nary);
lal committed
291 292 293
				ruldto.setApplyrangeid(naryid);
				ruldto.setStarttime(starttime);
				BeanUtil.copyProperties(listAs.get(i), ruldto , "starttime","applyrange","applyrangeid");
ilal committed
294 295 296
				rulesdto.add(ruldto);
			}
			return ResultUtil.data(pageAs, rulesdto, "操作成功!");
ilal committed
297 298
	}
	
ilal committed
299 300 301
	
	@Autowired
	private KqglAssoOvertimeRangeMapper kqglassoovertimerangemapper;
ilal committed
302 303 304 305 306 307 308 309 310 311 312
	/**
	 * 新增/修改--加班规则
	 */
	@PostMapping(value = "/overtime_rules")
	@ApiOperation(value = "7:新增/修改--加班规则", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 7)
	public Result<Object> InOvertimerules(@CurrentUser UserBean userBean,@RequestBody KqglAssoOvertimeRulesDto overrules) {
		overrules.setCreateTime(new Date().getTime());
		overrules.setOrgCode(userBean.getOrgCode());
		overrules.setCreateUserid(userBean.getEmpNum());
		KqglAssoOvertimeRules rul = KqglAssoOvertimeRules.builder().build();
ilal committed
313
		BeanUtil.copyProperties(overrules, rul , "starttime","applyrange");
ilal committed
314 315 316 317
		if (!rul.insertOrUpdate()) 
			return ResultUtil.error("操作失败");
		Integer id = rul.getId();
		Console.log("新增/修改加班规则id: " + id);
ilal committed
318
		List<KqglAssoOvertimeRange> overatts=new ArrayList<KqglAssoOvertimeRange>();
lal committed
319
		String[] launchs = overrules.getApplyrangeid();
ilal committed
320 321 322 323 324
		if(launchs.length == 0) {
			KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, id));
		}else if(launchs != null && launchs.length>0){
			for(int p=0;p<launchs.length;p++){
				KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, id));
lal committed
325 326 327
				
				KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, Integer.valueOf(launchs[p])));
				
ilal committed
328 329 330 331
				KqglAssoOvertimeRange vice = KqglAssoOvertimeRange.builder().build();
				vice.setOvertimeRulesId(id);
				vice.setAttgroupId(Integer.valueOf(launchs[p]));
				overatts.add(vice);
lal committed
332 333 334
				
				//应用范围应用到相对应的考勤组************
				KqglMainKqz.builder().id(Integer.valueOf(launchs[p])).overtimeRulesId(id).build().updateById();
ilal committed
335 336 337 338 339
			}
		}
		if(overatts.size() > 0) {
			kqglassoovertimerangemapper.insertovertimerangelist(overatts);
		}
lal committed
340 341
		
		
ilal committed
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
		List<KqglAssOvertimeVice> overtimes=new ArrayList<KqglAssOvertimeVice>();
		StartTimeRestDto[] rest = overrules.getStarttime();
		if(rest != null && rest.length>0){
			for(int p=0;p<rest.length;p++){
				KqglAssOvertimeVice.builder().build().delete(new QueryWrapper<KqglAssOvertimeVice>().lambda().eq(KqglAssOvertimeVice::getOvertimeRulesId, id));
				KqglAssOvertimeVice vice = new KqglAssOvertimeVice();
				vice.setOvertimeRulesId(id);
				vice.setBreakStartTime(rest[p].getStarttime());
				vice.setBreakEndTime(rest[p].getEndtime());
				vice.setOverType(rest[p].getOvertype());
				overtimes.add(vice);
			}
		}
		if(overtimes.size()>0){
			kqglassovertimevicemapper.insertovertimeviceList(overtimes);
		}
		return  ResultUtil.data(rul, "操作成功!");
	}
	
	/**
	 * 	根据加班规则id获取加班规则信息
	 */
	@GetMapping(value="/Overtime/{id}")
	@ApiOperation(value = "8:根据加班规则id获取加班规则信息", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 8)
ilal committed
367 368
	public Result<IndividualOvertimeRuleDto> getOvertimeRules(@PathVariable("id") Integer id) {
		IndividualOvertimeRuleDto overrule = IndividualOvertimeRuleDto.builder().build();
ilal committed
369
		KqglAssoOvertimeRules rules = KqglAssoOvertimeRules.builder().id(id).build().selectById();
ilal committed
370 371 372 373 374
		List<KqglAssoOvertimeRange> overtim = kqglassoovertimerangemapper.selectList(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, rules.getId()));
		String[] arr = new String[overtim.size()];//用户名
		for (int i = 0, n = overtim.size(); i < n; i++) {
			arr[i] = overtim.get(i).getAttgroupId().toString();
		}
ilal committed
375 376 377 378
		KqglAssoOvertimeRulesDto ruldto = KqglAssoOvertimeRulesDto.builder().build();
		ruldto.setApplyrange(arr);
		BeanUtil.copyProperties(rules, ruldto , "starttime","applyrange");
		overrule.setRules(ruldto);
ilal committed
379
		List<KqglAssOvertimeVice> vice = new LambdaQueryChainWrapper<KqglAssOvertimeVice>(kqglassovertimevicemapper).eq(KqglAssOvertimeVice::getOvertimeRulesId, id).list();
ilal committed
380
		overrule.setStarttime(vice);		
ilal committed
381 382 383 384 385 386 387 388 389 390 391 392 393 394
		return ResultUtil.data(overrule,"操作成功!");
	}
	
	/**
	 * 	删除加班规则
	 * @throws Exception 
	 */
	@DeleteMapping(value = "/Overtime/{id}")
	@ApiOperation(value = "9:删除加班规则", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 9)
	public Result<Integer> deleteOvertimeRules(@PathVariable("id") Integer id) throws Exception {
		if(!KqglAssoOvertimeRules.builder().id(id).build().deleteById()) {
			throw new Exception();
		}else {
lal committed
395 396 397 398 399 400 401
			
			List<KqglAssoOvertimeRange> rans = kqglassoovertimerangemapper.selectList(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, id));
			for(KqglAssoOvertimeRange ran:rans) {
				KqglMainKqz.builder().id(ran.getAttgroupId()).overtimeRulesId(0).build().updateById();
			}
			
			KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, id));
ilal committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
			KqglAssOvertimeVice.builder().build().delete(new QueryWrapper<KqglAssOvertimeVice>().lambda().eq(KqglAssOvertimeVice::getOvertimeRulesId, id));
			return ResultUtil.success("删除成功!");
		}
	}
	
	/**
	 * 	编辑加班基础设置
	 */
	@PostMapping(value = "/overtime_basic_settings")
	@ApiOperation(value = "10:编辑加班基础设置", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 10)
	public Result<Object> OvertimeBasicSettings(@CurrentUser UserBean userBean,@RequestBody KqglAssoOvertimeBasics overtiasics) {
		overtiasics.setModifyUserid(userBean.getEmpNum());
		overtiasics.setModifyTime(new Date().getTime());
		overtiasics.setOrgCode(userBean.getOrgCode());
		return overtiasics.insertOrUpdate() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
	}
	
	@Autowired
	private KqglAssoLeaveRulesMapper kqglassoleaverulesmapper;
	/**
ilal committed
423
	 * 初始化假期数据
ilal committed
424 425 426 427 428 429 430 431 432
	 */
	@PostMapping(value = "/initialization_data")
	@ApiOperation(value = "11:初始化假期数据", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 11)
	public Result<Object> InitializationData(@CurrentUser UserBean userBean) {
		//获取模板数据
		List<KqglAssoLeaveRules> ruless = new LambdaQueryChainWrapper<KqglAssoLeaveRules>(kqglassoleaverulesmapper).eq(KqglAssoLeaveRules::getOrgCode, 0).list();
		//查询当前公司是否已初始化
		KqglAssoLeaveRules rule = kqglassoleaverulesmapper.selectOne(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, userBean.getOrgCode())
ilal committed
433
				.eq(KqglAssoLeaveRules::getLeaveType, 1).last("LIMIT 1"));
ilal committed
434 435 436 437 438
		if(rule == null) {
			List<KqglAssoLeaveRules> rullist = new ArrayList<KqglAssoLeaveRules>();
			for(KqglAssoLeaveRules rul : ruless){
				KqglAssoLeaveRules vice = KqglAssoLeaveRules.builder().name(rul.getName()).company(rul.getCompany()).leaveType(rul.getLeaveType())
						.apply(rul.getApply()).createTime(new Date().getTime()).createUserid(userBean.getEmpNum()).orgCode(userBean.getOrgCode())
lal committed
439
						.isOpen(rul.getIsOpen()).leaveBalance(rul.getLeaveBalance()).rulesType(rul.getRulesType()).build();
ilal committed
440 441 442 443 444
				rullist.add(vice);
			}
			if(rullist.size() > 0) {
				kqglassoleaverulesmapper.insertleaverulesList(rullist);
			}
ilal committed
445 446 447
			return ResultUtil.success("操作成功!");
		}else {
			return ResultUtil.success("重复初始化数据!");
ilal committed
448
		}
ilal committed
449
		
ilal committed
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
	}
	
	@Autowired
	private KqglAssoRulesViceMapper kqglassorulesvicemapper;
	/**
	 *	 新增/修改--假期规则
	 */
	@PostMapping(value = "/leave_rules")
	@ApiOperation(value = "12:新增/修改--假期规则", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 12)
	public Result<Object> LeaveRules(@CurrentUser UserBean userBean,@RequestBody KqglAssoLeaveRulesDto leaverules) {
		leaverules.setCreateTime(new Date().getTime());
		leaverules.setOrgCode(userBean.getOrgCode());
		leaverules.setCreateUserid(userBean.getEmpNum());
		leaverules.setIsOpen(1);//是否开启 0:否;1:是  [只针对系统项]
		KqglAssoLeaveRules learul = KqglAssoLeaveRules.builder().build();
		// 克隆 KqglAssoOvertimeRulesDto对象 到 KqglAssoOvertimeRules对象
		BeanUtil.copyProperties(leaverules, learul , "starttime");
		if (!learul.insertOrUpdate()) 
			return ResultUtil.error("操作失败");
		Integer id = learul.getId();
		Console.log("新增/修改--假期规则id: " + id);
ilal committed
472 473 474
		
		KqglAssoLeaveBalance.builder().build().delete(new QueryWrapper<KqglAssoLeaveBalance>().lambda().eq(KqglAssoLeaveBalance::getLeaveRulesId, id)
				.eq(KqglAssoLeaveBalance :: getOrgCode, userBean.getOrgCode()));
lal committed
475
		List<YgglMainEmp> yggl = YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()));
ilal committed
476 477 478 479 480 481
		if(leaverules.getLeaveBalance() == 1) {//假期余额 0:关(该项余额为“不限余额”);1:开(该项余额为“0”)
			//该项公司员工余额为“0”
			for(YgglMainEmp ye:yggl) {
				KqglAssoLeaveBalance.builder().leaveRulesId(id).userid(ye.getEmpNum()).modifyAction(1).balanceDays("+0")
						.reason("系统按照规则自动").modifyUserid(userBean.getEmpNum()).modifyTimer(new Date().getTime()).orgCode(userBean.getOrgCode()).isAutomatic(1).modifyNumber(1).build().insert();//员工假期余额
			}
lal committed
482 483
		}else {
			for(YgglMainEmp ye:yggl) {
lal committed
484
				KqglAssoLeaveBalance.builder().leaveRulesId(id).userid(ye.getEmpNum()).modifyAction(1).balanceDays("-1-1")
lal committed
485 486 487
						.reason("不限制余额").modifyUserid(userBean.getEmpNum()).modifyTimer(new Date().getTime()).orgCode(userBean.getOrgCode()).isAutomatic(1).modifyNumber(1).build().insert();//员工假期余额
			}
		} 
ilal committed
488 489
		List<KqglAssoRulesVice> vices = new ArrayList<KqglAssoRulesVice>();
		String[] rest = leaverules.getRange();
ilal committed
490 491 492
		if(rest.length == 0) {
			KqglAssoRulesVice.builder().build().delete(new QueryWrapper<KqglAssoRulesVice>().lambda().eq(KqglAssoRulesVice::getLeaveRulesId, id));
		}else if(rest != null && rest.length>0){
ilal committed
493 494 495 496 497 498 499 500 501 502 503
			for(int p=0;p<rest.length;p++){
				KqglAssoRulesVice.builder().build().delete(new QueryWrapper<KqglAssoRulesVice>().lambda().eq(KqglAssoRulesVice::getLeaveRulesId, id));
				KqglAssoRulesVice vice = KqglAssoRulesVice.builder().build();
				vice.setLeaveRulesId(id);
				vice.setAttgroupId(Integer.valueOf(rest[p]));
				vices.add(vice);
			}
		}
		if(vices.size()>0){
			kqglassorulesvicemapper.insertrulesviceList(vices);
		}
ilal committed
504
		return  ResultUtil.data(learul, "操作成功!");
ilal committed
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
	}
	
	/**
	 *	 删除假期规则
	 * @throws Exception 
	 */
	@DeleteMapping(value = "/leave_rule/{id}")
	@ApiOperation(value = "13: 删除假期规则", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 13)
	public Result<Integer> Deleteleaverule(@PathVariable("id") Integer id) throws Exception {
		if(!KqglAssoLeaveRules.builder().id(id).build().deleteById()) {
			throw new Exception();
		}else {
			KqglAssoRulesVice.builder().build().delete(new QueryWrapper<KqglAssoRulesVice>().lambda().eq(KqglAssoRulesVice::getLeaveRulesId, id));
			return ResultUtil.success("删除成功!");
		}
	}
	
	/**
	 * 	根据假期规则id获取假期规则信息
	 */
	@GetMapping(value="/Vacation_information/{id}")
	@ApiOperation(value = "14:根据假期规则id获取假期规则信息", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 14)
ilal committed
529 530
	public Result<VacationInformationDto> VacationInformation(@PathVariable("id") Integer id) {
		VacationInformationDto overrule = VacationInformationDto.builder().build();
ilal committed
531 532
		KqglAssoLeaveRules rules = KqglAssoLeaveRules.builder().id(id).build().selectById();
		overrule.setRules(rules);
lal committed
533 534
		List<KqglAssoRulesViceDto> vice = kqglassorulesvicemapper.leaveRulesIdload(id);
		
ilal committed
535
		overrule.setRange(vice);		
ilal committed
536 537
		return ResultUtil.data(overrule,"操作成功!");
	}
ilal committed
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
	
	
	@Autowired
	private KqglAssoKqjMapper kqglassokqjmapper;
	@Autowired
	private KqglAssoYhsbMapper kqglassoyhsbmapper;
	@Autowired
	private KqglMainKqzMapper kqglmainkqzmapper;
	/**
	 * 获取考勤机数据
	 */
	@GetMapping(value="/AttMachine")
	@ApiOperation(value = "15:获取考勤机数据-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 15)
	public Result<Object> getAttMachineEquipment(@CurrentUser UserBean userBean){
		List<KqglAssoKqj> attendanList = new LambdaQueryChainWrapper<KqglAssoKqj>(kqglassokqjmapper).eq(KqglAssoKqj::getQyid, userBean.getOrgCode()).list();
        return ResultUtil.data(attendanList,"操作成功!");
	}
	
ilal committed
557 558 559 560
	@GetMapping(value="/synchrotime/{code}")
	@ApiOperation(value = "考勤机一键同步", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> SynchronizationTime(@CurrentUser UserBean userBean,@PathVariable("code") String code) {
		
lal committed
561
		String url = mac_command+"/setTime";
ilal committed
562 563
        HttpHeaders headers = new HttpHeaders();
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
lal committed
564
        params.add("devId", code);
ilal committed
565 566 567 568
        RestTemplate restTemplate = new RestTemplate();
        HttpEntity httpEntity = new HttpEntity(params, headers);
        try {
			ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
lal committed
569
			System.err.print(request.getBody());
ilal committed
570 571 572 573 574 575 576
		} catch (RestClientException e) {
			System.err.println("提示:考勤机服务出错");
			return ResultUtil.success("失败");
		}
		return ResultUtil.success("成功");
	}
	
ilal committed
577
	/**
ilal committed
578 579 580 581 582 583 584 585 586 587
	 * 	移除考勤机管理员
	 */
	@PostMapping(value = "/removeadministrator/{kqjid}/{id}")
	@ApiOperation(value = "移除考勤机管理员", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> RemoveAdministrator(@PathVariable int kqjid,@PathVariable int id, @RequestBody Map<String,String> mmd) {
		String[] xgyh = mmd.get("a").split(",");
		 if(xgyh.length > 0){
			 KqglAssoKqj kqj = KqglAssoKqj.builder().id(kqjid).build().selectById();//查询考勤机“序列号”
			 for(int a=0;a<xgyh.length;a++){
					
lal committed
588
					String url = mac_command+"/addUserPrivilege";
ilal committed
589 590
			        HttpHeaders headers = new HttpHeaders();
			        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
lal committed
591 592 593
			        params.add("devId", kqj.getCode());
			        params.add("userId", xgyh[a]);
			        params.add("privilege", 1);
ilal committed
594 595 596 597
			        RestTemplate restTemplate = new RestTemplate();
			        HttpEntity httpEntity = new HttpEntity(params, headers);
			        try {
						ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
lal committed
598
						System.err.print(request.getBody());
ilal committed
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
					} catch (RestClientException e) {
						System.err.println("提示:考勤机服务出错");
						return ResultUtil.success("失败");
					}
			        KqglAssoYhsb.builder().id(id).isGly(0).build().updateById();
			 }
		 }
		return ResultUtil.success("成功");
	}
	
	 @PostMapping(value = "/modifyauthority/{kqjid}/{id}")
	 @ApiOperation(value = "添加考勤机管理员", httpMethod = "POST", notes = "接口发布说明")
	 public Result<Object> ModifyAuthority(@CurrentUser UserBean userBean,@PathVariable int kqjid,@PathVariable int id, @RequestBody Map<String,String> mmd) {
		 String[] xgyh = mmd.get("a").split(",");
		 if(xgyh.length > 0){
			 KqglAssoKqj kqj = KqglAssoKqj.builder().id(kqjid).build().selectById();//查询考勤机“序列号”
			 
			for(int a=0;a<xgyh.length;a++){
				
				
lal committed
619
				String url = mac_command+"/addUserPrivilege";
ilal committed
620 621
		        HttpHeaders headers = new HttpHeaders();
		        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
lal committed
622 623 624
		        params.add("devId", kqj.getCode());
		        params.add("userId", xgyh[a]);
		        params.add("privilege", 2);
ilal committed
625 626 627 628
		        RestTemplate restTemplate = new RestTemplate();
		        HttpEntity httpEntity = new HttpEntity(params, headers);
		        try {
					ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
lal committed
629
					System.err.print(request.getBody());
ilal committed
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
				} catch (RestClientException e) {
					System.err.println("提示:考勤机服务出错");
					return ResultUtil.success("失败");
				}
		        
		        UserEquiRelation kqjry = new UserEquiRelation();
		        kqjry.setId(id);
		        kqjry.setIsGly(1);
		        userequirelationmapper.updateByPrimaryKeySelective(kqjry);
			}
		}
		return ResultUtil.success("成功");
		 
	}
	
	
	/**
ilal committed
647 648 649 650 651 652 653 654 655
	 * 新增考勤机
	 */
	@PostMapping(value = "/Attendance_machine")
	@ApiOperation(value = "16:新增考勤机", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 16)
	public Result<Object> AttendanceMachine(@CurrentUser UserBean userBean,@RequestBody KqglAssoKqj kqglassokqj) {
		kqglassokqj.setLuryid(userBean.getEmpNum());
		kqglassokqj.setLusjTime(new Date().getTime());
		kqglassokqj.setQyid(userBean.getOrgCode());
ilal committed
656
		
lal committed
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
		KqglAssoKqj kqj = KqglAssoKqj.builder().build().selectOne(new QueryWrapper<KqglAssoKqj>().lambda().eq(KqglAssoKqj::getCode, kqglassokqj.getCode()));
		if(kqj == null) {
			if(!kqglassokqj.insert())
				return ResultUtil.error("操作失败--新增考勤机");
			
			String url = mac_command+"/addDev";
	        HttpHeaders headers = new HttpHeaders();
	        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
	        params.add("orgCode", kqglassokqj.getType());
			params.add("devId", kqglassokqj.getCode());
	        RestTemplate restTemplate = new RestTemplate();
	        HttpEntity httpEntity = new HttpEntity(params, headers);
	        try {
				ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
				System.err.print(request.getBody());
			} catch (RestClientException e) {
				System.err.println("提示:考勤机服务出错");
				return ResultUtil.success("失败");
			}
			
			return ResultUtil.data(kqglassokqj,"操作成功!");
		}else {
			return ResultUtil.error("考勤机已存在或已被使用");
ilal committed
680 681
		}
		
lal committed
682
		
ilal committed
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
	}
	
	/**
	 * 删除考勤机信息
	 */
	@DeleteMapping(value = "/attmachine/{id}")
	@ApiOperation(value = "17:删除考勤机信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 17)
	public Result<Integer> deattmachine(@PathVariable("id") Integer id) {
		
		return KqglAssoKqj.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
	
	/**
	 * 考勤机内成员
	 */
	@GetMapping(value="/aircraftmembers/{id}")
	@ApiOperation(value = "18:考勤机成员", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 18)
	public ResponseResult selectAircraftMembers(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
		List<MachinememberDto> kqjcys = kqglassoyhsbmapper.selectAircraftMembers(id,userBean.getOrgCode());
		return new ResponseResult().success("考勤机成员", kqjcys);
	}
	
	/**
	 * 获取考勤机数据-根据 组织机构代码
	 */
	@GetMapping(value="/AttGroupMachine")
	@ApiOperation(value = "19:获取考勤机数据-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 19)
	public Result<Object> getAttGroupMachineList(@CurrentUser UserBean userBean) {
			List<KqglMainKqzDto> attmacList = kqglmainkqzmapper.selectAttGroupMachineByQyid(userBean.getOrgCode());
			return ResultUtil.data(attmacList);
	}
	
	/*********打卡地址***********/
	@Autowired
	private KqglAssoDkdzMapper kqglassodkdzmapper;
	/**
	 * 获取打卡地址数据
	 */
	@PostMapping(value = "/PunchAddress")
	@ApiOperation(value = "20:获取打卡地址数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 20)
	public Result<Object> getPunchCardAddress(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
			IPage<KqglAssoDkdz> page = new Page<KqglAssoDkdz>(
			 attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
			 attquerycriteriadto.getTotalPage() == null ? 10 : attquerycriteriadto.getTotalPage());
			attquerycriteriadto.setOrgCode(userBean.getOrgCode());
			attquerycriteriadto.setEmpNum(userBean.getEmpNum());
			
lal committed
734
			IPage<KqglAssoDkdz> pageAs = kqglassodkdzmapper.selectPage(page, new QueryWrapper<KqglAssoDkdz>().lambda().eq(KqglAssoDkdz::getQyid, userBean.getOrgCode()).orderByDesc(KqglAssoDkdz::getId));
ilal committed
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791
			List<KqglAssoDkdz> listAs = pageAs.getRecords();
			return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
	/**
	 * 根据打卡地址id获取打卡地址信息
	 */
	@GetMapping(value="/PuAddress/{id}")
	@ApiOperation(value = "21:获取打卡地址信息-根据打卡地址id", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 21)
	public Result<Object> getPunchAddressByid(@PathVariable("id") Integer id) {
		
		return ResultUtil.data(KqglAssoDkdz.builder().id(id).build().selectById(),"操作成功!");
	}

	/**
	 * 新增/修改--打卡地址信息
	 */
	@PostMapping(value = "/PunchAddress_addmod")
	@ApiOperation(value = "22:新增/修改--打卡地址信息", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 22)
	public Result<Object> PunchCardAddress(@CurrentUser UserBean userBean,@RequestBody KqglAssoDkdz kqglassodkdz) {
		kqglassodkdz.setLuryid(userBean.getEmpNum());
		kqglassodkdz.setLusjTime(new Date().getTime());
		kqglassodkdz.setQyid(userBean.getOrgCode());
		return kqglassodkdz.insertOrUpdate() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
	}
	
	/**
	 * 删除打卡地址信息
	 */
	@DeleteMapping(value = "/PunchAddress/{id}")
	@ApiOperation(value = "23:删除打卡地址信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 23)
	public Result<Integer> deletePunchCardAddress(@PathVariable("id") Integer id) {
		
		return KqglAssoDkdz.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
	
	/*********打卡WIFI***********/
	/**
	 * 获取打卡WIFI数据
	 */
	@Autowired
	private KqglAssoDkwxMapper kqglassodkwxmapper;
	
	@PostMapping(value = "/PunchWIFI")
	@ApiOperation(value = "24:获取打卡WIFI数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 24)
	public Result<Object> getPunchCardWIFI(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
		
			IPage<KqglAssoDkwx> page = new Page<KqglAssoDkwx>(
			 attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
			 attquerycriteriadto.getTotalPage() == null ? 10 : attquerycriteriadto.getTotalPage());
			attquerycriteriadto.setOrgCode(userBean.getOrgCode());
			attquerycriteriadto.setEmpNum(userBean.getEmpNum());
			
lal committed
792
			IPage<KqglAssoDkwx> pageAs = kqglassodkwxmapper.selectPage(page, new QueryWrapper<KqglAssoDkwx>().lambda().eq(KqglAssoDkwx::getQyid, userBean.getOrgCode()).orderByDesc(KqglAssoDkwx::getId));
ilal committed
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
			List<KqglAssoDkwx> listAs = pageAs.getRecords();
			return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
	/**
	 * 根据打卡WIFIid获取打卡WIFI信息
	 */
	@GetMapping(value="/PuWIFI/{id}")
	@ApiOperation(value = "25:获取打卡WIFI信息-根据打卡WIFIid", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 25)
	public Result<Object> getPunchWIFIByid(@PathVariable("id") Integer id) {
		
		return ResultUtil.data(KqglAssoDkwx.builder().id(id).build().selectById(),"操作成功!");
	}
	
	/**
	 * 新增/修改--打卡WIFI信息
	 */
	@PostMapping(value = "/PunchWIFI_addmod")
	@ApiOperation(value = "26:新增/修改--打卡WIFI信息", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 26)
	public Result<Object> PunchCardWIFI(@CurrentUser UserBean userBean,@RequestBody KqglAssoDkwx kqglassodkwx) {
		kqglassodkwx.setLuryid(userBean.getEmpNum());
		kqglassodkwx.setLusjTime(new Date().getTime());
		kqglassodkwx.setQyid(userBean.getOrgCode());
		return kqglassodkwx.insertOrUpdate() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
	}
	
	/**
	 * 删除打卡WIFI信息
	 */
	@DeleteMapping(value = "/PunchWIFI/{id}")
	@ApiOperation(value = "27:删除打卡地址信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 27)
	public Result<Integer> deletePunchCardWIFI(@PathVariable("id") Integer id) {
		
		return KqglAssoDkwx.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
	
ilal committed
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
	@Autowired
	private KqglAssoLeaveBalanceMapper kqglassoleavebalancemapper;
	/**
	 * 新增/修改--员工假期余额
	 */
	@PostMapping(value = "/Leave_balance")
	@ApiOperation(value = "28:新增/修改--员工假期余额", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 28)
	public Result<Object> LeaveBalance(@CurrentUser UserBean userBean,@RequestBody KqglAssoLeaveBalance balance) {
		balance.setModifyUserid(userBean.getEmpNum());
		balance.setModifyTimer(new Date().getTime());
		balance.setOrgCode(userBean.getOrgCode());
		KqglAssoLeaveBalance balan = kqglassoleavebalancemapper.selectOne(new QueryWrapper<KqglAssoLeaveBalance>().lambda().eq(KqglAssoLeaveBalance::getUserid, balance.getUserid())
				.orderByDesc(KqglAssoLeaveBalance :: getModifyNumber).last("LIMIT 1"));
		if(balan != null) {
			balance.setModifyNumber(balan.getModifyNumber()+1);
		}else {
			balance.setModifyNumber(1);
		}
		return balance.insert() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
	}
ilal committed
853
	
ilal committed
854 855 856 857 858 859 860
	/**
	 * 根据 组织机构代码获取员工假期余额表头
	 */
	@GetMapping(value="/balance_header")
	@ApiOperation(value = "29:根据 组织机构代码获取员工假期余额表头", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 29)
	public Result<Object> BalanceHeader(@CurrentUser UserBean userBean) {
lal committed
861 862 863
//		List<KqglAssoLeaveRules> balheas = new LambdaQueryChainWrapper<KqglAssoLeaveRules>(kqglassoleaverulesmapper).eq(KqglAssoLeaveRules :: getOrgCode,userBean.getOrgCode())
//				.eq(KqglAssoLeaveRules :: getLeaveType, 2).or().eq(KqglAssoLeaveRules :: getIsOpen, 1).list();
		List<KqglAssoLeaveRules> balheas = kqglassoleaverulesmapper.selHeaderdata(userBean.getOrgCode(), 2, 1);
ilal committed
864 865
		return ResultUtil.data(balheas, "操作成功!");
	}
ilal committed
866
	
ilal committed
867
	/**
ilal committed
868
	 * 	查询列表-假期规则*******************************************
ilal committed
869 870
	 */
	@GetMapping(value = "/list_leave_rules")
ilal committed
871 872
	@ApiOperation(value = "30: 查询列表-假期规则", httpMethod = "GET", notes = " 查询列表-假期规则")
	@ApiOperationSupport(order = 30)
ilal committed
873 874 875
	public Result<Object> selectListLeaveRules(@CurrentUser UserBean userBean) {
		List<KqglAssoLeaveRules> balheas = new LambdaQueryChainWrapper<KqglAssoLeaveRules>(kqglassoleaverulesmapper).eq(KqglAssoLeaveRules :: getOrgCode,userBean.getOrgCode())
				.eq(KqglAssoLeaveRules :: getLeaveType, 2).or().eq(KqglAssoLeaveRules :: getIsOpen, 1).list();
ilal committed
876
		List<LeaveTypeDto> leas = new ArrayList<LeaveTypeDto>();
ilal committed
877 878 879 880 881 882
		for(KqglAssoLeaveRules rul : balheas) {
			LeaveTypeDto lea = LeaveTypeDto.builder().build();
			lea.setId(rul.getId());
			lea.setValue(rul.getName());
			leas.add(lea);
		}
ilal committed
883 884 885 886
		return ResultUtil.data(leas, "操作成功!");
	}
	
	/**
ilal committed
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
	 * 	根据组织机构代码 获取考勤组
	 */
	@GetMapping(value="/check_workatt")
	@ApiOperation(value = "31:根据组织机构代码 获取考勤组", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 31)
	public Result<Object> CheckWorkatt(@CurrentUser UserBean userBean) {
		List<KqglMainKqz> kqzs = KqglMainKqz.builder().build().selectList(new QueryWrapper<KqglMainKqz>().lambda().eq(KqglMainKqz::getQyid, userBean.getOrgCode()));
		List<LeaveTypeDto> leas = new ArrayList<LeaveTypeDto>();
		for(KqglMainKqz rul : kqzs) {
			LeaveTypeDto lea = LeaveTypeDto.builder().build();
			lea.setId(rul.getId());
			lea.setValue(rul.getName());
			leas.add(lea);
		}
		return ResultUtil.data(leas, "操作成功!");
	}
	
	/**
ilal committed
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928
	 * 	根据组织机构代码 获取加班基础设置信息
	 */
	@PostMapping(value = "/overtime_basic_information")
	@ApiOperation(value = "32:根据组织机构代码 获取加班基础设置信息", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 32)
	public Result<Object> overtimebasicinformation(@CurrentUser UserBean userBean) {
		KqglAssoOvertimeBasics kqjdev = KqglAssoOvertimeBasics.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeBasics>().lambda().eq(KqglAssoOvertimeBasics::getOrgCode, userBean.getOrgCode()));
		return ResultUtil.data(kqjdev, "操作成功!");
	}
	
	/**
	 * 	查询列表-获取假期规则数据-分页
	 */
	@PostMapping(value = "/select_leave_rules")
	@ApiOperation(value = "33:获取假期规则数据-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 33)
	public Result<Object> selectleaverules(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
			IPage<KqglAssoLeaveRules> page = new Page<KqglAssoLeaveRules>(
			 attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
			 attquerycriteriadto.getTotalPage() == null ? 10 : attquerycriteriadto.getTotalPage());
			attquerycriteriadto.setOrgCode(userBean.getOrgCode());
			attquerycriteriadto.setEmpNum(userBean.getEmpNum());
			IPage<KqglAssoLeaveRules> pageAs = kqglassoleaverulesmapper.selectPage(page, new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, userBean.getOrgCode()));
			List<KqglAssoLeaveRules> listAs = pageAs.getRecords();
ilal committed
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948
			List<KqglAssoLeaveRulesDto> leadto = new ArrayList<KqglAssoLeaveRulesDto>();
			for (int i = 0, n = listAs.size(); i < n; i++) {
				String[] nary = null;
				if(listAs.get(i).getApply() == 0) {//全公司
					nary = new String[1];//用户名
					nary[0] = "全公司";
				}else {//考勤组
					List<KqglAssoRulesVice> vice = kqglassorulesvicemapper.selectList(new QueryWrapper<KqglAssoRulesVice>().lambda().eq(KqglAssoRulesVice::getLeaveRulesId, listAs.get(i).getId()));
					nary = new String[vice.size()];//用户名
					for(int y = 0,l = vice.size(); y < l ; y++) {
						KqglMainKqz kqzmc = kqglmainkqzmapper.selectOne(new QueryWrapper<KqglMainKqz>().lambda().eq(KqglMainKqz::getId, vice.get(y).getAttgroupId()));
						nary[y] = kqzmc.getName();
					}
				}
				KqglAssoLeaveRulesDto learul = KqglAssoLeaveRulesDto.builder().build();
				learul.setApplyrange(nary);
				BeanUtil.copyProperties(listAs.get(i), learul , "range","applyrange");
				leadto.add(learul);
			}
			return ResultUtil.data(pageAs, leadto, "操作成功!");
ilal committed
949 950
	}
	
ilal committed
951
	/*****************考勤组***********************/
ilal committed
952 953 954 955
	/**
	 * 	查询列表-考勤组-分页
	 */
	@PostMapping(value = "/attendance_group")
lal committed
956
	@ApiOperation(value = "34:查询列表-考勤组-分页", httpMethod = "POST", notes = "查询列表-考勤组-分页")
ilal committed
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
	@ApiOperationSupport(order = 34)
	public Result<Object> AttendanceGroup(@CurrentUser UserBean userBean, @Validated @RequestBody AttqueryCriteriaDto attquerycriteriadto){
			IPage<KqglMainKqzDto> page = new Page<KqglMainKqzDto>(
			attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
			attquerycriteriadto.getTotalPage() == null ? 10 : attquerycriteriadto.getTotalPage());
			attquerycriteriadto.setOrgCode(userBean.getOrgCode());
			attquerycriteriadto.setEmpNum(userBean.getEmpNum());
			// 缺-部门id 搜索
			IPage<KqglMainKqzDto> pageAs = kqglmainkqzmapper.selectPageByQueryKqglMain(page, attquerycriteriadto);
			List<KqglMainKqzDto> listAs = pageAs.getRecords();
			return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
	/**
	 * 	获取打卡地址数据
	 */
	@GetMapping(value="/InGroupPunchAddress")
	@ApiOperation(value = "35:获取打卡地址数据", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 35)
	public Result<Object> getInGroupPunchAddress(@CurrentUser UserBean userBean) {
			List<KqglAssoDkdz> shiftList = KqglAssoDkdz.builder().build().selectList(new QueryWrapper<KqglAssoDkdz>().lambda().eq(KqglAssoDkdz::getQyid, userBean.getOrgCode()));
			return ResultUtil.data(shiftList);
	}
	
	/**
	 * 	获取打卡WIFI数据
	 */
	@GetMapping(value="/InGroupPunchWIFI")
	@ApiOperation(value = "36:获取打卡WIFI数据", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 36)
	public Result<Object> getInGroupPunchWIFI(@CurrentUser UserBean userBean) {
			List<KqglAssoDkwx> shiftList = KqglAssoDkwx.builder().build().selectList(new QueryWrapper<KqglAssoDkwx>().lambda().eq(KqglAssoDkwx::getQyid, userBean.getOrgCode()));
			return ResultUtil.data(shiftList);
	}
	
	/**
	 * 获取班次 
	 */
	@GetMapping(value="/AttShift")
	@ApiOperation(value = "37:获取班次-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 37)
	public Result<Object> getAttShiftList(@CurrentUser UserBean userBean) {
			List<KqglAssoBcsz> attshiftList = KqglAssoBcsz.builder().build().selectList(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getQyid, userBean.getOrgCode()));
			return ResultUtil.data(attshiftList);
	}
	
	/**
	 * 获取员工数据
	 */
	@GetMapping(value="/Employee")
	@ApiOperation(value = "38:获取员工数据-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 38)
	public Result<Object> getEmployeeData(@CurrentUser UserBean userBean) {
lal committed
1010
			List<YgglMainEmp> yggl = YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).ne(YgglMainEmp::getJobStatus, "3"));
ilal committed
1011 1012 1013
			return ResultUtil.data(yggl);
	}
	
ilal committed
1014 1015 1016
	//用户与设备关系表
	@Autowired
	private UserEquiRelationMapper userequirelationmapper;
ilal committed
1017 1018 1019 1020 1021 1022
	/**
	 *	 删除考勤组
	 */
	@DeleteMapping(value = "/AttendanceGroup/{id}")
	@ApiOperation(value = "39:删除考勤组", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 39)
ilal committed
1023
	public Result<Integer> DelAttendanceGroup(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
lal committed
1024
		 
lal committed
1025 1026 1027 1028 1029 1030
				List<UserAttendanceRel> attusers = userattendancerelmapper.selectAttendanceOfficerByKqzid(id, userBean.getOrgCode());//该考勤组人数
				//该考勤组所绑定的考勤机
				List<KqglAssoKqzdkfs> kqjs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, id).eq(KqglAssoKqzdkfs::getType, 1));
				String DevId = "";
				for(KqglAssoKqzdkfs abp:kqjs) {
					KqglAssoKqj kqj = KqglAssoKqj.builder().id(abp.getDkfsid()).build().selectById();//查询考勤机“序列号”
lal committed
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
					if(kqj != null) {
						DevId = kqj.getCode();
						for(UserAttendanceRel user:attusers) {
							String user_id = user.getEmpnum();//"1692";//要删除的考勤组里面用户ID
							
							String url = mac_command+"/deleteUser";
					        HttpHeaders headers = new HttpHeaders();
					        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
					        params.add("devId", DevId);
					        params.add("userId", user_id);
					        RestTemplate restTemplate = new RestTemplate();
					        HttpEntity httpEntity = new HttpEntity(params, headers);
lal committed
1043 1044 1045 1046 1047 1048 1049
					        try {
								ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
								System.err.print(request.getBody());
							} catch (RestClientException e) {
								System.err.println("提示:考勤机服务出错");
								return ResultUtil.error("删除失败:提示:考勤机服务出错");
							}
lal committed
1050
						}
lal committed
1051
					}
lal committed
1052
					
lal committed
1053
				}
lal committed
1054 1055 1056
				
		if(KqglMainKqz.builder().id(id).build().deleteById()) {	
				
lal committed
1057
			userequirelationmapper.deleteBykqzid(id);
ilal committed
1058
			 
ilal committed
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
			//删除考勤组绑定的打卡方式
			KqglAssoKqzdkfs.builder().build().delete(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, id));
			//删除用户和考勤组关系表
			KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getKqzid, id));
			//删除特殊日期表
			KqglAssoTeshu.builder().build().delete(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, id));
			//删除排班明细表(自由排班)
			KqglAssoPbmx.builder().build().delete(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getKqzid, id));
			//删除考勤周排班
			KqglAssoZhoupaiban.builder().build().delete(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, id));
ilal committed
1069 1070 1071 1072 1073 1074 1075
			
			
			//刪除加班规则-应用范围
			KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, id));
			//刪除假期规则-适用范围
			KqglAssoRulesVice.builder().build().delete(new QueryWrapper<KqglAssoRulesVice>().lambda().eq(KqglAssoRulesVice::getAttgroupId, id));
			
ilal committed
1076 1077 1078 1079 1080
			return ResultUtil.data(id,"删除成功");
		}
		return ResultUtil.error("删除失败");
	}
	
ilal committed
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102
	@Autowired
	private KqglAssoKqzdkfsMapper kqglassokqzdkfsmapper;
	@Autowired
	private KqglAssoYhkqzMapper kqglassoyhkqzmapper;
	@Autowired
	private KqglAssoZhoupaibanMapper kqglassozhoupaibanmapper;
	@Autowired
	private KqglAssoTeshuMapper kqglassoteshumapper;
	@Autowired
	private KqglAssoPbmxMapper kqglassopbmxmapper;
	/**
	 * 	新建考勤组
	 */
	@PostMapping(value = "/AttendanceGroup")
	@ApiOperation(value = "40:新增考勤组数据", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 40)
	public Result<Object> AttendanceGroupList(@CurrentUser UserBean userBean,@RequestBody AttendanceAssistantDto attass) {
		KqglMainKqz attgro = KqglMainKqz.builder().name(attass.getName()).kqbz(attass.getRemarks()).pbfs(attass.getAtttype()).qyid(userBean.getOrgCode())
				.isWq(attass.getFieldpersonnel()).isFdjjr(attass.getLegalholidays()).isXzbcdk(attass.getOptscheduling()).sybc(String.join(",",attass.getAttShifts()))
				.isDqtx(attass.getAttRemind()).txry(String.join(",",attass.getAttRemindUserids())).txfs(attass.getAdvanceDays()).txxhts(attass.getRemCycleDays())
				.txsjTime(attass.getReminderTime()).tsfs(String.join(",",attass.getPromptingMode())).isWpbsdk(attass.getAttRemind()).kqkssjTime(attass.getNewAttTime())
				.zsgzsc(attass.getLeastworkTime()).zcgzsc(attass.getNormalWorkTime()).jbzdsc(attass.getMaxOvertimeTime()).overtimeRulesId(attass.getOvertimeRulesId()).build();
lal committed
1103
		
ilal committed
1104 1105 1106 1107 1108 1109 1110
//		if (!attgro.insertOrUpdate()) 
		if (!attgro.insert()) 
			return ResultUtil.error("操作失败--新增考勤组");
		
		Integer attid = attgro.getId();
		Console.log("新增--考勤组id: " + attid);
		
lal committed
1111 1112 1113
		//添加加班规则
		KqglAssoOvertimeRange.builder().overtimeRulesId(attass.getOvertimeRulesId()).attgroupId(attid).build().insert();
		
ilal committed
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
		List<KqglAssoKqzdkfs> kqzdkfslist = new ArrayList<KqglAssoKqzdkfs>();
		String[] attmac = attass.getAttmachines();//考勤机 
		if(attmac.length>0){
			for (int i = 0; i < attmac.length; i++) {
				KqglAssoKqzdkfs attgbpmac = KqglAssoKqzdkfs.builder().dkfsid(Integer.valueOf(attmac[i])).kqzId(attid).type(1).qyid(userBean.getOrgCode()).state(1).build();
				kqzdkfslist.add(attgbpmac);
			}
		}
		String[] atad = attass.getAttadds();//考勤地址
		if(atad.length > 0){
			for(int a=0;a<atad.length;a++){
				KqglAssoKqzdkfs attgbpadd = KqglAssoKqzdkfs.builder().dkfsid(Integer.valueOf(atad[a])).kqzId(attid).type(2).qyid(userBean.getOrgCode()).state(1).build();
				kqzdkfslist.add(attgbpadd);
			}
		}
		String[] atwf = attass.getAttwifis();//考勤WIFI
		if(atwf.length > 0){
			for(int f=0;f<atwf.length;f++){
				KqglAssoKqzdkfs attgbpwf = KqglAssoKqzdkfs.builder().dkfsid(Integer.valueOf(atwf[f])).kqzId(attid).type(3).qyid(userBean.getOrgCode()).state(1).build();
				kqzdkfslist.add(attgbpwf);
			}
		}
		if(kqzdkfslist.size()>0){
			kqglassokqzdkfsmapper.insertKqglAssokqzdKfsList(kqzdkfslist);
		}
		
		//用户和考勤组关系
		List<KqglAssoYhkqz> yhkqzlist = new ArrayList<KqglAssoYhkqz>();
		String[] attser = attass.getAttuserids();
		if(attser.length>0){
			for(int u=0;u<attser.length;u++){
				if(attass.getAtttype() == 2){ KqglAssoPbmx.builder().build().delete(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, Integer.valueOf(attser[u])));}
				KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, Integer.valueOf(attser[u])));
				
				KqglAssoYhkqz kquser = KqglAssoYhkqz.builder().kqzid(attid).userid(Integer.valueOf(attser[u])).qyid(userBean.getOrgCode()).build();
				yhkqzlist.add(kquser);
				
				List<KqglAssoKqzdkfs> kqjs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, attid).eq(KqglAssoKqzdkfs::getType, 1));
				
				for(KqglAssoKqzdkfs abp:kqjs) {
					KqglAssoKqj kqj = KqglAssoKqj.builder().id(abp.getDkfsid()).build().selectById();
					KqglAssoYhsb kqjry = KqglAssoYhsb.builder().build().selectOne(new QueryWrapper<KqglAssoYhsb>().lambda().eq(KqglAssoYhsb::getUserId, Integer.valueOf(attser[u])).eq(KqglAssoYhsb::getKqjid, kqj.getId()));
					if(kqjry == null) {
lal committed
1157 1158 1159 1160 1161 1162 1163 1164
						KqglAssoYhsb uskqj = KqglAssoYhsb.builder().userId(Integer.valueOf(attser[u])).kqjid(kqj.getId()).type(1).build();
						
						UserEquiRelation isgly = userequirelationmapper.selectByuserId(Integer.valueOf(attser[u]));
						if(isgly != null) {
							uskqj.setIsGly(isgly.getIsGly());
						}else {
							uskqj.setIsGly(0);
						}
ilal committed
1165 1166 1167
						if (!uskqj.insert()) 
							return ResultUtil.error("操作失败--新增用户与设备关系");
						
lal committed
1168
						
ilal committed
1169 1170
						YgglMainEmp yggluser = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).eq(YgglMainEmp::getEmpNum, attser[u]));
						
lal committed
1171
						String url = mac_command+"/addUserName";
ilal committed
1172 1173
				        HttpHeaders headers = new HttpHeaders();
				        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
lal committed
1174 1175 1176
				        params.add("devId", kqj.getCode());
				        params.add("userId", attser[u]);
				        params.add("userName", yggluser.getName());
ilal committed
1177 1178 1179
				        RestTemplate restTemplate = new RestTemplate();
				        HttpEntity httpEntity = new HttpEntity(params, headers);
				        ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
lal committed
1180
				        System.err.print(request.getBody());
ilal committed
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
					}
				}
			}
			
		}
		if(yhkqzlist.size()>0){
			kqglassoyhkqzmapper.insertKqglAssoKqzdkfsList(yhkqzlist);
		}
		
		List<KqglAssoZhoupaiban> attweeklist = new ArrayList<KqglAssoZhoupaiban>();//固定排版周记录
		String[] weektime = attass.getAttWeekdays();//周工作日【固定排班】
		String[] weekshif = attass.getAttWeekdaysShifts();//周工作日班次【固定排班】
		if(weektime.length>0 && weekshif.length>0 && attass.getAtttype() == 1){
			for(int h=0;h<weektime.length;h++){
				KqglAssoZhoupaiban attweek = KqglAssoZhoupaiban.builder().kqzid(attid).type(Integer.valueOf(weektime[h])).bcid(Integer.valueOf(weekshif[h])).build();
				attweeklist.add(attweek);
			}
		}
		String[] attFrWorkdays = attass.getAttFreeWorkdays();// 周工作日【自由工时】
		if(attFrWorkdays.length>0 && attass.getAtttype() == 3){
			for(int w=0;w<attFrWorkdays.length;w++){
				KqglAssoZhoupaiban attfrwor = KqglAssoZhoupaiban.builder().kqzid(attid).type(Integer.valueOf(attFrWorkdays[w])).bcid(0).build();
				attweeklist.add(attfrwor);
			}
		}
		if(attweeklist.size()>0){
			kqglassozhoupaibanmapper.insertKqglAssoZhoupaibanList(attweeklist);
		}
		
		
		List<KqglAssoTeshu> speclist = new ArrayList<KqglAssoTeshu>();
		String[] attmuspudata = attass.getAttMustPunchData();// 必须打卡的日期【固定排班】
		String[] attmuspushifid = attass.getAttMustPunchShifid();// 必须打卡的班次id【固定排班】
		String[] attnonpudata = attass.getAttNonPunchData();// 不用打卡的日期【固定排班】
		if(attmuspudata.length>0 && attmuspushifid.length>0 && attass.getAtttype() == 1){
			for(int m=0;m<attmuspudata.length;m++){
				KqglAssoTeshu mut = KqglAssoTeshu.builder().kqzid(attid).tsrq(attmuspudata[m]).bcid(Integer.valueOf(attmuspushifid[m])).lusjTime(new Date().getTime()).luryid(userBean.getEmpNum()).type(1).build();
				speclist.add(mut);
			}
		}
		if(attnonpudata.length>0 && attass.getAtttype() == 1){
			for(int n=0;n<attnonpudata.length;n++){
				KqglAssoTeshu non = KqglAssoTeshu.builder().kqzid(attid).tsrq(attnonpudata[n]).bcid(0).lusjTime(new Date().getTime()).luryid(userBean.getEmpNum()).type(2).build();
				speclist.add(non);
			}
		}
		if(speclist.size()>0){
			kqglassoteshumapper.insertKqglAssoTeshuList(speclist);
		}
		
		//记录排班(排班制)
		List<KqglAssoPbmxDto> schlist=new ArrayList<KqglAssoPbmxDto>();
		KqglAssoPbmxDto[] schedules = attass.getSchedules();// 排班日期【排班制】--班次id、日期
		if(schedules.length>0 && attass.getAtttype() == 2){
			for(int p=0;p<schedules.length;p++){
				KqglAssoPbmxDto sch = KqglAssoPbmxDto.builder().userid(schedules[p].getUserid()).data(schedules[p].getData()).bcid(schedules[p].getBcid()).kqzid(attid).build();
				schlist.add(sch);
			}
		}
		if(schlist.size()>0){
			kqglassopbmxmapper.insertKqglAssoPbmxList(schlist);
		}
		
		return ResultUtil.data(attgro,"操作成功!");
	}
	
	
lal committed
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281
	
	/**
	 * 	获取当前考勤组所有人员
	 */
	@GetMapping(value="/AttUserGroupList/{id}")
	@ApiOperation(value = "获取当前考勤组所有人员", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> getAttUserGroupList(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
		
		UserAttendanceRelDto usatt = UserAttendanceRelDto.builder().build();
		List<UserAttendanceRel> userattgor = userattendancerelmapper.selectAttendanceOfficerByKqzid(id,userBean.getOrgCode());
		usatt.setUseratts(userattgor);
		
		KqglMainKqz kqztypeid = kqglmainkqzmapper.selectOne(new QueryWrapper<KqglMainKqz>().lambda().eq(KqglMainKqz::getId, id));
		usatt.setTypeid(kqztypeid.getPbfs());
		
		return ResultUtil.data(usatt);
	}
	
	@PostMapping(value = "/setmembers")
	@ApiOperation(value = "考勤设置成员", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> Attsetmembers(@CurrentUser UserBean userBean,@RequestBody AttMemberSettings attsetuser) {
		
		//确认当前考勤组是否存在考勤机打卡
		List<KqglAssoKqzdkfs> dkfs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getType, 1).eq(KqglAssoKqzdkfs::getKqzId, attsetuser.getAttgroupid()));
		if(dkfs.size() > 0) {
			for(KqglAssoKqzdkfs fss:dkfs) {
				String DevId = null;
				int kqjid = 0;
				KqglAssoKqj kqj = KqglAssoKqj.builder().id(fss.getDkfsid()).build().selectById();//查询考勤机“序列号”
				DevId = kqj.getCode();
				kqjid = kqj.getId();
				
				//考勤组新增员工
				String[] addmember = attsetuser.getAddMember();
lal committed
1282
				String urladd = mac_command+"/addUserName";
lal committed
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298
				for(int a=0;a<addmember.length;a++){
					HttpHeaders headers = new HttpHeaders();
			        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
			        params.add("devId", DevId);
			        params.add("userId", addmember[a]);
			        YgglMainEmp yggluser = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).eq(YgglMainEmp::getEmpNum, addmember[a]));
			        params.add("userName", yggluser.getName());
			        RestTemplate restTemplate = new RestTemplate();
			        HttpEntity httpEntity = new HttpEntity(params, headers);
			        ResponseEntity<String> request = restTemplate.postForEntity(urladd, httpEntity, String.class);
			        System.err.print(request.getBody());
			        
			        //需要改下下
			        KqglAssoYhsb uskqj = KqglAssoYhsb.builder().userId(Integer.valueOf(addmember[a])).kqjid(kqjid).type(1).isGly(0).build();
					if (!uskqj.insert()) 
						return ResultUtil.error("操作失败--新增用户与设备关系");
lal committed
1299 1300
					
					KqglAssoYhkqz.builder().kqzid(attsetuser.getAttgroupid()).userid(Integer.valueOf(addmember[a])).qyid(userBean.getOrgCode()).build().insert();
lal committed
1301 1302 1303 1304
				}
				
				//考勤组减少员工 
		        String[] removemember = attsetuser.getRemoveMember();
lal committed
1305
		        String urlre = mac_command+"/deleteUser";
lal committed
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319
		        for(int r=0;r<removemember.length;r++){
		        	HttpHeaders headers = new HttpHeaders();
		            MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
		            params.add("devId", DevId);
		            params.add("userId", removemember[r]);
		            RestTemplate restTemplate = new RestTemplate();
		            HttpEntity httpEntity = new HttpEntity(params, headers);
		            ResponseEntity<String> request = restTemplate.postForEntity(urlre, httpEntity, String.class);
		            System.err.print(request.getBody());
		            
		            //用户与设备关系表
		            KqglAssoYhsb.builder().build().delete(new QueryWrapper<KqglAssoYhsb>().lambda().eq(KqglAssoYhsb::getUserId, removemember[r]).eq(KqglAssoYhsb::getKqjid, kqjid).eq(KqglAssoYhsb::getType, 1));
		            //考勤机管理员
		            KqglAssoKqjgly.builder().build().delete(new QueryWrapper<KqglAssoKqjgly>().lambda().eq(KqglAssoKqjgly::getKqjid, kqjid).eq(KqglAssoKqjgly::getUserid, removemember[r]));
lal committed
1320 1321
		            //用户和考勤组关系表
		            KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getKqzid, attsetuser.getAttgroupid()).eq(KqglAssoYhkqz::getUserid, removemember[r]));
lal committed
1322 1323 1324 1325 1326 1327 1328 1329 1330
				}
			}
			
		}
		
        return ResultUtil.success("成功");
	}
	
	
ilal committed
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375
	@PutMapping(value="/switch")
	@ApiOperation(value = "41:设置假期规则开关", httpMethod = "PUT", notes = "接口发布说明")
	@ApiOperationSupport(order = 41)
	public Result<Object> setswitch(@CurrentUser UserBean userBean, @RequestBody SetConditionsDto setconditionsdto) {
		return KqglAssoLeaveRules.builder().id(setconditionsdto.getId()).isOpen(setconditionsdto.getParameters()).build().updateById() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
	}


	/**
	 * 获取修改的排班明细--【修改考勤组】--------------------------------------------------------------------------------------
	 */
	@PostMapping(value = "/AttGroupSchedulingList")
	@ApiOperation(value = "42:获取修改的排班明细", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 42)
	public Result<Object> getAttGroupSchedulingList(@CurrentUser UserBean userBean,@RequestBody AttSchedulingDto attscheduling) {
			String str = new SimpleDateFormat("yyyy-MM").format(new Date());
			if(("").equals(attscheduling.getDate()) || attscheduling.getDate() == null){
				attscheduling.setDate(str);
			}
			attscheduling.setQyid(userBean.getOrgCode());
			List<KqglAssoPbmxDto> schlist = kqglassopbmxmapper.selectAttGroupScheduling(attscheduling);
			return ResultUtil.data(schlist);
	}
	
	/**
	 * 根据考勤组id获取班次信息--【修改考勤组】
	 */
	@GetMapping(value="/roster/{id}/{date}")
	@ApiOperation(value = "43:根据考勤组id获取班次信息", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 43)
	public Result<Object> getRosterList(@PathVariable("id") Integer id,@PathVariable("date") String date) {
		
		KqzAttendanceGroupSearchDto jycx = KqzAttendanceGroupSearchDto.builder().overall(date).qyid(id).build();
		
		List<KqglAssoBcsz> shifs = kqglassobcszmapper.selectRosterByKqzid(jycx);
		return ResultUtil.data(shifs);
	}
	
	private SimpleDateFormat mat = new SimpleDateFormat("yyyy-MM-dd");
	
	@Autowired
	private KqglAssoDkjlMapper kqglassodkjlmapper;
	
	//打卡记录
	@Autowired
lal committed
1376
	private PunchRecordMapper punchrecordmapper;
ilal committed
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
	//打卡明细表
	@Autowired
	private PunchCardDetailsMapper punchcarddetailsservice;
	/**
	 * 修改考勤组排班(修改排班后,需判断是否有打卡记录,有则匹配当天修改后的班次,无则不需要修改)
	 * @throws ParseException 
	 */
	@PutMapping(value = "/attscheduling")
	@ApiOperation(value = "44:修改考勤组排班", httpMethod = "PUT", notes = "接口发布说明")
	@ApiOperationSupport(order = 44)
	public Result<Object> updateAttscheduling(@CurrentUser UserBean userBean,@RequestBody AttendanceAssistantDto attass) throws ParseException {
		int id = Integer.valueOf(attass.getAttgroupid());//修改数据id
		
		List<KqglAssoPbmxDto> schlist = new ArrayList<KqglAssoPbmxDto>();
		KqglAssoPbmxDto[] schedules = attass.getSchedules();// 排班日期【排班制】--班次id、日期
		if(schedules.length>0 && attass.getAtttype() == 2){
			for(int p=0;p<schedules.length;p++){
				KqglAssoPbmxDto sch = KqglAssoPbmxDto.builder().userid(schedules[p].getUserid()).data(schedules[p].getData()).bcid(schedules[p].getBcid()).kqzid(Integer.valueOf(attass.getAttgroupid())).build();
				schlist.add(sch);
				String data = mat.format(new Date(schedules[p].getData().toString()));
				Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(data,"yyyy-MM-dd")).getTime();
				Long endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(data,"yyyy-MM-dd")).getTime();
				
				KqglAssoBcsz banci = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, schedules[p].getBcid()));
				Long sbdk1 = 0l,xbdk1 = 0l,sbdk2 = 0l,xbdk2 = 0l,sbdk3 = 0l,xbdk3 = 0l;
				if(banci != null){
					if(banci.getSxbcs()== 1 || banci.getSxbcs()== 2 || banci.getSxbcs()== 3){
						sbdk1 = Long.valueOf(ClockInTool.dateToStamp(data+" "+ClockInTool.dealDateFormat(banci.getSbdk1(),2)+":00"));
						xbdk1 = Long.valueOf(ClockInTool.dateToStamp(data+" "+ClockInTool.dealDateFormat(banci.getXbdk1(),2)+":00"));
					}
					if(banci.getSxbcs()== 2 || banci.getSxbcs()== 3){
						sbdk2 = Long.valueOf(ClockInTool.dateToStamp(data+" "+ClockInTool.dealDateFormat(banci.getSbdk2(),2)+":00"));
						xbdk2 = Long.valueOf(ClockInTool.dateToStamp(data+" "+ClockInTool.dealDateFormat(banci.getXbdk2(),2)+":00"));
					}
					if(banci.getSxbcs()== 3){
						sbdk3 = Long.valueOf(ClockInTool.dateToStamp(data+" "+ClockInTool.dealDateFormat(banci.getSbdk3(),2)+":00"));
						xbdk3 = Long.valueOf(ClockInTool.dateToStamp(data+" "+ClockInTool.dealDateFormat(banci.getXbdk3(),2)+":00"));
					}
				}
				
				KqglAssoDkjl mapuca = KqglAssoDkjl.builder().build().selectOne(new QueryWrapper<KqglAssoDkjl>().lambda().gt(KqglAssoDkjl::getAttime, startDate).lt(KqglAssoDkjl::getAttime, endDate).eq(KqglAssoDkjl::getUserId, schedules[p].getUserid()).last("LIMIT 1"));
				
				List<KqglAssoDkjl> mapucalist = kqglassodkjlmapper.selectList(new QueryWrapper<KqglAssoDkjl>().lambda().gt(KqglAssoDkjl::getAttime, startDate).lt(KqglAssoDkjl::getAttime, endDate).eq(KqglAssoDkjl::getUserId, schedules[p].getUserid()).orderByAsc(KqglAssoDkjl::getId));
				
				if(mapuca != null && !(schedules[p].getBcid()).equals(mapuca.getBcid())){
//					List<KqglAssoDkjl> initial = kqglassodkjlmapper.selectList(new QueryWrapper<KqglAssoDkjl>().lambda().gt(KqglAssoDkjl::getAttime, startDate).lt(KqglAssoDkjl::getAttime, endDate).eq(KqglAssoDkjl::getUserId, schedules[p].getUserid()).orderByAsc(KqglAssoDkjl::getId));
					if(mapucalist.size() > 0){
						RestMethod(mapucalist,mapucalist.get(0).getDkmxid());
					}
				}
				KqglAssoDkjl minAttid = null,maxAttid = null;
				int dkmxid = 0;
				if(mapucalist.size() > 0){
					//最小值
			        minAttid = mapucalist.stream().min(Comparator.comparing(KqglAssoDkjl::getId)).get();
					//最大值
					maxAttid = mapucalist.stream().max(Comparator.comparing(KqglAssoDkjl::getId)).get();
					//对应打卡明细表id
					dkmxid = maxAttid.getDkmxid();
				}
				//当天有打卡记录且当天打卡班次和当前修改后的班次不匹配再进行重新维护
				if(mapuca != null && !(schedules[p].getBcid()).equals(mapuca.getBcid())){
					if(banci != null){//修改后有班次打卡
						if(banci.getSxbcs() == 1){//修改后一天打两次
							if(mapucalist.size() > 2){/////当天打卡多条的话 取最开始打的卡和最后打的卡 作为新一轮的上下班考勤
								for(KqglAssoDkjl pre : mapucalist){
									if(pre.getId() != minAttid.getId() && pre.getId() != maxAttid.getId()){//去除最大和最小 其他均改为“打卡无效:此记录已被更新”
										int results=0;long attime;
										if((pre.getSort())%2 > 0){
											Long time = (pre.getDktime() - sbdk1)/1000/60;
											if(time > 0){ results= Integer.valueOf(time.toString());}
											attime= sbdk1;//上班应打卡时间
										}else{
											Long time = (pre.getDktime() - xbdk1)/1000/60;
											if(time > 0){}else{results = Math.abs(Integer.valueOf(time.toString()));}
											attime = xbdk1;//下班应打卡时间
										}
										KqglAssoDkjl.builder().id(pre.getId()).status(0).sort(0).results(results).attime(attime).bcid(banci.getId()).build().updateById();
									}else {
										if(pre.getId() == minAttid.getId()){//上班
											Long time = (pre.getDktime() - sbdk1)/1000/60;
											int status=0,results=0;//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
											if(time > 0){ status=3; results=Integer.valueOf(time.toString());}else{ status = 1; results = 0;}
											KqglAssoDkjl.builder().id(pre.getId()).type(1).status(status).results(results).attime(sbdk1).bcid(banci.getId()).build().updateById();
										}else if(pre.getId() == maxAttid.getId()){//下班
											Long time = (pre.getDktime() - xbdk1)/1000/60;
											int status=0,results=0;
											if(time > 0){ status = 1; results = 0;}else{ status = 4; results = Math.abs(Integer.valueOf(time.toString()));}
											KqglAssoDkjl.builder().id(pre.getId()).type(2).status(status).results(results).attime(xbdk1).bcid(banci.getId()).sort(2).build().updateById();
										}
									}
								}
								KqglAssoDkjl mindata = KqglAssoDkjl.builder().id(minAttid.getId()).build().selectById();
								KqglAssoDkmx.builder().id(dkmxid).sbdk1(mindata.getDktime()).sbdk1jg(mindata.getResults()).xbdk1(null).xbdk1jg(0).sbdk2(null).sbdk2jg(0).xbdk2(null)
										.xbdk2jg(0).sbdk3(null).sbdk3jg(0).ydkcs(banci.getSxbcs()*2).gzsc(Double.valueOf("0")).build().updateById();
								
								KqglAssoDkjl maxdata = KqglAssoDkjl.builder().id(maxAttid.getId()).build().selectById();
								Long woktimes = (maxdata.getDktime() - mindata.getDktime())/1000/60;
								KqglAssoDkmx.builder().id(dkmxid).xbdk1(maxdata.getDktime()).xbdk1jg(maxdata.getResults()).gzsc(Double.valueOf(woktimes)).build().updateById();
							}else {
								KqglAssoDkjl mindataone = null;
								if(minAttid != null || maxAttid != null){
									int status=0,results=0;
									Long time = (mapucalist.get(0).getDktime() - sbdk1)/1000/60;
									if(time > 0){ status = 3; results = Integer.valueOf(time.toString()); }else{ status = 1; results=0; }
									KqglAssoDkjl.builder().id(mapucalist.get(0).getId()).type(1).status(status).results(results).attime(sbdk1).bcid(banci.getId()).build().updateById();
									mindataone = KqglAssoDkjl.builder().id(minAttid.getId()).build().selectById();
									KqglAssoDkmx.builder().id(dkmxid).sbdk1(mindataone.getDktime()).sbdk1jg(mindataone.getResults()).ydkcs(banci.getSxbcs()*2).gzsc(Double.valueOf("0")).build().updateById();
								}
								
								if(maxAttid != null && minAttid.getId() != maxAttid.getId()){
									int status=0,results=0;
									Long time = (mapucalist.get(1).getDktime() - xbdk1)/1000/60;
									if(time > 0){ status = 1; results=0; }else{ status = 4; results = Math.abs(Integer.valueOf(time.toString())); }
									KqglAssoDkjl.builder().id(mapucalist.get(1).getId()).type(2).status(status).results(results).attime(xbdk1).bcid(banci.getId()).sort(2).build().updateById();
									KqglAssoDkjl maxdata = KqglAssoDkjl.builder().id(maxAttid.getId()).build().selectById();
									Long woktimes = (maxdata.getDktime() - mindataone.getDktime())/1000/60;
									KqglAssoDkmx.builder().id(dkmxid).xbdk1(maxdata.getDktime()).xbdk1jg(maxdata.getResults()).gzsc(Double.valueOf(woktimes)).build().updateById();
								}
							}
						}else if(banci.getSxbcs() == 2){//修改后一天打四次
							if(mapucalist.size() > 4){//当天打卡多次
								String[] str= new String[3];
								for(int y=0;y<mapucalist.size();y++){
									if(y == 0){//上班
lal committed
1502
										PunchRecord mindata = punchrecordmapper.selectByPrimaryKey(minAttid.getId());//上班
ilal committed
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
										PunchRecord record = new PunchRecord();
										record.setId(mapucalist.get(y).getId());
										Long time = (mindata.getDktime() - sbdk1)/1000/60;
										if(time > 0){
											record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
											record.setResults(Integer.valueOf(time.toString()));// 打卡结果
										}else{
											record.setStatus(1);
											record.setResults(0);// 打卡结果
										}
										record.setAttime(sbdk1);
										record.setBcid(banci.getId());//班次id
lal committed
1515
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
									}
									if(y == 1 || y == 2){
										PunchRecord record = new PunchRecord();
										record.setId(mapucalist.get(y).getId());
										if((mapucalist.get(y).getSort())%2 == 0){//下班
											Long time = (mapucalist.get(y).getDktime() - xbdk1)/1000/60;
											if(time > 0){
												record.setStatus(1);
												record.setResults(0);// 打卡结果
											}else{
												record.setStatus(4);
												record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
											}
											record.setAttime(xbdk1);//下班应打卡时间
											str[0] = String.valueOf(mapucalist.get(y).getId());
										}else{//上班
											Long time = (mapucalist.get(y).getDktime() - sbdk2)/1000/60;
											if(time > 0){
												record.setStatus(3);
												record.setResults(Integer.valueOf(time.toString()));// 打卡结果
											}else{
												record.setStatus(1);
												record.setResults(0);// 打卡结果
											}
											record.setAttime(sbdk2);//上班应打卡时间
											
											str[1] = String.valueOf(mapucalist.get(y).getId());
										}
										record.setBcid(banci.getId());//班次id
lal committed
1545
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1546
									}
lal committed
1547
									PunchRecord maxdata = punchrecordmapper.selectByPrimaryKey(maxAttid.getId());//下班
ilal committed
1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562
									if(mapucalist.get(y).getId() == maxdata.getId()){//下班
										PunchRecord record = new PunchRecord();
										record.setId(maxdata.getId());
										record.setType(2);//下班
										Long time = (maxdata.getDktime() - xbdk2)/1000/60;
										if(time > 0){
											record.setStatus(1);
											record.setResults(0);// 打卡结果
										}else{
											record.setStatus(4);
											record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
										}
										record.setSort(4);
										record.setAttime(xbdk2);
										record.setBcid(banci.getId());//班次id
lal committed
1563
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574
										
										str[2] = String.valueOf(maxdata.getId());
									}
									if(y == 3 || y > 3 && mapucalist.get(y).getId() != maxdata.getId()){
										PunchRecord record = new PunchRecord();
										record.setId(mapucalist.get(y).getId());
										record.setStatus(0);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setSort(0);//序号(0:打卡无效:此记录已被更新)
										record.setResults(0);// 打卡结果
										record.setAttime(mapucalist.get(y).getDktime());//上班应打卡时间
										record.setBcid(banci.getId());//班次id
lal committed
1575
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1576 1577 1578
									}
								}
								//修改打卡明细
lal committed
1579
								PunchRecord mindata = punchrecordmapper.selectByPrimaryKey(minAttid.getId());//上班
ilal committed
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597
								PunchCardDetails record = new PunchCardDetails();
								record.setId(dkmxid);//需修改的明细id
								record.setSbdk1(mindata.getDktime());
								record.setSbdk1jg(mindata.getResults());// 上班1打卡结果
								record.setXbdk1(null);
								record.setXbdk1jg(0);// 下班1打卡结果
								record.setSbdk2(null);
								record.setSbdk2jg(0);// 上班2打卡结果
								record.setXbdk2(null);
								record.setXbdk2jg(0);// 下班2打卡结果
								record.setSbdk3(null);
								record.setSbdk3jg(0);// 上班3打卡结果
								record.setXbdk3(null);
								record.setXbdk3jg(0);// 下班3打卡结果
								record.setYdkcs(banci.getSxbcs()*2);//应打卡次数
								record.setGzsc(Double.valueOf("0"));
								punchcarddetailsservice.ModifyPunchDetails(record);
								for(int t=0;t<str.length;t++){
lal committed
1598
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(Integer.valueOf(str[t]));//单条打卡明细
ilal committed
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631
									
									PunchCardDetails dkmx = new PunchCardDetails();
									dkmx.setId(dkmxid);//需修改的明细id
									if(t == 0){
										dkmx.setXbdk1(dtdkmx.getDktime());
										dkmx.setXbdk1jg(dtdkmx.getResults());// 下班1打卡结果
									}else if(t == 1){
										dkmx.setSbdk2(dtdkmx.getDktime());
										dkmx.setSbdk2jg(dtdkmx.getResults());// 上班2打卡结果
									}else{
										dkmx.setXbdk2(dtdkmx.getDktime());
										dkmx.setXbdk2jg(dtdkmx.getResults());// 下班2打卡结果
									}
									Long woktimes = (dtdkmx.getDktime() - mindata.getDktime())/1000/60;
									dkmx.setGzsc(Double.valueOf(woktimes));
									punchcarddetailsservice.updateByPrimaryKeySelective(dkmx);
								}
							}else{//打卡小于4次
								PunchRecord mindataone = null;
								if(minAttid != null || maxAttid != null){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(0).getId());//当天一条记录的id
									record.setType(1);//上班
									Long time = (mapucalist.get(0).getDktime() - sbdk1)/1000/60;
									if(time > 0){
										record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setResults(Integer.valueOf(time.toString()));// 打卡结果
									}else{
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}
									record.setAttime(sbdk1);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1632 1633
									punchrecordmapper.updateByPrimaryKeySelective(record);
									mindataone = punchrecordmapper.selectByPrimaryKey(minAttid.getId());//上班
ilal committed
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656
									PunchCardDetails dan = new PunchCardDetails();
									dan.setId(dkmxid);//需修改的明细id
									dan.setSbdk1(mindataone.getDktime());
									dan.setSbdk1jg(mindataone.getResults());// 上班1打卡结果
									dan.setYdkcs(banci.getSxbcs()*2);//应打卡次数
									dan.setGzsc(Double.valueOf("0"));
									punchcarddetailsservice.updateByPrimaryKeySelective(dan);
								}
								PunchCardDetails pcd = new PunchCardDetails();
								if(mapucalist.size() >= 2){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(1).getId());//当天一条记录的id
									record.setType(2);
									Long time = (mapucalist.get(1).getDktime() - xbdk1)/1000/60;
									if(time > 0){
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}else{
										record.setStatus(4);
										record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
									}
									record.setAttime(xbdk1);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1657 1658
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(mapucalist.get(1).getId());//单条打卡明细
ilal committed
1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675
									pcd.setXbdk1(dtdkmx.getDktime());
									pcd.setXbdk1jg(dtdkmx.getResults());
								}
								if(mapucalist.size() >= 3){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(2).getId());//当天一条记录的id
									record.setType(1);
									Long time = (mapucalist.get(2).getDktime() - sbdk2)/1000/60;
									if(time > 0){
										record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setResults(Integer.valueOf(time.toString()));// 打卡结果
									}else{
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}
									record.setAttime(sbdk2);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1676 1677
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(mapucalist.get(2).getId());//单条打卡明细
ilal committed
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694
									pcd.setSbdk2(dtdkmx.getDktime());
									pcd.setSbdk2jg(dtdkmx.getResults());
								}
								if(mapucalist.size() >= 4){
									PunchRecord record = new PunchRecord();
									record.setId(maxAttid.getId());//当天一条记录的id
									record.setType(2);
									Long time = (maxAttid.getDktime() - xbdk2)/1000/60;
									if(time > 0){
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}else{
										record.setStatus(4);
										record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
									}
									record.setAttime(xbdk2);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1695 1696
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(maxAttid.getId());//单条打卡明细
ilal committed
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707
									pcd.setXbdk2(dtdkmx.getDktime());
									pcd.setXbdk2jg(dtdkmx.getResults());
								}
								pcd.setId(dkmxid);
								punchcarddetailsservice.updateByPrimaryKeySelective(pcd);
							}
						}else if(banci.getSxbcs() == 3){//修改后一天打六次
							if(mapucalist.size() > 6){//当天打卡多次
								String[] str= new String[5];
								for(int y=0;y<mapucalist.size();y++){
									if(y == 0){//上班
lal committed
1708
										PunchRecord mindata = punchrecordmapper.selectByPrimaryKey(minAttid.getId());//上班
ilal committed
1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720
										PunchRecord record = new PunchRecord();
										record.setId(mapucalist.get(y).getId());
										Long time = (mindata.getDktime() - sbdk1)/1000/60;
										if(time > 0){
											record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
											record.setResults(Integer.valueOf(time.toString()));// 打卡结果
										}else{
											record.setStatus(1);
											record.setResults(0);// 打卡结果
										}
										record.setAttime(sbdk1);
										record.setBcid(banci.getId());//班次id
lal committed
1721
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777
									}
									if(y == 1 || y == 2 || y == 3 || y == 4){
										PunchRecord record = new PunchRecord();
										record.setId(mapucalist.get(y).getId());
										if((mapucalist.get(y).getSort())%2 == 0){//下班
											if(y == 1){
												Long time = (mapucalist.get(y).getDktime() - xbdk1)/1000/60;
												if(time > 0){
													record.setStatus(1);
													record.setResults(0);// 打卡结果
												}else{
													record.setStatus(4);
													record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
												}
												record.setAttime(xbdk1);//下班应打卡时间
												str[0] = String.valueOf(mapucalist.get(y).getId());
											}
											if(y == 3){
												Long time = (mapucalist.get(y).getDktime() - xbdk2)/1000/60;
												if(time > 0){
													record.setStatus(1);
													record.setResults(0);// 打卡结果
												}else{
													record.setStatus(4);
													record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
												}
												record.setAttime(xbdk2);//下班应打卡时间
												str[2] = String.valueOf(mapucalist.get(y).getId());
											}
										}else{//上班
											if(y == 2){
												Long time = (mapucalist.get(y).getDktime() - sbdk2)/1000/60;
												if(time > 0){
													record.setStatus(3);
													record.setResults(Integer.valueOf(time.toString()));// 打卡结果
												}else{
													record.setStatus(1);
													record.setResults(0);// 打卡结果
												}
												record.setAttime(sbdk2);//上班应打卡时间
												str[1] = String.valueOf(mapucalist.get(y).getId());
											}
											if(y == 4){
												Long time = (mapucalist.get(y).getDktime() - sbdk3)/1000/60;
												if(time > 0){
													record.setStatus(3);
													record.setResults(Integer.valueOf(time.toString()));// 打卡结果
												}else{
													record.setStatus(1);
													record.setResults(0);// 打卡结果
												}
												record.setAttime(sbdk3);//上班应打卡时间
												str[3] = String.valueOf(mapucalist.get(y).getId());
											}
										}
										record.setBcid(banci.getId());//班次id
lal committed
1778
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1779
									}
lal committed
1780
									PunchRecord maxdata = punchrecordmapper.selectByPrimaryKey(maxAttid.getId());//下班
ilal committed
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795
									if(mapucalist.get(y).getId() == maxdata.getId()){//下班
										PunchRecord record = new PunchRecord();
										record.setId(maxdata.getId());
										record.setType(2);//下班
										Long time = (maxdata.getDktime() - xbdk3)/1000/60;
										if(time > 0){
											record.setStatus(1);
											record.setResults(0);// 打卡结果
										}else{
											record.setStatus(4);
											record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
										}
										record.setSort(6);
										record.setAttime(xbdk3);
										record.setBcid(banci.getId());//班次id
lal committed
1796
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807
										
										str[4] = String.valueOf(maxdata.getId());
									}
									if(y == 5 || y > 5 && mapucalist.get(y).getId() != maxdata.getId()){
										PunchRecord record = new PunchRecord();
										record.setId(mapucalist.get(y).getId());
										record.setStatus(0);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setSort(0);//序号(0:打卡无效:此记录已被更新)
										record.setResults(0);// 打卡结果
										record.setAttime(mapucalist.get(y).getDktime());//上班应打卡时间
										record.setBcid(banci.getId());//班次id
lal committed
1808
										punchrecordmapper.updateByPrimaryKeySelective(record);
ilal committed
1809 1810 1811
									}
								}
								//修改打卡明细
lal committed
1812
								PunchRecord mindata = punchrecordmapper.selectByPrimaryKey(minAttid.getId());//上班
ilal committed
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830
								PunchCardDetails record = new PunchCardDetails();
								record.setId(dkmxid);//需修改的明细id
								record.setSbdk1(mindata.getDktime());
								record.setSbdk1jg(mindata.getResults());// 上班1打卡结果
								record.setXbdk1(null);
								record.setXbdk1jg(0);// 下班1打卡结果
								record.setSbdk2(null);
								record.setSbdk2jg(0);// 上班2打卡结果
								record.setXbdk2(null);
								record.setXbdk2jg(0);// 下班2打卡结果
								record.setSbdk3(null);
								record.setSbdk3jg(0);// 上班3打卡结果
								record.setXbdk3(null);
								record.setXbdk3jg(0);// 下班3打卡结果
								record.setYdkcs(banci.getSxbcs()*2);//应打卡次数
								record.setGzsc(Double.valueOf("0"));
								punchcarddetailsservice.ModifyPunchDetails(record);
								for(int t=0;t<str.length;t++){
lal committed
1831
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(Integer.valueOf(str[t]));//单条打卡明细
ilal committed
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869
									PunchCardDetails dkmx = new PunchCardDetails();
									dkmx.setId(dkmxid);//需修改的明细id
									if(t == 0){
										dkmx.setXbdk1(dtdkmx.getDktime());
										dkmx.setXbdk1jg(dtdkmx.getResults());// 下班1打卡结果
									}else if(t == 1){
										dkmx.setSbdk2(dtdkmx.getDktime());
										dkmx.setSbdk2jg(dtdkmx.getResults());// 上班2打卡结果
									}else if(t == 2){
										dkmx.setXbdk2(dtdkmx.getDktime());
										dkmx.setXbdk2jg(dtdkmx.getResults());// 下班2打卡结果
									}else if(t == 3){
										dkmx.setSbdk3(dtdkmx.getDktime());
										dkmx.setSbdk3jg(dtdkmx.getResults());// 上班3打卡结果
									}else{
										dkmx.setXbdk3(dtdkmx.getDktime());
										dkmx.setXbdk3jg(dtdkmx.getResults());// 下班3打卡结果
									}
									Long woktimes = (dtdkmx.getDktime() - mindata.getDktime())/1000/60;
									dkmx.setGzsc(Double.valueOf(woktimes));
									punchcarddetailsservice.updateByPrimaryKeySelective(dkmx);
								}
							}else{
								PunchRecord mindataone = null;
								if(minAttid != null || maxAttid != null){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(0).getId());//当天一条记录的id
									record.setType(1);//上班
									Long time = (mapucalist.get(0).getDktime() - sbdk1)/1000/60;
									if(time > 0){
										record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setResults(Integer.valueOf(time.toString()));// 打卡结果
									}else{
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}
									record.setAttime(sbdk1);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1870 1871
									punchrecordmapper.updateByPrimaryKeySelective(record);
									mindataone = punchrecordmapper.selectByPrimaryKey(minAttid.getId());//上班
ilal committed
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894
									PunchCardDetails dan = new PunchCardDetails();
									dan.setId(dkmxid);//需修改的明细id
									dan.setSbdk1(mindataone.getDktime());
									dan.setSbdk1jg(mindataone.getResults());// 上班1打卡结果
									dan.setYdkcs(banci.getSxbcs()*2);//应打卡次数
									dan.setGzsc(Double.valueOf("0"));
									punchcarddetailsservice.updateByPrimaryKeySelective(dan);
								}
								PunchCardDetails pcd = new PunchCardDetails();
								if(mapucalist.size() >= 2){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(1).getId());//当天一条记录的id
									record.setType(2);
									Long time = (mapucalist.get(1).getDktime() - xbdk1)/1000/60;
									if(time > 0){
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}else{
										record.setStatus(4);
										record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
									}
									record.setAttime(xbdk1);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1895 1896
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(mapucalist.get(1).getId());//单条打卡明细
ilal committed
1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913
									pcd.setXbdk1(dtdkmx.getDktime());
									pcd.setXbdk1jg(dtdkmx.getResults());
								}
								if(mapucalist.size() >= 3){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(2).getId());//当天一条记录的id
									record.setType(1);
									Long time = (mapucalist.get(2).getDktime() - sbdk2)/1000/60;
									if(time > 0){
										record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setResults(Integer.valueOf(time.toString()));// 打卡结果
									}else{
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}
									record.setAttime(sbdk2);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1914 1915
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(mapucalist.get(2).getId());//单条打卡明细
ilal committed
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932
									pcd.setSbdk2(dtdkmx.getDktime());
									pcd.setSbdk2jg(dtdkmx.getResults());
								}
								if(mapucalist.size() >= 4){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(3).getId());//当天一条记录的id
									record.setType(1);
									Long time = (mapucalist.get(3).getDktime() - xbdk2)/1000/60;
									if(time > 0){
										record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setResults(Integer.valueOf(time.toString()));// 打卡结果
									}else{
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}
									record.setAttime(xbdk2);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1933 1934
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(mapucalist.get(3).getId());//单条打卡明细
ilal committed
1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
									pcd.setXbdk2(dtdkmx.getDktime());
									pcd.setXbdk2jg(dtdkmx.getResults());
								}
								if(mapucalist.size() >= 5){
									PunchRecord record = new PunchRecord();
									record.setId(mapucalist.get(4).getId());//当天一条记录的id
									record.setType(1);
									Long time = (mapucalist.get(4).getDktime() - sbdk3)/1000/60;
									if(time > 0){
										record.setStatus(3);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
										record.setResults(Integer.valueOf(time.toString()));// 打卡结果
									}else{
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}
									record.setAttime(sbdk3);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1952 1953
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(mapucalist.get(4).getId());//单条打卡明细
ilal committed
1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971
									pcd.setSbdk3(dtdkmx.getDktime());
									pcd.setSbdk3jg(dtdkmx.getResults());
									
								}
								if(mapucalist.size() >= 6){
									PunchRecord record = new PunchRecord();
									record.setId(maxAttid.getId());//当天一条记录的id
									record.setType(2);
									Long time = (maxAttid.getDktime() - xbdk3)/1000/60;
									if(time > 0){
										record.setStatus(1);
										record.setResults(0);// 打卡结果
									}else{
										record.setStatus(4);
										record.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
									}
									record.setAttime(xbdk3);//当天应打卡时间
									record.setBcid(banci.getId());//班次id
lal committed
1972 1973
									punchrecordmapper.updateByPrimaryKeySelective(record);
									PunchRecord dtdkmx = punchrecordmapper.selectByPrimaryKey(maxAttid.getId());//单条打卡明细
ilal committed
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021
									pcd.setXbdk3(dtdkmx.getDktime());
									pcd.setXbdk3jg(dtdkmx.getResults());
								}
								pcd.setId(dkmxid);
								punchcarddetailsservice.updateByPrimaryKeySelective(pcd);
							}
						}
					}else{////修改后班次为休息的
						RestMethod(mapucalist,dkmxid);
					}
				}
			}
		}
		
		if(schlist.size()>0){
			//删除排班明细表(自由排班)
			KqglAssoPbmx.builder().build().delete(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getKqzid, id));
			kqglassopbmxmapper.insertKqglAssoPbmxList(schlist);
			return ResultUtil.data(schlist,"修改考勤组排班成功");
		}
		
		return ResultUtil.error("修改考勤组排班失败");
	}
	
	/**
	 *	班次修改调用方法
	 */
	public void RestMethod(List<KqglAssoDkjl> mapucalist,int dkmxid){
		int q = 1;
		for(KqglAssoDkjl pres : mapucalist){
			int type = 0;
			if(q%2 > 0){type= 1;}else{type = 2;}
			KqglAssoDkjl.builder().id(pres.getId()).results(0).type(type).status(1).sort(q).attime(pres.getDktime()).bcid(0).build().updateById();
			q++;
		}
		if(mapucalist.size() > 0){/*******修改打卡明细数据****/
			KqglAssoDkmx pcd = KqglAssoDkmx.builder().build();
			if(mapucalist.size() >= 1){ pcd.setSbdk1(mapucalist.get(0).getDktime());pcd.setSbdk1jg(0);}
			if(mapucalist.size() >= 2){ pcd.setXbdk1(mapucalist.get(1).getDktime());pcd.setXbdk1jg(0);}
			if(mapucalist.size() >= 3){ pcd.setSbdk2(mapucalist.get(2).getDktime());pcd.setSbdk2jg(0);}
			if(mapucalist.size() >= 4){ pcd.setXbdk2(mapucalist.get(3).getDktime()); pcd.setXbdk2jg(0);}
			if(mapucalist.size() >= 5){ pcd.setSbdk3(mapucalist.get(4).getDktime()); pcd.setSbdk3jg(0);}
			if(mapucalist.size() >= 6){ pcd.setXbdk3(mapucalist.get(5).getDktime()); pcd.setXbdk3jg(0);}
			pcd.setId(dkmxid);
			pcd.updateById();
		}
	}
	
ilal committed
2022 2023
	
	@PostMapping(value = "/leave_balance_list")
lal committed
2024
	@ApiOperation(value = "45:获取假期余额列表数据", httpMethod = "POST", notes = "接口发布说明")
ilal committed
2025 2026 2027 2028
	@ApiOperationSupport(order = 45)
	public Result<Object> LeaveBalanceList(@CurrentUser UserBean userBean, @Validated @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
		IPage<EmployeeLeaveBalanceDto> page = new Page<EmployeeLeaveBalanceDto>(
				attquerycriteriadto.getCurrentPage() == null ? 1 : attquerycriteriadto.getCurrentPage(),
lal committed
2029
				attquerycriteriadto.getTotalPage() == 10 ? 9999 : attquerycriteriadto.getTotalPage());
ilal committed
2030 2031 2032 2033 2034 2035 2036 2037
				attquerycriteriadto.setOrgCode(userBean.getOrgCode());
				attquerycriteriadto.setEmpNum(userBean.getEmpNum());
				// 缺-部门id 搜索
				IPage<EmployeeLeaveBalanceDto> pageAs = kqglassoleavebalancemapper.selectPageByQueryLeaveBalance(page, attquerycriteriadto);
				List<EmployeeLeaveBalanceDto> listAs = pageAs.getRecords();
				return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
lal committed
2038
	
lal committed
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048
	/**
	 * 	根据用户id和假期id查询余额具体数据
	 */
	@PostMapping(value = "/modify_employee_balance")
	@ApiOperation(value = "根据用户id和假期id查询余额具体数据", httpMethod = "POST", notes = "接口发布说明")
//	@ApiOperationSupport(order = 45)
	public Result<Object> ModifyEmployeeBalance(@RequestBody ModifyEmployeeBalanceDto bala) {
		List<KqglAssoLeaveBalance> ballist = kqglassoleavebalancemapper.selectList(new QueryWrapper<KqglAssoLeaveBalance>().lambda().eq(KqglAssoLeaveBalance::getLeaveRulesId, bala.getLeaverulesid()).eq(KqglAssoLeaveBalance::getUserid, bala.getEmpnum()));
		return ResultUtil.data(ballist,"操作成功!");
	}
lal committed
2049 2050
	
	
lal committed
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
	/**
	 * 	考勤原始记录-根据 模糊 + 高級查詢-分页
	 */
	@PostMapping(value = "/attendancecalendar")
	@ApiOperation(value = "考勤原始记录-根据 模糊 + 高級查詢-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 34)
	public Result<Object> AttendanceCalendar(@CurrentUser UserBean userBean, @Validated @RequestBody OriginalRecordDto originalrecorddto){
		
			IPage<PunchRecord> page = new Page<PunchRecord>(
					originalrecorddto.getCurrentPage() == null ? 1 : originalrecorddto.getCurrentPage(),
					originalrecorddto.getTotalPage() == null ? 10 : originalrecorddto.getTotalPage());
			originalrecorddto.setQyid(userBean.getOrgCode());
			
			IPage<PunchRecord> pageAs = punchrecordmapper.QueryOriginalRecord(page, originalrecorddto);
			List<PunchRecord> listAs = pageAs.getRecords();
			return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
	
lal committed
2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082
	/**
	 * 获取考勤组所需加班规则
	 */
	@GetMapping(value="/attovertimerules")
	@ApiOperation(value = "获取考勤组所需加班规则", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 15)
	public Result<Object> getAttOvertimeRules(@CurrentUser UserBean userBean){
		
		List<KqglAssoOvertimeRules> attoverrul = new LambdaQueryChainWrapper<KqglAssoOvertimeRules>(kqglassoovertimerulesmapper).eq(KqglAssoOvertimeRules::getOrgCode, userBean.getOrgCode()).list();
		
        return ResultUtil.data(attoverrul,"操作成功!");
	}
	
lal committed
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123
	@Autowired
	private KqglAssoMonthPunchSummaryMapper kqglassomonthpunchsummarymapper;
	@PostMapping(value = "/Summary_data")
	@ApiOperation(value = "获取考勤报表汇总数据", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> SummarydataList(@CurrentUser UserBean userBean, @Validated @RequestBody AttendanceSummaryQueryDto attesummqueto) throws ParseException {
		
		IPage<KqglAssoMonthPunchSummaryDto> page = new Page<KqglAssoMonthPunchSummaryDto>(
				attesummqueto.getCurrentPage() == null ? 1 : attesummqueto.getCurrentPage(),
				attesummqueto.getTotalPage() == null ? 10 : attesummqueto.getTotalPage());
				attesummqueto.setOrgCode(userBean.getOrgCode());
				
				String year = null,month = null;
				String staapptime = null,endapptime = null;
				if(attesummqueto.getTimes() != null && !("").equals(attesummqueto.getTimes())) {
					year = attesummqueto.getTimes().substring(0, 4);
					month = attesummqueto.getTimes().substring(5, 7);
					staapptime = ClockInTool.getFirstDayOfMonth1(Integer.valueOf(year),Integer.valueOf(month));
					endapptime = ClockInTool.getLastDayOfMonth1(Integer.valueOf(year),Integer.valueOf(month));
				}else {
					year =  new SimpleDateFormat("yyyy").format(new Date()).toString();
					month = new SimpleDateFormat("MM").format(new Date()).toString();
					
					Calendar c = Calendar.getInstance();    
					c.add(Calendar.MONTH, 0);
					c.set(Calendar.DAY_OF_MONTH,1);
					staapptime = DateUtil.getStringFormat(DateUtil.getStringTime(mat.format(c.getTime()),"yyyy-MM-dd"));
					Calendar ca = Calendar.getInstance();    
					ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));  
					endapptime = DateUtil.getStringFormat(DateUtil.getStringTime(mat.format(ca.getTime()),"yyyy-MM-dd"));
				}
				
				attesummqueto.setYear(year);
				attesummqueto.setMonth(month);
				attesummqueto.setStaapptime(staapptime);
				attesummqueto.setEndapptime(endapptime);
				// 缺-部门id 搜索
				IPage<KqglAssoMonthPunchSummaryDto> pageAs = kqglassomonthpunchsummarymapper.AttendanceSummaryData(page, attesummqueto);
				List<KqglAssoMonthPunchSummaryDto> listAs = pageAs.getRecords();
				return ResultUtil.data(pageAs, listAs, "操作成功!");
	}
	
lal committed
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155
	@PostMapping(value = "/Daily_details")
	@ApiOperation(value = "获取考勤每日详情数据", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> DailydetailsList(@CurrentUser UserBean userBean, @Validated @RequestBody AttendanceSummaryQueryDto attesummqueto) throws ParseException {
		
		IPage<DailyDetailsDto> page = new Page<DailyDetailsDto>(
				attesummqueto.getCurrentPage() == null ? 1 : attesummqueto.getCurrentPage(),
				attesummqueto.getTotalPage() == null ? 10 : attesummqueto.getTotalPage());
				attesummqueto.setOrgCode(userBean.getOrgCode());
				
				String year = null,month = null,time = null;
				if(attesummqueto.getTimes() != null && !("").equals(attesummqueto.getTimes())) {
					year = attesummqueto.getTimes().substring(0, 4);
					month = attesummqueto.getTimes().substring(5, 7);
					time = attesummqueto.getTimes();
				}else {
					year =  new SimpleDateFormat("yyyy").format(new Date()).toString();
					month = new SimpleDateFormat("MM").format(new Date()).toString();
					
					time = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString();
				}
				
				attesummqueto.setYear(year);
				attesummqueto.setMonth(month);
				attesummqueto.setTimes(time);
				// 缺-部门id 搜索
				IPage<DailyDetailsDto> pageAs = kqglassomonthpunchsummarymapper.Dailydetails(page, attesummqueto);
				List<DailyDetailsDto> listAs = pageAs.getRecords();
				return ResultUtil.data(pageAs, listAs, "操作成功!");
		
		
	}
	
lal committed
2156
	
lal committed
2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208
	@Autowired
	private KqglAssoDkmxMapper kqglassodkmxmapper;
	/**
	 * 	更改打卡结果
	 * @throws ParseException 
	 */
	@PostMapping(value = "/change_punch_results")
	@ApiOperation(value = "更改打卡结果", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> ChangePunchResults(@CurrentUser UserBean userBean,@RequestBody ChangePunchResultsDto chpunchr) throws ParseException {
		String data = chpunchr.getData();//应更改时间yyyy-MMM-dd
		String minutes = chpunchr.getMinutes();//更改分钟数
		
		KqglAssoBcsz dkbc = kqglassobcszmapper.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, chpunchr.getBcszid()));
		String clock_time = null;//应打卡时间
		long clock_time_ = 0l;
		long changed_time = 0l;//改过的最终时间
		int results = 0;//打卡结果
		
		if(dkbc != null){
			if(chpunchr.getClocktype() == 1) {
				clock_time = (data+" "+dkbc.getSbdk1()+":00").replaceAll("\r|\n", "");
			}else if(chpunchr.getClocktype() == 2) {
				clock_time = (data+" "+dkbc.getXbdk1()+":00").replaceAll("\r|\n", "");
			}else if(chpunchr.getClocktype() == 3) {
				clock_time = (data+" "+dkbc.getSbdk2()+":00").replaceAll("\r|\n", "");
			}else if(chpunchr.getClocktype() == 4) {
				clock_time = (data+" "+dkbc.getXbdk2()+":00").replaceAll("\r|\n", "");
			}else if(chpunchr.getClocktype() == 5) {
				clock_time = (data+" "+dkbc.getSbdk3()+":00").replaceAll("\r|\n", "");
			}else {
				clock_time = (data+" "+dkbc.getXbdk3()+":00").replaceAll("\r|\n", "");
			}
			
			if(chpunchr.getAtttype() == 1) {//正常
				changed_time = Long.valueOf(ClockInTool.dateToStamp(clock_time));
			}else if(chpunchr.getAtttype() == 2) {//迟到
				changed_time = Long.valueOf(ClockInTool.dateToStamp(ClockInTool.addtime(clock_time, minutes)));
				results = Integer.valueOf(minutes);
			}else {//早退
				changed_time = Long.valueOf(ClockInTool.dateToStamp(ClockInTool.addtime(clock_time, "-"+minutes)));
				results = Integer.valueOf(minutes);
			}
			
			long sbdk1 = 0,xbdk1 = 0,sbdk2 = 0,xbdk2 = 0,sbdk3 = 0,xbdk3 = 0;
			int sbdk1jg = 0,xbdk1jg = 0,sbdk2jg = 0,xbdk2jg = 0,sbdk3jg = 0,xbdk3jg = 0;
			
			//kqgl_asso_dkmx 打卡明细是否存在打卡记录
			KqglAssoDkmx dkmx = kqglassodkmxmapper.selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getData, chpunchr.getData()).eq(KqglAssoDkmx::getUserid, chpunchr.getNum()));
			if(dkmx != null) {
				if(chpunchr.getClocktype() == 1) {
					sbdk1 = changed_time;
					sbdk1jg = results;
lal committed
2209 2210 2211
					if(results == 0) {
						sbdk1jg = -1;
					}
lal committed
2212 2213 2214 2215 2216
					
					KqglAssoDkmx.builder().id(dkmx.getId()).sbdk1(sbdk1).sbdk1jg(sbdk1jg).build().updateById();
				}else if(chpunchr.getClocktype() == 2) {
					xbdk1 = changed_time;
					xbdk1jg = results;
lal committed
2217 2218 2219
					if(results == 0) {
						xbdk1jg = -1;
					}
lal committed
2220 2221 2222 2223 2224
					
					KqglAssoDkmx.builder().id(dkmx.getId()).xbdk1(xbdk1).xbdk1jg(xbdk1jg).build().updateById();
				}else if(chpunchr.getClocktype() == 3) {
					sbdk2 = changed_time;
					sbdk2jg = results;
lal committed
2225 2226 2227
					if(results == 0) {
						sbdk2jg = -1;
					}
lal committed
2228 2229 2230 2231
					KqglAssoDkmx.builder().id(dkmx.getId()).sbdk2(sbdk2).sbdk2jg(sbdk2jg).build().updateById();
				}else if(chpunchr.getClocktype() == 4) {
					xbdk2 = changed_time;
					xbdk2jg = results;
lal committed
2232 2233 2234
					if(results == 0) {
						xbdk2jg = -1;
					}
lal committed
2235 2236 2237 2238
					KqglAssoDkmx.builder().id(dkmx.getId()).xbdk2(xbdk2).xbdk2jg(xbdk2jg).build().updateById();
				}else if(chpunchr.getClocktype() == 5) {
					sbdk3 = changed_time;
					sbdk3jg = results;
lal committed
2239 2240 2241
					if(results == 0) {
						sbdk3jg = -1;
					}
lal committed
2242 2243 2244 2245
					KqglAssoDkmx.builder().id(dkmx.getId()).sbdk3(sbdk3).sbdk3jg(sbdk3jg).build().updateById();
				}else {
					xbdk3 = changed_time;
					xbdk3jg = results;
lal committed
2246 2247 2248
					if(results == 0) {
						xbdk3jg = -1;
					}
lal committed
2249 2250 2251 2252 2253 2254 2255 2256 2257
					KqglAssoDkmx.builder().id(dkmx.getId()).xbdk3(xbdk3).xbdk3jg(xbdk3jg).build().updateById();
				}
			}
			
			//打卡记录表
			clock_time_ = Long.valueOf(ClockInTool.dateToStamp(clock_time));
			
			Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(data,"yyyy-MM-dd")).getTime();
			String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(startDate));//转换打卡时间格式
lal committed
2258 2259 2260 2261 2262 2263
			int type = 0;
			if((chpunchr.getClocktype())%2 > 0){
				type = 1;
			}else {
				type = 2;
			}
lal committed
2264
			
lal committed
2265
			KqglAssoDkjl pre = KqglAssoDkjl.builder().dktime(changed_time).results(results).userId(chpunchr.getNum()).type(type).status(9).sort(chpunchr.getClocktype())
lal committed
2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278
					.cardType(3).qyid(userBean.getOrgCode()).attdate(attdate_+" "+ClockInTool.dateToWeek2(data)).attime(clock_time_).dkmxid(dkmx.getId()).bcid(chpunchr.getBcszid()).remarks("管理员改为正常").punchmode(0)
					.punchequipment("").build();
			if (!pre.insert()) {
				throw new CustomException("打卡记录-新增异常");
			 }
			
			return ResultUtil.success("操作成功!");
		}else {
			
			return ResultUtil.error("操作失败,检查班次是否存在");
		}
	}
	
lal committed
2279 2280
	
	
lal committed
2281 2282 2283 2284 2285 2286 2287 2288
//	@GetMapping(value = "/summary_report")
//	@ApiOperation(value = "考勤汇总报表(暂时不用)", httpMethod = "GET", notes = "接口发布说明")
//	public Result<Object> attendance_summary_report() {
//		Map<String, Object> map = new HashMap<String, Object>();
//		
//		return ResultUtil.data(map);
//	}
	
ilal committed
2289
	/**************************/
ilal committed
2290
	/**
ilal committed
2291 2292 2293
	 * 	查询列表-加班补偿方式
	 */
	@GetMapping(value = "/list_compensate")
ilal committed
2294
	@ApiOperation(value = "222: 查询列表-加班补偿方式", httpMethod = "GET", notes = " 查询列表-加班补偿方式")
ilal committed
2295 2296 2297 2298
	public Result<Object> selectListCompensate() {

		List<CompensateDto> coms = new ArrayList<CompensateDto>();
		CompensateDto com = CompensateDto.builder().build();
ilal committed
2299 2300
		com.setId(1);
		com.setValue("加班费");
ilal committed
2301 2302
		coms.add(com);
		CompensateDto coms2 = CompensateDto.builder().build();
ilal committed
2303 2304
		coms2.setId(2);
		coms2.setValue("调休");
ilal committed
2305 2306 2307 2308 2309
		coms.add(coms2);

		return ResultUtil.data(coms, "操作成功!");
	}
}