Commit 8667e872 authored by 姬鋆屾's avatar 姬鋆屾
parents 44f4c6f2 e5abd908
package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikQuery;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq;
import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo;
import com.mortals.xhx.module.hik.door.service.IHikDoorService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 同步获取下午海康门禁事件
*/
@Slf4j
@Service("SyncDoorsEventAfterTask")
public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService {
@Autowired
private AttendanceRecordHikService recordHikService;
@Autowired
private StaffService staffService;
@Autowired
private IHikDoorService hikDoorService;
@Override
public void excuteTask(ITask task) throws AppException {
syncDoorEvents();
calculateAttendByDay();
}
private void calculateAttendByDay() {
Context context = new Context();
UserEntity userEntity = new UserEntity();
userEntity.setCreateUserId(1L);
userEntity.setCreateUserName("system");
userEntity.setCreateTime(new Date());
context.setUser(userEntity);
AttendanceRecordHikQuery recordHikEntity = new AttendanceRecordHikQuery();
// Date todayStart = DateUtil.offsetHour(new Date(), -5).toJdkDate();
// recordHikEntity.setAttendanceDateStart(DateUtils.getCurrStrDate());
recordHikEntity.setAttendanceDateStart(DateUtil.offsetHour(new Date(), -5).toString());
recordHikEntity.setAttendanceDateEnd(DateUtils.getCurrStrDate());
try {
recordHikService.addAttendanceRecordByQuery(recordHikEntity, context);
} catch (Exception e) {
log.error("计算考勤异常", e);
}
}
private void syncDoorEvents() {
DoorEventReq doorEventReq = new DoorEventReq();
List<Integer> eventTypes = new ArrayList<>();
eventTypes.add(196885);
eventTypes.add(196887);
eventTypes.add(196893);
eventTypes.add(196888);
eventTypes.add(196889);
eventTypes.add(196890);
eventTypes.add(196891);
doorEventReq.setEventTypes(eventTypes);
// 获取当天的开始时间
Date todayStart = DateUtil.offsetHour(new Date(), -5).toJdkDate();
// Date todayStart = DateUtil.beginOfDay(new Date());
// 获取当天的结束时间
Date todayEnd = DateUtil.endOfDay(new Date());
doorEventReq.setStartTime(todayStart);
doorEventReq.setEndTime(todayEnd);
doorEventReq.setPageNo(1);
doorEventReq.setPageSize(1);
Rest<DoorEventDataInfo> doorEventsRest = hikDoorService.getDoorEvents(doorEventReq);
log.info("doorEventsRest:{} msg:{}", doorEventsRest.getCode(), doorEventsRest.getMsg());
if (doorEventsRest.getCode() == YesNoEnum.YES.getValue()) {
//分页获取考勤数据
Integer total = doorEventsRest.getData().getTotal();
int pageCount = PageUtil.totalPage(total, 1000);
for (int i = 1; i <= pageCount; i++) {
doorEventReq.setPageNo(i);
doorEventReq.setPageSize(1000);
doorEventsRest = hikDoorService.getDoorEvents(doorEventReq);
log.info("doorEventsRest:{} msg:{},page:{}", doorEventsRest.getCode(), doorEventsRest.getMsg(), doorEventReq.getPageNo());
getDoorEvents(doorEventsRest);
}
}
}
private void getDoorEvents(Rest<DoorEventDataInfo> doorEventsRest) {
//同步当前考勤数据
List<AttendanceRecordHikEntity> attRecords = doorEventsRest.getData().getList().stream().map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue();
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}", item.getJobNo());
return null;
}
recordHikEntity.setStaffId(staffCache.getId());
recordHikEntity.setStaffName(staffCache.getName());
recordHikEntity.setWorkNum(staffCache.getWorkNum());
recordHikEntity.setDeptId(staffCache.getDeptId());
recordHikEntity.setDeptName(staffCache.getDeptName());
recordHikEntity.setPositionId(staffCache.getPositionId());
recordHikEntity.setPositionName(staffCache.getPositionName());
recordHikEntity.setAttendanceDate(item.getEventTime());
recordHikEntity.setAttendanceAddress(item.getDoorName());
recordHikEntity.setEventSource("门禁点");
recordHikEntity.setRemark(item.getEventId());
recordHikEntity.setCreateTime(new Date());
recordHikEntity.setCreateUserName("系统管理员");
recordHikEntity.setCreateUserId(1L);
return recordHikEntity;
}).filter(f -> f != null).collect(Collectors.toList());
log.info("attRecords size:{}", attRecords.size());
List<String> eventIds = attRecords.parallelStream().filter(f -> !ObjectUtils.isEmpty(f) && !ObjectUtils.isEmpty(f.getRemark())).map(i -> i.getRemark()).collect(Collectors.toList());
//查询当天考勤记录是否有重复的 有的 则不添加
AttendanceRecordHikQuery recordHikQuery = new AttendanceRecordHikQuery();
recordHikQuery.setAttendanceDateStart(DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd"));
recordHikQuery.setAttendanceDateEnd(DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyy-MM-dd"));
recordHikQuery.setRemarkList(eventIds);
Set<String> eventIdSet = recordHikService.find(recordHikQuery).parallelStream().map(i -> i.getRemark()).collect(Collectors.toSet());
//去重 时分秒打卡的 也要去掉重复。
List<AttendanceRecordHikEntity> saveRecordList = attRecords.stream().filter(f -> !eventIdSet.contains(f.getRemark())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(saveRecordList)) {
//单个插入 去掉重复时间段的打卡记录
for (AttendanceRecordHikEntity recordHikEntity : saveRecordList) {
try {
recordHikService.save(recordHikEntity);
} catch (Exception e) {
log.error("基础考勤数据保存异常", e.getMessage());
}
}
// recordHikService.save(saveRecordList);
}
log.info("saveRecordList size:{}", saveRecordList.size());
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -23,12 +20,10 @@ import com.mortals.xhx.module.hik.door.service.IHikDoorService; ...@@ -23,12 +20,10 @@ import com.mortals.xhx.module.hik.door.service.IHikDoorService;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.time.Year;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -73,7 +68,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -73,7 +68,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
recordHikEntity.setAttendanceDateStart(DateUtil.offsetHour(new Date(), -5).toString()); recordHikEntity.setAttendanceDateStart(DateUtil.offsetHour(new Date(), -5).toString());
recordHikEntity.setAttendanceDateEnd(DateUtils.getCurrStrDate()); recordHikEntity.setAttendanceDateEnd(DateUtils.getCurrStrDate());
try { try {
recordHikService.addAttendanceRecord(recordHikEntity, context); recordHikService.addAttendanceRecordByQuery(recordHikEntity, context);
} catch (Exception e) { } catch (Exception e) {
log.error("计算考勤异常", e); log.error("计算考勤异常", e);
} }
...@@ -123,7 +118,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -123,7 +118,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
recordHikEntity.initAttrValue(); recordHikEntity.initAttrValue();
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0")); StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(item.getJobNo(), 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) { if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}",item.getJobNo()); log.info("staff is null !staffCode:{}", item.getJobNo());
return null; return null;
} }
...@@ -140,13 +135,11 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -140,13 +135,11 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
recordHikEntity.setEventSource("门禁点"); recordHikEntity.setEventSource("门禁点");
recordHikEntity.setRemark(item.getEventId()); recordHikEntity.setRemark(item.getEventId());
recordHikEntity.setCreateTime(new Date()); recordHikEntity.setCreateTime(new Date());
recordHikEntity.setCreateUserName("system"); recordHikEntity.setCreateUserName("系统管理员");
recordHikEntity.setCreateUserId(1L); recordHikEntity.setCreateUserId(1L);
return recordHikEntity; return recordHikEntity;
}).filter(f->f!=null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
log.info("attRecords size:{}", attRecords.size()); log.info("attRecords size:{}", attRecords.size());
List<String> eventIds = attRecords.parallelStream().filter(f -> !ObjectUtils.isEmpty(f) && !ObjectUtils.isEmpty(f.getRemark())).map(i -> i.getRemark()).collect(Collectors.toList()); List<String> eventIds = attRecords.parallelStream().filter(f -> !ObjectUtils.isEmpty(f) && !ObjectUtils.isEmpty(f.getRemark())).map(i -> i.getRemark()).collect(Collectors.toList());
//查询当天考勤记录是否有重复的 有的 则不添加 //查询当天考勤记录是否有重复的 有的 则不添加
...@@ -156,9 +149,18 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -156,9 +149,18 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
recordHikQuery.setRemarkList(eventIds); recordHikQuery.setRemarkList(eventIds);
Set<String> eventIdSet = recordHikService.find(recordHikQuery).parallelStream().map(i -> i.getRemark()).collect(Collectors.toSet()); Set<String> eventIdSet = recordHikService.find(recordHikQuery).parallelStream().map(i -> i.getRemark()).collect(Collectors.toSet());
//去重 时分秒打卡的 也要去掉重复。
List<AttendanceRecordHikEntity> saveRecordList = attRecords.stream().filter(f -> !eventIdSet.contains(f.getRemark())).collect(Collectors.toList()); List<AttendanceRecordHikEntity> saveRecordList = attRecords.stream().filter(f -> !eventIdSet.contains(f.getRemark())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(saveRecordList)) { if (!ObjectUtils.isEmpty(saveRecordList)) {
recordHikService.save(saveRecordList); //单个插入 去掉重复时间段的打卡记录
for (AttendanceRecordHikEntity recordHikEntity : saveRecordList) {
try {
recordHikService.save(recordHikEntity);
} catch (Exception e) {
log.error("基础考勤数据保存异常", e.getMessage());
}
}
// recordHikService.save(saveRecordList);
} }
log.info("saveRecordList size:{}", saveRecordList.size()); log.info("saveRecordList size:{}", saveRecordList.size());
} }
...@@ -168,20 +170,4 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -168,20 +170,4 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
public void stopTask(ITask task) throws AppException { public void stopTask(ITask task) throws AppException {
} }
public static void main(String[] args) {
// 获取当前时间的小时数
int hour = DateUtil.hour(new Date(), true);
// 获取当前时间所在小时的开始时间和结束时间
Date startTime = DateUtil.beginOfHour(new Date());
Date endTime = DateUtil.endOfHour(new Date());
// 格式化时间为指定格式
String startTimeStr = DateUtil.format(startTime, "yyyy-MM-dd HH:00:00");
String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:59:59");
// 输出结果
System.out.println("当前时间所在小时的开始时间:" + startTimeStr);
System.out.println("当前时间所在小时的结束时间:" + endTimeStr);
}
} }
...@@ -20,6 +20,9 @@ import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity; ...@@ -20,6 +20,9 @@ import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordEntity;
import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery; import com.mortals.xhx.module.attendance.model.AttendanceLeaveRecordQuery;
import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService; import com.mortals.xhx.module.attendance.service.AttendanceLeaveRecordService;
import com.mortals.xhx.module.dingding.personal.service.IDingPersonService; import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
...@@ -54,7 +57,8 @@ public class DingMessageController { ...@@ -54,7 +57,8 @@ public class DingMessageController {
private IDingPersonService dingPersonService; private IDingPersonService dingPersonService;
@Autowired @Autowired
private AttendanceLeaveRecordService attendanceLeaveRecordService; private AttendanceLeaveRecordService attendanceLeaveRecordService;
@Autowired
private StaffService staffService;
/** /**
* appKey * appKey
...@@ -109,15 +113,22 @@ public class DingMessageController { ...@@ -109,15 +113,22 @@ public class DingMessageController {
AttendanceLeaveRecordEntity leaveRecordEntity = new AttendanceLeaveRecordEntity(); AttendanceLeaveRecordEntity leaveRecordEntity = new AttendanceLeaveRecordEntity();
leaveRecordEntity.initAttrValue(); leaveRecordEntity.initAttrValue();
leaveRecordEntity.setRemark(processInstanceId); //将钉钉的事物id作为备注填入数据库 leaveRecordEntity.setRemark(processInstanceId); //将钉钉的事物id作为备注填入数据库
leaveRecordEntity.setLeavePersonId(Long.parseLong(result.getOriginatorUserId()));
leaveRecordEntity.setLeavePerson(result.getTitle().substring(0,result.getTitle().indexOf("提交")));
leaveRecordEntity.setDeptId(Long.parseLong(result.getOriginatorDeptId()));
leaveRecordEntity.setDeptName(result.getOriginatorDeptName());
Rest<String> mobileRest = dingPersonService.getPersonById(result.getOriginatorUserId());
if(mobileRest.getCode() == Rest.SUCCESS) {
String mobile = mobileRest.getData();
StaffEntity staffEntity = staffService.selectOne(new StaffQuery().phoneNumber(mobile));
if(!ObjectUtils.isEmpty(staffEntity)){
leaveRecordEntity.setLeavePersonId(staffEntity.getId());
leaveRecordEntity.setLeavePerson(staffEntity.getName());
leaveRecordEntity.setDeptId(staffEntity.getDeptId());
leaveRecordEntity.setDeptName(staffEntity.getDeptName());
leaveRecordEntity.setPhoneNumber(staffEntity.getPhoneNumber());
if(result.getTasks().size() >0 ){ if(result.getTasks().size() >0 ){
Date startTime = dateFormat(result.getTasks().get(0).getCreateTime()); Date startTime = dateFormat(result.getTasks().get(0).getCreateTime());
Date endTime = dateFormat(result.getTasks().get(0).getFinishTime()); Date endTime = dateFormat(result.getTasks().get(0).getFinishTime());
leaveRecordEntity.setStartTime(startTime); leaveRecordEntity.setStartTime(startTime);
leaveRecordEntity.setEndTime(endTime); leaveRecordEntity.setEndTime(endTime);
...@@ -252,6 +263,20 @@ public class DingMessageController { ...@@ -252,6 +263,20 @@ public class DingMessageController {
} }
}else {
log.info("该号码("+mobile +")未在本系统绑定");
}
}else {
log.info("根据id在钉钉平台查询电话失败"+mobileRest.getMsg());
}
} }
} }
......
package com.mortals.xhx.module.attendance.model; package com.mortals.xhx.module.attendance.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel; import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
...@@ -29,6 +32,7 @@ public class AttendanceStatEntity extends AttendanceStatVo { ...@@ -29,6 +32,7 @@ public class AttendanceStatEntity extends AttendanceStatVo {
/** /**
* 员工姓名 * 员工姓名
*/ */
@Excel(name = "员工姓名")
private String staffName; private String staffName;
/** /**
* 所属部门 * 所属部门
...@@ -37,6 +41,7 @@ public class AttendanceStatEntity extends AttendanceStatVo { ...@@ -37,6 +41,7 @@ public class AttendanceStatEntity extends AttendanceStatVo {
/** /**
* 所属部门名称 * 所属部门名称
*/ */
@Excel(name = "部门名称")
private String deptName; private String deptName;
/** /**
* 回单位(天) * 回单位(天)
...@@ -312,11 +317,11 @@ public class AttendanceStatEntity extends AttendanceStatVo { ...@@ -312,11 +317,11 @@ public class AttendanceStatEntity extends AttendanceStatVo {
this.earlyLeaveMeeting = BigDecimal.valueOf(0); this.earlyLeaveMeeting = BigDecimal.valueOf(0);
this.year = -1; this.year = DateUtil.year(new Date());
this.month = -1; this.month = DateUtil.month(new Date())+1;
this.day = -1; this.day = DateUtil.dayOfMonth(new Date());
this.remark = ""; this.remark = "";
...@@ -338,4 +343,8 @@ public class AttendanceStatEntity extends AttendanceStatVo { ...@@ -338,4 +343,8 @@ public class AttendanceStatEntity extends AttendanceStatVo {
this.afternoonTimes = 0; this.afternoonTimes = 0;
} }
public static void main(String[] args) {
System.out.println(DateUtil.dayOfMonth(new Date()));
}
} }
\ No newline at end of file
...@@ -4,6 +4,8 @@ import com.mortals.framework.service.ICRUDService; ...@@ -4,6 +4,8 @@ import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.attendance.dao.AttendanceRecordHikDao; import com.mortals.xhx.module.attendance.dao.AttendanceRecordHikDao;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity; import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
import java.util.List;
/** /**
* AttendanceRecordHikService * AttendanceRecordHikService
* *
...@@ -17,9 +19,26 @@ public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecor ...@@ -17,9 +19,26 @@ public interface AttendanceRecordHikService extends ICRUDService<AttendanceRecor
AttendanceRecordHikDao getDao(); AttendanceRecordHikDao getDao();
/** /**
* 将原始数据导入打卡记录表 * 根据查询条件生成打卡记录
* @param entity * @param attendanceRecordHikQuery
*/
void addAttendanceRecordByQuery(AttendanceRecordHikEntity attendanceRecordHikQuery, Context context) throws Exception;
/**
* 根据查询条件生成打卡记录
* @param hikEntity
*/ */
void addAttendanceRecord(AttendanceRecordHikEntity entity, Context context) throws Exception; void addAttendanceRecord(AttendanceRecordHikEntity hikEntity, Context context) throws Exception;
/**
* 根据查原始记录列表生成打卡记录
* @param hikEntityList
*/
void addAttendanceRecordList(List<AttendanceRecordHikEntity> hikEntityList, Context context) throws Exception;
} }
...@@ -127,7 +127,7 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro ...@@ -127,7 +127,7 @@ public class AttendanceRecordHikController extends BaseCRUDJsonBodyMappingContro
if (ObjectUtils.isEmpty(hikEntity.getAttendanceDateStart())) { if (ObjectUtils.isEmpty(hikEntity.getAttendanceDateStart())) {
throw new AppException("请选择开始日期"); throw new AppException("请选择开始日期");
} }
hikService.addAttendanceRecord(hikEntity, getContext()); hikService.addAttendanceRecordByQuery(hikEntity, getContext());
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -5,11 +5,14 @@ import com.mortals.xhx.base.system.param.service.ParamService; ...@@ -5,11 +5,14 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.AllHolidaysEnum; import com.mortals.xhx.common.code.AllHolidaysEnum;
import com.mortals.xhx.module.attendance.model.AttendanceVacationBalanceEntity; import com.mortals.xhx.module.attendance.model.AttendanceVacationBalanceEntity;
import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceService; import com.mortals.xhx.module.attendance.service.AttendanceVacationBalanceService;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* *
...@@ -25,6 +28,9 @@ public class AttendanceVacationBalanceController extends BaseCRUDJsonBodyMapping ...@@ -25,6 +28,9 @@ public class AttendanceVacationBalanceController extends BaseCRUDJsonBodyMapping
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private DeptService deptService;
public AttendanceVacationBalanceController(){ public AttendanceVacationBalanceController(){
super.setModuleDesc( "员工假期余额信息"); super.setModuleDesc( "员工假期余额信息");
...@@ -33,6 +39,7 @@ public class AttendanceVacationBalanceController extends BaseCRUDJsonBodyMapping ...@@ -33,6 +39,7 @@ public class AttendanceVacationBalanceController extends BaseCRUDJsonBodyMapping
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model,"AllHolidays",AllHolidaysEnum.getEnumMap()); this.addDict(model,"AllHolidays",AllHolidaysEnum.getEnumMap());
this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getDeptName())));
super.init(model, context); super.init(model, context);
} }
......
package com.mortals.xhx.module.dept.model; package com.mortals.xhx.module.dept.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.Date;
import java.util.ArrayList; import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel; import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.dept.model.vo.DeptPerformStatVo; import com.mortals.xhx.module.dept.model.vo.DeptPerformStatVo;
import lombok.Data; import lombok.Data;
/** /**
* 部门绩效分数统计实体对象 * 部门绩效分数统计实体对象
* *
* @author zxfei * @author zxfei
* @date 2023-07-14 * @date 2023-07-20
*/ */
@Data @Data
public class DeptPerformStatEntity extends DeptPerformStatVo { public class DeptPerformStatEntity extends DeptPerformStatVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -165,10 +163,10 @@ public class DeptPerformStatEntity extends DeptPerformStatVo { ...@@ -165,10 +163,10 @@ public class DeptPerformStatEntity extends DeptPerformStatVo {
this.remark = ""; this.remark = "";
this.year = -1; this.year = DateUtil.year(new Date());
this.month = -1; this.month = DateUtil.month(new Date())+1;
this.day = -1; this.day = DateUtil.dayOfMonth(new Date());
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.dingding.personal.service; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.dingding.personal.service;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody; import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.dingding.IDingTalkService; import com.mortals.xhx.module.dingding.IDingTalkService;
import com.mortals.xhx.module.dingding.personal.model.req.workmsg.WorkMsgReq; import com.mortals.xhx.module.dingding.personal.model.req.workmsg.WorkMsgReq;
...@@ -27,6 +28,14 @@ public interface IDingPersonService extends IDingTalkService { ...@@ -27,6 +28,14 @@ public interface IDingPersonService extends IDingTalkService {
*/ */
Rest<String> getPersonByMobile(String mobile); Rest<String> getPersonByMobile(String mobile);
/**
* 根据id获取用户电话
*
* @param id
* @return
*/
Rest<String> getPersonById(String id);
/** /**
* 根据code获取钉钉用户id * 根据code获取钉钉用户id
* *
......
...@@ -6,9 +6,11 @@ import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody; ...@@ -6,9 +6,11 @@ import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.aliyun.tea.TeaException; import com.aliyun.tea.TeaException;
import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request; import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.dingtalk.api.request.OapiV2UserGetRequest;
import com.dingtalk.api.request.OapiV2UserGetbymobileRequest; import com.dingtalk.api.request.OapiV2UserGetbymobileRequest;
import com.dingtalk.api.request.OapiV2UserGetuserinfoRequest; import com.dingtalk.api.request.OapiV2UserGetuserinfoRequest;
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response; import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserGetbymobileResponse; import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse; import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -50,6 +52,26 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID ...@@ -50,6 +52,26 @@ public class DingPersonServiceImpl extends AbstractDingTalkService implements ID
} }
} }
@Override
public Rest<String> getPersonById(String id) {
try {
DingTalkClient client = getDingTalkClient("/topapi/v2/user/get");
OapiV2UserGetRequest req = new OapiV2UserGetRequest();
req.setUserid(id); //用户id
log.info("getPersonByID:{}",id);
OapiV2UserGetResponse rsp = client.execute(req, getToken());
log.info("钉钉返回用户信息:{}", rsp.getBody());
if (rsp.getErrcode() == 0) {
return Rest.ok("成功", rsp.getResult().getMobile());
} else {
return Rest.fail(String.format("code:%s,msg:%s", rsp.getErrcode(), rsp.getErrmsg()));
}
} catch (ApiException e) {
log.info("根据手机号码查询人员异常", e);
return Rest.fail(e.getMessage());
}
}
@Override @Override
public Rest<String> getPersonByCode(String code) { public Rest<String> getPersonByCode(String code) {
try { try {
......
...@@ -12,6 +12,8 @@ import com.mortals.xhx.base.system.param.service.ParamService; ...@@ -12,6 +12,8 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.perform.model.PerformRulesQuery; import com.mortals.xhx.module.perform.model.PerformRulesQuery;
import com.mortals.xhx.module.perform.model.vo.AppealInfo; import com.mortals.xhx.module.perform.model.vo.AppealInfo;
import com.mortals.xhx.module.perform.model.vo.AppealSummaryQuery; import com.mortals.xhx.module.perform.model.vo.AppealSummaryQuery;
...@@ -65,6 +67,8 @@ public class PerformAttendAppealController extends BaseCRUDJsonBodyMappingContro ...@@ -65,6 +67,8 @@ public class PerformAttendAppealController extends BaseCRUDJsonBodyMappingContro
private UserService userService; private UserService userService;
@Autowired @Autowired
private PerformRulesService rulesService; private PerformRulesService rulesService;
@Autowired
private DeptService deptService;
public PerformAttendAppealController() { public PerformAttendAppealController() {
...@@ -84,8 +88,9 @@ public class PerformAttendAppealController extends BaseCRUDJsonBodyMappingContro ...@@ -84,8 +88,9 @@ public class PerformAttendAppealController extends BaseCRUDJsonBodyMappingContro
this.addDict(model, "reviewResult", paramService.getParamBySecondOrganize("PerformAttendAppeal", "reviewResult")); this.addDict(model, "reviewResult", paramService.getParamBySecondOrganize("PerformAttendAppeal", "reviewResult"));
this.addDict(model, "reviewSource", paramService.getParamBySecondOrganize("PerformAttendAppeal", "reviewSource")); this.addDict(model, "reviewSource", paramService.getParamBySecondOrganize("PerformAttendAppeal", "reviewSource"));
this.addDict(model, "irregularType", IrregularTypeEnum.getEnumMap()); this.addDict(model, "irregularType", IrregularTypeEnum.getEnumMap());
this.addDict(model, "irregularOtherType", IrregularOtherTypeEnum.getEnumMap()); this.addDict(model, "irregularOtherType", IrregularOtherTypeEnum.getEnumMap());
this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getDeptName())));
super.init(model, context); super.init(model, context);
} }
......
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