|
@@ -4,13 +4,19 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.boman.common.core.utils.DateUtils;
|
|
import com.boman.common.core.utils.DateUtils;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
|
+import com.boman.common.redis.RedisKey;
|
|
|
|
+import com.boman.domain.GenTable;
|
|
|
|
+import com.boman.domain.GenTableColumn;
|
|
|
|
+import com.boman.domain.constant.FormDataConstant;
|
|
import com.boman.domain.dto.AjaxResult;
|
|
import com.boman.domain.dto.AjaxResult;
|
|
import com.boman.domain.dto.ClockOnDto;
|
|
import com.boman.domain.dto.ClockOnDto;
|
|
import com.boman.domain.dto.FormDataDto;
|
|
import com.boman.domain.dto.FormDataDto;
|
|
import com.boman.web.core.service.TableServiceCmdService;
|
|
import com.boman.web.core.service.TableServiceCmdService;
|
|
import com.boman.web.core.service.attendance.rules.AttendanceRulesService;
|
|
import com.boman.web.core.service.attendance.rules.AttendanceRulesService;
|
|
import com.boman.web.core.service.common.ICommonService;
|
|
import com.boman.web.core.service.common.ICommonService;
|
|
|
|
+import com.boman.web.core.service.select.IBaseSelectService;
|
|
import com.boman.web.core.utils.AuthUtils;
|
|
import com.boman.web.core.utils.AuthUtils;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -27,6 +33,9 @@ import static com.boman.domain.constant.AttendanceConst.*;
|
|
import static com.boman.domain.constant.AttendanceRulesConst.ATTENDANCE_RULES_END_TIME;
|
|
import static com.boman.domain.constant.AttendanceRulesConst.ATTENDANCE_RULES_END_TIME;
|
|
import static com.boman.domain.constant.AttendanceRulesConst.ATTENDANCE_RULES_START_TIME;
|
|
import static com.boman.domain.constant.AttendanceRulesConst.ATTENDANCE_RULES_START_TIME;
|
|
import static com.boman.domain.constant.FormDataConstant.CONDITION;
|
|
import static com.boman.domain.constant.FormDataConstant.CONDITION;
|
|
|
|
+import static com.boman.domain.constant.FormDataConstant.PAGE_ROWS;
|
|
|
|
+import static com.boman.web.core.utils.ColumnUtils.withoutHrReturnColumnNames;
|
|
|
|
+import static com.boman.web.core.utils.HandlerFormDataUtils.handleNullColumnValue;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author shiqian
|
|
* @author shiqian
|
|
@@ -43,6 +52,8 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
private AttendanceRulesService rulesService;
|
|
private AttendanceRulesService rulesService;
|
|
@Resource
|
|
@Resource
|
|
private TableServiceCmdService cmdService;
|
|
private TableServiceCmdService cmdService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBaseSelectService selectService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 功能描述: 根据tableName和userId查找当月考勤
|
|
* 功能描述: 根据tableName和userId查找当月考勤
|
|
@@ -51,7 +62,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
* @param userName userName
|
|
* @param userName userName
|
|
* @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
* @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
*/
|
|
*/
|
|
- private List<JSONObject> listByUserName(String tableName, Long userName) {
|
|
|
|
|
|
+ private List<JSONObject> listByUserName(String tableName, String userName) {
|
|
requireNonNull(tableName, "tableName is empty");
|
|
requireNonNull(tableName, "tableName is empty");
|
|
requireNonNull(userName, "userName is empty");
|
|
requireNonNull(userName, "userName is empty");
|
|
|
|
|
|
@@ -71,14 +82,14 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
* @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
* @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public AjaxResult attendanceRecord(String tableName, Long userName) {
|
|
|
|
|
|
+ public AjaxResult attendanceRecord(String tableName, String userName) {
|
|
Map<String, Object> mapObj = new HashMap<>(4);
|
|
Map<String, Object> mapObj = new HashMap<>(4);
|
|
List<JSONObject> byMap = listByUserName(tableName, userName);
|
|
List<JSONObject> byMap = listByUserName(tableName, userName);
|
|
if (isEmpty(byMap)) {
|
|
if (isEmpty(byMap)) {
|
|
mapObj.put("leave", 0);
|
|
mapObj.put("leave", 0);
|
|
mapObj.put("late", 0);
|
|
mapObj.put("late", 0);
|
|
mapObj.put("leaveOr", 0);
|
|
mapObj.put("leaveOr", 0);
|
|
- mapObj.put("dateList", 0);
|
|
|
|
|
|
+ mapObj.put("dateList", new ArrayList<>(0));
|
|
return AjaxResult.success(mapObj);
|
|
return AjaxResult.success(mapObj);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,7 +126,8 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- *根据tableName和userId查找当月考勤详细记录
|
|
|
|
|
|
+ * 根据tableName和userId查找当月考勤详细记录
|
|
|
|
+ *
|
|
* @param dto
|
|
* @param dto
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -123,26 +135,47 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
public AjaxResult detailedRecord(FormDataDto dto) {
|
|
public AjaxResult detailedRecord(FormDataDto dto) {
|
|
// 查询条件
|
|
// 查询条件
|
|
JSONObject condition = ifNullSetEmpty(dto.getFixedData().getJSONObject(CONDITION));
|
|
JSONObject condition = ifNullSetEmpty(dto.getFixedData().getJSONObject(CONDITION));
|
|
- List<JSONObject> byMap = commonService.getByMap(dto.getTable(), condition);
|
|
|
|
- List<Map<String,Object>> detailedRecordList = new ArrayList<>();
|
|
|
|
- if (ObjectUtils.isNotEmpty(byMap)){
|
|
|
|
- for (JSONObject jsonObject : byMap) {
|
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
|
- Object attendanceTableWork = jsonObject.get("attendance_table_work");
|
|
|
|
- Object attendanceTableOffWork = jsonObject.get("attendance_table_offwork");
|
|
|
|
- map.put("attendanceTableWork","未打卡");
|
|
|
|
- map.put("attendanceTableOffWork","未打卡");
|
|
|
|
- if (ObjectUtils.isNotEmpty(attendanceTableWork)){
|
|
|
|
- map.put("attendanceTableWork",attendanceTableWork+"已打卡");
|
|
|
|
- }
|
|
|
|
- if (ObjectUtils.isNotEmpty(attendanceTableOffWork)) {
|
|
|
|
- map.put("attendanceTableWork", attendanceTableOffWork + "已打卡");
|
|
|
|
- }
|
|
|
|
- map.put("dateTime",jsonObject.get("attendance_table_week") + " " + jsonObject.get("attendance_table_todaytime"));
|
|
|
|
- detailedRecordList.add(map);
|
|
|
|
|
|
+ String tableName = dto.getTable();
|
|
|
|
+ GenTable genTable = cmdService.getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
|
|
+ List<GenTableColumn> columns = genTable.getColumns();
|
|
|
|
+ JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
|
|
+ int total = selectService.countByCondition(tableName, condition, packCondition);
|
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
|
+ result.put(FormDataConstant.PAGE_TOTAL, total);
|
|
|
|
+ if (total <= 0) {
|
|
|
|
+ result.put(FormDataConstant.PAGE_ROWS, null);
|
|
|
|
+ return AjaxResult.success(result);
|
|
|
|
+ }
|
|
|
|
+ List<String> showData = withoutHrReturnColumnNames(columns);
|
|
|
|
+ List<JSONObject> rows = selectService.selectByCondition(tableName, condition, packCondition, showData, dto);
|
|
|
|
+ // 查询时为null的列不显示的处理
|
|
|
|
+ handleNullColumnValue(rows, showData);
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> detailedRecordList = new ArrayList<>();
|
|
|
|
+ if (isEmpty(rows)) {
|
|
|
|
+ result.put(FormDataConstant.PAGE_ROWS, rows);
|
|
|
|
+ return AjaxResult.success(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (JSONObject jsonObject : rows) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>(5);
|
|
|
|
+ Object attendanceTableWork = jsonObject.get("attendance_table_work");
|
|
|
|
+ Object attendanceTableOffWork = jsonObject.get("attendance_table_offwork");
|
|
|
|
+ map.put("attendanceTableWork", "未打卡");
|
|
|
|
+ map.put("attendanceTableOffWork", "未打卡");
|
|
|
|
+ if (isNotEmpty(attendanceTableWork)) {
|
|
|
|
+ map.put("attendanceTableWork", attendanceTableWork + "已打卡");
|
|
|
|
+ }
|
|
|
|
+ if (isNotEmpty(attendanceTableOffWork)) {
|
|
|
|
+ map.put("attendanceTableWork", attendanceTableOffWork + "已打卡");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ map.put("dateTime", jsonObject.get("attendance_table_week") + " " + jsonObject.get("attendance_table_todaytime"));
|
|
|
|
+ detailedRecordList.add(map);
|
|
}
|
|
}
|
|
- return AjaxResult.success(detailedRecordList);
|
|
|
|
|
|
+
|
|
|
|
+ result.put(PAGE_ROWS, detailedRecordList);
|
|
|
|
+ return AjaxResult.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -162,10 +195,10 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
JSONObject condition = new JSONObject();
|
|
JSONObject condition = new JSONObject();
|
|
condition.put("attendance_table_username", userName);
|
|
condition.put("attendance_table_username", userName);
|
|
// in
|
|
// in
|
|
- condition.put(ATTENDANCE_TABLE_TODAYTIME, DateUtils.getDate());
|
|
|
|
|
|
+ condition.put(ATTENDANCE_TABLE_TODAYTIME, Lists.newArrayList(DateUtils.getDate()));
|
|
dto.setFixedData(condition);
|
|
dto.setFixedData(condition);
|
|
int count = commonService.count(dto);
|
|
int count = commonService.count(dto);
|
|
- return count > 0 ? "下班打卡" : "上班打卡";
|
|
|
|
|
|
+ return count > 0 ? GO_OFF_WORK : GO_TO_WORK;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -238,7 +271,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
|
|
|
|
JSONObject commitData = new JSONObject();
|
|
JSONObject commitData = new JSONObject();
|
|
commitData.put(ATTENDANCE_USER_NAME, SecurityUtils.getUsername());
|
|
commitData.put(ATTENDANCE_USER_NAME, SecurityUtils.getUsername());
|
|
- commitData.put(ATTENDANCE_TABLE_TODAYTIME, DateUtils.getDate());
|
|
|
|
|
|
+ commitData.put(ATTENDANCE_TABLE_TODAYTIME, Lists.newArrayList(DateUtils.getDate()));
|
|
commitData.put(ATTENDANCE_TABLE_LONGITUDE, dto.getLongitude());
|
|
commitData.put(ATTENDANCE_TABLE_LONGITUDE, dto.getLongitude());
|
|
commitData.put(ATTENDANCE_TABLE_LATITUDE, dto.getLatitude());
|
|
commitData.put(ATTENDANCE_TABLE_LATITUDE, dto.getLatitude());
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
@@ -323,7 +356,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
|
private List<JSONObject> listByUserNameAndTime(String tableName, String userName, String time) {
|
|
private List<JSONObject> listByUserNameAndTime(String tableName, String userName, String time) {
|
|
JSONObject condition = new JSONObject(2);
|
|
JSONObject condition = new JSONObject(2);
|
|
condition.put(ATTENDANCE_USER_NAME, userName);
|
|
condition.put(ATTENDANCE_USER_NAME, userName);
|
|
- condition.put(ATTENDANCE_TABLE_TODAYTIME, time);
|
|
|
|
|
|
+ condition.put(ATTENDANCE_TABLE_TODAYTIME, Lists.newArrayList(time));
|
|
return commonService.getByMap(tableName, condition);
|
|
return commonService.getByMap(tableName, condition);
|
|
}
|
|
}
|
|
|
|
|