TimeCardController.java 143 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.Date;
ilal committed
9
import java.util.List;
ilal committed
10
import java.util.Map;
11
import java.util.concurrent.locks.ReentrantLock;
ilal committed
12

13 14
import cn.timer.api.aspect.lang.annotation.Log;
import cn.timer.api.aspect.lang.enums.BusinessType;
284718418@qq.com committed
15
import cn.timer.api.bean.dzht.DzhtAssoMbzj;
16
import com.alibaba.fastjson.JSONObject;
284718418@qq.com committed
17 18
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.swagger.annotations.ApiParam;
ilal committed
19
import org.springframework.beans.factory.annotation.Autowired;
lal committed
20
import org.springframework.beans.factory.annotation.Value;
ilal committed
21 22
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
23
import org.springframework.http.HttpStatus;
ilal committed
24
import org.springframework.http.ResponseEntity;
ilal committed
25
import org.springframework.transaction.annotation.Transactional;
ilal committed
26 27
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
28
import org.springframework.util.StringUtils;
ilal committed
29
import org.springframework.validation.annotation.Validated;
284718418@qq.com committed
30
import org.springframework.web.bind.annotation.*;
ilal committed
31
import org.springframework.web.client.RestClientException;
ilal committed
32
import org.springframework.web.client.RestTemplate;
ilal committed
33

lal committed
34
import com.alibaba.fastjson.JSON;
ilal committed
35 36 37 38
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
39 40
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;

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

ilal committed
144
@Api(tags = "3.0[1]考勤模块")
ilal committed
145 146 147 148
@RestController
@Transactional
@RequestMapping(value = "/kqmk", produces = { "application/json", "multipart/form-data" })
public class TimeCardController {
149

lal committed
150 151
	@Value("${config-8timer.machine8timerUrl}")
	public String mac_command; // 回调地址
152 153


ilal committed
154 155 156 157 158 159
	@Autowired
	private KqglAssoBcszMapper kqglassobcszmapper;
	@Autowired
	private KqglAssoOvertimeRulesMapper kqglassoovertimerulesmapper;
	@Autowired
	private KqglAssOvertimeViceMapper kqglassovertimevicemapper;
160

lal committed
161 162 163
	//用户和考勤组关系
	@Autowired
	private UserAttendanceRelMapper userattendancerelmapper;
164 165

	private static  ReentrantLock lock= new ReentrantLock();
ilal committed
166 167 168
	/**
	 * 查询列表-获取班次数据-分页
	 */
ilal committed
169
	@PostMapping(value = "/ShiftDataList")
ilal committed
170 171 172
	@ApiOperation(value = "1.获取班次数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 1)
	public Result<Object> selectShifts(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
173 174 175 176 177 178 179 180 181 182
		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());
		IPage<KqglAssoBcsz> pageAs = kqglassobcszmapper.selectPage(page, new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getQyid, userBean.getOrgCode()).orderByDesc(KqglAssoBcsz::getId));
		List<KqglAssoBcsz> listAs = pageAs.getRecords();
		return ResultUtil.data(pageAs, listAs, "操作成功!");
	}

ilal committed
183 184 185 186 187 188 189
	/**
	 * 新增班次信息
	 */
	@PostMapping(value = "/Shif")
	@ApiOperation(value = "2:新增班次信息", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 2)
	public Result<KqglAssoBcsz> ShiftInformation(@CurrentUser UserBean userBean,@RequestBody KqglAssoBcsz shif) {
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211

		String sdf = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		shif.setQyid(userBean.getOrgCode());
		shif.setLusjTime(new Date().getTime());
		shif.setLuryid(userBean.getEmpNum());//录入人员

		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);
lal committed
212
			}
213 214 215 216 217 218 219 220
		}else {
			if(xbbydk) {
				shif.setXbdk3("");
				String asd = ClockInTool.addtime(sdf+" "+shif.getSbdk3()+":00", "1").substring(11, 16);
				shif.setXbdk3(asd);
			}
		}

lal committed
221 222 223 224 225
//			if(kqglassobcszmapper.insert(shif)>0){
//				return ResultUtil.data(shif, "新增班次成功");
//			}else{
//				return ResultUtil.error("新增班次失败");
//			}
226 227 228 229 230 231 232 233

		if (!shif.insert())
			return ResultUtil.error("操作失败");


		return ResultUtil.data(shif, "新增班次成功");
	}

ilal committed
234 235 236 237 238 239 240 241 242
	/**
	 * 删除班次信息
	 */
	@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("没有找到该对象");
	}
243

ilal committed
244 245 246 247 248 249 250 251 252
	/**
	 * 根据班次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(),"操作成功!");
	}
253

ilal committed
254 255 256 257 258 259 260
	/**
	 * 修改班次信息
	 */
	@PutMapping(value = "/Shif")
	@ApiOperation(value = "5:修改班次信息", httpMethod = "PUT", notes = "接口发布说明")
	@ApiOperationSupport(order = 5)
	public Result<KqglAssoBcsz> updateShiftInformation(@CurrentUser UserBean userBean,@RequestBody KqglAssoBcsz shif) {
261 262 263 264 265
		shif.setQyid(userBean.getOrgCode());//企业id
		if (kqglassobcszmapper.update(shif) > 0) {
			return ResultUtil.data(shif,"修改班次信息成功");
		}
		return ResultUtil.error("修改班次信息失败");
ilal committed
266
	}
267

ilal committed
268 269
	/**
	 * 查询列表-获取加班规则数据-分页
270 271
	 * @throws InvocationTargetException
	 * @throws IllegalAccessException
ilal committed
272 273 274 275
	 */
	@PostMapping(value = "/select_overtime_rules")
	@ApiOperation(value = "6.获取加班规则数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 6)
ilal committed
276
	public Result<Object> selectOvertimeRules(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) throws IllegalAccessException, InvocationTargetException {
277 278 279 280 281 282 283 284 285 286 287 288 289
		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();
		List<KqglAssoOvertimeRulesDto> rulesdto = new ArrayList<KqglAssoOvertimeRulesDto>();
		for (int i = 0, n = listAs.size(); i < n; i++) {
			String[] nary = null;
			String[] naryid = null;
			if(listAs.get(i).getAppliedScope() == 0) {//全公司
				nary = new String[1];//用户名
lal committed
290
//					naryid = new String[1];//用户名
291
				nary[0] = "未使用";
lal committed
292
//					naryid[0] = "0";
293 294 295 296 297 298 299 300
			}else {
				List<KqglAssoOvertimeRange> overtim = kqglassoovertimerangemapper.selectList(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, listAs.get(i).getId()));
				nary = new String[overtim.size()];//用户名
				naryid = new String[overtim.size()];//用户名
				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();
					naryid[y] = String.valueOf(kqzmc.getId());
lal committed
301
				}
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
			}


			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;
			}



			KqglAssoOvertimeRulesDto ruldto = KqglAssoOvertimeRulesDto.builder().build();
			ruldto.setApplyrange(nary);
			ruldto.setApplyrangeid(naryid);
			ruldto.setStarttime(starttime);
			BeanUtil.copyProperties(listAs.get(i), ruldto , "starttime","applyrange","applyrangeid");
			rulesdto.add(ruldto);
		}
		return ResultUtil.data(pageAs, rulesdto, "操作成功!");
	}


ilal committed
327 328
	@Autowired
	private KqglAssoOvertimeRangeMapper kqglassoovertimerangemapper;
ilal committed
329 330 331 332 333 334 335 336 337 338 339
	/**
	 * 新增/修改--加班规则
	 */
	@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
340
		BeanUtil.copyProperties(overrules, rul , "starttime","applyrange");
341
		if (!rul.insertOrUpdate())
ilal committed
342 343 344
			return ResultUtil.error("操作失败");
		Integer id = rul.getId();
		Console.log("新增/修改加班规则id: " + id);
ilal committed
345
		List<KqglAssoOvertimeRange> overatts=new ArrayList<KqglAssoOvertimeRange>();
lal committed
346
		String[] launchs = overrules.getApplyrangeid();
ilal committed
347 348 349 350 351
		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));
352

lal committed
353
				KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, Integer.valueOf(launchs[p])));
354

ilal committed
355 356 357 358
				KqglAssoOvertimeRange vice = KqglAssoOvertimeRange.builder().build();
				vice.setOvertimeRulesId(id);
				vice.setAttgroupId(Integer.valueOf(launchs[p]));
				overatts.add(vice);
359

lal committed
360 361
				//应用范围应用到相对应的考勤组************
				KqglMainKqz.builder().id(Integer.valueOf(launchs[p])).overtimeRulesId(id).build().updateById();
ilal committed
362 363 364 365 366
			}
		}
		if(overatts.size() > 0) {
			kqglassoovertimerangemapper.insertovertimerangelist(overatts);
		}
367 368


ilal committed
369 370 371 372
		List<KqglAssOvertimeVice> overtimes=new ArrayList<KqglAssOvertimeVice>();
		StartTimeRestDto[] rest = overrules.getStarttime();
		if(rest != null && rest.length>0){
			for(int p=0;p<rest.length;p++){
lal committed
373 374 375 376 377 378 379 380 381
				if(rest[p].getStarttime() != null) {
					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);
				}else {
lal committed
382
					continue;
lal committed
383
				}
384

ilal committed
385 386 387 388 389 390 391
			}
		}
		if(overtimes.size()>0){
			kqglassovertimevicemapper.insertovertimeviceList(overtimes);
		}
		return  ResultUtil.data(rul, "操作成功!");
	}
392

ilal committed
393 394 395 396 397 398
	/**
	 * 	根据加班规则id获取加班规则信息
	 */
	@GetMapping(value="/Overtime/{id}")
	@ApiOperation(value = "8:根据加班规则id获取加班规则信息", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 8)
ilal committed
399 400
	public Result<IndividualOvertimeRuleDto> getOvertimeRules(@PathVariable("id") Integer id) {
		IndividualOvertimeRuleDto overrule = IndividualOvertimeRuleDto.builder().build();
ilal committed
401
		KqglAssoOvertimeRules rules = KqglAssoOvertimeRules.builder().id(id).build().selectById();
ilal committed
402 403 404 405 406
		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
407 408 409 410
		KqglAssoOvertimeRulesDto ruldto = KqglAssoOvertimeRulesDto.builder().build();
		ruldto.setApplyrange(arr);
		BeanUtil.copyProperties(rules, ruldto , "starttime","applyrange");
		overrule.setRules(ruldto);
ilal committed
411
		List<KqglAssOvertimeVice> vice = new LambdaQueryChainWrapper<KqglAssOvertimeVice>(kqglassovertimevicemapper).eq(KqglAssOvertimeVice::getOvertimeRulesId, id).list();
412
		overrule.setStarttime(vice);
ilal committed
413 414
		return ResultUtil.data(overrule,"操作成功!");
	}
415

ilal committed
416 417
	/**
	 * 	删除加班规则
418
	 * @throws Exception
ilal committed
419 420 421 422 423 424 425 426
	 */
	@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 {
427

lal committed
428 429 430 431
			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();
			}
432

lal committed
433
			KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getOvertimeRulesId, id));
ilal committed
434 435 436 437
			KqglAssOvertimeVice.builder().build().delete(new QueryWrapper<KqglAssOvertimeVice>().lambda().eq(KqglAssOvertimeVice::getOvertimeRulesId, id));
			return ResultUtil.success("删除成功!");
		}
	}
438

ilal committed
439 440 441 442 443 444 445 446 447 448 449 450
	/**
	 * 	编辑加班基础设置
	 */
	@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("操作失败!");
	}
451

ilal committed
452 453 454
	@Autowired
	private KqglAssoLeaveRulesMapper kqglassoleaverulesmapper;
	/**
ilal committed
455
	 * 初始化假期数据
ilal committed
456 457 458 459 460 461 462 463 464
	 */
	@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
465
				.eq(KqglAssoLeaveRules::getLeaveType, 1).last("LIMIT 1"));
ilal committed
466 467 468 469 470
		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
471
						.isOpen(rul.getIsOpen()).leaveBalance(rul.getLeaveBalance()).rulesType(rul.getRulesType()).build();
ilal committed
472 473 474 475 476
				rullist.add(vice);
			}
			if(rullist.size() > 0) {
				kqglassoleaverulesmapper.insertleaverulesList(rullist);
			}
ilal committed
477 478 479
			return ResultUtil.success("操作成功!");
		}else {
			return ResultUtil.success("重复初始化数据!");
ilal committed
480
		}
481

ilal committed
482
	}
483

ilal committed
484 485
	@Autowired
	private KqglAssoRulesViceMapper kqglassorulesvicemapper;
486

ilal committed
487 488 489 490 491 492 493
	/**
	 *	 新增/修改--假期规则
	 */
	@PostMapping(value = "/leave_rules")
	@ApiOperation(value = "12:新增/修改--假期规则", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 12)
	public Result<Object> LeaveRules(@CurrentUser UserBean userBean,@RequestBody KqglAssoLeaveRulesDto leaverules) {
lal committed
494
		String current_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
495

ilal committed
496 497 498 499 500 501 502
		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");
503
		if (!learul.insertOrUpdate())
ilal committed
504 505 506
			return ResultUtil.error("操作失败");
		Integer id = learul.getId();
		Console.log("新增/修改--假期规则id: " + id);
507

lal committed
508 509
		KqglAssoLeaveEmployeeBalance.builder().build().delete(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, id)
				.eq(KqglAssoLeaveEmployeeBalance :: getOrgCode, userBean.getOrgCode()));
lal committed
510
		List<YgglMainEmp> yggl = YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()));
511

ilal committed
512 513 514
		if(leaverules.getLeaveBalance() == 1) {//假期余额 0:关(该项余额为“不限余额”);1:开(该项余额为“0”)
			//该项公司员工余额为“0”
			for(YgglMainEmp ye:yggl) {
lal committed
515
				KqglAssoLeaveEmployeeBalance.builder().leaveRulesId(id).userid(ye.getEmpNum()).balanceDays(0.0).modifyUserid(userBean.getEmpNum()).modifyTimer(current_time).orgCode(userBean.getOrgCode()).build().insert();
ilal committed
516
			}
lal committed
517 518
		}else {
			for(YgglMainEmp ye:yggl) {
lal committed
519
				KqglAssoLeaveEmployeeBalance.builder().leaveRulesId(id).userid(ye.getEmpNum()).balanceDays(-1).modifyUserid(userBean.getEmpNum()).modifyTimer(current_time).orgCode(userBean.getOrgCode()).build().insert();
lal committed
520
			}
521 522
		}

ilal committed
523 524
		List<KqglAssoRulesVice> vices = new ArrayList<KqglAssoRulesVice>();
		String[] rest = leaverules.getRange();
ilal committed
525 526 527
		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
528 529 530 531 532 533 534 535 536 537 538
			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
539
		return  ResultUtil.data(learul, "操作成功!");
ilal committed
540
	}
541

ilal committed
542 543
	/**
	 *	 删除假期规则
544
	 * @throws Exception
ilal committed
545 546 547 548 549 550 551 552 553 554 555 556
	 */
	@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("删除成功!");
		}
	}
557

ilal committed
558 559 560 561 562 563
	/**
	 * 	根据假期规则id获取假期规则信息
	 */
	@GetMapping(value="/Vacation_information/{id}")
	@ApiOperation(value = "14:根据假期规则id获取假期规则信息", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 14)
ilal committed
564 565
	public Result<VacationInformationDto> VacationInformation(@PathVariable("id") Integer id) {
		VacationInformationDto overrule = VacationInformationDto.builder().build();
ilal committed
566 567
		KqglAssoLeaveRules rules = KqglAssoLeaveRules.builder().id(id).build().selectById();
		overrule.setRules(rules);
lal committed
568
		List<KqglAssoRulesViceDto> vice = kqglassorulesvicemapper.leaveRulesIdload(id);
569 570

		overrule.setRange(vice);
ilal committed
571 572
		return ResultUtil.data(overrule,"操作成功!");
	}
284718418@qq.com committed
573 574 575 576 577 578 579 580 581 582 583 584
	/**
	 *	 是否开启假期规则
	 */
	@PutMapping(value = "/leave_rules_open")
	@ApiOperation(value = "14.1:是否开启假期规则 ", httpMethod = "PUT", notes = "接口发布说明")
	@ApiOperationSupport(order = 14)
	public Result<Object> leaveRulesOpen(@RequestBody KqglAssoLeaveRulesDto kqglAssoLeaveRulesDto) {
		UpdateWrapper<KqglAssoLeaveRules> updateWrapper = new UpdateWrapper<>();
		updateWrapper.eq("id", kqglAssoLeaveRulesDto.getId()).set("is_open", kqglAssoLeaveRulesDto.getIsOpen());
		KqglAssoLeaveRules.builder().build().update(updateWrapper);
		return  ResultUtil.success();
	}
585 586


ilal committed
587 588 589 590 591 592 593 594 595 596 597 598 599 600
	@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();
601
		return ResultUtil.data(attendanList,"操作成功!");
ilal committed
602
	}
603

lal committed
604 605 606 607
	@PostMapping(value = "/att_machine_status")
	@ApiOperation(value = "15.1:获取考勤机状态", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 28)
	public Result<Object> AttendanceMachineStatus(@CurrentUser UserBean userBean,@RequestBody AttendanceMachineStatus balance) {
608

lal committed
609 610
		String msg = "";
		List<AttstateDate> stas = new ArrayList<AttstateDate>();
611

lal committed
612 613 614 615
		String[] state = balance.getState();
		if(state.length > 0) {
			for(int p=0;p<state.length;p++){
				AttstateDate sta = AttstateDate.builder().build();
616

lal committed
617
				String url = mac_command+"/getDevInfo";
618 619
				HttpHeaders headers = new HttpHeaders();
				MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
lal committed
620
				params.add("devId", state[p]);
621 622 623
				RestTemplate restTemplate = new RestTemplate();
				HttpEntity httpEntity = new HttpEntity(params, headers);
				try {
lal committed
624 625 626 627 628 629 630
					ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
					com.alibaba.fastjson.JSONObject object = JSON.parseObject(request.getBody());
					msg = object.get("message").toString();
					sta.setCode(state[p]);
					sta.setState(Integer.valueOf(object.get("data").toString()));
					stas.add(sta);
				} catch (RestClientException e) {
ilal committed
631
					Logoutput("提示:考勤机服务出错-1");
lal committed
632 633 634 635
					return ResultUtil.success("失败");
				}
			}
		}
636

lal committed
637
		return ResultUtil.data(stas,"获取成功");
lal committed
638
	}
639 640


lal committed
641
	@SuppressWarnings("all")
ilal committed
642 643 644
	@GetMapping(value="/synchrotime/{code}")
	@ApiOperation(value = "考勤机一键同步", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> SynchronizationTime(@CurrentUser UserBean userBean,@PathVariable("code") String code) {
645

lal committed
646
		String url = mac_command+"/setTime";
647 648 649 650 651 652
		HttpHeaders headers = new HttpHeaders();
		MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
		params.add("devId", code);
		RestTemplate restTemplate = new RestTemplate();
		HttpEntity httpEntity = new HttpEntity(params, headers);
		try {
ilal committed
653
			ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
ilal committed
654
			Logoutput(request.getBody());
ilal committed
655
		} catch (RestClientException e) {
ilal committed
656
			Logoutput("提示:考勤机服务出错-2");
ilal committed
657 658 659 660
			return ResultUtil.success("失败");
		}
		return ResultUtil.success("成功");
	}
661

ilal committed
662
	/**
ilal committed
663 664
	 * 	移除考勤机管理员
	 */
lal committed
665
	@SuppressWarnings("all")
ilal committed
666 667 668 669
	@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(",");
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
		if(xgyh.length > 0){
			KqglAssoKqj kqj = KqglAssoKqj.builder().id(kqjid).build().selectById();//查询考勤机“序列号”
			for(int a=0;a<xgyh.length;a++){

				String url = mac_command+"/addUserPrivilege";
				HttpHeaders headers = new HttpHeaders();
				MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
				params.add("devId", kqj.getCode());
				params.add("userId", xgyh[a]);
				params.add("privilege", 1);
				RestTemplate restTemplate = new RestTemplate();
				HttpEntity httpEntity = new HttpEntity(params, headers);
				try {
					ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
					Logoutput(request.getBody());
				} catch (RestClientException e) {
					Logoutput("提示:考勤机服务出错-3");
					return ResultUtil.success("失败");
				}
				KqglAssoYhsb.builder().id(id).isGly(0).build().updateById();
			}
		}
ilal committed
692 693
		return ResultUtil.success("成功");
	}
694 695 696 697 698 699 700 701 702

	@SuppressWarnings("all")
	@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();//查询考勤机“序列号”

ilal committed
703
			for(int a=0;a<xgyh.length;a++){
704 705


lal committed
706
				String url = mac_command+"/addUserPrivilege";
707 708 709 710 711 712 713 714
				HttpHeaders headers = new HttpHeaders();
				MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
				params.add("devId", kqj.getCode());
				params.add("userId", xgyh[a]);
				params.add("privilege", 2);
				RestTemplate restTemplate = new RestTemplate();
				HttpEntity httpEntity = new HttpEntity(params, headers);
				try {
ilal committed
715
					ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
ilal committed
716
					Logoutput(request.getBody());
ilal committed
717
				} catch (RestClientException e) {
ilal committed
718
					Logoutput("提示:考勤机服务出错-4");
ilal committed
719 720
					return ResultUtil.success("失败");
				}
721 722 723 724 725

				UserEquiRelation kqjry = new UserEquiRelation();
				kqjry.setId(id);
				kqjry.setIsGly(1);
				userequirelationmapper.updateByPrimaryKeySelective(kqjry);
ilal committed
726 727 728
			}
		}
		return ResultUtil.success("成功");
729

ilal committed
730
	}
731 732


ilal committed
733
	/**
ilal committed
734 735
	 * 新增考勤机
	 */
lal committed
736
	@SuppressWarnings("all")
ilal committed
737 738 739 740 741 742 743
	@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());
744

lal committed
745 746
		KqglAssoKqj kqj = KqglAssoKqj.builder().build().selectOne(new QueryWrapper<KqglAssoKqj>().lambda().eq(KqglAssoKqj::getCode, kqglassokqj.getCode()));
		if(kqj == null) {
lal committed
747
			String msg = "";
lal committed
748 749
			if(!kqglassokqj.insert())
				return ResultUtil.error("操作失败--新增考勤机");
750

lal committed
751
			String url = mac_command+"/addDev";
752 753 754
			HttpHeaders headers = new HttpHeaders();
			MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
			params.add("orgCode", kqglassokqj.getType());
lal committed
755
			params.add("devId", kqglassokqj.getCode());
756 757 758
			RestTemplate restTemplate = new RestTemplate();
			HttpEntity httpEntity = new HttpEntity(params, headers);
			try {
lal committed
759
				ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
lal committed
760 761
				com.alibaba.fastjson.JSONObject object = JSON.parseObject(request.getBody());
				msg = object.get("message").toString();
lal committed
762
			} catch (RestClientException e) {
ilal committed
763
//				Logoutputln("提示:考勤机服务出错");
lal committed
764
				return ResultUtil.success(msg);
lal committed
765
			}
766

lal committed
767
			return ResultUtil.data(kqglassokqj,msg);
lal committed
768 769
		}else {
			return ResultUtil.error("考勤机已存在或已被使用");
ilal committed
770
		}
771 772


ilal committed
773
	}
774

ilal committed
775 776 777 778 779 780 781
	/**
	 * 删除考勤机信息
	 */
	@DeleteMapping(value = "/attmachine/{id}")
	@ApiOperation(value = "17:删除考勤机信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 17)
	public Result<Integer> deattmachine(@PathVariable("id") Integer id) {
782

ilal committed
783 784
		return KqglAssoKqj.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
785

ilal committed
786 787 788 789 790 791 792 793 794 795
	/**
	 * 考勤机内成员
	 */
	@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);
	}
796

ilal committed
797 798 799 800 801 802 803
	/**
	 * 获取考勤机数据-根据 组织机构代码
	 */
	@GetMapping(value="/AttGroupMachine")
	@ApiOperation(value = "19:获取考勤机数据-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 19)
	public Result<Object> getAttGroupMachineList(@CurrentUser UserBean userBean) {
804 805
		List<KqglMainKqzDto> attmacList = kqglmainkqzmapper.selectAttGroupMachineByQyid(userBean.getOrgCode());
		return ResultUtil.data(attmacList);
ilal committed
806
	}
807

ilal committed
808 809 810 811 812 813 814 815 816 817
	/*********打卡地址***********/
	@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) {
818 819 820 821 822 823 824 825 826 827 828
		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());

		IPage<KqglAssoDkdz> pageAs = kqglassodkdzmapper.selectPage(page, new QueryWrapper<KqglAssoDkdz>().lambda().eq(KqglAssoDkdz::getQyid, userBean.getOrgCode()).orderByDesc(KqglAssoDkdz::getId));
		List<KqglAssoDkdz> listAs = pageAs.getRecords();
		return ResultUtil.data(pageAs, listAs, "操作成功!");
	}

ilal committed
829 830 831 832 833 834 835
	/**
	 * 根据打卡地址id获取打卡地址信息
	 */
	@GetMapping(value="/PuAddress/{id}")
	@ApiOperation(value = "21:获取打卡地址信息-根据打卡地址id", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 21)
	public Result<Object> getPunchAddressByid(@PathVariable("id") Integer id) {
836

ilal committed
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
		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("操作失败!");
	}
852

ilal committed
853 854 855 856 857 858 859
	/**
	 * 删除打卡地址信息
	 */
	@DeleteMapping(value = "/PunchAddress/{id}")
	@ApiOperation(value = "23:删除打卡地址信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 23)
	public Result<Integer> deletePunchCardAddress(@PathVariable("id") Integer id) {
860

ilal committed
861 862
		return KqglAssoDkdz.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
863

ilal committed
864 865 866 867 868 869
	/*********打卡WIFI***********/
	/**
	 * 获取打卡WIFI数据
	 */
	@Autowired
	private KqglAssoDkwxMapper kqglassodkwxmapper;
870

ilal committed
871 872 873 874
	@PostMapping(value = "/PunchWIFI")
	@ApiOperation(value = "24:获取打卡WIFI数据-根据 组织机构代码-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 24)
	public Result<Object> getPunchCardWIFI(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
875 876 877 878 879 880 881 882 883 884 885 886

		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());

		IPage<KqglAssoDkwx> pageAs = kqglassodkwxmapper.selectPage(page, new QueryWrapper<KqglAssoDkwx>().lambda().eq(KqglAssoDkwx::getQyid, userBean.getOrgCode()).orderByDesc(KqglAssoDkwx::getId));
		List<KqglAssoDkwx> listAs = pageAs.getRecords();
		return ResultUtil.data(pageAs, listAs, "操作成功!");
	}

ilal committed
887 888 889 890 891 892 893
	/**
	 * 根据打卡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) {
894

ilal committed
895 896
		return ResultUtil.data(KqglAssoDkwx.builder().id(id).build().selectById(),"操作成功!");
	}
897

ilal committed
898 899 900 901 902 903 904
	/**
	 * 新增/修改--打卡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) {
905

ilal committed
906
		List<KqglAssoDkwx> cxwifi = KqglAssoDkwx.builder().build().selectList(new QueryWrapper<KqglAssoDkwx>().lambda().eq(KqglAssoDkwx::getQyid, userBean.getOrgCode()).eq(KqglAssoDkwx::getMac, kqglassodkwx.getMac()));
ilal committed
907
		if(cxwifi.size() > 0 && kqglassodkwx.getId() == null) {
ilal committed
908 909
			return ResultUtil.error("此WiFi已存在");
		}
910

ilal committed
911 912 913 914
		kqglassodkwx.setLuryid(userBean.getEmpNum());
		kqglassodkwx.setLusjTime(new Date().getTime());
		kqglassodkwx.setQyid(userBean.getOrgCode());
		return kqglassodkwx.insertOrUpdate() ? ResultUtil.success("添加成功!") : ResultUtil.error("添加失败!");
915

ilal committed
916
	}
917

ilal committed
918 919 920 921 922 923 924
	/**
	 * 删除打卡WIFI信息
	 */
	@DeleteMapping(value = "/PunchWIFI/{id}")
	@ApiOperation(value = "27:删除打卡地址信息", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 27)
	public Result<Integer> deletePunchCardWIFI(@PathVariable("id") Integer id) {
925

ilal committed
926 927
		return KqglAssoDkwx.builder().id(id).build().deleteById() ? ResultUtil.success("删除成功!") : ResultUtil.error("没有找到该对象");
	}
928

ilal committed
929 930 931 932 933 934 935 936 937 938 939 940
	@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());
lal committed
941 942 943 944 945 946
		String balanceDays = "0";
		if(balance.getModifyAction() == 1) {//增加
			balanceDays = "+" + balance.getBalanceDays();
		}else {
			balanceDays = "-" + balance.getBalanceDays();
		}
947

lal committed
948
		balance.setBalanceDays(balanceDays);
949

ilal committed
950 951 952 953 954 955 956
		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);
		}
957

lal committed
958 959 960 961 962
		//添加成功
		if(balance.insert()) {
			//查询员工假期余额表中所对应的假期id
			KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, balance.getLeaveRulesId())
					.eq(KqglAssoLeaveEmployeeBalance::getUserid, balance.getUserid()).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, userBean.getOrgCode()));
963

lal committed
964 965 966
			//获取最后得到的最终余额
			double balance_days = kqglassoleavebalancemapper.Sumbalancedays(balance.getUserid(), userBean.getOrgCode(),balance.getLeaveRulesId());
			if(emba != null && balance_days > 0) {
chenzg committed
967

lal committed
968 969 970 971
				if(emba.getBalanceDays() != -1) {//确认为限制余额的
					//修改最终的余额数
					KqglAssoLeaveEmployeeBalance.builder().id(emba.getId()).balanceDays(balance_days).build().updateById();
				}
chenzg committed
972 973 974 975 976
			}else{
				if(emba.getBalanceDays() != -1) {//确认为限制余额的
					//修改最终的余额数
					KqglAssoLeaveEmployeeBalance.builder().id(emba.getId()).balanceDays(0).build().updateById();
				}
lal committed
977 978
			}
		}
979 980


lal committed
981
		return ResultUtil.success("操作成功!") ;
982

lal committed
983
//		return balance.insert() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
ilal committed
984
	}
985

ilal committed
986
	/**
lal committed
987
	 * 根据考勤余额id获取信息  ||大于“0”为有数字限制   ||为“-1”时为无数字限制
lal committed
988 989
	 */
	@GetMapping(value="/hqleavebalance/{id}")
lal committed
990
	@ApiOperation(value = "根据考勤余额id获取信息", httpMethod = "GET", notes = "接口发布说明")
lal committed
991
	public Result<Object> hqleavebalance(@PathVariable("id") Integer id,@CurrentUser UserBean userBean) {
lal committed
992
//		JiaqibalanceDto leanemp = kqglassoleavebalancemapper.selectleavebalanceList(id,userBean.getEmpNum());
993

lal committed
994
		JiaqibalanceDto leanemp = JiaqibalanceDto.builder().build();
995

lal committed
996 997 998 999 1000
		KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getUserid, userBean.getEmpNum())
				.eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, id).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, userBean.getOrgCode()));
		if(emba != null) {
			leanemp.setBalancedays(String.valueOf(emba.getBalanceDays()));
		}
1001

lal committed
1002 1003
		return ResultUtil.data(leanemp, "操作成功!");
	}
1004 1005


lal committed
1006
	/**
ilal committed
1007 1008 1009 1010 1011 1012
	 * 根据 组织机构代码获取员工假期余额表头
	 */
	@GetMapping(value="/balance_header")
	@ApiOperation(value = "29:根据 组织机构代码获取员工假期余额表头", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 29)
	public Result<Object> BalanceHeader(@CurrentUser UserBean userBean) {
lal committed
1013 1014 1015
//		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
1016 1017
		return ResultUtil.data(balheas, "操作成功!");
	}
1018

ilal committed
1019
	/**
ilal committed
1020
	 * 	查询列表-假期规则*******************************************
ilal committed
1021 1022
	 */
	@GetMapping(value = "/list_leave_rules")
ilal committed
1023 1024
	@ApiOperation(value = "30: 查询列表-假期规则", httpMethod = "GET", notes = " 查询列表-假期规则")
	@ApiOperationSupport(order = 30)
ilal committed
1025
	public Result<Object> selectListLeaveRules(@CurrentUser UserBean userBean) {
lal committed
1026 1027
//		List<KqglAssoLeaveRules> balheas = new LambdaQueryChainWrapper<KqglAssoLeaveRules>(kqglassoleaverulesmapper).eq(KqglAssoLeaveRules :: getOrgCode,userBean.getOrgCode())
//				.eq(KqglAssoLeaveRules :: getLeaveType, 2).or().eq(KqglAssoLeaveRules :: getIsOpen, 1).list();
ilal committed
1028
		List<LeaveTypeDto> leas = new ArrayList<LeaveTypeDto>();
lal committed
1029
		KqglAssoYhkqz yhd = KqglAssoYhkqz.builder().build().selectOne(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, userBean.getEmpNum()).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
1030

lal committed
1031 1032
		if(yhd != null) {
			//获取假期适用全公司的
lal committed
1033
			String company = "";
lal committed
1034 1035 1036 1037 1038
			List<KqglAssoLeaveRules> whole = kqglassoleaverulesmapper.selCompanywidedata(userBean.getOrgCode(), 2, 1);
			for(KqglAssoLeaveRules rul : whole) {
				LeaveTypeDto lea = LeaveTypeDto.builder().build();
				lea.setId(rul.getId());
				lea.setValue(rul.getName());
lal committed
1039 1040 1041 1042 1043 1044 1045 1046
				if(rul.getCompany() == 1) {
					company = "天";
				}else if(rul.getCompany() == 2) {
					company = "半天";
				}else {
					company = "小时";
				}
				lea.setCompany(company);
lal committed
1047 1048
				leas.add(lea);
			}
1049

lal committed
1050 1051 1052 1053 1054
			List<KqglAssoLeaveRules> assholi = kqglassoleaverulesmapper.AssociatedHolidays(yhd.getKqzid());
			for(KqglAssoLeaveRules rul1 : assholi) {
				LeaveTypeDto lea = LeaveTypeDto.builder().build();
				lea.setId(rul1.getId());
				lea.setValue(rul1.getName());
lal committed
1055 1056 1057 1058 1059 1060 1061 1062
				if(rul1.getCompany() == 1) {
					company = "天";
				}else if(rul1.getCompany() == 2) {
					company = "半天";
				}else {
					company = "小时";
				}
				lea.setCompany(company);
lal committed
1063 1064
				leas.add(lea);
			}
lal committed
1065 1066 1067
			return ResultUtil.data(leas, "操作成功!");
		}else {
			return ResultUtil.success("请先加入考勤组") ;
ilal committed
1068
		}
1069

lal committed
1070 1071 1072 1073 1074 1075 1076 1077
//		List<KqglAssoLeaveRules> balheas = kqglassoleaverulesmapper.selHeaderdata(userBean.getOrgCode(), 2, 1);
//		List<LeaveTypeDto> leas = new ArrayList<LeaveTypeDto>();
//		for(KqglAssoLeaveRules rul : balheas) {
//			LeaveTypeDto lea = LeaveTypeDto.builder().build();
//			lea.setId(rul.getId());
//			lea.setValue(rul.getName());
//			leas.add(lea);
//		}
1078

ilal committed
1079
	}
1080

ilal committed
1081
	/**
ilal committed
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
	 * 	根据组织机构代码 获取考勤组
	 */
	@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, "操作成功!");
	}
1098

ilal committed
1099
	/**
ilal committed
1100 1101 1102 1103 1104 1105 1106 1107 1108
	 * 	根据组织机构代码 获取加班基础设置信息
	 */
	@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, "操作成功!");
	}
1109

ilal committed
1110 1111 1112 1113 1114 1115 1116
	/**
	 * 	查询列表-获取假期规则数据-分页
	 */
	@PostMapping(value = "/select_leave_rules")
	@ApiOperation(value = "33:获取假期规则数据-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 33)
	public Result<Object> selectleaverules(@CurrentUser UserBean userBean, @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
		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();
		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();
ilal committed
1136 1137
				}
			}
1138 1139 1140 1141 1142 1143
			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
1144
	}
1145

ilal committed
1146
	/*****************考勤组***********************/
ilal committed
1147 1148 1149 1150
	/**
	 * 	查询列表-考勤组-分页
	 */
	@PostMapping(value = "/attendance_group")
lal committed
1151
	@ApiOperation(value = "34:查询列表-考勤组-分页", httpMethod = "POST", notes = "查询列表-考勤组-分页")
ilal committed
1152 1153
	@ApiOperationSupport(order = 34)
	public Result<Object> AttendanceGroup(@CurrentUser UserBean userBean, @Validated @RequestBody AttqueryCriteriaDto attquerycriteriadto){
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
		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();

		List<KqglMainKqzDto> sumlistAs = new ArrayList<KqglMainKqzDto>();

		for(KqglMainKqzDto makq : listAs) {
			KqglMainKqzDto mas = KqglMainKqzDto.builder().build();
			BeanUtil.copyProperties(makq, mas , "kqzdkfslist");

			QueryWrapper<KqglAssoKqzdkfs> queryWrapper = new QueryWrapper<>();
			queryWrapper.select("kqz_id","type","qyid","state").eq("qyid", userBean.getOrgCode())
					.eq("kqz_id", mas.getId()).groupBy("kqz_id","type","qyid","state");
			List<KqglAssoKqzdkfs> assfs = KqglAssoKqzdkfs.builder().build().selectList(queryWrapper);

			List<KqglAssoKqzdkfs> kqzdkfslist = new ArrayList<KqglAssoKqzdkfs>();
			for(KqglAssoKqzdkfs fs : assfs) {
				KqglAssoKqzdkfs dkfs = KqglAssoKqzdkfs.builder().build();
				dkfs.setKqzId(fs.getKqzId());
				dkfs.setType(fs.getType());
				kqzdkfslist.add(dkfs);
ilal committed
1180
			}
1181 1182 1183 1184 1185
			mas.setKqzdkfslist(kqzdkfslist);
			sumlistAs.add(mas);
		}

		return ResultUtil.data(pageAs, sumlistAs, "操作成功!");
ilal committed
1186
	}
1187

ilal committed
1188 1189 1190 1191 1192 1193 1194
	/**
	 * 	获取打卡地址数据
	 */
	@GetMapping(value="/InGroupPunchAddress")
	@ApiOperation(value = "35:获取打卡地址数据", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 35)
	public Result<Object> getInGroupPunchAddress(@CurrentUser UserBean userBean) {
1195 1196
		List<KqglAssoDkdz> shiftList = KqglAssoDkdz.builder().build().selectList(new QueryWrapper<KqglAssoDkdz>().lambda().eq(KqglAssoDkdz::getQyid, userBean.getOrgCode()));
		return ResultUtil.data(shiftList);
ilal committed
1197
	}
1198

ilal committed
1199 1200 1201 1202 1203 1204 1205
	/**
	 * 	获取打卡WIFI数据
	 */
	@GetMapping(value="/InGroupPunchWIFI")
	@ApiOperation(value = "36:获取打卡WIFI数据", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 36)
	public Result<Object> getInGroupPunchWIFI(@CurrentUser UserBean userBean) {
1206 1207
		List<KqglAssoDkwx> shiftList = KqglAssoDkwx.builder().build().selectList(new QueryWrapper<KqglAssoDkwx>().lambda().eq(KqglAssoDkwx::getQyid, userBean.getOrgCode()));
		return ResultUtil.data(shiftList);
ilal committed
1208
	}
1209

ilal committed
1210
	/**
1211
	 * 获取班次
ilal committed
1212 1213 1214 1215 1216
	 */
	@GetMapping(value="/AttShift")
	@ApiOperation(value = "37:获取班次-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 37)
	public Result<Object> getAttShiftList(@CurrentUser UserBean userBean) {
1217 1218
		List<KqglAssoBcsz> attshiftList = KqglAssoBcsz.builder().build().selectList(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getQyid, userBean.getOrgCode()));
		return ResultUtil.data(attshiftList);
ilal committed
1219
	}
1220

ilal committed
1221 1222 1223 1224 1225 1226
	/**
	 * 获取员工数据
	 */
	@GetMapping(value="/Employee")
	@ApiOperation(value = "38:获取员工数据-根据 组织机构代码", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 38)
1227 1228 1229 1230
	public Result<Object> getEmployeeData(@CurrentUser UserBean userBean)  {

		lock.lock();

1231
		List<YgglMainEmp> yggl = YgglMainEmp.builder().build().selectList(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).ne(YgglMainEmp::getJobStatus, "3"));
1232
		lock.unlock();
1233 1234
		return ResultUtil.data(yggl);
	}
1235 1236


ilal committed
1237 1238 1239
	//用户与设备关系表
	@Autowired
	private UserEquiRelationMapper userequirelationmapper;
ilal committed
1240 1241 1242
	/**
	 *	 删除考勤组
	 */
lal committed
1243
	@SuppressWarnings("all")
ilal committed
1244 1245 1246
	@DeleteMapping(value = "/AttendanceGroup/{id}")
	@ApiOperation(value = "39:删除考勤组", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 39)
1247
	@Log(title = "考勤设置-删除考勤组", businessType = BusinessType.DELETE)
ilal committed
1248
	public Result<Integer> DelAttendanceGroup(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
1249

lal committed
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259
		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();//查询考勤机“序列号”
			if(kqj != null) {
				DevId = kqj.getCode();
				for(UserAttendanceRel user:attusers) {
					String user_id = user.getEmpnum();//"1692";//要删除的考勤组里面用户ID
1260

lal committed
1261
					String url = mac_command+"/deleteUser";
1262 1263 1264 1265 1266 1267 1268
					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);
					try {
lal committed
1269
						ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
ilal committed
1270
						Logoutput(request.getBody());
lal committed
1271
					} catch (RestClientException e) {
ilal committed
1272
						Logoutput("提示:考勤机服务出错-5");
1273

lal committed
1274 1275
						return ResultUtil.error("删除失败:提示:考勤机服务出错");
					}
lal committed
1276
				}
lal committed
1277
			}
1278

lal committed
1279
		}
1280

lal committed
1281
		List<AdditionalDto> userlist = kqglassoleavebalancemapper.RealTimeUpdate(userBean.getOrgCode(),id);
1282 1283 1284

		if(KqglMainKqz.builder().id(id).build().deleteById()) {

lal committed
1285
			userequirelationmapper.deleteBykqzid(id);
1286

ilal committed
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296
			//删除考勤组绑定的打卡方式
			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));
1297 1298


ilal committed
1299 1300 1301 1302
			//刪除加班规则-应用范围
			KqglAssoOvertimeRange.builder().build().delete(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, id));
			//刪除假期规则-适用范围
			KqglAssoRulesVice.builder().build().delete(new QueryWrapper<KqglAssoRulesVice>().lambda().eq(KqglAssoRulesVice::getAttgroupId, id));
1303

lal committed
1304 1305 1306 1307 1308
			try {
				realtimeupdate.AttendanceTask(userBean.getOrgCode(), 0, 3,userlist);
			} catch (ParseException e) {
				e.printStackTrace();
			}
1309

ilal committed
1310 1311 1312 1313
			return ResultUtil.data(id,"删除成功");
		}
		return ResultUtil.error("删除失败");
	}
1314

ilal committed
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
	@Autowired
	private KqglAssoKqzdkfsMapper kqglassokqzdkfsmapper;
	@Autowired
	private KqglAssoYhkqzMapper kqglassoyhkqzmapper;
	@Autowired
	private KqglAssoZhoupaibanMapper kqglassozhoupaibanmapper;
	@Autowired
	private KqglAssoTeshuMapper kqglassoteshumapper;
	@Autowired
	private KqglAssoPbmxMapper kqglassopbmxmapper;
1325

lal committed
1326 1327
	@Autowired
	private RealTimeUpdate realtimeupdate;
ilal committed
1328 1329 1330
	/**
	 * 	新建考勤组
	 */
lal committed
1331
	@SuppressWarnings("all")
ilal committed
1332 1333 1334 1335 1336 1337 1338 1339
	@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())
ilal committed
1340 1341
				.zsgzsc(attass.getLeastworkTime()).zcgzsc(attass.getNormalWorkTime()).jbzdsc(attass.getMaxOvertimeTime()).overtimeRulesId(attass.getOvertimeRulesId())
				.restdayclock(attass.getRestdayclock()).build();
1342 1343 1344

//		if (!attgro.insertOrUpdate())
		if (!attgro.insert())
ilal committed
1345
			return ResultUtil.error("操作失败--新增考勤组");
1346

ilal committed
1347 1348
		Integer attid = attgro.getId();
		Console.log("新增--考勤组id: " + attid);
1349

lal committed
1350
		//添加加班规则
lal committed
1351 1352 1353
		if(attass.getOvertimeRulesId() > 0) {
			KqglAssoOvertimeRange.builder().overtimeRulesId(attass.getOvertimeRulesId()).attgroupId(attid).build().insert();
		}
1354

ilal committed
1355
		List<KqglAssoKqzdkfs> kqzdkfslist = new ArrayList<KqglAssoKqzdkfs>();
1356
		String[] attmac = attass.getAttmachines();//考勤机
ilal committed
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
		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);
		}
1380

ilal committed
1381 1382 1383 1384 1385
		//用户和考勤组关系
		List<KqglAssoYhkqz> yhkqzlist = new ArrayList<KqglAssoYhkqz>();
		String[] attser = attass.getAttuserids();
		if(attser.length>0){
			for(int u=0;u<attser.length;u++){
lal committed
1386 1387 1388
				if(attass.getAtttype() == 2){
					KqglAssoPbmx.builder().build().delete(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, Integer.valueOf(attser[u])));
				}
1389

lal committed
1390
				KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, Integer.valueOf(attser[u])).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
1391

ilal committed
1392 1393
				KqglAssoYhkqz kquser = KqglAssoYhkqz.builder().kqzid(attid).userid(Integer.valueOf(attser[u])).qyid(userBean.getOrgCode()).build();
				yhkqzlist.add(kquser);
1394

ilal committed
1395
				List<KqglAssoKqzdkfs> kqjs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, attid).eq(KqglAssoKqzdkfs::getType, 1));
1396

ilal committed
1397 1398 1399 1400
				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) {
1401

ilal committed
1402
						YgglMainEmp yggluser = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).eq(YgglMainEmp::getEmpNum, attser[u]));
lal committed
1403
						String url = mac_command+"/addUserName";
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
						HttpHeaders headers = new HttpHeaders();
						MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
						params.add("devId", kqj.getCode());
						params.add("userId", attser[u]);
						params.add("userName", yggluser.getName());
						RestTemplate restTemplate = new RestTemplate();
						HttpEntity httpEntity = new HttpEntity(params, headers);
						ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
						Logoutput(request.getBody());

						KqglAssoYhsb.builder().build().delete(new QueryWrapper<KqglAssoYhsb>().lambda().eq(KqglAssoYhsb::getUserId, attser[u]).eq(KqglAssoYhsb::getKqjid, kqj.getId()));

ilal committed
1416
						KqglAssoYhsb uskqj = KqglAssoYhsb.builder().userId(Integer.valueOf(attser[u])).kqjid(kqj.getId()).type(1).build();
1417

ilal committed
1418 1419 1420 1421 1422 1423
						UserEquiRelation isgly = userequirelationmapper.selectByuserId(Integer.valueOf(attser[u]));
						if(isgly != null) {
							uskqj.setIsGly(isgly.getIsGly());
						}else {
							uskqj.setIsGly(0);
						}
1424
						if (!uskqj.insert())
ilal committed
1425
							return ResultUtil.error("操作失败--新增用户与设备关系");
ilal committed
1426 1427 1428
					}
				}
			}
1429

ilal committed
1430 1431 1432 1433
		}
		if(yhkqzlist.size()>0){
			kqglassoyhkqzmapper.insertKqglAssoKqzdkfsList(yhkqzlist);
		}
1434

ilal committed
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453
		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);
		}
1454 1455


ilal committed
1456 1457 1458
		List<KqglAssoTeshu> speclist = new ArrayList<KqglAssoTeshu>();
		String[] attmuspudata = attass.getAttMustPunchData();// 必须打卡的日期【固定排班】
		String[] attmuspushifid = attass.getAttMustPunchShifid();// 必须打卡的班次id【固定排班】
ilal committed
1459 1460
//		String[] attnonpudata = attass.getAttNonPunchData();// 不用打卡的日期【固定排班】
		ResttryfixdayDto[] attnonpudata = attass.getAttNonPunchData();// 不用打卡的日期【固定排班】
1461

ilal committed
1462 1463 1464 1465 1466 1467
		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);
			}
		}
1468

ilal committed
1469 1470
		if(attnonpudata.length>0 && attass.getAtttype() == 1){
			for(int n=0;n<attnonpudata.length;n++){
ilal committed
1471
				KqglAssoTeshu non = KqglAssoTeshu.builder().kqzid(attid).tsrq(attnonpudata[n].getDate()).legalday(attnonpudata[n].getWhether()).bcid(0).lusjTime(new Date().getTime()).luryid(userBean.getEmpNum()).type(2).build();
ilal committed
1472 1473 1474 1475
				speclist.add(non);
			}
		}
		if(speclist.size()>0){
1476 1477 1478
			speclist.forEach(t ->{
				kqglassoteshumapper.insert(t);
			});
ilal committed
1479
		}
1480 1481


ilal committed
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
		//记录排班(排班制)
		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);
		}
1494 1495


lal committed
1496 1497 1498 1499 1500
		try {
			realtimeupdate.AttendanceTask(userBean.getOrgCode(), attid, 1,null);
		} catch (ParseException e) {
			e.printStackTrace();
		}
1501

ilal committed
1502 1503
		return ResultUtil.data(attgro,"操作成功!");
	}
1504

lal committed
1505 1506 1507
	@GetMapping(value="/Overtime_rule_default")
	@ApiOperation(value = "获取当前公司的默认加班规则", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> Overtime_rule_default(@CurrentUser UserBean userBean) {
1508

lal committed
1509 1510
		KqglAssoOvertimeRules defovwe = KqglAssoOvertimeRules.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRules>().lambda().eq(KqglAssoOvertimeRules::getOrgCode, userBean.getOrgCode())
				.eq(KqglAssoOvertimeRules::getOvertimeruledefault, 1));
1511

lal committed
1512 1513
		return ResultUtil.data(defovwe,"操作成功!");
	}
1514 1515


lal committed
1516 1517 1518 1519 1520 1521
	/**
	 * 	获取当前考勤组所有人员
	 */
	@GetMapping(value="/AttUserGroupList/{id}")
	@ApiOperation(value = "获取当前考勤组所有人员", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> getAttUserGroupList(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
1522

lal committed
1523 1524 1525
		UserAttendanceRelDto usatt = UserAttendanceRelDto.builder().build();
		List<UserAttendanceRel> userattgor = userattendancerelmapper.selectAttendanceOfficerByKqzid(id,userBean.getOrgCode());
		usatt.setUseratts(userattgor);
1526

lal committed
1527 1528
		KqglMainKqz kqztypeid = kqglmainkqzmapper.selectOne(new QueryWrapper<KqglMainKqz>().lambda().eq(KqglMainKqz::getId, id));
		usatt.setTypeid(kqztypeid.getPbfs());
1529

lal committed
1530 1531
		return ResultUtil.data(usatt);
	}
1532 1533

	//	@SuppressWarnings("all")
lal committed
1534 1535 1536
	@PostMapping(value = "/setmembers")
	@ApiOperation(value = "考勤设置成员", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> Attsetmembers(@CurrentUser UserBean userBean,@RequestBody AttMemberSettings attsetuser) {
1537

ilal committed
1538
		KqglMainKqz kqzm = KqglMainKqz.builder().id(attsetuser.getAttgroupid()).build().selectById();
1539

ilal committed
1540
		List<AdditionalDto> userlist = new ArrayList<AdditionalDto>();
1541

lal committed
1542 1543 1544 1545 1546
		List<KqglAssoKqzdkfs> qtdkfs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().ne(KqglAssoKqzdkfs::getType, 1).eq(KqglAssoKqzdkfs::getKqzId, attsetuser.getAttgroupid()));
		if(qtdkfs.size() > 0) {
			//考勤组新增员工
			String[] addmember = attsetuser.getAddMember();
			for(int a=0;a<addmember.length;a++){
1547

ilal committed
1548 1549 1550 1551
				if(kqzm.getPbfs() == 2){
					KqglAssoPbmx.builder().build().delete(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, Integer.valueOf(addmember[a])));
				}
				KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, Integer.valueOf(addmember[a])).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
1552

lal committed
1553 1554
				KqglAssoYhkqz.builder().kqzid(attsetuser.getAttgroupid()).userid(Integer.valueOf(addmember[a])).qyid(userBean.getOrgCode()).build().insert();
			}
1555 1556 1557 1558 1559 1560 1561

			//考勤组减少员工
			String[] removemember = attsetuser.getRemoveMember();
			for(int r=0;r<removemember.length;r++){
				//用户和考勤组关系表
				KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getKqzid, attsetuser.getAttgroupid()).eq(KqglAssoYhkqz::getUserid, removemember[r]));
			}
lal committed
1562
		}
1563

lal committed
1564 1565 1566 1567 1568 1569 1570
		//确认当前考勤组是否存在考勤机打卡
		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();//查询考勤机“序列号”
lal committed
1571 1572 1573 1574 1575 1576
				if(kqj != null) {
					DevId = kqj.getCode();
					kqjid = kqj.getId();
				}else {
					return ResultUtil.error("考勤机不存在");
				}
1577

lal committed
1578 1579
				//考勤组新增员工
				String[] addmember = attsetuser.getAddMember();
lal committed
1580
				String urladd = mac_command+"/addUserName";
lal committed
1581 1582
				for(int a=0;a<addmember.length;a++){
					HttpHeaders headers = new HttpHeaders();
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595
					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);
					Logoutput(request.getBody());

					//需要改下下
					KqglAssoYhsb uskqj = KqglAssoYhsb.builder().userId(Integer.valueOf(addmember[a])).kqjid(kqjid).type(1).isGly(0).build();
					if (!uskqj.insert())
lal committed
1596
						return ResultUtil.error("操作失败--新增用户与设备关系");
1597

ilal committed
1598 1599 1600 1601
					if(kqzm.getPbfs() == 2){
						KqglAssoPbmx.builder().build().delete(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, Integer.valueOf(addmember[a])));
					}
					KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, Integer.valueOf(addmember[a])).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
1602

lal committed
1603
					KqglAssoYhkqz.builder().kqzid(attsetuser.getAttgroupid()).userid(Integer.valueOf(addmember[a])).qyid(userBean.getOrgCode()).build().insert();
lal committed
1604
				}
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624

				//考勤组减少员工
				String[] removemember = attsetuser.getRemoveMember();
				String urlre = mac_command+"/deleteUser";
				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);
					Logoutput(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]));
					//用户和考勤组关系表
					KqglAssoYhkqz.builder().build().delete(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getKqzid, attsetuser.getAttgroupid()).eq(KqglAssoYhkqz::getUserid, removemember[r]));
lal committed
1625 1626
				}
			}
1627

lal committed
1628
		}
1629

ilal committed
1630 1631 1632 1633 1634
		try {
			realtimeupdate.AttendanceTask(userBean.getOrgCode(), attsetuser.getAttgroupid(), 1,null);
		} catch (ParseException e) {
			e.printStackTrace();
		}
1635 1636 1637 1638



		return ResultUtil.success("成功");
lal committed
1639
	}
1640 1641


ilal committed
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656
	@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) {
1657 1658 1659 1660 1661 1662 1663
		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);
ilal committed
1664
	}
1665

ilal committed
1666 1667 1668 1669 1670 1671 1672
	/**
	 * 根据考勤组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) {
1673

ilal committed
1674
		KqzAttendanceGroupSearchDto jycx = KqzAttendanceGroupSearchDto.builder().overall(date).qyid(id).build();
1675

ilal committed
1676 1677 1678
		List<KqglAssoBcsz> shifs = kqglassobcszmapper.selectRosterByKqzid(jycx);
		return ResultUtil.data(shifs);
	}
1679

ilal committed
1680
	private SimpleDateFormat mat = new SimpleDateFormat("yyyy-MM-dd");
1681

ilal committed
1682 1683
	//打卡记录
	@Autowired
lal committed
1684
	private PunchRecordMapper punchrecordmapper;
lal committed
1685

1686 1687 1688



ilal committed
1689
	@PostMapping(value = "/leave_balance_list")
lal committed
1690
	@ApiOperation(value = "45:获取假期余额列表数据", httpMethod = "POST", notes = "接口发布说明")
ilal committed
1691 1692
	@ApiOperationSupport(order = 45)
	public Result<Object> LeaveBalanceList(@CurrentUser UserBean userBean, @Validated @RequestBody AttqueryCriteriaDto attquerycriteriadto) {
lal committed
1693
		IPage<EmployeeLeaveBalanceDto> page = new Page<EmployeeLeaveBalanceDto>(attquerycriteriadto.getCurrentPage(),attquerycriteriadto.getTotalPage());
1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721

		attquerycriteriadto.setOrgCode(userBean.getOrgCode());
		attquerycriteriadto.setEmpNum(userBean.getEmpNum());
		// 缺-部门id 搜索
		IPage<EmployeeLeaveBalanceDto> pageAs = kqglassoleavebalancemapper.selectPageByQueryLeaveBalance(page, attquerycriteriadto);

		List<EmployeeLeaveBalanceDto> listAs = pageAs.getRecords();

		List<EmployeeLeaveBalanceDto> sumlist = new ArrayList<EmployeeLeaveBalanceDto>();
		for(EmployeeLeaveBalanceDto endo : listAs) {
			EmployeeLeaveBalanceDto dets = EmployeeLeaveBalanceDto.builder().build();
			BeanUtil.copyProperties(endo, dets , "balanceTo");

			List<KqglAssoLeaveEmployeeBalance> empye = KqglAssoLeaveEmployeeBalance.builder().build().selectList(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getUserid, endo.getEmpnum())
					.eq(KqglAssoLeaveEmployeeBalance::getOrgCode, endo.getOrgcode()));
			List<BalanceSheetDataDto> balanceTo = new ArrayList<BalanceSheetDataDto>();
			for(KqglAssoLeaveEmployeeBalance empyes : empye) {
				BalanceSheetDataDto bal = BalanceSheetDataDto.builder().build();
				bal.setBalancedays(empyes.getBalanceDays());
				bal.setLeaverulesid(empyes.getLeaveRulesId());
				balanceTo.add(bal);
			}
			dets.setBalanceTo(balanceTo);
			sumlist.add(dets);

		}

		return ResultUtil.data(pageAs, sumlist, "操作成功!");
ilal committed
1722
	}
1723 1724


lal committed
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
	 * 	移除考勤机管理员
	 */
	@SuppressWarnings("all")
	@PostMapping(value = "/removeemp/{kqjid}/{id}")
	@ApiOperation(value = "删除考勤机内成员", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 46)
	public Result<Object> RemoveEmp(@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++){

				String url = mac_command+"/deleteUser";
				HttpHeaders headers = new HttpHeaders();
				MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
				params.add("devId", kqj.getCode());
				params.add("userId", xgyh[a]);
				RestTemplate restTemplate = new RestTemplate();
				HttpEntity httpEntity = new HttpEntity(params, headers);
				try {
					ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
					if (!StringUtils.isEmpty(request) && request.getStatusCode() == HttpStatus.OK) {
						Logoutput(request.getBody());
						JSONObject jsonObj = JSON.parseObject(request.getBody());
						if (!"200".equals(jsonObj.getString("code"))) {
							return ResultUtil.error(jsonObj.getString("message"));
						}
					}
				} catch (RestClientException e) {
					Logoutput("提示:考勤机服务出错-3");
					return ResultUtil.success("失败");
				}
				KqglAssoYhsb.builder().id(id).build().deleteById();
			}
		}
		return ResultUtil.success("成功");
	}
	/**
lal committed
1764 1765 1766 1767 1768 1769 1770 1771 1772
	 * 	根据用户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,"操作成功!");
	}
1773 1774


lal committed
1775 1776
	/**
	 * 	考勤原始记录-根据 模糊 + 高級查詢-分页
1777
	 * @throws ParseException
lal committed
1778 1779 1780 1781
	 */
	@PostMapping(value = "/attendancecalendar")
	@ApiOperation(value = "考勤原始记录-根据 模糊 + 高級查詢-分页", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 34)
ilal committed
1782
	public Result<Object> AttendanceCalendar(@CurrentUser UserBean userBean, @Validated @RequestBody OriginalRecordDto originalrecorddto) throws ParseException{
1783

chenzg committed
1784
			IPage<PunchRecord> page = new Page<PunchRecord>(
1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805
				originalrecorddto.getCurrentPage() == null ? 1 : originalrecorddto.getCurrentPage(),
				originalrecorddto.getTotalPage() == null ? 10 : originalrecorddto.getTotalPage());
		originalrecorddto.setQyid(userBean.getOrgCode());
		if(!originalrecorddto.getStart().equals("") && !originalrecorddto.getEnd().equals("") && originalrecorddto.getStart() != null && originalrecorddto.getEnd() != null) {

			String sdaet = originalrecorddto.getStart() + " 00:00:00";
			String staapptime = ClockInTool.dateToStamp(sdaet);
			originalrecorddto.setStart(staapptime);

			String edate = originalrecorddto.getEnd() + " 23:59:59";
			String endapptime = ClockInTool.dateToStamp(edate);
			originalrecorddto.setEnd(endapptime);
		}


		IPage<PunchRecord> pageAs = punchrecordmapper.QueryOriginalRecord(page, originalrecorddto);
		List<PunchRecord> listAs = pageAs.getRecords();
		return ResultUtil.data(pageAs, listAs, "操作成功!");
	}


ilal committed
1806 1807 1808 1809
	@PostMapping(value = "/exportattendancecalendar")
	@ApiOperation(value = "", httpMethod = "POST", notes = "接口发布说明")
	@ApiOperationSupport(order = 34)
	public Result<Object> exportattendancecalendar(@CurrentUser UserBean userBean, @Validated @RequestBody OriginalRecordDto originalrecorddto) throws ParseException{
1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827

		originalrecorddto.setQyid(userBean.getOrgCode());
		if(!originalrecorddto.getStart().equals("") && !originalrecorddto.getEnd().equals("") && originalrecorddto.getStart() != null && originalrecorddto.getEnd() != null) {
			String sdaet = originalrecorddto.getStart() + " 00:00:00";
			String staapptime = ClockInTool.dateToStamp(sdaet);
			originalrecorddto.setStart(staapptime);

			String edate = originalrecorddto.getEnd() + " 23:59:59";
			String endapptime = ClockInTool.dateToStamp(edate);
			originalrecorddto.setEnd(endapptime);
		}

		List<PunchRecord> listAs = punchrecordmapper.exportQueryOriginalRecord(originalrecorddto);

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


lal committed
1828 1829 1830 1831 1832 1833 1834
	/**
	 * 获取考勤组所需加班规则
	 */
	@GetMapping(value="/attovertimerules")
	@ApiOperation(value = "获取考勤组所需加班规则", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 15)
	public Result<Object> getAttOvertimeRules(@CurrentUser UserBean userBean){
1835

lal committed
1836
		List<KqglAssoOvertimeRules> attoverrul = new LambdaQueryChainWrapper<KqglAssoOvertimeRules>(kqglassoovertimerulesmapper).eq(KqglAssoOvertimeRules::getOrgCode, userBean.getOrgCode()).list();
1837 1838

		return ResultUtil.data(attoverrul,"操作成功!");
lal committed
1839
	}
1840

lal committed
1841 1842 1843 1844 1845
	@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 {
1846

lal committed
1847
		IPage<KqglAssoMonthPunchSummaryDto> page = new Page<KqglAssoMonthPunchSummaryDto>( attesummqueto.getCurrentPage(),attesummqueto.getTotalPage());
1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901
		attesummqueto.setOrgCode(userBean.getOrgCode());

		String year = null,month = null;
		String staapptime = null,endapptime = 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();

			String time = attesummqueto.getTimes()+"-01";
			String sdaet = ClockInTool.getMinMonthDate(time);
			staapptime = String.valueOf(ClockInTool.getStartTime(0,ClockInTool.getStringTime(sdaet,"yyyy-MM-dd")).getTime());
			String edate = ClockInTool.getMaxMonthDate(time);
			endapptime = String.valueOf(ClockInTool.getnowEndTime(23,ClockInTool.getStringTime(edate,"yyyy-MM-dd")).getTime());
		}else {
			year =  new SimpleDateFormat("yyyy").format(new Date()).toString();
			month = new SimpleDateFormat("MM").format(new Date()).toString();

			time_ = new SimpleDateFormat("yyyy-MM").format(new Date()).toString();

			Calendar c = Calendar.getInstance();
			c.add(Calendar.MONTH, 0);
			c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
			String first = mat.format(c.getTime());
			staapptime = String.valueOf(DateUtil.getStartTime(0,DateUtil.getStringTime(first,"yyyy-MM-dd")).getTime());

			//获取当前月最后一天
			Calendar ca = Calendar.getInstance();
			ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
			String last = mat.format(ca.getTime());
			endapptime = String.valueOf(DateUtil.getnowEndTime(23,DateUtil.getStringTime(last,"yyyy-MM-dd")).getTime());
		}


		attesummqueto.setYear(year);
		attesummqueto.setMonth(month);
		attesummqueto.setStaapptime(staapptime);
		attesummqueto.setEndapptime(endapptime);

		attesummqueto.setTimes(time_);

		// 缺-部门id 搜索
		IPage<KqglAssoMonthPunchSummaryDto> pageAs = kqglassomonthpunchsummarymapper.AttendanceSummaryData(page, attesummqueto);

		List<KqglAssoMonthPunchSummaryDto> listAs = pageAs.getRecords();

		List<KqglAssoMonthPunchSummaryDto> sumlist = new ArrayList<KqglAssoMonthPunchSummaryDto>();

		for(KqglAssoMonthPunchSummaryDto endo : listAs) {
			KqglAssoMonthPunchSummaryDto dets = KqglAssoMonthPunchSummaryDto.builder().build();

			BeanUtil.copyProperties(endo, dets , "balanceTo");

lal committed
1902 1903
//					List<KqglAssoLeaveEmployeeBalance> empye = KqglAssoLeaveEmployeeBalance.builder().build().selectList(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getUserid, endo.getNum())
//							.eq(KqglAssoLeaveEmployeeBalance::getOrgCode, endo.getOrgCode()));
1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920


			List<BalanceSheetDataDto> empye = kqglassomonthpunchsummarymapper.MonthlySummaryLeave(endo.getOrgCode(), endo.getNum(), attesummqueto.getTimes());

			List<BalanceSheetDataDto> balanceTo = new ArrayList<BalanceSheetDataDto>();
			for(BalanceSheetDataDto empyes : empye) {
				BalanceSheetDataDto bal = BalanceSheetDataDto.builder().build();
				bal.setBalancedays(empyes.getBalancedays());
				bal.setLeaverulesid(empyes.getLeaverulesid());
				balanceTo.add(bal);
			}
			dets.setBalanceTo(balanceTo);
			sumlist.add(dets);

		}

		return ResultUtil.data(pageAs, sumlist, "操作成功!");
lal committed
1921
	}
1922

lal committed
1923 1924 1925
	@PostMapping(value = "/Daily_details")
	@ApiOperation(value = "获取考勤每日详情数据", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> DailydetailsList(@CurrentUser UserBean userBean, @Validated @RequestBody AttendanceSummaryQueryDto attesummqueto) throws ParseException {
1926

lal committed
1927 1928 1929
		IPage<DailyDetailsDto> page = new Page<DailyDetailsDto>(
				attesummqueto.getCurrentPage() == null ? 1 : attesummqueto.getCurrentPage(),
				attesummqueto.getTotalPage() == null ? 10 : attesummqueto.getTotalPage());
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
		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();

		List<DailyDetailsDto> sumlist = new ArrayList<DailyDetailsDto>();

		//多条

		for(DailyDetailsDto endo : listAs) {
			DailyDetailsDto dets = DailyDetailsDto.builder().build();

			BeanUtil.copyProperties(endo, dets , "balanceTo");

lal committed
1961 1962
//					List<KqglAssoLeaveEmployeeBalance> empye = KqglAssoLeaveEmployeeBalance.builder().build().selectList(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getUserid, endo.getNum())
//							.eq(KqglAssoLeaveEmployeeBalance::getOrgCode, endo.getOrgcode()));
1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977

			List<BalanceSheetDataDto> empye = kqglassomonthpunchsummarymapper.AttenSumDailyDetails(endo.getOrgcode(), endo.getNum(), attesummqueto.getTimes());

			List<BalanceSheetDataDto> balanceTo = new ArrayList<BalanceSheetDataDto>();
			for(BalanceSheetDataDto empyes : empye) {
				BalanceSheetDataDto bal = BalanceSheetDataDto.builder().build();
				bal.setBalancedays(empyes.getBalancedays());
				bal.setLeaverulesid(empyes.getLeaverulesid());
				balanceTo.add(bal);
			}
			dets.setBalanceTo(balanceTo);
			sumlist.add(dets);
		}

		return ResultUtil.data(pageAs, sumlist, "操作成功!");
lal committed
1978
	}
1979 1980


lal committed
1981 1982 1983 1984
	@Autowired
	private KqglAssoDkmxMapper kqglassodkmxmapper;
	/**
	 * 	更改打卡结果
1985
	 * @throws ParseException
lal committed
1986 1987 1988 1989 1990
	 */
	@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
1991

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

ilal committed
1995
		String punchattdate = new SimpleDateFormat("yyyy-MM-dd").format(Double.valueOf(startDate));//转换打卡时间格式
1996

lal committed
1997
		String minutes = chpunchr.getMinutes();//更改分钟数
1998

lal committed
1999 2000 2001 2002 2003
		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;//打卡结果
2004

lal committed
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
		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", "");
			}
2019

lal committed
2020 2021 2022 2023 2024 2025 2026 2027 2028
			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);
			}
2029

lal committed
2030 2031
			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;
2032

lal committed
2033
			int dkmxid = 0;
2034

lal committed
2035
			//kqgl_asso_dkmx 打卡明细是否存在打卡记录
lal committed
2036
			KqglAssoDkmx dkmx = kqglassodkmxmapper.selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getData, chpunchr.getData()).eq(KqglAssoDkmx::getUserid, chpunchr.getNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode()));
lal committed
2037
			if(dkmx != null) {
lal committed
2038 2039 2040 2041 2042 2043 2044 2045
				dkmxid = dkmx.getId();
				if(chpunchr.getClocktype() == 1) {
					sbdk1 = changed_time;
					sbdk1jg = results;
					KqglAssoDkmx.builder().id(dkmx.getId()).sbdk1(sbdk1).sbdk1jg(sbdk1jg).dktj1(2).build().updateById();
				}else if(chpunchr.getClocktype() == 2) {
					xbdk1 = changed_time;
					xbdk1jg = results;
2046

lal committed
2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065
					KqglAssoDkmx.builder().id(dkmx.getId()).xbdk1(xbdk1).xbdk1jg(xbdk1jg).dktj2(2).build().updateById();
				}else if(chpunchr.getClocktype() == 3) {
					sbdk2 = changed_time;
					sbdk2jg = results;
					KqglAssoDkmx.builder().id(dkmx.getId()).sbdk2(sbdk2).sbdk2jg(sbdk2jg).dktj3(2).build().updateById();
				}else if(chpunchr.getClocktype() == 4) {
					xbdk2 = changed_time;
					xbdk2jg = results;
					KqglAssoDkmx.builder().id(dkmx.getId()).xbdk2(xbdk2).xbdk2jg(xbdk2jg).dktj4(2).build().updateById();
				}else if(chpunchr.getClocktype() == 5) {
					sbdk3 = changed_time;
					sbdk3jg = results;
					KqglAssoDkmx.builder().id(dkmx.getId()).sbdk3(sbdk3).sbdk3jg(sbdk3jg).dktj5(2).build().updateById();
				}else {
					xbdk3 = changed_time;
					xbdk3jg = results;
					KqglAssoDkmx.builder().id(dkmx.getId()).xbdk3(xbdk3).xbdk3jg(xbdk3jg).dktj6(2).build().updateById();
				}
			}else {
2066

lal committed
2067 2068
				KqglAssoDkmx pcd = KqglAssoDkmx.builder().userid(chpunchr.getNum()).data(data).qyid(userBean.getOrgCode()).dksj(startDate).ydkcs(dkbc.getSxbcs()*2)
						.gzsc(0d).build();
lal committed
2069 2070 2071
				if(chpunchr.getClocktype() == 1) {
					sbdk1 = changed_time;
					sbdk1jg = results;
2072

lal committed
2073 2074 2075
					pcd.setSbdk1(sbdk1);
					pcd.setSbdk1jg(sbdk1jg);
					pcd.setDktj1(2);
2076
					if (!pcd.insert()) {
lal committed
2077
						throw new CustomException("打卡明细-新增异常-1");
2078
					}
lal committed
2079 2080 2081
				}else if(chpunchr.getClocktype() == 2) {
					xbdk1 = changed_time;
					xbdk1jg = results;
2082 2083 2084 2085 2086

					pcd.setXbdk1(xbdk1);
					pcd.setXbdk1jg(xbdk1jg);
					pcd.setDktj2(2);
					if (!pcd.insert()) {
lal committed
2087
						throw new CustomException("打卡明细-新增异常-1");
2088 2089
					}

lal committed
2090 2091 2092
				}else if(chpunchr.getClocktype() == 3) {
					sbdk2 = changed_time;
					sbdk2jg = results;
2093

lal committed
2094 2095 2096
					pcd.setSbdk2(sbdk2);
					pcd.setSbdk2jg(sbdk2jg);
					pcd.setDktj3(2);
2097
					if (!pcd.insert()) {
lal committed
2098
						throw new CustomException("打卡明细-新增异常-1");
2099
					}
lal committed
2100 2101 2102
				}else if(chpunchr.getClocktype() == 4) {
					xbdk2 = changed_time;
					xbdk2jg = results;
2103

lal committed
2104
					pcd.setXbdk2(xbdk2);
2105 2106 2107
					pcd.setXbdk2jg(xbdk2jg);
					pcd.setDktj4(2);
					if (!pcd.insert()) {
lal committed
2108
						throw new CustomException("打卡明细-新增异常-1");
2109
					}
lal committed
2110 2111 2112
				}else if(chpunchr.getClocktype() == 5) {
					sbdk3 = changed_time;
					sbdk3jg = results;
2113

lal committed
2114 2115 2116
					pcd.setSbdk3(sbdk3);
					pcd.setSbdk3jg(sbdk3jg);
					pcd.setDktj5(2);
2117
					if (!pcd.insert()) {
lal committed
2118
						throw new CustomException("打卡明细-新增异常-1");
2119
					}
lal committed
2120 2121 2122
				}else {
					xbdk3 = changed_time;
					xbdk3jg = results;
2123 2124 2125 2126 2127

					pcd.setXbdk3(xbdk3);
					pcd.setXbdk3jg(xbdk3jg);
					pcd.setDktj6(2);
					if (!pcd.insert()) {
lal committed
2128
						throw new CustomException("打卡明细-新增异常-1");
2129
					}
lal committed
2130
				}
2131

lal committed
2132
				dkmxid = pcd.getId();
lal committed
2133
			}
2134

ilal committed
2135
			double gzsc = 0;
2136

ilal committed
2137
			long rest_time = 0;
ilal committed
2138
			if(dkbc.getStartTime() != null && !("").equals(dkbc.getStartTime()) && dkbc.getEndTime() != null && !("").equals(dkbc.getEndTime())) {
ilal committed
2139
				long kaishixiuxi = Long.valueOf(ClockInTool.dateToStamp(punchattdate + " " +dkbc.getStartTime()+":00"));
2140 2141
				long jieshuxiuxi = Long.valueOf(ClockInTool.dateToStamp(punchattdate + " " +dkbc.getEndTime()+":00"));
				rest_time = (jieshuxiuxi - kaishixiuxi)/1000/60;//休息时间
ilal committed
2142
			}
2143

ilal committed
2144 2145
			//请假时长
			KqglAssoRelationSummary qjsc = kqglassorelationsummarymapper.Businessdayclockin(userBean.getEmpNum(), 2, punchattdate, userBean.getOrgCode());
2146

ilal committed
2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164
			//计算工作时长
			KqglAssoDkmx dkgzsc = KqglAssoDkmx.builder().id(dkmxid).build().selectById();
			if(dkgzsc.getYdkcs() == 2 || dkgzsc.getYdkcs() == 4 || dkgzsc.getYdkcs() == 6) {
				if(dkgzsc.getSbdk1() != null && dkgzsc.getXbdk1() != null) {
					gzsc = gzsc + (dkgzsc.getXbdk1() - dkgzsc.getSbdk1())/1000/60;
				}
			}
			if(dkgzsc.getYdkcs() == 4 || dkgzsc.getYdkcs() == 6) {
				if(dkgzsc.getSbdk2() != null && dkgzsc.getXbdk2() != null) {
					gzsc = gzsc + (dkgzsc.getXbdk2() - dkgzsc.getSbdk2())/1000/60;
				}
			}
			if(dkgzsc.getYdkcs() == 6) {
				if(dkgzsc.getSbdk3() != null && dkgzsc.getXbdk3() != null) {
					gzsc = gzsc + (dkgzsc.getXbdk3() - dkgzsc.getSbdk3())/1000/60;
				}
			}
			gzsc = gzsc - rest_time - qjsc.getDuration();
2165

ilal committed
2166
			KqglAssoDkmx.builder().id(dkmxid).gzsc(gzsc).build().updateById();
2167

lal committed
2168 2169
			//打卡记录表
			clock_time_ = Long.valueOf(ClockInTool.dateToStamp(clock_time));
2170 2171


lal committed
2172
			int type = 0;
2173
			//0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休
lal committed
2174 2175
			//9:管理员改为正常 10:管理员改为迟到 11:管理员改为早退  12:补卡通过/正常 13:补卡通过/迟到 14:补卡通过/早退
			int status = 2;
lal committed
2176 2177
			if((chpunchr.getClocktype())%2 > 0){
				type = 1;
2178

lal committed
2179 2180 2181 2182 2183
				if(results == 0) {
					status = 9;
				}else {
					status = 10;
				}
lal committed
2184 2185
			}else {
				type = 2;
2186

lal committed
2187 2188 2189 2190 2191
				if(results == 0) {
					status = 9;
				}else {
					status = 11;
				}
lal committed
2192
			}
2193

lal committed
2194
			KqglAssoDkjl pre = KqglAssoDkjl.builder().dktime(changed_time).results(results).userId(chpunchr.getNum()).type(type).status(status).sort(chpunchr.getClocktype())
lal committed
2195
					.cardType(0).qyid(userBean.getOrgCode()).attdate(attdate_+" "+ClockInTool.dateToWeek2(data)).attime(clock_time_).dkmxid(dkmxid).bcid(chpunchr.getBcszid()).remarks("管理员更改操作").punchmode(0)
lal committed
2196 2197 2198
					.punchequipment("").build();
			if (!pre.insert()) {
				throw new CustomException("打卡记录-新增异常");
2199 2200
			}

lal committed
2201 2202
			return ResultUtil.success("操作成功!");
		}else {
2203

lal committed
2204 2205 2206
			return ResultUtil.error("操作失败,检查班次是否存在");
		}
	}
2207 2208 2209



lal committed
2210 2211 2212 2213
//	@GetMapping(value = "/summary_report")
//	@ApiOperation(value = "考勤汇总报表(暂时不用)", httpMethod = "GET", notes = "接口发布说明")
//	public Result<Object> attendance_summary_report() {
//		Map<String, Object> map = new HashMap<String, Object>();
2214
//
lal committed
2215 2216
//		return ResultUtil.data(map);
//	}
2217

ilal committed
2218
	/**
ilal committed
2219 2220
	 * 	查询列表-加班补偿方式
	 */
lal committed
2221 2222 2223
	@GetMapping(value = "/overtime_type")
	@ApiOperation(value = "222: 加班类型", httpMethod = "GET", notes = " 查询列表-加班补偿方式")
	public Result<Object> overtimetypelist(@CurrentUser UserBean userBean) {
2224

lal committed
2225 2226 2227
		KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userBean.getEmpNum(),userBean.getOrgCode()); //考勤组信息
		if(attgro != null) {
			List<CompensateDto> coms = new ArrayList<CompensateDto>();
2228

lal committed
2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252
			KqglAssoYhkqz yhd = KqglAssoYhkqz.builder().build().selectOne(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, userBean.getEmpNum()).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
			if(yhd != null) {
				KqglAssoOvertimeRange timeran = KqglAssoOvertimeRange.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, yhd.getKqzid()));
				if(timeran != null) {
					KqglAssoOvertimeRules rul = KqglAssoOvertimeRules.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRules>().lambda().eq(KqglAssoOvertimeRules::getId, timeran.getOvertimeRulesId()).eq(KqglAssoOvertimeRules::getOrgCode, userBean.getOrgCode()));
					if(rul != null) {
						if(rul.getIsWorkovertime() == 1) {
							CompensateDto com = CompensateDto.builder().build();
							com.setId(1);
							com.setValue("工作日加班");
							coms.add(com);
						}
						if(rul.getIsRestovertime() == 1) {
							CompensateDto com2 = CompensateDto.builder().build();
							com2.setId(2);
							com2.setValue("休息日加班");
							coms.add(com2);
						}
						if(rul.getIsHolidays() == 1) {
							CompensateDto com3 = CompensateDto.builder().build();
							com3.setId(3);
							com3.setValue("节假日加班");
							coms.add(com3);
						}
lal committed
2253 2254 2255
					}
				}
			}
lal committed
2256 2257 2258
			return ResultUtil.data(coms, "操作成功!");
		}else {
			return ResultUtil.success("操作失败,请先加入考勤组");
lal committed
2259
		}
ilal committed
2260
	}
2261 2262


lal committed
2263 2264 2265 2266 2267 2268 2269
	/**************************/
	/**
	 * 	查询列表-加班补偿方式   id:
	 */
	@GetMapping(value = "/list_compensate/{id}")
	@ApiOperation(value = "222: 查询列表-加班补偿方式", httpMethod = "GET", notes = " 查询列表-加班补偿方式")
	public Result<Object> selectListCompensate(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
2270

lal committed
2271 2272
		KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userBean.getEmpNum(),userBean.getOrgCode()); //考勤组信息
		if(attgro != null) {
2273

lal committed
2274 2275 2276 2277 2278 2279 2280 2281 2282
			List<CompensateDto> coms = new ArrayList<CompensateDto>();
			KqglAssoYhkqz yhd = KqglAssoYhkqz.builder().build().selectOne(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, userBean.getEmpNum()).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
			if(yhd != null) {
				KqglAssoOvertimeRange timeran = KqglAssoOvertimeRange.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, yhd.getKqzid()));
				if(timeran != null) {
					KqglAssoOvertimeRules rul = KqglAssoOvertimeRules.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRules>().lambda().eq(KqglAssoOvertimeRules::getId, timeran.getOvertimeRulesId()));
					if(rul != null) {
						if(id == 1) {
							if(rul.getIsWorkovertime() == 1 && rul.getWorkSwitch() == 1) {
lal committed
2283
								if(!("0").equals(rul.getWorkOne())) {
lal committed
2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294
									CompensateDto com = CompensateDto.builder().build();
									com.setId(1);
									com.setValue("调休");
									coms.add(com);
								}
								if(rul.getWorkTwo() != 0) {
									CompensateDto com2 = CompensateDto.builder().build();
									com2.setId(2);
									com2.setValue("加班费");
									coms.add(com2);
								}
lal committed
2295
								if(!("0").equals(rul.getWorkThree())) {
lal committed
2296 2297
									CompensateDto com3 = CompensateDto.builder().build();
									com3.setId(3);
lal committed
2298
									com3.setValue("调休");
lal committed
2299
									coms.add(com3);
2300

lal committed
2301 2302 2303 2304
									CompensateDto com4 = CompensateDto.builder().build();
									com4.setId(4);
									com4.setValue("加班费");
									coms.add(com4);
lal committed
2305 2306 2307 2308
								}
							}
						}else if(id == 2) {
							if(rul.getIsRestovertime() == 1 && rul.getRestSwitch() == 1) {
lal committed
2309
								if(!("0").equals(rul.getRestOne())) {
lal committed
2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320
									CompensateDto com = CompensateDto.builder().build();
									com.setId(1);
									com.setValue("调休");
									coms.add(com);
								}
								if(rul.getRestTwo() != 0) {
									CompensateDto com2 = CompensateDto.builder().build();
									com2.setId(2);
									com2.setValue("加班费");
									coms.add(com2);
								}
lal committed
2321
								if(!("0").equals(rul.getRestThree())) {
lal committed
2322 2323
									CompensateDto com3 = CompensateDto.builder().build();
									com3.setId(3);
lal committed
2324
									com3.setValue("调休");
lal committed
2325
									coms.add(com3);
2326

lal committed
2327 2328 2329 2330
									CompensateDto com4 = CompensateDto.builder().build();
									com4.setId(4);
									com4.setValue("加班费");
									coms.add(com4);
lal committed
2331 2332 2333 2334
								}
							}
						}else {
							if(rul.getIsHolidays() == 1 && rul.getHolidaysSwitch() == 1) {
lal committed
2335
								if(!("0").equals(rul.getHolidaysOne())) {
lal committed
2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346
									CompensateDto com = CompensateDto.builder().build();
									com.setId(1);
									com.setValue("调休");
									coms.add(com);
								}
								if(rul.getHolidaysTwo() != 0) {
									CompensateDto com2 = CompensateDto.builder().build();
									com2.setId(2);
									com2.setValue("加班费");
									coms.add(com2);
								}
lal committed
2347
								if(!("0").equals(rul.getHolidaysThree())) {
lal committed
2348 2349
									CompensateDto com3 = CompensateDto.builder().build();
									com3.setId(3);
lal committed
2350
									com3.setValue("调休");
lal committed
2351
									coms.add(com3);
2352

lal committed
2353 2354 2355 2356
									CompensateDto com4 = CompensateDto.builder().build();
									com4.setId(4);
									com4.setValue("加班费");
									coms.add(com4);
lal committed
2357 2358 2359
								}
							}
						}
2360

lal committed
2361 2362 2363
					}
				}
			}
2364

lal committed
2365 2366 2367 2368 2369
			return ResultUtil.data(coms, "操作成功!");
		}else {
			return ResultUtil.error("操作失败,请先加入考勤组");
		}
	}
2370 2371 2372 2373




lal committed
2374
	public AttendanceCardListDto MethodCall(int qyid,int userid,String date) throws ParseException {
2375

lal committed
2376
		AttendanceCardListDto attcar = new AttendanceCardListDto();
2377 2378 2379 2380 2381 2382 2383 2384
		String str = null;
		if(!("").equals(date)){
			str = date;
		}else{
			Date d = new Date();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			str = sdf.format(d);
		}
lal committed
2385 2386
//		 Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(str,"yyyy-MM-dd")).getTime();
//	     Long endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(str,"yyyy-MM-dd")).getTime();
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430

		KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息

		//pbfs:排班方式 1:固定排班;2:自由排班;3:自由工时
		if(attgro != null){//判断当前用户是否加入到考勤组
			//排班制
			KqglAssoPbmxDto jrpb = kqglassopbmxmapper.getScheduleSpecificAttendance(attgro.getId(),userid,str);
			//固定排班
			int week = Integer.valueOf(ClockInTool.dateToWeek(str));//4

			KqglAssoZhoupaiban atwek = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
					.eq(KqglAssoZhoupaiban::getType, week).ne(KqglAssoZhoupaiban::getBcid, 0));

			if(attgro.getPbfs() == 1){//固定排班
				if(atwek != null){//有固定周排班
					KqglAssoTeshu rest = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId())
							.eq(KqglAssoTeshu::getTsrq, str).eq(KqglAssoTeshu::getBcid, 0));
					if(rest != null){//今天休息  Sort返回0【特殊日期--休息】
						List<AttSchedule> atts = new ArrayList<AttSchedule>();
						AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
						atts.add(as);
						attcar.setAttsch(atts);
					}else{//今天上班
						KqglAssoBcsz bcz = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));

						if(bcz != null){
							Getshiftinformationbatch(bcz,attcar,str);
						}
					}
				}else{//必须打卡
					KqglAssoTeshu tsri = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId())
							.eq(KqglAssoTeshu::getTsrq, str).ne(KqglAssoTeshu::getBcid, 0));
					if(tsri != null){
						KqglAssoBcsz tsrq = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, tsri.getBcid()));
						if(tsrq!=null){
							Getshiftinformationbatch(tsrq,attcar,str);
						}
					}else{//休息
						List<AttSchedule> atts = new ArrayList<AttSchedule>();
						AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
						atts.add(as);
						attcar.setAttsch(atts);
					}
				}
lal committed
2431 2432
			}else if(attgro.getPbfs() == 2){//自由排班
				//未排班时,员工可选择班次打卡
lal committed
2433
//			    if(attgro.getIsXzbcdk() == 1){
2434
//			    	attcar.setOptscheduling(true);
lal committed
2435 2436 2437
//			    }else{
//			    	attcar.setOptscheduling(false);
//			    }
lal committed
2438 2439 2440 2441 2442 2443 2444
				if(jrpb != null){
					if(jrpb.getBcid() != 0){//有班次时("Bcid"不为0时)
						KqglAssoBcsz tsrq = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, jrpb.getBcid()));
						/**已简化**/
						Getshiftinformationbatch(tsrq,attcar,str);
					}else{//当天排班为休息
						List<AttSchedule> atts1 = new ArrayList<AttSchedule>();
2445 2446 2447
						AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
						atts1.add(as);
						attcar.setAttsch(atts1);
lal committed
2448 2449 2450 2451 2452
					}
				}
			}else{//自由工时
				KqglAssoZhoupaiban wekz = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
						.eq(KqglAssoZhoupaiban::getBcid, 0).eq(KqglAssoZhoupaiban::getType, week));
2453

lal committed
2454 2455 2456 2457
				if(wekz != null){//
					String dada = str+" "+attgro.getKqkssjTime()+":00";
					attcar.setStapclotime(Long.valueOf(ClockInTool.dateToStamp(dada)));
				}
2458

lal committed
2459 2460 2461 2462
				if(!("").equals(attgro.getJbzdsc())){
					attcar.setCanpunchworkdate(Double.valueOf(attgro.getJbzdsc()));//上班打卡后多久大下班卡
				}
			}
2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516
			if(jrpb != null || atwek != null){
				KqglAssoBcsz shif = KqglAssoBcsz.builder().build();
				if(attgro.getPbfs() == 1){
					shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));
				}else if(attgro.getPbfs() == 2){
					shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, jrpb.getBcid()));
				}

				if(shif != null){
					if(shif.getIsXbdk() == 1){
						attcar.setNoclockout(true);// 下班不用打卡
					}else{
						attcar.setNoclockout(false);// 下班不用打卡
					}
					attcar.setAllowlate(shif.getYxcdfzs());// 允许迟到分钟数
					attcar.setSeriouslate(shif.getYzcdfzs());// 严重迟到分钟数
					attcar.setAbsenteeismlate(shif.getKgcdfzs());// 旷工迟到分钟数
					if(shif.getIsWzwd() == 1){
						attcar.setIslatelate(true);// 晚走晚到
						List<AttLateLate> atwzwd = new ArrayList<AttLateLate>();
						int p = 0;
						if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1())){p = 2;}
						if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1()) && !("").equals(shif.getXbwz2()) && !("").equals(shif.getSbwd2())){p = 4;}
						if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1()) && !("").equals(shif.getXbwz2()) && !("").equals(shif.getSbwd2()) && !("").equals(shif.getXbwz3()) && !("").equals(shif.getSbwd3())){p = 6;}
						AttLateLate ala = AttLateLate.builder().build();
						ala.setLatewalk(shif.getXbwz1());
						ala.setArrivelate(shif.getSbwd1());
						atwzwd.add(ala);
						if(p == 4 || p == 6){
							AttLateLate alat = AttLateLate.builder().build();
							alat.setLatewalk(shif.getXbwz2());
							alat.setArrivelate(shif.getSbwd2());
							atwzwd.add(alat);
						}
						if(p == 6){
							AttLateLate alas = AttLateLate.builder().build();
							alas.setLatewalk(shif.getXbwz3());
							alas.setArrivelate(shif.getSbwd3());
							atwzwd.add(alas);
						}
						attcar.setAttlat(atwzwd);
					}else{
						attcar.setIslatelate(false);// 晚走晚到
					}
				}
			}
			attcar.setAttgrouptype(attgro.getPbfs());//1:固定排班;2:自由排班;3:自由工时
		}else{
			attcar.setAttgrouptype(0);//1:固定排班;2:自由排班;3:自由工时
		}
		return attcar;
	}


lal committed
2517 2518 2519 2520 2521 2522
	public void Getshiftinformationbatch(KqglAssoBcsz shiftm,AttendanceCardListDto attcar,String str){
		int isXbdk1Cr = shiftm.getIsXbdk1Cr();//下班1是否次日(0:否;1:是)
		int isSbdk2Cr = shiftm.getIsSbdk2Cr();//上班2是否次日(0:否;1:是)
		int isXbdk2Cr = shiftm.getIsXbdk2Cr();//下班2是否次日(0:否;1:是)
		int isSbdk3Cr = shiftm.getIsSbdk3Cr();//上班3是否次日(0:否;1:是)
		int isXbdk3Cr = shiftm.getIsXbdk3Cr();//下班3是否次日(0:否;1:是)
2523

lal committed
2524 2525
		//次日专用
		String next_day = ClockInTool.requires_extra_times(str,1,2,1);
2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630

		List<AttSchedule> atts = new ArrayList<AttSchedule>();
		if(shiftm.getSxbcs() == 1 || shiftm.getSxbcs() == 2 || shiftm.getSxbcs() == 3){//1次上下班
			for(int o=0;o<2;o++){
				if(o==0){
					AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(1).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbdk1()+":00").replaceAll("\r|\n", ""))))
							.starttime(("").equals(shiftm.getSbqjks1()) || shiftm.getSbqjks1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjks1()+":00").replaceAll("\r|\n", ""))))
							.endtime(("").equals(shiftm.getSbqjjs1()) || shiftm.getSbqjjs1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjjs1()+":00").replaceAll("\r|\n", ""))))
							.nextday(0).build();

					atts.add(as);
				}else{
					//次日
					if(isXbdk1Cr > 0) {
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(2).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbdk1()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getXbqjks1()) || shiftm.getXbqjks1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjks1()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getXbqjjs1()) || shiftm.getXbqjjs1() ==null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjjs1()+":00").replaceAll("\r|\n", ""))))
								.nextday(1).build();
						atts.add(as);
					}else {
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(2).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbdk1()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getXbqjks1()) || shiftm.getXbqjks1() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjks1()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getXbqjjs1()) || shiftm.getXbqjjs1() ==null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjjs1()+":00").replaceAll("\r|\n", ""))))
								.nextday(0).build();
						atts.add(as);
					}

				}
			}
			attcar.setAttsch(atts);
		}
		if(shiftm.getSxbcs() == 2 || shiftm.getSxbcs() == 3){//2次上下班
			for(int o=0;o<2;o++){
				if(o==0){
					if(isSbdk2Cr > 0) {//次日
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(3).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbdk2()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getSbqjks2())|| shiftm.getSbqjks2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjks2()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getSbqjjs2()) || shiftm.getSbqjjs2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjjs2()+":00").replaceAll("\r|\n", ""))))
								.nextday(1).build();
						atts.add(as);
					}else {
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(3).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbdk2()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getSbqjks2())|| shiftm.getSbqjks2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjks2()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getSbqjjs2()) || shiftm.getSbqjjs2()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjjs2()+":00").replaceAll("\r|\n", ""))))
								.nextday(0).build();
						atts.add(as);
					}

				}else{
					if(isXbdk2Cr > 0) {//次日
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(4).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbdk2()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getXbqjks2()) || shiftm.getXbqjks2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjks2()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getXbqjjs2()) || shiftm.getXbqjjs2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjjs2()+":00").replaceAll("\r|\n", ""))))
								.nextday(1).build();
						atts.add(as);
					}else {
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(4).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbdk2()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getXbqjks2()) || shiftm.getXbqjks2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjks2()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getXbqjjs2()) || shiftm.getXbqjjs2()== null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjjs2()+":00").replaceAll("\r|\n", ""))))
								.nextday(0).build();
						atts.add(as);
					}

				}
			}
			attcar.setAttsch(atts);
		}
		if(shiftm.getSxbcs() == 3){//3次上下班
			for(int o=0;o<2;o++){
				if(o==0){
					if(isSbdk3Cr > 0) {//次日
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(5).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbdk3()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getSbqjks3()) || shiftm.getSbqjks3() == null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjks3()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getSbqjjs3()) || shiftm.getSbqjjs3() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getSbqjjs3()+":00").replaceAll("\r|\n", ""))))
								.nextday(1).build();
						atts.add(as);
					}else {
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(5).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbdk3()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getSbqjks3()) || shiftm.getSbqjks3() == null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjks3()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getSbqjjs3()) || shiftm.getSbqjjs3() == null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getSbqjjs3()+":00").replaceAll("\r|\n", ""))))
								.nextday(0).build();
						atts.add(as);
					}

				}else{
					if(isXbdk3Cr > 0) {//次日
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(6).time(Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbdk3()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getXbqjks3()) || shiftm.getXbqjks3()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjks3()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getXbqjjs3()) || shiftm.getXbqjjs3() ==null? 0 : Long.valueOf(ClockInTool.dateToStamp((next_day+" "+shiftm.getXbqjjs3()+":00").replaceAll("\r|\n", ""))))
								.nextday(1).build();
						atts.add(as);
					}else {
						AttSchedule as = AttSchedule.builder().id(shiftm.getId()).sort(6).time(Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbdk3()+":00").replaceAll("\r|\n", ""))))
								.starttime(("").equals(shiftm.getXbqjks3()) || shiftm.getXbqjks3()== null ? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjks3()+":00").replaceAll("\r|\n", ""))))
								.endtime(("").equals(shiftm.getXbqjjs3()) || shiftm.getXbqjjs3() ==null? 0 : Long.valueOf(ClockInTool.dateToStamp((str+" "+shiftm.getXbqjjs3()+":00").replaceAll("\r|\n", ""))))
								.nextday(0).build();
						atts.add(as);
					}

				}
			}
			attcar.setAttsch(atts);
		}
	}

lal committed
2631 2632 2633 2634
	/**
	 * 	工作台日历数据
	 * @param userBean
	 * @return
2635
	 * @throws ParseException
lal committed
2636 2637 2638 2639
	 */
	@GetMapping(value = "/workbench_calendar/{date}")
	@ApiOperation(value = "999: 工作台日历数据", httpMethod = "GET", notes = "查询数据")
	public Result<Object> Workbench_calendar(@CurrentUser UserBean userBean,@PathVariable("date") String date) throws ParseException {
2640 2641
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式

lal committed
2642
		String current = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
lal committed
2643
		String yue = new SimpleDateFormat("yyyy-MM").format(new Date());
2644

lal committed
2645
		SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM");
2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669
		Date date_;
		try {
			date_ = df1.parse(date);
		}catch (ParseException e){
			e.printStackTrace();
			date_=new Date();
		}
		int dateOne= ClockInTool.getYearMonth(date_);
		int dangqian = ClockInTool.getYearMonth(new Date());//当前

		List<WorkbenchCalendarDto> workcal = new ArrayList<WorkbenchCalendarDto>();

		if(dateOne<=dangqian){
			Long startMonth = 0l;
			Long endMonth = 0l;
			if(date == null || ("").equals(date)) {
				Calendar c = Calendar.getInstance();
				c.add(Calendar.MONTH, 0);
				c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
				String first = mat.format(c.getTime());
				startMonth = DateUtil.getStartTime(0,DateUtil.getStringTime(first,"yyyy-MM-dd")).getTime();

				endMonth = new Date().getTime();

lal committed
2670
//    	        //获取当前月最后一天
2671 2672
//    	        Calendar ca = Calendar.getInstance();
//    	        ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
lal committed
2673 2674
//    	        String last = mat.format(ca.getTime());
//    	        endMonth = DateUtil.getnowEndTime(23,DateUtil.getStringTime(last,"yyyy-MM-dd")).getTime();
2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696
			}else {
				String time = date+"-01";
				String sdaet = ClockInTool.getMinMonthDate(time);
				startMonth = ClockInTool.getStartTime(0,ClockInTool.getStringTime(sdaet,"yyyy-MM-dd")).getTime();
				String edate = ClockInTool.getMaxMonthDate(time);
				endMonth = ClockInTool.getnowEndTime(23,ClockInTool.getStringTime(edate,"yyyy-MM-dd")).getTime();

				if(date.equals(yue)) {
					endMonth = new Date().getTime();
				}

			}

			String[] rangeArray=ClockInTool.listToString(ClockInTool.getDays(df.format(startMonth),df.format(endMonth))).split(";");//目前为止所有日期


			String[] range=rangeArray[0].split(",");

			KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userBean.getEmpNum(),userBean.getOrgCode()); //考勤组信息

			int bcid = 0;

lal committed
2697
//    		List<WorkbenchCalendarDto> workcal = new ArrayList<WorkbenchCalendarDto>();
2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782
			for(String num : range) {
				Long start_time = DateUtil.getStartTime(0,DateUtil.getStringTime(num,"yyyy-MM-dd")).getTime();
				Long end_time = DateUtil.getnowEndTime(23,DateUtil.getStringTime(num,"yyyy-MM-dd")).getTime();

				WorkbenchCalendarDto wocal = WorkbenchCalendarDto.builder().build();
				wocal.setDate(num);
				if(attgro != null) {//有无考勤组
					AttendanceCardListDto attdate = MethodCall(userBean.getOrgCode(),userBean.getEmpNum(),num);//获取当天所打卡班次
					List<AttSchedule> ashss = attdate.getAttsch();//获取今天应打卡时间

					if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {//班次不为空

						if(date == null || ("").equals(date)) {//未输入  当月
							if(current.equals(num)) {
								bcid = ashss.get(0).getId();//班次id
							}
						}else {//输入
							if(date.equals(yue)) {//输入为当月
								if(current.equals(num)) {
									bcid = ashss.get(0).getId();//班次id
								}
							}else {//输入不是当月
								String time = date+"-01";
								if(time.equals(num)) {
									bcid = ashss.get(0).getId();//班次id
								}
							}
						}

						KqglAssoBcsz bcsts = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, ashss.get(0).getId()));

						if(ashss.get(0).getId() != 0) {
							KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
									.ge(KqglAssoDkmx::getDksj, start_time).le(KqglAssoDkmx::getDksj, end_time));
							if(dkmc != null) {
								if(attdate.getAttsch().size() == 2 || attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
									if(dkmc.getSbdk1() != null && dkmc.getSbdk1jg() == 0 && dkmc.getXbdk1() != null && dkmc.getXbdk1jg() == 0) {
										wocal.setCalendar_status(1);//打卡正常
									}else {
										if(dkmc.getXbdk1() == null && attdate.getAttsch().size() == 2) {
											if(bcsts.getIsXbdk()==1) {//下班不用打卡
												wocal.setCalendar_status(1);//打卡正常
											}else {
												wocal.setCalendar_status(3);//打卡异常
											}
										}else {
											wocal.setCalendar_status(3);//打卡异常
										}

									}
								}

								if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
									if(dkmc.getSbdk2() != null && dkmc.getSbdk2jg() == 0 && dkmc.getXbdk2() != null && dkmc.getXbdk2jg() == 0) {
										wocal.setCalendar_status(1);//打卡正常
									}else {
										if(dkmc.getXbdk2() == null && attdate.getAttsch().size() == 4) {
											if(bcsts.getIsXbdk()==1) {//下班不用打卡
												wocal.setCalendar_status(1);//打卡正常
											}else {
												wocal.setCalendar_status(3);//打卡异常
											}
										}else {
											wocal.setCalendar_status(3);//打卡异常
										}

									}
								}

								if(attdate.getAttsch().size() == 6) {
									if(dkmc.getSbdk3() != null && dkmc.getSbdk3jg() == 0 && dkmc.getXbdk3() != null && dkmc.getXbdk3jg() == 0) {
										wocal.setCalendar_status(1);//打卡正常
									}else {
										if(dkmc.getXbdk3() == null && attdate.getAttsch().size() == 6) {
											if(bcsts.getIsXbdk()==1) {//下班不用打卡
												wocal.setCalendar_status(1);//打卡正常
											}else {
												wocal.setCalendar_status(3);//打卡异常
											}
										}else {
											wocal.setCalendar_status(3);//打卡异常
										}
									}
								}

ilal committed
2783 2784 2785 2786 2787
//    		    				KqglAssoRelationSummary asssum = KqglAssoRelationSummary.builder().build().selectOne(new QueryWrapper<KqglAssoRelationSummary>().lambda().eq(KqglAssoRelationSummary::getUserId, userBean.getEmpNum())
//    		    						.eq(KqglAssoRelationSummary::getAppTime, num).last("LIMIT 1"));
//    		    				if(asssum != null) {
//    		    					wocal.setCalendar_status(2);//事务(请假,加班,调休,出差)
//    		    				}
2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851
							}else {
								wocal.setCalendar_status(3);//打卡异常
							}


							//事务(请假,加班,调休,出差)
							KqglAssoRelationSummary asssum = KqglAssoRelationSummary.builder().build().selectOne(new QueryWrapper<KqglAssoRelationSummary>().lambda().eq(KqglAssoRelationSummary::getUserId, userBean.getEmpNum())
									.eq(KqglAssoRelationSummary::getAppTime, num).last("LIMIT 1"));
							if(asssum != null) {
								if(asssum.getApprovalType() == 5) {//补卡
									wocal.setCalendar_status(1);//打卡正常
								}else {
									wocal.setCalendar_status(2);//事务(请假,加班,调休,出差)
								}

								//0:无;1:事假;2:调休;3:病假;4:年假;5:产假;6:陪产假;7:婚假;8:例假;9:丧假;10:哺乳假;11:加班;12:出差;13:外出
								if(asssum.getApprovalType() == 1) {
									wocal.setCalendar_status_type(11);
								}else if(asssum.getApprovalType() == 2) {
									//请假
									KqglAssoLeaveRules rul = KqglAssoLeaveRules.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getId,asssum.getLeaveTypeId()));
									if(rul.getRulesType() == 1) {
										wocal.setCalendar_status_type(1);
									}else if(rul.getRulesType() == 2) {
										wocal.setCalendar_status_type(2);
									}else if(rul.getRulesType() == 3) {
										wocal.setCalendar_status_type(3);
									}else if(rul.getRulesType() == 4) {
										wocal.setCalendar_status_type(4);
									}else if(rul.getRulesType() == 5) {
										wocal.setCalendar_status_type(5);
									}else if(rul.getRulesType() == 6) {
										wocal.setCalendar_status_type(6);
									}else if(rul.getRulesType() == 7) {
										wocal.setCalendar_status_type(7);
									}else if(rul.getRulesType() == 8) {
										wocal.setCalendar_status_type(8);
									}else if(rul.getRulesType() == 9) {
										wocal.setCalendar_status_type(9);
									}else if(rul.getRulesType() == 10) {
										wocal.setCalendar_status_type(10);
									}
								}else if(asssum.getApprovalType() == 3) {
									wocal.setCalendar_status_type(12);
								}else if(asssum.getApprovalType() == 4) {
									wocal.setCalendar_status_type(13);
								}
							}


						}else {
							wocal.setCalendar_status(4);//休息
						}
					}else {
						wocal.setCalendar_status(0);//无排班
					}
				}else {
					wocal.setCalendar_status(0);//无排班
				}
				workcal.add(wocal);
			}

			List<CalendarPunchDetailsDto> detailed = new ArrayList<CalendarPunchDetailsDto>();
			CalendarPunchDetailsDto dets = CalendarPunchDetailsDto.builder().build();
lal committed
2852 2853
//    	    dets.setDate(current);
//    	    detailed.add(dets1);
2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879

			Long starttime = DateUtil.getStartTime(0,DateUtil.getStringTime(current,"yyyy-MM-dd")).getTime();
			Long endtime = DateUtil.getnowEndTime(23,DateUtil.getStringTime(current,"yyyy-MM-dd")).getTime();

			KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build();
			if(date == null || ("").equals(date)) {//未输入  当月
				dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
						.ge(KqglAssoDkmx::getDksj, starttime).le(KqglAssoDkmx::getDksj, endtime));
				dets.setDate(current);
			}else {//输入
				if(date.equals(yue)) {//输入为当月
					dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
							.ge(KqglAssoDkmx::getDksj, starttime).le(KqglAssoDkmx::getDksj, endtime));
					dets.setDate(current);
				}else {//输入不是当月
					String time = date+"-01";
					Long starttime_ = DateUtil.getStartTime(0,DateUtil.getStringTime(time,"yyyy-MM-dd")).getTime();
					Long endtime_ = DateUtil.getnowEndTime(23,DateUtil.getStringTime(time,"yyyy-MM-dd")).getTime();

					dets.setDate(time);

					dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
							.ge(KqglAssoDkmx::getDksj, starttime_).le(KqglAssoDkmx::getDksj, endtime_));
				}
			}

lal committed
2880 2881
//    	    KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
//    				.ge(KqglAssoDkmx::getDksj, starttime).le(KqglAssoDkmx::getDksj, endtime));
2882 2883

			if(dkmc!=null && dkmc.getData() != null) {
lal committed
2884
//    	    	CalendarPunchDetailsDto dets = CalendarPunchDetailsDto.builder().build();
2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898
				dets.setSbdksj1(dkmc.getSbdk1() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getSbdk1())));
				dets.setSbdksj1jg(dkmc.getSbdk1jg());
				dets.setXbdksj1(dkmc.getXbdk1() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getXbdk1())));
				dets.setXbdksj1jg(dkmc.getXbdk1jg());

				dets.setSbdksj2(dkmc.getSbdk2() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getSbdk2())));
				dets.setSbdksj2jg(dkmc.getSbdk2jg());
				dets.setXbdksj2(dkmc.getXbdk2() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getXbdk2())));
				dets.setXbdksj2jg(dkmc.getXbdk2jg());

				dets.setSbdksj3(dkmc.getSbdk3() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getSbdk3())));
				dets.setSbdksj3jg(dkmc.getSbdk3jg());
				dets.setXbdksj3(dkmc.getXbdk3() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getXbdk3())));
				dets.setXbdksj3jg(dkmc.getXbdk3jg());
lal committed
2899
//    	    	detailed.add(dets);
2900 2901 2902 2903 2904
			}

			if(bcid > 0) {
				KqglAssoBcsz bcs = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, bcid));
				if(bcs != null) {
lal committed
2905
//    	    		CalendarPunchDetailsDto dets = CalendarPunchDetailsDto.builder().build();
2906 2907 2908 2909 2910 2911 2912
					dets.setClock_num(bcs.getSxbcs()*2);
					dets.setBcsbdk1(bcs.getSbdk1() == null ? "" : bcs.getSbdk1().replaceAll("\r|\n", ""));
					dets.setBcxbdk1(bcs.getXbdk1() == null ? "" : bcs.getXbdk1().replaceAll("\r|\n", ""));
					dets.setBcsbdk2(bcs.getSbdk2() == null ? "" : bcs.getSbdk2().replaceAll("\r|\n", ""));
					dets.setBcxbdk2(bcs.getXbdk2() == null ? "" : bcs.getXbdk2().replaceAll("\r|\n", ""));
					dets.setBcsbdk3(bcs.getSbdk3() == null ? "" : bcs.getSbdk3().replaceAll("\r|\n", ""));
					dets.setBcxbdk3(bcs.getXbdk3() == null ? "" : bcs.getXbdk3().replaceAll("\r|\n", ""));
lal committed
2913
//    	    		detailed.add(dets);
2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924
				}
			}
			detailed.add(dets);
			WorkbenchCalendarDto wocal1 = WorkbenchCalendarDto.builder().build();
			wocal1.setDetailed(detailed);

			workcal.add(wocal1);
		}



lal committed
2925 2926
		return ResultUtil.data(workcal, "操作成功!");
	}
2927 2928


lal committed
2929 2930 2931 2932 2933 2934 2935 2936 2937
	/**
	 * @param userBean
	 * @param date 日历年月日
	 * @return
	 * @throws ParseException
	 */
	@GetMapping(value = "/Calendar_punch_details/{date}")
	@ApiOperation(value = "999: 日历打卡详情", httpMethod = "GET", notes = "查询数据")
	public Result<Object> Calendar_punch_details(@CurrentUser UserBean userBean,@PathVariable("date") String date) throws ParseException {
2938

ilal committed
2939 2940 2941 2942 2943
		KqglMainKqz kqza = null;
		KqglAssoYhkqz yhz = KqglAssoYhkqz.builder().build().selectOne(new QueryWrapper<KqglAssoYhkqz>().lambda().eq(KqglAssoYhkqz::getUserid, userBean.getEmpNum()).eq(KqglAssoYhkqz::getQyid, userBean.getOrgCode()));
		if(yhz != null) {
			kqza = KqglMainKqz.builder().id(yhz.getKqzid()).build().selectById();
		}
2944

lal committed
2945
		AttendanceCardListDto attdate = MethodCall(userBean.getOrgCode(),userBean.getEmpNum(),date);//获取当天所打卡班次
2946

lal committed
2947 2948 2949
		List<AttSchedule> ashss = attdate.getAttsch();//获取今天应打卡时间
		int bcid = 0;
		if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {//班次不为空
2950
			bcid = ashss.get(0).getId();//班次id
lal committed
2951
		}
2952

lal committed
2953 2954
		List<DetailsofbusinessDto> ils = new ArrayList<DetailsofbusinessDto>();
		DetailsofbusinessDto iness = DetailsofbusinessDto.builder().build();
2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056


		List<CalendarPunchDetailsDto> detslist = new ArrayList<CalendarPunchDetailsDto>();
		CalendarPunchDetailsDto dets = CalendarPunchDetailsDto.builder().build();
		dets.setDate(date);
		Long starttime = DateUtil.getStartTime(0,DateUtil.getStringTime(date,"yyyy-MM-dd")).getTime();
		Long endtime = DateUtil.getnowEndTime(23,DateUtil.getStringTime(date,"yyyy-MM-dd")).getTime();
		KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
				.ge(KqglAssoDkmx::getDksj, starttime).le(KqglAssoDkmx::getDksj, endtime));
		if(dkmc!=null) {
			dets.setSbdksj1(dkmc.getSbdk1() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getSbdk1())));
			dets.setSbdksj1jg(dkmc.getSbdk1jg());
			dets.setXbdksj1(dkmc.getXbdk1() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getXbdk1())));
			dets.setXbdksj1jg(dkmc.getXbdk1jg());
			dets.setSbdksj2(dkmc.getSbdk2() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getSbdk2())));
			dets.setSbdksj2jg(dkmc.getSbdk2jg());
			dets.setXbdksj2(dkmc.getXbdk2() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getXbdk2())));
			dets.setXbdksj2jg(dkmc.getXbdk2jg());
			dets.setSbdksj3(dkmc.getSbdk3() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getSbdk3())));
			dets.setSbdksj3jg(dkmc.getSbdk3jg());
			dets.setXbdksj3(dkmc.getXbdk3() == null ? "" : ClockInTool.stampToDate3(String.valueOf(dkmc.getXbdk3())));
			dets.setXbdksj3jg(dkmc.getXbdk3jg());
		}

		if(kqza != null && kqza.getPbfs() == 1) {
			KqglAssoTeshu tss = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, kqza.getId()).eq(KqglAssoTeshu::getTsrq, date));
			if(tss != null) {
				bcid = tss.getBcid();
			}
		}

		if(bcid > 0) {
			KqglAssoBcsz bcs = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, bcid));
			if(bcs != null) {
				dets.setClock_num(bcs.getSxbcs()*2);
				dets.setBcsbdk1(bcs.getSbdk1() == null ? "" : bcs.getSbdk1().replaceAll("\r|\n", ""));
				dets.setBcxbdk1(bcs.getXbdk1() == null ? "" : bcs.getXbdk1().replaceAll("\r|\n", ""));
				dets.setBcsbdk2(bcs.getSbdk2() == null ? "" : bcs.getSbdk2().replaceAll("\r|\n", ""));
				dets.setBcxbdk2(bcs.getXbdk2() == null ? "" : bcs.getXbdk2().replaceAll("\r|\n", ""));
				dets.setBcsbdk3(bcs.getSbdk3() == null ? "" : bcs.getSbdk3().replaceAll("\r|\n", ""));
				dets.setBcxbdk3(bcs.getXbdk3() == null ? "" : bcs.getXbdk3().replaceAll("\r|\n", ""));
			}
		}
		detslist.add(dets);
		iness.setCaldet(detslist);//当天打卡详情

		KqglAssoOvertimeBasics bais = KqglAssoOvertimeBasics.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeBasics>().lambda().eq(KqglAssoOvertimeBasics::getOrgCode, userBean.getOrgCode()));
		String company = "";
		if(bais != null) {
			if(bais.getMinimumUnit() == 1) {
				company = "分钟";
			}else if(bais.getMinimumUnit() == 2) {
				company = "半小时";
			}else if(bais.getMinimumUnit() == 3) {
				company = "小时";
			}else if(bais.getMinimumUnit() == 4) {
				company = "半天";
			}else if(bais.getMinimumUnit() == 5) {
				company = "天";
			}
		}

		List<CalendarDetailsDto> tais = new ArrayList<CalendarDetailsDto>();


		List<KqglAssoRelationSummary> sums = KqglAssoRelationSummary.builder().build().selectList(new QueryWrapper<KqglAssoRelationSummary>().lambda().eq(KqglAssoRelationSummary::getUserId, userBean.getEmpNum())
				.eq(KqglAssoRelationSummary::getAppTime, date).eq(KqglAssoRelationSummary::getOrgCode, userBean.getOrgCode()));
		if(sums.size() > 0) {
			for(KqglAssoRelationSummary suu : sums) {
				CalendarDetailsDto ta = CalendarDetailsDto.builder().build();
				String content = "";
				if(suu.getApprovalType() == 1) {//加班
					ta.setAffair_type(1);
					content = suu.getStartTime()+"-"+suu.getEndTime()+"加班"+suu.getDuration()+company;
				}else if(suu.getApprovalType() == 2) {//请假
					ta.setAffair_type(2);
					content = suu.getStartTime()+"-"+suu.getEndTime()+"请假"+suu.getDuration()+"天";
				}else if(suu.getApprovalType() == 3) {//出差
					ta.setAffair_type(3);
					content = suu.getStartTime()+"-"+suu.getEndTime()+"出差"+suu.getDuration()+"天";
				}else if(suu.getApprovalType() == 4) {//外出
					ta.setAffair_type(4);
					content = suu.getStartTime()+"-"+suu.getEndTime()+"外出"+suu.getDuration()+"天";
				}else if(suu.getApprovalType() == 5) {//补卡
					ta.setAffair_type(5);
					ta.setStart_time(suu.getStartTime());
					content = suu.getStartTime()+"已补卡";
				}
				ta.setDuration(String.valueOf(suu.getDuration()));
				if(suu.getApprovalType() != 5) {
					ta.setStart_time(suu.getStartTime());
					ta.setEnd_time(suu.getEndTime());
				}
				ta.setContent(content);
				tais.add(ta);
			}
		}

		iness.setCalils(tais);

		ils.add(iness);

lal committed
3057 3058
		return ResultUtil.data(ils, "操作成功!");
	}
3059

lal committed
3060 3061
	@Autowired
	private KqglAssoRelationSummaryMapper kqglassorelationsummarymapper;
3062

lal committed
3063
	@GetMapping(value = "/worktable_attendance_from/{date}")
lal committed
3064
	@ApiOperation(value = "999:工作台考勤表格", httpMethod = "GET", notes = "查询数据")
lal committed
3065
	public Result<Object> worktable_attendance_from(@CurrentUser UserBean userBean,@PathVariable("date") String date) throws ParseException {
lal committed
3066
		CalendarTableDataDto tabl = CalendarTableDataDto.builder().build();
lal committed
3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078
		String belongyear = null;
		String belongmonth = null;
		String ttstr = null;//
		if(date == null || ("").equals(date)) {
			belongyear = new SimpleDateFormat("yyyy").format(new Date());
			belongmonth = new SimpleDateFormat("MM").format(new Date());
			ttstr = new SimpleDateFormat("yyyy-MM").format(new Date()).toString();//
		}else {
			belongyear = date.substring(0, 4);
			belongmonth = date.substring(5, 7);
			ttstr = date;
		}
lal committed
3079 3080
		//1:加班 2:请假 3:出差 4:外出 5:补卡
		KqglAssoRelationSummary qjj = kqglassorelationsummarymapper.selectTabledata(userBean.getEmpNum(), 2, ttstr);
3081

lal committed
3082 3083
		KqglAssoMonthPunchSummary punsum = KqglAssoMonthPunchSummary.builder().build().selectOne(new QueryWrapper<KqglAssoMonthPunchSummary>().lambda().eq(KqglAssoMonthPunchSummary::getNum, userBean.getEmpNum())
				.eq(KqglAssoMonthPunchSummary::getOrgCode, userBean.getOrgCode()).eq(KqglAssoMonthPunchSummary::getBelongYear, belongyear).eq(KqglAssoMonthPunchSummary::getBelongMonth, belongmonth));
3084

lal committed
3085
		BalanceSheetDataDto empye = kqglassomonthpunchsummarymapper.FormMonthlySummaryLeave(userBean.getOrgCode(), userBean.getEmpNum(), ttstr);
3086

lal committed
3087 3088
		tabl.setAttendance(punsum == null ? "" : String.valueOf(punsum.getDaysOnDuty()));// 应出勤
		tabl.setAttended(punsum == null ? "" : String.valueOf(punsum.getActualAttDays()));// 已出勤
lal committed
3089
		tabl.setLeave(qjj == null ? "" : String.valueOf(empye.getBalancedays()));// 请假*******************
lal committed
3090
		tabl.setLackworkcard(punsum == null ? "" : String.valueOf(punsum.getNumberWorkCardShortage()));// 上班缺卡
lal committed
3091 3092 3093
		tabl.setWorkovertime(punsum == null ? "" : String.valueOf(punsum.getTotalOvertimeHours()));// 加班
		tabl.setCompensatoryleave(punsum == null ? "" : String.valueOf(punsum.getDaysOff()));// 休息天数
		tabl.setEvection(punsum == null ? "" : String.valueOf(punsum.getLengthBusinessTrip()));// 出差
lal committed
3094
		tabl.setOffdutycardshortage(punsum == null ? "" : String.valueOf(punsum.getNumberDutyCardShortage()));// 下班缺卡
3095

lal committed
3096
		return ResultUtil.data(tabl, "操作成功!");
lal committed
3097
	}
3098 3099


lal committed
3100 3101 3102
	@PostMapping(value = "/isitused")
	@ApiOperation(value = "(加班规则)当选择加班规则范围中存在已使用的考勤组时,在用户确认后给用户一个提示,提示用户哪个考勤组已被使用,是否修改", httpMethod = "POST", notes = "接口发布说明")
	public Result<Object> Isitused(@CurrentUser UserBean userBean,@RequestBody KqglAssoOvertimeRulesDto overrules) {
3103

lal committed
3104
		String msg = "";
3105

lal committed
3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116
		String[] launchs = overrules.getApplyrangeid();
		if(launchs.length > 0) {
			for(int p=0;p<launchs.length;p++){
				KqglAssoOvertimeRange ran = KqglAssoOvertimeRange.builder().build().selectOne(new QueryWrapper<KqglAssoOvertimeRange>().lambda().eq(KqglAssoOvertimeRange::getAttgroupId, launchs[p]));
				if(ran != null) {
					KqglMainKqz kqz = KqglMainKqz.builder().build().selectOne(new QueryWrapper<KqglMainKqz>().lambda().eq(KqglMainKqz::getId, ran.getAttgroupId()));
					if(p == 0) {
						msg += kqz.getName();
					}else {
						msg += "、"+kqz.getName();
					}
3117

lal committed
3118 3119 3120
				}
			}
		}
3121

lal committed
3122 3123
		return ResultUtil.data(msg, "操作成功!");
	}
3124 3125 3126



lal committed
3127 3128 3129
	@GetMapping(value="/overtime_verification/{workovertimetype}/{starttime}/{endtime}")
	@ApiOperation(value = "加班验证", httpMethod = "GET", notes = "接口发布说明")
	public Result<Object> Overtime_verification(@CurrentUser UserBean userBean,@PathVariable("workovertimetype") Integer workovertimetype,
3130 3131
												@PathVariable("starttime") String starttime,@PathVariable("endtime") String endtime) {

lal committed
3132 3133 3134 3135 3136
		String msg = "";
		//workovertimetype:1=工作日加班  2=休息日加班 3=节假日加班
		Integer ending = 0;
		String starttime_ = ClockInTool.Str_Time_formatting(starttime,"yyyy-MM-dd");
		String endtime_ = ClockInTool.Str_Time_formatting(endtime,"yyyy-MM-dd");
3137

lal committed
3138 3139 3140 3141
		if((starttime_).equals(endtime_)) {
			try {
				AttendanceCardListDto attdate = MethodCall(userBean.getOrgCode(),userBean.getEmpNum(),starttime_);//获取当天所打卡班次
				List<AttSchedule> ashss = attdate.getAttsch();//获取今天应打卡时间
3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153
				if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {//班次不为空
					if(ashss.get(0).getId() != 0) {
						//工作日
						ending = 1;
					}else {
						//休息
						ending = 2;
					}
				}else {
					//未排班
					ending = 99;
				}
lal committed
3154 3155 3156
			} catch (ParseException e) {
				e.printStackTrace();
			}
3157

lal committed
3158 3159 3160 3161 3162 3163 3164 3165
		}else {//不同日期
			try {
				AttendanceCardListDto attdateone = MethodCall(userBean.getOrgCode(),userBean.getEmpNum(),starttime_);//获取当天所打卡班次
				AttendanceCardListDto attdatetwo = MethodCall(userBean.getOrgCode(),userBean.getEmpNum(),endtime_);//获取当天所打卡班次
				List<AttSchedule> ashone = attdateone.getAttsch();//获取今天应打卡时间
				List<AttSchedule> ashtwo = attdatetwo.getAttsch();//获取今天应打卡时间
				if(EmptyUtil.isNotEmpty(attdateone.getAttsch()) && EmptyUtil.isNotEmpty(attdatetwo.getAttsch())) {//班次不为空
					if(ashone.get(0).getId() != 0 && ashtwo.get(0).getId() != 0) {
3166 3167 3168 3169 3170 3171
						//工作日
						ending = 1;
					}else {
						//休息
						ending = 2;
					}
lal committed
3172 3173
				}else {
					//未排班
3174
					ending = 99;
lal committed
3175 3176 3177 3178 3179
				}
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
3180

lal committed
3181 3182 3183 3184
		if(ending != workovertimetype) {
			//所选日期范围与加班类型不匹配,请重新选择
			msg = "所选日期范围与加班类型不匹配,请重新选择";
		}
3185

lal committed
3186 3187 3188 3189
		if(ending == 99) {
			//所选日期范围暂无排班,请联系管理员
			msg = "所选日期范围暂无排班,请联系管理员";
		}
3190

lal committed
3191 3192
		return ResultUtil.data(msg,"操作成功!");
	}
3193 3194


lal committed
3195
	@GetMapping(value = "/Weekly_attendance_data/{date}")
lal committed
3196
	@ApiOperation(value = "考勤周数据--app接口", httpMethod = "GET", notes = "查询数据")
lal committed
3197
	public Result<Object> Weekly_attendance_data(@CurrentUser UserBean userBean,@PathVariable("date") String date) throws ParseException {
3198 3199


lal committed
3200 3201
		return ResultUtil.data(null,"操作成功!");
	}
3202 3203


ilal committed
3204 3205 3206 3207 3208 3209 3210
	/**
	 * 	删除考勤机
	 */
	@DeleteMapping(value = "/attendance/{code}")
	@ApiOperation(value = "删除考勤机", httpMethod = "DELETE", notes = "接口发布说明")
	@ApiOperationSupport(order = 3)
	public Result<Integer> DeleteAttendance(@PathVariable("code") String code) {
3211

ilal committed
3212 3213
		KqglAssoKqj kqj = KqglAssoKqj.builder().build().selectOne(new QueryWrapper<KqglAssoKqj>().lambda().eq(KqglAssoKqj::getCode, code));
		int kqjid = kqj.getId();
3214

ilal committed
3215 3216 3217 3218
		if(KqglAssoKqj.builder().id(kqjid).build().deleteById()) {
			KqglAssoYhsb.builder().build().delete(new QueryWrapper<KqglAssoYhsb>().lambda().eq(KqglAssoYhsb::getKqjid, kqjid));
			KqglAssoKqjgly.builder().build().delete(new QueryWrapper<KqglAssoKqjgly>().lambda().eq(KqglAssoKqjgly::getKqjid, kqjid));
		}
3219

ilal committed
3220 3221
		return ResultUtil.data(null,"操作成功!");
	}
3222 3223 3224 3225 3226





ilal committed
3227 3228
	@Value("${config-8timer.environmental-science}")
	public String environmental_science;
3229

ilal committed
3230
	public void Logoutput(String science) {
3231

ilal committed
3232
		if(!("pro").equals(environmental_science)) {
3233

ilal committed
3234 3235 3236 3237
			System.out.println(science);
		}else {
			System.out.println("");
		}
3238

ilal committed
3239
	}
3240 3241 3242



ilal committed
3243
}