Commit a23a0388 by ilal Committed by chenzg

提交

parent e702a93d
...@@ -5068,881 +5068,6 @@ public class AttController { ...@@ -5068,881 +5068,6 @@ public class AttController {
return ResultUtil.success("成功"); return ResultUtil.success("成功");
} }
@GetMapping(value="/synchrotime/{code}")
@ApiOperation(value = "考勤机一键同步", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 54)
public Result<AttemacDto> SynchronizationTime(@CurrentUser UserBean userBean,@PathVariable("code") String code) {
String sNowTxt = DateUtil.getStringFormat(System.currentTimeMillis(),"yyyyMMddHHmmss");
JSONObject vResultJson = new JSONObject();
vResultJson.put("time", sNowTxt);
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command;
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("cmd", "SET_TIME");
params.add("devid", code);
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
try {
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
} catch (RestClientException e) {
// e.printStackTrace();
System.err.println("提示:考勤机服务出错");
return ResultUtil.success("失败");
}
return ResultUtil.success("成功");
}
/**
* 移除考勤机管理员
*/
@PostMapping(value = "/removeadministrator/{kqjid}/{id}")
@ApiOperation(value = "移除考勤机管理员", httpMethod = "POST", notes = "接口发布说明")
@ApiOperationSupport(order = 55)
public Result<Void> RemoveAdministrator(@PathVariable int kqjid,@PathVariable int id, @RequestBody Map<String,String> mmd) {
String[] xgyh = mmd.get("a").split(",");
if(xgyh.length > 0){
for(int a=0;a<xgyh.length;a++){
AttendanceMachine kqj = attendancemachineservice.selectByPrimaryKey(kqjid);//查询考勤机“序列号”
JSONObject vResultJson = new JSONObject();
vResultJson.put("user_id", xgyh[a]);
vResultJson.put("user_privilege", "USER");
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command;
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("cmd", "SET_USER_INFO");
params.add("devid", kqj.getCode());
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
UserEquiRelation kqjry = new UserEquiRelation();
kqjry.setId(id);
kqjry.setIsGly(0);
userequirelationmapper.updateByPrimaryKeySelective(kqjry);
}
}
return ResultUtil.success("成功");
}
@GetMapping(value="/aircraftmembers/{id}")//****/
@ApiOperation(value = "考勤机成员", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 56)
public ResponseResult selectAircraftMembers(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) {
Integer orgCode = userBean.getOrgCode();
List<MachinememberDto> kqjcys = userequirelationmapper.selectAircraftMembers(id,orgCode);
return new ResponseResult().success("考勤机成员", kqjcys);
}
// asDevId //考勤机编号
// asUserId //打卡用户id
// asVerifyMode //打卡方式 1:指纹 20:人脸
// asIOMode
// sStdIoTime //打卡时间
@PostMapping(value = "/punchclock")
@ApiOperation(value = "考勤机打卡", httpMethod = "POST", notes = "接口发布说明")
public ResponseResult punchclock(@RequestParam String json) {
JSONObject jsonArray = new JSONObject(json);
String asDevId = jsonArray.get("asDevId").toString();
String asUserId = jsonArray.get("asUserId").toString();
String asVerifyMode = jsonArray.get("asVerifyMode").toString();
String asIOMode = "0";
String sStdIoTime = jsonArray.get("sStdIoTime").toString();
AttendanceMachine kqjdev = attendancemachineservice.selectByQyidDev(asDevId);
/***********************************************************考勤机打卡(开始)********************************************************************************************/
YgglMainEmp user = new LambdaQueryChainWrapper<YgglMainEmp>(ygglmainempmapper).eq(YgglMainEmp::getEmpNum, asUserId).eq(YgglMainEmp::getOrgCode, kqjdev.getQyid()).one();
if(user != null) {
int qyid = user.getOrgCode();//坏小孩【企业id】
int userid = user.getEmpNum();//用户id
AttendanceGroup attgro = attendancegroupservice.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
//pbfs;// 排班方式 1:固定排班;2:自由排班;3:自由工时
if(attgro != null) {
List<AttGroupBinPunchMode> kqjs = attgroupbinpunchmodeservice.selectMachineByKqzId(attgro.getId());//该考勤组所绑定的考勤机
if(kqjs.size() > 0) {
long time_ = 0;
try {
time_ = DateUtil.getStringTime(sStdIoTime, "yyyy-MM-dd HH:mm:ss");
} catch (ParseException e1) {
e1.printStackTrace();
}//打卡时间戳
String putime = new SimpleDateFormat("yyyy-MM-dd").format(time_);//转换打卡时间格式
Long startDate = 0l;//打卡当天开始时间
Long endDate = 0l;//打卡当天结束时间
try {
startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
int dkmx = 0;
PunchCardDetails dkmc = punchcarddetailsservice.SingleAttendanceDays(userid,startDate,endDate);//查询打卡当天是否有记录
AttendanceCardList attdate = MethodCall(qyid,userid,putime);
ClockCollectData clockt = new ClockCollectData();
long starttime1 = 0; long starttime1ks = 0; long starttime1js = 0;
long endtime1 = 0; long endtime1ks = 0; long endtime1js = 0;
long starttime2 = 0; long starttime2ks = 0; long starttime2js = 0;
long endtime2 = 0; long endtime2ks = 0; long endtime2js = 0;
long starttime3 = 0; long starttime3ks = 0; long starttime3js = 0;
long endtime3 = 0; long endtime3ks = 0; long endtime3js = 0;
if(attdate.getAttsch().size() > 0) {
List<AttSchedule> ash = attdate.getAttsch();
int y = 0;
clockt.setShifid(ash.get(y).getId());
if(attdate.getAttsch().size() == 2 || attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
starttime1 = ash.get(0).getTime();
starttime1ks = ash.get(0).getStarttime();
starttime1js = ash.get(0).getEndtime();
endtime1 = ash.get(1).getTime();
endtime1ks = ash.get(1).getStarttime();
endtime1js = ash.get(1).getEndtime();
}
if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
starttime2 = ash.get(2).getTime();
starttime2ks = ash.get(2).getStarttime();
starttime2js = ash.get(2).getEndtime();
endtime2 = ash.get(3).getTime();
endtime2ks = ash.get(3).getStarttime();
endtime2js = ash.get(3).getEndtime();
}
if(attdate.getAttsch().size() == 6) {
starttime3 = ash.get(4).getTime();
starttime3ks = ash.get(4).getStarttime();
starttime3js = ash.get(4).getEndtime();
endtime3 = ash.get(5).getTime();
endtime3ks = ash.get(5).getStarttime();
endtime3js = ash.get(5).getEndtime();
}
}
long punchcardtime = 0;//应打卡时间
long punchstart = 0;//应打卡开始时间
long punchend = 0;//应打卡结束时间
int atttype = 0;
if(dkmc == null) {//上班1 ****新增
punchcardtime = starttime1;
punchstart = starttime1ks;
punchend = starttime1js;
atttype = 1;
}else {
if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() == null)){ //下班1
punchcardtime = endtime1;
punchstart = endtime1ks;
punchend = endtime1js;
atttype = 2;
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() == null)){ //上班2
punchcardtime = starttime2;
punchstart = starttime2ks;
punchend = starttime2js;
atttype = 3;
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (!("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() != null) && (("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() == null)){ //下班2
punchcardtime = endtime2;
punchstart = endtime2ks;
punchend = endtime2js;
atttype = 4;
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (!("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() != null) && (!("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() != null)
&& (("").equals(dkmc.getSbdk3()) || dkmc.getSbdk3() == null)){ //上班3
punchcardtime = starttime3;
punchstart = starttime3ks;
punchend = starttime3js;
atttype = 5;
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (!("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() != null) && (!("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() != null)
&& (!("").equals(dkmc.getSbdk3()) || dkmc.getSbdk3() != null) && (("").equals(dkmc.getXbdk3()) || dkmc.getXbdk3() == null)){ //下班3
punchcardtime = endtime3;
punchstart = endtime3ks;
punchend = endtime3js;
atttype = 6;
}else {
punchcardtime = 0;
punchstart = 0;
punchend = 0;
atttype = 7;
}
}
ShiftManagement shif = null;
if(attdate.getAttsch().size() > 0 && clockt.getShifid() > 0){//有无班次
shif = shiftmanagementservice.selectByPrimaryKey(clockt.getShifid());
}
//打卡记录录入*****************************************************************************************************************************
//打卡是否有时间范围限制
boolean isRange = true;
if(punchstart>0 && punchend>0) {
String staputime = new SimpleDateFormat("HH:mm").format(punchstart);//应打卡开始时间
String entputime = new SimpleDateFormat("HH:mm").format(punchend);//应打卡结束时间
String DKputime = new SimpleDateFormat("HH:mm").format(time_);//打卡时间
System.out.println(staputime);
System.out.println(entputime);
System.out.println(DKputime);
boolean effectiveDate = false;
try {
effectiveDate = hourMinuteBetween(DKputime, staputime, entputime);
} catch (Exception e) {
e.printStackTrace();
}
if (effectiveDate) {
System.out.println("当前时间在范围内");
}else {
System.out.println("当前时间在不在范围内");
isRange = false;
}
}
if(isRange) {
if(dkmc == null) {//上班1 ****新增
PunchCardDetails pcd = new PunchCardDetails();
pcd.setUserid(userid);
pcd.setData(putime);//打卡日期(yyyy-MM-dd)
pcd.setSbdk1(time_);//上班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setSbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
}else{
pcd.setSbdk1jg(0);// 打卡结果
}
}
if(shif != null){
pcd.setYdkcs(shif.getSxbcs()*2);//应打卡次数
}
pcd.setQyid(qyid);//企业id
pcd.setDksj(startDate);//打卡时间
punchcarddetailsservice.insertSelective(pcd);
dkmx = pcd.getId();
}else { //*****修改
dkmx = dkmc.getId();
PunchCardDetails pcd = new PunchCardDetails();
if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() == null)){//下班1
pcd.setId(dkmc.getId());
pcd.setXbdk1(time_);//下班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setXbdk1jg(0);// 打卡结果
}else{
pcd.setXbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
}
}
if(dkmc.getSbdk1() != null){
Long time = (time_ - dkmc.getSbdk1())/1000/60;
pcd.setGzsc(Math.abs(Double.valueOf(time.toString())));//只打一次卡时计算工作时长
}
punchcarddetailsservice.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() == null)){//上班2
pcd.setId(dkmc.getId());
pcd.setSbdk2(time_);//上班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setSbdk2jg(Math.abs(Integer.valueOf(time.toString())));
}else{
pcd.setSbdk2jg(0);// 打卡结果
}
}
punchcarddetailsservice.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (!("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() != null) && (("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() == null)){//下班2
pcd.setId(dkmc.getId());
pcd.setXbdk2(time_);//下班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setXbdk2jg(0);// 打卡结果
}else{
pcd.setXbdk2jg(Math.abs(Integer.valueOf(time.toString())));
}
}
//班次为4次时,计算工作时长
if(dkmc.getSbdk2() != null){
Long time = (time_ - dkmc.getSbdk2())/1000/60;
BigDecimal om = new BigDecimal(dkmc.getGzsc());
BigDecimal on = new BigDecimal(time);
double worktime = Math.abs(om.add(on).doubleValue());
pcd.setGzsc(worktime);
}
punchcarddetailsservice.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (!("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() != null) && (!("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() != null)
&& (("").equals(dkmc.getSbdk3()) || dkmc.getSbdk3() == null)){//上班3
pcd.setId(dkmc.getId());
pcd.setSbdk3(time_);//上班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setSbdk3jg(Math.abs(Integer.valueOf(time.toString())));
}else{
pcd.setSbdk3jg(0);// 打卡结果
}
}
punchcarddetailsservice.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (!("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() != null) && (!("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() != null)
&& (!("").equals(dkmc.getSbdk3()) || dkmc.getSbdk3() != null) && (("").equals(dkmc.getXbdk3()) || dkmc.getXbdk3() == null)){//下班3
pcd.setId(dkmc.getId());
pcd.setXbdk3(time_);//下班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setXbdk3jg(0);// 打卡结果
}else{
pcd.setXbdk3jg(Math.abs(Integer.valueOf(time.toString())));
}
}
//班次为6次时,计算工作时长
if(dkmc.getSbdk3() != null){
Long time = (time_ - dkmc.getSbdk3())/1000/60;
BigDecimal om = new BigDecimal(dkmc.getGzsc());//第二次
BigDecimal on = new BigDecimal(time);
double worktime = Math.abs(om.add(on).doubleValue());
pcd.setGzsc(worktime);
}
}
pcd.setId(dkmc.getId());
if(atttype <= 6){
int update = punchcarddetailsservice.updateByPrimaryKeySelective(pcd);//修改打卡记录
}
}
}
//原始打卡记录数据录入**************************************************************************************************************************************
PunchRecord pre = new PunchRecord();
pre.setDktime(time_);// 打卡时间
Long time = (time_ - punchcardtime)/1000/60;
if(punchcardtime == 0){
pre.setResults(0);// 打卡结果
}else{
if(isRange) {
if((atttype)%2 > 0){//上班
if(time > 0){
pre.setResults(Integer.valueOf(time.toString()));// 打卡结果
}else{
pre.setResults(0);// 打卡结果
}
}else{//下班
if(time > 0){
pre.setResults(0);// 打卡结果
}else{
pre.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
}
}
}else {
pre.setResults(0);// 打卡结果
}
}
pre.setUserId(userid);// 用户id
if((atttype)%2 > 0){
pre.setType(1);// 类型(类型 0:无排班打卡 1:上班 2:下班)
if(punchcardtime == 0){//无班次打卡
pre.setStatus(1);
}else{
if(isRange) {
//打卡
if(time > 0){
pre.setStatus(3);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}else if(pre.getResults() == 0){
pre.setStatus(1);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}
}else {
pre.setStatus(2);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}
}
}else{
pre.setType(2);// 类型(类型 0:无排班打卡 1:上班 2:下班)
if(punchcardtime == 0){//无班次打卡
pre.setStatus(1);
}else{
if(isRange) {
//打卡
if(time < 0){
pre.setStatus(4);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}else if(pre.getResults() == 0){
pre.setStatus(1);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}
}else {
pre.setStatus(2);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}
}
}
pre.setSort(atttype);// 序号
pre.setCardType(3);// 打卡类型(1:GPS,2:WIFI,3:考勤机)
pre.setQyid(qyid);// 企业id
String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(startDate));//转换打卡时间格式
pre.setAttdate(attdate_+" "+dateToWeek2(putime));// 考勤日期
long date = new Date().getTime();
if(punchcardtime == 0 && !isRange){
pre.setAttime(date);// 考勤时间(应打卡时间)
}else{
pre.setAttime(punchcardtime);// 考勤时间(应打卡时间)
}
pre.setDkmxid(dkmx);// 打卡明细id
pre.setBcid(clockt.getShifid());// 班次id
if(("1").equals(asVerifyMode)) {
pre.setRemarks("考勤机指纹打卡");
}else if(("20").equals(asVerifyMode)) {
pre.setRemarks("考勤机人脸打卡");
}
pre.setPunchmode(Integer.valueOf(asVerifyMode));
pre.setPunchequipment(asDevId);//
punchrecordservice.insertSelective(pre);//新增打卡记录
}
}
}
/***********************************************************考勤机打卡(结束)********************************************************************************************/
return new ResponseResult().success("考勤机打卡成功", null);
}
/**
*
* @param nowDate 要比较的时间
* @param startDate 开始时间
* @param endDate 结束时间
* @return true在时间段内,false不在时间段内
* @throws Exception
*/
public static boolean hourMinuteBetween(String nowDate, String startDate, String endDate) throws Exception{
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
Date now = format.parse(nowDate);
Date start = format.parse(startDate);
Date end = format.parse(endDate);
long nowTime = now.getTime();
long startTime = start.getTime();
long endTime = end.getTime();
return nowTime >= startTime && nowTime <= endTime;
}
@PostMapping(value = "/removeuser/{kqjid}")
@ApiOperation(value = "批量移除用户", httpMethod = "POST", notes = "接口发布说明")
@ApiOperationSupport(order = 56)
public Result<Void> RemoveUser(@PathVariable int kqjid, @RequestBody Map<String,String> mmd) {
String[] xgyh = mmd.get("a").split(",");
if(xgyh.length > 0){
for(int a=0;a<xgyh.length;a++){
UserEquiRelation scyhkqj = userequirelationmapper.selectByuserIdkqjid(Integer.valueOf(xgyh[a]), kqjid);
AttendanceMachine kqj = attendancemachineservice.selectByPrimaryKey(scyhkqj.getKqjid());//查询考勤机“序列号”
JSONObject vResultJson = new JSONObject();
vResultJson.put("user_id", scyhkqj.getUserId());
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command;
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("cmd", "DELETE_USER");
params.add("devid", kqj.getCode());
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
try {
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
} catch (RestClientException e) {
// e.printStackTrace();
System.err.println("提示:考勤机服务出错");
return ResultUtil.success("失败");
}
userequirelationmapper.deleteByPrimaryKey(scyhkqj.getId());
//该用户是否为管理员 否则一同删除
// KqglAssoKqjgly gly = new LambdaQueryChainWrapper<KqglAssoKqjgly>(kqglassokqjglymapper).eq(KqglAssoKqjgly::getKqjid, kqjid)
// .eq(KqglAssoKqjgly::getUserid, xgyh[a]).one();
//
// if(gly != null){
// KqglAssoKqjgly.builder().build().deleteById(gly.getId());
// }
}
}
return ResultUtil.success("成功");
}
@PostMapping(value = "/modifyauthority/{kqjid}/{id}")
@ApiOperation(value = "添加考勤机管理员", httpMethod = "POST", notes = "接口发布说明")
@ApiOperationSupport(order = 55)
public Result<Void> ModifyAuthority(@CurrentUser UserBean userBean,@PathVariable int kqjid,@PathVariable int id, @RequestBody Map<String,String> mmd) {
Integer empNum = userBean.getEmpNum();
Integer orgCode = userBean.getOrgCode();
String[] xgyh = mmd.get("a").split(",");
if(xgyh.length > 0){
AttendanceMachine kqj = attendancemachineservice.selectByPrimaryKey(kqjid);
for(int a=0;a<xgyh.length;a++){
YgglMainEmp use = new LambdaQueryChainWrapper<YgglMainEmp>(ygglmainempmapper).eq(YgglMainEmp::getEmpNum, xgyh[a]).one();
JSONObject vResultJson = new JSONObject();
vResultJson.put("user_id", xgyh[a]);
// vResultJson.put("user_name", "管-"+use.getName()+"-"+a);
vResultJson.put("user_privilege", "MANAGER");
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command;
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("cmd", "SET_USER_INFO");
params.add("devid", kqj.getCode());
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
try {
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
} catch (RestClientException e) {
// e.printStackTrace();
System.err.println("提示:考勤机服务出错");
return ResultUtil.success("失败");
}
UserEquiRelation kqjry = new UserEquiRelation();
kqjry.setId(id);
kqjry.setIsGly(1);
userequirelationmapper.updateByPrimaryKeySelective(kqjry);
//考勤机管理员
// KqglAssoKqjgly gly = KqglAssoKqjgly.builder().build();
// gly.setKqjid(kqjid);//考勤机id
// gly.setGlybh(Integer.valueOf(xgyh[a]));//管理员编号
// gly.setGluxm("管-"+use.getName());//管理员姓名
// gly.setUserid(use.getEmpNum());//原用户id
// gly.setTjry(empNum);//添加人员
// gly.setQyid(orgCode);//企业id
// gly.insertOrUpdate();
}
}
return ResultUtil.success("成功");
}
public AttendanceCardList MethodCall(int qyid,int userid,String date) {
AttendanceCardList attcar = new AttendanceCardList();
String str = null;
if(!("").equals(date)){
str = date;
}else{
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
str = sdf.format(d);
}
Long startDate = 0l;
Long endDate = 0l;
try {
startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(str,"yyyy-MM-dd")).getTime();
endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(str,"yyyy-MM-dd")).getTime();
} catch (ParseException e) {
e.printStackTrace();
}
AttendanceGroup attgro = attendancegroupservice.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
//pbfs:排班方式 1:固定排班;2:自由排班;3:自由工时
if(attgro != null){//判断当前用户是否加入到考勤组
//排班制
Schedule jrpb = scheduleservice.getScheduleSpecificAttendance(attgro.getId(),userid,str);
//固定排班
int week = Integer.valueOf(dateToWeek(str));//4
AttendanceWeeklySch atwek = attendanceweeklyschservice.selectZhouDetail(attgro.getId(),week);//固定周排班
if(attgro.getPbfs() == 1){//固定排班
if(atwek != null){//有固定周排班
SpecialDate rest = specialdateservice.SpecialDateSpecialDayOff(attgro.getId(), str);//查询打卡当天是否在特殊休息日期里面存在
if(rest != null){//今天休息 Sort返回0【特殊日期--休息】
List<AttSchedule> atts = new ArrayList<AttSchedule>();
AttSchedule as = new AttSchedule();
as.setId(0);
as.setSort(0);//0:表示今天为休息日
as.setTime(0l);
as.setStarttime(0l);
as.setEndtime(0l);
atts.add(as);
attcar.setAttsch(atts);
}else{//今天上班
ShiftManagement bcz = shiftmanagementservice.selectByPrimaryKey(atwek.getBcid());
if(bcz != null){
Getshiftinformationbatch(bcz,attcar,str);
}
}
}else{
//必须打卡
SpecialDate tsri = specialdateservice.SpecialDateTroubleshooting(attgro.getId(), str);//判断特殊日期
if(tsri != null){
ShiftManagement tsrq = shiftmanagementservice.selectByPrimaryKey(tsri.getBcid());
if(tsrq!=null){
Getshiftinformationbatch(tsrq,attcar,str);
}
}else{
//休息
List<AttSchedule> atts = new ArrayList<AttSchedule>();
AttSchedule as = new AttSchedule();
as.setId(0);
as.setSort(0);//0:表示今天为休息日
as.setTime(0l);
as.setStarttime(0l);
as.setEndtime(0l);
atts.add(as);
attcar.setAttsch(atts);
}
}
}else if(attgro.getPbfs() == 2){//自由排班
//未排班时,员工可选择班次打卡
if(attgro.getIsXzbcdk() == 1){
attcar.setOptscheduling(true);
}else{
attcar.setOptscheduling(false);
}
// Schedule jrpb = scheduleservice.getScheduleSpecificAttendance(attgro.getId(),userid,str);
if(jrpb != null){
List<AttSchedule> atts = new ArrayList<AttSchedule>();
if(jrpb.getBcid() != 0){//有班次时("Bcid"不为0时)
if(jrpb.getSxbcs() == 1 || jrpb.getSxbcs() == 2 || jrpb.getSxbcs() == 3){//1次上下班
for(int o=0;o<2;o++){
if(o==0){
AttSchedule as = new AttSchedule();
as.setId(jrpb.getBcid());
as.setSort(1);
as.setTime(Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbdk1(),2)+":00")));
as.setStarttime(("").equals(jrpb.getSbqjks1())? 0 :Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbqjks1(),2)+":00")));
as.setEndtime(("").equals(jrpb.getSbqjjs1()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbqjjs1(),2)+":00")));
atts.add(as);
}else{
AttSchedule as = new AttSchedule();
as.setId(jrpb.getBcid());
as.setSort(2);
as.setTime(Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbdk1(),2)+":00")));
as.setStarttime(("").equals(jrpb.getXbqjks1()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbqjks1(),2)+":00")));
as.setEndtime(("").equals(jrpb.getXbqjjs1()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbqjjs1(),2)+":00")));
atts.add(as);
}
}
attcar.setAttsch(atts);
}
if(jrpb.getSxbcs() == 2 || jrpb.getSxbcs() == 3){//2次上下班
for(int o=0;o<2;o++){
if(o==0){
AttSchedule as = new AttSchedule();
as.setId(jrpb.getBcid());
as.setSort(3);
as.setTime(Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbdk2(),2)+":00")));
as.setStarttime(("").equals(jrpb.getSbqjks2()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbqjks2(),2)+":00")));
as.setEndtime(("").equals(jrpb.getSbqjjs2()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbqjjs2(),2)+":00")));
atts.add(as);
}else{
AttSchedule as = new AttSchedule();
as.setId(jrpb.getBcid());
as.setSort(4);
as.setTime(Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbdk2(),2)+":00")));
as.setStarttime(("").equals(jrpb.getXbqjks2()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbqjks2(),2)+":00")));
as.setEndtime(("").equals(jrpb.getXbqjjs2()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbqjjs2(),2)+":00")));
atts.add(as);
}
}
attcar.setAttsch(atts);
}
if(jrpb.getSxbcs() == 3){//3次上下班
for(int o=0;o<2;o++){
if(o==0){
AttSchedule as = new AttSchedule();
as.setId(jrpb.getBcid());
as.setSort(5);
as.setTime(Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbdk3(),2)+":00")));
as.setStarttime(("").equals(jrpb.getSbqjks3()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbqjks3(),2)+":00")));
as.setEndtime(("").equals(jrpb.getSbqjjs3()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getSbqjjs3(),2)+":00")));
atts.add(as);
}else{
AttSchedule as = new AttSchedule();
as.setId(jrpb.getBcid());
as.setSort(6);
as.setTime(Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbdk3(),2)+":00")));
as.setStarttime(("").equals(jrpb.getXbqjks3()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbqjks3(),2)+":00")));
as.setEndtime(("").equals(jrpb.getXbqjjs3()) ? 0 : Long.valueOf(dateToStamp(str+" "+dealDateFormat(jrpb.getXbqjjs3(),2)+":00")));
atts.add(as);
}
}
attcar.setAttsch(atts);
}
}else{//当天排班为休息
List<AttSchedule> atts1 = new ArrayList<AttSchedule>();
AttSchedule as = new AttSchedule();
as.setId(0);
as.setSort(0);//0:表示今天为休息日
as.setTime(0l);
as.setStarttime(0l);
as.setEndtime(0l);
atts1.add(as);
attcar.setAttsch(atts1);
}
}
}else{//自由工时
//int week = Integer.valueOf(dateToWeek(str));//4
AttendanceWeeklySch wekz = attendanceweeklyschservice.WeeklyFreeRoster(attgro.getId(),week);
if(wekz != null){//
String dada = str+" "+attgro.getKqkssjTime()+":00";
attcar.setStapclotime(Long.valueOf(dateToStamp(dada)));
}
if(!("").equals(attgro.getJbzdsc())){
attcar.setCanpunchworkdate(Double.valueOf(attgro.getJbzdsc()));//上班打卡后多久大下班卡
}
}
if(jrpb != null || atwek != null){
ShiftManagement shif = null;
if(attgro.getPbfs() == 1){
shif = shiftmanagementservice.selectByPrimaryKey(atwek.getBcid());
}else if(attgro.getPbfs() == 2){
shif = shiftmanagementservice.selectByPrimaryKey(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 = new AttLateLate();
ala.setLatewalk(shif.getXbwz1());
ala.setArrivelate(shif.getSbwd1());
atwzwd.add(ala);
if(p == 4 || p == 6){
AttLateLate alat = new AttLateLate();
alat.setLatewalk(shif.getXbwz2());
alat.setArrivelate(shif.getSbwd2());
atwzwd.add(alat);
}
if(p == 6){
AttLateLate alas = new AttLateLate();
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;
}
/**********************/
/**********************/
/** /**
* 获取报表汇总 * 获取报表汇总
*/ */
......
...@@ -7,6 +7,7 @@ import java.util.ArrayList; ...@@ -7,6 +7,7 @@ import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
...@@ -40,6 +41,7 @@ import cn.timer.api.bean.kqgl.AttendanceMachine; ...@@ -40,6 +41,7 @@ import cn.timer.api.bean.kqgl.AttendanceMachine;
import cn.timer.api.bean.kqgl.PunchCardDetails; import cn.timer.api.bean.kqgl.PunchCardDetails;
import cn.timer.api.bean.kqgl.PunchRecord; import cn.timer.api.bean.kqgl.PunchRecord;
import cn.timer.api.bean.kqgl.UserAttendanceRel; import cn.timer.api.bean.kqgl.UserAttendanceRel;
import cn.timer.api.bean.kqgl.UserEquiRelation;
import cn.timer.api.bean.kqmk.KqglAssOvertimeVice; import cn.timer.api.bean.kqmk.KqglAssOvertimeVice;
import cn.timer.api.bean.kqmk.KqglAssoBcsz; import cn.timer.api.bean.kqmk.KqglAssoBcsz;
import cn.timer.api.bean.kqmk.KqglAssoDkdz; import cn.timer.api.bean.kqmk.KqglAssoDkdz;
...@@ -86,6 +88,7 @@ import cn.timer.api.dao.kqmk.KqglAssoYhkqzMapper; ...@@ -86,6 +88,7 @@ import cn.timer.api.dao.kqmk.KqglAssoYhkqzMapper;
import cn.timer.api.dao.kqmk.KqglAssoYhsbMapper; import cn.timer.api.dao.kqmk.KqglAssoYhsbMapper;
import cn.timer.api.dao.kqmk.KqglAssoZhoupaibanMapper; import cn.timer.api.dao.kqmk.KqglAssoZhoupaibanMapper;
import cn.timer.api.dao.kqmk.KqglMainKqzMapper; import cn.timer.api.dao.kqmk.KqglMainKqzMapper;
import cn.timer.api.dto.kqgl.AttemacDto;
import cn.timer.api.dto.kqmk.AttSchedulingDto; import cn.timer.api.dto.kqmk.AttSchedulingDto;
import cn.timer.api.dto.kqmk.AttendanceAssistantDto; import cn.timer.api.dto.kqmk.AttendanceAssistantDto;
import cn.timer.api.dto.kqmk.AttqueryCriteriaDto; import cn.timer.api.dto.kqmk.AttqueryCriteriaDto;
...@@ -467,7 +470,6 @@ public class TimeCardController { ...@@ -467,7 +470,6 @@ public class TimeCardController {
@GetMapping(value="/synchrotime/{code}") @GetMapping(value="/synchrotime/{code}")
@ApiOperation(value = "考勤机一键同步", httpMethod = "GET", notes = "接口发布说明") @ApiOperation(value = "考勤机一键同步", httpMethod = "GET", notes = "接口发布说明")
@ApiOperationSupport(order = 54)
public Result<Object> SynchronizationTime(@CurrentUser UserBean userBean,@PathVariable("code") String code) { public Result<Object> SynchronizationTime(@CurrentUser UserBean userBean,@PathVariable("code") String code) {
JSONObject vResultJson = new JSONObject(); JSONObject vResultJson = new JSONObject();
...@@ -490,6 +492,80 @@ public class TimeCardController { ...@@ -490,6 +492,80 @@ public class TimeCardController {
} }
/** /**
* 移除考勤机管理员
*/
@PostMapping(value = "/removeadministrator/{kqjid}/{id}")
@ApiOperation(value = "移除考勤机管理员", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> RemoveAdministrator(@PathVariable int kqjid,@PathVariable int id, @RequestBody Map<String,String> mmd) {
String[] xgyh = mmd.get("a").split(",");
if(xgyh.length > 0){
KqglAssoKqj kqj = KqglAssoKqj.builder().id(kqjid).build().selectById();//查询考勤机“序列号”
for(int a=0;a<xgyh.length;a++){
JSONObject vResultJson = new JSONObject();
vResultJson.put("devId", kqj.getCode());
vResultJson.put("userId", xgyh[a]);
vResultJson.put("privilege", 1);
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command+"/addUserPrivilege";
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
try {
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
} catch (RestClientException e) {
System.err.println("提示:考勤机服务出错");
return ResultUtil.success("失败");
}
KqglAssoYhsb.builder().id(id).isGly(0).build().updateById();
}
}
return ResultUtil.success("成功");
}
@PostMapping(value = "/modifyauthority/{kqjid}/{id}")
@ApiOperation(value = "添加考勤机管理员", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> ModifyAuthority(@CurrentUser UserBean userBean,@PathVariable int kqjid,@PathVariable int id, @RequestBody Map<String,String> mmd) {
String[] xgyh = mmd.get("a").split(",");
if(xgyh.length > 0){
KqglAssoKqj kqj = KqglAssoKqj.builder().id(kqjid).build().selectById();//查询考勤机“序列号”
for(int a=0;a<xgyh.length;a++){
JSONObject vResultJson = new JSONObject();
vResultJson.put("devId", kqj.getCode());
vResultJson.put("userId", xgyh[a]);
vResultJson.put("privilege", 2);
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command+"/addUserPrivilege";
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
try {
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
} catch (RestClientException e) {
System.err.println("提示:考勤机服务出错");
return ResultUtil.success("失败");
}
UserEquiRelation kqjry = new UserEquiRelation();
kqjry.setId(id);
kqjry.setIsGly(1);
userequirelationmapper.updateByPrimaryKeySelective(kqjry);
}
}
return ResultUtil.success("成功");
}
/**
* 新增考勤机 * 新增考勤机
*/ */
@PostMapping(value = "/Attendance_machine") @PostMapping(value = "/Attendance_machine")
...@@ -499,7 +575,29 @@ public class TimeCardController { ...@@ -499,7 +575,29 @@ public class TimeCardController {
kqglassokqj.setLuryid(userBean.getEmpNum()); kqglassokqj.setLuryid(userBean.getEmpNum());
kqglassokqj.setLusjTime(new Date().getTime()); kqglassokqj.setLusjTime(new Date().getTime());
kqglassokqj.setQyid(userBean.getOrgCode()); kqglassokqj.setQyid(userBean.getOrgCode());
return kqglassokqj.insert() ? ResultUtil.success("操作成功!") : ResultUtil.error("操作失败!");
if(!kqglassokqj.insert())
return ResultUtil.error("操作失败--新增考勤机");
JSONObject vResultJson = new JSONObject();
vResultJson.put("devId", kqglassokqj.getCode());
vResultJson.put("orgCode", userBean.getOrgCode());
String sFinal = vResultJson.toString();
String url = StaticVariable.mac_command+"/addDev";
HttpHeaders headers = new HttpHeaders();
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("json", sFinal);
RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers);
try {
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class);
} catch (RestClientException e) {
System.err.println("提示:考勤机服务出错");
return ResultUtil.success("失败");
}
return ResultUtil.success("操作成功!");
} }
/** /**
...@@ -1754,7 +1852,6 @@ public class TimeCardController { ...@@ -1754,7 +1852,6 @@ public class TimeCardController {
return ResultUtil.data(pageAs, listAs, "操作成功!"); return ResultUtil.data(pageAs, listAs, "操作成功!");
} }
/**************************/ /**************************/
/** /**
* 查询列表-加班补偿方式 * 查询列表-加班补偿方式
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment